<?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'; //XOOPS檔頭
include_once "../function.php";	
include_once "../class/themeset.php";
//上傳圖檔
include_once XOOPS_ROOT_PATH."/modules/neillibrary/class/imguploader.php";	

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


//先建構class($themesetclass)
$themesetclass   = new  themesetclass;  
$topvsplit =$themesetclass-> themespublicb($variableok,$setting); 
list($variableok,$setting) = $topvsplit;

//切割$setting陣列內容
$variablesplit=cuttingfunction($cutting=$variableok,$sign=";"); 


switch ($op) {
	case "updated3":   
	redirect_header($_SERVER['PHP_SELF'].'?op=advertise3&menutype='.advertiseupdated3().'',0 , _MS_SHARED02);
	break;
	case "save_news3":   
	redirect_header($_SERVER['PHP_SELF'].'?op=advertise3&menutype='.advertisesave_news3().'',0 , _MS_SHARED02);
	break;
	case "advertise3":   
	$main=advertise_table03();
	break;
	case "advertise4":   
	$main=advertise_table04($mid=modulesmidvar($modulesid="neothemesadmin"));
	break;
	case "save_news4":   
	redirect_header($_SERVER['PHP_SELF'].'?op=advertise4&menutype='.advertisesave_news4().'',0 , _MS_SHARED02);
	break;
	case "updated4":   
	redirect_header($_SERVER['PHP_SELF'].'?op=advertise4&menutype='.advertiseupdated4().'',0 , _MS_SHARED02);
	break;
	
	case "updated2":   
	redirect_header($_SERVER['PHP_SELF'].'?op=advertise2&menutype='.advertiseupdated2().'',0 , _MS_SHARED02);
	break;
	case "save_news2":   
	redirect_header($_SERVER['PHP_SELF'].'?op=advertise2&menutype='.advertisesave_news2().'',0 , _MS_SHARED02);
	break;
	case "advertise2":   
	$main=advertise_table02();
	break;
	case "advertiseupdate01":   
    redirect_header($_SERVER['PHP_SELF'].'?menutype='.advertiseupdate01().'',0 , _MS_SHARED02);
	break;
	default:
	//GTM代碼管理
	$main=advertise_table01();
}

function advertise_menu(){
global $xoopsModule,$menutype; 	

switch($menutype){
  case "1":
$typecss1="active'";
  break;
  case "2":
$typecss2="active'";
  break;
  case "3":
$typecss3="active'";
  break;
  case "4":
$typecss4="active'";
  break;
  default:
$typecss1="active'";
}


$menu="	
<ul class='nav nav-pills'>
  <li class='nav-item' ><a class='nav-link ".$typecss1."' href='".XOOPS_URL."/modules/".$xoopsModule->getVar("dirname")."/admin/".basename(__FILE__)."?op=default&menutype=1'>"._MA_ADVERTISEPHP02."</a></li>
  <li class='nav-item' ><a class='nav-link ".$typecss2."' href='".XOOPS_URL."/modules/".$xoopsModule->getVar("dirname")."/admin/".basename(__FILE__)."?op=advertise2&menutype=2'>"._MA_ADVERTISEPHP03."</a></li>
  <li class='nav-item' ><a class='nav-link ".$typecss3."' href='".XOOPS_URL."/modules/".$xoopsModule->getVar("dirname")."/admin/".basename(__FILE__)."?op=advertise3&menutype=3'>"._MA_ADVERTISEPHP04."</a></li>
  <li class='nav-item'><a class='nav-link ".$typecss4."' href='".XOOPS_URL."/modules/".$xoopsModule->getVar("dirname")."/admin/".basename(__FILE__)."?op=advertise4&menutype=4'>"._MA_ADVERTISEPHP44."</a></li>
 </ul>
 <div class='w-100'></div>
";

  return $menu;
	}

