$dummy2 = array(); if (array_is_valid($dummy)) { foreach ($dummy as $idummy) { $dummy2[] = $idummy['COLUMN_NAME']; } $dummy2 = array_values(array_unique($dummy2)); } $instance[$instanceKey] = $dummy2; } return $instance[$instanceKey]; } function query($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); $row_rsdummy = @mysql_fetch_assoc($rsdummy); $totalRows_rsdummy = @mysql_num_rows($rsdummy); $data = array($row_rsdummy, $rsdummy, $totalRows_rsdummy); return $data; break; case "mysqli": try { $rsdummy = mysqli_query($__connection, $query_rsdummy); // For queries that don't return results (INSERT, UPDATE, DELETE, SET, etc.) if ($rsdummy === TRUE) { return array(NULL, TRUE, 0); } /* if ($rsdummy && $rsdummy instanceof mysqli_result) { $row_rsdummy = @mysqli_fetch_assoc($rsdummy); dump($row_rsdummy); $totalRows_rsdummy = @mysqli_num_rows($rsdummy); $data = array($row_rsdummy, $rsdummy, $totalRows_rsdummy); } // Query failed return false; */ $row_rsdummy = @mysqli_fetch_assoc($rsdummy); $totalRows_rsdummy = @mysqli_num_rows($rsdummy); $data = array($row_rsdummy, $rsdummy, $totalRows_rsdummy); return $data; } catch (mysqli_sql_exception $e) { //echo "Error: " . $e->getMessage(); } break; } return FALSE; } function crud_get_row_case_senstive($table = "", $id = FALSE, $options = array()) { if (empty($table) || empty($id)) { return FALSE; } $primary_key = isset($options['primary_key']) ? $options['primary_key'] : 'id'; $connection = (!empty($options['connection'])) ? $options['connection'] : FALSE; if (!empty($connectionOverride = connection_override())) { $connection = $connectionOverride; } // Handle case sensitivity $useBinary = "BINARY "; // Prepare query $query = "SELECT * FROM `$table` WHERE {$useBinary}{$primary_key} = '$id'"; // Execute if (!$connection) { $row = querytorowarray($query); } else { $row = querytorowarray($query, ["connection" => $connection]); } return array_is_valid($row) ? $row : FALSE; } function crud_get_row($table = "", $id = FALSE, $options = array()) { if (empty($table)) { return FALSE; } if (empty($id)) { return FALSE; } $primary_key = 'id'; if (isset($options['primary_key'])) { $primary_key = $options['primary_key']; } $connection = (!empty($options['connection'])) ? $options['connection'] : FALSE; if (!empty($connectionOverride = connection_override())) { $connection = $connectionOverride; } if (!$connection) { $row = querytorowarray("select * from `$table` where $primary_key='$id'"); } else { $optionsAction = ["connection" => $connection]; $row = querytorowarray("select * from `$table` where $primary_key='$id'", $optionsAction); } if (array_is_valid($row)) { return $row; } return FALSE; } function crud_get_row_by($table = "", $column = "", $value = NULL, $options = array()) { if (empty($table)) { return FALSE; } if (empty($column)) { return FALSE; } $row = querytorowarray("select * from `$table` where $column='$value'"); if (array_is_valid($row)) { return $row; } return FALSE; } function crud_update_row($table = "", $id = FALSE, $data = array(), $options = array()) { if (empty($table)) { return FALSE; } if (empty($id)) { return FALSE; } $connection = (!empty($options['connection'])) ? $options['connection'] : FALSE; if (!empty($connectionOverride = connection_override())) { $connection = $connectionOverride; } if (!$connection) { $dbColumns = column_name($table, config_get("db_database")); } else { $dbColumns = column_name_extended($table, "", ["connection" => $connection]); } if (array_is_valid($dbColumns)) { foreach ($dbColumns as $k => $v) { if (array_key_exists($v, $data)) { $ins[$v] = $data[$v]; } } if (array_is_valid($ins)) { $primary_key = 'id'; if (isset($options['primary_key'])) { $primary_key = $options['primary_key']; } $sql = "update `$table` set "; $sql_set = ""; $sql_where = " where $primary_key = " . "'" . $id . "'"; foreach ($ins as $k => $v) { $v = \App\CRUD::valueEscape($v, ["value_escape_type" => $options['value_escape_type'], "connection" => $connection]); $sql_set .= "`" . $k . "` = '" . $v . "',"; } $sql_set = trim(rtrim($sql_set, ",")); if (!empty($sql_set) && !empty($sql_where)) { $sql = $sql . $sql_set . $sql_where; if (!$connection) { query_update($sql); if (query_affected_rows() > 0) { return TRUE; } } else { query_update($sql, ["connection" => $connection]); if (query_affected_rows(["connection" => $connection]) > 0) { return TRUE; } } } } } } function crud_query($sql, $options = array()) { if (empty($sql)) { return FALSE; } $connection = (!empty($options['connection'])) ? $options['connection'] : FALSE; if (!$connection) { query_update($sql); if (query_affected_rows() > 0) { return TRUE; } } else { query_update($sql, ["connection" => $connection]); if (query_affected_rows(["connection" => $connection]) > 0) { return TRUE; } } } function connection_override_enable($enabled = FALSE) { static $override_enabled = FALSE; if (func_num_args() > 0) { $override_enabled = $enabled; } return $override_enabled; } function connection_override() { if (\App\Gears\GearsV2Testing::is_connection_override() && is_testing_local()) { if (connection_override_enable() === TRUE) { return db_connect_test(); } } return FALSE; // Check if the override is enabled globally if (!connection_override_enable()) { return FALSE; } // Test if it's a local environment if (is_testing_local()) { return db_connect_test(); } return FALSE; } function crud_insert($table = "", $data = array(), $options = array()) { if (empty($table)) { return FALSE; } if (array_is_valid($data)) { $connection = (!empty($options['connection'])) ? $options['connection'] : FALSE; if (!empty($connectionOverride = connection_override())) { $connection = $connectionOverride; } 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']; if (isset($options['connection'])) { $__connection = $options['connection']; } $__mysql_driver = config_get("mysql_driver"); switch ($__mysql_driver) { default: case "mysql": $id = mysql_insert_id($__connection); break; case "mysqli": $id = mysqli_insert_id($__connection); break; } 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": try { $rsdummy = mysqli_query($__connection, $query_rsdummy); $rid = mysqli_insert_id($__connection); if (is_numeric($rid)) { return $rid; } } catch (mysqli_sql_exception $e) { } 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": try { $rsdummy = mysqli_query($__connection, $query_rsdummy); if ($rsdummy !== FALSE) { return TRUE; } } catch (mysqli_sql_exception $e) { } 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": try { $result = mysqli_query($__connection, $sql); $data = mysqli_fetch_assoc($result); return $data; } catch (mysqli_sql_exception $e) { //echo "Error: " . $e->getMessage(); } 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": try { $r = mysqli_query($__connection, $sql); $data = mysqli_num_rows($r); return $data; } catch (mysqli_sql_exception $e) { //echo "Error: " . $e->getMessage(); } 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 FALS