示例#1
0
function dftp_connect($ftphost, $ftpuser, $ftppass, $ftppath, $ftpport = 21, $ftpssl = 0, $silent = 0)
{
    global $ftp;
    @set_time_limit(0);
    $ftphost = wipespecial($ftphost);
    $ftpport = intval($ftpport);
    $ftpssl = intval($ftpssl);
    $ftp['timeout'] = intval($ftp['timeout']);
    $func = $ftpssl && function_exists('ftp_ssl_connect') ? 'ftp_ssl_connect' : 'ftp_connect';
    if ($func == 'ftp_connect' && !function_exists('ftp_connect')) {
        if ($silent) {
            return -4;
        } else {
            errorlog('FTP', "FTP not supported.", 0);
        }
    }
    if ($ftp_conn_id = @$func($ftphost, $ftpport, 20)) {
        if ($ftp['timeout'] && function_exists('ftp_set_option')) {
            @ftp_set_option($ftp_conn_id, FTP_TIMEOUT_SEC, $ftp['timeout']);
        }
        if (dftp_login($ftp_conn_id, $ftpuser, $ftppass)) {
            if ($ftp['pasv']) {
                dftp_pasv($ftp_conn_id, TRUE);
            }
            if (dftp_chdir($ftp_conn_id, $ftppath)) {
                return $ftp_conn_id;
            } else {
                if ($silent) {
                    return -3;
                } else {
                    errorlog('FTP', "Chdir '{$ftppath}' error.", 0);
                }
            }
        } else {
            if ($silent) {
                return -2;
            } else {
                errorlog('FTP', '530 Not logged in.', 0);
            }
        }
    } else {
        if ($silent) {
            return -1;
        } else {
            errorlog('FTP', "Couldn't connect to {$ftphost}:{$ftpport}.", 0);
        }
    }
    dftp_close($ftp_conn_id);
    return -1;
}
示例#2
0
            }
            $md5 = md5_file(DISCUZ_ROOT . './' . $script);
            $discuzfiles = file(DISCUZ_ROOT . './data/discuzfiles.md5');
            $md5datanew = array();
            foreach ($discuzfiles as $line) {
                $md5file = trim(substr($line, 34));
                $md5str = trim(substr($line, 0, 32));
                $md5datanew[$md5file] = $md5str;
            }
            $md5datanew['./' . $script] = $md5;
            $fp = fopen(DISCUZ_ROOT . './data/discuzfiles.md5', 'wb');
            foreach ($md5datanew as $key => $val) {
                fwrite($fp, $val . ' *' . $key . "\r\n");
            }
            fclose($fp);
            if ($run) {
                include_once $script;
                dftp_delete($ftpid, $script);
            }
            dftp_close($ftpid);
        }
        exit(true);
    }
} elseif ($operation == 'openbbs') {
    if (!($bbc = intval($bbc))) {
        removedir($packagepath);
    }
    DB::query("UPDATE " . DB::table('common_setting') . " SET svalue='{$bbc}' WHERE skey='bbclosed'");
    updatecache('setting');
    exit(true);
}