function advertise_table04($mid=""){
global $xoopsDB,$xoopsModule,$menutype,$xoopsModuleConfig,$dgad;	


if(empty($dgad)){  
//新增
$dgad_form['1']="<h4>"._MA_ADVERTISEPHP45."</h4>";
$listval['enable']=1;
//POST類型
$dgad_form['7']="<input type='hidden' name='menutype' value='".$menutype."'><input type='hidden' name='op' value='save_news4'>";
}else{
//編輯
$dgad_form['1']="<h4>"._MA_ADVERTISEPHP46."</h4>";
//開啟lowerrightad資料表
//批次轉換htmlspecialchars
$listval=htmlspecialcharsbatch($allowvar=array("before_t","digital","after_t","side_t"),$eachvar=moduledb($dbneme="neil_digitalad",$where="  where `dgad` = '".$dgad."'"));
//POST類型
$dgad_form['7']="<input type='hidden' name='menutype' value='".$menutype."'><input type='hidden' name='dgad' value='".$listval['dgad']."'><input type='hidden' name='op' value='updated4'>";

}


//廣告標題
$dgad_form['2']=inputtext($class="",$name="before_t",$value="".$listval['before_t']."",$placeholder=""._MS_SHARED21._MA_ADVERTISEPHP47."");
//數字內容
$dgad_form['3']=inputtext($class="",$name="digital",$value="".$listval['digital']."",$placeholder=""._MS_SHARED21._MA_ADVERTISEPHP48."");
//廣告後結尾
$dgad_form['4']=inputtext($class="",$name="after_t",$value="".$listval['after_t']."",$placeholder=""._MS_SHARED21._MA_ADVERTISEPHP49."");
//廣告側標
$dgad_form['5']=inputtext($class="",$name="side_t",$value="".$listval['side_t']."",$placeholder=""._MS_SHARED21._MA_ADVERTISEPHP50."");
//是否啟用
$dgad_form['6']=radioinline($class="",$name="enable",$text=array(_MS_SHARED04,_MS_SHARED03),$checked="".$listval['enable'].""); 


//TABLE區塊	
foreach($Arr=databasetablewhile($dbneme="neil_digitalad",$where="  order by  btnsort  ASC")   as $key=> $val){
if($Arr[$key]['dgad']==$dgad) $colorstyle[$key]="color1";	
$dgad_form['9'].="
	    <tr class='deletetr{$key} tr ".$colorstyle[$key]."' id='".$Arr[$key]['dgad']."'  >
        <td>".$Arr[$key]['dgad']."</td>
        <td>".sprintf(_MA_ADVERTISEPHP53,$Arr[$key]['before_t'],"140%",$Arr[$key]['digital'],$Arr[$key]['after_t'],$Arr[$key]['side_t'])."</td>      
        <td>".enable($envar=$Arr[$key]['enable'])."</td>
        <td><a href='" .XOOPS_URL. "/modules/". $xoopsModule->getVar("dirname")."/admin/".basename(__FILE__)."?op=advertise4&menutype=".$menutype."&dgad=".$Arr[$key]['dgad']."'  class='btn btn-sm btn-info'>"._MS_SHARED08."</a>   
        <a id='deletebotton{$key}' type='button' mane='156,".$Arr[$key]['dgad'].",".$Arr[$key]['before_t'].$Arr[$key]['digital'].$Arr[$key]['after_t'].","._MA_ADVERTISEPHP24.",,neil_digitalad,".$xoopsModule->getVar("dirname").",,dgad'  class='btn btn-sm btn-danger   deleteeach'>"._MS_SHARED09."</a>     
        </tr>";
}

$dgad_form['8']="
<table class='table sortable basictable' name='164,".$xoopsModule->getVar("dirname").",".$menutype.",".$pageid.",".$typesid.",".$sortid.",".$suid.",neil_digitalad,dgad'>
<thead>
  <tr>     
      <th style='width: 6%'>"._MS_SHARED06."</th>
      <th>"._MA_ADVERTISEPHP52."</th>
      <th style='width: 12%'>"._MS_SHARED10."</th>  
      <th style='width: 18%'>"._MS_SHARED07."</th>  
 </tr>
</thead>
<tbody>
".$dgad_form['9']."
</tbody>
</table>
<p  class='help-block text-center'>"._MS_SHARED143."</p>	   		
";




$main.="
<div class='container'>
<h4>"._MA_ADVERTISEPHP44."&nbsp;<label for='sel2'>Digital Advertising management</label>&nbsp; <a class='btn btn-warning'  href='" . XOOPS_URL . "/modules/".$xoopsModule->getVar("dirname")."/admin/".basename(__FILE__)."?op=advertise4&menutype=4'>"._MS_SHARED25."</a> &nbsp; <a class='btn btn-info'  href='" . XOOPS_URL . "/modules/system/admin.php?fct=blocksadmin&op=list&filter=1&selgen=".$mid."&selmod=-1&selgrp=-1&selvis=-1'>"._MA_BLOCKMENUSORTPHP02."</a></h4>
<div class='row'>".advertise_menu()."  <br /> 		 	
";

    
//左邊區塊
$main.="

<div id='digitaladbox' class='col-md-4'>
<form method='post'  action='{$_SERVER['PHP_SELF']}'>		
".$dgad_form['1']."<hr />

<div  class='row'>	
<label class='col-md-4 control-label'>"._MA_ADVERTISEPHP47."</label>
<div class='col-md-8 '> ".$dgad_form['2']." 
<span id='required_before_t' class='red blockeach6'>"._MS_SHARED22."</span>
<br /><br /></div> 
</div>
 	
<div  class='row'>	
<label class='col-md-4 control-label'>"._MA_ADVERTISEPHP48."</label>
<div class='col-md-8 '> ".$dgad_form['3']." 
<span id='required_digital' class='red blockeach6'>"._MS_SHARED22."</span>
<br /><br /></div> 
</div>
 	
<div  class='row'>	
<label class='col-md-4 control-label'>"._MA_ADVERTISEPHP49."</label>
<div class='col-md-8 '> ".$dgad_form['4']." 
<span id='required_after_t' class='red blockeach6'>"._MS_SHARED22."</span>
<br /><br /></div> 
</div>
	
<div  class='row'>	
<label class='col-md-4 control-label'>"._MA_ADVERTISEPHP50."</label>
<div class='col-md-8 '> ".$dgad_form['5']." 
<span id='required_side_t' class='red blockeach6'>"._MS_SHARED22."</span>
<br /><br /></div> 
</div>
	
<div  class='row'>	
<label class='col-md-4 control-label'>"._MS_SHARED44."</label>
<div class='col-md-8 '> ".$dgad_form['6']." 
<br /><br /></div> 
</div> 
 
".$dgad_form['7']."		
<button  type='submit' disabled='disabled' class='btn btn-primary btn-lg btn-block contentbtn'>"._MS_SHARED01."</button>
<div id='help-blocktext' class='text-center'><span id='helpBlock' class='help-block'><span  class='red'>"._MS_SHARED30."</span></span></div>    
</form>  
</div>
	  
";

//右邊區塊 
$main.="
<div class='col-md-8'><h4>"._MA_ADVERTISEPHP51."</h4><hr />
".$dgad_form['8']."
</div>";

$main.="
</div>




<script>var itemsvar='.tr'; dragmenufunction();</script>  	  
<script>
    $('.basictable').basictable({
        breakpoint: 640,
        orceResponsive: true,
    });
</script>  
<script>neothemesadmin_digitalform();</script>
	";
	
	
  return $main;
}



