public function getError() { $err = $this->ftp->PopError(); if ($err) { return $err['msg']; } }
/** * Add file list to Object after ftp connect * @return void|Object */ function getAdminFTPList() { Context::loadLang('./modules/autoinstall/lang'); set_time_limit(5); require_once _XE_PATH_ . 'libs/ftp.class.php'; $ftp_info = Context::getRequestVars(); if (!$ftp_info->ftp_user || !$ftp_info->ftp_password) { return new Object(-1, 'msg_ftp_invalid_auth_info'); } $this->pwd = $ftp_info->ftp_root_path; if (!$ftp_info->ftp_host) { $ftp_info->ftp_host = "127.0.0.1"; } if (!$ftp_info->ftp_port || !is_numeric($ftp_info->ftp_port)) { $ftp_info->ftp_port = "21"; } if ($ftp_info->sftp == 'Y') { if (!function_exists(ssh2_sftp)) { return new Object(-1, 'disable_sftp_support'); } return $this->getSFTPList(); } $oFtp = new ftp(); if ($oFtp->ftp_connect($ftp_info->ftp_host, $ftp_info->ftp_port)) { if ($oFtp->ftp_login($ftp_info->ftp_user, $ftp_info->ftp_password)) { $_list = $oFtp->ftp_rawlist($this->pwd); $oFtp->ftp_quit(); } else { return new Object(-1, 'msg_ftp_invalid_auth_info'); } } $list = array(); if ($_list) { foreach ($_list as $k => $v) { $src = null; $src->data = $v; $res = Context::convertEncoding($src); $v = $res->data; if (strpos($v, 'd') === 0 || strpos($v, '<DIR>')) { $list[] = substr(strrchr($v, ' '), 1) . '/'; } } } else { return new Object(-1, 'msg_ftp_no_directory'); } $this->add('list', $list); }
static function ftp_step() { echo "hey"; $result = upgrader::get_all_files(); require "ftpabstract.php"; $mstring = "cache/" . time() . ".php"; file_put_contents(ABSPATH . $mstring, "adi"); chmod(ABSPATH . $mstring, 0777); $ftp = new ftp(); $ftp->Verbose = TRUE; $ftp->LocalEcho = TRUE; if (!$ftp->SetServer($_REQUEST['fserver'])) { $ftp->quit(); die("Setting server failed :(\n<br>"); } if (!$ftp->connect()) { die("Cannot connect: Refresh and try again\n<br>"); } if (!$ftp->login($_REQUEST['fusername'], $_REQUEST['fpassword'])) { $ftp->quit(); die("Login failed: Refresh and try again\n<br>"); } require 'path.php'; $finder = new finder(); $finder->mstring = $mstring; $finder->connect($ftp); $res = $finder->searcher(); $dirs = $result['dirs']; $phpfiles = $result['phpfiles']; $only_files = $result['only_files']; $everything = $phpfiles; //$result["everything"]; // file_put_contents("out.txt", print_r($everything, true)); $xdirs = \CODOF\Util::get_777s(); @$ftp->chmod($res, 0777); foreach ($everything as $thing) { @$ftp->chmod($res . $thing, 0777); // echo $res.$thing."<br>"; } upgrader::chmod_array($ftp, $everything, $res, 0777); upgrader::direct_upgrade(); $result = upgrader::get_all_files(); //get all files after unpacking $dirs = $result['dirs']; $phpfiles = $result['phpfiles']; $only_files = $result['only_files']; $everything = $phpfiles; //$result["everything"]; upgrader::chmod_array($ftp, $phpfiles, $res, 0644); //PHP FILES upgrader::chmod_array($ftp, $dirs, $res, 0755); //ALL DIRS upgrader::chmod_array($ftp, $xdirs, $res, 0777); //CACHE & SITE DIRS }
/** * * 连接并登陆ftp服务器 * * @param string $host * @param string $username * @param string $password * @param int $port * @param int $timeout * @param bool $pasv * @return bool */ public static function connect($host, $username, $password, $port = 21, $timeout = 90, $pasv = false) { if ((self::$resource = ftp_connect($host, $port, $timeout)) === false) { throw_exception('ftp unable to connect'); } if (!self::login($username, $password)) { throw_exception('ftp unable to login'); } if ($pasv === true) { self::pasv($pasv); } return true; }
function getInstallFTPList() { $ftp_info = Context::getRequestVars(); if (!$ftp_info->ftp_user || !$ftp_info->ftp_password) { return new Object(-1, 'msg_ftp_invalid_auth_info'); } $this->pwd = $ftp_info->ftp_root_path; if (!$ftp_info->ftp_host) { $ftp_info->ftp_host = "127.0.0.1"; } if ($ftp_info->sftp == 'Y') { return $this->getSFTPList(); } if (function_exists(ftp_connect)) { $connection = ftp_connect($ftp_info->ftp_host, $ftp_info->ftp_port); if (!$connection) { return new Object(-1, sprintf(Context::getLang('msg_ftp_not_connected'), $ftp_info->ftp_host)); } $login_result = @ftp_login($connection, $ftp_info->ftp_user, $ftp_info->ftp_password); if (!$login_result) { ftp_close($connection); return new Object(-1, 'msg_ftp_invalid_auth_info'); } if ($ftp_info->ftp_pasv != "N") { ftp_pasv($connection, true); } $_list = ftp_rawlist($connection, $this->pwd); ftp_close($connection); } else { require_once _XE_PATH_ . 'libs/ftp.class.php'; $oFtp = new ftp(); if ($oFtp->ftp_connect($ftp_info->ftp_host, $ftp_info->ftp_port)) { if ($oFtp->ftp_login($ftp_info->ftp_user, $ftp_info->ftp_password)) { $_list = $oFtp->ftp_rawlist($this->pwd); $oFtp->ftp_quit(); } else { $oFtp->ftp_quit(); return new Object(-1, 'msg_ftp_invalid_auth_info'); } } } $list = array(); if ($_list) { foreach ($_list as $k => $v) { $src = null; $src->data = $v; $res = Context::convertEncoding($src); $v = $res->data; if (strpos($v, 'd') === 0 || strpos($v, '<DIR>')) { $list[] = substr(strrchr($v, ' '), 1) . '/'; } } } $this->add('list', $list); }
/** * @brief 디렉토리 생성 * * 주어진 경로를 단계별로 접근하여 recursive하게 디렉토리 생성 **/ function makeDir($path_string) { static $oFtp = null; // safe_mode 일 경우 ftp 정보를 이용해서 디렉토리 생성 if (ini_get('safe_mode') && $oFtp == null) { if (!Context::isFTPRegisted()) { return; } require_once _XE_PATH_ . 'libs/ftp.class.php'; $ftp_info = Context::getFTPInfo(); $oFtp = new ftp(); if (!$oFtp->ftp_connect('localhost')) { return; } if (!$oFtp->ftp_login($ftp_info->ftp_user, $ftp_info->ftp_password)) { $oFtp->ftp_quit(); return; } } $path_string = str_replace(_XE_PATH_, '', $path_string); $path_list = explode('/', $path_string); $path = _XE_PATH_; for ($i = 0; $i < count($path_list); $i++) { if (!$path_list[$i]) { continue; } $path .= $path_list[$i] . '/'; if (!is_dir($path)) { if (ini_get('safe_mode')) { $oFtp->ftp_mkdir($path); $oFtp->ftp_site("CHMOD 777 " . $path); } else { @mkdir($path, 0755); @chmod($path, 0755); } } } return is_dir($path_string); }
?> " /></td> </tr> </table> </form> <?php echo foot(); } elseif ($job == 'ftp2') { require_once "classes/ftp/class.ftp.php"; require_once "classes/ftp/class.ftp_" . pemftp_class_module() . ".php"; $temp = array('ftp_server' => $gpc->get('ftp_server', none), 'ftp_port' => $gpc->get('ftp_port', int), 'ftp_user' => $gpc->get('ftp_user', none), 'ftp_pw' => $gpc->get('ftp_pw', none), 'ftp_path' => $gpc->get('ftp_path', none, DIRECTORY_SEPARATOR)); $error = false; $dataGiven = count(array_unique($temp)) == 5; if ($dataGiven) { ob_start(); $ftp = new ftp(true, true); if (!$ftp->SetServer($temp['ftp_server'], $temp['ftp_port'])) { $error = 'admin_server_port_invalid'; } else { if (!$ftp->connect()) { $error = 'admin_cannot_connect_to_ftp_server'; } else { if (!$ftp->login($temp['ftp_user'], $temp['ftp_pw'])) { $ftp->quit(); $error = 'admin_cannot_authenticate_at_ftp_server'; } else { if (!$ftp->chdir($temp['ftp_path']) || !$ftp->file_exists('data/config.inc.php')) { $ftp->quit(); $lang->assign('ftp_path', $temp['ftp_path']); $error = 'admin_ftp_directory_does_not_exist'; }
function procInstallCheckFtp() { $ftp_info = Context::gets('ftp_user', 'ftp_password', 'ftp_port'); $ftp_info->ftp_port = (int) $ftp_info->ftp_port; if (!$ftp_info->ftp_port) { $ftp_info->ftp_port = 21; } if (!$ftp_info->ftp_user || !$ftp_info->ftp_password) { return new Object(-1, 'msg_safe_mode_ftp_needed'); } require_once _XE_PATH_ . 'libs/ftp.class.php'; $oFtp = new ftp(); if (!$oFtp->ftp_connect('localhost', $ftp_info->ftp_port)) { return new Object(-1, 'msg_ftp_not_connected'); } if (!$oFtp->ftp_login($ftp_info->ftp_user, $ftp_info->ftp_password)) { $oFtp->ftp_quit(); return new Object(-1, 'msg_ftp_invalid_auth_info'); } $oFtp->ftp_quit(); $this->setMessage('msg_ftp_connect_success'); }
function procInstallCheckFtp() { $ftp_info = Context::gets('ftp_user', 'ftp_password', 'ftp_port', 'sftp'); $ftp_info->ftp_port = (int) $ftp_info->ftp_port; if (!$ftp_info->ftp_port) { $ftp_info->ftp_port = 21; } if (!$ftp_info->sftp) { $ftp_info->sftp = 'N'; } if (!$ftp_info->ftp_user || !$ftp_info->ftp_password) { return new Object(-1, 'msg_safe_mode_ftp_needed'); } if ($ftp_info->sftp == 'Y') { $connection = ssh2_connect('localhost', $ftp_info->ftp_port); if (!ssh2_auth_password($connection, $ftp_info->ftp_user, $ftp_info->ftp_password)) { return new Object(-1, 'msg_ftp_invalid_auth_info'); } } else { require_once _XE_PATH_ . 'libs/ftp.class.php'; $oFtp = new ftp(); if (!$oFtp->ftp_connect('127.0.0.1', $ftp_info->ftp_port)) { return new Object(-1, sprintf(Context::getLang('msg_ftp_not_connected'), 'localhost')); } if (!$oFtp->ftp_login($ftp_info->ftp_user, $ftp_info->ftp_password)) { $oFtp->ftp_quit(); return new Object(-1, 'msg_ftp_invalid_auth_info'); } $oFtp->ftp_quit(); } $this->setMessage('msg_ftp_connect_success'); }
/** * @access public */ public function __destruct() { $this->ftp->quit(); }
if (isset($_REQUEST['ftp_user'])) { $config['ftp_user'] = trim($_REQUEST['ftp_user']); } if (isset($_REQUEST['ftp_pw'])) { $config['ftp_pw'] = trim($_REQUEST['ftp_pw']); } if (isset($_REQUEST['ftp_port'])) { $config['ftp_port'] = trim($_REQUEST['ftp_port']) + 0; } if (isset($_REQUEST['ftp_path'])) { $config['ftp_path'] = trim($_REQUEST['ftp_path']); } require_once "../classes/ftp/class.ftp.php"; require_once "../classes/ftp/class.ftp_" . pemftp_class_module() . ".php"; echo '<div class="bbody" style="display: none;"><strong>FTP-Command-Log:</strong>:<br /><pre>'; $ftp = new ftp(true, true); if (!$ftp->SetServer($config['ftp_server'], $config['ftp_port'])) { $ftp->quit(); } if (!$ftp->connect()) { ?> </pre></div> <div class="bbody">Could not connect to ftp server! Pleasy try again later or check the ftp server settings (server, port)!</div> <div class="bfoot center"><a class="submit" href="index.php?step=<?php echo $step - 1; ?> ">Go back</a></div> <?php } else { if (!$ftp->login($config['ftp_user'], $config['ftp_pw'])) { $ftp->quit();
/** * Generates ZIP archive * @return string|WP_Error */ protected function _generateArchive() { global $blog_id; set_time_limit(0); // Prepare archive directory $uploadDir = wp_upload_dir(); $exporter = wp_get_current_user(); $archiveName = $uploadDir['path'] . '/' . self::HOOK . '-' . $blog_id . '-' . time() . '-' . $exporter->user_login; $archiveDir = $archiveName . '/'; if (!file_exists($archiveDir)) { wp_mkdir_p($archiveDir); } // Prepare queue $baseUrl = untrailingslashit(home_url()); $newBaseUrl = untrailingslashit($this->_options->getOption('baseUrl')); $urlsQueue = array_unique(array_merge(array(trailingslashit($baseUrl)), $this->_getListOfLocalFilesByUrl(array(get_template_directory_uri())), $this->_getListOfLocalFilesByUrl(explode("\n", $this->_options->getOption('additionalUrls'))))); // Process queue $this->_exportLog = array(); while (count($urlsQueue)) { $currentUrl = array_shift($urlsQueue); //echo "Processing ". $currentUrl."<br />"; $urlResponse = new StaticHtmlOutput_UrlRequest($currentUrl); $urlResponse->cleanup(); // Add current url to the list of processed urls $this->_exportLog[$currentUrl] = true; // Add new urls to the queue foreach ($urlResponse->extractAllUrls($baseUrl) as $newUrl) { if (!isset($this->_exportLog[$newUrl]) && $newUrl != $currentUrl && !in_array($newUrl, $urlsQueue)) { //echo "Adding ".$newUrl." to the list<br />"; $urlsQueue[] = $newUrl; } } // Save url data $urlResponse->replaceBaseUlr($baseUrl, $newBaseUrl); $this->_saveUrlData($urlResponse, $archiveDir); } // Create archive object $tempZip = $archiveName . '.tmp'; $zipArchive = new ZipArchive(); if ($zipArchive->open($tempZip, ZIPARCHIVE::CREATE) !== true) { return new WP_Error('Could not create archive'); } $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($archiveDir)); foreach ($iterator as $fileName => $fileObject) { $baseName = basename($fileName); if ($baseName != '.' && $baseName != '..') { if (!$zipArchive->addFile(realpath($fileName), str_replace($archiveDir, '', $fileName))) { return new WP_Error('Could not add file: ' . $fileName); } } } $zipArchive->close(); rename($tempZip, $archiveName . '.zip'); if ($this->_options->getOption('sendViaFTP') == 1) { //crude FTP addition require_once '/home/leon/leonwp/wp-content/plugins/static-html-output-plugin/library/FTP/ftp.php'; $config = array(); //keys[passive_mode(true|false)|transfer_mode(FTP_ASCII|FTP_BINARY)|reattempts(int)|log_path|verbose(true|false)|create_mask(default:0777)] $ftp = new ftp($config); $ftp->conn($this->_options->getOption('ftpServer'), $this->_options->getOption('ftpUsername'), filter_input(INPUT_POST, 'ftpPassword')); //Crude FTP $ftp->put($this->_options->getOption('ftpRemotePath'), $archiveName . '/'); unset($ftp); } // Remove temporary files unless user requested to keep or needed for FTP transfer if ($this->_options->getOption('retainStaticFiles') != 1) { $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($archiveDir), RecursiveIteratorIterator::CHILD_FIRST); foreach ($iterator as $fileName => $fileObject) { // Remove file if ($fileObject->isDir()) { // Ignore special dirs $dirName = basename($fileName); if ($dirName != '.' && $dirName != '..') { rmdir($fileName); } } else { unlink($fileName); } } rmdir($archiveDir); } return str_replace(ABSPATH, trailingslashit(home_url()), $archiveName . '.zip'); }
<?php if (INSTALL_INIT == 'upgrade') { $config['ftp_host'] = $_SERVER['SERVER_ADDR']; $config['ftp_port'] = empty($config['ftp_port']) ? 21 : $config['ftp_port']; $config['ftp_root'] = empty($config['ftp_root']) ? 'public_html' : $config['ftp_root']; $ftp = false; if (!empty($config['ftp_username']) && !empty($config['ftp_password'])) { $ftp = new ftp($config['ftp_host'], $config['ftp_username'], $config['ftp_password'], $config['ftp_root'], $config['ftp_port']); } if ($ftp && $ftp->connect() && $ftp->is_dir($config['ftp_root'])) { $_SESSION['ftp_root'] = $config['ftp_root']; include ROOT_PATH . 'admin/install/upgrade1.php'; } else { echo '<h2>ยินดีต้อนรับสู่การปรับรุ่นของ GCMS เวอร์ชั่น ' . $version . '</h2>'; echo '<p><em>เราตรวจพบโฟลเดอร์ <strong>install/</strong> บนเซิร์ฟเวอร์ของคุณ และตรวจพบ <strong>GCMS</strong> เวอร์ชั่นใหม่บนเซิร์ฟเวอร์ของคุณ</em> และต้องการการปรับรุ่น</p>'; echo '<h3>ระบุที่อยู่ FTP ของโฮสต์</h3>'; echo '<p>ก่อนอื่นเราแนะนำให้คุณระบุค่ากำหนดต่างๆของ FTP Server ของคุณ FTP จะช่วยให้คุณจัดการกับไฟล์และไดเร็คทอรี่บน GCMS ได้ง่ายขึ้น ถ้าคุณไม่รู้ค่ากำหนดเหล่านี้ คุณสามารถข้ามขั้นตอนนี้ไปก่อนได้</p>'; echo '<form method=post action=index.php autocomplete=off>'; echo '<p class=row><label for=ftp_host>โฮสต์</label><input type=text size=70 id=ftp_host name=ftp_host value="' . (!empty($_SESSION['ftp_host']) ? $_SESSION['ftp_host'] : $config['ftp_host']) . '"></p>'; echo '<p class="row comment">FTP โดเมน เช่น ftp.domain.tld หรือ ที่อยู่ IP ของโฮสต์</p>'; echo '<p class=row><label for=ftp_username>ชื่อผู้ใช้</label><input type=text size=70 id=ftp_username name=ftp_username value="' . (!empty($_SESSION['ftp_username']) ? $_SESSION['ftp_username'] : $config['ftp_username']) . '"></p>'; echo '<p class="row comment">ชื่อผู้ใช้ของ FTP</p>'; echo '<p class=row><label for=ftp_password>รหัสผ่าน</label><input type=password size=70 id=ftp_password name=ftp_password value="' . (!empty($_SESSION['ftp_password']) ? $_SESSION['ftp_password'] : $config['ftp_password']) . '"></p>'; echo '<p class="row comment">รหัสผ่านของ FTP</p>'; echo '<p class=row><label for=ftp_root>FTP Root</label><input type=text size=70 id=ftp_root name=ftp_root value="' . (!empty($_SESSION['ftp_root']) ? $_SESSION['ftp_root'] : $config['ftp_root']) . '"></p>'; echo '<p class="row comment">ไดเรคทอรี่เริ่มต้นของของโฮสต์เช่น public_html หรือ www</p>'; echo '<p class=row><label for=ftp_port>พอร์ต</label><input type=text size=70 id=ftp_port name=ftp_port value="' . (!empty($_SESSION['ftp_port']) ? $_SESSION['ftp_port'] : $config['ftp_port']) . '"></p>'; echo '<p class="row comment">FTP พอร์ต (ค่าปกติคือ 20)</p>'; echo '<input type=hidden name=step value=1>'; echo '<p><input class=button type=submit value="ดำเนินการต่อ."></p>';
function getftpurl($host, $port, $url, $saveToFile = 0) { global $nn, $lastError, $PHP_SELF, $FtpBytesTotal, $FtpBytesReceived, $FtpTimeStart, $FtpChunkSize, $options; $ftp = new ftp(FALSE, FALSE); $server = "{$host}:{$port}"; if (empty($host) || empty($port) || !$ftp->SetServer($host, (int) $port)) { $ftp->quit(); $lastError = sprintf(lang(79), $server); return FALSE; } else { if (!$ftp->connect()) { $ftp->quit(); $lastError = sprintf(lang(79), $server); return FALSE; } else { if (!$ftp->login()) { $ftp->quit(); $lastError = lang(80); return FALSE; } else { echo '<p>'; printf(lang(81), $server); echo '<br />'; //$ftp->Passive(FALSE); $tmp = explode("/", $url); $ftp_file = array_pop($tmp); $ftp_dir = implode('/', $tmp); $ftp->chdir($ftp_dir); $fileSize = $FtpBytesTotal = $ftp->filesize($ftp_file); $FtpChunkSize = round($fileSize / 333); if (strpos($saveToFile, '?') !== false) { $saveToFile = substr($saveToFile, 0, strpos($saveToFile, '?')); } if ($options['file_size_limit'] > 0) { if ($fileSize > $options['file_size_limit'] * 1024 * 1024) { $lastError = lang(336) . bytesToKbOrMbOrGb($options['file_size_limit'] * 1024 * 1024) . "."; return false; } } if (!empty($options['rename_prefix'])) { $File_Name = $options['rename_prefix'] . '_' . basename($saveToFile); $saveToFile = dirname($saveToFile) . PATH_SPLITTER . $File_Name; } if (!empty($options['rename_suffix'])) { $ext = strrchr(basename($saveToFile), '.'); $before_ext = explode($ext, basename($saveToFile)); $File_Name = $before_ext[0] . '_' . $options['rename_suffix'] . $ext; $saveToFile = dirname($saveToFile) . PATH_SPLITTER . $File_Name; } if ($options['rename_underscore']) { $File_Name = str_replace(array(' ', '%20'), '_', basename($saveToFile)); $saveToFile = dirname($saveToFile) . PATH_SPLITTER . $File_Name; } $filetype = strrchr($saveToFile, '.'); if (is_array($options['forbidden_filetypes']) && in_array(strtolower($filetype), $options['forbidden_filetypes'])) { if ($options['forbidden_filetypes_block']) { html_error(sprintf(lang(82), $filetype)); } $saveToFile = str_replace($filetype, $options['rename_these_filetypes_to'], $saveToFile); } if (@file_exists($saveToFile) && $options['bw_save']) { // Skip in audl. if (isset($_GET['audl'])) { echo '<script type="text/javascript">parent.nextlink();</script>'; } html_error(lang(99) . ': ' . link_for_file($saveToFile)); } elseif (@file_exists($saveToFile)) { $saveToFile = dirname($saveToFile) . PATH_SPLITTER . time() . '_' . basename($saveToFile); } printf(lang(83), basename($saveToFile), bytesToKbOrMbOrGb($fileSize)); echo "<br />"; require_once TEMPLATE_DIR . '/transloadui.php'; $FtpTimeStart = getmicrotime(); if ($ftp->get($ftp_file, $saveToFile)) { $ftp->quit(); $time = getmicrotime() - $FtpTimeStart; return array('time' => sec2time(round($time)), 'speed' => @round($FtpBytesTotal / 1024 / $time, 2), 'received' => TRUE, 'size' => bytesToKbOrMbOrGb($fileSize), 'bytesReceived' => $FtpBytesReceived, 'bytesTotal' => $FtpBytesTotal, 'file' => $saveToFile); } $ftp->quit(); return FALSE; } } } }
$content = $server_src->get($path . '/' . $v['name']); $server->put($dest . '/' . $v['name'], $content); } $i++; } } if ($_POST['path'] == 'root') { $_POST['path'] = ''; } $site = $_GET['site']; if ($_POST['server_type']) { $options = array('site' => $_POST); } switch ($server_type) { case 'ftp': $server = new ftp(); $result = $server->connect($host, $username, $password, $port, $dir, array('pasv' => $pasv)); if ($result === false) { print_r($server->ftp_log); exit; } break; case 'sftp': $server = new sftp(); $result = $server->connect($host, $username, $password, $port, $dir); if ($result === false) { print_r($server->ftp_log); exit; } break; default:
function getftpurl($host, $port, $url, $saveToFile = 0) { global $nn, $lastError, $PHP_SELF, $AUTH, $IS_FTP, $FtpBytesTotal, $FtpBytesReceived, $FtpTimeStart, $FtpChunkSize, $options; $ftp = new ftp(FALSE, FALSE); if (!$ftp->SetServer($host, (int) $port)) { $ftp->quit(); $server = $host . ':' . $port; $lastError = sprintf(lang(79), $server) . "<br />" . '<a href="javascript:history.back(-1);">' . lang(78) . '</a><br /><br />'; return FALSE; } else { if (!$ftp->connect()) { $ftp->quit(); $lastError = sprintf(lang(79), $server) . "<br />" . '<a href="javascript:history.back(-1);">' . lang(78) . '</a><br /><br />'; return FALSE; } else { if (!$ftp->login($AUTH["ftp"]["login"], $AUTH["ftp"]["password"])) { $ftp->quit(); $lastError = lang(80) . "<br />" . '<a href="javascript:history.back(-1);">' . lang(78) . '</a><br /><br />'; return FALSE; } else { echo '<p>'; printf(lang(81), $host); echo '<br />'; //$ftp->Passive(FALSE); $tmp = explode("/", $url); $ftp_file = array_pop($tmp); $ftp_dir = implode("/", $tmp); $ftp->chdir($ftp_dir); $fileSize = $FtpBytesTotal = $ftp->filesize($ftp_file); $FtpChunkSize = round($fileSize / 333); list($saveToFile, $tmp) = explode('?', $saveToFile); if (!empty($options['rename_prefix'])) { $File_Name = $options['rename_prefix'] . '_' . basename($saveToFile); $saveToFile = dirname($saveToFile) . PATH_SPLITTER . $File_Name; } if (!empty($options['rename_suffix'])) { $ext = strrchr(basename($saveToFile), "."); $before_ext = explode($ext, basename($saveToFile)); $File_Name = $before_ext[0] . '_' . $options['rename_suffix'] . $ext; $saveToFile = dirname($saveToFile) . PATH_SPLITTER . $File_Name; } if ($options['rename_underscore']) { $File_Name = str_replace(array(' ', '%20'), '_', basename($saveToFile)); $saveToFile = dirname($saveToFile) . PATH_SPLITTER . $File_Name; } $filetype = strrchr($saveToFile, "."); if (is_array($options['forbidden_filetypes']) && in_array(strtolower($filetype), $options['forbidden_filetypes'])) { if ($options['forbidden_filetypes_block']) { html_error(sprintf(lang(82), $filetype)); } else { $saveToFile = str_replace($filetype, $options['rename_these_filetypes_to'], $saveToFile); } } if (file_exists($saveToFile)) { $saveToFile = dirname($saveToFile) . PATH_SPLITTER . time() . "_" . basename($saveToFile); } printf(lang(83), $saveToFile, bytesToKbOrMbOrGb($fileSize)); echo "<br />"; ?> <br /> <table cellspacing="0" cellpadding="0" style="FONT-FAMILY: Tahoma; FONT-SIZE: 11px;"> <tr> <td></td> <td> <div class="progressouter"> <div id="progress" class="ftpprogress"> </div> </div> </td> <td></td> <tr> <tr> <td align="left" id="received">0 KB</td> <td align="center" id="percent">0%</td> <td align="right" id="speed">0 KB/s</td> </tr> </table> <br /> <div id="resume" align="center" style="FONT-FAMILY: Tahoma; FONT-SIZE: 11px;"></div> <script type="text/javascript"> /* <![CDATA[ */ function pr(percent, received, speed){ document.getElementById("received").innerHTML = '<b>' + received + '</b>'; document.getElementById("percent").innerHTML = '<b>' + percent + '%</b>'; document.getElementById("progress").style.width = percent + '%'; document.getElementById("speed").innerHTML = '<b>' + speed + ' KB/s</b>'; document.title = 'Downloaded ' + percent + '%'; return true; } function mail(str, field) { document.getElementById("mailPart." + field).innerHTML = str; return true; } /* ]]> */ </script> <br /> <?php $FtpTimeStart = getmicrotime(); if ($ftp->get($ftp_file, $saveToFile)) { return array("time" => sec2time(round($time)), "speed" => @round($FtpBytesTotal / 1024 / (getmicrotime() - $FtpTimeStart), 2), "received" => TRUE, "size" => bytesToKbOrMbOrGb($fileSize), "bytesReceived" => $FtpBytesReceived, "bytesTotal" => $FtpBytesTotal, "file" => $saveToFile); } else { return FALSE; } $ftp->quit(); } } } }
/** * Creates a directory * * This function creates directories recursively, which means that if ancestors of the target directory does not exist, they will be created too. * * @param string $path_string Path of target directory * @return bool true if success. It might return nothing when ftp is used and connection to the ftp address failed. **/ function makeDir($path_string) { static $oFtp = null; // if safe_mode is on, use FTP if (ini_get('safe_mode')) { $ftp_info = Context::getFTPInfo(); if ($oFtp == null) { if (!Context::isFTPRegisted()) { return; } require_once _XE_PATH_ . 'libs/ftp.class.php'; $oFtp = new ftp(); if (!$ftp_info->ftp_host) { $ftp_info->ftp_host = "127.0.0.1"; } if (!$ftp_info->ftp_port) { $ftp_info->ftp_port = 21; } if (!$oFtp->ftp_connect($ftp_info->ftp_host, $ftp_info->ftp_port)) { return; } if (!$oFtp->ftp_login($ftp_info->ftp_user, $ftp_info->ftp_password)) { $oFtp->ftp_quit(); return; } } $ftp_path = $ftp_info->ftp_root_path; if (!$ftp_path) { $ftp_path = "/"; } } $path_string = str_replace(_XE_PATH_, '', $path_string); $path_list = explode('/', $path_string); $path = _XE_PATH_; for ($i = 0; $i < count($path_list); $i++) { if (!$path_list[$i]) { continue; } $path .= $path_list[$i] . '/'; $ftp_path .= $path_list[$i] . '/'; if (!is_dir($path)) { if (ini_get('safe_mode')) { $oFtp->ftp_mkdir($ftp_path); $oFtp->ftp_site("CHMOD 777 " . $ftp_path); } else { @mkdir($path, 0755); @chmod($path, 0755); } } } return is_dir($path_string); }
<table class="border" border="0" cellspacing="0" cellpadding="4" align="center"> <tr> <td class="obox" colspan="2"><span class="right"><a class="button" href="admin.php?action=settings&job=ftp"><?php echo $lang->phrase('admin_configure_ftp_connection'); ?> </a></span><?php echo $lang->phrase('admin_ftp_connection_test'); ?> </td> </tr> <tr> <td class="mbox" width="100%"><strong><?php echo $lang->phrase('admin_ftp_command_log'); ?> </strong><br /><pre><?php $ftp = new ftp(true, true); if (!$ftp->SetServer($config['ftp_server'], $config['ftp_port'])) { ?> </pre><?php echo $lang->phrase('admin_server_port_invalid'); } else { if (!$ftp->connect()) { ?> </pre><?php echo $lang->phrase('admin_cannot_connect_to_ftp_server'); } else { if (!$ftp->login($config['ftp_user'], $config['ftp_pw'])) { $ftp->quit(); ?> </pre><?php echo $lang->phrase('admin_cannot_authenticate_at_ftp_server');
/** * Etablish a ftp-connection, cache connection-object * @param string $server Address of the ftp-server * @param string $port Port of the ftp-server * @param string $user for the connection * @param string $pass Password for the connection * @param string StartDirectory, where to change dir to. */ function getFTPConnection($server, $port, $user, $pass, $startdir) { $ftpConn = new ftp(); $ftpConn->ftp_connect($server, $port); $ftpConn->ftp_login($user, $pass); $ftpConn->ftp_chdir($startdir); return $ftpConn; }
<?php namespace cd; set_include_path(get_include_path() . PATH_SEPARATOR . dirname(__FILE__) . '/../core/'); //XXX: status: not working!?!? require_once 'core.php'; require_once 'client_ftp.php'; $f = new ftp('ftp://ftp.sunet.se/'); //$f->setDebug(true); $dir = $f->getDir('/pub/os/Linux/distributions/slackware/slackware-10.2/'); foreach ($dir as $file) { if ($file['is_file']) { $get = $file['name']; $data = $f->getData($get); d($data); } } die;
function main($id, $mode) { global $config, $db, $user, $auth, $template, $cache; global $phpbb_root_path, $phpbb_admin_path, $phpEx, $table_prefix; global $safe_mode, $file_uploads; include_once $phpbb_root_path . 'includes/functions_user.' . $phpEx; $this->default_variables(); // Check and set some common vars $action = request_var('action', ''); $action = isset($_POST['update_details']) ? 'update_details' : $action; $action = isset($_POST['download_file']) ? 'download_file' : $action; $action = isset($_POST['upload_file']) ? 'upload_file' : $action; $action = isset($_POST['upload_data']) ? 'upload_data' : $action; $action = isset($_POST['submit_file']) ? 'submit_file' : $action; $action = isset($_POST['remove_store']) ? 'details' : $action; $lang_id = request_var('id', 0); if (isset($_POST['missing_file'])) { $missing_file = request_var('missing_file', array('' => 0)); list($_REQUEST['language_file'], ) = array_keys($missing_file); } list($this->language_directory, $this->language_file) = explode('|', request_var('language_file', '|common.' . $phpEx)); $this->language_directory = basename($this->language_directory); $this->language_file = basename($this->language_file); $user->add_lang('acp/language'); $this->tpl_name = 'acp_language'; $this->page_title = 'ACP_LANGUAGE_PACKS'; if ($action == 'upload_data' && request_var('test_connection', '')) { $test_connection = false; $action = 'upload_file'; $method = request_var('method', ''); include_once $phpbb_root_path . 'includes/functions_transfer.' . $phpEx; switch ($method) { case 'ftp': $transfer = new ftp(request_var('host', ''), request_var('username', ''), request_var('password', ''), request_var('root_path', ''), request_var('port', ''), request_var('timeout', '')); break; default: trigger_error($user->lang['INVALID_UPLOAD_METHOD']); } $test_connection = $transfer->open_session(); $transfer->close_session(); } switch ($action) { case 'upload_file': include_once $phpbb_root_path . 'includes/functions_transfer.' . $phpEx; $method = request_var('method', ''); $requested_data = call_user_func(array($method, 'data')); foreach ($requested_data as $data => $default) { $template->assign_block_vars('data', array('DATA' => $data, 'NAME' => $user->lang[strtoupper($method . '_' . $data)], 'EXPLAIN' => $user->lang[strtoupper($method . '_' . $data) . '_EXPLAIN'], 'DEFAULT' => !empty($_REQUEST[$data]) ? request_var($data, '') : $default)); } $entry = $_POST['entry']; foreach ($entry as $key => $value) { if (is_array($value)) { foreach ($value as $key2 => $data) { $entry[$key][$key2] = htmlentities($data); } } else { $entry[$key] = htmlentities($value); } } $hidden_data = build_hidden_fields(array('file' => $this->language_file, 'dir' => $this->language_directory, 'method' => $method, 'entry' => $entry)); $template->assign_vars(array('S_UPLOAD' => true, 'NAME' => $method, 'U_ACTION' => $this->u_action . "&id={$lang_id}&action=upload_data", 'HIDDEN' => $hidden_data, 'S_CONNECTION_SUCCESS' => request_var('test_connection', '') && $test_connection === true ? true : false, 'S_CONNECTION_FAILED' => request_var('test_connection', '') && $test_connection !== true ? true : false)); break; case 'update_details': if (!$lang_id) { trigger_error($user->lang['NO_LANG_ID'] . adm_back_link($this->u_action)); } $sql = 'SELECT * FROM ' . LANG_TABLE . "\n\t\t\t\t\tWHERE lang_id = {$lang_id}"; $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); $sql_ary = array('lang_english_name' => request_var('lang_english_name', $row['lang_english_name']), 'lang_local_name' => request_var('lang_local_name', $row['lang_local_name'], true), 'lang_author' => request_var('lang_author', $row['lang_author'], true)); $db->sql_query('UPDATE ' . LANG_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' WHERE lang_id = ' . $lang_id); add_log('admin', 'LOG_LANGUAGE_PACK_UPDATED', $sql_ary['lang_english_name']); trigger_error($user->lang['LANGUAGE_DETAILS_UPDATED'] . adm_back_link($this->u_action)); break; case 'submit_file': case 'download_file': case 'upload_data': if (!$lang_id || !isset($_POST['entry']) || !is_array($_POST['entry'])) { trigger_error($user->lang['NO_LANG_ID'] . adm_back_link($this->u_action)); } if (!$this->language_file || !$this->language_directory && !in_array($this->language_file, $this->main_files)) { trigger_error($user->lang['NO_FILE_SELECTED'] . adm_back_link($this->u_action)); } $sql = 'SELECT * FROM ' . LANG_TABLE . "\n\t\t\t\t\tWHERE lang_id = {$lang_id}"; $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); if (!$safe_mode) { $mkdir_ary = array('language', 'language/' . $row['lang_iso']); if ($this->language_directory) { $mkdir_ary[] = 'language/' . $row['lang_iso'] . '/' . $this->language_directory; } foreach ($mkdir_ary as $dir) { $dir = $phpbb_root_path . 'store/' . $dir; if (!is_dir($dir)) { if (!@mkdir($dir, 0777)) { trigger_error("Could not create directory {$dir}"); } @chmod($dir, 0777); } } } // Get target filename for storage folder $filename = $this->get_filename($row['lang_iso'], $this->language_directory, $this->language_file, true, true); $fp = fopen($phpbb_root_path . $filename, 'wb'); if (!$fp) { trigger_error($user->lang['UNABLE_TO_WRITE_FILE']); } if ($this->language_directory == 'email') { // Email Template $entry = STRIP ? stripslashes($_POST['entry']) : $_POST['entry']; $entry = preg_replace('#&(\\#[0-9]+;)#', '&\\1', $entry); fwrite($fp, $entry); } else { $name = ($this->language_directory ? $this->language_directory . '_' : '') . $this->language_file; $header = str_replace(array('{FILENAME}', '{LANG_NAME}', '{CHANGED}', '{AUTHOR}'), array($name, $row['lang_english_name'], date('Y-m-d', time()), $row['lang_author']), $this->language_file_header); if (strpos($this->language_file, 'help_') === 0) { // Help File $header .= '$help = array(' . "\n"; fwrite($fp, $header); foreach ($_POST['entry'] as $key => $value) { if (!is_array($value)) { } else { $entry = "\tarray(\n"; foreach ($value as $_key => $_value) { $_value = STRIP ? stripslashes($_value) : $_value; $_value = preg_replace('#&(\\#[0-9]+;)#', '&\\1', $_value); $entry .= "\t\t" . (int) $_key . "\t=> '" . str_replace("'", "\\'", $_value) . "',\n"; } $entry .= "\t),\n"; } fwrite($fp, $entry); } } else { // Language File $header .= $this->lang_header; fwrite($fp, $header); foreach ($_POST['entry'] as $key => $value) { if (!is_array($value)) { $value = STRIP ? stripslashes($value) : $value; $value = preg_replace('#&(\\#[0-9]+;)#', '&\\1', $value); $entry = "\t'" . $key . "'\t=> '" . str_replace("'", "\\'", $value) . "',\n"; } else { $entry = "\n\t'" . $key . "'\t=> array(\n"; foreach ($value as $_key => $_value) { $_value = STRIP ? stripslashes($_value) : $_value; $_value = preg_replace('#&(\\#[0-9]+;)#', '&\\1', $_value); $entry .= "\t\t'" . $_key . "'\t=> '" . str_replace("'", "\\'", $_value) . "',\n"; } $entry .= "\t),\n\n"; } fwrite($fp, $entry); } } $footer = "));\n\n?>"; fwrite($fp, $footer); } fclose($fp); if ($action == 'download_file') { header('Pragma: no-cache'); header('Content-Type: application/octetstream; name="' . $this->language_file . '"'); header('Content-disposition: attachment; filename=' . $this->language_file); $fp = fopen($phpbb_root_path . $filename, 'rb'); while ($buffer = fread($fp, 1024)) { echo $buffer; } fclose($fp); exit; } else { if ($action == 'upload_data') { $sql = 'SELECT lang_iso FROM ' . LANG_TABLE . "\n\t\t\t\t\t\tWHERE lang_id = {$lang_id}"; $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); $file = request_var('file', ''); $dir = request_var('dir', ''); $old_file = '/' . $this->get_filename($row['lang_iso'], $dir, $file, false, true); $lang_path = 'language/' . $row['lang_iso'] . '/' . ($dir ? $dir . '/' : ''); include_once $phpbb_root_path . 'includes/functions_transfer.' . $phpEx; $method = request_var('method', ''); switch ($method) { case 'ftp': $transfer = new ftp(request_var('host', ''), request_var('username', ''), request_var('password', ''), request_var('root_path', ''), request_var('port', ''), request_var('timeout', '')); break; default: trigger_error($user->lang['INVALID_UPLOAD_METHOD']); } if (($result = $transfer->open_session()) !== true) { trigger_error($user->lang[$result] . adm_back_link($this->u_action)); } $transfer->rename($lang_path . $file, $lang_path . $file . '.bak'); $transfer->copy_file('store/' . $lang_path . $file, $lang_path . $file); $transfer->close_session(); add_log('admin', 'LOG_LANGUAGE_FILE_REPLACED', $file); trigger_error($user->lang['UPLOAD_COMPLETED']); } } $action = 'details'; // no break; // no break; case 'details': if (!$lang_id) { trigger_error($user->lang['NO_LANG_ID'] . adm_back_link($this->u_action)); } $this->page_title = 'LANGUAGE_PACK_DETAILS'; $sql = 'SELECT * FROM ' . LANG_TABLE . ' WHERE lang_id = ' . $lang_id; $result = $db->sql_query($sql); $lang_entries = $db->sql_fetchrow($result); $db->sql_freeresult($result); $lang_iso = $lang_entries['lang_iso']; $missing_vars = $missing_files = array(); // Get email templates $email_files = filelist($phpbb_root_path . 'language/' . $config['default_lang'], 'email', 'txt'); $email_files = $email_files['email/']; // Get acp files $acp_files = filelist($phpbb_root_path . 'language/' . $config['default_lang'], 'acp', $phpEx); $acp_files = $acp_files['acp/']; // Get mod files $mods_files = filelist($phpbb_root_path . 'language/' . $config['default_lang'], 'mods', $phpEx); $mods_files = isset($mods_files['mods/']) ? $mods_files['mods/'] : array(); // Check if our current filename matches the files switch ($this->language_directory) { case 'email': if (!in_array($this->language_file, $email_files)) { trigger_error($user->lang['WRONG_LANGUAGE_FILE'] . adm_back_link($this->u_action . '&action=details&id=' . $lang_id)); } break; case 'acp': if (!in_array($this->language_file, $acp_files)) { trigger_error($user->lang['WRONG_LANGUAGE_FILE'] . adm_back_link($this->u_action . '&action=details&id=' . $lang_id)); } break; case 'mods': if (!in_array($this->language_file, $mods_files)) { trigger_error($user->lang['WRONG_LANGUAGE_FILE'] . adm_back_link($this->u_action . '&action=details&id=' . $lang_id)); } break; default: if (!in_array($this->language_file, $this->main_files)) { trigger_error($user->lang['WRONG_LANGUAGE_FILE'] . adm_back_link($this->u_action . '&action=details&id=' . $lang_id)); } } if (isset($_POST['remove_store'])) { $store_filename = $this->get_filename($lang_iso, $this->language_directory, $this->language_file, true, true); @unlink($phpbb_root_path . $store_filename); } include_once $phpbb_root_path . 'includes/functions_transfer.' . $phpEx; $methods = transfer::methods(); foreach ($methods as $method) { $template->assign_block_vars('buttons', array('VALUE' => $method)); } $template->assign_vars(array('S_DETAILS' => true, 'U_ACTION' => $this->u_action . "&action=details&id={$lang_id}", 'U_BACK' => $this->u_action, 'LANG_LOCAL_NAME' => $lang_entries['lang_local_name'], 'LANG_ENGLISH_NAME' => $lang_entries['lang_english_name'], 'LANG_ISO' => $lang_entries['lang_iso'], 'LANG_AUTHOR' => $lang_entries['lang_author'], 'ALLOW_UPLOAD' => sizeof($methods))); // If current lang is different from the default lang, then first try to grab missing/additional vars if ($lang_iso != $config['default_lang']) { $is_missing_var = false; foreach ($this->main_files as $file) { if (file_exists($phpbb_root_path . $this->get_filename($lang_iso, '', $file))) { $missing_vars[$file] = $this->compare_language_files($config['default_lang'], $lang_iso, '', $file); if (sizeof($missing_vars[$file])) { $is_missing_var = true; } } else { $missing_files[] = $this->get_filename($lang_iso, '', $file); } } // Now go through acp/mods directories foreach ($acp_files as $file) { if (file_exists($phpbb_root_path . $this->get_filename($lang_iso, 'acp', $file))) { $missing_vars['acp/' . $file] = $this->compare_language_files($config['default_lang'], $lang_iso, 'acp', $file); if (sizeof($missing_vars['acp/' . $file])) { $is_missing_var = true; } } else { $missing_files[] = $this->get_filename($lang_iso, 'acp', $file); } } if (sizeof($mods_files)) { foreach ($mods_files as $file) { if (file_exists($phpbb_root_path . $this->get_filename($lang_iso, 'mods', $file))) { $missing_vars['mods/' . $file] = $this->compare_language_files($config['default_lang'], $lang_iso, 'mods', $file); if (sizeof($missing_vars['mods/' . $file])) { $is_missing_var = true; } } else { $missing_files[] = $this->get_filename($lang_iso, 'mods', $file); } } } // More missing files... for example email templates? foreach ($email_files as $file) { if (!file_exists($phpbb_root_path . $this->get_filename($lang_iso, 'email', $file))) { $missing_files[] = $this->get_filename($lang_iso, 'email', $file); } } if (sizeof($missing_files)) { $template->assign_vars(array('S_MISSING_FILES' => true, 'L_MISSING_FILES' => sprintf($user->lang['THOSE_MISSING_LANG_FILES'], $lang_entries['lang_local_name']), 'MISSING_FILES' => implode('<br />', $missing_files))); } if ($is_missing_var) { $template->assign_vars(array('S_MISSING_VARS' => true, 'L_MISSING_VARS_EXPLAIN' => sprintf($user->lang['THOSE_MISSING_LANG_VARIABLES'], $lang_entries['lang_local_name']), 'U_MISSING_ACTION' => $this->u_action . "&action={$action}&id={$lang_id}")); foreach ($missing_vars as $file => $vars) { if (!sizeof($vars)) { continue; } $template->assign_block_vars('missing', array('FILE' => $file, 'TPL' => $this->print_language_entries($vars, '', false), 'KEY' => strpos($file, '/') === false ? '|' . $file : str_replace('/', '|', $file))); } } } // Main language files $s_lang_options = '<option value="|common.' . $phpEx . '" class="sep">' . $user->lang['LANGUAGE_FILES'] . '</option>'; foreach ($this->main_files as $file) { if (strpos($file, 'help_') === 0) { continue; } $prefix = file_exists($phpbb_root_path . $this->get_filename($lang_iso, '', $file, true, true)) ? '* ' : ''; $selected = !$this->language_directory && $this->language_file == $file ? ' selected="selected"' : ''; $s_lang_options .= '<option value="|' . $file . '"' . $selected . '>' . $prefix . $file . '</option>'; } // Help Files $s_lang_options .= '<option value="|common.' . $phpEx . '" class="sep">' . $user->lang['HELP_FILES'] . '</option>'; foreach ($this->main_files as $file) { if (strpos($file, 'help_') !== 0) { continue; } $prefix = file_exists($phpbb_root_path . $this->get_filename($lang_iso, '', $file, true, true)) ? '* ' : ''; $selected = !$this->language_directory && $this->language_file == $file ? ' selected="selected"' : ''; $s_lang_options .= '<option value="|' . $file . '"' . $selected . '>' . $prefix . $file . '</option>'; } // Now every other language directory $check_files = array('email', 'acp', 'mods'); foreach ($check_files as $check) { if (!sizeof(${$check . '_files'})) { continue; } $s_lang_options .= '<option value="|common.' . $phpEx . '" class="sep">' . $user->lang[strtoupper($check) . '_FILES'] . '</option>'; foreach (${$check . '_files'} as $file) { $prefix = file_exists($phpbb_root_path . $this->get_filename($lang_iso, $check, $file, true, true)) ? '* ' : ''; $selected = $this->language_directory == $check && $this->language_file == $file ? ' selected="selected"' : ''; $s_lang_options .= '<option value="' . $check . '|' . $file . '"' . $selected . '>' . $prefix . $file . '</option>'; } } // Get Language Entries - if saved within store folder, we take this one (with the option to remove it) $lang = array(); $is_email_file = $this->language_directory == 'email' ? true : false; $is_help_file = strpos($this->language_file, 'help_') === 0 ? true : false; $file_from_store = file_exists($phpbb_root_path . $this->get_filename($lang_iso, $this->language_directory, $this->language_file, true, true)) ? true : false; $no_store_filename = $this->get_filename($lang_iso, $this->language_directory, $this->language_file); if (!$file_from_store && !file_exists($phpbb_root_path . $no_store_filename)) { $print_message = sprintf($user->lang['MISSING_LANGUAGE_FILE'], $no_store_filename); } else { if ($is_email_file) { $lang = file_get_contents($phpbb_root_path . $this->get_filename($lang_iso, $this->language_directory, $this->language_file, $file_from_store)); } else { $help = array(); include $phpbb_root_path . $this->get_filename($lang_iso, $this->language_directory, $this->language_file, $file_from_store); if ($is_help_file) { $lang = $help; unset($help); } } $print_message = ($this->language_directory ? $this->language_directory . '/' : '') . $this->language_file; } // Normal language pack entries $template->assign_vars(array('U_ENTRY_ACTION' => $this->u_action . "&action=details&id={$lang_id}#entries", 'S_EMAIL_FILE' => $is_email_file, 'S_FROM_STORE' => $file_from_store, 'S_LANG_OPTIONS' => $s_lang_options, 'PRINT_MESSAGE' => $print_message)); if (!$is_email_file) { $method = $is_help_file ? 'print_help_entries' : 'print_language_entries'; $tpl = ''; $name = ($this->language_directory ? $this->language_directory . '/' : '') . $this->language_file; if (isset($missing_vars[$name]) && sizeof($missing_vars[$name])) { $tpl .= $this->{$method}($missing_vars[$name], '* '); } $tpl .= $this->{$method}($lang); $template->assign_var('TPL', $tpl); unset($tpl); } else { $template->assign_vars(array('LANG' => $lang)); unset($lang); } return; break; case 'delete': if (!$lang_id) { trigger_error($user->lang['NO_LANG_ID'] . adm_back_link($this->u_action)); } $sql = 'SELECT * FROM ' . LANG_TABLE . ' WHERE lang_id = ' . $lang_id; $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); if ($row['lang_iso'] == $config['default_lang']) { trigger_error($user->lang['NO_REMOVE_DEFAULT_LANG'] . adm_back_link($this->u_action)); } $db->sql_query('DELETE FROM ' . LANG_TABLE . ' WHERE lang_id = ' . $lang_id); $sql = 'UPDATE ' . USERS_TABLE . " \n\t\t\t\t\tSET user_lang = '{$config['default_lang']}'\n\t\t\t\t\tWHERE user_lang = '{$row['lang_iso']}'"; $db->sql_query($sql); add_log('admin', 'LOG_LANGUAGE_PACK_DELETED', $row['lang_english_name']); trigger_error(sprintf($user->lang['LANGUAGE_PACK_DELETED'], $row['lang_english_name']) . adm_back_link($this->u_action)); break; case 'install': $lang_iso = request_var('iso', ''); $lang_iso = basename($lang_iso); if (!$lang_iso || !file_exists("{$phpbb_root_path}language/{$lang_iso}/iso.txt")) { trigger_error($user->lang['LANGUAGE_PACK_NOT_EXIST'] . adm_back_link($this->u_action)); } $file = file("{$phpbb_root_path}language/{$lang_iso}/iso.txt"); $lang_pack = array('iso' => $lang_iso, 'name' => trim(htmlspecialchars($file[0])), 'local_name' => trim(htmlspecialchars($file[1])), 'author' => trim(htmlspecialchars($file[2]))); unset($file); $sql = 'SELECT lang_iso FROM ' . LANG_TABLE . "\n\t\t\t\t\tWHERE lang_iso = '" . $db->sql_escape($lang_iso) . "'"; $result = $db->sql_query($sql); if ($row = $db->sql_fetchrow($result)) { trigger_error($user->lang['LANGUAGE_PACK_ALREADY_INSTALLED'] . adm_back_link($this->u_action)); } $db->sql_freeresult($result); if (!$lang_pack['name'] || !$lang_pack['local_name']) { trigger_error($user->lang['INVALID_LANGUAGE_PACK'] . adm_back_link($this->u_action)); } // Add language pack $sql_ary = array('lang_iso' => $lang_pack['iso'], 'lang_dir' => $lang_pack['iso'], 'lang_english_name' => $lang_pack['name'], 'lang_local_name' => $lang_pack['local_name'], 'lang_author' => $lang_pack['author']); $db->sql_query('INSERT INTO ' . LANG_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary)); add_log('admin', 'LOG_LANGUAGE_PACK_INSTALLED', $lang_pack['name']); trigger_error(sprintf($user->lang['LANGUAGE_PACK_INSTALLED'], $lang_pack['name']) . adm_back_link($this->u_action)); break; case 'download': if (!$lang_id) { trigger_error($user->lang['NO_LANG_ID'] . adm_back_link($this->u_action)); } $sql = 'SELECT * FROM ' . LANG_TABLE . ' WHERE lang_id = ' . $lang_id; $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); $use_method = request_var('use_method', ''); $methods = array('.tar'); $available_methods = array('.tar.gz' => 'zlib', '.tar.bz2' => 'bz2', '.zip' => 'zlib'); foreach ($available_methods as $type => $module) { if (!@extension_loaded($module)) { continue; } $methods[] = $type; } // Let the user decide in which format he wants to have the pack if (!$use_method) { $this->page_title = 'SELECT_DOWNLOAD_FORMAT'; $radio_buttons = ''; foreach ($methods as $method) { $radio_buttons .= '<input type="radio"' . (!$radio_buttons ? ' id="use_method"' : '') . ' class="radio" value="' . $method . '" name="use_method" /> ' . $method . ' '; } $template->assign_vars(array('S_SELECT_METHOD' => true, 'U_BACK' => $this->u_action, 'U_ACTION' => $this->u_action . "&action={$action}&id={$lang_id}", 'RADIO_BUTTONS' => $radio_buttons)); return; } if (!in_array($use_method, $methods)) { $use_method = '.tar'; } include_once $phpbb_root_path . 'includes/functions_compress.' . $phpEx; if ($use_method == 'zip') { $compress = new compress_zip('w', $phpbb_root_path . 'store/lang_' . $row['lang_iso'] . $use_method); } else { $compress = new compress_tar('w', $phpbb_root_path . 'store/lang_' . $row['lang_iso'] . $use_method, $use_method); } // Get email templates $email_templates = filelist($phpbb_root_path . 'language/' . $row['lang_iso'], 'email', 'txt'); $email_templates = $email_templates['email/']; // Get acp files $acp_files = filelist($phpbb_root_path . 'language/' . $row['lang_iso'], 'acp', $phpEx); $acp_files = $acp_files['acp/']; // Get mod files $mod_files = filelist($phpbb_root_path . 'language/' . $row['lang_iso'], 'mods', $phpEx); $mod_files = isset($mod_files['mods/']) ? $mod_files['mods/'] : array(); // Add main files $this->add_to_archive($compress, $this->main_files, $row['lang_iso']); // Write files in folders $this->add_to_archive($compress, $email_templates, $row['lang_iso'], 'email'); $this->add_to_archive($compress, $acp_files, $row['lang_iso'], 'acp'); $this->add_to_archive($compress, $mod_files, $row['lang_iso'], 'mods'); // Write ISO File $iso_src = html_entity_decode($row['lang_english_name']) . "\n"; $iso_src .= html_entity_decode($row['lang_local_name']) . "\n"; $iso_src .= html_entity_decode($row['lang_author']); $compress->add_data($iso_src, 'language/' . $row['lang_iso'] . '/iso.txt'); // index.html files $compress->add_data('', 'language/' . $row['lang_iso'] . '/index.html'); $compress->add_data('', 'language/' . $row['lang_iso'] . '/email/index.html'); $compress->add_data('', 'language/' . $row['lang_iso'] . '/acp/index.html'); if (sizeof($mod_files)) { $compress->add_data('', 'language/' . $row['lang_iso'] . '/mods/index.html'); } $compress->close(); $compress->download('lang_' . $row['lang_iso']); @unlink($phpbb_root_path . 'store/lang_' . $row['lang_iso'] . '.' . $use_method); exit; break; } $sql = 'SELECT user_lang, COUNT(user_lang) AS lang_count FROM ' . USERS_TABLE . ' GROUP BY user_lang'; $result = $db->sql_query($sql); $lang_count = array(); while ($row = $db->sql_fetchrow($result)) { $lang_count[$row['user_lang']] = $row['lang_count']; } $db->sql_freeresult($result); $sql = 'SELECT * FROM ' . LANG_TABLE; $result = $db->sql_query($sql); $installed = array(); while ($row = $db->sql_fetchrow($result)) { $installed[] = $row['lang_iso']; $tagstyle = $row['lang_iso'] == $config['default_lang'] ? '*' : ''; $template->assign_block_vars('lang', array('U_DETAILS' => $this->u_action . "&action=details&id={$row['lang_id']}", 'U_DOWNLOAD' => $this->u_action . "&action=download&id={$row['lang_id']}", 'U_DELETE' => $this->u_action . "&action=delete&id={$row['lang_id']}", 'ENGLISH_NAME' => $row['lang_english_name'], 'TAG' => $tagstyle, 'LOCAL_NAME' => $row['lang_local_name'], 'ISO' => $row['lang_iso'], 'USED_BY' => isset($lang_count[$row['lang_iso']]) ? $lang_count[$row['lang_iso']] : 0)); } $db->sql_freeresult($result); $new_ary = $iso = array(); $dp = opendir("{$phpbb_root_path}language"); while (($file = readdir($dp)) !== false) { if ($file[0] != '.' && file_exists("{$phpbb_root_path}language/{$file}/iso.txt")) { if (!in_array($file, $installed)) { if ($iso = file("{$phpbb_root_path}language/{$file}/iso.txt")) { if (sizeof($iso) == 3) { $new_ary[$file] = array('iso' => $file, 'name' => trim($iso[0]), 'local_name' => trim($iso[1]), 'author' => trim($iso[2])); } } } } } unset($installed); @closedir($dp); if (sizeof($new_ary)) { foreach ($new_ary as $iso => $lang_ary) { $template->assign_block_vars('notinst', array('ISO' => $lang_ary['iso'], 'LOCAL_NAME' => $lang_ary['local_name'], 'NAME' => $lang_ary['name'], 'U_INSTALL' => $this->u_action . '&action=install&iso=' . urlencode($lang_ary['iso']))); } } unset($new_ary); }
/** * Creates a directory * * This function creates directories recursively, which means that if ancestors of the target directory does not exist, they will be created too. * * @param string $path_string Path of target directory * @return bool TRUE if success. It might return nothing when ftp is used and connection to the ftp address failed. */ public static function makeDir($path_string) { if (self::exists($path_string) !== FALSE) { return TRUE; } if (!ini_get('safe_mode')) { @mkdir($path_string, 0755, TRUE); @chmod($path_string, 0755); } else { static $oFtp = NULL; $ftp_info = Context::getFTPInfo(); if ($oFtp == NULL) { if (!Context::isFTPRegisted()) { return; } $oFtp = new ftp(); if (!$ftp_info->ftp_host) { $ftp_info->ftp_host = "127.0.0.1"; } if (!$ftp_info->ftp_port) { $ftp_info->ftp_port = 21; } if (!$oFtp->ftp_connect($ftp_info->ftp_host, $ftp_info->ftp_port)) { return; } if (!$oFtp->ftp_login($ftp_info->ftp_user, $ftp_info->ftp_password)) { $oFtp->ftp_quit(); return; } } if (!($ftp_path = $ftp_info->ftp_root_path)) { $ftp_path = DIRECTORY_SEPARATOR; } $path_string = str_replace(_XE_PATH_, '', $path_string); $path_list = explode(DIRECTORY_SEPARATOR, $path_string); $path = _XE_PATH_; for ($i = 0, $c = count($path_list); $i < $c; $i++) { if (!$path_list[$i]) { continue; } $path .= $path_list[$i] . DIRECTORY_SEPARATOR; $ftp_path .= $path_list[$i] . DIRECTORY_SEPARATOR; if (!is_dir($path)) { $oFtp->ftp_mkdir($ftp_path); $oFtp->ftp_site("CHMOD 777 " . $ftp_path); } } } return is_dir($path_string); }
function ftp_go() { global $list, $options, $FtpUpload, $FtpBytesTotal, $FtpChunkSize, $FtpTimeStart, $FtpUploadBytesSent, $FtpLastChunkTime, $FtpLast; require_once CLASS_DIR . "ftp.php"; $ftp = new ftp(); if (!$ftp->SetServer($_POST["host"], (int) $_POST["port"])) { $ftp->quit(); printf(lang(79), $_POST["host"] . ":" . $_POST["port"]); echo '<br /><a href="javascript:history.back(-1);">' . lang(78) . '</a><br /><br />'; } else { if (!$ftp->connect()) { $ftp->quit(); echo "<br />"; printf(lang(79), $_POST["host"] . ":" . $_POST["port"]); echo '<br /><a href="javascript:history.back(-1);">' . lang(78) . '</a><br /><br />'; } else { printf(lang(81), 'ftp://' . $_POST['host'] . ':' . $_POST['port']); if (!$ftp->login($_POST["login"], $_POST["password"])) { $ftp->quit(); echo "<br />"; echo lang(80); echo '<br /><a href="javascript:history.back(-1);">' . lang(78) . '</a><br /><br />'; } else { //$ftp->Passive(FALSE); if (!$ftp->chdir($_POST["dir"])) { $ftp->quit(); echo "<br />"; printf(lang(159), $_POST['dir']); echo '<br /><a href="javascript:history.back(-1);">' . lang(78) . '</a><br /><br />'; } else { ?> <br /> <div id="status"></div> <br /> <table cellspacing="0" cellpadding="0"> <tr> <td></td> <td> <div class="progressouter"> <div style="width:298px"> <div id="progress" class="ftpprogress"></div> </div> </div> </td> <td></td> </tr> <tr> <td align="left" id="received">0 KB</td> <td align="center" id="percent">0%</td> <td align="right" id="speed">0 KB/s</td> </tr> </table> <br /> <script type="text/javascript">switchCell(3);</script> <?php for ($i = 0; $i < count($_POST["files"]); $i++) { $file = $list[$_POST["files"][$i]]; echo '<script type="text/javascript">pr(0,0,0);changeStatus(' . "'" . addslashes(basename($file["name"])) . "', '" . $file["size"] . "');</script>"; $FtpUpload = true; $FtpBytesTotal = filesize($file['name']); $FtpChunkSize = round($FtpBytesTotal / 333); $FtpTimeStart = getmicrotime(); $FtpUploadBytesSent = $FtpLastChunkTime = $FtpLast = 0; if ($ftp->put($file["name"], basename($file["name"]))) { $time = round(getmicrotime() - $FtpTimeStart); $speed = @round($FtpBytesTotal / 1024 / $time, 2); echo '<script type="text/javascript">pr(100, ' . "'" . bytesToKbOrMbOrGb($FtpBytesTotal) . "', " . $speed . ")</script>\r\n"; flush(); if (@$_POST["del_ok"] && !$options['disable_deleting']) { if (@unlink($file["name"])) { unset($list[$_POST["files"][$i]]); } } printf(lang(160), '<a href="ftp://' . $_POST["login"] . ':' . $_POST["password"] . '@' . $_POST["host"] . ':' . $_POST["port"] . $_POST["dir"] . (substr($_POST["dir"], -1) != '/' ? '/' : '') . basename($file["name"]) . '"><b>' . basename($file["name"]) . '</b></a>'); echo "<br />" . lang(161) . ": <b>" . sec2time($time) . "</b><br />" . lang(162) . ": <b>" . $speed . " KB/s</b><br /><br />"; } else { printf(lang(163), basename($file['name'])); echo "<br />"; } } $ftp->quit(); } } } } }
$db->query("TRUNCATE TABLE `cc1_groups`"); $db->query("TRUNCATE TABLE `cc1_groups_inhalt`"); $db->query("TRUNCATE TABLE `cc1_messages`"); $db->query("TRUNCATE TABLE `cc1_news`"); $db->query("TRUNCATE TABLE `cc1_new_land`"); $db->query("TRUNCATE TABLE `cc1_sessions`"); $db->query("TRUNCATE TABLE `cc1_spions`"); $db->query("DELETE FROM `cc1_users` WHERE `serveradmin` != 1"); $db->query("UPDATE `cc1_crand` SET `used` = '0'"); all_delete(LITO_ROOT_PATH . 'alli_flag'); all_delete(LITO_ROOT_PATH . 'battle_kr'); all_delete(LITO_ROOT_PATH . 'image_user'); all_delete(LITO_ROOT_PATH . 'image_sig'); all_delete(LITO_ROOT_PATH . 'images_tmp'); include_once LITO_ROOT_PATH . "acp/includes/ftp_class.php"; $ftp = new ftp($ftphost, $ftpuser, $ftppassword, $ftproot, $ftpport); if (!$ftp->lito_root) { error_msg('Stellen sie sicher, dass ihre FTP Daten richtig sind!'); exit; } $ftp->mk_dir('alli_flag'); $ftp->mk_dir('battle_kr'); $ftp->mk_dir('image_user'); $ftp->mk_dir('image_sig'); $ftp->mk_dir('images_tmp'); $ftp->chown_perm(0777, "alli_flag"); $ftp->chown_perm(0777, "battle_kr"); $ftp->chown_perm(0777, "image_user"); $ftp->chown_perm(0777, "images_sig"); $ftp->chown_perm(0777, "images_tmp"); $ftp->disconnect();
if (!preg_match('!^[a-z_\\-]*$!', $_GET['new'])) { error_msg('Der neue Name darf nur Buchstaben (a-z), Unterstriche (_) und Minus (-) enthalten!'); exit; } $nstd_q = $db->query("SELECT * FROM `cc" . $n . "_desigs` WHERE `design_id` = '" . $id . "'"); if (!$db->num_rows($nstd_q)) { error_msg('Das Template wurde nicht in der Datenbank gefunden!'); exit; } $cp_q = $db->query("SELECT * FROM `cc" . $n . "_desigs` WHERE `design_name` = '" . $_GET['new'] . "'"); if ($db->num_rows($cp_q)) { error_msg('Das Zieltemplate ist bereits in der Datenbank!'); exit; } $nstd = $db->fetch_array($nstd_q); $ftp = new ftp($ftphost, $ftpuser, $ftppassword, $ftproot, $ftpport); if (!$ftp->lito_root) { error_msg('FTP Daten scheinen nicht zu stimmen!'); exit; } if (!$ftp->exists('themes/' . $nstd['design_name'])) { error_msg('Die Daten des Quell Templates konnten nicht auf dem Server gefunden werden!'); exit; } if (!$ftp->exists('images/' . $nstd['design_name'])) { error_msg('Die Daten des Quell Templates konnten nicht auf dem Server gefunden werden!'); exit; } if (!$ftp->exists('css/' . $nstd['design_name'])) { error_msg('Die Daten des Quell Templates konnten nicht auf dem Server gefunden werden!'); exit;
function getftpurl($host, $port, $url, $saveToFile = 0) { global $nn, $lastError, $PHP_SELF, $FtpBytesTotal, $FtpBytesReceived, $FtpTimeStart, $FtpChunkSize, $options, $L; $ftp = new ftp(FALSE, FALSE); $server = "{$host}:{$port}"; if (empty($host) || empty($port) || !$ftp->SetServer($host, (int) $port)) { $ftp->quit(); $lastError = $L->sprintf($L->say['couldnt_establish_con'], $server) . "<br />" . '<a href="javascript:history.back(-1);">' . $L->say['_back'] . '</a><br /><br />'; return FALSE; } else { if (!$ftp->connect()) { $ftp->quit(); $lastError = $L->sprintf($L->say['couldnt_establish_con'], $server) . "<br />" . '<a href="javascript:history.back(-1);">' . $L->say['_back'] . '</a><br /><br />'; return FALSE; } else { if (!$ftp->login()) { $ftp->quit(); $lastError = $L->say['incorrect_userpass'] . "<br />" . '<a href="javascript:history.back(-1);">' . $L->say['_back'] . '</a><br /><br />'; return FALSE; } else { echo '<p>'; $L->sprintf($L->say['_con'], $host); echo '<br />'; //$ftp->Passive(FALSE); $tmp = explode("/", $url); $ftp_file = array_pop($tmp); $ftp_dir = implode("/", $tmp); $ftp->chdir($ftp_dir); $fileSize = $FtpBytesTotal = $ftp->filesize($ftp_file); $FtpChunkSize = round($fileSize / 333); if (strpos($saveToFile, '?') !== false) { $saveToFile = substr($saveToFile, 0, strpos($saveToFile, '?')); } if ($options['maxlimitsize'] > 0) { if ($fileSize > $options['maxlimitsize'] * 1024 * 1024) { $lastError = $L->sprintf($L->say['_sorry_tobig'], bytesToKbOrMbOrGb($fileSize), $options["maxlimitsize"]); return false; } } if ($options['minlimitsize'] > 0) { if ($fileSize < $options['minlimitsize'] * 1024 * 1024) { $lastError = $L->sprintf($L->say['_sorry_tosmall'], bytesToKbOrMbOrGb($fileSize), $options["minlimitsize"]); return false; } } if (!empty($options["add_ext_5city"]) || !empty($options['rename_suffix']) || !empty($options['rename_prefix']) || $options['rename_underscore']) { if (!empty($options["add_ext_5city"])) { $ext = str_replace(".", "", $options["add_ext_5city"]); $File_Name = basename($saveToFile) . "." . $options["add_ext_5city"]; } if (!empty($options['rename_prefix'])) { $File_Name = $options['rename_prefix'] . '_' . basename($saveToFile); } if (!empty($options['rename_suffix'])) { $ext = strrchr(basename($saveToFile), "."); $before_ext = explode($ext, basename($saveToFile)); $File_Name = $before_ext[0] . '_' . $options['rename_suffix'] . $ext; } if ($options['rename_underscore']) { $File_Name = str_replace(array(' ', '%20'), '_', basename($saveToFile)); } $saveToFile = dirname($saveToFile) . PATH_SPLITTER . $File_Name; } $filetype = strrchr($saveToFile, "."); if (is_array($options['forbidden_filetypes']) && in_array(strtolower($filetype), $options['forbidden_filetypes'])) { if ($options['forbidden_filetypes_block']) { html_error($L->sprintf($L->say['_forbid_filetype'], $filetype)); } else { $saveToFile = str_replace($filetype, $options['rename_these_filetypes_to'], $saveToFile); } } if (file_exists($saveToFile)) { $saveToFile = dirname($saveToFile) . PATH_SPLITTER . time() . "_" . basename($saveToFile); } if (!empty($options["add_ext_5city"])) { $ext = "." . get_extension(basename($saveToFile)); $File_Name = str_replace($ext, "", basename($saveToFile)); } echo $L->sprintf($L->say['_saveprogres'], $saveToFile, $ext, bytesToKbOrMbOrGb($fileSize)) . "<br />"; require_once TEMPLATE_DIR . 'transloadui.php'; $FtpTimeStart = getmicrotime(); if ($ftp->get($ftp_file, $saveToFile)) { $ftp->quit(); $time = getmicrotime() - $FtpTimeStart; return array('time' => sec2time(round($time)), 'speed' => @round($FtpBytesTotal / 1024 / $time, 2), 'received' => TRUE, 'size' => bytesToKbOrMbOrGb($fileSize), 'bytesReceived' => $FtpBytesReceived, 'bytesTotal' => $FtpBytesTotal, 'file' => $saveToFile); } $ftp->quit(); return FALSE; } } } }
/** * Handles uploading processes of the migration * * @param array $files Files to upload * @param string $ftp_password FTP Password * @return bool TRUE on success, FALSE on failure */ function upload_files($files, $ftp_password) { // Load plugin settings $wpmove_options = $this->get_admin_options(); // Instantiate the FTP class $ftp = new ftp(); // Enter Passive Mode if enabled if ($wpmove_options['ftp_passive_mode']) { $ftp->Passive(TRUE); } echo '<span class="code">'; printf(__('Connecting to %s:%d...', 'WPMove'), $wpmove_options['ftp_hostname'], $wpmove_options['ftp_port']); $this->flush_output(); // Set the hostname and the port $ftp->SetServer($wpmove_options['ftp_hostname'], intval($wpmove_options['ftp_port'])); // Try connecting to the server if ($ftp->connect()) { echo ' <strong>' . __('Success!', 'WPMove') . '</strong><br>'; $this->flush_output(); // Display a different message if no password is given if ('' !== $ftp_password) { printf(__('Logging in as %s using password...', 'WPMove'), $wpmove_options['ftp_username']); } else { printf(__('Logging in as %s without a password...', 'WPMove'), $wpmove_options['ftp_username']); } $this->flush_output(); // Login to the server using the supplied credentials if ($ftp->login($wpmove_options['ftp_username'], $ftp_password)) { echo ' <strong>' . __('Success!', 'WPMove') . '</strong><br>' . __('Starting uploading files...', 'WPMove') . '<br>'; $this->flush_output(); // Changes the present working directory to the backup directory on the remote server $ftp->chdir($wpmove_options['ftp_remote_path']); // Start counting errors during the file upload $error_count = 0; // Upload the given backup files under the backup folder to the server foreach ($files as $file) { printf(__('%s is being uploaded...', 'WPMove'), basename($file)); $this->flush_output(); if (FALSE !== $ftp->put(trailingslashit(WPMOVE_BACKUP_DIR) . $file, basename($file))) { echo '<strong>' . __(' Success!', 'WPMove') . '</strong><br>'; } else { echo '<strong>' . __(' Failed!', 'WPMove') . '</strong><br>'; $error_count++; } $this->flush_output(); } // Notify the user about the errors occured if ($error_count) { printf(_n('Uploading files is completed with %d error...', 'Uploading files is completed with %d errors...', $error_count, 'WPMove'), $error_count); } else { _e('Uploading files is completed without an error...', 'WPMove'); } $this->flush_output(); echo '<br>'; _e('Closing the FTP connection...', 'WPMove'); echo '</span><br>'; // Close the connection $ftp->quit(); // Return TRUE on success return TRUE; } // Close the connection $ftp->quit(); } echo ' <strong>' . __(' Failed!', 'WPMove') . '</strong><br>' . __('Operation terminated...', 'WPMove') . '</span><br>'; // If it reaches here, apparently it failed return FALSE; }
function ampps_ftp($host, $port, $username, $pass, $cd = false, $pub = '', $pri = '', $passphrase = '') { global $settings; if ($settings['protocol'] == 'sftp' && !class_exists('sftp')) { include_once '_' . $settings['protocol'] . '.php'; } elseif ($settings['protocol'] == 'ftps' && !class_exists('ftps')) { include_once '_' . $settings['protocol'] . '.php'; } elseif ($settings['protocol'] == 'ftp' && !class_exists('ftp_base')) { include_once '_' . $settings['protocol'] . '.php'; } elseif ($settings['protocol'] == 'customio' && !class_exists('CustomIO')) { include_once '_' . $settings['protocol'] . '.php'; } if ($settings['protocol'] == 'ftp') { $ftp = new ftp(FALSE, FALSE); if (!$ftp->SetServer($host)) { $ftp->quit(); return 0; } if (!$ftp->connect()) { return -1; } if (!$ftp->login($username, $pass)) { $ftp->quit(); return -2; } if (!empty($cd)) { if (!$ftp->chdir($cd)) { if (!$ftp->chdir(trim($cd, '/'))) { return -3; } //return -3; } } if (!$ftp->SetType(FTP_AUTOASCII)) { } if (!$ftp->Passive(TRUE)) { } } if ($settings['protocol'] == 'sftp' || $settings['protocol'] == 'ftps' || $settings['protocol'] == 'customio') { if ($settings['protocol'] == 'customio') { $ftp = new CustomIO(); } else { $ftp = new $settings['protocol'](); } if ($settings['protocol'] == 'sftp' && !empty($pub) && !empty($pri)) { $ftp->auth_pass = 0; } else { $ftp->auth_pass = 1; } $ret = $ftp->connect($host, $port, $username, $pass, $pub, $pri, $passphrase); if (!is_object($ftp)) { return -1; } if (!$ret) { return -2; } /* if($settings['protocol'] == 'sftp' && (!$ret)){ return -2; } if(($settings['protocol'] == 'ftps' || $settings['protocol'] == 'customio') && !$ftp->ftp_conn){ return -2; } */ if (!empty($cd)) { if (!$ftp->is_dir($cd)) { return -3; } } } return $ftp; }
/** * ajax删除图片 */ public function ajax_delpic() { $model = D('Pic'); $data['source'] = CONTROLLER_NAME; $data['picid'] = $_POST['pid']; $vo = $model->field('domain,filepath,thumb')->where($data)->find(); //dump($vo);exit; //include "../../Ftp.php"; //是否开启FTP删除 if (false) { import('@.ORG.Ftp'); $ftphost = $_SCONFIG['ftphost']; $ftpport = $_SCONFIG['ftpport']; $ftpuser = $_SCONFIG['ftpuser']; $ftppassword = $_SCONFIG['ftppassword']; $ftp = new ftp($ftphost, $ftpport, $ftpuser, $ftppassword); // 打开FTP连接 $dir = $_FTP[$vo['domain']] . '/' . $vo['filepath']; //删除远程文件 $ftp->del_file($dir); } else { //$dir = $_NFTP[$vo['domain']].'/'.$vo['filepath']; $dir = C('IMG_ROOT') . $vo['filepath']; unlink($dir); if ($vo['thumb']) { $thumbs = explode(',', $vo['thumb']); foreach ($thumbs as $thumb) { $thumb_dir = C('IMG_ROOT') . get_thumb($vo['filepath'], str_ireplace("_", "", $thumb)); //echo $thumb_dir;exit; unlink($thumb_dir); } } } $url = $vo['domain'] . $vo['filepath']; $result = $model->where($data)->delete(); //dump($result);exit; /* if(!$fp=@fopen($url,"r")){ //echo iconv("GBK", "UTF-8", "远程文件不存在!"); }else{ echo "文件删除失败"; exit; } */ if ($result) { $this->history($_POST['pid'], 'deletepic'); $msg['error_code'] = 0; $msg['notice'] = '删除成功'; echo json_encode($msg); exit; } else { $msg['error_code'] = 8002; $msg['notice'] = '删除失败'; echo json_encode($msg); exit; } exit; }
echo '<h2>เริ่มต้นการปรับรุ่น GCMS เวอร์ชั่น ' . $version . '</h2>'; echo '<p>ตัวปรับรุ่นจะดำเนินการปรับปรุงฐานข้อมูล(เวอร์ชั่น <strong>4.5.0</strong> ขึ้นไปเท่านั้น) และแฟ้มระบบที่จำเป็น คุณควรสำรองฐานข้อมูลทั้งหมดของคุณก่อนเริ่มดำเนินการปรับรุ่น</p>'; echo '<p>โปรแกรมจะทำการอัปเกรดให้เฉพาะส่วนที่เป็นแกน (core) ของ GCMS เท่านั้น โมดูลที่ติดตั้งเพิ่มเติมในภายหลังไม่ได้ถูกอัปเกรดไปด้วย คุณอาจจะต้องดำเนินการอัปเกรดโมดูลอื่นๆที่ไม่ใช่โมดูลมาตรฐานของ GCMS ด้วยตัวเอง</p>'; echo '<p>คุณอาจต้องการ "ติดตั้งใหม่" ถ้าคุณต้องการเริ่มต้นการติดตั้ง GCMS ใหม่แบบสะอาดหมดจด หรือหากการปรับรุ่นไม่สามารถดำเนินการได้ ซึ่งจะมีผลให้ข้อมูลทั้งหมดของคุณสูญหายไปด้วย</p>'; // ตรวจสอบไฟ์ลและโฟลเดอร์ echo '<h3>ตรวจสอบองค์ประกอบต่างๆ ที่จำเป็นสำหรับการติดตั้ง</h3>'; echo '<ol>'; if (isset($_POST['ftp_host'])) { // connect ftp $_SESSION['ftp_host'] = trim($_POST['ftp_host']); $_SESSION['ftp_username'] = trim($_POST['ftp_username']); $_SESSION['ftp_password'] = trim($_POST['ftp_password']); $_SESSION['ftp_root'] = trim($_POST['ftp_root']); $ftp_port = trim(gcms::getVars($_POST, 'ftp_port', '')); $_SESSION['ftp_port'] = $ftp_port = '' ? 21 : $ftp_port; $ftp = new ftp($_SESSION['ftp_host'], $_SESSION['ftp_username'], $_SESSION['ftp_password'], $_SESSION['ftp_root'], $_SESSION['ftp_port']); } if (!empty($_SESSION['ftp_username']) && !empty($_SESSION['ftp_password'])) { if ($ftp->connect()) { if ($ftp->is_dir($_SESSION['ftp_root'])) { echo '<li class=correct><strong>FTP</strong> <i>เชื่อมต่อสำเร็จ</i></li>'; } else { echo '<li class=incorrect><strong>FTP Root</strong> <em>ไม่ถูกต้อง</em> กรุณาตรวจสอบจากโฮสต์ของคุณ</li>'; } } else { echo '<li class=incorrect><strong>FTP</strong> <em>ไม่สามารถใช้งานได้</em></li>'; } } if (is_dir(DATA_PATH)) { echo '<li>ตรวจสอบโฟลเดอร์ <strong>' . DATA_FOLDER . '</strong></li>'; ob_flush();