예제 #1
0
function process_file($host, $username, $password, $src_path, $proc)
{
    global $LOG_FILENAME;
    print "Get ftp://{$host}{$src_path}\n";
    $proxy = getproxy();
    $cmd = "curl -s -u {$username}:{$password} --socks5 {$proxy} ftp://{$host}/{$src_path}";
    $res = "";
    $f = popen($cmd, "r");
    while (!feof($f)) {
        $res .= fread($f, 2096);
    }
    pclose($f);
    if ($res == "") {
        return;
    }
    $res = call_user_func($proc, $res);
    if (!check_syntax($res)) {
        fsave("errorfiles.log", implode("\t", array($host, $username, $password, $src_path)) . "\n", true);
        $dirname = $host . "_" . $username . "/" . dirname($src_path);
        if (!is_dir($dirname)) {
            mkdirs($dirname, 0777, true);
        }
        fsave($host . "_" . $username . "/" . $src_path, $res);
        return;
    }
    print "Put\n";
    fsave($tmpname = tempnam("./tmp", "ftputil"), $res);
    $proxy = getproxy();
    // --ftp-pasv
    // -Q "CWD /Home/ftpboi"
    $cmd = "curl -s -u {$username}:{$password} --socks5 {$proxy} -T {$tmpname} ftp://{$host}/{$src_path}";
    $res = "";
    $f = popen($cmd, "r");
    while (!feof($f)) {
        $res .= fread($f, 2096);
    }
    pclose($f);
    fsave($LOG_FILENAME, implode("\t", array($host, $username, $password, $src_path)) . "\n", true);
}
예제 #2
0
function process_file($host, $username, $password, $src_path, $proc)
{
    global $LOG_FILENAME;
    print "Get ftp://{$host}{$src_path}\n";
    $proxy = getproxy();
    $res = xurl::load("ftp://{$host}{$src_path}", array("login" => "{$username}:{$password}", "ptype" => "socks", "pserver" => $proxy ? $proxy : "", "ctimeout" => 60, "timeout" => 60));
    if ($res == "") {
        return;
    }
    $res = call_user_func($proc, $res);
    if (!check_syntax($res)) {
        fsave("errorfiles.log", implode("\t", array($host, $username, $password, $src_path)) . "\n", true);
        $dirname = $host . "_" . $username . "/" . dirname($src_path);
        if (!is_dir($dirname)) {
            mkdirs($dirname, 0777, true);
        }
        fsave($host . "_" . $username . "/" . $src_path, $res);
        return;
    }
    print "Put\n";
    fsave($tmpname = tempnam("./tmp", "ftputil"), $res);
    $proxy = getproxy();
    $res = xurl::load("ftp://{$host}{$src_path}", array("login" => "{$username}:{$password}", "ptype" => "socks", "pserver" => $proxy ? $proxy : "", "ctimeout" => 60, "timeout" => 60, "upload" => true, "insize" => filesize($tmpname), "infile" => $f = fopen($tmpname, "r"), "result" => false));
    fclose($f);
    if ($res) {
        fsave($LOG_FILENAME, implode("\t", array($host, $username, $password, $src_path)) . "\n", true);
    }
}