"; for ($i=0; $i$arFile[$i] - ". $arFile[$i+1]. "\n"; echo " \n"; } */ function saveSearch($s) { /* if (!file_exists("last_searches")) $arFile = array(); else $arFile = file("last_searches", 0); $newFile = array_slice($arFile, -18, 18); array_push($newFile, $s."\n"); if (strlen($GLOBALS[REMOTE_HOST])) array_push($newFile, $GLOBALS[REMOTE_HOST]."\n"); else array_push($newFile, $GLOBALS[REMOTE_ADDR]."\n"); $fp = fopen("last_searches", "w"); for ($i=0; $i
Gnutella search
Search for: Server timeout

semiofficial gnutella site
PHP source

Search for any type of file you like. If you're interested in movies showing people shaving their cats, then search for "cat shaving avi". If home improvement is more your thing, try "wood nailing jpg". Queries are space-separated words, the result must contain all words entered. Searching for "*.mp3" is the same as searching for "mp3", so save yourself some typing, and 2 bytes of my bandwidth and use the latter. Be patient, the gnutellanet is not Yahoo! or Hotbot-- the first search results usually don't start rolling in for 15 seconds or so.

Please note that searches are logged by the web server!

Last 10 searches
Feedback
1048576) return sprintf("%.1f MB", (float)$size / 1048576.0); if ($size > 1024) return sprintf("%.1f KB", (float)$size / 1024.0); else return $size. " bytes"; } function randomBanner() { echo "
\n"; switch (rand(0, 2)) { case 0: ?> \n"; } function QueryResponseDataAvail($fp, $datasize) { $numrecs = getByte($fp); $port = getWord($fp); $ip = getIP($fp); $speed = getInt($fp); // echo "
    \n"; // echo "
  • Numrecs: $numrecs
  • \n"; // echo "
  • Host port: $port
  • \n"; // echo "
  • Host IP: $ip
  • \n"; // echo "
  • Host speed: $speed kbps
  • \n"; // echo "
      \n"; if ((substr($ip, 0, 8) == "192.168.") || (substr($ip, 0, 3) == "10.")) { writeToStatusWin("Query response, but on private net: $ip"); return; } $GLOBALS[results_found]++; if ($GLOBALS[status_window_open]) { closeStatusWin(); // randomBanner(); commonHeader(); } ?> \n"; else echo " \n"; echo " \n"; echo " \n"; echo " \n"; // echo " \n"; echo " \n"; // there's an extra nullbyte on the end fread($fp, 1); } // echo " \n"; // echo " \n"; echo " \n"; echo " \n"; echo "
      Host is running at kbps ( records)
      myplay.com File name Size
      "; echo ""; echo "$filename". sizeToStr($filesize). "$fileidx
      ClientID128: ". bin2Hex(fread($fp, 16)). "
      ". "Support the gnutella network! ". "Run a server!\n"; echo "
      \n"; } function CoCreateGUID() { srand((double)microtime()*1000000); $t = (string)rand() . bin2hex(microtime()); return substr($t, 1, 16); } function onShutdown() { fclose($GLOBALS[fp]); printCommonFooter(); } function IsValidGnutellaHeader($sin) { GLOBAL $datasize; $datasize = ord($sin[19]) | (ord($sin[20]) << 8) | (ord($sin[21]) << 16) | (ord($sin[22]) <<24); return ((ord($sin[16]) == 0x00) && ($datasize == 0)) || // Inits always have 0 len ((ord($sin[16]) == 0x01) && ($datasize == 14)) || // Init resp 14 ((ord($sin[16]) == 0x40) && ($datasize == 26)) || // Push req 26 ( ((ord($sin[16]) == 0x80) || (ord($sin[16]) == 0x81)) && (($datasize < 5000) && ($datasize > 0)) ); } function messageIn($stype) { GLOBAL $messages_in; GLOBAL $MsgDataStr; if (!$messages_in) writetoStatusWin("Legend: p-ping P-pong ". "U-push req q-query
      "); $messages_in++; if ($messages_in % 30) $MsgDataStr = $MsgDataStr. $stype; else { writeToStatusWin($MsgDataStr. "
      "); $MsgDataStr = "MsgData: "; } } /* if (!$do) { ?> Temporarily down for script coding. Try back around 8:30 EST
      -- Bry
      50) $maxresults = 50; if (!$host) // $host = "192.168.100.74"; $host = "24.188.150.81"; // $host = "127.0.0.1"; /* if (!$port)*/ $port = 6346; if (!$timeout) $timeout = 30; else if ($timeout > 60) $timeout = 60; // Allow direct download from this page $connectok = 1; if (!isset($connectok)) $connectok = 0; openStatusWin(); writeToStatusWin("Saving search request...
      "); saveSearch($query); writeToStatusWin("Connecting to ".$host.":".$port."
      "); $fp = fsockopen($host, $port, &$errno, &$errstr, 10); if (!$fp) { closeStatusWin(); echo "Could not connect to $host:$port
      \n"; echo "($errno) $errstr\n"; } else { writeToStatusWin("Connected, initializing protocol...
      "); register_shutdown_function("onShutdown"); fputs($fp, "GNUTELLA CONNECT/0.4\n\n"); $resp = fread($fp, 13); if ($resp != "GNUTELLA OK\n\n") { closeStatusWin(); echo "Was not a gnutella server\n"; } else { $q_len = strlen($query); $p_len = $q_len + 3; $search = CoCreateGUID(). "\x80". // type = query "\x05". // TTL = 5 "\x00". // HopCount = 0 chr($p_len & 0xff). chr(($p_len & 0xff00) >> 8). chr(($p_len & 0xff0000) >> 16). chr(($p_len & 0xff000000) >> 24). "\x00\x00". // Min Speed = 0 $query."\x00"; writeToStatusWin("Sending search request '".$query."'...
      "); fwrite($fp, $search, 23 + $p_len); $results_found = 0; $messages_in = 0; $MsgDataStr = "MsgData: "; $sin = ""; $iStartTime = time(); while ($results_found < $maxresults) { set_socket_blocking($fp, false); while ((strlen($sin) < 23) && ($iStartTime + $timeout > time())) { $spart = fread($fp, 23 - strlen($sin)); if (strlen($spart)) $sin = $sin . $spart; else usleep(250000); } set_socket_blocking($fp, true); if (strlen($sin) < 23) { if ($status_window_open) { closeStatusWin(); commonHeader(); } // echo "\n"; echo "Query timed out ($timeout secs). "; echo "This usually indicates that there are no more search results\n"; echo "but might also mean that the gnutellanet is getting hammered.\n"; // echo ""; break; } // echo bin2hex($sin); // echo "
      \n"; if (!IsValidGnutellaHeader($sin)) { // closeStatusWin(); // echo "Bogus packet received from gnutella, size=$datasize, type=0x". // bin2hex($sin[16])."\n"; $sin = substr($sin, 1, 22); continue; } switch (ord($sin[16])) { case 0x00: messageIn("p"); break; case 0x01: messageIn("P"); $sin = fread($fp, $datasize); break; case 0x40: messageIn("U"); $sin = fread($fp, $datasize); break; case 0x80: messageIn("Q"); $sin = fread($fp, $datasize); break; case 0x81; QueryResponseDataAvail($fp, $datasize); break; } // switch flush(); $sin = ""; } } onShutdown(); } // could connect ?>