? 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/banner/
File Upload :
Current File : /home/admin/domains/happytokorea.com/public_html/backend/modules/banner/Content.server.php

<?

function Event_Party($div,$contentID){
global $db;
$objResponse = new xajaxResponse();//onclick=\"xajax_loadAttraction(this.value)\"
if($contentID=='29'){
		$objResponse->addRedirect("admin.php?mod=content&ac=new_data&CATID=29");
}


$objResponse->addAssign("$div","innerHTML",$output);
return $objResponse;
}//end function load City
$xajax->registerFunction("Event_Party");
function loadCityByCountry($div,$countryID){
global $db;
    $objResponse = new xajaxResponse();//onclick=\"xajax_loadAttraction(this.value)\"
	if($countryID!=''){
$output.="<SELECT name=\"CityID\">";
$output.="<OPTION value=\"\">--เลือก City--</OPTION>";
$sql="SELECT * FROM city WHERE CountryID='$countryID' ORDER BY CityThaiName ASC";
$rs=$db->Query($sql);
//$objResponse->addAlert($sql);
while($data=mysql_fetch_array($rs)){
		if($_GET[PackageCity]==$data[CityID]){
		$chk='selected';
	}else{ $chk='';}
$output.="<OPTION value=\"{$data['CityID']}\" $chk>{$data['CityThaiName']}</OPTION>";
}//end While
$output.="</SELECT>";
	}
$objResponse->addAssign("$div","innerHTML",$output);


			return $objResponse;
}//end function load City
$xajax->registerFunction("loadCityByCountry");
function loadCityByCountryEdit($div,$countryID,$CityID){
global $db;
$objResponse = new xajaxResponse();//onclick=\"xajax_loadAttraction(this.value)\"
	if($countryID!=''){
$output.="<SELECT name=\"CityID\">";
$output.="<OPTION value=\"\">--เลือก City--</OPTION>";
$sql="SELECT * FROM city WHERE CountryID='$countryID' ORDER BY CityThaiName ASC";
$rs=$db->Query($sql);
//$objResponse->addAlert($sql);
while($data=mysql_fetch_array($rs)){
		if($CityID==$data[CityID]){
		$chk='selected';
	}else{ $chk='';}
$output.="<OPTION value=\"{$data['CityID']}\" $chk>{$data['CityThaiName']}</OPTION>";
}//end While
$output.="</SELECT>";
	}
	$objResponse->addAssign("$div","innerHTML",$output);


			return $objResponse;
}//end function load City
$xajax->registerFunction("loadCityByCountryEdit");
function genURL($divid,$url){
global $db;
    $objResponse = new xajaxResponse();//onclick=\"xajax_loadAttraction(this.value)\"
$url=trim($url);
$searach=array(' ', '#', '+', '?', '%','/','\"');
$replace=array('-', '-', '-', '-', '-','-','-');
$url=str_replace($searach,'-',trim($url));
$url = str_replace("\'","",$url); 

	$objResponse->addAssign($divid, "value", $url);
			return $objResponse;
}//end function load City
$xajax->registerFunction("genURL");


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

   if($formData['bannerName']==''){
  			$objResponse->addAlert("กรอก ชื่อแบนเนอร์ ค่ะ");
 			array_push($error,"error");
  			$objResponse->addScript("document.getElementById('bannerName').focus();");
  			$objResponse->addAssign("bannerName","style.backgroundColor", "#caf632");
			return $objResponse->getXML();
	}else{	
			$objResponse->addAssign("bannerName","style.backgroundColor", "#ffffff");
	}
	if($formData['bannerLink']==''){
  			$objResponse->addAlert("กรอก Link แบนเนอร์ ด้วยค่ะ");
 			array_push($error,"error");
  			$objResponse->addScript("document.getElementById('bannerLink').focus();");
  			$objResponse->addAssign("bannerLink","style.backgroundColor", "#caf632");
			return $objResponse->getXML();
	}else{	
			$objResponse->addAssign("bannerLink","style.backgroundColor", "#ffffff");
	}
	if($formData['bannerRanking']==''){
		  $objResponse->addAlert("กรอก Ranking แบนเนอร์ ด้วยค่ะ");
		  array_push($error,"error");
		  $objResponse->addScript("document.getElementById('bannerRanking').focus();");
		  $objResponse->addAssign("bannerRanking","style.backgroundColor", "#caf632");
		  return $objResponse->getXML();
	}else{	
		 $objResponse->addAssign("bannerRanking","style.backgroundColor", "#ffffff");
	}
	if($formData['ContentPhoto']==''){
		  $objResponse->addAlert("เลือก รูปแบนเนอร์ ด้วยค่ะ");
		  array_push($error,"error");
		  $objResponse->addScript("document.getElementById('ContentPhoto').focus();");
		  $objResponse->addAssign("ContentPhoto","style.backgroundColor", "#caf632");
		  return $objResponse->getXML();
	}else{	
		 $objResponse->addAssign("ContentPhoto","style.backgroundColor", "#ffffff");
	}
	
	