function advertise_table03(){	
global $xoopsDB,$xoopsModule,$menutype,$xoopsModuleConfig,$rdad,$variablesplit;	

$img_date = date("H:i:s");
if(empty($rdad)){  //新增

$lowerrightad_table_form['7']="<h4>"._MA_ADVERTISEPHP31."</h4>";
//POST類型
$lowerrightad_table_form['8']="<input type='hidden' name='menutype' value='".$menutype."'><input type='hidden' name='op' value='save_news3'>";
$lowerrightad['enable']=1;
$lowerrightad['target']['0']=1;
$lowerrightad['target']['1']=1;
$lowerrightad['maturity']=timedate($datevar="Y-m-d");

}else{  //編輯
$lowerrightad_table_form['7']="<h4>"._MA_ADVERTISEPHP32."</h4>";


//開啟lowerrightad資料表
//批次轉換htmlspecialchars
$lowerrightad=htmlspecialcharsbatch($allowvar=array("title","url","maturity"),$eachvar=moduledb($dbneme="neil_lowerrightad",$where="  where `rdad` = '".$rdad."'"));

//廣告連結
$lowerrightad['url']=cuttingfunction($cutting=$lowerrightad['url'],$sign=",");
//已上傳圖片
$lowerrightad['imgid']=cuttingfunction($cutting=$lowerrightad['imgid'],$sign=",");



if(file_exists(XOOPS_ROOT_PATH.'/uploads/'.$xoopsModule->getVar("dirname").'/'.$lowerrightad['imgid']['0'].'.png')){
//已上傳圖片-右上
$lowerrightad_table_form['11']['0']="<div  class='form-group imgidboxrt'>
	 <div class='col-md-12'> 
   <div class='text-center'> <h4><span id='helpBlock' class='help-block'>"._MA_PLAYERADMINPHP12."</span></h4> </div> 	

    <div class='thumbnail '>   
        <img src='".XOOPS_URL."/uploads/".$xoopsModule->getVar("dirname")."/".$lowerrightad['imgid']['0'].".png?state=".$img_date."' >
      <a id='rtimgdelete' type='button' name='".$lowerrightad['imgid']['0']."'  class='btn btn-sm btn-danger  btn-block'>"._MA_ADVERTISEPHP42."</a>     
  	 </div>
     	 
		 <br /></div> 
</div>";
}
if(!empty($lowerrightad['imgid']['1'])){
//已上傳圖片-右下
$lowerrightad_table_form['11']['1']="<div id='imgidbox' class='form-group'>
	 <div class='col-md-12'> 
   <div class='text-center'> <h4><span id='helpBlock' class='help-block'>"._MA_PLAYERADMINPHP12."</span></h4> </div> 	

    <div class='thumbnail'>   
        <img src='".XOOPS_URL."/uploads/".$xoopsModule->getVar("dirname")."/".$lowerrightad['imgid']['1'].".png?state=".$img_date."' >
     </div>
		 <br /></div> 
</div>";
}

//連結開啟方式
$lowerrightad['target']=cuttingfunction($cutting=$lowerrightad['target'],$sign=",");

//POST類型
$lowerrightad_table_form['8']="<input type='hidden' name='menutype' value='".$menutype."'><input type='hidden' name='rdad' value='".$lowerrightad['rdad']."'><input type='hidden' name='op' value='updated3'>";
}

//是否啟用彈出廣告功能
$lowerrightad_table_form['0']=radioinline($class="",$name="neothemesadmin8",$text=array(_MS_SHARED04,_MS_SHARED03),$checked=$xoopsModuleConfig['neothemesadmin8']); 

//廣告標題
$lowerrightad_table_form['1']=inputtext($class="",$name="title",$value="".$lowerrightad['title']."",$placeholder=""._MS_SHARED21._MA_ADVERTISEPHP16."");

//廣告連結-上
$lowerrightad_table_form['2']=inputtext($class="",$name="urlArr[1]",$value="".$lowerrightad['url']['0']."",$placeholder=""._MS_SHARED21._MA_ADVERTISEPHP17."");

//上傳圖檔-上
$lowerrightad_table_form['3']=typefile($multiple=false,$name="upfile1",$id="blockimg0",$class="previeweach"); 

//連結開啟方式-上
$lowerrightad_table_form['4']=radioinline($class="",$name="targetArr[1]",$text=array(_MS_SHARED31,_MS_SHARED32),$checked=$lowerrightad['target']['0']); 


//廣告連結-下
$lowerrightad_table_form['13']=inputtext($class="",$name="urlArr[2]",$value="".$lowerrightad['url']['1']."",$placeholder=""._MS_SHARED21._MA_ADVERTISEPHP17."");

//上傳圖檔-下
$lowerrightad_table_form['14']=typefile($multiple=false,$name="upfile2",$id="blockimg1",$class="previeweach"); 

//連結開啟方式-上
$lowerrightad_table_form['15']=radioinline($class="",$name="targetArr[2]",$text=array(_MS_SHARED31,_MS_SHARED32),$checked=$lowerrightad['target']['1']); 




//到期時間
$lowerrightad_table_form['5']=inputtext($class="mydate",$name="maturity",$value="".$lowerrightad['maturity']."",$placeholder="".$lowerrightad['maturity']."",$id="mydate1");

//是否啟用
$lowerrightad_table_form['6']=radioinline($class="",$name="enable",$text=array(_MS_SHARED04,_MS_SHARED03),$checked="".$lowerrightad['enable'].""); 

//彈出廣告框顯示方式
$lowerrightad_table_form['12']=radioinline($class="",$name="neothemesadmin9",$text=array(_MA_ADVERTISEPHP25,_MA_ADVERTISEPHP26),$checked=$xoopsModuleConfig['neothemesadmin9']); 

//TABLE區塊	
foreach($lowerrightadArr=databasetablewhile($dbneme="neil_lowerrightad",$where="  order by  btnsort  ASC")   as $key=> $val){



$td['enable']=enable($envar=$lowerrightadArr[$key]['enable']);


$lowerrightadArr[$key]['target']=cuttingfunction($cutting=$lowerrightadArr[$key]['target'],$sign=",");	

//頁面開啟方式

$td['target'][$key]['1']=pagemethod($types=$lowerrightadArr[$key]['target']['1']);

$lowerrightadArr[$key]['imgid']=cuttingfunction($cutting=$lowerrightadArr[$key]['imgid'],$sign=",");	

if(file_exists(XOOPS_ROOT_PATH.'/uploads/'.$xoopsModule->getVar("dirname").'/'.$lowerrightadArr[$key]['imgid']['0'].'.png')){
$td['img'][$key]['0']="<div  style='width: 100%' class='thumbnail'><img  title='".$lowerrightadArr[$key]['title']."'  src='".XOOPS_URL."/uploads/".$xoopsModule->getVar("dirname")."/".$lowerrightadArr[$key]['imgid']['0'].".png?state=".$img_date."'></div>";
$td['target'][$key]['0']=pagemethod($types=$lowerrightadArr[$key]['target']['0']);
}else{
$td['img'][$key]['0']="<div  style='width: 100%' class='thumbnail'><img  title='".$lowerrightadArr[$key]['title']."'  src='".XOOPS_URL."/modules/".$xoopsModule->getVar("dirname")."/images/nocontent.png'></div>";
$td['target'][$key]['0']['text']=_MA_ADVERTISEPHP41;
}
$td['img'][$key]['1']="<div  style='width: 100%' class='thumbnail'><img  title='".$lowerrightadArr[$key]['title']."'  src='".XOOPS_URL."/uploads/".$xoopsModule->getVar("dirname")."/".$lowerrightadArr[$key]['imgid']['1'].".png?state=".$img_date."'></div>";




$rdadenable[$key]=radioinlinelist($dataid="1",$class="adenableeach",$name="adenable",$text="",$value=$lowerrightadArr[$key]['rdad'],$oid=$lowerrightadArr[$key]['adenable'],$id="adenable_".$lowerrightadArr[$key]['rdad']."");	

if($lowerrightadArr[$key]['rdad']==$rdad) $colorstyle[$key]="color1";


//判斷到期
if($lowerrightadArr[$key]['maturity'] < timedate($datevar="Y-m-d")) $maturityrext[$key]="<span style='font-size: 95%;' class='label label-danger'>"._MA_ADVERTISEPHP20."</span>";
	
$lowerrightad_table_form['10'].="<tr class='deletetr{$key} tr ".$colorstyle[$key]."' id='".$lowerrightadArr[$key]['rdad']."'  >
        <td>".$lowerrightadArr[$key]['rdad']."</td>
        <td>".$rdadenable[$key]."</td>
        <td>".$td['img'][$key]['0']."</td>
        <td>".$td['img'][$key]['1']."</td>
        <td>".$lowerrightadArr[$key]['title']."</td>      
        <td>".$lowerrightadArr[$key]['maturity'].$maturityrext[$key]."</td>    	
        <td>".$td['enable']."</td>
       <td>".sprintf(_MA_ADVERTISEPHP39,$td['target'][$key]['0']['text'])."<p>".sprintf(_MA_ADVERTISEPHP40,$td['target'][$key]['1']['text'])."</td>       	
        <td><a href='" .XOOPS_URL. "/modules/". $xoopsModule->getVar("dirname")."/admin/".basename(__FILE__)."?op=advertise3&menutype=".$menutype."&rdad=".$lowerrightadArr[$key]['rdad']."'  class='btn btn-sm btn-info'>"._MS_SHARED08."</a>   
     <a id='deletebotton{$key}' type='button' mane='156,".$lowerrightadArr[$key]['rdad'].",".$lowerrightadArr[$key]['title'].","._MA_ADVERTISEPHP24.",,neil_lowerrightad,".$xoopsModule->getVar("dirname").",,rdad'  class='btn btn-sm btn-danger   deleteeach'>"._MS_SHARED09."</a>     
     </tr>";
}

 
$lowerrightad_table_form['9']="
<table class='table sortable basictable' name='164,".$xoopsModule->getVar("dirname").",".$menutype.",".$pageid.",".$typesid.",".$sortid.",".$suid.",neil_lowerrightad,rdad'>
    <thead>
      <tr>
      
        <th style='width: 1%'>"._MS_SHARED06."</th>
        <th style='width: 1%'>"._MA_ADVERTISEPHP23."</th>
        <th style='width: 10%'>"._MA_ADVERTISEPHP37."</th>
        <th style='width: 10%'>"._MA_ADVERTISEPHP38."</th>
        <th style='width: 14%'>"._MA_ADVERTISEPHP16."</th>
        <th style='width: 10%'>"._MA_ADVERTISEPHP19."</th>
              <th style='width: 8%'>"._MS_SHARED10."</th>  
                    <th style='width: 15%'>"._MA_PLAYERADMINPHP05."</th>        
                 <th style='width: 15%'>"._MS_SHARED07."</th>  
      </tr>
    </thead>
    <tbody>
   ".$lowerrightad_table_form['10']."
     
    </tbody>
  </table>
   <p  class='help-block text-center'>"._MS_SHARED143."</p>	   		
";
 
 
 
$main.="

	<div class='container'>
  <h4>"._MA_ADVERTISEPHP28."&nbsp;<label for='sel2'>Floating ad management</label>&nbsp; <a class='btn btn-warning'  href='" . XOOPS_URL . "/modules/".$xoopsModule->getVar("dirname")."/admin/".basename(__FILE__)."?op=advertise3&menutype=3'>"._MS_SHARED25."</a></h4>
    <div class='row'>
  	".advertise_menu()."   		 	
    ";
    
$main.="<br /> <div class='col-md-12'>
	<div class='alert alert-info' role='alert'><br />
	    <h5 class='row'>
    <label class='col-md-3  control-label'>"._MA_ADVERTISEPHP29."</label>   
     <div class='col-md-3 '>
    ".$lowerrightad_table_form['0']."<br /><br />
    </div>     
    

    <label class='col-md-3  control-label'>"._MA_ADVERTISEPHP30."</label>   
     <div class='col-md-3 '>
    ".$lowerrightad_table_form['12']."<br /><br />
    </div>     
     	   
     <div class='col-md-12'>
     
    <button type='button' class='btn btn-primary btn-block popbtn'>"._MS_SHOPPINGCART48."</button>
    </div>    
   </h5> </div></div><script>neothemesadmin_lowerrightad_ny();</script>
  "; 
    
//左邊區塊
$main.="

  <div id='lowerrightadbox' class='col-md-4'>
 <form method='post'  action='{$_SERVER['PHP_SELF']}' enctype='multipart/form-data'>	 	  
  	  ".$lowerrightad_table_form['7']."<hr />
 
 

<div  class='row'>	
<label class='col-md-3 control-label'>"._MA_ADVERTISEPHP16."</label>
 		 <div class='col-md-9'> ".$lowerrightad_table_form['1']." 
 	<span id='helpBlocktitle' class='red blockeach6'>"._MS_SHARED22."</span>
  	   <br /><br /></div> 
 	 	</div>
 
 
<div  class='row'>	
<label class='col-md-3 control-label'>"._MA_ADVERTISEPHP19."</label>
 		 <div class='col-md-9'> ".$lowerrightad_table_form['5']." 
 <span id='helpBlock' class='help-block'>"._MA_ADVERTISEPHP21."</span>
 	<span id='helpBlockmaturity' class='red blockeach6'>"._MS_SHARED22."</span>
  	   <br /><br /></div> 
 	 	</div> 
 
 <div  class='row'>	
<label class='col-md-3 control-label'>"._MS_SHARED44."</label>
 		 <div class='col-md-9'> ".$lowerrightad_table_form['6']." 
  	   <br /><br /><br /></div> 
 		</div> 	
 		
<h4>"._MA_ADVERTISEPHP34."</h4>
<hr />	
 
 	
<div  class='row'>	
<label class='col-md-3 control-label'>"._MA_ADVERTISEPHP17."</label>
 		 <div class='col-md-9'> ".$lowerrightad_table_form['2']." 
  	   <br /></div> 
 		</div> 	
 	
 	

  <div class='row'>
    <label class='col-md-3 control-label'>"._MA_ADVERTISEPHP18."</label>   
     <div class='col-md-9'>
    ".$lowerrightad_table_form['3']." 
 <span id='helpBlock' class='help-block'>".sprintf(_MA_ADVERTISEPHP35,$variablesplit['21'])."</span>     
     <div class='preview0' ></div>  
<br />
           </div> </div>
".$lowerrightad_table_form['11']['0']."

 
 
<div  class='row'>	
<label class='col-md-3 control-label'>"._MA_BLOCKMENUSORTPHP13."</label>
 		 <div class='col-md-9'> ".$lowerrightad_table_form['4']." 
  	   <br /><br /><br /></div> 
 		</div> 	 
 
 
<h4>"._MA_ADVERTISEPHP33."</h4>
<hr />	 
 
<div  class='row'>	
<label class='col-md-3 control-label'>"._MA_ADVERTISEPHP17."</label>
 		 <div class='col-md-9'> ".$lowerrightad_table_form['13']." 
  	   <br /></div> 
 		</div> 	 
 	
 	
  <div class='row'>
    <label class='col-md-3 control-label'>"._MA_ADVERTISEPHP18."</label>   
     <div class='col-md-9'>
    ".$lowerrightad_table_form['14']." 
   <span id='helpBlock' class='help-block'>".sprintf(_MA_ADVERTISEPHP35,$variablesplit['22'])."</span>         
      	<span id='helpBlockimgid' class='red blockeach6'>"._MS_SHARED22."</span> 
     <div class='preview1' ></div>  
<br />
           </div> </div>
".$lowerrightad_table_form['11']['1']."
 	
 	
<div  class='row'>	
<label class='col-md-3 control-label'>"._MA_BLOCKMENUSORTPHP13."</label>
 		 <div class='col-md-9'> ".$lowerrightad_table_form['15']." 
  	   <br /><br /><br /></div> 
 		</div> 	 
 	
 
	   	  
   

  	  
 
  ".$lowerrightad_table_form['8']."	
 <button  type='submit' disabled='disabled' class='btn btn-primary btn-lg btn-block contentbtn'>"._MS_SHARED01."</button>
<div id='help-blocktext' class='text-center'><span id='helpBlock' class='help-block'><span  class='red'>"._MS_SHARED30."</span></span></div>    
     </form> 	  
  	  </div>
	  
  	  
    ";
//右邊區塊 
$main.="

  <div class='col-md-8'><h4>"._MA_ADVERTISEPHP36."</h4><hr />
  	  ".$lowerrightad_table_form['9']."
    	  </div>
  	  	  

  	     	 
    ";
$main.="
</div>




<script>var itemsvar='.tr'; dragmenufunction();</script>  	  
<script>
$('.basictable').basictable({
    breakpoint: 640,
    orceResponsive: true,
});
$(document).ready(function() {
    $('body').on('change', '#mydate1', function() {
        var date = $(this).val();
        var newDate = /\d{4}-\d{1,2}-\d{1,2}/g.exec(date);
        $(this).val(newDate);
        $('.ui-timepicker-div').remove();
    })
    $('body').on('click', '#rtimgdelete', function() {
        $.ajax({
            url: '".XOOPS_URL."/modules/neothemesadmin/ajax.php',
            type: 'POST',
            data: {
                id: '6',
                dbid: $(this).attr('name')
            },
            success: function(response) {
                $('.imgidboxrt').remove();
                swal('"._MS_SHARED223."', '"._MS_SHARED224."', 'success');
            },
            error: function() {
                console.log('ajax error!');
            }
        })
    })
});  	
</script>  
<script>previeweachfunction();neothemesadmin_specifiedtoplay(dbname='neil_lowerrightad',idname='rdad');neothemesadmin_lowerrightad();</script>
	";
 

	
	


  return $main;
}







