if (!$connection) { $dbColumns = column_name($table, config_get("db_database")); } else { $dbColumns = column_name_extended($table, "", ["connection" => $connection]); } if (array_is_valid($dbColumns)) { $ins = array(); foreach ($dbColumns as $k => $v) { if (array_key_exists($v, $data)) { $ins[$v] = $data[$v]; } } if (array_is_valid($ins)) { $data = $ins; $sql = "insert into $table "; $sql_insert = array(); foreach ($data as $k => $v) { $sql_insert['key'][] = $k; $sql_insert['value'][] = \App\CRUD::valueEscape($v, ["value_escape_type" => $options['value_escape_type'], "connection" => $connection]); } if (array_is_valid($sql_insert)) { $sql_col_key = ""; $sql_col_value = ""; if (array_is_valid($sql_insert['key'])) { foreach ($sql_insert['key'] as $k => $v) { $sql_col_key .= "`" . $v . "`" . ","; $sql_col_value .= "'" . $sql_insert['value'][$k] . "'" . ","; } } $sql_col_key = trim(rtrim($sql_col_key, ",")); $sql_col_value = trim(rtrim($sql_col_value, ",")); if (!empty($sql_col_key) && !empty($sql_col_value)) { $sql = $sql . "(" . $sql_col_key . ")" . " VALUES " . "(" . $sql_col_value . ")"; if (!$connection) { query_update($sql); return query_insert_id(); } else { query_update($sql, ["connection" => $connection]); return query_insert_id(["connection" => $connection]); } } } } } } return FALSE; } function query_last_insert_id() { $__connection = $GLOBALS['link']; $id = mysql_insert_id($__connection); return $id; } function query_insert($sql, $options = array()) { $query_rsdummy = $sql; $__connection = $GLOBALS['connection']; if (isset($options['connection'])) { $__connection = $options['connection']; } $__mysql_driver = config_get("mysql_driver"); switch ($__mysql_driver) { default: case "mysql": $rsdummy = mysql_query($query_rsdummy, $__connection); $rid = mysql_insert_id(); if (is_numeric($rid)) { return $rid; } break; case "mysqli": $rsdummy = mysqli_query($__connection, $query_rsdummy); $rid = mysqli_insert_id($__connection); if (is_numeric($rid)) { return $rid; } break; } return FALSE; } function query_affected_rows($options = array()) { $__connection = $GLOBALS['connection']; if (isset($options['connection'])) { $__connection = $options['connection']; } $__mysql_driver = config_get("mysql_driver"); switch ($__mysql_driver) { default: case "mysql": $id = mysql_affected_rows($__connection); if (is_numeric($id)) { return $id; } break; case "mysqli": $id = mysqli_affected_rows($__connection); if (is_numeric($id)) { return $id; } break; } return FALSE; } function query_insert_id($options = array()) { $__connection = $GLOBALS['connection']; if (isset($options['connection'])) { $__connection = $options['connection']; } $__mysql_driver = config_get("mysql_driver"); switch ($__mysql_driver) { default: case "mysql": $rid = mysql_insert_id(); if (is_numeric($rid)) { return $rid; } break; case "mysqli": $rid = mysqli_insert_id($__connection); if (is_numeric($rid)) { return $rid; } break; } return FALSE; } function query_update($sql, $options = array()) { $query_rsdummy = $sql; $__connection = $GLOBALS['connection']; if (isset($options['connection'])) { $__connection = $options['connection']; } $__mysql_driver = config_get("mysql_driver"); switch ($__mysql_driver) { default: case "mysql": $rsdummy = mysql_query($query_rsdummy, $__connection); if ($rsdummy !== FALSE) { return TRUE; } break; case "mysqli": $rsdummy = mysqli_query($__connection, $query_rsdummy); if ($rsdummy !== FALSE) { return TRUE; } break; } return FALSE; } function query_count($sql, $options = array()) { $__connection = $GLOBALS['connection']; if (isset($options['connection'])) { $__connection = $options['connection']; } $__mysql_driver = config_get("mysql_driver"); switch ($__mysql_driver) { default: case "mysql": $result = mysql_query($sql, $__connection); $data = mysql_fetch_assoc($result); return $data; break; case "mysqli": $result = mysqli_query($__connection, $sql); $data = mysqli_fetch_assoc($result); return $data; break; } return FALSE; } function querynumrows($sql, $options = array()) { $__connection = $GLOBALS['connection']; if (isset($options['connection'])) { $__connection = $options['connection']; } $__mysql_driver = config_get("mysql_driver"); switch ($__mysql_driver) { default: case "mysql": $r = mysql_query($sql, $__connection); $data = mysql_num_rows($r); return $data; break; case "mysqli": $r = mysqli_query($__connection, $sql); $data = mysqli_num_rows($r); return $data; break; } return FALSE; } function querytorowarray($sql, $options = array()) { $data = querytoarray($sql, $options); if (isset($data['0'])) { return $data['0']; } return FALSE; } function querytoarray($sql, $options = array()) { $returned = query($sql, $options); if ($returned[2] > 0) { $__mysql_driver = config_get("mysql_driver"); switch ($__mysql_driver) { default: case "mysql": $dummy = array(); do { array_push($dummy, $returned[0]); } while ($returned[0] = mysql_fetch_assoc($returned[1])); return $dummy; break; case "mysqli": $dummy = array(); do { array_push($dummy, $returned[0]); } while ($returned[0] = mysqli_fetch_assoc($returned[1])); return $dummy; break; } } } /** * rtrim similar behaviour * * @param $subject * @param $search * @param string $replace * * @return mixedS */ function string_last_replace($subject, $search, $replace = "") { $pos = strrpos($subject, $search); if ($pos !== FALSE) { $subject = substr_replace($subject, $replace, $pos, strlen($search)); } return $subject; } // Get string between function get_string_between($string, $start, $end) { $string = " " . $string; $ini = strpos($string, $start); if ($ini == 0) return ""; $ini += strlen($start); $len = strpos($string, $end, $ini) - $ini; return substr($string, $ini, $len); } function link_encode($str) { $dummy = str_replace(" ", "-", $str); $dummy = str_replace("/", "+", $dummy); $dummy = str_replace("&", "%26", $dummy); $dummy = str_replace("'", "%27", $dummy); // $dummy = str_replace("'","`",$dummy); $dummy = strtolower($dummy); return $dummy; } function link_encode2($str) { $dummy = str_replace("/", "+", $str); $dummy = str_replace("&", "", $dummy); $dummy = str_replace("'", "", $dummy); $dummy = str_replace(",", "", $dummy); $dummy = str_replace(" ", " ", $dummy); $dummy = str_replace(" ", " ", $dummy); $dummy = str_replace(" ", "-", $dummy); $dummy = str_replace("---", "-", $dummy); $dummy = str_replace("--", "-", $dummy); // $dummy = str_replace("'","`",$dummy); $dummy = strtolower($dummy); return $dummy; } function division($a, $b) { if ($b == 0) return NULL; return $a / $b; } function comment_fingerprint_generate($str = "") { $str = trim($str); $str = strtolower($str); $str = preg_replace("/[^a-zA-Z0-9]+/", "", $str); if (function_exists("sha1")) { $str = sha1($str); } return $str; } function link_decode($str) { $dummy = str_replace("-", " ", $str); $dummy = str_replace("-County", "", $dummy); //$dummy = str_replace("-","/",$dummy); $dummy = str_replace("%26", "&", $dummy); $dummy = str_replace("+", "/", $dummy); $dummy = str_replace("'", "%27", $dummy); //$dummy = str_replace("`","'",$dummy); $dummy = ucwords($dummy); //print "---$dummy---"; return $dummy; } function listing_viewdetail_request_store($data = array()) { if (array_is_valid($data)) { $ins = array(); $keys_valid = array("name", "first_name", "last_name", "email", "zipcode", "phone", "surl", "ip", "listing_id", "domain", "table", "type", "cat", "category", "city", "state"); foreach ($keys_valid as $k => $v) { if (isset($data[$v])) { $ins[$v] = $data[$v]; } } $keys_required = array("name", "first_name", "last_name", "email", "zipcode", "phone", "listing_id", "domain", "table"); if (array_is_valid($keys_required)) { foreach ($keys_required as $k => $v) { if (!isset($ins[$v])) { return FALSE; } } } $keys_not_empty = array("listing_id", "domain", "table"); if (array_is_valid($keys_not_empty)) { foreach ($keys_not_empty as $k => $v) { if (empty($ins[$v])) { return FALSE; } } } if (array_is_valid($ins)) { $skip_ids = session_get("lvd.skip_ids"); if (!array_is_valid($skip_ids)) { $skip_ids = array(); } if (!in_array($ins['listing_id'], $skip_ids)) { $sql = "insert into q_listing_viewdetail_request (`name`,first_name,last_name,email,zipcode,phone,surl,ip,listing_id,domain,`table`,`type`,cdate,cat,category,city,state) values ('{name}','{first_name}','{last_name}','{email}','{zipcode}','{phone}','{surl}','{ip}','{listing_id}','{domain}','{table}','{type}','{cdate}','{cat}','{category}','{city}','{state}')"; $sql = str_replace("{name}", $ins['name'], $sql); $sql = str_replace("{first_name}", $ins['first_name'], $sql); $sql = str_replace("{last_name}", $ins['last_name'], $sql); $sql = str_replace("{email}", $ins['email'], $sql); $sql = str_replace("{zipcode}", $ins['zipcode'], $sql); $sql = str_replace("{phone}", $ins['phone'], $sql); $sql = str_replace("{surl}", $ins['surl'], $sql); $sql = str_replace("{ip}", $ins['ip'], $sql); $sql = str_replace("{listing_id}", $ins['listing_id'], $sql); $sql = str_replace("{domain}", $ins['domain'], $sql); $sql = str_replace("{table}", $ins['table'], $sql); $sql = str_replace("{type}", $ins['type'], $sql); $sql = str_replace("{cat}", $ins['cat'], $sql); $sql = str_replace("{category}", $ins['category'], $sql); $sql = str_replace("{city}", $ins['city'], $sql); $sql = str_replace("{state}", $ins['state'], $sql); $sql = str_replace("{cdate}", mysql_now(), $sql); $rid = query_insert($sql); if (!empty($rid)) { $storeLocalData = array(); $storeLocalData['name'] = $ins['name']; $storeLocalData['first_name'] = $ins['first_name']; $storeLocalData['last_name'] = $ins['last_name']; $storeLocalData['email'] = $ins['email']; $storeLocalData['zipcode'] = $ins['zipcode']; $storeLocalData['phone'] = $ins['phone']; session_set("lvd.data", $storeLocalData); session_set("lvd.already", TRUE); $skip_ids[] = $ins['listing_id']; session_set("lvd.skip_ids", $skip_ids); return $rid; } } return TRUE; } } return FALSE; } function ValidateEmail($value) { $regex = '/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i'; if ($value == '') { return FALSE; } else { $string = preg_replace($regex, '', $value); } return empty($string) ? TRUE : FALSE; } function mysql_now() { return date('Y-m-d H:i:s'); } function url_is_amp($url = "") { if (!empty($url)) { $parts = parse_url($url); $path = rtrim($parts['path'], "/"); $path_array = explode("/", $path); $path_array = array_values($path_array); $path_last = end($path_array); $path_last = strtolower($path_last); $is_amp_request = ($path_last == "amp") ? TRUE : FALSE; return $is_amp_request; } return FALSE; } function url_is_absolute($url) { $pattern = "/^(?:ftp|https?|feed)?:?\/\/(?:(?:(?:[\w\.\-\+!$&'\(\)*\+,;=]|%[0-9a-f]{2})+:)* (?:[\w\.\-\+%!$&'\(\)*\+,;=]|%[0-9a-f]{2})+@)?(?: (?:[a-z0-9\-\.]|%[0-9a-f]{2})+|(?:\[(?:[0-9a-f]{0,4}:)*(?:[0-9a-f]{0,4})\]))(?::[0-9]+)?(?:[\/|\?] (?:[\w#!:\.\?\+\|=&@$'~*,;\/\(\)\[\]\-]|%[0-9a-f]{2})*)?$/xi"; return (bool)preg_match($pattern, $url); } function url_certainly_absolute($url = "", $host = "") { if (!url_is_absolute($url)) { $host = rtrim($host, "/") . "/"; $url = ltrim($url, "/"); $url = $host . $url; } return $url; } function current_url_to_amp() { $url = current_url_extended(); if (!url_is_amp($url)) { $parts = parse_url($url); $path = rtrim($parts['path'], "/") . "/amp/"; $url = $parts['scheme'] . "://" . $parts['host'] . $path . $parts['query']; } return $url; } function current_url_to_noamp() { $url = current_url_extended(); if (url_is_amp($url)) { $parts = parse_url($url); $path = rtrim(rtrim($parts['path'], "/"), "/amp"); $url = $parts['scheme'] . "://" . $parts['host'] . $path . $parts['query']; } return $url; } function url_to_amp($url) { $parts = parse_url($url); $path = rtrim(rtrim($parts['path'], "/"), "/amp") . "/amp/"; $join_arr = array(); if (!empty($parts['scheme'])) { $join_arr[] = $parts['scheme'] . "://"; } if (!empty($parts['host'])) { $join_arr[] = $parts['host']; } if (!empty($path)) { $join_arr[] = $path; } if (!empty($parts['query'])) { $join_arr[] = $parts['query']; } $url = implode("", $join_arr); return $url; } function url_to_amp_none($url) { $parts = parse_url($url); $path = rtrim(rtrim($parts['path'], "/"), "/amp"); $join_arr = array(); if (!empty($parts['scheme'])) { $join_arr[] = $parts['scheme'] . "://"; } if (!empty($parts['host'])) { $join_arr[] = $parts['host']; } if (!empty($path)) { $join_arr[] = $path; } if (!empty($parts['query'])) { $join_arr[] = $parts['query']; } $url = implode("", $join_arr); return $url; } function adset_get_item($adset = "", $type = "") { if (!empty($type) && !empty($adset)) { $type = rtrim($type, ".php") . ".php"; $path = __DIR__ . "/template/common/adsets/" . $adset . "/" . $type; if (file_exists($path)) { include($path); } } return FALSE; } function is_valid_phone($str) { $str = preg_replace("/[^0-9]/", "", $str); $str = ltrim($str, "1"); if (strlen($str) != 10) { return FALSE; } return TRUE; } function ensure_storage_path_writable() { if (!is_storage_path_writable()) { $chmod = "0777"; mkdir(WEBROOTPATH . "/storage/", octdec($chmod), TRUE); chmod(WEBROOTPATH . "/storage/", octdec($chmod)); } return TRUE; } function is_storage_path_writable() { return is_directory_writable(WEBROOTPATH . "/storage/"); } function is_directory_writable_extended($dir) { if (empty($dir)) { return FALSE; } $dir = rtrim($dir, "/") . "/"; // try to create this directory if it doesn't exist $booExists = is_dir($dir) || (mkdir($dir, 0777, TRUE) && is_dir($dir)); $booIsWritable = FALSE; if ($booExists && is_writable($dir)) { $tempFile = tempnam($dir, 'tmp'); if ($tempFile !== FALSE) { $res = file_put_contents($tempFile, 'test'); $booIsWritable = $res !== FALSE; @unlink($tempFile); } } return $booIsWritable; } function is_directory_writable($dir = "") { if (empty($dir)) { return FALSE; } if (is_dir($dir) && is_writable($dir)) { return TRUE; } return FALSE; } function is_valid_date($date, $format = 'Y-m-d') { $f = DateTime::createFromFormat($format, $date); $valid = DateTime::getLastErrors(); return ($valid['warning_count'] == 0 and $valid['error_count'] == 0); } function is_valid_zipcode($str, $options = array()) { switch ($options['type']) { default: if (!empty($str)) { return TRUE; } break; case "us": $str = filter_var($str, FILTER_SANITIZE_NUMBER_INT); if (!empty($str)) { if (strlen($str) == 4 || strlen($str) == 5) { return TRUE; } } break; } return FALSE; } function is_valid_first_name($str) { if (!empty($str)) { return TRUE; } return FALSE; } function is_valid_last_name($str) { if (!empty($str)) { return TRUE; } return FALSE; } function is_spam_keyword($str = "") { $spam = ""; $str = strtolower($str); $spam_arr = querytoarray("select * from spam_keywords"); if (array_is_valid($spam_arr)) { foreach ($spam_arr as $ispam) { if (strlen(strstr($str, strtolower($ispam['keyword']))) > 0) { $spam .= "spam"; } } } if (!empty($spam)) { return FALSE; } return TRUE; } function is_valid_email($str) { if (!empty($str)) { return ValidateEmail($str); } return FALSE; } function is_valid_money($number) { if (is_null($number)) { return FALSE; } return preg_match("/^-?[0-9]+(?:\.[0-9]{1,2})?$/", $number); } function is_valid_percentage($number) { if (is_numeric($number)) { return FALSE; } if ($number >= 0 && $number <= 100) { return TRUE; } return FALSE; } function number_certainly($number) { $number = preg_replace("/[^0-9\.]/", "", $number); return $number; } function custom_include_get_item($type = "") { if (!empty($type)) { $data = config_site_get("", "template_include"); if (isset($data[$type])) { $file = ltrim($data[$type], "/"); $path = BOOTSTRAPPATH . "/" . $file; if (file_exists($path)) { include($path); } } } return FALSE; } function render_html_view($file = "", $data = array(), $options = []) { if (empty($file)) { return FALSE; } if (file_exists($file) && is_file($file)) { ob_start(); $__renderData = (array_is_valid($data)) ? $data : []; include($file); $html = ob_get_contents(); ob_end_clean(); return $html; } return FALSE; } function custom_domain_view_include($file = "", $options = array()) { if (!empty($file)) { $filePathData = pathinfo($file); if (empty($filePathData['extension'])) { $file = $file . ".php"; } $path = WEBROOTPATH . "/custom/" . domain_certainly(__domainCertainly()) . "/" . $file; $path_common = WEBROOTPATH . "/custom/" . "*" . "/" . $file; if (array_key_exists("template", $options)) { $path = WEBROOTPATH . "/custom/" . domain_certainly(__domainCertainly()) . "/" . $options['template'] . "/" . $file; } $data = $options['data']; if (file_exists($path)) { ob_start(); $__renderHtmlData = $data; include($path); $html = ob_get_contents(); ob_end_clean(); echo $html; return TRUE; } if (file_exists($path_common) && $options['skip_common'] !== TRUE) { ob_start(); $__renderHtmlData = $data; include($path_common); $html = ob_get_contents(); ob_end_clean(); echo $html; return TRUE; } if (!empty($options['default']) && file_exists($options['default'])) { ob_start(); $__renderHtmlData = $data; include($options['default']); $html = ob_get_contents(); ob_end_clean(); echo $html; return TRUE; } return FALSE; } } function href_to_amp($html) { $a = new SimpleXMLElement($html); $href = (string)$a['href']; $anchor = (string)$a[0]; $href = url_to_amp($href); $html = '' . $anchor . ''; return $html; } function current_url_extended() { $scheme = $_SERVER['SERVER_PORT'] == 80 ? 'http' : 'https'; $url = $scheme . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; return $url; } function current_host_extended() { $scheme = $_SERVER['SERVER_PORT'] == 80 ? 'http' : 'https'; $url = $scheme . '://' . $_SERVER['HTTP_HOST'] . "/"; return $url; } function validate_ip($ip) { if (strtolower($ip) === 'unknown') return FALSE; // generate ipv4 network address $ip = ip2long($ip); // if the ip is set and not equivalent to 255.255.255.255 if ($ip !== FALSE && $ip !== -1) { // make sure to get unsigned long representation of ip // due to discrepancies between 32 and 64 bit OSes and // signed numbers (ints default to signed in PHP) $ip = sprintf('%u', $ip); // do private network range checking if ($ip >= 0 && $ip <= 50331647) return FALSE; if ($ip >= 167772160 && $ip <= 184549375) return FALSE; if ($ip >= 2130706432 && $ip <= 2147483647) return FALSE; if ($ip >= 2851995648 && $ip <= 2852061183) return FALSE; if ($ip >= 2886729728 && $ip <= 2887778303) return FALSE; if ($ip >= 3221225984 && $ip <= 3221226239) return FALSE; if ($ip >= 3232235520 && $ip <= 3232301055) return FALSE; if ($ip >= 4294967040) return FALSE; } return TRUE; } function cookie_get_safe($name) { $key = $name; $value = array_key_exists($key, $_COOKIE) ? json_decode(base64_decode($_COOKIE[$key])) : NULL; if ($value == NULL) { return FALSE; } return $value; } function cookie_set_safe($name, $value, $expiration = 0, $domain = '') { $enc = base64_encode(json_encode($value)); return cookie_set($name, $enc, $expiration, '/', $domain); } function cookie_set($name, $value = '', $expire = 0, $path = '', $domain = '', $secure = FALSE, $httponly = FALSE) { $_COOKIE[$name] = $value; if (!empty($expire)) { $expire = time() + $expire; } return setcookie($name, $value, $expire, $path, $domain, $secure, $httponly); } function cookie_delete($name, $path = '', $domain = '', $secure = FALSE, $httponly = FALSE) { $value = time() - 1314000; $_COOKIE[$name] = $value; return setcookie($name, '', $value, $path, $domain, $secure, $httponly); } function session_init($id = "") { if (session_status() == PHP_SESSION_NONE) { if (!empty($id)) { session_id($id); } session_start(); } return TRUE; } function session_set($key = "", $value = "") { session_init(); if (empty($key)) { return FALSE; } $_SESSION[$key] = json_encode($value); return TRUE; } function session_id_get() { session_init(); return session_id(); } function session_get($key = "") { session_init(); if (empty($key)) { return FALSE; } $data = isset($_SESSION[$key]) ? json_decode($_SESSION[$key], TRUE) : NULL; return $data; } function session_delete($key = "") { session_init(); if (empty($key)) { return FALSE; } unset($_SESSION[$key]); return TRUE; } function get_ip_address() { // check cloudflare // Try to use Enable Pseudo IPv4 on CF. If client use IPv6 it will be in Cf-Connecting-IPv6 header. if (isset($_SERVER["HTTP_CF_CONNECTING_IP"]) && validate_ip($_SERVER['HTTP_X_FORWARDED'])) { $ip = $_SERVER["HTTP_CF_CONNECTING_IP"]; $ip = \App\Helpers\IPHelper::ensureIPv4($ip); return $ip; } // check for shared internet/ISP IP if (!empty($_SERVER['HTTP_CLIENT_IP']) && validate_ip($_SERVER['HTTP_CLIENT_IP'])) { $ip = $_SERVER["HTTP_CLIENT_IP"]; $ip = \App\Helpers\IPHelper::ensureIPv4($ip); return $ip; } // check for IPs passing through proxies if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { // check if multiple ips exist in var if (strpos($_SERVER['HTTP_X_FORWARDED_FOR'], ',') !== FALSE) { $iplist = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']); foreach ($iplist as $ip) { if (validate_ip($ip)) return $ip; } } else { if (validate_ip($_SERVER['HTTP_X_FORWARDED_FOR'])) return $_SERVER['HTTP_X_FORWARDED_FOR']; } } if (!empty($_SERVER['HTTP_X_FORWARDED']) && validate_ip($_SERVER['HTTP_X_FORWARDED'])) return $_SERVER['HTTP_X_FORWARDED']; if (!empty($_SERVER['HTTP_X_CLUSTER_CLIENT_IP']) && validate_ip($_SERVER['HTTP_X_CLUSTER_CLIENT_IP'])) return $_SERVER['HTTP_X_CLUSTER_CLIENT_IP']; if (!empty($_SERVER['HTTP_FORWARDED_FOR']) && validate_ip($_SERVER['HTTP_FORWARDED_FOR'])) return $_SERVER['HTTP_FORWARDED_FOR']; if (!empty($_SERVER['HTTP_FORWARDED']) && validate_ip($_SERVER['HTTP_FORWARDED'])) return $_SERVER['HTTP_FORWARDED']; // return unreliable ip since all else failed return $_SERVER['REMOTE_ADDR']; } function listing_get_detail($id = "", $options = array()) { if (empty($id)) { return FALSE; } $precheck = TRUE; if (!isset($options['x_table'])) { $precheck = FALSE; } if ($precheck) { $x_table = set_value_of($options['x_table'], $options['table']); $x_table_data = $x_table . "_data"; $data = querytorowarray("select * from `$x_table_data`" . " where id='$id' limit 1"); if (array_is_valid($data)) { $_options_format = array(); if (isset($options['cat'])) { $_options_format['cat'] = $options['cat']; } if (isset($options['category'])) { $_options_format['category'] = $options['category']; } if (isset($options['current_city'])) { $_options_format['current_city'] = $options['current_city']; } if (isset($options['current_state'])) { $_options_format['current_state'] = $options['current_state']; } if (isset($options['current_country'])) { $_options_format['current_country'] = $options['current_country']; } if (isset($options['current_longitude'])) { $_options_format['current_longitude'] = $options['current_longitude']; } if (isset($options['current_latitude'])) { $_options_format['current_latitude'] = $options['current_latitude']; } if (isset($options['address_formatter'])) { $_options_format['address_formatter'] = $options['address_formatter']; } $_options_format['table'] = $x_table; $data = __format_listing_item_data($data, $_options_format); return $data; } } return FALSE; } function url_title($str, $separator = 'dash', $lowercase = FALSE) { if ($separator == 'dash') { $search = '_'; $replace = '-'; } else { $search = '-'; $replace = '_'; } $trans = array( '&\#\d+?;' => '', '&\S+?;' => '', '\s+' => $replace, '\.' => $replace, '[^a-z0-9\-_]' => '', $replace . '+' => $replace, $replace . '$' => $replace, '^' . $replace => $replace, '\.+$' => '', ); $str = strip_tags($str); foreach ($trans as $key => $val) { $str = preg_replace("#" . $key . "#i", $val, $str); } if ($lowercase === TRUE) { $str = strtolower($str); } return trim(stripslashes($str), $replace); } function url_state_generate($options = array()) { $url_mapping = url_mapping_get(GeneralEnum::URL_MAPPING_TYPE_S); switch ($options['type']) { default: $href = "/" . $url_mapping . "/" . link_encode($options['state']) . "/" . link_encode($options['subcat_slug']); $text = $options['text']; break; case "301edback": $href = "/" . $url_mapping . "/" . link_encode($options['state']) . "/" . link_encode($options['subcat_slug']); $text = $options['text']; break; case "mainkeyword": $href = "/" . $url_mapping . "/" . link_encode($options['state']) . "/" . link_encode($options['main_keyword']) . "/" . link_encode($options['subcat_slug']); $text = $options['text']; break; case "sitemap": $href = "/" . $url_mapping . "/" . link_encode($options['state']) . "/" . $options['subcat_slug']; $text = $options['text']; break; case "sitemap_301": $href = "/" . $url_mapping . "/" . link_encode($options['state']) . "/" . $options['other']; $text = $options['text']; break; } if ($options['return_type'] == "href") { return $href; } if ($options['return_type'] == "text") { return $text; } $link = "" . $text . ""; return $link; } function url_cityorcounty_generate($options = array()) { return url_city_generate($options); } function url_categories_generate($options = array()) { return url_city_generate($options); } function url_geo_generate($options = array()) { return url_city_generate($options); } function url_tos_generate($options = array()) { $url_mapping = url_mapping_get(GeneralEnum::URL_MAPPING_TYPE_TOS); $href = "/" . $url_mapping; $text = "TOS"; if ($options['return_type'] == "href") { return $href; } if ($options['return_type'] == "text") { return $text; } $link = "" . $text . ""; return $link; } function url_privacypolicy_generate($options = array()) { $url_mapping = url_mapping_get(GeneralEnum::URL_MAPPING_TYPE_PRIVACY_POLICY); $href = "/" . $url_mapping; $text = "Privacy"; if ($options['return_type'] == "href") { return $href; } if ($options['return_type'] == "href_full") { $domain = (!empty($options['domain'])) ? $options['domain'] : __