| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489 |
- <?php
- class common {
-
-
- static function dbconnect() {
- global $config;
- global $conn;
- $conn = mysqli_connect($config['db_host'],$config['db_username'],$config['db_password'],$config['db_name']);
- mysqli_query($conn,"SET NAMES utf8");
- mysqli_set_charset($conn, 'utf8mb4');
- return true;
- }
- static function dbconnect2() {
- global $config;
- global $conn;
- $conn = mysqli_connect($config['db_host'],$config['db_username'],$config['db_password'],'rockhome_backend');
- mysqli_query($conn,"SET NAMES utf8");
- mysqli_set_charset($conn, 'utf8mb4');
- return true;
- }
- static function checkIPAddress() {
- $ip = $this->getIPAddress();
- if ($ip!='') {
- return true;
- }
- else {
- return false;
- }
- }
-
-
- static function getIPAddress() {
- return $_SERVER['REMOTE_ADDR'];
- }
-
-
- static function validate_ip($ip) {
- if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 | FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) === false) {
- return false;
- }
- return true;
- }
-
-
- static function getMainCategories() {
- self::dbconnect();
- global $conn;
- $res = mysqli_query($conn,"select * from azonics_categories where category_status='0' order by category_id asc;");
-
- if (mysqli_num_rows($res)>0) {
- while ($row = mysqli_fetch_object($res)) {
- $menu[] = $row;
- }
- }
-
- return $menu;
- }
- static function checkAgentInFavorites($agentid) {
- self::dbconnect();
- global $conn;
- $res = mysqli_query($conn,"select * from saved_agents where sp_userid='".$_SESSION['userid']."' and sp_agent_id='".$agentid."' and sp_status='1';");
- if (mysqli_num_rows($res)>0) {
- return true;
- }
- else {
- return false;
- }
- }
- static function checkOfficeInFavorites($officeid) {
- self::dbconnect();
- global $conn;
- $res = mysqli_query($conn,"select * from saved_offices where sp_userid='".$_SESSION['userid']."' and sp_office_id='".$officeid."' and sp_status='1';");
- if (mysqli_num_rows($res)>0) {
- return true;
- }
- else {
- return false;
- }
- }
- static function get_user_data($userid) {
- self::dbconnect();
- global $conn;
- if ($userid!='') {
- $res = mysqli_query($conn,"SELECT * FROM users WHERE id='".$userid."';");
- if (mysqli_num_rows($res)>0) {
- return mysqli_fetch_object($res);
- }
- else {
- return false;
- }
- }
- else {
- return false;
- }
- }
- static function checkPropertyInFavorites($propertyID) {
- self::dbconnect();
- global $conn;
- $res = mysqli_query($conn,"select * from saved_properties where sp_userid='".$_SESSION['userid']."' and sp_property_id='".$propertyID."' and sp_status='1';");
- if (mysqli_num_rows($res)>0) {
- return true;
- }
- else {
- return false;
- }
- }
-
-
- static function getUsernameByUserID($uid='') {
- self::dbconnect();
- global $conn;
- if ($uid) {
- $res = mysqli_query($conn,"select * from azonics_users where user_id='".$uid."';");
- if (mysqli_num_rows($res)>0) {
- $row = mysqli_fetch_array($res);
- return $row['user_nick'];
- }
- else {
- return '';
- }
- }
- else {
- return false;
- }
- }
- static function getPropertyImagesCount($id) {
- self::dbconnect2();
- global $conn;
- if ($id!=='') {
- $res = mysqli_query($conn,"SELECT * FROM hiper_ingatlan_kep WHERE regszam='".$id."' ORDER BY sorrend ASC;");
- return mysqli_num_rows($res);
- }
- else {
- return 0;
- }
- }
- static function getOfficeName($officeID) {
- self::dbconnect();
- global $conn;
- if ($officeID!='') {
- $res = mysqli_query($conn,"SELECT * FROM hiper_iroda WHERE azonosito='".$officeID."';");
- if (mysqli_num_rows($res)>0) {
- $row = mysqli_fetch_array($res);
- return $row['nev'];
- }
- else {
- return false;
- }
- }
- else {
- return false;
- }
- }
- static function get_image_url($fname) {
- $maindir = substr($fname,1,3);
- $subdir = substr($fname,1,5);
- //return 'https://prod.rockhome.hu:8445/pictures/ingatlan/'.$maindir.'/'.$subdir.'/'.$fname;
- return 'https://prod.rockhome.hu'.$fname;
- }
- static function get_image_url_mark($fname) {
- return 'https://prod.rockhome.hu'.$fname;
- }
- static function url_exists($url) {
- $file = $url;
- $file_headers = @get_headers($file);
-
- if(!$file_headers || stristr($file_headers[0],"404 Not Found")) {
- $exists = false;
- }
- else {
- $exists = true;
- }
-
- return $exists;
- }
- static function getOfficeRate($id,$justVotesNumber=false) {
- self::dbconnect();
- global $conn;
- if ($id!=='') {
- $res = mysqli_query($conn,"SELECT SUM(rate) AS maxpoints, COUNT(rate) AS votes FROM iroda_ratings WHERE iroda='".$id."' AND statusz='1';");
- if (mysqli_num_rows($res)>0) {
- $row = mysqli_fetch_array($res);
- $rate = round($row['maxpoints']/$row['votes']);
- if ($justVotesNumber) {
- return $row['votes'];
- }
- else {
- return $rate;
- }
- }
- else {
- return 0;
- }
- }
- else {
- return 0;
- }
- }
- static function getTitleByURL() {
- self::dbconnect();
- global $conn;
- $temp = explode('?',$_SERVER['REQUEST_URI']);
- $res = mysqli_query($conn,"SELECT * FROM azonics_news WHERE slide_title='".$temp[0]."';");
- if (mysqli_num_rows($res)>0 && $temp[0]!='/') {
- $row = mysqli_fetch_array($res);
- return $row['slide_subtitle'];
- }
- else {
- return 'Rock Home ingatlanok';
- }
- }
- static function getKeywordsByURL() {
- self::dbconnect();
- global $conn;
- $temp = explode('?',$_SERVER['REQUEST_URI']);
- $res = mysqli_query($conn,"SELECT * FROM azonics_news WHERE slide_title='".$temp[0]."';");
- if (mysqli_num_rows($res)>0 && $temp[0]!='/') {
- $row = mysqli_fetch_array($res);
- return $row['slide_buttontitle'];
- }
- else {
- return 'Rock Home, ingatlanok';
- }
- }
- static function getDescriptionByURL() {
- self::dbconnect();
- global $conn;
- $temp = explode('?',$_SERVER['REQUEST_URI']);
- $res = mysqli_query($conn,"SELECT * FROM azonics_news WHERE slide_title='".$temp[0]."';");
- if (mysqli_num_rows($res)>0 && $temp[0]!='/') {
- $row = mysqli_fetch_array($res);
- return $row['slide_buttonURL'];
- }
- else {
- return 'A Rock Home dinamikusan növekvő ingatlanhálózata magas szinvonalú és emberközpontú szolgáltatásokkal vár. Lakáseladás, kiadás vagy vétel? Velünk biztosan jól jársz! Új hangot hozunk a hazai ingatlanközvetítésbe - okosabban, gyorsabban, személyesebben - és persze rockosabban.';
- }
- }
- static function getAgentRate($id,$justVotesNumber=false) {
- self::dbconnect();
- global $conn;
- if ($id!=='') {
- $res = mysqli_query($conn,"SELECT SUM(rate) AS maxpoints, COUNT(rate) AS votes FROM munkatars_ratings WHERE munkatars='".$id."' AND statusz='1';");
- if (mysqli_num_rows($res)>0) {
- $row = mysqli_fetch_array($res);
- $rate = round($row['maxpoints']/$row['votes']);
- if ($justVotesNumber==true) {
- return $row['votes'];
- }
- else {
- return $rate;
- }
- }
- else {
- return 0;
- }
- }
- else {
- return 0;
- }
- }
- static function getErtekesitesTipusOptions($selected='') {
-
- }
- static function getKey($key,$val) {
- self::dbconnect2();
- global $conn;
- if ($key!='' && $val!='') {
- $res = mysqli_query($conn,"SELECT `config_value` AS emelet FROM `dictionary` WHERE `group`='".$key."' AND `config_key`='".$val."';") or die(mysqli_error($conn));
- if (mysqli_num_rows($res)>0) {
- $row = mysqli_fetch_array($res);
- return $row['emelet'];
- }
- else {
- return false;
- }
- }
- else {
- return false;
- }
- }
- static function getPropertyTeaser($property,$showAddress=true) {
- if ($property->ertekesites=='elado') {
- $result = 'Eladó';
- }
- else {
- $result = 'Kiadó';
- }
- if ($property->tipus=='tarsashazi') {
- $result.= ' lakás';
- }
- elseif ($property->tipus=='csaladihaz') {
- $result.= ' családi ház';
- }
- elseif ($property->tipus=='epuletresz') {
- $result.= ' épületrész';
- }
- elseif ($property->tipus=='hazresz') {
- $result.= ' házrész';
- }
- elseif ($property->tipus=='ikerhaz') {
- $result.= ' ikerház';
- }
- elseif ($property->tipus=='onalloepulet') {
- $result.= ' önálló épület';
- }
- elseif ($property->tipus=='teljesepulet' && $property->jelleg!='telek') {
- $result.= ' teljes épület';
- }
- elseif ($property->tipus=='beruhazasi') {
- $result.= ' beruházás';
- }
- elseif ($property->jelleg=='garazs') {
- $result.= ' garázs';
- }
- elseif ($property->jelleg=='kereskedelmi') {
- $result.= ' kereskedelmi';
- }
- elseif ($property->jelleg=='mezogazdasagi') {
- $result.= ' mezőgazdasági';
- }
- elseif ($property->tipus=='tarolo') {
- $result.= ' tároló';
- }
- elseif ($property->jelleg=='telek') {
- $result.= ' telek';
- }
- /*if ($showAddress) {
- if (stristr($property->telepules,'Budapest')) {
- $result.= ' '.$property->telepules.'. kerület';
- }
- else {
- $result.= ' '.$property->telepules;
- }
- }*/
- return $result;
- }
- static function getPageSlug($pageID) {
- self::dbconnect();
- global $conn;
- if ($pageID!='') {
- $res = mysqli_query($conn,"SELECT page_slug FROM azonics_pages WHERE page_id='".$pageID."';");
- if (mysqli_num_rows($res)>0) {
- $row = mysqli_fetch_array($res);
- return $row['page_slug'];
- }
- else {
- return false;
- }
- }
- else {
- return false;
- }
- }
- static function generateSlug($key) {
- $key = strtolower($key);
- $key = str_replace(" ","-",$key);
- $key = str_replace(".","",$key);
- $key = str_replace("(","-",$key);
- $key = str_replace(")","-",$key);
- $accented = array( "á", "é", "í", "ó", "ö", "ő", "ú", "ü", "ű" );
- $mask = array( "a", "e", "i", "o", "o", "o", "u", "u", "u" );
- $key = str_replace($accented,$mask,$key);
- if (stristr($key,'budapest')) {
- $roman = array(
- "budapest-i",
- "budapest-ii",
- "budapest-iii",
- "budapest-iv",
- "budapest-v",
- "budapest-vi",
- "budapest-vii",
- "budapest-viii",
- "budapest-ix",
- "budapest-x",
- "budapest-xi",
- "budapest-xii",
- "budapest-xiii",
- "budapest-xiv",
- "budapest-xv",
- "budapest-xvi",
- "budapest-xvii",
- "budapest-xviii",
- "budapest-xix",
- "budapest-xx",
- "budapest-xxi",
- "budapest-xxii",
- "budapest-xxiii");
- $arab = array(
- "budapest-01",
- "budapest-02",
- "budapest-03",
- "budapest-04",
- "budapest-05",
- "budapest-06",
- "budapest-07",
- "budapest-08",
- "budapest-09",
- "budapest-10",
- "budapest-11",
- "budapest-12",
- "budapest-13",
- "budapest-14",
- "budapest-15",
- "budapest-16",
- "budapest-17",
- "budapest-18",
- "budapest-19",
- "budapest-20",
- "budapest-21",
- "budapest-22",
- "budapest-23"
- );
- $key = str_replace($arab,$roman,$key);
- $key.= '-kerulet';
- }
- return $key;
- }
-
-
- }
|