function advertise_table02(){	
global $xoopsDB,$xoopsModule,$menutype,$xoopsModuleConfig,$ad,$url,$blocktitle;	

$img_date = date("H:i:s");
if(empty($ad)){  //新增

//判斷傳入值
if(!empty($url)) $neil_popupads['url']=base64_decode($url);
if(!empty($blocktitle)) $neil_popupads['title']=$blocktitle; 


$popupads_table_form['7']="<h4>"._MA_ADVERTISEPHP14."</h4>";
//POST類型
$popupads_table_form['8']="<input type='hidden' name='menutype' value='".$menutype."'><input type='hidden' name='op' value='save_news2'>";
$neil_popupads['enable']=1;
$neil_popupads['target']=0;
$neil_popupads['maturity']=timedate($datevar="Y-m-d");
$neil_popupads['imgwidth']=$xoopsModuleConfig['neothemesadmin6'];

}else{  //編輯
$popupads_table_form['7']="<h4>"._MA_ADVERTISEPHP15."</h4>";

//開啟neil_popupads資料表
//批次轉換htmlspecialchars
$neil_popupads=htmlspecialcharsbatch($allowvar=array("title","url","maturity"),$eachvar=moduledb($dbneme="neil_popupads",$where="  where `ad` = '".$ad."'"));

if(!empty($neil_popupads['imgid'])){
//已上傳圖片
$popupads_table_form['11']="<div id='imgidbox' class='form-group'>
	 <div class='col-md-12'> 
   <div class='text-center'> <h4><span id='helpBlock' class='help-block'>"._MA_PLAYERADMINPHP12."</span></h4> </div> 	
  <div class='row'>
    <div class='thumbnail'>   
        <img src='".XOOPS_URL."/uploads/".$xoopsModule->getVar("dirname")."/".$neil_popupads['imgid'].".png?state=".$img_date."' >
     </div></div>  
		 <br /></div> 
</div>";
}

//POST類型
$popupads_table_form['8']="<input type='hidden' name='menutype' value='".$menutype."'><input type='hidden' name='ad' value='".$neil_popupads['ad']."'><input type='hidden' name='op' value='updated2'>";
}

//是否啟用彈出廣告功能
$popupads_table_form['0']=radioinline($class="",$name="neothemesadmin5",$text=array(_MS_SHARED04,_MS_SHARED03),$checked=$xoopsModuleConfig['neothemesadmin5']); 

//廣告標題
$popupads_table_form['1']=inputtext($class="",$name="title",$value="".$neil_popupads['title']."",$placeholder=""._MS_SHARED21._MA_ADVERTISEPHP16."");

//廣告連結
$popupads_table_form['2']=inputtext($class="",$name="url",$value="".$neil_popupads['url']."",$placeholder=""._MS_SHARED21._MA_ADVERTISEPHP17."");

//上傳圖檔
$popupads_table_form['3']=typefile($multiple=false,$name="upfile",$id="blockimg",$class=""); 

//連結開啟方式
$popupads_table_form['4']=radioinline($class="",$name="target",$text=array(_MS_SHARED31,_MS_SHARED32),$checked=$neil_popupads['target']); 


//到期時間
$popupads_table_form['5']=inputtext($class="mydate",$name="maturity",$value="".$neil_popupads['maturity']."",$placeholder="".$neil_popupads['maturity']."",$id="mydate1");

//是否啟用
$popupads_table_form['6']=radioinline($class="",$name="enable",$text=array(_MS_SHARED04,_MS_SHARED03),$checked="".$neil_popupads['enable'].""); 

//彈出廣告框顯示方式
$popupads_table_form['12']=radioinline($class="",$name="neothemesadmin7",$text=array(_MA_ADVERTISEPHP25,_MA_ADVERTISEPHP26),$checked=$xoopsModuleConfig['neothemesadmin7']); 

//廣告圖片寬度
$popupads_table_form['13']=inputtext($class="",$name="imgwidth",$value="".$neil_popupads['imgwidth']."",$placeholder=""._MS_SHARED21._MA_ADVERTISEPHP43."");

//TABLE區塊	
foreach($neil_popupadsArr=databasetablewhile($dbneme="neil_popupads",$where="  order by  btnsort  ASC")   as $key=> $val){
	

$td['enable']=enable($envar=$neil_popupadsArr[$key]['enable']);
$td['img']="<div  style='width: 100%' class='thumbnail'><img  title='".$neil_popupadsArr[$key]['title']."'  src='".XOOPS_URL."/uploads/".$xoopsModule->getVar("dirname")."/".$neil_popupadsArr [$key]['imgid'].".png?state=".$img_date."'></div>";
//頁面開啟方式
$td['target']=pagemethod($types=$neil_popupadsArr[$key]['target']);

$adenable[$key]=radioinlinelist($dataid="1",$class="adenableeach",$name="adenable",$text="",$value=$neil_popupadsArr[$key]['ad'],$oid=$neil_popupadsArr[$key]['adenable'],$id="adenable_".$neil_popupadsArr[$key]['ad']."");	

if($neil_popupadsArr[$key]['ad']==$ad) $colorstyle[$key]="color1";


//判斷到期
if($neil_popupadsArr[$key]['maturity'] < timedate($datevar="Y-m-d")) $maturityrext[$key]="<span style='font-size: 95%;' class='label label-danger'>"._MA_ADVERTISEPHP20."</span>";
	
$popupads_table_form['10'].="<tr class='deletetr{$key} tr ".$colorstyle[$key]."' id='".$neil_popupadsArr[$key]['ad']."'  >
        <td>".$neil_popupadsArr[$key]['ad']."</td>
        <td>".$adenable[$key]."</td>
        <td>".$td['img']."</td>
        <td>".$neil_popupadsArr[$key]['title']."</td>      
        <td>".$neil_popupadsArr[$key]['maturity'].$maturityrext[$key]."</td>    	
        <td>".$td['enable']."</td>
       <td>".$td['target']['text']."</td>       	
        <td><a href='" .XOOPS_URL. "/modules/". $xoopsModule->getVar("dirname")."/admin/".basename(__FILE__)."?op=advertise2&menutype=".$menutype."&ad=".$neil_popupadsArr[$key]['ad']."'  class='btn btn-sm btn-info'>"._MS_SHARED08."</a>   
     <a id='deletebotton{$key}' type='button' mane='156,".$neil_popupadsArr[$key]['ad'].",".$neil_popupadsArr[$key]['title'].","._MA_ADVERTISEPHP24.",,neil_popupads,".$xoopsModule->getVar("dirname").",,ad'  class='btn btn-sm btn-danger   deleteeach'>"._MS_SHARED09."</a>     
     </tr>";
}

 
$popupads_table_form['9']="
<table class='table sortable basictable' name='164,".$xoopsModule->getVar("dirname").",".$menutype.",".$pageid.",".$typesid.",".$sortid.",".$suid.",neil_popupads,ad'>
    <thead>
      <tr>
      
        <th style='width: 3%'>"._MS_SHARED06."</th>
        <th style='width: 3%'>"._MA_ADVERTISEPHP23."</th>
        <th style='width: 13%'>"._MA_ADVERTISEPHP18."</th>
        <th style='width: 16%'>"._MA_ADVERTISEPHP16."</th>
        <th style='width: 10%'>"._MA_ADVERTISEPHP19."</th>
              <th style='width: 8%'>"._MS_SHARED10."</th>  
                    <th style='width: 10%'>"._MA_PLAYERADMINPHP05."</th>        
                 <th style='width: 14%'>"._MS_SHARED07."</th>  
      </tr>
    </thead>
    <tbody>
   ".$popupads_table_form['10']."
     
    </tbody>
  </table>
   <span id='helpBlock' class='help-block text-center'>"._MS_SHARED143."</span>	   		
";
 
$main.="

	<div class='container'>
  <h4>"._MA_ADVERTISEPHP12."&nbsp;<label for='sel2'>Pop-up management</label>&nbsp; <a class='btn btn-warning'  href='" . XOOPS_URL . "/modules/".$xoopsModule->getVar("dirname")."/admin/".basename(__FILE__)."?op=advertise2&menutype=2'>"._MS_SHARED25."</a></h4>
    <div class='row'>
  	".advertise_menu()."   		 	
    ";
    
$main.=" <div class='col-md-12'><br />
	<div class='alert alert-info' role='alert'><br />
	 <h5 class='row'>
    <label class='col-md-3  control-label'>"._MA_ADVERTISEPHP13."</label>   
     <div class='col-md-3 '>
    ".$popupads_table_form['0']."<br /><br />
    </div>     
    

    <label class='col-md-3  control-label'>"._MA_ADVERTISEPHP27."</label>   
     <div class='col-md-3 '>
    ".$popupads_table_form['12']."<br /><br />
    </div>     
     	   
     <div class='col-md-12'>
         <button type='button' class='btn btn-primary btn-block popbtn'>"._MS_SHOPPINGCART48."</button>
    
   </h5>
   </div></div><script>neothemesadmin_popupfeature_ny();</script>
  "; 
    
//左邊區塊
$main.="

  <div id='popupadsbox' class='col-md-4'>
<form method='post'  action='{$_SERVER['PHP_SELF']}' enctype='multipart/form-data'>	  	  
  	  ".$popupads_table_form['7']."<hr />
 
 

<div  class='row'>	
<label class='col-md-3 control-label'>"._MA_ADVERTISEPHP16."</label>
 		 <div class='col-md-9'> ".$popupads_table_form['1']." 
 	<span id='helpBlocktitle' class='red blockeach5'>"._MS_SHARED22."</span>
  	   <br /><br /></div> 
 	 	</div>
 	
<div  class='row'>	
<label class='col-md-3 control-label'>"._MA_ADVERTISEPHP17."</label>
 		 <div class='col-md-9'> ".$popupads_table_form['2']." 
  	   <br /></div> 
 		</div> 	
 	
 	

  <div class='row'>
    <label class='col-md-3 control-label'>"._MA_ADVERTISEPHP18."</label>   
     <div class='col-md-9'>
    ".$popupads_table_form['3']." 
      	<span id='helpBlockimgid' class='red blockeach5'>"._MS_SHARED22."</span> 
     <div class='preview' name=true></div>  
  <br />
           </div> </div>
".$popupads_table_form['11']."

 
 
<div  class='row'>	
<label class='col-md-3 control-label'>"._MA_BLOCKMENUSORTPHP13."</label>
 		 <div class='col-md-9'> ".$popupads_table_form['4']." 
  	   <br /><br /></div> 
 		</div> 	 
 	
<div  class='row'>	
<label class='col-md-3 control-label'>"._MA_ADVERTISEPHP43."</label>
 		 <div class='col-md-9'> ".$popupads_table_form['13']." 
	<span id='helpBlockimgwidth' class='red blockeach5'>"._MS_SHARED22."</span>  	
  	   <br /><br /></div> 
 		</div> 
 
<div  class='row'>	
<label class='col-md-3 control-label'>"._MA_ADVERTISEPHP19."</label>
 		 <div class='col-md-9'> ".$popupads_table_form['5']." 
 <span id='helpBlock' class='help-block'>"._MA_ADVERTISEPHP21."</span>
 	<span id='helpBlockmaturity' class='red blockeach5'>"._MS_SHARED22."</span>
  	   <br /><br /></div> 
 	 	</div>
 
 

 

 <div  class='row'>	
<label class='col-md-3 control-label'>"._MS_SHARED44."</label>
 		 <div class='col-md-9'> ".$popupads_table_form['6']." 
  	   <br /><br /></div> 
 		</div> 		   	  
   

  	  
 
  ".$popupads_table_form['8']."	
 <button  type='submit' disabled='disabled' class='btn btn-primary btn-lg btn-block contentbtn'>"._MS_SHARED01."</button>
<div id='help-blocktext' class='text-center'><span id='helpBlock' class='help-block'><span  class='red'>"._MS_SHARED30."</span></span></div>    
  	   </form>   
  	  </div>
	  
  	  
    ";
//右邊區塊 
$main.="

  <div class='col-md-8'><h4>"._MA_ADVERTISEPHP22."</h4><hr />
  	  ".$popupads_table_form['9']."
    	  </div>
  	  	  

  	     	 
    ";
$main.="
</div>




<script>var itemsvar='.tr'; dragmenufunction();</script>  	  
<script>
    $('.basictable').basictable({
        breakpoint: 640,
        orceResponsive: true,
    });
$(document).ready(function() {
   $('body').on('change', '#mydate1', function() {
   var date = $(this).val();   
   var newDate=/\d{4}-\d{1,2}-\d{1,2}/g.exec(date);
   $(this).val(newDate);   
   $('.ui-timepicker-div').remove();   
    })
});    	
</script>  
<script>previewfunction();neothemesadmin_specifiedtoplay(dbname='neil_popupads',idname='ad');neothemesadmin_popupadsform();</script>
	";
 
 
	
	


  return $main;
}



