From a3f08c44be78d4517e9f1619811def09b2ec7e7a Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Sun, 22 Apr 2012 18:00:24 +0200 Subject: [PATCH 01/35] API: RSS-Feeds are now shortened to 1000 characters. (With added link) --- include/api.php | 93 +++++++++++++++++++++++++------------------------ 1 file changed, 48 insertions(+), 45 deletions(-) diff --git a/include/api.php b/include/api.php index 0885a1434b..11494ba278 100644 --- a/include/api.php +++ b/include/api.php @@ -4,26 +4,26 @@ require_once("conversation.php"); require_once("oauth.php"); require_once("html2plain.php"); - /* + /* * Twitter-Like API - * + * */ $API = Array(); - $called_api = Null; + $called_api = Null; function api_date($str){ //Wed May 23 06:01:13 +0000 2007 return datetime_convert('UTC', 'UTC', $str, "D M d H:i:s +0000 Y" ); } - - + + function api_register_func($path, $func, $auth=false){ global $API; $API[$path] = array('func'=>$func, 'auth'=>$auth); } - + /** * Simple HTTP Login */ @@ -682,24 +682,24 @@ 'geo' => '', 'coordinates' => $lastwall['coord'], 'place' => $lastwall['location'], - 'contributors' => '' + 'contributors' => '' ); } return api_apply_template("user", $type, array('$user' => $user_info)); - + } api_register_func('api/users/show','api_users_show'); - + /** - * + * * http://developer.twitter.com/doc/get/statuses/home_timeline - * + * * TODO: Optional parameters * TODO: Add reply info */ function api_statuses_home_timeline(&$a, $type){ if (local_user()===false) return false; - + $user_info = api_get_user($a); // get last newtork messages @@ -711,7 +711,7 @@ $since_id = (x($_REQUEST,'since_id')?$_REQUEST['since_id']:0); $max_id = (x($_REQUEST,'max_id')?$_REQUEST['max_id']:0); //$since_id = 0;//$since_id = (x($_REQUEST,'since_id')?$_REQUEST['since_id']:0); - + $start = $page*$count; //$include_entities = (x($_REQUEST,'include_entities')?$_REQUEST['include_entities']:false); @@ -719,7 +719,7 @@ if ($max_id > 0) $sql_extra = 'AND `item`.`id` <= '.intval($max_id); - $r = q("SELECT `item`.*, `item`.`id` AS `item_id`, + $r = q("SELECT `item`.*, `item`.`id` AS `item_id`, `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`, `contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`, `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid` @@ -738,7 +738,7 @@ $ret = api_format_items($r,$user_info); - + $data = array('$statuses' => $ret); switch($type){ case "atom": @@ -752,7 +752,7 @@ return($as); break; } - + return api_apply_template("timeline", $type, $data); } api_register_func('api/statuses/home_timeline','api_statuses_home_timeline', true); @@ -760,7 +760,7 @@ function api_statuses_public_timeline(&$a, $type){ if (local_user()===false) return false; - + $user_info = api_get_user($a); // get last newtork messages @@ -772,7 +772,7 @@ $since_id = (x($_REQUEST,'since_id')?$_REQUEST['since_id']:0); $max_id = (x($_REQUEST,'max_id')?$_REQUEST['max_id']:0); //$since_id = 0;//$since_id = (x($_REQUEST,'since_id')?$_REQUEST['since_id']:0); - + $start = $page*$count; //$include_entities = (x($_REQUEST,'include_entities')?$_REQUEST['include_entities']:false); @@ -780,7 +780,7 @@ if ($max_id > 0) $sql_extra = 'AND `item`.`id` <= '.intval($max_id); - /*$r = q("SELECT `item`.*, `item`.`id` AS `item_id`, + /*$r = q("SELECT `item`.*, `item`.`id` AS `item_id`, `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`, `contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`, `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid` @@ -797,17 +797,17 @@ intval($since_id), intval($start), intval($count) );*/ - $r = q("SELECT `item`.*, `item`.`id` AS `item_id`, + $r = q("SELECT `item`.*, `item`.`id` AS `item_id`, `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`, - `contact`.`network`, `contact`.`thumb`, `contact`.`self`, `contact`.`writable`, + `contact`.`network`, `contact`.`thumb`, `contact`.`self`, `contact`.`writable`, `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`, `user`.`nickname`, `user`.`hidewall` FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` LEFT JOIN `user` ON `user`.`uid` = `item`.`uid` WHERE `item`.`visible` = 1 AND `item`.`deleted` = 0 and `item`.`moderated` = 0 - AND `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' - AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = '' - AND `item`.`private` = 0 AND `item`.`wall` = 1 AND `user`.`hidewall` = 0 + AND `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' + AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = '' + AND `item`.`private` = 0 AND `item`.`wall` = 1 AND `user`.`hidewall` = 0 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 $sql_extra AND `item`.`id`>%d @@ -818,7 +818,7 @@ $ret = api_format_items($r,$user_info); - + $data = array('$statuses' => $ret); switch($type){ case "atom": @@ -832,7 +832,7 @@ return($as); break; } - + return api_apply_template("timeline", $type, $data); } api_register_func('api/statuses/public_timeline','api_statuses_public_timeline', true); @@ -848,11 +848,11 @@ // params $id = intval($a->argv[3]); - logger('API: api_statuses_show: '.$id); + logger('API: api_statuses_show: '.$id); //$include_entities = (x($_REQUEST,'include_entities')?$_REQUEST['include_entities']:false); - $r = q("SELECT `item`.*, `item`.`id` AS `item_id`, + $r = q("SELECT `item`.*, `item`.`id` AS `item_id`, `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`, `contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`, `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid` @@ -866,7 +866,7 @@ ); $ret = api_format_items($r,$user_info); - + $data = array('$status' => $ret[0]); /*switch($type){ case "atom": @@ -1004,7 +1004,7 @@ $ret = api_format_items($r,$user_info); - + $data = array('$statuses' => $ret); switch($type){ case "atom": @@ -1018,7 +1018,7 @@ return($as); break; } - + return api_apply_template("timeline", $type, $data); } api_register_func('api/statuses/mentions','api_statuses_mentions', true); @@ -1069,14 +1069,14 @@ $ret = api_format_items($r,$user_info); - + $data = array('$statuses' => $ret); switch($type){ case "atom": case "rss": $data = api_rss_extra($a, $data, $user_info); } - + return api_apply_template("timeline", $type, $data); } @@ -1085,25 +1085,25 @@ function api_favorites(&$a, $type){ if (local_user()===false) return false; - + $user_info = api_get_user($a); // in friendica starred item are private // return favorites only for self logger('api_favorites: self:' . $user_info['self']); - + if ($user_info['self']==0) { $ret = array(); } else { - - + + // params $count = (x($_GET,'count')?$_GET['count']:20); $page = (x($_REQUEST,'page')?$_REQUEST['page']-1:0); if ($page<0) $page=0; - + $start = $page*$count; - $r = q("SELECT `item`.*, `item`.`id` AS `item_id`, + $r = q("SELECT `item`.*, `item`.`id` AS `item_id`, `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`, `contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`, `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid` @@ -1120,16 +1120,16 @@ ); $ret = api_format_items($r,$user_info); - + } - + $data = array('$statuses' => $ret); switch($type){ case "atom": case "rss": $data = api_rss_extra($a, $data, $user_info); } - + return api_apply_template("timeline", $type, $data); } @@ -1199,7 +1199,7 @@ $as['link']['type'] = "text/html"; return($as); } - + function api_format_items($r,$user_info) { //logger('api_format_items: ' . print_r($r,true)); @@ -1214,14 +1214,14 @@ $status_user = (($item['cid']==$user_info['id'])?$user_info: api_item_get_user($a,$item)); if ($item['parent']!=$item['id']) { - $r = q("select id from item where parent=%s and id<%s order by id desc limit 1", + $r = q("select id from item where parent=%s and id<%s order by id desc limit 1", intval($item['parent']), intval($item['id'])); if ($r) $in_reply_to_status_id = $r[0]['id']; else $in_reply_to_status_id = $item['parent']; - $r = q("select `item`.`contact-id`, `contact`.nick, `item`.`author-name` from item, contact + $r = q("select `item`.`contact-id`, `contact`.nick, `item`.`author-name` from item, contact where `contact`.`id` = `item`.`contact-id` and `item`.id=%d", intval($in_reply_to_status_id)); $in_reply_to_screen_name = $r[0]['author-name']; @@ -1242,6 +1242,9 @@ else $statustext = trim($statustitle."\n\n".$statusbody); + if (($item["network"] == NETWORK_FEED) and (strlen($statustext)> 1000)) + $statustext = substr($statustext, 0, 1000)."... \n".$item["plink"]; + $status = array( 'text' => $statustext, 'truncated' => False, From 8c80fe0bf51fa472ddf9bf225490e47ea1bf4a7f Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Sun, 20 May 2012 00:11:32 +0200 Subject: [PATCH 02/35] Performance tests --- include/config.php | 2 +- include/dba.php | 20 ++++++++++++-------- mod/network.php | 2 +- view/theme/diabook/theme.php | 5 +++++ 4 files changed, 19 insertions(+), 10 deletions(-) diff --git a/include/config.php b/include/config.php index 4cff38090c..e416bec6e1 100644 --- a/include/config.php +++ b/include/config.php @@ -6,7 +6,7 @@ * Note: * Please do not store booleans - convert to 0/1 integer values * The get_?config() functions return boolean false for keys that are unset, - * and this could lead to subtle bugs. + * and this could lead to subtle bugs. * * There are a few places in the code (such as the admin panel) where boolean * configurations need to be fixed as of 10/08/2011. diff --git a/include/dba.php b/include/dba.php index c9f880241b..7ecce72704 100644 --- a/include/dba.php +++ b/include/dba.php @@ -32,9 +32,9 @@ class dba { if (!(strlen($server) && strlen($user))){ $this->connected = false; $this->db = null; - return; + return; } - + if($install) { if(strlen($server) && ($server !== 'localhost') && ($server !== '127.0.0.1')) { if(! dns_get_record($server, DNS_A + DNS_CNAME + DNS_PTR)) { @@ -71,23 +71,27 @@ class dba { } public function q($sql) { - + if((! $this->db) || (! $this->connected)) return false; - + $this->error = ''; + //@file_put_contents("/tmp/friendica-db.log", datetime_convert().':'.session_id(). ' Start '.$sql."\n", FILE_APPEND); + if($this->mysqli) $result = @$this->db->query($sql); else $result = @mysql_query($sql,$this->db); + //@file_put_contents("/tmp/friendica-db.log", datetime_convert().':'.session_id(). ' Stop '."\n", FILE_APPEND); + if($this->mysqli) { if($this->db->errno) $this->error = $this->db->error; } elseif(mysql_errno($this->db)) - $this->error = mysql_error($this->db); + $this->error = mysql_error($this->db); if(strlen($this->error)) { logger('dba: ' . $this->error); @@ -107,8 +111,8 @@ class dba { else $mesg = mysql_num_rows($result) . ' results' . EOL; } - - $str = 'SQL = ' . printable($sql) . EOL . 'SQL returned ' . $mesg + + $str = 'SQL = ' . printable($sql) . EOL . 'SQL returned ' . $mesg . (($this->error) ? ' error: ' . $this->error : '') . EOL; @@ -146,7 +150,7 @@ class dba { } } - + if($this->debug) logger('dba: ' . printable(print_r($r, true))); return($r); diff --git a/mod/network.php b/mod/network.php index e59839ccc1..c5347756ce 100644 --- a/mod/network.php +++ b/mod/network.php @@ -413,7 +413,7 @@ function network_content(&$a, $update = 0) { $myurl = str_replace(array('www.','.'),array('','\\.'),$myurl); $diasp_url = str_replace('/profile/','/u/',$myurl); $sql_extra .= sprintf(" AND `item`.`parent` IN (SELECT distinct(`parent`) from item where ( `author-link` like '%s' or `tag` like '%s' or tag like '%s' )) ", - dbesc(protect_sprintf('%s' . $myurl)), + dbesc(protect_sprintf('%' . $myurl)), dbesc(protect_sprintf('%' . $myurl . '\\]%')), dbesc(protect_sprintf('%' . $diasp_url . '\\]%')) ); diff --git a/view/theme/diabook/theme.php b/view/theme/diabook/theme.php index de7e418419..83079782e8 100755 --- a/view/theme/diabook/theme.php +++ b/view/theme/diabook/theme.php @@ -18,6 +18,11 @@ $a->page['htmlhead'] .= sprintf('', $diabook_ //init css on network and profilepages $cssFile = null; + +// Preload config +load_config("diabook"); +load_pconfig(local_user(), "diabook"); + //get statuses of boxes at right-hand-column $close_pages = false; $site_close_pages = get_config("diabook", "close_pages" ); From fafd41f4bfcebdc0560f6b458df2cb089fce63ff Mon Sep 17 00:00:00 2001 From: friendica Date: Fri, 25 May 2012 14:36:17 -0700 Subject: [PATCH 04/35] keep private FB stuff out of personal notes --- boot.php | 2 +- mod/notes.php | 6 ++-- util/messages.po | 81 +++++++++++++++++++++++++++--------------------- 3 files changed, 50 insertions(+), 39 deletions(-) diff --git a/boot.php b/boot.php index 634cf28c92..64420f4341 100644 --- a/boot.php +++ b/boot.php @@ -9,7 +9,7 @@ require_once('include/nav.php'); require_once('include/cache.php'); define ( 'FRIENDICA_PLATFORM', 'Friendica'); -define ( 'FRIENDICA_VERSION', '3.0.1353' ); +define ( 'FRIENDICA_VERSION', '3.0.1354' ); define ( 'DFRN_PROTOCOL_VERSION', '2.23' ); define ( 'DB_UPDATE_VERSION', 1144 ); diff --git a/mod/notes.php b/mod/notes.php index 0072ce447f..64cc17a653 100644 --- a/mod/notes.php +++ b/mod/notes.php @@ -80,7 +80,8 @@ function notes_content(&$a,$update = false) { $r = q("SELECT COUNT(*) AS `total` FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` - WHERE `item`.`uid` = %d AND `item`.`visible` = 1 and `item`.`moderated` = 0 AND `item`.`deleted` = 0 + WHERE `item`.`uid` = %d AND `item`.`visible` = 1 and `item`.`moderated` = 0 + AND `item`.`deleted` = 0 AND `item`.`origin` = 1 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 AND `contact`.`self` = 1 AND `item`.`id` = `item`.`parent` AND `item`.`wall` = 0 $sql_extra ", @@ -95,7 +96,8 @@ function notes_content(&$a,$update = false) { $r = q("SELECT `item`.`id` AS `item_id`, `contact`.`uid` AS `contact-uid` FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` - WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0 and `item`.`moderated` = 0 + WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0 + and `item`.`moderated` = 0 AND `item`.`origin` = 1 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 AND `contact`.`self` = 1 AND `item`.`id` = `item`.`parent` AND `item`.`wall` = 0 $sql_extra diff --git a/util/messages.po b/util/messages.po index 7aefd8f67d..1fd6628b82 100644 --- a/util/messages.po +++ b/util/messages.po @@ -6,9 +6,9 @@ #, fuzzy msgid "" msgstr "" -"Project-Id-Version: 3.0.1353\n" +"Project-Id-Version: 3.0.1354\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2012-05-24 16:51-0700\n" +"POT-Creation-Date: 2012-05-25 10:00-0700\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -904,7 +904,7 @@ msgid "" msgstr "" #: ../../mod/install.php:139 ../../mod/install.php:203 -#: ../../mod/install.php:480 +#: ../../mod/install.php:482 msgid "Please see the file \"INSTALL.txt\"." msgstr "" @@ -976,151 +976,160 @@ msgstr "" msgid "Could not find a command line version of PHP in the web server PATH." msgstr "" -#: ../../mod/install.php:320 +#: ../../mod/install.php:318 +msgid "" +"If you don't have a command line version of PHP installed on server, you " +"will not be able to run background polling via cron. See 'Activating scheduled tasks'" +msgstr "" + +#: ../../mod/install.php:322 msgid "PHP executable path" msgstr "" -#: ../../mod/install.php:320 -msgid "Enter full path to php executable" +#: ../../mod/install.php:322 +msgid "" +"Enter full path to php executable. You can leave this blank to continue the " +"installation." msgstr "" -#: ../../mod/install.php:325 +#: ../../mod/install.php:327 msgid "Command line PHP" msgstr "" -#: ../../mod/install.php:334 +#: ../../mod/install.php:336 msgid "" "The command line version of PHP on your system does not have " "\"register_argc_argv\" enabled." msgstr "" -#: ../../mod/install.php:335 +#: ../../mod/install.php:337 msgid "This is required for message delivery to work." msgstr "" -#: ../../mod/install.php:337 +#: ../../mod/install.php:339 msgid "PHP register_argc_argv" msgstr "" -#: ../../mod/install.php:358 +#: ../../mod/install.php:360 msgid "" "Error: the \"openssl_pkey_new\" function on this system is not able to " "generate encryption keys" msgstr "" -#: ../../mod/install.php:359 +#: ../../mod/install.php:361 msgid "" "If running under Windows, please see \"http://www.php.net/manual/en/openssl." "installation.php\"." msgstr "" -#: ../../mod/install.php:361 +#: ../../mod/install.php:363 msgid "Generate encryption keys" msgstr "" -#: ../../mod/install.php:368 +#: ../../mod/install.php:370 msgid "libCurl PHP module" msgstr "" -#: ../../mod/install.php:369 +#: ../../mod/install.php:371 msgid "GD graphics PHP module" msgstr "" -#: ../../mod/install.php:370 +#: ../../mod/install.php:372 msgid "OpenSSL PHP module" msgstr "" -#: ../../mod/install.php:371 +#: ../../mod/install.php:373 msgid "mysqli PHP module" msgstr "" -#: ../../mod/install.php:372 +#: ../../mod/install.php:374 msgid "mb_string PHP module" msgstr "" -#: ../../mod/install.php:377 ../../mod/install.php:379 +#: ../../mod/install.php:379 ../../mod/install.php:381 msgid "Apache mod_rewrite module" msgstr "" -#: ../../mod/install.php:377 +#: ../../mod/install.php:379 msgid "" "Error: Apache webserver mod-rewrite module is required but not installed." msgstr "" -#: ../../mod/install.php:384 +#: ../../mod/install.php:386 msgid "Error: libCURL PHP module required but not installed." msgstr "" -#: ../../mod/install.php:388 +#: ../../mod/install.php:390 msgid "" "Error: GD graphics PHP module with JPEG support required but not installed." msgstr "" -#: ../../mod/install.php:392 +#: ../../mod/install.php:394 msgid "Error: openssl PHP module required but not installed." msgstr "" -#: ../../mod/install.php:396 +#: ../../mod/install.php:398 msgid "Error: mysqli PHP module required but not installed." msgstr "" -#: ../../mod/install.php:400 +#: ../../mod/install.php:402 msgid "Error: mb_string PHP module required but not installed." msgstr "" -#: ../../mod/install.php:417 +#: ../../mod/install.php:419 msgid "" "The web installer needs to be able to create a file called \".htconfig.php\" " "in the top folder of your web server and it is unable to do so." msgstr "" -#: ../../mod/install.php:418 +#: ../../mod/install.php:420 msgid "" "This is most often a permission setting, as the web server may not be able " "to write files in your folder - even if you can." msgstr "" -#: ../../mod/install.php:419 +#: ../../mod/install.php:421 msgid "" "At the end of this procedure, we will give you a text to save in a file " "named .htconfig.php in your Friendica top folder." msgstr "" -#: ../../mod/install.php:420 +#: ../../mod/install.php:422 msgid "" "You can alternatively skip this procedure and perform a manual installation. " "Please see the file \"INSTALL.txt\" for instructions." msgstr "" -#: ../../mod/install.php:423 +#: ../../mod/install.php:425 msgid ".htconfig.php is writable" msgstr "" -#: ../../mod/install.php:434 +#: ../../mod/install.php:436 msgid "" "Url rewrite in .htconfig is not working. Check your server configuration." msgstr "" -#: ../../mod/install.php:436 +#: ../../mod/install.php:438 msgid "Url rewrite is working" msgstr "" -#: ../../mod/install.php:442 +#: ../../mod/install.php:444 msgid "" "The database configuration file \".htconfig.php\" could not be written. " "Please use the enclosed text to create a configuration file in your web " "server root." msgstr "" -#: ../../mod/install.php:467 +#: ../../mod/install.php:469 msgid "Errors encountered creating database tables." msgstr "" -#: ../../mod/install.php:478 +#: ../../mod/install.php:480 msgid "

What next

" msgstr "" -#: ../../mod/install.php:479 +#: ../../mod/install.php:481 msgid "" "IMPORTANT: You will need to [manually] setup a scheduled task for the poller." msgstr "" From 27c903a8d0d9e8eeca31a21356256593da683da6 Mon Sep 17 00:00:00 2001 From: friendica Date: Fri, 25 May 2012 15:56:18 -0700 Subject: [PATCH 05/35] improve location change notifications --- mod/profiles.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/mod/profiles.php b/mod/profiles.php index 8e4fba74e0..ca3890eb94 100644 --- a/mod/profiles.php +++ b/mod/profiles.php @@ -176,9 +176,18 @@ function profiles_post(&$a) { $changes[] = t('Interests'); $value = $interest; } - if($address != $orig[0]['address'] || $locality != $orig[0]['locality'] || $region != $orig[0]['region'] + if($address != $orig[0]['address']) { + $changes[] = t('Address'); + // New address not sent in notifications, potential privacy issues + // in case this leaks to unintended recipients. Yes, it's in the public + // profile but that doesn't mean we have to broadcast it to everybody. + } + if($locality != $orig[0]['locality'] || $region != $orig[0]['region'] || $country_name != $orig[0]['country-name']) { $changes[] = t('Location'); + $comma1 = ((($locality) && ($region || $country_name)) ? ', ' : ' '); + $comma2 = (($region && $country_name) ? ', ' : ''); + $value = $locality . $comma1 . $region . $comma2 . $country_name; } profile_activity($changes,$value); From 0ef8ccf11bbc6f353610b0a67c203a7f8438387b Mon Sep 17 00:00:00 2001 From: friendica Date: Fri, 25 May 2012 17:42:35 -0700 Subject: [PATCH 06/35] fix wall_uploaded photo permissions on group post by member --- mod/item.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mod/item.php b/mod/item.php index 81dd553cdb..df242d6f7c 100644 --- a/mod/item.php +++ b/mod/item.php @@ -355,13 +355,15 @@ function item_post(&$a) { $image_uri = substr($image_uri,0, strpos($image_uri,'-')); if(! strlen($image_uri)) continue; - $srch = '<' . intval($contact_record['id']) . '>'; + $srch = '<' . intval($contact_id) . '>'; + $r = q("SELECT `id` FROM `photo` WHERE `allow_cid` = '%s' AND `allow_gid` = '' AND `deny_cid` = '' AND `deny_gid` = '' AND `resource-id` = '%s' AND `uid` = %d LIMIT 1", dbesc($srch), dbesc($image_uri), intval($profile_uid) ); + if(! count($r)) continue; From bb4712b171f1c5ee02a49afc9ebff9bb8af3b052 Mon Sep 17 00:00:00 2001 From: friendica Date: Fri, 25 May 2012 18:06:51 -0700 Subject: [PATCH 07/35] bug #434 - default group placement not working after accepting dfrn friend request --- mod/dfrn_confirm.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mod/dfrn_confirm.php b/mod/dfrn_confirm.php index 093993bbc4..564ae5ca23 100644 --- a/mod/dfrn_confirm.php +++ b/mod/dfrn_confirm.php @@ -500,7 +500,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) { ); if($contact && $g && intval($g[0]['def_gid'])) { require_once('include/group.php'); - group_add_member($uid,'',$contact[0]['id'],$g[0]['def_gid']); + group_add_member($uid,'',$contact['id'],$g[0]['def_gid']); } // Let's send our user to the contact editor in case they want to From 49512105082dde72553f4250e6284920612cc6b8 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Sat, 26 May 2012 03:21:07 +0200 Subject: [PATCH 08/35] Speed optimisation by enabling the posibility of the MySQL fulltext engine --- htconfig.php | 3 +++ include/api.php | 20 ++++++++++++++------ include/dba.php | 4 ++-- mod/network.php | 18 +++++++++++++----- mod/search.php | 16 +++++++++++----- 5 files changed, 43 insertions(+), 18 deletions(-) diff --git a/htconfig.php b/htconfig.php index 872572654a..2c5658be4d 100644 --- a/htconfig.php +++ b/htconfig.php @@ -88,3 +88,6 @@ $a->config['system']['itemcache'] = ""; // If enabled, the lockpath is used for a lockfile to check if the poller is running $a->config['system']['lockpath'] = ""; + +// If enabled, the MyBB fulltext engine is used +$a->config['system']['use_fulltext_engine'] = true; diff --git a/include/api.php b/include/api.php index f58a91a72f..5697fbdbcb 100644 --- a/include/api.php +++ b/include/api.php @@ -976,7 +976,7 @@ $since_id = (x($_REQUEST,'since_id')?$_REQUEST['since_id']:0); $max_id = (x($_REQUEST,'max_id')?$_REQUEST['max_id']:0); //$since_id = 0;//$since_id = (x($_REQUEST,'since_id')?$_REQUEST['since_id']:0); - + $start = $page*$count; //$include_entities = (x($_REQUEST,'include_entities')?$_REQUEST['include_entities']:false); @@ -985,11 +985,19 @@ $myurl = substr($myurl,strpos($myurl,'://')+3); $myurl = str_replace(array('www.','.'),array('','\\.'),$myurl); $diasp_url = str_replace('/profile/','/u/',$myurl); - $sql_extra .= sprintf(" AND `item`.`parent` IN (SELECT distinct(`parent`) from item where ( `author-link` regexp '%s' or `tag` regexp '%s' or tag regexp '%s' )) ", - dbesc($myurl . '$'), - dbesc($myurl . '\\]'), - dbesc($diasp_url . '\\]') - ); + + if (get_config('system','use_fulltext_engine')) + $sql_extra .= sprintf(" AND `item`.`parent` IN (SELECT distinct(`parent`) from item where (MATCH(`author-link`) AGAINST ('".'"%s"'."' in boolean mode) or MATCH(`tag`) AGAINST ('".'"%s"'."' in boolean mode) or MATCH(tag) AGAINST ('".'"%s"'."' in boolean mode))) ", + dbesc(protect_sprintf($myurl)), + dbesc(protect_sprintf($myurl)), + dbesc(protect_sprintf($diasp_url)) + ); + else + $sql_extra .= sprintf(" AND `item`.`parent` IN (SELECT distinct(`parent`) from item where ( `author-link` like '%s' or `tag` like '%s' or tag like '%s' )) ", + dbesc(protect_sprintf('%' . $myurl)), + dbesc(protect_sprintf('%' . $myurl . '\\]%')), + dbesc(protect_sprintf('%' . $diasp_url . '\\]%')) + ); if ($max_id > 0) $sql_extra .= ' AND `item`.`id` <= '.intval($max_id); diff --git a/include/dba.php b/include/dba.php index 7ecce72704..c19d4a8fc9 100644 --- a/include/dba.php +++ b/include/dba.php @@ -77,14 +77,14 @@ class dba { $this->error = ''; - //@file_put_contents("/tmp/friendica-db.log", datetime_convert().':'.session_id(). ' Start '.$sql."\n", FILE_APPEND); + @file_put_contents("/tmp/friendica-db.log", datetime_convert().':'.session_id(). ' Start '.$sql."\n", FILE_APPEND); if($this->mysqli) $result = @$this->db->query($sql); else $result = @mysql_query($sql,$this->db); - //@file_put_contents("/tmp/friendica-db.log", datetime_convert().':'.session_id(). ' Stop '."\n", FILE_APPEND); + @file_put_contents("/tmp/friendica-db.log", datetime_convert().':'.session_id(). ' Stop '."\n", FILE_APPEND); if($this->mysqli) { if($this->db->errno) diff --git a/mod/network.php b/mod/network.php index c6f683b935..f54d055d38 100644 --- a/mod/network.php +++ b/mod/network.php @@ -416,11 +416,19 @@ function network_content(&$a, $update = 0) { $myurl = substr($myurl,strpos($myurl,'://')+3); $myurl = str_replace(array('www.','.'),array('','\\.'),$myurl); $diasp_url = str_replace('/profile/','/u/',$myurl); - $sql_extra .= sprintf(" AND `item`.`parent` IN (SELECT distinct(`parent`) from item where ( `author-link` like '%s' or `tag` like '%s' or tag like '%s' )) ", - dbesc(protect_sprintf('%' . $myurl)), - dbesc(protect_sprintf('%' . $myurl . '\\]%')), - dbesc(protect_sprintf('%' . $diasp_url . '\\]%')) - ); + if (get_config('system','use_fulltext_engine')) + $sql_extra .= sprintf(" AND `item`.`parent` IN (SELECT distinct(`parent`) from item where (MATCH(`author-link`) AGAINST ('".'"%s"'."' in boolean mode) or MATCH(`tag`) AGAINST ('".'"%s"'."' in boolean mode) or MATCH(tag) AGAINST ('".'"%s"'."' in boolean mode))) ", + dbesc(protect_sprintf($myurl)), + dbesc(protect_sprintf($myurl)), + dbesc(protect_sprintf($diasp_url)) + ); + else + $sql_extra .= sprintf(" AND `item`.`parent` IN (SELECT distinct(`parent`) from item where ( `author-link` like '%s' or `tag` like '%s' or tag like '%s' )) ", + dbesc(protect_sprintf('%' . $myurl)), + dbesc(protect_sprintf('%' . $myurl . '\\]%')), + dbesc(protect_sprintf('%' . $diasp_url . '\\]%')) + ); + } diff --git a/mod/search.php b/mod/search.php index 3e6bf68aa6..ac51346963 100644 --- a/mod/search.php +++ b/mod/search.php @@ -109,11 +109,17 @@ function search_content(&$a) { if(! $search) return $o; - if($tag) - $sql_extra = sprintf(" AND `item`.`tag` REGEXP '%s' ", dbesc('\\]' . preg_quote($search) . '\\[')); - else - $sql_extra = sprintf(" AND `item`.`body` REGEXP '%s' ", dbesc(preg_quote($search))); - + if (get_config('system','use_fulltext_engine')) { + if($tag) + $sql_extra = sprintf(" AND MATCH (`item`.`tag`) AGAINST ('".'"%s"'."' in boolean mode) ", '#'.preg_quote($search)); + else + $sql_extra = sprintf(" AND MATCH (`item`.`body`) AGAINST ('".'"%s"'."' in boolean mode) ", dbesc(preg_quote($search))); + } else { + if($tag) + $sql_extra = sprintf(" AND `item`.`tag` REGEXP '%s' ", dbesc('\\]' . preg_quote($search) . '\\[')); + else + $sql_extra = sprintf(" AND `item`.`body` REGEXP '%s' ", dbesc(preg_quote($search))); + } From a612b10b2a1c2d1afbca1fd2f38ebc35110081dc Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Sat, 26 May 2012 03:23:18 +0200 Subject: [PATCH 09/35] Deactivating the test output in db engine --- include/dba.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/dba.php b/include/dba.php index c19d4a8fc9..7ecce72704 100644 --- a/include/dba.php +++ b/include/dba.php @@ -77,14 +77,14 @@ class dba { $this->error = ''; - @file_put_contents("/tmp/friendica-db.log", datetime_convert().':'.session_id(). ' Start '.$sql."\n", FILE_APPEND); + //@file_put_contents("/tmp/friendica-db.log", datetime_convert().':'.session_id(). ' Start '.$sql."\n", FILE_APPEND); if($this->mysqli) $result = @$this->db->query($sql); else $result = @mysql_query($sql,$this->db); - @file_put_contents("/tmp/friendica-db.log", datetime_convert().':'.session_id(). ' Stop '."\n", FILE_APPEND); + //@file_put_contents("/tmp/friendica-db.log", datetime_convert().':'.session_id(). ' Stop '."\n", FILE_APPEND); if($this->mysqli) { if($this->db->errno) From f5290a5a107ef2d6c309c4a3205319c9b0d13994 Mon Sep 17 00:00:00 2001 From: friendica Date: Fri, 25 May 2012 18:29:06 -0700 Subject: [PATCH 10/35] missing entries on personal tab after sql text search optimise --- mod/network.php | 9 ++++----- mod/wallmessage.php | 4 ++-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/mod/network.php b/mod/network.php index f43eeb67e6..fbfe2de4fd 100644 --- a/mod/network.php +++ b/mod/network.php @@ -414,16 +414,15 @@ function network_content(&$a, $update = 0) { if($conv) { $myurl = $a->get_baseurl() . '/profile/'. $a->user['nickname']; $myurl = substr($myurl,strpos($myurl,'://')+3); - $myurl = str_replace(array('www.','.'),array('','\\.'),$myurl); + $myurl = str_replace('www.','',$myurl); $diasp_url = str_replace('/profile/','/u/',$myurl); $sql_extra .= sprintf(" AND `item`.`parent` IN (SELECT distinct(`parent`) from item where ( `author-link` like '%s' or `tag` like '%s' or tag like '%s' )) ", - dbesc(protect_sprintf('%s' . $myurl)), - dbesc(protect_sprintf('%' . $myurl . '\\]%')), - dbesc(protect_sprintf('%' . $diasp_url . '\\]%')) + dbesc(protect_sprintf('%' . $myurl)), + dbesc(protect_sprintf('%' . $myurl . ']%')), + dbesc(protect_sprintf('%' . $diasp_url . ']%')) ); } - if($update) { // only setup pagination on initial page view diff --git a/mod/wallmessage.php b/mod/wallmessage.php index 1a4882b643..cf349775c6 100644 --- a/mod/wallmessage.php +++ b/mod/wallmessage.php @@ -44,7 +44,7 @@ function wallmessage_post(&$a) { } // Work around doubled linefeeds in Tinymce 3.5b2 -dbg(1); + $body = str_replace("\r\n","\n",$body); $body = str_replace("\n\n","\n",$body); @@ -67,7 +67,7 @@ dbg(1); default: info( t('Message sent.') . EOL ); } -dbg(0); + // goaway($a->get_baseurl() . '/profile/' . $user['nickname']); } From a5dc41ab131d4235eb947ff00d7af0593bf0e460 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Sat, 26 May 2012 11:51:48 +0200 Subject: [PATCH 11/35] Saved searches now can search for tags as well --- mod/network.php | 20 ++++++++++++++++---- mod/search.php | 3 +-- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/mod/network.php b/mod/network.php index f54d055d38..6b4fa9a5b3 100644 --- a/mod/network.php +++ b/mod/network.php @@ -402,10 +402,22 @@ function network_content(&$a, $update = 0) { if(x($_GET,'search')) { $search = escape_tags($_GET['search']); - $sql_extra .= sprintf(" AND ( `item`.`body` like '%s' OR `item`.`tag` like '%s' ) ", - dbesc(protect_sprintf('%' . $search . '%')), - dbesc(protect_sprintf('%]' . $search . '[%')) - ); + if (get_config('system','use_fulltext_engine')) { + if(strpos($search,'#') === 0) + $sql_extra .= sprintf(" AND (MATCH(tag) AGAINST ('".'"%s"'."' in boolean mode)) ", + dbesc(protect_sprintf($search)) + ); + else + $sql_extra .= sprintf(" AND (MATCH(`item`.`body`) AGAINST ('".'"%s"'."' in boolean mode) or MATCH(tag) AGAINST ('".'"%s"'."' in boolean mode)) ", + dbesc(protect_sprintf($search)), + dbesc(protect_sprintf($search)) + ); + } else { + $sql_extra .= sprintf(" AND ( `item`.`body` like '%s' OR `item`.`tag` like '%s' ) ", + dbesc(protect_sprintf('%' . $search . '%')), + dbesc(protect_sprintf('%]' . $search . '[%')) + ); + } } if(strlen($file)) { $sql_extra .= file_tag_file_query('item',unxmlify($file)); diff --git a/mod/search.php b/mod/search.php index ac51346963..d4cd9d9676 100644 --- a/mod/search.php +++ b/mod/search.php @@ -71,7 +71,7 @@ function search_content(&$a) { notice( t('Public access denied.') . EOL); return; } - + nav_set_selected('search'); require_once("include/bbcode.php"); @@ -96,7 +96,6 @@ function search_content(&$a) { $o .= search($search,'search-box','/search',((local_user()) ? true : false)); - if(strpos($search,'#') === 0) { $tag = true; $search = substr($search,1); From 7f19d39b146844fd71d148690d3e550df9d3043b Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Sat, 26 May 2012 15:41:23 +0200 Subject: [PATCH 12/35] Doing negative caching for config values, special logfile for database optmisations --- include/config.php | 24 ++++++++++++++++++++++-- include/dba.php | 6 ++++-- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/include/config.php b/include/config.php index 6edc3f286c..df1070c13c 100644 --- a/include/config.php +++ b/include/config.php @@ -30,6 +30,9 @@ function load_config($family) { $a->config[$family][$k] = $rr['v']; } } + } else if ($rr['cat'] != 'config') { + // Negative caching + $a->config[$family] = "!!"; } }} @@ -47,6 +50,13 @@ function get_config($family, $key, $instore = false) { global $a; if(! $instore) { + // Looking if the whole family isn't set + if(isset($a->config[$family])) { + if($a->config[$family] === '!!') { + return false; + } + } + if(isset($a->config[$family][$key])) { if($a->config[$family][$key] === '!!') { return false; @@ -87,11 +97,11 @@ function set_config($family,$key,$value) { dbesc($key), dbesc($dbvalue) ); - if($ret) + if($ret) return $value; return $ret; } - + $ret = q("UPDATE `config` SET `v` = '%s' WHERE `cat` = '%s' AND `k` = '%s' LIMIT 1", dbesc($dbvalue), dbesc($family), @@ -118,6 +128,9 @@ function load_pconfig($uid,$family) { $k = $rr['k']; $a->config[$uid][$family][$k] = $rr['v']; } + } else if ($rr['cat'] != 'config') { + // Negative caching + $a->config[$uid][$family] = "!!"; } }} @@ -129,6 +142,13 @@ function get_pconfig($uid,$family, $key, $instore = false) { global $a; if(! $instore) { + // Looking if the whole family isn't set + if(isset($a->config[$uid][$family])) { + if($a->config[$uid][$family] === '!!') { + return false; + } + } + if(isset($a->config[$uid][$family][$key])) { if($a->config[$uid][$family][$key] === '!!') { return false; diff --git a/include/dba.php b/include/dba.php index 7ecce72704..20c08c2dd0 100644 --- a/include/dba.php +++ b/include/dba.php @@ -77,14 +77,16 @@ class dba { $this->error = ''; - //@file_put_contents("/tmp/friendica-db.log", datetime_convert().':'.session_id(). ' Start '.$sql."\n", FILE_APPEND); + if (get_config("system", "db_log") != "") + @file_put_contents(get_config("system", "db_log"), datetime_convert().':'.session_id(). ' Start '.$sql."\n", FILE_APPEND); if($this->mysqli) $result = @$this->db->query($sql); else $result = @mysql_query($sql,$this->db); - //@file_put_contents("/tmp/friendica-db.log", datetime_convert().':'.session_id(). ' Stop '."\n", FILE_APPEND); + if (get_config("system", "db_log") != "") + @file_put_contents(get_config("system", "db_log"), datetime_convert().':'.session_id(). ' Stop '."\n", FILE_APPEND); if($this->mysqli) { if($this->db->errno) From 73c61b6f96353ae7cbf73db7ed8b22f74f8ebdc3 Mon Sep 17 00:00:00 2001 From: friendica Date: Sat, 26 May 2012 16:11:51 -0700 Subject: [PATCH 13/35] allow force ssl on notifications --- boot.php | 2 +- include/enotify.php | 2 +- util/messages.po | 146 +++++++++++++++++++++++--------------------- 3 files changed, 77 insertions(+), 73 deletions(-) diff --git a/boot.php b/boot.php index 64420f4341..3f4820d67d 100644 --- a/boot.php +++ b/boot.php @@ -9,7 +9,7 @@ require_once('include/nav.php'); require_once('include/cache.php'); define ( 'FRIENDICA_PLATFORM', 'Friendica'); -define ( 'FRIENDICA_VERSION', '3.0.1354' ); +define ( 'FRIENDICA_VERSION', '3.0.1355' ); define ( 'DFRN_PROTOCOL_VERSION', '2.23' ); define ( 'DB_UPDATE_VERSION', 1144 ); diff --git a/include/enotify.php b/include/enotify.php index ca134ac86c..f7ef74fac5 100644 --- a/include/enotify.php +++ b/include/enotify.php @@ -13,7 +13,7 @@ function notification($params) { $banner = t('Friendica Notification'); $product = FRIENDICA_PLATFORM; - $siteurl = z_path(); + $siteurl = $a->get_baseurl(true); $thanks = t('Thank You,'); $sitename = get_config('config','sitename'); $site_admin = sprintf( t('%s Administrator'), $sitename); diff --git a/util/messages.po b/util/messages.po index 1fd6628b82..2f6a1c4068 100644 --- a/util/messages.po +++ b/util/messages.po @@ -6,9 +6,9 @@ #, fuzzy msgid "" msgstr "" -"Project-Id-Version: 3.0.1354\n" +"Project-Id-Version: 3.0.1355\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2012-05-25 10:00-0700\n" +"POT-Creation-Date: 2012-05-26 10:00-0700\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -52,7 +52,7 @@ msgstr "" #: ../../mod/message.php:96 ../../mod/allfriends.php:9 #: ../../mod/nogroup.php:25 ../../mod/wall_upload.php:53 #: ../../mod/follow.php:8 ../../mod/display.php:138 ../../mod/profiles.php:7 -#: ../../mod/profiles.php:365 ../../mod/delegate.php:6 +#: ../../mod/profiles.php:374 ../../mod/delegate.php:6 #: ../../mod/suggest.php:28 ../../mod/invite.php:13 ../../mod/invite.php:81 #: ../../mod/dfrn_confirm.php:53 ../../addon/facebook/facebook.php:503 #: ../../include/items.php:3214 ../../index.php:306 @@ -131,7 +131,7 @@ msgstr "" #: ../../mod/settings.php:760 ../../mod/settings.php:964 #: ../../mod/manage.php:109 ../../mod/group.php:85 ../../mod/admin.php:417 #: ../../mod/admin.php:653 ../../mod/admin.php:789 ../../mod/admin.php:988 -#: ../../mod/admin.php:1075 ../../mod/profiles.php:534 +#: ../../mod/admin.php:1075 ../../mod/profiles.php:543 #: ../../mod/invite.php:119 ../../addon/facebook/facebook.php:605 #: ../../addon/yourls/yourls.php:76 ../../addon/ljpost/ljpost.php:93 #: ../../addon/nsfw/nsfw.php:57 ../../addon/planets/planets.php:158 @@ -331,7 +331,7 @@ msgstr "" #: ../../mod/settings.php:910 ../../mod/settings.php:916 #: ../../mod/settings.php:952 ../../mod/settings.php:953 #: ../../mod/settings.php:954 ../../mod/settings.php:955 -#: ../../mod/register.php:511 ../../mod/profiles.php:511 +#: ../../mod/register.php:511 ../../mod/profiles.php:520 msgid "Yes" msgstr "" @@ -342,7 +342,7 @@ msgstr "" #: ../../mod/settings.php:910 ../../mod/settings.php:916 #: ../../mod/settings.php:952 ../../mod/settings.php:953 #: ../../mod/settings.php:954 ../../mod/settings.php:955 -#: ../../mod/register.php:512 ../../mod/profiles.php:512 +#: ../../mod/register.php:512 ../../mod/profiles.php:521 msgid "No" msgstr "" @@ -2879,34 +2879,34 @@ msgstr "" msgid "Empty post discarded." msgstr "" -#: ../../mod/item.php:377 ../../mod/wall_upload.php:99 +#: ../../mod/item.php:379 ../../mod/wall_upload.php:99 #: ../../mod/wall_upload.php:108 ../../mod/wall_upload.php:115 #: ../../include/message.php:144 msgid "Wall Photos" msgstr "" -#: ../../mod/item.php:786 +#: ../../mod/item.php:788 msgid "System error. Post not saved." msgstr "" -#: ../../mod/item.php:811 +#: ../../mod/item.php:813 #, php-format msgid "" "This message was sent to you by %s, a member of the Friendica social network." msgstr "" -#: ../../mod/item.php:813 +#: ../../mod/item.php:815 #, php-format msgid "You may visit them online at %s" msgstr "" -#: ../../mod/item.php:814 +#: ../../mod/item.php:816 msgid "" "Please contact the sender by replying to this post if you do not wish to " "receive these messages." msgstr "" -#: ../../mod/item.php:816 +#: ../../mod/item.php:818 #, php-format msgid "%s posted an update." msgstr "" @@ -3788,8 +3788,8 @@ msgstr "" msgid "Search" msgstr "" -#: ../../mod/profiles.php:21 ../../mod/profiles.php:375 -#: ../../mod/profiles.php:489 ../../mod/dfrn_confirm.php:62 +#: ../../mod/profiles.php:21 ../../mod/profiles.php:384 +#: ../../mod/profiles.php:498 ../../mod/dfrn_confirm.php:62 msgid "Profile not found." msgstr "" @@ -3833,237 +3833,241 @@ msgstr "" msgid "Interests" msgstr "" -#: ../../mod/profiles.php:181 +#: ../../mod/profiles.php:180 +msgid "Address" +msgstr "" + +#: ../../mod/profiles.php:187 msgid "Location" msgstr "" -#: ../../mod/profiles.php:253 +#: ../../mod/profiles.php:262 msgid "Profile updated." msgstr "" -#: ../../mod/profiles.php:320 +#: ../../mod/profiles.php:329 msgid " and " msgstr "" -#: ../../mod/profiles.php:328 +#: ../../mod/profiles.php:337 msgid "public profile" msgstr "" -#: ../../mod/profiles.php:331 +#: ../../mod/profiles.php:340 #, php-format msgid "%1$s changed %2$s to “%3$s”" msgstr "" -#: ../../mod/profiles.php:332 +#: ../../mod/profiles.php:341 #, php-format msgid " - Visit %1$s's %2$s" msgstr "" -#: ../../mod/profiles.php:335 +#: ../../mod/profiles.php:344 #, php-format msgid "%1$s has an updated %2$s, changing %3$s." msgstr "" -#: ../../mod/profiles.php:394 +#: ../../mod/profiles.php:403 msgid "Profile deleted." msgstr "" -#: ../../mod/profiles.php:412 ../../mod/profiles.php:446 +#: ../../mod/profiles.php:421 ../../mod/profiles.php:455 msgid "Profile-" msgstr "" -#: ../../mod/profiles.php:431 ../../mod/profiles.php:473 +#: ../../mod/profiles.php:440 ../../mod/profiles.php:482 msgid "New profile created." msgstr "" -#: ../../mod/profiles.php:452 +#: ../../mod/profiles.php:461 msgid "Profile unavailable to clone." msgstr "" -#: ../../mod/profiles.php:510 +#: ../../mod/profiles.php:519 msgid "Hide your contact/friend list from viewers of this profile?" msgstr "" -#: ../../mod/profiles.php:533 +#: ../../mod/profiles.php:542 msgid "Edit Profile Details" msgstr "" -#: ../../mod/profiles.php:535 +#: ../../mod/profiles.php:544 msgid "View this profile" msgstr "" -#: ../../mod/profiles.php:536 +#: ../../mod/profiles.php:545 msgid "Create a new profile using these settings" msgstr "" -#: ../../mod/profiles.php:537 +#: ../../mod/profiles.php:546 msgid "Clone this profile" msgstr "" -#: ../../mod/profiles.php:538 +#: ../../mod/profiles.php:547 msgid "Delete this profile" msgstr "" -#: ../../mod/profiles.php:539 +#: ../../mod/profiles.php:548 msgid "Profile Name:" msgstr "" -#: ../../mod/profiles.php:540 +#: ../../mod/profiles.php:549 msgid "Your Full Name:" msgstr "" -#: ../../mod/profiles.php:541 +#: ../../mod/profiles.php:550 msgid "Title/Description:" msgstr "" -#: ../../mod/profiles.php:542 +#: ../../mod/profiles.php:551 msgid "Your Gender:" msgstr "" -#: ../../mod/profiles.php:543 +#: ../../mod/profiles.php:552 #, php-format msgid "Birthday (%s):" msgstr "" -#: ../../mod/profiles.php:544 +#: ../../mod/profiles.php:553 msgid "Street Address:" msgstr "" -#: ../../mod/profiles.php:545 +#: ../../mod/profiles.php:554 msgid "Locality/City:" msgstr "" -#: ../../mod/profiles.php:546 +#: ../../mod/profiles.php:555 msgid "Postal/Zip Code:" msgstr "" -#: ../../mod/profiles.php:547 +#: ../../mod/profiles.php:556 msgid "Country:" msgstr "" -#: ../../mod/profiles.php:548 +#: ../../mod/profiles.php:557 msgid "Region/State:" msgstr "" -#: ../../mod/profiles.php:549 +#: ../../mod/profiles.php:558 msgid " Marital Status:" msgstr "" -#: ../../mod/profiles.php:550 +#: ../../mod/profiles.php:559 msgid "Who: (if applicable)" msgstr "" -#: ../../mod/profiles.php:551 +#: ../../mod/profiles.php:560 msgid "Examples: cathy123, Cathy Williams, cathy@example.com" msgstr "" -#: ../../mod/profiles.php:552 ../../include/profile_advanced.php:43 +#: ../../mod/profiles.php:561 ../../include/profile_advanced.php:43 msgid "Sexual Preference:" msgstr "" -#: ../../mod/profiles.php:553 +#: ../../mod/profiles.php:562 msgid "Homepage URL:" msgstr "" -#: ../../mod/profiles.php:554 ../../include/profile_advanced.php:49 +#: ../../mod/profiles.php:563 ../../include/profile_advanced.php:49 msgid "Political Views:" msgstr "" -#: ../../mod/profiles.php:555 +#: ../../mod/profiles.php:564 msgid "Religious Views:" msgstr "" -#: ../../mod/profiles.php:556 +#: ../../mod/profiles.php:565 msgid "Public Keywords:" msgstr "" -#: ../../mod/profiles.php:557 +#: ../../mod/profiles.php:566 msgid "Private Keywords:" msgstr "" -#: ../../mod/profiles.php:558 +#: ../../mod/profiles.php:567 msgid "Example: fishing photography software" msgstr "" -#: ../../mod/profiles.php:559 +#: ../../mod/profiles.php:568 msgid "(Used for suggesting potential friends, can be seen by others)" msgstr "" -#: ../../mod/profiles.php:560 +#: ../../mod/profiles.php:569 msgid "(Used for searching profiles, never shown to others)" msgstr "" -#: ../../mod/profiles.php:561 +#: ../../mod/profiles.php:570 msgid "Tell us about yourself..." msgstr "" -#: ../../mod/profiles.php:562 +#: ../../mod/profiles.php:571 msgid "Hobbies/Interests" msgstr "" -#: ../../mod/profiles.php:563 +#: ../../mod/profiles.php:572 msgid "Contact information and Social Networks" msgstr "" -#: ../../mod/profiles.php:564 +#: ../../mod/profiles.php:573 msgid "Musical interests" msgstr "" -#: ../../mod/profiles.php:565 +#: ../../mod/profiles.php:574 msgid "Books, literature" msgstr "" -#: ../../mod/profiles.php:566 +#: ../../mod/profiles.php:575 msgid "Television" msgstr "" -#: ../../mod/profiles.php:567 +#: ../../mod/profiles.php:576 msgid "Film/dance/culture/entertainment" msgstr "" -#: ../../mod/profiles.php:568 +#: ../../mod/profiles.php:577 msgid "Love/romance" msgstr "" -#: ../../mod/profiles.php:569 +#: ../../mod/profiles.php:578 msgid "Work/employment" msgstr "" -#: ../../mod/profiles.php:570 +#: ../../mod/profiles.php:579 msgid "School/education" msgstr "" -#: ../../mod/profiles.php:575 +#: ../../mod/profiles.php:584 msgid "" "This is your public profile.
It may " "be visible to anybody using the internet." msgstr "" -#: ../../mod/profiles.php:585 ../../mod/directory.php:111 +#: ../../mod/profiles.php:594 ../../mod/directory.php:111 msgid "Age: " msgstr "" -#: ../../mod/profiles.php:620 +#: ../../mod/profiles.php:629 msgid "Edit/Manage Profiles" msgstr "" -#: ../../mod/profiles.php:621 ../../boot.php:1069 +#: ../../mod/profiles.php:630 ../../boot.php:1069 msgid "Change profile photo" msgstr "" -#: ../../mod/profiles.php:622 ../../boot.php:1070 +#: ../../mod/profiles.php:631 ../../boot.php:1070 msgid "Create New Profile" msgstr "" -#: ../../mod/profiles.php:633 ../../boot.php:1080 +#: ../../mod/profiles.php:642 ../../boot.php:1080 msgid "Profile Image" msgstr "" -#: ../../mod/profiles.php:635 ../../boot.php:1083 +#: ../../mod/profiles.php:644 ../../boot.php:1083 msgid "visible to everybody" msgstr "" -#: ../../mod/profiles.php:636 ../../boot.php:1084 +#: ../../mod/profiles.php:645 ../../boot.php:1084 msgid "Edit visibility" msgstr "" From 5a7363b248e51b93c401a84d1b99f33632c44711 Mon Sep 17 00:00:00 2001 From: friendica Date: Sat, 26 May 2012 16:21:48 -0700 Subject: [PATCH 14/35] more ssl policy stuff --- boot.php | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/boot.php b/boot.php index 3f4820d67d..b41b8d9a0e 100644 --- a/boot.php +++ b/boot.php @@ -441,22 +441,19 @@ if(! class_exists('App')) { if(intval($this->config['system']['ssl_policy']) === intval(SSL_POLICY_FULL)) $scheme = 'https'; - // We need to populate the $ssl flag across the entire program before turning this on. - // Basically, we'll have $ssl = true on any links which can only be seen by a logged in user - // (and also the login link). Anything seen by an outsider will have it turned off. - // At present, setting SSL_POLICY_SELFSIGN will only force remote contacts to update their - // contact links to this site with "http:" if they are currently using "https:" + // Basically, we have $ssl = true on any links which can only be seen by a logged in user + // (and also the login link). Anything seen by an outsider will have it turned off. - // if($this->config['system']['ssl_policy'] == SSL_POLICY_SELFSIGN) { - // if($ssl) - // $scheme = 'https'; - // else - // $scheme = 'http'; - // } - } + if($this->config['system']['ssl_policy'] == SSL_POLICY_SELFSIGN) { + if($ssl) + $scheme = 'https'; + else + $scheme = 'http'; + } + } - $this->baseurl = $scheme . "://" . $this->hostname . ((isset($this->path) && strlen($this->path)) ? '/' . $this->path : '' ); - return $this->baseurl; + $this->baseurl = $scheme . "://" . $this->hostname . ((isset($this->path) && strlen($this->path)) ? '/' . $this->path : '' ); + return $this->baseurl; } function set_baseurl($url) { From 08941d42856984a3076e972804ac016400341f91 Mon Sep 17 00:00:00 2001 From: friendica Date: Sat, 26 May 2012 23:46:42 -0700 Subject: [PATCH 15/35] handle multiple underscores in D* links --- include/auth.php | 2 ++ include/bb2diaspora.php | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/include/auth.php b/include/auth.php index b87662fea2..cba6a67a7f 100644 --- a/include/auth.php +++ b/include/auth.php @@ -53,6 +53,8 @@ if((isset($_SESSION)) && (x($_SESSION,'authenticated')) && ((! (x($_POST,'auth-p $check = get_config('system','paranoia'); // extra paranoia - if the IP changed, log them out if($check && ($_SESSION['addr'] != $_SERVER['REMOTE_ADDR'])) { + logger('Session address changed. Paranoid setting in effect, blocking session. ' + . $_SESSION['addr'] . ' != ' . $_SERVER['REMOTE_ADDR']); nuke_session(); goaway(z_root()); } diff --git a/include/bb2diaspora.php b/include/bb2diaspora.php index 8487f845a6..d86ba45437 100644 --- a/include/bb2diaspora.php +++ b/include/bb2diaspora.php @@ -221,13 +221,18 @@ function bb2diaspora($Text,$preserve_nl = false) { $Text = preg_replace("/\<(.*?)(src|href)=(.*?)\&\;(.*?)\>/ism",'<$1$2=$3&$4>',$Text); - $Text = preg_replace('/\[(.*?)\]\((.*?)\\\\_(.*?)\)/ism','[$1]($2_$3)',$Text); + $Text = preg_replace_callback('/\[(.*?)\]\((.*?)\)/ism','unescape_underscores_in_links',$Text); call_hooks('bb2diaspora',$Text); return $Text; } +function unescape_underscores_in_links($m) { + $y = str_replace('\\_','_', $m[2]); + return('[' . $m[1] . '](' . $y . ')'); +} + function format_event_diaspora($ev) { $a = get_app(); From 2bd1004587fc8d928b9458b2383b656df115578c Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 27 May 2012 21:01:58 -0700 Subject: [PATCH 16/35] rework the way private photos are embedded to avoid url differences and also check the permissions if possible to make sure that nothing sneaks by. --- boot.php | 2 +- include/delivery.php | 2 +- include/items.php | 88 +++++++++++++++++++++++++++++--- include/notifier.php | 2 +- mod/settings.php | 1 + util/messages.po | 116 +++++++++++++++++++++---------------------- 6 files changed, 142 insertions(+), 69 deletions(-) diff --git a/boot.php b/boot.php index b41b8d9a0e..aff026a71d 100644 --- a/boot.php +++ b/boot.php @@ -9,7 +9,7 @@ require_once('include/nav.php'); require_once('include/cache.php'); define ( 'FRIENDICA_PLATFORM', 'Friendica'); -define ( 'FRIENDICA_VERSION', '3.0.1355' ); +define ( 'FRIENDICA_VERSION', '3.0.1356' ); define ( 'DFRN_PROTOCOL_VERSION', '2.23' ); define ( 'DB_UPDATE_VERSION', 1144 ); diff --git a/include/delivery.php b/include/delivery.php index 61b0bd33a5..32943d5dab 100644 --- a/include/delivery.php +++ b/include/delivery.php @@ -288,7 +288,7 @@ function delivery_run($argv, $argc){ if($normal_mode) { if($item_id == $item['id'] || $item['id'] == $item['parent']) - $atom .= atom_entry($item,'text',null,$owner,true); + $atom .= atom_entry($item,'text',null,$owner,true,(($top_level) ? $contact['id'] : 0)); } else $atom .= atom_entry($item,'text',null,$owner,true); diff --git a/include/items.php b/include/items.php index e5b640fd23..f45b40cc0b 100644 --- a/include/items.php +++ b/include/items.php @@ -2832,7 +2832,7 @@ function atom_author($tag,$name,$uri,$h,$w,$photo) { return $o; } -function atom_entry($item,$type,$author,$owner,$comment = false) { +function atom_entry($item,$type,$author,$owner,$comment = false,$cid = 0) { $a = get_app(); @@ -2844,7 +2844,7 @@ function atom_entry($item,$type,$author,$owner,$comment = false) { if($item['allow_cid'] || $item['allow_gid'] || $item['deny_cid'] || $item['deny_gid']) - $body = fix_private_photos($item['body'],$owner['uid']); + $body = fix_private_photos($item['body'],$owner['uid'],$item,$cid); else $body = $item['body']; @@ -2927,14 +2927,17 @@ function atom_entry($item,$type,$author,$owner,$comment = false) { return $o; } -function fix_private_photos($s,$uid) { +function fix_private_photos($s,$uid, $item = null, $cid = 0) { $a = get_app(); - logger('fix_private_photos'); + + logger('fix_private_photos', LOGGER_DEBUG); + $site = substr($a->get_baseurl(),strpos($a->get_baseurl,'://')); if(preg_match("/\[img\](.*?)\[\/img\]/is",$s,$matches)) { $image = $matches[1]; - logger('fix_private_photos: found photo ' . $image); - if(stristr($image ,$a->get_baseurl() . '/photo/')) { + logger('fix_private_photos: found photo ' . $image, LOGGER_DEBUG); + if(stristr($image , $site . '/photo/')) { + $replace = false; $i = basename($image); $i = str_replace('.jpg','',$i); $x = strpos($i,'-'); @@ -2947,8 +2950,39 @@ function fix_private_photos($s,$uid) { intval($uid) ); if(count($r)) { - logger('replacing photo'); - $s = str_replace($image, 'data:image/jpg;base64,' . base64_encode($r[0]['data']), $s); + + // Check to see if we should replace this photo link with an embedded image + // 1. No need to do so if the photo is public + // 2. If there's a contact-id provided, see if they're in the access list + // for the photo. If so, embed it. + // 3. Otherwise, if we have an item, see if the item permissions match the photo + // permissions, regardless of order but first check to see if they're an exact + // match to save some processing overhead. + + // Currently we only embed one private photo per message so as not to hit import + // size limits at the receiving end. + + // To embed multiples, we would need to parse out the embedded photos on message + // receipt and limit size based only on the text component. Would also need to + // ignore all photos during bbcode translation and item localisation, as these + // will hit internal regex backtrace limits. + + if(has_permissions($r[0])) { + if($cid) { + $recips = enumerate_permissions($r[0]); + if(in_array($cid, $recips)) { + $replace = true; + } + } + elseif($item) { + if(compare_permissions($item,$r[0])) + $replace = true; + } + } + if($replace) { + logger('replacing photo'); + $s = str_replace($image, 'data:image/jpg;base64,' . base64_encode($r[0]['data']), $s); + } } } logger('fix_private_photos: replaced: ' . $s, LOGGER_DATA); @@ -2958,6 +2992,44 @@ function fix_private_photos($s,$uid) { } +function has_permissions($obj) { + if(($obj['allow_cid'] != '') || ($obj['allow_gid'] != '') || ($obj['deny_cid'] != '') || ($obj['deny_gid'] != '')) + return true; + return false; +} + +function compare_permissions($obj1,$obj2) { + // first part is easy. Check that these are exactly the same. + if(($obj1['allow_cid'] == $obj2['allow_cid']) + && ($obj1['allow_gid'] == $obj2['allow_gid']) + && ($obj1['deny_cid'] == $obj2['deny_cid']) + && ($obj1['deny_gid'] == $obj2['deny_gid'])) + return true; + + // This is harder. Parse all the permissions and compare the resulting set. + + $recipients1 = enumerate_permissions($obj1); + $recipients2 = enumerate_permissions($obj2); + sort($recipients1); + sort($recipients2); + if($recipients1 == $recipients2) + return true; + return false; +} + +// returns an array of contact-ids that are allowed to see this object + +function enumerate_permissions($obj) { + require_once('include/group.php'); + $allow_people = expand_acl($obj['allow_cid']); + $allow_groups = expand_groups(expand_acl($obj['allow_gid'])); + $deny_people = expand_acl($obj['deny_cid']); + $deny_groups = expand_groups(expand_acl($obj['deny_gid'])); + $recipients = array_unique(array_merge($allow_people,$allow_groups)); + $deny = array_unique(array_merge($deny_people,$deny_groups)); + $recipients = array_diff($recipients,$deny); + return $recipients; +} function item_getfeedtags($item) { $ret = array(); diff --git a/include/notifier.php b/include/notifier.php index cb4fb2a31c..070e7a4361 100644 --- a/include/notifier.php +++ b/include/notifier.php @@ -345,7 +345,7 @@ function notifier_run($argv, $argc){ if($mail) { $public_message = false; // mail is not public - $body = fix_private_photos($item['body'],$owner['uid']); + $body = fix_private_photos($item['body'],$owner['uid'],null,$message[0]['contact-id']); $atom .= replace_macros($mail_template, array( '$name' => xmlify($owner['name']), diff --git a/mod/settings.php b/mod/settings.php index 40fa55eeaa..e6eb4011fa 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -15,6 +15,7 @@ function get_theme_config_file($theme){ } function settings_init(&$a) { + // These lines provide the javascript needed by the acl selector $a->page['htmlhead'] .= "