Buongiorno a tutti del Forum!
Ho deciso di chiedere il vostro aiuto dopo una mattinata di ricerche infruttuose riguardo il mio problema.
Praticamente per un sito al quale sto lavorando avrei bisogno di uno script che acceda alla rete IRC, si colleghi ad un server, si logghi in un canale e scarichi un pack da un bot utilizzando il comando XDCC.
Dopo un po' di ricerche ho trovato uno script (che si chiama XDCC Fetcher e viene rilasciato con licenza GNU) che sembra fare al caso mio.
Infatti fa esattamente quello che ho detto: dato il server, il bot e il numero di pack comincia lo scaricamento...il mio problema è che salva il file su una cartella del server.
Quindi vengo alla mia domanda: è possibile fare in modo che il file venga invece salvato sul pc del client, ovvero con la classica finestra di dialogo che chiede dove salvare il file e poi comincia lo scaricamento?

Grazie a tutti per la disponibilità!!!
Di seguito trovate il codice delle pagine principali, comunque lo script è scaricabile interamente da http://webscripts.softpedia.com/scri...er--36626.html

Config.php
Codice PHP:
<?php
// Download folder 
$downloadfolder "downloads"
// Logs folder 
$logsfolder "/logs"
// Debug Modes 
$showrealtime true
$logall false?>
Index.php

