<?php
include_once XOOPS_ROOT_PATH."/modules/neothemesadmin/function.php";
include_once "../class/themeset.php";
function xoops_module_update_neothemesadmin() {
	include XOOPS_ROOT_PATH . '/modules/neothemesadmin/class/themesset/defaultltheme.php';
	$xoops_theme = $installtheme;
	global $xoopsDB;
	go_updatedefault1();
	go_updatedefault2();	
	go_update3();
	if(!chk_chk4()) go_update4();
	go_update5($xoops_theme,$theme_set_allowed);
	go_update7($xoops_theme);
	go_update8($xoops_theme);
	if(!chk_chk9()) go_update9();
	if(!chk_chk10()) go_update10();
	if(!chk_chk11()) go_update11();
	go_update12();
	go_update13();
	go_update16();
	go_update17();
	go_update18();
	go_update19();
	go_update21();
	go_update22();
	//模組加入防護模組網路爬蟲例外
	protectorexception($modulesid="neothemesadmin");
	//建立neothemesadmin資料夾
	fileadminfunction($fileurl="",$type="4",$fileex="",$from=XOOPS_ROOT_PATH."/uploads/neothemesadmin",$fileurlnew="");
	//搬移圖檔案neothemesadmin資料夾
	go_update23($xoops_theme);
	go_update24($xoops_theme);
	go_update26($xoops_theme);
    go_update27($xoops_theme);
    go_update28($xoops_theme);
    go_update29($xoops_theme);
    //更新完成後變更更新選項寫入更新時間
    update($dbname="neothemesconfig",$set="set enable='0' where nsn='1'");
    update($dbname="config",$set="set conf_value='".timedate($datevar="Y-m-d H:i:s")."'  where conf_name='neothemesadmin1'");    
    go_update30();
    go_update31();
    go_update32($xoops_theme);    
    go_update33();
	return true;
}
//預設欄位格式轉換
function go_updatedefault1() {
	global $xoopsDB;
	//轉neocontactusform
	$sql="ALTER TABLE ".$xoopsDB->prefix("neocontactusform")." 
	CHANGE `replytime` `replytime` datetime NULL DEFAULT NULL";
	$xoopsDB->queryF($sql);
	//轉neothemesmarquee
	$sql="ALTER TABLE ".$xoopsDB->prefix("neothemesmarquee")." 
	CHANGE `post_date` `post_date` datetime NULL DEFAULT NULL";
	$xoopsDB->queryF($sql);
	//轉neothemesflash
	$sql="ALTER TABLE ".$xoopsDB->prefix("neothemesflash")." 
	CHANGE `post_date` `post_date` datetime NULL DEFAULT NULL";
	$xoopsDB->queryF($sql);
	return true;
}


function  go_updatedefault2() {
	//舊位置
	$oldvar="".XOOPS_ROOT_PATH."/modules/neillibrary/patch/onInstall/system/register.php";
	//新位置
	$newvar="".XOOPS_ROOT_PATH."/register.php";
	//複製
	copy($oldvar , $newvar);
	//舊位置
	$oldvar="".XOOPS_ROOT_PATH."/modules/neillibrary/patch/onInstall/profile/register.php";
	//新位置
	$newvar="".XOOPS_ROOT_PATH."/modules/profile/register.php";
	//複製
	copy($oldvar , $newvar);
	//舊位置
	$oldvar="".XOOPS_ROOT_PATH."/modules/neillibrary/patch/onInstall/system/robots.txt";
	//新位置
	$newvar="".XOOPS_ROOT_PATH."/robots.txt";
	//複製
	copy($oldvar , $newvar);
	
	if(file_exists(XOOPS_ROOT_PATH."/modules/system/themes/tad/tad.php")) {
	//舊位置
	$oldvar="".XOOPS_ROOT_PATH."/modules/neillibrary/patch/onInstall/system/tad/tad.php";
	//新位置
	$newvar="".XOOPS_ROOT_PATH."/modules/system/themes/tad/tad.php";
	//複製
	copy($oldvar , $newvar);
	}
	
	//舊位置
	$oldvar="".XOOPS_ROOT_PATH."/modules/neillibrary/patch/onInstall/kernel/block.php";
	//新位置
	$newvar="".XOOPS_ROOT_PATH."/kernel/block.php";
	//複製
	copy($oldvar , $newvar);	

	//舊位置
	$oldvar="".XOOPS_ROOT_PATH."/modules/neillibrary/patch/onInstall/modules/system/class/block.php";
	//新位置
	$newvar="".XOOPS_ROOT_PATH."/modules/system/class/block.php";
	//複製
	copy($oldvar , $newvar);
	
}


