Untitled Note

php 16 views • Aug 13, 2026
Edit
php
<p>&lt;?php<br>// 检查系统是否已安装(使用绝对路径检查)<br>$basePath = dirname(__DIR__);<br>if (!file_exists($basePath . '/config/database.php') || !file_exists($basePath . '/includes/init.php')) {<br>&nbsp; &nbsp; // 系统未安装,重定向到安装向导<br>&nbsp; &nbsp; header('Location: ../install/');<br>&nbsp; &nbsp; exit();<br>}</p>
<p>session_start();</p>
<p>// 检查是否已登录<br>if (!isset($_SESSION['admin_id'])) {<br>&nbsp; &nbsp; header('Location: index.php');<br>&nbsp; &nbsp; exit();<br>}</p>
<p>// 包含初始化文件<br>require_once '../includes/init.php';</p>
<p>$error = '';<br>$success = '';</p>
<p>// 获取当前配置<br>$upload_max_size = get_system_config('upload_max_size', 2097152);<br>$default_algorithm = get_system_config('default_algorithm', 'enphp');<br>$points_per_encrypt = get_system_config('points_per_encrypt', 10);<br>$points_per_decrypt = get_system_config('points_per_decrypt', 5);<br>$registration_points = get_system_config('registration_points', 100);<br>$site_name = get_system_config('site_name', 'PHP加密解密系统');</p>
<p>// 支持的加密算法<br>$algorithms = [<br>&nbsp; &nbsp; 'eval' =&gt; 'Eval加密',<br>&nbsp; &nbsp; 'goto' =&gt; 'Goto加密',<br>&nbsp; &nbsp; 'enphp' =&gt; 'EnPHP加密',<br>&nbsp; &nbsp; 'enphpv2' =&gt; 'EnPHP V2加密',<br>&nbsp; &nbsp; 'jiamiZym' =&gt; 'JiamiZym加密',<br>&nbsp; &nbsp; 'magicTwo' =&gt; 'MagicTwo加密',<br>&nbsp; &nbsp; 'noname1' =&gt; 'NoName1加密',<br>&nbsp; &nbsp; 'phpjm' =&gt; 'PHPJM加密',<br>&nbsp; &nbsp; 'phpjm2' =&gt; 'PHPJM2加密'<br>];</p>
<p>if ($_SERVER['REQUEST_METHOD'] === 'POST') {<br>&nbsp; &nbsp; $upload_max_size = (int)$_POST['upload_max_size'];<br>&nbsp; &nbsp; $default_algorithm = $_POST['default_algorithm'];<br>&nbsp; &nbsp; $points_per_encrypt = (int)$_POST['points_per_encrypt'];<br>&nbsp; &nbsp; $points_per_decrypt = (int)$_POST['points_per_decrypt'];<br>&nbsp; &nbsp; $registration_points = (int)$_POST['registration_points'];<br>&nbsp; &nbsp; $site_name = $_POST['site_name'];<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; try {<br>&nbsp; &nbsp; &nbsp; &nbsp; // 更新配置<br>&nbsp; &nbsp; &nbsp; &nbsp; update_system_config('upload_max_size', $upload_max_size);<br>&nbsp; &nbsp; &nbsp; &nbsp; update_system_config('default_algorithm', $default_algorithm);<br>&nbsp; &nbsp; &nbsp; &nbsp; update_system_config('points_per_encrypt', $points_per_encrypt);<br>&nbsp; &nbsp; &nbsp; &nbsp; update_system_config('points_per_decrypt', $points_per_decrypt);<br>&nbsp; &nbsp; &nbsp; &nbsp; update_system_config('registration_points', $registration_points);<br>&nbsp; &nbsp; &nbsp; &nbsp; update_system_config('site_name', $site_name);<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp; $success = '系统配置更新成功!';<br>&nbsp; &nbsp; } catch (Exception $e) {<br>&nbsp; &nbsp; &nbsp; &nbsp; $error = '更新配置时出错: ' . $e-&gt;getMessage();<br>&nbsp; &nbsp; }<br>}<br>?&gt;<br>&lt;!DOCTYPE html&gt;<br>&lt;html lang="zh-CN"&gt;<br>&lt;head&gt;<br>&nbsp; &nbsp; &lt;meta charset="UTF-8"&gt;<br>&nbsp; &nbsp; &lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&gt;<br>&nbsp; &nbsp; &lt;title&gt;系统设置 - PHP加密解密系统&lt;/title&gt;<br>&nbsp; &nbsp; &lt;link rel="stylesheet" href="../assets/style.css"&gt;<br>&lt;/head&gt;<br>&lt;body&gt;<br>&nbsp; &nbsp; &lt;div class="container"&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &lt;div class="sidebar"&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;h2&gt;管理后台&lt;/h2&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;ul&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;li&gt;&lt;a href="dashboard.php"&gt;仪表板&lt;/a&gt;&lt;/li&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;li&gt;&lt;a href="users.php"&gt;用户管理&lt;/a&gt;&lt;/li&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;li&gt;&lt;a href="cards.php"&gt;卡密管理&lt;/a&gt;&lt;/li&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;li&gt;&lt;a href="settings.php" class="active"&gt;系统设置&lt;/a&gt;&lt;/li&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;li&gt;&lt;a href="encrypt.php"&gt;加密功能&lt;/a&gt;&lt;/li&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;li&gt;&lt;a href="decrypt.php"&gt;解密功能&lt;/a&gt;&lt;/li&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;li&gt;&lt;a href="logout.php"&gt;退出登录&lt;/a&gt;&lt;/li&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/ul&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &lt;/div&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &lt;div class="main-content"&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;div class="header"&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;h1&gt;系统设置&lt;/h1&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;div&gt;欢迎,&lt;?php echo htmlspecialchars($_SESSION['admin_username']); ?&gt; | &lt;a href="logout.php"&gt;退出&lt;/a&gt;&lt;/div&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/div&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;div class="content"&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;h2&gt;系统配置&lt;/h2&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;?php if ($error): ?&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;div class="error"&gt;&lt;?php echo htmlspecialchars($error); ?&gt;&lt;/div&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;?php endif; ?&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;?php if ($success): ?&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;div class="success"&gt;&lt;?php echo htmlspecialchars($success); ?&gt;&lt;/div&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;?php endif; ?&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;form method="POST"&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;div class="form-group"&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;label for="site_name"&gt;网站名称:&lt;/label&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;input type="text" id="site_name" name="site_name" value="&lt;?php echo htmlspecialchars($configs['site_name']); ?&gt;" required&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/div&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;div class="form-group"&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;label for="upload_max_size"&gt;上传文件大小限制 (字节):&lt;/label&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;input type="number" id="upload_max_size" name="upload_max_size" value="&lt;?php echo htmlspecialchars($configs['upload_max_size']); ?&gt;" required&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;small&gt;当前值约为 &lt;?php echo round($configs['upload_max_size'] / 1024 / 1024, 2); ?&gt; MB&lt;/small&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/div&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;div class="form-group"&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;label for="default_algorithm"&gt;默认加密算法:&lt;/label&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;select id="default_algorithm" name="default_algorithm"&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;?php foreach ($algorithms as $key =&gt; $name): ?&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;option value="&lt;?php echo $key; ?&gt;" &lt;?php echo ($configs['default_algorithm'] === $key) ? 'selected' : ''; ?&gt;&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;?php echo htmlspecialchars($name); ?&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/option&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;?php endforeach; ?&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/select&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/div&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;div class="form-group"&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;label for="points_per_encrypt"&gt;每次加密消耗积分:&lt;/label&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;input type="number" id="points_per_encrypt" name="points_per_encrypt" value="&lt;?php echo htmlspecialchars($configs['points_per_encrypt']); ?&gt;" min="0" required&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/div&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;div class="form-group"&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;label for="points_per_decrypt"&gt;每次解密消耗积分:&lt;/label&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;input type="number" id="points_per_decrypt" name="points_per_decrypt" value="&lt;?php echo htmlspecialchars($configs['points_per_decrypt']); ?&gt;" min="0" required&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/div&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;div class="form-group"&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;label for="registration_points"&gt;注册赠送积分:&lt;/label&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;input type="number" id="registration_points" name="registration_points" value="&lt;?php echo htmlspecialchars($configs['registration_points']); ?&gt;" min="0" required&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/div&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;button type="submit" class="btn btn-success"&gt;保存设置&lt;/button&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/form&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/div&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &lt;/div&gt;<br>&nbsp; &nbsp; &lt;/div&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;</p>