summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/common.php27
-rwxr-xr-xscripts/enjitqueuehandler.php14
-rwxr-xr-xscripts/facebookqueuehandler.php11
-rwxr-xr-xscripts/jabberqueuehandler.php5
-rwxr-xr-xscripts/maildaemon.php6
-rwxr-xr-xscripts/ombqueuehandler.php11
-rw-r--r--scripts/pingqueuehandler.php5
-rwxr-xr-xscripts/publicqueuehandler.php9
-rwxr-xr-xscripts/smsqueuehandler.php9
-rwxr-xr-xscripts/synctwitterfriends.php5
-rw-r--r--scripts/triminboxes.php9
-rwxr-xr-xscripts/twitterqueuehandler.php11
-rwxr-xr-xscripts/twitterstatusfetcher.php7
-rwxr-xr-xscripts/xmppconfirmhandler.php9
-rwxr-xr-xscripts/xmppdaemon.php6
15 files changed, 110 insertions, 34 deletions
diff --git a/lib/common.php b/lib/common.php
index 0333030e1..a8c7634f6 100644
--- a/lib/common.php
+++ b/lib/common.php
@@ -67,14 +67,25 @@ function _sn_to_path($sn)
return $p;
}
-// try to figure out where we are
-
-$_server = array_key_exists('SERVER_NAME', $_SERVER) ?
- strtolower($_SERVER['SERVER_NAME']) :
- null;
-$_path = array_key_exists('SCRIPT_NAME', $_SERVER) ?
- _sn_to_path($_SERVER['SCRIPT_NAME']) :
- null;
+// try to figure out where we are. $server and $path
+// can be set by including module, else we guess based
+// on HTTP info.
+
+if (isset($server)) {
+ $_server = $server;
+} else {
+ $_server = array_key_exists('SERVER_NAME', $_SERVER) ?
+ strtolower($_SERVER['SERVER_NAME']) :
+ null;
+}
+
+if (isset($path)) {
+ $_path = $path;
+} else {
+ $_path = array_key_exists('SCRIPT_NAME', $_SERVER) ?
+ _sn_to_path($_SERVER['SCRIPT_NAME']) :
+ null;
+}
// default configuration, overwritten in config.php
diff --git a/scripts/enjitqueuehandler.php b/scripts/enjitqueuehandler.php
index c28bbe01d..15ab3a427 100755
--- a/scripts/enjitqueuehandler.php
+++ b/scripts/enjitqueuehandler.php
@@ -27,6 +27,11 @@ if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
define('LACONICA', true);
+// Preset the server at the command line
+
+$server = ($argc > 2) ? $argv[2] : null;
+$path = ($argc > 3) ? $argv[3] : null;
+
require_once(INSTALLDIR . '/lib/common.php');
require_once(INSTALLDIR . '/lib/mail.php');
require_once(INSTALLDIR . '/lib/queuehandler.php');
@@ -35,7 +40,6 @@ set_error_handler('common_error_handler');
class EnjitQueueHandler extends QueueHandler
{
-
function transport()
{
return 'enjit';
@@ -60,7 +64,6 @@ class EnjitQueueHandler extends QueueHandler
return "skipped";
}
-
#
# Build an Atom message from the notice
#
@@ -93,8 +96,8 @@ class EnjitQueueHandler extends QueueHandler
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
-
- curl_setopt($ch, CURLOPT_HEADER, 1);
+
+ curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1) ;
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
@@ -103,7 +106,7 @@ class EnjitQueueHandler extends QueueHandler
#
# curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
# curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
- # curl_setopt($ch, CURLOPT_VERBOSE, 1);
+ # curl_setopt($ch, CURLOPT_VERBOSE, 1);
$result = curl_exec($ch);
@@ -115,7 +118,6 @@ class EnjitQueueHandler extends QueueHandler
return $code;
}
-
}
diff --git a/scripts/facebookqueuehandler.php b/scripts/facebookqueuehandler.php
index a505e8ecc..f9123db8c 100755
--- a/scripts/facebookqueuehandler.php
+++ b/scripts/facebookqueuehandler.php
@@ -27,6 +27,11 @@ if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
define('LACONICA', true);
+// Preset the server at the command line
+
+$server = ($argc > 2) ? $argv[2] : null;
+$path = ($argc > 3) ? $argv[3] : null;
+
require_once(INSTALLDIR . '/lib/common.php');
require_once(INSTALLDIR . '/lib/facebookutil.php');
require_once(INSTALLDIR . '/lib/queuehandler.php');
@@ -35,12 +40,12 @@ set_error_handler('common_error_handler');
class FacebookQueueHandler extends QueueHandler
{
-
+
function transport()
{
return 'facebook';
}
-
+
function start()
{
$this->log(LOG_INFO, "INITIALIZE");
@@ -51,7 +56,7 @@ class FacebookQueueHandler extends QueueHandler
{
return facebookBroadcastNotice($notice);
}
-
+
function finish()
{
}
diff --git a/scripts/jabberqueuehandler.php b/scripts/jabberqueuehandler.php
index 130be6e04..b848442fd 100755
--- a/scripts/jabberqueuehandler.php
+++ b/scripts/jabberqueuehandler.php
@@ -27,6 +27,11 @@ if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
define('LACONICA', true);
+// Preset the server at the command line
+
+$server = ($argc > 2) ? $argv[2] : null;
+$path = ($argc > 3) ? $argv[3] : null;
+
require_once(INSTALLDIR . '/lib/common.php');
require_once(INSTALLDIR . '/lib/jabber.php');
require_once(INSTALLDIR . '/lib/xmppqueuehandler.php');
diff --git a/scripts/maildaemon.php b/scripts/maildaemon.php
index ccc1eef52..dc3ab0b56 100755
--- a/scripts/maildaemon.php
+++ b/scripts/maildaemon.php
@@ -27,6 +27,11 @@ if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
define('LACONICA', true);
+// Preset the server at the command line
+
+$server = ($argc > 1) ? $argv[1] : null;
+$path = ($argc > 2) ? $argv[2] : null;
+
require_once(INSTALLDIR . '/lib/common.php');
require_once(INSTALLDIR . '/lib/mail.php');
require_once('Mail/mimeDecode.php');
@@ -36,7 +41,6 @@ require_once('Mail/mimeDecode.php');
class MailerDaemon
{
-
function __construct()
{
}
diff --git a/scripts/ombqueuehandler.php b/scripts/ombqueuehandler.php
index 5fe7cf01d..4c5890f57 100755
--- a/scripts/ombqueuehandler.php
+++ b/scripts/ombqueuehandler.php
@@ -27,6 +27,11 @@ if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
define('LACONICA', true);
+// Preset the server at the command line
+
+$server = ($argc > 2) ? $argv[2] : null;
+$path = ($argc > 3) ? $argv[3] : null;
+
require_once(INSTALLDIR . '/lib/common.php');
require_once(INSTALLDIR . '/lib/omb.php');
require_once(INSTALLDIR . '/lib/queuehandler.php');
@@ -35,12 +40,12 @@ set_error_handler('common_error_handler');
class OmbQueueHandler extends QueueHandler
{
-
+
function transport()
{
return 'omb';
}
-
+
function start()
{
$this->log(LOG_INFO, "INITIALIZE");
@@ -56,7 +61,7 @@ class OmbQueueHandler extends QueueHandler
return omb_broadcast_remote_subscribers($notice);
}
}
-
+
function finish()
{
}
diff --git a/scripts/pingqueuehandler.php b/scripts/pingqueuehandler.php
index f57752cd2..84ef9be27 100644
--- a/scripts/pingqueuehandler.php
+++ b/scripts/pingqueuehandler.php
@@ -27,6 +27,11 @@ if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
define('LACONICA', true);
+// Preset the server at the command line
+
+$server = ($argc > 2) ? $argv[2] : null;
+$path = ($argc > 3) ? $argv[3] : null;
+
require_once(INSTALLDIR . '/lib/common.php');
require_once(INSTALLDIR . '/lib/ping.php');
require_once(INSTALLDIR . '/lib/queuehandler.php');
diff --git a/scripts/publicqueuehandler.php b/scripts/publicqueuehandler.php
index c0452cbee..017174ed8 100755
--- a/scripts/publicqueuehandler.php
+++ b/scripts/publicqueuehandler.php
@@ -27,6 +27,11 @@ if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
define('LACONICA', true);
+// Preset the server at the command line
+
+$server = ($argc > 2) ? $argv[2] : null;
+$path = ($argc > 3) ? $argv[3] : null;
+
require_once(INSTALLDIR . '/lib/common.php');
require_once(INSTALLDIR . '/lib/jabber.php');
require_once(INSTALLDIR . '/lib/xmppqueuehandler.php');
@@ -35,12 +40,12 @@ set_error_handler('common_error_handler');
class PublicQueueHandler extends XmppQueueHandler
{
-
+
function transport()
{
return 'public';
}
-
+
function handle_notice($notice)
{
try {
diff --git a/scripts/smsqueuehandler.php b/scripts/smsqueuehandler.php
index 631719aa2..0366d4c4c 100755
--- a/scripts/smsqueuehandler.php
+++ b/scripts/smsqueuehandler.php
@@ -27,6 +27,11 @@ if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
define('LACONICA', true);
+// Preset the server at the command line
+
+$server = ($argc > 2) ? $argv[2] : null;
+$path = ($argc > 3) ? $argv[3] : null;
+
require_once(INSTALLDIR . '/lib/common.php');
require_once(INSTALLDIR . '/lib/mail.php');
require_once(INSTALLDIR . '/lib/queuehandler.php');
@@ -35,7 +40,7 @@ set_error_handler('common_error_handler');
class SmsQueueHandler extends QueueHandler
{
-
+
function transport()
{
return 'sms';
@@ -51,7 +56,7 @@ class SmsQueueHandler extends QueueHandler
{
return mail_broadcast_notice_sms($notice);
}
-
+
function finish()
{
}
diff --git a/scripts/synctwitterfriends.php b/scripts/synctwitterfriends.php
index 8a338f1b4..7f418894e 100755
--- a/scripts/synctwitterfriends.php
+++ b/scripts/synctwitterfriends.php
@@ -30,6 +30,11 @@ define('LACONICA', true);
// Uncomment this to get useful console output
//define('SCRIPT_DEBUG', true);
+// Preset the server at the command line
+
+$server = ($argc > 1) ? $argv[1] : null;
+$path = ($argc > 2) ? $argv[2] : null;
+
require_once(INSTALLDIR . '/lib/common.php');
// Make a lockfile
diff --git a/scripts/triminboxes.php b/scripts/triminboxes.php
index 0d2eaeaf0..0d545b326 100644
--- a/scripts/triminboxes.php
+++ b/scripts/triminboxes.php
@@ -32,6 +32,11 @@ mb_internal_encoding('UTF-8');
define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
define('LACONICA', true);
+// Preset the server at the command line
+
+$server = ($argc > 2) ? $argv[2] : null;
+$path = ($argc > 3) ? $argv[3] : null;
+
require_once(INSTALLDIR . '/lib/common.php');
$user = new User();
@@ -74,10 +79,10 @@ while ($user->fetch()) {
$delay = 3.0 * ($finish - $start);
print "Delaying $delay seconds...";
-
+
// Wait to let slaves catch up
usleep($delay * 1000000);
-
+
print "DONE.\n";
}
diff --git a/scripts/twitterqueuehandler.php b/scripts/twitterqueuehandler.php
index 6089b5c7d..d6fb17cc8 100755
--- a/scripts/twitterqueuehandler.php
+++ b/scripts/twitterqueuehandler.php
@@ -27,6 +27,11 @@ if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
define('LACONICA', true);
+// Preset the server at the command line
+
+$server = ($argc > 2) ? $argv[2] : null;
+$path = ($argc > 3) ? $argv[3] : null;
+
require_once(INSTALLDIR . '/lib/common.php');
require_once(INSTALLDIR . '/lib/twitter.php');
require_once(INSTALLDIR . '/lib/queuehandler.php');
@@ -35,12 +40,12 @@ set_error_handler('common_error_handler');
class TwitterQueueHandler extends QueueHandler
{
-
+
function transport()
{
return 'twitter';
}
-
+
function start()
{
$this->log(LOG_INFO, "INITIALIZE");
@@ -51,7 +56,7 @@ class TwitterQueueHandler extends QueueHandler
{
return broadcast_twitter($notice);
}
-
+
function finish()
{
}
diff --git a/scripts/twitterstatusfetcher.php b/scripts/twitterstatusfetcher.php
index 442435be1..c18261b5b 100755
--- a/scripts/twitterstatusfetcher.php
+++ b/scripts/twitterstatusfetcher.php
@@ -33,7 +33,12 @@ define('MAXCHILDREN', 2);
define('POLL_INTERVAL', 60); // in seconds
// Uncomment this to get useful logging
-define('SCRIPT_DEBUG', true);
+// define('SCRIPT_DEBUG', true);
+
+// Preset the server at the command line
+
+$server = ($argc > 2) ? $argv[2] : null;
+$path = ($argc > 3) ? $argv[3] : null;
require_once INSTALLDIR . '/lib/common.php';
require_once INSTALLDIR . '/lib/daemon.php';
diff --git a/scripts/xmppconfirmhandler.php b/scripts/xmppconfirmhandler.php
index 1fa361a36..217481d65 100755
--- a/scripts/xmppconfirmhandler.php
+++ b/scripts/xmppconfirmhandler.php
@@ -27,6 +27,11 @@ if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
define('LACONICA', true);
+// Preset the server at the command line
+
+$server = ($argc > 2) ? $argv[2] : null;
+$path = ($argc > 3) ? $argv[3] : null;
+
require_once(INSTALLDIR . '/lib/common.php');
require_once(INSTALLDIR . '/lib/jabber.php');
require_once(INSTALLDIR . '/lib/xmppqueuehandler.php');
@@ -39,12 +44,12 @@ class XmppConfirmHandler extends XmppQueueHandler
{
var $_id = 'confirm';
-
+
function class_name()
{
return 'XmppConfirmHandler';
}
-
+
function run()
{
if (!$this->start()) {
diff --git a/scripts/xmppdaemon.php b/scripts/xmppdaemon.php
index 528df5d2f..0f98becda 100755
--- a/scripts/xmppdaemon.php
+++ b/scripts/xmppdaemon.php
@@ -27,6 +27,11 @@ if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
define('LACONICA', true);
+// Preset the server at the command line
+
+$server = ($argc > 2) ? $argv[2] : null;
+$path = ($argc > 3) ? $argv[3] : null;
+
require_once(INSTALLDIR . '/lib/common.php');
require_once(INSTALLDIR . '/lib/jabber.php');
require_once(INSTALLDIR . '/lib/daemon.php');
@@ -39,7 +44,6 @@ set_error_handler('common_error_handler');
class XMPPDaemon extends Daemon
{
-
function XMPPDaemon($resource=null)
{
static $attrs = array('server', 'port', 'user', 'password', 'host');