<?php
//-- 引入檔案 --//
include 'header.php'; //XOOPS檔頭
include_once "../function.php"; //引入自訂的共同函數檔
include_once XOOPS_ROOT_PATH."/modules/neillibrary/function/cityadminfunction.php"; //引入城市鄉鎮管理function
	

//-- 所有函數 --//
//-- 流程判斷 ($op 為XOOPS常用之動作變數，用來告知程式欲執行之動作)--//

//允許傳送變數
$allowvar =array("op","cityid","i","status");
//接收變數區
foreach($_REQUEST as $var=> $value){	
if(in_array($var,$allowvar)){
 $$var=sqlinjectionfound($val=trim(isset($value)?$value:""));
} 
}


switch($op){


  case "settingsupdate":
redirect_header(XOOPS_URL. "/modules/".$xoopsModule->getVar("dirname")."/admin/settings.php".settingsupdate()."" ,0 , _MS_SHARED02);    
  break;

/*====城市鄉鎮管理===========*/
  case "city":
$main=neillibrary_cityfunction(); 
    break;
 
  case "cityinsert": 
redirect_header(XOOPS_URL. "/modules/".$xoopsModule->getVar("dirname")."/admin/settings.php?op=city".neillibrary_cityinsert()."" ,0 , _MS_SHARED02);    
  break;

  case "cityupdate": 
redirect_header(XOOPS_URL. "/modules/".$xoopsModule->getVar("dirname")."/admin/settings.php?op=city".neillibrary_cityupdate()."" ,0 , _MS_SHARED02);    
  break;
 
  case "citysortupdate": 
redirect_header(XOOPS_URL. "/modules/".$xoopsModule->getVar("dirname")."/admin/settings.php?op=city".neillibrary_citysortupdate()."" ,0 , _MS_SHARED02);    
  break;  
  

/*======網站資訊============*/
  case "newsfunction":
$main=newsfunction(); 
    break;
  
   case "newsupdate":
redirect_header(XOOPS_URL. "/modules/".$xoopsModule->getVar("dirname")."/admin/settings.php?op=newsfunction".newsupdate()."" ,0 , _MS_SHARED02);    
  break; 
    
      
  default:
$main=settings();
}


//網站資訊
function newsfunction(){
 global $xoopsDB,$xoopsModuleConfig,$xoopsModule; 


//個資保護聲明
$settings['1']=inputtextarea($class="",$name="neillibrary8",$id="",$rows="6",$cols="80",$value="".htmlspecialchars($xoopsModuleConfig['neillibrary8'])."");


$main="<div class='container'>

 <div class='page-header'>
  <h1>"._MA_SETTINGSPHP10."<small >Website information settings</small></h1>
</div>

	<form method='post'  action='{$_SERVER['PHP_SELF']}'>"; 
	   

$main.=" <div class='form-group'>
    <label class='col-sm-12 control-label'><h3>"._MA_SETTINGSPHP11."  <a  href='" .XOOPS_URL. "/modules/". $xoopsModule->getVar("dirname")."/information.php?op=privacy' class='btn  btn-info btn-xs active'>"._MA_SETTINGSPHP12."</a></h3></label>   
     <div class='col-sm-12'>
    ".$settings['1']."
    <br /><br />   
           </div> </div>
  "; 	



$main.="    	  	  	  
 <input type='hidden' name='op' value='newsupdate'>   	  
  	
 <button  type='submit' class='btn btn-primary btn-lg btn-block button'>"._MS_SHARED01."</button>
  </form> </div>

<script src='".XOOPS_URL."/modules/neillibrary/js/ckeditor/ckeditor.js'></script>
<script>
CKEDITOR.replace('neillibrary8' , {
toolbar : 'my' ,
skin: 'moono'	
	    });
</script>   
 
 
 "; 
if(!empty(modulesmidvar($modulesid="xLanguage",$var="isactive"))){
$main.="<script>neillibrary_llanguagetext(afterid='#buttonbar_mod');</script>";
}



 return $main;
}



