X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=scripts%2Fsmsqueuehandler.php;h=6583a77da85fa898950c40bad4d25bf56898084e;hb=6f5b765c97c8616e4a79719bfe835cb03dc0a236;hp=aa07ca46dc55957c503ccb719b3b94acc1284b5c;hpb=ed2aeecfddcbf02a9183a5b5b29262ebda4c27fe;p=quix0rs-gnu-social.git diff --git a/scripts/smsqueuehandler.php b/scripts/smsqueuehandler.php index aa07ca46dc..6583a77da8 100755 --- a/scripts/smsqueuehandler.php +++ b/scripts/smsqueuehandler.php @@ -1,8 +1,8 @@ #!/usr/bin/env php . */ -# Abort if called from a web server -if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) { - print "This script must be run from the command line\n"; - exit(); -} - define('INSTALLDIR', realpath(dirname(__FILE__) . '/..')); -define('LACONICA', true); -require_once(INSTALLDIR . '/lib/common.php'); -require_once(INSTALLDIR . '/lib/mail.php'); -require_once(INSTALLDIR . '/lib/queuehandler.php'); +$shortoptions = 'i::'; +$longoptions = array('id::'); -set_error_handler('common_error_handler'); +$helptext = <<log(LOG_INFO, "INITIALIZE"); - return true; - } +END_OF_SMS_HELP; - function handle_notice($notice) { - return mail_broadcast_notice_sms($notice); - } - - function finish() { - } -} +require_once INSTALLDIR.'/scripts/commandline.inc'; -mb_internal_encoding('UTF-8'); +require_once INSTALLDIR . '/lib/mail.php'; +require_once INSTALLDIR . '/lib/queuehandler.php'; -$id = ($argc > 1) ? $argv[1] : NULL; +class SmsQueueHandler extends QueueHandler +{ + function transport() + { + return 'sms'; + } -$handler = new SmsQueueHandler($id); + function start() + { + $this->log(LOG_INFO, "INITIALIZE"); + return true; + } + + function handle_notice($notice) + { + return mail_broadcast_notice_sms($notice); + } -if ($handler->start()) { - $handler->handle_queue(); + function finish() + { + } } -$handler->finish(); +if (have_option('i')) { + $id = get_option_value('i'); +} else if (have_option('--id')) { + $id = get_option_value('--id'); +} else if (count($args) > 0) { + $id = $args[0]; +} else { + $id = null; +} + +$handler = new SmsQueueHandler($id); + +$handler->runOnce();