X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=boot.php;h=f0d40544f4ff0e066bda9b35bc294c9145d0ef56;hb=c2086ec50ed339fb864c8f0a93fbc40ff530c666;hp=948cca46dc1383be8b466ab3a205907cde103974;hpb=7be66b1d91f80c3cee0ed6f08392c3f3f1bffc1e;p=friendica.git diff --git a/boot.php b/boot.php index 948cca46dc..f0d40544f4 100644 --- a/boot.php +++ b/boot.php @@ -2,7 +2,7 @@ set_time_limit(0); -define ( 'BUILD_ID', 1016 ); +define ( 'BUILD_ID', 1017 ); define ( 'DFRN_PROTOCOL_VERSION', '2.0' ); define ( 'EOL', "
\r\n" ); @@ -145,7 +145,7 @@ class App { set_include_path("include/$this->hostname" . PATH_SEPARATOR . 'include' . PATH_SEPARATOR . '.' ); - if((x($_SERVER,'QUERY_STRING')) && substr($_SERVER['QUERY_STRING'],0,2) == "q=") + if((x($_SERVER,'QUERY_STRING')) && substr($_SERVER['QUERY_STRING'],0,2) === "q=") $_SERVER['QUERY_STRING'] = substr($_SERVER['QUERY_STRING'],2); if(x($_GET,'q')) $this->cmd = trim($_GET['q'],'/'); @@ -376,6 +376,11 @@ function fetch_url($url,$binary = false, &$redirects = 0) { curl_setopt($ch, CURLOPT_HEADER, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER,true); + + $curl_time = intval(get_config('system','curl_timeout')); + if($curl_time) + curl_setopt($ch, CURLOPT_TIMEOUT, $curl_time); + // by default we will allow self-signed certs // but you can override this @@ -434,6 +439,10 @@ function post_url($url,$params, $headers = null, &$redirects = 0) { curl_setopt($ch, CURLOPT_POST,1); curl_setopt($ch, CURLOPT_POSTFIELDS,$params); + $curl_time = intval(get_config('system','curl_timeout')); + if($curl_time) + curl_setopt($ch, CURLOPT_TIMEOUT, $curl_time); + if(is_array($headers)) curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); @@ -736,7 +745,7 @@ function hex2bin($s) { if(! function_exists('paginate')) { function paginate(&$a) { $o = ''; - $stripped = ereg_replace("(&page=[0-9]*)","",$_SERVER['QUERY_STRING']); + $stripped = preg_replace('/(&page=[0-9]*)/','',$_SERVER['QUERY_STRING']); $stripped = str_replace('q=','',$stripped); $stripped = trim($stripped,'/'); $url = $a->get_baseurl() . '/' . $stripped; @@ -1151,13 +1160,25 @@ function validate_url(&$url) { $url = 'http://' . $url; $h = parse_url($url); - if(! $h) { - return false; + if(($h) && (checkdnsrr($h['host'], 'ANY'))) { + return true; } - if(! checkdnsrr($h['host'], 'ANY')) { + return false; +}} + +// checks that email is an actual resolvable internet address + +if(! function_exists('validate_email')) { +function validate_email($addr) { + + if(! strpos($addr,'@')) return false; + $h = substr($addr,strpos($addr,'@') + 1); + + if(($h) && (checkdnsrr($h, 'ANY'))) { + return true; } - return true; + return false; }} // Check $url against our list of allowed sites, @@ -1274,7 +1295,9 @@ function load_view_file($s) { $b = basename($s); $d = dirname($s); $lang = get_config('system','language'); - if($lang && file_exists("$d/$lang/$b")) + if($lang === false) + $lang = 'en'; + if(file_exists("$d/$lang/$b")) return file_get_contents("$d/$lang/$b"); return file_get_contents($s); }} @@ -1444,3 +1467,25 @@ function search($s) { return $o; }} +if(! function_exists('valid_email')) { +function valid_email($x){ + if(preg_match('/^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)+$/',$x)) + return true; + return false; +}} + + +if(! function_exists('gravatar_img')) { +function gravatar_img($email) { + $size = 175; + $opt = 'identicon'; // psuedo-random geometric pattern if not found + $rating = 'pg'; + $hash = md5(trim(strtolower($email))); + + $url = 'http://www.gravatar.com/avatar/' . $hash . '.jpg' + . '?s=' . $size . '&d=' . $opt . '&r=' . $rating; + + logger('gravatar: ' . $email . ' ' . $url); + return $url; +}} +