コード例 #1
0
ファイル: checks.inc.php プロジェクト: polarlight1989/08cms
<?php

(!defined('M_COM') || !defined('M_ADMIN')) && exit('No Permission');
aheader();
if ($action == 'ftpcheck') {
    include_once M_ROOT . "./include/ftp.fun.php";
    $checkmsg = '';
    $checkdir = substr(md5('08cms' + $timestamp), 12, 8);
    $checkfile = 'test.txt';
    $c_ftp = new cls_ftp();
    $conn_ret = $c_ftp->mconnect($ftp_host, $ftp_user, authcode($ftp_password, 'DECODE', md5($authkey)), $ftp_dir, $ftp_port, $ftp_pasv, $ftp_timeout, $ftp_ssl);
    if ($conn_ret == -1) {
        $checkmsg = 'settings_remote_1';
    } elseif ($conn_ret == -2) {
        $checkmsg = 'settings_remote_2';
    } elseif ($conn_ret == -3) {
        $checkmsg = 'settings_remote_3';
    } elseif ($conn_ret == -4) {
        $checkmsg = 'settings_remote_4';
    }
    if (!$checkmsg) {
        if (!$c_ftp->mmkdir($checkdir)) {
            $checkmsg = 'settings_remote_mderr';
        } else {
            if (!(function_exists('ftp_chmod') && $c_ftp->mchmod(0777, $checkdir)) && !$c_ftp->msite("'CHMOD 0777 {$checkdir}'") && !@ftp_exec($c_ftp->conn_id, "SITE CHMOD 0777 {$checkdir}")) {
                $checkmsg = 'settings_remote_chmoderr' . '\\n';
            }
            $checkfile = $checkdir . '/' . $checkfile;
            if (!$c_ftp->mput($checkfile, M_ROOT . './robots.txt', FTP_BINARY)) {
                $checkmsg .= 'settings_remote_uperr';
                $c_ftp->mdelete($checkfile);
コード例 #2
0
ファイル: ftp.fun.php プロジェクト: polarlight1989/08cms
function ftp_upload(&$target, &$url)
{
    global $c_ftp, $ftp_enabled, $ftp_pwd, $ftp_host, $ftp_port, $ftp_user, $ftp_password, $ftp_timeout, $ftp_pasv, $ftp_ssl, $ftp_dir, $ftp_url, $authkey, $dir_userfile;
    if (!$ftp_enabled) {
        return;
    }
    if (empty($c_ftp->conn_id)) {
        $c_ftp = new cls_ftp();
        $c_ftp->mconnect($ftp_host, $ftp_user, authcode($ftp_password, 'DECODE', md5($authkey)), $ftp_dir, $ftp_port, $ftp_pasv, $ftp_timeout, $ftp_ssl);
        if (!$c_ftp->conn_id) {
            return 0;
        }
        $ftp_pwd = false;
    }
    $tmp = explode('/', $url);
    $count = count($tmp);
    $dest = $tmp[--$count];
    if (!$ftp_pwd && $count > 0) {
        $i = 0;
        $c_ftp->mchdir('/' != substr($ftp_dir, 0, 1) ? '/' . $ftp_dir : $ftp_dir);
        while ($i < $count) {
            if (!$c_ftp->mchdir($tmp[$i])) {
                $c_ftp->mmkdir($tmp[$i]);
                $c_ftp->mchmod(0777, $tmp[$i]);
                if (!$c_ftp->mchdir($tmp[$i])) {
                    return;
                }
                $c_ftp->mput('index.htm', M_ROOT . $dir_userfile . '/index.htm', FTP_BINARY);
                $c_ftp->mput('index.html', M_ROOT . $dir_userfile . '/index.html', FTP_BINARY);
            }
            $i++;
        }
        $ftp_pwd = true;
    }
    if (!$c_ftp->mput($dest, $target, FTP_BINARY)) {
        return 0;
    }
    @unlink($target);
    $url = '<!ftpurl />' . $url;
    return 1;
}