MOON
Server: Apache
System: Linux 54-179-220-51.cprapid.com 3.10.0-1160.144.1.el7.tuxcare.els4.x86_64 #1 SMP Tue Apr 7 08:40:40 UTC 2026 x86_64
User: thehunarfound (1001)
PHP: 7.4.29
Disabled: NONE
Upload Files
File: /home/thehunarfound/public_html/sms/lib/common_function.php
<?php 
global $db_old;
class connect
{
	/* Connection to Database*/
	function connect()
	{
		
		//*/$servername = "localhost";
		/*$username = "supergiz_dev2ur";
		$password = "Boom_268";
		$database = "supergiz_dev2";*/

		/*
		$servername = "localhost";
		$username = "supergiz_live";
		$password = "Boom_268";
		$database = "supergiz_live";*/

		/**/
		
// 		$servername = "localhost";
// 		$username = "root";
// 		$password = "";
// 		$database = "CMA";
		
		$servername = "localhost";
		$username = "hunar_sms";
		$password = "@zaQh[2qq?[@321";
		$database = "hunar_sms";
		
		
		/*$servername = "localhost";
		$username = "supergiz_dev";
		$password = "Boom_268";
		$database = "supergiz_dev";*/
		
		$con = mysql_connect($servername,$username,$password);
		$database = mysql_select_db($database,$con);
	} 

	/* Function to fetch all records */
	function record_set($table="", $where="", $order="", $limit="")
	{
		$sql = "select * from $table";
		
		if($where!='')
		{
			$sql = $sql." ".$where;
		
		}
		
		if($order!='')
		{
			$sql = $sql." ORDER BY ".$order;
		}
		if($limit!='')
		{
			$sql = $sql." ".$limit;
		}
		
		$result = mysql_query($sql) or die(mysql_error());
		if($result)
		{
		while($row = mysql_fetch_assoc($result))
			{
				$output[] = $row;  //store result in array
						
			}
				
			return $output;
	   }
	   else
	   {
	   		return false;
	   }
	   
			
	} 

 function single_record($table="", $field="", $where="", $order="", $limit="")
	{
		$sql = "select $field from $table";
		if($where!='')
		{
			$sql = $sql." ".$where;
		}
		if($order!='')
		{
			$sql = $sql." ORDER BY ".$order;
		}
		if($limit!='')
		{
			$sql = $sql." ".$limit;
		}
		
   // echo $sql;
		$result = mysql_query($sql) or die(mysql_error());
		if($result)
		{
		while($row = mysql_fetch_object($result))
			{
				$output = $row; 
						
			}
				
			return $output;
	   }
	   else
	   {
	   		return false;
	   }
	   
			
	} 


function verify($username,$password,$tb)
   	{
		$query="SELECT user_pass FROM `$tb` WHERE user_login='$username'";
		$result = mysql_query($query);
		if(!$result)  
			{
				 echo "Error Occured:".mysql_error()."Error No:".mysql_errno()."<br>";
			}
		else
			{
				$row = mysql_fetch_row($result);
				$cpassword = $row[0];
				$password = md5($password); //md5() - to encrypt entered password.
				if(!mysql_num_rows($result))
				{
				  return(0); //not registered
				}   
				else
				{
					if($password == $cpassword)
					 {   session_start();
						 $_SESSION['user_login'] = $username; //successful login
						  return(1);
					 }
					 else
					 {
						return(2); //password incorrect
					 }
		 		 }
			}
    } //End of function verify
	
	
	/* Function to Log out*/
	function logout()
	{		
		unset($_SESSION['member_id']);
		session_destroy();
		echo "<script>window.location='index.php'</script>";
	} 
	
	function agent_logout()
	{		
		unset($_SESSION['agentid']);
		session_destroy();
		echo "<script>window.location='index.php'</script>";
	} 

	/* To check user has logged in or not */
	function chk_agent_login()
	{
		if (empty($_SESSION['agentid']) or $_SESSION['agentid'] == '')
		{
		echo "<script>window.location='index.php'</script>";
		}
	}
	
	
	function chk_member_login()
	{
		if (empty($_SESSION['member_id']) or $_SESSION['member_id'] == '')
		{
		echo "<script>window.location='mysg_login.php'</script>";
		}
	}
	
	
	function chk_sg_brokers_member_login()
	{
		if (empty($_SESSION['member_id']) or $_SESSION['member_id'] == '')
		{
		echo "<script>window.location='sg_brokers_login.php'</script>";
		}
	}

	function randomid()
	{
		$num1 = rand(1000, 9999);
		$num2 = rand(1, 9);
		$num = $num1 . $num2;
	return $num;
	}
	
	function genListingID($agentid)
	{
		global $db_old;
		
		$getAgent = $db_old->single_record("sg_agents", "first_name,last_name, state", "Where agent_id = '$agentid'", "", "");
		
		$firstname = $getAgent->first_name;
		$twoletters = substr($firstname,0,2);
		$lastname = $getAgent->last_name;
		$stateid = $getAgent->state;
		
		/*$getState = $db_old->single_record("sg_state", "StateAbbreviation", "Where Stateid = '$stateid'", "", "");
		$stateA = $getState->StateAbbreviation;*/
		
		$digits = $db_old->randomid();
		
		//$resultData = strtoupper($lastname.$stateA)."-".$digits;
		$resultData = strtoupper($twoletters.$lastname)."-".$digits;
		
		return $resultData;
		
	}
	
	function genListingIDOffice($officeid)
	{
		global $db_old;
		
		$getOffice = $db_old->single_record("sg_offices", "first_name,last_name", "Where office_id = '$officeid'", "", "");
		
		$firstname = $getOffice->first_name;
		$twoletters = substr($firstname,0,2);
		$lastname = $getOffice->last_name;
		
		/*$getState = $db_old->single_record("sg_state", "StateAbbreviation", "Where Stateid = '$stateid'", "", "");
		$stateA = $getState->StateAbbreviation;*/
		
		$digits = $db_old->randomid();
		
		//$resultData = strtoupper($lastname.$stateA)."-".$digits;
		$resultData = strtoupper($twoletters.$lastname)."-".$digits;
		
		return $resultData;
		
	}

function prop_name($catid)
{
	global $db_old;
	$property_name = $db_old->single_record("sg_category","category","where category_id ='$catid'","","");
	$pname = $property_name->category;
	return $pname;
}

}  // End of class connect


?>