Continued with #3010:

- removed added debug messages (maybe they will come back in accordance to
  code-style guidelines?)
- converted $a->get_baseurl() back to App::get_baseurl()
- reverted back other code I have touched/merged as this was double:
  (substr($url, 0, 4) !== 'http') on $url = 'https://bla'; will be FALSE
  (means found http at start), too.

Signed-off-by: Roland Häder <roland@mxchange.org>
This commit is contained in:
Roland Häder 2016-12-14 16:59:35 +01:00
parent 4b860e7575
commit 23d4db5149
5 changed files with 16 additions and 27 deletions

View File

@ -693,7 +693,7 @@
'follow_request_sent' => false, 'follow_request_sent' => false,
'statusnet_blocking' => false, 'statusnet_blocking' => false,
'notifications' => false, 'notifications' => false,
//'statusnet_profile_url' => $a->get_baseurl()."/contacts/".$uinfo[0]['cid'], //'statusnet_profile_url' => App::get_baseurl()."/contacts/".$uinfo[0]['cid'],
'statusnet_profile_url' => $uinfo[0]['url'], 'statusnet_profile_url' => $uinfo[0]['url'],
'uid' => intval($uinfo[0]['uid']), 'uid' => intval($uinfo[0]['uid']),
'cid' => intval($uinfo[0]['cid']), 'cid' => intval($uinfo[0]['cid']),
@ -1078,8 +1078,8 @@
if ($r) { if ($r) {
$phototypes = Photo::supportedTypes(); $phototypes = Photo::supportedTypes();
$ext = $phototypes[$r[0]['type']]; $ext = $phototypes[$r[0]['type']];
$_REQUEST['body'] .= "\n\n".'[url='.$a->get_baseurl().'/photos/'.$r[0]['nickname'].'/image/'.$r[0]['resource-id'].']'; $_REQUEST['body'] .= "\n\n".'[url='.App::get_baseurl().'/photos/'.$r[0]['nickname'].'/image/'.$r[0]['resource-id'].']';
$_REQUEST['body'] .= '[img]'.$a->get_baseurl()."/photo/".$r[0]['resource-id']."-".$r[0]['scale'].".".$ext."[/img][/url]"; $_REQUEST['body'] .= '[img]'.App::get_baseurl()."/photo/".$r[0]['resource-id']."-".$r[0]['scale'].".".$ext."[/img][/url]";
} }
} }
@ -2302,7 +2302,7 @@
$text = preg_replace_callback( $text = preg_replace_callback(
"|data:image/([^;]+)[^=]+=*|m", "|data:image/([^;]+)[^=]+=*|m",
function($match) use ($item) { function($match) use ($item) {
return $a->get_baseurl()."/display/".$item['guid']; return App::get_baseurl()."/display/".$item['guid'];
}, },
$text); $text);
return $text; return $text;
@ -2690,7 +2690,7 @@
$name = $a->config['sitename']; $name = $a->config['sitename'];
$server = $a->get_hostname(); $server = $a->get_hostname();
$logo = $a->get_baseurl() . '/images/friendica-64.png'; $logo = App::get_baseurl() . '/images/friendica-64.png';
$email = $a->config['admin_email']; $email = $a->config['admin_email'];
$closed = (($a->config['register_policy'] == REGISTER_CLOSED) ? 'true' : 'false'); $closed = (($a->config['register_policy'] == REGISTER_CLOSED) ? 'true' : 'false');
$private = (($a->config['system']['block_public']) ? 'true' : 'false'); $private = (($a->config['system']['block_public']) ? 'true' : 'false');
@ -2698,7 +2698,7 @@
if($a->config['api_import_size']) if($a->config['api_import_size'])
$texlimit = string($a->config['api_import_size']); $texlimit = string($a->config['api_import_size']);
$ssl = (($a->config['system']['have_ssl']) ? 'true' : 'false'); $ssl = (($a->config['system']['have_ssl']) ? 'true' : 'false');
$sslserver = (($ssl === 'true') ? str_replace('http:','https:',$a->get_baseurl()) : ''); $sslserver = (($ssl === 'true') ? str_replace('http:','https:',App::get_baseurl()) : '');
$config = array( $config = array(
'site' => array('name' => $name,'server' => $server, 'theme' => 'default', 'path' => '', 'site' => array('name' => $name,'server' => $server, 'theme' => 'default', 'path' => '',
@ -3075,7 +3075,7 @@
$photo['album'] = $rr['album']; $photo['album'] = $rr['album'];
$photo['filename'] = $rr['filename']; $photo['filename'] = $rr['filename'];
$photo['type'] = $rr['type']; $photo['type'] = $rr['type'];
$thumb = $a->get_baseurl()."/photo/".$rr['resource-id']."-".$rr['scale'].".".$typetoext[$rr['type']]; $thumb = App::get_baseurl()."/photo/".$rr['resource-id']."-".$rr['scale'].".".$typetoext[$rr['type']];
if ($type == "xml") if ($type == "xml")
$data['photo'][] = array("@attributes" => $photo, "1" => $thumb); $data['photo'][] = array("@attributes" => $photo, "1" => $thumb);
@ -3124,11 +3124,11 @@
for ($k=intval($data['photo']['minscale']); $k<=intval($data['photo']['maxscale']); $k++) for ($k=intval($data['photo']['minscale']); $k<=intval($data['photo']['maxscale']); $k++)
$data['photo']['links'][$k.":link"]["@attributes"] = array("type" => $data['photo']['type'], $data['photo']['links'][$k.":link"]["@attributes"] = array("type" => $data['photo']['type'],
"scale" => $k, "scale" => $k,
"href" => $a->get_baseurl()."/photo/".$data['photo']['resource-id']."-".$k.".".$typetoext[$data['photo']['type']]); "href" => App::get_baseurl()."/photo/".$data['photo']['resource-id']."-".$k.".".$typetoext[$data['photo']['type']]);
} else { } else {
$data['photo']['link'] = array(); $data['photo']['link'] = array();
for ($k=intval($data['photo']['minscale']); $k<=intval($data['photo']['maxscale']); $k++) { for ($k=intval($data['photo']['minscale']); $k<=intval($data['photo']['maxscale']); $k++) {
$data['photo']['link'][$k] = $a->get_baseurl()."/photo/".$data['photo']['resource-id']."-".$k.".".$typetoext[$data['photo']['type']]; $data['photo']['link'][$k] = App::get_baseurl()."/photo/".$data['photo']['resource-id']."-".$k.".".$typetoext[$data['photo']['type']];
} }
} }
unset($data['photo']['resource-id']); unset($data['photo']['resource-id']);

View File

@ -1525,7 +1525,7 @@ class dfrn {
"to_email" => $importer["email"], "to_email" => $importer["email"],
"uid" => $importer["importer_uid"], "uid" => $importer["importer_uid"],
"item" => $suggest, "item" => $suggest,
"link" => $a->get_baseurl()."/notifications/intros", "link" => App::get_baseurl()."/notifications/intros",
"source_name" => $importer["name"], "source_name" => $importer["name"],
"source_link" => $importer["url"], "source_link" => $importer["url"],
"source_photo" => $importer["photo"], "source_photo" => $importer["photo"],
@ -1792,8 +1792,6 @@ class dfrn {
* @param int $posted_id The record number of item record that was just posted * @param int $posted_id The record number of item record that was just posted
*/ */
private function do_poke($item, $importer, $posted_id) { private function do_poke($item, $importer, $posted_id) {
$a = get_app();
$verb = urldecode(substr($item["verb"],strpos($item["verb"], "#")+1)); $verb = urldecode(substr($item["verb"],strpos($item["verb"], "#")+1));
if(!$verb) if(!$verb)
return; return;
@ -1813,7 +1811,7 @@ class dfrn {
} }
} }
if($Blink && link_compare($Blink,$a->get_baseurl()."/profile/".$importer["nickname"])) { if($Blink && link_compare($Blink,App::get_baseurl()."/profile/".$importer["nickname"])) {
// send a notification // send a notification
notification(array( notification(array(
@ -1824,7 +1822,7 @@ class dfrn {
"to_email" => $importer["email"], "to_email" => $importer["email"],
"uid" => $importer["importer_uid"], "uid" => $importer["importer_uid"],
"item" => $item, "item" => $item,
"link" => $a->get_baseurl()."/display/".urlencode(get_item_guid($posted_id)), "link" => App::get_baseurl()."/display/".urlencode(get_item_guid($posted_id)),
"source_name" => stripslashes($item["author-name"]), "source_name" => stripslashes($item["author-name"]),
"source_link" => $item["author-link"], "source_link" => $item["author-link"],
"source_photo" => ((link_compare($item["author-link"],$importer["url"])) "source_photo" => ((link_compare($item["author-link"],$importer["url"]))

View File

@ -721,7 +721,7 @@ function check_item_notification($itemid, $uid, $defaulttype = "") {
$params["to_email"] = $user[0]["email"]; $params["to_email"] = $user[0]["email"];
$params["item"] = $item[0]; $params["item"] = $item[0];
$params["parent"] = $item[0]["parent"]; $params["parent"] = $item[0]["parent"];
$params["link"] = $a->get_baseurl().'/display/'.urlencode($item[0]["guid"]); $params["link"] = App::get_baseurl().'/display/'.urlencode($item[0]["guid"]);
$params["otype"] = 'item'; $params["otype"] = 'item';
$params["source_name"] = $item[0]["author-name"]; $params["source_name"] = $item[0]["author-name"];
$params["source_link"] = $item[0]["author-link"]; $params["source_link"] = $item[0]["author-link"];

View File

@ -590,7 +590,7 @@ function process_events ($arr) {
$is_first = ($d !== $last_date); $is_first = ($d !== $last_date);
$last_date = $d; $last_date = $d;
$edit = ((! $rr['cid']) ? array($a->get_baseurl().'/events/event/'.$rr['id'],t('Edit event'),'','') : null); $edit = ((! $rr['cid']) ? array(App::get_baseurl().'/events/event/'.$rr['id'],t('Edit event'),'','') : null);
$title = strip_tags(html_entity_decode(bbcode($rr['summary']),ENT_QUOTES,'UTF-8')); $title = strip_tags(html_entity_decode(bbcode($rr['summary']),ENT_QUOTES,'UTF-8'));
if(! $title) { if(! $title) {
list($title, $_trash) = explode("<br",bbcode($rr['desc']),2); list($title, $_trash) = explode("<br",bbcode($rr['desc']),2);

View File

@ -388,32 +388,23 @@ function http_status_exit($val, $description = array()) {
* @return boolean True if it's a valid URL, fals if something wrong with it * @return boolean True if it's a valid URL, fals if something wrong with it
*/ */
function validate_url(&$url) { function validate_url(&$url) {
logger(sprintf('[%s:%d]: url=%s - CALLED!', __FUNCTION__, __LINE__, $url), LOGGER_TRACE);
if(get_config('system','disable_url_validation')) if(get_config('system','disable_url_validation'))
logger(sprintf('[%s:%d]: URL validation disabled, returning TRUE - EXIT!', __FUNCTION__, __LINE__), LOGGER_TRACE);
return true; return true;
// no naked subdomains (allow localhost for tests) // no naked subdomains (allow localhost for tests)
if(strpos($url,'.') === false && strpos($url,'/localhost/') === false) if(strpos($url,'.') === false && strpos($url,'/localhost/') === false)
logger(sprintf('[%s:%d]: URL is not complete, returning FALSE - EXIT!', __FUNCTION__, __LINE__), LOGGER_TRACE);
return false; return false;
if(substr($url,0,4) != 'http' && substr($url,0,5) != 'https') if(substr($url,0,4) != 'http')
$url = 'http://' . $url; $url = 'http://' . $url;
logger(sprintf('[%s:%d]: url=%s - before parse_url() ...', __FUNCTION__, __LINE__, $url), LOGGER_DEBUG); // @TODO Really supress function outcomes? Why not find them + debug them?
$h = @parse_url($url); $h = @parse_url($url);
logger(sprintf('[%s:%d]: h[]=%s', __FUNCTION__, __LINE__, gettype($h)), LOGGER_DEBUG);
if((is_array($h)) && (dns_get_record($h['host'], DNS_A + DNS_CNAME + DNS_PTR) || filter_var($h['host'], FILTER_VALIDATE_IP) )) { if((is_array($h)) && (dns_get_record($h['host'], DNS_A + DNS_CNAME + DNS_PTR) || filter_var($h['host'], FILTER_VALIDATE_IP) )) {
logger(sprintf('[%s:%d]: URL %s validated. - EXIT!', __FUNCTION__, __LINE__, $url), LOGGER_TRACE);
return true; return true;
} }
logger(sprintf('[%s:%d]: URL %s maybe not valid - EXIT!', __FUNCTION__, __LINE__, $url), LOGGER_TRACE);
return false; return false;
} }