Esempio n. 1
0
function ftpupload($source, $attach)
{
    global $authkey, $ftp;
    $ftp['pwd'] = isset($ftp['pwd']) ? $ftp['pwd'] : FALSE;
    $dest = $attach['attachment'];
    if ($ftp['on'] && (!$ftp['allowedexts'] && !$ftp['disallowedexts'] || $ftp['allowedexts'] && in_array($attach['ext'], explode("\n", strtolower($ftp['allowedexts']))) || $ftp['disallowedexts'] && !in_array($attach['ext'], explode("\n", strtolower($ftp['disallowedexts'])))) && (!$ftp['minsize'] || $attach['size'] >= $ftp['minsize'] * 1024)) {
        require_once DISCUZ_ROOT . './include/ftp.func.php';
        if (!$ftp['connid']) {
            if (!($ftp['connid'] = dftp_connect($ftp['host'], $ftp['username'], authcode($ftp['password'], 'DECODE', md5($authkey)), $ftp['attachdir'], $ftp['port'], $ftp['ssl']))) {
                if ($ftp['mirror'] == 1) {
                    ftpupload_error($source, $attach);
                } else {
                    return 0;
                }
            }
            $ftp['pwd'] = FALSE;
        }
        $tmp = explode('/', $dest);
        if (count($tmp) > 1) {
            if (!$ftp['pwd'] && !dftp_chdir($ftp['connid'], $tmp[0])) {
                if (!dftp_mkdir($ftp['connid'], $tmp[0])) {
                    errorlog('FTP', "Mkdir '{$ftp['attachdir']}/{$tmp['0']}' error.", 0);
                    if ($ftp['mirror'] == 1) {
                        ftpupload_error($source, $attach);
                    } else {
                        return 0;
                    }
                }
                if (!function_exists('ftp_chmod') || !dftp_chmod($ftp['connid'], 0777, $tmp[0])) {
                    dftp_site($ftp['connid'], "'CHMOD 0777 {$tmp['0']}'");
                }
                if (!dftp_chdir($ftp['connid'], $tmp[0])) {
                    errorlog('FTP', "Chdir '{$ftp['attachdir']}/{$tmp['0']}' error.", 0);
                    if ($ftp['mirror'] == 1) {
                        ftpupload_error($source, $attach);
                    } else {
                        return 0;
                    }
                }
                dftp_put($ftp['connid'], 'index.htm', $GLOBALS['attachdir'] . '/index.htm', FTP_BINARY);
            }
            $dest = $tmp[1];
            $ftp['pwd'] = TRUE;
        }
        if (dftp_put($ftp['connid'], $dest, $source, FTP_BINARY)) {
            if ($attach['thumb']) {
                if (dftp_put($ftp['connid'], $dest . '.thumb.jpg', $source . '.thumb.jpg', FTP_BINARY)) {
                    if ($ftp['mirror'] != 2) {
                        @unlink($source);
                        @unlink($source . '.thumb.jpg');
                    }
                    return 1;
                } else {
                    dftp_delete($ftp['connid'], $dest);
                }
            } else {
                if ($ftp['mirror'] != 2) {
                    @unlink($source);
                }
                return 1;
            }
        }
        errorlog('FTP', "Upload '{$source}' error.", 0);
        $ftp['mirror'] == 1 && ftpupload_error($source, $attach);
    }
    return 0;
}
Esempio n. 2
0
function dunlink($filename, $havethumb = 0, $remote = 0)
{
    global $authkey, $ftp, $attachdir;
    if ($remote) {
        require_once DISCUZ_ROOT . './include/ftp.func.php';
        if (!$ftp['connid']) {
            if (!($ftp['connid'] = dftp_connect($ftp['host'], $ftp['username'], authcode($ftp['password'], 'DECODE', md5($authkey)), $ftp['attachdir'], $ftp['port'], $ftp['ssl']))) {
                return;
            }
        }
        dftp_delete($ftp['connid'], $filename);
        $havethumb && dftp_delete($ftp['connid'], $filename . '.thumb.jpg');
    } else {
        @unlink($attachdir . '/' . $filename);
        $havethumb && @unlink($attachdir . '/' . $filename . '.thumb.jpg');
    }
}
                $alertmsg = $lang['settings_attach_remote_chmoderr'] . '\\n';
            }
            $testfile = $testdir . '/' . $testfile;
            if (!dftp_put($ftp_conn_id, $testfile, DISCUZ_ROOT . './robots.txt', FTP_BINARY)) {
                $alertmsg .= $lang['settings_attach_remote_uperr'];
                dftp_delete($ftp_conn_id, $testfile);
                dftp_delete($ftp_conn_id, $testfile . '.uploading');
                dftp_delete($ftp_conn_id, $testfile . '.abort');
                dftp_rmdir($ftp_conn_id, $testdir);
            } else {
                if (!@readfile($settingsnew['ftp']['attachurl'] . '/' . $testfile)) {
                    $alertmsg .= $lang['settings_attach_remote_geterr'];
                    dftp_delete($ftp_conn_id, $testfile);
                    dftp_rmdir($ftp_conn_id, $testdir);
                } else {
                    if (!dftp_delete($ftp_conn_id, $testfile)) {
                        $alertmsg .= $lang['settings_attach_remote_delerr'];
                    } else {
                        dftp_rmdir($ftp_conn_id, $testdir);
                        $alertmsg = $lang['settings_attach_remote_ok'];
                    }
                }
            }
        }
    }
    echo '<script language="javascript">alert(\'' . str_replace('\'', '\\\'', $alertmsg) . '\');parent.$(\'cpform\').action=\'' . $BASESCRIPT . '?action=settings&edit=yes\';parent.$(\'cpform\').target=\'_self\'</script>';
} elseif ($operation == 'mailcheck') {
    $mail = serialize($settingsnew['mail']);
    $test_tos = explode(',', $test_to);
    $date = date('Y-m-d H:i:s');
    $alertmsg = '';
Esempio n. 4
0
function ftpupload($source, $dest, $havethumb = 0)
{
    global $authkey, $ftp;
    if ($ftp['on']) {
        require_once DISCUZ_ROOT . './include/ftp.func.php';
        if (!$ftp['connid']) {
            if (!($ftp['connid'] = dftp_connect($ftp['host'], $ftp['username'], authcode($ftp['password'], 'DECODE', md5($authkey)), $ftp['attachdir'], $ftp['port'], $ftp['ssl']))) {
                return 0;
            }
            $ftp['pwd'] = FALSE;
        }
        $tmp = explode('/', $dest);
        if (count($tmp) > 1) {
            if (!$ftp['pwd'] && !dftp_chdir($ftp['connid'], $tmp[0])) {
                if (!dftp_mkdir($ftp['connid'], $tmp[0])) {
                    errorlog('FTP', "Mkdir '{$ftp['attachdir']}/{$tmp['0']}' error.", 0);
                    return 0;
                }
                if (!function_exists('ftp_chmod') || !dftp_chmod($ftp['connid'], 0777, $tmp[0])) {
                    dftp_site($ftp['connid'], "'CHMOD 0777 {$tmp['0']}'");
                }
                if (!dftp_chdir($ftp['connid'], $tmp[0])) {
                    errorlog('FTP', "Chdir '{$ftp['attachdir']}/{$tmp['0']}' error.", 0);
                    return 0;
                }
                dftp_put($ftp['connid'], 'index.htm', $GLOBALS['attachdir'] . '/index.htm', FTP_BINARY);
            }
            $dest = $tmp[1];
            $ftp['pwd'] = TRUE;
        }
        if (dftp_put($ftp['connid'], $dest, $source, FTP_BINARY)) {
            if ($havethumb) {
                if (dftp_put($ftp['connid'], $dest . '.thumb.jpg', $source . '.thumb.jpg', FTP_BINARY)) {
                    @unlink($source);
                    @unlink($source . '.thumb.jpg');
                    return 1;
                } else {
                    dftp_delete($ftp['connid'], $dest);
                }
            } else {
                @unlink($source);
                return 1;
            }
        }
        errorlog('FTP', "Upload '{$source}' error.", 0);
    }
    return 0;
}
Esempio n. 5
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);
}
Esempio n. 6
0
				$alertmsg = $lang['settings_remote_chmoderr'].'\n';
			}
			$tmpfile = $tmpdir.'/test.txt';
			if(!dftp_put($ftp_conn_id, $tmpfile, DISCUZ_ROOT.'./robots.txt', FTP_BINARY)) {
				$alertmsg .= $lang['settings_remote_uperr'];
				dftp_delete($ftp_conn_id, $tmpfile);
				dftp_delete($ftp_conn_id, $tmpfile.'.uploading');
				dftp_delete($ftp_conn_id, $tmpfile.'.abort');
				dftp_rmdir($ftp_conn_id, $tmpdir);
			} else {
				if(!@readfile($settingsnew['ftp']['attachurl'].'/'.$tmpfile)) {
					$alertmsg .= $lang['settings_remote_geterr'];
					dftp_delete($ftp_conn_id, $tmpfile);
					dftp_rmdir($ftp_conn_id, $tmpdir);
				} else {
					if(!dftp_delete($ftp_conn_id, $tmpfile)) {
						$alertmsg .= $lang['settings_remote_delerr'];
					} else {
						dftp_rmdir($ftp_conn_id, $tmpdir);
						$alertmsg = $lang['settings_remote_ok'];
					}
				}
			}
		}
	}
	echo '<script language="javascript">alert(\''.str_replace('\'', '\\\'', $alertmsg).'\');parent.$(\'settings\').action=\'admincp.php?action=settings&edit=yes\';parent.$(\'settings\').target=\'_self\'</script>';

} elseif($action == 'mailcheck') {

	$mail = serialize($settingsnew['mail']);
	$test_tos = explode(',', $test_to);