<?php
foreach(array_keys($_FILES) as  $val){	
if(!empty($_FILES[$val]['name'])  &&  !is_array($_FILES[$val]['type'])){	
$_FILES[$val]['name']=strtotime(date("Y-m-d H:i:s")).'.'.substr(strrchr($_FILES[$val]['name'], '.'), 1);
}
}	
include_once "header.php";        //引入自訂的共同函數檔

global  $xoopsDB,$xoopsModule,$xoopsConfig,$xoopsTpl;

$selectid=(empty($_REQUEST['selectid']))?"":$_REQUEST['selectid'];  
$status=(empty($_REQUEST['status']))?"":$_REQUEST['status'];  
$exchange=(empty($_REQUEST['exchange']))?"":$_REQUEST['exchange'];  
$selectidedit=(empty($_REQUEST['selectidedit']))?"":$_REQUEST['selectidedit'];  
$cartnumber=(empty($_REQUEST['cartnumber']))?"":$_REQUEST['cartnumber'];  
$carttype=(empty($_REQUEST['carttype']))?"0":$_REQUEST['carttype'];  
$suid=(empty($_REQUEST['suid']))?"":$_REQUEST['suid'];  
$checkboxArr=(empty($_REQUEST['checkboxArr']))?"":$_REQUEST['checkboxArr'];  
$prderpeopleid=(empty($_REQUEST['prderpeopleid']))?"":$_REQUEST['prderpeopleid'];  
$ordernumber=(empty($_REQUEST['ordernumber']))?"":$_REQUEST['ordernumber'];  
$total=(empty($_REQUEST['total']))?"":$_REQUEST['total'];  
$coststotal=(empty($_REQUEST['coststotal']))?"":$_REQUEST['coststotal'];  
$invoicetype=(empty($_REQUEST['invoicetype']))?"":$_REQUEST['invoicetype'];  
$prderpeopletext=(empty($_REQUEST['prderpeopletext']))?"":$_REQUEST['prderpeopletext'];  
$receivertext=(empty($_REQUEST['receivertext']))?"":$_REQUEST['receivertext'];  
$invoicetext=(empty($_REQUEST['invoicetext']))?"":$_REQUEST['invoicetext'];  
$donatetext=(empty($_REQUEST['donatetext']))?"":$_REQUEST['donatetext'];  
$remarks=(empty($_REQUEST['remarks']))?"":$_REQUEST['remarks'];  
$payment=(empty($_REQUEST['payment']))?"":$_REQUEST['payment'];  
$orderstatus=(empty($_REQUEST['orderstatus']))?"":$_REQUEST['orderstatus'];  
$neilshopcartid=(empty($_REQUEST['neilshopcartid']))?"":$_REQUEST['neilshopcartid'];  
$orderid=(empty($_REQUEST['orderid']))?"":$_REQUEST['orderid'];  
$phone=(empty($_REQUEST['phone']))?"":$_REQUEST['phone'];  
$telephone=(empty($_REQUEST['telephone']))?"":$_REQUEST['telephone'];  
$addresslist=(empty($_REQUEST['addresslist']))?"":$_REQUEST['addresslist'];  
$payment=(empty($_REQUEST['payment']))?"":$_REQUEST['payment'];  
$returnsmane=(empty($_REQUEST['returnsmane']))?"":$_REQUEST['returnsmane'];  
$shopcartid=(empty($_REQUEST['shopcartid']))?"":$_REQUEST['shopcartid'];  
$blacklist=(empty($_REQUEST['blacklist']))?"0":$_REQUEST['blacklist'];  
$receiverid=(empty($_REQUEST['receiverid']))?"0":$_REQUEST['receiverid'];  
$receiverreturn=(empty($_REQUEST['receiverreturn']))?"0":$_REQUEST['receiverreturn'];  
$listreturn=(empty($_REQUEST['list']))?"0":$_REQUEST['list'];  
$invoiceid=(empty($_REQUEST['invoiceid']))?"0":$_REQUEST['invoiceid'];  
$uniformnumbers=(empty($_REQUEST['uniformnumbers']))?""._MS_SHOPPINGCART69."":$_REQUEST['uniformnumbers'];  
$invoicetitle=(empty($_REQUEST['invoicetitle']))?"":$_REQUEST['invoicetitle'];  
$invoiceuser=(empty($_REQUEST['invoiceuser']))?"":$_REQUEST['invoiceuser'];  
$operating=(empty($_REQUEST['operating']))?"":$_REQUEST['operating'];  
$pageid=(empty($_REQUEST['pageid']))?"":$_REQUEST['pageid'];  
$monday=(empty($_REQUEST['monday']))?"":$_REQUEST['monday'];  
$tuesday=(empty($_REQUEST['tuesday']))?"":$_REQUEST['tuesday'];  
$wednesday=(empty($_REQUEST['wednesday']))?"":$_REQUEST['wednesday'];  
$thursday=(empty($_REQUEST['thursday']))?"":$_REQUEST['thursday'];  
$friday=(empty($_REQUEST['friday']))?"":$_REQUEST['friday'];  
$enfunction=(empty($_REQUEST['enfunction']))?"":$_REQUEST['enfunction'];  
$basid=(empty($_REQUEST['basid']))?"":$_REQUEST['basid'];  
$sortid=(empty($_REQUEST['sortid']))?"":$_REQUEST['sortid'];  
$sortvar=(empty($_REQUEST['sortvar']))?"":$_REQUEST['sortvar'];  
$movieurl=(empty($_REQUEST['movieurl']))?"":$_REQUEST['movieurl'];  
$reviewtype=(empty($_REQUEST['reviewtype']))?"":$_REQUEST['reviewtype']; 
$review=(empty($_REQUEST['review']))?"":$_REQUEST['review']; 
$robot=(empty($_REQUEST['robot']))?"":$_REQUEST['robot']; 
$imguploader=(empty($_REQUEST['imguploader']))?"":$_REQUEST['imguploader']; 

//防外部傳參
if(empty(alignmenturl())) exit;	

//允許傳送變數
$allowvar =array("id","sorttitle","sorttext","dbid","groupid","type","operation","fileid","newsid","albumid","name","email","enable","timedate","reviewtext","check","operate","of_sortid","moviedescription","title","movieid");

//接收變數區
foreach($_REQUEST as $var=> $value){	
if(in_array($var,$allowvar)){
$$var=sqlinjectionfound($val=trim(isset($value)?$value:""));
} 
}






//陣列
$Arr=isset($_REQUEST['Arr'])?$_REQUEST['Arr']:"";


$number=8; //當前var變數編號
for ($i=1 ; $i<=$number ; $i++) {
${"var".$i}=(isset($_REQUEST["var".$i]))?$_REQUEST['var'.$i]:""; 
}
unset($number,$i); //刪除變數


//引入模組函數	
$xoopsmodule=(empty($_REQUEST['xoopsmodule']))?"":$_REQUEST['xoopsmodule'];  
if(!empty($xoopsmodule)){
include_once XOOPS_ROOT_PATH."/modules/".$xoopsmodule."/function.php";	
include_once XOOPS_ROOT_PATH."/modules/".$xoopsmodule."/blocks_function.php";	
include_once XOOPS_ROOT_PATH."/modules/".$xoopsmodule."/language/".$xoopsConfig['language']."/main.php";	
include_once XOOPS_ROOT_PATH."/modules/".$xoopsmodule."/language/".$xoopsConfig['language']."/blocks.php";	
}



if(!empty($imguploader)){
//上傳圖檔

include_once XOOPS_ROOT_PATH."/modules/neillibrary/class/imguploader.php";	
}