function advertise_table01(){
 global $xoopsDB,$xoopsModuleConfig,$menutype; 


//GTM代碼
$ListArr=phpconversion($conversion=base64_decode($xoopsModuleConfig['neothemesadmin3']),$type="unserialize"); 


//GTM-script
$settings['1']=inputtextarea($class="",$name="gtmscript",$id="",$rows="6",$cols="80",$value="".htmlspecialchars($ListArr['gtmscript'])."");
//GTM-noscript
$settings['2']=inputtextarea($class="",$name="gtmnoscript",$id="",$rows="6",$cols="80",$value="".htmlspecialchars($ListArr['gtmnoscript'])."");
//GTM-網域驗證
$settings['3']=inputtextarea($class="",$name="gtmverify",$id="",$rows="6",$cols="80",$value="".htmlspecialchars($ListArr['gtmverify'])."");
//GTM狀態
$settings['4']=radioinline($class="",$name="neothemesadmin4",$text=array(_MS_SHARED04,_MS_SHARED03),$checked=$xoopsModuleConfig['neothemesadmin4']); 



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

 <div class='page-header'>
  <h3>"._MA_ADVERTISEPHP01.'-'._MA_ADVERTISEPHP02."<small >Advertising admin</small></h3>
".advertise_menu()."     
</div>
<form method='post'  action='{$_SERVER['PHP_SELF']}'>"; 

$main.=" <div class='form-group'>
    <label class='col-md-12 control-label'><h3>"._MA_ADVERTISEPHP11."</h3></label>   
     <div class='col-md-12'>
    ".$settings['4']."
    <br /><br />   
           </div> </div>
  "; 

	   
$main.=" <div class='form-group'>
    <label class='col-md-12 control-label'><h3>"._MA_ADVERTISEPHP05." <small >".htmlspecialchars(_MA_ADVERTISEPHP06)."</small></h3></label>   
     <div class='col-md-12'>
    ".$settings['1']."
    <br /
           </div> </div>
  "; 	

$main.=" <div class='form-group'>
    <label class='col-md-12 control-label'><h3>"._MA_ADVERTISEPHP07." <small >".htmlspecialchars(_MA_ADVERTISEPHP08)."</small></h3></label>   
     <div class='col-md-12'>
    ".$settings['2']."
    <br />
           </div> </div>
  "; 
$main.=" <div class='form-group'>
    <label class='col-md-12 control-label'><h3>"._MA_ADVERTISEPHP09." <small >".htmlspecialchars(_MA_ADVERTISEPHP10)."</small></h3></label>   
     <div class='col-md-12'>
    ".$settings['3']."
    <br />
           </div> </div>
  "; 


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




//編輯右下浮動廣告
function advertiseupdated3(){
global $xoopsDB,$xoopsModuleConfig,$menutype,$xoopsModule,$rdad,$variablesplit; 	
//去資料表標籤-去除空白跟HTML標籤
$_POST=strip_tagsremovesqlArr($allowvar="",$postvar=$_POST,$sqltags=array("title","maturity"));  

//必填欄位驗證
$arr =array("title","maturity");
//會員帳號/密碼
foreach($arr as  $val){	
if(empty($_POST[$val])){
redirect_header($_SERVER['PHP_SELF'].'?op=advertise3&menutype='.$menutype.'',0 , _MS_SHARED90);
break;
}
}

//製作圖檔-右上	
if(!empty($_FILES['upfile1']['name'])){ 	
//製作圖片
save_pic($up_id="rdad_rt_".$rdad."",$width=$variablesplit['21'],$height="0",$modules="".$xoopsModule->getVar("dirname")."",$plural=false,$convert="png",$arr=false,$process=1,$crop=false,$upfile=$_FILES['upfile1'],$type="1");
}



//製作圖檔-右下	
if(!empty($_FILES['upfile2']['name'])){ 	
//製作圖片
save_pic($up_id="rdad_rb_".$rdad."",$width=$variablesplit['22'],$height="0",$modules="".$xoopsModule->getVar("dirname")."",$plural=false,$convert="png",$arr=false,$process=1,$crop=false,$upfile=$_FILES['upfile2'],$type="1");
}




$setvar="set 
title='{$_POST['title']}',		
url='".sqlinjectionfound($val=cuttingfunction($cutting=$_POST['urlArr'],$sign=",",$type="2"))."',	
target='".cuttingfunction($cutting=$_POST['targetArr'],$sign=",",$type="2")."',
maturity='{$_POST['maturity']}',	
enable='{$_POST['enable']}'
where rdad='".$rdad."'";
update($dbname="neil_lowerrightad",$set=$setvar);  



	
return $menutype;
}



//編輯數字廣告
function advertiseupdated4(){
global $xoopsDB,$xoopsModuleConfig,$menutype,$xoopsModule,$dgad; 	


//去資料表標籤-去除空白跟HTML標籤
$_POST=strip_tagsremovesqlArr($allowvar="",$postvar=$_POST,$sqltags=array("before_t","digital","after_t","side_t"));  

//必填欄位驗證
$arr =array("before_t","digital","after_t","side_t");
//會員帳號/密碼
foreach($arr as  $val){	
if(empty($_POST[$val])){
redirect_header($_SERVER['PHP_SELF'].'?op=advertise4&menutype='.$menutype.'',0 , _MS_SHARED90);
break;
}
}


//0->無單引號 1->有單引號
$variable=array(
"before_t"=>1,	
"digital"=>1,	
"after_t"=>1,			
"side_t"=>1,	
"enable"=>1						
);

foreach($variable as $key=> $val){
$dbpost[$key]=!empty($val) ? "".$key."='".$_POST[$key]."'" : "".$key."=".$_POST[$key].""; // get TRUE
}

//儲存neilhonorcontent
update($dbname="neil_digitalad",$set="set ".implode(',', $dbpost)."  where dgad='".$dgad."'");  



return $menutype;
}








//新增數字廣告
function advertisesave_news4(){
global $xoopsDB,$xoopsModuleConfig,$menutype,$xoopsModule; 

//去資料表標籤-去除空白跟HTML標籤
$_POST=strip_tagsremovesqlArr($allowvar="",$postvar=$_POST,$sqltags=array("before_t","digital","after_t","side_t"));  

//必填欄位驗證
$arr =array("before_t","digital","after_t","side_t");
//會員帳號/密碼
foreach($arr as  $val){	
if(empty($_POST[$val])){
redirect_header($_SERVER['PHP_SELF'].'?op=advertise4&menutype='.$menutype.'',0 , _MS_SHARED90);
break;
}
}




/*======資料處理區===========*/
$_POST['btnsort']=0;

//0->無單引號 1->有單引號
$variable=array(
"before_t"=>1,
"digital"=>1,	
"after_t"=>1,
"side_t"=>1,		
"btnsort"=>1,	
"enable"=>1		
);

foreach($variable as $key=> $val){
$dbpost[$key]=!empty($val) ? "'".$_POST[$key]."'" : $_POST[$key]; // get TRUE
}

//儲存neilhonorcontent
$dgad=insert($dbname="neil_digitalad",$values="(".implode(',', array_keys($variable)).")values(".implode(',', $dbpost).")"); 



return $menutype;

}





//新增右下浮動廣告
function advertisesave_news3(){
 global $xoopsDB,$xoopsModuleConfig,$menutype,$xoopsModule,$variablesplit; 
 

//去資料表標籤-去除空白跟HTML標籤
$_POST=strip_tagsremovesqlArr($allowvar="",$postvar=$_POST,$sqltags=array("title","maturity"));  

//必填欄位驗證
$arr =array("title","maturity");
//會員帳號/密碼
foreach($arr as  $val){	
if(empty($_POST[$val])){
redirect_header($_SERVER['PHP_SELF'].'?op=advertise3&menutype='.$menutype.'',0 , _MS_SHARED90);
break;
}
}

if(empty($_FILES['upfile2']['name'])) 	redirect_header($_SERVER['PHP_SELF'].'?op=advertise3&menutype='.$menutype.'',0 , _MS_SHARED90);

//判斷adenable
$adenable=empty(moduledb($dbneme="neil_lowerrightad",$where="")) ? '1' : '0'; // get TRUE

	

$valuesvar="(
title,url,imgid,target,maturity,btnsort,enable,adenable) 
values(
'{$_POST['title']}','".sqlinjectionfound($val=cuttingfunction($cutting=$_POST['urlArr'],$sign=",",$type="2"))."','','".cuttingfunction($cutting=$_POST['targetArr'],$sign=",",$type="2")."','{$_POST['maturity']}','0','{$_POST['enable']}','".$adenable."'
)";	  
$rdad=insert($dbname="neil_lowerrightad",$values=$valuesvar);


//製作圖檔-右上	
if(!empty($_FILES['upfile1']['name'])){ 	
//製作圖片
save_pic($up_id="rdad_rt_".$rdad."",$width=$variablesplit['21'],$height="0",$modules="".$xoopsModule->getVar("dirname")."",$plural=false,$convert="png",$arr=false,$process=1,$crop=false,$upfile=$_FILES['upfile1'],$type="1");
}



//製作圖檔-右下	
if(!empty($_FILES['upfile2']['name'])){ 	
//製作圖片
save_pic($up_id="rdad_rb_".$rdad."",$width=$variablesplit['22'],$height="0",$modules="".$xoopsModule->getVar("dirname")."",$plural=false,$convert="png",$arr=false,$process=1,$crop=false,$upfile=$_FILES['upfile2'],$type="1");
}

//儲存圖檔檔名
$setvar="set imgid='rdad_rt_".$rdad.",rdad_rb_".$rdad."'   where rdad='".$rdad."'";
update($dbname="neil_lowerrightad",$set=$setvar); 

return $menutype;
}











