First commit
This commit is contained in:
0
uc_server/plugin/replacemykey/index.htm
Normal file
0
uc_server/plugin/replacemykey/index.htm
Normal file
54
uc_server/plugin/replacemykey/plugin.php
Normal file
54
uc_server/plugin/replacemykey/plugin.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
|
||||
!defined('IN_UC') && exit('Access Denied');
|
||||
|
||||
class control extends pluginbase {
|
||||
|
||||
function control() {
|
||||
$this->pluginbase();
|
||||
}
|
||||
|
||||
function onindex() {
|
||||
|
||||
if($this->submitcheck()) {
|
||||
if(!getgpc('reconfkey', 'P')) {
|
||||
$this->message('replacemykey_no_confirm', 'BACK');
|
||||
}
|
||||
if($this->_replacemykey()) {
|
||||
$this->message('replacemykey_succeed', 'BACK');
|
||||
} else {
|
||||
$this->message('replacemykey_false', 'BACK');
|
||||
}
|
||||
}
|
||||
|
||||
$this->view->display('plugin_replacemykey');
|
||||
}
|
||||
|
||||
function _replacemykey() {
|
||||
$oldmykey = UC_MYKEY;
|
||||
$newmykey = $this->generate_key();
|
||||
$configfile = UC_ROOT.'./data/config.inc.php';
|
||||
if(!is_writable($configfile)) {
|
||||
return false;
|
||||
}
|
||||
$config = file_get_contents($configfile);
|
||||
$config = preg_replace("/define\('UC_MYKEY',\s*'.*?'\);/i", "define('UC_MYKEY', '$newmykey');", $config);
|
||||
if(file_put_contents($configfile, $config) === false) {
|
||||
return false;
|
||||
}
|
||||
$apps = $this->db->fetch_all("SELECT appid, authkey FROM ".UC_DBTABLEPRE."applications", 'appid');
|
||||
foreach($apps as $k => $v) {
|
||||
if($tmp = $this->authcode($v['authkey'], 'DECODE', $oldmykey)) {
|
||||
$appid = $v['appid'];
|
||||
$appkey = $this->authcode($tmp, 'ENCODE', $newmykey);
|
||||
$this->db->query("UPDATE ".UC_DBTABLEPRE."applications SET authkey='$appkey' WHERE appid='$appid'");
|
||||
if($this->db->errno()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
16
uc_server/plugin/replacemykey/plugin.xml
Normal file
16
uc_server/plugin/replacemykey/plugin.xml
Normal file
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<root>
|
||||
<item id="name">密钥更新</item>
|
||||
<item id="version">1.0.0</item>
|
||||
<item id="author">Discuz! X Community Team</item>
|
||||
<item id="date">2022-1-30</item>
|
||||
<item id="lastmodified">2022-1-30</item>
|
||||
<item id="copyright">Discuz! X Community Team</item>
|
||||
<item id="tabindex">2</item>
|
||||
<item id="tips">当站点沦陷时您应该考虑进行密钥更新,以避免黑客通过已知的 UC_MYKEY 密钥破解 UC_KEY 密钥。</item>
|
||||
<item id="lang">
|
||||
<item id="plugin_replacemykey_tips">在操作之前建议您选择低峰期操作或关闭下级应用,并做好 UCenter 以及各应用的数据、文件备份工作。</item>
|
||||
<item id="plugin_replacemykey_confirm">确认</item>
|
||||
<item id="plugin_replacemykey_confirm_tips">我已了解上述风险,并已经做好网站备份工作。</item>
|
||||
</item>
|
||||
</root>
|
18
uc_server/plugin/replacemykey/plugin_replacemykey.htm
Normal file
18
uc_server/plugin/replacemykey/plugin_replacemykey.htm
Normal file
@@ -0,0 +1,18 @@
|
||||
{template plugin_header}
|
||||
<p class="i">{lang plugin_replacemykey_tips}</p>
|
||||
<form method="post">
|
||||
<input type="hidden" name="formhash" value="{FORMHASH}">
|
||||
<table class="dbtb" style="height:123px;">
|
||||
<tr>
|
||||
<td class="tbtitle">{lang plugin_replacemykey_confirm}:</td>
|
||||
<td><input type="checkbox" name="reconfkey" id="reconfkey" class="checkbox" /><label for="reconfkey">{lang plugin_replacemykey_confirm_tips}</label></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>
|
||||
<input type="submit" name="submit" value="{lang submit}" class="btn" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
{template plugin_footer}
|
Reference in New Issue
Block a user