switch($id){
  case "1":
$where=" where `nsn` = '$dbid'";
$DBname="neothemeskeyword";  
!empty($isAdmin) ? deletefunction($where,$DBname) : '';  
  break;
  
  case "2":
$where=" where `donateid` = '$dbid'";
$DBname="neilshopinvoicedonation";  
!empty($isAdmin) ? deletefunction($where,$DBname) : '';  
  break;    
  
  case "3":
$where=" where `logisticsid` = '$dbid'";
$DBname="neilshoplogistics";  
!empty($isAdmin) ? deletefunction($where,$DBname) : '';  
  break;    

  case "4":
/*$where=" where `sortid` = '$dbid'";
$DBname="neilshopsort";  
!empty($isAdmin) ? deletefunction($where,$DBname) : '';  */


$dbneme="neilshopsort";
//第一層
$where="  where `sortid` = '".$dbid."'   order by  sortidsort  DESC";  //where數值
$Arr=databasetablewhile($dbneme,$where);


//遞回開始
foreach($Arr as $key=> $val){
$sortvar.=$Arr[$key]['sortid'].","; 
$sortvar.=sortretorted($dbneme,$sortid="".$Arr[$key]['sortid']."");
}

//去除最後一個字元
$sortvar=substr($sortvar,0,-1);
//切割陣列
$sortvarArr=cuttingfunction($cutting=$sortvar,$sign=",");


foreach($sortvarArr as $key=> $val){
$where=" where `sortid` = '".$val."'";
$DBname="neilshopsort";  
!empty($isAdmin) ? deletefunction($where,$DBname) : '';

//組合刪除
$deletetr.="#deletetr".$val.",";
}
//去除最後一個字元
$deletetr=substr($deletetr,0,-1);


echo json_encode($deletetr);exit;
  break;
 
  case "5":
//讀取neilshopsort資料表 
$dbneme="neilshopsort";  //資料表名稱


if($exchange=='true'){
$dbid=$dbid;
}else{
$dbid=$selectidedit;
}

if($status==edit){
if($exchange=='true'){
 $where=" where `of_sortid` = '".$dbid."' &&  `enable` = '1' order by sortidsort ASC";   //where數值-修改
}else{
 $where=" where `of_sortid` = '".$dbid."' &&  `enable` = '1' order by sortidsort ASC";   //where數值-修改 
 /*$sortselect=moduledb($dbneme,$where);
 $oid=$sortselect['sortid'];*/
}
}else{
  $where=" where `of_sortid` = '".$dbid."' &&  `enable` = '1' order by sortidsort ASC";   //where數值-新增
}

if(!empty($dbid)){
//$sort=!empty($isAdmin) ? databasetablewhile($dbneme,$where) : ''; 
$sort=databasetablewhile($dbneme,$where); 
}
$optionone.=optionbox($sortvar=$sort,$oid=$of_sortid);

if(!empty($optionone)){
$select.="<select id=".$selectid." class='form-control' name='of_sortid' >
	 <option   data-id='".$dbid."' value=".$dbid."  >"._MS_SHARED13."</option>
     	".$optionone."   
  </select>	 <p>

";
}
echo $select.="
	<script>var level='1';</script>	
 <script src='".XOOPS_URL."/modules/neilshop/js/ajaxjs.js'></script>
";

  break;

  case "6":
//讀取neilshopsort資料表 
$dbneme="neilshopsort";  //資料表名稱


if($exchange=='true'){
$dbid=$dbid;
}else{
$dbid=$selectidedit;
}

if($status==edit){
if($exchange=='true'){
 $where=" where `of_sortid` = '".$dbid."' &&  `enable` = '1' order by sortidsort ASC";   //where數值-修改
}else{
 $where=" where `of_sortid` = '".$dbid."' &&  `enable` = '1' order by sortidsort ASC";   //where數值-修改 
/* $sortselect=moduledb($dbneme,$where);
 $oid=$sortselect['sortid'];*/
}
}else{
  $where=" where `of_sortid` = '".$dbid."' &&  `enable` = '1' order by sortidsort ASC";   //where數值-新增
}

if(!empty($dbid)){
//$sort=!empty($isAdmin) ? databasetablewhile($dbneme,$where) : ''; 
$sort=databasetablewhile($dbneme,$where); 
}
$optionone.=optionbox($sortvar=$sort,$oid=$of_sortid);

if(!empty($optionone)){
 $select.="<select id=".$selectid." class='form-control' name='of_sortid' >
	 <option   data-id='".$dbid."' value=".$dbid."  >"._MS_SHARED13."</option>
     	".$optionone."   
  </select>	 <p>

";
}

$select.="<script>var level='2';</script>";

if($exchange=='true'){
$select.="	
  <script src='".XOOPS_URL."/modules/neilshop/js/ajaxjs.js'></script>
	 ";}
echo $select;

  break;


  case "7":
//讀取neilshopsort資料表 
$dbneme="neilshopsort";  //資料表名稱


if($exchange=='true'){
$dbid=$dbid;
}else{
$dbid=$selectidedit;
}


if($status==edit){
if($exchange=='true'){
 $where=" where `of_sortid` = '".$dbid."' &&  `enable` = '1' order by sortidsort ASC";   //where數值-修改
}else{
 $where=" where `of_sortid` = '".$dbid."' &&  `enable` = '1' order by sortidsort ASC";   //where數值-修改 
 /*$sortselect=moduledb($dbneme,$where);
 $oid=$sortselect['sortid'];*/
}
}else{
  $where=" where `of_sortid` = '".$dbid."' &&  `enable` = '1' order by sortidsort ASC";   //where數值-新增
}

if(!empty($dbid)){
//$sort=!empty($isAdmin) ? databasetablewhile($dbneme,$where) : ''; 
$sort=databasetablewhile($dbneme,$where); 
}
$optionone.=optionbox($sortvar=$sort,$oid=$of_sortid);

if(!empty($optionone)){
echo $select.="<select id=".$selectid." class='form-control' name='of_sortid' >
	 <option   data-id='".$dbid."' value=".$dbid."  >"._MS_SHARED13."</option>
     	".$optionone."   
  </select>	 <p>

";
}
  break;

  case "8":
$where=" where `deliveryid` = '$dbid'";
$DBname="neilshopdelivery";  
!empty($isAdmin) ? deletefunction($where,$DBname) : '';  
  break;    

  case "9":
$where=" where `giftsid` = '$dbid'";
$DBname="neilshopgifts";  
!empty($isAdmin) ? deletefunction($where,$DBname) : '';  
  break;  

  case "10":
//讀取商品資料表
 $dbneme="neilshopproductcontent";  //資料表名稱
  $where=" where `productid` = '$dbid' and  `ordernumber` = '0' ";
 $productDB=moduledb($dbneme,$where); 	  


if(empty($productDB)){
$data=_MS_SHOPPINGCART45;
}else{
!empty($isAdmin) ? deletefunction($where,$dbneme) : ''; 
}

echo $data;	   
  break;

  case "11":
//取的ip位置
$userip=get_real_ip();
//取得UID
$uid=$user_uid;
//購物車存放商品上限
  $dbneme="config";  //資料表名稱
  $where=" where `conf_name` = 'numbercapped'";   //where數值-修改
  $confignumbercapped=moduledb($dbneme,$where);

  $dbneme="neilshopproductcontent";  //資料表名稱
  $where=" where `productid` = '".$dbid."' and  `productstatus` != 'notshelves' ";   //where數值-修改
  $productLimt=moduledb($dbneme,$where);
  //取得商品金額
 /* if($productLimt['productstatus']=='promotions'){ //判斷是否為促銷商品
  $amount=$productLimt['discountprice']; 
  }else{
  $amount=$productLimt['price'];	   
  }*/



  
//贈品陣列轉字串
if(!empty($checkboxArr)){
 $giftsid=phpconversion($conversion=$checkboxArr,$type="serialize");
} 


$statusdata=true;
//判斷商品數量為0
if($productLimt['amount']==0){
$data=_MD_AJAX01;
$statusdata=false;
}

if($cartnumber > productLimt['amount']){
$statusdata=false;
}

$dbneme="neilshopcart";  //資料表名稱
//判斷是否訂購同樣商品
 $where=" where `enable` = '0' and  `productid` = '".$dbid."'  and  `carttype` = '".$carttype."' and (`userip` = '".$userip."' or  `uid` = '".$uid."')";   //where數值-修改
 $cappedLimt=moduledb($dbneme,$where);
if(!empty($cappedLimt['productid'])){
  $data=_MD_AJAX03;
  $statusdata=false;
}

//判斷訂購商品上限次數
  $where=" where `enable` = '0' and  `carttype` = '".$carttype."' and  (`userip` = '".$userip."' or  `uid` = '".$uid."')";   //where數值-修改
  $cappedArr=databasetablewhile($dbneme,$where);
//  $capped=count($cappedArr);
   $capped = is_array($cappedArr) ? count($cappedArr) : 0 ; 
  
  if($capped>$confignumbercapped['conf_value']){
  $data=_MD_AJAX02;
  $statusdata=false;
  }

//黑名單判斷
$blacklist=blacklistfunction($suid=$uid);
if($blacklist==1){
$data=_MD_AJAX10;
$statusdata=false;
}

//欄位數字判斷
if(!is_numeric($cartnumber)){
$data=_MD_AJAX12;
$statusdata=false;
} 
 

if($statusdata==true and !empty($productLimt['productid'])){ 	 	
$valuesvar="(userip,productid,giftsid,uid,cartnumber,carttype) values('{$userip}','{$dbid}','{$giftsid}','{$uid}','{$cartnumber}','{$carttype}')";	  
insert($dbname="neilshopcart",$values=$valuesvar);  
if($carttype==1){
$data=_MD_AJAX04;
}else{
$data=_MD_AJAX05;
}

}

  
/*$data=$uid;
$data="error";*/
echo $data;	  



  break;      
      

  case "12":
//取的ip位置
$userip=get_real_ip();
//取得UID
$uid=$user_uid;  	  
$dbneme="neilshopcart";  //資料表名稱
//判斷是否訂購同樣商品
 $where=" where `enable` = '0' and   `carttype` = '1' and (`userip` = '".$userip."' or  `uid` = '".$uid."')";   //where數值-修改
 $cartnumberArr=databasetablewhile($dbneme,$where);	  
 $cartnumber = is_array($cartnumberArr) ? count($cartnumberArr) : 0 ;
//  $cartnumber=count($cartnumberArr);
  echo $cartnumber;
  break;    
  
  
  case "13":
//確認刪除者UID相符
$readpermission=readpermission($user_uid=$suid);	
	   	   
   	   
$where=" where `shopcartid` = '$dbid'";
$DBname="neilshopcart";  

if(!empty($xoopsUser) and !empty($readpermission)){
deletefunction($where,$DBname);
} 

  break;    
  
  
  case "14":
//訂購人資料
//取得UID
$uid=$user_uid;  

//讀取購買者資料
$dbneme="neilshoppurchaser";
$where=" where `uid` = '".$uid."' ";   //where數值-修改
$shoppurchaser=moduledb($dbneme,$where);

//讀取收件人資料表
$dbneme="neilshopreceiver";
$where=" where `uid` = '".$uid."' &&  `receiverid` = '".$shoppurchaser['receiverid']."' ";   //where數值-修改
$shopreceiver=moduledb($dbneme,$where);



//切割字串(地址)
$address=cuttingfunction($cutting="".$shopreceiver['address']."",$sign="-"); 

//姓名
$shoppingcart['name']=inputtext($class="",$name="recipientname",$value="".$shopreceiver['name']."",$placeholder=""._MS_SHARED21.""._MS_SHOPPINGCART31."",$id="recipientname");
//行動電話	
$shoppingcart['phone']=inputtext($class="",$name="recipientphone",$value="".$shopreceiver['phone']."",$placeholder=""._MS_SHARED21.""._MS_SHOPPINGCART32."",$id="recipientphone");
//聯絡電話	
$shoppingcart['telephone']=inputtext($class="",$name="recipienttelephone",$value="".$shopreceiver['telephone']."",$placeholder=""._MS_SHARED21.""._MS_SHOPPINGCART33."",$id="recipienttelephone");

//地址-縣市	
$shoppingcart['county']=inputtext($class="",$name="recipientcounty",$value="".$address[0]."",$placeholder=""._MS_SHARED21.""._MS_SHOPPINGCART35."",$id="recipientcounty");
//地址-鄉鎮區
$shoppingcart['townshiparea']=inputtext($class="",$name="recipienttownshiparea",$value="".$address[1]."",$placeholder=""._MS_SHARED21.""._MS_SHOPPINGCART36."",$id="recipienttownshiparea");

//地址
$shoppingcart['address']=inputtext($class="",$name="recipientaddress",$value="".$address[2]."",$placeholder=""._MS_SHARED21.""._MS_SHOPPINGCART34."",$id="recipientaddress");

//電子信箱
$shoppingcart['email']=inputtext($class="",$name="recipientemail",$value="".$shopreceiver['email']."",$placeholder=""._MS_SHARED21.""._MS_SHOPPINGCART37."",$id="recipientemail");

if(empty($shopreceiver)){
$prderpeoplechangestyle="style='display: none'";
$shoppingcart['prderpeoplechange']="<input type='hidden' name='prderpeoplechange' value='1'>";
}else{
$shoppingcart['prderpeoplechange']=checkbox($dataid=true,$name="prderpeoplechange",$value="1",$optionname=""._MS_SHOPPINGCART40."",$oid="");  
}

//存入收件件資料
//$shoppingcart['prderpeoplechange']=checkbox($dataid=true,$name="prderpeoplechange",$value="1",$optionname=""._MS_SHOPPINGCART40."",$oid="");  

$receiverbox="
<ul class='list-group'>
  <li class='list-group-item'>
     <span id='helpBlock' class='help-block'>"._MS_SHOPPINGCART31."<span id='help-blockrecipientname' class='red'>("._MS_SHARED22.")</span></span>
    ".$shoppingcart['name']."</li>
  <li class='list-group-item'><span id='helpBlock' class='help-block'>"._MS_SHOPPINGCART32."<span id='help-blockrecipientphone' class='red'>("._MS_SHARED22.")</span></span>".$shoppingcart['phone']."</li>
  <li class='list-group-item'><span id='helpBlock' class='help-block'>"._MS_SHOPPINGCART33."</span>".$shoppingcart['telephone']."</li>
  <li class='list-group-item'> <span id='helpBlock' class='help-block'>"._MS_SHOPPINGCART34."<span id='help-blockrecipientaddress' class='red'>("._MS_SHARED22.")</span></span>
      <div  class='row'>
  <div class='col-md-6 col-md-6custom'>".$shoppingcart['county']."</div>
    <div class='col-md-6 col-md-6custom'>".$shoppingcart['townshiparea']."</div>
     </div>
     ".$shoppingcart['address']."
    
    </li>
  <li class='list-group-item'><span id='helpBlock' class='help-block'>"._MS_SHOPPINGCART37."<span id='help-blockrecipientemail' class='red'>("._MS_SHARED22.")</span></span>".$shoppingcart['email']."</li>
 <li ".$prderpeoplechangestyle." class='list-group-item'>".$shoppingcart['prderpeoplechange']."</li>
	</ul>
 <input type='hidden' name='receiverid' value='".$shopreceiver['receiverid']."'> 		
 <script src='".XOOPS_URL."/modules/neilshop/js/formvalidation.js'></script>		
"; 
echo $receiverbox;
  break;     
  
  
   case "15": 

//取得UID
$uid=$user_uid;  

//讀取購買者資料
$dbneme="neilshoppurchaser";
$where=" where `uid` = '".$uid."' ";   //where數值-修改
$shoppurchaser=moduledb($dbneme,$where);

//讀取發票資料表
$dbneme="neilshopinvoice";
$where=" where `uid` = '".$uid."' &&  `invoiceid` = '".$shoppurchaser['invoiceid']."' ";   //where數值-修改
$neilshopinvoice=moduledb($dbneme,$where);

//切割字串(地址)
$invoiceaddress=cuttingfunction($cutting="".$neilshopinvoice['invoiceaddress']."",$sign="-"); 



//存入統編紀錄中
//$shoppingcart['invoicechange']=checkbox($dataid=true,$name="invoicechange",$value="1",$optionname=""._MS_SHOPPINGCART44."",$oid="");   
 
//統一編號
$shoppingcart['uniformnumbers']=inputtext($class="",$name="uniformnumbers",$value="".$neilshopinvoice['uniformnumbers']."",$placeholder=""._MS_SHARED21.""._MS_SHOPPINGCART39."",$id="uniformnumbers");  
//發票抬頭
$shoppingcart['invoicetitle']=inputtext($class="",$name="invoicetitle",$value="".$neilshopinvoice['invoicetitle']."",$placeholder=""._MS_SHARED21.""._MS_SHOPPINGCART41."",$id="invoicetitle");  
//發票收件人
$shoppingcart['invoiceuser']=inputtext($class="",$name="invoiceuser",$value="".$neilshopinvoice['invoiceuser']."",$placeholder=""._MS_SHARED21.""._MS_SHOPPINGCART42."",$id="invoiceuser");  

//地址-縣市	
$shoppingcart['invoiceusercounty']=inputtext($class="",$name="invoiceusercounty",$value="".$invoiceaddress[0]."",$placeholder=""._MS_SHARED21.""._MS_SHOPPINGCART35."",$id="invoiceusercounty");

//地址-鄉鎮區
$shoppingcart['invoiceusertownshiparea']=inputtext($class="",$name="invoiceusertownshiparea",$value="".$invoiceaddress[1]."",$placeholder=""._MS_SHARED21.""._MS_SHOPPINGCART36."",$id="invoiceusertownshiparea");

//地址
$shoppingcart['invoiceuseraddress']=inputtext($class="",$name="invoiceuseraddress",$value="".$invoiceaddress[2]."",$placeholder=""._MS_SHARED21.""._MS_SHOPPINGCART34."",$id="invoiceuseraddress");
  
if(empty($neilshopinvoice)){
$invoiceaddresschangestyle="style='display: none'";
$shoppingcart['invoicechange']="<input type='hidden' name='invoicechange' value='1'>";

}else{
$shoppingcart['invoicechange']=checkbox($dataid=true,$name="invoicechange",$value="1",$optionname=""._MS_SHOPPINGCART44."",$oid="");    
}
  
  
  
$inputtypebox="
 <span id='helpBlock' class='help-block'>"._MS_SHOPPINGCART39."<span id='help-blockuniformnumbers' class='red'>("._MS_SHOPPINGCART50.")</span></span>
    ".$shoppingcart['uniformnumbers']."
 <span id='helpBlock' class='help-block'>"._MS_SHOPPINGCART41."<span id='help-blockinvoicetitle' class='red'>("._MS_SHARED22.")</span></span>
    ".$shoppingcart['invoicetitle']."
 <span id='helpBlock' class='help-block'>"._MS_SHOPPINGCART42."<span id='help-blockinvoiceuser' class='red'>("._MS_SHARED22.")</span></span>  
    ".$shoppingcart['invoiceuser']." 
    <span id='helpBlock' class='help-block'>"._MS_SHOPPINGCART43."<span id='help-blockinvoiceuseraddress' class='red'>("._MS_SHARED22.")</span></span>
    <div  class='row'>
    <div class='col-md-3 col-md-6custom' >".$shoppingcart['invoiceusercounty']."</div>
    <div class='col-md-3 col-md-6custom' >".$shoppingcart['invoiceusertownshiparea']."</div>
    <div class='col-md-6 col-md-6custom'>".$shoppingcart['invoiceuseraddress']."</div>
    </div>
    <span ".$invoiceaddresschangestyle.">".$shoppingcart['invoicechange']."</span>
    
      <br /> <br /> 
     <input type='hidden' name='invoiceid' value='".$neilshopinvoice['invoiceid']."'> 	  	  
     <script src='".XOOPS_URL."/modules/neilshop/js/formvalidation.js'></script>	
";

  
echo $inputtypebox;     
    break;    
    
    case "16":
//寫入收件人ID   	
//確認操作UID相符
$readpermission=readpermission($user_uid=$suid);	
if(!empty($xoopsUser) and !empty($readpermission)){
$setvar="set receiverid='{$dbid}'  where prderpeopleid='".$prderpeopleid."'";
update($dbname="neilshoppurchaser",$set=$setvar);  
}  
$data='receiver';

echo $data;	  
 	
       break;  	  
       
    case "17":
//寫入發票ID   	
//確認操作UID相符
$readpermission=readpermission($user_uid=$suid);	
if(!empty($xoopsUser) and !empty($readpermission)){
$setvar="set invoiceid='{$dbid}'  where prderpeopleid='".$prderpeopleid."'";
update($dbname="neilshoppurchaser",$set=$setvar);  
}   
$data='invoice';

echo $data;	  	
       break;  	

//訂單寫入
    case "18":
//確認操作UID相符
$readpermission=readpermission($user_uid=$suid);
if(!empty($xoopsUser) and !empty($readpermission)){
	
//讀取訂單資料表
$dbneme="neilshoporder";
$where=" where `uid` = '".$suid."'  order by  orderid   DESC ";   //where數值-修改
$neilshoporder=moduledb($dbneme,$where);

//判斷訂單是否存在
if($neilshoporder['ordernumber']!=$ordernumber){
$valuesvar="(ordernumber,total,coststotal,invoicetype,uid,prderpeopletext,receivertext,invoicetext,donatetext,remarks,payment,orderstatus,neilshopcartid) values('{$ordernumber}','{$total}','{$coststotal}','{$invoicetype}','{$suid}','{$prderpeopletext}','{$receivertext}','{$invoicetext}','{$donatetext}','{$remarks}','{$payment}','{$orderstatus}','{$neilshopcartid}')";	  
insert($dbname="neilshoporder",$values=$valuesvar); 

//讀取訂單資料表
$dbneme="neilshoporder";
$where=" where `uid` = '".$suid."'  order by  orderid   DESC ";   //where數值-修改
$neilshoporder=moduledb($dbneme,$where);

//寫入訂單狀態資料表	
$valuesvar="(orderid,ordertrue) values('".$neilshoporder['orderid']."','".date("Y-m-d H:i:s")."')";	  
insert($dbname="neilshoporderstatus",$values=$valuesvar); 



//購物車寫入enable
$neilshopcartArr=phpconversion($conversion=$neilshopcartid,$type="unserialize"); 
foreach($neilshopcartArr as $key=> $val){

//開啟購物車資料表
$dbneme="neilshopcart";
$where=" where `shopcartid` = '".$val."' ";   //where數值-修改
$neilshopcart=moduledb($dbneme,$where);	

//開啟商品資料表
$dbneme="neilshopproductcontent";
$where=" where `productid` = '".$neilshopcart['productid']."' ";   //where數值-修改
$neilshopproductcontent=moduledb($dbneme,$where);

//商品數量
$amount=$neilshopproductcontent['amount']-$neilshopcart['cartnumber'];
//訂購次數
$ordernumber=$neilshopproductcontent['ordernumber']+$neilshopcart['cartnumber'];

//存入商品資料表 數量
$setvar="set amount='".$amount."', ordernumber='".$ordernumber."'  where productid='".$neilshopcart['productid']."'";
update($dbname="neilshopproductcontent",$set=$setvar);	
	
$setvar="set  enable='1'  where shopcartid='".$val."'";
update($dbname="neilshopcart",$set=$setvar); 
}

//需刪除的SESSION
unset($_SESSION['remarks'][$suid]);
unset($_SESSION['invoicetype'][$suid]);
unset($_SESSION['inputtype'][$suid]);
unset($_SESSION['payment'][$suid]);	

}
}
    	
    	       
      break;     
      
     case "19":    
 $readpermission=readpermission($user_uid=$suid);    	 
 if(!empty($xoopsUser) and !empty($readpermission)){
//解訂單資料表
$dbneme="neilshoporder";
$where=" where `orderid` = '".$orderid."' ";   //where數值-修改
$neilshoporder=moduledb($dbneme,$where);
//字串轉陣列
$prderpeopletextArr=phpconversion($conversion=$neilshoporder['prderpeopletext'],$type="unserialize"); 

if(!empty($isAdmin)){
$button="<button type='button' id='prderpeopedit' class='btn btn-default'>"._MS_SHARED08."</button>";
}


if(empty($operation)){
$scriptbox=" <script src='".XOOPS_URL."/modules/neilshop/js/shoppingcartajax.js'></script>";
}



$prderpeopletexbox="
   <div id='prderpeopeditmane' mane='20,".$suid.",".$orderid."'></div>	
<ul class='list-group'>
  <li class='list-group-item'>"._MS_SHOPPINGCART31.""._MS_SHOPPINGCART46."".$prderpeopletextArr[0]."".$button."</li>
  <li class='list-group-item'>"._MS_SHOPPINGCART32.""._MS_SHOPPINGCART46."".$prderpeopletextArr[1]."</li>    
  <li class='list-group-item'>"._MS_SHOPPINGCART33.""._MS_SHOPPINGCART46."".$prderpeopletextArr[2]."</li>  
   <li class='list-group-item'>"._MS_SHOPPINGCART34.""._MS_SHOPPINGCART46."".$prderpeopletextArr[3]."</li> 
   <li class='list-group-item'>"._MS_SHOPPINGCART47.""._MS_SHOPPINGCART46."".$prderpeopletextArr[4]."</li>       
</ul>
    ".$scriptbox."	
	";


echo $prderpeopletexbox;




 }    	 
     	  
          break;  	 
       
     case "20":
 
 $readpermission=readpermission($user_uid=$suid);    	 
 if(!empty($xoopsUser) and !empty($readpermission)){
//解訂單資料表
$dbneme="neilshoporder";
$where=" where `orderid` = '".$orderid."' ";   //where數值-修改
$neilshoporder=moduledb($dbneme,$where);
//字串轉陣列
$prderpeopletextArr=phpconversion($conversion=$neilshoporder['prderpeopletext'],$type="unserialize"); 

if(!empty($isAdmin)){
$button="<button type='button' id='prderpeopstore' class='btn btn-warning'>"._MS_SHOPPINGCART48."</button>";
}

//姓名
$shoppingcart['name']=inputtext($class="",$name="name",$value="".$prderpeopletextArr[0]."",$placeholder=""._MS_SHARED21.""._MS_SHOPPINGCART31."",$id="chasername");
//行動電話	
$shoppingcart['phone']=inputtext($class="",$name="phone",$value="".$prderpeopletextArr[1]."",$placeholder=""._MS_SHARED21.""._MS_SHOPPINGCART32."",$id="chaserphone");
//聯絡電話	
$shoppingcart['telephone']=inputtext($class="",$name="telephone",$value="".$prderpeopletextArr[2]."",$placeholder=""._MS_SHARED21.""._MS_SHOPPINGCART33."",$id="chasertelephone");

//地址
$shoppingcart['address']=inputtext($class="",$name="addresslist",$value="".$prderpeopletextArr[3]."",$placeholder=""._MS_SHARED21.""._MS_SHOPPINGCART33."",$id="chaseraddresslist");
//電子信箱
$shoppingcart['email']=inputtext($class="",$name="email",$value="".$prderpeopletextArr[4]."",$placeholder=""._MS_SHARED21.""._MS_SHOPPINGCART37."",$id="chaseremail");



$prderpeopletexbox="
   <div id='prderpeopstoremane' mane='21,".$suid.",".$orderid.",19'></div>	
<ul class='list-group'>
  <li class='list-group-item'>
    <div  class='row'>
    <div class='col-md-3'>"._MS_SHOPPINGCART31.""._MS_SHOPPINGCART46."</div>
    <div class='col-md-7'>".$shoppingcart['name']."</div>
    <div class='col-md-2'>".$button."</div>
    </div>	
    	</li>
     <li class='list-group-item'>

     <div  class='row'>
    <div class='col-md-3'>"._MS_SHOPPINGCART32.""._MS_SHOPPINGCART46."</div>
    <div class='col-md-9'>".$shoppingcart['phone']."</div>
     </div>	 
    	</li>
  
      <li class='list-group-item'>

     <div  class='row'>
    <div class='col-md-3'>"._MS_SHOPPINGCART33.""._MS_SHOPPINGCART46."</div>
    <div class='col-md-9'>".$shoppingcart['telephone']."</div>
     </div>	 
    	</li> 
  
      <li class='list-group-item'>

     <div  class='row'>
    <div class='col-md-3'>"._MS_SHOPPINGCART34.""._MS_SHOPPINGCART46."</div>
    <div class='col-md-9'>".$shoppingcart['address']."</div>
     </div>	 
    	</li> 
        <li class='list-group-item'>	 
      <div  class='row'>
    <div class='col-md-3'>"._MS_SHOPPINGCART47.""._MS_SHOPPINGCART46."</div>
    <div class='col-md-9'>".$shoppingcart['email']."</div>
     </div>	 
    	</li>    	 
     
</ul>
   
	";


echo $prderpeopletexbox; 
 
 
  }    	 
          break;    
          
     case "21":          
 //確認操作UID相符
$readpermission=readpermission($user_uid=$suid);
if(!empty($xoopsUser) and !empty($readpermission)){

//購買人資料
$prderpeopletext[0]=$name;
$prderpeopletext[1]=$phone;
$prderpeopletext[2]=$telephone;
$prderpeopletext[3]=$addresslist;
$prderpeopletext[4]=$email;
//陣列轉字串
$prderpeopletext=phpconversion($conversion=$prderpeopletext,$type="serialize"); 

$setvar="set  prderpeopletext='{$prderpeopletext}'  where orderid='".$orderid."'";
update($dbname="neilshoporder",$set=$setvar); 

}         
          
          
           break;   
           
     case "22":


$readpermission=readpermission($user_uid=$suid);    	 
 if(!empty($xoopsUser) and !empty($readpermission)){
//解訂單資料表
$dbneme="neilshoporder";
$where=" where `orderid` = '".$orderid."' ";   //where數值-修改
$neilshoporder=moduledb($dbneme,$where);
//字串轉陣列
$receivertextArr=phpconversion($conversion=$neilshoporder['receivertext'],$type="unserialize"); 

if(!empty($isAdmin)){
$button="<button type='button' id='receiveredit' class='btn btn-default'>"._MS_SHARED08."</button>";
}



$prderpeopletexbox="
   <div id='receivereditmane' mane='23,".$suid.",".$orderid."'></div>	
<ul class='list-group'>
  <li class='list-group-item'>"._MS_SHOPPINGCART31.""._MS_SHOPPINGCART46."".$receivertextArr[0]."".$button."</li>
  <li class='list-group-item'>"._MS_SHOPPINGCART32.""._MS_SHOPPINGCART46."".$receivertextArr[1]."</li>    
  <li class='list-group-item'>"._MS_SHOPPINGCART33.""._MS_SHOPPINGCART46."".$receivertextArr[2]."</li>  
   <li class='list-group-item'>"._MS_SHOPPINGCART34.""._MS_SHOPPINGCART46."".$receivertextArr[3]."</li> 
   <li class='list-group-item'>"._MS_SHOPPINGCART47.""._MS_SHOPPINGCART46."".$receivertextArr[4]."</li>       
</ul>
	
	";


echo $prderpeopletexbox;




 }    	 
    	                         
      break;     
      
  case "23":

 $readpermission=readpermission($user_uid=$suid);    	 
 if(!empty($xoopsUser) and !empty($readpermission)){
//解訂單資料表
$dbneme="neilshoporder";
$where=" where `orderid` = '".$orderid."' ";   //where數值-修改
$neilshoporder=moduledb($dbneme,$where);
//字串轉陣列
$receivertextArr=phpconversion($conversion=$neilshoporder['receivertext'],$type="unserialize"); 

if(!empty($isAdmin)){
$button="<button type='button' id='receiverstore' class='btn btn-warning'>"._MS_SHOPPINGCART48."</button>";
}

//姓名
$shoppingcart['name']=inputtext($class="",$name="name",$value="".$receivertextArr[0]."",$placeholder=""._MS_SHARED21.""._MS_SHOPPINGCART31."",$id="recipientname");
//行動電話	
$shoppingcart['phone']=inputtext($class="",$name="phone",$value="".$receivertextArr[1]."",$placeholder=""._MS_SHARED21.""._MS_SHOPPINGCART32."",$id="recipientphone");
//聯絡電話	
$shoppingcart['telephone']=inputtext($class="",$name="telephone",$value="".$receivertextArr[2]."",$placeholder=""._MS_SHARED21.""._MS_SHOPPINGCART33."",$id="recipientelephone");

//地址
$shoppingcart['address']=inputtext($class="",$name="addresslist",$value="".$receivertextArr[3]."",$placeholder=""._MS_SHARED21.""._MS_SHOPPINGCART33."",$id="recipienaddress");
//電子信箱
$shoppingcart['email']=inputtext($class="",$name="email",$value="".$receivertextArr[4]."",$placeholder=""._MS_SHARED21.""._MS_SHOPPINGCART37."",$id="recipienemail");


//mane='ID,".suid.",".orderid.",返回ID'
$prderpeopletexbox="
   <div id='receiversstore' mane='24,".$suid.",".$orderid.",22'></div>	
<ul class='list-group'>
  <li class='list-group-item'>
    <div  class='row'>
    <div class='col-md-3'>"._MS_SHOPPINGCART31.""._MS_SHOPPINGCART46."</div>
    <div class='col-md-7'>".$shoppingcart['name']."</div>
    <div class='col-md-2'>".$button."</div>
    </div>	
    	</li>
     <li class='list-group-item'>

     <div  class='row'>
    <div class='col-md-3'>"._MS_SHOPPINGCART32.""._MS_SHOPPINGCART46."</div>
    <div class='col-md-9'>".$shoppingcart['phone']."</div>
     </div>	 
    	</li>
  
      <li class='list-group-item'>

     <div  class='row'>
    <div class='col-md-3'>"._MS_SHOPPINGCART33.""._MS_SHOPPINGCART46."</div>
    <div class='col-md-9'>".$shoppingcart['telephone']."</div>
     </div>	 
    	</li> 
  
      <li class='list-group-item'>

     <div  class='row'>
    <div class='col-md-3'>"._MS_SHOPPINGCART34.""._MS_SHOPPINGCART46."</div>
    <div class='col-md-9'>".$shoppingcart['address']."</div>
     </div>	 
    	</li> 
        <li class='list-group-item'>	 
      <div  class='row'>
    <div class='col-md-3'>"._MS_SHOPPINGCART47.""._MS_SHOPPINGCART46."</div>
    <div class='col-md-9'>".$shoppingcart['email']."</div>
     </div>	 
    	</li>    	 
     
</ul>
  
	";


echo $prderpeopletexbox; 
 
 
  }    	 
  	        
      
    break;           
    
    
    
    case "24":  
 //確認操作UID相符
$readpermission=readpermission($user_uid=$suid);
if(!empty($xoopsUser) and !empty($readpermission)){

//購買人資料
$prderpeopletext[0]=$name;
$prderpeopletext[1]=$phone;
$prderpeopletext[2]=$telephone;
$prderpeopletext[3]=$addresslist;
$prderpeopletext[4]=$email;
//陣列轉字串
$receivertext=phpconversion($conversion=$prderpeopletext,$type="serialize"); 

$setvar="set  receivertext='{$receivertext}'  where orderid='".$orderid."'";
update($dbname="neilshoporder",$set=$setvar); 

}         
   
    
    
      break;      


    case "25":  
$readpermission=readpermission($user_uid=$suid);    	 
 if(!empty($xoopsUser) and !empty($readpermission)){
//解訂單資料表
$dbneme="neilshoporder";
$where=" where `orderid` = '".$orderid."' ";   //where數值-修改
$neilshoporder=moduledb($dbneme,$where);
//字串轉陣列
$invoicetexttArr=phpconversion($conversion=$neilshoporder['invoicetext'],$type="unserialize"); 

if(!empty($isAdmin)){
$button="<button type='button' id='orderinvoiceedit' class='btn btn-default readpermissionbtn'>"._MS_SHARED08."</button>";
}



$prderpeopletexbox="
   <div id='invoicereditmane' mane='26,".$suid.",".$orderid."'></div>	
<ul class='list-group'>
  <li class='list-group-item'>"._MS_SHOPPINGCART39.""._MS_SHOPPINGCART46."".$invoicetexttArr[0]."".$button."</li>
  <li class='list-group-item'>"._MS_SHOPPINGCART41.""._MS_SHOPPINGCART46."".$invoicetexttArr[1]."</li>    
  <li class='list-group-item'>"._MS_SHOPPINGCART42.""._MS_SHOPPINGCART46."".$invoicetexttArr[2]."</li>  
   <li class='list-group-item'>"._MS_SHOPPINGCART43.""._MS_SHOPPINGCART46."".$invoicetexttArr[3]."</li>    
</ul>
 
	";


echo $prderpeopletexbox;

 }    	 
    
    break;
    
    case "26":
  
  
  $readpermission=readpermission($user_uid=$suid);    	 
 if(!empty($xoopsUser) and !empty($readpermission)){
//解訂單資料表
$dbneme="neilshoporder";
$where=" where `orderid` = '".$orderid."' ";   //where數值-修改
$neilshoporder=moduledb($dbneme,$where);
//字串轉陣列
$invoicetexttArr=phpconversion($conversion=$neilshoporder['invoicetext'],$type="unserialize"); 

if(!empty($isAdmin)){
$button="<button type='button' id='invoicestore' class='btn btn-warning'>"._MS_SHOPPINGCART48."</button>";
}

//統一編號
$shoppingcart['uniformnumbers']=inputtext($class="",$name="uniformnumbers",$value="".$invoicetexttArr[0]."",$placeholder=""._MS_SHARED21.""._MS_SHOPPINGCART39."",$id="uniformnumbers");
//發票抬頭	
$shoppingcart['invoicetitle']=inputtext($class="",$name="invoicetitle",$value="".$invoicetexttArr[1]."",$placeholder=""._MS_SHARED21.""._MS_SHOPPINGCART41."",$id="invoicetitle");
//發票收件人
$shoppingcart['invoiceuser']=inputtext($class="",$name="invoiceuser",$value="".$invoicetexttArr[2]."",$placeholder=""._MS_SHARED21.""._MS_SHOPPINGCART42."",$id="invoiceuser");

//發票寄送地址
$shoppingcart['invoiceaddress']=inputtext($class="",$name="invoiceaddress",$value="".$invoicetexttArr[3]."",$placeholder=""._MS_SHARED21.""._MS_SHOPPINGCART43."",$id="invoiceaddress");


//mane='ID,".suid.",".orderid.",返回ID'
$prderpeopletexbox="
   <div id='invoicestoremane' mane='27,".$suid.",".$orderid.",25'></div>	
<ul class='list-group'>
  <li class='list-group-item'>
    <div  class='row'>
    <div class='col-md-3'>"._MS_SHOPPINGCART39.""._MS_SHOPPINGCART46."</div>
    <div class='col-md-7'>".$shoppingcart['uniformnumbers']."</div>
    <div class='col-md-2'>".$button."</div>
    </div>	
    	</li>
     <li class='list-group-item'>

     <div  class='row'>
    <div class='col-md-3'>"._MS_SHOPPINGCART41.""._MS_SHOPPINGCART46."</div>
    <div class='col-md-9'>".$shoppingcart['invoicetitle']."</div>
     </div>	 
    	</li>
  
      <li class='list-group-item'>

     <div  class='row'>
    <div class='col-md-3'>"._MS_SHOPPINGCART42.""._MS_SHOPPINGCART46."</div>
    <div class='col-md-9'>".$shoppingcart['invoiceuser']."</div>
     </div>	 
    	</li> 
  
      <li class='list-group-item'>

     <div  class='row'>
    <div class='col-md-3'>"._MS_SHOPPINGCART43.""._MS_SHOPPINGCART46."</div>
    <div class='col-md-9'>".$shoppingcart['invoiceaddress']."</div>
     </div>	 
    	</li> 
   	 
     
</ul>

	";


echo $prderpeopletexbox; 
 
 
  }    	 
    	
    	
    	      
    
     break;   
     
    case "27":
 
 //確認操作UID相符
$readpermission=readpermission($user_uid=$suid);
if(!empty($xoopsUser) and !empty($readpermission)){

//購買人資料
$prderpeopletext[0]=$name;
$prderpeopletext[1]=$phone;
$prderpeopletext[2]=$telephone;
$prderpeopletext[3]=$addresslist;

//陣列轉字串
$invoicetext=phpconversion($conversion=$prderpeopletext,$type="serialize"); 

$setvar="set  invoicetext='{$invoicetext}'  where orderid='".$orderid."'";
update($dbname="neilshoporder",$set=$setvar); 

}     	     
             	            
     break;
     
    case "28":    
//金流串接
//開訂單資料表
//綠界金流
include_once XOOPS_ROOT_PATH . "/modules/neillibrary/ecpaycheck.php";

$dbneme="neilshoporder";
$where=" where `uid` = '".$suid."' and  `orderid` = '".$orderid."'";   //where數值-修改
$neilshoporder=moduledb($dbneme,$where);



//廠商交易編號
$trade_no = "".$ordernumber."";
//交易金額
$total_amt = "".$neilshoporder['total']."";
//商品名稱，如果商品名稱有多筆，需在金流付款選擇頁一行一行顯示商品名稱的話，商品名稱請以井號分隔(#)
//去除最後一個字元
//字串轉陣列
$neilshopcartidArr=phpconversion($conversion=$neilshoporder['neilshopcartid'],$type="unserialize"); 
foreach($neilshopcartidArr as $key=> $val){
//解購物車資料表
$dbneme="neilshopcart";
$where=" where `shopcartid` = '".$val."'";   //where數值-修改
$shopcartArr=moduledb($dbneme,$where);
//define("_MS_SHOPPINGCART82","%s-單價%s元X%s=%s元#");
$totalamount[$key]=$shopcartArr['amount']*$shopcartArr['cartnumber'];

$productnamestring.=sprintf(_MS_SHOPPINGCART82,$shopcartArr['productname'],$shopcartArr['amount'],$shopcartArr['cartnumber'],$totalamount[$key]);

}


$item_name = substr($productnamestring,0,-1);
//選擇預設付款方式
$choose_payment = "".$payment."";

$ecpaycode=ecpaycode($trade_no,$total_amt,$item_name,$choose_payment,$suid=$suid,$modules="neilshop");


$payment=$ecpaycode['html_code'];  
    	
    	
    	
 
echo $payment;    	
       break;
     case "29":
   
   
 $readpermission=readpermission($user_uid=$suid);
if(!empty($xoopsUser) and !empty($readpermission)){
$setvar="set ordernumber='{$ordernumber}', payment='{$payment}'  where orderid='".$orderid."'";
update($dbname="neilshoporder",$set=$setvar);  
}    	 
    	 
 
      break;      
      case "30": //同意退款
//讀取退貨退款資料表
$dbneme="neilshopreturns";
$where=" where `orderid` = '".$orderid."' ";   //where數值-修改
$returnsdate=moduledb($dbneme,$where);
//手續費
$processcontrol['remittancefee']=inputtext($class="",$name="remittancefee",$value="",$placeholder=""._MS_SHARED21.""._MS_SHOPPINGCART51."",$id="remittancefee");
//實退金額
$processcontrol['refundamount']=inputtext($class="",$name="refundamount",$value="",$placeholder=""._MS_SHARED21.""._MS_SHOPPINGCART52."",$id="refundamount");
//匯款末五碼
$processcontrol['lastfiveyards']=inputtext($class="",$name="lastfiveyards",$value="",$placeholder=""._MS_SHARED21.""._MS_SHOPPINGCART55."",$id="lastfiveyards");
//讀取時間
$processcontrol['setuptime']=timedate($datevar="Y-m-d H:i:s");
//退款時間
$processcontrol['refundtime']=inputtext($class="mydate",$name="refundtime",$value="".$processcontrol['setuptime']."",$placeholder="".$processcontrol['setuptime']."",$id="mydate1");

//同意退款說明
$processcontrol['refundjob']=inputtextarea($class="",$name="refundjob",$id="refundjob",$rows="6",$cols="80",$value="".$returnsmane."");         	  
//寫入設定選項
$processcontrol['refundjobchange']=checkbox($dataid=true,$name="refundjobechange",$value="1",$optionname=""._MS_SHOPPINGCART54."",$oid="");        	  
      	  
$tabledate="
<div class='row'>
  <div class='col-md-3'>"._MS_SHOPPINGCART51."</div>	
  <div class='col-md-9'>".$processcontrol['remittancefee']."</div>	
	</div>	<p>
<div class='row'>
  <div class='col-md-3'>"._MS_SHOPPINGCART52."<span id='help-blockrefundamount' class='red'>("._MS_SHARED26.")</span></div>	
  <div class='col-md-9'>".$processcontrol['refundamount']."</div>	
	</div>		<p>	
<div class='row'>
  <div class='col-md-3'>"._MS_SHOPPINGCART55."</div>	
  <div class='col-md-9'>".$processcontrol['lastfiveyards']."</div>	
	</div>		<p>		
	
<div class='row'>
  <div class='col-md-3'>"._MS_SHOPPINGCART56."</div>	
  <div class='col-md-9'>".$processcontrol['refundtime']."</div>	
	</div>		<p>	
		
<div class='row'>
  <div class='col-md-3'>"._MS_SHOPPINGCART53."<span id='help-blockrefundjob' class='red'>("._MS_SHARED26.")</span></div>
  <div class='col-md-9'>".$processcontrol['refundjob']."".$processcontrol['refundjobchange']."</div>	
	</div>	
   	<script src='" . XOOPS_URL . "/modules/neillibrary/js/customize.js'></script> 
   	<script src='" . XOOPS_URL . "/modules/neilshop/js/formvalidation.js'></script> 		  
	  
	  ";
      	  
 
 
  echo  $tabledate;        
        break;
       case "31": //不同意退款

//不同意退款說明
$processcontrol['invalidrefundjob']=inputtextarea($class="",$name="invalidrefundjob",$id="",$rows="6",$cols="80",$value="".$returnsmane."");   

//寫入設定選項
$processcontrol['invalidrefundjobchange']=checkbox($dataid=true,$name="invalidrefundjobchange",$value="1",$optionname=""._MS_SHOPPINGCART58."",$oid="");    
$tabledate="
<div class='row'>
  <div class='col-md-3'>"._MS_SHOPPINGCART57."</div>	
  <div class='col-md-9'>".$processcontrol['invalidrefundjob']."".$processcontrol['invalidrefundjobchange']."</div>	
	</div>	

";

echo  $tabledate;    
	  	  
      	       
        break;   
        
 case "32": //同意退貨
//同意退貨說明
$processcontrol['agreereturn']=inputtextarea($class="",$name="agreereturn",$id="agreereturn",$rows="6",$cols="80",$value="".$returnsmane."");         	  
//寫入設定選項
$processcontrol['agreereturnchange']=checkbox($dataid=true,$name="agreereturnchange",$value="1",$optionname=""._MS_SHOPPINGCART60."",$oid="");   
	 
 $tabledate="<div class='row'>
  <div class='col-md-3'>"._MS_SHOPPINGCART59."<span id='help-blockagreereturn' class='red'>("._MS_SHARED26.")</span></div>
  <div class='col-md-9'>".$processcontrol['agreereturn']."".$processcontrol['agreereturnchange']."</div>	
	</div>
   	<script src='" . XOOPS_URL . "/modules/neilshop/js/formvalidation.js'></script> 	
		";	 
 	         
 echo  $tabledate;             
 break;   
 
 
 case "33": //不同意退貨
//不同意退貨說明
$processcontrol['donotagreereturn']=inputtextarea($class="",$name="donotagreereturn",$id="",$rows="6",$cols="80",$value="".$returnsmane."");         	  
//寫入設定選項
$processcontrol['donotagreereturnchange']=checkbox($dataid=true,$name="donotagreereturnchange",$value="1",$optionname=""._MS_SHOPPINGCART62."",$oid="");   
	 
 $tabledate="<div class='row'>
  <div class='col-md-3' ><span style='white-space:nowrap'>"._MS_SHOPPINGCART61."</span></div>	
  <div class='col-md-9'>".$processcontrol['donotagreereturn']."".$processcontrol['donotagreereturnchange']."</div>	
	</div>	";	 
 	         
 echo  $tabledate;             
 break;  
 
 case "34": //追蹤商品加入購物車 
 
//取的ip位置
$userip=get_real_ip();
//取得UID
$uid=$user_uid;
//購物車存放商品上限
  $dbneme="config";  //資料表名稱
  $where=" where `conf_name` = 'numbercapped'";   //where數值-修改
  $confignumbercapped=moduledb($dbneme,$where);
//商品資料表
  $dbneme="neilshopproductcontent";  //資料表名稱
  $where=" where `productid` = '".$dbid."' and  `productstatus` != 'notshelves' ";   //where數值-修改
  $productLimt=moduledb($dbneme,$where);

  
$statusdata=true;
//判斷商品數量為0
if($productLimt['amount']==0){
$data=_MD_AJAX01;
$statusdata=false;
}

if($cartnumber > productLimt['amount']){
$statusdata=false;
}

$dbneme="neilshopcart";  //資料表名稱
//判斷是否訂購同樣商品
 $where=" where `enable` = '0' and  `productid` = '".$dbid."'  and  `carttype` = '1' and (`userip` = '".$userip."' or  `uid` = '".$uid."')";   //where數值-修改
 $cappedLimt=moduledb($dbneme,$where);
if(!empty($cappedLimt['productid'])){
  $data=_MD_AJAX03;
  $statusdata=false;
}

//判斷訂購商品上限次數
  $where=" where `enable` = '0' and  `carttype` = '1' and (`userip` = '".$userip."' or  `uid` = '".$uid."')";   //where數值-修改
  $cappedArr=databasetablewhile($dbneme,$where);  
 // $capped=count($cappedArr);
  $capped = is_array($cappedArr) ? count($cappedArr) : 0 ;
  
  if($capped>$confignumbercapped['conf_value']){
  $data=_MD_AJAX02;
  $statusdata=false;
  }

if($statusdata==true and !empty($productLimt['productid'])){ 
$setvar="set userip='{$userip}', uid='{$uid}',carttype='1'  where shopcartid='".$shopcartid."'";
update($dbname="neilshopcart",$set=$setvar);  
$data=_MD_AJAX04;
}

  

echo $data;	   
 
 
 
 break; 
 
 
 
  case "35":
//取的ip位置
$userip=get_real_ip();
//取得UID
$uid=$user_uid;  	  
$dbneme="neilshopcart";  //資料表名稱
 $where=" where `enable` = '0' and   `carttype` = '0' and (`userip` = '".$userip."' or  `uid` = '".$uid."')";   //where數值-修改
 $cartnumberArr=databasetablewhile($dbneme,$where);	  
 // $cartnumber=count($cartnumberArr);
    $cartnumber = is_array($cartnumberArr) ? count($cartnumberArr) : 0 ;
  
  echo $cartnumber;
  break;   
 
 
  case "36":
  	  
 $readpermission=readpermission($user_uid=$suid);
 //開啟預購清單資料表
$statusdata=true;
$dbneme="neilshopbookorders";  //資料表名稱
//判斷是否預購同樣商品
 $where=" where `enable` = '0' and  `productid` = '".$dbid."'  and `uid` = '".$suid."'";   //where數值-修改
 $preorderLimt=moduledb($dbneme,$where);
if(!empty($preorderLimt['productid'])){
  $data=_MD_AJAX07;
  $statusdata=false;
} 
//取的USER-MAIL
 $useremail=$xoopsUser->email();  
 //USER-帳號
 $useruname=$xoopsUser->uname();
 
//黑名單判斷
$blacklist=blacklistfunction($suid=$suid);
if($blacklist==1){
$data=_MD_AJAX11;
$statusdata=false;
} 
  
if(!empty($xoopsUser) and !empty($readpermission) and $statusdata!=false){
$valuesvar="(productid,useremail,uid,useruname) values('{$dbid}','{$useremail}','{$suid}','{$useruname}')";	  
insert($dbname="neilshopbookorders",$values=$valuesvar); 
$data=_MD_AJAX06;
}  

echo $data;	 
  	   
    break;   
    
    
    case "37":  
//確認刪除者UID相符
$readpermission=readpermission($user_uid=$suid);	
	   	   
   	   
$where=" where `preorderid` = '$dbid'";
$DBname="neilshopbookorders";  

if(!empty($xoopsUser) and !empty($readpermission)){
deletefunction($where,$DBname);
} 
    	
    	
    
   break;   
   
    case "38":     

$readpermission=readpermission($user_uid=$suid);    	 
 if(!empty($xoopsUser) and !empty($readpermission)){

$dbneme="neilshoppurchaser";
$where=" where `uid` = '".$suid."' ";   //where數值-修改
$neilshoporder=moduledb($dbneme,$where);


$button="<button type='button' id='subscriberedit' class='btn btn-default'>"._MS_SHARED08."</button>";

if($neilshoporder['blacklist']==1 and !empty($isAdmin)){
$blacklisttext=_MS_SHOPPINGCART63;
}

$prderpeopletexbox="
   <div id='subscribereditmane' mane='39,".$suid."'></div>	
<ul class='list-group'>
  <li class='list-group-item'>"._MS_SHOPPINGCART31.""._MS_SHOPPINGCART46."".$neilshoporder['name']." &nbsp;<a class='btn btn-default btn-md' target='_blank' href='".XOOPS_URL."/modules/profile/userinfo.php?uid=".$neilshoporder['uid']."'>"._MS_SHOPPINGCART64."</a>".$blacklisttext."".$button."</li>
  <li class='list-group-item'>"._MS_SHOPPINGCART32.""._MS_SHOPPINGCART46."".$neilshoporder['phone']."</li>    
  <li class='list-group-item'>"._MS_SHOPPINGCART33.""._MS_SHOPPINGCART46."".$neilshoporder['telephone']."</li>  
   <li class='list-group-item'>"._MS_SHOPPINGCART34.""._MS_SHOPPINGCART46."".$neilshoporder['address']."</li> 
   <li class='list-group-item'>"._MS_SHOPPINGCART47.""._MS_SHOPPINGCART46."".$neilshoporder['email']."</li>       
</ul>
     <script src='".XOOPS_URL."/modules/neilshop/js/shoppingcartajax.js'></script>		
	";


echo $prderpeopletexbox;




 }    	

   break;  
   
    case "39":
  $readpermission=readpermission($user_uid=$suid);    	 
 if(!empty($xoopsUser) and !empty($readpermission)){

$dbneme="neilshoppurchaser";
$where=" where `uid` = '".$suid."' ";   //where數值-修改
$neilshoppurchaser=moduledb($dbneme,$where);
$button="<button type='button'  id='editorderpeople' class='btn btn-warning'>"._MS_SHOPPINGCART48."</button>";
//姓名
$shoppingcart['name']=inputtext($class="",$name="name",$value="".$neilshoppurchaser['name']."",$placeholder=""._MS_SHARED21.""._MS_SHOPPINGCART31."",$id="name");
//行動電話	
$shoppingcart['phone']=inputtext($class="",$name="phone",$value="".$neilshoppurchaser['phone']."",$placeholder=""._MS_SHARED21.""._MS_SHOPPINGCART32."",$id="phone");
//聯絡電話	
$shoppingcart['telephone']=inputtext($class="",$name="telephone",$value="".$neilshoppurchaser['telephone']."",$placeholder=""._MS_SHARED21.""._MS_SHOPPINGCART33."",$id="telephone");

//切割字串(地址)
$address=cuttingfunction($cutting="".$neilshoppurchaser['address']."",$sign="-"); 
//地址
//$shoppingcart['address']=inputtext($class="",$name="addresslist",$value="".$neilshoppurchaser['address']."",$placeholder=""._MS_SHARED21.""._MS_SHOPPINGCART33."",$id="addresslist");

//地址-縣市	
$shoppingcart['county']=inputtext($class="",$name="county",$value="".$address[0]."",$placeholder=""._MS_SHARED21.""._MS_SHOPPINGCART35."",$id="county");
//地址-鄉鎮區
$shoppingcart['townshiparea']=inputtext($class="",$name="townshiparea",$value="".$address[1]."",$placeholder=""._MS_SHARED21.""._MS_SHOPPINGCART36."",$id="townshiparea");

//地址
$shoppingcart['address']=inputtext($class="",$name="address",$value="".$address[2]."",$placeholder=""._MS_SHARED21.""._MS_SHOPPINGCART34."",$id="addresscolumn");

//電子信箱
$shoppingcart['email']=inputtext($class="",$name="email",$value="".$neilshoppurchaser['email']."",$placeholder=""._MS_SHARED21.""._MS_SHOPPINGCART37."",$id="email");


//mane='ID,".suid.",".orderid.",返回ID'
$prderpeopletexbox="
   <div id='editorderpeoplemane' mane='40,".$suid.",38'></div>	
<ul class='list-group'>
  <li class='list-group-item'>
    <div  class='row'>
    <div class='col-md-4'>"._MS_SHOPPINGCART31.""._MS_SHOPPINGCART46."<span id='help-blockname' class='red'>("._MS_SHARED22.")</span></div>
    <div class='col-md-6'>".$shoppingcart['name']."</div>
    <div class='col-md-2'>".$button."</div>
    </div>	
    	</li>
     <li class='list-group-item'>

     <div  class='row'>
    <div class='col-md-4'>"._MS_SHOPPINGCART32.""._MS_SHOPPINGCART46."<span id='help-blockphone' class='red'>("._MS_SHARED22.")</span></div>
    <div class='col-md-8'>".$shoppingcart['phone']."</div>
     </div>	 
    	</li>
  
      <li class='list-group-item'>

     <div  class='row'>
    <div class='col-md-4'>"._MS_SHOPPINGCART33.""._MS_SHOPPINGCART46."</div>
    <div class='col-md-8'>".$shoppingcart['telephone']."</div>
     </div>	 
    	</li> 
  
      <li class='list-group-item'>

     <div  class='row'>
    <div class='col-md-4'>"._MS_SHOPPINGCART34.""._MS_SHOPPINGCART46."<span  id='help-blockaddress' class='red'>("._MS_SHARED22.")</span></div>
    <div class='col-md-8'>
       <div  class='row rowcustom'>
      <div class='col-md-3'>".$shoppingcart['county']."</div>   
            <div class='col-md-3'>".$shoppingcart['townshiparea']."</div> 
               <div class='col-md-6'>".$shoppingcart['address']."</div>    
         </div>	 
    	 
    	 </div>
     </div>	 
    	</li> 
        <li class='list-group-item'>	 
      <div  class='row'>
    <div class='col-md-4'>"._MS_SHOPPINGCART47.""._MS_SHOPPINGCART46."<span id='help-blockemail' class='red'>"._MS_SHARED22."</span></div>
    <div class='col-md-8'>".$shoppingcart['email']."</div>
     </div>	 
    	</li>    	 
     
</ul>

     <script src='".XOOPS_URL."/modules/neilshop/js/formvalidation.js'></script>	
		
	";


echo $prderpeopletexbox; 
 
 
  } 
      break;  
      
    case "40":
 //確認操作UID相符
$readpermission=readpermission($user_uid=$suid);
//無害化處理
if(judgeHtml($name)==true or !is_numeric($phone) or judgeHtml($telephone)==true or judgeHtml($addresslist)==true or judgeEmail($email)==true ){
$harmful=true;
}



if(!empty($xoopsUser) and !empty($readpermission)  and $harmful!=true){
$setvar="set  name='{$name}',phone='{$phone}',telephone='{$telephone}',address='{$addresslist}',email='{$email}'  where uid='".$suid."'";
update($dbname="neilshoppurchaser",$set=$setvar); 

}      
    	      
    	   
         break;     
         
         
     case "41":     
$readpermission=readpermission($user_uid=$suid);
  
if(!empty($xoopsUser) and !empty($readpermission)){
$setvar="set  blacklist='{$blacklist}' where prderpeopleid='".$dbid."'";
update($dbname="neilshoppurchaser",$set=$setvar); 
if($blacklist==1){
$data=_MD_AJAX08;
}else{
$data=_MD_AJAX09;
}

}  

echo $data;	 
     	 
 break;    
 
  case "42":
$where=" where `prderpeopleid` = '$dbid'";
$DBname="neilshoppurchaser";  
!empty($isAdmin) ? deletefunction($where,$DBname) : '';  
  break;   
   	    
  case "43":    
  	  
  	           
$readpermission=readpermission($user_uid=$suid);    	 
 if(!empty($xoopsUser) and !empty($readpermission)){
//解收件人資料表
$dbneme="neilshopreceiver";
$where=" where `uid` = '".$suid."' and  `receiverid` = '".$receiverid."'";   //where數值-修改
$readpermission=moduledb($dbneme,$where);


$button="<button type='button' id='readpermissionedit' class='btn btn-default readpermissionbtn'>"._MS_SHARED08."</button>";


$blacklisttext=_MS_SHOPPINGCART65;
//mane='ID,".suid.",".receiverid.",返回ID'
$prderpeopletexbox="
   <div id='readpermissioneditmane' mane='44,".$suid.",".$readpermission['receiverid'].",43'></div>	
<ul class='list-group'>
  <li class='list-group-item'>"._MS_SHOPPINGCART31.""._MS_SHOPPINGCART46."".$readpermission['name']."".$blacklisttext."".$button."</li>
  <li class='list-group-item'>"._MS_SHOPPINGCART32.""._MS_SHOPPINGCART46."".$readpermission['phone']."</li>    
  <li class='list-group-item'>"._MS_SHOPPINGCART33.""._MS_SHOPPINGCART46."".$readpermission['telephone']."</li>  
   <li class='list-group-item'>"._MS_SHOPPINGCART34.""._MS_SHOPPINGCART46."".$readpermission['address']."</li> 
   <li class='list-group-item'>"._MS_SHOPPINGCART47.""._MS_SHOPPINGCART46."".$readpermission['email']."</li>       
</ul>
     <script src='".XOOPS_URL."/modules/neilshop/js/shoppingcartajax.js'></script>		
	";


echo $prderpeopletexbox;




 }    	

  break; 
  
  case "44":      

 $readpermission=readpermission($user_uid=$suid);    	 
 if(!empty($xoopsUser) and !empty($readpermission)){

$dbneme="neilshopreceiver";
$where=" where `uid` = '".$suid."'  and  `receiverid` = '".$receiverid."' ";   //where數值-修改
$neilshopreceiver=moduledb($dbneme,$where);
$button="<button type='button'  id='receiverbtn' class='btn btn-warning '>"._MS_SHOPPINGCART48."</button>";
//姓名
$shoppingcart['name']=inputtext($class="",$name="name",$value="".$neilshopreceiver['name']."",$placeholder=""._MS_SHARED21.""._MS_SHOPPINGCART31."",$id="name");
//行動電話	
$shoppingcart['phone']=inputtext($class="",$name="phone",$value="".$neilshopreceiver['phone']."",$placeholder=""._MS_SHARED21.""._MS_SHOPPINGCART32."",$id="phone");
//聯絡電話	
$shoppingcart['telephone']=inputtext($class="",$name="telephone",$value="".$neilshopreceiver['telephone']."",$placeholder=""._MS_SHARED21.""._MS_SHOPPINGCART33."",$id="telephone");

//切割字串(地址)
$address=cuttingfunction($cutting="".$neilshopreceiver['address']."",$sign="-"); 
//地址
//$shoppingcart['address']=inputtext($class="",$name="addresslist",$value="".$neilshoppurchaser['address']."",$placeholder=""._MS_SHARED21.""._MS_SHOPPINGCART33."",$id="addresslist");

//地址-縣市	
$shoppingcart['county']=inputtext($class="",$name="county",$value="".$address[0]."",$placeholder=""._MS_SHARED21.""._MS_SHOPPINGCART35."",$id="county");
//地址-鄉鎮區
$shoppingcart['townshiparea']=inputtext($class="",$name="townshiparea",$value="".$address[1]."",$placeholder=""._MS_SHARED21.""._MS_SHOPPINGCART36."",$id="townshiparea");

//地址
$shoppingcart['address']=inputtext($class="",$name="address",$value="".$address[2]."",$placeholder=""._MS_SHARED21.""._MS_SHOPPINGCART34."",$id="addresscolumn");

//電子信箱
$shoppingcart['email']=inputtext($class="",$name="email",$value="".$neilshopreceiver['email']."",$placeholder=""._MS_SHARED21.""._MS_SHOPPINGCART37."",$id="email");


//mane='ID,".suid.",".orderid.",返回ID,列表值'
$prderpeopletexbox="
   <div id='receivermane' mane='45,".$suid.",".$neilshopreceiver['receiverid'].",".$receiverreturn.",".$listreturn."' ></div>	
<ul class='list-group'  >
  <li class='list-group-item'>
    <div  class='row'>
    <div class='col-md-4'>"._MS_SHOPPINGCART31.""._MS_SHOPPINGCART46."<span id='help-blockname' class='red'>("._MS_SHARED22.")</span></div>
    <div class='col-md-6'>".$shoppingcart['name']."</div>
    <div class='col-md-2'>".$button."</div>
    </div>	
    	</li>
     <li class='list-group-item'>

     <div  class='row'>
    <div class='col-md-4'>"._MS_SHOPPINGCART32.""._MS_SHOPPINGCART46."<span id='help-blockphone' class='red'>("._MS_SHARED22.")</span></div>
    <div class='col-md-8'>".$shoppingcart['phone']."</div>
     </div>	 
    	</li>
  
      <li class='list-group-item'>

     <div  class='row'>
    <div class='col-md-4'>"._MS_SHOPPINGCART33.""._MS_SHOPPINGCART46."</div>
    <div class='col-md-8'>".$shoppingcart['telephone']."</div>
     </div>	 
    	</li> 
  
      <li class='list-group-item'>

     <div  class='row'>
    <div class='col-md-4'>"._MS_SHOPPINGCART34.""._MS_SHOPPINGCART46."<span  id='help-blockaddress' class='red'>("._MS_SHARED22.")</span></div>
    <div class='col-md-8'>
       <div  class='row rowcustom'>
      <div class='col-md-3'>".$shoppingcart['county']."</div>   
            <div class='col-md-3'>".$shoppingcart['townshiparea']."</div> 
               <div class='col-md-6'>".$shoppingcart['address']."</div>    
         </div>	 
    	 
    	 </div>
     </div>	 
    	</li> 
        <li class='list-group-item'>	 
      <div  class='row'>
    <div class='col-md-4'>"._MS_SHOPPINGCART47.""._MS_SHOPPINGCART46."<span id='help-blockemail' class='red'>"._MS_SHARED22."</span></div>
    <div class='col-md-8'>".$shoppingcart['email']."</div>
     </div>	 
    	</li>    	 
     
</ul>
     <script src='".XOOPS_URL."/modules/neilshop/js/shoppingcartajax.js'></script>	
     <script src='".XOOPS_URL."/modules/neilshop/js/formvalidation.js'></script>	
		
	";


echo $prderpeopletexbox; 
 
 
  } 
  
    break; 
  
  
    case "45":
 //確認操作UID相符
$readpermission=readpermission($user_uid=$suid);
//無害化處理
if(judgeHtml($name)==true or !is_numeric($phone) or judgeHtml($telephone)==true or judgeHtml($addresslist)==true or judgeEmail($email)==true ){
$harmful=true;
}



if(!empty($xoopsUser) and !empty($readpermission) and $harmful!=true){
$setvar="set  name='{$name}',phone='{$phone}',telephone='{$telephone}',address='{$addresslist}',email='{$email}'  where receiverid='".$receiverid."'";
update($dbname="neilshopreceiver",$set=$setvar); 

}      
    	      
    	   
         break;      
  
     case "46": 
   	           
$readpermission=readpermission($user_uid=$suid);    	 
 if(!empty($xoopsUser) and !empty($readpermission)){
//解訂購人資料表
$dbneme="neilshoppurchaser";
$where=" where `uid` = '".$suid."' ";   //where數值-修改
$neilshoppurchaser=moduledb($dbneme,$where);
 	 
 	 
//解收件人資料表
$dbneme="neilshopreceiver";
$where=" where `uid` = '".$suid."' and  `receiverid` != '".$neilshoppurchaser['receiverid']."'";   //where數值-修改
$neilshopreceiverArr=databasetablewhile($dbneme,$where); 

foreach($neilshopreceiverArr as $key=> $val){
	
$button="
	<div  class='row  recipientlistbtn'>
	<button type='button' id='defaultbtn{$key}' class='btn btn-success'>"._MS_SHARED27."</button>
    <button type='button' id='deletebotton{$key}' mane='48,".$neilshopreceiverArr[$key]['receiverid'].",".$neilshopreceiverArr[$key]['name'].","._MS_SHOPPINGCART67.",".$suid."'  class='btn btn-danger deleteeach'>"._MS_SHARED09."</button>	
   <button type='button' id='readpermissionlistedit{$key}' class='btn btn-default '>"._MS_SHARED08."</button></div>";
//mane='ID,".suid.",".receiverid.",返回ID'
$prderpeopletexbox.="
   <div id='defaultbtnedit{$key}' mane='47,".$suid.",".$neilshopreceiverArr[$key]['receiverid'].",".$neilshopreceiverArr[$key]['name'].","._MS_SHOPPINGCART66."' ></div>		
   <div id='readpermissionlistedit{$key}' mane='44,".$suid.",".$neilshopreceiverArr[$key]['receiverid'].",46,list' class='receiverlisteach'></div>	
<ul class='list-group' id='deletetr{$key}'>
  <li class='list-group-item'>"._MS_SHOPPINGCART31.""._MS_SHOPPINGCART46."".$neilshopreceiverArr[$key]['name']."".$button."</li>
  <li class='list-group-item'>"._MS_SHOPPINGCART32.""._MS_SHOPPINGCART46."".$neilshopreceiverArr[$key]['phone']."</li>    
  <li class='list-group-item'>"._MS_SHOPPINGCART33.""._MS_SHOPPINGCART46."".$neilshopreceiverArr[$key]['telephone']."</li>  
   <li class='list-group-item'>"._MS_SHOPPINGCART34.""._MS_SHOPPINGCART46."".$neilshopreceiverArr[$key]['address']."</li> 
   <li class='list-group-item'>"._MS_SHOPPINGCART47.""._MS_SHOPPINGCART46."".$neilshopreceiverArr[$key]['email']."</li>       
</ul>
";
}
$prderpeopletexbox.="
 <script src='".XOOPS_URL."/modules/neillibrary/js/customize.js'></script>		
 <script src='".XOOPS_URL."/modules/neilshop/js/shoppingcartajax.js'></script>		
";


echo $prderpeopletexbox;




 }      	 
  
   break; 
   
       case "47":
 //確認操作UID相符
$readpermission=readpermission($user_uid=$suid);
if(!empty($xoopsUser) and !empty($readpermission)){
$setvar="set  receiverid='{$dbid}'  where uid='".$suid."'";
update($dbname="neilshoppurchaser",$set=$setvar); 

$res['result']=$suid;
$res['result2']=$dbid;
echo json_encode($res);exit;

}     



     break; 
        case "48":
    
//確認刪除者UID相符
$readpermission=readpermission($user_uid=$suid);	 	   
$where=" where `receiverid` = '$dbid'";
$DBname="neilshopreceiver";  

if(!empty($xoopsUser) and !empty($readpermission)){
deletefunction($where,$DBname);
}     
        	
         break;    	    
         case "49":
         	 
$readpermission=readpermission($user_uid=$suid);    	 
 if(!empty($xoopsUser) and !empty($readpermission)){
//解發票資料表
$dbneme="neilshopinvoice";
$where=" where `uid` = '".$suid."' and  `invoiceid` = '".$invoiceid."'";   //where數值-修改
$invoicelist=moduledb($dbneme,$where);


$button="<button type='button' id='invoiceedit' class='btn btn-default readpermissionbtn'>"._MS_SHARED08."</button>";


$blacklisttext=_MS_SHOPPINGCART68;
//mane='ID,".suid.",".receiverid.",返回ID'
$prderpeopletexbox="
   <div id='invoiceeditmane' mane='50,".$suid.",".$invoicelist['invoiceid'].",49' ></div>	
<ul class='list-group'>
  <li class='list-group-item'>"._MS_SHOPPINGCART39.""._MS_SHOPPINGCART46."".$invoicelist['uniformnumbers']."".$blacklisttext."".$button."</li>
  <li class='list-group-item'>"._MS_SHOPPINGCART41.""._MS_SHOPPINGCART46."".$invoicelist['invoicetitle']."</li>    
  <li class='list-group-item'>"._MS_SHOPPINGCART42.""._MS_SHOPPINGCART46."".$invoicelist['invoiceuser']."</li>  
   <li class='list-group-item'>"._MS_SHOPPINGCART43.""._MS_SHOPPINGCART46."".$invoicelist['invoiceaddress']."</li> 
</ul>
     <script src='".XOOPS_URL."/modules/neilshop/js/shoppingcartajax.js'></script>		
	";


echo $prderpeopletexbox;
 }    	       	    
         	 
         	 
        break;    
        

  case "50":
  	  

 $readpermission=readpermission($user_uid=$suid);    	 
 if(!empty($xoopsUser) and !empty($readpermission)){

$dbneme="neilshopinvoice";
$where=" where `uid` = '".$suid."'  and  `invoiceid` = '".$invoiceid."' ";   //where數值-修改
$neilshopinvoice=moduledb($dbneme,$where);

$button="<button type='button'  id='invoicebtn' class='btn btn-warning '>"._MS_SHOPPINGCART48."</button>";
//統一編號
$shoppingcart['uniformnumbers']=inputtext($class="",$name="uniformnumbers",$value="".$neilshopinvoice['uniformnumbers']."",$placeholder=""._MS_SHARED21.""._MS_SHOPPINGCART39."",$id="uniformnumbers");
//發票抬頭
$shoppingcart['invoicetitle']=inputtext($class="",$name="invoicetitle",$value="".$neilshopinvoice['invoicetitle']."",$placeholder=""._MS_SHARED21.""._MS_SHOPPINGCART41."",$id="invoicetitle");
//發票收件人	
$shoppingcart['invoiceuser']=inputtext($class="",$name="invoiceuser",$value="".$neilshopinvoice['invoiceuser']."",$placeholder=""._MS_SHARED21.""._MS_SHOPPINGCART42."",$id="invoiceuser");

//切割字串(地址)
$address=cuttingfunction($cutting="".$neilshopinvoice['invoiceaddress']."",$sign="-"); 

//地址-縣市	
$shoppingcart['invoiceusercounty']=inputtext($class="",$name="invoiceusercounty",$value="".$address[0]."",$placeholder=""._MS_SHARED21.""._MS_SHOPPINGCART35."",$id="invoiceusercounty");
//地址-鄉鎮區
$shoppingcart['invoiceusertownshiparea']=inputtext($class="",$name="invoiceusertownshiparea",$value="".$address[1]."",$placeholder=""._MS_SHARED21.""._MS_SHOPPINGCART36."",$id="invoiceusertownshiparea");

//地址
$shoppingcart['invoiceuseraddress']=inputtext($class="",$name="invoiceuseraddress",$value="".$address[2]."",$placeholder=""._MS_SHARED21.""._MS_SHOPPINGCART34."",$id="invoiceuseraddress");




//mane='ID,".suid.",".orderid.",返回ID,列表值'
$prderpeopletexbox="
   <div id='invoicebtnmane' mane='51,".$suid.",".$neilshopinvoice['invoiceid'].",".$receiverreturn.",".$listreturn."' ></div>	
<ul class='list-group'  >
  <li class='list-group-item'>
    <div  class='row'>
    <div class='col-md-4'>"._MS_SHOPPINGCART39.""._MS_SHOPPINGCART46."</div>
    <div class='col-md-6'>".$shoppingcart['uniformnumbers']."<span id='help-blockuniformnumbers' class='red'>("._MS_SHOPPINGCART50.")</span></div>
    <div class='col-md-2'>".$button."</div>
    </div>	
    	</li>
     <li class='list-group-item'>

     <div  class='row'>
    <div class='col-md-4'>"._MS_SHOPPINGCART41.""._MS_SHOPPINGCART46."<span id='help-blockinvoicetitle' class='red'>("._MS_SHARED22.")</span></div>
    <div class='col-md-8'>".$shoppingcart['invoicetitle']."</div>
     </div>	 
    	</li>
  
      <li class='list-group-item'>

     <div  class='row'>
    <div class='col-md-4'>"._MS_SHOPPINGCART42.""._MS_SHOPPINGCART46."<span id='help-blockinvoiceuser' class='red'>("._MS_SHARED22.")</span></div>
    <div class='col-md-8'>".$shoppingcart['invoiceuser']."</div>
     </div>	 
    	</li> 
  
      <li class='list-group-item'>

     <div  class='row'>
    <div class='col-md-4'>"._MS_SHOPPINGCART34.""._MS_SHOPPINGCART46."<span  id='help-blockinvoiceuseraddress' class='red'>("._MS_SHARED22.")</span></div>
    <div class='col-md-8'>
       <div  class='row rowcustom'>
      <div class='col-md-3'>".$shoppingcart['invoiceusercounty']."</div>   
            <div class='col-md-3'>".$shoppingcart['invoiceusertownshiparea']."</div> 
               <div class='col-md-6'>".$shoppingcart['invoiceuseraddress']."</div>    
         </div>	 
    	 
    	 </div>
     </div>	 
    	</li> 
  	 
     
</ul>
     <script src='".XOOPS_URL."/modules/neilshop/js/shoppingcartajax.js'></script>	
     <script src='".XOOPS_URL."/modules/neilshop/js/formvalidation.js'></script>	
		
	";


echo $prderpeopletexbox; 
 
 
  }   	  
  	  
  	  
break;    	          	  
   case "51":    
   
 //確認操作UID相符
$readpermission=readpermission($user_uid=$suid);

//無害化處理
if(judgeHtml($uniformnumbers)==true or judgeHtml($invoicetitle)==true  or judgeHtml($invoiceuser)==true or judgeHtml($addresslist)==true){
$harmful=true;
}

if(!empty($xoopsUser) and !empty($readpermission) and $harmful!=true){
$setvar="set  uniformnumbers='{$uniformnumbers}',invoicetitle='{$invoicetitle}',invoiceuser='{$invoiceuser}',invoiceaddress='{$addresslist}'  where invoiceid='".$invoiceid."'";
update($dbname="neilshopinvoice",$set=$setvar); 

}      
       
   break;    
   
    case "52":    
 $readpermission=readpermission($user_uid=$suid);    	 
 if(!empty($xoopsUser) and !empty($readpermission)){
//解訂購人資料表
$dbneme="neilshoppurchaser";
$where=" where `uid` = '".$suid."' ";   //where數值-修改
$neilshoppurchaser=moduledb($dbneme,$where);


 	 
//解發票資料表
$dbneme="neilshopinvoice";
$where=" where `uid` = '".$suid."' and  `invoiceid` != '".$neilshoppurchaser['invoiceid']."'";   //where數值-修改
$neilshopinvoiceArr=databasetablewhile($dbneme,$where); 

foreach($neilshopinvoiceArr as $key=> $val){
	
$button="
	<div  class='row  recipientlistbtn'>
	<button type='button' id='invoicedefaultbtn{$key}' class='btn btn-success'>"._MS_SHARED28."</button>
    <button type='button' id='deletebotton{$key}' mane='54,".$neilshopinvoiceArr[$key]['invoiceid'].",".$neilshopinvoiceArr[$key]['invoicetitle'].","._MS_SHOPPINGCART71.",".$suid."'  class='btn btn-danger deleteeach'>"._MS_SHARED09."</button>	
   <button type='button' id='invoicelistedit{$key}' class='btn btn-default '>"._MS_SHARED08."</button></div>";
//mane='ID,".suid.",".receiverid.",返回ID'
$prderpeopletexbox.="
   <div id='invoicedefaultmane{$key}' mane='53,".$suid.",".$neilshopinvoiceArr[$key]['invoiceid'].",".$neilshopinvoiceArr[$key]['invoicetitle'].","._MS_SHOPPINGCART70."' ></div>		
   <div id='invoicelisteditmane{$key}' mane='50,".$suid.",".$neilshopinvoiceArr[$key]['invoiceid'].",52,list' class='invoicelisteach'></div>	
<ul class='list-group' id='deletetr{$key}'>
  <li class='list-group-item'>"._MS_SHOPPINGCART39.""._MS_SHOPPINGCART46."".$neilshopinvoiceArr[$key]['uniformnumbers']."".$button."</li>
  <li class='list-group-item'>"._MS_SHOPPINGCART41.""._MS_SHOPPINGCART46."".$neilshopinvoiceArr[$key]['invoicetitle']."</li>    
  <li class='list-group-item'>"._MS_SHOPPINGCART42.""._MS_SHOPPINGCART46."".$neilshopinvoiceArr[$key]['invoiceuser']."</li>  
   <li class='list-group-item'>"._MS_SHOPPINGCART43.""._MS_SHOPPINGCART46."".$neilshopinvoiceArr[$key]['invoiceaddress']."</li> 
</ul>
";
}
$prderpeopletexbox.="
 <script src='".XOOPS_URL."/modules/neillibrary/js/customize.js'></script>		
 <script src='".XOOPS_URL."/modules/neilshop/js/shoppingcartajax.js'></script>		
";


echo $prderpeopletexbox;




 }     	
    	
     break;      
     
     case "53":
  //確認操作UID相符
$readpermission=readpermission($user_uid=$suid);
if(!empty($xoopsUser) and !empty($readpermission)){
$setvar="set  invoiceid='{$dbid}'  where uid='".$suid."'";
update($dbname="neilshoppurchaser",$set=$setvar); 

$res['result']=$suid;
$res['result2']=$dbid;
echo json_encode($res);exit;

}       	 
     	 
     	        
         break;   	
         
       case "54":      
  
  //確認刪除者UID相符
$readpermission=readpermission($user_uid=$suid);	 	   
$where=" where `invoiceid` = '$dbid'";
$DBname="neilshopinvoice";  

if(!empty($xoopsUser) and !empty($readpermission)){
deletefunction($where,$DBname);
}     
     
       	   
     break;       	    
   
        
       case "55":     
$where=" where `nsn` = '$dbid'";
$DBname="neothemesmarquee";  
!empty($isAdmin) ? deletefunction($where,$DBname) : '';         	   
       	   
   
     break;    
     
     
     
     
  case "56":
//讀取productsort資料表 
/*$dbneme="productsort";  //資料表名稱


if($exchange=='true'){
$dbid=$dbid;
}else{
$dbid=$selectidedit;
}

if($status==edit){
if($exchange=='true'){
 $where=" where `of_sortid` = '".$dbid."' order by sortidsort ASC";   //where數值-修改
}else{
 $where=" where `sortid` = '".$dbid."' order by sortidsort ASC";   //where數值-修改 
 $sortselect=moduledb($dbneme,$where);
 $oid=$sortselect['sortid'];
}
}else{
  $where=" where `of_sortid` = '".$dbid."' order by sortidsort ASC";   //where數值-新增
}

if(!empty($dbid)){
//$sort=!empty($isAdmin) ? databasetablewhile($dbneme,$where) : ''; 
$sort=databasetablewhile($dbneme,$where); 
}
$optionone.=optionbox($sortvar=$sort,$oid=$oid);

if(!empty($optionone)){
$select.="<select id=".$selectid." class='form-control' name='of_sortid' >
	 <option   data-id='".$dbid."' value=".$dbid."  >"._MS_SHARED13."</option>
     	".$optionone."   
  </select>	 <p>

";
}
echo $select.="
	<script>var level='1';</script>	
 <script src='".XOOPS_URL."/modules/neilproduct/js/ajaxjs.js'></script>
";
*/
  break;

  case "57":
//讀取neilshopsort資料表 
/*$dbneme="productsort";  //資料表名稱


if($exchange=='true'){
$dbid=$dbid;
}else{
$dbid=$selectidedit;
}

if($status==edit){
if($exchange=='true'){
 $where=" where `of_sortid` = '".$dbid."' order by sortidsort ASC";   //where數值-修改
}else{
 $where=" where `sortid` = '".$dbid."' order by sortidsort ASC";   //where數值-修改 
 $sortselect=moduledb($dbneme,$where);
 $oid=$sortselect['sortid'];
}
}else{
  $where=" where `of_sortid` = '".$dbid."' order by sortidsort ASC";   //where數值-新增
}

if(!empty($dbid)){
//$sort=!empty($isAdmin) ? databasetablewhile($dbneme,$where) : ''; 
$sort=databasetablewhile($dbneme,$where); 
}
$optionone.=optionbox($sortvar=$sort,$oid=$oid);

if(!empty($optionone)){
 $select.="<select id=".$selectid." class='form-control' name='of_sortid' >
	 <option   data-id='".$dbid."' value=".$dbid."  >"._MS_SHARED13."</option>
     	".$optionone."   
  </select>	 <p>

";
}


$select.="<script>var level='2';</script>";

if($exchange=='true'){
$select.="	
  <script src='".XOOPS_URL."/modules/neilproduct/js/ajaxjs.js'></script>
	 ";}
echo $select;
*/

  break;


  case "58":
//讀取neilshopsort資料表 
/*$dbneme="productsort";  //資料表名稱


if($exchange=='true'){
$dbid=$dbid;
}else{
$dbid=$selectidedit;
}


if($status==edit){
if($exchange=='true'){
 $where=" where `of_sortid` = '".$dbid."' order by sortidsort ASC";   //where數值-修改
}else{
 $where=" where `sortid` = '".$dbid."' order by sortidsort ASC";   //where數值-修改 
 $sortselect=moduledb($dbneme,$where);
 $oid=$sortselect['sortid'];
}
}else{
  $where=" where `of_sortid` = '".$dbid."' order by sortidsort ASC";   //where數值-新增
}

if(!empty($dbid)){
//$sort=!empty($isAdmin) ? databasetablewhile($dbneme,$where) : ''; 
$sort=databasetablewhile($dbneme,$where); 
}
$optionone.=optionbox($sortvar=$sort,$oid=$oid);

if(!empty($optionone)){
echo $select.="<select id=".$selectid." class='form-control' name='of_sortid' >
	 <option   data-id='".$dbid."' value=".$dbid."  >"._MS_SHARED13."</option>
     	".$optionone."   
  </select>	 <p>

";
}*/
  break;     
     
     
   case "59":
/*$where=" where `sortid` = '$dbid'";
$DBname="productsort";  
!empty($isAdmin) ? deletefunction($where,$DBname) : '';  */
  break;    
     
     
  case "60":
//讀取商品資料表
 $dbneme="productcontent";  //資料表名稱
  $where=" where `productid` = '$dbid'";
 $productDB=moduledb($dbneme,$where); 	  

!empty($isAdmin) ? deletefunction($where,$dbneme) : ''; 
 
  break;     

  case "61":
//讀取商品諮詢資料表
 $dbneme="productinquiry";  //資料表名稱
  $where=" where `pinquiryid` = '$dbid'";
 $productDB=moduledb($dbneme,$where); 	  

!empty($isAdmin) ? deletefunction($where,$dbneme) : ''; 
 
  break;     
  
   case "62":    
if($operating=='read'){   
if(empty($_SESSION['deviation'])  or (time('Y-m-d H:i:s').'000') > $_SESSION['deviation']){
$result=$_SESSION['deviation'];    
}else{
$result=time('Y-m-d H:i:s').'000';  
}
}    	
if($operating=='writing'){     	
$_SESSION['deviation']=$dbid;   
}
if($operating=='updated'){     	
$_SESSION['deviation']='';  
}   
 
if($operating=='sendout'){     	
$_SESSION['deviation']=time('Y-m-d H:i:s').'000'; 
} 

echo $result;  
   
    break;      
    
    
    
   case "63":
//讀取neilshopsort資料表 

if(!empty($var4) && $var4=='top') exit;  	 //編輯分類不顯示同層底層分類 	    

$dbneme= empty($var1) ? "productsort" : $var1; // get TRUE

$dbid=$exchange=='true'? $dbid : $selectidedit; // get TRUE
$typesDB=!empty($var3) ? "&& `typesid` = '".$var3."' " : ''; // get TRUE	

$where=" where `of_sortid` = '".$dbid."'  ".$typesDB."  && `enable` = '1'  order by sortidsort ASC";   //where數值-新增

if(!empty($dbid)){
//$sort=!empty($isAdmin) ? databasetablewhile($dbneme,$where) : ''; 
$sort=databasetablewhile($dbneme,$where); 
}


$optionone.=optionbox($sortvar=$sort,$oid=$of_sortid,$dbneme,$var2,$type,$var3);




if(!empty($optionone)){
$select.="<select id=".$selectid." class='form-control' name='of_sortid' >
	 <option   data-id='0' value='".$dbid."'  >"._MS_SHARED13."</option>
     	".$optionone."   
  </select>	 <p>

";
}

$blockule=preg_match("/blocks/i", $selectid) ? 'blocks/' : ''; // get TRUE
	
if(!empty($sort)){
echo $select.="
	<script>var level='1';</script>	
	
	
 <script src='".XOOPS_URL."/modules/".$xoopsmodule."/js/".$blockule."ajaxjs.js'></script>
	 
";
}

  break;

  case "64":

if(!empty($var4) && $var4=='1') exit;  //編輯分類不顯示同層底層分類 	  
//讀取neilshopsort資料表 
$dbneme= empty($var1) ? "productsort" : $var1; // get TRUE

$dbid=$exchange=='true'? $dbid : $selectidedit; // get TRUE

$typesDB=!empty($var3) ? "&& `typesid` = '".$var3."' " : ''; // get TRUE	

$where=" where `of_sortid` = '".$dbid."' ".$typesDB."  && `enable` = '1' order by sortidsort ASC";   //where數值-新增

if(!empty($dbid)){
$sort=databasetablewhile($dbneme,$where); 
}


$optionone.=optionbox($sortvar=$sort,$oid=$of_sortid,$dbneme,$var2,$type,$var3);

if(!empty($optionone)){
 $select.="<select id=".$selectid." class='form-control' name='of_sortid' >
	 <option   data-id='0' value='".$dbid."'   >"._MS_SHARED13."</option>
     	".$optionone."   
  </select>	 <p>

";
}

$select.="<script>var level='2';</script>";
$blockule=preg_match("/blocks/i", $selectid) ? 'blocks/' : ''; // get TRUE
if($exchange=='true'){
$select.="	
  <script src='".XOOPS_URL."/modules/".$xoopsmodule."/js/".$blockule."ajaxjs.js'></script>
	 ";}
	 

echo $select;


  break;


  case "65":
  	  
//讀取neilshopsort資料表 
$dbneme= empty($var1) ? "productsort" : $var1; // get TRUE

$dbid=$exchange=='true'? $dbid : $selectidedit; // get TRUE

$typesDB=!empty($var3) ? "&& `typesid` = '".$var3."' " : ''; // get TRUE	

$where=" where `of_sortid` = '".$dbid."' ".$typesDB."  && `enable` = '1' order by sortidsort ASC";   //where數值-新增
if(!empty($dbid)){
$sort=databasetablewhile($dbneme,$where); 
}

$optionone.=optionbox($sortvar=$sort,$oid=$of_sortid,$dbneme,$var2,$type,$var3);
if(!empty($optionone)){
echo $select.="<select id=".$selectid." class='form-control' name='of_sortid' >
	 <option   data-id='0' value='".$dbid."'  >"._MS_SHARED13."</option>
     	".$optionone."   
  </select>	 <p>

";
}
  break;   
    
    
    
case "66": //萬用分類刪除  	  
  	  
//特殊權限
switch($xoopsmodule){
  case "neilsignedup_c":
neilsignedup_c_specialpermission($deleteList="",$pageid=$var2,$dbid);
  break;   
  case "neilsignedup_a":
neilsignedup_a_specialpermission($deleteList="",$pageid=$var2,$dbid);
  break;   
case "neilproduct":
neilproduct_specialpermission($deleteList="",$pageid=$var2,$dbid);
  break; 
 case "neilenglishresults":
if(empty(useradmin($uid=$xoopsUser->getVar('uid'),$basid=$basid))) exit;
  break; 
  
  default:
//刪除權限(管理員)
if(empty(admingroupfunction($dbneme="neilmfdcmstypes",$where=" where `typesid` = '".$var6."' && `enable` = '1'  ",$admintype="admingroup"))) exit;   	  
}  	 	  
  	  
$dbneme= $var2; // get TRUE
 
$typesDB=!empty($var6) ? "&& `typesid` = '".$var6."' " : ''; // get TRUE
$sortidname=!empty($var7) ? $var7 : 'sortid'; // get TRUE		

//第一層
switch($xoopsmodule){
  case "neilenglishresults":
$where="  where `".$sortidname."` = '".$dbid."'  &&  `basid` = '".$basid."' &&  `enfunction` = '".$enfunction."'   order by  sortidsort  DESC";  //where數值
  break;  
  default:
$where="  where `".$sortidname."` = '".$dbid."' ".$typesDB."  order by  sortidsort  DESC";  //where數值
}

//遞回開始
foreach($Arr=databasetablewhile($dbneme,$where) as $key=> $val){
$sortvar.=$Arr[$key][$sortidname].","; 
$sortvar.=sortretorted($dbneme,$sortid="".$Arr[$key][$sortidname]."",$typs=$var8);
}

//刪除分類
foreach($sortvarArr=cuttingfunction($cutting=substr($sortvar,0,-1),$sign=",") as $key=> $val){	
//刪除內容
$where2="  where `".$sortidname."` = '".$val."' ".$typesDB."   order by  ".$var4."  DESC";  //where數值
$centerArr=databasetablewhile($dbneme2=$var3,$where2);


//刪除內容1
switch($xoopsmodule){
  case "neilmfdcms":	  
fileadminfunction($fileurl="",$type="1",$fileex="",$from=XOOPS_ROOT_PATH.'/uploads/'.$xoopsmodule.'/types'.$var6.'/'.$val.'file');    
//刪除自訂按鈕
neillibrary_memudeletfunction($pageid=$val,$menutype=0,$modulesid=$xoopsmodule);  
  break;
  case "neilalbum":	  
fileadminfunction($fileurl="",$type="1",$fileex="",$from=XOOPS_ROOT_PATH.'/uploads/'.$xoopsmodule.'/'.$val.'file');
//刪除自訂按鈕
neillibrary_memudeletfunction($pageid=$val,$menutype=0,$modulesid=$xoopsmodule);      
  break;
  case "neilonlinevideo":	  
fileadminfunction($fileurl="",$type="1",$fileex="",$from=XOOPS_ROOT_PATH.'/uploads/'.$xoopsmodule.'/'.$val.'file');
  break;
  case "neilfilefolder":	  
fileadminfunction($fileurl="",$type="1",$fileex="",$from=XOOPS_ROOT_PATH.'/uploads/'.$xoopsmodule.'/'.$val.'file');
  break;    
  case "neilsignedup_c":	  
fileadminfunction($fileurl="",$type="1",$fileex="",$from=XOOPS_ROOT_PATH.'/uploads/'.$xoopsmodule.'/'.$val.'file');
//刪除自訂按鈕
neillibrary_memudeletfunction($pageid=$val,$menutype=0,$modulesid=$xoopsmodule);    
  break;      
  case "neilsignedup_a":	  
fileadminfunction($fileurl="",$type="1",$fileex="",$from=XOOPS_ROOT_PATH.'/uploads/'.$xoopsmodule.'/'.$val.'file');
//刪除自訂按鈕
neillibrary_memudeletfunction($pageid=$val,$menutype=0,$modulesid=$xoopsmodule);    

  break;   
  case "neilofficebriefing":	  
neillibrary_memudeletfunction($pageid=$val,$menutype=0,$modulesid=$xoopsmodule);
  break; 
  case "neilproduct":	  
fileadminfunction($fileurl="",$type="1",$fileex="",$from=XOOPS_ROOT_PATH.'/uploads/'.$xoopsmodule.'/'.$val.'file');
//刪除自訂按鈕
neillibrary_memudeletfunction($pageid=$val,$menutype=0,$modulesid=$xoopsmodule);  
//刪除加入商品諮詢
neilproduct_deletinquiry($pageid=$val);
  break;  
  case "neilenglishresults":
englishresults_deletedata($enfunction,$pageid=$val);
  break; 
  
  
  default:
}
  	
//刪除內容
foreach($centerArr as $key=> $i){
$where3=" where `".$var4."` = '".$centerArr[$key][$var4]."'";
deletefunction($where3,$DBname=$var3);	


//刪除內容2
switch($xoopsmodule){
  case "neilproduct":
foreach($Arr=databasetablewhile($dbneme=$var5,$where3) as $key=> $i){	
deletefunction($where4=" where `pimgid` = '".$Arr[$key]['pimgid']."'",$dbneme=$var5);
}
  break;
  case "neilofficebriefing":
neillibrary_memudeletfunction($pageid=$centerArr[$key][$var4],$menutype=1,$modulesid=$xoopsmodule);  	//刪除正本自訂按鈕   	   
neilofficebriefing_deleteproductimg($var5,$where3,$synchronize=$centerArr[$key][$var4],$modulesid=$xoopsmodule);
  break;
  
  case "neilfilefolder":  
neilfilefolder_deletefolderlist($dbid=$centerArr[$key][$var4],$sortid=$val,$xoopsmodule,$typevar="");
  break;

  case "neilsignedup_c":
neilsignedup_c_deleteapplylist($dbid=$centerArr[$key][$var4],$xoopsmodule);    
  break;     
  
  case "neilsignedup_a":
neilsignedup_a_deleteapplylist($dbid=$centerArr[$key][$var4],$xoopsmodule);    
  break;  
  
  case "neilmfdcms":	  
//刪除自訂按鈕
neillibrary_memudeletfunction($pageid=$centerArr[$key][$var4],$menutype=1,$modulesid=$xoopsmodule);

//刪除留言資料-內容回覆類型
$typesList=moduledb($dbneme="neilmfdcmstypes",$where="  where  `typesid` = '".$var6."'    ");   
if($typesList['types']=='4') neilmfdcms_messagedate($centerid=$centerArr[$key][$var4]);

  break;
  
  case "neilalbum":	  
//刪除自訂按鈕
neillibrary_memudeletfunction($pageid=$centerArr[$key][$var4],$menutype=1,$modulesid=$xoopsmodule);

  break;
  
  default:
}


}

	
//刪除分類
$where=" where `".$sortidname."` = '".$val."'";
deletefunction($where,$DBname=$dbneme);
//組合刪除
$deletetr.="#deletetr".$val.",";
}  	 


echo json_encode(substr($deletetr,0,-1));exit;  	  
  	  

  break;    
  
  
    
    
 
 /* case "67":
$where=" where `productid` = '$dbid'";
$DBname="productcontent";  
!empty($isAdmin) ? deletefunction($where,$DBname) : '';    


//解商品圖片
$dbneme="productimg";
$where=" where productid='".$dbid."' order by  pimgid  ASC";
$productimgArr=databasetablewhile($dbneme,$where); 

foreach($productimgArr as $key=> $val){


//刪除大縮圖
if(file_exists(XOOPS_ROOT_PATH.'/uploads/neilproduct/image/.thumbs/'.$productimgArr[$key]['pimgfile'].'.jpg')){
 unlink(XOOPS_ROOT_PATH.'/uploads/neilproduct/image/.thumbs/'.$productimgArr[$key]['pimgfile'].'.jpg');//將檔案刪除
} 

//刪除小縮圖
if(file_exists(XOOPS_ROOT_PATH.'/uploads/neilproduct/image/.thumbs/'.$productimgArr[$key]['pimgfile'].'_tmb.jpg')){
 unlink(XOOPS_ROOT_PATH.'/uploads/neilproduct/image/.thumbs/'.$productimgArr[$key]['pimgfile'].'_tmb.jpg');//將檔案刪除
} 

$where=" where `pimgid` = '".$productimgArr[$key]['pimgid']."'";
$DBname="productimg";  
!empty($isAdmin) ? deletefunction($where,$DBname) : '';    

}






  break; */
    
 /* case "68":

	      
   break;  
   
   */
   
  case "69":
 /* 	  

$dbneme="officebriefingsort";
//第一層
$where="  where `sortid` = '".$dbid."'   order by  sortidsort  DESC";  //where數值
$Arr=databasetablewhile($dbneme,$where);


//遞回開始
foreach($Arr as $key=> $val){
$sortvar.=$Arr[$key]['sortid'].","; 
$sortvar.=sortretorted($dbneme,$sortid="".$Arr[$key]['sortid']."");
}

//去除最後一個字元
$sortvar=substr($sortvar,0,-1);
//切割陣列
$sortvarArr=cuttingfunction($cutting=$sortvar,$sign=",");


foreach($sortvarArr as $key=> $val){
$where=" where `sortid` = '".$val."'";
$DBname="officebriefingsort";  
!empty($isAdmin) ? deletefunction($where,$DBname) : '';
//組合刪除
$deletetr.="#deletetr".$val.",";
}
//去除最後一個字元
$deletetr=substr($deletetr,0,-1);


echo json_encode($deletetr);exit; */   	  

  break;      
  
  
   
      
         case "70":
//讀取neilshopsort資料表 
$dbneme="officebriefingsort";  //資料表名稱

//name值
$namevar= empty($var1) ? "of_sortid" : $var1; // get TRUE

$dbid=$exchange=='true'? $dbid : $selectidedit; // get TRUE
$where=" where `of_sortid` = '".$dbid."' &&  `enable` = '1' order by sortidsort ASC";   //where數值-新增



if(!empty($dbid)){
$sort=databasetablewhile($dbneme,$where); 
}
$optionone.=optionbox($sortvar=$sort,$oid=$of_sortid);


if(!empty($optionone)){
$select.="<select id=".$selectid." class='form-control' name='".$namevar."' >
<option   data-id='".$dbid."' value='".$dbid."'  >"._MS_SHARED39."</option>
     	".$optionone."   
  </select>	 <p>

";
}	 

echo $select;

  break;


  case "71":
//管理員權限
if(empty($isAdmin)) exit;    


$Arrdate = array(); //建構陣列 



//刪除簡介正本
$i=0;
$Arrdate[$i]['dbneme']="officebriefingcontent";
$Arrdate[$i]['where']=" where `officeid` = '$dbid'";
$Arrdate[$i]['id']="officeid";

//刪除自訂按鈕
neillibrary_memudeletfunction($pageid=$dbid,$menutype=1,$modulesid='neilofficebriefing');

//刪除簡介副本
$i++;
$Arrdate[$i]['dbneme']="officebriefingcontent";
$Arrdate[$i]['where']=" where `synchronize` = '$dbid'";
$Arrdate[$i]['id']="officeid";

//解出正本officeid
$dbneme="officebriefingcontent";
$where=" where `synchronize` = '$dbid'";
$contentList=moduledb($dbneme,$where);	
$i++;
$Arrdate[$i]['dbneme']="neillibrary_modulesmenu";
$Arrdate[$i]['where']=" where `modulesid` = 'neilofficebriefing'  &&  `menutype` = '1'   &&  `pageid` = '".$contentList['officeid']."' ";
$Arrdate[$i]['id']="menuid";




//刪除圖檔
$dbneme="officebriefingimg";
$where=" where `officeid` = '$dbid'";  //where數值 
$officebriefingimgArr=databasetablewhile($dbneme,$where);  

foreach($officebriefingimgArr as $key=> $val){
//檔名
$fileurl=XOOPS_ROOT_PATH.'/uploads/neilofficebriefing/image/.thumbs/'.$officebriefingimgArr[$key]['pimgfile'].'.jpg';
fileadminfunction($fileurl,$type="2",$fileex="",$from="");
}

$i++;
$Arrdate[$i]['dbneme']="officebriefingimg";
$Arrdate[$i]['where']=" where `officeid` = '$dbid'";
$Arrdate[$i]['id']="pimgid";

//批次刪除function
deleteArr($Arrdate=$Arrdate);	



//刪除圖檔
if(file_exists(XOOPS_ROOT_PATH.'/uploads/'.$xoopsmodule.'/types'.$neilmfdcmscenterList['typesid'].'/'.$neilmfdcmscenterList['sortid'].'file/image/.thumbs/'.$neilmfdcmscenterList['representimg'].'.png')){
 unlink(XOOPS_ROOT_PATH.'/uploads/'.$xoopsmodule.'/types'.$neilmfdcmscenterList['typesid'].'/'.$neilmfdcmscenterList['sortid'].'file/image/.thumbs/'.$neilmfdcmscenterList['representimg'].'.png');//將檔案刪除
} 






/*
foreach($synchronizeArr as $key=> $val){
//刪除副本資料表	
$where=" where `officeid` = '".$synchronizeArr[$key]['officeid']."'";
$DBname="officebriefingcontent";  
!empty($isAdmin) ? deletefunction($where,$DBname) : '';  		
}
  	  
//刪除圖片  	  
  	  
$where=" where `officeid` = '$dbid'";
$DBname="officebriefingcontent";  
!empty($isAdmin) ? deletefunction($where,$DBname) : '';    
*/


  break; 
 
  case "72":
  	  
if(!empty($isAdmin)){
$setvar="set  uid='".$selectid."'  where officeid='".$dbid."'";
update($dbname="officebriefingcontent",$set=$setvar); 
}     	     
  	  
   break;  	     
   
   
  case "73":
 /*if(empty($xoopsUser)){
 $deletetr=_MS_SHARED37;
 }else{
 $uid=$xoopsUser->getVar('uid');    	  

 //判斷分類是否有投票進行
$dbneme="neilvideosvote_category";  //資料表名稱
$where=" where `cat_id` = '".$of_sortid."'  order by  cat_id   DESC";
$neilvideosvote_categoryList=moduledb($dbneme,$where); 	 

if($neilvideosvote_categoryList['ispoll']==0){
echo $deletetr=_MS_SHOPPINGCART76; 
exit;
}  	 

//開啟neilvideosvote_poll_log資料表
$dbneme="neilvideosvote_poll_log";  //資料表名稱
$where=" where `uid` = '".$uid."'  order by  id   DESC";
$polllogList=moduledb($dbneme,$where); 	 
$create_time=$polllogList['create_time'];
$create_time=timedate($datevar=$create_time,$type=3,$calculate="",$m="",$d="",$y="",$format="Y-m-d H:i:s");
//判斷投票天數

//加上一天的天數
$create_timeoneday=timedate($datevar="".$create_time."",$type="2",$calculate="+",$m="",$d=1,$y="");

//判斷投票日期
//開啟neilvideosvote_category資料表
$dbneme="neilvideosvote_category";  //資料表名稱
$where=" where `cat_id` = '".$of_sortid."'  order by  cat_id   DESC";
$neilvideosvotecategoryList=moduledb($dbneme,$where); 	 
//投票開始時間
$poll_start_time=timedate($datevar=$neilvideosvotecategoryList['poll_start'],$type=3,$calculate="",$m="",$d="",$y="",$format="Y-m-d H:i:s");
//投票結束時間
$poll_end_time=timedate($datevar=$neilvideosvotecategoryList['poll_end'],$type=3,$calculate="",$m="",$d="",$y="",$format="Y-m-d H:i:s");

//投票已結束
if(timedate($datevar="Y-m-d H:i:s") > $poll_end_time){
echo $deletetr=_MS_SHOPPINGCART74; 
exit;
}

//投票尚未開始
if($poll_start_time > timedate($datevar="Y-m-d H:i:s")){
echo $deletetr=_MS_SHOPPINGCART75; 
exit;
}


//判斷投票時間是否超過24小時
if(timedate($datevar="Y-m-d H:i:s") > $create_timeoneday){	
//存入neilvideosvote_poll_log資料表
$valuesvar="(item_id,cat_id,uid,create_time) values('{$dbid}','{$of_sortid}','{$uid}','".time()."')";	  
insert($dbname="neilvideosvote_poll_log",$values=$valuesvar); 

//開啟neilvideosvote_item資料表
$dbneme="neilvideosvote_item";  //資料表名稱
$where=" where `item_id` = '".$dbid."'  order by  item_id   DESC";
$neilvideosvoteitemList=moduledb($dbneme,$where); 	 

//得票數+1
$vote=$neilvideosvoteitemList['vote']+1;

//存入neilvideosvote_item
$setvar="set  vote='".$vote."'  where item_id='".$dbid."'";
update($dbname="neilvideosvote_item",$set=$setvar);


$deletetr=_MS_SHOPPINGCART72; 
}else{
$deletetr=_MS_SHOPPINGCART73; 
}

} 	  
  	  





echo $deletetr;    	  
	 */ 
   break;  	
   
   
  case "74":      
//開啟neilvideosvote_item資料表
/*$dbneme="neilvideosvote_item";  //資料表名稱
$where=" where `item_id` = '".$dbid."'  order by  item_id   DESC";
$neilvideosvoteitemList=moduledb($dbneme,$where); 	 
  
  
echo empty($neilvideosvoteitemList['vote']) ? '0' : $neilvideosvoteitemList['vote']; // get TRUE   
  */
   break;  	
  
  case "75":     
/* $where=" where `item_id` = '$dbid'";
$DBname="neilvideosvote_item";  
!empty($isAdmin) ? deletefunction($where,$DBname) : '';     	  
  	  */
  	  
    break;  	 	    
         
 /*case "76":      
$xoops_theme = $GLOBALS['xoopsConfig']['theme_set'];
$where=" where `nsn` = '$dbid'";
$DBname="neothemesflash";  
!empty($isAdmin) ? deletefunction($where,$DBname) : '';     

 $delimgid="p".$dbid.".jpg"; 
//刪除實體圖片
if(file_exists(XOOPS_ROOT_PATH.'/uploads/'.$xoops_theme.'/'.$delimgid)){
 unlink(XOOPS_ROOT_PATH.'/uploads/'.$xoops_theme.'/'.$delimgid);//將檔案刪除
} 
   	   
  break;   	 */ 
  
  
   case "77":
$where=" where `sortid` = '$dbid'";
$DBname="neilcurriculumsort";  
!empty($isAdmin) ? deletefunction($where,$DBname) : '';   


//組合刪除
$deletetr.="#deletetr".$dbid."";
echo json_encode($deletetr);exit;     
  break;      
  
  
   case "78":
$where=" where `subjectid` = '$dbid'";
$DBname="neilsubject";  
!empty($isAdmin) ? deletefunction($where,$DBname) : '';   

  break;    

   case "79":
$where=" where `savingtimeid` = '$dbid'";
$DBname="neilsavingtime";  
!empty($isAdmin) ? deletefunction($where,$DBname) : '';   

  break;     
  
   case "80":
$useradmin=useradmin($uid=$xoopsUser->getVar('uid'),$curriculumid=$pageid);  	   
$where=" where `instructorid` = '$dbid'";
$DBname="neilinstructor";  
!empty($useradmin) ? deletefunction($where,$DBname) : '';   
  break;   
  
   case "81":  
 //管理權限
$useradmin=useradmin($uid=$xoopsUser->getVar('uid'),$curriculumid=$pageid);  	   
  if(!empty($useradmin)){

//陣列轉字串
$mondaystring=phpconversion($conversion=$monday,$type="serialize"); 
$tuesdaystring=phpconversion($conversion=$tuesday,$type="serialize"); 
$wednesdaystring=phpconversion($conversion=$wednesday,$type="serialize"); 
$thursdaystring=phpconversion($conversion=$thursday,$type="serialize"); 
$fridaystring=phpconversion($conversion=$friday,$type="serialize"); 

 if(empty($selectid)){  //新增
 //新增資料
$valuesvar="(curriculumid,savingtimeid,monday,tuesday,wednesday,thursday,friday) values('{$pageid}','{$dbid}','{$mondaystring}','{$tuesdaystring}','{$wednesdaystring}','{$thursdaystring}','{$fridaystring}')";	  
insert($dbname="neilsavingtimecontent",$values=$valuesvar); 
 }else{  //編輯
 
$setvar="set  monday='".$mondaystring."' , tuesday='".$tuesdaystring."'  , wednesday='".$wednesdaystring."' , thursday='".$thursdaystring."' , friday='".$fridaystring."' where timecontentid='".$selectid."'";
update($dbname="neilsavingtimecontent",$set=$setvar);
 }

  }     	   
   	   
    break;    
    
    
  case "82":
  	  
if(!empty($isAdmin)){
$setvar="set  uid='".$selectid."'  where curriculumid='".$dbid."'";
update($dbname="neilcurriculumcontent",$set=$setvar); 
}     	     
  	  
   break;  	    
   
     case "83":
$where=" where `curriculumid` = '$dbid'";
$DBname="neilcurriculumcontent";  
!empty($isAdmin) ? deletefunction($where,$DBname) : '';  

//開啟課表節次內容資料表
$dbneme="neilsavingtimecontent";
$where=" where `curriculumid` = '$dbid'";  //where數值 
$neilsavingtimecontentArr=databasetablewhile($dbneme,$where);  

foreach($neilsavingtimecontentArr as $i=> $val){
//刪除課表節次內容資料表	
$where=" where `timecontentid` = '".$neilsavingtimecontentArr[$i]['timecontentid']."'";
$DBname="neilsavingtimecontent";  
!empty($isAdmin) ? deletefunction($where,$DBname) : '';  		
}

//開啟課表任課老師資料表
$dbneme="neilinstructor";
$where=" where `curriculumid` = '$dbid'";  //where數值 
$neilinstructorArr=databasetablewhile($dbneme,$where);  

foreach($neilinstructorArr as $i=> $val){
//刪除課表任課老師資料表	
$where=" where `instructorid` = '".$neilinstructorArr[$i]['instructorid']."'";
$DBname="neilinstructor";  
!empty($isAdmin) ? deletefunction($where,$DBname) : '';  		
}

  
  break; 
   

   case "84":
//讀取neilshopsort資料表 
/*$dbneme="neothemesmenu";  //資料表名稱


if($exchange=='true'){
$dbid=$dbid;
}else{
$dbid=$selectidedit;
}

if($status==edit){
if($exchange=='true'){
 $where=" where `of_sortid` = '".$dbid."'  && `enable` = '1'  order by sortidsort ASC";   //where數值-修改
}else{
 $where=" where `of_sortid` = '".$dbid."'  && `enable` = '1'  order by sortidsort ASC";   //where數值-修改 

}
}else{
  $where=" where `of_sortid` = '".$dbid."'  && `enable` = '1'  order by sortidsort ASC";   //where數值-新增
}

if(!empty($dbid)){
//$sort=!empty($isAdmin) ? databasetablewhile($dbneme,$where) : ''; 
$sort=databasetablewhile($dbneme,$where); 
}
$optionone.=optionbox($sortvar=$sort,$oid=$of_sortid);

if(!empty($optionone)){
$select.="<select id=".$selectid." class='form-control' name='of_sortid' >
	 <option   data-id='".$dbid."' value=".$dbid."  >"._MS_SHARED42."</option>
     	".$optionone."   
  </select>	 <p>

";
}
echo $select.="

";*/

  break;
    	   
    	   
    
  case "85":
$dbneme="neothemesmenu";
//第一層
$where="  where `sortid` = '".$dbid."'   order by  sortidsort  DESC";  //where數值
$Arr=databasetablewhile($dbneme,$where);


//遞回開始
foreach($Arr as $key=> $val){
$sortvar.=$Arr[$key]['sortid'].","; 
$sortvar.=sortretorted($dbneme,$sortid="".$Arr[$key]['sortid']."");
}

//去除最後一個字元
$sortvar=substr($sortvar,0,-1);
//切割陣列
$sortvarArr=cuttingfunction($cutting=$sortvar,$sign=",");


foreach($sortvarArr as $key=> $val){
$where=" where `sortid` = '".$val."'";
$DBname="neothemesmenu";  
!empty($isAdmin) ? deletefunction($where,$DBname) : '';
//組合刪除
$deletetr.="#deletetr".$val.",";
}  	  


//去除最後一個字元
$deletetr=substr($deletetr,0,-1);


echo json_encode($deletetr);exit;  	  
  	  

  break;        	   
 
 
 
  case "86":
$dbneme="neoblockmenubutton";
//第一層
$where="  where `sortid` = '".$dbid."'   order by  sortidsort  DESC";  //where數值
$Arr=databasetablewhile($dbneme,$where);


//遞回開始
foreach($Arr as $key=> $val){
$sortvar.=$Arr[$key]['sortid'].","; 
$sortvar.=sortretorted($dbneme,$sortid="".$Arr[$key]['sortid']."");
}

//去除最後一個字元
$sortvar=substr($sortvar,0,-1);
//切割陣列
$sortvarArr=cuttingfunction($cutting=$sortvar,$sign=",");


foreach($sortvarArr as $key=> $val){
$where=" where `sortid` = '".$val."'";
$DBname="neoblockmenubutton";  
!empty($isAdmin) ? deletefunction($where,$DBname) : '';
//組合刪除
$deletetr.="#deletetr".$val.",";
}  	  


//去除最後一個字元
$deletetr=substr($deletetr,0,-1);


echo json_encode($deletetr);exit;  	  
  	  

  break;   
  
  
  
 case "87":   
if(empty($isAdmin)) exit;	     
$where=" where `sortid` = '$dbid'";
$DBname="neoblockmenubutton";  
//開啟neoblockmenubutton資料夾
$listv=moduledb($DBname="neoblockmenubutton",$where=" where `sortid` = '$dbid'");
//刪除實體圖片
fileadminfunction($fileurl=XOOPS_ROOT_PATH.'/uploads/neothemesadmin/'.$listv['buttonimg'].'.png',$type="2",$fileex="",$from="",$fileurlnew="",$exclude="");
deletefunction($where,$DBname);     
   	   
  break;   	    
  
  
  case "88":  
$xoops_theme = $GLOBALS['xoopsConfig']['theme_set'];  	      
$where=" where `sortid` = '$dbid'";
$DBname="neoblockmenusort";  
!empty($isAdmin) ? deletefunction($where,$DBname) : '';     


$dbneme="neoblockmenubutton";
//第一層
$where="  where `categoryid` = '".$dbid."'   order by  sortid  DESC";  //where數值
$Arr=databasetablewhile($dbneme,$where);


//遞回開始
foreach($Arr as $key=> $val){
$sortvar.=$Arr[$key]['sortid'].","; 
$sortvar.=sortretorted($dbneme,$sortid="".$Arr[$key]['sortid']."");
}

//去除最後一個字元
$sortvar=substr($sortvar,0,-1);
//切割陣列
$sortvarArr=cuttingfunction($cutting=$sortvar,$sign=",");


foreach($sortvarArr as $key=> $val){
$where=" where `sortid` = '".$val."'";
$DBname="neoblockmenubutton";  
$neoblockmenubuttonList=moduledb($DBname,$where);
!empty($isAdmin) ? deletefunction($where,$DBname) : '';

//製作圖片
//檔名
$imgid=$neoblockmenubuttonList['buttonimg'];
$delimgid=$imgid.".png"; 

//刪除實體圖片
if(file_exists(XOOPS_ROOT_PATH.'/uploads/'.$xoops_theme.'/'.$delimgid)){
 unlink(XOOPS_ROOT_PATH.'/uploads/'.$xoops_theme.'/'.$delimgid);//將檔案刪除
} 

}  	 

   	   
  break;   	 	   
  
 /* case "89":    
 if(!empty($isAdmin)){
//讀取neilbasicinformation資料表
$dbneme="neilbasicinformation";
$where=" where basid='".$dbid."' order by  basid  DESC";
$basidList=moduledb($dbneme,$where);
$enablebox=sprintf(_MD_AJAX13,enable($envar=$basidList['enable'],$type=true));  
  
  }
  

echo $enablebox;  
  break;  
  
  case "90":      
$where=" where `basid` = '$dbid'";
$DBname="neilbasicinformation";  
!empty($isAdmin) ? deletefunction($where,$DBname) : '';    
   break;    
   
  case "91":    
 if(!empty($isAdmin)){  
 
$enable=empty($enable) ? '0' : $enable;

$setvar="set  `enable` = '".$enable."'	where `basid` = '$dbid'";
update($dbname="neilbasicinformation",$set=$setvar);

if(empty($enable)){
$enabletext=_MD_AJAX14;
}else{
$enabletext=_MD_AJAX15;
}  	  

echo $enabletext;   	   
   }
      
    break;    
    
    */
 /*  case "92":
  	  
if(!empty($isAdmin)){


//判斷UID是否重複	
if(!empty(useradmin($uid=$selectid,$basid=$dbid,$type='1'))){	
$enabletext=_MS_SHOPPINGCART78;	
}else{
$setvar="set  uid='".$selectid."'  where basid='".$dbid."'";
update($dbname="neilbasicinformation",$set=$setvar); 
$enabletext=_MS_SHOPPINGCART79;	
}


	

}  
   	     
echo $enabletext;   	  	  
   break;     
 */
   case "93":

//權限判斷
if(empty(useradmin($uid=$xoopsUser->getVar('uid'),$basid=$dbid))) exit;



if($status=='add'){ //新增
$valuesvar="(basid,enfunction,of_sortid,sorttitle,sorttext,enable) values('{$dbid}','{$enfunction}','{$of_sortid}','{$sorttitle}','{$sorttext}','{$enable}')";	  
insert($dbname="neilbritishcapitalsort",$values=$valuesvar);    	   
}else{  //儲存

//讀取父分類
$dbneme="neilbritishcapitalsort";
$where="  where `sortid` = '".$sortid."'  order by  of_sortid  DESC";  //where數值
$sortselect=moduledb($dbneme,$where);

$of_sortid=$sortid!=$of_sortid ? $of_sortid: $sortselect['of_sortid'];   

$setvar="set basid='{$dbid}' , enfunction='{$enfunction}' , of_sortid='{$of_sortid}' , sorttitle='{$sorttitle}' , sorttext='{$sorttext}' , enable='{$enable}'  where sortid='".$sortid."'";
update($dbname="neilbritishcapitalsort",$set=$setvar);
}   	       
    break; 
    
    case "94":   
//讀取neilbritishcapitalsort資料表 
$dbneme="neilbritishcapitalsort";  //資料表名稱



$dbid=empty($dbid) ? $selectidedit : $dbid; // get TRUE

if(empty($enable)) $enableDB="&&  `enable` = '1'";


 $where=" where `of_sortid` = '".$dbid."' ".$enableDB."   &&  `basid` = '".$basid."' &&  `enfunction` = '".$enfunction."' order by sortidsort ASC";   //where數值-新增

if(!empty($dbid)){
$sort=databasetablewhile($dbneme,$where); 
}
$optionone.=optionbox($sortvar=$sort,$oid=$of_sortid);


if(!empty($optionone)){
$select.="<select id=".$selectid." class='form-control' name='of_sortid' >
	 <option   value=".$dbid."  >"._MS_SHARED71."</option>
     	".$optionone."   
  </select>	 <p>

";
}

if(!empty($optionone)){
$select.="	
 <script src='".XOOPS_URL."/modules/neilenglishresults/js/menu/ajaxjs2.js'></script>
  
"; 	
}
 	
echo $select;   	
     break;  	
     
     case "95":   
//讀取neilbritishcapitalsort資料表 
$dbneme="neilbritishcapitalsort";  //資料表名稱


$dbid=empty($dbid) ? $selectidedit : $dbid; // get TRUE

if(empty($enable)) $enableDB="&&  `enable` = '1'";

 $where=" where `of_sortid` = '".$dbid."' ".$enableDB."  &&  `basid` = '".$basid."' &&  `enfunction` = '".$enfunction."'  order by sortidsort ASC";   //where數值-新增


if(!empty($dbid)){
$sort=databasetablewhile($dbneme,$where); 
}
$optionone.=optionbox($sortvar=$sort,$oid=$of_sortid);

if(!empty($optionone)){
 $select.="<select    id=".$selectid." class='form-control' name='of_sortid' >
	 <option    value=".$dbid."  >"._MS_SHARED71."</option>
     	".$optionone."   
  </select>	 <p>

";
}

if(!empty($dbid)){
$select.="	
	<script>var $selectid='".$dbid."';</script>		
 <script src='".XOOPS_URL."/modules/neilenglishresults/js/menu/ajaxjs3.js'></script>
	 ";
}
echo $select;

     	 
     	 
     	 
     break;  	 
     
      case "96":       
//讀取neilbritishcapitalsort資料表 
$dbneme="neilbritishcapitalsort";  //資料表名稱

$dbid=empty($dbid) ? $selectidedit : $dbid; // get TRUE


if(empty($enable)) $enableDB="&&  `enable` = '1'";

 $where=" where `of_sortid` = '".$dbid."' ".$enableDB."    &&  `basid` = '".$basid."' &&  `enfunction` = '".$enfunction."' order by sortidsort ASC";   //where數值-新增


if(!empty($dbid)){

$sort=databasetablewhile($dbneme,$where); 
}
$optionone.=optionbox($sortvar=$sort,$oid=$of_sortid);

if(!empty($optionone)){
echo $select.="<select id=".$selectid." class='form-control' name='of_sortid' >
	 <option   value=".$dbid."  >"._MS_SHARED71."</option>
     	".$optionone."   
  </select>	 <p>

";
}
      	  
     
     
     
       break;  	    


  /* case "97":     

//權限判斷
if(empty(useradmin($uid=$xoopsUser->getVar('uid'),$basid=$basid))) exit;
   	   
$dbneme="neilbritishcapitalsort";
//第一層
$where="  where `sortid` = '".$dbid."' &&  `basid` = '".$basid."' &&  `enfunction` = '".$enfunction."'   order by  sortidsort  DESC";  //where數值
$Arr=databasetablewhile($dbneme,$where);


//遞回開始
foreach($Arr as $key=> $val){
$sortvar.=$Arr[$key]['sortid'].","; 
$sortvar.=sortretorted($dbneme,$sortid="".$Arr[$key]['sortid']."");
}

//去除最後一個字元
$sortvar=substr($sortvar,0,-1);
//切割陣列
$sortvarArr=cuttingfunction($cutting=$sortvar,$sign=",");


foreach($sortvarArr as $key=> $val){
$where=" where `sortid` = '".$val."'";
$DBname="neilbritishcapitalsort";  
deletefunction($where,$DBname);

//組合刪除
$deletetr.="#deletetr".$val.",";
}
//去除最後一個字元
$deletetr=substr($deletetr,0,-1);


echo json_encode($deletetr);exit;	   
   	   
  break;  	 
  */
    case "98":    
//權限判斷
if(empty(useradmin($uid=$xoopsUser->getVar('uid'),$basid=$dbid))) exit;


 foreach($sortid as $key=> $val){   
$setvar="set sortidsort='{$sortvar[$key]}'  where sortid='".$val."'";
update($dbname="neilbritishcapitalsort",$set=$setvar);	 
 
 }	
    	
  	         	    
   break;  	 
   
   
case "99":   //英資影片新增編輯儲存
//權限判斷
if(empty(useradmin($uid=$xoopsUser->getVar('uid'),$basid=$dbid))) exit;
//判斷影片格式
$movieurl=$type=="y" ? youtubeurl($youtubeurl=$movieurl) :$movieurl;
$typeto=$type=='y' ? 'b' : 'n';
//影片代表圖
$tmburl=onlinevideobox($width="",$height="",$url=$movieurl,$typeto,$img="");
//開啟neilbasicinformation
$basidList=moduledb($dbneme="neilbasicinformation",$where="  where `basid` = '".$dbid."'  ");
//建構陣列-去資料表標籤
$sqlinjectionArr = array();
//建構陣列
$i=0;
$sqlinjectionArr[$i]=$title;
//title
$i++;
$sqlinjectionArr[$i]=$moviedescription;
//description
$Arrclean=removesqlforeach($var=$sqlinjectionArr,$coderemove=true);
foreach($Arrclean as $var=> $value) {
	$$var=trim(isset($value)?$value:"");
}
if($status=='add') {
//新增		
if(!empty($isAdmin)){
$enable="1";
$review="4";
$reviewtype="go";
}else{
$enable="0";
$review="1";
$reviewtype="";
}


$valuesvar="(basid,sortid,movieurl,title,moviedescription,setuptime,frequency,enable,review,reviewtime,id,enfunction,reviewtype,tmburl,type) values('{$dbid}','{$of_sortid}','{$movieurl}','{$title}','{$moviedescription}',current_timestamp(),'0','{$enable}','{$review}',current_timestamp(),'0','1','{$reviewtype}','','".$type."')";
$movieid=insert($dbname="neilenmovie",$values=$valuesvar);
	
	
if(!empty($isAdmin)){	
//建立審核資料
englishresults_gofunction($dbid,$var1=$movieid,$reviewtext=_MD_INDEXPHP88,$enfunction=1,$review=4);
}
	
	
    //儲存成果影音最新一筆ID
    update($dbname="config",$set="set conf_value='".$movieid."'  where conf_name='neilenglishresults16'");  
    //儲存最新一筆成果類型ID
    update($dbname="config",$set="set conf_value='1'  where conf_name='neilenglishresults19'"); 
    
	
	//檔名
	$filename=$type=="y" ? "youtubeurl_".$movieid :"facebook_".$movieid;
	//建立資料夾
	fileadminfunction($fileurl="",$type="4",$fileex="",$from=XOOPS_ROOT_PATH . "/uploads/neilenglishresults/enf".$dbid."/movie",$fileurlnew="",$exclude="");
	//建立檔案
	if(!empty($tmburl)) neillibrary_curlsave_file($tmburl,XOOPS_ROOT_PATH.'/uploads/neilenglishresults/enf'.$dbid.'/movie/'.$filename.'.png');
	//存入ID數值
	$setvar="set id='{$movieid}'  ,  tmburl='".$filename."'  where movieid='".$movieid."'";
	update($dbname="neilenmovie",$set=$setvar);

    if(empty($isAdmin)){	
	//通知管理員
	$url="".XOOPS_URL."/modules/".$xoopsmodule."/moviecenter.php?op=page&basid=".$basid."&movieid=".$movieid."&reviewadmin=1";
	reviewadminmail($companyname=$basidList['companyname'],$getGroupid=1,$timedate=timedate($datevar="Y-m-d H:i:s"),$enfunction=1,$title,$type=1,$review=1,$url=$url);
    }
} else {
	//儲存
	//檔名
	$filename=$type=="y" ? "youtubeurl_".$movieid :"facebook_".$movieid;
	//建立檔案
	if(!empty($tmburl)) neillibrary_curlsave_file($tmburl,XOOPS_ROOT_PATH.'/uploads/neilenglishresults/enf'.$dbid.'/movie/'.$filename.'.png');
	$setvar="set sortid='{$of_sortid}' , movieurl='{$movieurl}' , title='{$title}' , moviedescription='{$moviedescription}' , tmburl='".$filename."' , type='{$type}'  where movieid='".$movieid."'";
	update($dbname="neilenmovie",$set=$setvar);
}
break; 	  	  
                
                
/*      case "100":  
//權限判斷


if(empty(useradmin($uid=$xoopsUser->getVar('uid'),$basid=$pageid))) exit;       	  

//刪除審核
deletneilenreview($basid=$pageid,$id=$dbid,$enfunction="1");

$where=" where `movieid` = '$dbid'";
$DBname="neilenmovie";  
$deleteList=moduledb($DBname,$where);
//刪除代表圖
fileadminfunction($fileurl=XOOPS_ROOT_PATH.'/uploads/neilenglishresults/enf'.$pageid.'/movie/'.$deleteList['tmburl'].'.png',$type="2",$fileex="",$from="",$fileurlnew="",$exclude="");
deletefunction($where,$DBname);


echo false;  	     	  
           break;  	  	                   
 */
 
  /*    case "101":   

$selectid=empty($selectid) ? '0' : $selectid; // get TRUE
      	  
switch($enfunction){
  case "1":
$setvar="set enable='{$selectid}'   where movieid='".$dbid."'";   	  
!empty($isAdmin) ? update($dbname="neilenmovie",$set=$setvar) : '';  	
  break;
 
  case "2":
$setvar="set enable='{$selectid}'   where albumid='".$dbid."'";   	  
!empty($isAdmin) ? update($dbname="neilenalbum",$set=$setvar) : '';  	
  break; 
  
  case "3":
$setvar="set enable='{$selectid}'   where newsid='".$dbid."'";   	  
!empty($isAdmin) ? update($dbname="neilennews",$set=$setvar) : '';  	
  break;   

  case "4":
$setvar="set enable='{$selectid}'   where fileid='".$dbid."'";   	  
!empty($isAdmin) ? update($dbname="neilenfile",$set=$setvar) : '';  	
  break;   

}
      
 
           break;  	 */
           
           
   case "102":   


$basidList=moduledb($dbneme="neilbasicinformation",$where="  where `basid` = '".$dbid."'  ");



switch($enfunction){
  case "1":
$dbneme="neilenmovie";
$where="  where `movieid` = '".$var1."'  ";  //where數值
  break;
  case "2":
$dbneme="neilenalbum";
$where="  where `albumid` = '".$var1."'  ";  //where數值
  break;  

  case "4":
$dbneme="neilenfile";
$where="  where `fileid` = '".$var1."'  ";  //where數值
  break;  
}


$dateList=moduledb($dbneme,$where);


$url="".XOOPS_URL."/modules/".$xoopsmodule."/".filetypevar($type=$enfunction,$basid=$dbid,$id=$var1)."&reviewadmin=1"; 
   	   
 //寫入權限判斷
if($reviewtype=='go'){
if(empty($isAdmin)) exit;
$enable=$review==4 ? '1' : '0'; // get TRUE		   
$enableBD="enable='{$enable}' ,";
//建立審核資料
englishresults_gofunction($dbid,$var1,$reviewtext,$enfunction,$review);

//MAIL通知單位管理員
reviewadminreplymail($timedate=timedate($datevar="Y-m-d H:i:s"),$title=$dateList['title'],$review=$review,$type=1,$companyname=$basidList['companyname'],$usermail=$basidList['email'],$url=$url,$enfunction=$enfunction);
}else{
if(empty(useradmin($uid=$xoopsUser->getVar('uid'),$basid=$dbid))) exit; 
$enableBD="";
//更新審核資料
backfunction($var2,$reviewtext,$review);
//MAIL通知管理員
reviewadminmail($companyname=$basidList['companyname'],$getGroupid=1,$timedate=timedate($datevar="Y-m-d H:i:s"),$enfunction=$enfunction,$title=$dateList['title'],$type=1,$review=$review,$url=$url);
}   	   
   	   
//儲存最新一筆成果類型ID
update($dbname="config",$set="set conf_value='".$enfunction."'  where conf_name='neilenglishresults19'"); 	  

switch($enfunction){
  case "1":


$setvar="set ".$enableBD." review='{$review}' , reviewtime='".timedate($datevar="Y-m-d H:i:s")."' , reviewtype='{$reviewtype}'  where movieid='".$var1."'";   	  
update($dbname="neilenmovie",$set=$setvar);

//儲存成果影音最新一筆審核ID
update($dbname="config",$set="set conf_value='".$var1."'  where conf_name='neilenglishresults16'");  

  break;
  

  case "2":
 	  
  	  
$setvar="set ".$enableBD." review='{$review}' , reviewtime='".timedate($datevar="Y-m-d H:i:s")."' , reviewtype='{$reviewtype}'  where albumid='".$var1."'";   	  
update($dbname="neilenalbum",$set=$setvar); 

//儲存成果相簿最新一筆審核ID
update($dbname="config",$set="set conf_value='".$var1."'  where conf_name='neilenglishresults17'");  
	
  break; 
  
 /* case "3":
  
 $setvar="set ".$enableBD." review='{$review}' , reviewtime='".timedate($datevar="Y-m-d H:i:s")."' , reviewtype='{$reviewtype}'  where newsid='".$var1."'";   	  
update($dbname="neilennews",$set=$setvar); 	
  break;   */

  case "4":


$setvar="set ".$enableBD." review='{$review}' , reviewtime='".timedate($datevar="Y-m-d H:i:s")."' , reviewtype='{$reviewtype}'  where fileid='".$var1."'";   	  
update($dbname="neilenfile",$set=$setvar); 	

//儲存成果檔案最新一筆審核ID
update($dbname="config",$set="set conf_value='".$var1."'  where conf_name='neilenglishresults18'");    
	
  break;  

}
      
 
           
   break;           
   case "103":   
//base64編碼
$contactustext=base64_encode($dbid);   	   
$setvar="set contactustext='{$contactustext}' ";
!empty($isAdmin) ? update($dbname="neothemesconfig",$set=$setvar) : '';  	  	   
     break;     
     
case "104":             
	
//機器人檢查
if(empty(defenserobot($var=$robot,$type=2)) and empty(alignmenturl())){
$harmful=true;
$type=2;
}	
	
//去除資料庫標籤SQL
foreach($Arr as $key=> $val){
$Arrclean[$key]=sqlinjectionfound($var=$val);
}	    

////無害化處理
if(judgeHtml($Arrclean[0])==true or (!is_numeric($Arrclean[1]) and !empty($Arrclean[1])) or judgeHtml($Arrclean[2])==true or judgeHtml($Arrclean[3])==true or judgeEmail($Arrclean[4])==true or (judgeurl($Arrclean[5])==true and !empty($Arrclean[5])) or judgeHtml($Arrclean[6])==true){
$harmful=true;
$type=1;
} 


//字元判斷
$configvar=configvar($modulesid="neilmessage");    


if(mb_strlen($Arrclean[6], "utf-8") > $configvar['neilmessage2']){
$harmful=true;
$type=3;
}

  
  
if($harmful==true){
switch($type){
  case "1":  //無害化
$text=_MS_SHARED34;
  break;
  
  case "2": //機器人
$text=_MS_SHARED75;
  break;  
  
  case "3": //字元判斷
$text=_MS_SHARED76;
  break;    
  
  default:

}







}else{
$valuesvar="(name,phone,telephone,companyname,email,weburl,content) values('".$Arrclean[0]."','".$Arrclean[1]."','".$Arrclean[2]."','".$Arrclean[3]."','".$Arrclean[4]."','".$Arrclean[5]."','".$Arrclean[6]."')";	  
$insertreturn=insert($dbname="neilboard",$values=$valuesvar);

//通知管理員
$url="".XOOPS_URL."/modules/".$xoopsmodule."/index.php?op=replydata&board=".$insertreturn."&permission=admin";
messageadminmail($getGroupid=1,$timedate=timedate($datevar="Y-m-d H:i:s"),$name=$Arrclean[0],$url=$url);

$text=""._MS_SHARED74.",".$insertreturn."";
}




echo $text;          
    
 break;    
 


  case "105":
$where=" where `board` = '$dbid'";
$DBname="neilboard";  
!empty($isAdmin) ? deletefunction($where,$DBname) : '';    
  break;

 
  case "106": 
 if(empty($isAdmin)) exit;
   
$setvar="set  replycontent='{$var3}' , replytime='".timedate($datevar="Y-m-d H:i:s")."' , type='1'  where board='".$var2."'";   	  
update($dbname="neilboard",$set=$setvar); 	
  
//通知訪客
//開啟neilboard資料表
$dbneme="neilboard";
$where=" where  board='".$var2."'  ";
$neilboardList=moduledb($dbneme,$where);
 
$url="".XOOPS_URL."/modules/".$xoopsmodule."/index.php?op=replydata&board=".$var2."";
//reviewadminreplymail($timedate=timedate($datevar="Y-m-d H:i:s"),$title=$neilenmovieList['title'],$review=$review,$type=1,$companyname=$basidList['companyname'],$usermail=$basidList['email'],$url=$url);
messagereplymail($name=$neilboardList['name'],$timedate=timedate($datevar="Y-m-d H:i:s"),$usermail=$neilboardList['email'],$url=$url);
   break;
   
   
case "107":   //相片新增編輯儲存
//權限判斷
if(empty(useradmin($uid=$xoopsUser->getVar('uid'),$basid=$dbid))) exit;


//上傳檔案驗證
$nanekey=array_keys($_FILES);
$prohibit=neillibrary_donotuploadfiles($filevar=$_FILES[$nanekey[0]],$operate=2);
if(!empty($prohibit['harmful'])) exit; 


//建構陣列-去資料表標籤
$sqlinjectionArr = array();
//建構陣列
$i=0;
$sqlinjectionArr[$i]=$title;
$i++;
$sqlinjectionArr[$i]=$moviedescription;

$Arrclean=removesqlforeach($var=$sqlinjectionArr,$coderemove=true);
foreach($Arrclean as $var=> $value) {
$$var=trim(isset($value)?$value:"");
}





if($status=='add'){ //新增	
	
if(!empty($isAdmin)){
$enable="1";
$review="4";
$reviewtype="go";
}else{
$enable="0";
$review="1";
$reviewtype="";
}



$valuesvar="(basid,sortid,title,albumtext,setuptime,basimg,basimgnumber,representimg,frequency,enable,review,reviewtime,id,enfunction,reviewtype,rightenable) values('{$dbid}','{$of_sortid}','{$title}','{$moviedescription}',current_timestamp(),'','0','','0','{$enable}','{$review}',current_timestamp(),'0','2','{$reviewtype}','{$check}')";	  
$albumid=insert($dbname="neilenalbum",$values=$valuesvar);    

if(!empty($isAdmin)){	
//建立審核資料
englishresults_gofunction($dbid,$var1=$albumid,$reviewtext=_MD_INDEXPHP88,$enfunction=2,$review=4);
}
	 
//儲存成果相片最新一筆ID
update($dbname="config",$set="set conf_value='".$albumid."'  where conf_name='neilenglishresults17'");  
//儲存最新一筆成果類型ID
update($dbname="config",$set="set conf_value='2'  where conf_name='neilenglishresults19'"); 

    
//開啟
$basidList=moduledb($dbneme="neilbasicinformation",$where="  where `basid` = '".$dbid."'  ");
if(empty($isAdmin)){	
//通知管理員
$url="".XOOPS_URL."/modules/".$xoopsmodule."/albumcenter.php?op=page&basid=".$basid."&albumid=".$albumid."&reviewadmin=1";
reviewadminmail($companyname=$basidList['companyname'],$getGroupid=1,$timedate=timedate($datevar="Y-m-d H:i:s"),$enfunction=2,$title,$type=1,$review=1,$url);
}
}else{  //儲存
$setvar="set basid='{$dbid}' , sortid='{$of_sortid}' , title='{$title}' , albumtext='{$moviedescription}' ,  rightenable='{$check}'  where albumid='".$albumid."'";
update($dbname="neilenalbum",$set=$setvar);

}      


//開啟
$dbneme="neilenalbum";
$where="   where `albumid` = '".$albumid."' ";  //where數值
$albumList=moduledb($dbneme,$where);

//製作圖檔  
$urlfile="".$xoopsmodule."/enf".$basid."/album";

foreach($_FILES['file']['name'] as $key=> $val){
	
$albumList['basimgnumber']=!empty($albumList['basimgnumber']) ? $albumList['basimgnumber'] : '0'; // get TRUE  	
//圖檔編號	
$basimgnumber[$key]=$albumList['basimgnumber']+($key+1);

//大縮圖
$bigbasimg[]="bigbasimg".$albumid."_".$basimgnumber[$key]."";
//小縮圖
$smallbasimg[]="smallbasimg".$albumid."_".$basimgnumber[$key]."";


//大縮圖DB
$bigbasimgDB[$key]['bigbasimg']="bigbasimg".$albumid."_".$basimgnumber[$key]."";
//小縮圖DB
$smallbasimgDB[$key]['smallbasimg']="smallbasimg".$albumid."_".$basimgnumber[$key]."";


//圖檔編號
$basimgnumbeDB=$basimgnumber[$key];

}


//圖檔大小
$configvar=configvar($modulesid="neilenglishresults");   
//大縮圖
save_pic($up_id=$bigbasimg,$width=$configvar['neilenglishresults14'],$height="0",$modules="".$urlfile."",$plural=true,$convert="jpg",$arr=false,$process=1,$crop=false,$upfile=$_FILES['file'],$type="");
//小縮圖
save_pic($up_id=$smallbasimg,$width=$configvar['neilenglishresults13'],$height="0",$modules="".$urlfile."",$plural=true,$convert="jpg",$arr=false,$process=1,$crop=false,$upfile=$_FILES['file'],$type="");


//圖檔組合-合併陣列
$basimgArr=array_merge($bigbasimgDB,$smallbasimgDB);



if($status=='add'){
//陣列轉字串
$basimg=phpconversion($conversion=$basimgArr,$type="serialize"); 

//存入ID數值
$setvar="set id='{$albumid}' ,basimg='{$basimg}' ,basimgnumber='{$basimgnumbeDB}'  where albumid='".$albumid."'";
update($dbname="neilenalbum",$set=$setvar);   	
}else{

//合併陣列

//字串轉陣列
if(!empty($_FILES['file']['name'][0])){
$basimgArrold=phpconversion($conversion=$albumList['basimg'],$type="unserialize");
$basimgArrnew=array_merge($basimgArrold,$basimgArr);
//陣列轉字串
$basimg=phpconversion($conversion=$basimgArrnew,$type="serialize"); 
$setvar="set basimg='{$basimg}' ,basimgnumber='{$basimgnumbeDB}'  where albumid='".$albumid."'";
update($dbname="neilenalbum",$set=$setvar);   
}

}  	   
      	  
break;  
       
       
       
  /*    case "108":  
//權限判斷


if(empty(useradmin($uid=$xoopsUser->getVar('uid'),$basid=$pageid))) exit;       	  

//開啟neilenreview資料表
$dbneme="neilenreview";
$where="  where `basid` = '".$pageid."' &&  `enid` = '".$dbid."' &&  `enfunction` = '".$enfunction."'   order by  eviewid  DESC";  //where數值
$neilenreviewArr=databasetablewhile($dbneme,$where);

foreach($neilenreviewArr as $key=> $val){
$where=" where `eviewid` = '".$neilenreviewArr[$key]['eviewid']."'";
$DBname="neilenreview";  
deletefunction($where,$DBname);
}


//開啟
$dbneme="neilenalbum";
$where="   where `albumid` = '".$dbid."' ";  //where數值
$albumList=moduledb($dbneme,$where);


//字串轉陣列
$bigbasimgArr=phpconversion($conversion=$albumList['basimg'],$type="unserialize");

foreach($bigbasimgArr as $key=> $val){

//刪除實體圖片-小圖
if(file_exists(XOOPS_ROOT_PATH.'/uploads/'.$xoopsmodule.'/enf'.$pageid.'/album/'.$bigbasimgArr[$key]['smallbasimg'].'.jpg')){
 unlink(XOOPS_ROOT_PATH.'/uploads/'.$xoopsmodule.'/enf'.$pageid.'/album/'.$bigbasimgArr[$key]['smallbasimg'].'.jpg');//將檔案刪除
} 
//刪除實體圖片-大圖
if(file_exists(XOOPS_ROOT_PATH.'/uploads/'.$xoopsmodule.'/enf'.$pageid.'/album/'.$bigbasimgArr[$key]['bigbasimg'].'.jpg')){
 unlink(XOOPS_ROOT_PATH.'/uploads/'.$xoopsmodule.'/enf'.$pageid.'/album/'.$bigbasimgArr[$key]['bigbasimg'].'.jpg');//將檔案刪除
} 

}





$where=" where `albumid` = '$dbid'";
$DBname="neilenalbum";  
deletefunction($where,$DBname);







echo false;  	     	  
           break;  	       
       */
       
      case "109":     
if(empty(useradmin($uid=$xoopsUser->getVar('uid'),$basid=$basid))) exit;     
       
       
$setvar="set representimg='{$var1}'  where albumid='".$albumid."'";
update($dbname="neilenalbum",$set=$setvar);   	
       
   
           break;    
            
  case "110":    
if(empty(useradmin($uid=$xoopsUser->getVar('uid'),$basid=$pageid))) exit;     
  
//開啟
$dbneme="neilenalbum";
$where="   where `albumid` = '".$dbid."' ";  //where數值
$albumList=moduledb($dbneme,$where);

//字串轉陣列
$bigbasimgArr=phpconversion($conversion=$albumList['basimg'],$type="unserialize");

//替換字串-小縮圖檔名
$var2=str_replace ("bigbasimg","smallbasimg",$var1);  //替換前,替換後,資料來源


//刪大圖
foreach($bigbasimgArr as $key=> $val){
  if($bigbasimgArr[$key]['bigbasimg']==$var1){ 
  	  
  unset($bigbasimgArr[$key]['bigbasimg']);

//刪除實體圖片-大圖
if(file_exists(XOOPS_ROOT_PATH.'/uploads/'.$xoopsmodule.'/enf'.$pageid.'/album/'.$var1.'.jpg')){
 unlink(XOOPS_ROOT_PATH.'/uploads/'.$xoopsmodule.'/enf'.$pageid.'/album/'.$var1.'.jpg');//將檔案刪除
}   
  
  }

//刪小圖
  if($bigbasimgArr[$key]['smallbasimg']==$var2){
    unset($bigbasimgArr[$key]['smallbasimg']);
//刪除實體圖片-小圖
if(file_exists(XOOPS_ROOT_PATH.'/uploads/'.$xoopsmodule.'/enf'.$pageid.'/album/'.$var2.'.jpg')){
 unlink(XOOPS_ROOT_PATH.'/uploads/'.$xoopsmodule.'/enf'.$pageid.'/album/'.$var2.'.jpg');//將檔案刪除
} 
    
  }
}

//陣列轉字串
$basimg=phpconversion($conversion=$bigbasimgArr,$type="serialize"); 

//判斷代表圖是否為刪除圖片
if($albumList['representimg']==$var1) $representimg=", representimg=''"; 

	

$setvar="set basimg='{$basimg}'  ".$representimg."  where albumid='".$dbid."'";
update($dbname="neilenalbum",$set=$setvar);   	


	  
  break;      	              
 
 
  case "111":       
  	  
  	  
  	  
//權限判斷
if(empty(useradmin($uid=$xoopsUser->getVar('uid'),$basid=$dbid))) exit;

//base64編碼
$moviedescription=base64_encode($moviedescription);
$titleDB=sqlinjectionfound($var=$title);
if($status=='add'){ //新增	




$valuesvar="(basid,sortid,title,newstext,review,enfunction) values('{$dbid}','{$of_sortid}','{$titleDB}','{$moviedescription}','1','3')";	  
$newsid=insert($dbname="neilennews",$values=$valuesvar);    	  

//存入ID數值
$setvar="set id='{$newsid}'   where newsid='".$newsid."'";
update($dbname="neilennews",$set=$setvar);


//開啟
$dbneme="neilbasicinformation";
$where="  where `basid` = '".$dbid."'  ";  //where數值
$basidList=moduledb($dbneme,$where);


$dbneme="neilennews";
$where="  where `newsid` = '".$newsid."'  order by  newsid  DESC";  //where數值
$neilennewsList=moduledb($dbneme,$where);


//通知管理員
$url="".XOOPS_URL."/modules/".$xoopsmodule."/newscenter.php?op=page&basid=".$basid."&newsid=".$newsid."&reviewadmin=1";
reviewadminmail($companyname=$basidList['companyname'],$getGroupid=1,$timedate=timedate($datevar="Y-m-d H:i:s"),$enfunction=3,$title=$neilennewsList['title'],$type=1,$review=$neilennewsList['review'],$url=$url);

 
}else{  //儲存


$setvar="set sortid='{$of_sortid}' , title='{$titleDB}' , newstext='{$moviedescription}'   where newsid='".$newsid."'";
update($dbname="neilennews",$set=$setvar);
}       	  
  	  
  	  
  	  
  	  
  	  
  break;    
  
  
      case "112":  
//權限判斷


if(empty(useradmin($uid=$xoopsUser->getVar('uid'),$basid=$pageid))) exit;       	  

//開啟neilenreview資料表
$dbneme="neilenreview";
$where="  where `basid` = '".$pageid."' &&  `enid` = '".$dbid."' &&  `enfunction` = '".$enfunction."'   order by  eviewid  DESC";  //where數值
$neilenreviewArr=databasetablewhile($dbneme,$where);

foreach($neilenreviewArr as $key=> $val){
$where=" where `eviewid` = '".$neilenreviewArr[$key]['eviewid']."'";
$DBname="neilenreview";  
deletefunction($where,$DBname);
}


$where=" where `newsid` = '$dbid'";
$DBname="neilennews";  
deletefunction($where,$DBname);



echo false;  	     	  
           break;  	  
  
  
case "113":    //表件新增編輯儲存
 
//權限判斷
if(empty(useradmin($uid=$xoopsUser->getVar('uid'),$basid=$dbid))) exit;

//上傳檔案驗證
$nanekey=array_keys($_FILES);
$prohibit=neillibrary_donotuploadfiles($filevar=$_FILES[$nanekey[0]],$operate=1);
if(!empty($prohibit['harmful'])) exit; 

//建構陣列-去資料表標籤
$sqlinjectionArr = array();
//建構陣列
$i=0;
$sqlinjectionArr[$i]=$title;
$i++;
$sqlinjectionArr[$i]=$moviedescription;
$Arrclean=removesqlforeach($var=$sqlinjectionArr,$coderemove=true);
foreach($Arrclean as $var=> $value) {
$$var=trim(isset($value)?$value:"");
}

foreach($Arrclean as $var=> $value){		
$$var=trim(isset($value)?$value:""); 
}

	 

if($status=='add'){ //新增	
	
if(!empty($isAdmin)){
$enableDB="1";
$review="4";
$reviewtype="go";
}else{
$enableDB="0";
$review="1";
$reviewtype="";
}


 
$valuesvar="(basid,sortid,title,filetext,namefile,setuptime,frequency,enable,review,reviewtime,id,enfunction,reviewtype,browsegroup,zipenable,numberfile) values('{$dbid}','{$of_sortid}','{$title}','{$moviedescription}','',current_timestamp(),'0','{$enableDB}','{$review}',current_timestamp(),'0','4','{$reviewtype}','".phpconversion($conversion=cuttingfunction($cutting=$var3,$sign=","),$type="serialize")."','".$enable."','0')";	  
$fileid=insert($dbname="neilenfile",$values=$valuesvar);  

if(!empty($isAdmin)){	
//建立審核資料
englishresults_gofunction($dbid,$var1=$fileid,$reviewtext=_MD_INDEXPHP88,$enfunction=4,$review=4);
}


//儲存成果檔案最新一筆ID
update($dbname="config",$set="set conf_value='".$fileid."'  where conf_name='neilenglishresults18'");  
//儲存最新一筆成果類型ID
update($dbname="config",$set="set conf_value='4'  where conf_name='neilenglishresults19'");
//開啟
$dbneme="neilbasicinformation";
$where="  where `basid` = '".$dbid."'  ";  //where數值
$basidList=moduledb($dbneme,$where);
if(empty($isAdmin)){	
//通知管理員
$url="".XOOPS_URL."/modules/".$xoopsmodule."/filecenter.php?op=page&basid=".$basid."&fileid=".$fileid."&reviewadmin=1";
reviewadminmail($companyname=$basidList['companyname'],$getGroupid=1,$timedate=timedate($datevar="Y-m-d H:i:s"),$enfunction=4,$title,$type=1,$review=1,$url);
}
}else{  //儲存
$setvar="set basid='{$dbid}' , sortid='{$of_sortid}' , title='{$title}' , filetext='{$moviedescription}' , browsegroup='".phpconversion($conversion=cuttingfunction($cutting=$var3,$sign=","),$type="serialize")."' , zipenable='".$enable."'   where fileid='".$fileid."'";
update($dbname="neilenfile",$set=$setvar);
}      



//上傳檔案  
if(!empty($_FILES['file']['name'][0])){ 
//檔案路徑	
$fileurl="".$xoopsmodule."/enf".$dbid."/file";
$fileList=moduledb($dbneme="neilenfile",$where="   where `fileid` = '".$fileid."' ");

foreach($_FILES['file']['name'] as $key=> $val){	
$fileArr['file_n'][$key]=strriposfunction($val,$type="1"); //檔名
$fileArr['file_e'][$key]=strriposfunction($val,$type="2"); //副檔名	
$fileArr['file_s'][$key]=$_FILES['file']['size'][$key]; //檔案大小
$fileArr['file_d'][$key]="".$fileList['fileid'].'_'.$fileList['numberfile']+($key+1)."_".strriposfunction($val,$type="1"); //下載檔名
$fileArr['file_id'][$key]=$fileList['numberfile']+($key+1); //檔案ID	
$numberDB=$fileList['numberfile']+($key+1);	
}

//上傳檔案  
save_pic($up_id=$fileArr['file_d'],$width="",$height="",$modules="".$fileurl."",$plural=false,$convert=$fileArr['file_e'],$arr=false,$process=1,$crop=false,$upfile=$_FILES['file'],$type="3");


//合併陣列
if(!empty($fileList['namefile']) && $fileList['namefile']!='N;'){
$filedateDB=array_merge_recursive(phpconversion($conversion=$fileList['namefile'],$type="unserialize"),$fileArr);
}else{
$filedateDB=$fileArr;
}



//存入ID數值及檔名
$setvar="set id='{$fileid}' ,namefile='".phpconversion($conversion=$filedateDB,$type="serialize")."' ,  numberfile='".$numberDB."' where fileid='".$fileid."'";
update($dbname="neilenfile",$set=$setvar);  
}




  	   
break;      
  	        
  	        
   case "114":    //下載次數
   	   
$dbneme="neilenfile";
$where="  where `fileid` = '".$var1."'  order by  fileid  DESC";  //where數值
$fileList=moduledb($dbneme,$where);	   
   	     	        
//下載次數+1
$fileList['frequency']=!empty($fileList['frequency']) ? $fileList['frequency'] : '0'; // get TRUE  	
$frequency=$fileList['frequency']+1;

  	  
$setvar="set frequency='{$frequency}'  where fileid='".$var1."'";
update($dbname="neilenfile",$set=$setvar);  
  
$text=sprintf(_MS_SHOPPINGCART80,$frequency);  
  	  
echo $text;  	  
  	  
  break;   	
  
   /* case "115":    //刪除表件 
      
//權限判斷


if(empty(useradmin($uid=$xoopsUser->getVar('uid'),$basid=$pageid))) exit;       	  

//開啟neilenreview資料表
$dbneme="neilenreview";
$where="  where `basid` = '".$pageid."' &&  `enid` = '".$dbid."' &&  `enfunction` = '".$enfunction."'   order by  eviewid  DESC";  //where數值
$neilenreviewArr=databasetablewhile($dbneme,$where);

foreach($neilenreviewArr as $key=> $val){
$where=" where `eviewid` = '".$neilenreviewArr[$key]['eviewid']."'";
$DBname="neilenreview";  
deletefunction($where,$DBname);
}


//開啟
$dbneme="neilenfile";
$where="   where `fileid` = '".$dbid."' ";  //where數值
$fileList=moduledb($dbneme,$where);

if(file_exists(XOOPS_ROOT_PATH.'/uploads/'.$xoopsmodule.'/enf'.$pageid.'/file/'.$fileList['namefile'])){
 unlink(XOOPS_ROOT_PATH.'/uploads/'.$xoopsmodule.'/enf'.$pageid.'/file/'.$fileList['namefile']);//將檔案刪除
} 

$where=" where `fileid` = '$dbid'";
$DBname="neilenfile";  
deletefunction($where,$DBname);







echo false;  
      
    break;   */     
    

    case "117":    //購物車備註說明區塊

 $readpermission=readpermission($user_uid=$suid);    	 
 if(!empty($xoopsUser) and !empty($readpermission)){
//解訂單資料表
$dbneme="neilshoporder";
$where=" where `orderid` = '".$orderid."' ";   //where數值-修改
$neilshoporder=moduledb($dbneme,$where);


if(!empty($isAdmin)){
$button="<button type='button' name='118,".$suid.",".$orderid."' id='remarksedit' class='btn btn-default'>"._MS_SHARED08."</button>";
}

$remarksbox="
 <div class='media-body'>".$button."
  <h4 class='media-heading'>".nl2br($neilshoporder['remarks'])."</h4><br />
    </div>

    
	";


echo $remarksbox;


 }

 

  break;   
  
  
    case "118":    //編輯備註說明 
  
  
 $readpermission=readpermission($user_uid=$suid);    	 
 if(!empty($xoopsUser) and !empty($readpermission)){
//解訂單資料表
$dbneme="neilshoporder";
$where=" where `orderid` = '".$orderid."' ";   //where數值-修改
$neilshoporder=moduledb($dbneme,$where);


if(!empty($isAdmin)){
$button="<button type='button'  name='119,".$suid.",".$orderid."' id='remarksstore'  class='btn btn-block btn-warning'>"._MS_SHOPPINGCART48."</button>";
}

//備註
$shoppingcart['remarks']=inputtextarea($class="",$name="remarksname",$id="remarksname",$rows="6",$cols="80",$value="".$neilshoporder['remarks'].""); 

//mane='ID,".suid.",".orderid.",返回ID'
$remarksbox="
 <div class='media-body'>
  <h4 class='media-heading'>".$shoppingcart['remarks']."</h4>
    ".$button."
    </div>

 
	";


echo $remarksbox; 
 
 
  }    	 
  	   
  
    break;   
    
      case "119":    //儲存備註說明   
      	  
       //確認操作UID相符
$readpermission=readpermission($user_uid=$suid);
if(!empty($xoopsUser) and !empty($readpermission)){



$setvar="set  remarks='".sqlinjectionfound($var=$var1)."'  where orderid='".$orderid."'";
update($dbname="neilshoporder",$set=$setvar); 

}         
   	  
    
    
        break;   
        
        
      case "120":    //訂單作廢區塊         

if(empty($isAdmin)) exit;        

//解訂單資料表
$dbneme="neilshoporder";
$where=" where `orderid` = '".$orderid."' ";   //where數值-修改
$neilshoporder=moduledb($dbneme,$where);



if($neilshoporder['orderstatus'] > 1)

if(empty($neilshoporder['enable'])){
$obsoletebox="
<button type='button' id='obsoletebtn'  name='121,".$suid.",".$orderid."' class='btn btn-danger btn-lg btn-block'><span class='glyphicon glyphicon-remove' aria-hidden='true'></span>"._MS_SHOPPINGCART285."</button><br />
	";
}else{
$obsoletebox="
<div class='alert alert-danger' role='alert'><span class='glyphicon glyphicon-remove' aria-hidden='true'></span>"._MS_SHOPPINGCART286."</div><br />
	";
}


echo $obsoletebox;
  	  
         break;    	  
         
         
      case "121":    //訂單作廢寫入資料庫
      	  
      	  
//將商品數量加回銷售數量扣除
//開啟訂單資料表
$dbneme="neilshoporder";	   	   
$where=" where `orderid` = '".$orderid."'  order by  orderid   DESC";
$neilshoporder=moduledb($dbneme,$where);
     	  
//字串轉陣列
$neilshopcartArr=phpconversion($conversion=$neilshoporder['neilshopcartid'],$type="unserialize"); 
foreach($neilshopcartArr as $i=> $val){

$dbneme="neilshopcart";
$where=" where `shopcartid` = '".$val."' ";   //where數值-修改
$neilshopcart=moduledb($dbneme,$where);

//更改購物車狀態
$setvar="set obsolete='1'  where shopcartid='".$val."'";
update($dbname="neilshopcart",$set=$setvar);



//開啟商品資料表
$dbneme="neilshopproductcontent";
$where=" where `productid` = '".$neilshopcart['productid']."' ";   //where數值-修改
$neilshopproductcontent=moduledb($dbneme,$where);
//商品數量
$amount=$neilshopproductcontent['amount']+$neilshopcart['cartnumber'];
//訂購次數
$ordernumber=$neilshopproductcontent['ordernumber']-$neilshopcart['cartnumber'];
//存入商品資料表 數量
$setvar="set amount='".$amount."', ordernumber='".$ordernumber."'  where productid='".$neilshopcart['productid']."'";
update($dbname="neilshopproductcontent",$set=$setvar);


}      	  
      	  
    	  
if(empty($isAdmin)) exit;            	  
$setvar="set  enable='1'  where orderid='".$orderid."'";
update($dbname="neilshoporder",$set=$setvar); 

echo true;      	  
      	  
      break; 	            
         
         
      case "122":    //刪除自訂按鈕
           
           
$where=" where `nsn` = '$dbid'";
$DBname="neorightmenu";  
!empty($isAdmin) ? deletefunction($where,$DBname) : '';           
           
           
           
        break;      
        

      case "123":    //刪除賀卡
      	  
      	  
//權限判斷


if(empty($isAdmin)) exit;       	  

//開啟neilenreview資料表
$dbneme="neilecardfunction";
$where="  where  `ecardid` = '".$dbid."'    ";  //where數值
$neilecardfunctionList=moduledb($dbneme,$where);


$img=cuttingfunction($cutting=$neilecardfunctionList['img'],$sign=",");


//刪除大縮圖
if(file_exists(XOOPS_ROOT_PATH.'/uploads/'.$xoopsmodule.'/image/.tmb/'.$img[0].'.jpg')){
 unlink(XOOPS_ROOT_PATH.'/uploads/'.$xoopsmodule.'/image/.tmb/'.$img[0].'.jpg');//將檔案刪除
} 

//刪除小縮圖
if(file_exists(XOOPS_ROOT_PATH.'/uploads/'.$xoopsmodule.'/image/.thumbs/'.$img[1].'.jpg')){
 unlink(XOOPS_ROOT_PATH.'/uploads/'.$xoopsmodule.'/image/.thumbs/'.$img[1].'.jpg');//將檔案刪除
} 


$where=" where `ecardid` = '$dbid'";
$DBname="neilecardfunction";  
deletefunction($where,$DBname);







echo false;  
      
         
         
         
             break;       
             
             
             
     case "124":    //寄送賀卡         
             

//機器人檢查
if(empty(defenserobot($var=$robot,$type=2)) and empty(alignmenturl())){
$harmful=true;
$type=2;
}		

//迴圈去除SQL標籤
$Arrclean=removesqlforeach($var=$Arr);   

//無害化處理
if(judgeHtml($Arrclean[0])==true or judgeHtml($Arrclean[1])==true or judgeEmail($Arrclean[2])==true or  judgeEmail($Arrclean[3])==true or judgeHtml($Arrclean[4])==true   or  judgeHtml($Arrclean[5])==true or judgeHtml($Arrclean[6])==true or !is_numeric($Arrclean[7]) or isDate($Arrclean[8])==true  ){
$harmful=true;
$type=1;
} 


//字元判斷
$configvar=configvar($modulesid="neilecard"); 

if(mb_strlen($Arrclean[4], "utf-8") > $configvar['neilecard10']){
$harmful=true;
$type=3;
}

  
  
if($harmful==true){
switch($type){
  case "1":  //無害化
$text=_MS_SHARED34;
  break;
  
  case "2": //機器人
$text=_MS_SHARED75;
  break;  
  
  case "3": //字元判斷
$text=_MS_SHARED76;
  break;     
  default:

}


}else{

if(!empty($Arr[7])){
$text=_MD_ECARDCENTERPHP32;
}else{
$status=sendagreetingcardmail($ecardArr=$Arr,$timedate=timedate($datevar="Y-m-d H:i:s"),$ecardid=$dbid);  
$text=!empty($status) ? _MD_ECARDCENTERPHP33 : _MD_ECARDCENTERPHP34; // get TRUE
} 

//寫入資料表
//$movie=youtubeurl($youtubeurl=$Arrclean[5]);	
$valuesvar="(ecardid,ip,sendername,recipientname,sendernemail,recipientmail,description,youtube,ecardtheway,reservationtime,type,style) values('".$dbid."','".get_real_ip()."','".$Arrclean[0]."','".$Arrclean[1]."','".$Arrclean[2]."','".$Arrclean[3]."','".$Arrclean[4]."','".$Arrclean[5]."','".$Arrclean[7]."','".$Arrclean[8]."','".$status."','".$Arrclean[6]."')";	  
$insertreturn=insert($dbname="neilecardsender",$values=$valuesvar);

//寄送次數
//開啟賀卡
$dbneme="neilecardfunction";
$where=" where   ecardid='".$dbid."' ";
$neilecardfunctionList=moduledb($dbneme,$where);

$neilecardfunctionList['sendcounter']=!empty($neilecardfunctionList['sendcounter']) ? $neilecardfunctionList['sendcounter'] : '0'; // get TRUE  	
$sendcounter=$neilecardfunctionList['sendcounter']+1;

$setvar="set sendcounter='".$sendcounter."' where ecardid='".$ecardid."'";
update($dbname="neilecardfunction",$set=$setvar);

}


echo $text;


     break;      
     
     
     
  case "125"://防機器人     
 
   
$robot = array(); //建構陣列 
//不是機器人

$robot['0']=checkbox($dataid=true,$name="mycheck",$value="1",$optionname=""._MS_SHARED73."",$oid="",$i,$class="notarobot".$var1."");  

//驗證資料
$robot['1']=defenserobot($var=timedate($datevar="Y-m-d H:i:s"),$type=1); 


$robot['4']=radioinline($class="",$name="enable",$text=array(_MS_SHARED86,_MS_SHARED87),$checked=""); 

$uid=!empty($xoopsUser) ? $xoopsUser->getVar('uid') : '0'; // get TRUE
//開啟時間
$dbneme="robotip";
    if(!empty($uid)){
    $where=" where   `uid` = '".$uid."' ";   //where數值-修改	
    }else{
    $where=" where  `ip` = '".get_real_ip()."'  &&   `cookieid` = '".$_COOKIE['neil']['cookieid']."'  ";   //where數值-修改	
    }	

$robottimeip=moduledb($dbneme,$where);	
$robottimedate=$robottimeip['robottime'];
//產生圖片
$robottimedateingbox='<img id="fonttoimageGDbox" src="data:image/png;base64,'.fonttoimageGDfunction($width="100",$height="20",$x="7",$y="4",$font_size="5",$word=$robottimedate).'" />';


switch($var1){
  case "1":  //模組頁面
  case "5": 
 
$blockeach =!empty($var2) ? $var2 : ($var1=='1' ? 'blockeach' : 'blockeach3'); // get TRUE
	
	
//$blockeach=$var1=='1' ? 'blockeach' : 'blockeach3'; // get TRUE
	
$text="
<div class='form-group'>
   <label class='col-sm-2 col-xs-2 control-label emptyfield'></label>
    <div class='col-sm-10 col-xs-8'>
 <div class='checkboxmycheck".$var1." ".$blockeach."'></div>
<div id='checkboxmycheckbox'>".$robot['0']."<div>
    </div>
  </div>
  
 <div class='robottimedateboxdiv robottimedatebox".$var1."' style='display: none;'> 
<label  class=' control-label'>".$robottimedateingbox._MS_SHARED88."</label>
".$robot['4']."<br />
  </div> 
";

  break;
		
	  case "2":	//區塊頁面	
$text="
<div id='checkboxmycheckbox'>
 <div class='checkboxmycheck".$var1." ".$var2."'></div>
".$robot['0']."

 <div class='robottimedateboxdiv robottimedatebox".$var1."' style='display: none;'>   

<label  >".$robottimedateingbox._MS_SHARED88."</label>
".$robot['4']."    
  </div> 
       </div>
";		
		
		
	  break;	
	  
	  	  case "3":	 //註冊表單

	  	$text="
<div id='checkboxmycheckbox'>".$robot['0']."</div><br /><br />
	
<span class='robottimedateboxdiv   robottimedatebox".$var1."' style='display: none;'>
<label control-label>".$robottimedateingbox._MS_SHARED88."</label>
 		 ".$robot['4']." 

  	   <br /><br /> 
</span>
";   
	  
	  break;	
	  
	  
	  
	  case "4":	//索取簡章
$text="
<div id='checkboxmycheckbox'>
 <div class='checkboxmycheck".$var1." ".$var2."'></div>
".$robot['0']."

 <div class='robottimedateboxdiv robottimedatebox".$var1."' style='display: none;'>   

<label  >".$robottimedateingbox._MS_SHARED88."</label>
".$robot['4']."    
  </div> 
       </div>
";		
		
		
	  break;	
	  
	  
	  	
  
  default:
  
}


$text.="
<input class='verification".$var1."' type='hidden' disabled='disabled' name='verification' value='".$robot['1']."'>	
		
<style type='text/css'> 
 /* <![CDATA[ */
    
#fonttoimageGDbox{
transform:scale(1.2,1.2);
margin:1px 5px 0px 0px;
}    
    

     /* ]]> */ 
 </style>	
<script>
	
	$('.notarobot".$var1."').click(function(){
	$('#regform .form-group #submitButton ,#userinfo #submitButton').attr('disabled', false); 
	if($('[name=op]').val()=='finish'){
    $('#XOOPS_TOKEN_REQUEST').attr('disabled', false); 
    }	
	$('.verification".$var1."').attr('disabled', false);	
    $('.notarobot".$var1."').hide();	
    $('.robottimedatebox".$var1."').show();	     
    $('.robottimedatebox".$var1." input[name=enable][value=".rand(0,1)."]').prop('checked',true);		
	});		
	
</script>	
		
";

	 
echo $text;


       break;   
       
       
   case "126"://更新通知

//管理員判斷   	   
if(empty($isAdmin)) exit;      

//開啟neothemesconfig資料表
$configList=moduledb($dbneme="neothemesconfig",$where=" where   nsn='1' ");

if(_MA_NEODWADMIN_THEMESID < $dbid && empty($configList['enable'])){	
	
$updatenotice=sprintf(_MA_NEODWADMIN_THEMESDESCRIPTION,_MA_NEODWADMIN_THEMESID,$dbid,$var1,$var2); 	
$text="
<aside id='descriptiontpl'>
<div id='kclosebtn'></div><h3>".$updatenotice."</h3>
</aside>
";
}
  
  echo $text;
   	            
    break; 
    
   case "127"://關閉通知
//管理員判斷   	   
if(empty($isAdmin)) exit;     
update($dbname="neothemesconfig",$set="set enable='".$dbid."' where nsn='1'");
update($dbname="config",$set="set conf_value='".timedate($datevar="Y-m-d H:i:s")."'  where conf_name='neothemesadmin1'");
     
     
       break;    
       
       
       
   case "128"://聯絡我們  
//管理員判斷   	   
if(empty($isAdmin)) exit;      

//開啟聯絡我們資料表
$dbneme="neocontactusform";
$where=" where `cfid` = '".$dbid."'";   //where數值-修改
$contactuscontentlist=moduledb($dbneme,$where);



if(empty($enable)){  //管理員回覆

//回覆判斷
if(empty($contactuscontentlist['replytext'])){
$box=inputtextarea($class="",$name="replytext",$id="replytext",$rows="6",$cols="80",$value="")." <span id='helpBlock' class='help-block white'>"._MD_CONTACTUSTABLEPHP36."</span>"."  
<input type='hidden' name='email_user' value='".$contactuscontentlist['email_user']."'>
<input type='hidden' name='texe_user' value='".$contactuscontentlist['texe_user']."'>		
<input type='hidden' name='name_user' value='".$contactuscontentlist['name_user']."'>	
<input type='hidden' name='cfid' value='".$contactuscontentlist['cfid']."'>	
<input type='hidden' name='enable' value='".$enable."'>	
<button  type='submit' name='op' value='replyupdate' class='btn btn-primary btn-lg btn-block'>"._MD_CONTACTUSTABLEPHP37."</button> </div>";  

$boxtd="<div class='row'><div class='col-md-12'>".$box."</div></div>";
}else{

$replytext=neillibrary_textprocessing($val=$contactuscontentlist['replytext']);  	
$box=sprintf(_MD_CONTACTUSTABLEPHP35,$replytext);
$boxtd=" <div class='row'>
<div class='col-md-12'>".sprintf(_MD_CONTACTUSTABLEPHP38,$contactuscontentlist['replytime'])."</div>
<div class='col-md-12'><div class='alert alert-info' role='alert'>".$box."</div></div>
</div>";
}
		
  
}else{  //指定會員回覆
	
//開啟會員資料表
//下拉選單(管理者)
foreach($usersArr=databasetablewhile($dbneme="users",$where="  order by  uid  ASC")  as $i=> $val){	
$uname= empty($usersArr[$i]['name']) ? $usersArr[$i]['uname'] : "".$usersArr[$i]['uname']."->".$usersArr[$i]['name'].""; // get TRUE		
$usersoptionone.=optionselect($dataid=$usersArr[$i]['uid'],$optionname="".$uname."",$oid="",$value=$usersArr[$i]['uid']);
}	


$box="<span id='helpBlock' class='help-block red'>"._MD_CONTACTUSTABLEPHP42."</span>".inputtextarea($class="",$name="directions",$id="directions",$rows="6",$cols="80",$value="")." <span id='helpBlock' class='help-block white'>"._MD_CONTACTUSTABLEPHP43."</span>"."  
<input type='hidden' name='cfid' value='".$contactuscontentlist['cfid']."'>	
<input type='hidden' name='enable' value='".$enable."'>		
<button  type='submit' name='op' value='replyupdate' class='btn btn-primary btn-lg btn-block'>"._MD_CONTACTUSTABLEPHP37."</button> </div>";  

$boxtd="<div class='row'>
<div class='col-md-4 sizebox1'> 
<span id='helpBlock' class='help-block red'>"._MD_CONTACTUSTABLEPHP44."</span>	
	 <select  class='form-control selecteach' name='uid' >
    	".$usersoptionone."
  </select>	</div>
<div class='col-md-8'>".$box."</div></div>";
 
}

    
echo $boxtd;
      
         break;     
         
    case "129"://聯絡我們  
if(empty($isAdmin) && empty(readpermission($user_uid="",$type="1",$dbvar="neocontactusform",$where=" where `cfid` = '".$dbid."' ")))   exit;      	
   
   
//開啟聯絡我們資料表
$dbneme="neocontactusform";
$where=" where `cfid` = '".$dbid."'";   //where數值-修改
$contactuscontentlist=moduledb($dbneme,$where); 
   
//回覆判斷
if(empty($contactuscontentlist['replytext'])){
$box=inputtextarea($class="",$name="replytext",$id="replytext",$rows="6",$cols="80",$value="")." <span id='helpBlock' class='help-block'>"._MD_CONTACTUSTABLEPHP36."</span>"."  
<input type='hidden' name='email_user' value='".$contactuscontentlist['email_user']."'>
<input type='hidden' name='texe_user' value='".$contactuscontentlist['texe_user']."'>		
<input type='hidden' name='name_user' value='".$contactuscontentlist['name_user']."'>	
<input type='hidden' name='cfid' value='".$contactuscontentlist['cfid']."'>	
<input type='hidden' name='respond' value='".true."'>		
<button  type='submit' name='op' value='replyupdate' class='btn btn-primary btn-lg btn-block'>"._MD_CONTACTUSTABLEPHP37."</button> </div>";  

$boxtd="<div class='row'>
<div class='col-md-12'><div class='alert alert-warning' role='alert'>".sprintf(_MD_CONTACTUSTABLEPHP45,neillibrary_textprocessing($val=$contactuscontentlist['directions']),$contactuscontentlist['transfer'],XoopsUser::getUnameFromId($contactuscontentlist['uid'],0))."</div></div>
<div class='col-md-12'>".$box."</div></div>";
}else{

$replytext=neillibrary_textprocessing($val=$contactuscontentlist['replytext']);	



	
$box=sprintf(_MD_CONTACTUSTABLEPHP46,$replytext,XoopsUser::getUnameFromId($contactuscontentlist['uid'],0));
$boxtd=" <div class='row'>
<div class='col-md-12'>".sprintf(_MD_CONTACTUSTABLEPHP38,$contactuscontentlist['replytime'])."</div>
<div class='col-md-12'><div class='alert alert-info' role='alert'>".$box."</div></div>
</div>";
}
         
     echo $boxtd;      
     break;    
     
     
     
    case "130"://商品項目選單  
//讀取neilshopsort資料表 
$dbneme= empty($var1) ? "productcontent" : $var1; // get TRUE

/*
if($exchange=='true'){
$dbid=$dbid;
}else{
$dbid=$selectidedit;
}*/

//echo $exchange;

$dbid=empty($of_sortid) ? $dbid : $of_sortid; // get TRUE


$where=" where `sortid` = '".$dbid."' &&  `productstatus` != 'notshelves'  order by productsort ASC";   //where數值-新增
if(!empty($dbid)){
$sort=databasetablewhile($dbneme,$where); 
}
$optionone.=optionbox2($sortvar=$sort,$oid=$var3);

if(!empty($optionone)){
echo $select.="<select  class='form-control' name='productid' >
	 <option   data-id='0' value=''  >"._MD_SHOPWCASE78."</option>
     	".$optionone."   
  </select>	 <p>

";
} 
     
     
        break;      
        
        
        
        
      case "131":    //刪除文創
      	  
      	  
//權限判斷


if(empty($isAdmin)) exit;       	  

//開啟neilenreview資料表
$dbneme="neilwenchuangfunction";
$where="  where  `wenchuangid` = '".$dbid."'    ";  //where數值
$neilwenchuangfunctionList=moduledb($dbneme,$where);


$img=$neilwenchuangfunctionList['img'];


//刪除大縮圖
if(file_exists(XOOPS_ROOT_PATH.'/uploads/'.$xoopsmodule.'/image/.thumbs/'.$img.'.jpg')){
 unlink(XOOPS_ROOT_PATH.'/uploads/'.$xoopsmodule.'/image/.thumbs/'.$img.'.jpg');//將檔案刪除
}




$where=" where `wenchuangid` = '$dbid'";
$DBname="neilwenchuangfunction";  
deletefunction($where,$DBname);







echo false;  
      
         
         
         
             break;  
        
        
        
        
/*case "132":    //刪除榮譽榜檔案   
$configvar=configvar($modulesid="neilhonorlist");
if(empty(neillibrary_modulesgrouppermission($conf_value=$configvar['neilhonorlist1']))) exit;
//開啟neilhonorcontent
$listval=moduledb($dbneme="neilhonorcontent",$where="   where `hc_id` = '".$dbid."' ");

// 字串轉陣列
$Arr = phpconversion($conversion = $listval['honorfile'], $type = "unserialize");
foreach ($Arr['newname'] as $key => $val) {
    if ($val == $var1) {
        unset($Arr['newname'][$key]);
        unset($Arr['oldname'][$key]);
        fileadminfunction($fileurl = XOOPS_ROOT_PATH . '/uploads/' . $xoopsmodule . '/file/' . $val . '', $type = "2", $fileex = "", $from = "", $fileurlnew = "", $exclude = "");
    }
}
//使用 array_values() 重新索引陣列
$Arr['newname'] = array_values($Arr['newname']);
$Arr['oldname'] = array_values($Arr['oldname']);

// 陣列轉字串並更新資料庫
$setvar = "set honorfile='".phpconversion($conversion = $Arr, $type = "serialize")."' where hc_id='" . $dbid . "'";
update($dbname = "neilhonorcontent", $set = $setvar);


break;   
 */                
      case "133":    //刪除自訂按鈕
           
           
$where=" where `nsn` = '$dbid'";
$DBname="neilrandomidiom";  
!empty($isAdmin) ? deletefunction($where,$DBname) : '';           
           
echo false;  
           
        break;               
    


 /*     case "134":    //刪除影音

  	  
      	  

//開啟neilenreview資料表
$dbneme="neilonlinevideocenter";
$where="  where  `centerid` = '".$dbid."'    ";  //where數值
$deleteList=moduledb($dbneme,$where);

//權限判斷
if($xoopsUser->getVar('uid')==$deleteList['uid']  && !empty(grouppermission($dbneme="neilonlinevideosort",$where=" where `sortid` = '".$deleteList['sortid']."' order by  sortid  ASC",$var="admingroup",$type=true)) || !empty($isAdmin) ){
$where=" where `centerid` = '$dbid'";
$DBname="neilonlinevideocenter";  
deletefunction($where,$DBname);
}
echo false;     
             break;    

*/

case "135":    //撥放器縮圖
	
//權限判斷
if( !empty(grouppermission($dbneme="neilonlinevideosort",$where="order by  sortid  ASC",$var="admingroup",$type=true)) ){
$typevar=$var2=="y" ? 'b' : 't'; // get TRUE	
$fbhtml=onlinevideobox($width="",$height="",$url=$var1,$type=$typevar,$img="");
}

echo $fbhtml;


break;    


//相簿加入代表圖
      case "136":     
if(!empty(grouppermission($dbneme="neilalbumsort",$where=" where `sortid` = '".$sortid."' order by  sortid  ASC",$var="admingroup",$type=true)) ){

$setvar="set representimg='{$var1}'  where centerid='".$var2."'";
update($dbname="neilalbumcenter",$set=$setvar);   	
       
}   
           break;    


//刪除圖片
case "137":    
if(!empty(grouppermission($dbneme="neilalbumsort",$where=" where `sortid` = '".$pageid."' order by  sortid  ASC",$var="admingroup",$type=true)) ) {
	//開啟
	$dbneme="neilalbumcenter";
	$where="   where `centerid` = '".$dbid."' ";
	//where數值
	$albumList=moduledb($dbneme,$where);
	//字串轉陣列
	$bigbasimgArr=phpconversion($conversion=$albumList['basimg'],$type="unserialize");
	//刪除實體圖片-小圖
	if(file_exists(XOOPS_ROOT_PATH.'/uploads/'.$xoopsmodule.'/'.$pageid.'file/image/.thumbs/small_'.$var1.'.jpg')) {
		unlink(XOOPS_ROOT_PATH.'/uploads/'.$xoopsmodule.'/'.$pageid.'file/image/.thumbs/small_'.$var1.'.jpg');
		//將檔案刪除
	}
	//刪除實體圖片-大圖
	if(file_exists(XOOPS_ROOT_PATH.'/uploads/'.$xoopsmodule.'/'.$pageid.'file/image/.thumbs/big_'.$var1.'.jpg')) {
		unlink(XOOPS_ROOT_PATH.'/uploads/'.$xoopsmodule.'/'.$pageid.'file/image/.thumbs/big_'.$var1.'.jpg');
		//將檔案刪除
	}
	//刪除陣列	
    $bigbasimgDB = array_filter($bigbasimgArr, function($imgname) use ($var1) {
    return $imgname['imgname'] != $var1;
    });
  //  $bigbasimgDB = array_values($bigbasimgDB);	//重新產生索引	
	//陣列轉字串
	$basimg=phpconversion($conversion=$bigbasimgDB,$type="serialize");
	//判斷代表圖是否為刪除圖片
	$representimg=$albumList['representimg']=='small_'.$var1 ? '' : $albumList['representimg'];
	// get TRUE
	$setvar="set basimg='{$basimg}' , representimg='{$representimg}'  where centerid='".$dbid."'";
	update($dbname="neilalbumcenter",$set=$setvar);
}
break;   


/*
case "138":    //刪除相簿  	  
//開啟neilalbumcenter資料表
$dbneme="neilalbumcenter";
$where="  where  `centerid` = '".$dbid."'    ";
//where數值
$deleteList=moduledb($dbneme,$where);
//權限判斷
if($xoopsUser->getVar('uid')==$deleteList['uid']  && !empty(grouppermission($dbneme="neilalbumsort",$where=" where `sortid` = '".$deleteList['sortid']."' order by  sortid  ASC",$var="admingroup",$type=true)) || !empty($isAdmin) ) {
	//刪除圖檔
	//字串轉陣列
	$bigbasimgArr=phpconversion($conversion=$deleteList['basimg'],$type="unserialize");
	foreach($bigbasimgArr as $key=> $val) {
		//刪除實體圖片-小圖
		if(file_exists(XOOPS_ROOT_PATH.'/uploads/'.$xoopsmodule.'/'.$deleteList['sortid'].'file/image/.thumbs/small_'.$val['imgname'].'.jpg')) {
			unlink(XOOPS_ROOT_PATH.'/uploads/'.$xoopsmodule.'/'.$deleteList['sortid'].'file/image/.thumbs/small_'.$val['imgname'].'.jpg');
			//將檔案刪除
		}
		//刪除實體圖片-大圖
		if(file_exists(XOOPS_ROOT_PATH.'/uploads/'.$xoopsmodule.'/'.$deleteList['sortid'].'file/image/.thumbs/big_'.$val['imgname'].'.jpg')) {
			unlink(XOOPS_ROOT_PATH.'/uploads/'.$xoopsmodule.'/'.$deleteList['sortid'].'file/image/.thumbs/big_'.$val['imgname'].'.jpg');
			//將檔案刪除
		}
	}
//刪除自訂按鈕
    neillibrary_memudeletfunction($pageid=$dbid,$menutype=1,$modulesid='neilalbum');	
//刪除內容
	deletefunction($where=" where `centerid` = '$dbid'",$DBname="neilalbumcenter");
}
echo false;
break; 
*/
 
       case "139":    //寫入已回覆  
 
 //權限判斷
if(empty( readpermission($user_uid="",$type="2",$dbvar="neilrform1",$where="",$modulesid="neilrform"))) exit;
$setvar="set uid='".$xoopsUser->getVar('uid')."', setuptime='".timedate($datevar="Y-m-d H:i:s")."' , type='1'    where rformrid='".$dbid."'";
update($dbname="neirformcenter",$set=$setvar);              
      break; 
                
  
case "140":    
//管理員權限
if(empty($isAdmin)) exit;   
foreach($sortid as $key=> $val){   
$setvar="set ".$var1."='{$sortvar[$key]}'  where sortid='".$val."'";
update($dbname=$dbid,$set=$setvar);	 
}	            	    
break;  
  
  case "141":      
//管理員權限
if(empty($isAdmin)) exit;   

$Arrdate = array(); //建構陣列 

//相同where查詢欄位
$whereDB=" where `basid` = '$dbid'";
//刪英資單位
$i=0;
$Arrdate[$i]['dbneme']="neilbasicinformation";
$Arrdate[$i]['where']=$whereDB;
$Arrdate[$i]['id']="basid";
//刪英資分類
$i++;
$Arrdate[$i]['dbneme']="neilbritishcapitalsort";
$Arrdate[$i]['where']=$whereDB;
$Arrdate[$i]['id']="sortid";
//刪除英資影片
$i++;
$Arrdate[$i]['dbneme']="neilenmovie";
$Arrdate[$i]['where']=$whereDB;
$Arrdate[$i]['id']="movieid";
//刪除英資相簿
$i++;
$Arrdate[$i]['dbneme']="neilenalbum";
$Arrdate[$i]['where']=$whereDB;
$Arrdate[$i]['id']="albumid";
//刪除英資成果表件
$i++;
$Arrdate[$i]['dbneme']="neilenfile";
$Arrdate[$i]['where']=$whereDB;
$Arrdate[$i]['id']="fileid";
//刪除英資成果審核
$i++;
$Arrdate[$i]['dbneme']="neilenreview";
$Arrdate[$i]['where']=$whereDB;
$Arrdate[$i]['id']="eviewid";

//批次刪除function
deleteArr($Arrdate=$Arrdate);	
//刪除資料夾
fileadminfunction($fileurl="",$type="1",$fileex="",$from=XOOPS_ROOT_PATH.'/uploads/neilenglishresults/enf'.$dbid);   
   break;   
   
   
  case "142":  //影片類型說明
  	  
  	  
switch($type){
  case "y":
$box="<span id='helpBlock' class='help-block'>"._MS_SHARED107."</span>
";
  break;
  
  case "f":
$box="<span id='helpBlock' class='help-block'>"._MS_SHARED108."</span>
";
  break;  
  
  default:
$box="<span id='helpBlock' class='help-block'>"._MS_SHARED110."</span>
";
  
} 

echo $box;
   
   
   
   break;   
          
          
//商品加入代表圖
      case "143":     
//管理員權限
/*if(empty($isAdmin)) exit;   
$setvar="set blockimg='{$var1}'  where productid='".$var2."'";
update($dbname="productcontent",$set=$setvar);   
*/
           break;     
          
          
 //刪除加入代表圖
      case "144":     
//管理員權限
/*if(empty($isAdmin)) exit; 
$setvar="set ".$var3."=''  where ".$var2."='".$dbid."'";
update($dbname=$var1,$set=$setvar);   */
           break;           
                
  
  
  
 //防機器人產生時間
      case "145":   
      	  
//新增加時間驗證
robotformtimecreate();       	    

           break;     
  
  
   case "146":   
//管理員權限
if(empty($isAdmin)) exit;  
//圖檔名
$imgid="aboutblockimg";	
 //上傳檔案  
if(!empty($_FILES['file']['name'])){ 
save_pic($up_id=$imgid,$width=$var1,$height="0",$modules="".$var2."",$plural=false,$convert="png",$arr=false,$process=1,$crop=false,$upfile=$_FILES['file'],$type="1"); 
}
 
 //存入ID數值及檔名
$setvar="set aboutustext='".base64_encode($dbid)."' ";
update($dbname="neothemesconfig",$set=$setvar);  	  

echo  $imgid;
 
     break;  
  
  
    case "147":   
//管理員權限
if(empty($isAdmin)) exit;  
 
//去資料表標籤-去除空白跟HTML標籤
$_POST=strip_tagsremovesqlArr($allowvar=array("dbid"),$postvar=$_POST,$sqltags="");  

 
if($type=='edit'){	
$setvar="set tagtext='{$dbid}'  where tagid='".$var1."'";
update($dbname="neilmfdcmstag",$set=$setvar);  	
}else{
$valuesvar="(tagtext) values('{$_POST['dbid']}')";	
$productid=insert($dbname="neilmfdcmstag",$values=$valuesvar);
} 
 

 
 
      break;  

  
  
  
  case "148":  //刪除標籤 
//管理員權限
if(!empty($isAdmin)) deletefunction($where=" where `tagid` = '$dbid'",$DBname="neilmfdcmstag");
  
break;    
  
 
 
  case "149":  //內容管理預設首頁
//管理員權限
if(empty($isAdmin)) exit;  
foreach($typesidArr=databasetablewhile($dbneme="neilmfdcmstypes",$wheree="  order by  typesid  ASC")  as $key=> $val){
$tindex[$key]=($typesidArr[$key]['typesid']==$dbid) ? '1' : '0'; // get TRUE
$setvar="set tindex='".$tindex[$key]."'  where typesid='".$typesidArr[$key]['typesid']."'";
update($dbname="neilmfdcmstypes",$set=$setvar);  
} 
break;    
   
   
   
   case "150":  //刪除代表圖-內容管理
   	   
$dbneme="neilmfdcmscenter";
$where=" where `centerid` = '".$var2."' &&  `typesid` = '".$var1."' ";
$neilmfdcmscenterList=moduledb($dbneme,$where);   
//發佈者判斷
//權限判斷
if(($xoopsUser->getVar('uid')!=$neilmfdcmscenterList['uid']  || empty(grouppermission($dbneme="neilmfdcmssort",$where=" where `typesid` = '".$var1."' && `sortid` = '".$neilmfdcmscenterList['sortid']."' order by  sortid  ASC",$var="admingroup",$type=true))) && empty(admingroupfunction($dbneme="neilmfdcmstypes",$where=" where `typesid` = '".$var1."' && `enable` = '1'  ",$admintype="admingroup")) )exit;






//刪除圖檔
if(file_exists(XOOPS_ROOT_PATH.'/uploads/'.$xoopsmodule.'/types'.$var1.'/'.$neilmfdcmscenterList['sortid'].'file/image/.thumbs/'.$neilmfdcmscenterList['representimg'].'.png')){
 unlink(XOOPS_ROOT_PATH.'/uploads/'.$xoopsmodule.'/types'.$var1.'/'.$neilmfdcmscenterList['sortid'].'file/image/.thumbs/'.$neilmfdcmscenterList['representimg'].'.png');//將檔案刪除
} 


$setvar="set representimg=''  where centerid='".$neilmfdcmscenterList['centerid']."'";
update($dbname="neilmfdcmscenter",$set=$setvar);  
  
   
   
 break;   
 
 
 //刪除檔案
 /* case "151":    
$dbneme="neilmfdcmscenter";
$where=" where `centerid` = '".$dbid."'  ";
$neilmfdcmscenterList=moduledb($dbneme,$where);   
//發佈者判斷
//權限判斷
if(($xoopsUser->getVar('uid')!=$neilmfdcmscenterList['uid']  || empty(grouppermission($dbneme="neilmfdcmssort",$where=" where `typesid` = '".$neilmfdcmscenterList['typesid']."' && `sortid` = '".$neilmfdcmscenterList['sortid']."' order by  sortid  ASC",$var="admingroup",$type=true))) && empty(admingroupfunction($dbneme="neilmfdcmstypes",$where=" where `typesid` = '".$neilmfdcmscenterList['typesid']."' && `enable` = '1'  ",$admintype="admingroup")) )exit;



//字串轉陣列
$namefileArr=phpconversion($conversion=$neilmfdcmscenterList['namefile'],$type="unserialize");

foreach($namefileArr['newname'] as $key=> $val){
if($val==$var1){ 
  unset($namefileArr['newname'][$key]);  
  unset($namefileArr['oldname'][$key]);  
  
//刪除實體檔案
if(file_exists(XOOPS_ROOT_PATH.'/uploads/'.$xoopsmodule.'/types'.$neilmfdcmscenterList['typesid'].'/'.$neilmfdcmscenterList['sortid'].'file/file/'.$val.'')){
 unlink(XOOPS_ROOT_PATH.'/uploads/'.$xoopsmodule.'/types'.$neilmfdcmscenterList['typesid'].'/'.$neilmfdcmscenterList['sortid'].'file/file/'.$val.'');//將檔案刪除
}  
  }else{
$filedateDB['newname'][$key]=$namefileArr['newname'][$key]; //存資料庫
$filedateDB['oldname'][$key]=$namefileArr['oldname'][$key];  //取檔名  	  
  }
}

//陣列轉字串
if(!empty($filedateDB)) $datefile=phpconversion($conversion=$filedateDB,$type="serialize"); 

$setvar="set namefile='{$datefile}'   where centerid='".$dbid."'";
update($dbname="neilmfdcmscenter",$set=$setvar);   	

	  
  break;    
 
 */
 
 
case "152":    //刪除內容	  
$dbneme="neilmfdcmscenter";
$where="  where  `centerid` = '".$dbid."'    ";  //where數值
$neilmfdcmscenterList=moduledb($dbneme,$where);   

//權限判斷
if(($xoopsUser->getVar('uid')!=$neilmfdcmscenterList['uid']  || empty(grouppermission($dbneme="neilmfdcmssort",$where=" where `typesid` = '".$neilmfdcmscenterList['typesid']."' && `sortid` = '".$neilmfdcmscenterList['sortid']."' order by  sortid  ASC",$var="admingroup",$type=true))) && empty(admingroupfunction($dbneme="neilmfdcmstypes",$where=" where `typesid` = '".$neilmfdcmscenterList['typesid']."' && `enable` = '1'  ",$admintype="admingroup")) )exit;


//刪除圖檔
if(file_exists(XOOPS_ROOT_PATH.'/uploads/'.$xoopsmodule.'/types'.$neilmfdcmscenterList['typesid'].'/'.$neilmfdcmscenterList['sortid'].'file/image/.thumbs/'.$neilmfdcmscenterList['representimg'].'.png')){
 unlink(XOOPS_ROOT_PATH.'/uploads/'.$xoopsmodule.'/types'.$neilmfdcmscenterList['typesid'].'/'.$neilmfdcmscenterList['sortid'].'file/image/.thumbs/'.$neilmfdcmscenterList['representimg'].'.png');//將檔案刪除
} 

//刪除QRCODE
neillibrary_qrcodrebox($qrcodeimg=$neilmfdcmscenterList['qrcodeimg'],$alt="",$class="",$type="1",$url="");

//刪除檔案
$fileArr=phpconversion($conversion=$neilmfdcmscenterList['namefile'],$type="unserialize"); 

foreach($fileArr['newname'] as $key=> $val){
if(file_exists(XOOPS_ROOT_PATH.'/uploads/'.$xoopsmodule.'/types'.$neilmfdcmscenterList['typesid'].'/'.$neilmfdcmscenterList['sortid'].'file/file/'.$val.'')){
 unlink(XOOPS_ROOT_PATH.'/uploads/'.$xoopsmodule.'/types'.$neilmfdcmscenterList['typesid'].'/'.$neilmfdcmscenterList['sortid'].'file/file/'.$val.'');//將檔案刪除
} 

}


//刪除自訂按鈕
neillibrary_memudeletfunction($pageid=$dbid,$menutype=1,$modulesid='neilmfdcms');


$typesList=moduledb($dbneme="neilmfdcmstypes",$where="  where  `typesid` = '".$neilmfdcmscenterList['typesid']."'    ");   

//刪除留言資料-內容回覆類型
if($typesList['types']=='4') neilmfdcms_messagedate($centerid=$dbid);

//資料刪除
deletefunction($where=" where `centerid` = '$dbid'",$DBname="neilmfdcmscenter");

echo false;     
             break;     
 
 
  
  case "153":      
//管理員權限
if(empty($isAdmin)) exit;   

$Arrdate = array(); //建構陣列 

//相同where查詢欄位
$whereDB=" where `typesid` = '$dbid'";
//刪內容類型
$i=0;
$Arrdate[$i]['dbneme']="neilmfdcmstypes";
$Arrdate[$i]['where']=$whereDB;
$Arrdate[$i]['id']="typesid";

//刪內容分類
$i++;
$Arrdate[$i]['dbneme']="neilmfdcmssort";
$Arrdate[$i]['where']=$whereDB;
$Arrdate[$i]['id']="sortid";

//刪除自訂按鈕
$dbneme="neilmfdcmssort";
$where=" where  `typesid` = '".$dbid."'   order by  sortid DESC"; 
$deletesortArr=databasetablewhile($dbneme,$where);
foreach($deletesortArr as $key=> $val){
neillibrary_memudeletfunction($pageid=$deletesortArr[$key]['sortid'],$menutype=0,$modulesid=$xoopsmodule);  
}


//刪內容資料
$i++;
$Arrdate[$i]['dbneme']="neilmfdcmscenter";
$Arrdate[$i]['where']=$whereDB;
$Arrdate[$i]['id']="centerid";


$dbneme="neilmfdcmscenter";
$where=" where  `typesid` = '".$dbid."'   order by  centerid  DESC"; 
$deletecenteridArr=databasetablewhile($dbneme,$where);
foreach($deletecenteridArr as $key=> $val){
//刪除自訂按鈕	
neillibrary_memudeletfunction($pageid=$deletecenteridArr[$key]['centerid'],$menutype=1,$modulesid=$xoopsmodule);  
//刪除留言資料-內容回覆類型
$typesList=moduledb($dbneme="neilmfdcmstypes",$where="  where  `typesid` = '".$dbid."'    ");   
if($typesList['types']=='4') neilmfdcms_messagedate($centerid=$deletecenteridArr[$key]['centerid']);

}







//批次刪除function
deleteArr($Arrdate=$Arrdate);	

//刪除檔案
fileadminfunction($fileurl="",$type="1",$fileex="",$from=XOOPS_ROOT_PATH.'/uploads/'.$xoopsmodule.'/types'.$dbid.'');


echo false;  
   
   break; 
 
  case "154":  //更新上傳檔案
//群組管理權限
if(($xoopsUser->getVar('uid')!=$suid || empty(grouppermission($dbneme="neilfilefoldersort",$where=" where `sortid` = '".$of_sortid."'  order by  sortid  ASC",$var="admingroup",$type=true))) && empty($isAdmin)) exit;
 
$setvar="set titlefile='".sqlinjectionfound($sqlinjectionArr=$var1)."' , filetext='".sqlinjectionfound($sqlinjectionArr=$var2)."' , edit='1'  where folderid='".$dbid."'";
update($dbname="neilfilefolderlist",$set=$setvar);
  
  	   
 
    break;   
    
case "155":  //刪除上傳檔案
//群組管理權限
if(($xoopsUser->getVar('uid')!=$suid || empty(grouppermission($dbneme="neilfilefoldersort",$where=" where `sortid` = '".$of_sortid."'  order by  sortid  ASC",$var="admingroup",$type=true))) && empty($isAdmin)) exit;
//檔名
$fileurl=XOOPS_ROOT_PATH.'/uploads/neilfilefolder/'.$of_sortid.'file/file/'.$var1.'';
fileadminfunction($fileurl,$type="2",$fileex="",$from="");
deletefunction($where=" where `folderid` = '".$dbid."'",$dbneme='neilfilefolderlist');
break;


case "156":  //萬用關聯刪除內容頁
//$pageid 刪除頁面資料表名稱
//$enfunction 分類頁面資料表名稱   	   
//$keyvar 主刪除資料AUTO_INCREMENT鍵name
$keyvar=!empty($var1) ? $var1 : 'centerid';
// get TRUE
$deleteList=moduledb($dbneme=$pageid,$where="  where  `".$keyvar."` = '".$dbid."' ");

//特殊權限
switch($xoopsmodule) {
	case "neilsignedup_c":
	neilsignedup_c_specialpermission($deleteList,$pageid,$dbid);
	break;
	case "neilsignedup_a":
	neilsignedup_a_specialpermission($deleteList,$pageid,$dbid);
	break;
}

//權限判斷
switch($xoopsmodule) {
	case "neilperiodical":
	$periodidval=neilperiodical_removepermission($varid=$pageid,$uid=$xoopsUser->getVar('uid'),$dbid);
	break;
	case "neilmfdcms":
	$defaultlist=moduledb($dbneme="neilmfdcmsreplydata",$where="  where `replyid` = '".$dbid."'   ");
	$periodidval=neilmfdcms_removepermission($varid=$pageid,$uid=$xoopsUser->getVar('uid'),$dbid);
	//紀錄刪除ID
	neilmfdcms_removepermission($varid=$pageid,$uid=$xoopsUser->getVar('uid'),$dbid,$operate="",$record=1);
	break;
	case "neilenglishresults":
    if(empty(useradmin($uid=$xoopsUser->getVar('uid'),$basid=$deleteList['basid']))) exit; 
	break;
	case "neilproduct":
    if(empty(neilproduct_authority($dbid))  &&  empty($isAdmin)) exit;
	break;
	case "neilhonorlist":
    if(empty(honorlist_honorgetusr($deleteList['honor_uid']))) exit;
	break;
		
	default:
	if(($xoopsUser->getVar('uid')!=$deleteList['uid'] || empty(grouppermission($dbneme=$enfunction,$where=" where `sortid` = '".$deleteList['sortid']."'  order by  sortid  ASC",$var="admingroup",$type=true))) && empty($isAdmin)) exit;
}

//刪除內容頁
deletefunction($where=" where `".$keyvar."` = '$dbid'",$DBname=$pageid);

//模組關聯刪除內容
switch($xoopsmodule) {
	case "neilhonorlist":
    //刪除圖檔
    fileadminfunction($fileurl=XOOPS_ROOT_PATH.'/uploads/'.$xoopsmodule.'/cover/'.$deleteList['hc_id'].'.png',$type="2",$fileex="",$from="",$fileurlnew="",$exclude="");
    fileadminfunction($fileurl=XOOPS_ROOT_PATH.'/uploads/'.$xoopsmodule.'/cover/'.$deleteList['hc_id'].'_small.png',$type="2",$fileex="",$from="",$fileurlnew="",$exclude="");
	//刪除檔案
	neilhonorlist_deletefile($honorfile=$deleteList['honorfile'],$xoopsmodule);
	break;
	case "neilonlinevideo":
	//刪除圖檔
	fileadminfunction($fileurl=XOOPS_ROOT_PATH.'/uploads/'.$xoopsmodule.'/'.$deleteList['sortid'].'file/image/'.$deleteList['tmburl'].'.png',$type="2",$fileex="",$from="",$fileurlnew="",$exclude="");
	break;
	case "neothemesadmin":
	if($pageid=='neil_textblock') {
		//刪除圖檔
		fileadminfunction($fileurl=XOOPS_ROOT_PATH.'/uploads/'.$xoopsmodule.'/block_'.$dbid.'.png',$type="2",$fileex="",$from="",$fileurlnew="",$exclude="");
	}
	if($pageid=='neothemesflash') {
		//刪除圖檔
		fileadminfunction($fileurl=XOOPS_ROOT_PATH.'/uploads/'.$GLOBALS['xoopsConfig']['theme_set'].'/p'.$dbid.'.png',$type="2",$fileex="",$from="",$fileurlnew="",$exclude="");
	}
	if($pageid=='neil_popupads') {
		//刪除圖檔
		fileadminfunction($fileurl=XOOPS_ROOT_PATH.'/uploads/'.$xoopsmodule.'/popupads_'.$dbid.'.png',$type="2",$fileex="",$from="",$fileurlnew="",$exclude="");
	}
	if($pageid=='neil_lowerrightad') {
		fileadminfunction($fileurl=XOOPS_ROOT_PATH.'/uploads/'.$xoopsmodule.'/rdad_rt_'.$dbid.'.png',$type="2",$fileex="",$from="",$fileurlnew="",$exclude="");
		fileadminfunction($fileurl=XOOPS_ROOT_PATH.'/uploads/'.$xoopsmodule.'/rdad_rb_'.$dbid.'.png',$type="2",$fileex="",$from="",$fileurlnew="",$exclude="");
	}
	break;
	case "neilmfdcms":
	//需增加啟用留言功能判斷
	//如果沒開啟群組名單更新統計數據
	neilmfdcms_removepermission($varid='updaterecord',$uid=$xoopsUser->getVar('uid'),$dbid,$operate="",$record="",$defaultlist);
	break;
	case "neilfilefolder":
	//刪除檔案資料
	neilfilefolder_deletefolderlist($dbid,$sortid=$deleteList['sortid'],$xoopsmodule,$typevar=true);
	break;
	case "neilsignedup_c":
	//刪除代表圖  	  
	neilsignedup_c_deletedrawing($xoopsmodule,$sortid=$deleteList['sortid'],$representimg=$deleteList['representimg'],$centerid=$deleteList['centerid'],$category=1);
	//刪除報名表
	neilsignedup_c_deleteapplylist($dbid,$xoopsmodule);
	//刪除自訂按鈕
	neillibrary_memudeletfunction($pageid=$dbid,$menutype=1,$modulesid='neilsignedup_c');
	break;
	case "neilsignedup_a":
	//刪除代表圖  	  
	neilsignedup_a_deletedrawing($xoopsmodule,$sortid=$deleteList['sortid'],$representimg=$deleteList['representimg'],$centerid=$deleteList['centerid'],$category=1);  
	//刪除報名表
	neilsignedup_a_deleteapplylist($dbid,$xoopsmodule);
	//刪除自訂按鈕
	neillibrary_memudeletfunction($pageid=$dbid,$menutype=1,$modulesid='neilsignedup_a');
	//刪除資料夾
	fileadminfunction($fileurl="",$type="1",$fileex="",$from=XOOPS_ROOT_PATH.'/uploads/'.$xoopsmodule.'/'.$deleteList['sortid'].'file/centerid_'.$deleteList['centerid'].'');
    //刪除檔案
    neilsignedup_a_deletefile($xoopsmodule,$deleteList);
	break;
	case "neilperiodical":  	    	  
		switch($pageid) {
		case "neilperiodical_content":
		//刪除圖檔	  
		neilperiodical_deletedrawing($xoopsmodule,$periodid=$deleteList['periodid'],$projectid=$deleteList['projectid'],$representimg=$deleteList['img']);
		break;
		case "neilperiodical_period":
		//刪除項目內容圖檔  
		neilperiodical_project_delete($xoopsmodule,$periodid=$dbid);
		//刪除自訂按鈕
		neillibrary_memudeletfunction($pageid=$dbid,$menutype=0,$modulesid='neilperiodical');
		break;
		case "neilperiodical_project":
		//刪除內容
		neilperiodical_content_delete($val=$dbid,$kname=$keyvar);
		//刪除檔案
		fileadminfunction($fileurl="",$type="1",$fileex="",$from=XOOPS_ROOT_PATH.'/uploads/'.$xoopsmodule.'/'.$periodidval.'file/project/'.$dbid.'file');
		break;
		default:
	}
	break;
	case "neilenglishresults":
	deletneilenreview($basid=$deleteList['basid'],$id=$deleteList['id'],$enfunction=$deleteList['enfunction']);

	switch($enfunction) {
		case "1":
		//刪除代表圖
		fileadminfunction($fileurl=XOOPS_ROOT_PATH.'/uploads/neilenglishresults/enf'.$deleteList['basid'].'/movie/'.$deleteList['tmburl'].'.png',$type="2",$fileex="",$from="",$fileurlnew="",$exclude="");
        //儲存成果影音最新一筆刪除ID
        update($dbname="config",$set="set conf_value='".$deleteList['id']."'  where conf_name='neilenglishresults16'");  
		break;
		case "2":
		//刪除圖檔
		foreach($bigbasimgArr=phpconversion($conversion=$deleteList['basimg'],$type="unserialize") as $i=> $val) {
			//刪除實體圖片-小圖
			fileadminfunction($fileurl=XOOPS_ROOT_PATH.'/uploads/neilenglishresults/enf'.$deleteList['basid'].'/album/'.$bigbasimgArr[$i]['smallbasimg'].'.jpg',$type="2",$fileex="",$from="",$fileurlnew="",$exclude="");
			//刪除實體圖片-大圖
			fileadminfunction($fileurl=XOOPS_ROOT_PATH.'/uploads/neilenglishresults/enf'.$deleteList['basid'].'/album/'.$bigbasimgArr[$i]['bigbasimg'].'.jpg',$type="2",$fileex="",$from="",$fileurlnew="",$exclude="");
		}
        //儲存成果相簿最新一筆刪除ID
        update($dbname="config",$set="set conf_value='".$deleteList['id']."'  where conf_name='neilenglishresults17'");  
		break;
		case "4":			
    	$i=0;
    	//刪除檔案
        $namefileArr=phpconversion($conversion=$deleteList['namefile'],$type="unserialize");
        foreach($Arr=$namefileArr['file_id'] as $key=> $val) {
              fileadminfunction($fileurl=XOOPS_ROOT_PATH.'/uploads/neilenglishresults/enf'.$deleteList['basid'].'/file/'.$namefileArr['file_d'][$i].'.'.$namefileArr['file_e'][$i].'',$type="2",$fileex="",$from="",$fileurlnew="",$exclude="");
	          $i++;
        }
        //儲存成果檔案最新一筆刪除ID
        update($dbname="config",$set="set conf_value='".$deleteList['id']."'  where conf_name='neilenglishresults18'");          
		break;
	}
    //儲存最新一筆成果類型ID
    update($dbname="config",$set="set conf_value='".$enfunction."'  where conf_name='neilenglishresults19'"); 
	break;
	case "neilproduct":		
	if($pageid=='productcontent'){
    //刪除商品圖檔
    neilproduct_deleteproductimage($dbid,$deleteList);	
	//刪除自訂按鈕
	neillibrary_memudeletfunction($page=$dbid,$menutype=1,$modulesid='neilproduct');    
	//刪除加入商品諮詢
    neilproduct_deletinquiry($page=$dbid);
    //刪除檔案
    neilproduct_deletefile($xoopsmodule,$deleteList);
    
    //刪除父母血緣    
    if(function_exists('neilproduct_deleteparent')){
    //刪父親	
    neilproduct_deleteparent($deleteList,$pageid,$nameval="father");
    //刪母親
    neilproduct_deleteparent($deleteList,$pageid,$nameval="mother");
    }
        
    }
	if($pageid=='productinquiry'){
    //紀錄pinquiryid
    update($dbname="config",$set="set conf_value='".$deleteList['pinquiryid']."'  where conf_name='productsystem28'");		
    //減去商品諮詢統計
    foreach($Arr=databasetablewhile($dbneme="productcontent",$where=" where `productid` IN (".$deleteList['productid'].")") as $key=> $val){
    $setvar="set inquirynumber='".($Arr[$key]['inquirynumber']-1)."' where productid='".$Arr[$key]['productid']."'";
    update($dbname="productcontent",$set=$setvar);
    }    
    //刪除資料夾
    fileadminfunction($fileurl="",$type="1",$fileex="",$from=XOOPS_ROOT_PATH.'/uploads/'.$xoopsmodule.'/formdate/'.$deleteList['formid'].'file/'.$deleteList['pinquiryid'].'_child');		
	}   	 	
	break;	
	case "neilalbum":	
	//刪除圖檔
	//字串轉陣列
	$bigbasimgArr=phpconversion($conversion=$deleteList['basimg'],$type="unserialize");
	foreach($bigbasimgArr as $key=> $val) {
		//刪除實體圖片-小圖
		if(file_exists(XOOPS_ROOT_PATH.'/uploads/'.$xoopsmodule.'/'.$deleteList['sortid'].'file/image/.thumbs/small_'.$val['imgname'].'.jpg')) {
			unlink(XOOPS_ROOT_PATH.'/uploads/'.$xoopsmodule.'/'.$deleteList['sortid'].'file/image/.thumbs/small_'.$val['imgname'].'.jpg');
			//將檔案刪除
		}
		//刪除實體圖片-大圖
		if(file_exists(XOOPS_ROOT_PATH.'/uploads/'.$xoopsmodule.'/'.$deleteList['sortid'].'file/image/.thumbs/big_'.$val['imgname'].'.jpg')) {
			unlink(XOOPS_ROOT_PATH.'/uploads/'.$xoopsmodule.'/'.$deleteList['sortid'].'file/image/.thumbs/big_'.$val['imgname'].'.jpg');
			//將檔案刪除
		}
	}
    //刪除自訂按鈕
    neillibrary_memudeletfunction($pageid=$dbid,$menutype=1,$modulesid='neilalbum');
	break;
}


echo false;  


    break;   
    
    case "157":  //檔案上傳儲存審核
//管理員權限
if(empty($isAdmin)) exit;   

//儲存審核資料
$setvar="set reviewtype='".$var1."' ,  reviewtext='".$var2."'  where centerid='".$dbid."'";
update($dbname="neilfilefoldercenter",$set=$setvar);

$reviewtype=$var1=='1' ? _MD_FILEFOLDERCENTERPHP23 : strip_tags(_MD_FILEFOLDERCENTERPHP44); // get TRUE    

//發送郵件通知會員審核結果
neilfilefolder_reviewuserreplymail($timedate=timedate($datevar="Y-m-d H:i:s"),$title,$review=$reviewtype,$usermail=$email,$userid=XoopsUser::getUnameFromId($suid,0),$centerid=$dbid,$of_sortid=$sortid);

	
$box="<div class='text-center'>".sprintf(_MD_FILEFOLDERCENTERPHP50,$reviewtype,$var2)."<a href='".XOOPS_URL."/modules/".$xoopsmodule."/filefolderadmin.php' class='btn btn-success btn-block'>"._MD_FILEFOLDERCENTERPHP51."</a></div>";  	

   
 echo $box; 
 
    
     break;     
     
    case "158":  //群組管理介面
//管理員權限
if(empty($isAdmin)) exit;   


//抓出會員資料
$usersArr=databasetablewhile($dbneme="users",$where=" order by  uid  ASC");  

//開啟groups_users_link抓出uid
$userArrlink=databasetablewhile($dbnemeuser="groups_users_link",$whereuser="  where   `groupid` = '".$groupid."'   order by  uid  DESC",$selectkey="DISTINCT uid");  
foreach($userArrlink as $key=> $val){
$userArruidlink[$key]=$userArrlink[$key]['uid'];
}

//迴圈解出uid
foreach($usersArr as $key=> $val){
//$userArr[$key]['uid']; //群組內UID
if(!empty($userArruidlink) &&   in_array($usersArr[$key]['uid'],$userArruidlink)){
$paid[]=$usersArr[$key]['uid']; //群組中會員
}else{
$unpaid[]=$usersArr[$key]['uid']; //非群組中會員
}
}

//群組中會員
foreach($paid as  $val){
$paidoptionselect.=optionselect($dataid=$val,$optionname=XoopsUser::getUnameFromId($val,1),$oid=false,$value=$val,$id="");
}


//非群組中會員
foreach($unpaid as  $val){
$unpaidoptionselect.=optionselect($dataid=$val,$optionname=XoopsUser::getUnameFromId($val,1),$oid=false,$value=$val,$id="");
}


     
$box=" <table class='table table-striped'>
    <thead>
      <tr >
        <th class='text-center' style='width: 40%;'>"._MS_GROUPADMIN06."</th>
        <th class='text-center' style='width: 20%;'>"._MS_SHARED119."</th>
        <th class='text-center' style='width: 40%;'>"._MS_GROUPADMIN07."</th>
      </tr>      	  
    </thead>
    <tbody>
    <tr >   	  
<td>
<div class='form-group'>
	<select class='form-control paid'  id='sel1' name='paid' multiple  >
    	".$paidoptionselect."   
  </select>	
    <span id='helpBlock' class='help-block'>"._MS_GROUPADMIN08."</span>    		  	  
  </div>

</td>
	
	
	
<td class='text-center'><div class='row'>
  <div class='col-md-6 col-xs-6'><button id='removebtn' name='159,".$groupid."' type='button' class='btn btn-danger'>"._MS_GROUPADMIN10."</button></div>
  <div class='col-md-6 col-xs-6'><button id='joinbtn' name='159,".$groupid."' type='button' class='btn btn-primary'>"._MS_GROUPADMIN09."</button></div>
</div></td>
	
	
			  
<td><div class='form-group'>
	<select class='form-control unpaid'  id='sel1' name='unpaid' multiple  >
    	".$unpaidoptionselect."   
  </select>	
    <span id='helpBlock' class='help-block'>"._MS_GROUPADMIN08."</span>  	  
  </div></td>
    </tr>  		  
    </tbody>
  </table> 	

<script>xoopsgroupadminoperating();</script>


   ";    
     
 echo $box;      
      break;     
      

    case "159":  //加入移除群組操作
//管理員權限
if(empty($isAdmin)) exit; 


switch($type){
  case "1": //加入群組  	  
foreach($Arr as $key=> $val){
$valuesvar="(groupid,uid) values('".$groupid."','".$val."')";	  
$centerid=insert($dbname="groups_users_link",$values=$valuesvar);
} 
break;  
  
case "2": //移除群組
foreach($Arr as $key=> $val){
deletefunction($where=" where `groupid` = '$groupid' && `uid` = '$val'  ",$DBname="groups_users_link");
}   
break;
}


truncatefunction($DBname="session");//清空session	    

break;      





   case "160":  //刪除代表圖-線上報名
   	   
   	   
switch($type){
  case "1":
  	  
$valList[1]="neilsignedup_a_center";
$valList[2]="neilsignedup_a_sort";
  break;
  
  default:
$valList[1]="neilsignedup_c_center";
$valList[2]="neilsignedup_c_sort";
}


   	   
$dbneme=$valList[1];
$where=" where `centerid` = '".$var1."' ";
$signedupList=moduledb($dbneme,$where);   
//發佈者判斷
//權限判斷
if(($xoopsUser->getVar('uid')!=$signedupList['uid']  || empty(grouppermission($dbneme=$valList[2],$where=" where  `sortid` = '".$signedupList['sortid']."' order by  sortid  ASC",$var="admingroup",$types=true))) && empty($isAdmin) )exit;

//刪除圖檔
switch($type){
  case "1":
//刪除圖檔
neilsignedup_a_deletedrawing($xoopsmodule,$sortid=$signedupList['sortid'],$representimg=$signedupList['representimg'],$centerid=$signedupList['centerid']);
  break;
  
  default:
//刪除圖檔
neilsignedup_c_deletedrawing($xoopsmodule,$sortid=$signedupList['sortid'],$representimg=$signedupList['representimg'],$centerid=$signedupList['centerid']);
}

   
   
 break;  
        
        
        
        
        
    case "161":  //課程報名儲存審核
    	
    	
switch($type){
  case "1":
$dbnemeList[1]="neilsignedup_a_center";
$dbnemeList[2]="neilsignedup_a_sort";
$dbnemeList[3]="neilsignedup_a_apply";
//儲存最新審核ID   
update($dbname="config",$set="set conf_value='".$var3."'  where conf_name='neilsignedup_a16'");
  break;
  
  default:
$dbnemeList[1]="neilsignedup_c_center";
$dbnemeList[2]="neilsignedup_c_sort";
$dbnemeList[3]="neilsignedup_c_apply";
//儲存最新審核ID   
update($dbname="config",$set="set conf_value='".$var3."'  where conf_name='neilsignedup_c15'");
}
    	
    	
    	
    	
$dbneme=$dbnemeList[1];
$where=" where `centerid` = '".$dbid."' ";
$ListDB=moduledb($dbneme,$where);   
 
//課程狀態判斷
if(empty($ListDB['enable'])) exit; 
    	

if(($xoopsUser->getVar('uid')!=$ListDB['uid']  || empty(grouppermission($dbneme=$dbnemeList[2],$where=" where  `sortid` = '".$ListDB['sortid']."' order by  sortid  ASC",$var="admingroup",$types=true))) && empty($isAdmin) )exit;



//儲存課程報名審核資料
$setvar="set approvedtime='".timedate($datevar="Y-m-d H:i:s")."' ,  checks='".$var1."' ,  reviewreply='".$var2."'   ,  reviewuid='".$xoopsUser->getVar('uid')."'  where applyid='".$var3."'";
update($dbname=$dbnemeList[3],$set=$setvar);

if($var1=='1'){
	
//報名人數判斷-為0自動修改可報名人數
if(($ListDB['cansignup']-$ListDB['registered'])=='0'){
$cansignupDB=" cansignup='".($ListDB['cansignup']+1)."' ,";	
}
	
//回寫課程資料
$setvar="set ".$cansignupDB." registered='".($ListDB['registered']+1)."'   where centerid='".$dbid."'";
update($dbname=$dbnemeList[1],$set=$setvar);
}

	
switch($type){
  case "1":
  	  
$reviewtype=neilsignedup_a_approvalstatus($status=$var1);
//發送郵件通知會員審核結果
neilsignedup_a_reviewuserreplymail($timedate=timedate($datevar="Y-m-d H:i:s"),$title=$ListDB['title'],$review=$reviewtype,$usermail=$email,$userid=$name,$centerid=$dbid,$of_sortid=$sortid,$reviewreply=$var2,$number=$var4);
  	    	  

  break;
  
  
  default:
$reviewtype=neilsignedup_c_approvalstatus($status=$var1);
//發送郵件通知會員審核結果
neilsignedup_c_reviewuserreplymail($timedate=timedate($datevar="Y-m-d H:i:s"),$title=$ListDB['title'],$review=$reviewtype,$usermail=$email,$userid=$name,$centerid=$dbid,$of_sortid=$sortid,$reviewreply=$var2,$number=$var4);
  	  

}	
	
	

    
     break;          
        
     case "162":  //取消課程報名   
     	 
     	 
switch($type){
  case "1":
$dbneme="neilsignedup_a_center";
$where=" where `centerid` = '".$dbid."' ";
$ListDB=moduledb($dbneme,$where);     
//課程狀態判斷
if(empty($ListDB['enable'])) exit;
if(($xoopsUser->getVar('uid')!=$ListDB['uid']  || empty(grouppermission($dbneme="neilsignedup_a_sort",$where=" where  `sortid` = '".$ListDB['sortid']."' order by  sortid  ASC",$var="admingroup",$types=true))) && empty($isAdmin)   &&   empty(neilsignedup_a_applicantfunction($uid=$xoopsUser->getVar('uid'),$applyid=$var1))     )exit;
$uid=$xoopsUser->getVar('uid');    
  
//通知課程管理員
//開啟users
$usersListDB=moduledb($dbneme="users",$where="   where `uid` = '".$ListDB['uid']."'");
//開啟ugroups_users_link查詢UID是否為管理群組
if(empty(moduledb($dbneme="groups_users_link",$where="   where `uid` = '".$ListDB['uid']."' &&  `groupid` = '1'  "))) $usermail=$usersListDB['email'];
//發MAIL通知管理群組
neilsignedup_a_cancellationnoticemail($centerid=$dbid,$of_sortid=$ListDB['sortid'],$timedate=timedate($datevar="Y-m-d H:i:s"),$userid=XoopsUser::getUnameFromId($uid,1),$title=$ListDB['title'],$getGroupid=1,$usermail,$applyid=$var1,$names=$var2,$usermail2=$email,$number=$var3);

//儲存課程報名審核資料
$setvar="set  checks='3' ,  reviewuid='".$uid."' , canceltime='".timedate($datevar="Y-m-d H:i:s")."'    where applyid='".$var1."'";
update($dbname="neilsignedup_a_apply",$set=$setvar);
     	 
//回寫課程資料
$setvar="set  registered='".($ListDB['registered']-1)."'   where centerid='".$dbid."'";
update($dbname="neilsignedup_a_center",$set=$setvar);   

  break;
  
  default:


$dbneme="neilsignedup_c_center";
$where=" where `centerid` = '".$dbid."' ";
$ListDB=moduledb($dbneme,$where);     
//課程狀態判斷
if(empty($ListDB['enable'])) exit;
if(($xoopsUser->getVar('uid')!=$ListDB['uid']  || empty(grouppermission($dbneme="neilsignedup_c_sort",$where=" where  `sortid` = '".$ListDB['sortid']."' order by  sortid  ASC",$var="admingroup",$types=true))) && empty($isAdmin)   &&   empty(neilsignedup_c_applicantfunction($uid=$xoopsUser->getVar('uid'),$applyid=$var1))     )exit;
$uid=$xoopsUser->getVar('uid');    
  
//通知課程管理員
//開啟users
$usersListDB=moduledb($dbneme="users",$where="   where `uid` = '".$ListDB['uid']."'");
//開啟ugroups_users_link查詢UID是否為管理群組
if(empty(moduledb($dbneme="groups_users_link",$where="   where `uid` = '".$ListDB['uid']."' &&  `groupid` = '1'  "))) $usermail=$usersListDB['email'];
//發MAIL通知管理群組
neilsignedup_c_cancellationnoticemail($centerid=$dbid,$of_sortid=$ListDB['sortid'],$timedate=timedate($datevar="Y-m-d H:i:s"),$userid=XoopsUser::getUnameFromId($uid,1),$title=$ListDB['title'],$getGroupid=1,$usermail,$applyid=$var1,$names=$var2,$usermail2=$email,$number=$var3);

//儲存課程報名審核資料
$setvar="set  checks='3' ,  reviewuid='".$uid."' , canceltime='".timedate($datevar="Y-m-d H:i:s")."'    where applyid='".$var1."'";
update($dbname="neilsignedup_c_apply",$set=$setvar);
     	 
//回寫課程資料
$setvar="set  registered='".($ListDB['registered']-1)."'   where centerid='".$dbid."'";
update($dbname="neilsignedup_c_center",$set=$setvar);   




}
     	 
     	 
	
  
    break;  
    
    
     case "163":  //取消課程     	 
     	 
     	 
switch($type){
  case "1":
  //活動報名
$dbnemelist[1]="neilsignedup_a_center";
$dbnemelist[2]="neilsignedup_a_sort";
$dbnemelist[3]="neilsignedup_a_apply";
  
  break;
  
  default:
$dbnemelist[1]="neilsignedup_c_center";
$dbnemelist[2]="neilsignedup_c_sort";
$dbnemelist[3]="neilsignedup_c_apply";
  //課程報名
}   	 







     	 
  	 
$dbneme=$dbnemelist[1];
$where=" where `centerid` = '".$dbid."' ";
$ListDB=moduledb($dbneme,$where);     


if(($xoopsUser->getVar('uid')!=$ListDB['uid']  || empty(grouppermission($dbneme=$dbnemelist[2],$where=" where  `sortid` = '".$ListDB['sortid']."' order by  sortid  ASC",$var="admingroup",$types=true))) && empty($isAdmin)  )exit;
    
//發送郵件通知報名者
$applyArr=databasetablewhile($dbnemeuser=$dbnemelist[3],$whereuser="  where   `centerid` = '".$dbid."'  &&  `checks` = '1'  order by  applyid  DESC");  
foreach($applyArr as $key=> $val){
	
switch($type){
  case "1":
  //執行對應函數
neilsignedup_a_cancelcoursemail($timedate=timedate($datevar="Y-m-d H:i:s"),$title=$ListDB['title'],$usermail=$applyArr[$key]['email'],$userid=$applyArr[$key]['names'],$number=$applyArr[$key]['number']);
  break;
  
  default:
  //預設動作
neilsignedup_c_cancelcoursemail($timedate=timedate($datevar="Y-m-d H:i:s"),$title=$ListDB['title'],$usermail=$applyArr[$key]['email'],$userid=$applyArr[$key]['names'],$number=$applyArr[$key]['number']);
}
}
    
     	 
     	 
//儲存課程資料表     	 
$setvar="set  status='2' ,  enable='0'   where centerid='".$dbid."'";
update($dbname=$dbnemelist[1],$set=$setvar);     	 
    
    
    
     break;     
    
 
 
case "164":  //自訂選單排序
//權限機制  
switch($xoopsmodule) {
	case "neilofficebriefing":  	
	neilofficebriefing_menuAuthorityadmin($type,$uid=$xoopsUser->getVar('uid'),$officeid=$dbid);
	break;
	case "neilmfdcms":   	  
	neilmfdcms_menuAuthorityadmin($type,$typesid=$var1,$sortid=$var2,$suid=$var3);
	break;
	case "neilsignedup_c":  	
	neilsignedup_c_menuAuthorityadmin($type,$suid=$var3,$sortid=$var2);
	break;
	case "neilsignedup_a":  	
	neilsignedup_a_menuAuthorityadmin($type,$suid=$var3,$sortid=$var2);
	break;
	case "neilalbum":  	
	neilalbum_menuAuthorityadmin($type,$suid=$var3,$sortid=$var2);
	break;
	case "neilperiodical":  	
	neilperiodical_menuAuthorityadmin($type);
	break;
	case "neilfilefolder":  	
	neilfilefolder_menuAuthorityadmin($type,$suid=$var3,$sortid=$var2);
	break;
	case "neilonlinevideo":  	
	neilonlinevideo_menuAuthorityadmin($type,$suid=$var3,$sortid=$var2);
	break;
    case "neothemesadmin":  	
    if(empty($isAdmin))  exit;
    break; 
    case "neilproduct":  	
    if(empty($isAdmin))  exit;
    break; 
	default:
	  exit;
}
$dbname=empty($var4) ? 'neillibrary_modulesmenu' : $var4;
// get TRUE
$dbkey=empty($var5) ? 'menuid' : $var5;
// get TRUE
switch($var6) {
	case "1":
	//儲存更新排序-區塊陣列
	$listvar=moduledb($dbname,$where=" where ".$dbkey."='".$val."'");
	//字串轉陣列
	$imgArr=phpconversion($conversion=$listvar[$var7],$type="unserialize");
	//變更陣列排序
	foreach($Arr as $key=> $val) {
	//	if(file_exists(XOOPS_ROOT_PATH.'/uploads/'.$xoopsmodule.'/'.$var2.'file/image/.thumbs/small_'.$imgArr[$val].'.jpg')) {
			$imgArrnaw[$val]=$imgArr[$val];
	//	}
	}
	//儲存更新排序
	$setvar="set  ".$var7."='".phpconversion($conversion=$imgArrnaw,$type="serialize")."'   where ".$dbkey."='".$dbid."'";
	update($dbname,$set=$setvar);
	break;
	default:
	//儲存更新排序-表單   	
    $name=empty($var8) ? 'btnsort' : $var8; //排序name
	foreach($Arr as $key=> $val) {
		$setvar="set  ".$name."='".$key."'   where ".$dbkey."='".$val."'";
		update($dbname,$set=$setvar);
	}
}
break; 
       
       
       
       
      case "165":    //通用刪除自訂按鈕
//權限機制           
switch($xoopsmodule){
  case "neilofficebriefing":
neilofficebriefing_menuAuthorityadmin($type=$var2,$uid=$xoopsUser->getVar('uid'),$officeid=$var3);
  break;
  case "neilmfdcms":  	
neilmfdcms_menuAuthorityadmin($type=$var2,$typesid=$var4,$sortid=$var5,$suid=$var6);
  break;  
  
  case "neilsignedup_c":  	
neilsignedup_c_menuAuthorityadmin($type=$var2,$suid=$var6,$sortid=$var5);    
  break;  
  
  case "neilsignedup_a":  	
neilsignedup_a_menuAuthorityadmin($type=$var2,$suid=$var6,$sortid=$var5);    
  break;  
  
  case "neilperiodical":  	
neilperiodical_menuAuthorityadmin($type=$var2);
  break;    
  
  case "neilfilefolder":  	
neilfilefolder_menuAuthorityadmin($type=$var2,$suid=$var6,$sortid=$var5);    
  break; 
   
  case "neilalbum":  	
neilalbum_menuAuthorityadmin($type=$var2,$suid=$var6,$sortid=$var5);
  break;
  
case "neilproduct":  	
if(empty($isAdmin))  exit;
break; 
  
  default:
exit;
}


//刪除按鈕
deletefunction($where=" where `".$var1."` = '$dbid'",$DBname=$pageid);             
           
        break;     
       
       
       
case "166":    //開啟關閉區塊樣式
//管理員權限
if(empty($isAdmin)) exit; 	        	
if(empty($var2)){ //關閉區塊樣式
$setvar="set  title='[nobox]".$var3."'   where bid='".$var1."'";
update($dbname="newblocks",$set=$setvar); 
}else{ //開啟區塊樣式
$setvar="set  title='".str_replace ("[nobox]","",$var3)."'   where bid='".$var1."'";
update($dbname="newblocks",$set=$setvar);  
}  
   
         break; 
         
         
case "167":    //讀取布景區塊ICON 
//開啟neilblocksicon資料表
$iconList=moduledb($dbneme="neilblocksicon",$where=" where `bid` = '".$dbid."' ");    
         
$iconbox=empty($iconList['icon']) ? '<span class="glyphicon glyphicon-log-out" aria-hidden="true"></span>' : $iconList['icon']; // get TRUE

echo $iconbox;           
break;    
         

case "168":    //寫入布景區塊ICON 
//管理員權限
if(empty($isAdmin)) exit; 	  

//開啟neilblocksicon資料表
$iconList=moduledb($dbneme="neilblocksicon",$where=" where `bid` = '".$dbid."' ");    

if(empty($iconList['icon'])){
//新增
$valuesvar="(bid,icon) values('".$dbid."','".$var1."')";	  
insert($dbname="neilblocksicon",$values=$valuesvar);

}else{
//更新
$setvar="set  icon='".$var1."'   where bid='".$dbid."'";
update($dbname="neilblocksicon",$set=$setvar);   
}

break;    

case "169":
//城市鄉鎮選單
$dbneme="neillibrary_citydate";  //資料表名稱
$dbid=$exchange=='true'? $dbid : $selectidedit; // get TRUE
$where=" where `of_cityid` = '".$dbid."' &&  `enable` = '1' order by sortidsort ASC";   //where數值-新增
if(!empty($dbid)){
$sort=databasetablewhile($dbneme,$where); 
}
$optionone.=optionbox($sortvar=$sort,$oid=$of_sortid,$dbneme="",$var2="3",$type="",$typesid="");
if(!empty($optionone)){
$select.="<select id=".$selectid." class='form-control' name='".$var1."' >
<option   data-id='".$dbid."' value='".$dbid."'  >"._MS_CITY_MENU08."</option>
     	".$optionone."   
  </select>	 <p>
";
}	
echo $select;
  break;
  
  

   case "170":   //區塊代表圖上傳
//管理員權限
if(empty($isAdmin)) exit;  

 //上傳檔案  
if(!empty($_FILES['file']['name'])){ 
save_pic($up_id=$var3,$width=$var1,$height="0",$modules="".$var2."",$plural=false,$convert="png",$arr=false,$process=1,$crop=false,$upfile=$_FILES['file'],$type="1"); 
}

 
     break;  


 case "171":    //簡章寫入已回覆  
 
 //權限判斷
if(empty(readpermission($user_uid="",$type="2",$dbvar="neilsignedup_c13",$where="",$modulesid="neilsignedup_c"))) exit;

$setvar="set uid='".$xoopsUser->getVar('uid')."', setuptime='".timedate($datevar="Y-m-d H:i:s")."' , type='1'    where briefid='".$dbid."'";
update($dbname="neilsignedup_c_brief",$set=$setvar);    

$box="<br /><div class='col-sm-12 col-xs-12 text-center'><div class='alert alert-info' role='alert'>".sprintf(_MD_SIGNEDUPCENTERPHP209,XoopsUser::getUnameFromId($xoopsUser->getVar('uid'),1),timedate($datevar="Y-m-d H:i:s"))."</div></div>";

echo $box;


          
      break; 
                

 case "172":    //變更期刊狀態 
$configvar=configvar($modulesid="neilperiodical");  	 
//管理權限
if(empty(neillibrary_modulesgrouppermission($conf_value=$configvar['neilperiodical9']))) exit;

//開啟期別資料表
$periodList=moduledb($dbneme="neilperiodical_period",$where=" where `periodid` = '".$var1."'");

//判斷狀態
if(empty($periodList['enable'])){ //發布期刊
$enable='1';
$enabletext=_MS_SHARED177;
$uidval=sprintf(_MD_PERIODADMINPHP21,XoopsUser::getUnameFromId($xoopsUser->getVar('uid'),1));
$posttime="'".timedate($datevar="Y-m-d H:i:s")."'";
}else{ //取消發布
$enable='0';
$enabletext=_MS_SHARED176;
$uidval=sprintf(_MD_PERIODADMINPHP22,XoopsUser::getUnameFromId($xoopsUser->getVar('uid'),1));
$posttime='NULL';
}

$setvar="set enable='".$enable."' ,  uid='".$xoopsUser->getVar('uid')."' ,  posttime={$posttime}   where periodid='".$var1."'";
update($dbname="neilperiodical_period",$set=$setvar);  



echo  $enable.','.$enabletext.','.$uidval;
 
break;      


case "173":
//電子校刊-班級選單
$dbneme="neillibrary_class";  //資料表名稱
$dbid=$exchange=='true'? $dbid : $selectidedit; // get TRUE
$where=" where `of_classid` = '".$dbid."' &&  `enable` = '1' order by sortidsort ASC";   //where數值-新增
if(!empty($dbid)){
$sort=databasetablewhile($dbneme,$where); 
}

$title= empty($var2) ? _MA_CLASSADMINPHP10 : $var2; // get TRUE


$optionone.=optionbox($sortvar=$sort,$oid=$of_sortid,$dbneme="",$var2="4",$type="",$typesid="");


if(!empty($optionone)){
$select.="<select id=".$selectid." class='form-control' name='".$var1."' >
<option   data-id='0' value='".$dbid."'  >".$title."</option>
     	".$optionone."   
  </select>	 <p>
";
}	
echo $select;
  break;


//電子校刊-審核功能
case "174":
$configvar=configvar($modulesid="neilperiodical");  
	
//權限判斷
switch($var1){
  case "neilperiodical_user":
//管理權限
if(empty(neillibrary_modulesgrouppermission($conf_value=$configvar['neilperiodical9']))) exit;

$setvar="set enable='1' ,  reviewtime = '".timedate($datevar="Y-m-d H:i:s")."'   where userid='".$dbid."'";
update($dbname="neilperiodical_user",$set=$setvar);  


$userList=$userlist=moduledb($dbneme="neilperiodical_user",$where="  where `userid` = '".$dbid."'   ");
//E-MAIL通知投稿人資格審核回覆
neilperiodical_user_auditnoticemail($name=$userList['name'],$review=_MS_SHARED181,$timedate=timedate($datevar="Y-m-d H:i:s"),$usermail=$userList['email']);   


echo  sprintf(_MD_PERIODADMINPHP73,_MS_SHARED181).','.sprintf(_MD_PERIODADMINPHP72,timedate($datevar="Y-m-d H:i:s"));

  break;
  
  
  default:
exit;
}



case "175":
//電子校刊-項目選單
$dbneme="neilperiodical_project";  //資料表名稱
$dbid=$exchange=='true'? $dbid : $selectidedit; // get TRUE

	
$enableDB=empty($status) ? " &&  `enable` = '1'" : ''; // get TRUE
	
$where=" where `periodid` = '".$dbid."' ".$enableDB." order by sortidsort ASC";   //where數值-新增
if(!empty($dbid)){
$sort=databasetablewhile($dbneme,$where); 
}
$optionone.=optionbox($sortvar=$sort,$oid=$of_sortid,$dbneme="",$var2="5",$type="",$typesid="");


if(!empty($optionone)){
$select.="<select id=".$selectid." class='form-control' name='projectid' >
<option   data-id='0' value=''  >"._MD_PERIODADMINPHP98."</option>
     	".$optionone."   
  </select>	 <p>
";

}	


echo $select;
  break;	


 case "176":    //變投稿內容狀態 
 	 
$contentlist=moduledb($dbneme="neilperiodical_content",$where="  where `contentid` = '".$var1."'  ");	 
 	 
$configvar=configvar($modulesid="neilperiodical");  	 
//管理權限
if(empty(neillibrary_modulesgrouppermission($conf_value=$configvar['neilperiodical9']))    && empty(grouppermission($dbneme="neilperiodical_period",$where=" where  `periodid` = '".$contentlist['periodid']."'  order by  periodid  ASC",$var="admingroup",$type=true))) exit;


//判斷狀態
if(empty($enable)){ //啟用內容
$enable='1';
$enableyext=sprintf(_MD_PERIODADMINPHP135,_MD_PERIODADMINPHP131);
}else{ //關閉內容
$enable='0';
$enableyext=sprintf(_MD_PERIODADMINPHP135,_MD_PERIODADMINPHP130);
}

$setvar="set enable='".$enable."'  where contentid='".$var1."'";
update($dbname="neilperiodical_content",$set=$setvar);  



echo  $enable.','.$enableyext;
 
break; 	


    case "177":  //電子校刊儲存審核
//開啟neilperiodical_content
$contentList=moduledb($dbneme="neilperiodical_content",$where=" where `contentid` = '".$dbid."'    ");	
$userList=$userlist=moduledb($dbneme="neilperiodical_user",$where="  where `userid` = '".$contentList['userid']."'   ");

$timedate=timedate($datevar="Y-m-d H:i:s");

//期別項目管理權限(按照periodid)
$configvar=configvar($modulesid="neilperiodical");  	 
if(empty(neillibrary_modulesgrouppermission($conf_value=$configvar['neilperiodical9']))    && empty(grouppermission($dbneme="neilperiodical_period",$where=" where  `periodid` = '".$contentList['periodid']."'  order by  periodid  ASC",$var="admingroup",$typevar=true))) exit;

//儲存最新審核ID   
update($dbname="config",$set="set conf_value='".$dbid."'  where conf_name='neilperiodical12'");

if(!empty($type)){
//審核通過
$setvar="set review='".$xoopsUser->getVar('uid')."' ,  reviewtime='".$timedate."' ,  checks='".$type."' ,  reviewtext='".sqlinjectionfound($var=$var2)."'  where contentid='".$dbid."'";
update($dbname="neilperiodical_content",$set=$setvar);

//寫入投稿紀錄
$setvar="set  record = (".$userList['record']."+1)   where userid='".$contentList['userid']."'";
update($dbname="neilperiodical_user",$set=$setvar);  

//通知投稿人審核通過
neilperiodical_contentreviewreplyemail($contentid=$contentList['contentid'],$name=$contentList['name'],$type,$title=$contentList['title'],$timedate,$reviewtext=sqlinjectionfound($var=$var2),$usermail=$userList['email']);
}else{
//審核不通過
//通知投稿人審核不通過
neilperiodical_contentreviewreplyemail($contentid=$contentList['contentid'],$name=$contentList['name'],$type,$title=$contentList['title'],$timedate,$reviewtext=sqlinjectionfound($var=$var2),$usermail=$userList['email']);

//刪除內容圖檔
if($contentList['typesof']=='1' || $contentList['typesof']=='2'){
//刪除舊圖檔
$fileurl['b']=XOOPS_ROOT_PATH.'/uploads/'.$xoopsmodule.'/'.$contentList['periodid'].'file/project/'.$contentList['projectid'].'file/image/b_'.$contentList['img'].'.png';
$fileurl['s']=XOOPS_ROOT_PATH.'/uploads/'.$xoopsmodule.'/'.$contentList['periodid'].'file/project/'.$contentList['projectid'].'file/image/s_'.$contentList['img'].'.png';
foreach($fileurl as  $val){
fileadminfunction($fileurl=$val,$type="2",$fileex="",$from="");
}
}
//刪除內容
deletefunction($where=" where `contentid` = '".$contentList['contentid']."'",$DBname="neilperiodical_content");
}


   
   
echo $type; 

break;


case "178":    //變投候選容狀態 
$contentlist=moduledb($dbneme="neilperiodical_content",$where="  where `contentid` = '".$var1."'  ");
$configvar=configvar($modulesid="neilperiodical");
//管理權限
if(empty(neillibrary_modulesgrouppermission($conf_value=$configvar['neilperiodical9']))    && empty(grouppermission($dbneme="neilperiodical_period",$where=" where  `periodid` = '".$contentlist['periodid']."'  order by  periodid  ASC",$var="admingroup",$type=true))) exit;
$setvar="set checks='".$enable."'  where contentid='".$var1."'";
update($dbname="neilperiodical_content",$set=$setvar);
echo  $enable;
break;	


case "179":    //AJAX長輪詢監控-控制未審核/候選操作
	
//期別項目管理權限(按照periodid)
$configvar=configvar($modulesid="neilperiodical");
if(empty(neillibrary_modulesgrouppermission($conf_value=$configvar['neilperiodical9']))    && empty(grouppermission($dbneme="neilperiodical_period",$where=" where  `periodid` = '".$var1."'  order by  periodid  ASC",$var="admingroup",$typevar=true))) exit;

if(empty($timedate))exit();
set_time_limit(0);
//無限請求超時時間      
$i=0;
//開啟neilperiodical_period資料表
//開啟neilperiodical_project資料表
$showdate=neilperiodical_datamanagement($periodid=$var1,$projectid=$var2,$showdate);
if(!empty($var1)) $periodDB=" `periodid` = '".$var1."' and";
if(!empty($var2)) $projectDB=" `projectid` = '".$var2."' and";
$dbneme="neilperiodical_content";
while (true) {
	usleep(500000);
	//0.5秒     
	$i++;

    //未審核 
    $countvar2 = is_array(databasetablewhile($dbneme,$where=" where ".$periodDB.$projectDB."  (`checks` = '0' || `checks` = '2' ) ")) ? count(databasetablewhile($dbneme,$where=" where ".$periodDB.$projectDB."  (`checks` = '0' || `checks` = '2')  ")) : 0 ;
	//若得到數據則返回前端，並結束本次查詢      
	if($countvar2!=$var3) {
	//已審核        
	$countvar1 = is_array(databasetablewhile($dbneme,$where=" where ".$periodDB.$projectDB."  `checks` = '1' and `typesof` != '4' ")) ? count(databasetablewhile($dbneme,$where=" where ".$periodDB.$projectDB." `checks` = '1' and `typesof` != '4' ")) : 0 ;
		if(!empty($var2)) {
			//項目有值
			//變更徵稿數量
			if($countvar1 > $showdate['project']['quantity']) {
				$setvar="set quantity='".$countvar1."'  where projectid='".$var2."'";
				update($dbname="neilperiodical_project",$set=$setvar);
				$showdate['project']['quantity']=$countvar1;
			}
			//未審核(包含候選)		
			$auditdata="<div class='text-center alert alert-warning ' role='alert'>".sprintf(_MD_PERIODADMINPHP196,$showdate['project']['quantity'],$countvar1,$countvar2,($showdate['project']['quantity']-$countvar1))."</div>";
		} else {
			//項目空值
			$auditdata="<span id='auditedvar'  style='display: none;'>".$countvar2."</span></div>";
		}
		//開啟最新一筆審核ID
		$contentlist=moduledb($dbneme="config",$where=" where `conf_name` = 'neilperiodical12' ");
		
	//	$contentlist=configvar($modulesid="neilperiodical");		
		$state=1;
		echo  $state.','.$auditdata.','.$contentlist['conf_value'];
		unset($countvar1,$countvar2,$auditdata,$contentlist);
		//刪除變數
		exit();
	}
	//伺服器($timedate*0.5)秒後告訴前端無數據      
	if($i==$timedate) {
		$state=0;
		echo   $state.','.false;
		exit();
	}
}
break;


case "180":    //AJAX長輪詢監控審核-萬用
	
$ListDB=moduledb($dbneme=$var4,$where=" where `centerid` = '".$var1."' ");


switch($xoopsmodule) {
	case "neilsignedup_a":
	//權限	
    if(($xoopsUser->getVar('uid')!=$ListDB['uid']  || empty(grouppermission($dbneme=$var4,$where=" where  `sortid` = '".$ListDB['sortid']."' order by  sortid  ASC",$var="admingroup",$types=true))) && empty($isAdmin) ) exit;
	if(empty($ListDB['enable'])) exit; //狀態判斷		
	$text=_MD_SIGNEDUPCENTERPHP240;
	$conf_name='neilsignedup_a16';
	$wherevar=" where `centerid` = '".$var1."' and `sortid` = '".$ListDB['sortid']."' and  `checks` = '0'  ";
	$dbnemevar='neilsignedup_a_apply';
	break;
	case "neilsignedup_c":
	//權限	
    if(($xoopsUser->getVar('uid')!=$ListDB['uid']  || empty(grouppermission($dbneme=$var4,$where=" where  `sortid` = '".$ListDB['sortid']."' order by  sortid  ASC",$var="admingroup",$types=true))) && empty($isAdmin) ) exit;
	if(empty($ListDB['enable'])) exit; //狀態判斷	
	$text=_MD_SIGNEDUPCENTERPHP213;
	$conf_name='neilsignedup_c15';
	$wherevar=" where `centerid` = '".$var1."' and `sortid` = '".$ListDB['sortid']."' and  `checks` = '0'  ";
	$dbnemevar='neilsignedup_c_apply';
	break;
	case "neilmfdcms":
	if($var4=='neilmfdcmscenter'){	
	//權限	
    if(empty(admingroupfunction($dbneme1="neilmfdcmstypes",$where=" where `typesid` = '".$ListDB['typesid']."' && `enable` = '1'  " ,$admintype="admingroup")) &&  (!empty($xoopsUser) && $ListDB['uid']!=$xoopsUser->getVar('uid'))  &&  empty(admingroupfunction($dbneme="neilmfdcmscenter",$where=" where `typesid` = '".$ListDB['typesid']."' && `centerid` = '".$ListDB['centerid']."'",$admintype="browsegroup")) ) exit;
	if(empty($ListDB['enable'])) exit; //狀態判斷	
	$wherevar=" where `centerid` = '".$var1."'  ";
	$dbnemevar='neilmfdcmsreplydata';
	}	
	
	break;
    default:
    if(empty($isAdmin)) exit;

}

if(empty($timedate))exit();
set_time_limit(0);
//無限請求超時時間      
$i=0;  

switch($operate){
  case "1":
//內容編輯刪除監控-開始
while (true) {
	usleep(500000);
	//0.5秒     
	$i++;
	//取得內容數
	$countvar = is_array(databasetablewhile($dbneme=$dbnemevar,$where=$wherevar)) ? count(databasetablewhile($dbneme=$dbnemevar,$where=$wherevar)) : 0 ;
	//若得到數據則返回前端，並結束本次查詢      
   if($countvar > $var3) {
   	   //監控新增
	   //開啟最新一筆新增ID
		$contentlist=moduledb($dbneme=$var4,$where=" where `centerid` = '".$var1."' ");
		$replyid=$contentlist['newreplyid'];
		//留言統計資料
        $countbar=neilmfdcms_statisticaldata($centerid=$var1,$soid="",$stype="",$record=true);              
        $state=1;
        if(!empty($contentlist['grouplist'])  &&  !empty(neilmfdcms_removevisitorsuser()) && !empty(neilmfdcms_groupmessagelist($replygroup=$ListDB['replygroup'],$centerid=$ListDB['centerid']))){
        $grouplistcontent=neilmfdcms_groupmessagelist($replygroup=$ListDB['replygroup'],$centerid=$ListDB['centerid'],$replystatus=$ListDB['replystatus']); //留言統計資料	
        $replystatusbox=neilmfdcms_replystatusfunction($centerid=$ListDB['centerid']);  //回覆狀態
        }       
        echo  $state.','.$replyid.','.sprintf(_MD_MFDCMSCENTERPHP93,$countbar['0'],$countbar['1'],$countbar['2']).','.$var1.','.$grouplistcontent['box'].','.$replystatusbox;      
       	unset($countvar,$replyid,$countbar,$state,$contentlist,$grouplistcontent,$replystatusbox); 
    	//刪除變數		
     	exit();   
	}
   if($countvar < $var3) {
   	   //監控刪除
	   //開啟最新一筆刪除ID
		$contentlist=moduledb($dbneme=$var4,$where=" where `centerid` = '".$var1."' ");
		$replyid=$contentlist['deletereplyid'];
		//留言統計資料
        $countbar=neilmfdcms_statisticaldata($centerid=$var1,$soid="",$stype="",$record=true);              
        $state=2;
        if(!empty($contentlist['grouplist'])  &&  !empty(neilmfdcms_removevisitorsuser()) && !empty(neilmfdcms_groupmessagelist($replygroup=$ListDB['replygroup'],$centerid=$ListDB['centerid']))){
        $grouplistcontent=neilmfdcms_groupmessagelist($replygroup=$ListDB['replygroup'],$centerid=$ListDB['centerid'],$replystatus=$ListDB['replystatus']); 	//留言統計資料
        $replystatusbox=neilmfdcms_replystatusfunction($centerid=$ListDB['centerid']);  //回覆狀態
        }
        echo  $state.','.$replyid.','.sprintf(_MD_MFDCMSCENTERPHP93,$countbar['0'],$countbar['1'],$countbar['2']).','.$var1.','.$grouplistcontent['box'].','.$replystatusbox;    
       	unset($countvar,$replyid,$countbar,$state,$contentlist,$replystatusbox); 
    	//刪除變數		
     	exit();   
	}
	
	   if(!empty(neilmfdcms_statisticaldata($centerid=$var1,$soid=$var5,$stype="1"))) {
	    //監控統計數據變更
	    $state=3;
	   	//留言統計資料
        $countbar=neilmfdcms_statisticaldata($centerid=$var1);   
        echo  $state.','.sprintf(_MD_MFDCMSCENTERPHP93,$countbar['0'],$countbar['1'],$countbar['2']);    
       	unset($state,$countbar); 
        exit();            
	   }
	
	
	
	//伺服器($timedate*0.5)秒後告訴前端無數據      
	if($i==$timedate) {
		$state=0;
		echo   $state.','.false;
		exit();
	}
	
}
//內容編輯刪除監控-結束   
  break;
  
  default:
  	  
//審核操作監控-開始  
while (true) {
	usleep(500000);
	//0.5秒     
	$i++;
	//未審核 
	$countvar = is_array(databasetablewhile($dbneme=$dbnemevar,$where=$wherevar)) ? count(databasetablewhile($dbneme=$dbnemevar,$where=$wherevar)) : 0 ;
	//若得到數據則返回前端，並結束本次查詢      
	if($countvar!=$var3) {
		//開啟資料表取得新數據	    
		$ListDBnews=moduledb($dbneme=$var4,$where=" where `centerid` = '".$var1."' ");
		$auditdata="<div class='text-center alert alert-warning ' role='alert'>".sprintf($text,$ListDBnews['cansignup'],$ListDBnews['registered'],$countvar,($ListDBnews['cansignup']-$ListDBnews['registered']))."</div>";
		//開啟最新一筆審核ID
		$contentlist=moduledb($dbneme="config",$where=" where `conf_name` = '".$conf_name."' ");
		$state=1;
		echo  $state.','.$auditdata.','.$contentlist['conf_value'];
		unset($countvar,$auditdata,$contentlist,$ListDBnews);
		//刪除變數
		exit();
	}
	//伺服器($timedate*0.5)秒後告訴前端無數據      
	if($i==$timedate) {
		$state=0;
		echo   $state.','.false;
		exit();
	}
}
//審核操作監控-結束


  
}


break;




case "181":    //寫入cookies	
//建立cookie
$configvar=configvar($modulesid="neillibrary");
$httponly= XOOPS_PROT=='http://' ? false : true; // get TRUE
//建立cookieid
if(empty($_COOKIE['neil']['cookieid'])){
$backvar[0]=setcookie("neil[cookieid]", "cid_".timedate($datevar=timedate($datevar="Y-m-d H:i:s"),$type="5")."_".rand(0,999), strtotime( '+'.$configvar['neillibrary2'].' days' ), "/", XOOPS_COOKIE_DOMAIN, $httponly);
$backvar[1]="<div style='font-size: 150%' class='text-center alert alert-info' role='alert'><span class='glyphicon glyphicon-exclamation-sign' aria-hidden='true'></span> "._MS_SHARED197."</div>";
} 

echo json_encode($backvar);	
break;	
  

case "182":    //課表管理者初始化
//管理員權限
if(empty($isAdmin)) exit;  

$emptyArr=databasetablewhile($dbneme="neilcurriculumcontent",$where=" order by  curriculumid  DESC");  
foreach($emptyArr as $key=> $val){
$setvar="set uid='0'  where curriculumid='".$emptyArr[$key]['curriculumid']."'";
update($dbname="neilcurriculumcontent",$set=$setvar);  
}
	
	
break;	 	


case "183":    //內容管理儲存留言
	
//機器人IP判斷
if(!empty(robottimeip($type="2"))) $robot=true;	
	
//機器人檢查
if(empty(alignmenturl())){ 
robottimeipwrite($type="1"); 
$robot=true;	
}
if($enable==='0' or $enable==='1') $enablevar=true;
if(empty($enablevar)){ 
robottimeipwrite($type="1"); 
$robot=true;
}

if(empty($var1) or  empty(defenserobot($var=$var1,$type=2))){
robottimeipwrite($type="1"); 
$robot=true;
}

//機器人關閉JS判斷
if(!empty(robottimeip($type="1"))) $robot=true;		

//人工時間驗證
if(empty($enablevar) or  empty(robottime($var=$enable))) $robot=true;	
	


if(!empty($robot)){
echo $box="<div class='alert alert-purple alertbrowsetext text-center' role='alert'><span class='glyphicon glyphicon-remove' aria-hidden='true'></span> "._MS_SHARED75."</div>";
exit;
}


//重複貼文判斷
$wherevar=!empty($xoopsUser) ? "where `centerid` = '".$dbid."' && `uid` = '".$xoopsUser->getVar('uid')."'" : "where `centerid` = '".$dbid."' && (`ip` = '".get_real_ip()."' &&  `cookieid` = '".$_COOKIE['neil']['cookieid']."')"; // get TRUE
$rubbish=neillibrary_rubbishmessage($dbneme="neilmfdcmsreplydata",$where=$wherevar,$cvar=$reviewtext,$kname="rcontent",$modulesid="neillibrary",$configkey="neillibrary12");


if(!empty($rubbish)){
echo $box="<div class='alert alert-purple alertbrowsetext text-center' role='alert'><span class='glyphicon glyphicon-remove' aria-hidden='true'></span> "._MS_SHARED201."</div>";
exit;
}




//開啟neilmfdcmscenter資料表
$centerlist=moduledb($dbneme="neilmfdcmscenter",$where="  where `centerid` = '".$dbid."' && `enable` = '1'  ");
$typeslist=moduledb($dbneme="neilmfdcmstypes",$where="  where `typesid` = '".$centerlist['typesid']."'  ");

//未啟用留言功能停止執行
if(empty($centerlist['messageyn'])) exit;


$uid=!empty($xoopsUser) ? $xoopsUser->getVar('uid') : '0'; // get TRUE
$configvar=configvar($modulesid="neilmfdcms");
	
 //類別觀看權限
if(empty(admingroupfunction($dbneme="neilmfdcmstypes",$where=" where `typesid` = '".$centerlist['typesid']."' && `enable` = '1'  ",$admintype="browsegroup")) ) exit;
//分類觀看權限
if(empty(grouppermission($dbneme="neilmfdcmssort",$where="  where `typesid` = '".$centerlist['typesid']."' &&  `sortid` = '".$centerlist['sortid']."' order by  sortid  ASC",$var="browsegroup",$type=true)) &&  empty(admingroupfunction($dbneme="neilmfdcmstypes",$where=" where `typesid` = '".$centerlist['typesid']."'  && `enable` = '1'  ",$admintype="admingroup")) ) exit;
//判斷分類是否啟用
if((!empty(sorttruefunction($dbneme="neilmfdcmssort",$centerlist['sortid'])) ) && empty(admingroupfunction($dbneme="neilmfdcmstypes",$where=" where `typesid` = '".$centerlist['typesid']."' && `enable` = '1'  ",$admintype="admingroup"))) exit;
//內文瀏覽權限
if(empty(admingroupfunction($dbneme1="neilmfdcmstypes",$where=" where `typesid` = '".$centerlist['typesid']."' && `enable` = '1'  " ,$admintype="admingroup")) &&  $centerlist['uid']!=$uid  &&  empty(admingroupfunction($dbneme="neilmfdcmscenter",$where=" where `typesid` = '".$centerlist['typesid']."' && `centerid` = '".$centerlist['centerid']."'",$admintype="browsegroup")) ) exit;
//內文回覆權限
if(empty(admingroupfunction($dbneme1="neilmfdcmstypes",$where=" where `typesid` = '".$centerlist['typesid']."' && `enable` = '1'  " ,$admintype="admingroup")) &&  $centerlist['uid']!=$uid  &&  empty(admingroupfunction($dbneme="neilmfdcmscenter",$where=" where `typesid` = '".$centerlist['typesid']."' && `centerid` = '".$centerlist['centerid']."'",$admintype="replygroup")) ) exit;
//必填欄位驗證
if(empty($reviewtext)) exit;
//訪客cookie判斷
if(empty($uid) && empty($_COOKIE['neil']['cookieid'])) exit;

//字數判斷
if(mb_strlen(phpstrip_tags($notags=sqlinjectionfound($val=$reviewtext)), "utf-8") > $configvar['neilmfdcms10']) exit;

$check=!empty($check) ? $check : '0'; // get TRUE




if($operate=='edit'){
//編輯
//權限
$box=neilmfdcms_removepermission($varid="neilmfdcmsreplydata",$uid=$xoopsUser->getVar('uid'),$dbid=$var2,$operate);
//儲存
if(empty($box)){
$setvar="set rcontent='".sqlinjectionfound($var=neillibrary_textprocessing($val=$reviewtext,$item="1"),$coderemove=true)."' ,  private='".$check."'  where replyid='".$var2."'";
update($dbname="neilmfdcmsreplydata",$set=$setvar);  
$box="<div class='alert alert-purple alertbrowsetext text-center' role='alert'><span class='glyphicon glyphicon glyphicon-ok' aria-hidden='true'></span> "._MD_MFDCMSCENTERPHP90."</div>";

}


}else{
//新增

$valuesvar="(centerid,replytime,rcontent,uid,ip,cookieid,private) values('".$dbid."',current_timestamp(),'".sqlinjectionfound($var=neillibrary_textprocessing($val=$reviewtext,$item="1"),$coderemove=true)."','".$uid."','".get_real_ip()."','".$_COOKIE['neil']['cookieid']."','".$check."')";	  
$replyid=insert($dbname="neilmfdcmsreplydata",$values=$valuesvar);

//需增加啟用留言功能判斷
//如果沒開啟群組名單更新統計數據
if($typeslist['types']=='4'){
if(empty($centerlist['grouplist']) && !empty(neilmfdcms_removevisitorsuser()))  neilmfdcms_groupmessagelist($replygroup=$centerlist['replygroup'],$centerid=$centerlist['centerid'],$replystatus=$centerlist['replystatus']);
}

//紀錄新增ID
$setvar="set   newreplyid='".$replyid."'  where centerid='".$dbid."'";
update($dbname="neilmfdcmscenter",$set=$setvar);  

if(!empty($replyid)){
$box="<div class='alert alert-purple alertbrowsetext text-center' role='alert'><span class='glyphicon glyphicon glyphicon-ok' aria-hidden='true'></span> "._MD_MFDCMSCENTERPHP80."</div>";

//寄送通知->對象 管理員/類別管理群 / 發文者
$userslist=moduledb($dbneme="users",$where="  where `uid` = '".$centerlist['uid']."'  ");
neilmfdcms_contentreplymail($typesid=$centerlist['typesid'],$centerid=$centerlist['centerid'],$sortid=$centerlist['sortid'],$replyid,$getGroupid=$typeslist['admingroup'],$usermail=$userslist['email'],$timedate=timedate($datevar="Y-m-d H:i:s"),$name=XoopsUser::getUnameFromId($uid,1),$title=$centerlist['title']);
}

$box=$box.','.$replyid;

}








echo $box;




break;	 	


case "184":    //會員註冊ID及E-MAIL判斷
global $xoopsConfigUser;	

if(!empty($xoopsUser)) exit;

//登入後返回頁面連結	
switch($var3){
  case "neilsignedup_a":
$url=XOOPS_URL."/user.php?xoops_redirect=/modules/".$var3."/signedupcenter.php?url=".base64_encode('?op=signup&centerid='.$var1.'&sortid='.$var2.'')."";
  break;
  case "neilsignedup_c":
$url=XOOPS_URL."/user.php?xoops_redirect=/modules/".$var3."/signedupcenter.php?url=".base64_encode('?op=signup&centerid='.$var1.'&sortid='.$var2.'')."";
  break;
  case "neilproduct":
$url=XOOPS_URL."/user.php?xoops_redirect=/modules/".$var3."/shopwcase.php?url=".base64_encode('?op=commconsult')."";
  break;
  default:
  //預設動作
}

//$url=XOOPS_URL."/user.php?xoops_redirect=/modules/neilsignedup_c/signedupcenter.php?url=".base64_encode('?op=signup&centerid='.$var1.'&sortid='.$var2.'')."";

//判斷帳號字數長短
//註冊會員設定
$config_handler  = xoops_getHandler('config');
$xoopsConfigUser = $config_handler->getConfigsByCat(XOOPS_CONF_USER);


//判斷帳號長度-最小
if($type=='1' && mb_strlen($dbid, "utf-8") < $xoopsConfigUser['minuname']){
$box="<div class='alert alert-pink' role='alert'>".sprintf(_MS_REGISTERUSER10,mb_strlen($dbid, "utf-8"),$xoopsConfigUser['minuname'])."</div>";
}

//判斷帳號長度-最大
if($type=='1' && mb_strlen($dbid, "utf-8") > $xoopsConfigUser['maxuname']){
$box="<div class='alert alert-pink' role='alert'>".sprintf(_MS_REGISTERUSER11,mb_strlen($dbid, "utf-8"),$xoopsConfigUser['maxuname'])."</div>";
}

//判斷重複帳號
if($type=='1' && !empty(moduledb($dbneme="users",$where="   where `uname` = '".$dbid."'"))){
$box="<div class='alert alert-pink' role='alert'>".sprintf(_MS_REGISTERUSER06,$dbid,$url)."</div>";
} 

//判斷密碼長度-最小
if($type=='2' && mb_strlen($dbid, "utf-8") < $xoopsConfigUser['minpass']){
$box="<div class='alert alert-pink' role='alert'>".sprintf(_MS_REGISTERUSER12,mb_strlen($dbid, "utf-8"),$xoopsConfigUser['minpass'])."</div>";
}

//判斷重複E-MAIL
if($type=='3' && !empty(moduledb($dbneme="users",$where="   where `email` = '".$dbid."'"))){
$box="<div class='alert alert-pink' role='alert'>".sprintf(_MS_REGISTERUSER07,$dbid,$url)."</div>";
} 
	


echo $box;





break;	 

case "185":    //刪除區塊代表圖-共用
//管理員權限
if(empty($isAdmin)) exit;  	

//刪除圖檔
if(file_exists(XOOPS_ROOT_PATH.'/uploads/'.$var1)){
 unlink(XOOPS_ROOT_PATH.'/uploads/'.$var1);//將檔案刪除
} 


break;	 
 
 
 
//刪除自訂表單檔案
case "186":    
 //權限設定  	  
switch($xoopsmodule) {
	case "neilsignedup_a":
	$ListDB=moduledb($dbneme="neilsignedup_a_center",$where="   where `centerid` = '".$dbid."'   ");
	if(empty(neilsignedup_a_applicantfunction($uid=$xoopsUser->getVar('uid'),$applyid=$pageid)) && (($xoopsUser->getVar('uid')!=$ListDB['uid']  || empty(grouppermission($dbneme="neilsignedup_a_sort",$where=" where  `sortid` = '".$ListDB['sortid']."' order by  sortid  ASC",$var="admingroup",$type=true))) && empty($isAdmin)) ) exit;
	break;
	case "neilproduct":
    if(empty(neilproduct_authority($pageid))  && empty($isAdmin))exit;
	break;
	default:
    exit;
}
$ListDB2=moduledb($dbneme=$var3,$where="   where `".$var4."` = '".$pageid."'   ");
//字串轉陣列
$namefileArr=phpconversion($conversion=$ListDB2['field'],$type="unserialize");
foreach($namefileArr as $key=> $val) {
	if($namefileArr[$key]['fypeoption']=='7') {
		foreach($namefileArr[$key]['fieldval'] as $i=> $va2) {
			if($va2['filename']==$var1) {
				//刪除陣列
				unset($namefileArr[$key]['fieldval'][$i]);
				//刪除實體檔案
				fileadminfunction($fileurl=XOOPS_ROOT_PATH.'/uploads/'.$var2.'/'.$var1.'',$type="2",$fileex="",$from="",$fileurlnew="",$exclude="");
			}
		}
	}
}
$setvar="set field='".phpconversion($conversion=array_values($namefileArr),$type="serialize")."'   where ".$var4."='".$pageid."'";
update($dbname=$var3,$set=$setvar);
break;
 
 
 
//自訂表單檔案上傳驗證 
case "187":    
//數量
$quantity = is_array($_FILES['file']['name']) ? count($_FILES['file']['name']) : 0 ;
if($quantity > $var1) {
	$harmful.="<div class='alert alert-yellow-customize' role='alert'>".sprintf(_MS_CUSTOMFIELD45,$var1,$quantity)."</div>";
}
//字串轉陣列	
foreach($_FILES['file']['tmp_name'] as $i=> $val) {
	//檢測文件的 MIME 內容類型	
	$mime_type = mime_content_type($val);
	//可上傳MIME類型
	foreach($fieldArr=phpconversion($conversion=$var2,$type="unserialize") as $val) {
		switch($val) {
			case "1":
			//圖片類型檔案						
			$allowed_file_types = ['image/png', 'image/jpeg','image/gif'];
			break;
			case "2":
			//文件類型檔案
			$allowed_file_types = ['application/msword','application/vnd.ms-excel','application/vnd.ms-powerpoint','application/pdf','application/vnd.openxmlformats-officedocument.presentationml.presentation','application/vnd.openxmlformats-officedocument.wordprocessingml.document','application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'];
			break;
		}
	}
	if(empty($fieldArr)  ||   (!empty($fieldArr['0']) &&  !empty($fieldArr['1']))) {
		$allowed_file_types = ['image/png', 'image/jpeg','image/gif','application/msword','application/vnd.ms-excel','application/vnd.ms-powerpoint','application/pdf','application/vnd.openxmlformats-officedocument.presentationml.presentation','application/vnd.openxmlformats-officedocument.wordprocessingml.document','application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'];
	}
	if (!in_array($mime_type, $allowed_file_types)) {
		// File type is NOT allowed.
		$failed.='<span class="glyphicon glyphicon-remove" aria-hidden="true"></span> '.$_FILES['file']['name'][$i].'<br />';
	}
}
if(!empty($failed))	$harmful.="<div class='alert alert-red-customize' role='alert'>".sprintf(_MS_CUSTOMFIELD46,$failed)."<p><p><button id='cleardata' type='button' class='btn btn-success btn-block'>"._MS_SHARED247."</button></div>";
if(!empty($harmful)) $warnbox="<span   class='red ".$var3."'>"._MS_CUSTOMFIELD47."</span>";
echo $harmful.$warnbox;

break;
                      
case "188":
//禁止上傳檔案
//取出key
$nanekey=array_keys($_FILES);
$prohibit=neillibrary_donotuploadfiles($filevar=$_FILES[$nanekey[0]],$operate);
if(!empty($prohibit['harmful'])){
	$box="<div id='warningtext' class='alert alert-red-customize' role='alert'>
 	    	"._MS_SHARED235."<br />
			".$prohibit['name']."	
		    <p><p>
           <button id='cleardata' type='button' class='btn btn-success btn-block'>"._MS_SHARED247."</button>
		  </div>";	
    echo $box;
}                       
break;
 
case "189":
//多語言標籤產生區塊 
echo neillibrary_xLanguagetext();  
break;


case "190":  //刪除附件檔案(萬用)  
	 
//$var1=刪除檔案檔名	
//$var2=刪除檔案資料表	
//$var3=刪除檔案資料表主key
//$var4=刪除檔案欄位key	
	
//開啟資料表
$listval=moduledb($dbneme=$var2,$where="   where `".$var3."` = '".$dbid."' ");
//$configvar=configvar($xoopsmodule);

//權限
switch($xoopsmodule){
  case "neilsignedup_a":
  //發佈者判斷
  if($xoopsUser->getVar('uid')!=$listval['uid'] && empty($isAdmin)) exit;
  $path=XOOPS_ROOT_PATH.'/uploads/'.$xoopsmodule.'/'.$listval['sortid'].'file/';
  break;  
  case "neilsignedup_c":
  //發佈者判斷
  if($xoopsUser->getVar('uid')!=$listval['uid'] && empty($isAdmin)) exit;
  $path=XOOPS_ROOT_PATH.'/uploads/'.$xoopsmodule.'/'.$listval['sortid'].'file/';  
  break;
  case "neilmfdcms":
  //權限判斷
  if(($xoopsUser->getVar('uid')!=$listval['uid']  || empty(grouppermission($dbneme="neilmfdcmssort",$where=" where `typesid` = '".$listval['typesid']."' && `sortid` = '".$listval['sortid']."' order by  sortid  ASC",$var="admingroup",$type=true))) && empty(admingroupfunction($dbneme="neilmfdcmstypes",$where=" where `typesid` = '".$listval['typesid']."' && `enable` = '1'  ",$admintype="admingroup")) )exit;
  $path=XOOPS_ROOT_PATH.'/uploads/'.$xoopsmodule.'/types'.$listval['typesid'].'/'.$listval['sortid'].'file/file/'; 
  break;  
  case "neilhonorlist":
  //權限判斷
  if($xoopsUser->getVar('uid')!=$listval['honor_uid'] && empty($isAdmin)) exit;
  $path=XOOPS_ROOT_PATH.'/uploads/'.$xoopsmodule.'/file/';
  break;  
  case "neilproduct":
  //權限判斷
  if(empty($isAdmin)) exit;
  $path=XOOPS_ROOT_PATH.'/uploads/'.$xoopsmodule.'/'.$listval['sortid'].'file/';
  break;  
    
}

// 字串轉陣列
$Arr = phpconversion($conversion = $listval[$var4], $type = "unserialize");
foreach ($Arr['newname'] as $key => $val) {
    if ($val == $var1) {
        unset($Arr['newname'][$key]);
        unset($Arr['oldname'][$key]);
        fileadminfunction($fileurl=$path.$val, $type = "2", $fileex = "", $from = "", $fileurlnew = "", $exclude = "");
    }
}
//使用 array_values() 重新索引陣列
$Arr['newname'] = array_values($Arr['newname']);
$Arr['oldname'] = array_values($Arr['oldname']);

// 陣列轉字串並更新資料庫
$setvar = "set ".$var4."='".phpconversion($conversion = $Arr, $type = "serialize")."' where ".$var3."='" . $dbid . "'";
update($dbname = $var2, $set = $setvar);

break; 

                             
default:

}








function optionbox($sort="",$oid="",$dbneme="",$var2="",$type="",$typesid=""){
foreach($sort as $key=> $val){
$value=$sort[$key]['sortid'];



switch($var2){
  case "1":
if(!empty(grouppermission($dbneme,$where="  where `sortid` = '".$sort[$key]['sortid']."'  order by  sortid  ASC",$var="admingroup",$type)) ||  (!empty($typesid) && !empty(admingroupfunction($dbneme2="neilmfdcmstypes",$where=" where `typesid` = '".$typesid."' && `enable` = '1'  " ,$admintype="admingroup")))){	
$optionone.=optionselect($dataid=$sort[$key]['sortid'],$optionname=$sort[$key]['sorttitle'],$oid="".$oid."",$value=$value);
}
  break;
  
  case "2":
if(!empty(grouppermission($dbneme,$where="  where `sortid` = '".$sort[$key]['sortid']."'  order by  sortid  ASC",$var="browsegroup",$type)) ||  (!empty($typesid) && !empty(admingroupfunction($dbneme2="neilmfdcmstypes",$where=" where `typesid` = '".$typesid."' && `enable` = '1'  " ,$admintype="admingroup")))){	
$optionone.=optionselect($dataid=$sort[$key]['sortid'],$optionname=$sort[$key]['sorttitle'],$oid="".$oid."",$value=$value);
}
  break;  
  
  case "3":  //城市鄉鎮選單
$value=$sort[$key]['cityid'];  	  
$optionone.=optionselect($dataid=$sort[$key]['cityid'],$optionname=$sort[$key]['citytitle'],$oid="".$oid."",$value=$value);
  break;  
  
  case "4":  //年級班級選單
$value=$sort[$key]['classid'];  	  
$optionone.=optionselect($dataid=$sort[$key]['classid'],$optionname=$sort[$key]['classtitle'],$oid="".$oid."",$value=$value);
  break;  

  case "5":  //電子校刊項目選單
$value=$sort[$key]['projectid'];  	  
$optionone.=optionselect($dataid=$sort[$key]['projectid'],$optionname=$sort[$key]['projecttitle'],$oid="".$oid."",$value=$value);
  break;    
   
  default:
$optionone.=optionselect($dataid=$sort[$key]['sortid'],$optionname=$sort[$key]['sorttitle'],$oid="".$oid."",$value=$value);
}









}
return $optionone;
}

function optionbox2($sort="",$oid=""){
foreach($sort as $key=> $val){
$value=$sort[$key]['productid'];
$optionone.=optionselect($dataid=$sort[$key]['productid'],$optionname=$sort[$key]['productidtitle'],$oid="".$oid."",$value=$value);
}
return $optionone;
}	


exit; 
 
?>
