? 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/libs/
File Upload :
Current File : /home/admin/domains/happytokorea.com/public_html/libs/MySql.php

<?php
class MySql
{
	//÷觤 SQL
	var $_sql;
	//纤 Resource ҡõԡ ҹ  MYSQL
	var $_resource;
	//纤 ID 任żŷҹ MYSQL
	var $_result;
//纤ҷաäԴҴ RETURN Ẻ Integer
	var $_errorNum=0;
	//纤ҷԴҴ STRING
	var $_errorMsg="";
//ѧѹԴͰҹ MYSQL
   var $_cur;
// poiter Resource
	function MySql()
	{
		global $cfg;
		//ԴͰҹ
		if(!($this->_resource=@mysql_connect($cfg['db_host'],$cfg['db_user'],$cfg['db_password']))){
		echo "can not  connect database";
		exit();
		}
		//͡ҹ
	//	COLLATE 'utf8_general_ci';");
	
	$conn = @mysql_connect($cfg['db_host'],$cfg['db_user'],$cfg['db_password']);
	@mysql_select_db($cfg['db_name'])or die(mysql_error());
	
	if(!mysql_query("SET NAMES 'utf8' COLLATE 'utf8_general_ci'",$conn)){
		echo mysql_error();
		echo "<br>can not slelect db name";
			exit();
		}
/*
		if(!@mysql_select_db($cfg['db_name'])){
			echo "can not slelect db name";
			exit();
		}
		*/
	}//Դѧѹ sql_db

	function closeMysql()
	{
		mysql_close($this->_resource);
	}//end db_close()

	function setQuery($sql)
	{
	$this->_sql=trim($sql);
	}

// ѧѹ 觤 Query
	function  QueryReturn()
	{
		$this->_result = mysql_query( $this->_sql,$this->_resource);
		return $this->_result;
	}// Դ function QueryReturn()
	function  QueryReturn2($sql)
	{
		$this->_sql=trim($sql);
		$this->_result = mysql_query( $this->_sql,$this->_resource);
		return $this->_result;
	}// Դ function QueryReturn()
//ա觤ҡѺ
	function freeQuery()
	{
		$this->_result = mysql_query( $this->_sql,$this->_resource);
	}// Դ function QueryNoReturn()

	//ա觤ҡѺͧ setQuery 
	//ҧ $result=$this->Query("select * from table1");
	function Query($sql){
	$result=$this->QueryReturn($this->setQuery($sql));
	return $result;
}
	function mysqlError(){
		$this->__errorMsg=mysql_error();
		return $this->__errorMsg;
}//end mysql Error
function numRows()
	{
		return @mysql_num_rows($this->_result);
	}//end numRows

