| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399 |
- <?php
- class profile_model extends Model {
- public function loadSettings($userid) {
- $result = $this->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;
- }
- }
- }
|