//編輯彈出廣告
function advertiseupdated2(){
global $xoopsDB,$xoopsModuleConfig,$menutype,$xoopsModule,$ad; 	
//去資料表標籤-去除空白跟HTML標籤
$_POST=strip_tagsremovesqlArr($allowvar="",$postvar=$_POST,$sqltags=array("title","url","maturity"));  

//必填欄位驗證
$arr =array("title","maturity");
//會員帳號/密碼
foreach($arr as  $val){	
if(empty($_POST[$val])){
redirect_header($_SERVER['PHP_SELF'].'?op=advertise2&menutype='.$menutype.'',0 , _MS_SHARED90);
break;
}
}

if(!empty($_FILES['upfile']['name'])){ 	
//製作圖片
save_pic($up_id="popupads_".$ad."",$width=$_POST['imgwidth'],$height="0",$modules="".$xoopsModule->getVar("dirname")."",$plural=false,$convert="png",$arr=false,$process=1,$crop=false,$upfile=$_FILES['upfile'],$type="1");
}


$setvar="set 
title='{$_POST['title']}',	
url='{$_POST['url']}',	
target='{$_POST['target']}',
maturity='{$_POST['maturity']}',	
enable='{$_POST['enable']}',
imgwidth='{$_POST['imgwidth']}'
where ad='".$ad."'";
update($dbname="neil_popupads",$set=$setvar);  



	
return $menutype;
}


