From b28b468b2182493b958afecb388501fd66de230f Mon Sep 17 00:00:00 2001 From: Friendika Date: Tue, 16 Aug 2011 20:05:02 -0700 Subject: [PATCH] cleanup --- boot.php | 4 ++-- include/network.php | 32 +++++++++++++++++++++----------- include/notifier.php | 4 ++-- include/oembed.php | 3 ++- include/text.php | 4 ++++ mod/display.php | 2 +- mod/network.php | 3 +-- mod/profile.php | 3 +-- mod/register.php | 2 +- mod/search.php | 1 + view/register.tpl | 3 ++- 11 files changed, 38 insertions(+), 23 deletions(-) diff --git a/boot.php b/boot.php index 7186ce7c68..39bb6a9dac 100644 --- a/boot.php +++ b/boot.php @@ -7,13 +7,13 @@ require_once('include/text.php'); require_once("include/pgettext.php"); -define ( 'FRIENDIKA_VERSION', '2.2.1073' ); +define ( 'FRIENDIKA_VERSION', '2.2.1074' ); define ( 'DFRN_PROTOCOL_VERSION', '2.21' ); define ( 'DB_UPDATE_VERSION', 1079 ); define ( 'EOL', "
\r\n" ); define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' ); -define ( 'DOWN_ARROW', '⇩' ); + /** * diff --git a/include/network.php b/include/network.php index ddfc349778..9871b9edcd 100644 --- a/include/network.php +++ b/include/network.php @@ -5,7 +5,7 @@ // results. if(! function_exists('fetch_url')) { -function fetch_url($url,$binary = false, &$redirects = 0) { +function fetch_url($url,$binary = false, &$redirects = 0, $timeout = 0) { $a = get_app(); @@ -17,9 +17,13 @@ function fetch_url($url,$binary = false, &$redirects = 0) { curl_setopt($ch, CURLOPT_RETURNTRANSFER,true); curl_setopt($ch, CURLOPT_USERAGENT, "Friendika"); - $curl_time = intval(get_config('system','curl_timeout')); - curl_setopt($ch, CURLOPT_TIMEOUT, (($curl_time !== false) ? $curl_time : 60)); - + if(intval($timeout)) { + curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); + } + else { + $curl_time = intval(get_config('system','curl_timeout')); + curl_setopt($ch, CURLOPT_TIMEOUT, (($curl_time !== false) ? $curl_time : 60)); + } // by default we will allow self-signed certs // but you can override this @@ -66,7 +70,7 @@ function fetch_url($url,$binary = false, &$redirects = 0) { $url_parsed = @parse_url($url); if (isset($url_parsed)) { $redirects++; - return fetch_url($url,$binary,$redirects); + return fetch_url($url,$binary,$redirects,$timeout); } } @@ -83,7 +87,7 @@ function fetch_url($url,$binary = false, &$redirects = 0) { // post request to $url. $params is an array of post variables. if(! function_exists('post_url')) { -function post_url($url,$params, $headers = null, &$redirects = 0) { +function post_url($url,$params, $headers = null, &$redirects = 0, $timeout = 0) { $a = get_app(); $ch = curl_init($url); if(($redirects > 8) || (! $ch)) @@ -95,8 +99,13 @@ function post_url($url,$params, $headers = null, &$redirects = 0) { curl_setopt($ch, CURLOPT_POSTFIELDS,$params); curl_setopt($ch, CURLOPT_USERAGENT, "Friendika"); - $curl_time = intval(get_config('system','curl_timeout')); - curl_setopt($ch, CURLOPT_TIMEOUT, (($curl_time !== false) ? $curl_time : 60)); + if(intval($timeout)) { + curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); + } + else { + $curl_time = intval(get_config('system','curl_timeout')); + curl_setopt($ch, CURLOPT_TIMEOUT, (($curl_time !== false) ? $curl_time : 60)); + } if(defined('LIGHTTPD')) { if(!is_array($headers)) { @@ -150,7 +159,7 @@ function post_url($url,$params, $headers = null, &$redirects = 0) { $url_parsed = @parse_url($url); if (isset($url_parsed)) { $redirects++; - return post_url($url,$binary,$headers,$redirects); + return post_url($url,$params,$headers,$redirects,$timeout); } } $a->set_curl_code($http_code); @@ -497,8 +506,9 @@ function fetch_lrdd_template($host) { if(! function_exists('fetch_xrd_links')) { function fetch_xrd_links($url) { - - $xml = fetch_url($url); + $xrd_timeout = intval(get_config('system','xrd_timeout')); + $redirects = 0; + $xml = fetch_url($url,false,$redirects,(($xrd_timeout) ? $xrd_timeout : 30)); logger('fetch_xrd_links: ' . $xml, LOGGER_DATA); diff --git a/include/notifier.php b/include/notifier.php index 332cd19e36..b8aa07dc75 100644 --- a/include/notifier.php +++ b/include/notifier.php @@ -557,7 +557,7 @@ function notifier_run($argv, $argc){ * */ - $max_allowed = ((get_config('system','maxpubdeliver') === false) ? 150 : intval(get_config('system','maxpubdeliver'))); + $max_allowed = ((get_config('system','maxpubdeliver') === false) ? 999 : intval(get_config('system','maxpubdeliver'))); /** * @@ -567,7 +567,7 @@ function notifier_run($argv, $argc){ */ $r = q("SELECT `id`, `name` FROM `contact` - WHERE `network` = 'dfrn' AND `uid` = %d AND `blocked` = 0 AND `pending` = 0 + WHERE `network` = NETWORK_DFRN AND `uid` = %d AND `blocked` = 0 AND `pending` = 0 AND `rel` != %d ", intval($owner['uid']), intval(CONTACT_IS_SHARING) diff --git a/include/oembed.php b/include/oembed.php index b325a766e3..06f71a3b32 100644 --- a/include/oembed.php +++ b/include/oembed.php @@ -17,7 +17,8 @@ function oembed_fetch_url($embedurl){ $txt = ""; // try oembed autodiscovery - $html_text = fetch_url($embedurl); + $redirects = 0; + $html_text = fetch_url($embedurl, false, $redirects, 15); if(! $html_text) return; $dom = @DOMDocument::loadHTML($html_text); diff --git a/include/text.php b/include/text.php index aeb20bb0f9..803bf0e510 100644 --- a/include/text.php +++ b/include/text.php @@ -948,3 +948,7 @@ function base64url_decode($s) { return base64_decode(strtr($s,'-_','+/')); } + +function cc_license() { +return '
' . t('Shared content is covered by the Creative Commons Attribution 3.0 license.') . '
'; +} diff --git a/mod/display.php b/mod/display.php index 159ff57edf..52a84e755e 100644 --- a/mod/display.php +++ b/mod/display.php @@ -114,7 +114,7 @@ function display_content(&$a) { } - $o .= '
' . t('Shared content is covered by the Creative Commons Attribution 3.0 license.') . '
'; + $o .= cc_license(); return $o; } diff --git a/mod/network.php b/mod/network.php index 7bdd3f3f10..05b74b50a4 100644 --- a/mod/network.php +++ b/mod/network.php @@ -297,9 +297,8 @@ function network_content(&$a, $update = 0) { $o .= conversation($a,$r,$mode,$update); if(! $update) { - $o .= paginate($a); - $o .= '
' . t('Shared content is covered by the Creative Commons Attribution 3.0 license.') . '
'; + $o .= cc_license(); } return $o; diff --git a/mod/profile.php b/mod/profile.php index 71912458f1..a4c6ea7107 100644 --- a/mod/profile.php +++ b/mod/profile.php @@ -236,9 +236,8 @@ function profile_content(&$a, $update = 0) { $o .= conversation($a,$r,'profile',$update); if(! $update) { - $o .= paginate($a); - $o .= '
' . t('Shared content is covered by the Creative Commons Attribution 3.0 license.') . '
'; + $o .= cc_license(); } return $o; diff --git a/mod/register.php b/mod/register.php index fbd21a567f..5fceebd4bd 100644 --- a/mod/register.php +++ b/mod/register.php @@ -501,7 +501,7 @@ function register_content(&$a) { } - $license = t('Shared content is covered by the Creative Commons Attribution 3.0 license.'); + $license = cc_license(); $o = get_markup_template("register.tpl"); diff --git a/mod/search.php b/mod/search.php index 9b465c0e52..88ff9bbb73 100644 --- a/mod/search.php +++ b/mod/search.php @@ -91,6 +91,7 @@ function search_content(&$a) { $o .= conversation($a,$r,'search',false); $o .= paginate($a); + $o .= cc_license(); return $o; } diff --git a/view/register.tpl b/view/register.tpl index 16e8ba7675..8ce1d20acb 100644 --- a/view/register.tpl +++ b/view/register.tpl @@ -57,5 +57,6 @@
-
$license
+$license +