首页 > CMS建站 > PhpCMS > 正文

给PHPCMS V9 增加关闭网站功能

2020-10-10 21:03:08
字体:
来源:转载
供稿:网友

/phpcms/modules/admin/templates/setting.tpl.php:

在代码:

  1. <div id="div_setting_1" class="contentList pad-10"
  2. <table width="100%"  class="table_form"

后面另起一行:添加代码:

  1. <!-- Admpub: --> 
  2. <tr> 
  3.     <th width="120">网站状态</th> 
  4.     <td class="y-bg"><input name="setconfig[website_is_closed]" value="2" type="radio"<?php echo ($website_is_closed==2) ? ' checked="checked"' : '';?> /> 仅供管理员访问<!-- Only admin -->&nbsp;&nbsp;&nbsp;&nbsp; 
  5.     <input name="setconfig[website_is_closed]" value="1" type="radio"<?php echo ($website_is_closed==1) ? ' checked="checked"' : '';?> /> 禁止所有人访问<!-- Ban all -->&nbsp;&nbsp;&nbsp;&nbsp; 
  6.     <input name="setconfig[website_is_closed]" value="0" type="radio" <?php echo (!$website_is_closed) ? ' checked="checked"' : '';?> /> 允许所有人访问<!-- Open to all --></td> 
  7.   </tr> 
  8.   <tr> 
  9.     <th width="120">关站提示信息</th> 
  10.     <td class="y-bg"><textarea rows="2" cols="20" id="tips" style="height:40px; width:80%" name="setconfig[off_site_because]"><?php echo htmlspecialchars($off_site_because);?></textarea>&nbsp;&nbsp;&nbsp;&nbsp;支持HTML标签</td> //Cuoxin.com 
  11.   </tr> 
  12. <!-- /Admpub --> 

/phpcms/modules/admin/functions/global.func.php

在set_config()函数中,在代码:

if(in_array($k,array(

后面添加:

/*[SWH|+]:*/'website_is_closed','off_site_because',/*[SWH|+];*/

/phpcms/modules/admin/setting.php:

在代码:

set_config($_POST['setconfig']);

前面另起一行,添加代码:

  1. //[SWH|+]: 
  2. if(!emptyempty($_POST['setconfig']['website_is_closed'])){ 
  3.     $str='<!DOCTYPE HTML><html><head><meta http-equiv="Content-Type" content="text/html; charset='.CHARSET.'" /><meta http-equiv="refresh" content="1;url=index.php" /><title></title></head><body></body></html>'
  4.     if(pc_base::load_config('system','lock_ex')){  
  5.         file_put_contents(PHPCMS_PATH.'index.html'$str, LOCK_EX); 
  6.     }else
  7.         file_put_contents(PHPCMS_PATH.'index.html'$str); 
  8.     } 
  9. unset($str); 
  10. //[SWH|+]; 

/index.php:

在代码:pc_base::creat_app();前面另起一行,添加代码:

  1. //[SWH|+]: 
  2. switch(pc_base::load_config('system','website_is_closed')){ 
  3.     case '2'//仅允许后台用户访问 
  4.         $session_storage = 'session_'.pc_base::load_config('system','session_storage'); 
  5.         pc_base::load_sys_class($session_storage); 
  6.         if(!emptyempty($_SESSION['userid']) && !emptyempty($_SESSION['roleid'])){ 
  7.             break
  8.         } 
  9.     case '1'//禁止所有人访问 
  10.         if($_GET['m']=='admin'){ 
  11.             break//可以访问后台 
  12.         } 
  13.         if(pc_base::load_config('system','off_site_because')!==''){ 
  14.             echo nl2br(pc_base::load_config('system','off_site_because')); 
  15.         } 
  16.         exit
  17.     default//向所有公开 
  18. //[SWH|+]; 

/caches/configs/system.php:

在文件末尾的代码:

);?>

前面添加:

  1. 'website_is_closed' => '0'
  2. 'off_site_because' => ''

完毕.

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表