//新增彈出廣告
function advertisesave_news2(){
 global $xoopsDB,$xoopsModuleConfig,$menutype,$xoopsModule; 
 
  
//去資料表標籤-去除空白跟HTML標籤
$_POST=strip_tagsremovesqlArr($allowvar="",$postvar=$_POST,$sqltags=array("title","url","maturity"));  

//必填欄位驗證
$arr =array("title","maturity");
//會員帳號/密碼
foreach($arr as  $val){	
if(empty($_POST[$val])){
redirect_header($_SERVER['PHP_SELF'].'?op=advertise2&menutype='.$menutype.'',0 , _MS_SHARED90);
break;
}
}

if(empty($_FILES['upfile']['name'])) redirect_header($_SERVER['PHP_SELF'].'?op=advertise2&menutype='.$menutype.'',0 , _MS_SHARED90);

//判斷adenable
$adenable=empty(moduledb($dbneme="neil_popupads",$where="")) ? '1' : '0'; // get TRUE

$valuesvar="(
title,url,imgid,target,maturity,btnsort,enable,adenable,imgwidth) 
values(
'{$_POST['title']}','{$_POST['url']}','','{$_POST['target']}','{$_POST['maturity']}','0','{$_POST['enable']}','".$adenable."','{$_POST['imgwidth']}')";	  
$ad=insert($dbname="neil_popupads",$values=$valuesvar);