codice:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>XDCC Fetcher</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <style type="text/css"> TABLE.Section { border:solid 1px #333333; width:300; margin-bottom: 25px; } TD { font-family: Verdana, Arial; font-size: 12px; color: #333333; } TD.Section { padding:5px; } .TableTitle { position: relative; top: -15px; padding-left: 2px; padding-right: 2px; color: #333333; background-color: #CCCCCC; font-weight: bold; font-size: 10px; } FORM { margin: 0px; } INPUT { font-size: 10px; border:solid 1px #333333; background-color: #FFFFFF; color:#333333; } .ClientText { font-weight: bold; font-size: 10px; color: #FF0000; } .ClientList { font-size: 10px; position: absolute; visibility: hidden; } .ClientList A { padding-left: 15px; color: #333333; font-size: 12px; } IMG { width: 300px; height: 32px; border: 0px; margin-top: 30px; margin-bottom: 15px; } .CopyRight { font-family: Verdana, Arial; font-size: 10px; color: #999999; text-align: center; } </style> </head> <body bgcolor="#CCCCCC"> <center>[img]logo.gif[/img]</center> <table align="center" class="Section"> <tr> <td class="Section"><span class="TableTitle">Connected Clients</span>
 <div id="ClientList" class="ClientList"></div> <div id="ClientText" class="ClientText"> <?php if (isset($_GET["clientstarted"]) && $_GET["clientstarted"] == "yes") { echo "Client started! "; } elseif (isset($_GET["clientstopped"]) && $_GET["clientstopped"] == "yes") { echo "Client stopped! "; } ?>Loading client list...</div> </td> </tr> </table> <table align="center" class="Section"> <tr> <td class="Section"><span class="TableTitle">Add New Client</span>
<form method="GET" action="startclient.php"> <table cellpadding="0" cellspacing="0"> <tr> <td>IRC server address:</td> <td width="10"></td> <td><input name="server" type="text" size="25" value="<?php echo showContent("server"); ?>"></td> </tr> <tr> <td>IRC server port:</td> <td width="10"></td> <td><input name="port" type="text" size="4" value="<?php echo showContent("port","6667"); ?>"></td> </tr> <tr> <td>IRC channel:</td> <td width="10"></td> <td><input name="channel" type="text" size="15" value="<?php echo showContent("channel"); ?>"></td> </tr> <tr> <td>User nick:</td> <td width="10"></td> <td><input name="user" type="text" size="15" value="<?php echo showContent("user"); ?>"></td> </tr> <tr> <td>Pack number:</td> <td width="10"></td> <td><input name="pack" type="text" size="4" value="<?php echo showContent("pack"); ?>"></td> </tr> <tr> <td align="center" colspan="3">
 <input type="submit" value="GO GET IT!"></td> </tr> </table> </form></td> </tr> </table> <div class="CopyRight">XDCC Fetcher 0.1 beta. Copyright &copy; 2005 Mark Cilia Vincenti</div> <div class="CopyRight">Comments &amp; downloads @ http://xdccfetcher.sourceforge.net</div> <?php include "config.php"; function showContent($field, $default = "") { if (isset($_GET[$field])) { if ($_GET[$field] == "") { return $default; } else { return $_GET[$field]; } } else { return $default; } } echo " <iframe name=\"ClientRef\" src=\"jsgetclientlist.php\" width=\"0\" height=\"0\"></iframe> <script language=\"JavaScript\"> var oldclients = new Array(9); var clients = new Array(9); var oldclientscounter = -2; var clientscounter = -1; var flag = 0; var counter = 0; function ShowClients() { if (oldclientscounter == clientscounter) { flag = 0; for (counter = 0; counter <= clientscounter; counter++) { if (clients[counter] != oldclients[counter]) { flag = 1; } } } else { flag = 1; } if (flag == 1) { if (oldclientscounter >= 0) { document.getElementById('ClientList').innerHTML=''; } for (counter = 0; counter <= clientscounter; counter++) { document.getElementById('ClientList').innerHTML+=(counter + 1) + '<a href=\"showlog.php?log=' + clients[counter] + '\">' + clients[counter] + '</a><a href=\"showlog.php?log=' + clients[counter] + '\">view</a><a href=\"stopclient.php?log=' + clients[counter] + '\">stop</a>
'; } oldclients = clients; oldclientscounter = clientscounter; if (clientscounter >= 0) { ClientList.style.visibility='visible'; ClientList.style.position='relative'; ClientText.style.visibility='hidden'; ClientText.style.position='absolute'; document.getElementById('ClientText').innerHTML=''; } else { ClientText.style.visibility='visible'; ClientText.style.position='relative'; ClientList.style.visibility='hidden'; ClientList.style.position='absolute'; document.getElementById('ClientText').innerHTML='There are currently no connected clients'; } } } </script></body> </html>";?>
Client.php (la pagina che esegue materialmente il download del file):
Codice PHP:
<?php set_time_limit(0); ignore_user_abort(true); register_shutdown_function("xfdie"); include "config.php"; include "raw.php"; if ($showrealtime == false) { echo "<script>window.location.href='index.php?clientstarted=yes&" $_SERVER["QUERY_STRING"] . "';</script>"flush(); } else { echo "<pre>"; } $killed false$handle ""$dcc ""$timer ""; function xfwrite ($data$echo true) { if (substr($data,-1) != "\n") { $data .= "\n"; } fwrite($GLOBALS["fp"],$data); if ($echo) { xfecho($data"blue"); } } function ($num) { if (isset($GLOBALS["parse"][$num])) { return $GLOBALS["parse"][$num]; } } function savetofile () { $dccgettemp ""$dccgettemp fgets($GLOBALS["dcc"],1024); if ($dccgettemp != "") { $GLOBALS["dccget"] = $dccgettemp$GLOBALS["currfilesize"] += strlen($dccgettemp); fwrite($GLOBALS["handle"], $dccgettemp); } } function xfecho ($data$color "black"$ts 1) { if (($data != "") && ($data != "\n") && (file_exists($GLOBALS["logfilename"]))) { if (substr($data,-1) != "\n") { $data .= "\n"; } if ($ts == 1) { $write time() . " " $color " " $data; } elseif ($color == "") { $write $data; } else { $write $color " " $data; } fwrite($GLOBALS["logfile"],$write); if ($GLOBALS["showrealtime"]) { echo $write; } } } function xfdie () { if ($GLOBALS["killed"] == false) { if ($GLOBALS["handle"]) { fclose($GLOBALS["handle"]); } if (($GLOBALS["dcc"]) && (!feof($GLOBALS["dcc"]))) { fclose($GLOBALS["dcc"]); } if ($GLOBALS["lockfilename"] && $GLOBALS["lockfilename"] != "" && file_exists($GLOBALS["lockfilename"])) { @unlink($GLOBALS["lockfilename"]); } if (($GLOBALS["fp"]) && (!feof($GLOBALS["fp"]))) { xfwrite("PRIVMSG " $GLOBALS["user"] . " :XDCC REMOVE"); xfwrite("PRIVMSG " $GLOBALS["user"] . " :XDCC REMOVE " $GLOBALS["pack"]); xfwrite("QUIT :XDCC Fetcher 0.1 beta (build 20050305) [url]http://xdccfetcher.sourceforge.net[/url]"); sleep(5); if (!feof($GLOBALS["fp"])) { fclose($GLOBALS["fp"]); } } xfecho("process killed (connection status: " connection_status() . ")"); fclose($GLOBALS["logfile"]); $GLOBALS["killed"] = true; die(); } } // Initialisation variables $server = ltrim(rtrim($_GET["server"])); $port = ltrim(rtrim($_GET["port"])); $channel = ltrim(rtrim($_GET["channel"])); if (substr($channel,0,1) != "#") { $channel = "#" . ltrim(rtrim($channel)); } $user = $_GET["user"]; $pack = $_GET["pack"]; if (substr($pack,0,1) != "#") { $pack = "#" . ltrim(rtrim($pack)); } $join = 0; $joined = 0; $ison = 0; $percent = -1; while ((!isset($nick)) || file_exists($logfilename)) { $nick = "xf" . rand(10000,99999); $logfilename = $logsfolder . $nick . ".log"; $delfilename = $logsfolder . $nick . ".del"; } $logfile = fopen($logfilename, 'a'); while (1 == 1) { $fp = @fsockopen($server, $port, $errno, $errstr, 30); if (!$fp) { xfecho("$errstr ($errno)"); xfdie(); } else { stream_set_blocking($fp,0); xfwrite("NICK " . $nick); xfwrite("USER " . $nick . " \"xdccfetcher.com\" \"$server\" :xdccfetcher.sourceforge.net"); while (!feof($fp)) { $fparr = array($fp); stream_select($fparr, $write = NULL, $except = NULL, 3); $get = fgets($fp); $parse = explode(" ",$get); CheckRaw($get); if (rtrim($get) != "" && p(0) != "PING") { if ($logall == true || (stristr($get,$user) && p(2) == $nick)) { xfecho($get); } } if (p(0) == "PING") { xfecho("PING? PONG!","green"); xfwrite("PONG " . substr(p(1), 1),false); } elseif ((p(1) == "PRIVMSG") && (p(2) == $nick) && (p(3) == ":STOPXF")) { xfecho("Manual abort"); xfdie(); } elseif ((p(1) == "PRIVMSG") && (p(2) == $nick) && (p(3) == ":COMMANDXF")) { $string = ""; for ($x=4; $x<count($parse); $x++) { $string .= $parse[$x] . " "; } if ($string != "") { xfwrite(rtrim($string)); } } elseif (!file_exists($logfilename)) { xfdie(); } elseif (file_exists($delfilename)) { @unlink($delfilename); sleep(2); fclose($logfile); @unlink($logfilename); xfdie(); } elseif ((stristr($get,$user)) && (stristr($get,"all slots full")) && (!stristr($get,"Added you")) && (p(1) == "NOTICE") && (p(2) == $nick)) { $timer = time() + 30; } elseif ((time() >= $timer) && ($timer != 0)) { $timer = 0; xfwrite("PRIVMSG " . $user . " :XDCC SEND " . $pack . ""); } elseif ((stristr(p(0),$user)) && (p(3) == ":DCC")) { if (p(4) == "SEND") { echo "Starting DCC...\n"; $DCCfilesize = (int)(substr(p(8),0,-3)); $DCCfilename = p(5); $DCCip = long2ip(p(6)); $DCCport = p(7); $filename = $downloadfolder . $DCCfilename; } elseif (p(4) == "ACCEPT") { echo "Resume accepted...\n"; } if ((file_exists($filename)) && (p(4) == "SEND")) { if (filesize($filename) >= $DCCfilesize) { xfecho("File already downloaded"); xfdie(); } xfecho("Attempting resume..."); xfwrite("PRIVMSG " . $user . " :DCC RESUME " . $DCCfilename . " " . $DCCport . " " . filesize($filename) . ""); } else { xfecho("Connecting to $DCCip on port $DCCport ($DCCfilesize bytes)..."); $dcc = @fsockopen($DCCip, $DCCport, $errno, $errstr, 30); if (!$dcc) { xfecho("$errstr ($errno)"); xfdie(); } else { stream_set_blocking($dcc,0); xfecho("connected..."); $filename = $downloadfolder . $DCCfilename; if (file_exists($filename . ".lck")) { $filename = $downloadfolder . $nick . ".sav"; } $lockfilename = $filename . ".lck"; $handle = fopen($lockfilename, 'a'); fclose($handle); if (file_exists($filename)) { $currfilesize = filesize($filename); } else { $currfilesize = 0; } $handle = fopen($filename, 'a'); while (!feof($dcc)) { savetofile(); if (!feof($fp)) { $get = fgets($fp); if ($get) { $parse = explode(" ",$get); if (p(0) == "PING") { xfecho($get); xfwrite("PONG " . substr(p(1), 1)); } elseif ((p(1) == "PRIVMSG") && (p(2) == $nick) && (p(3) == ":STOPXF")) { xfecho("Manual abort"); xfdie(); } elseif ((p(1) == "PRIVMSG") && (p(2) == $nick) && (p(3) == ":COMMANDXF")) { $string = ""; $x = 4; while (p(x) != "") { $string .= $p($x) . " "; $x++; } if ($string != "") { xfwrite(rtrim($string)); } } } } $currpercent = (int)(($currfilesize / $DCCfilesize) * 100); if ($currpercent > $percent) { $percent = $currpercent; xfecho("<script>document.title='" . $percent . "% completed - " . $DCCfilename . " - " . $nick . "';</script>", "", false); } if (!file_exists($logfilename)) { xfdie(); } elseif (file_exists($delfilename)) { @unlink($delfilename); sleep(2); fclose($logfile); @unlink($logfilename); xfdie(); } elseif ($currfilesize >= $DCCfilesize) { xfecho("Downloaded!"); xfdie(); } elseif ($currfilesize > $DCCfilesize) { xfecho("Current filesize is greater than expected! Aborting."); xfdie(); } $dccarr = array($dcc); @stream_select($dccarr, $write = NULL, $except = NULL, 3); } if (filesize($filename) < $DCCfilesize) { xfecho("aborted."); fclose($dcc); @unlink($lockfilename); fclose($handle); xfwrite("PRIVMSG " . $user . " :XDCC SEND " . $pack . ""); } } } } } } xfecho("Disconnected from server! Reconnecting in 60 seconds..."); sleep(60); }?> </pre>