X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=boot.php;h=cdb1b35edb8d2bdec0d0f080cd401055cba7d07b;hb=6a3815e751b013d2fba1e1de6df89566f971e39c;hp=925585d44acc6f23f87f0689d9cf4a474124a5b3;hpb=ce2f8c939da00f412eff0172c0e4ed4113dac34d;p=friendica.git
diff --git a/boot.php b/boot.php
index 925585d44a..cdb1b35edb 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'],'/');
@@ -163,6 +163,7 @@ class App {
if($this->cmd === '.well-known/host-meta')
require_once('include/hostxrd.php');
+
$this->pager['page'] = ((x($_GET,'page')) ? $_GET['page'] : 1);
$this->pager['itemspage'] = 50;
$this->pager['start'] = ($this->pager['page'] * $this->pager['itemspage']) - $this->pager['itemspage'];
@@ -355,10 +356,10 @@ function load_translation_table($lang) {
if(! function_exists('t')) {
function t($s) {
-
+
$a = get_app();
- if($a->strings[$s])
+ if(x($a->strings,$s))
return $a->strings[$s];
return $s;
}}
@@ -375,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
@@ -433,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);
@@ -620,6 +630,9 @@ function xml_status($st, $message = '') {
$xml_message = ((strlen($message)) ? "\t" . xmlify($message) . "\r\n" : '');
+ if($st)
+ logger('xml_status returning non_zero: ' . $st . " message=" . $message);
+
header( "Content-type: text/xml" );
echo ''."\r\n";
echo "\r\n\t$st\r\n$xml_message\r\n";
@@ -735,7 +748,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;
@@ -954,6 +967,7 @@ function webfinger_dfrn($s) {
return $s;
}
$links = webfinger($s);
+ logger('webfinger_dfrn: ' . $s . ':' . print_r($links,true), LOGGER_DATA);
if(count($links)) {
foreach($links as $link)
if($link['@attributes']['rel'] === NAMESPACE_DFRN)
@@ -978,6 +992,7 @@ function webfinger($s) {
}
if(strlen($host)) {
$tpl = fetch_lrdd_template($host);
+ logger('webfinger: lrdd template: ' . $tpl);
if(strlen($tpl)) {
$pxrd = str_replace('{uri}', urlencode('acct:'.$s), $tpl);
$links = fetch_xrd_links($pxrd);
@@ -1066,9 +1081,12 @@ function fetch_lrdd_template($host) {
if(! function_exists('fetch_xrd_links')) {
function fetch_xrd_links($url) {
+
$xml = fetch_url($url);
if (! $xml)
return array();
+
+ logger('fetch_xrd_links: ' . $xml, LOGGER_DATA);
$h = simplexml_load_string($xml);
$arr = convert_xml_element_to_array($h);
@@ -1145,13 +1163,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,
@@ -1268,7 +1298,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);
}}
@@ -1353,8 +1385,8 @@ function like_puller($a,$item,&$arr,$mode) {
$verb = (($mode === 'like') ? ACTIVITY_LIKE : ACTIVITY_DISLIKE);
if((activity_match($item['verb'],$verb)) && ($item['id'] != $item['parent'])) {
- $url = $item['url'];
- if(($item['network'] === 'dfrn') && (! $item['self'])) {
+ $url = $item['author-link'];
+ if(($item['network'] === 'dfrn') && (! $item['self']) && ($item['author-link'] == $item['url'])) {
$url = $a->get_baseurl() . '/redir/' . $item['contact-id'];
$sparkle = ' class="sparkle" ';
}
@@ -1364,7 +1396,7 @@ function like_puller($a,$item,&$arr,$mode) {
$arr[$item['parent']] = 1;
else
$arr[$item['parent']] ++;
- $arr[$item['parent'] . '-l'][] = '' . $item['name'] . '';
+ $arr[$item['parent'] . '-l'][] = '' . $item['author-name'] . '';
}
return;
}}
@@ -1390,7 +1422,7 @@ function contact_block() {
$a = get_app();
if((! is_array($a->profile)) || ($a->profile['hide-friends']))
return $o;
- $r = q("SELECT COUNT(*) AS `total` FROM `contact` WHERE `uid` = %d AND `self` = 0 ",
+ $r = q("SELECT COUNT(*) AS `total` FROM `contact` WHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 and `pending` = 0",
intval($a->profile['uid'])
);
if(count($r)) {
@@ -1420,10 +1452,43 @@ function contact_block() {
$o .= '
' . "\r\n";
}
$o .= '';
- $o .= '';
+ $o .= '';
}
return $o;
}}
+if(! function_exists('search')) {
+function search($s) {
+ $a = get_app();
+ $o = '';
+ $o .= '
';
+ 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;
+}}
+