	function loadObject()
	{
		$objcet= array();
		$cur=$this->QueryReturn();
		while($ob=mysql_fetch_object($cur)){
		$object[]=$ob;
		}
		mysql_free_result($cur);
return $object;
	}
	Function getDataOneColum($table,$field){
		$object=Array();
		$FieldData=Array();
		$this->_sql="SELECT $field FROM $table";
		$this->setQuery($this->_sql);
		$this->_result=$this->QueryReturn();
		$numrow=$this->numRows();
		if($numrow!=0){
		While($arr=mysql_fetch_array($this->_result)){
		$object[]=$arr[0];
		}//end while
		}//end if numRows
		mysql_free_result($this->_result);
			Return $object;
	}
	/*
	ѧѹ getDataOneRow 
	觤Ңŷ Array 㹵ҧšѺ
	Ը  㹵ҧ  user=>id,user,pass
	$data=getDataOneRow('user',$key,'field');
	$output=$data['id'];
	$output2=$data['user'];
	$output.....
	*/
	function getDataOneRow($table,$key,$condition){
        $object=Array();
		$FieldName=Array();
		$this->_sql="SELECT * FROM $table";
		$this->setQuery($this->_sql);
		$this->_result=$this->QueryReturn();
		$i = 0;
while ($i < @mysql_num_fields($this->_result)) {
    $meta = mysql_fetch_field($this->_result, $i);
	$FieldName[]=$meta->name;
	$i++;
}
$num_field=$i;
@mysql_free_result($this->_result);
		$this->_sql="SELECT * FROM $table WHERE $condition='$key'";
		$this->setQuery($this->_sql);
		$this->_result=$this->QueryReturn();
		$i=0;
		if($this->numRows()!=0){
		$arr=mysql_fetch_array($this->_result);
		for($i=0;$i<$num_field;$i++){
			$object[$FieldName[$i]]=$arr[$FieldName[$i]];
		}
	}//end if numRows
		@mysql_free_result($this->_result);
			Return $object;
	}
	/*
ѧѹŴǵ $table  ͹
 $data=$db->getRow('member','where id=1');
	*/
function getRow($table,$condition){
        $object=Array();
		$FieldName=Array();
		$this->_sql="SELECT * FROM $table";
		$this->setQuery($this->_sql);
		$this->_result=$this->QueryReturn();
		$i = 0;
while ($i < @mysql_num_fields($this->_result)) {
    $meta = mysql_fetch_field($this->_result, $i);
	$FieldName[]=$meta->name;
	$i++;
}
$num_field=$i;
@mysql_free_result($this->_result);
		$this->_sql="SELECT * FROM $table $condition";
		$this->setQuery($this->_sql);
		$this->_result=$this->QueryReturn();
		$numrow=$this->numRows();
		$i=0;
		if($numrow!=0){
		$arr=mysql_fetch_array($this->_result);
		for($i=0;$i<$num_field;$i++){
			$object[$FieldName[$i]]=$arr[$FieldName[$i]];
		}
	}//end if numRows
		@mysql_free_result($this->_result);
			Return $object;
	}
	/*
	Ҥҷѹ֡شҡҹ
	*/
function getLastInsert($field,$table,$condition){
	$result=mysql_query("select max($field) from $table $condition");
	$data=mysql_fetch_array($result);
	return $data[0];
}//ѧѹ
function Insert($table,$filed){
 $chk_count=count($filed);
 $i=0;
foreach($filed as $key=>$v){    
			$i++;
//	$v=$this->db_input($v);
if($i==$chk_count){
			$fields.="$key";
			$value.="'$v'";
	}else{
			$value.="'$v',";
			$fields.="$key,";
	}
}// foreach
			$sql="insert into $table (".$fields.") values (".$value.")";
			$this->setQuery($sql);
			$result=$this->QueryReturn();
			if($result){$return=1;}else{ $return=0;}
	return $return;
}//end function Insert
function Update($table,$filed,$condition){
 $chk_count=count($filed);
 $i=0;
foreach($filed as $key=>$value){    
			$i++;
		$v=$this->db_input($v);
if($i==$chk_count){
			$data.="$key='$value'";
	}else{
			$data.="$key='$value',";
	}
}// foreach
			$sql="UPDATE $table set $data $condition";
			$this->setQuery($sql);
			$result=$this->QueryReturn();
			if($result){
							$return=true;
				}else{ $return=false;}
	return $return;
}//end function Insert
/* 
Ǩͺ $data 㹰ҹͻ
*/
function check_data($table,$field,$data){
$this->Query("SELECT $field FROM $table where $field='$data'");
$numRow=$this->numRows();
return $numRow;
}
function check_data_edit($table,$field,$data,$id_field,$id){
$this->Query("SELECT $field FROM $table where $field='$data' and $id_field!='$id'");
$numRow=$this->numRows();
return $numRow;
}
 function db_input($string) {

    if (function_exists('mysql_real_escape_string')) {
      return mysql_real_escape_string($string, $this->_resource);
    } elseif (function_exists('mysql_escape_string')) {
      return mysql_escape_string($string);
    }
    return htmlspecialchars($string);
  }
  function db_output($string) {
	  $string=htmlspecialchars($string);
	  $string=stripslashes($string);
    return $string;
  }
  function count_data($table,$condition){
$this->setQuery("SELECT COUNT(*) FROM $table $condition");
$result=$this->QueryReturn();
$totalRows = mysql_fetch_row($result);
 return $totalRows[0];
  }
}//Դ class db_Sql




?>

T1KUS90T
  root-grov@210.1.60.28:~$