/** * getInstance * * @return HTTP|FTP */ public static function getInstance() { if (self::$_instance === null) { if (Config::get('Gmanager', 'mode') === 'FTP') { self::$_instance = new FTP(Config::get('FTP', 'user'), Config::get('FTP', 'pass'), Config::get('FTP', 'host'), Config::get('FTP', 'port')); } else { self::$_instance = new HTTP(); } } return self::$_instance; }
/** * setConfig * * @param string $config */ public static function setConfig($config) { self::$_config = new Config_Ini($config); Registry::set('top', '<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="vi"> <head><title>Quản lí - Gmanager 0.8.1 beta</title> <meta http-equiv="Content-Type" content="' . self::getContentType() . '; charset=UTF-8" /> <link rel="stylesheet" type="text/css" href="vtr/style.css"/> <script type="text/javascript" src="js.js"></script> <script type="text/javascript" src="data/js.source.js"></script></head><body> <div class="header" align="center"><a href="index.php"><h1>LPanel 2.1</h1></a> <p align="left"><img src="vtr/img/pma.png" alt=""/> <a href="pma/">P.M.A</a> | <img src="vtr/icon/SQL.png" alt=""/> <a href="pma/saoluu.php">S.Lưu</a> | <img src="vtr/img/cpanel.png" alt=""/> <a href="index.php?set">C.đặt</a> | <img src="vtr/img/exit.png" alt=""/> <a href="index.php?exit">Thoát</a></p></div> '); Registry::set('foot', '<div class="header" align="center"> <div align="left"> <img src="vtr/img/pma.png" alt=""/> <a href="pma/">P.M.A</a> | <img src="vtr/icon/SQL.png" alt=""/> <a href="pma/saoluu.php">S.Lưu</a> | <img src="vtr/img/cpanel.png" alt=""/> <a href="index.php?set">C.đặt</a> | <img src="vtr/img/exit.png" alt=""/> <a href="index.php?exit">Thoát</a> </div> <h2><a href="index.php?info">V2.1 - Tmc</a></h2> </div></body></html>'); Language::setLanguage(self::get('Gmanager', 'language')); define('PCLZIP_TEMPORARY_DIR', self::getTemp() . '/'); define('GMANAGER_REQUEST_TIME', time()); mb_internal_encoding('UTF-8'); setlocale(LC_ALL, self::get('PHP', 'locale')); date_default_timezone_set(self::get('PHP', 'timeZone')); @set_time_limit(self::get('PHP', 'timeLimit')); ini_set('max_execution_time', self::get('PHP', 'timeLimit')); ini_set('memory_limit', self::get('PHP', 'memoryLimit')); ini_set('error_prepend_string', '<div class="red">'); ini_set('error_append_string', '</div><div class="rb"><br/></div>' . Registry::get('foot')); ini_set('error_log', Errors::getTraceFile()); set_error_handler('Errors::errorHandler'); if (self::get('Auth', 'enable')) { Auth::main(); } Gmanager::getInstance()->init(); }
/** * setConfig * * @param string $config */ public static function setConfig($config) { self::$_config = new Config_Ini($config); Registry::set('top', '<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ru"><head><title>%title% - Gmanager 0.8.1 beta</title><meta http-equiv="Content-Type" content="' . self::getContentType() . '; charset=UTF-8" /><link rel="stylesheet" type="text/css" href="public/style.min.css"/><script type="text/javascript" src="public/script.min.js"></script></head><body>'); Registry::set('foot', '<div class="w">Powered by Gemorroj<br/><a href="http://wapinet.ru/gmanager/">wapinet.ru</a></div></body></html>'); Language::setLanguage(self::get('Gmanager', 'language')); define('PCLZIP_TEMPORARY_DIR', self::getTemp() . '/'); define('GMANAGER_REQUEST_TIME', time()); mb_internal_encoding('UTF-8'); setlocale(LC_ALL, self::get('PHP', 'locale')); date_default_timezone_set(self::get('PHP', 'timeZone')); @set_time_limit(self::get('PHP', 'timeLimit')); ini_set('max_execution_time', self::get('PHP', 'timeLimit')); ini_set('memory_limit', self::get('PHP', 'memoryLimit')); ini_set('error_log', Errors::getTraceFile()); ini_set('error_prepend_string', '<div class="red">'); ini_set('error_append_string', '</div><div class="rb"><br/></div>' . Registry::get('foot')); Errors::initHandler(); if (self::get('Auth', 'enable')) { Auth::main(); } Gmanager::getInstance()->init(); }
/** * Backup * * @param string $host * @param string $name * @param string $pass * @param string $db * @param string $charset * @param array $tables * @return mixed */ public function backup($host = null, $name = null, $pass = null, $db = '', $charset = null, $tables = array()) { $connect = $this->_connect($host, $name, $pass, $db, $charset); if (is_object($connect)) { $this->_resource = $connect; } else { return $connect; } $true = $false = ''; if ($tables) { if ($tables['tables']) { foreach ($tables['tables'] as $f) { $q = $this->_resource->query('SHOW CREATE TABLE `' . str_replace('`', '``', $f) . '`;'); if ($q) { $tmp = $q->fetch_row(); $true .= $tmp[1] . ";\n\n"; } else { $false .= $this->_resource->error . "\n"; } } } if ($tables['data']) { foreach ($tables['data'] as $f) { $q = $this->_resource->query('SELECT * FROM `' . str_replace('`', '``', $f) . '`;'); if ($q) { if ($q->num_rows) { $true .= 'INSERT INTO `' . str_replace('`', '``', $f) . '` VALUES'; while ($row = $q->fetch_row()) { $true .= "\n("; foreach ($row as $v) { $true .= $v === null ? 'NULL,' : "'" . str_replace("'", "''", $v) . "',"; } $true = rtrim($true, ',') . '),'; } $true = rtrim($true, ',') . ";\n\n"; } } else { $false .= $this->_resource->error . "\n"; } } } if ($true) { $dir = dirname($tables['file']); if (!Gmanager::getInstance()->is_dir($dir)) { Gmanager::getInstance()->mkdir($dir); } if (!Gmanager::getInstance()->file_put_contents($tables['file'], $true)) { $false .= Errors::get() . "\n"; } } if ($false) { return Helper_View::message(Language::get('sql_backup_false') . '<pre>' . trim($false) . '</pre>', Helper_View::MESSAGE_ERROR); } else { return Helper_View::message(Language::get('sql_backup_true'), Helper_View::MESSAGE_SUCCESS); } } else { $q = $this->_resource->query('SHOW TABLES;'); if ($q) { while ($row = $q->fetch_row()) { $true .= '<option value="' . rawurlencode($row[0]) . '">' . htmlspecialchars($row[0], ENT_NOQUOTES) . '</option>'; } return $true; } } return false; }
/** * renameFile * * @param string $name * @param string $arch_name * @param bool $del * @param bool $overwrite * @return string */ public function renameFile($name, $arch_name, $del = false, $overwrite = false) { $tmp = Config::getTemp() . '/GmanagerZip' . GMANAGER_REQUEST_TIME; $zip = $this->_open(); $folder = ''; $sysName = IOWrapper::set($name); foreach ($zip->extract(PCLZIP_OPT_PATH, $tmp) as $f) { if ($f['status'] != 'ok') { Helper_System::clean($tmp); if (Config::get('Gmanager', 'mode') == 'FTP') { Gmanager::getInstance()->ftpArchiveEnd(); } return Helper_View::message(Language::get('extract_false'), Helper_View::MESSAGE_ERROR); break; } if ($arch_name == $f['stored_filename']) { $folder = $f['folder']; } } if (file_exists($tmp . '/' . $sysName)) { if ($overwrite) { if ($folder) { Helper_System::clean($tmp . '/' . $sysName); } else { unlink($tmp . '/' . $sysName); } } else { Helper_System::clean($tmp); if (Config::get('Gmanager', 'mode') == 'FTP') { Gmanager::getInstance()->ftpArchiveEnd(); } return Helper_View::message(Language::get('overwrite_false'), Helper_View::MESSAGE_ERROR); } } if ($folder) { @mkdir($tmp . '/' . $sysName, 0755, true); } elseif (!is_dir($tmp . '/' . dirname($sysName))) { @mkdir($tmp . '/' . dirname($sysName), 0755, true); } if ($folder) { // переделать на ftp if ($del) { $result = Gmanager::getInstance()->moveFiles($tmp . '/' . $arch_name, $tmp . '/' . $name); } else { $result = Gmanager::getInstance()->copyFiles($tmp . '/' . $arch_name, $tmp . '/' . $name); } } else { if ($del) { $result = rename($tmp . '/' . $arch_name, $tmp . '/' . $sysName); } else { $result = copy($tmp . '/' . $arch_name, $tmp . '/' . $sysName); } } if (!$result) { Helper_System::clean($tmp); if (Config::get('Gmanager', 'mode') == 'FTP') { Gmanager::getInstance()->ftpArchiveEnd(); } if ($folder) { if ($del) { return Helper_View::message(str_replace('%title%', htmlspecialchars($arch_name, ENT_NOQUOTES), Language::get('move_files_false')), Helper_View::MESSAGE_ERROR); } else { return Helper_View::message(str_replace('%title%', htmlspecialchars($arch_name, ENT_NOQUOTES), Language::get('copy_files_false')), Helper_View::MESSAGE_ERROR); } } else { if ($del) { return Helper_View::message(str_replace('%file%', htmlspecialchars($arch_name, ENT_NOQUOTES), Language::get('move_file_false')), Helper_View::MESSAGE_ERROR); } else { return Helper_View::message(str_replace('%file%', htmlspecialchars($arch_name, ENT_NOQUOTES), Language::get('copy_file_false')), Helper_View::MESSAGE_ERROR); } } } $result = $zip->create($tmp, PCLZIP_OPT_REMOVE_PATH, mb_substr($tmp, mb_strlen(dirname(dirname($tmp))))) != 0; Helper_System::clean($tmp); if (Config::get('Gmanager', 'mode') == 'FTP') { Gmanager::getInstance()->ftpArchiveEnd($this->_name); } if ($result) { if ($folder) { if ($del) { return Helper_View::message(str_replace('%title%', htmlspecialchars($arch_name, ENT_NOQUOTES), Language::get('move_files_true')), Helper_View::MESSAGE_SUCCESS); } else { return Helper_View::message(str_replace('%title%', htmlspecialchars($arch_name, ENT_NOQUOTES), Language::get('copy_files_true')), Helper_View::MESSAGE_SUCCESS); } } else { if ($del) { return Helper_View::message(str_replace('%file%', htmlspecialchars($arch_name, ENT_NOQUOTES), Language::get('move_file_true')), Helper_View::MESSAGE_SUCCESS); } else { return Helper_View::message(str_replace('%file%', htmlspecialchars($arch_name, ENT_NOQUOTES), Language::get('copy_file_true')), Helper_View::MESSAGE_SUCCESS); } } } else { if ($folder) { if ($del) { return Helper_View::message(str_replace('%title%', htmlspecialchars($arch_name, ENT_NOQUOTES), Language::get('move_files_false')), Helper_View::MESSAGE_ERROR); } else { return Helper_View::message(str_replace('%title%', htmlspecialchars($arch_name, ENT_NOQUOTES), Language::get('copy_files_false')), Helper_View::MESSAGE_ERROR); } } else { if ($del) { return Helper_View::message(str_replace('%file%', htmlspecialchars($arch_name, ENT_NOQUOTES), Language::get('move_file_false')), Helper_View::MESSAGE_ERROR); } else { return Helper_View::message(str_replace('%file%', htmlspecialchars($arch_name, ENT_NOQUOTES), Language::get('copy_file_false')), Helper_View::MESSAGE_ERROR); } } } }
/** * Backup * * @param string $host * @param string $name * @param string $pass * @param string $db * @param string $charset * @param array $tables * @return string|bool */ public function backup($host = null, $name = null, $pass = null, $db = '', $charset = null, $tables = array()) { $connect = $this->_connect($host, $name, $pass, $db, $charset); if ($connect instanceof PDO) { $this->_resource = $connect; } else { return $connect; } $true = $false = ''; if ($tables) { if ($tables['tables']) { foreach ($tables['tables'] as $f) { $out = array(); exec(escapeshellcmd(Config::get('Postgres', 'path')) . ' -U ' . escapeshellarg($name) . ' -F p -b -s -t ' . escapeshellarg($f) . ' ' . escapeshellarg($db), $out); if ($out) { $true .= implode("\n", $out); } else { $false .= Language::get('sql_schema_error') . htmlspecialchars($f, ENT_NOQUOTES) . "\n"; } } } if ($tables['data']) { foreach ($tables['data'] as $f) { $q = $this->_resource->query('SELECT * FROM ' . str_replace(array('"', "'"), array('""', "''"), $f) . ';'); if ($q) { if ($q->columnCount()) { $true .= 'INSERT INTO ' . str_replace(array('"', "'"), array('""', "''"), $f) . ' VALUES'; while ($row = $q->fetch(PDO::FETCH_NUM)) { $true .= "\n("; foreach ($row as $v) { $true .= $v === null ? 'NULL,' : "'" . str_replace("'", "''", $v) . "',"; } $true = rtrim($true, ',') . '),'; } $true = rtrim($true, ',') . ";\n\n"; } } else { $tmp = $this->_resource->errorInfo(); $false .= $tmp[2] . "\n"; } } } if ($true) { $dir = dirname($tables['file']); if (!Gmanager::getInstance()->is_dir($dir)) { Gmanager::getInstance()->mkdir($dir, null, true); } if (!Gmanager::getInstance()->file_put_contents($tables['file'], $true)) { $false .= Errors::get() . "\n"; } } if ($false) { return Helper_View::message(Language::get('sql_backup_false') . '<pre>' . trim($false) . '</pre>', Helper_View::MESSAGE_ERROR); } else { return Helper_View::message(Language::get('sql_backup_true'), Helper_View::MESSAGE_SUCCESS); } } else { $q = $this->_resource->query('SELECT * FROM information_schema.tables;'); if ($q) { while ($row = $q->fetch(PDO::FETCH_ASSOC)) { $true .= '<option value="' . rawurlencode($row['table_name']) . '">' . htmlspecialchars($row['table_name'], ENT_NOQUOTES) . '</option>'; } return $true; } } return false; }
/** * Backup * * @param string $host (not used) * @param string $name (not used) * @param string $pass (not used) * @param string $db * @param string $charset (not used) * @param array $tables * @return string|bool */ public function backup($host = null, $name = null, $pass = null, $db = '', $charset = null, $tables = array()) { $connect = $this->_connect($db); if ($connect instanceof PDO) { $this->_resource = $connect; } else { return $connect; } $true = $false = ''; if ($tables) { if ($tables['tables']) { foreach ($tables['tables'] as $f) { $q = $this->_resource->query('PRAGMA table_info(`' . str_replace('`', '``', $f) . '`);'); if ($q) { $true .= 'CREATE TABLE `' . str_replace('`', '``', $f) . '` (' . "\n"; foreach ($q->fetchAll(PDO::FETCH_ASSOC) as $v) { $true .= ' ' . $v['name'] . ' ' . $v['type'] . ($v['notnull'] ? ' NOT NULL' : '') . ' DEFAULT ' . ($v['dflt_value'] === null || $v['dflt_value'] == 'NULL' ? 'NULL' : '"' . $v['dflt_value'] . '"') . ($v['pk'] ? ' PRIMARY KEY' : '') . ",\n"; } $true = trim($true, ",\n") . "\n" . ');' . "\n\n"; } else { $tmp = $this->_resource->errorInfo(); $false .= $tmp[2] . "\n"; } } } if ($tables['data']) { foreach ($tables['data'] as $f) { $q = $this->_resource->query('SELECT * FROM `' . str_replace('`', '``', $f) . '`;'); if ($q) { if ($q->columnCount()) { $true .= 'INSERT INTO `' . str_replace('`', '``', $f) . '` VALUES'; while ($row = $q->fetch(PDO::FETCH_NUM)) { $true .= "\n("; foreach ($row as $v) { $true .= $v === null ? 'NULL,' : "'" . str_replace("'", "''", $v) . "',"; } $true = rtrim($true, ',') . '),'; } $true = rtrim($true, ',') . ";\n\n"; } } else { $tmp = $this->_resource->errorInfo(); $false .= $tmp[2] . "\n"; } } } if ($true) { $dir = dirname($tables['file']); if (!Gmanager::getInstance()->is_dir($dir)) { Gmanager::getInstance()->mkdir($dir, null, true); } if (!Gmanager::getInstance()->file_put_contents($tables['file'], $true)) { $false .= Errors::get() . "\n"; } } if ($false) { return Helper_View::message(Language::get('sql_backup_false') . '<pre>' . htmlspecialchars(trim($false), ENT_NOQUOTES) . '</pre>', Helper_View::MESSAGE_ERROR); } else { return Helper_View::message(Language::get('sql_backup_true'), Helper_View::MESSAGE_SUCCESS); } } else { $q = $this->_resource->query('SELECT name FROM sqlite_master WHERE type = "table" ORDER BY name;'); if ($q) { while ($row = $q->fetch(PDO::FETCH_NUM)) { $true .= '<option value="' . rawurlencode($row[0]) . '">' . htmlspecialchars($row[0], ENT_NOQUOTES) . '</option>'; } return $true; } } return false; }
if ($archive && $archive != Archive::FORMAT_GZ) { $obj = new Archive(); $factory = $obj->setFormat($archive)->setFile(Registry::get('current'))->factory(); if ($if) { echo $factory->lookFile($_GET['f']); } else { echo $factory->listArchive($idown); $f = 1; } } elseif ($archive == Archive::FORMAT_GZ) { echo Gmanager::getInstance()->gz(Registry::get('current')) . '<div class="ch"><form action="?gmanager_action=change&c=' . Registry::get('rCurrent') . '&go=1" method="post"><div><input type="submit" name="gz_extract" value="' . Language::get('extract_archive') . '"/></div></form></div>'; $if = true; } else { echo Gmanager::getInstance()->look(Registry::get('current'), $itype, $idown); } if (Gmanager::getInstance()->file_exists(Registry::get('current')) || Registry::get('currentType') == 'link') { if ($archive) { $d = Helper_View::getRawurl(dirname(Registry::get('current'))); $found = '<div class="rb">' . Language::get('create') . ' <a href="?gmanager_action=change&go=create_file&c=' . $d . '">' . Language::get('file') . '</a> / <a href="?gmanager_action=change&go=create_dir&c=' . $d . '">' . Language::get('dir') . '</a><br/></div><div class="rb"><a href="?gmanager_action=change&go=upload&c=' . $d . '">' . Language::get('upload') . '</a><br/></div><div class="rb"><a href="?gmanager_action=change&go=mod&c=' . $d . '">' . Language::get('mod') . '</a><br/></div>'; } else { $found = '<form action="?' . htmlspecialchars($_SERVER['QUERY_STRING'], ENT_COMPAT, 'UTF-8') . '" method="post"><div><input name="limit" value="' . Registry::get('limit') . '" type="text" onkeypress="return Gmanager.number(event)" class="pinput"/><input type="submit" value="' . Language::get('limit') . '"/></div></form><div class="rb">' . Language::get('create') . ' <a href="?gmanager_action=change&go=create_file&c=' . Registry::get('rCurrent') . '">' . Language::get('file') . '</a> / <a href="?gmanager_action=change&go=create_dir&c=' . Registry::get('rCurrent') . '">' . Language::get('dir') . '</a><br/></div><div class="rb"><a href="?gmanager_action=change&go=upload&c=' . Registry::get('rCurrent') . '">' . Language::get('upload') . '</a><br/></div><div class="rb"><a href="?gmanager_action=change&go=mod&c=' . Registry::get('rCurrent') . '">' . Language::get('mod') . '</a><br/></div>'; } } else { $found = '<div class="red">' . Language::get('file_not_found') . '(' . Registry::get('hCurrent') . ')' . '<br/></div>'; } $tm = '<div class="rb">' . round(microtime(true) - GMANAGER_START, 4) . ' / ' . Helper_View::formatSize(memory_get_peak_usage()) . '<br/></div>'; if (!$if && !$f && !$ia) { echo '</table><div class="ch"><input onclick="return Gmanager.checkForm(document.forms[1],\'check[]\');" type="submit" name="full_chmod" value="' . Language::get('chmod') . '"/> <input onclick="return (Gmanager.checkForm(document.forms[1],\'check[]\') && Gmanager.delNotify());" type="submit" name="full_del" value="' . Language::get('del') . '"/> <input onclick="return Gmanager.checkForm(document.forms[1],\'check[]\');" type="submit" name="full_rename" value="' . Language::get('change') . '"/> <input onclick="return Gmanager.checkForm(document.forms[1],\'check[]\');" type="submit" name="fname" value="' . Language::get('rename') . '"/> <input onclick="return Gmanager.checkForm(document.forms[1],\'check[]\');" type="submit" name="create_archive" value="' . Language::get('create_archive') . '"/></div></div></form>' . $found . $tm . Registry::get('foot'); } elseif ($f) { echo '</table><div class="ch"><input onclick="return Gmanager.checkForm(document.forms[1],\'check[]\');" type="submit" name="full_extract" value="' . Language::get('extract_file') . '"/> <input type="submit" name="mega_full_extract" value="' . Language::get('extract_archive') . '"/>'; if ($archive != Archive::FORMAT_RAR) {
/** * renameFile * * @param string $name * @param string $arch_name * @param bool $del * @param bool $overwrite * @return string */ public function renameFile($name, $arch_name, $del = false, $overwrite = false) { $tmp = Config::getTemp() . '/GmanagerTar' . GMANAGER_REQUEST_TIME; $tgz = $this->_open(); $sysName = IOWrapper::set($name); $folder = ''; foreach ($tgz->listContent() as $f) { if ($arch_name == $f['filename']) { $folder = $f['typeflag'] == 5 ? 1 : 0; break; } } if (!$tgz->extract($tmp)) { Helper_System::clean($tmp); if (Config::get('Gmanager', 'mode') == 'FTP') { Gmanager::getInstance()->ftpArchiveEnd(); } return Helper_View::message(Language::get('extract_false'), Helper_View::MESSAGE_ERROR); } if (file_exists($tmp . '/' . $sysName)) { if ($overwrite) { if ($folder) { Helper_System::clean($tmp . '/' . $sysName); } else { unlink($tmp . '/' . $sysName); } } else { Helper_System::clean($tmp); if (Config::get('Gmanager', 'mode') == 'FTP') { Gmanager::getInstance()->ftpArchiveEnd(); } return Helper_View::message(Language::get('overwrite_false'), Helper_View::MESSAGE_ERROR); } } if ($folder) { @mkdir($tmp . '/' . $sysName, 0755, true); } else { @mkdir($tmp . '/' . dirname($sysName), 0755, true); } if ($folder) { if ($del) { $result = Gmanager::getInstance()->moveFiles($tmp . '/' . $name, $tmp . '/' . $arch_name); } else { $result = Gmanager::getInstance()->copyFiles($tmp . '/' . $name, $tmp . '/' . $arch_name); } } else { if ($del) { $result = rename($tmp . '/' . $arch_name, $tmp . '/' . $sysName); } else { $result = copy($tmp . '/' . $arch_name, $tmp . '/' . $sysName); } } if (!$result) { Helper_System::clean($tmp); if (Config::get('Gmanager', 'mode') == 'FTP') { Gmanager::getInstance()->ftpArchiveEnd(); } if ($folder) { if ($del) { return Helper_View::message(str_replace('%title%', htmlspecialchars($arch_name, ENT_NOQUOTES), Language::get('move_files_false')), Helper_View::MESSAGE_ERROR); } else { return Helper_View::message(str_replace('%title%', htmlspecialchars($arch_name, ENT_NOQUOTES), Language::get('copy_files_false')), Helper_View::MESSAGE_ERROR); } } else { if ($del) { return Helper_View::message(str_replace('%file%', htmlspecialchars($arch_name, ENT_NOQUOTES), Language::get('move_file_false')), Helper_View::MESSAGE_ERROR); } else { return Helper_View::message(str_replace('%file%', htmlspecialchars($arch_name, ENT_NOQUOTES), Language::get('copy_file_false')), Helper_View::MESSAGE_ERROR); } } } $result = $tgz->createModify($tmp, '.', $tmp); Helper_System::clean($tmp); if (Config::get('Gmanager', 'mode') == 'FTP') { Gmanager::getInstance()->ftpArchiveEnd($this->_name); } if ($result) { if ($folder) { if ($del) { return Helper_View::message(str_replace('%title%', htmlspecialchars($arch_name, ENT_NOQUOTES), Language::get('move_files_true')), Helper_View::MESSAGE_SUCCESS); } else { return Helper_View::message(str_replace('%title%', htmlspecialchars($arch_name, ENT_NOQUOTES), Language::get('copy_files_true')), Helper_View::MESSAGE_SUCCESS); } } else { if ($del) { return Helper_View::message(str_replace('%file%', htmlspecialchars($arch_name, ENT_NOQUOTES), Language::get('move_file_true')), Helper_View::MESSAGE_SUCCESS); } else { return Helper_View::message(str_replace('%file%', htmlspecialchars($arch_name, ENT_NOQUOTES), Language::get('copy_file_true')), Helper_View::MESSAGE_SUCCESS); } } } else { if ($folder) { if ($del) { return Helper_View::message(str_replace('%title%', htmlspecialchars($arch_name, ENT_NOQUOTES), Language::get('move_files_false')), Helper_View::MESSAGE_ERROR); } else { return Helper_View::message(str_replace('%title%', htmlspecialchars($arch_name, ENT_NOQUOTES), Language::get('copy_files_false')), Helper_View::MESSAGE_ERROR); } } else { if ($del) { return Helper_View::message(str_replace('%file%', htmlspecialchars($arch_name, ENT_NOQUOTES), Language::get('move_file_false')), Helper_View::MESSAGE_ERROR); } else { return Helper_View::message(str_replace('%file%', htmlspecialchars($arch_name, ENT_NOQUOTES), Language::get('copy_file_false')), Helper_View::MESSAGE_ERROR); } } } }
$v = ''; } echo '<div class="input"><form action="change.php?go=cmd&c=' . Registry::get('rCurrent') . '" method="post"><div>' . Language::get('cmd_code') . '<br/><input type="text" name="cmd" value="' . $v . '" style="width:98%"/><br/><input type="submit" value="' . Language::get('cmd_go') . '"/></div></form></div>'; break; default: if (!Gmanager::getInstance()->file_exists(Registry::get('current'))) { echo Helper_View::message(Language::get('not_found'), Helper_View::MESSAGE_ERROR); break; } $archive = Helper_Archive::isArchive(Helper_System::getType(Registry::get('current'))); if (isset($_GET['f']) && ($archive == Archive::FORMAT_ZIP || $archive == Archive::FORMAT_TAR || $archive == Archive::FORMAT_BZ2)) { $r_file = Helper_View::getRawurl($_GET['f']); $h_file = htmlspecialchars($_GET['f']); echo '<div class="input"><form action="change.php?go=rename&c=' . Registry::get('rCurrent') . '&f=' . $r_file . '" method="post"><div><input type="hidden" name="arch_name" value="' . $r_file . '"/>' . Language::get('change_func') . '<br/><input type="text" name="name" value="' . $h_file . '"/><br/><input type="checkbox" name="overwrite" id="overwrite" checked="checked"/><label for="overwrite">' . Language::get('overwrite_existing_files') . '</label><br/><input type="checkbox" name="del" id="del" value="1"/><label for="del">' . Language::get('change_del') . '</label><br/><input type="submit" value="' . Language::get('ch') . '"/></div></form></div>'; } else { $size = $md5 = ''; if (Registry::get('currentType') == 'dir') { $size = Helper_View::formatSize(Gmanager::getInstance()->size(Registry::get('current'), true)); } else { $size = Helper_View::formatSize(Gmanager::getInstance()->size(Registry::get('current'))); if (Config::get('Gmanager', 'mode') == 'FTP') { $md5 = Language::get('md5') . ': ' . md5(Gmanager::getInstance()->file_get_contents(Registry::get('current'))); } else { $md5 = Language::get('md5') . ': ' . md5_file(IOWrapper::set(Registry::get('current'))); } } echo '<div class="input"><form action="change.php?go=rename&c=' . Registry::get('rCurrent') . '" method="post"><div>' . Language::get('change_func') . '<br/><input type="text" name="name" value="' . $realpath . '"/><br/><input type="checkbox" name="overwrite" id="overwrite" checked="checked"/><label for="overwrite">' . Language::get('overwrite_existing_files') . '</label><br/><input type="checkbox" name="del" id="del" value="1"/><label for="del">' . Language::get('change_del') . '</label><br/><input onkeypress="return Gmanager.number(event)" type="text" size="4" maxlength="4" style="-wap-input-format:\'4N\';width:28pt;" name="chmod" value="' . Gmanager::getInstance()->lookChmod(Registry::get('current')) . '"/>' . Language::get('change_chmod') . '<br/><input type="submit" value="' . Language::get('ch') . '"/></div></form></div><div>' . Language::get('sz') . ': ' . $size . '<br/>' . $md5 . '</div>'; } break; } echo '<div class="rb">' . round(microtime(true) - GMANAGER_START, 4) . ' / ' . Helper_View::formatSize(memory_get_peak_usage()) . '<br/></div>' . Registry::get('foot');
/** * listArchive * * @todo refactoring to ListData * @param string $down * @return string */ public function listArchive($down = '') { $rar = $this->_open(); $list = $rar->getEntries(); if (!$list) { if (Config::get('Gmanager', 'mode') == 'FTP') { Gmanager::getInstance()->ftpArchiveEnd(); } return '<tr class="border"><td colspan="' . (array_sum(Config::getSection('Display')) + 1) . '">' . Helper_View::message(Language::get('archive_error'), Helper_View::MESSAGE_ERROR_EMAIL) . '</td></tr>'; } else { $r_current = Helper_View::getRawurl($this->_name); $l = ''; $i = 0; if ($down) { $list = array_reverse($list); } foreach ($list as $entry) { $r_name = Helper_View::getRawurl($entry->getName()); if ($entry->isDirectory()) { $type = 'DIR'; $name = htmlspecialchars($entry->getName(), ENT_NOQUOTES); $size = ' '; $down = ' '; } else { $type = htmlspecialchars(Helper_System::getType($entry->getName()), ENT_NOQUOTES); $name = '<a href="?c=' . $r_current . '&f=' . $r_name . '">' . htmlspecialchars(Helper_View::strLink($entry->getName(), true), ENT_NOQUOTES) . '</a>'; $size = Helper_View::formatSize($entry->getUnpackedSize()); $down = '<a href="change.php?get=' . $r_current . '&f=' . $r_name . '">' . Language::get('get') . '</a>'; } $l .= '<tr class="border"><td class="check"><input name="check[]" type="checkbox" value="' . $r_name . '"/></td>'; if (Config::get('Display', 'name')) { $l .= '<td>' . $name . '</td>'; } if (Config::get('Display', 'down')) { $l .= '<td>' . $down . '</td>'; } if (Config::get('Display', 'type')) { $l .= '<td>' . $type . '</td>'; } if (Config::get('Display', 'size')) { $l .= '<td>' . $size . '</td>'; } if (Config::get('Display', 'change')) { $l .= '<td> </td>'; } if (Config::get('Display', 'del')) { $l .= '<td>' . Language::get('dl') . '</td>'; } if (Config::get('Display', 'chmod')) { $l .= '<td> </td>'; } if (Config::get('Display', 'date')) { $l .= '<td>' . strftime(Config::get('Gmanager', 'dateFormat'), strtotime($entry->getFileTime())) . '</td>'; } if (Config::get('Display', 'uid')) { $l .= '<td> </td>'; } if (Config::get('Display', 'gid')) { $l .= '<td> </td>'; } if (Config::get('Display', 'n')) { $l .= '<td>' . ++$i . '</td>'; } $l .= '</tr>'; } if (Config::get('Gmanager', 'mode') == 'FTP') { Gmanager::getInstance()->ftpArchiveEnd(); } return $l; } }
$http = ''; } if (Registry::get('lineEditor') && $data['lines'] > Config::get('LineEditor', 'minLines')) { $isLineEditor = true; $i = $start; $j = 0; $edit = '<table class="pedit"><tbody id="pedit">'; foreach (array_slice(explode("\n", $data['content']), $start, $end) as $var) { $j++; $i++; $edit .= '<tr id="i' . $j . '"><td class="pedit_l">' . $i . '</td><td class="pedit_c"><input name="line[' . ($i - 1) . '][]" type="text" value="' . htmlspecialchars($var, $quotes, 'UTF-8') . '"/></td><td class="pedit_r"><a title="' . Language::get('add') . '" href="javascript:void(0);" onclick="Gmanager.editAdd(this);">[+]</a> / <a title="' . Language::get('dl') . '" href="javascript:void(0);" onclick="Gmanager.editDel(this);">[-]</a></td></tr>'; } if ($end > $i) { $j++; $edit .= '<tr id="i' . $j . '"><td class="pedit_l">' . ($i + 1) . '+</td><td class="pedit_c"><input name="line[' . $i . '][]" type="text"/></td><td class="pedit_r"><a title="' . Language::get('add') . '" href="javascript:void(0);" onclick="Gmanager.editAdd(this);">[+]</a> / <a title="' . Language::get('dl') . '" href="javascript:void(0);" onclick="Gmanager.editDel(this);">[-]</a></td></tr>'; } $edit .= '</tbody></table>'; $appendEdit = '<input onkeypress="return Gmanager.number(event)" style="-wap-input-format:\'*N\';width:24pt;" type="text" value="' . ($start + 1) . '" name="start" /> - <input onkeypress="return Gmanager.number(event)" style="-wap-input-format:\'*N\';width:24pt;" type="text" value="' . $end . '" name="end"/> <input name="editorLine" type="submit" value="' . Language::get('look') . '"/><br/>'; } else { $isLineEditor = false; $edit = '<textarea class="lines" name="text" rows="18" cols="64" wrap="' . (Config::get('Editor', 'wrap') ? 'on' : 'off') . '">' . htmlspecialchars($data['content'], $quotes, 'UTF-8') . '</textarea><br/>'; $appendEdit = ''; } echo '<div class="input">' . $data['lines'] . ' ' . Language::get('lines') . ' / ' . $data['size'] . '<form action="edit.php?c=' . Registry::get('rCurrent') . $f . '" method="post"><div class="edit">' . $edit . '</div><fieldset class="edit">' . $appendEdit . '<input name="editorSave" type="submit" value="' . Language::get('save') . '"/><select name="charset"><option value="utf-8">utf-8</option><option value="windows-1251"' . ($charset[1] == 'windows-1251' ? ' selected="selected"' : '') . '>windows-1251</option><option value="iso-8859-1"' . ($charset[1] == 'iso-8859-1' ? ' selected="selected"' : '') . '>iso-8859-1</option><option value="cp866"' . ($charset[1] == 'cp866' ? ' selected="selected"' : '') . '>cp866</option><option value="koi8-r"' . ($charset[1] == 'koi8-r' ? ' selected="selected"' : '') . '>koi8-r</option></select><br/>' . Language::get('chmod') . ' <input onkeypress="return Gmanager.number(event)" type="text" name="chmod" value="' . Gmanager::getInstance()->lookChmod(Registry::get('current')) . '" size="4" maxlength="4" style="-wap-input-format:\'4N\';width:28pt;"/><br/><input type="submit" name="get" value="' . Language::get('get') . '"/><br/>' . ($isLineEditor ? '<a href="edit.php?lineEditor=0&c=' . Registry::get('rCurrent') . $f . '">' . Language::get('basic_editor') . '</a>' : Language::get('basic_editor')) . ' / ' . ($isLineEditor ? Language::get('line_editor') : '<a href="edit.php?lineEditor=1&c=' . Registry::get('rCurrent') . $f . '">' . Language::get('line_editor') . '</a>') . '</fieldset><fieldset class="edit">' . Language::get('replace_from') . '<br/><input type="text" name="from" value="' . (isset($_POST['from']) ? htmlspecialchars($_POST['from']) : '') . '" style="width:128pt;"/>' . Language::get('replace_to') . '<input type="text" name="to" value="' . (isset($_POST['to']) ? htmlspecialchars($_POST['to']) : '') . '" style="width:128pt;"/><br/><input type="checkbox" name="regexp" id="regexp" value="1"' . (isset($_POST['regexp']) ? ' checked="checked"' : '') . '/><label for="regexp">' . Language::get('regexp') . '</label><br/><input type="checkbox" name="case" id="case" value="1"' . (isset($_POST['case']) ? ' checked="checked"' : '') . '/><label for="case">' . Language::get('register') . '</label><br/><input type="submit" name="editorReplace" value="' . Language::get('replace') . '"/></fieldset></form></div>' . $http . '<div class="rb"><a href="edit.php?c=' . Registry::get('rCurrent') . $f . '&' . $full_charset . 'go=syntax">' . Language::get('syntax') . '</a><br/></div>'; if ($archive == '' && extension_loaded('xml')) { echo '<div class="rb"><a href="edit.php?c=' . Registry::get('rCurrent') . '&' . $full_charset . 'go=validator">' . Language::get('validator') . '</a><br/></div>'; } echo '<div class="rb">' . Language::get('charset') . '<form action="edit.php?" style="padding:0;margin:0;"><div><input type="hidden" name="c" value="' . Registry::get('rCurrent') . '"/><input type="hidden" name="f" value="' . rawurlencode($_GET['f']) . '"/>' . ($isLineEditor ? '<input type="hidden" name="start" value="' . ($start + 1) . '"/><input type="hidden" name="end" value="' . $end . '"/>' : '') . '<select name="charset"><option value="default">' . Language::get('charset_no') . '</option><optgroup label="UTF-8"><option value="utf-8 -> windows-1251"' . ($_GET['charset'] == 'utf-8 -> windows-1251' ? ' selected="selected"' : '') . '>utf-8 -> windows-1251</option><option value="utf-8 -> iso-8859-1"' . ($_GET['charset'] == 'utf-8 -> iso-8859-1' ? ' selected="selected"' : '') . '>utf-8 -> iso-8859-1</option><option value="utf-8 -> cp866"' . ($_GET['charset'] == 'utf-8 -> cp866' ? ' selected="selected"' : '') . '>utf-8 -> cp866</option><option value="utf-8 -> koi8-r"' . ($_GET['charset'] == 'utf-8 -> koi8-r' ? ' selected="selected"' : '') . '>utf-8 -> koi8-r</option></optgroup><optgroup label="Windows-1251"><option value="windows-1251 -> utf-8"' . ($_GET['charset'] == 'windows-1251 -> utf-8' ? ' selected="selected"' : '') . '>windows-1251 -> utf-8</option><option value="windows-1251 -> iso-8859-1"' . ($_GET['charset'] == 'windows-1251 -> iso-8859-1' ? ' selected="selected"' : '') . '>windows-1251 -> iso-8859-1</option><option value="windows-1251 -> cp866"' . ($_GET['charset'] == 'windows-1251 -> cp866' ? ' selected="selected"' : '') . '>windows-1251 -> cp866</option><option value="windows-1251 -> koi8-r"' . ($_GET['charset'] == 'windows-1251 -> koi8-r' ? ' selected="selected"' : '') . '>windows-1251 -> koi8-r</option></optgroup><optgroup label="ISO-8859-1"><option value="iso-8859-1 -> utf-8"' . ($_GET['charset'] == 'iso-8859-1 -> utf-8' ? ' selected="selected"' : '') . '>iso-8859-1 -> utf-8</option><option value="iso-8859-1 -> windows-1251"' . ($_GET['charset'] == 'iso-8859-1 -> windows-1251' ? ' selected="selected"' : '') . '>iso-8859-1 -> windows-1251</option><option value="iso-8859-1 -> cp866"' . ($_GET['charset'] == 'iso-8859-1 -> cp866' ? ' selected="selected"' : '') . '>iso-8859-1 -> cp866</option><option value="iso-8859-1 -> koi8-r"' . ($_GET['charset'] == 'iso-8859-1 -> koi8-r' ? ' selected="selected"' : '') . '>iso-8859-1 -> koi8-r</option></optgroup><optgroup label="CP866"><option value="cp866 -> utf-8"' . ($_GET['charset'] == 'cp866 -> utf-8' ? ' selected="selected"' : '') . '>cp866 -> utf-8</option><option value="cp866 -> windows-1251"' . ($_GET['charset'] == 'cp866 -> windows-1251' ? ' selected="selected"' : '') . '>cp866 -> windows-1251</option><option value="cp866 -> iso-8859-1"' . ($_GET['charset'] == 'cp866 -> iso-8859-1' ? ' selected="selected"' : '') . '>cp866 -> iso-8859-1</option><option value="cp866 -> koi8-r"' . ($_GET['charset'] == 'cp866 -> koi8-r' ? ' selected="selected"' : '') . '>cp866 -> koi8-r</option></optgroup><optgroup label="KOI8-R"><option value="koi8-r -> utf-8"' . ($_GET['charset'] == 'koi8-r -> utf-8' ? ' selected="selected"' : '') . '>koi8-r -> utf-8</option><option value="koi8-r -> windows-1251"' . ($_GET['charset'] == 'koi8-r -> windows-1251' ? ' selected="selected"' : '') . '>koi8-r -> windows-1251</option><option value="koi8-r -> iso-8859-1"' . ($_GET['charset'] == 'koi8-r -> iso-8859-1' ? ' selected="selected"' : '') . '>koi8-r -> iso-8859-1</option><option value="koi8-r -> cp866"' . ($_GET['charset'] == 'koi8-r -> cp866' ? ' selected="selected"' : '') . '>koi8-r -> cp866</option></optgroup></select> <input type="submit" value="' . Language::get('ch') . '"/></div></form></div><div class="rb">' . Language::get('beautifier') . ' (alpha)<form action="edit.php?" style="padding:0;margin:0;"><div><input type="hidden" name="beautify" value="1"/><input type="hidden" name="c" value="' . Registry::get('rCurrent') . '"/><input type="hidden" name="f" value="' . rawurlencode($_GET['f']) . '"/><input type="hidden" name="f" value="' . rawurlencode($_GET['f']) . '"/>' . ($isLineEditor ? '<input type="hidden" name="start" value="' . ($start + 1) . '"/><input type="hidden" name="end" value="' . $end . '"/>' : '') . '<input type="submit" value="' . Language::get('beautify') . '" /></div></form></div>'; break; } echo '<div class="rb">' . round(microtime(true) - GMANAGER_START, 4) . ' / ' . Helper_View::formatSize(memory_get_peak_usage()) . '<br/></div>' . Registry::get('foot');
/** * getListSearchArray * * @param string $where where * @param string $pattern regexp pattern * @param bool $inText in text * @param int $limit max file size * @param bool $archive in gz archives * @param string $t target * @return array */ private static function _getListSearchArray($where = '', $pattern = '', $inText = false, $limit = 8388608, $archive = false, $t = '') { static $count = 0; static $page = array(); $where = str_replace('//', '/', $where . '/'); $obj = Gmanager::getInstance(); foreach ($obj->iterator($where) as $f) { if ($obj->is_dir($where . $f)) { self::_getListSearchArray($where . $f . '/', $pattern, $inText, $limit, $archive, $t); continue; } $type = htmlspecialchars(Helper_System::getType(Helper_System::basename($f)), ENT_NOQUOTES); $arch = Helper_Archive::isArchive($type); $stat = $obj->stat($where . $f); $pname = $pdown = $ptype = $psize = $pchange = $pdel = $pchmod = $pdate = $puid = $pgid = $pn = $in = null; if ($inText) { if ($stat['size'] > $limit || $arch && !$archive || $arch && $archive && $type != Archive::FORMAT_GZ) { continue; } $in = preg_match_all($pattern, $type == Archive::FORMAT_GZ ? $obj->getGzContent($where . $f) : $obj->file_get_contents($where . $f), $match); unset($match); if ($in) { $in = ' (' . $in . ')'; } else { continue; } } else { $in = preg_match_all($pattern, $f, $match); unset($match); if (!$in) { continue; } } $count++; //$h_file = htmlspecialchars($c . $f, ENT_COMPAT); $r_file = Helper_View::getRawurl($where . $f); if (Config::get('Display', 'name')) { $name = htmlspecialchars(Helper_View::strLink($where . $f, true), ENT_NOQUOTES); if ($arch) { $pname = '<a href="index.php?' . $r_file . '">' . $name . '</a>' . $in . ''; } else { $pname = '<a href="edit.php?' . $r_file . '"' . $t . '>' . $name . '</a>' . $in . ''; } } if (Config::get('Display', 'size')) { $psize = '' . Helper_View::formatSize($stat['size']) . ''; } if (Config::get('Display', 'chmod')) { $pchmod = '<a href="change.php?go=chmod&c=' . $r_file . '">' . $obj->lookChmod($where . $f) . '</a>'; } $page[$f] = '<input name="check[]" type="checkbox" value="' . $r_file . '"/>' . $pname . $psize . $pchmod . $pn; } //natcasesort($page); return $page; }