From e9251499dd63523a552bc3bf6274e3b851cba4c8 Mon Sep 17 00:00:00 2001 From: fabrixxm Date: Mon, 24 Jan 2011 22:00:02 +0100 Subject: [PATCH 01/16] Added proc_run() and modified all occurrence of proc_close(proc_open()) to use proc_run() --- boot.php | 30 ++++++++++++++++++++++++++++++ mod/dfrn_confirm.php | 4 ++-- mod/dfrn_notify.php | 6 +++--- mod/follow.php | 4 ++-- mod/item.php | 7 +++---- mod/like.php | 8 ++++---- mod/message.php | 4 ++-- mod/photos.php | 13 ++++++------- mod/profile_photo.php | 4 ++-- mod/profiles.php | 4 ++-- mod/settings.php | 4 ++-- 11 files changed, 58 insertions(+), 30 deletions(-) diff --git a/boot.php b/boot.php index 86ad29296..207faaf48 100644 --- a/boot.php +++ b/boot.php @@ -2215,3 +2215,33 @@ function link_compare($a,$b) { return true; return false; }} + + +/** + * + * Wrap calls to proc_close(proc_open()) and call hook + * so plugins can take part in process :) + * + * args: + * $cmd program to run + * next args are passed as $cmd command line + * + * e.g.: proc_run("ls","-la","/tmp"); + * + * $cmd and string args are surrounded with "" + */ +if(! function_exists('run_proc')) { +function proc_run($cmd){ + $args = func_get_args(); + foreach ($args as &$arg){ + if(is_string($arg)) $arg='"'.$arg.'"'; + } + $cmdline = implode($args," "); + + call_hooks("proc_run", $args); + + proc_close(proc_open($cmdline." &",array(),$foo)); +}} + +?> + diff --git a/mod/dfrn_confirm.php b/mod/dfrn_confirm.php index 41e0771af..24e8bf106 100644 --- a/mod/dfrn_confirm.php +++ b/mod/dfrn_confirm.php @@ -438,8 +438,8 @@ function dfrn_confirm_post(&$a,$handsfree = null) { $php_path = ((strlen($a->config['php_path'])) ? $a->config['php_path'] : 'php'); - proc_close(proc_open("\"$php_path\" \"include/notifier.php\" \"activity\" \"$i\" &", - array(),$foo)); + //proc_close(proc_open("\"$php_path\" \"include/notifier.php\" \"activity\" \"$i\" &", array(),$foo)); + proc_run($php_path,"include/notifier.php","activity","$i"); } diff --git a/mod/dfrn_notify.php b/mod/dfrn_notify.php index 49356d358..39d882411 100644 --- a/mod/dfrn_notify.php +++ b/mod/dfrn_notify.php @@ -283,9 +283,9 @@ function dfrn_notify_post(&$a) { $php_path = ((strlen($a->config['php_path'])) ? $a->config['php_path'] : 'php'); - proc_close(proc_open("\"$php_path\" \"include/notifier.php\" \"comment-import\" \"$posted_id\" &", - array(),$foo)); - + //proc_close(proc_open("\"$php_path\" \"include/notifier.php\" \"comment-import\" \"$posted_id\" &", array(),$foo)); + proc_run($php_path,"include/notifier.php","comment-import","$posted_id"); + if((! $is_like) && ($importer['notify-flags'] & NOTIFY_COMMENT) && (! $importer['self'])) { require_once('bbcode.php'); $from = stripslashes($datarray['author-name']); diff --git a/mod/follow.php b/mod/follow.php index e5eb7763b..102f46aec 100644 --- a/mod/follow.php +++ b/mod/follow.php @@ -206,8 +206,8 @@ function follow_post(&$a) { // pull feed and consume it, which should subscribe to the hub. $php_path = ((x($a->config,'php_path') && strlen($a->config['php_path'])) ? $a->config['php_path'] : 'php'); - proc_close(proc_open("\"$php_path\" \"include/poller.php\" \"$contact_id\" &", array(), $foo)); - + //proc_close(proc_open("\"$php_path\" \"include/poller.php\" \"$contact_id\" &", array(), $foo)); + proc_run($php_path,"include/poller.php","$contact_id"); // create a follow slap diff --git a/mod/item.php b/mod/item.php index feef7c95f..11e79a7ab 100644 --- a/mod/item.php +++ b/mod/item.php @@ -421,8 +421,7 @@ function item_post(&$a) { logger('mod_item: notifier invoked: ' . "\"$php_path\" \"include/notifier.php\" \"$notify_type\" \"$post_id\" &"); - proc_close(proc_open("\"$php_path\" \"include/notifier.php\" \"$notify_type\" \"$post_id\" &", - array(),$foo)); + proc_run($php_path, "include/notifier.php", $notify_type, "$post_id"); $datarray['id'] = $post_id; @@ -520,8 +519,8 @@ function item_content(&$a) { // send the notification upstream/downstream as the case may be - proc_close(proc_open("\"$php_path\" \"include/notifier.php\" \"drop\" \"$drop_id\" &", - array(), $foo)); + //proc_close(proc_open("\"$php_path\" \"include/notifier.php\" \"drop\" \"$drop_id\" &", array(), $foo)); + proc_run($php_path,"include/notifier.php","drop","$drop_id"); goaway($a->get_baseurl() . '/' . $_SESSION['return_url']); return; //NOTREACHED diff --git a/mod/like.php b/mod/like.php index 7b2097578..c78c1f030 100644 --- a/mod/like.php +++ b/mod/like.php @@ -102,8 +102,8 @@ function like_content(&$a) { ); $php_path = ((strlen($a->config['php_path'])) ? $a->config['php_path'] : 'php'); - proc_close(proc_open("\"$php_path\" \"include/notifier.php\" \"like\" \"$post_id\" &", - array(),$foo)); + //proc_close(proc_open("\"$php_path\" \"include/notifier.php\" \"like\" \"$post_id\" &", array(),$foo)); + proc_run($php_path,"include/notifier.php","like","$post_id"); return; } @@ -176,8 +176,8 @@ EOT; $php_path = ((strlen($a->config['php_path'])) ? $a->config['php_path'] : 'php'); - proc_close(proc_open("\"$php_path\" \"include/notifier.php\" \"like\" \"$post_id\" &", - array(),$foo)); + //proc_close(proc_open("\"$php_path\" \"include/notifier.php\" \"like\" \"$post_id\" &", array(),$foo)); + proc_run($php_path,"include/notifier.php","like","$post_id"); return; // NOTREACHED } \ No newline at end of file diff --git a/mod/message.php b/mod/message.php index 9cc2e2826..7615f22be 100644 --- a/mod/message.php +++ b/mod/message.php @@ -72,8 +72,8 @@ function message_post(&$a) { $php_path = ((strlen($a->config['php_path'])) ? $a->config['php_path'] : 'php'); if($post_id) { - proc_close(proc_open("\"$php_path\" \"include/notifier.php\" \"mail\" \"$post_id\" &", - array(),$foo)); + //proc_close(proc_open("\"$php_path\" \"include/notifier.php\" \"mail\" \"$post_id\" &", array(),$foo)); + proc_run($php_path,"include/notifier.php","mail","$post_id"); notice( t('Message sent.') . EOL ); } else { diff --git a/mod/photos.php b/mod/photos.php index e811ca395..11d234bf7 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -179,9 +179,8 @@ function photos_post(&$a) { // send the notification upstream/downstream as the case may be if($rr['visible']) - proc_close(proc_open("\"$php_path\" \"include/notifier.php\" \"drop\" \"$drop_id\" & ", - array(),$foo)); - + //proc_close(proc_open("\"$php_path\" \"include/notifier.php\" \"drop\" \"$drop_id\" & ",array(),$foo)); + proc_run($php_path,"include/notifier.php","drop","$drop_id"); } } } @@ -228,8 +227,8 @@ function photos_post(&$a) { $php_path = ((strlen($a->config['php_path'])) ? $a->config['php_path'] : 'php'); if($i[0]['visible']) - proc_close(proc_open("\"$php_path\" \"include/notifier.php\" \"drop\" \"$drop_id\" & ", - array(),$foo)); + //proc_close(proc_open("\"$php_path\" \"include/notifier.php\" \"drop\" \"$drop_id\" & ", array(),$foo)); + proc_run($php_path,"include/notifier.php","drop","$drop_id"); } } @@ -454,8 +453,8 @@ function photos_post(&$a) { $item_id = item_store($arr); $php_path = ((strlen($a->config['php_path'])) ? $a->config['php_path'] : 'php'); - proc_close(proc_open("\"$php_path\" \"include/notifier.php\" \"tag\" \"$item_id\" & ", - array(),$foo)); + //proc_close(proc_open("\"$php_path\" \"include/notifier.php\" \"tag\" \"$item_id\" & ",array(),$foo)); + proc_run($php_path,"include/notifier.php","tag","$item_id"); } } diff --git a/mod/profile_photo.php b/mod/profile_photo.php index 64093b2de..8b72bfca0 100644 --- a/mod/profile_photo.php +++ b/mod/profile_photo.php @@ -90,8 +90,8 @@ function profile_photo_post(&$a) { $php_path = ((strlen($a->config['php_path'])) ? $a->config['php_path'] : 'php'); $url = $_SESSION['my_url']; if($url && strlen(get_config('system','directory_submit_url'))) - proc_close(proc_open("\"$php_path\" \"include/directory.php\" \"$url\" &", - array(),$foo)); + //proc_close(proc_open("\"$php_path\" \"include/directory.php\" \"$url\" &",array(),$foo)); + proc_run($php_path,"include/directory.php","$url"); } else notice( t('Unable to process image') . EOL); diff --git a/mod/profiles.php b/mod/profiles.php index 0bb476549..d74219501 100644 --- a/mod/profiles.php +++ b/mod/profiles.php @@ -203,8 +203,8 @@ function profiles_post(&$a) { $php_path = ((strlen($a->config['php_path'])) ? $a->config['php_path'] : 'php'); $url = $_SESSION['my_url']; if($url && strlen(get_config('system','directory_submit_url'))) - proc_close(proc_open("\"$php_path\" \"include/directory.php\" \"$url\" &", - array(),$foo)); + //proc_close(proc_open("\"$php_path\" \"include/directory.php\" \"$url\" &", array(),$foo)); + proc_run($php_path,"include/directory.php","$url"); } } } diff --git a/mod/settings.php b/mod/settings.php index 1923c58da..fd75657c7 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -170,8 +170,8 @@ function settings_post(&$a) { $php_path = ((strlen($a->config['php_path'])) ? $a->config['php_path'] : 'php'); $url = $_SESSION['my_url']; if($url && strlen(get_config('system','directory_submit_url'))) - proc_close(proc_open("\"$php_path\" \"include/directory.php\" \"$url\" &", - array(),$foo)); + //proc_close(proc_open("\"$php_path\" \"include/directory.php\" \"$url\" &",array(),$foo)); + proc_run($php_path,"include/directory.php","$url"); } $_SESSION['theme'] = $theme; From 2020ea23b106c159a705c26e6c79156aafde75ba Mon Sep 17 00:00:00 2001 From: fabrixxm Date: Mon, 24 Jan 2011 22:01:56 +0100 Subject: [PATCH 02/16] Mods to script runned via CLI to permits to run also included --- include/directory.php | 4 ++-- include/notifier.php | 39 ++++++++++++++++++++++----------------- include/poller.php | 10 ++++++---- include/queue.php | 6 +++--- 4 files changed, 33 insertions(+), 26 deletions(-) diff --git a/include/directory.php b/include/directory.php index 5f835dc4b..4fdcf4928 100644 --- a/include/directory.php +++ b/include/directory.php @@ -11,7 +11,7 @@ if($argc != 2) - exit; + return; load_config('system'); @@ -24,5 +24,5 @@ fetch_url($dir . '?url=' . bin2hex($argv[1])); - exit; + return; diff --git a/include/notifier.php b/include/notifier.php index 4efdad4ce..bb38ecf51 100644 --- a/include/notifier.php +++ b/include/notifier.php @@ -16,7 +16,7 @@ require_once('include/bbcode.php'); if($argc < 3) - exit; + return; $a->set_baseurl(get_config('system','url')); @@ -29,8 +29,9 @@ case 'mail': default: $item_id = intval($argv[2]); - if(! $item_id) - killme(); + if(! $item_id){ + killme(); return; + } break; } @@ -42,8 +43,9 @@ $message = q("SELECT * FROM `mail` WHERE `id` = %d LIMIT 1", intval($item_id) ); - if(! count($message)) - killme(); + if(! count($message)){ + killme(); return; + } $uid = $message[0]['uid']; $recipients[] = $message[0]['contact-id']; $item = $message[0]; @@ -55,8 +57,9 @@ $r = q("SELECT `parent`, `uid`, `edited` FROM `item` WHERE `id` = %d LIMIT 1", intval($item_id) ); - if(! count($r)) - killme(); + if(! count($r)){ + killme(); return; + } $parent_id = $r[0]['parent']; $uid = $r[0]['uid']; @@ -66,8 +69,9 @@ intval($parent_id) ); - if(! count($items)) - killme(); + if(! count($items)){ + killme(); return; + } } $r = q("SELECT `contact`.*, `user`.`nickname`, `user`.`sprvkey`, `user`.`spubkey`, `user`.`page-flags` @@ -78,9 +82,9 @@ if(count($r)) $owner = $r[0]; - else - killme(); - + else { + killme(); return; + } $hub = get_config('system','huburl'); // If this is a public conversation, notify the feed hub @@ -150,8 +154,9 @@ $r = q("SELECT * FROM `contact` WHERE `id` IN ( $conversant_str ) AND `blocked` = 0 AND `pending` = 0"); - if( ! count($r)) - killme(); + if( ! count($r)){ + killme(); return; + } $contacts = $r; } @@ -248,9 +253,9 @@ $r = q("SELECT * FROM `contact` WHERE `id` IN ( %s ) AND `blocked` = 0 ", dbesc($recip_str) ); - if(! count($r)) - killme(); - + if(! count($r)){ + killme(); return; + } // delivery loop require_once('include/salmon.php'); diff --git a/include/poller.php b/include/poller.php index 024b9fbcd..a4bc60767 100644 --- a/include/poller.php +++ b/include/poller.php @@ -19,11 +19,12 @@ $a->set_baseurl(get_config('system','url')); logger('poller: start'); - + // run queue delivery process in the background $php_path = ((x($a->config,'php_path') && strlen($a->config['php_path'])) ? $a->config['php_path'] : 'php'); - proc_close(proc_open("\"$php_path\" \"include/queue.php\" &", array(), $foo)); + //proc_close(proc_open("\"$php_path\" \"include/queue.php\" &", array(), $foo)); + proc_run($php_path,"include/queue.php"); $hub_update = false; @@ -46,8 +47,9 @@ $sql_extra AND `self` = 0 AND `blocked` = 0 AND `readonly` = 0 ORDER BY RAND()"); - if(! count($contacts)) - killme(); + if(! count($contacts)){ + killme(); return; + } foreach($contacts as $contact) { diff --git a/include/queue.php b/include/queue.php index 96ddfa81b..fae93e328 100644 --- a/include/queue.php +++ b/include/queue.php @@ -50,9 +50,9 @@ function remove_queue_item($id) { $r = q("SELECT `id` FROM `queue` WHERE `last` < UTC_TIMESTAMP() - INTERVAL 15 MINUTE "); - if(! count($r)) - killme(); - + if(! count($r)){ + killme(); return; + } // delivery loop require_once('include/salmon.php'); From 3a575cdfdef10fdff6b96ef1bb71c19e441ff895 Mon Sep 17 00:00:00 2001 From: fabrixxm Date: Mon, 24 Jan 2011 22:02:53 +0100 Subject: [PATCH 03/16] first try of 'poormancron' whith 'proc_run' hook --- addon/poormancron/poormancron.php | 51 +++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 addon/poormancron/poormancron.php diff --git a/addon/poormancron/poormancron.php b/addon/poormancron/poormancron.php new file mode 100644 index 000000000..98231727d --- /dev/null +++ b/addon/poormancron/poormancron.php @@ -0,0 +1,51 @@ +300) { + set_config('poormancron','lastupdate', $now); + $b .= ""; + $b .= ""; + + } + +} + + +function poormancron_procrun($a, $args) { + $argv = array_shift($args); + $argc = count($argv); + function killme(){ + // pass + } + require_once($argv[0]); +} + + +?> From 517d6812dabfbb93b34045048e8894fb54d220a7 Mon Sep 17 00:00:00 2001 From: Fabio Comuni Date: Fri, 28 Jan 2011 14:01:50 +0100 Subject: [PATCH 04/16] cal proc_run hook before string escape --- boot.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/boot.php b/boot.php index 207faaf48..d3187648c 100644 --- a/boot.php +++ b/boot.php @@ -1655,7 +1655,6 @@ function attribute_contains($attr,$s) { if(! function_exists('logger')) { function logger($msg,$level = 0) { - $debugging = get_config('system','debugging'); $loglevel = intval(get_config('system','loglevel')); $logfile = get_config('system','logfile'); @@ -2233,15 +2232,13 @@ function link_compare($a,$b) { if(! function_exists('run_proc')) { function proc_run($cmd){ $args = func_get_args(); + call_hooks("proc_run", $args); + foreach ($args as &$arg){ if(is_string($arg)) $arg='"'.$arg.'"'; } $cmdline = implode($args," "); - - call_hooks("proc_run", $args); - proc_close(proc_open($cmdline." &",array(),$foo)); }} -?> - +?> \ No newline at end of file From ef33ca67501559fba72281f0d1f32fc6ef43704d Mon Sep 17 00:00:00 2001 From: Fabio Comuni Date: Fri, 28 Jan 2011 14:04:18 +0100 Subject: [PATCH 05/16] modded scripts to be runned in cli so they can be included and executed in main program --- include/directory.php | 28 +++++++++++++++++--------- include/notifier.php | 47 ++++++++++++++++++++++++++----------------- include/poller.php | 32 ++++++++++++++++++----------- include/queue.php | 31 ++++++++++++++++++---------- 4 files changed, 88 insertions(+), 50 deletions(-) diff --git a/include/directory.php b/include/directory.php index 4fdcf4928..2c9daa5ea 100644 --- a/include/directory.php +++ b/include/directory.php @@ -1,14 +1,19 @@ Date: Fri, 28 Jan 2011 14:04:40 +0100 Subject: [PATCH 06/16] updated poormancron plugin --- addon/poormancron/poormancron.php | 35 ++++++++++++++----------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/addon/poormancron/poormancron.php b/addon/poormancron/poormancron.php index 98231727d..c31d2772c 100644 --- a/addon/poormancron/poormancron.php +++ b/addon/poormancron/poormancron.php @@ -7,18 +7,15 @@ */ function poormancron_install() { - - register_hook('profile_sidebar', 'addon/poormancron/poormancron.php', 'poormancron_hook'); - register_hook('proc_run', 'addon/poormancron/poormancron.php','poormancron_procrun'); - + register_hook('page_end', 'addon/poormancron/poormancron.php', 'poormancron_hook'); + register_hook('proc_run', 'addon/poormancron/poormancron.php','poormancron_procrun'); logger("installed poormancron"); } function poormancron_uninstall() { - - unregister_hook('profile_sidebar', 'addon/poormancron/poormancron.php', 'poormancron_hook'); - unregister_hook('proc_run', 'addon/poormancron/poormancron.php','poormancron_procrun'); - logger("removed poormancron"); + unregister_hook('page_end', 'addon/poormancron/poormancron.php', 'poormancron_hook'); + unregister_hook('proc_run', 'addon/poormancron/poormancron.php','poormancron_procrun'); + logger("removed poormancron"); } @@ -30,22 +27,22 @@ function poormancron_hook($a,&$b) { // 300 secs, 5 mins if (!$lastupdate || ($now-$lastupdate)>300) { set_config('poormancron','lastupdate', $now); - $b .= ""; - $b .= ""; - + $php_path = ((strlen($a->config['php_path'])) ? $a->config['php_path'] : 'php'); + proc_run($php_path,"include/poller.php"); } - } - -function poormancron_procrun($a, $args) { - $argv = array_shift($args); +function poormancron_procrun($a, $argv) { + logger("poormancron procrun ".implode(", ",$argv)); + array_shift($argv); $argc = count($argv); - function killme(){ - // pass - } - require_once($argv[0]); + logger("poormancron procrun require_once ".basename($argv[0])); + require_once(basename($argv[0])); + $funcname=str_replace(".php", "", basename($argv[0]))."_run"; + + $funcname($argv, $argc); } + ?> From 45bbf1cd3fc25ecbcfe68bea74d704c355406d40 Mon Sep 17 00:00:00 2001 From: Friendika Date: Sat, 29 Jan 2011 01:25:46 -0800 Subject: [PATCH 07/16] document poormancron as alternative in INSTALL.txt --- INSTALL.txt | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/INSTALL.txt b/INSTALL.txt index 70e4f24ef..12dca9c5b 100644 --- a/INSTALL.txt +++ b/INSTALL.txt @@ -29,7 +29,7 @@ php.ini file - Mysql 5.x - ability to schedule jobs with cron (Linux/Mac) or Scheduled Tasks -(Windows) +(Windows) [Note: other options are presented in Section 7 of this document] - Installation into a top-level domain or sub-domain (without a directory/path component in the URL) is preferred. Directory paths will @@ -89,3 +89,18 @@ You can generally find the location of PHP by executing "which php". If you have troubles with this section please contact your hosting provider for assistance. Friendika will not work correctly if you cannot perform this step. +Alternative: You may be able to use the 'poormancron' plugin to perform this +step if you are using a recent Friendika release. To do this, edit the file +".htconfig.php" and look for a line describing your plugins. On a fresh +installation, it will look like + +$a->config['system']['addon'] = 'js_upload'; + +This indicates the "js_upload" addon module is enabled. You may add additional +addons/plugins using this same line in the configuration file. Change it to +read + +$a->config['system']['addon'] = 'js_upload,poormancron'; + +and save your changes. + From f970d9ab4d608d36aca405c11746082156e1e661 Mon Sep 17 00:00:00 2001 From: Friendika Date: Sat, 29 Jan 2011 22:35:11 -0800 Subject: [PATCH 08/16] implement SSL redirection policy (none, full, selfsign) --- boot.php | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/boot.php b/boot.php index 223c9416d..83ceaac28 100644 --- a/boot.php +++ b/boot.php @@ -10,6 +10,16 @@ define ( 'EOL', "
\r\n" ); define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' ); define ( 'DOWN_ARROW', '⇩' ); + +/** + * SSL redirection policies + */ + +define ( 'SSL_POLICY_NONE', 0 ); +define ( 'SSL_POLICY_FULL', 1 ); +define ( 'SSL_POLICY_SELFSIGN' 2 ); + + /** * log levels */ @@ -273,7 +283,14 @@ class App { if(strlen($this->baseurl)) return $this->baseurl; - $this->baseurl = (($ssl) ? 'https' : $this->scheme) . "://" . $this->hostname . ((isset($this->path) && strlen($this->path)) ? '/' . $this->path : '' ); + $scheme = $this->scheme; + + if(($ssl) || ($a->config['ssl_policy'] == SSL_POLICY_FULL)) + $scheme = 'https'; + if(($a->config['ssl_policy'] == SSL_POLICY_SELFSIGN) && (local_user() || x($_POST,'auth-params'))) + $scheme = 'https'; + + $this->baseurl = ( $scheme . "://" . $this->hostname . ((isset($this->path) && strlen($this->path)) ? '/' . $this->path : '' ); return $this->baseurl; } From a362dc46e3ea75a9223e753d854631f2b80c6762 Mon Sep 17 00:00:00 2001 From: Friendika Date: Sat, 29 Jan 2011 22:38:58 -0800 Subject: [PATCH 09/16] cleanup ssl_policy implementation --- boot.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/boot.php b/boot.php index 83ceaac28..c4afa07b0 100644 --- a/boot.php +++ b/boot.php @@ -17,7 +17,7 @@ define ( 'DOWN_ARROW', '⇩' ); define ( 'SSL_POLICY_NONE', 0 ); define ( 'SSL_POLICY_FULL', 1 ); -define ( 'SSL_POLICY_SELFSIGN' 2 ); +define ( 'SSL_POLICY_SELFSIGN', 2 ); /** @@ -280,8 +280,8 @@ class App { } function get_baseurl($ssl = false) { - if(strlen($this->baseurl)) - return $this->baseurl; +// if(strlen($this->baseurl)) +// return $this->baseurl; $scheme = $this->scheme; @@ -290,7 +290,7 @@ class App { if(($a->config['ssl_policy'] == SSL_POLICY_SELFSIGN) && (local_user() || x($_POST,'auth-params'))) $scheme = 'https'; - $this->baseurl = ( $scheme . "://" . $this->hostname . ((isset($this->path) && strlen($this->path)) ? '/' . $this->path : '' ); + $this->baseurl = $scheme . "://" . $this->hostname . ((isset($this->path) && strlen($this->path)) ? '/' . $this->path : '' ); return $this->baseurl; } From 8673b08c1c1daffcd166ad96b2b3729a893ab5c8 Mon Sep 17 00:00:00 2001 From: Friendika Date: Sat, 29 Jan 2011 22:41:01 -0800 Subject: [PATCH 10/16] even more cleanup prior to push --- boot.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/boot.php b/boot.php index c4afa07b0..bb7819fde 100644 --- a/boot.php +++ b/boot.php @@ -17,7 +17,7 @@ define ( 'DOWN_ARROW', '⇩' ); define ( 'SSL_POLICY_NONE', 0 ); define ( 'SSL_POLICY_FULL', 1 ); -define ( 'SSL_POLICY_SELFSIGN', 2 ); +define ( 'SSL_POLICY_SELFSIGN', 2 ); /** @@ -280,8 +280,6 @@ class App { } function get_baseurl($ssl = false) { -// if(strlen($this->baseurl)) -// return $this->baseurl; $scheme = $this->scheme; From c0128432825416929b00d0fa9563f2d1f92e9ba3 Mon Sep 17 00:00:00 2001 From: Friendika Date: Sat, 29 Jan 2011 23:47:40 -0800 Subject: [PATCH 11/16] identify email-only contacts --- mod/follow.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/mod/follow.php b/mod/follow.php index a90ae3f51..62ba2585c 100644 --- a/mod/follow.php +++ b/mod/follow.php @@ -10,7 +10,9 @@ function follow_post(&$a) { // NOTREACHED } - $url = notags(trim($_POST['url'])); + $url = $orig_url = notags(trim($_POST['url'])); + + $email_conversant = false; if($url) { $links = lrdd($url); @@ -29,6 +31,11 @@ function follow_post(&$a) { } } + else { + if((strpos($orig_url,'@')) && validate_email($orig_url)) { + $email_conversant = true; + } + } } // If we find a DFRN site, send our subscriber to the other person's From e8d52d879baf6a35de335cb2ef6a2fb0a5eb8b3e Mon Sep 17 00:00:00 2001 From: Friendika Date: Sun, 30 Jan 2011 15:28:50 -0800 Subject: [PATCH 12/16] more debugging to see if the google push hub is even trying to publish our content. --- mod/dfrn_poll.php | 1 + mod/item.php | 1 + 2 files changed, 2 insertions(+) diff --git a/mod/dfrn_poll.php b/mod/dfrn_poll.php index 1061cdb89..85e7fc0af 100644 --- a/mod/dfrn_poll.php +++ b/mod/dfrn_poll.php @@ -26,6 +26,7 @@ function dfrn_poll_init(&$a) { } if(($dfrn_id === '') && (! x($_POST,'dfrn_id')) && ($a->argc > 1)) { + logger('dfrn_poll: public feed request from ' . $_SERVER['REMOTE_ADDR'] ); header("Content-type: application/atom+xml"); $o = get_feed_for($a, '*', $a->argv[1],$last_update); echo $o; diff --git a/mod/item.php b/mod/item.php index 11e79a7ab..cc1886c17 100644 --- a/mod/item.php +++ b/mod/item.php @@ -71,6 +71,7 @@ function item_post(&$a) { $location = notags(trim($_POST['location'])); $coord = notags(trim($_POST['coord'])); $verb = notags(trim($_POST['verb'])); + $emailcc = notags(trim($_POST['emailcc'])); if(! strlen($body)) { notice( t('Empty post discarded.') . EOL ); From a598f17e6d95d8a82df2994d61bfab74271dfe58 Mon Sep 17 00:00:00 2001 From: Friendika Date: Sun, 30 Jan 2011 18:25:41 -0800 Subject: [PATCH 13/16] wrong ref in ssl policy --- boot.php | 4 ++-- include/notifier.php | 2 +- include/poller.php | 2 +- index.php | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/boot.php b/boot.php index bb7819fde..6b4fa080e 100644 --- a/boot.php +++ b/boot.php @@ -283,9 +283,9 @@ class App { $scheme = $this->scheme; - if(($ssl) || ($a->config['ssl_policy'] == SSL_POLICY_FULL)) + if(($ssl) || ($this->config['ssl_policy'] == SSL_POLICY_FULL)) $scheme = 'https'; - if(($a->config['ssl_policy'] == SSL_POLICY_SELFSIGN) && (local_user() || x($_POST,'auth-params'))) + if(($this->config['ssl_policy'] == SSL_POLICY_SELFSIGN) && (local_user() || x($_POST,'auth-params'))) $scheme = 'https'; $this->baseurl = $scheme . "://" . $this->hostname . ((isset($this->path) && strlen($this->path)) ? '/' . $this->path : '' ); diff --git a/include/notifier.php b/include/notifier.php index dd5d55ed0..59e29d7d1 100644 --- a/include/notifier.php +++ b/include/notifier.php @@ -363,7 +363,7 @@ function notifier_run($argv, $argc){ continue; $params = 'hub.mode=publish&hub.url=' . urlencode($a->get_baseurl() . '/dfrn_poll/' . $owner['nickname'] ); post_url($h,$params); - logger('pubsub: publish: ' . $h . ' returned ' . $a->get_curl_code()); + logger('pubsub: publish: ' . $h . ' ' . $params . ' returned ' . $a->get_curl_code()); if(count($hubs) > 1) sleep(7); // try and avoid multiple hubs responding at precisely the same time } diff --git a/include/poller.php b/include/poller.php index 1003b2f08..0dbc6f583 100644 --- a/include/poller.php +++ b/include/poller.php @@ -76,7 +76,7 @@ function poller_run($argv, $argc){ $contact['priority'] = (($interval !== false) ? intval($interval) : 3); $hub_update = false; - if(datetime_convert('UTC','UTC', 'now') > datetime_convert('UTC','UTC', $t . " + 1 day")) + if((datetime_convert('UTC','UTC', 'now') > datetime_convert('UTC','UTC', $t . " + 1 day")) || $force) $hub_update = true; } diff --git a/index.php b/index.php index ae6a578cb..685a76a13 100644 --- a/index.php +++ b/index.php @@ -140,7 +140,7 @@ if(strlen($a->module)) { } else { if((x($_SERVER,'QUERY_STRING')) && ($_SERVER['QUERY_STRING'] === 'q=internal_error.html') && isset($dreamhost_error_hack)) { - logger('index.php: dreamhost_error_hack invoked'); + logger('index.php: dreamhost_error_hack invoked. Original URI =' . $_SERVER['REQUEST_URI']); goaway($a->get_baseurl() . $_SERVER['REQUEST_URI']); } From 3eefe8b50003c858d4930c03cc06d2679a14347c Mon Sep 17 00:00:00 2001 From: Friendika Date: Sun, 30 Jan 2011 19:38:03 -0800 Subject: [PATCH 14/16] more ssl_policy cleanup, allow manual feed update per contact when hub is whacked, log feed parse errors --- boot.php | 10 ++++++---- include/items.php | 4 ++++ include/poller.php | 3 +++ mod/contacts.php | 10 ++++++++++ view/de/contact_edit.tpl | 5 +++-- view/en/contact_edit.tpl | 5 +++-- view/fr/contact_edit.tpl | 5 +++-- view/it/contact_edit.tpl | 5 +++-- view/theme/default/style.css | 3 +++ view/theme/duepuntozero/style.css | 4 ++++ 10 files changed, 42 insertions(+), 12 deletions(-) diff --git a/boot.php b/boot.php index 6b4fa080e..6cbb4f07c 100644 --- a/boot.php +++ b/boot.php @@ -283,10 +283,12 @@ class App { $scheme = $this->scheme; - if(($ssl) || ($this->config['ssl_policy'] == SSL_POLICY_FULL)) - $scheme = 'https'; - if(($this->config['ssl_policy'] == SSL_POLICY_SELFSIGN) && (local_user() || x($_POST,'auth-params'))) - $scheme = 'https'; + if(x($this->config,'ssl_policy')) { + if(($ssl) || ($this->config['ssl_policy'] == SSL_POLICY_FULL)) + $scheme = 'https'; + if(($this->config['ssl_policy'] == SSL_POLICY_SELFSIGN) && (local_user() || x($_POST,'auth-params'))) + $scheme = 'https'; + } $this->baseurl = $scheme . "://" . $this->hostname . ((isset($this->path) && strlen($this->path)) ? '/' . $this->path : '' ); return $this->baseurl; diff --git a/include/items.php b/include/items.php index e238280fc..a5991d663 100644 --- a/include/items.php +++ b/include/items.php @@ -903,6 +903,10 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0) { $feed->enable_order_by_date(false); $feed->init(); + if($feed->error()) + logger('consume_feed: Error parsing XML: ' . $feed->error()); + + // Check at the feed level for updated contact name and/or photo $name_updated = ''; diff --git a/include/poller.php b/include/poller.php index 0dbc6f583..4567a5cfc 100644 --- a/include/poller.php +++ b/include/poller.php @@ -58,6 +58,9 @@ function poller_run($argv, $argc){ foreach($contacts as $contact) { + if($manual_id) + $contact['last-update'] = '0000-00-00 00:00:00'; + if($contact['priority'] || $contact['subhub']) { $hub_update = true; diff --git a/mod/contacts.php b/mod/contacts.php index 177ca9973..4c627c88f 100644 --- a/mod/contacts.php +++ b/mod/contacts.php @@ -121,6 +121,15 @@ function contacts_content(&$a) { return; // NOTREACHED } + if($cmd === 'update') { + + // pull feed and consume it, which should subscribe to the hub. + + $php_path = ((x($a->config,'php_path') && strlen($a->config['php_path'])) ? $a->config['php_path'] : 'php'); + proc_run($php_path,"include/poller.php","$contact_id"); + goaway($a->get_baseurl() . '/contacts/' . $contact_id); + // NOTREACHED + } if($cmd === 'block') { $blocked = (($orig_record[0]['blocked']) ? 0 : 1); @@ -248,6 +257,7 @@ function contacts_content(&$a) { '$last_update' => (($r[0]['last-update'] == '0000-00-00 00:00:00') ? t('Never') : datetime_convert('UTC',date_default_timezone_get(),$r[0]['last-update'],'D, j M Y, g:i A')), + '$udnow' => t('Update now'), '$profile_select' => contact_profile_assign($r[0]['profile-id'],(($r[0]['network'] !== 'dfrn') ? true : false)), '$contact_id' => $r[0]['id'], '$block_text' => (($r[0]['blocked']) ? t('Unblock this contact') : t('Block this contact') ), diff --git a/view/de/contact_edit.tpl b/view/de/contact_edit.tpl index fcd3f2d66..0b32bdd66 100644 --- a/view/de/contact_edit.tpl +++ b/view/de/contact_edit.tpl @@ -3,6 +3,8 @@
$name
+
+
@@ -24,13 +26,12 @@
- -
$lastupdtext$last_update
$updpub
$poll_interval +
diff --git a/view/en/contact_edit.tpl b/view/en/contact_edit.tpl index ea546b784..9aca60188 100644 --- a/view/en/contact_edit.tpl +++ b/view/en/contact_edit.tpl @@ -3,6 +3,8 @@
$name
+ +
@@ -24,13 +26,12 @@
- -
$lastupdtext$last_update
$updpub
$poll_interval +
diff --git a/view/fr/contact_edit.tpl b/view/fr/contact_edit.tpl index c7d2d5975..9f36ddcc4 100644 --- a/view/fr/contact_edit.tpl +++ b/view/fr/contact_edit.tpl @@ -3,6 +3,8 @@
$name
+ +
@@ -24,14 +26,13 @@
- -
$lastupdtext$last_update
$updpub
$poll_interval +
diff --git a/view/it/contact_edit.tpl b/view/it/contact_edit.tpl index d4217ba8c..ac0f13a54 100644 --- a/view/it/contact_edit.tpl +++ b/view/it/contact_edit.tpl @@ -3,6 +3,8 @@
$name
+ +
@@ -24,13 +26,12 @@
- -
$lastupdtext$last_update
$updpub
$poll_interval +
diff --git a/view/theme/default/style.css b/view/theme/default/style.css index 3ef63e265..ae45a4244 100644 --- a/view/theme/default/style.css +++ b/view/theme/default/style.css @@ -1333,6 +1333,9 @@ input#dfrn-url { #contact-edit-poll-text { margin-bottom: 10px; } +#contact-edit-update-now { + margin-top: 15px; +} #contact-edit-photo-wrapper { margin-bottom: 20px; diff --git a/view/theme/duepuntozero/style.css b/view/theme/duepuntozero/style.css index 59a5bf88a..d6a1744a6 100644 --- a/view/theme/duepuntozero/style.css +++ b/view/theme/duepuntozero/style.css @@ -1209,6 +1209,10 @@ input#dfrn-url { margin-bottom: 10px; } +#contact-edit-update-now { + margin-top: 15px; +} + #contact-edit-photo-wrapper { margin-bottom: 20px; } From 6935d34e7683fa2cf43092b39346c3c43cb8d38d Mon Sep 17 00:00:00 2001 From: Friendika Date: Sun, 30 Jan 2011 19:49:26 -0800 Subject: [PATCH 15/16] disable "take me home" hotkey, different on FF (shift-home), IE ($). --- include/main.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/include/main.js b/include/main.js index fcd1d6fee..a24f0ae08 100644 --- a/include/main.js +++ b/include/main.js @@ -44,12 +44,13 @@ $('#pause').html(''); } } - if(event.keyCode == '36' && event.shiftKey == true) { - if(homebase !== undefined) { - event.preventDefault(); - document.location = homebase; - } - } +// this is shift-home on FF, but $ on IE, disabling until I figure out why the diff. +// if(event.keyCode == '36' && event.shiftKey == true) { +// if(homebase !== undefined) { +// event.preventDefault(); +// document.location = homebase; +// } +// } }); }); From d8877b88d6c26e29019312f02297411817692361 Mon Sep 17 00:00:00 2001 From: Friendika Date: Sun, 30 Jan 2011 22:45:02 -0800 Subject: [PATCH 16/16] limit privacy ACL's to networks which can handle privacy --- include/acl_selectors.php | 17 +++++++++-------- include/main.js | 1 + 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/include/acl_selectors.php b/include/acl_selectors.php index d0952421e..554782a82 100644 --- a/include/acl_selectors.php +++ b/include/acl_selectors.php @@ -30,7 +30,7 @@ function group_select($selname,$selclass,$preselected = false,$size = 4) { -function contact_select($selname, $selclass, $preselected = false, $size = 4, $privmail = false, $celeb = false) { +function contact_select($selname, $selclass, $preselected = false, $size = 4, $privmail = false, $celeb = false, $privatenet = false) { $o = ''; @@ -43,6 +43,10 @@ function contact_select($selname, $selclass, $preselected = false, $size = 4, $p $sql_extra .= sprintf(" AND `rel` = %d ", intval(REL_BUD)); } + if($privmail || $privatenet) { + $sql_extra .= " AND `network` IN ( 'dfrn' ) "; + } + if($privmail) $o .= "