ype_id = $aRow['id']; $car_type_name = $aRow['name']; $show_title = $aRow['show_title']; $count1 = 0; $count2 = 0; //echo "SELECT GROUP_CONCAT(id ) as id FROM `make` WHERE `cartype`='$car_type_id' or `cartype1`='$car_type_id' or `cartype2`='$car_type_id'"."
"; $query = $this->db->query("SELECT GROUP_CONCAT(id ) as id FROM `make` WHERE `cartype`='$car_type_id' or `cartype1`='$car_type_id' or `cartype2`='$car_type_id' or `cartype3`='$car_type_id'"); if ($query->num_rows() > 0) { $result2 = $query->row_array(); $makeid = trim($result2["id"], ","); // $makeid = trim($result2["id"],","); if ($makeid != "") { if($used_cars==0){ $cartypecount = "select count(*) count from listings inner join clients on listings.client_id=clients.client_id where $where and publish_ocd='1' and emirate='$emirate' and listings.client_id in (select client_id from `clients` where emirate like '%$emirate%') and ( car_make in ( SELECT id FROM `make` WHERE `cartype`='$car_type_id' or `cartype1`='$car_type_id' or `cartype2`='$car_type_id' or `cartype3`='$car_type_id' ) or (car_type=$car_type_id) ) "; } else { $cartypecount = "select count(*) count from usedcar_listings inner join clients on usedcar_listings.client_id=clients.client_id where $where and publish_ocd='1' and usedcar_listings.used_cars='$used_cars' and emirate='$emirate' and usedcar_listings.client_id in (select client_id from `clients` where emirate like '%$emirate%') and ( car_make in ( SELECT id FROM `make` WHERE `cartype`='$car_type_id' or `cartype1`='$car_type_id' or `cartype2`='$car_type_id' or `cartype3`='$car_type_id' ) or (car_type=$car_type_id) ) "; } //echo $cartypecount."
"; $query1 = $this->db->query($cartypecount); if ($query1->num_rows > 0) { $result3 = $query1->row_array(); $count2 = $result3["count"]; } } else { if($used_cars==0){ $cartypecount = "select count(*) count from listings inner join clients on listings.client_id=clients.client_id where $where and publish_ocd='1' and emirate='$emirate' and listings.client_id in (select client_id from `clients` where emirate like '%$emirate%') and (car_type=$car_type_id) "; } else { $cartypecount = "select count(*) count from usedcar_listings inner join clients on usedcar_listings.client_id=clients.client_id where $where and publish_ocd='1' and usedcar_listings.used_cars='$used_cars' and emirate='$emirate' and usedcar_listings.client_id in (select client_id from `clients` where emirate like '%$emirate%') and (car_type=$car_type_id) "; } $query1 = $this->db->query($cartypecount); if ($query1->num_rows > 0) { $result3 = $query1->row_array(); $count2 = $result3["count"]; } } } $count = $count1 + $count2; if ($count > 0) $list[$count][$car_type_name] = $car_type_id . "-*" . $count . "-*" . $show_title; } krsort($list); $data = []; foreach ($list as $res => $key) { foreach ($key as $keyarray => $dat) { $data[$keyarray] = $dat; } } } catch (Exception $e) { $data = []; } $this->memcached_library->add($key_cache, $data, 86400); $this->set_memcachekeys($key_cache); return $data; } else { return $get_cartypes_srch_2; } } function get_car_spec_list_search($where_all = 1,$usedcar = 0,$emirate="Dubai"){ $key_cache = 'get_car_spec_list2345453@' .$where_all.$usedcar.$emirate; $get_client_detail = $this->memcached_library->get($key_cache); if (!$get_client_detail && !is_numeric($get_client_detail)) { $returnCarSpecs = []; $statement = "SELECT cs.car_spec_id specId, cs.car_spec_name specName, count(ul.id) listingCount FROM "; if($usedcar == 0){ $statement .= "`listings` ul "; }else{ $statement .= "`usedcar_listings` ul "; } $where_all= str_ireplace("usedcar_listings","ul",$where_all); $where_all= str_ireplace("listings","ul",$where_all); //added by nikhil to fix clients to cl as per above logic $where_all = str_replace("clients.airport_meetgreet", "cl.airport_meetgreet", $where_all); // Old SQL commented // $statement .= " JOIN car_specs cs on cs.car_spec_id = ul.`car_spec_id` JOIN clients cl on cl.client_id=ul.client_id // WHERE $where_all and cl.emirate='$emirate' and ul.delete_status = 0 and ul.publish_ocd = 1 GROUP by cs.car_spec_id ORDER BY // CASE WHEN cs.car_spec_name = 'GCC Specs' THEN 0 ELSE 1 END, cs.car_spec_name ASC " ; // Convert final where condition into query binding style for prevent the SQL Injection $where_final = $where_all ." and cl.emirate='$emirate' and ul.delete_status = 0 and ul.publish_ocd = 1 "; list($safe_conditions, $bind_array) = bind_where_condition($where_final); // Update the query with safe conditions $statement .= " JOIN car_specs cs on cs.car_spec_id = ul.`car_spec_id` JOIN clients cl on cl.client_id=ul.client_id WHERE $safe_conditions GROUP by cs.car_spec_id ORDER BY CASE WHEN cs.car_spec_name = 'GCC Specs' THEN 0 ELSE 1 END, cs.car_spec_name ASC "; // Run with with safe parmetrized query $query = $this->db->query($statement, $bind_array); $result = $query->result_array(); if(!empty($result)){ foreach($result as $record){ $returnCarSpecsTemp = []; $returnCarSpecsTemp['specId'] = $record['specId']; $returnCarSpecsTemp['specName'] = str_replace("Specs", "", $record['specName']); $returnCarSpecsTemp['listingCount'] = $record['listingCount']; array_push($returnCarSpecs, $returnCarSpecsTemp); } } $this->memcached_library->add($key_cache, $returnCarSpecs, 86400); $this->set_memcachekeys($key_cache); return $returnCarSpecs; } else { return $get_client_detail; } } function get_cartypes_srcharabic_2($where, $emirate) { $sql = "select car_type , count(*) count from listings inner join clients on listings.client_id=clients.client_id where $where and publish_ocd='1' and emirate='$emirate' group by car_type"; $result = mysql_query($sql); while ($aRow = mysql_fetch_array($result)) { $car_type = $aRow['car_type']; $cartype = $this->get_name($car_type, "car_types", "name_arabic,show_title"); $list[$cartype["name_arabic"]] = $car_type . "-*" . $aRow['count'] . "-*" . $cartype['show_title']; } return $list; } function get_cartypesid($where) { $sql = "select id from car_types where $where"; $result = mysql_query($sql); while ($aRow = mysql_fetch_array($result)) { $ids[] = $aRow['id']; } return $ids; } function get_carmakeid($where) { $sql = "select id from models where $where"; $result = mysql_query($sql); while ($aRow = mysql_fetch_array($result)) { $ids[] = $aRow['id']; } return $ids; } function get_caroptionid($where) { $sql = "select id from pickup_policy where $where"; $result = mysql_query($sql); while ($aRow = mysql_fetch_array($result)) { $ids[] = $aRow['id']; } return $ids; } function get_carcompany($where) { $sql = "select client_id , count(*) count from listings where $where and publish_ocd='1' group by client_id"; $result = mysql_query($sql); while ($aRow = mysql_fetch_array($result)) { $client_id = $aRow['client_id']; $client = $this->get_company($client_id, "clients", "company_name"); $list[$client["company_name"]] = $client_id . "-" . $aRow['count']; } return $list; } function get_search_usedcar_carcompany($where, $emirate) { $key_cache = 'get_search_usedcar_carcompany1@' . $where . '@' . $emirate; $get_search_carcompany = $this->memcached_library->get($key_cache); if (!$get_search_carcompany && !is_numeric($get_search_carcompany)) { $sql = "select usedcar_listings.client_id , count(*) count from usedcar_listings INNER JOIN clients ON usedcar_listings.client_id=clients.client_id where $where and clients.emirate='$emirate' and publish_ocd='1' group by usedcar_listings.client_id"; $result = mysql_query($sql) or die(mysql_error()); while ($aRow = mysql_fetch_array($result)) { $client_id = $aRow['client_id']; $client = $this->get_company($client_id, "clients", "company_name"); $list[$client["company_name"]] = $client_id . "-" . $aRow['count']; } $this->memcached_library->add($key_cache, $list, 86400); $this->set_memcachekeys($key_cache); return $list; } else { return $get_search_carcompany; } } function get_search_carcompany($where, $emirate,$used_cars=0) { $key_cache = 'get_search_carcompany3@' . $where . '@' . $emirate.$used_cars; $get_search_carcompany = $this->memcached_library->get($key_cache); if (!$get_search_carcompany && !is_numeric($get_search_carcompany)) { if($used_cars==0){ $sql = "select listings.client_id , count(*) count from listings INNER JOIN clients ON listings.client_id=clients.client_id where $where and clients.emirate='$emirate' and publish_ocd='1' group by listings.client_id"; } else { $sql = "select usedcar_listings.client_id , count(*) count from usedcar_listings INNER JOIN clients ON usedcar_listings.client_id=clients.client_id where $where and clients.emirate='$emirate' and (usedcar_listings.used_cars='1' OR usedcar_listings.used_cars='2') and publish_ocd='1' group by usedcar_listings.client_id"; } $result = mysql_query($sql) or die(mysql_error()); while ($aRow = mysql_fetch_array($result)) { $client_id = $aRow['client_id']; $client = $this->get_company($client_id, "clients", "company_name"); $list[$client["company_name"]] = $client_id . "-" . $aRow['count']; } $this->memcached_library->add($key_cache, $list, 86400); $this->set_memcachekeys($key_cache); return $list; } else { return $get_search_carcompany; } } function get_client_more_rental($client) { $sql = "select more_rentals from clients where client_id = '$client'"; $result = mysql_query($sql) or die(mysql_error()); while ($aRow = mysql_fetch_array($result)) { $more_rentals = $aRow['more_rentals']; } return $more_rentals; } function get_search_carcompany_arabic($where, $emirate) { $sql = "select listings.client_id , count(*) count from listings INNER JOIN clients ON listings.client_id=clients.client_id where $where and clients.emirate='$emirate' and publish_ocd='1' group by listings.client_id"; $result = mysql_query($sql) or die(mysql_error()); while ($aRow = mysql_fetch_array($result)) { $client_id = $aRow['client_id']; $client = $this->get_company($client_id, "clients", "company_name_arabic"); $list[$client["company_name_arabic"]] = $client_id . "-" . $aRow['count']; } return $list; } function get_carcompanyid($where) { $sql = "select id from clients where $where"; $result = mysql_query($sql); $rows = mysql_fetch_assoc($result); return $rows; } function get_all_usedcar_clients($where = null) { if($where != null) { $sql = $this->db->query("SELECT `client_id`,`company_name`,`limit_number`,`emirate` FROM `clients` WHERE more_rentals = 5 $where"); } else { $sql = $this->db->query("SELECT `client_id`,`company_name`,`limit_number`,`emirate` FROM `clients` WHERE more_rentals = 5"); } $rows = []; $results = $sql->result(); $k = 0; if ($results) { foreach ($results as $res) { $rows[$k]['client_id'] = $res->client_id; $rows[$k]['company_name'] = $res->company_name; $rows[$k]['emirate'] = $res->emirate; $sql8=mysql_query("select * from usedcar_listings where client_id='$res->client_id' and publish_ocd='1' and delete_status='0'") or die(mysql_error()); $rows[$k]['total_listings']=mysql_num_rows($sql8); $rows[$k]['total_client_listing']=$res->limit_number; $k++; } } return $rows; } function get_all_clients() { $sql = $this->db->query("SELECT `client_id`,`company_name` FROM `clients` "); $rows = []; $results = $sql->result(); $k = 0; if ($results) { foreach ($results as $res) { $rows[$k]['client_id'] = $res->client_id; $rows[$k]['company_name'] = $res->company_name; $k++; } } return $rows; } function get_all_clients_display() { $sql = $this->db->query("SELECT `client_id`,`company_name` FROM `clients` "); $rows = []; $results = $sql->result(); $k = 0; if ($results) { foreach ($results as $res) { // $rows[$k]['client_id'] =$res->client_id; $rows[$res->client_id] = $res->company_name; $k++; } } return $rows; } function getbuggy_carscount($where) { $key_cache = 'getbuggy_carscount@' . $where; //$this->memcached_library->delete($key_cache); $getbuggy_carscount = $this->memcached_library->get($key_cache); if (!$getbuggy_carscount && !is_numeric($getbuggy_carscount)) { $sql = "select count(*) count from buggy_listing inner join clients on buggy_listing.client_id=clients.client_id where $where and car_type = '32' and publish_ocd='1'"; $result = mysql_query($sql); $aRow = mysql_fetch_array($result); $count = $aRow['count']; $this->memcached_library->add($key_cache, $count, 86400); $this->set_memcachekeys($key_cache); return $count; } else { return $getbuggy_carscount; } } function get_carscount($where=null,$used_cars=0) { $key_cache = 'get_carscount24@' . $where.$used_cars; //$this->memcached_library->delete($key_cache); $get_carscount = $this->memcached_library->get($key_cache); if (!$get_carscount && !is_numeric($get_carscount)) { if($used_cars==0) { $sql = "select count(*) count from listings inner join clients on listings.client_id=clients.client_id where $where and used_cars='$used_cars' and publish_ocd='1'"; } else{ $sql = "select count(*) count from usedcar_listings inner join clients on listings.client_id=clients.client_id where $where and used_cars='$used_cars' and publish_ocd='1'"; } $result = mysql_query($sql); $aRow = mysql_fetch_array($result); $count = $aRow['count']; $this->memcached_library->add($key_cache, $count, 86400); $this->set_memcachekeys($key_cache); return $count; } else { return $get_carscount; } } function get_carscount_home($where) { $key_cache = 'get_carscounts1234@' . $where; $get_carscount = $this->memcached_library->get($key_cache); if (!$get_carscount && !is_numeric($get_carscount)) { // $sql = "select count(*) count from listings where $where and and publish_ocd='1' and delete_status='0'"; $sql = "select count(*) count from listings where delete_status = 0 and car_type != 2 and daily_price_status='1' and listings.client_id in (select client_id from `clients` where emirate like '%Dubai%') and listings.client_id!=247 and publish_ocd='1' "; $result = mysql_query($sql); $aRow = mysql_fetch_array($result); $count = $aRow['count']; $this->memcached_library->add($key_cache, $count, 86400); $this->set_memcachekeys($key_cache); return $count; } else { return $get_carscount; } } function get_premcarscount() { $key_cache = 'get_premcarscount'; $get_premcarscount = $this->memcached_library->get($key_cache); if (!$get_premcarscount && !is_numeric($get_premcarscount)) { $sql = "select count(*) count from listings INNER JOIN clients on listings.client_id=clients.client_id where delete_status = 0 and publish_ocd='1' and daily_price >= 400 and emirate='Dubai'"; $result = mysql_query($sql); $aRow = mysql_fetch_array($result); $count = $aRow['count']; $this->memcached_library->add($key_cache, $count, 86400); $this->set_memcachekeys($key_cache); return $count; } else { return $get_premcarscount; } } function get_sportscount_home() { $key_cache = 'get_sportscount_home7'; $get_sportscount = $this->memcached_library->get($key_cache); if (!$get_sportscount && !is_numeric($get_sportscount)) { /* $query_make = $this->db->query("SELECT GROUP_CONCAT(id ) as id FROM `make` WHERE `cartype` in (7) or `cartype1` in (7) or `cartype2` in (7) "); $makeid = ""; if($query_make->num_rows() > 0){ $result = $query_make->row_array(); $makeid = $result["id"]; } $sql = "select count(*) count from listings where delete_status = 0 and car_type != 2 and daily_price_status='1' and (car_make in ($makeid) or (car_type='7')or car_make in (SELECT id from make where doors='2') and car_type NOT IN ('3','9','11','14')or (keywords like '%Convertible%' or keywords like '%gtc%' or keywords like '%dawn%' or keywords like '%cabriolet%' or keywords like '%grancabrio%' or keywords like '%spyder%' or car_make='481' or car_make='438')) and listings.client_id in (select client_id from `clients` where emirate like '%Dubai%') and listings.client_id!=247 and publish_ocd='1' "; $result = mysql_query($sql); $aRow = mysql_fetch_array($result); $count = $aRow['count'] ; $this->memcached_library->add($key_cache, $count, 3600); $this->set_memcachekeys($key_cache); return $count;*/ //$sql = "select count(*) count from listings inner join make on listings.car_make=make.id where publish_ocd='1' and delete_status = 0 and listings.car_type != 2 and daily_price_status='1' and (make.cartype in (7) or make.cartype1 in (7) or make.cartype2 in (7)) and client_id in (select client_id from clients where emirate='Dubai')"; $sql = "select count(*) count from listings inner join clients on listings.client_id=clients.client_id where delete_status = 0 and car_type != 2 and daily_price_status='1' and (car_make in (SELECT id FROM `make` WHERE `cartype` in (7) or `cartype1` in (7) or `cartype2` in (7) or `cartype3` in (7)) or car_type='7' ) and clients.emirate like '%Dubai%' and ( IF(`daily_price_offer` != '=', daily_price_offer >='850', daily_price >= 850) and daily_price!='0') and listings.client_id!=247 and publish_ocd='1'"; $result = mysql_query($sql); $aRow = mysql_fetch_array($result); $count = $aRow['count']; $this->memcached_library->add($key_cache, $count, 86400); $this->set_memcachekeys($key_cache); return $count; } else { return $get_sportscount; } } function get_luxurycount() { $key_cache = 'get_luxurycount9'; $get_premcarscount = $this->memcached_library->get($key_cache); if (!$get_premcarscount && !is_numeric($get_premcarscount)) { /* $query_make = $this->db->query("SELECT GROUP_CONCAT(id ) as id FROM `make` WHERE `cartype` in (4,8) or `cartype1` in (4,8) or `cartype2` in (4,8) "); $makeid = ""; if($query_make->num_rows() > 0){ $result = $query_make->row_array(); $makeid = $result["id"]; } $makeid=$makeid.'0'; $sql = "select count(*) count from listings where delete_status = 0 and car_type != 2 and daily_price_status='1' and (car_make in ($makeid) or (car_type='4,8') or car_make in (SELECT id from make where doors='2') and car_type NOT IN ('3','9','11','14') or (keywords like '%Convertible%' or keywords like '%gtc%' or keywords like '%dawn%' or keywords like '%cabriolet%' or keywords like '%grancabrio%' or keywords like '%spyder%' or car_make='481' or car_make='438')) and listings.client_id in (select client_id from `clients` where emirate like '%Dubai%') and daily_price >= 800 and daily_price!='0' and listings.client_id!=247 and publish_ocd='1'";*/ $sql = "select count(*) count from listings inner join clients on listings.client_id=clients.client_id where delete_status = 0 and car_type != 2 and daily_price_status='1' and (car_make in (SELECT id FROM `make` WHERE `cartype` in (8) or `cartype1` in (8) or `cartype2` in (8) or `cartype3` in (8)) or car_type='8' ) and clients.emirate like '%Dubai%' and ( IF(`daily_price_offer` != '=', daily_price_offer >='850', daily_price >= 850) and daily_price!='0') and listings.client_id!=247 and publish_ocd='1'"; $result = mysql_query($sql); $aRow = mysql_fetch_array($result); $count = $aRow['count']; $this->memcached_library->add($key_cache, $count, 86400); $this->set_memcachekeys($key_cache); return $count; } else { return $get_premcarscount; } } function get_sportscount() { $key_cache = 'get_sportscount'; $get_sportscount = $this->memcached_library->get($key_cache); if (!$get_sportscount && !is_numeric($get_sportscount)) { $sql = "select count(*) count from listings INNER JOIN clients on listings.client_id=clients.client_id where delete_status = 0 and publish_ocd='1' and car_type = '7' and emirate='Dubai'"; $result = mysql_query($sql); $aRow = mysql_fetch_array($result); $count = $aRow['count']; $this->memcached_library->add($key_cache, $count, 86400); $this->set_memcachekeys($key_cache); return $count; } else { return $get_sportscount; } } function get_carmake($where) { $key_cache = 'get_carmake@' . $where; $get_carmake = $this->memcached_library->get($key_cache); if (!$get_carmake && !is_numeric($get_carmake)) { $sql = "select car_model , count(*) count from listings where $where and publish_ocd='1' group by car_model"; $result = mysql_query($sql); while ($aRow = mysql_fetch_array($result)) { $car_make = $aRow['car_model']; $carmake = $this->get_name($car_make, "models", "name"); $list[$carmake["name"]] = $car_make . "-" . $aRow['count']; } $this->memcached_library->add($key_cache, $list, 86400); $this->set_memcachekeys($key_cache); return $list; } else { return $get_carmake; } } function get_carmake_arabic($where) { $sql = "select car_model , count(*) count from listings where $where and publish_ocd='1' group by car_model"; $result = mysql_query($sql); while ($aRow = mysql_fetch_array($result)) { $car_make = $aRow['car_model']; $carmake = $this->get_name($car_make, "models", "name_arabic"); $list[$carmake["name_arabic"]] = $car_make . "-" . $aRow['count']; } return $list; } function get_carmodel($id) { $sql = "select car_make , count(*) count from listings where car_model = '$id' and publish_ocd='1' group by car_make"; $result = mysql_query($sql); while ($aRow = mysql_fetch_array($result)) { $car_make = $aRow['car_make']; $carmake = $this->get_name($car_make, "make", "name"); $list[$carmake["name"]] = $car_make; } return $list; } function get_area($emirate,$used_cars=0) { $key_cache = 'get_area@' . $emirate.$used_cars; $get_area = $this->memcached_library->get($key_cache); if (!$get_area && !is_numeric($get_area)) { if($used_cars==0) { $sql = "select location from clients inner join listings on clients.client_id=listings.client_id where publish_ocd='1' and emirate ='$emirate' and location!='' group by location order by location asc"; } else { $sql = "select location from clients inner join usedcar_listings on clients.client_id=usedcar_listings.client_id where publish_ocd='1' and emirate ='$emirate' and usedcar_listings.used_cars='$used_cars' and location!='' group by location order by location asc"; } $result = mysql_query($sql); while ($aRow = mysql_fetch_array($result)) { $loc = $aRow['location']; $array = explode('*', $loc); foreach ($array as $key => $value) { if (in_array($value, $dup)) { continue; } $list[$value] = $value; } $dup[] = $value; } $this->memcached_library->add($key_cache, $list, 86400); $this->set_memcachekeys($key_cache); return $list; } else { return $get_area; } } function get_cardelv($where,$used_cars=0) { $key_cache = 'get_cardelv@' . $where.$used_cars; $get_cardelv = $this->memcached_library->get($key_cache); if (!$get_cardelv && !is_numeric($get_cardelv)) { if($used_cars==0) { $sql = "select pick_up , count(*) count from listings where $where and publish_ocd='1' group by pick_up"; } else { $sql = "select pick_up , count(*) count from usedcar_listings where $where and usedcar_listings.used_cars='$used_cars' and publish_ocd='1' group by pick_up"; } $result = mysql_query($sql); while ($aRow = mysql_fetch_array($result)) { $pick_up = $aRow['pick_up']; $pickup = $this->get_name($pick_up, "pickup_policy", "name"); $list[$pickup["name"]] = $pick_up . "-" . $aRow['count']; } $this->memcached_library->add($key_cache, $list, 86400); $this->set_memcachekeys($key_cache); return $list; } else { return $get_cardelv; } } function get_transmission($where,$used_cars=0) { $key_cache = 'get_transmission@' . $where.$used_cars; $get_transmission = $this->memcached_library->get($key_cache); if (!$get_transmission && !is_numeric($get_transmission)) { if($used_cars==0) { $sql = "select transmission , count(*) count from listings where $where and publish_ocd='1' group by transmission"; } else{ $sql = "select transmission , count(*) count from usedcar_listings where $where and used_cars='$used_cars' and publish_ocd='1' group by transmission"; } $result = mysql_query($sql); while ($aRow = mysql_fetch_array($result)) { $transmission = $aRow['transmission']; $transmission = $this->get_name($transmission, "transmission", "name"); $list[$transmission["name"]] = $aRow['transmission'] . "-" . $aRow['count']; } $this->memcached_library->add($key_cache, $list, 86400); $this->set_memcachekeys($key_cache); return $list; } else { return $get_transmission; } } function getbuggy_cars_count($where) { $key_cache = 'getbuggy_cars_count@' . $where; $getbuggy_cars_count = $this->memcached_library->get($key_cache); // $this->memcached_library->delete($key_cache); if (!$getbuggy_cars_count && !is_numeric($getbuggy_cars_count)) { $sql = "select count(*) count from buggy_listing inner join clients on buggy_listing.client_id=clients.client_id where $where and car_type = '32' and publish_ocd='1'"; $result = mysql_query($sql) or die(mysql_error()); $aRow = mysql_fetch_array($result); $count = $aRow['count']; $this->memcached_library->add($key_cache, $count, 86400); $this->set_memcachekeys($key_cache); return $count; } else { return $getbuggy_cars_count; } } function get_cars_count($where,$used_cars=0) { $key_cache = 'get_cars_count120@' . $where.$used_cars; $get_cars_count = $this->memcached_library->get($key_cache); // $this->memcached_library->delete($key_cache); if (!$get_cars_count && !is_numeric($get_cars_count)) { if($used_cars==0) { $sql = "select count(*) count from listings inner join clients on listings.client_id=clients.client_id where $where and publish_ocd='1'"; } else { $sql = "select count(*) count from usedcar_listings inner join clients on usedcar_listings.client_id=clients.client_id where $where and usedcar_listings.used_cars='$used_cars' and publish_ocd='1'"; } $result = mysql_query($sql) or die(mysql_error()); $aRow = mysql_fetch_array($result); $count = $aRow['count']; $this->memcached_library->add($key_cache, $count, 86400); $this->set_memcachekeys($key_cache); return $count; } else { return $get_cars_count; } } function get_cars_coupecount($emirate,$used_cars=0) { $key_cache = 'get_cars_coupecount@' . $emirate.$used_cars; $get_cars_coupecount = $this->memcached_library->get($key_cache); if (!$get_cars_coupecount && !is_numeric($get_cars_coupecount)) { if($used_cars==0) { $sql = "select count(*) count from make inner join listings on make.id=listings.car_make inner join clients on clients.client_id=listings.client_id where make.doors='2' and listings.publish_ocd='1' and listings.delete_status='0' and clients.emirate='$emirate' "; } else { $sql = "select count(*) count from make inner join usedcar_listings on make.id=usedcar_listings.car_make inner join clients on clients.client_id=usedcar_listings.client_id where make.doors='2' and usedcar_listings.used_cars='$used_cars' and usedcar_listings.publish_ocd='1' and usedcar_listings.delete_status='0' and clients.emirate='$emirate' "; } $result = mysql_query($sql); $aRow = mysql_fetch_array($result); $count = $aRow['count']; $this->memcached_library->add($key_cache, $count, 86400); $this->set_memcachekeys($key_cache); return $count; } else { return $get_cars_coupecount; } } function get_cars_convert($emirate,$used_cars=0) { $key_cache = "get_cars_convert@" . $emirate.$used_cars; $cars_convert = $this->memcached_library->get($key_cache); if (!$cars_convert && !is_numeric($cars_convert)) { if($used_cars==0) { $sql = "select count(*) count from listings inner join clients on listings.client_id=clients.client_id where keywords like '%Convertible%' and publish_ocd='1' and delete_status='0' and emirate='$emirate'"; } else { $sql = "select count(*) count from usedcar_listings inner join clients on usedcar_listings.client_id=clients.client_id where keywords like '%Convertible%' and publish_ocd='1'and usedcar_listings.used_cars='$used_cars' and delete_status='0' and emirate='$emirate'"; } $result = mysql_query($sql); $aRow = mysql_fetch_array($result); $count = $aRow['count']; $this->memcached_library->add($key_cache, $count, 86400); $this->set_memcachekeys($key_cache); return $count; } else { return $cars_convert; } } function get_cars_ids() { $key_cache = "get_cars_ids"; $get_cars_ids = $this->memcached_library->get($key_cache); if (!$get_cars_ids && !is_numeric($get_cars_ids)) { $sql = "select ids from ids"; $result = mysql_query($sql); $aRow = mysql_fetch_array($result); $count = $aRow['ids']; $this->memcached_library->add($key_cache, $count, 86400); $this->set_memcachekeys($key_cache); return $count; } else { return $get_cars_ids; } } function insert_newsletter($newsletter) { $sql = "insert into newsletter (email) values ('" . mysql_real_escape_string($newsletter) . "')"; mysql_query($sql); } function insert_contact($post) { $ip = $this->get_your_ip(); echo $sql = "insert into contact (id,name,email,phone,message,ip) values ('', '" . mysql_real_escape_string($post["NAME"]) . "', '" . mysql_real_escape_string($post["EMAIL"]) . "', '" . mysql_real_escape_string($post["MOBILE"]) . "', '" . mysql_real_escape_string($post["NOTE"]) . "', '" . mysql_real_escape_string($ip) . "' )"; mysql_query($sql); } function check_ip_full_day($ip,$used_cars=0,$table='email_sms') { $date=date("Y-m-d"); $sql = mysql_query("select count(*) as count from $table where ip='$ip' and usedcar='$used_cars' and date(`time`)='$date'") or die(mysql_error()); $count=mysql_fetch_array($sql); return $count['count']; } function track_click_phone($listing_id, $client_id) { $date_today=date('Y-m-d'); $ip = $this->get_your_ip(); $check_full_day_leads= $this->check_ip_full_day($ip,0,'email_sms'); if($check_full_day_leads > 60) { $daily_spam='1'; } else if(!empty($ip)) { $check_spam_ip=mysql_query("select time from `email_sms` where listing_id='$listing_id' and type='2' and ip='$ip' and date(`time`)='$date_today'"); if(mysql_num_rows($check_spam_ip)>0){ $i=0; while($spam = mysql_fetch_array($check_spam_ip)) { $expiry_time = new DateTime($spam['time']); $current_date = new DateTime(); $diff = $expiry_time->diff($current_date); $hour=$diff->format('%h'); $minute=$diff->format('%i'); if(($hour==1 && $minute<5) || ($hour==0)) { $i++; } } $dailyspam = $i; if($dailyspam>=2) { $daily_spam='1'; } else { $daily_spam='0'; } } else { $daily_spam='0'; } } else { $daily_spam='0'; } $sql = "insert into email_sms(client_id,listing_id,type,ip,daily_spam,time) values (" . "'" . mysql_real_escape_string($client_id) . "'," . "'" . mysql_real_escape_string($listing_id) . "'," . "'2'" . "," . "'" . mysql_real_escape_string($ip) . "'," . "'" . mysql_real_escape_string($daily_spam) . "'," . "'" . date('Y-m-d H:i:s') . "'" . ")"; //echo $sql; mysql_query($sql); } function track_click_phone2($listing_id, $client_id, $featured_listing, $best_offer_listing) { $ip = $this->get_your_ip(); $date_today=date('Y-m-d'); $check_full_day_leads= $this->check_ip_full_day($ip,0,'email_sms'); if($check_full_day_leads > 60) { $daily_spam='1'; } else if(!empty($ip)) { $check_spam_ip=mysql_query("select time from `email_sms` where listing_id='$listing_id' and type='2' and ip='$ip' and date(`time`)='$date_today'"); if(mysql_num_rows($check_spam_ip)>0){ $i=0; while($spam = mysql_fetch_array($check_spam_ip)) { $expiry_time = new DateTime($spam['time']); $current_date = new DateTime(); $diff = $expiry_time->diff($current_date); $hour=$diff->format('%h'); $minute=$diff->format('%i'); if(($hour==1 && $minute<5) || ( $hour==0)) { $i++; } } $dailyspam = $i; if($dailyspam>=2) { $daily_spam='1'; } else { $daily_spam='0'; } } else { $daily_spam='0'; } } else { $daily_spam='0'; } $sql = "insert into email_sms(client_id,listing_id,type,ip,featured_listing,best_offer_listing,daily_spam,time) values (" . "'" . mysql_real_escape_string($client_id) . "'," . "'" . mysql_real_escape_string($listing_id) . "'," . "'2'" . "," . "'" . mysql_real_escape_string($ip) . "'," . "'" . mysql_real_escape_string($featured_listing) . "'," . "'" . mysql_real_escape_string($best_offer_listing) . "'," . "'" . mysql_real_escape_string($daily_spam) . "'," . "'" . date('Y-m-d H:i:s') . "'" . ")"; //echo $sql; mysql_query($sql); } function track_click_phone5($listing_id, $client_id, $featured_listing, $best_offer_listing, $verification, $price_stat, $premium) { $ip = $this->get_your_ip(); $user_id = 0; $date_today=date('Y-m-d'); $check_full_day_leads= $this->check_ip_full_day($ip,0,'email_sms'); if($check_full_day_leads > 60) { $daily_spam='1'; } else if(!empty($ip)) { $check_spam_ip=mysql_query("select time from `email_sms` where listing_id='$listing_id' and type='2' and ip='$ip' and date(`time`)='$date_today'"); if(mysql_num_rows($check_spam_ip)>0){ $i=0; while($spam = mysql_fetch_array($check_spam_ip)) { $expiry_time = new DateTime($spam['time']); $current_date = new DateTime(); $diff = $expiry_time->diff($current_date); $hour=$diff->format('%h'); $minute=$diff->format('%i'); if(($hour==1 && $minute<5) || ( $hour==0)) { $i++; } } $dailyspam = $i; if($dailyspam>=2) { $daily_spam='1'; } else { $daily_spam='0'; } } else { $daily_spam='0'; } } else { $daily_spam='0'; } if(isset($_COOKIE['void']) && $this->session->userdata("userr_id") != ""){ $user_id = $this->session->userdata("userr_id"); } $sql = "insert into email_sms(client_id,user_id,listing_id,type,ip,featured_listing,best_offer_listing,verified_listing,price_stat,premium_listing,daily_spam,time) values (" . "'" . mysql_real_escape_string($client_id) . "'," . "'" . mysql_real_escape_string($user_id) . "'," . "'" . mysql_real_escape_string($listing_id) . "'," . "'2'" . "," . "'" . mysql_real_escape_string($ip) . "'," . "'" . mysql_real_escape_string($featured_listing) . "'," . "'" . mysql_real_escape_string($best_offer_listing) . "'," . "'" . mysql_real_escape_string($verification) . "'," . "'" . mysql_real_escape_string($price_stat) . "'," . "'" . mysql_real_escape_string($premium) . "'," . "'" . mysql_real_escape_string($daily_spam) . "'," . "'" . date('Y-m-d H:i:s') . "'" . ")"; //echo $sql; mysql_query($sql); } function track_click_phone55_usedcar($listing_id, $client_id, $featured_listing, $best_offer_listing, $verification, $price_stat, $premium, $month_lead) { $ip = $this->get_your_ip(); $user_id = 0; $date_today=date('Y-m-d'); $check_full_day_leads= $this->check_ip_full_day($ip,1,'email_sms'); if($check_full_day_leads > 60) { $daily_spam='1'; } else if(!empty($ip)) { $check_spam_ip=mysql_query("select time from `email_sms` where listing_id='$listing_id' and type='2' and usedcar = '1' and ip='$ip' and date(`time`)='$date_today'"); if(mysql_num_rows($check_spam_ip)>0){ $i=0; while($spam = mysql_fetch_array($check_spam_ip)) { $expiry_time = new DateTime($spam['time']); $current_date = new DateTime(); $diff = $expiry_time->diff($current_date); $hour=$diff->format('%h'); $minute=$diff->format('%i'); if(($hour==1 && $minute<5) || ( $hour==0)) { $i++; } } $dailyspam = $i; if($dailyspam>=2) { $daily_spam='1'; } else { $daily_spam='0'; } } else { $daily_spam='0'; } } else { $daily_spam='0'; } if(isset($_COOKIE['void']) && $this->session->userdata("userr_id") != ""){ $user_id = $this->session->userdata("userr_id"); } $sql = "insert into email_sms(client_id,user_id,listing_id,type,ip,featured_listing,best_offer_listing,verified_listing,price_stat,premium_listing,month_lead,daily_spam,usedcar,time) values (" . "'" . mysql_real_escape_string($client_id) . "'," . "'" . mysql_real_escape_string($user_id) . "'," . "'" . mysql_real_escape_string($listing_id) . "'," . "'2'" . "," . "'" . mysql_real_escape_string($ip) . "'," . "'" . mysql_real_escape_string($featured_listing) . "'," . "'" . mysql_real_escape_string($best_offer_listing) . "'," . "'" . mysql_real_escape_string($verification) . "'," . "'" . mysql_real_escape_string($price_stat) . "'," . "'" . mysql_real_escape_string($premium) . "'," . "'" . mysql_real_escape_string($month_lead) . "'," . "'" . mysql_real_escape_string($daily_spam) . "'," . "'1'" . "," . "'" . date('Y-m-d H:i:s') . "'" . ")"; //echo $sql; mysql_query($sql); } function track_click_phone55($listing_id, $client_id, $featured_listing, $best_offer_listing, $verification, $price_stat, $premium, $month_lead, $hourly = 0) { $ip = $this->get_your_ip(); $user_id = 0; $date_today=date('Y-m-d'); $check_full_day_leads= $this->check_ip_full_day($ip,0,'email_sms'); if($check_full_day_leads > 60) { $daily_spam='1'; } else if(!empty($ip)) { $check_spam_ip=mysql_query("select time from `email_sms` where listing_id='$listing_id' and type='2' and ip='$ip' and date(`time`)='$date_today'"); if(mysql_num_rows($check_spam_ip)>0){ $i=0; while($spam = mysql_fetch_array($check_spam_ip)) { $expiry_time = new DateTime($spam['time']); $current_date = new DateTime(); $diff = $expiry_time->diff($current_date); $hour=$diff->format('%h'); $minute=$diff->format('%i'); if(($hour==1 && $minute<5) || ( $hour==0)) { $i++; } } $dailyspam = $i; if($dailyspam>=2) { $daily_spam='1'; } else { $daily_spam='0'; } } else { $daily_spam='0'; } } else { $daily_spam='0'; } if(isset($_COOKIE['void']) && $this->session->userdata("userr_id") != ""){ $user_id = $this->session->userdata("userr_id"); } $sql = "insert into email_sms(client_id,user_id,listing_id,type,ip,featured_listing,best_offer_listing,verified_listing,price_stat,premium_listing,month_lead,daily_spam,time,is_hourly) values (" . "'" . mysql_real_escape_string($client_id) . "'," . "'" . mysql_real_escape_string($user_id) . "'," . "'" . mysql_real_escape_string($listing_id) . "'," . "'2'" . "," . "'" . mysql_real_escape_string($ip) . "'," . "'" . mysql_real_escape_string($featured_listing) . "'," . "'" . mysql_real_escape_string($best_offer_listing) . "'," . "'" . mysql_real_escape_string($verification) . "'," . "'" . mysql_real_escape_string($price_stat) . "'," . "'" . mysql_real_escape_string($premium) . "'," . "'" . mysql_real_escape_string($month_lead) . "'," . "'" . mysql_real_escape_string($daily_spam) . "'," . "'" . date('Y-m-d H:i:s') . "'," ."'".$hourly."'" . ")"; //echo $sql; mysql_query($sql); } function track_usedcar_click_phone55($listing_id, $client_id, $featured_listing, $best_offer_listing, $verification, $price_stat, $premium, $month_lead) { $ip = $this->get_your_ip(); $user_id = 0; $date_today=date('Y-m-d'); $check_full_day_leads= $this->check_ip_full_day($ip,1,'email_sms'); if($check_full_day_leads > 60) { $daily_spam='1'; } else if(!empty($ip)) { $check_spam_ip=mysql_query("select time from `email_sms` where listing_id='$listing_id' and type='2' and ip='$ip' and usedcar = '1' and date(`time`)='$date_today'"); if(mysql_num_rows($check_spam_ip)>0){ $i=0; while($spam = mysql_fetch_array($check_spam_ip)) { $expiry_time = new DateTime($spam['time']); $current_date = new DateTime(); $diff = $expiry_time->diff($current_date); $hour=$diff->format('%h'); $minute=$diff->format('%i'); if(($hour==1 && $minute<5) || ( $hour==0)) { $i++; } } $dailyspam = $i; if($dailyspam>=2) { $daily_spam='1'; } else { $daily_spam='0'; } } else { $daily_spam='0'; } } else { $daily_spam='0'; } if(isset($_COOKIE['void']) && $this->session->userdata("userr_id") != ""){ $user_id = $this->session->userdata("userr_id"); } $sql = "insert into email_sms(client_id,user_id,listing_id,type,ip,featured_listing,best_offer_listing,verified_listing,price_stat,premium_listing,month_lead,daily_spam,usedcar,time) values (" . "'" . mysql_real_escape_string($client_id) . "'," . "'" . mysql_real_escape_string($user_id) . "'," . "'" . mysql_real_escape_string($listing_id) . "'," . "'2'" . "," . "'" . mysql_real_escape_string($ip) . "'," . "'" . mysql_real_escape_string($featured_listing) . "'," . "'" . mysql_real_escape_string($best_offer_listing) . "'," . "'" . mysql_real_escape_string($verification) . "'," . "'" . mysql_real_escape_string($price_stat) . "'," . "'" . mysql_real_escape_string($premium) . "'," . "'" . mysql_real_escape_string($month_lead) . "'," . "'" . mysql_real_escape_string($daily_spam) . "'," . "'1'" . "," . "'" . date('Y-m-d H:i:s') . "'" . ")"; //echo $sql; mysql_query($sql); } function track_click_phone4($listing_id, $client_id, $featured_listing, $best_offer_listing, $verification, $price_stat) { $ip = $this->get_your_ip(); $date_today=date('Y-m-d'); $check_full_day_leads= $this->check_ip_full_day($ip,0,'email_sms'); if($check_full_day_leads > 60) { $daily_spam='1'; } else if(!empty($ip)) { $check_spam_ip=mysql_query("select time from `email_sms` where listing_id='$listing_id' and type='2' and ip='$ip' and date(`time`)='$date_today'"); if(mysql_num_rows($check_spam_ip)>0){ $i=0; while($spam = mysql_fetch_array($check_spam_ip)) { $expiry_time = new DateTime($spam['time']); $current_date = new DateTime(); $diff = $expiry_time->diff($current_date); $hour=$diff->format('%h'); $minute=$diff->format('%i'); if(($hour==1 && $minute<5) || ( $hour==0)) { $i++; } } $dailyspam = $i; if($dailyspam>=2) { $daily_spam='1'; } else { $daily_spam='0'; } } else { $daily_spam='0'; } } else { $daily_spam='0'; } $sql = "insert into email_sms(client_id,listing_id,type,ip,featured_listing,best_offer_listing,verified_listing,price_stat,daily_spam,time) values (" . "'" . mysql_real_escape_string($client_id) . "'," . "'" . mysql_real_escape_string($listing_id) . "'," . "'2'" . "," . "'" . mysql_real_escape_string($ip) . "'," . "'" . mysql_real_escape_string($featured_listing) . "'," . "'" . mysql_real_escape_string($best_offer_listing) . "'," . "'" . mysql_real_escape_string($verification) . "'," . "'" . mysql_real_escape_string($price_stat) . "'," . "'" . mysql_real_escape_string($daily_spam) . "'," . "'" . date('Y-m-d H:i:s') . "'" . ")"; //echo $sql; mysql_query($sql); } function track_click_phone3($listing_id, $client_id, $featured_listing, $best_offer_listing, $verification) { $ip = $this->get_your_ip(); $date_today=date('Y-m-d'); $check_full_day_leads= $this->check_ip_full_day($ip,0,'email_sms'); if($check_full_day_leads > 60) { $daily_spam='1'; } else if(!empty($ip)) { $check_spam_ip=mysql_query("select time from `email_sms` where listing_id='$listing_id' and type='2' and ip='$ip' and date(`time`)='$date_today'"); if(mysql_num_rows($check_spam_ip)>0){ $i=0; while($spam = mysql_fetch_array($check_spam_ip)) { $expiry_time = new DateTime($spam['time']); $current_date = new DateTime(); $diff = $expiry_time->diff($current_date); $hour=$diff->format('%h'); $minute=$diff->format('%i'); if(($hour==1 && $minute<5) || ( $hour==0)) { $i++; } } $dailyspam = $i; if($dailyspam>=2) { $daily_spam='1'; } else { $daily_spam='0'; } } else { $daily_spam='0'; } } else { $daily_spam='0'; } $sql = "insert into email_sms(client_id,listing_id,type,ip,featured_listing,best_offer_listing,verified_listing,daily_spam,time) values (" . "'" . mysql_real_escape_string($client_id) . "'," . "'" . mysql_real_escape_string($listing_id) . "'," . "'2'" . "," . "'" . mysql_real_escape_string($ip) . "'," . "'" . mysql_real_escape_string($featured_listing) . "'," . "'" . mysql_real_escape_string($best_offer_listing) . "'," . "'" . mysql_real_escape_string($verification) . "'," . "'" . mysql_real_escape_string($daily_spam) . "'," . "'" . date('Y-m-d H:i:s') . "'" . ")"; //echo $sql; mysql_query($sql); } function check_user_lead_count() { $ip = $this->get_your_ip(); $trackids = mysql_query("select id from email_sms where ip='$ip' group by client_id"); $trackid = mysql_fetch_array($trackids); return ($trackid); } function track_click_whatsapp5_offer($listing_id, $client_id, $featured_listing, $best_offer_listing, $verification, $price_stat, $premium) { $ip = $this->get_your_ip(); $user_id = 0; if(isset($_COOKIE['void']) && $this->session->userdata("userr_id") != ""){ $user_id = $this->session->userdata("userr_id"); } $date_today=date('Y-m-d'); $check_full_day_leads= $this->check_ip_full_day($ip,0,'email_sms'); if($check_full_day_leads > 60) { $daily_spam='1'; } else if(!empty($ip)) { $check_spam_ip=mysql_query("select time from `email_sms` where listing_id='$listing_id' and type='5' and ip='$ip' and date(`time`)='$date_today'"); if(mysql_num_rows($check_spam_ip)>0){ $i=0; while($spam = mysql_fetch_array($check_spam_ip)) { $expiry_time = new DateTime($spam['time']); $current_date = new DateTime(); $diff = $expiry_time->diff($current_date); $hour=$diff->format('%h'); $minute=$diff->format('%i'); if(($hour==1 && $minute<5) || ( $hour==0)) { $i++; } } $dailyspam = $i; if($dailyspam>=2) { $daily_spam='1'; } else { $daily_spam='0'; } } else { $daily_spam='0'; } } else { $daily_spam='0'; } $sql = "insert into email_sms(client_id,user_id,listing_id,type,ip,featured_listing,best_offer_listing,verified_listing,price_stat,premium_listing,whatsapp_offer,daily_spam,time) values (" . "'" . mysql_real_escape_string($client_id) . "'," . "'" . mysql_real_escape_string($user_id) . "'," . "'" . mysql_real_escape_string($listing_id) . "'," . "'5'" . "," . "'" . mysql_real_escape_string($ip) . "'," . "'" . mysql_real_escape_string($featured_listing) . "'," . "'" . mysql_real_escape_string($best_offer_listing) . "'," . "'" . mysql_real_escape_string($verification) . "'," . "'" . mysql_real_escape_string($price_stat) . "'," . "'" . mysql_real_escape_string($premium) . "'," . "'1'" . "," . "'" . mysql_real_escape_string($daily_spam) . "'," . "'" . date('Y-m-d H:i:s') . "'" . ")"; //echo $sql; mysql_query($sql); } function track_click_whatsapp5($listing_id, $client_id, $featured_listing, $best_offer_listing, $verification, $price_stat, $premium) { $ip = $this->get_your_ip(); $user_id = 0; if(isset($_COOKIE['void']) && $this->session->userdata("userr_id") != ""){ $user_id = $this->session->userdata("userr_id"); } $date_today=date('Y-m-d'); $check_full_day_leads= $this->check_ip_full_day($ip,0,'email_sms'); if($check_full_day_leads > 60) { $daily_spam='1'; } else if(!empty($ip)) { $check_spam_ip=mysql_query("select time from `email_sms` where listing_id='$listing_id' and type='5' and ip='$ip' and date(`time`)='$date_today'"); if(mysql_num_rows($check_spam_ip)>0){ $i=0; while($spam = mysql_fetch_array($check_spam_ip)) { $expiry_time = new DateTime($spam['time']); $current_date = new DateTime(); $diff = $expiry_time->diff($current_date); $hour=$diff->format('%h'); $minute=$diff->format('%i'); if(($hour==1 && $minute<5) || ( $hour==0)) { $i++; } } $dailyspam = $i; if($dailyspam>=2) { $daily_spam='1'; } else { $daily_spam='0'; } } else { $daily_spam='0'; } } else { $daily_spam='0'; } $sql = "insert into email_sms(client_id,user_id,listing_id,type,ip,featured_listing,best_offer_listing,verified_listing,price_stat,premium_listing,daily_spam,time) values (" . "'" . mysql_real_escape_string($client_id) . "'," . "'" . mysql_real_escape_string($user_id) . "'," . "'" . mysql_real_escape_string($listing_id) . "'," . "'5'" . "," . "'" . mysql_real_escape_string($ip) . "'," . "'" . mysql_real_escape_string($featured_listing) . "'," . "'" . mysql_real_escape_string($best_offer_listing) . "'," . "'" . mysql_real_escape_string($verification) . "'," . "'" . mysql_real_escape_string($price_stat) . "'," . "'" . mysql_real_escape_string($premium) . "'," . "'" . mysql_real_escape_string($daily_spam) . "'," . "'" . date('Y-m-d H:i:s') . "'" . ")"; //echo $sql; mysql_query($sql); } function track_click_whatsapp_desert($id, $price, $name, $transfer_option, $adult_count, $child_count, $infant_count, $pickup){ $ip = $this->get_your_ip(); $user_id = 0; if(isset($_COOKIE['void']) && $this->session->userdata("userr_id") != ""){ $user_id = $this->session->userdata("userr_id"); } $sql = "insert into email_sms_desert(user_id,listing_id,ip,price,safari_name,transfer_option,adult_count,child_count,infant_count,pickupdate,time) values (" . "'" . mysql_real_escape_string($user_id) . "'," . "'" . mysql_real_escape_string($id) . "'," . "'" . mysql_real_escape_string($ip) . "'," . "'" . mysql_real_escape_string($price) . "'," . "'" . mysql_real_escape_string($name) . "'," . "'" . mysql_real_escape_string($transfer_option) . "'," . "'" . mysql_real_escape_string($adult_count) . "'," . "'" . mysql_real_escape_string($child_count) . "'," . "'" . mysql_real_escape_string($infant_count) . "'," . "'" . mysql_real_escape_string($pickup) . "'," . "'" . date('Y-m-d H:i:s') . "'" . ")"; //echo $sql; mysql_query($sql); } function track_click_whatsapp55_usedcar($listing_id, $client_id, $featured_listing, $best_offer_listing, $verification, $price_stat, $premium,$month_lead) { $ip = $this->get_your_ip(); $user_id = 0; if(isset($_COOKIE['void']) && $this->session->userdata("userr_id") != ""){ $user_id = $this->session->userdata("userr_id"); } $date_today=date('Y-m-d'); $check_full_day_leads= $this->check_ip_full_day($ip,1,'email_sms'); if($check_full_day_leads > 60) { $daily_spam='1'; } else if(!empty($ip)) { $check_spam_ip=mysql_query("select time from `email_sms` where listing_id='$listing_id' and type='5' and ip='$ip' and usedcar = '1' and date(`time`)='$date_today'"); if(mysql_num_rows($check_spam_ip)>0){ $i=0; while($spam = mysql_fetch_array($check_spam_ip)) { $expiry_time = new DateTime($spam['time']); $current_date = new DateTime(); $diff = $expiry_time->diff($current_date); $hour=$diff->format('%h'); $minute=$diff->format('%i'); if(($hour==1 && $minute<5) || ( $hour==0)) { $i++; } } $dailyspam = $i; if($dailyspam>=2) { $daily_spam='1'; } else { $daily_spam='0'; } } else { $daily_spam='0'; } } else { $daily_spam='0'; } $sql = "insert into email_sms(client_id,user_id,listing_id,type,ip,featured_listing,best_offer_listing,verified_listing,price_stat,premium_listing,month_lead,daily_spam,usedcar,time) values (" . "'" . mysql_real_escape_string($client_id) . "'," . "'" . mysql_real_escape_string($user_id) . "'," . "'" . mysql_real_escape_string($listing_id) . "'," . "'5'" . "," . "'" . mysql_real_escape_string($ip) . "'," . "'" . mysql_real_escape_string($featured_listing) . "'," . "'" . mysql_real_escape_string($best_offer_listing) . "'," . "'" . mysql_real_escape_string($verification) . "'," . "'" . mysql_real_escape_string($price_stat) . "'," . "'" . mysql_real_escape_string($premium) . "'," . "'" . mysql_real_escape_string($month_lead) . "'," . "'" . mysql_real_escape_string($daily_spam) . "'," . "'1'" . "," . "'" . date('Y-m-d H:i:s') . "'" . ")"; //echo $sql; mysql_query($sql); } function track_click_whatsapp55($listing_id, $client_id, $featured_listing, $best_offer_listing, $verification, $price_stat, $premium,$month_lead,$hourly=0) { $ip = $this->get_your_ip(); $user_id = 0; if(isset($_COOKIE['void']) && $this->session->userdata("userr_id") != ""){ $user_id = $this->session->userdata("userr_id"); } $date_today=date('Y-m-d'); $check_full_day_leads= $this->check_ip_full_day($ip,0,'email_sms'); if($check_full_day_leads > 60) { $daily_spam='1'; } else if(!empty($ip)) { $check_spam_ip=mysql_query("select time from `email_sms` where listing_id='$listing_id' and type='5' and ip='$ip' and date(`time`)='$date_today'"); if(mysql_num_rows($check_spam_ip)>0){ $i=0; while($spam = mysql_fetch_array($check_spam_ip)) { $expiry_time = new DateTime($spam['time']); $current_date = new DateTime(); $diff = $expiry_time->diff($current_date); $hour=$diff->format('%h'); $minute=$diff->format('%i'); if(($hour==1 && $minute<5) || ( $hour==0)) { $i++; } } $dailyspam = $i; if($dailyspam>=2) { $daily_spam='1'; } else { $daily_spam='0'; } } else { $daily_spam='0'; } } else { $daily_spam='0'; } $sql = "insert into email_sms(client_id,user_id,listing_id,type,ip,featured_listing,best_offer_listing,verified_listing,price_stat,premium_listing,month_lead,daily_spam,time,is_hourly) values (" . "'" . mysql_real_escape_string($client_id) . "'," . "'" . mysql_real_escape_string($user_id) . "'," . "'" . mysql_real_escape_string($listing_id) . "'," . "'5'" . "," . "'" . mysql_real_escape_string($ip) . "'," . "'" . mysql_real_escape_string($featured_listing) . "'," . "'" . mysql_real_escape_string($best_offer_listing) . "'," . "'" . mysql_real_escape_string($verification) . "'," . "'" . mysql_real_escape_string($price_stat) . "'," . "'" . mysql_real_escape_string($premium) . "'," . "'" . mysql_real_escape_string($month_lead) . "'," . "'" . mysql_real_escape_string($daily_spam) . "'," . "'" . date('Y-m-d H:i:s') . "'," ."'".$hourly."'" . ")"; //echo $sql; mysql_query($sql); } function track_click_whatsapp4($listing_id, $client_id, $featured_listing, $best_offer_listing, $verification, $price_stat) { $ip = $this->get_your_ip(); $date_today=date('Y-m-d'); $check_full_day_leads= $this->check_ip_full_day($ip,0,'email_sms'); if($check_full_day_leads > 60) { $daily_spam='1'; } else if(!empty($ip)) { $check_spam_ip=mysql_query("select time from `email_sms` where listing_id='$listing_id' and type='5' and ip='$ip' and date(`time`)='$date_today'"); if(mysql_num_rows($check_spam_ip)>0){ $i=0; while($spam = mysql_fetch_array($check_spam_ip)) { $expiry_time = new DateTime($spam['time']); $current_date = new DateTime(); $diff = $expiry_time->diff($current_date); $hour=$diff->format('%h'); $minute=$diff->format('%i'); if(($hour==1 && $minute<5) || ( $hour==0)) { $i++; } } $dailyspam = $i; if($dailyspam>=2) { $daily_spam='1'; } else { $daily_spam='0'; } } else { $daily_spam='0'; } } else { $daily_spam='0'; } $sql = "insert into email_sms(client_id,listing_id,type,ip,featured_listing,best_offer_listing,verified_listing,price_stat,daily_spam,time) values (" . "'" . mysql_real_escape_string($client_id) . "'," . "'" . mysql_real_escape_string($listing_id) . "'," . "'5'" . "," . "'" . mysql_real_escape_string($ip) . "'," . "'" . mysql_real_escape_string($featured_listing) . "'," . "'" . mysql_real_escape_string($best_offer_listing) . "'," . "'" . mysql_real_escape_string($verification) . "'," . "'" . mysql_real_escape_string($price_stat) . "'," . "'" . mysql_real_escape_string($daily_spam) . "'," . "'" . date('Y-m-d H:i:s') . "'" . ")"; //echo $sql; mysql_query($sql); } function track_click_whatsapp($listing_id, $client_id) { $ip = $this->get_your_ip(); $date_today=date('Y-m-d'); $check_full_day_leads= $this->check_ip_full_day($ip,0,'email_sms'); if($check_full_day_leads > 60) { $daily_spam='1'; } else if(!empty($ip)) { $check_spam_ip=mysql_query("select time from `email_sms` where listing_id='$listing_id' and type='5' and ip='$ip' and date(`time`)='$date_today'"); if(mysql_num_rows($check_spam_ip)>0){ $i=0; while($spam = mysql_fetch_array($check_spam_ip)) { $expiry_time = new DateTime($spam['time']); $current_date = new DateTime(); $diff = $expiry_time->diff($current_date); $hour=$diff->format('%h'); $minute=$diff->format('%i'); if(($hour==1 && $minute<5) || ( $hour==0)) { $i++; } } $dailyspam = $i; if($dailyspam>=2) { $daily_spam='1'; } else { $daily_spam='0'; } } else { $daily_spam='0'; } } else { $daily_spam='0'; } $sql = "insert into email_sms(client_id,listing_id,type,ip,daily_spam,time) values (" . "'" . mysql_real_escape_string($client_id) . "'," . "'" . mysql_real_escape_string($listing_id) . "'," . "'5'" . "," . "'" . mysql_real_escape_string($ip) . "'," . "'" . mysql_real_escape_string($daily_spam) . "'," . "'" . date('Y-m-d H:i:s') . "'" . ")"; //echo $sql; mysql_query($sql); } function track_usedcar_click_whatsapp($listing_id, $client_id) { $ip = $this->get_your_ip(); $date_today=date('Y-m-d'); $check_full_day_leads= $this->check_ip_full_day($ip,1,'email_sms'); if($check_full_day_leads > 60) { $daily_spam='1'; } else if(!empty($ip)) { $check_spam_ip=mysql_query("select time from `email_sms` where listing_id='$listing_id' and type='5' and usedcar = '1' and ip='$ip' and date(`time`)='$date_today'"); if(mysql_num_rows($check_spam_ip)>0){ $i=0; while($spam = mysql_fetch_array($check_spam_ip)) { $expiry_time = new DateTime($spam['time']); $current_date = new DateTime(); $diff = $expiry_time->diff($current_date); $hour=$diff->format('%h'); $minute=$diff->format('%i'); if(($hour==1 && $minute<5) || ( $hour==0)) { $i++; } } $dailyspam = $i; if($dailyspam>=2) { $daily_spam='1'; } else { $daily_spam='0'; } } else { $daily_spam='0'; } } else { $daily_spam='0'; } $sql = "insert into email_sms(client_id,listing_id,type,ip,daily_spam,usedcar,time) values (" . "'" . mysql_real_escape_string($client_id) . "'," . "'" . mysql_real_escape_string($listing_id) . "'," . "'5'" . "," . "'" . mysql_real_escape_string($ip) . "'," . "'" . mysql_real_escape_string($daily_spam) . "'," . "'1'" . "," . "'" . date('Y-m-d H:i:s') . "'" . ")"; //echo $sql; mysql_query($sql); } function track_click_whatsapp2($listing_id, $client_id, $featured_listing, $best_offer_listing) { $ip = $this->get_your_ip(); $date_today=date('Y-m-d'); $check_full_day_leads= $this->check_ip_full_day($ip,0,'email_sms'); if($check_full_day_leads > 60) { $daily_spam='1'; } else if(!empty($ip)) { $check_spam_ip=mysql_query("select time from `email_sms` where listing_id='$listing_id' and type='5' and ip='$ip' and date(`time`)='$date_today'"); if(mysql_num_rows($check_spam_ip)>0){ $i=0; while($spam = mysql_fetch_array($check_spam_ip)) { $expiry_time = new DateTime($spam['time']); $current_date = new DateTime(); $diff = $expiry_time->diff($current_date); $hour=$diff->format('%h'); $minute=$diff->format('%i'); if(($hour==1 && $minute<5) || ( $hour==0)) { $i++; } } $dailyspam = $i; if($dailyspam>=2) { $daily_spam='1'; } else { $daily_spam='0'; } } else { $daily_spam='0'; } } else { $daily_spam='0'; } $sql = "insert into email_sms(client_id,listing_id,type,ip,featured_listing,best_offer_listing,daily_spam,time) values (" . "'" . mysql_real_escape_string($client_id) . "'," . "'" . mysql_real_escape_string($listing_id) . "'," . "'5'" . "," . "'" . mysql_real_escape_string($ip) . "'," . "'" . mysql_real_escape_string($featured_listing) . "'," . "'" . mysql_real_escape_string($best_offer_listing) . "'," . "'" . mysql_real_escape_string($daily_spam) . "'," . "'" . date('Y-m-d H:i:s') . "'" . ")"; //echo $sql; mysql_query($sql); } function track_click_whatsapp3($listing_id, $client_id, $featured_listing, $best_offer_listing, $verification) { $ip = $this->get_your_ip(); $date_today=date('Y-m-d'); $check_full_day_leads= $this->check_ip_full_day($ip,0,'email_sms'); if($check_full_day_leads > 60) { $daily_spam='1'; } else if(!empty($ip)) { $check_spam_ip=mysql_query("select time from `email_sms` where listing_id='$listing_id' and type='5' and ip='$ip' and date(`time`)='$date_today'"); if(mysql_num_rows($check_spam_ip)>0){ $i=0; while($spam = mysql_fetch_array($check_spam_ip)) { $expiry_time = new DateTime($spam['time']); $current_date = new DateTime(); $diff = $expiry_time->diff($current_date); $hour=$diff->format('%h'); $minute=$diff->format('%i'); if(($hour==1 && $minute<5) || ( $hour==0)) { $i++; } } $dailyspam = $i; if($dailyspam>=2) { $daily_spam='1'; } else { $daily_spam='0'; } } else { $daily_spam='0'; } } else { $daily_spam='0'; } $sql = "insert into email_sms(client_id,listing_id,type,ip,featured_listing,best_offer_listing,verified_listing,daily_spam,time) values (" . "'" . mysql_real_escape_string($client_id) . "'," . "'" . mysql_real_escape_string($listing_id) . "'," . "'5'" . "," . "'" . mysql_real_escape_string($ip) . "'," . "'" . mysql_real_escape_string($featured_listing) . "'," . "'" . mysql_real_escape_string($best_offer_listing) . "'," . "'" . mysql_real_escape_string($verification) . "'," . "'" . mysql_real_escape_string($daily_spam) . "'," . "'" . date('Y-m-d H:i:s') . "'" . ")"; //echo $sql; mysql_query($sql); } function insert_email_latest7($client_id, $listing_id, $name, $email, $mobile, $message, $car, $status, $pick_up, $drop_off, $featured_listing, $best_offer_listing, $check_verification, $restrict_leads, $price_stat, $message_for_user, $message_for_client, $premium_listing) { $ip = $this->get_your_ip(); $sql = "insert into email_sms (client_id,listing_id,name,email,mobile,type,message,status,car_name,pickupdate,dropoffdate,featured_listing,best_offer_listing,verified_listing,restrict_leads,ip,price_stat,message_for_user,message_for_client,premium_listing,time) values (" . "'" . mysql_real_escape_string($client_id) . "'," . "'" . mysql_real_escape_string($listing_id) . "'," . "'" . mysql_real_escape_string($name) . "'," . "'" . mysql_real_escape_string($email) . "'," . "'" . mysql_real_escape_string($mobile) . "'," . "'1'" . "," . "'" . mysql_real_escape_string($message) . "'," . "'" . mysql_real_escape_string($status) . "'," . "'" . mysql_real_escape_string($car) . "'," . "'" . mysql_real_escape_string($pick_up) . "'," . "'" . mysql_real_escape_string($drop_off) . "'," . "'" . mysql_real_escape_string($featured_listing) . "'," . "'" . mysql_real_escape_string($best_offer_listing) . "'," . "'" . mysql_real_escape_string($check_verification) . "'," . "'" . mysql_real_escape_string($restrict_leads) . "'," . "'" . mysql_real_escape_string($ip) . "'," . "'" . mysql_real_escape_string($price_stat) . "'," . "'" . mysql_real_escape_string($message_for_user) . "'," . "'" . mysql_real_escape_string($message_for_client) . "'," . "'" . mysql_real_escape_string($premium_listing) . "'," . "'" . date('Y-m-d H:i:s') . "'" . ")"; mysql_query($sql); return mysql_insert_id(); } function insert_email_latest8($client_id, $listing_id, $name, $email, $mobile, $message, $car, $status, $pick_up, $drop_off, $featured_listing, $best_offer_listing, $check_verification, $restrict_leads, $price_stat, $message_for_user, $message_for_client, $premium_listing, $page) { $ip = $this->get_your_ip(); $user_id = 0; if(isset($_COOKIE['void']) && $this->session->userdata("userr_id") != ""){ $user_id = $this->session->userdata("userr_id"); } $sql = "insert into email_sms (client_id,user_id,listing_id,name,email,mobile,type,message,status,car_name,pickupdate,dropoffdate,featured_listing,best_offer_listing,verified_listing,restrict_leads,ip,price_stat,message_for_user,message_for_client,premium_listing,page,time) values (" . "'" . mysql_real_escape_string($client_id) . "'," . "'" . mysql_real_escape_string($user_id) . "'," . "'" . mysql_real_escape_string($listing_id) . "'," . "'" . mysql_real_escape_string($name) . "'," . "'" . mysql_real_escape_string($email) . "'," . "'" . mysql_real_escape_string($mobile) . "'," . "'1'" . "," . "'" . mysql_real_escape_string($message) . "'," . "'" . mysql_real_escape_string($status) . "'," . "'" . mysql_real_escape_string($car) . "'," . "'" . mysql_real_escape_string($pick_up) . "'," . "'" . mysql_real_escape_string($drop_off) . "'," . "'" . mysql_real_escape_string($featured_listing) . "'," . "'" . mysql_real_escape_string($best_offer_listing) . "'," . "'" . mysql_real_escape_string($check_verification) . "'," . "'" . mysql_real_escape_string($restrict_leads) . "'," . "'" . mysql_real_escape_string($ip) . "'," . "'" . mysql_real_escape_string($price_stat) . "'," . "'" . mysql_real_escape_string($message_for_user) . "'," . "'" . mysql_real_escape_string($message_for_client) . "'," . "'" . mysql_real_escape_string($premium_listing) . "'," . "'" . mysql_real_escape_string($page) . "'," . "'" . date('Y-m-d H:i:s') . "'" . ")"; mysql_query($sql); return mysql_insert_id(); } function updateuserid($insertid, $name, $email, $uid){ $sql = "update email_sms set user_id = '" . $uid . "', name = '".$name."', email = '".$email."' where id = $insertid"; mysql_query($sql); //echo $sql; } function insert_email_latest88($client_id, $listing_id, $name, $email, $mobile, $message, $car, $status, $pick_up, $drop_off, $featured_listing, $best_offer_listing, $check_verification, $restrict_leads, $price_stat, $message_for_user, $message_for_client, $premium_listing, $page,$month_lead) { if (isset($_COOKIE['void']) && $this->session->userdata("userr_id") != ""){ $user_id = $this->session->userdata("userr_id"); } else { $user_id = 0; } $ip = $this->get_your_ip(); $sql = "insert into email_sms (client_id,user_id,listing_id,name,email,mobile,type,message,status,car_name,pickupdate,dropoffdate,featured_listing,best_offer_listing,verified_listing,restrict_leads,ip,price_stat,message_for_user,message_for_client,premium_listing,page,month_lead,time) values (" . "'" . mysql_real_escape_string($client_id) . "'," . "'" . mysql_real_escape_string($user_id) . "'," . "'" . mysql_real_escape_string($listing_id) . "'," . "'" . mysql_real_escape_string($name) . "'," . "'" . mysql_real_escape_string($email) . "'," . "'" . mysql_real_escape_string($mobile) . "'," . "'1'" . "," . "'" . mysql_real_escape_string($message) . "'," . "'" . mysql_real_escape_string($status) . "'," . "'" . mysql_real_escape_string($car) . "'," . "'" . mysql_real_escape_string($pick_up) . "'," . "'" . mysql_real_escape_string($drop_off) . "'," . "'" . mysql_real_escape_string($featured_listing) . "'," . "'" . mysql_real_escape_string($best_offer_listing) . "'," . "'" . mysql_real_escape_string($check_verification) . "'," . "'" . mysql_real_escape_string($restrict_leads) . "'," . "'" . mysql_real_escape_string($ip) . "'," . "'" . mysql_real_escape_string($price_stat) . "'," . "'" . mysql_real_escape_string($message_for_user) . "'," . "'" . mysql_real_escape_string($message_for_client) . "'," . "'" . mysql_real_escape_string($premium_listing) . "'," . "'" . mysql_real_escape_string($page) . "'," . "'" . mysql_real_escape_string($month_lead) . "'," . "'" . date('Y-m-d H:i:s') . "'" . ")"; mysql_query($sql); return mysql_insert_id(); } function insert_submit_form_status($user_id, $listing_id, $client_id,$email_feed) { if($user_id == 0){ $sql = "update feedback_track set submit_enquiry_form = 1, email_sms_track_id = '$email_feed' where client_id = $client_id and listing_id = $listing_id"; } else { $sql = "update feedback_track set submit_enquiry_form = 1, email_sms_track_id = '$email_feed' where client_id = $client_id and listing_id = $listing_id and user_id = $user_id"; } mysql_query($sql); return $sql; } function insert_email_latest9($client_id, $listing_id,$car_typ, $name, $email, $mobile, $message, $car, $status, $pick_up, $drop_off, $featured_listing, $best_offer_listing, $check_verification, $restrict_leads, $price_stat, $message_for_user, $message_for_client, $premium_listing = '') { $ip = $this->get_your_ip(); $page = "Details Page"; $user_id = 0; if(isset($_COOKIE['void']) && $this->session->userdata("userr_id") != ""){ $user_id = $this->session->userdata("userr_id"); } $sql = "insert into email_sms (client_id,user_id,listing_id,car_type,name,email,mobile,type,message,status,car_name,pickupdate,dropoffdate,featured_listing,best_offer_listing,verified_listing,restrict_leads,ip,price_stat,message_for_user,message_for_client,page,time,premium_listing) values (" . "'" . mysql_real_escape_string($client_id) . "'," . "'" . mysql_real_escape_string($user_id) . "'," . "'" . mysql_real_escape_string($listing_id) . "'," . "'" . mysql_real_escape_string($car_typ) . "'," . "'" . mysql_real_escape_string($name) . "'," . "'" . mysql_real_escape_string($email) . "'," . "'" . mysql_real_escape_string($mobile) . "'," . "'6'" . "," . "'" . mysql_real_escape_string($message) . "'," . "'" . mysql_real_escape_string($status) . "'," . "'" . mysql_real_escape_string($car) . "'," . "'" . mysql_real_escape_string($pick_up) . "'," . "'" . mysql_real_escape_string($drop_off) . "'," . "'" . mysql_real_escape_string($featured_listing) . "'," . "'" . mysql_real_escape_string($best_offer_listing) . "'," . "'" . mysql_real_escape_string($check_verification) . "'," . "'" . mysql_real_escape_string($restrict_leads) . "'," . "'" . mysql_real_escape_string($ip) . "'," . "'" . mysql_real_escape_string($price_stat) . "'," . "'" . mysql_real_escape_string($message_for_user) . "'," . "'" . mysql_real_escape_string($message_for_client) . "'," . "'" . mysql_real_escape_string($page) . "'," . "'" . date('Y-m-d H:i:s') . "'," . "'" . mysql_real_escape_string($premium_listing) . "'" . ")"; mysql_query($sql); return mysql_insert_id(); } function insert_email_latest6($client_id, $listing_id, $name, $email, $mobile, $message, $car, $status, $pick_up, $drop_off, $featured_listing, $best_offer_listing, $check_verification, $restrict_leads, $price_stat, $message_for_user, $message_for_client, $premium_listing = '', $start_time, $used_cars=0) { $ip = $this->get_your_ip(); $page = "Details Page"; $user_id = 0; if(isset($_COOKIE['void']) && $this->session->userdata("userr_id") != ""){ $user_id = $this->session->userdata("userr_id"); } $sql = "insert into email_sms (client_id,user_id,listing_id,name,email,mobile,type,message,status,car_name,pickupdate,dropoffdate,featured_listing,best_offer_listing,verified_listing,restrict_leads,ip,price_stat,message_for_user,message_for_client,page,time,premium_listing,usedcar,start_time) values (" . "'" . mysql_real_escape_string($client_id) . "'," . "'" . mysql_real_escape_string($user_id) . "'," . "'" . mysql_real_escape_string($listing_id) . "'," . "'" . mysql_real_escape_string($name) . "'," . "'" . mysql_real_escape_string($email) . "'," . "'" . mysql_real_escape_string($mobile) . "'," . "'1'" . "," . "'" . mysql_real_escape_string($message) . "'," . "'" . mysql_real_escape_string($status) . "'," . "'" . mysql_real_escape_string($car) . "'," . "'" . mysql_real_escape_string($pick_up) . "'," . "'" . mysql_real_escape_string($drop_off) . "'," . "'" . mysql_real_escape_string($featured_listing) . "'," . "'" . mysql_real_escape_string($best_offer_listing) . "'," . "'" . mysql_real_escape_string($check_verification) . "'," . "'" . mysql_real_escape_string($restrict_leads) . "'," . "'" . mysql_real_escape_string($ip) . "'," . "'" . mysql_real_escape_string($price_stat) . "'," . "'" . mysql_real_escape_string($message_for_user) . "'," . "'" . mysql_real_escape_string($message_for_client) . "'," . "'" . mysql_real_escape_string($page) . "'," . "'" . date('Y-m-d H:i:s') . "'," . "'" . mysql_real_escape_string($premium_listing) . "'," . "'" . mysql_real_escape_string($used_cars) . "'," . "'" . mysql_real_escape_string($start_time) . "'" . ")"; mysql_query($sql); return mysql_insert_id(); } function insert_email_latest66($client_id, $listing_id, $name, $email, $mobile, $message, $car, $status, $pick_up, $drop_off, $featured_listing, $best_offer_listing, $check_verification, $restrict_leads, $price_stat, $message_for_user, $message_for_client, $premium_listing = '',$month_lead) { $ip = $this->get_your_ip(); $page = "Details Page"; $user_id = 0; if(isset($_COOKIE['void']) && $this->session->userdata("userr_id") != ""){ $user_id = $this->session->userdata("userr_id"); } $sql = "insert into email_sms (client_id,user_id,listing_id,name,email,mobile,type,message,status,car_name,pickupdate,dropoffdate,featured_listing,best_offer_listing,verified_listing,restrict_leads,ip,price_stat,message_for_user,message_for_client,page,time,month_lead,premium_listing) values (" . "'" . mysql_real_escape_string($client_id) . "'," . "'" . mysql_real_escape_string($user_id) . "'," . "'" . mysql_real_escape_string($listing_id) . "'," . "'" . mysql_real_escape_string($name) . "'," . "'" . mysql_real_escape_string($email) . "'," . "'" . mysql_real_escape_string($mobile) . "'," . "'1'" . "," . "'" . mysql_real_escape_string($message) . "'," . "'" . mysql_real_escape_string($status) . "'," . "'" . mysql_real_escape_string($car) . "'," . "'" . mysql_real_escape_string($pick_up) . "'," . "'" . mysql_real_escape_string($drop_off) . "'," . "'" . mysql_real_escape_string($featured_listing) . "'," . "'" . mysql_real_escape_string($best_offer_listing) . "'," . "'" . mysql_real_escape_string($check_verification) . "'," . "'" . mysql_real_escape_string($restrict_leads) . "'," . "'" . mysql_real_escape_string($ip) . "'," . "'" . mysql_real_escape_string($price_stat) . "'," . "'" . mysql_real_escape_string($message_for_user) . "'," . "'" . mysql_real_escape_string($message_for_client) . "'," . "'" . mysql_real_escape_string($page) . "'," . "'" . date('Y-m-d H:i:s') . "'," . "'" . mysql_real_escape_string($month_lead) . "'," . "'" . mysql_real_escape_string($premium_listing) . "'" . ")"; mysql_query($sql); return mysql_insert_id(); } function insert_email_latest5($client_id, $listing_id, $name, $email, $mobile, $message, $car, $status, $pick_up, $drop_off, $featured_listing, $best_offer_listing, $check_verification, $restrict_leads) { $ip = $this->get_your_ip(); $sql = "insert into email_sms (client_id,listing_id,name,email,mobile,type,message,status,car_name,pickupdate,dropoffdate,featured_listing,best_offer_listing,verified_listing,restrict_leads,ip,time) values (" . "'" . mysql_real_escape_string($client_id) . "'," . "'" . mysql_real_escape_string($listing_id) . "'," . "'" . mysql_real_escape_string($name) . "'," . "'" . mysql_real_escape_string($email) . "'," . "'" . mysql_real_escape_string($mobile) . "'," . "'1'" . "," . "'" . mysql_real_escape_string($message) . "'," . "'" . mysql_real_escape_string($status) . "'," . "'" . mysql_real_escape_string($car) . "'," . "'" . mysql_real_escape_string($pick_up) . "'," . "'" . mysql_real_escape_string($drop_off) . "'," . "'" . mysql_real_escape_string($featured_listing) . "'," . "'" . mysql_real_escape_string($best_offer_listing) . "'," . "'" . mysql_real_escape_string($check_verification) . "'," . "'" . mysql_real_escape_string($restrict_leads) . "'," . "'" . mysql_real_escape_string($ip) . "'," . "'" . date('Y-m-d H:i:s') . "'" . ")"; mysql_query($sql); } function insert_spam_email_captcha($client_id, $listing_id, $name, $email, $mobile, $messasge_txt, $car, $page_current) { $ip = $this->get_your_ip(); $sql = "insert into email_sms_captcha_spam (client_id,listing_id,name,email,mobile,message,car,ip,page,time) values (" . "'" . mysql_real_escape_string($client_id) . "'," . "'" . mysql_real_escape_string($listing_id) . "'," . "'" . mysql_real_escape_string($name) . "'," . "'" . mysql_real_escape_string($email) . "'," . "'" . mysql_real_escape_string($mobile) . "'," . "'" . mysql_real_escape_string($messasge_txt) . "'," . "'" . mysql_real_escape_string($car) . "'," . "'" . mysql_real_escape_string($ip) . "'," . "'" . mysql_real_escape_string($page_current) . "'," . "'" . date('Y-m-d H:i:s') . "'" . ")"; mysql_query($sql); } function insert_all_spam($name, $email, $mobile, $message, $ip, $page) { $sql = "insert into email_all_spam (name,email,mobile,message,ip,page,time) values (" . "'" . mysql_real_escape_string($name) . "'," . "'" . mysql_real_escape_string($email) . "'," . "'" . mysql_real_escape_string($mobile) . "'," . "'" . mysql_real_escape_string($message) . "'," . "'" . mysql_real_escape_string($ip) . "'," . "'" . mysql_real_escape_string($page) . "'," . "'" . date('Y-m-d H:i:s') . "'" . ")"; mysql_query($sql); } function insert_spam_email($client_id, $listing_id, $name, $email, $mobile, $message, $car, $status, $pick_up, $drop_off, $featured_listing, $best_offer_listing, $check_verification, $restrict_leads) { $ip = $this->get_your_ip(); $sql = "insert into email_sms_spam (client_id,listing_id,name,email,mobile,type,message,status,car_name,pickupdate,dropoffdate,featured_listing,best_offer_listing,verified_listing,restrict_leads,ip,time) values (" . "'" . mysql_real_escape_string($client_id) . "'," . "'" . mysql_real_escape_string($listing_id) . "'," . "'" . mysql_real_escape_string($name) . "'," . "'" . mysql_real_escape_string($email) . "'," . "'" . mysql_real_escape_string($mobile) . "'," . "'1'" . "," . "'" . mysql_real_escape_string($message) . "'," . "'" . mysql_real_escape_string($status) . "'," . "'" . mysql_real_escape_string($car) . "'," . "'" . mysql_real_escape_string($pick_up) . "'," . "'" . mysql_real_escape_string($drop_off) . "'," . "'" . mysql_real_escape_string($featured_listing) . "'," . "'" . mysql_real_escape_string($best_offer_listing) . "'," . "'" . mysql_real_escape_string($check_verification) . "'," . "'" . mysql_real_escape_string($restrict_leads) . "'," . "'" . mysql_real_escape_string($ip) . "'," . "'" . date('Y-m-d H:i:s') . "'" . ")"; mysql_query($sql); } function insert_email_latest($client_id, $listing_id, $name, $email, $mobile, $message, $car, $status) { $ip = $this->get_your_ip(); $sql = "insert into email_sms (client_id,listing_id,name,email,mobile,type,message,status,car_name,time) values (" . "'" . mysql_real_escape_string($client_id) . "'," . "'" . mysql_real_escape_string($listing_id) . "'," . "'" . mysql_real_escape_string($name) . "'," . "'" . mysql_real_escape_string($email) . "'," . "'" . mysql_real_escape_string($mobile) . "'," . "'1'" . "," . "'" . mysql_real_escape_string($message) . "'," . "'" . mysql_real_escape_string($status) . "'," . "'" . mysql_real_escape_string($car) . "'," . "'" . date('Y-m-d H:i:s') . "'" . ")"; mysql_query($sql); } function insert_email_latest2($client_id, $listing_id, $name, $email, $mobile, $message, $car, $status, $pick_up, $drop_off) { $ip = $this->get_your_ip(); $sql = "insert into email_sms (client_id,listing_id,name,email,mobile,type,message,status,car_name,pickupdate,dropoffdate,time) values (" . "'" . mysql_real_escape_string($client_id) . "'," . "'" . mysql_real_escape_string($listing_id) . "'," . "'" . mysql_real_escape_string($name) . "'," . "'" . mysql_real_escape_string($email) . "'," . "'" . mysql_real_escape_string($mobile) . "'," . "'1'" . "," . "'" . mysql_real_escape_string($message) . "'," . "'" . mysql_real_escape_string($status) . "'," . "'" . mysql_real_escape_string($car) . "'," . "'" . mysql_real_escape_string($pick_up) . "'," . "'" . mysql_real_escape_string($drop_off) . "'," . "'" . date('Y-m-d H:i:s') . "'" . ")"; mysql_query($sql); } function insert_email_latest3($client_id, $listing_id, $name, $email, $mobile, $message, $car, $status, $pick_up, $drop_off, $featured_listing, $best_offer_listing) { $ip = $this->get_your_ip(); $sql = "insert into email_sms (client_id,listing_id,name,email,mobile,type,message,status,car_name,pickupdate,dropoffdate,featured_listing,best_offer_listing,time) values (" . "'" . mysql_real_escape_string($client_id) . "'," . "'" . mysql_real_escape_string($listing_id) . "'," . "'" . mysql_real_escape_string($name) . "'," . "'" . mysql_real_escape_string($email) . "'," . "'" . mysql_real_escape_string($mobile) . "'," . "'1'" . "," . "'" . mysql_real_escape_string($message) . "'," . "'" . mysql_real_escape_string($status) . "'," . "'" . mysql_real_escape_string($car) . "'," . "'" . mysql_real_escape_string($pick_up) . "'," . "'" . mysql_real_escape_string($drop_off) . "'," . "'" . mysql_real_escape_string($featured_listing) . "'," . "'" . mysql_real_escape_string($best_offer_listing) . "'," . "'" . date('Y-m-d H:i:s') . "'" . ")"; mysql_query($sql); } function insert_email_latest4($client_id, $listing_id, $name, $email, $mobile, $message, $car, $status, $pick_up, $drop_off, $featured_listing, $best_offer_listing, $check_verification) { $ip = $this->get_your_ip(); $sql = "insert into email_sms (client_id,listing_id,name,email,mobile,type,message,status,car_name,pickupdate,dropoffdate,featured_listing,best_offer_listing,verified_listing,ip,time) values (" . "'" . mysql_real_escape_string($client_id) . "'," . "'" . mysql_real_escape_string($listing_id) . "'," . "'" . mysql_real_escape_string($name) . "'," . "'" . mysql_real_escape_string($email) . "'," . "'" . mysql_real_escape_string($mobile) . "'," . "'1'" . "," . "'" . mysql_real_escape_string($message) . "'," . "'" . mysql_real_escape_string($status) . "'," . "'" . mysql_real_escape_string($car) . "'," . "'" . mysql_real_escape_string($pick_up) . "'," . "'" . mysql_real_escape_string($drop_off) . "'," . "'" . mysql_real_escape_string($featured_listing) . "'," . "'" . mysql_real_escape_string($best_offer_listing) . "'," . "'" . mysql_real_escape_string($check_verification) . "'," . "'" . mysql_real_escape_string($ip) . "'," . "'" . date('Y-m-d H:i:s') . "'" . ")"; mysql_query($sql); } function insert_email($client_id, $listing_id, $name, $email, $mobile, $pickup, $dropoff, $pickupdate, $dropoffdate, $message, $car, $status) { $ip = $this->get_your_ip(); $sql = "insert into email_sms (client_id,listing_id,name,email,mobile,pickup,dropoff,pickupdate,dropoffdate,type,message,status,car_name,time) values (" . "'" . mysql_real_escape_string($client_id) . "'," . "'" . mysql_real_escape_string($listing_id) . "'," . "'" . mysql_real_escape_string($name) . "'," . "'" . mysql_real_escape_string($email) . "'," . "'" . mysql_real_escape_string($mobile) . "'," . "'" . mysql_real_escape_string($pickup) . "'," . "'" . mysql_real_escape_string($dropoff) . "'," . "'" . mysql_real_escape_string($pickupdate) . "'," . "'" . mysql_real_escape_string($dropoffdate) . "'," . "'1'" . "," . "'" . mysql_real_escape_string($message) . "'," . "'" . mysql_real_escape_string($status) . "'," . "'" . mysql_real_escape_string($car) . "'," . "'" . date('Y-m-d H:i:s') . "'" . ")"; mysql_query($sql); } function insert_email_lease($client_id, $name, $email_add, $phone_number, $sender, $period, $type, $message_req, $ip, $web_address) { $sql = "insert into email_lease (client_id,name,email_id,mobile,sender,period,car_type,message,ip,web_address,ts) values (" . "'" . mysql_real_escape_string($client_id) . "'," . "'" . mysql_real_escape_string($name) . "'," . "'" . mysql_real_escape_string($email_add) . "'," . "'" . mysql_real_escape_string($phone_number) . "'," . "'" . mysql_real_escape_string($sender) . "'," . "'" . mysql_real_escape_string($period) . "'," . "'" . mysql_real_escape_string($type) . "'," . "'" . mysql_real_escape_string($message_req) . "'," . "'" . mysql_real_escape_string($ip) . "'," . "'" . mysql_real_escape_string($web_address) . "'," . "'" . date('Y-m-d H:i:s') . "'" . ")"; mysql_query($sql); } function insert_email_lease2($client_id, $name, $email_add, $phone_number, $sender, $period, $type, $message_req, $emirates, $ip, $web_address) { $sql = "insert into email_lease (client_id,name,email_id,mobile,sender,period,car_type,message,emirates,ip,web_address,ts) values (" . "'" . mysql_real_escape_string($client_id) . "'," . "'" . mysql_real_escape_string($name) . "'," . "'" . mysql_real_escape_string($email_add) . "'," . "'" . mysql_real_escape_string($phone_number) . "'," . "'" . mysql_real_escape_string($sender) . "'," . "'" . mysql_real_escape_string($period) . "'," . "'" . mysql_real_escape_string($type) . "'," . "'" . mysql_real_escape_string($message_req) . "'," . "'" . mysql_real_escape_string($emirates) . "'," . "'" . mysql_real_escape_string($ip) . "'," . "'" . mysql_real_escape_string($web_address) . "'," . "'" . date('Y-m-d H:i:s') . "'" . ")"; mysql_query($sql); } function insert_email_lease_newsection($lease_type, $insert_id, $lease_id, $client_id, $name, $email_add, $phone_number, $sender, $period, $type, $message_req, $emirates, $ip, $web_address, $car, $message_for_user, $message_for_client) { $sql = "insert into email_lease (lease_type,insert_id,lease_id,client_id,car_name,name,email_id,mobile,sender,period,car_type,message,emirates,ip,web_address,message_for_user,message_for_client,ts) values (" . "'" . mysql_real_escape_string($lease_type) . "'," . "'" . mysql_real_escape_string($insert_id) . "'," . "'" . mysql_real_escape_string($lease_id) . "'," . "'" . mysql_real_escape_string($client_id) . "'," . "'" . mysql_real_escape_string($car) . "'," . "'" . mysql_real_escape_string($name) . "'," . "'" . mysql_real_escape_string($email_add) . "'," . "'" . mysql_real_escape_string($phone_number) . "'," . "'" . mysql_real_escape_string($sender) . "'," . "'" . mysql_real_escape_string($period) . "'," . "'" . mysql_real_escape_string($type) . "'," . "'" . mysql_real_escape_string($message_req) . "'," . "'" . mysql_real_escape_string($emirates) . "'," . "'" . mysql_real_escape_string($ip) . "'," . "'" . mysql_real_escape_string($web_address) . "'," . "'" . mysql_real_escape_string($message_for_user) . "'," . "'" . mysql_real_escape_string($message_for_client) . "'," . "'" . date('Y-m-d H:i:s') . "'" . ")"; mysql_query($sql); return mysql_insert_id(); } function insert_email_lease_spam($client_id, $name, $email_add, $phone_number, $sender, $period, $type, $message_req, $emirates, $ip, $web_address) { $sql = "insert into email_lease_spam (client_id,name,email_id,mobile,sender,period,car_type,message,emirates,ip,web_address,ts) values (" . "'" . mysql_real_escape_string($client_id) . "'," . "'" . mysql_real_escape_string($name) . "'," . "'" . mysql_real_escape_string($email_add) . "'," . "'" . mysql_real_escape_string($phone_number) . "'," . "'" . mysql_real_escape_string($sender) . "'," . "'" . mysql_real_escape_string($period) . "'," . "'" . mysql_real_escape_string($type) . "'," . "'" . mysql_real_escape_string($message_req) . "'," . "'" . mysql_real_escape_string($emirates) . "'," . "'" . mysql_real_escape_string($ip) . "'," . "'" . mysql_real_escape_string($web_address) . "'," . "'" . date('Y-m-d H:i:s') . "'" . ")"; mysql_query($sql); } function insert_shownumber($client_id, $listing_id) { $ip = $this->get_your_ip(); // Updated to Codeigniter Query Builder for prevent SQL Injection $res = $this->db->insert('email_sms', array('client_id' => $client_id, 'listing_id' => $listing_id, 'type' => '2', 'ip' => $ip)); } function get_search_info($complete_url) { $key_cache="get_search_info1".$complete_url; //if modifying key then modify on the premium listing controller $search_info = $this->memcached_library->get($key_cache); if (!$search_info && !is_numeric($search_info)) { $sql = mysql_query("select * from search_info where url like '%$complete_url%'"); if (mysql_num_rows($sql) > 0) { $listings = array(); while ($val = mysql_fetch_array($sql)) { $aRow[$val['id']] ['title'] = $val['title']; $aRow[$val['id']] ['description'] = $val['meta_desc']; $aRow[$val['id']] ['h1'] = $val['h1']; $aRow[$val['id']] ['h2'] = $val['h2']; $aRow[$val['id']] ['bottom_content'] = $val['bottom_content']; $aRow[$val['id']] ['faq_title'] = $val['faq_title']; $aRow[$val['id']] ['faq'] = $val['faq']; } $listings=$aRow; } else{ $listings="0"; } $this->memcached_library->add($key_cache, $listings, 86400); return $listings; } else { return $search_info; } } function premium_queries($url_premium,$order) { //$key_cache = 'premium_queries_lat2@'.$url_premium.'@'.$order; $key_cache="premium_queries_lat4".$url_premium; //if modifying key then modify on the premium listing controller // $this->memcached_library->delete($key_cache); $premium_queries = $this->memcached_library->get($key_cache); if (!$premium_queries && !is_numeric($premium_queries)) { if (strpos($order, 'featured') !== false) { $order = str_ireplace("featured desc", "", $order); $order = str_ireplace(", images_verify desc", "images_verify desc", $order); } $sql = mysql_query("select listing_id,client_id from premium_listings where seo_url='$url_premium'"); if (mysql_num_rows($sql) > 0) { $listings = array(); while ($val = mysql_fetch_array($sql)) { $lists = $val['listing_id']; $client_id = $val['client_id']; $sql2 = mysql_query("select listings.id from listings inner join clients on listings.client_id=clients.client_id where listings.id='$lists' and publish_ocd='1'"); if (mysql_num_rows($sql2) > 0) { $listings[] = $lists; } else { $val2 = []; $sql3 = mysql_query("select listings.id from listings inner join clients on listings.client_id=clients.client_id where listings.client_id='$client_id' and publish_ocd='1' order by $order refresh desc limit 1"); if (mysql_num_rows($sql3) > 0) { $val2 = mysql_fetch_array($sql3); $listings[] = $val2['id']; } } } } else{ $listings="0"; } $this->memcached_library->add($key_cache, $listings); return $listings; } else { return $premium_queries; } } function premium_queries_used($url_premium,$order) { //$key_cache = 'premium_queries_lat2@'.$url_premium.'@'.$order; $key_cache="premium_queries_lat_used4".$url_premium; //if modifying key then modify on the premium listing controller // $this->memcached_library->delete($key_cache); $premium_queries = $this->memcached_library->get($key_cache); if (!$premium_queries && !is_numeric($premium_queries)) { if (strpos($order, 'featured') !== false) { $order = str_ireplace("featured desc", "", $order); $order = str_ireplace(", images_verify desc", "images_verify desc", $order); } $sql = mysql_query("select listing_id,client_id from premium_listings where seo_url='$url_premium'"); if (mysql_num_rows($sql) > 0) { $listings = array(); while ($val = mysql_fetch_array($sql)) { $lists = $val['listing_id']; $client_id = $val['client_id']; $sql2 = mysql_query("select usedcar_listings.id from usedcar_listings inner join clients on usedcar_listings.client_id=clients.client_id where usedcar_listings.id='$lists' and publish_ocd='1'"); if (mysql_num_rows($sql2) > 0) { $listings[] = $lists; } else { $val2 = []; $sql3 = mysql_query("select usedcar_listings.id from usedcar_listings inner join clients on usedcar_listings.client_id=clients.client_id where usedcar_listings.client_id='$client_id' and publish_ocd='1' order by $order refresh desc limit 1"); if (mysql_num_rows($sql3) > 0) { $val2 = mysql_fetch_array($sql3); $listings[] = $val2['id']; } } } } else{ $listings="0"; } $this->memcached_library->add($key_cache, $listings); return $listings; } else { return $premium_queries; } } public function get_seo_slider($seo_parameter_slider, $emirate) { $key_cache = 'get_seo_slider294512@' . $seo_parameter_slider . '@' . $emirate; // $this->memcached_library->delete($key_cache); $get_seo_slider = $this->memcached_library->get($key_cache); if (!$get_seo_slider && !is_numeric($get_seo_slider)) { $parameter_array_slider = explode("&", $seo_parameter_slider); $countcarcompany_slider = substr_count($seo_parameter_slider, 'carcompany%5B%5D'); $countgroup_slider = substr_count($seo_parameter_slider, 'group%5B%5D'); $countlisting_slider = substr_count($seo_parameter_slider, 'listing_id%5B%5D'); //echo $countlisting_slider; foreach ($parameter_array_slider as $i) { # split into keyword and value list($keyword_slider, $value_slider) = explode('=', $i, 2); if ($keyword_slider == 'group%5B%5D' || $keyword_slider == 'group[]' || $keyword_slider == '&group' || $keyword_slider == 'group') { if ($countgroup_slider > 1) { $group_slider[] = $value_slider; } else { $group_slider = $value_slider; } } elseif ($keyword_slider == 'listing_id%5B%5D' || $keyword_slider == 'listing[]' || $keyword_slider == 'listing') { if ($countlisting_slider > 1) { $carlisting_slider[] = $value_slider; } else { $carlisting_slider = $value_slider; } } elseif ($keyword_slider == 'carcompany%5B%5D' || $keyword_slider == 'carcompany[]' || $keyword_slider == 'carcompany') { if ($countcarcompany_slider > 1) { $carcompany_slider[] = $value_slider; } else { $carcompany_slider = $value_slider; } } elseif ($keyword_slider == 'fea' || $keyword_slider == 'fea%5B%5D' || $keyword_slider == 'fea[]') { $fea_slider[] = $value_slider; } elseif ($keyword_slider == 'convertible') { $convertible_slider = $value_slider; } elseif ($keyword_slider == 'cruise-control') { $cruise_control_slider = $value_slider; } elseif ($keyword_slider == 'coupe') { $coupe_slider = $value_slider; } elseif ($keyword_slider == 'carmake') { $carmake_slider = $value_slider; } elseif ($keyword_slider == 'carmodel') { $carmodel_slider = $value_slider; } elseif ($keyword_slider == 'year') { $year_slider = $value_slider; } else { $keyword_slider = $value_slider; } } if (!empty($carcompany_slider)) { if (is_array($carcompany_slider)) { $carcompany = array_filter($carcompany_slider); if (!empty($carcompany_slider)) { $carcompany_where_slider = implode(",", $carcompany_slider); if (1 === preg_match('~[0-9]~', $carcompany_where_slider)) { $where_slider[] = " listings.client_id in (" . $carcompany_where_slider . ")"; } } } else { if ($carcompany_slider != '0' || $carcompany_slider != '') { $where_slider[] = " listings.client_id in (" . $carcompany_slider . ")"; } } } if (!empty($carlisting_slider)) { if (is_array($carlisting_slider)) { $carcompany = array_filter($carlisting_slider); if (!empty($carlisting_slider)) { $carlisting_where_slider = implode(",", $carlisting_slider); if (1 === preg_match('~[0-9]~', $carlisting_where_slider)) { $where_slider[] = " listings.id in (" . $carlisting_where_slider . ")"; } } } else { if ($carlisting_slider != '0' || $carlisting_slider != '') { $where_slider[] = " listings.id in (" . $carlisting_slider . ")"; } } } if (!empty($fea_slider)) { $fea_where2_slider = implode(",", $fea_slider); if (1 === preg_match('~[0-9]~', $fea_where2_slider)) { foreach ($fea_slider as $fea_where_slider) { $where_slider[] = " CONCAT(',', free_features, ',') like '%,$fea_where_slider,%'"; } } } if (!empty($cruise_control_slider)) { $where_slider[] = "cruise_control='1'"; } if (!empty($convertible_slider)) { $where_convertible_slider = "or (keywords like '%Convertible%' or keywords like '%gtc%' or keywords like '%dawn%' or keywords like '%cabriolet%' or keywords like '%grancabrio%' or keywords like '%spyder%' or car_make='481' or car_make='438')"; $where_convertible2_slider = "(keywords like '%Convertible%' or keywords like '%gtc%' or keywords like '%dawn%' or keywords like '%cabriolet%' or keywords like '%grancabrio%' or keywords like '%spyder%' or car_make='481' or car_make='438') "; } else { $where_convertible_slider = ""; } if (!empty($coupe_slider)) { $where_coupe_slider = "or car_make in (SELECT id from make where doors='2') and car_type NOT IN ('3','9','11','14')"; $where_coupe2_slider = "car_make in (SELECT id from make where doors='2') and car_type NOT IN ('3','9','11','14')"; } else { $where_coupe_slider = ""; } if (!empty($group_slider)) { if (is_array($group_slider)) { $group_slider = array_filter($group_slider); $group_where_slider = implode(",", $group_slider); if (1 === preg_match('~[0-9]~', $group_where_slider)) { $where_slider[] = "(car_type in (" . $group_where_slider . ")" . $where_coupe_slider . $where_convertible_slider . ")"; } } else { $group_where_slider = $group_slider; $where_slider[] = "(car_type='$group_where_slider'" . $where_coupe_slider . $where_convertible_slider . ")"; } } elseif (!empty($coupe_slider) && !empty($convertible_slider)) { $where_slider[] = "(" . $where_convertible2_slider . " or " . $where_coupe2_slider . ")"; } elseif (!empty($coupe_slider)) { $where_slider[] = "$where_coupe2_slider"; } elseif (!empty($convertible_slider)) { $where_slider[] = "$where_convertible2_slider"; } if (!empty($year_slider)) { $where_slider[] = " year= '$year_slider'"; } if (!empty($carmake_slider)) { //$carmake_where = implode(",", $carmake); $where_slider[] = " car_model in (" . $carmake_slider . ")"; } if (!empty($carmodel_slider) && $carmodel_slider != '0') { //$carmake_where = implode(",", $carmake); $where_slider[] = " car_make in (" . $carmodel_slider . ")"; } $where_slider[] = " listings.client_id in (select client_id from `clients` where emirate like '%$emirate%')"; if (!empty($where_slider)) { $where_stmt_slider = implode(" and ", $where_slider); } else { $where_stmt_slider = "1"; } $order_slider = "featured desc , page desc ,"; if ($where_stmt_slider == '1') { $seott = "0"; $brands_array = array(); } else { list($seott,$brands_array) = $this->GetAllCars_slider('0', '5', $where_stmt_slider, $order_slider); } if(empty($seott)) { $seott="0"; $brands_array = array(); } $this->memcached_library->add($key_cache, array($seott,$brands_array), 86400); $this->set_memcachekeys($key_cache); return array($seott,$brands_array); } else { return $get_seo_slider; } } function get_track_id() { $key_cache = 'get_track_id'; $get_track_id = $this->memcached_library->get($key_cache); if (!$get_track_id && !is_numeric($get_track_id)) { $trackids = mysql_query("select id from call_tracking order by id DESC limit 1"); $trackid = mysql_fetch_array($trackids); $this->memcached_library->add($key_cache, $trackid, 86400); $this->set_memcachekeys($key_cache); return $trackid; } else { return $get_track_id; } } function insert_calltrack_usedcar($client_id, $client_name, $listing_id) { $ip = $this->get_your_ip(); // Updated to Codeigniter Query Builder for prevent SQL Injection $res = $this->db->insert('usedcar_call_tracking', [ 'client_id' => $client_id, 'client_name' => $client_name, 'listing_id' => $listing_id, 'ip' => $ip ]); return $this->db->insert_id(); } function insert_calltrack($client_id, $client_name, $listing_id) { $ip = $this->get_your_ip(); // Updated to Codeigniter Query Builder for prevent SQL Injection $res = $this->db->insert('call_tracking', [ 'client_id' => $client_id, 'client_name' => $client_name, 'listing_id' => $listing_id, 'ip' => $ip ]); return $this->db->insert_id(); } function insert_usedcar_calltrack($client_id, $client_name, $listing_id) { $ip = $this->get_your_ip(); // Updated to Codeigniter Query Builder for prevent SQL Injection $res = $this->db->insert('usedcar_call_tracking', [ 'client_id' => $client_id, 'client_name' => $client_name, 'listing_id' => $listing_id, 'ip' => $ip ]); return $this->db->insert_id(); } function update_calltrack($track_id, $field, $value) { echo $sql = "update call_tracking set $field = '" . $value . "' where id = $track_id"; mysql_query($sql); } function get_contact_details($client_id) { $key_cache = 'get_contact_details@' . $client_id; $get_contact_details = $this->memcached_library->get($key_cache); if (!$get_contact_details && !is_numeric($get_contact_details)) { //$sql = "select email , phone_number , sms_phone , company_name from clients where client_id = $client_id"; // Code updated for prevent SQL Injection risks $query = $this->db->query("SELECT * FROM clients WHERE client_id = ?", [$client_id]); $aRow = $query->row_array(); $this->memcached_library->add($key_cache, $aRow, 86400); $this->set_memcachekeys($key_cache); return $aRow; } else { return $get_contact_details; } } function languages_speak_list() { $key_cache = 'languages_speak_list'; // $languages_speak_list=$this->memcached_library->delete($key_cache); $languages_speak_list = $this->memcached_library->get($key_cache); if (!$languages_speak_list && !is_numeric($languages_speak_list)) { $this->db->select('*'); $this->db->from('languages_speak'); $query = $this->db->get() or die(mysql_error()); $trans_result = $query->result_array(); foreach ($trans_result as $row) { $result[$row["id"]] = $row["language"]; } $this->memcached_library->add($key_cache, $result, 86400); $this->set_memcachekeys($key_cache); return $result; } else { return $languages_speak_list; } } function get_user($client_id, $username, $password) { $sql = "select id , client_id from users_c where " . " username = '" . mysql_real_escape_string($username) . "' and password=md5('" . mysql_real_escape_string($password) . "')"; $result = mysql_query($sql); $aRow = mysql_fetch_array($result); if (empty($aRow)) { return false; } return $aRow; } /* function sms_to_client($to,$message){ $text = urlencode("$message"); //echo "http://api.clickatell.com/http/sendmsg?user=oneclickgroup&password=OCXKcOOddLNNPH&api_id=3522402&to=$to&text=$text" ; file_get_contents("http://api.clickatell.com/http/sendmsg?user=oneclickgroup&password=OCXKcOOddLNNPH&api_id=3522402&to=$to&text=$text&senderid=OCD"); return 1; } function sms_to_client($to,$message){ $text = urlencode("$message"); file_get_contents("http://mshastra.com/sendurlcomma.aspx?user=20077167&pwd=mahesh20&senderid=oneclickdrv&mobileno=$to&msgtext=$message&priority=High&CountryCode=ALL"); return 1; } function sms_to_client($to,$message){ $text = urlencode("$message"); file_get_contents("http://mshastra.com/sendurlcomma.aspx?user=20077167&pwd=mahesh20&senderid=oneclickdrv&mobileno=$to&msgtext=$text&priority=High&CountryCode=ALL"); return 1; }*/ function sms_to_client($to, $message) { $text = urlencode("$message"); $country_code = substr($to, 0, 2); if ($country_code == "91") { $senderid = "OCDRVE"; } else { $senderid = "OneClickDrv"; } file_get_contents("http://mshastra.com/sendurlcomma.aspx?user=20087796&pwd=Ocd@123&senderid=$senderid&mobileno=+$to&msgtext=$text&CountryCode=ALL"); return 1; } function min_price() { $key_cache = "min_price"; $min_price = $this->memcached_library->get($key_cache); if (!$min_price && !is_numeric($min_price)) { $sql = "select min(daily_price) price from listings INNER JOIN clients on listings.client_id=clients.client_id where delete_status = 0 and publish_ocd='1' and daily_price > 0 and clients.client_country='UAE' "; $result = mysql_query($sql); $aRow = mysql_fetch_array($result); $count = $aRow['price']; $this->memcached_library->add($key_cache, $count, 86400); $this->set_memcachekeys($key_cache); return $count; } else { return $min_price; } } function get_all_companies() { $sql = "select * from clients"; $result = mysql_query($sql); while ($aRow = mysql_fetch_array($result)) { $list[] = $aRow; } return $list; } /* Model for seo search attribute*/ function get_seo_data($url_id) { $key_cache = 'get_seo_data29012@' . $url_id; // $this->memcached_library->delete($key_cache); $get_seo_data = $this->memcached_library->get($key_cache); if (!$get_seo_data && !is_numeric($get_seo_data)) { $this->set_memcachekeys($key_cache); $this->db->select('*'); $this->db->from('seo_search'); $this->db->where('url', $url_id); //$this->db->or_where("(url LIKE '$url_id')"); $this->db->limit('1'); $query = $this->db->get() or die(mysql_error()); if ($query->num_rows() > 0) { $this->memcached_library->add($key_cache, $query->result_array(), 86400); return $query->result_array(); } else { $this->memcached_library->add($key_cache, '0', 86400); return '0'; } } else { return $get_seo_data; } } function get_seo_data_french($url_id,$morocco) { $key_cache = 'get_seo_data29012_french@' . $url_id."@".$morocco; // $this->memcached_library->delete($key_cache); $get_seo_data = $this->memcached_library->get($key_cache); if (!$get_seo_data && !is_numeric($get_seo_data)) { $this->set_memcachekeys($key_cache); $this->db->select('*'); $this->db->from('seo_search'); //$this->db->where('lang_redirection_url', $url_id); $this->db->where('is_morocco_domain', $morocco); $this->db->where("(lang_redirection_url LIKE '%$url_id%')"); $this->db->limit('1'); $query = $this->db->get() or die(mysql_error()); // echo $this->db->last_query(); if ($query->num_rows() > 0) { $this->memcached_library->add($key_cache, $query->result_array(), 86400); return $query->result_array(); } else { $this->memcached_library->add($key_cache, '0', 86400); return '0'; } } else { return $get_seo_data; } } function get_company_slider_data($client_id) { $key_cache = 'get_company_slider_data@' . $client_id; $get_seo_data = $this->memcached_library->get($key_cache); if (!$get_seo_data && !is_numeric($get_seo_data)) { $this->set_memcachekeys($key_cache); $this->db->select('*'); $this->db->from('company_slider_manage'); $this->db->where('client_id', $client_id); $this->db->limit('1'); $query = $this->db->get() or die(mysql_error()); if ($query->num_rows() > 0) { $this->memcached_library->add($key_cache, $query->result_array(), 3600); return $query->result_array(); } else { $this->memcached_library->add($key_cache, '0', 3600); return '0'; } } else { return $get_seo_data; } } function get_slider_url($url){ $list = array(); $lang_code = $this->session->userdata("lang_code"); $key_cache = 'get_slider_url@' . $url; //update cacahe key in seo_new controller->edit_seo as well // $this->memcached_library->delete($key_cache); $get_slider_url = $this->memcached_library->get($key_cache); if (!$get_slider_url && !is_numeric($get_slider_url)) { $sql=mysql_query("select * from slider_urls where url='$url' limit 1"); if(mysql_num_rows($sql)>0) { while ($aRow = mysql_fetch_array($sql)) { $list['seo_parameter_slider3']=$aRow['slider_two_parameter']; $list['slider_title3']=$aRow['slider_two_title']; $list['slider_url3']=$aRow['slider_two_url_viewall']; $list['seo_parameter_slider']=$aRow['slider_one_parameter']; $list['slider_title']=$aRow['slider_one_title']; $list['slider_url']=$aRow['slider_one_url_viewall']; } } $this->memcached_library->add($key_cache, $list); $this->set_memcachekeys($key_cache); return $list; } else { return $get_slider_url; } } function get_seo_data_new($url_id,$is_morocco_domain=0) { $lang_code = $this->session->userdata("lang_code"); $key_cache = 'get_seo_data2901234_new@' . $url_id.$is_morocco_domain; //update cacahe key in seo_new controller->edit_seo as well // $this->memcached_library->delete($key_cache); $get_seo_data = $this->memcached_library->get($key_cache); if (!$get_seo_data && !is_numeric($get_seo_data)) { $this->set_memcachekeys($key_cache); $this->db->select('*'); $this->db->from('seo_search'); $this->db->where('url', $url_id); $this->db->where('is_morocco_domain', $is_morocco_domain); //$this->db->or_where("(url LIKE '$url_id')"); $this->db->limit('1'); $query = $this->db->get() or die(mysql_error()); if ($query->num_rows() > 0) { $this->memcached_library->add($key_cache, $query->result_array(), 86400); return $query->result_array(); } else { $lang_url = $lang_code."||".$url_id; $lang_url_coma = $lang_url.","; $qry = "SELECT * FROM seo_search WHERE is_morocco_domain='$is_morocco_domain' and (lang_redirection_url LIKE '%$lang_url' OR lang_redirection_url LIKE '%$lang_url_coma%') LIMIT 1"; $query1 = $this->db->query($qry); if ($query1->num_rows() > 0) { $this->memcached_library->add($key_cache, $query1->result_array(), 86400); return $query1->result_array(); }else{ $url_match = array(); $active_languages = active_languages(); foreach ($active_languages as $active_langs){ $check = $active_langs["language_code"]."||".$url_id; $check_coma = $check.","; $url_match[] = "lang_redirection_url LIKE '%$check'"; $url_match[] = "lang_redirection_url LIKE '%$check_coma%'"; } $url_match_str = implode(" OR ", $url_match); $qry = "SELECT * FROM seo_search WHERE is_morocco_domain='$is_morocco_domain' and ($url_match_str) LIMIT 1"; $query2 = $this->db->query($qry); if ($query2->num_rows() > 0) { $this->memcached_library->add($key_cache, $query2->result_array(), 86400); return $query2->result_array(); }else{ $this->memcached_library->add($key_cache, '0', 86400); return '0'; } } } } else { return $get_seo_data; } } function car_search_seo_international($country) { $subquery=" SELECT emirate FROM `emirate` where is_live and is_morocco_domain='0' and country='$country' "; $sql = "SELECT * FROM (`seo_search`) WHERE `city` IN ($subquery)"; $query = $this->db->query($sql) or die(mysql_error()); if ($query->num_rows() > 0) { return $query->result_array(); } else { return '0'; } } function car_search_seo_morocco($country) { $subquery=" SELECT emirate FROM `emirate` where is_live and is_morocco_domain='1' and country='$country' "; $sql = "SELECT * FROM (`seo_search`) WHERE `city` IN ($subquery)"; $query = $this->db->query($sql) or die(mysql_error()); if ($query->num_rows() > 0) { return $query->result_array(); } else { return '0'; } } function car_search_seo_morocco_city($country,$city) { $subquery=" SELECT emirate FROM `emirate` where is_live and is_morocco_domain='1' and country='$country' "; $sql = "SELECT * FROM (`seo_search`) WHERE lower(`city`) IN ('$city')"; $query = $this->db->query($sql) or die(mysql_error()); if ($query->num_rows() > 0) { return $query->result_array(); } else { return '0'; } } function car_search_seo_morocco_city_carrental($country,$city) { $subquery=" SELECT emirate FROM `emirate` where is_live and is_morocco_domain='1' and country='$country' "; $sql = "SELECT * FROM (`seo_search`) WHERE product_type=0 and is_morocco_domain='1' and lower(`city`) IN ('$city')"; $query = $this->db->query($sql) or die(mysql_error()); if ($query->num_rows() > 0) { return $query->result_array(); } else { return '0'; } } function car_search_seo_morocco_city_usedcar($country,$city) { $subquery=" SELECT emirate FROM `emirate` where is_live and is_morocco_domain='1' and country='$country' "; $sql = "SELECT * FROM (`seo_search`) WHERE product_type!=0 and is_morocco_domain='1' and lower(`city`) IN ('$city')"; $query = $this->db->query($sql) or die(mysql_error()); if ($query->num_rows() > 0) { return $query->result_array(); } else { return '0'; } } function car_search_seo() { $subquery=array('Dubai','Abu Dhabi','Sharjah','Ajman','Ras Al Khaimah','Fujairah'); $prodtype=array('0'); $this->db->select('*'); $this->db->from('seo_search'); $this->db->where_in('city', $subquery); $this->db->where_in('product_type', $prodtype); $query = $this->db->get() or die(mysql_error()); if ($query->num_rows() > 0) { return $query->result_array(); } else { return '0'; } } function car_search_used_seo($emirate = '') { if(!empty($emirate)){ $subquery=[$emirate]; }else{ $subquery=array('Dubai','Abu Dhabi','Sharjah','Ajman','Ras Al Khaimah','Fujairah'); } $prodtype=array('1','2'); $this->db->select('*'); $this->db->from('seo_search'); $this->db->where_in('city', $subquery); $this->db->where_in('product_type', $prodtype); $query = $this->db->get() or die(mysql_error()); if ($query->num_rows() > 0) { return $query->result_array(); } else { return '0'; } } function car_search() { $this->db->select('*'); $this->db->from('seo_search'); $this->db->where_in('city', 'SELECT emirate FROM `emirate` where is_live'); $query = $this->db->get() or die(mysql_error()); if ($query->num_rows() > 0) { return $query->result_array(); } else { return '0'; } } function get_directory_sitemap() { $this->db->select('*'); $this->db->from('directory_content'); $query = $this->db->get() or die(mysql_error()); if ($query->num_rows() > 0) { return $query->result_array(); } else { return '0'; } } function car_listings() { $this->db->select('listings.id,listings.images_verify,listings.verification_expiry,listings.daily_price_offer,listings.monthly_price_offer,listings.car_model,listings.car_make,models.name,listings.client_id,listings.daily_price,listings.passengers,listings.larg_bag,listings.year,monthly_price,car_type,doors'); $this->db->from('listings'); $this->db->join('models', 'listings.car_model = models.id', 'inner'); $this->db->where('publish_ocd', '1'); $this->db->where('delete_status', '0'); $query = $this->db->get(); return $query->result_array(); } /* Edit ids for recommended cars */ function get_ids() { $this->db->select("ids"); $this->db->from("ids"); $this->db->limit("1"); $query = $this->db->get(); if ($query->num_rows() > 0) { return $query->result_array(); } else { return '0'; } } function edit_ids($data) { $this->db->where('uniq_id', '1'); $this->db->update('ids', $data); $report = array(); $report['error'] = $this->db->_error_number(); $report['message'] = $this->db->_error_message(); if ($report !== 0) { return true; } else { return false; } } function total_listings($client_id) { $this->db->select('count(client_id) as count'); $this->db->where('client_id', $client_id); $this->db->where('delete_status', '0'); $this->db->where('publish_ocd', '1'); $sql = $this->db->get('listings'); $data = $sql->result_array(); return $data[0]['count']; //return $sql->num_rows(); } function total_listings_all($client_id) { $this->db->select('count(client_id) as count'); $this->db->where('client_id', $client_id); $this->db->where('delete_status', '0'); // $this->db->where('publish_ocd','1'); $sql = $this->db->get('listings'); // echo $this->db->last_query(); $data = $sql->result_array(); return $data[0]['count']; //return $sql->num_rows(); } function total_lead_web($client_id) { $this->db->select('count(client_id) as count'); $this->db->where('client_id', $client_id); $this->db->where('delete_status', '0'); // $this->db->where('publish_ocd','1'); $sql = $this->db->get('listings'); // echo $this->db->last_query(); $data = $sql->result_array(); return $data[0]['count']; //return $sql->num_rows(); } function total_lead_app($client_id, $startdate, $enddate) { $sql = mysql_query("select count(id) as count from mobileapp_email_sms_track where client_id='$client_id' and daily_spam='0' and ts BETWEEN '$startdate' AND '$enddate'"); $results = mysql_fetch_array($sql); $count = $results['count']; return $count; } function total_lead_admin_app($startdate, $enddate) { $sql = mysql_query("select count(id) as count from mobileapp_email_sms_track where daily_spam='0' and ts BETWEEN '$startdate' AND '$enddate'"); $results = mysql_fetch_array($sql); $count = $results['count']; return $count; } function total_lead_webs($client_id, $startdate, $enddate) { $sql = mysql_query("select count(id) as count from email_sms where client_id='$client_id' and daily_spam='0' and ts BETWEEN '$startdate' AND '$enddate'"); $results = mysql_fetch_array($sql); $count = $results['count']; return $count; } function total_lead_admin_webs($startdate, $enddate) { $sql = mysql_query("select count(id) as count from email_sms where daily_spam='0' and ts BETWEEN '$startdate' AND '$enddate'"); $results = mysql_fetch_array($sql); $count = $results['count']; return $count; } function total_listings_admin_all() { $this->db->select('count(client_id) as count'); //$this->db->where('client_id',$client_id); $this->db->where('delete_status', '0'); // $this->db->where('publish_ocd','1'); $sql = $this->db->get('listings'); $data = $sql->result_array(); return $data[0]['count']; //return $sql->num_rows(); } function total_listings_admin_app() { $now_date = date('Y-m-d'); $this->db->select('count(client_id) as count'); $this->db->where('delete_status', '0'); $this->db->where('publish_ocd', '1'); $this->db->where('images_verify', '2'); $this->db->where('verification_expiry > ', "$now_date"); $sql = $this->db->get('listings'); $data = $sql->result_array(); return $data[0]['count']; // return $sql->num_rows(); } function total_listings_app($client_id) { $this->db->select('count(client_id) as count'); $this->db->where('client_id', $client_id); $this->db->where('delete_status', '0'); $this->db->where('publish_ocd', '1'); $sql = $this->db->get('listings'); $data = $sql->result_array(); return $data[0]['count']; } function total_listings_mobile($client_id) { $sql = mysql_query("select * from listings INNER JOIN clients on clients.client_id=listings.client_id where clients.client_id='$client_id' and publish_ocd='1' and delete_status='0' and clients.ocd_app='1' and listings.images_verify='2' and listings.verification_expiry >= '" . date('Y-m-d') . "'"); return mysql_num_rows($sql); } function total_listings_stat($client_id, $hourly) { if ($hourly == 1) { $where = "hour_price_status='1'"; } else { $where = "daily_price_status='1'"; } $sql = mysql_query("select * from listings where publish_ocd='1' and delete_status='0' and client_id='$client_id' and $where"); return $sql2 = mysql_num_rows($sql); } function total_lease($client_id) { $sql = mysql_query("select * from email_lease where client_id='$client_id' ORDER BY ts"); return mysql_num_rows($sql); } function day_by_lease($client_id, $date_range) { $sql = mysql_query("select * from email_lease where client_id='$client_id' and ts BETWEEN DATE_SUB(NOW(), INTERVAL $date_range DAY) AND NOW()"); return $sql2 = mysql_num_rows($sql); } function day_by_lease_email($client_id, $date_range) { $sql = mysql_query("select * from email_lease where lease_type='0' and client_id='$client_id' and ts BETWEEN DATE_SUB(NOW(), INTERVAL $date_range DAY) AND NOW()"); return $sql2 = mysql_num_rows($sql); } function day_by_lease_calls($client_id, $date_range) { $sql = mysql_query("select * from email_lease where lease_type='1' and client_id='$client_id' and ts BETWEEN DATE_SUB(NOW(), INTERVAL $date_range DAY) AND NOW()"); return $sql2 = mysql_num_rows($sql); } function day_by_lease_whatsapp($client_id, $date_range) { $sql = mysql_query("select * from email_lease where lease_type='2' and client_id='$client_id' and ts BETWEEN DATE_SUB(NOW(), INTERVAL $date_range DAY) AND NOW()"); return $sql2 = mysql_num_rows($sql); } function total_leads($client_id) { $sql = mysql_query("select email_sms.listing_id,listings.car_model,listings.car_make,listings.featured,listings.year,listings.monthly_price,listings.weekly_price,listings.daily_price,listings.transmission,email_sms.email,email_sms.mobile,email_sms.name,email_sms.message,email_sms.ts,email_sms.id from email_sms INNER JOIN listings ON email_sms.listing_id=listings.id where email_sms.type='1' and email_sms.client_id='$client_id' and listings.delete_status='0' and listings.publish_ocd='1' and email_sms.daily_spam='0' and email_sms.name NOT LIKE 'test' group by email_sms.listing_id ,email_sms.client_id,email_sms.mobile,DATE(ts) ORDER BY email_sms.id "); return mysql_num_rows($sql); } function day_by_leads($client_id, $startdate, $enddate) { $sql = mysql_query("select count(id) as count from email_sms where type='1' and client_id='$client_id' and daily_spam='0' and ts BETWEEN '$startdate' AND '$enddate'"); $results = mysql_fetch_array($sql); $count = $results['count']; return $count; } function day_by_leads_buggy($client_id, $startdate, $enddate) { $sql = mysql_query("select count(id) as count from email_sms_buggy where type='1' and client_id='$client_id' and ts BETWEEN '$startdate' AND '$enddate'"); $results = mysql_fetch_array($sql); $count = $results['count']; return $count; } function day_by_leads_yacht($client_id, $startdate, $enddate) { $sql = mysql_query("select count(id) as count from email_sms_yacht where type='1' and client_id='$client_id' and daily_spam='0' and ts BETWEEN '$startdate' AND '$enddate'"); $results = mysql_fetch_array($sql); $count = $results['count']; return $count; } function client_app_status($client_id) { // echo "select ocd_app from clients where id='$client_id'"; $sql = mysql_query("select ocd_app from clients where id='$client_id'"); $results = mysql_fetch_array($sql); $count = $results['ocd_app']; return $count; } function day_by_calls($client_id, $startdate, $enddate) { // echo "select count(id) as count from email_sms where type='2' and client_id='$client_id' and ts BETWEEN '$startdate' AND '$enddate'"; $sql = mysql_query("select count(id) as count from email_sms where type='2' and client_id='$client_id' and daily_spam='0' and ts BETWEEN '$startdate' AND '$enddate'"); $results = mysql_fetch_array($sql); $count = $results['count']; return $count; } function day_by_calls_yacht($client_id, $startdate, $enddate) { // echo "select count(id) as count from email_sms_yacht where type='2' and client_id='$client_id' and ts BETWEEN '$startdate' AND '$enddate'"; $sql = mysql_query("select count(id) as count from email_sms_yacht where type='2' and client_id='$client_id' and daily_spam = '0' and ts BETWEEN '$startdate' AND '$enddate'"); $results = mysql_fetch_array($sql); $count = $results['count']; return $count; } function day_by_calls_buggy($client_id, $startdate, $enddate) { // echo "select count(id) as count from email_sms where type='2' and client_id='$client_id' and ts BETWEEN '$startdate' AND '$enddate'"; $sql = mysql_query("select count(id) as count from email_sms_buggy where type='2' and client_id='$client_id' and ts BETWEEN '$startdate' AND '$enddate'"); $results = mysql_fetch_array($sql); $count = $results['count']; return $count; } function day_by_calls_mobile($client_id, $startdate, $enddate) { // echo "select count(*) as count from mobileapp_email_sms_track where type='2' and client_id='$client_id' and ts BETWEEN '$startdate' AND '$enddate'"; $sql = mysql_query("select count(*) as count from mobileapp_email_sms_track where type='2' and client_id='$client_id' and daily_spam='0' and ts BETWEEN '$startdate' AND '$enddate'"); $count = mysql_fetch_array($sql); return $count['count']; } function day_by_whatsapp($client_id, $startdate, $enddate) { //echo "select count(id) as count from email_sms where type='5' and client_id='$client_id' and ts BETWEEN '$startdate' AND '$enddate'"; $sql = mysql_query("select count(id) as count from email_sms where type='5' and client_id='$client_id' and daily_spam='0' and ts BETWEEN '$startdate' AND '$enddate'"); $results = mysql_fetch_array($sql); $count = $results['count']; return $count; } function day_by_whatsapp_buggy($client_id, $startdate, $enddate) { //echo "select count(id) as count from email_sms where type='5' and client_id='$client_id' and ts BETWEEN '$startdate' AND '$enddate'"; $sql = mysql_query("select count(id) as count from email_sms_buggy where type='5' and client_id='$client_id' and ts BETWEEN '$startdate' AND '$enddate'"); $results = mysql_fetch_array($sql); $count = $results['count']; return $count; } function day_by_whatsapp_yacht($client_id, $startdate, $enddate) { //echo "select count(id) as count from email_sms where type='5' and client_id='$client_id' and ts BETWEEN '$startdate' AND '$enddate'"; $sql = mysql_query("select count(id) as count from email_sms_yacht where type='5' and client_id='$client_id' and daily_spam='0' and ts BETWEEN '$startdate' AND '$enddate'"); $results = mysql_fetch_array($sql); $count = $results['count']; return $count; } function day_by_whatsapp_mobile($client_id, $startdate, $enddate) { $sql = mysql_query("select count(id) as count from mobileapp_email_sms_track where type='5' and client_id='$client_id' and daily_spam='0' and ts >= '$startdate' AND ts <='$enddate'"); $results = mysql_fetch_array($sql); $count = $results['count']; return $count; } function total_leads_stat($client_id, $hourly) { $sql = mysql_query("select email_sms.listing_id,listings.car_model,listings.car_make,listings.featured,listings.year,listings.monthly_price,listings.weekly_price,listings.daily_price,listings.transmission,email_sms.email,email_sms.mobile,email_sms.name,email_sms.message,email_sms.ts,email_sms.id from email_sms INNER JOIN listings ON email_sms.listing_id=listings.id where email_sms.type='1' and email_sms.client_id='$client_id' and listings.delete_status='0' and listings.publish_ocd='1' and email_sms.daily_spam='0' and email_sms.name NOT LIKE 'test' and $hourly group by email_sms.listing_id ,email_sms.client_id,email_sms.mobile,DATE(ts) ORDER BY email_sms.id "); return mysql_num_rows($sql); } function day_by_leads_stat($client_id, $date_range, $hourly) { $sql = mysql_query("select * from email_sms where type='1' and client_id='$client_id' and daily_spam='0' and ts BETWEEN DATE_SUB(NOW(), INTERVAL $date_range DAY) AND NOW() and $hourly"); return $sql2 = mysql_num_rows($sql); } function day_by_leads_featured_web($client_id, $startdate, $enddate) { if($client_id=="14") { $sql = mysql_query("select count(id) as count from email_sms where featured_listing='1' and daily_spam='0' and ts BETWEEN '$startdate' AND '$enddate'"); } else{ $sql = mysql_query("select count(id) as count from email_sms where featured_listing='1' and client_id='$client_id' and daily_spam='0' and ts BETWEEN '$startdate' AND '$enddate'"); } $results = mysql_fetch_array($sql); $count = $results['count']; //$count=$results['count']; return $count; } function monthly_leads_count_web($client_id, $startdate, $enddate) { $this->db->select('count(id) as count'); if($client_id != 14) { $this->db->where('client_id',$client_id); } $this->db->where('month_lead','1'); $this->db->where('daily_spam','0'); $this->db->where("ts BETWEEN '$startdate' AND '$enddate'"); $query = $this->db->get("email_sms"); // echo $this->db->last_query(); exit(); $results = $query->row_array(); $count = $results['count']; return $count; } function day_by_leads_featured_mobile($client_id, $startdate, $enddate) { if($client_id=='14'){ $sql = mysql_query("select count(id) as count from mobileapp_email_sms_track where featured_listing='1' and daily_spam='0' and ts BETWEEN '$startdate' AND '$enddate'"); } else{ $sql = mysql_query("select count(id) as count from mobileapp_email_sms_track where featured_listing='1' and daily_spam='0' and client_id='$client_id' and ts BETWEEN '$startdate' AND '$enddate'"); } $results = mysql_fetch_array($sql); $count = $results['count']; //$count=$results['count']; return $count; } function day_by_leads_premium_web($client_id, $startdate, $enddate) { if($client_id=='14'){ $sql = mysql_query("select * from email_sms where premium_listing='1' and daily_spam='0' and ts BETWEEN '$startdate' AND '$enddate'"); } else{ $sql = mysql_query("select * from email_sms where premium_listing='1' and daily_spam='0' and client_id='$client_id' and ts BETWEEN '$startdate' AND '$enddate'"); } return $sql2 = mysql_num_rows($sql); } function day_by_leads_premium_mobile($client_id, $startdate, $enddate) { if($client_id=='14'){ $sql = mysql_query("select * from mobileapp_email_sms_track where premium_listing='1' and daily_spam='0' and ts BETWEEN '$startdate' AND '$enddate'"); } else{ $sql = mysql_query("select * from mobileapp_email_sms_track where premium_listing='1' and daily_spam='0' and client_id='$client_id' and ts BETWEEN '$startdate' AND '$enddate'"); } return $sql2 = mysql_num_rows($sql); } function day_by_leads_stat_mobile($client_id, $startdate, $enddate) { $sql = mysql_query("select * from mobileapp_email_sms_track where type='1' and daily_spam='0' and client_id='$client_id' and ts BETWEEN '$startdate' AND '$enddate'"); return $sql2 = mysql_num_rows($sql); } function day_by_calls_stat($client_id, $date_range, $hourly) { $sql = mysql_query("select * from email_sms where type='2' and client_id='$client_id' and daily_spam='0' and ts BETWEEN DATE_SUB(NOW(), INTERVAL $date_range DAY) AND NOW() and $hourly"); return $sql2 = mysql_num_rows($sql); } function day_by_whatsapp_stat($client_id, $date_range, $hourly) { $sql = mysql_query("select * from email_sms where type='5' and client_id='$client_id' and daily_spam='0' and ts BETWEEN DATE_SUB(NOW(), INTERVAL $date_range DAY) AND NOW() and $hourly") or die(mysql_error()); return $sql2 = mysql_num_rows($sql); } function day_by_leads_admin($startdate, $enddate) { $sql = mysql_query("select count(id) as count from email_sms where type='1' and daily_spam='0' and ts BETWEEN '$startdate' AND '$enddate'"); $results = mysql_fetch_array($sql); $count = $results['count']; return $count; } function day_by_leads_admin_mobile($startdate, $enddate) { $sql = mysql_query("select count(id) as count from mobileapp_email_sms_track where type='1' and daily_spam='0' and ts BETWEEN '$startdate' AND '$enddate'"); $results = mysql_fetch_array($sql); $count = $results['count']; return $count; } function day_by_leads_admin_stat($date_range, $hourly) { $sql = mysql_query("select * from email_sms where type='1' and daily_spam='0' and ts BETWEEN DATE_SUB(NOW(), INTERVAL $date_range DAY) AND NOW() and $hourly"); return $sql2 = mysql_num_rows($sql); } function ocd_app_status($clients) { $sql = mysql_query("select ocd_app from clients where client_id='$clients' "); $results = mysql_fetch_array($sql); $count = $results['ocd_app']; return $count; } function more_rentals_status($clients) { $sql = mysql_query("select more_rentals from clients where client_id='$clients' "); $results = mysql_fetch_array($sql); $count = $results['more_rentals']; return $count; } function day_by_calls_admin_mobile($startdate, $enddate) { // echo "select count(id) as count from mobileapp_email_sms_track where type='2' and ts BETWEEN '$startdate' AND '$enddate'"; $sql = mysql_query("select count(id) as count from mobileapp_email_sms_track where type='2' and ts BETWEEN '$startdate' AND '$enddate'"); $results = mysql_fetch_array($sql); $count = $results['count']; return $count; } function day_by_calls_admin($startdate, $enddate) { $sql = mysql_query("select count(id) as count from email_sms where type='2' and daily_spam='0' and ts BETWEEN '$startdate' AND '$enddate'"); $results = mysql_fetch_array($sql); $count = $results['count']; return $count; } function day_by_calls_admin_stat($date_range, $hourly) { $sql = mysql_query("select * from email_sms where type='2' and daily_spam='0' and ts BETWEEN DATE_SUB(NOW(), INTERVAL $date_range DAY) AND NOW() and $hourly"); return $sql2 = mysql_num_rows($sql); } function day_by_whatsapp_admin($startdate, $enddate) { $sql = mysql_query("select count(id) as count from email_sms where type='5' and daily_spam='0' and ts BETWEEN '$startdate' AND '$enddate'"); $results = mysql_fetch_array($sql); $count = $results['count']; return $count; } function day_by_whatsapp_admin_mobile($startdate, $enddate) { $sql = mysql_query("select count(id) as count from mobileapp_email_sms_track where type='5' and daily_spam='0' and ts BETWEEN '$startdate' AND '$enddate'"); $results = mysql_fetch_array($sql); $count = $results['count']; return $count; } function day_by_whatsapp_admin_mobile_feature($client_id) { $sql = mysql_query("select * from email_sms where client_id='$client_id' and featured_listing='1' and daily_spam='0' and ts BETWEEN DATE_SUB(NOW(), INTERVAL 30 DAY) AND NOW()"); return $sql2 = mysql_num_rows($sql); } function day_by_whatsapp_admin_mobile_premium($client_id) { $sql = mysql_query("select * from email_sms where client_id='$client_id' and featured_listing='1' and daily_spam='0' and ts BETWEEN DATE_SUB(NOW(), INTERVAL 30 DAY) AND NOW()"); return $sql2 = mysql_num_rows($sql); } function day_by_whatsapp_admin_stat($date_range, $hourly) { $sql = mysql_query("select * from email_sms where type='5' and daily_spam='0' and ts BETWEEN DATE_SUB(NOW(), INTERVAL $date_range DAY) AND NOW() and $hourly"); return $sql2 = mysql_num_rows($sql); } function total_leads_admin() { $sql = mysql_query("select email_sms.listing_id,listings.car_model,listings.car_make,listings.featured,listings.year,listings.monthly_price,listings.weekly_price,listings.daily_price,listings.transmission,email_sms.email,email_sms.mobile,email_sms.name,email_sms.message,email_sms.ts,email_sms.id from email_sms INNER JOIN listings ON email_sms.listing_id=listings.id where email_sms.type='1' and listings.delete_status='0' and listings.publish_ocd='1' and email_sms.daily_spam='0' and email_sms.name NOT LIKE 'test' group by email_sms.listing_id ,email_sms.client_id,email_sms.mobile,DATE(ts) ORDER BY email_sms.id "); return mysql_num_rows($sql); } function all_total_leads($client_id, $startdate, $enddate) { if ($client_id == '14') { $sql = mysql_query("select count(id) as count from email_sms where ts BETWEEN '$startdate' AND '$enddate' and daily_spam='0' and type!='8' and type!=''"); } else { $sql = mysql_query("select count(id) as count from email_sms where client_id='$client_id' and daily_spam='0' and ts BETWEEN '$startdate' AND '$enddate' and type!='8' and type!=''"); } $leads = mysql_fetch_array($sql); return $leads['count']; } function all_total_leads_mob($client_id, $startdate, $enddate) { if ($client_id == '14') { $sql = mysql_query("select count(id) as count from mobileapp_email_sms_track where daily_spam='0' and ts BETWEEN '$startdate' AND '$enddate'"); } else { $sql = mysql_query("select count(id) as count from mobileapp_email_sms_track where client_id='$client_id' and daily_spam='0' and ts BETWEEN '$startdate' AND '$enddate'"); } $leads = mysql_fetch_array($sql); return $leads['count']; } function all_total_fea_leads($client_id, $startdate, $enddate) { if ($client_id == '14') { $sql = mysql_query("select count(email_sms.id) as count from email_sms inner join listings on listings.id=email_sms.listing_id where listings.publish_ocd='1' and listings.delete_status='0' and listings.featured='1' and email_sms.daily_spam='0' and ts BETWEEN '$startdate' AND '$enddate'") or die(mysql_error()); } else { $sql = mysql_query("select count(email_sms.id) as count from email_sms inner join listings on listings.id=email_sms.listing_id where listings.publish_ocd='1' and listings.delete_status='0' and listings.featured='1' and email_sms.daily_spam='0' and email_sms.client_id='$client_id' and ts BETWEEN '$startdate' AND '$enddate'") or die(mysql_error()); } $leads = mysql_fetch_array($sql); return $leads['count']; } function all_total_leads_fea_mob($client_id, $startdate, $enddate) { if ($client_id == '14') { $sql = mysql_query("select count(mobileapp_email_sms_track.id) as count from mobileapp_email_sms_track inner join listings on listings.id=mobileapp_email_sms_track.listing_id where listings.publish_ocd='1' and mobileapp_email_sms_track.daily_spam='0' and listings.delete_status='0' and listings.mobile_featured='1' and ts BETWEEN '$startdate' AND '$enddate'") or die(mysql_error()); } else { $sql = mysql_query("select count(mobileapp_email_sms_track.id) as count from mobileapp_email_sms_track inner join listings on listings.id=mobileapp_email_sms_track.listing_id where listings.publish_ocd='1' and mobileapp_email_sms_track.daily_spam='0' and listings.delete_status='0' and listings.mobile_featured='1' and mobileapp_email_sms_track.client_id='$client_id' and ts BETWEEN '$startdate' AND '$enddate'") or die(mysql_error()); } $leads = mysql_fetch_array($sql); return $leads['count']; } function all_total_recom_leads($client_id, $startdate, $enddate) { if ($client_id == '14') { $sql = mysql_query("select count(email_sms.id) as count from email_sms inner join listings on listings.id=email_sms.listing_id where listings.publish_ocd='1' and listings.delete_status='0' and email_sms.daily_spam='0' and listings.recommended='1' and ts BETWEEN '$startdate' AND '$enddate'") or die(mysql_error()); } else { $sql = mysql_query("select count(email_sms.id) as count from email_sms inner join listings on listings.id=email_sms.listing_id where listings.publish_ocd='1' and listings.delete_status='0' and email_sms.daily_spam='0' and listings.recommended='1' and email_sms.client_id='$client_id' and ts BETWEEN '$startdate' AND '$enddate'") or die(mysql_error()); } $leads = mysql_fetch_array($sql); return $leads['count']; } function all_total_leads_recom_mob($client_id, $startdate, $enddate) { if ($client_id == '14') { $sql = mysql_query("select count(mobileapp_email_sms_track.id) as count from mobileapp_email_sms_track inner join listings on listings.id=mobileapp_email_sms_track.listing_id where listings.publish_ocd='1' and mobileapp_email_sms_track.daily_spam='0' and listings.delete_status='0' and listings.recommended='1' and ts BETWEEN '$startdate' AND '$enddate'") or die(mysql_error()); } else { $sql = mysql_query("select count(mobileapp_email_sms_track.id) as count from mobileapp_email_sms_track inner join listings on listings.id=mobileapp_email_sms_track.listing_id where listings.publish_ocd='1' and mobileapp_email_sms_track.daily_spam='0' and listings.delete_status='0' and listings.recommended='1' and mobileapp_email_sms_track.client_id='$client_id' and ts BETWEEN '$startdate' AND '$enddate'") or die(mysql_error()); } $leads = mysql_fetch_array($sql); return $leads['count']; } function is_featured_mobile($client_id) { if ($client_id == '14') { return "1"; } else { $sql = mysql_query("select number_of_featured_listing_mobile from clients where client_id='$client_id'") or die(mysql_error()); $sql2 = mysql_fetch_array($sql); return $sql2['number_of_featured_listing_mobile']; } } function is_featured($client_id) { if ($client_id == '14') { return "1"; } else { $sql = mysql_query("select number_of_featured_listing from clients where client_id='$client_id'") or die(mysql_error()); $sql2 = mysql_fetch_array($sql); return $sql2['number_of_featured_listing']; } } function is_recomm($client_id) { if ($client_id == '14') { return "1"; } else { $sql = mysql_query("select recommended_listing from clients where client_id='$client_id'") or die(mysql_error()); $sql2 = mysql_fetch_array($sql); return $sql2['recommended_listing']; } } function impression_by_week_admin($date_range) { $sql = mysql_query("select SUM(impressions) as total from track_impressions where date_ts BETWEEN DATE_SUB(NOW(), INTERVAL '$date_range' DAY) AND NOW() group by client_id"); $sql2 = mysql_fetch_array($sql); return $sql2['total']; } function views_by_week_admin($date_range) { $sql = mysql_query("select SUM(views) as total from track_views where date_ts BETWEEN DATE_SUB(NOW(), INTERVAL '$date_range' DAY) AND NOW() group by client_id"); $sql2 = mysql_fetch_array($sql); return $sql2['total']; } function total_listings_admin() { $this->db->where('delete_status', '0'); $this->db->where('publish_ocd', '1'); $sql = $this->db->get('listings'); return $sql->num_rows(); } function total_listings_admin_mobile() { $sql = mysql_query("select * from listings inner join clients on clients.client_id=listings.client_id where delete_status='0' and publish_ocd='1' and clients.ocd_app='1' and listings.images_verify='2' and listings.verification_expiry >= '" . date('Y-m-d') . "'"); $sql2 = mysql_num_rows($sql); return $sql2; } function total_listings_admin_stat($hourly) { if ($hourly == 1) { $where = "hour_price_status='1'"; } else { $where = "daily_price_status='1'"; } $sql = mysql_query("select * from listings where publish_ocd='1' and delete_status='0' and $where"); return $sql2 = mysql_num_rows($sql); } function total_client_listing_admin() { $sql = mysql_query("select SUM(limit_number) as sum from clients"); $sql2 = mysql_fetch_array($sql); return $sql2['sum']; } function total_client_listing_admin_mobile() { $sql = mysql_query("select SUM(limit_number) as sum from clients where ocd_app='1'"); $sql2 = mysql_fetch_array($sql); return $sql2['sum']; } function total_impression($client_id) { $this->db->select('SUM(impressions) as total'); $this->db->where('client_id', $client_id); $this->db->where('delete_status', '0'); $this->db->where('publish_ocd', '1'); $this->db->group_by('client_id'); $sql = $this->db->get('listings'); return $sql->row()->total; } function featured_leads_all($client_id) { $sql = mysql_query("select * from email_sms where client_id='$client_id' and featured_listing='1' and daily_spam='0' and ts BETWEEN DATE_SUB(NOW(), INTERVAL 30 DAY) AND NOW()"); return $sql2 = mysql_num_rows($sql); } function premium_leads_all($client_id) { $sql = mysql_query("select * from email_sms where client_id='$client_id' and featured_listing='1' and daily_spam='0' and ts BETWEEN DATE_SUB(NOW(), INTERVAL 30 DAY) AND NOW()"); return $sql2 = mysql_num_rows($sql); } function best_offer_leads($client_id) { $sql = mysql_query("select * from email_sms where client_id='$client_id' and best_offer_listing='1' and daily_spam='0' and ts BETWEEN DATE_SUB(NOW(), INTERVAL 30 DAY) AND NOW()"); return $sql2 = mysql_num_rows($sql); } function featured_leads_by_email($client_id) { $sql = mysql_query("select * from email_sms INNER JOIN listings ON email_sms.listing_id=listings.id where email_sms.type='1' and email_sms.daily_spam='0' and listings.client_id='$client_id' and listings.featured='1' and listings.delete_status='0' and listings.publish_ocd='1' and email_sms.ts BETWEEN DATE_SUB(NOW(), INTERVAL 30 DAY) AND NOW()"); return $sql2 = mysql_num_rows($sql); } function featured_leads_by_call($client_id) { $sql = mysql_query("select * from email_sms INNER JOIN listings ON email_sms.listing_id=listings.id where email_sms.type='2' and email_sms.daily_spam='0' and listings.client_id='$client_id' and listings.featured='1' and listings.delete_status='0' and listings.publish_ocd='1' and email_sms.ts BETWEEN DATE_SUB(NOW(), INTERVAL 30 DAY) AND NOW()"); return $sql2 = mysql_num_rows($sql); } function featured_clicks($client_id) { $sql = mysql_query("select views from listings where listings.client_id='$client_id' and listings.featured='1' and listings.delete_status='0' and listings.publish_ocd='1'"); $sql2 = mysql_fetch_array($sql); return $clicks = $sql2['views']; } function impression_by_week($client_id, $date_range) { $sql = mysql_query("select SUM(impressions) as total from track_impressions where client_id='$client_id' and date_ts BETWEEN DATE_SUB(NOW(), INTERVAL '$date_range' DAY) AND NOW() group by client_id"); $sql2 = mysql_fetch_array($sql); return $sql2['total']; } function performance_chart($client_id, $date_range) { $list = array(); $sql = mysql_query("select SUM(impressions) as total,date_ts from track_impressions where client_id='$client_id' and date_ts BETWEEN DATE_SUB(NOW(), INTERVAL '$date_range' DAY) AND NOW() group by date_ts order by date_ts DESC"); while ($record = mysql_fetch_array($sql)) { $data['impressions'] = $record['total']; $date = $record['date_ts']; $data['date_ts'] = date("d-m-Y", strtotime($record['date_ts'])); $data['change_ts'] = date("F j, Y", strtotime($record['date_ts'])); $data['day'] = date("D", strtotime($record['date_ts'])); $sql2 = mysql_query("select SUM(views) as total2 from track_views where client_id='$client_id' and date_ts='$date'"); $views = mysql_fetch_array($sql2); if ($views['total2'] != '') { $data['views'] = $views['total2']; } else { $data['views'] = '0'; } $sql3 = mysql_query("select count(*) as total3,date(`ts`) as date from email_sms where client_id='$client_id' and daily_spam='0' and date(`ts`)='$date'"); $impressions = mysql_fetch_array($sql3); $data['leads'] = $impressions['total3']; $list[] = $data; } return $list; } function refresh_status_dashboard_report($client_id, $start_date, $end_date = '') { $total = 0; //$sql=mysql_query("select count(*) as total from refresh_history where client_id='$client_id' and refresh_type='0' and date(`actual_time`)='$date' group by date(`actual_time`) order by actual_time DESC") or die(mysql_error()); if ($end_date == '') { $sql = mysql_query(" SELECT SUM(total) AS total FROM ( select count(*) as total from refresh_history where client_id = '$client_id' and refresh_type = '0' and date(`actual_time`)= '" . $start_date . "' UNION ALL select count(*) as total from refresh_history_daily_backup where client_id = '$client_id' and refresh_type = '0' and date(`actual_time`)= '" . $start_date . "' ) t ") or die(mysql_error()); } else { $sql = mysql_query(" SELECT SUM(total) AS total FROM ( select count(*) as total from refresh_history where client_id = '$client_id' and refresh_type = '0' and date(`actual_time`)>= '" . $start_date . "' and date(`actual_time`)<= '" . $end_date . "' UNION ALL select count(*) as total from refresh_history_daily_backup where client_id = '$client_id' and refresh_type = '0' and date(`actual_time`)>= '" . $start_date . "' and date(`actual_time`)<= '" . $end_date . "' ) t ") or die(mysql_error()); } while ($record = mysql_fetch_array($sql)) { $total = $record['total']; } return $total; } function refresh_status($client_id, $start_date, $end_date = '') { $total = 0; //$sql=mysql_query("select count(*) as total from refresh_history where client_id='$client_id' and refresh_type='0' and date(`actual_time`)='$date' group by date(`actual_time`) order by actual_time DESC") or die(mysql_error()); /* if ($end_date == '') { $sql = mysql_query(" SELECT SUM(total) AS total FROM ( select count(*) as total from refresh_history where client_id = '$client_id' and refresh_type = '0' and date(`actual_time`)= '" . $start_date . "' UNION ALL select count(*) as total from refresh_history_daily_backup where client_id = '$client_id' and refresh_type = '0' and date(`actual_time`)= '" . $start_date . "' ) t ") or die(mysql_error()); } else { $sql = mysql_query(" SELECT SUM(total) AS total FROM ( select count(*) as total from refresh_history where client_id = '$client_id' and refresh_type = '0' and date(`actual_time`)>= '" . $start_date . "' and date(`actual_time`)<= '" . $end_date . "' UNION ALL select count(*) as total from refresh_history_daily_backup where client_id = '$client_id' and refresh_type = '0' and date(`actual_time`)>= '" . $start_date . "' and date(`actual_time`)<= '" . $end_date . "' ) t ") or die(mysql_error()); } */ if ($end_date == '') { $sql = mysql_query(" select count(*) as total from refresh_history where client_id = '$client_id' and refresh_type = '0' and date(`actual_time`)= '" . $start_date . "' ") or die(mysql_error()); } else { $sql = mysql_query(" select count(*) as total from refresh_history where client_id = '$client_id' and refresh_type = '0' and date(`actual_time`)>= '" . $start_date . "' and date(`actual_time`)<= '" . $end_date . "' ") or die(mysql_error()); } while ($record = mysql_fetch_array($sql)) { $total = $record['total']; } return $total; } function refresh_status_yacht($client_id, $start_date, $end_date = '') { $total = 0; //$sql=mysql_query("select count(*) as total from yacht_refresh_history where client_id='$client_id' and refresh_type='0' and date(`actual_time`)='$date' group by date(`actual_time`) order by actual_time DESC") or die(mysql_error()); if ($end_date == '') { $sql = mysql_query("select count(*) as total from yacht_refresh_history where client_id = '$client_id' and refresh_type = '0' and date(`actual_time`)= '" . $start_date . "'") or die(mysql_error()); } else { $sql = mysql_query("select count(*) as total from yacht_refresh_history where client_id = '$client_id' and refresh_type = '0' and date(`actual_time`)>= '" . $start_date . "' and date(`actual_time`)<= '" . $end_date . "'") or die(mysql_error()); } while ($record = mysql_fetch_array($sql)) { $total = $record['total']; } return $total; } function total_refresh_count($client_id) { $sql = mysql_query("select refresh_times from clients where client_id='$client_id'") or die(mysql_error()); while ($record = mysql_fetch_array($sql)) { $total = $record['refresh_times']; } return $total; } function total_refresh_count_yacht($client_id) { $sql = mysql_query("select refresh_times from clients where client_id='$client_id'") or die(mysql_error()); while ($record = mysql_fetch_array($sql)) { $total = $record['refresh_times']; } return $total; } function refresh_chart($client_id, $date_range) { $list = array(); $sql = mysql_query("select count(*) as total,actual_time from refresh_history where client_id='$client_id' and refresh_type='0' and date(`actual_time`) BETWEEN DATE_SUB(NOW(), INTERVAL '$date_range' DAY) AND NOW() group by date(`actual_time`) order by actual_time DESC") or die(mysql_error()); while ($record = mysql_fetch_array($sql)) { $data['refresh'] = $record['total']; $date = $record['actual_time']; $data['date_ts'] = date("d-m-Y", strtotime($date)); $data['change_ts'] = date("F j, Y", strtotime($date)); $data['day'] = date("D", strtotime($date)); $date2 = date("Y-m-d", strtotime($date)); $sql2 = mysql_query("select count(*) as total2,date(`ts`) as date from email_sms where client_id='$client_id' and daily_spam='0' and date(`ts`)='$date2'") or die(mysql_error()); $refresh = mysql_fetch_array($sql2); $data['leads'] = $refresh['total2']; $list[] = $data; } return $list; } function views_by_week($client_id, $date_range) { $sql = mysql_query("select SUM(views) as total from track_views where client_id='$client_id' and date_ts BETWEEN DATE_SUB(NOW(), INTERVAL '$date_range' DAY) AND NOW() group by client_id"); $sql2 = mysql_fetch_array($sql); return $sql2['total']; } function views($client_id) { $this->db->select('SUM(views) as total'); $this->db->where('client_id', $client_id); $this->db->where('delete_status', '0'); $this->db->where('publish_ocd', '1'); // $this->db->where('update_date BETWEEN DATE_SUB(NOW(), INTERVAL 7 DAY) AND NOW()'); $this->db->group_by('client_id'); $sql = $this->db->get('listings'); return $sql->row()->total; } function total_client_listing($client_id) { $this->db->select('limit_number'); $this->db->where('client_id', $client_id); $sql = $this->db->get('clients'); return $sql->row()->limit_number; } function total_client_listing_mobile($client_id) { $sql = mysql_query("select limit_number as sum from listings INNER JOIN clients on clients.client_id=listings.client_id where publish_ocd='1' and delete_status='0' and clients.ocd_app='1' and clients.client_id='$client_id' and listings.images_verify='2' and listings.verification_expiry >= '" . date('Y-m-d') . "'"); $sql2 = mysql_fetch_array($sql); return $sql2['sum']; } function check_popup($client_id, $date) { $sql = mysql_query("select * from popup_check where client_id='$client_id' and date_ts='$date'") or die(mysql_error()); if (mysql_num_rows($sql) > 0) { $return = "0"; } else { mysql_query("insert into popup_check set client_id='$client_id',date_ts='$date'"); $return = "1"; } return $return; } function views_by_client($client_id, $date_range) { $sql = mysql_query("select track_id,date_ts,SUM(views) as total from track_views where client_id='$client_id' and date_ts BETWEEN DATE_SUB(NOW(), INTERVAL '$date_range' DAY) AND NOW() group by date_ts"); while ($sql2 = mysql_fetch_array($sql)) { $sql_main[$sql2['track_id']]['date_ts'] = $sql2['date_ts']; $sql_main[$sql2['track_id']]['total'] = $sql2['total']; } return $sql_main; } function total_views($client_id, $date_range) { $sql = mysql_query("select track_id,date_ts,SUM(views) as total from track_views where client_id='$client_id' and date_ts BETWEEN DATE_SUB(NOW(), INTERVAL '$date_range' DAY) AND NOW() group by client_id"); if (mysql_num_rows($sql) > 0) { $sql2 = mysql_fetch_array($sql); $total = $sql2['total']; } else { $total = "0"; } return $total; } function views_by_record($client_id, $month, $year) { $sql = mysql_query("select track_id,date_ts,SUM(views) as total from track_views where client_id='$client_id' and month(date_ts)='$month' and year(date_ts)='$year'") or die(mysql_error()); if (mysql_num_rows($sql) > 0) { $sql2 = mysql_fetch_array($sql); if ($sql2['total'] > 0) { $sql_main = $sql2['total']; } else { $sql_main = "0"; } } else { $sql_main = '0'; } return $sql_main; } function total_views_month($client_id, $current_month, $previous_month, $two_month, $year) { $sql = mysql_query("select track_id,date_ts,SUM(views) as total from track_views where client_id='$client_id' and month(date_ts) IN ($current_month,$previous_month,$two_month) and year(date_ts)='$year' group by client_id") or die(mysql_error()); if (mysql_num_rows($sql) > 0) { $sql2 = mysql_fetch_array($sql); if ($sql2['total'] > 0) { $sql_main = $sql2['total']; } else { $sql_main = "0"; } } else { $sql_main = '0'; } return $sql_main; } function leads_by_record($client_id, $month, $year) { $sql = mysql_query("select count(*) as total from email_sms where client_id='$client_id' and daily_spam='0' and month(ts)='$month' and year(ts)='$year'") or die(mysql_error()); if (mysql_num_rows($sql) > 0) { $sql2 = mysql_fetch_array($sql); if ($sql2['total'] > 0) { $sql_main = $sql2['total']; } else { $sql_main = "0"; } } else { $sql_main = '0'; } return $sql_main; } function total_leads_month($client_id, $current_month, $previous_month, $two_month, $year) { $sql = mysql_query("select count(*) as total from email_sms where client_id='$client_id' and daily_spam='0' and month(ts) IN ($current_month,$previous_month,$two_month) and year(ts)='$year' group by client_id") or die(mysql_error()); if (mysql_num_rows($sql) > 0) { $sql2 = mysql_fetch_array($sql); if ($sql2['total'] > 0) { $sql_main = $sql2['total']; } else { $sql_main = "0"; } } else { $sql_main = '0'; } return $sql_main; } function get_carcompany_monthly_stas($where, $emirate) { $sql = "select listings.client_id , count(*) count from listings INNER JOIN clients ON listings.client_id=clients.client_id where $where and clients.emirate='$emirate' and publish_ocd='1' group by listings.client_id"; $result = mysql_query($sql) or die(mysql_error()); while ($aRow = mysql_fetch_array($result)) { $client_id = $aRow['client_id']; $client = $this->get_company($client_id, "clients", "company_name,email"); $list[$client["company_name"]] = $client_id . "-" . $client["email"]; } return $list; } function get_carcompany_monthly_stas2() { $sql = "select listings.client_id , count(*) count from listings INNER JOIN clients ON listings.client_id=clients.client_id where publish_ocd='1' group by listings.client_id"; $result = mysql_query($sql) or die(mysql_error()); while ($aRow = mysql_fetch_array($result)) { $client_id = $aRow['client_id']; $client = $this->get_company($client_id, "clients", "company_name,email"); $list[$client["company_name"]] = $client_id . "-" . $client["email"]; } return $list; } function day_by_imgleads_admin_mobile($startdate, $enddate) { $sql = mysql_query("select count(id) as count from mobileapp_email_sms_track where type='3' and ts BETWEEN '$startdate' AND '$enddate'"); $results = mysql_fetch_array($sql); $count = $results['count']; return $count; } function day_by_imgleads_admin($startdate, $enddate) { $sql = mysql_query("select count(id) as count from email_sms where type='3' and daily_spam='0' and ts BETWEEN '$startdate' AND '$enddate'"); $results = mysql_fetch_array($sql); $count = $results['count']; return $count; } function day_by_imgleads_admin_stat($date_range, $hourly) { $sql = mysql_query("select count(id) as count from email_sms where type='3' and daily_spam='0' and ts BETWEEN DATE_SUB(NOW(), INTERVAL $date_range DAY) AND NOW() and $hourly"); $results = mysql_fetch_array($sql); $count = $results['count']; return $count; } function day_by_imgleads($client_id, $startdate, $enddate) { $sql = mysql_query("select count(id) as count from email_sms where type='3' and daily_spam='0' and client_id='$client_id' and ts BETWEEN '$startdate' AND '$enddate'"); $results = mysql_fetch_array($sql); $count = $results['count']; return $count; } function day_by_ivr($client_id, $startdate, $enddate) { $sql = mysql_query("select count(id) as count from email_sms where type='8' and daily_spam='0' and client_id='$client_id' and ts BETWEEN '$startdate' AND '$enddate'"); $results = mysql_fetch_array($sql); $count = $results['count']; return $count; } function day_by_imgleads_mobile($client_id, $startdate, $enddate) { $sql = mysql_query("select count(id) as count from mobileapp_email_sms_track where type='3' and daily_spam='0' and client_id='$client_id' and ts BETWEEN '$startdate' AND '$enddate'"); $results = mysql_fetch_array($sql); $count = $results['count']; return $count; } function day_by_imgleads_stat($client_id, $date_range, $hourly) { $sql = mysql_query("select * from email_sms where type='3' and client_id='$client_id' and daily_spam='0' and ts BETWEEN DATE_SUB(NOW(), INTERVAL $date_range DAY) AND NOW() and $hourly"); return $sql2 = mysql_num_rows($sql); } function day_by_find_car_admin($startdate, $enddate) { $sql = mysql_query("select count(id) as count from email_sms where type='4' and daily_spam='0' and ts BETWEEN '$startdate' AND '$enddate'"); $results = mysql_fetch_array($sql); $count = $results['count']; return $count; } function day_by_find_car_admin_mobile($startdate, $enddate) { $sql = mysql_query("select count(id) as count from mobileapp_email_sms_track where type='4' and daily_spam='0' and ts BETWEEN '$startdate' AND '$enddate'"); $results = mysql_fetch_array($sql); $count = $results['count']; return $count; } function day_by_find_car_admin_stat($date_range, $hourly) { $sql = mysql_query("select count(id) as count from email_sms where type='4' and daily_spam='0' and ts BETWEEN DATE_SUB(NOW(), INTERVAL $date_range DAY) AND NOW() and $hourly"); $results = mysql_fetch_array($sql); $count = $results['count']; return $count; } function day_by_find_car($client_id, $date_range) { $sql = mysql_query("select count(id) as count from email_sms where type='4' and daily_spam='0'and client_id='$client_id' and ts BETWEEN '$startdate' AND '$enddate'"); $results = mysql_fetch_array($sql); $count = $results['count']; return $count; } function day_by_find_car_mobile($client_id, $startdate, $enddate) { $sql = mysql_query("select count(id) as count from mobileapp_email_sms_track where type='4' and daily_spam='0' and client_id='$client_id' and ts BETWEEN '$startdate' AND '$enddate'"); $results = mysql_fetch_array($sql); $count = $results['count']; return $count; } function day_b