function ftp_connect($host, $port = 21, $timeout = 0) { // Opens an FTP connection if ($timeout < 1) { $timeout = 90; } $ftp = new FTP(); if (!$ftp->connect($host, $port, $timeout)) { return false; } return $ftp; }
$dedeNowurls = explode("?", $dedeNowurl); $s_scriptName = $dedeNowurls[0]; //检验用户登录状态 $cuserLogin = new userLogin(); if ($cuserLogin->getUserID() <= 0) { if (empty($adminDirHand)) { ShowMsg("<b>提示:需输入后台管理目录才能登录</b><br /><form>请输入后台管理目录名:<input type='hidden' name='gotopage' value='" . urlencode($dedeNowurl) . "' /><input type='text' name='adminDirHand' value='dede' style='width:120px;' /><input style='width:80px;' type='submit' name='sbt' value='转入登录' /></form>", "javascript:;"); exit; } $adminDirHand = HtmlReplace($adminDirHand, 1); $gurl = "../../{$adminDirHand}/login.php?gotopage=" . urlencode($dedeNowurl); echo "<script language='javascript'>location='{$gurl}';</script>"; exit; } //启用远程站点则创建FTP类 if ($cfg_remote_site == 'Y') { require_once DEDEINC . '/ftp.class.php'; if (file_exists(DEDEDATA . "/cache/inc_remote_config.php")) { require_once DEDEDATA . "/cache/inc_remote_config.php"; } if (empty($remoteuploads)) { $remoteuploads = 0; } if (empty($remoteupUrl)) { $remoteupUrl = ''; } //初始化FTP配置 $ftpconfig = array('hostname' => $rmhost, 'port' => $rmport, 'username' => $rmname, 'password' => $rmpwd); $ftp = new FTP(); $ftp->connect($ftpconfig); }
} $ssl = get_conf('autobackup.ftpssl') ? true : false; /************************************************************ * BAZA DANYCH * ************************************************************/ if (get_conf('autobackup.db_backup')) { if (!$quiet) { print "Tworzę kopię bazy danych \n"; } if (!($filename_sql = $LMS->DataBaseCreate(get_conf('autobackup.db_gz', true), get_conf('autobackup.db_stats', false)))) { $filename_sql = false; } if (!$quiet) { print "Utworzono kopię bazy danych " . $filename_sql . "\n"; } if (get_conf('autobackup.db_ftpsend') && $filename_sql && $FTP->connect($ssl)) { $filename = str_replace(get_conf('directories.backup_dir') . '/', '', $filename_sql); $tmp = str_replace('.sql', '', $filename_sql); // $tmp = .' $FTP->chdir(get_conf('autobackup.db_ftppath'), true); if (!$quiet) { print "Tworze kopie bazy na FTP: " . $filename . "\n"; } $result = $FTP->upload($filename_sql, $filename, 'auto', $akcja); $FTP->close(); if (SYSLOG) { if ($result) { addlogs('lms-autobackup -> Utworzono kopię bazy ' . $filename . ' na serwerze FTP: ' . get_conf('autobackup.ftphost'), 'e=add;m=admin;'); } else { addlogs('lms-autobackup -> Nie utworzono kopii bazy ' . $filename . ' na serwerze FTP: ' . get_conf('autobackup.ftphost'), 'e=err;m=admin;'); }
} $pm->setVariable('skin', $_REQUEST['skin']); $pm->setVariable('stylesheet', $_REQUEST['stylesheet']); if (file_exists(TYPEF_DIR . "/skins/{$_REQUEST['skin']}{$_REQUEST['stylesheet']}")) { $pm->setVariable('source', file_get_contents(TYPEF_DIR . "/skins/{$_REQUEST['skin']}{$_REQUEST['stylesheet']}")); } else { if (file_exists(TYPEF_DIR . "/skins/default{$_REQUEST['stylesheet']}")) { $pm->setVariable('source', file_get_contents(TYPEF_DIR . "/skins/default{$_REQUEST['stylesheet']}")); } else { Typeframe::Redirect('Stylesheet does not exist.', Typeframe::CurrentPage()->applicationUri(), 1); return; } } if ($_POST['cmd'] == 'stylesheet-update') { $ftp = new FTP(); if (!$ftp->connect(TYPEF_FTP_HOST)) { Typeframe::Redirect('Unable to connect to FTP server.', Typeframe::CurrentPage()->applicationUri(), -1); return; } if (!$ftp->login($_SESSION['typef_ftp_user'], $_SESSION['typef_ftp_pass'])) { Typeframe::Redirect('Unable to log into FTP server.', Typeframe::CurrentPage()->applicationUri(), -1); return; } $h = tmpfile(); fwrite($h, $_REQUEST['source']); if (!fflush($h)) { die("Failed to flush"); } rewind($h); // Make sure that all required directories exist $dirs = dirname("{$_REQUEST['skin']}{$_REQUEST['stylesheet']}");
return; } $rsBackup = $db->prepare('SELECT * FROM #__backup WHERE backupid = ?'); $rsBackup->execute($_REQUEST['backupid']); if ($rsBackup->recordcount() == 0) { Typeframe::Redirect('The selected backup does not exist.', Typeframe::CurrentPage()->applicationUri(), 1); return; } $rowBackup = $rsBackup->fetch_array(); $fullpath = TYPEF_DIR . '/files/secure/backups/' . $rowBackup['filename']; if (!file_exists($fullpath)) { Typeframe::Redirect('The selected backup does not exist.', Typeframe::CurrentPage()->applicationUri(), 1); return; } $ftp = new FTP(); $ftp->connect(TYPEF_FTP_HOST); $ftp->login($_SESSION['typef_ftp_user'], $_SESSION['typef_ftp_pass']); if (file_exists(TYPEF_DIR . '/files/secure/backups/tmp')) { system('rm -rf ' . TYPEF_DIR . '/files/secure/backups/tmp'); } mkdir(TYPEF_DIR . '/files/secure/backups/tmp'); /* $archExtractor = new ArchiveExtractor(); $archExtractor->extractArchive($fullpath, TYPEF_SOURCE_DIR . '/backups/tmp'); */ $tmpdir = tempnam(sys_get_temp_dir(), 'phrm_'); unlink($tmpdir); mkdir($tmpdir); exec("tar -zxvf {$fullpath} -C {$tmpdir}", $list, $retval); if ($_POST['cmd'] == 'restore-all') { // Restore all files
/** * 删除 * * @param int $id * @return string */ function del($id) { if ($id) { $row = $this->dsql->GetOne("SELECT askid FROM `#@__askanswer` WHERE id='{$id}'"); $query = "DELETE FROM #@__askanswer WHERE id='{$id}'"; if ($this->dsql->ExecuteNoneQuery($query)) { $query2 = "UPDATE `#@__ask` SET replies = replies - 1 WHERE id='{$row['askid']}'"; $this->dsql->ExecuteNoneQuery($query2); global $cfg_basedir, $cfg_remote_site; //启用远程站点则创建FTP类 if ($cfg_remote_site == 'Y') { require_once DEDEINC . '/ftp.class.php'; if (file_exists(DEDEDATA . "/cache/inc_remote_config.php")) { require_once DEDEDATA . "/cache/inc_remote_config.php"; } if (empty($remoteuploads)) { $remoteuploads = 0; } if (empty($remoteupUrl)) { $remoteupUrl = ''; } //初始化FTP配置 $ftpconfig = array('hostname' => $rmhost, 'port' => $rmport, 'username' => $rmname, 'password' => $rmpwd); $ftp = new FTP(); $ftp->connect($ftpconfig); } $query = "SELECT url FROM `#@__uploads_ask` WHERE rid ='{$id}' AND type = 0"; $this->dsql->SetQuery($query); $this->dsql->Execute(); while ($row = $this->dsql->GetArray()) { if ($cfg_remote_site == 'Y' && $remoteuploads == 1) { $ftp->delete_file($row['url']); } else { @unlink($cfg_basedir . $row['url']); } } $this->dsql->ExecuteNoneQuery("DELETE FROM `#@__uploads_ask` WHERE rid ='{$id}' AND type = 0"); return TRUE; } else { return FALSE; } } else { return FALSE; } }
{ scroll(0,document.body.scrollHeight-document.body.clientHeight+30); } } //--> </SCRIPT> <?php $batch = 3000; //每一批次处理行数 $startline = $_GET['startline']; //起始行 $_POST = unserialize(stripslashes($_COOKIE['POST_VARS'])); rptout("开始文件传输...\n"); //ftp_pasv($conn_id, true); $ftp = new FTP(); if (!$ftp->connect($_POST['server'], $_POST['port'])) { die($ftp->error()); } echo nl2br($ftp->greet()); $ftp->login($_POST['user'], $_POST['pass']); echo "<br>"; echo $ftp->error(); echo "<br>"; echo nl2br($ftp->features()); $ftp->setType('FTP_BINARY'); echo "<br>Connect Ok<br>"; $fp_list = fopen('migtask.txt', 'r'); for ($i = 1; $i < $startline; $i++) { fgetline($fp_list); } //跳至起始行