if(!empty($_FILES['upfile']['name'])){ 	
//製作圖片
save_pic($up_id="popupads_".$ad."",$width=$_POST['imgwidth'],$height="0",$modules="".$xoopsModule->getVar("dirname")."",$plural=false,$convert="png",$arr=false,$process=1,$crop=false,$upfile=$_FILES['upfile'],$type="1");
}
//儲存圖檔檔名
$setvar="set imgid='popupads_".$ad."'   where ad='".$ad."'";
update($dbname="neil_popupads",$set=$setvar); 
 
return $menutype;
}



//GTM代碼更新
function advertiseupdate01(){
global $xoopsDB,$xoopsModuleConfig,$menutype; 

//更新GTM代碼
update($dbname="config",$set="set conf_value='".base64_encode(phpconversion($conversion=array('gtmscript'=>$_POST['gtmscript'],'gtmnoscript'=>$_POST['gtmnoscript'],'gtmverify'=>$_POST['gtmverify']),$type="serialize"))."'  where conf_name='neothemesadmin3'");
//更新GTM狀態
update($dbname="config",$set="set conf_value='{$_POST['neothemesadmin4']}'  where conf_name='neothemesadmin4'");

return $menutype;
}


loadModuleAdminMenu(13);
if(!empty(modulesmidvar($modulesid="xLanguage",$var="isactive"))){
$main.="<script>neillibrary_llanguagetext(afterid='#buttonbar');</script>";
}
echo $main;
include_once "footer.php"; //XOOPS檔尾		
?>