//系統設定
function settings(){
 global $xoopsDB,$xoopsModuleConfig; 



//是否啟用瀏覽裝置偵測功能
$settings['1']=radioinline($class="",$name="neillibrary1",$text=array(_MS_SHARED04,_MS_SHARED03),$checked=$xoopsModuleConfig['neillibrary1']); 

//刪除紀錄及解除IP封鎖時間
$settings['2']=inputtext($class="",$name="neillibrary2",$value="".$xoopsModuleConfig['neillibrary2']."",$placeholder="".$xoopsModuleConfig['neillibrary2'].""); 

//ck編輯器上傳圖片寬度
$settings['3']=inputtext($class="",$name="neillibrary3",$value="".$xoopsModuleConfig['neillibrary3']."",$placeholder="".$xoopsModuleConfig['neillibrary3'].""); 

//ck編輯器圖片最大高度
$settings['4']=inputtext($class="",$name="neillibrary4",$value="".$xoopsModuleConfig['neillibrary4']."",$placeholder="".$xoopsModuleConfig['neillibrary4'].""); 

//自動刪除caches時間
$settings['5']=inputtext($class="",$name="neillibrary5",$value="".$xoopsModuleConfig['neillibrary5']."",$placeholder="".$xoopsModuleConfig['neillibrary5'].""); 

//清空伺服器temp資料夾路徑
$settings['6']=inputtext($class="",$name="neillibrary7",$value="".$xoopsModuleConfig['neillibrary7']."",$placeholder="".$xoopsModuleConfig['neillibrary7'].""); 

//表單驗證可答錯次數
$settings['7']=inputtext($class="",$name="neillibrary9",$value="".$xoopsModuleConfig['neillibrary9']."",$placeholder="".$xoopsModuleConfig['neillibrary9'].""); 

//自動刪除temp資料夾檔案數量上限
$settings['8']=inputtext($class="",$name="neillibrary10",$value="".$xoopsModuleConfig['neillibrary10']."",$placeholder="".$xoopsModuleConfig['neillibrary10'].""); 

//清除模組QRcode重新產生圖檔
$settings['9']=radioinline($class="",$name="clearqrcode",$text=array(_MA_SETTINGSPHP18,_MA_SETTINGSPHP17),$checked='0'); 

//清除表單封鎖IP
$settings['10']=radioinline($class="",$name="clearip",$text=array(_MA_SETTINGSPHP18,_MA_SETTINGSPHP17),$checked='0'); 

//留言重複內容允許次數
$settings['11']=inputtext($class="",$name="neillibrary12",$value="".$xoopsModuleConfig['neillibrary12']."",$placeholder="".$xoopsModuleConfig['neillibrary12'].""); 

//附件檔上傳圖片最大寬度
$settings['12']=inputtext($class="",$name="neillibrary13",$value="".$xoopsModuleConfig['neillibrary13']."",$placeholder="".$xoopsModuleConfig['neillibrary13'].""); 


$main="<div class='container'>

 <div class='page-header'>
  <h1>"._MA_SETTINGSPHP01."<small >system program</small> </h1>
</div>

	<form method='post'  action='{$_SERVER['PHP_SELF']}'>"; 
	   




 
$main.=" <div class='form-group'>
    <label class='col-sm-3 control-label'>"._MA_SETTINGSPHP02."</label>   
     <div class='col-sm-9'>
    ".$settings['1']."
    <br /><br />   
           </div> </div>
  "; 	


$main.=" <div class='form-group'>	
<label class='col-sm-3'>"._MA_SETTINGSPHP03."</label>
 		 <div class='col-sm-9'> ".$settings['2']."    <br /></div> 
 		</div> 	
 	 "; 


$main.=" <div class='form-group'>	
<label class='col-sm-3'>"._MA_SETTINGSPHP13."</label>
 		 <div class='col-sm-9'> ".$settings['7']."    <br /></div> 
 		</div> 	
 	 "; 

$main.=" <div class='form-group'>	
<label class='col-sm-3'>"._MA_SETTINGSPHP04."</label>
 		 <div class='col-sm-9'> ".$settings['3']."    <br /></div> 
 		</div> 	
 	 "; 


$main.=" <div class='form-group'>	
<label class='col-sm-3'>"._MA_SETTINGSPHP05."</label>
 		 <div class='col-sm-9'> ".$settings['4']."    <br /></div> 
 		</div> 	
 	 "; 

$main.=" <div class='form-group'>	
<label class='col-sm-3'>"._MA_SETTINGSPHP24."</label>
 		 <div class='col-sm-9'> ".$settings['12']."    <br /></div> 
 		</div> 	
 	 "; 


$main.=" <div class='form-group'>	
<label class='col-sm-3'>"._MA_SETTINGSPHP06."</label>
 		 <div class='col-sm-9'> ".$settings['5']."<span id='helpBlock' class='help-block'>".sprintf(_MA_SETTINGSPHP09,timedate($datevar="".$xoopsModuleConfig['neillibrary6']."",$type="2",$calculate="+",$m="",$d=$xoopsModuleConfig['neillibrary5'],$y=""))."</span>	<br /></div> 
 		</div> 	
 	 "; 

$main.=" <div class='form-group'>	
<label class='col-sm-3'>"._MA_SETTINGSPHP07."</label>
 		 <div class='col-sm-9'> ".$settings['6']." <span id='helpBlock' class='help-block'>"._MA_SETTINGSPHP08."</span>	<br /></div> 
 		</div> 	  
 	 "; 

$main.=" <div class='form-group'>	
<label class='col-sm-3'>"._MA_SETTINGSPHP14."</label>
 		 <div class='col-sm-9'> ".$settings['8']." <span id='helpBlock' class='help-block'>"._MA_SETTINGSPHP15."</span>	<br /></div> 
 		</div> 	  
 	 "; 
$main.=" <div class='form-group'>	
<label class='col-sm-3'>"._MA_SETTINGSPHP22."</label>
 		 <div class='col-sm-9'> ".$settings['11']." <span id='helpBlock' class='help-block'>"._MA_SETTINGSPHP23."</span>	<br /></div> 
 		</div> 	  
 	 "; 

$main.=" <div class='form-group'>	
<label class='col-sm-3'>"._MA_SETTINGSPHP16."</label>
 		 <div class='col-sm-9'> ".$settings['9']." <span id='helpBlock' class='help-block'>"._MA_SETTINGSPHP19."</span>	<br /></div> 
 		</div> 	  
 	 "; 

$main.=" <div class='form-group'>	
<label class='col-sm-3'>"._MA_SETTINGSPHP20."</label>
 		 <div class='col-sm-9'> ".$settings['10']." <span id='helpBlock' class='help-block'>"._MA_SETTINGSPHP21."</span>	<br /></div> 
 		</div> 	  
 	 "; 

$main.="    	  	  	  
 <input type='hidden' name='op' value='settingsupdate'>   	  
  	
 <button  type='submit' class='btn btn-primary btn-lg btn-block button'>"._MS_SHARED01."</button>
  </form> </div>"; 
 
 
 
 return $main;
}









