function DisplayError($msg, $t = 0) { global $cfg_diserror; //向浏览器输出错误 switch ($t) { case 0: $title = '安全警告:MySql Error!'; break; case 1: $title = '安全警告:请检查您的SQL语句是否合法,您的操作将被强制停止!'; break; default: } $str = '<div style="font-family:\'微软雅黑\';font-size:12px;">'; $str .= '<h3 style="margin:0;padding:0;line-height:30px;color:red;">' . $title . '</h3>'; $str .= '<strong>错误文件</strong>:' . GetCurUrl() . '<br />'; $str .= '<strong>错误信息</strong>:' . $msg . ''; $str .= '</div>'; //判断是否输出错误提示 if ($cfg_diserror == 'Y') { echo $str; } //保存MySql错误日志 $userIP = GetIP(); $getUrl = GetCurUrl(); $getTime = GetDateTime(time()); $logfile = dirname(__FILE__) . '/../data/error/mysql_error_trace.php'; $savemsg = '<?php exit(); ?> Time: ' . $getTime . '. || Page: ' . $getUrl . ' || IP: ' . $userIP . ' || Error: ' . $msg . "\r\n"; Writef($logfile, $savemsg, 'a+'); //危险错误,强制停止 if ($t == 1) { exit; } }
function RewriteURL() { global $cfg_reurl_index, $cfg_reurl_about, $cfg_reurl_news, $cfg_reurl_newsshow, $cfg_reurl_product, $cfg_reurl_productshow, $cfg_reurl_case, $cfg_reurl_caseshow, $cfg_reurl_join, $cfg_reurl_joinshow, $cfg_reurl_message, $cfg_reurl_contact, $cfg_reurl_soft, $cfg_reurl_softshow, $cfg_reurl_goods, $cfg_reurl_goodsshow, $cfg_reurl_vote, $cfg_reurl_custom, $cfg_webpath, $gourl; //分析设置的重写规则 preg_match_all('/\\{(.*?)\\}/si', $cfg_reurl_about, $r_about); preg_match_all('/\\{(.*?)\\}/si', $cfg_reurl_news, $r_news); preg_match_all('/\\{(.*?)\\}/si', $cfg_reurl_newsshow, $r_newsshow); preg_match_all('/\\{(.*?)\\}/si', $cfg_reurl_product, $r_product); preg_match_all('/\\{(.*?)\\}/si', $cfg_reurl_productshow, $r_productshow); preg_match_all('/\\{(.*?)\\}/si', $cfg_reurl_case, $r_case); preg_match_all('/\\{(.*?)\\}/si', $cfg_reurl_caseshow, $r_caseshow); preg_match_all('/\\{(.*?)\\}/si', $cfg_reurl_join, $r_join); preg_match_all('/\\{(.*?)\\}/si', $cfg_reurl_joinshow, $r_joinshow); preg_match_all('/\\{(.*?)\\}/si', $cfg_reurl_message, $r_message); preg_match_all('/\\{(.*?)\\}/si', $cfg_reurl_contact, $r_contact); preg_match_all('/\\{(.*?)\\}/si', $cfg_reurl_soft, $r_soft); preg_match_all('/\\{(.*?)\\}/si', $cfg_reurl_softshow, $r_softshow); preg_match_all('/\\{(.*?)\\}/si', $cfg_reurl_goods, $r_goods); preg_match_all('/\\{(.*?)\\}/si', $cfg_reurl_goodsshow, $r_goodsshow); preg_match_all('/\\{(.*?)\\}/si', $cfg_reurl_vote, $r_vote); preg_match_all('/\\{(.*?)\\}/si', $cfg_reurl_custom, $r_custom); $r_index = $cfg_reurl_index; $r_about = RewriteURL_Str($r_about, $cfg_reurl_about); $r_news = RewriteURL_Str($r_news, $cfg_reurl_news); $r_newsshow = RewriteURL_Str($r_newsshow, $cfg_reurl_newsshow); $r_product = RewriteURL_Str($r_product, $cfg_reurl_product); $r_productshow = RewriteURL_Str($r_productshow, $cfg_reurl_productshow); $r_case = RewriteURL_Str($r_case, $cfg_reurl_case); $r_caseshow = RewriteURL_Str($r_caseshow, $cfg_reurl_caseshow); $r_join = RewriteURL_Str($r_join, $cfg_reurl_join); $r_joinshow = RewriteURL_Str($r_joinshow, $cfg_reurl_joinshow); $r_message = RewriteURL_Str($r_message, $cfg_reurl_message); $r_contact = RewriteURL_Str($r_contact, $cfg_reurl_contact); $r_soft = RewriteURL_Str($r_soft, $cfg_reurl_soft); $r_softshow = RewriteURL_Str($r_softshow, $cfg_reurl_softshow); $r_goods = RewriteURL_Str($r_goods, $cfg_reurl_goods); $r_goodsshow = RewriteURL_Str($r_goodsshow, $cfg_reurl_goodsshow); $r_vote = RewriteURL_Str($r_vote, $cfg_reurl_vote); $r_custom = RewriteURL_Str($r_custom, $cfg_reurl_custom); //apache独立主机规则 $apache = 'RewriteCond %{QUERY_STRING} ^(.*)$' . "\r\n"; $apache .= 'RewriteRule ^(.*)/' . $r_index . '$ $1/index.php' . "\r\n"; $apache .= 'RewriteCond %{QUERY_STRING} ^(.*)$' . "\r\n"; $apache .= 'RewriteRule ^(.*)/' . $r_about[0] . '$ $1/' . $r_about[4] . "\r\n"; $apache .= 'RewriteCond %{QUERY_STRING} ^(.*)$' . "\r\n"; $apache .= 'RewriteRule ^(.*)/' . $r_news[0] . '$ $1/' . $r_news[4] . "\r\n"; $apache .= 'RewriteCond %{QUERY_STRING} ^(.*)$' . "\r\n"; $apache .= 'RewriteRule ^(.*)/' . $r_newsshow[0] . '$ $1/' . $r_newsshow[4] . "\r\n"; $apache .= 'RewriteCond %{QUERY_STRING} ^(.*)$' . "\r\n"; $apache .= 'RewriteRule ^(.*)/' . $r_product[0] . '$ $1/' . $r_product[4] . "\r\n"; $apache .= 'RewriteCond %{QUERY_STRING} ^(.*)$' . "\r\n"; $apache .= 'RewriteRule ^(.*)/' . $r_productshow[0] . '$ $1/' . $r_productshow[4] . "\r\n"; $apache .= 'RewriteCond %{QUERY_STRING} ^(.*)$' . "\r\n"; $apache .= 'RewriteRule ^(.*)/' . $r_case[0] . '$ $1/' . $r_case[4] . "\r\n"; $apache .= 'RewriteCond %{QUERY_STRING} ^(.*)$' . "\r\n"; $apache .= 'RewriteRule ^(.*)/' . $r_caseshow[0] . '$ $1/' . $r_caseshow[4] . "\r\n"; $apache .= 'RewriteCond %{QUERY_STRING} ^(.*)$' . "\r\n"; $apache .= 'RewriteRule ^(.*)/' . $r_join[0] . '$ $1/' . $r_join[4] . "\r\n"; $apache .= 'RewriteCond %{QUERY_STRING} ^(.*)$' . "\r\n"; $apache .= 'RewriteRule ^(.*)/' . $r_joinshow[0] . '$ $1/' . $r_joinshow[4] . "\r\n"; $apache .= 'RewriteCond %{QUERY_STRING} ^(.*)$' . "\r\n"; $apache .= 'RewriteRule ^(.*)/' . $r_message[0] . '$ $1/' . $r_message[4] . "\r\n"; $apache .= 'RewriteCond %{QUERY_STRING} ^(.*)$' . "\r\n"; $apache .= 'RewriteRule ^(.*)/' . $r_contact[0] . '$ $1/' . $r_contact[4] . "\r\n"; $apache .= 'RewriteCond %{QUERY_STRING} ^(.*)$' . "\r\n"; $apache .= 'RewriteRule ^(.*)/' . $r_soft[0] . '$ $1/' . $r_soft[4] . "\r\n"; $apache .= 'RewriteCond %{QUERY_STRING} ^(.*)$' . "\r\n"; $apache .= 'RewriteRule ^(.*)/' . $r_softshow[0] . '$ $1/' . $r_softshow[4] . "\r\n"; $apache .= 'RewriteCond %{QUERY_STRING} ^(.*)$' . "\r\n"; $apache .= 'RewriteRule ^(.*)/' . $r_goods[0] . '$ $1/' . $r_goods[4] . "\r\n"; $apache .= 'RewriteCond %{QUERY_STRING} ^(.*)$' . "\r\n"; $apache .= 'RewriteRule ^(.*)/' . $r_goodsshow[0] . '$ $1/' . $r_goodsshow[4] . "\r\n"; $apache .= 'RewriteCond %{QUERY_STRING} ^(.*)$' . "\r\n"; $apache .= 'RewriteRule ^(.*)/' . $r_vote[0] . '$ $1/' . $r_vote[4] . "\r\n"; $apache .= 'RewriteCond %{QUERY_STRING} ^(.*)$' . "\r\n"; $apache .= 'RewriteRule ^(.*)/' . $r_custom[0] . '$ $1/' . $r_custom[4] . "\r\n"; //apache虚拟主机规则 $apache2 = 'RewriteCond %{QUERY_STRING} ^(.*)$' . "\r\n"; $apache2 .= 'RewriteRule ^' . $r_index . '$ index.php' . "\r\n"; $apache2 .= 'RewriteCond %{QUERY_STRING} ^(.*)$' . "\r\n"; $apache2 .= 'RewriteRule ^' . $r_about[0] . '$ ' . $r_about[1] . "\r\n"; $apache2 .= 'RewriteCond %{QUERY_STRING} ^(.*)$' . "\r\n"; $apache2 .= 'RewriteRule ^' . $r_news[0] . '$ ' . $r_news[1] . "\r\n"; $apache2 .= 'RewriteCond %{QUERY_STRING} ^(.*)$' . "\r\n"; $apache2 .= 'RewriteRule ^' . $r_newsshow[0] . '$ ' . $r_newsshow[1] . "\r\n"; $apache2 .= 'RewriteCond %{QUERY_STRING} ^(.*)$' . "\r\n"; $apache2 .= 'RewriteRule ^' . $r_product[0] . '$ ' . $r_product[1] . "\r\n"; $apache2 .= 'RewriteCond %{QUERY_STRING} ^(.*)$' . "\r\n"; $apache2 .= 'RewriteRule ^' . $r_productshow[0] . '$ ' . $r_productshow[1] . "\r\n"; $apache2 .= 'RewriteCond %{QUERY_STRING} ^(.*)$' . "\r\n"; $apache2 .= 'RewriteRule ^' . $r_case[0] . '$ ' . $r_case[1] . "\r\n"; $apache2 .= 'RewriteCond %{QUERY_STRING} ^(.*)$' . "\r\n"; $apache2 .= 'RewriteRule ^' . $r_caseshow[0] . '$ ' . $r_caseshow[1] . "\r\n"; $apache2 .= 'RewriteCond %{QUERY_STRING} ^(.*)$' . "\r\n"; $apache2 .= 'RewriteRule ^' . $r_join[0] . '$ ' . $r_join[1] . "\r\n"; $apache2 .= 'RewriteCond %{QUERY_STRING} ^(.*)$' . "\r\n"; $apache2 .= 'RewriteRule ^' . $r_joinshow[0] . '$ ' . $r_joinshow[1] . "\r\n"; $apache2 .= 'RewriteCond %{QUERY_STRING} ^(.*)$' . "\r\n"; $apache2 .= 'RewriteRule ^' . $r_message[0] . '$ ' . $r_message[1] . "\r\n"; $apache2 .= 'RewriteCond %{QUERY_STRING} ^(.*)$' . "\r\n"; $apache2 .= 'RewriteRule ^' . $r_contact[0] . '$ ' . $r_contact[1] . "\r\n"; $apache2 .= 'RewriteCond %{QUERY_STRING} ^(.*)$' . "\r\n"; $apache2 .= 'RewriteRule ^' . $r_soft[0] . '$ ' . $r_soft[1] . "\r\n"; $apache2 .= 'RewriteCond %{QUERY_STRING} ^(.*)$' . "\r\n"; $apache2 .= 'RewriteRule ^' . $r_softshow[0] . '$ ' . $r_softshow[1] . "\r\n"; $apache2 .= 'RewriteCond %{QUERY_STRING} ^(.*)$' . "\r\n"; $apache2 .= 'RewriteRule ^' . $r_goods[0] . '$ ' . $r_goods[1] . "\r\n"; $apache2 .= 'RewriteCond %{QUERY_STRING} ^(.*)$' . "\r\n"; $apache2 .= 'RewriteRule ^' . $r_goodsshow[0] . '$ ' . $r_goodsshow[1] . "\r\n"; $apache2 .= 'RewriteCond %{QUERY_STRING} ^(.*)$' . "\r\n"; $apache2 .= 'RewriteRule ^' . $r_vote[0] . '$ ' . $r_vote[1] . "\r\n"; $apache2 .= 'RewriteCond %{QUERY_STRING} ^(.*)$' . "\r\n"; $apache2 .= 'RewriteRule ^' . $r_custom[0] . '$ ' . $r_custom[1] . "\r\n"; //iis规则 $iis = 'RewriteRule ^(.*)/' . $r_index . '$ $1/index.php' . "\r\n"; $iis .= 'RewriteRule ^(.*)/' . $r_about[0] . '$ $1/' . $r_about[2] . "\r\n"; $iis .= 'RewriteRule ^(.*)/' . $r_news[0] . '$ $1/' . $r_news[2] . "\r\n"; $iis .= 'RewriteRule ^(.*)/' . $r_newsshow[0] . '$ $1/' . $r_newsshow[2] . "\r\n"; $iis .= 'RewriteRule ^(.*)/' . $r_product[0] . '$ $1/' . $r_product[2] . "\r\n"; $iis .= 'RewriteRule ^(.*)/' . $r_productshow[0] . '$ $1/' . $r_productshow[2] . "\r\n"; $iis .= 'RewriteRule ^(.*)/' . $r_case[0] . '$ $1/' . $r_case[2] . "\r\n"; $iis .= 'RewriteRule ^(.*)/' . $r_caseshow[0] . '$ $1/' . $r_caseshow[2] . "\r\n"; $iis .= 'RewriteRule ^(.*)/' . $r_join[0] . '$ $1/' . $r_join[2] . "\r\n"; $iis .= 'RewriteRule ^(.*)/' . $r_joinshow[0] . '$ $1/' . $r_joinshow[2] . "\r\n"; $iis .= 'RewriteRule ^(.*)/' . $r_message[0] . '$ $1/' . $r_message[2] . "\r\n"; $iis .= 'RewriteRule ^(.*)/' . $r_contact[0] . '$ $1/' . $r_contact[2] . "\r\n"; $iis .= 'RewriteRule ^(.*)/' . $r_soft[0] . '$ $1/' . $r_soft[2] . "\r\n"; $iis .= 'RewriteRule ^(.*)/' . $r_softshow[0] . '$ $1/' . $r_softshow[2] . "\r\n"; $iis .= 'RewriteRule ^(.*)/' . $r_goods[0] . '$ $1/' . $r_goods[2] . "\r\n"; $iis .= 'RewriteRule ^(.*)/' . $r_goodsshow[0] . '$ $1/' . $r_goodsshow[2] . "\r\n"; $iis .= 'RewriteRule ^(.*)/' . $r_vote[0] . '$ $1/' . $r_vote[2] . "\r\n"; $iis .= 'RewriteRule ^(.*)/' . $r_custom[0] . '$ $1/' . $r_custom[2] . "\r\n"; //iis7规则 $iis7 = '<rule name="index">' . "\r\n"; $iis7 .= ' <match url="^(.*/)*' . $r_index . '$" />' . "\r\n"; $iis7 .= ' <action type="Rewrite" url="{R:1}/index.php' . '" />' . "\r\n"; $iis7 .= '</rule>' . "\r\n"; $iis7 .= '<rule name="about">' . "\r\n"; $iis7 .= ' <match url="^(.*/)*' . $r_about[0] . '$" />' . "\r\n"; $iis7 .= ' <action type="Rewrite" url="{R:1}/' . $r_about[3] . '" />' . "\r\n"; $iis7 .= '</rule>' . "\r\n"; $iis7 .= '<rule name="news">' . "\r\n"; $iis7 .= ' <match url="^(.*/)*' . $r_news[0] . '$" />' . "\r\n"; $iis7 .= ' <action type="Rewrite" url="{R:1}/' . $r_news[3] . '" />' . "\r\n"; $iis7 .= '</rule>' . "\r\n"; $iis7 .= '<rule name="newsshow">' . "\r\n"; $iis7 .= ' <match url="^(.*/)*' . $r_newsshow[0] . '$" />' . "\r\n"; $iis7 .= ' <action type="Rewrite" url="{R:1}/' . $r_newsshow[3] . '" />' . "\r\n"; $iis7 .= '</rule>' . "\r\n"; $iis7 .= '<rule name="product">' . "\r\n"; $iis7 .= ' <match url="^(.*/)*' . $r_product[0] . '$" />' . "\r\n"; $iis7 .= ' <action type="Rewrite" url="{R:1}/' . $r_product[3] . '" />' . "\r\n"; $iis7 .= '</rule>' . "\r\n"; $iis7 .= '<rule name="productshow">' . "\r\n"; $iis7 .= ' <match url="^(.*/)*' . $r_productshow[0] . '$" />' . "\r\n"; $iis7 .= ' <action type="Rewrite" url="{R:1}/' . $r_productshow[3] . '" />' . "\r\n"; $iis7 .= '</rule>' . "\r\n"; $iis7 .= '<rule name="case">' . "\r\n"; $iis7 .= ' <match url="^(.*/)*' . $r_case[0] . '$" />' . "\r\n"; $iis7 .= ' <action type="Rewrite" url="{R:1}/' . $r_case[3] . '" />' . "\r\n"; $iis7 .= '</rule>' . "\r\n"; $iis7 .= '<rule name="caseshow">' . "\r\n"; $iis7 .= ' <match url="^(.*/)*' . $r_caseshow[0] . '$" />' . "\r\n"; $iis7 .= ' <action type="Rewrite" url="{R:1}/' . $r_caseshow[3] . '" />' . "\r\n"; $iis7 .= '</rule>' . "\r\n"; $iis7 .= '<rule name="join">' . "\r\n"; $iis7 .= ' <match url="^(.*/)*' . $r_join[0] . '$" />' . "\r\n"; $iis7 .= ' <action type="Rewrite" url="{R:1}/' . $r_join[3] . '" />' . "\r\n"; $iis7 .= '</rule>' . "\r\n"; $iis7 .= '<rule name="joinshow">' . "\r\n"; $iis7 .= ' <match url="^(.*/)*' . $r_joinshow[0] . '$" />' . "\r\n"; $iis7 .= ' <action type="Rewrite" url="{R:1}/' . $r_joinshow[3] . '" />' . "\r\n"; $iis7 .= '</rule>' . "\r\n"; $iis7 .= '<rule name="message">' . "\r\n"; $iis7 .= ' <match url="^(.*/)*' . $r_message[0] . '$" />' . "\r\n"; $iis7 .= ' <action type="Rewrite" url="{R:1}/' . $r_message[3] . '" />' . "\r\n"; $iis7 .= '</rule>' . "\r\n"; $iis7 .= '<rule name="contact">' . "\r\n"; $iis7 .= ' <match url="^(.*/)*' . $r_contact[0] . '$" />' . "\r\n"; $iis7 .= ' <action type="Rewrite" url="{R:1}/' . $r_contact[3] . '" />' . "\r\n"; $iis7 .= '</rule>' . "\r\n"; $iis7 .= '<rule name="soft">' . "\r\n"; $iis7 .= ' <match url="^(.*/)*' . $r_soft[0] . '$" />' . "\r\n"; $iis7 .= ' <action type="Rewrite" url="{R:1}/' . $r_soft[3] . '" />' . "\r\n"; $iis7 .= '</rule>' . "\r\n"; $iis7 .= '<rule name="softshow">' . "\r\n"; $iis7 .= ' <match url="^(.*/)*' . $r_softshow[0] . '$" />' . "\r\n"; $iis7 .= ' <action type="Rewrite" url="{R:1}/' . $r_softshow[3] . '" />' . "\r\n"; $iis7 .= '</rule>' . "\r\n"; $iis7 .= '<rule name="goods">' . "\r\n"; $iis7 .= ' <match url="^(.*/)*' . $r_goods[0] . '$" />' . "\r\n"; $iis7 .= ' <action type="Rewrite" url="{R:1}/' . $r_goods[3] . '" />' . "\r\n"; $iis7 .= '</rule>' . "\r\n"; $iis7 .= '<rule name="goodsshow">' . "\r\n"; $iis7 .= ' <match url="^(.*/)*' . $r_goodsshow[0] . '$" />' . "\r\n"; $iis7 .= ' <action type="Rewrite" url="{R:1}/' . $r_goodsshow[3] . '" />' . "\r\n"; $iis7 .= '</rule>' . "\r\n"; $iis7 .= '<rule name="vote">' . "\r\n"; $iis7 .= ' <match url="^(.*/)*' . $r_vote[0] . '$" />' . "\r\n"; $iis7 .= ' <action type="Rewrite" url="{R:1}/' . $r_vote[3] . '" />' . "\r\n"; $iis7 .= '</rule>' . "\r\n"; $iis7 .= '<rule name="custom">' . "\r\n"; $iis7 .= ' <match url="^(.*/)*' . $r_custom[0] . '$" />' . "\r\n"; $iis7 .= ' <action type="Rewrite" url="{R:1}/' . $r_custom[3] . '" />' . "\r\n"; $iis7 .= '</rule>' . "\r\n"; //nginx规则 $nginx = 'rewrite ^([^\\.]*)/' . $r_index . '$ $1/index.php last;' . "\r\n"; $nginx .= 'rewrite ^([^\\.]*)/' . $r_about[0] . '$ $1/' . $r_about[4] . ' last;' . "\r\n"; $nginx .= 'rewrite ^([^\\.]*)/' . $r_news[0] . '$ $1/' . $r_news[4] . ' last;' . "\r\n"; $nginx .= 'rewrite ^([^\\.]*)/' . $r_newsshow[0] . '$ $1/' . $r_newsshow[4] . ' last;' . "\r\n"; $nginx .= 'rewrite ^([^\\.]*)/' . $r_product[0] . '$ $1/' . $r_product[4] . ' last;' . "\r\n"; $nginx .= 'rewrite ^([^\\.]*)/' . $r_productshow[0] . '$ $1/' . $r_productshow[4] . ' last;' . "\r\n"; $nginx .= 'rewrite ^([^\\.]*)/' . $r_case[0] . '$ $1/' . $r_case[4] . ' last;' . "\r\n"; $nginx .= 'rewrite ^([^\\.]*)/' . $r_join[0] . '$ $1/' . $r_join[4] . ' last;' . "\r\n"; $nginx .= 'rewrite ^([^\\.]*)/' . $r_joinshow[0] . '$ $1/' . $r_joinshow[4] . ' last;' . "\r\n"; $nginx .= 'rewrite ^([^\\.]*)/' . $r_message[0] . '$ $1/' . $r_message[4] . ' last;' . "\r\n"; $nginx .= 'rewrite ^([^\\.]*)/' . $r_contact[0] . '$ $1/' . $r_contact[4] . ' last;' . "\r\n"; $nginx .= 'rewrite ^([^\\.]*)/' . $r_soft[0] . '$ $1/' . $r_soft[4] . ' last;' . "\r\n"; $nginx .= 'rewrite ^([^\\.]*)/' . $r_softshow[0] . '$ $1/' . $r_softshow[4] . ' last;' . "\r\n"; $nginx .= 'rewrite ^([^\\.]*)/' . $r_goods[0] . '$ $1/' . $r_goods[4] . ' last;' . "\r\n"; $nginx .= 'rewrite ^([^\\.]*)/' . $r_goodsshow[0] . '$ $1/' . $r_goodsshow[4] . ' last;' . "\r\n"; $nginx .= 'rewrite ^([^\\.]*)/' . $r_vote[0] . '$ $1/' . $r_vote[4] . ' last;' . "\r\n"; $nginx .= 'rewrite ^([^\\.]*)/' . $r_custom[0] . '$ $1/' . $r_custom[4] . ' last;' . "\r\n"; /* * 读取rewriteurl.html * 进行标记替换 */ if (empty($cfg_webpath)) { $webpath = '/'; } else { $webpath = $cfg_webpath; } $config_str = Readf(ADMIN_TEMP . '/html/rewriteurl.html'); $config_str = str_replace('{apache}', $apache, $config_str); $config_str = str_replace('{apache2}', $apache2, $config_str); $config_str = str_replace('{iis}', $iis, $config_str); $config_str = str_replace('{iis7}', $iis7, $config_str); $config_str = str_replace('{nginx}', $nginx, $config_str); $config_str = str_replace('{webpath}', $webpath, $config_str); //将替换后的内容写入rewriteurl.php文件 if (!Writef('rewriteurl.php', $config_str)) { ShowMsg("文件失败 rewriteurl.php 文件失败,可能是由于没有写入权限,因此不能更新配置!", $gourl); exit; } }
$str = '<?php if(!defined(\'IN_PHPMYWIND\')) exit(\'Request Error!\');' . "\r\n\r\n"; $dosql->Execute("SELECT `varname`,`vartype`,`varvalue`,`vargroup` FROM `#@__webconfig` ORDER BY orderid ASC"); while ($row = $dosql->GetArray()) { //强制去掉 ' //强制去掉最后一位 / $vartmp = str_replace("'", '', $row['varvalue']); if (substr($vartmp, -1) == '\\') { $vartmp = substr($vartmp, 1, -1); } if ($row['vartype'] == 'number') { if ($row['varvalue'] == '') { $vartmp = 0; } $str .= "\${$row['varname']} = " . $vartmp . ";\r\n"; } else { $str .= "\${$row['varname']} = '" . $vartmp . "';\r\n"; } } $str .= '?>'; Writef($config_cache, $str); } PutInfo("<strong class='blue'>完成所有数据还原!</strong><br /><br /><a href='?action={$action}'>[如果您的浏览器没有自动跳转,请点击这里]</a>" . $donejs); exit; } $tmsg = "{$tmsg}<div class='red'>成功还原 [{$nowfile}] 的{$oknum}条记录...</div>"; $doform = "<form name='gonext' method='post' action='?action={$action}'>\n\t\t<input type='hidden' name='dopost' value='reset' />\n\t\t<input type='hidden' name='dirname' value='{$dirname}' />\n <input type='hidden' name='startgo' value='1' />\n\t\t<input type='hidden' name='conftb' value='{$conftb}' />\n <input type='hidden' name='tbname' value='{$bakfilesTmp}' /></form>\n\t\t{$dojs}"; PutInfo($tmsg, $doform); exit; //还原操作结束 } }
function WriteConfig() { global $dosql; $str = '<?php if(!defined(\'IN_PHPMYWIND\')) exit(\'Request Error!\');' . "\r\n\r\n"; $dosql->Execute("SELECT `varname`,`vartype`,`varvalue`,`vargroup` FROM `#@__webconfig` ORDER BY `orderid` ASC"); while ($row = $dosql->GetArray()) { //统计代码转义 if ($row['varname'] == 'cfg_countcode') { $row['varvalue'] = stripslashes($row['varvalue']); } if ($row['vartype'] == 'number') { if ($row['varvalue'] == '') { $row['varvalue'] = 0; } $str .= "\${$row['varname']} = " . $row['varvalue'] . ";\r\n"; } else { $str .= "\${$row['varname']} = '" . str_replace("'", '', $row['varvalue']) . "';\r\n"; } } $str .= '?>'; Writef(PHPMYWIND_INC . '/config.cache.php', $str); }
$dosql->ExecNoneQuery($sql); } exit; } //删除记事本 if ($action == 'deladminnotes') { $sql = "DELETE FROM `#@__adminnotes` WHERE `uname`='" . $_SESSION['admin'] . "'"; $dosql->ExecNoneQuery($sql); exit; } //生成验证缓存 if ($action == 'updataauth') { $fdir = PHPMYWIND_DATA . '/cache/auth/'; $fname = 'auth_' . $cfg_auth_key . '.php'; //是否存在缓存 Writef($fdir . $fname, $jsonStr); echo TRUE; exit; } //切换访问设备 if ($action = 'selsiteeq') { $eq = isset($eq) ? $eq : 'pc'; if ($eq == 'pc') { $_SESSION['siteeq'] = 'pc'; } else { if ($eq == 'mobile') { $_SESSION['siteeq'] = 'mobile'; } else { $_SESSION['siteeq'] = 'pc'; } }
<?php //设置文件编码 $action = isset($action) ? $action : ''; //更新编辑文件 if ($action == 'update') { if ($cfg_editfile == 'Y') { //设置读取目录 $dir = PHPMYWIND_ROOT . '/'; //处理写入内容 $content = stripslashes($content); $content = str_replace("##textarea", "<textarea", $content); $content = str_replace("##/textarea", "</textarea", $content); $content = str_replace("##form", "<form", $content); $content = str_replace("##/form", "</form", $content); //内容写入文件 Writef($dir . $filename, $content, 'w'); ShowMsg('文件保存成功!', 'editfile.php'); exit; } else { ShowMsg('后台不允许直接编辑PHP文件!', 'editfile.php'); exit; } } //显示编辑文件 if (!empty($filename)) { //设置读取目录 $dir = PHPMYWIND_ROOT . '/'; $filename = iconv('utf-8', 'gb2312', $filename); $gbfilename = mb_convert_encoding($filename, 'utf-8', 'gb2312'); if (file_exists($dir . $filename)) { $content = '';
function CheckBOM($filename, $autoclear) { $contents = file_get_contents($filename); $charset[1] = substr($contents, 0, 1); $charset[2] = substr($contents, 1, 1); $charset[3] = substr($contents, 2, 1); if (ord($charset[1]) == 239 && ord($charset[2]) == 187 && ord($charset[3]) == 191) { //自动清除 if ($autoclear == 1) { $contstr = substr($contents, 3); Writef($filename, $contstr); return '<span class="red">发现BOM, 已自动清除</span>'; } else { return '<span class="red">发现BOM</span>'; } } else { return '<span class="green">没有发现BOM</span>'; } }