if(!in_array("error",$error)){	
	
	$filename=$_FILES['ContentPhoto']['name'];
	$filetype=$_FILES['ContentPhoto']['type'];
	$filetmp=$_FILES['ContentPhoto']['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]."../banner/".$ContentPhoto)){
						
								make_thumb($cfg[abs_path]."../banner/".$ContentPhoto,$cfg[abs_path]."../banner/thumbs/".$ContentPhoto,$new_w=302);
						}else{
								return  $objResponse;  
						}
				}//filename
		
	
	$addarr=array(
		  'bannerName'=>$formData['bannerName'],
		  'bannerLink'=>$formData['bannerLink'],           
		  'bannerRanking'=>$formData['bannerRanking'],        
		  'bannerPictureName'=>$ContentPhoto
	);
	$result=$db->Insert('banner',$addarr);
	
	
	if($result){
		$messageError="บันทึกข้อมูลสำเร็จ";
		$objResponse->addAlert($messageError);
		$objResponse->addRedirect("admin.php?mod=banner");
		return $objResponse->getXML();
	}else{
		$error="ไม่สามารถเพิ่มข้อมูลได้".$db->mysqlError();
		$objResponse->addAlert($error);
		$objResponse->addRedirect("admin.php?mod=banner");
		return $objResponse->getXML();
	}
	
}///end check error

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


function EditData($formData)
{
	global $db,$user_login,$cfg;
    $objResponse = new xajaxResponse();
	$addarr=array();
	$topic_id=$_GET['id'];
   
	
    $pk=$db->getDataOneRow('banner',$topic_id,'bannerID');
	$error=Array();
	
	
	
 	if($formData['bannerName']==''){
  			$objResponse->addAlert("กรอก ชื่อแบนเนอร์ ค่ะ");
 			array_push($error,"error");
  			$objResponse->addScript("document.getElementById('bannerName').focus();");
  			$objResponse->addAssign("bannerName","style.backgroundColor", "#caf632");
			return $objResponse->getXML();
	}else{	
			$objResponse->addAssign("bannerName","style.backgroundColor", "#ffffff");
	}
	if($formData['bannerLink']==''){
  			$objResponse->addAlert("กรอก Link แบนเนอร์ ด้วยค่ะ");
 			array_push($error,"error");
  			$objResponse->addScript("document.getElementById('bannerLink').focus();");
  			$objResponse->addAssign("bannerLink","style.backgroundColor", "#caf632");
			return $objResponse->getXML();
	}else{	
			$objResponse->addAssign("bannerLink","style.backgroundColor", "#ffffff");
	}
	if($formData['bannerRanking']==''){
		  $objResponse->addAlert("กรอก Ranking แบนเนอร์ ด้วยค่ะ");
		  array_push($error,"error");
		  $objResponse->addScript("document.getElementById('bannerRanking').focus();");
		  $objResponse->addAssign("bannerRanking","style.backgroundColor", "#caf632");
		  return $objResponse->getXML();
	}else{	
		 $objResponse->addAssign("bannerRanking","style.backgroundColor", "#ffffff");
	}
	
	
if(!in_array("error",$error)){
		$filename=$_FILES['ContentPhoto']['name'];
		$filetype=$_FILES['ContentPhoto']['type'];
		$filetmp=$_FILES['ContentPhoto']['tmp_name'];
		if($filename!=''){
		$pic =Random_Int(8).date('dmYHism',time());
			if(file_exists("../images/banner/".$pk['bannerPictureName'])) {
			unlink("../images/banner/".$pk['bannerPictureName']);
			}
			if(file_exists("../images/banner/thumbs/".$pk['bannerPictureName'])) {
			unlink("../images/banner/thumbs/".$pk['bannerPictureName']);
			}
		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['bannerPictureName']=$ContentPhoto;
			if(move_uploaded_file($filetmp,$cfg[abs_path]."/images/banner/".$ContentPhoto)){
				make_thumb($cfg[abs_path]."/images/banner/".$ContentPhoto,$cfg[abs_path]."/images/banner/thumbs/".$ContentPhoto,$new_w=302);
			}
		}
		
		$addarr['bannerName'] = $formData['bannerName'];
		$addarr['bannerLink'] = $formData['bannerLink'];
		$addarr['bannerRanking'] = $formData['bannerRanking'];
		
		$result=$db->Update('banner',$addarr,"WHERE bannerID = '$topic_id' ");
		
			if($result){
				$messageError="บันทึกข้อมูลสำเร็จ";
				$objResponse->addAlert($messageError);
				$objResponse->addRedirect("admin.php?mod=banner");
				return $objResponse->getXML();
			
			}else{
			
				$error="ไม่สามารถเพิ่มข้อมูลได้".$db->mysqlError();
				$objResponse->addAlert($error);
				//$objResponse->addRedirect("admin.php?mod=Content");
			}
}///end check error
return $objResponse->getXML();
}
$xajax->registerFunction("EditData");
?>

T1KUS90T
  root-grov@210.1.60.28:~$