/** * listArchive * * @todo refactoring to ListData * @param string $down * @return string */ public function listArchive($down = '') { $zip = $this->_open(); $list = $zip->listContent(); 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') . '<br/>' . $zip->errorInfo(true), Helper_View::MESSAGE_ERROR_EMAIL) . '</td></tr>'; } else { $r_current = Helper_View::getRawurl($this->_name); $l = ''; if ($down) { $list = array_reverse($list); } $s = sizeof($list); for ($i = 0; $i < $s; ++$i) { $r_name = Helper_View::getRawurl($list[$i]['filename']); if ($list[$i]['folder']) { $type = 'DIR'; $name = htmlspecialchars($list[$i]['filename'], ENT_NOQUOTES); $size = ' '; $down = ' '; } else { $type = htmlspecialchars(Helper_System::getType($list[$i]['filename']), ENT_NOQUOTES); $name = '<a href="?c=' . $r_current . '&f=' . $r_name . '">' . htmlspecialchars(Helper_View::strLink($list[$i]['filename'], true), ENT_NOQUOTES) . '</a>'; $size = Helper_View::formatSize($list[$i]['size']); $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><a href="change.php?c=' . $r_current . '&f=' . $r_name . '">' . Language::get('ch') . '</a></td>'; } if (Config::get('Display', 'del')) { $l .= '<td><a onclick="return Gmanager.delNotify();" href="change.php?go=del_zip_archive&c=' . $r_current . '&f=' . $r_name . '">' . Language::get('dl') . '</a></td>'; } if (Config::get('Display', 'chmod')) { $l .= '<td> </td>'; } if (Config::get('Display', 'date')) { $l .= '<td>' . strftime(Config::get('Gmanager', 'dateFormat'), $list[$i]['mtime']) . '</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 + 1) . '</td>'; } $l .= '</tr>'; } if (Config::get('Gmanager', 'mode') == 'FTP') { Gmanager::getInstance()->ftpArchiveEnd(); } $prop = $zip->properties(); if (isset($prop['comment']) && $prop['comment'] != '') { if (mb_convert_encoding($prop['comment'], 'UTF-8', 'UTF-8') != $prop['comment']) { $prop['comment'] = mb_convert_encoding($prop['comment'], 'UTF-8', Config::get('Gmanager', 'altEncoding')); } $l .= '<tr class="border"><td>' . Language::get('comment_archive') . '</td><td colspan="' . (array_sum(Config::getSection('Display')) + 1) . '"><pre>' . htmlspecialchars($prop['comment'], ENT_NOQUOTES) . '</pre></td></tr>'; } return $l; } }
} } 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) { echo ' <input type="submit" name="add_archive" value="' . Language::get('add_archive') . '"/> <input onclick="return (Gmanager.checkForm(document.forms[1],\'check[]\') && Gmanager.delNotify());" type="submit" name="del_archive" value="' . Language::get('del') . '"/>'; } echo '</div></div></form>' . $found . $tm . Registry::get('foot'); } elseif ($ia) { echo '</table><div class="ch"><input type="hidden" name="add_archive" value="' . rawurlencode($_GET['add_archive']) . '"/><input onclick="return Gmanager.checkForm(document.forms[1],\'check[]\');" type="submit" name="name" value="' . Language::get('add_archive') . '"/></div></div></form>' . $found . $tm . Registry::get('foot'); } else { echo $found . $tm . 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; } }
/** * 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; }
/** * gz * * @param string $c * @return string */ public function gz($c = '') { $data = Config::get('Gmanager', 'mode') == 'FTP' ? $this->ftpArchiveStart($c) : IOWrapper::set($c); $info = $this->getGzInfo($data); $ext = $this->getGzContent($data); if (Config::get('Gmanager', 'mode') == 'FTP') { $this->ftpArchiveEnd(); } if ($ext) { return Helper_View::message(Language::get('name') . ': ' . htmlspecialchars($info['name'], ENT_NOQUOTES) . '<br/>' . Language::get('archive_size') . ': ' . Helper_View::formatSize($this->size($c)) . '<br/>' . Language::get('real_size') . ': ' . Helper_View::formatSize($info['length']) . '<br/>' . Language::get('archive_date') . ': ' . strftime(Config::get('Gmanager', 'dateFormat'), self::$_instance->filemtime($c)), Helper_View::MESSAGE_SUCCESS) . $this->code(trim($ext)); } else { return Helper_View::message(Language::get('archive_error'), Helper_View::MESSAGE_ERROR_EMAIL); } }
/** * showEval * * @param string $eval * @return string */ public function showEval($eval = '') { ob_start(); $evalFunction = create_function('', $eval . "\n"); $info = array('time' => microtime(true), 'ram' => memory_get_usage(false)); //eval($eval); $evalFunction(); $info = array('ram' => Helper_View::formatSize(memory_get_usage(false) - $info['ram'], 6), 'time' => round(microtime(true) - $info['time'], 6)); $buf = ob_get_contents(); ob_end_clean(); if (mb_substr($buf, 0, mb_strlen(ini_get('error_prepend_string'))) == ini_get('error_prepend_string')) { $buf = mb_substr($buf, mb_strlen(ini_get('error_prepend_string'))); } if (mb_substr($buf, -mb_strlen(ini_get('error_append_string'))) == ini_get('error_append_string')) { $buf = mb_substr($buf, 0, -mb_strlen(ini_get('error_append_string'))); } return '<div class="input">' . Language::get('result') . '<br/><textarea class="lines" cols="48" rows="' . Helper_View::getRows($buf) . '">' . htmlspecialchars($buf, ENT_NOQUOTES) . '</textarea><br/>' . str_replace('%time%', $info['time'], Language::get('microtime')) . '<br/>' . Language::get('memory_get_usage') . ' ' . $info['ram'] . '<br/></div>'; }