//網站資訊更新
function newsupdate(){
  global $xoopsDB; 
  
//去資料表標籤-去除空白跟HTML標籤
$_POST=strip_tagsremovesqlArr($allowvar="",$postvar=$_POST,$sqltags=array("neillibrary8"));  

 
//更新個資保護聲明
update($dbname="config",$set="set conf_value='{$_POST['neillibrary8']}'  where conf_name='neillibrary8'");

}





//系統設定更新
function settingsupdate(){
  global $xoopsDB;   

//更新瀏覽裝置偵測設定
update($dbname="config",$set="set conf_value='{$_POST['neillibrary1']}'  where conf_name='neillibrary1'");

//更新刪除紀錄及解除IP封鎖時間
update($dbname="config",$set="set conf_value='{$_POST['neillibrary2']}'  where conf_name='neillibrary2'");

//更新ck編輯器上傳圖片寬度
update($dbname="config",$set="set conf_value='{$_POST['neillibrary3']}'  where conf_name='neillibrary3'");

//更新ck編輯器圖片最大高度
update($dbname="config",$set="set conf_value='{$_POST['neillibrary4']}'  where conf_name='neillibrary4'");

//更新自動刪除caches時間
update($dbname="config",$set="set conf_value='{$_POST['neillibrary5']}'  where conf_name='neillibrary5'");

//更新清空伺服器temp資料夾路徑
update($dbname="config",$set="set conf_value='{$_POST['neillibrary7']}'  where conf_name='neillibrary7'");


//更新表單驗證可答錯次數
update($dbname="config",$set="set conf_value='{$_POST['neillibrary9']}'  where conf_name='neillibrary9'");


//更新自動刪除temp資料夾檔案數量上限
update($dbname="config",$set="set conf_value='{$_POST['neillibrary10']}'  where conf_name='neillibrary10'");

//更新留言內容重複允許次數
update($dbname="config",$set="set conf_value='{$_POST['neillibrary12']}'  where conf_name='neillibrary12'");

//更新附件檔上傳圖片最大寬度
update($dbname="config",$set="set conf_value='{$_POST['neillibrary13']}'  where conf_name='neillibrary13'");



//清除模組QRcode重新產生圖檔
if(!empty($_POST['clearqrcode'])) fileadminfunction($fileurl="",$type="5",$fileex="",$from=$from=XOOPS_ROOT_PATH.'/uploads/neillibrary/qrcode',$fileurlnew="",$exclude=array(''));


//清除表單防機器人封鎖IP
if(!empty($_POST['clearip'])) truncatefunction($DBname="robotip");


}






echo $main;
include "footer.php"; //XOOPS檔尾
?>