/** * 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; } }
/** * 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; }
/** * 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; } }
/** * head * * @return string */ public function head() { if (Config::get('Gmanager', 'mode') != 'FTP') { $realpath = self::$_instance->realpath(Registry::get('current')); $realpath = $realpath ? $realpath : Registry::get('current'); } else { $realpath = Registry::get('current'); } $chmod = $this->lookChmod(Registry::get('current')); $chmod = $chmod ? $chmod : (isset($_POST['chmod'][0]) ? htmlspecialchars($_POST['chmod'][0], ENT_NOQUOTES) : (isset($_POST['chmod']) ? htmlspecialchars($_POST['chmod'], ENT_NOQUOTES) : 0)); $d = dirname(str_replace('\\', '/', $realpath)); $archive = Helper_Archive::isArchive(Helper_System::getType(Helper_System::basename(Registry::get('current')))); if (Registry::get('currentType') == 'dir' || Registry::get('currentTypeLink') == 'dir') { if (Registry::get('current') == '.') { return '<div class="border">' . Language::get('dir') . ' <a href="?">' . htmlspecialchars(Helper_View::strLink(self::$_instance->getcwd()), ENT_NOQUOTES) . '</a> (' . $this->lookChmod(self::$_instance->getcwd()) . ')<br/></div>'; } else { return '<div class="border">' . Language::get('back') . ' <a href="?c=' . Helper_View::getRawurl($d) . '">' . $d . '</a> (' . $this->lookChmod($d) . ')<br/></div><div class="border">' . Language::get('dir') . ' <a href="?c=' . Registry::get('rCurrent') . '">' . htmlspecialchars(str_replace('\\', '/', Helper_View::strLink($realpath)), ENT_NOQUOTES) . '</a> (' . $chmod . ')<br/></div>'; } } elseif (Registry::get('currentType') == 'file' && $archive) { $up = dirname($d); return '<div class="border">' . Language::get('back') . ' <a href="?c=' . Helper_View::getRawurl($up) . '">' . htmlspecialchars(Helper_View::strLink($up), ENT_NOQUOTES) . '</a> (' . $this->lookChmod($up) . ')<br/></div><div class="border">' . Language::get('dir') . ' <a href="?c=' . Helper_View::getRawurl($d) . '">' . htmlspecialchars(Helper_View::strLink($d), ENT_NOQUOTES) . '</a> (' . $this->lookChmod($d) . ')<br/></div><div class="border">' . Language::get('file') . ' <a href="?c=' . Registry::get('rCurrent') . '">' . htmlspecialchars(str_replace('\\', '/', Helper_View::strLink($realpath)), ENT_NOQUOTES) . '</a> (' . $chmod . ')<br/></div>'; } else { $up = dirname($d); return '<div class="border">' . Language::get('back') . ' <a href="?c=' . Helper_View::getRawurl($up) . '">' . htmlspecialchars(Helper_View::strLink($up), ENT_NOQUOTES) . '</a> (' . $this->lookChmod($up) . ')<br/></div><div class="border">' . Language::get('dir') . ' <a href="?c=' . Helper_View::getRawurl($d) . '">' . htmlspecialchars(Helper_View::strLink($d), ENT_NOQUOTES) . '</a> (' . $this->lookChmod($d) . ')<br/></div><div class="border">' . Language::get('file') . ' <a href="?gmanager_action=edit&c=' . Registry::get('rCurrent') . '">' . htmlspecialchars(str_replace('\\', '/', Helper_View::strLink($realpath)), ENT_NOQUOTES) . '</a> (' . $chmod . ')<br/></div>'; } }