query("SELECT * FROM users WHERE id='".$userid."';"); if (sizeof($result)>0) { return $result[0]; } else { return false; } } public function saveSettings($data) { $data = $this->escapeArray($data); $this->execute("UPDATE users SET username='".$data['username']."', firstname='".$data['fname']."', lastname='".$data['lname']."', email='".$data['email']."', subscribe='".$data['subscribe']."' WHERE id='".$_SESSION['userid']."';"); /*$this->execute("UPDATE users SET username='".$data['username']."', firstname='".$data['fname']."', lastname='".$data['lname']."', email='".$data['email']."', delivery_country='".$data['country']."', delivery_postal_code='".$data['zip']."', delivery_settlement='".$data['city']."', delivery_address='".$data['street']."', delivery_region='".$data['state']."', subscribe='".$data['subscribe']."' WHERE id='".$_SESSION['userid']."';");*/ return true; } public function savePass($pass) { if ($pass!=='') { $pass = $this->escapeString($pass); $newpass = hash('ripemd160',$pass); $this->execute("UPDATE users SET pass='".$newpass."' WHERE id='".$_SESSION['userid']."';"); return true; } else { return false; } } public function checkPass($pass) { if ($pass!=='') { $pass = $this->escapeString($pass); $newpass = hash('ripemd160',$pass); $check = $this->query("SELECT * FROm users WHERE pass='".$newpass."' AND id='".$_SESSION['userid']."';"); if (sizeof($check)>0) { return 'ok'; } else { return 'error'; } } else { return 'error'; } } public function save_search($query) { $query = serialize($query); if ($query!='') { $this->execute("INSERT INTO saved_search SET sch_query='".$query."', sch_userid='".$_SESSION['userid']."';"); return true; } else { return false; } } public function deleteSearch($id) { $id = $this->escapeString($id); if ($id!='') { $this->execute("DELETE FROM saved_search WHERE sch_id='".$id."';"); return true; } else { return false; } } public function check_favorite($property_id) { $property_id = $this->escapeString($property_id); $check = $this->query("SELECT * FROM saved_properties WHERE sp_userid='".$_SESSION['userid']."' AND sp_property_id='".$property_id."' AND sp_status='1';"); if (sizeof($check)>0) { return true; } else { return false; } } public function add_to_favorites($property_id) { $property_id = $this->escapeString($property_id); if ($property_id!='' && !$this->check_favorite($property_id)) { $this->execute("INSERT INTO saved_properties SET sp_userid='".$_SESSION['userid']."', sp_property_id='".$property_id."';"); return true; } else { return false; } } public function getUserFavoritePropertiesCount($userid) { $userid = $this->escapeString($userid); if ($userid!='') { $check = $this->query("SELECT * FROM saved_properties WHERE sp_userid='".$_SESSION['userid']."' AND sp_status='1';"); return sizeof($check); } else { return false; } } public function getUserFavoriteAgentsCount($userid) { $userid = $this->escapeString($userid); if ($userid!='') { $check = $this->query("SELECT * FROM saved_agents WHERE sp_userid='".$_SESSION['userid']."' AND sp_status='1';"); return sizeof($check); } else { return false; } } public function getUserFavoriteOfficesCount($userid) { $userid = $this->escapeString($userid); if ($userid!='') { $check = $this->query("SELECT * FROM saved_offices WHERE sp_userid='".$_SESSION['userid']."' AND sp_status='1';"); return sizeof($check); } else { return false; } } public function check_agent_favorite($agent_id) { $agent_id = $this->escapeString($agent_id); $check = $this->query("SELECT * FROM saved_agents WHERE sp_userid='".$_SESSION['userid']."' AND sp_agent_id='".$agent_id."' AND sp_status='1';"); if (sizeof($check)>0) { return true; } else { return false; } } public function add_agent_to_favorites($agent_id) { $agent_id = $this->escapeString($agent_id); if ($agent_id!='' && !$this->check_agent_favorite($agent_id)) { $this->execute("INSERT INTO saved_agents SET sp_userid='".$_SESSION['userid']."', sp_agent_id='".$agent_id."';"); return true; } else { return false; } } public function check_office_favorite($office_id) { $office_id = $this->escapeString($office_id); $check = $this->query("SELECT * FROM saved_offices WHERE sp_userid='".$_SESSION['userid']."' AND sp_office_id='".$office_id."' AND sp_status='1';"); if (sizeof($check)>0) { return true; } else { return false; } } public function add_office_to_favorites($office_id) { $office_id = $this->escapeString($office_id); if ($office_id!='' && !$this->check_office_favorite($office_id)) { $this->execute("INSERT INTO saved_offices SET sp_userid='".$_SESSION['userid']."', sp_office_id='".$office_id."';"); return true; } else { return false; } } public function getProperty($id) { if ($id!=='') { $id = $this->escapeString($id); $res = $this->query("SELECT *,getimgurl(indexkep,'ingatlan') AS indexkep FROM hiper_ingatlan WHERE id='".$id."' AND (rockhomera_mehet='1' OR rockhomera_mehet='0');"); if (sizeof($res)>0) { return $res[0]; } else { return false; } } else { return false; } } public function getAgent($id) { if ($id!=='') { $id = $this->escapeString($id); $res = $this->query("SELECT * FROM hiper_munkatars WHERE id='".$id."';"); if (sizeof($res)>0) { return $res[0]; } else { return false; } } else { return false; } } public function getOffice($id) { if ($id!=='') { $id = $this->escapeString($id); $res = $this->query("SELECT * FROM hiper_iroda WHERE id='".$id."';"); if (sizeof($res)>0) { return $res[0]; } else { return false; } } else { return false; } } public function getPropertyListByID($userid) { $userid = $this->escapeString($userid); if ($userid!='') { $check = $this->query("SELECT * FROM saved_properties WHERE sp_userid='".$userid."' AND sp_status='1' ORDER BY sp_createdate DESC;"); foreach ($check as $row) { $list[] = $row->sp_property_id; } if (is_array($list)) { foreach ($list as $item) { $results[] = $this->getProperty($item); } return $results; } else { return false; } } else { return false; } } public function getAgentListByID($userid) { $userid = $this->escapeString($userid); if ($userid!='') { $check = $this->query("SELECT * FROM saved_agents WHERE sp_userid='".$userid."' AND sp_status='1' ORDER BY sp_createdate DESC;"); foreach ($check as $row) { $list[] = $row->sp_agent_id; } if (is_array($list)) { foreach ($list as $item) { $results[] = $this->getAgent($item); } return $results; } else { return false; } } else { return false; } } public function getOfficesListByID($userid) { $userid = $this->escapeString($userid); if ($userid!='') { $check = $this->query("SELECT * FROM saved_offices WHERE sp_userid='".$userid."' AND sp_status='1' ORDER BY sp_createdate DESC;"); foreach ($check as $row) { $list[] = $row->sp_office_id; } if (is_array($list)) { foreach ($list as $item) { $results[] = $this->getOffice($item); } return $results; } else { return false; } } else { return false; } } public function getUserFavoriteSearchesCount($userid) { $result = $this->query("SELECT sch_id FROM saved_search WHERE sch_userid='".$userid."' AND sch_status='1';"); return sizeof($result); } public function getSearchesListByID($userid) { $result = $this->query("SELECT * FROM saved_search WHERE sch_userid='".$userid."' AND sch_status='1';"); return $result; } public function deleteProfileProperty($id) { $id = $this->escapeString($id); if ($id!='') { $this->execute("DELETE FROM saved_properties WHERE sp_property_id='".$id."' AND sp_userid='".$_SESSION['userid']."';"); return true; } else { return false; } } public function deleteProfileOffice($id) { $id = $this->escapeString($id); if ($id!='') { $this->execute("DELETE FROM saved_offices WHERE sp_office_id='".$id."' AND sp_userid='".$_SESSION['userid']."';"); return true; } else { return false; } } public function deleteProfileAgent($id) { $id = $this->escapeString($id); if ($id!='') { $this->execute("DELETE FROM saved_agents WHERE sp_agent_id='".$id."' AND sp_userid='".$_SESSION['userid']."';"); return true; } else { return false; } } }