From e9251499dd63523a552bc3bf6274e3b851cba4c8 Mon Sep 17 00:00:00 2001 From: fabrixxm Date: Mon, 24 Jan 2011 22:00:02 +0100 Subject: [PATCH] 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 86ad29296c..207faaf480 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 41e0771afa..24e8bf106a 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 49356d358c..39d8824110 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 e5eb7763bf..102f46aec6 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 feef7c95f8..11e79a7ab2 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 7b20975781..c78c1f030c 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 9cc2e2826c..7615f22bec 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 e811ca3957..11d234bf73 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 64093b2de0..8b72bfca06 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 0bb476549e..d74219501a 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 1923c58da1..fd75657c71 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;