Zdravim , zacal sem delat pokusnej ftp client.Pri zadani prikazu quote mi to hodi chybu :
Warning : fwrite(): supplied argument is not a valid stream resource in ...
Uz si nevim rady a predem moc dekuji za odpoved.
$ServerTimeOut = 60;
$default_port = 21;
function readline($prompt="ftp>"){
echo $prompt;
$line = fgets(STDIN, 999);
return trim($line);
}
function get_response($socket_open){
$response = (" ".fread($socket_open, 1000));
echo $response;
}
function connect(){
$CONNECTED = false;
$enterip = readline("IP/DNS:");
$expl_ip = explode(":", $enterip);
$serverip = $expl_ip[0]; $port = $expl_ip[1];
if(empty($expl_ip[1])){
$port = $default_port;
}
$socket_open = @fsockopen($serverip, $port, &$errno, &$errstr, $ServerTimeOut);
if(!$socket_open){
echo "Cannot connect to remote host (".$serverip.":".$port.")\n";
echo "Error : ".$errstr." (".$errno.")\n";
return false;
}
get_response($socket_open);
$username = readline("Username:");
fwrite($socket_open, "USER $username\n");
get_response($socket_open);
$passwd = readline("Password:");
fwrite($socket_open, "PASS $passwd\n");
get_response($socket_open);
$CONNECTED = true;
$data = $serverip."|".$port."|".$ServerTimeOut;
$meta = fopen("meta", "w+");
fwrite($meta, $data, 999);
fclose($meta);
}
function open_data_connection(){
$rmeta = fopen("meta", "r");
$rdata = fread($rmeta, 999);
fclose($rmeta);
$expl = explode("|", $rdata);
$serverip = $expl[0]; $port = $expl[1]; $ServerTimeOut = $expl[2];
if(empty($ServerTimeOut)) {
$ServerTimeOut = 60;
}
$socket_open = fsockopen($serverip, $port, &$errno, &$errstr, $ServerTimeOut);
if(!$socket_open){
echo "Cannot connect to remote host (".$serverip.":".$port.")\n";
echo "Error : ".$errstr." (".$errno.")\n";
return false;
}
return $socket_open;
}
function quote($socket_open){
open_data_connection();
$cmdToExec = readline("Exec:");
fwrite($socket_open, $cmdToExec);
get_response($socket_open);
}
$command = readline();
while($command){
switch($command){
case "o": connect(); $command = readline(); break;
case "quote": quote($socket_open); $command = readline(); break;
default: echo "COMMAND ERROR\n"; $command = readline();
}
}
?>
PHP - chyba
-
- Mohlo by vás zajímat
- Odpovědi
- Zobrazení
- Poslední příspěvek
-
- 1
- 1893
-
od Roman Tyčka
Zobrazit poslední příspěvek
25 pro 2023 18:41
-
- 1
- 2033
-
od petr22
Zobrazit poslední příspěvek
04 zář 2023 16:09
-
- 9
- 1535
-
od Domoo27
Zobrazit poslední příspěvek
12 úno 2024 23:54
-
-
Windows 98 chyba při startu ......VXD Příloha(y)
od Radovan-kocour » 24 říj 2023 18:49 » v Windows 11, 10, 8... - 5
- 1463
-
od Radovan-kocour
Zobrazit poslední příspěvek
25 říj 2023 15:24
-
-
- 9
- 1736
-
od petr22
Zobrazit poslední příspěvek
21 říj 2023 13:29
Zpět na “Programování a tvorba webu”
Kdo je online
Uživatelé prohlížející si toto fórum: Žádní registrovaní uživatelé a 35 hostů