<?php
include_once "header.php";        //引入自訂的共同函數檔
global  $xoopsDB,$xoopsModule,$xoopsModuleConfig;	

if(empty(alignmenturl())) exit;	

//允許傳送變數
$allowvar =array("id","sortid","btntype","enable","dbid","way","dbname","idname","zoomsize");
//接收變數區
foreach($_REQUEST as $var=> $value){	
if(in_array($var,$allowvar)){
 $$var=sqlinjectionfound($val=trim(isset($value)?$value:""));
} 
}



switch($id){
  case "1":
  	  
//管理員權限
if(empty($isAdmin)) exit;    
if(empty($btntype)) exit;    
	
$dbneme="neoblockmenusort";
$where="  where `radiogstyle` = '".$btntype."' &&  `enable` = '1'  order by  sorting  ASC";  //where數值 	
$sortoption=databasetablewhile($dbneme,$where);  
//下拉選單(分類)
foreach($sortoption as $key=> $val){
$options.=optionselect($dataid=$sortoption[$key]['sortid'],$optionname=$sortoption[$key]['sorttitle'],$oid=$sortid,$value=$sortoption[$key]['sortid'],$id="");
}  

$box="<select class='form-control selectbtn'  size='1'  name='options[0]' id='options[0]' >
<option value='0'  data-id='0' >"._MA_NEODWADMIN_TOSHARE03."</option>
".$options."											
</select>

";
$box.="
<script>
$('body').on('change', '.selectbtn', function() {
if($(this).find(':selected').attr('data-id')!='0'){	
$('#title').val($(this).find(':selected').text());
}
});
</script>      
";

 
echo  $box;   

  break;
  
  
case "2":    //佈景區塊選單
    	
if(empty($isAdmin)) exit;          	
if($btntype!='2') exit;  	


//下拉選單
foreach($sortArr=databasetablewhile($dbneme="neoblockmenusort",$where="  order by  sortid  DESC") as $key=> $val){
if($sortArr[$key]['radiogstyle']=='img'){
$value="imgfunction&categoryid=".$sortArr[$key]['sortid']."";
}else{
$value="textfunction&categoryid=".$sortArr[$key]['sortid']."";
}	
$pagrurl['1'].=optionselect($dataid=$sortArr[$key]['sortid'],$optionname=$sortArr[$key]['sorttitle'],$oid="",$value);
}
    
$pagrurl="<div class='row'>
  <div class='col-md-6'>"._MS_SHARED77."</div>
  <div class='col-md-6'> <select  class='form-control' name='sortvar' >
     ".$pagrurl['1']."
  </select>	 <br /></div>
</div>";
    
  echo $pagrurl;  
 break; 
  
  
case "3":    //儲存彈出廣告功能設定
if(empty($isAdmin)) exit;   
update($dbname="config",$set="set conf_value='".$enable."'  where conf_name='neothemesadmin5'");
update($dbname="config",$set="set conf_value='".$way."'  where conf_name='neothemesadmin7'");
break; 
  
  case "4":  //指定播放廣告
//管理員權限
if(empty($isAdmin)) exit;  
//取消其他廣告設定
foreach($adenableArr=databasetablewhile($dbname,$where="  order by  ".$idname."  ASC") as $key=> $val){	
$adenable[$key]=($adenableArr[$key][$idname]==$dbid) ? '1' : '0'; // get TRUE
$setvar="set adenable='".$adenable[$key]."'  where ".$idname."='".$adenableArr[$key][$idname]."'";
update($dbname,$set=$setvar);  
}  
break;  

case "5":    //儲存右下浮動廣告功能設定
if(empty($isAdmin)) exit;   
update($dbname="config",$set="set conf_value='".$enable."'  where conf_name='neothemesadmin8'");
update($dbname="config",$set="set conf_value='".$way."'  where conf_name='neothemesadmin9'");
break; 
  
case "6":    //刪除右下廣告圖檔
if(empty($isAdmin)) exit;   
fileadminfunction($fileurl=XOOPS_ROOT_PATH.'/uploads/'.$xoopsModule->getVar("dirname").'/'.$dbid.'.png',$type="2",$fileex="",$from="",$fileurlnew="",$exclude="");
break; 

case "7":    //儲存區塊說明文字
if(empty($isAdmin)) exit;   
//echo base64_encode($dbid);
update($dbname="config",$set="set conf_value='".$dbid."'  where conf_name='neothemesadmin10'");
break; 

case "8":    //網站放大功能
$logList=moduledb($dbneme="neillibrary_layoutcsslog",$where=" where `ip` = '".get_real_ip()."' && `cookieid` = '".$_COOKIE['neil']['cookieid']."'  order by  logid DESC");
if(!empty($logList)){
$setvar="set zoomsize='".$zoomsize."'  where logid='".$logList['logid']."'";
update($dbname="neillibrary_layoutcsslog",$set=$setvar);
}
break; 

case "9":    //版型配置子選單
if(empty($isAdmin)) exit;   
if($dbid < '3') exit;   

$Arr = array(); //建構陣列
$i=0;
$Arr[$i]['id']='3';  
$Arr[$i]['title']=_MA_NEODWADMIN_TOSHARE01;
$i++;
$Arr[$i]['id']='4';  
$Arr[$i]['title']=_MA_NEODWADMIN_TOSHARE02;
$i++;
$Arr[$i]['id']='5';  
$Arr[$i]['title']=_MA_NEODWADMIN_TOSHARE04;

//下拉選單(呈現方式)
foreach($Arr as $key=> $val){
$optionArr.=optionselect($dataid=$Arr[$key]['id'],$optionname=$Arr[$key]['title'],$oid="".$dbid."",$value=$Arr[$key]['id']);
}
$box="<select  class='form-control' name='field[13]' > 
      ".$optionArr."
     </select>";
	
echo $box;  
break; 


  default:

}


exit; 
 
?>