Commit 198afa0a authored by Evan Prodromou's avatar Evan Prodromou

change scripts to take server and path from commandline

parent 45430d2b
......@@ -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
......
......@@ -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;
}
}
......
......@@ -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()
{
}
......
......@@ -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');
......
......@@ -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()
{
}
......
......@@ -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()
{
}
......
......@@ -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');
......
......@@ -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 {
......
......@@ -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()
{
}
......
......@@ -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
......
......@@ -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";
}
......@@ -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()
{
}
......
......@@ -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';
......
......@@ -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()) {
......
......@@ -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');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment