Author: sich
Date: 2006-04-12 21:12:39 +0000 (Wed, 12 Apr 2006)
New Revision: 8532
Modified:
trunk/apps/DarknetSpiderBot/fcp.php
Log:
DarknetSpiderBot : Add error management (1 files)
Modified: trunk/apps/DarknetSpiderBot/fcp.php
===================================================================
--- trunk/apps/DarknetSpiderBot/fcp.php 2006-04-12 19:54:28 UTC (rev 8531)
+++ trunk/apps/DarknetSpiderBot/fcp.php 2006-04-12 21:12:39 UTC (rev 8532)
@@ -7,6 +7,8 @@
$addresse = "SSK at
PFeLTa1si2Ml5sDeUy7eDhPso6TPdmw-2gWfQ4Jg02w,3ocfrqgUMVWA2PeorZx40TW0c-FiIOL-TWKQHoDbVdE,AQABAAE/Index-21/";
+$ok_hello = 0;
+$error = NULL;
$fp = fsockopen($fcp_host,$fcp_port,$errno, $errstr, $timeout);
if (!$fp) {
@@ -25,81 +27,92 @@
{
$buffer = fgets($fp);
- if (preg_match_all('/NodeHello/si', $buffer, $match)) {
- //echo "ok connection\n";
- //break;
- }
- elseif (preg_match_all('/ProtocolError/si', $buffer, $match)) {
- echo "non ok connection\n";
+ if (preg_match_all('/ProtocolError/si', $buffer, $match)) {
+ $error = "non ok connection\n";
break;
}
if (preg_match_all('/EndMessage/si', $buffer, $match)) {
- //echo "ok connection\n";
+ $ok_hello = 1;
break;
}
-
}
- $out = "ClientGet\r\n";
- $out .= "URI=$addresse\r\n";
- $out .= "Identifier=Request Number One\r\n";
- $out .= "ReturnType=NONE\r\n";
- $out .= "Verbosity=1\r\n";
- $out .= "EndMessage\r\n";
+ if ($ok_hello == 1) {
+ $out = "ClientGet\r\n";
+ $out .= "URI=$addresse\r\n";
+ $out .= "Identifier=Request Number One\r\n";
+ $out .= "ReturnType=NONE\r\n";
+ $out .= "Verbosity=1\r\n";
+ $out .= "EndMessage\r\n";
+
+ fwrite($fp, $out);
+ $count = 1;
+ while ( !feof($fp) )
+ {
+ $buffer = fgets($fp);
- fwrite($fp, $out);
- $count = 1;
- while ( !feof($fp) )
- {
- $buffer = fgets($fp);
-
- if (preg_match_all('/ExtraDescription/si', $buffer, $match)) {
- $ExtraDescription = explode("=",$buffer);
- $ExtraDescription = $ExtraDescription[1];
- echo "echec recup cle : $ExtraDescription";
- break;
- }
- if (preg_match_all('/Metadata.ContentType=/si', $buffer,
$match)) {
- $content_type = explode("=",$buffer);
- $content_type = $content_type[1];
-
- if (preg_match_all('/text\/html/si', $content_type,
$match)) { }
- else {
- echo "non ok html";
+ if (preg_match_all('/ExtraDescription/si', $buffer,
$match)) {
+ $ExtraDescription = explode("=",$buffer);
+ $ExtraDescription = $ExtraDescription[1];
+ $error = "Get Failed : $ExtraDescription";
break;
}
+ if (preg_match_all('/Metadata.ContentType=/si',
$buffer, $match)) {
+ $content_type = explode("=",$buffer);
+ $content_type = $content_type[1];
+
+ if (preg_match_all('/text\/html/si',
$content_type, $match)) { }
+ else {
+ $error = "Error Content Type";
+ break;
+ }
+ }
+
+ if (preg_match_all('/GetFailed/si', $buffer, $match)) {
+ $count = 2;
+ $error = "Get Failed";
+ }
+
+ if (preg_match_all('/EndMessage/si', $buffer, $match))
{
+ $count = $count + 1;
+ if ($count > 2) { break; }
+ }
}
-
- if (preg_match_all('/EndMessage/si', $buffer, $match)) {
- $count = $count + 1;
- if ($count > 2) { break; }
- }
- }
-
- $out = "ClientGet\r\n";
- $out .= "URI=$addresse\r\n";
- $out .= "Identifier=Request Number One\r\n";
- $out .= "ReturnType=DISK\r\n";
- $out .= "Filename=D:\\Darknet\\bot\\test1.html\r\n";
- $out .= "Verbosity=0\r\n";
- $out .= "EndMessage\r\n";
- fwrite($fp, $out);
-
- while ( !feof($fp) )
- {
- $buffer = fgets($fp);
- echo $buffer;
+ if ($error == NULL) {
+ $out = "ClientGet\r\n";
+ $out .= "URI=$addresse\r\n";
+ $out .= "Identifier=Request Number One\r\n";
+ $out .= "ReturnType=DISK\r\n";
+ $out .= "Filename=D:\\Darknet\\bot\\test1.html\r\n";
+ $out .= "Verbosity=0\r\n";
+ $out .= "EndMessage\r\n";
+
+ fwrite($fp, $out);
+
+ while ( !feof($fp) )
+ {
+ $buffer = fgets($fp);
- if (preg_match_all('/EndMessage/si', $buffer, $match)) {
- break;
+ if (preg_match_all('/CodeDescription/si',
$buffer, $match)) {
+ $CodeDescription = explode("=",$buffer);
+ $CodeDescription = $CodeDescription[1];
+ $error = "Get Failed :
$CodeDescription";
+ break;
+ }
+
+ if (preg_match_all('/EndMessage/si', $buffer,
$match)) {
+ break;
+ }
+
+ $error = "all ok";
+ }
}
-
}
+
+echo $error;
-echo "ok out";
-
fclose($fp);
}
?>
\ No newline at end of file