function go_update3() {
	global $xoopsDB;
	$dbnane=$xoopsDB->prefix('session');
	$sql="TRUNCATE `$dbnane`;";
	$result=$xoopsDB->query($sql);
	return true;
}
//新增neorightmenu資料表
function chk_chk4() {
	global $xoopsDB;
	$sql="select count(*) from ".$xoopsDB->prefix("neorightmenu");
	$result=$xoopsDB->query($sql);
	if(empty($result)) return false;
	return true;
}
function go_update4() {
	global $xoopsDB;
	$sql="CREATE TABLE `".$xoopsDB->prefix("neorightmenu")."` (
   `nsn` smallint(5) unsigned NOT NULL AUTO_INCREMENT,
   `title` text NOT NULL,
   `url` text NOT NULL,
   `target` varchar(255) NOT NULL,
   `snid` int(255)  NOT NULL,   
    PRIMARY KEY (`nsn`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;";
	$xoopsDB->queryF($sql);
}
function go_update5($xoops_theme,$theme_set_allowed) {
	global $xoopsDB;
	$sql="ALTER TABLE ".$xoopsDB->prefix("neothemesconfig")." 
	ADD `line` varchar(255) NOT NULL DEFAULT '' AFTER `menuid`,
	ADD `fburl` varchar(255) NOT NULL DEFAULT '' AFTER `line`,
	ADD `fbfansurl` varchar(255) NOT NULL DEFAULT '' AFTER `fburl`,
	ADD `contactus` varchar(255) NOT NULL DEFAULT '' AFTER `fbfansurl`";
	$xoopsDB->queryF($sql);
	$sql="ALTER TABLE ".$xoopsDB->prefix("neothemeskeyword")." 
	ADD `title` varchar(255) NOT NULL DEFAULT '' AFTER `wdescription`";
	$xoopsDB->queryF($sql);
	$sql = "update " . $xoopsDB->prefix("config") . " set `conf_value`='{$xoops_theme}' where  conf_name = 'theme_set' ";
	$xoopsDB->queryF($sql);
	$sql = "update " . $xoopsDB->prefix("config") . " set `conf_value`='$theme_set_allowed' where  conf_name = 'theme_set_allowed' ";
	$xoopsDB->queryF($sql);
	return true;
}
function go_update7($xoops_theme) {
	global $xoopsDB;
	//判斷tadtools有沒有安裝
	$module_handler = &xoops_gethandler('module');
	$tadtools= &$module_handler->getByDirname('tadtools');
	if(!empty($tadtools)) {
		$sql = "select tt_theme from " . $xoopsDB->prefix('tadtools_setup')   . " where `tt_theme` = '{$xoops_theme}'";
		$result = $xoopsDB -> query($sql) or die($sql);
		$tt_themeNY = $xoopsDB -> getRowsNum($result);
		if(empty($tt_themeNY)) {
		$sql="insert into " . $xoopsDB->prefix('tadtools_setup') . "
        (`tt_theme`  ,  `tt_use_bootstrap` ,  `tt_bootstrap_color` ,  `tt_theme_kind`)
        values
        ('{$xoops_theme}'  ,  '1'  ,  'bootstrap3' ,  'bootstrap3')";
		$xoopsDB->query($sql);
		}
	}
	return true;
}
function go_update8($xoops_theme) {
	global $xoopsDB;
	$sql="select flashtext from ".$xoopsDB->prefix("neothemesflash");
	$result=$xoopsDB->query($sql);
	if(!empty($result)) {
		$sql = "ALTER TABLE `" . $xoopsDB->prefix("neothemesflash") . "` CHANGE `flashtext` `themesid` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ''";
		$xoopsDB->queryF($sql) or redirect_header(XOOPS_URL, 3, $xoopsDB->error());
	}
	return true;
}
//新增neoblockmenusort資料表
function chk_chk9() {
	global $xoopsDB;
	$sql="select count(*) from ".$xoopsDB->prefix("neoblockmenusort");
	$result=$xoopsDB->query($sql);
	if(empty($result)) return false;
	return true;
}
function go_update9() {
	global $xoopsDB;
	$sql="CREATE TABLE `".$xoopsDB->prefix("neoblockmenusort")."` (
    `sortid` smallint(5) unsigned NOT NULL AUTO_INCREMENT,
    `sorttitle` varchar(255) NOT NULL,
    `sortimg` varchar(255) NOT NULL,
    `sorting` int(255)  NOT NULL,   
     PRIMARY KEY (`sortid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;";
	$xoopsDB->queryF($sql);
}
//新增neoblockmenubutton資料表
function chk_chk10() {
	global $xoopsDB;
	$sql="select count(*) from ".$xoopsDB->prefix("neoblockmenubutton");
	$result=$xoopsDB->query($sql);
	if(empty($result)) return false;
	return true;
}
function go_update10() {
	global $xoopsDB;
	$sql="CREATE TABLE `".$xoopsDB->prefix("neoblockmenubutton")."` (
   `bid` smallint(5) unsigned NOT NULL AUTO_INCREMENT,
   `sortid` int(255)  NOT NULL,   
   `buttontitle` varchar(255) NOT NULL,
   `buttonurl` varchar(255) NOT NULL,
   `target` enum('0','1') NOT NULL default '0',  
   `sortyn` enum('y','n') NOT NULL default 'n',
   `modulesid` varchar(255) NOT NULL,  
   `variableid` varchar(255) NOT NULL,    
   `orderid` int(255)  NOT NULL,   
    PRIMARY KEY (`bid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;";
	$xoopsDB->queryF($sql);
}
//新增neocontactusform資料表
function chk_chk11() {
	global $xoopsDB;
	$sql="select count(*) from ".$xoopsDB->prefix("neocontactusform");
	$result=$xoopsDB->query($sql);
	if(empty($result)) return false;
	return true;
}
function go_update11() {
	global $xoopsDB;
	$sql="CREATE TABLE `".$xoopsDB->prefix("neocontactusform")."` (
    `cfid` smallint(5) unsigned NOT NULL AUTO_INCREMENT,
    `name_user` varchar(255) NOT NULL,
    `email_user` varchar(255) NOT NULL,
    `tel_user` varchar(255) NOT NULL,
    `citytel_user` varchar(255) NOT NULL,  
    `radiog` enum('male','female') NOT NULL,  
    `texe_user` text NOT NULL,
    `cfidtime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
    `readtrue` int(5)  NOT NULL,   
     PRIMARY KEY (`cfid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;";
	$xoopsDB->queryF($sql);
}
function go_update12() {
	global $xoopsDB;
	//搜尋模組ID	
	$sql = "select mid   from " . $xoopsDB->prefix('modules')   . " where `dirname` = 'neothemesadmin'";
	$result = $xoopsDB -> query($sql) or die($sql);
	list($mid) = $xoopsDB -> fetchRow($result);
	$sql="insert into " . $xoopsDB->prefix('group_permission') . "
    (`gperm_groupid`  ,`gperm_itemid`  ,  `gperm_modid`,  `gperm_name`)
    values
    ('2'  , '{$mid}'  ,  '1' ,  'module_read')";
	$xoopsDB->queryF($sql);
	$sql="insert into " . $xoopsDB->prefix('group_permission') . "
    (`gperm_groupid`  ,`gperm_itemid`  ,  `gperm_modid`,  `gperm_name`)
    values
    ('3'  , '{$mid}'  ,  '1' ,  'module_read')";
	$xoopsDB->queryF($sql);
	return true;
}
//新增neoblockmenusort資料表
function go_update13() {
	global $xoopsDB;
	$sql="select radiogstyle from ".$xoopsDB->prefix("neoblockmenusort");
	$result=$xoopsDB->query($sql);
	if(empty($result)) {
		$sql="ALTER TABLE ".$xoopsDB->prefix("neoblockmenusort")." 
	ADD `radiogstyle` enum('text','img') NOT NULL default 'text' AFTER `sorting`,
	ADD `imgstyle` enum('random','sorting') NOT NULL default 'sorting' AFTER `radiogstyle`";
		$xoopsDB->queryF($sql);
	}
	$sql="select buttonimg from ".$xoopsDB->prefix("neoblockmenubutton");
	$result=$xoopsDB->query($sql);
	if(empty($result)) {
		$sql="ALTER TABLE ".$xoopsDB->prefix("neoblockmenubutton")." 
	ADD `buttonimg` varchar(255) NOT NULL AFTER `orderid`";
		$xoopsDB->queryF($sql);
	}
	return true;
}

function go_update16() {
	global $xoopsDB;
	$sql="select  count(`contactmatters`) from ".$xoopsDB->prefix("neothemesconfig");
	$result=$xoopsDB->query($sql);
	if(empty($result)) {
		$sql="ALTER TABLE ".$xoopsDB->prefix("neothemesconfig")." 
	ADD `contactmatters` varchar(255) NOT NULL DEFAULT '' AFTER `contactus`";
		$xoopsDB->queryF($sql);
		$sql="ALTER TABLE ".$xoopsDB->prefix("neocontactusform")." 
	ADD `contactmatters`  varchar(255) NOT NULL default '' AFTER `readtrue`,
	ADD `replytext`  longtext NOT NULL AFTER `contactmatters`,		
	ADD `replytime`  datetime default NULL AFTER `replytext`";
		$xoopsDB->queryF($sql);
		$sql="ALTER TABLE ".$xoopsDB->prefix("neothemesmarquee")." 
	ADD `enable`  enum('1','0') NOT NULL default '1' AFTER `post_date`";
		$xoopsDB->queryF($sql);
		$sql = "update " . $xoopsDB->prefix("neothemesconfig") . " set `mnsnid`=''";
		$xoopsDB->queryF($sql);
	}
	if(file_exists(XOOPS_ROOT_PATH.'/modules/neothemesadmin/contactusformpost.php')) {
		unlink(XOOPS_ROOT_PATH.'/modules/neothemesadmin/contactusformpost.php');
		//將檔案刪除
	}
	return true;
}
function go_update17() {
	global $xoopsDB;
	$sql="select  count(`sorttitleurl`) from ".$xoopsDB->prefix("neoblockmenusort");
	$result=$xoopsDB->query($sql);
	if(empty($result)) {
		$sql="ALTER TABLE ".$xoopsDB->prefix("neoblockmenusort")." 
	ADD `sorttitleurl` varchar(255) NOT NULL default '' AFTER `imgstyle`,
	ADD `target` enum('0','1') NOT NULL default '0' AFTER `sorttitleurl`,
	ADD `enable` enum('1','0') NOT NULL default '0' AFTER `target`	
	";
		$xoopsDB->queryF($sql);
		//更新佈景設定參數
		$theme_set_allowed='a:11:{i:0;s:1:"1";i:1;s:1:"1";i:2;s:1:"1";i:3;s:1:"1";i:4;s:1:"1";i:5;s:1:"0";i:6;s:1:"1";i:7;s:1:"0";i:8;s:1:"0";i:9;s:1:"7";i:10;s:1:"0";}';
		$sql = "update " . $xoopsDB->prefix("neothemesconfig") . " set `field`='".$theme_set_allowed."'";
		$xoopsDB->queryF($sql);
		//neothemesflash新增欄位
		$sql="ALTER TABLE ".$xoopsDB->prefix("neothemesflash")." 
	ADD `enable` enum('1','0') NOT NULL default '1' AFTER `themesid`	
	";
		$xoopsDB->queryF($sql);
		/*==========neothemesmenu變更資料內容開始================*/
		//主迴圈
		$k=0;
		$selectdb=$xoopsDB->prefix('neothemesmenu');
		$sql="select * from  $selectdb  where `master_slave`=1  order by  nnumber  asc";
		$result = $xoopsDB -> query($sql) ;
		while(list($nsn,$nnumber,$master_slave,$manugroup,$content,$url,$target,$post_date) = $xoopsDB -> fetchRow($result)) {
			$targetnew=$target==1 ? $target : '0';
			// get TRUE
			$sql = "update ".$xoopsDB->prefix("neothemesmenu")." set   
	manugroup = '0',
	target = '".$targetnew."'
    where  nsn= '{$nsn}'";
			$xoopsDB->queryF($sql);
			/*============第二層迴圈==================*/
			$g="{$k}00";
			$sqla="select * from  $selectdb     where `master_slave`=2 and  `manugroup`=$manugroup   order by  nnumber  asc";
			$resulta = $xoopsDB -> query($sqla);
			while(list($nsna,$nnumbera,$master_slavea,$manugroupa,$contenta,$urla,$targeta,$post_datea,$snid) = $xoopsDB -> fetchRow($resulta)) {
				$targetnewa=$targeta==1 ? $targeta : '0';
				// get TRUE
				$sql = "update ".$xoopsDB->prefix("neothemesmenu")." set   
	manugroup = '".$nsn."',
	target = '".$targetnewa."'		
    where  nsn= '{$nsna}'";
				$xoopsDB->queryF($sql) ;
				/*============第三層迴圈==================*/
				$sql="select * from  $selectdb     where `master_slave`=3  and `snid`=$nsna   order by  nnumber  asc";
				$resultb[$g] = $xoopsDB -> query($sql);
				while(list($nsnb,$nnumberb,$master_slaveb,$manugroupb,$contentb,$urlb,$targetb,$post_dateb) = $xoopsDB -> fetchRow($resultb[$g])) {
					$targetnewb=$targetb==1 ? $targetb : '0';
					// get TRUE
					$sql = "update ".$xoopsDB->prefix("neothemesmenu")." set   
	manugroup = '".$nsna."',
	target = '".$targetnewb."'			
    where  nsn= '{$nsnb}'";
					$xoopsDB->queryF($sql);
				}
				$g++;
			}
			$k++;
		}
		/*=============變更資料內容結束==================*/
		//變更neothemesmenu欄位名稱及刪除新增欄位   
		$sql="ALTER TABLE ".$xoopsDB->prefix("neothemesmenu")." 
	CHANGE `nsn` `sortid` mediumint(8) UNSIGNED NOT NULL AUTO_INCREMENT,
	CHANGE `nnumber` `sortidsort` smallint(5) UNSIGNED NOT NULL default 0,	
	CHANGE `manugroup` `of_sortid` smallint(5) unsigned NOT NULL default 0,
	CHANGE `content` `sorttitle` varchar(255) NOT NULL default '',
	CHANGE `target` `target` enum('1','0') NOT NULL default '0',		
	DROP `master_slave`,
	DROP `post_date`,	
	DROP `snid`,
	ADD `enable` enum('1','0') NOT NULL default '1' AFTER `target`													
	";
		$xoopsDB->queryF($sql);
		//neoblockmenusort新增欄位
		$sql="ALTER TABLE ".$xoopsDB->prefix("neoblockmenusort")." 
	ADD `urlenable` enum('1','0') NOT NULL default '0' AFTER `target`,
	DROP `imgstyle`,
   	DROP `enable`,			
	ADD `enable` enum('1','0') NOT NULL default '1' AFTER `urlenable`				
	";
		$xoopsDB->queryF($sql);
		//變更neoblockmenubutton欄位名稱及刪除新增欄位   
		$sql="ALTER TABLE ".$xoopsDB->prefix("neoblockmenubutton")." 
  	CHANGE `sortid` `categoryid` smallint(5) unsigned NOT NULL default '0',		
	CHANGE `bid` `sortid` mediumint(8) UNSIGNED NOT NULL AUTO_INCREMENT,			
	CHANGE `buttontitle` `sorttitle` varchar(255) NOT NULL default '',		
	CHANGE `buttonurl` `url` text NOT NULL,		
	CHANGE `orderid` `sortidsort` smallint(5) UNSIGNED NOT NULL default 0,
  	CHANGE `sortyn` `sortyn` varchar(255) NOT NULL default '',				
	ADD `enable` enum('1','0') NOT NULL default '1' AFTER `buttonimg`,
	ADD `of_sortid` smallint(5) unsigned NOT NULL default '0' AFTER `sortid`,
    ADD `typesof` enum('1','0') NOT NULL default '0' AFTER `target`																			
	";
		$xoopsDB->queryF($sql);
		//刪除無用檔案     
		if(file_exists(XOOPS_ROOT_PATH.'/modules/neothemesadmin/admin/analyzefbid.php')) {
			unlink(XOOPS_ROOT_PATH.'/modules/neothemesadmin/admin/analyzefbid.php');
			//將檔案刪除
		}

		if(file_exists(XOOPS_ROOT_PATH.'/modules/neothemesadmin/admin/newflashimg.php')) {
			unlink(XOOPS_ROOT_PATH.'/modules/neothemesadmin/admin/newflashimg.php');
			//將檔案刪除
		}
		if(file_exists(XOOPS_ROOT_PATH.'/modules/neothemesadmin/admin/newmarquee.php')) {
			unlink(XOOPS_ROOT_PATH.'/modules/neothemesadmin/admin/newmarquee.php');
			//將檔案刪除
		}
		if(file_exists(XOOPS_ROOT_PATH.'/modules/neothemesadmin/admin/newmenu.php')) {
			unlink(XOOPS_ROOT_PATH.'/modules/neothemesadmin/admin/newmenu.php');
			//將檔案刪除
		}
		if(file_exists(XOOPS_ROOT_PATH.'/modules/neothemesadmin/blocks/themesmenuphone.php')) {
			unlink(XOOPS_ROOT_PATH.'/modules/neothemesadmin/blocks/themesmenuphone.php');
			//將檔案刪除
		}
		if(file_exists(XOOPS_ROOT_PATH.'/modules/neothemesadmin/glyphicon.php')) {
			unlink(XOOPS_ROOT_PATH.'/modules/neothemesadmin/glyphicon.php');
			//將檔案刪除
		}
		if(file_exists(XOOPS_ROOT_PATH.'/modules/neothemesadmin/admin/blockmenusortform.php')) {
			unlink(XOOPS_ROOT_PATH.'/modules/neothemesadmin/admin/blockmenusortform.php');
			//將檔案刪除
		}
		if(file_exists(XOOPS_ROOT_PATH.'/modules/neothemesadmin/admin/blockmenubuttonform.php')) {
			unlink(XOOPS_ROOT_PATH.'/modules/neothemesadmin/admin/blockmenubuttonform.php');
			//將檔案刪除
		}
		if(file_exists(XOOPS_ROOT_PATH.'/modules/neothemesadmin/admin/blockmenu.php')) {
			unlink(XOOPS_ROOT_PATH.'/modules/neothemesadmin/admin/blockmenu.php');
			//將檔案刪除
		}
		if(file_exists(XOOPS_ROOT_PATH.'/modules/neothemesadmin/admin/imguploader.php')) {
			unlink(XOOPS_ROOT_PATH.'/modules/neothemesadmin/admin/imguploader.php');
			//將檔案刪除
		}
	}
}
function go_update18() {
	global $xoopsDB;
	$sql="select  count(`contactustext`) from ".$xoopsDB->prefix("neothemesconfig");
	$result=$xoopsDB->query($sql);
	if(empty($result)) {
		$sql="ALTER TABLE ".$xoopsDB->prefix("neothemesconfig")." 
	ADD  `contactustext`  text NOT NULL default ''  AFTER `contactmatters`	";
		$xoopsDB->queryF($sql);
	}
	return true;
}
function go_update19() {
	global $xoopsDB;
	$sql="select  count(`enable`) from ".$xoopsDB->prefix("neorightmenu");
	$result=$xoopsDB->query($sql);
	if(empty($result)) {
		$sql="ALTER TABLE ".$xoopsDB->prefix("neorightmenu")." 
	ADD  `enable` enum('1','0') NOT NULL default '1'  AFTER `snid`";
		$xoopsDB->queryF($sql);
		$sql="ALTER TABLE ".$xoopsDB->prefix("neothemesconfig")." 
	ADD  `enable` enum('1','0') NOT NULL default '0'  AFTER `contactustext`	";
		$xoopsDB->queryF($sql);
		$sql="ALTER TABLE ".$xoopsDB->prefix("neocontactusform")." 
	ADD `enable` enum('1','0') NOT NULL default '0' AFTER `replytime`,
	ADD `directions` longtext NOT NULL AFTER `enable`,
	ADD `uid` mediumint(8) unsigned NOT NULL default 0 AFTER `directions`,
    ADD `transfer` datetime default NULL AFTER `uid`																			
	";
		$xoopsDB->queryF($sql);
	}
	if(file_exists(XOOPS_ROOT_PATH.'/modules/neothemesadmin/admin/rightmenutable.php')) {
		unlink(XOOPS_ROOT_PATH.'/modules/neothemesadmin/admin/rightmenutable.php');
		//將檔案刪除
	}
	if(file_exists(XOOPS_ROOT_PATH.'/modules/neothemesadmin/admin/contactuscontent.php')) {
		unlink(XOOPS_ROOT_PATH.'/modules/neothemesadmin/admin/contactuscontent.php');
		//將檔案刪除
	}
	return true;
}

//新增neilrandomidiom資料表
function  go_update21() {
	global $xoopsDB;
	$sql="select count(*) from ".$xoopsDB->prefix("neilrandomidiom");
	$result=$xoopsDB->query($sql);
	if(empty($result)) {
		$sql="CREATE TABLE `".$xoopsDB->prefix("neilrandomidiom")."` (
  `nsn` smallint(5) unsigned NOT NULL AUTO_INCREMENT,
  `setuptime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, 
  `content` text NOT NULL,
  `author` varchar(255) NOT NULL default '',
  `snid`  smallint(5) unsigned NOT NULL default '0',  
  `enable` enum('1','0') NOT NULL default '1', 
  `color` varchar(255) NOT NULL default '', 
  `icom` varchar(255) NOT NULL default '',   
   PRIMARY KEY (`nsn`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;";
		$xoopsDB->queryF($sql);
	}
}
function  go_update22() {
	global $xoopsDB;
	$sql="select  count(`icon`) from ".$xoopsDB->prefix("neoblockmenusort");
	$result=$xoopsDB->query($sql);
	if(empty($result)) {
		$sql="ALTER TABLE ".$xoopsDB->prefix("neoblockmenusort")." 
	ADD  `icon` varchar(255) NOT NULL default ''  AFTER `enable`	";
		$xoopsDB->queryF($sql);
		$sql="ALTER TABLE ".$xoopsDB->prefix("neothemesconfig")." 
	CHANGE `mnsnid` `mnsnid`   text NOT NULL default '' ";
		$xoopsDB->queryF($sql);
		$sql="ALTER TABLE ".$xoopsDB->prefix("neoblockmenusort")." 
	ADD  `browsegroup` varchar(255) NOT NULL default ''  AFTER `icon`	";
		$xoopsDB->queryF($sql);
		$sql="ALTER TABLE ".$xoopsDB->prefix("neoblockmenubutton")." 
	ADD  `browsegroup` varchar(255) NOT NULL default ''  AFTER `enable`	";
		$xoopsDB->queryF($sql);
		//datetime欄位轉換
		$sql="ALTER TABLE ".$xoopsDB->prefix("neocontactusform")." 
	CHANGE `transfer` `transfer`   datetime default NULL ";
		$xoopsDB->queryF($sql);
		//neothemesmenu新增欄位    
		$sql="ALTER TABLE ".$xoopsDB->prefix("neothemesmenu")." 
	ADD `browsegroup` varchar(255) NOT NULL default '' AFTER `enable`,
	ADD `displaytype` varchar(255) NOT NULL default '1' AFTER `browsegroup`
	";
		$xoopsDB->queryF($sql);
		//neothemesconfig新增欄位    
		$sql="ALTER TABLE ".$xoopsDB->prefix("neothemesconfig")." 
	ADD `aboutustext` text NOT NULL default '' AFTER `enable`
	";
		$xoopsDB->queryF($sql);
	}
}
function  go_update23($xoops_theme="") {
	//$xoops_theme='neilambilight'; // get TRUE 	 
	$buttonimgArr=databasetablewhile($dbneme="neoblockmenubutton",$where="  order by  sortid  DESC ");
	foreach($buttonimgArr as $key=> $val) {
		//舊位置
		$oldimg="".XOOPS_ROOT_PATH."/uploads/".$xoops_theme."/".$buttonimgArr[$key]['buttonimg'].".png";
		//新位置
		$newimg="".XOOPS_ROOT_PATH."/uploads/neothemesadmin/".$buttonimgArr[$key]['buttonimg'].".png";
		//小縮圖-搬移
		rename($oldimg, $newimg);
	}
}
function  go_update24($xoops_theme="") {
	//$xoops_theme='neilambilight'; // get TRUE 
	//舊位置
	$oldimg="".XOOPS_ROOT_PATH."/uploads/".$xoops_theme."/aboutblockimg.png";
	//新位置
	$newimg="".XOOPS_ROOT_PATH."/uploads/neothemesadmin/aboutblockimg.png";
	//小縮圖-搬移
	rename($oldimg, $newimg);
}


function  go_update26($xoops_theme="") {
	global $xoopsDB;
	$sql="select  count(`remarkstext`) from ".$xoopsDB->prefix("neothemesconfig");
	$result=$xoopsDB->query($sql);
	if(empty($result)) {
		$sql="ALTER TABLE ".$xoopsDB->prefix("neothemesconfig")." 
	ADD  `remarkstext`  text NOT NULL default ''  AFTER `aboutustext`	";
		$xoopsDB->queryF($sql);
		$sql="ALTER TABLE ".$xoopsDB->prefix("neoblockmenusort")." 
	ADD  `boxwidth` varchar(255)  NOT NULL default ''  AFTER `browsegroup`	";
		$xoopsDB->queryF($sql);
		//刪除無使用的detectfile.php
		fileadminfunction($fileurl=XOOPS_ROOT_PATH.'/modules/neothemesadmin/class/detectfile.php',$type="2",$fileex="",$from="",$fileurlnew="",$exclude="");
		//刪除無使用的selectdb.php
		fileadminfunction($fileurl=XOOPS_ROOT_PATH.'/modules/neothemesadmin/blocks/selectdb.php',$type="2",$fileex="",$from="",$fileurlnew="",$exclude="");
		//刪除無使用的selectdb.php
		fileadminfunction($fileurl=XOOPS_ROOT_PATH.'/modules/neothemesadmin/class/selectdb.php',$type="2",$fileex="",$from="",$fileurlnew="",$exclude="");
		//刪除無使用的function.php
		fileadminfunction($fileurl=XOOPS_ROOT_PATH.'/modules/neothemesadmin/class/function.php',$type="2",$fileex="",$from="",$fileurlnew="",$exclude="");
		//刪除無使用的assigntpl.php
		fileadminfunction($fileurl=XOOPS_ROOT_PATH.'/modules/neothemesadmin/blocks/assigntpl.php',$type="2",$fileex="",$from="",$fileurlnew="",$exclude="");
		//刪除無使用的centerblocks.tpl
		fileadminfunction($fileurl=XOOPS_ROOT_PATH.'/themes/neilambilight/computer/tpl/centerblocks.tpl',$type="2",$fileex="",$from="",$fileurlnew="",$exclude="");
		fileadminfunction($fileurl=XOOPS_ROOT_PATH.'/themes/neilambilight/phone/tpl/centerblocks.tpl',$type="2",$fileex="",$from="",$fileurlnew="",$exclude="");
		//刪除無使用的lrblockstpl.tpl
		fileadminfunction($fileurl=XOOPS_ROOT_PATH.'/themes/neilambilight/phone/tpl/lrblockstpl.tpl',$type="2",$fileex="",$from="",$fileurlnew="",$exclude="");
		//刪除無使用的blockfooter.tpl
		fileadminfunction($fileurl=XOOPS_ROOT_PATH.'/themes/neilambilight/computer/tpl/blockfooter.tpl',$type="2",$fileex="",$from="",$fileurlnew="",$exclude="");
		fileadminfunction($fileurl=XOOPS_ROOT_PATH.'/themes/neilambilight/phone/tpl/blockfooter.tpl',$type="2",$fileex="",$from="",$fileurlnew="",$exclude="");
		//刪除無使用的kxbdSuperMarquee.js
		fileadminfunction($fileurl=XOOPS_ROOT_PATH.'/themes/neilambilight/computer/js/kxbdSuperMarquee.js',$type="2",$fileex="",$from="",$fileurlnew="",$exclude="");
		fileadminfunction($fileurl=XOOPS_ROOT_PATH.'/themes/neilambilight/phone/js/kxbdSuperMarquee.js',$type="2",$fileex="",$from="",$fileurlnew="",$exclude="");
		//刪除無使用的jquery.mousewheel.js
		fileadminfunction($fileurl=XOOPS_ROOT_PATH.'/themes/neilambilight/phone/js/jquery.mousewheel.js',$type="2",$fileex="",$from="",$fileurlnew="",$exclude="");
		//刪除無使用的jquery.js
		fileadminfunction($fileurl=XOOPS_ROOT_PATH.'/modules/neillibrary/js/jquery.js',$type="2",$fileex="",$from="",$fileurlnew="",$exclude="");
		fileadminfunction($fileurl=XOOPS_ROOT_PATH.'/modules/neillibrary/js/jquery-3.3.1.min.js',$type="2",$fileex="",$from="",$fileurlnew="",$exclude="");
		fileadminfunction($fileurl=XOOPS_ROOT_PATH.'/modules/neillibrary/js/jquery-3.5.1.min.js',$type="2",$fileex="",$from="",$fileurlnew="",$exclude="");
		//刪除無使用的jquery-migrate.min.js
		fileadminfunction($fileurl=XOOPS_ROOT_PATH.'/modules/neillibrary/js/jquery-migrate.min.js',$type="2",$fileex="",$from="",$fileurlnew="",$exclude="");
		fileadminfunction($fileurl=XOOPS_ROOT_PATH.'/modules/neillibrary/js/jquery-migrate-3.3.0.min.js',$type="2",$fileex="",$from="",$fileurlnew="",$exclude="");
		//刪除無使用的smoothscroll
		fileadminfunction($fileurl="",$type="1",$fileex="",$from=XOOPS_ROOT_PATH.'/themes/'.$xoops_theme.'/computer/js/smoothscroll');
		//更新佈景設定參數
		$theme_set_allowed='a:21:{i:0;s:1:"1";i:1;s:1:"1";i:2;s:1:"1";i:3;s:1:"1";i:4;s:1:"1";i:5;s:1:"0";i:6;s:1:"1";i:7;s:1:"0";i:8;s:1:"1";i:9;s:1:"6";i:10;s:1:"0";i:11;s:1:"1";i:12;s:1:"1";i:14;s:1:"1";i:13;s:1:"1";i:15;s:1:"8";i:16;s:1:"8";i:17;s:8:"xsitemap";i:18;s:11:"logcounterx";i:19;s:0:"";i:20;s:2:"19";}';
		$sql = "update " . $xoopsDB->prefix("neothemesconfig") . " set `field`='".$theme_set_allowed."'";
		$xoopsDB->queryF($sql);
		//建立neilblocksicon資料表
		$sql="CREATE TABLE `".$xoopsDB->prefix("neilblocksicon")."` (
        `blocksid` smallint(5) unsigned NOT NULL AUTO_INCREMENT,
        `bid` smallint(5) unsigned NOT NULL default 0, /*區塊id*/
        `icon` varchar(255) NOT NULL default '', /* icon */  
         PRIMARY KEY (`blocksid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;";
		$xoopsDB->queryF($sql);
		//更改field欄位類型
		$sql="ALTER TABLE ".$xoopsDB->prefix("neothemesconfig")." 
    	CHANGE `field` `field` text NOT NULL default ''";
		$xoopsDB->queryF($sql);
		//清空computer->blocks
		fileadminfunction($fileurl="",$type="5",$fileex="",$from=XOOPS_ROOT_PATH.'/themes/'.$xoops_theme.'/computer/css/blocks',$fileurlnew="",$exclude=array('index.html','tad_link.css','tad_assignment.css','tad_idioms.css','tadnews.css'));
		//刪除neothemesadmin.css
		fileadminfunction($fileurl=XOOPS_ROOT_PATH.'/themes/'.$xoops_theme.'/computer/css/modules/neothemesadmin.css',$type="2",$fileex="",$from='');
		//清空phone->blocks
		fileadminfunction($fileurl="",$type="5",$fileex="",$from=XOOPS_ROOT_PATH.'/themes/'.$xoops_theme.'/phone/css/blocks',$fileurlnew="",$exclude=array('index.html','tad_link.css','tadgallery.css','tadnews.css','tad_honor.css','tad_form.css','tad_discuss.css','tad_cal.css','tad_assignment.css'));
		//刪除neothemesadmin.css
		fileadminfunction($fileurl=XOOPS_ROOT_PATH.'/themes/'.$xoops_theme.'/phone/css/modules/neothemesadmin.css',$type="2",$fileex="",$from="");
		//刪除neothemesconfig.sql
		fileadminfunction($fileurl=XOOPS_ROOT_PATH.'/modules/neothemesadmin/sql/neothemesconfig.sql',$type="2",$fileex="",$from="");
		///刪除tad_lunch2.css
		fileadminfunction($fileurl=XOOPS_ROOT_PATH.'/themes/'.$xoops_theme.'/phone/css/modules/tad_lunch2.css',$type="2",$fileex="",$from="");											
	    //更改多層自訂按鈕狀態->[nobox]
    	$layersList=bidnamefunction($op="",$bid="",$type="4",$var="`show_func` = 'neoblockmenulayers_block_show'",$id="show_func");
    	$setvar="set title='[nobox]".$layersList['title']."'    where bid='".$layersList['bid']."'";  
        update($dbname="newblocks",$set=$setvar);    		
	}	
	}	



function go_update27($xoops_theme="") {
	global $xoopsDB;
	//建立neil_address資料表
$sql="CREATE TABLE `".$xoopsDB->prefix("neil_address")."` (
  `menuid` mediumint(8) UNSIGNED NOT NULL AUTO_INCREMENT,
  `unit` varchar(255) NOT NULL default '', 
  `phone` varchar(255) NOT NULL default '', 
  `fax` varchar(255) NOT NULL default '', 
  `address` text NOT NULL,
  `remark` text NOT NULL, 
  `url` varchar(255) NOT NULL default '',   
  `target` enum('1','0') NOT NULL default '0',   		
  `fb` varchar(255) NOT NULL default '', 
  `line` varchar(255) NOT NULL default '', 
  `youtube` varchar(255) NOT NULL default '', 
  `maps` varchar(255) NOT NULL default '', 
  `btnsort` smallint(5) UNSIGNED NOT NULL default 0, 
  `enable` enum('1','0') NOT NULL default '1', 
   PRIMARY KEY (`menuid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;";
$xoopsDB->queryF($sql);
		
	//建立neil_textblock資料表
$sql="CREATE TABLE `".$xoopsDB->prefix("neil_textblock")."` (
  `textid` mediumint(8) UNSIGNED NOT NULL AUTO_INCREMENT,
  `title` varchar(255) NOT NULL default '', 
  `url` varchar(255) NOT NULL default '', 
  `target` enum('1','0') NOT NULL default '0',  
  `imgid` varchar(255) NOT NULL default '',  
  `content` text NOT NULL, /*內容*/    
  `btnsort` smallint(5) UNSIGNED NOT NULL default 0, 
  `enable` enum('1','0') NOT NULL default '1', 
   PRIMARY KEY (`textid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;";
$xoopsDB->queryF($sql);

//刪除無使用的tplthemescss.php
fileadminfunction($fileurl=XOOPS_ROOT_PATH.'/modules/neothemesadmin/admin/tplthemescss.php',$type="2",$fileex="",$from="",$fileurlnew="",$exclude="");	


//neothemesflash jpg轉png
foreach($imgArr=databasetablewhile($dbneme="neothemesflash",$wheree="  order by  nsn  ASC") as $key=> $val){
neillibrary_jpgtopng($input_file=XOOPS_ROOT_PATH.'/uploads/'.$xoops_theme.'/p'.$imgArr[$key]['imgid'].'.jpg',$output_file=XOOPS_ROOT_PATH.'/uploads/'.$xoops_theme.'/p'.$imgArr[$key]['imgid'].'.png');
}


	//建立neil_popupads資料表
$sql="CREATE TABLE `".$xoopsDB->prefix("neil_popupads")."` (
  `ad` mediumint(8) UNSIGNED NOT NULL AUTO_INCREMENT,
  `title` varchar(255) NOT NULL default '',  
  `url` varchar(255) NOT NULL default '',  
  `imgid` varchar(255) NOT NULL default '',  
  `target` enum('1','0') NOT NULL default '0',  
  `maturity` date NOT NULL, 
  `btnsort` smallint(5) UNSIGNED NOT NULL default 0, 
  `enable` enum('1','0') NOT NULL default '1', 
  `adenable` enum('1','0') NOT NULL default '0', 
   PRIMARY KEY (`ad`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;";
$xoopsDB->queryF($sql);


	//建立neil_lowerrightad資料表
$sql="CREATE TABLE `".$xoopsDB->prefix("neil_lowerrightad")."` (
  `rdad` mediumint(8) UNSIGNED NOT NULL AUTO_INCREMENT,
  `title` varchar(255) NOT NULL default '', 
  `url` text NOT NULL, 
  `imgid` varchar(255) NOT NULL default '',    
  `target` varchar(255) NOT NULL default '',  
  `maturity` date NOT NULL,
  `btnsort` smallint(5) UNSIGNED NOT NULL default 0, 
  `enable` enum('1','0') NOT NULL default '1', 
  `adenable` enum('1','0') NOT NULL default '0', 
   PRIMARY KEY (`rdad`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;";
$xoopsDB->queryF($sql);

}	



function go_update28($xoops_theme="") {
	global $xoopsDB;
	//判斷模組版本
	if(modulesmidvar($modulesid="neothemesadmin",$var="version") < '5.4') {
		//更新佈景設定參數	
		$theme_set_allowed='a:23:{i:0;s:1:"1";i:1;s:1:"1";i:2;s:1:"1";i:3;s:1:"1";i:4;s:1:"1";i:5;s:1:"0";i:6;s:1:"1";i:21;s:1:"5";i:7;s:1:"0";i:8;s:1:"1";i:9;s:1:"6";i:10;s:1:"0";i:11;s:1:"1";i:12;s:1:"1";i:14;s:1:"1";i:13;s:1:"1";i:15;s:1:"8";i:16;s:1:"8";i:17;s:8:"xsitemap";i:18;s:11:"logcounterx";i:19;s:0:"";i:20;s:2:"19";i:22;s:0:"";}';
		$sql = "update " . $xoopsDB->prefix("neothemesconfig") . " set `field`='".$theme_set_allowed."'";
		$xoopsDB->queryF($sql);
	}
	//刪除沒使用的ajax.php
    fileadminfunction($fileurl=XOOPS_ROOT_PATH.'/themes/'.$xoops_theme.'/program/ajax.php',$type="2",$fileex="",$from="",$fileurlnew="",$exclude="");	
	$sql="select  count(`imgwidth`) from ".$xoopsDB->prefix("neil_popupads");
	$result=$xoopsDB->query($sql);
	if(empty($result)) {
		//neothemesconfig新增欄位    
		$sql="ALTER TABLE ".$xoopsDB->prefix("neil_popupads")." 
    	ADD `imgwidth` varchar(255) NOT NULL default '' AFTER `adenable`
    	";
		$xoopsDB->queryF($sql);
	}
}


function go_update29($xoops_theme="") {
	global $xoopsDB;
	//刪除沒使用的xo_footerstatic.tpl
    fileadminfunction($fileurl=XOOPS_ROOT_PATH.'/themes/'.$xoops_theme.'/phone/tpl/xo_footerstatic.tpl',$type="2",$fileex="",$from="",$fileurlnew="",$exclude="");	
	//刪除沒使用的instructions.tpl
    fileadminfunction($fileurl=XOOPS_ROOT_PATH.'/themes/'.$xoops_theme.'/computer/tpl/instructions.tpl',$type="2",$fileex="",$from="",$fileurlnew="",$exclude="");	
    fileadminfunction($fileurl=XOOPS_ROOT_PATH.'/themes/'.$xoops_theme.'/phone/tpl/instructions.tpl',$type="2",$fileex="",$from="",$fileurlnew="",$exclude="");	 
    //刪除沒使用的instructions.php
    fileadminfunction($fileurl=XOOPS_ROOT_PATH.'/themes/'.$xoops_theme.'/program/instructions.php',$type="2",$fileex="",$from="",$fileurlnew="",$exclude="");	 
    //刪除沒使用的tadloginblocks.php
    fileadminfunction($fileurl=XOOPS_ROOT_PATH.'/themes/'.$xoops_theme.'/program/tadloginblocks.php',$type="2",$fileex="",$from="",$fileurlnew="",$exclude="");	 
    //刪除沒使用的neillibrary/js/bootstrap4color資料夾 
    fileadminfunction($fileurl="",$type="1",$fileex="",$from=XOOPS_ROOT_PATH.'/modules/neillibrary/js/bootstrap4color');    
}


//變更contactmatters欄位
function go_update30(){	
  global $xoopsDB;	
    $sql="ALTER TABLE ".$xoopsDB->prefix("neothemesconfig")." 
	CHANGE `contactmatters` `contactmatters` varchar(1020) NOT NULL default ''";	
    $xoopsDB->queryF($sql);       

    //刪除variableid欄位
	$sql="select  count(`variableid`) from ".$xoopsDB->prefix("neoblockmenubutton");
	$result=$xoopsDB->query($sql);
	if(!empty($result)) {
	$sql="ALTER TABLE ".$xoopsDB->prefix("neoblockmenubutton")." 
	DROP `variableid`,
	DROP `sortyn`";
	$xoopsDB->queryF($sql);
	}
    $sql="ALTER TABLE ".$xoopsDB->prefix("neoblockmenusort")." 
	CHANGE `sorttitleurl` `sorttitleurl` varchar(1020) NOT NULL default ''";	
    $xoopsDB->queryF($sql);  	
	
    return true;   
}



function go_update31() {
	global $xoopsDB;
	$sql="select  count(`address`) from ".$xoopsDB->prefix("neocontactusform");
	$result=$xoopsDB->query($sql);
	if(empty($result)) {
	$sql="ALTER TABLE ".$xoopsDB->prefix("neocontactusform")." 
	ADD  `address` text NOT NULL  AFTER `transfer`";
	$xoopsDB->queryF($sql);	
	
	//建立neil_digitalad資料表
    $sql="CREATE TABLE `".$xoopsDB->prefix("neil_digitalad")."` (
    `dgad` mediumint(8) UNSIGNED NOT NULL AUTO_INCREMENT,    
    `before_t` varchar(255) NOT NULL default '', 
    `digital` bigint(255) unsigned NOT NULL default 0,
    `after_t` varchar(255) NOT NULL default '', 
    `side_t` varchar(255) NOT NULL default '', 
    `btnsort` smallint(5) UNSIGNED NOT NULL default 0, 
    `enable` enum('1','0') NOT NULL default '1', 
    PRIMARY KEY (`dgad`)
    ) ENGINE=MyISAM;";
    $xoopsDB->queryF($sql);	

	//更新佈景設定參數	
	$theme_set_allowed='a:26:{i:0;s:1:"1";i:23;s:1:"0";i:1;s:1:"1";i:2;s:1:"1";i:3;s:1:"1";i:4;s:1:"1";i:5;s:1:"0";i:6;s:1:"1";i:21;s:1:"5";i:24;s:4:"1280";i:25;s:3:"400";i:7;s:1:"0";i:8;s:1:"1";i:9;s:1:"6";i:10;s:1:"0";i:11;s:1:"1";i:12;s:1:"1";i:14;s:1:"1";i:13;s:1:"1";i:15;s:1:"8";i:16;s:1:"8";i:17;s:8:"xsitemap";i:18;s:11:"logcounterx";i:19;s:0:"";i:20;s:2:"19";i:22;s:0:"";}';
	$sql = "update " . $xoopsDB->prefix("neothemesconfig") . " set `field`='".$theme_set_allowed."'";
	$xoopsDB->queryF($sql);
   
    //新增typeval欄位
	$sql="ALTER TABLE ".$xoopsDB->prefix("neothemesflash")." 
	ADD  `typeval` enum('1','0') NOT NULL default '0'  AFTER `enable`";
	$xoopsDB->queryF($sql);		
	}
	
	
    $sql="ALTER TABLE ".$xoopsDB->prefix("neothemesmenu")." 
	CHANGE `of_sortid` `of_sortid` mediumint(8) unsigned NOT NULL default 0,
	CHANGE `sortidsort` `sortidsort` mediumint(8) unsigned NOT NULL default 0
	";	
    $xoopsDB->queryF($sql);  	

    $sql="ALTER TABLE ".$xoopsDB->prefix("neoblockmenusort")." 
	CHANGE `sortid` `sortid` mediumint(8) unsigned NOT NULL AUTO_INCREMENT";	
    $xoopsDB->queryF($sql);  
	
    $sql="ALTER TABLE ".$xoopsDB->prefix("neoblockmenubutton")." 
	CHANGE `of_sortid` `of_sortid` mediumint(8) unsigned NOT NULL default 0,
	CHANGE `categoryid` `categoryid` mediumint(8) unsigned NOT NULL default 0
	";	
    $xoopsDB->queryF($sql);  
	
    $sql="ALTER TABLE ".$xoopsDB->prefix("neocontactusform")." 
	CHANGE `cfid` `cfid` bigint(255) unsigned NOT NULL AUTO_INCREMENT";	
    $xoopsDB->queryF($sql);  	
    
    $sql="ALTER TABLE ".$xoopsDB->prefix("neilblocksicon")." 
	CHANGE `blocksid` `blocksid` bigint(255) unsigned NOT NULL AUTO_INCREMENT,
	CHANGE `bid` `bid` bigint(255) unsigned NOT NULL default 0
	";	
    $xoopsDB->queryF($sql);  
	
	
	return true;
}


function go_update32($xoops_theme="") {
//刪除沒使用的adjustment.js
fileadminfunction($fileurl=XOOPS_ROOT_PATH.'/themes/'.$xoops_theme.'/computer/js/adjustment.js',$type="2",$fileex="",$from="",$fileurlnew="",$exclude="");	
fileadminfunction($fileurl=XOOPS_ROOT_PATH.'/themes/'.$xoops_theme.'/phone/js/adjustment.js',$type="2",$fileex="",$from="",$fileurlnew="",$exclude="");	
//刪除沒使用的bootstrap-touch-slider.css
fileadminfunction($fileurl=XOOPS_ROOT_PATH.'/themes/'.$xoops_theme.'/computer/css/style/bootstrap-touch-slider.css',$type="2",$fileex="",$from="",$fileurlnew="",$exclude="");	
fileadminfunction($fileurl=XOOPS_ROOT_PATH.'/themes/'.$xoops_theme.'/phone/css/style/bootstrap-touch-slider.css',$type="2",$fileex="",$from="",$fileurlnew="",$exclude="");	
}

//增加field欄位
function go_update33(){	
  global $xoopsDB;
  $sql="select  count(`field`) from ".$xoopsDB->prefix("neocontactusform");
  $result=$xoopsDB->query($sql);
  if(empty($result)){
    $sql="ALTER TABLE ".$xoopsDB->prefix("neocontactusform")." 
	ADD  `field` longtext NOT NULL  AFTER `address`";	
    $xoopsDB->queryF($sql);
  }
}

?>