diff options
Diffstat (limited to '_darcs/pristine/lib')
-rw-r--r-- | _darcs/pristine/lib/Shorturl_api.php | 15 | ||||
-rw-r--r-- | _darcs/pristine/lib/common.php | 3 | ||||
-rw-r--r-- | _darcs/pristine/lib/deleteaction.php | 12 | ||||
-rw-r--r-- | _darcs/pristine/lib/facebookaction.php | 30 | ||||
-rw-r--r-- | _darcs/pristine/lib/oauthstore.php | 21 | ||||
-rw-r--r-- | _darcs/pristine/lib/omb.php | 42 | ||||
-rw-r--r-- | _darcs/pristine/lib/openid.php | 33 | ||||
-rw-r--r-- | _darcs/pristine/lib/personal.php | 18 | ||||
-rw-r--r-- | _darcs/pristine/lib/profilelist.php | 15 | ||||
-rw-r--r-- | _darcs/pristine/lib/queuehandler.php | 39 | ||||
-rw-r--r-- | _darcs/pristine/lib/rssaction.php | 39 | ||||
-rw-r--r-- | _darcs/pristine/lib/search_engines.php | 33 | ||||
-rw-r--r-- | _darcs/pristine/lib/searchaction.php | 21 | ||||
-rw-r--r-- | _darcs/pristine/lib/settingsaction.php | 21 | ||||
-rw-r--r-- | _darcs/pristine/lib/stream.php | 6 | ||||
-rw-r--r-- | _darcs/pristine/lib/subs.php | 18 | ||||
-rw-r--r-- | _darcs/pristine/lib/theme.php | 6 | ||||
-rw-r--r-- | _darcs/pristine/lib/twitter.php | 21 | ||||
-rw-r--r-- | _darcs/pristine/lib/twitterapi.php | 105 | ||||
-rw-r--r-- | _darcs/pristine/lib/util.php | 372 | ||||
-rw-r--r-- | _darcs/pristine/lib/xmppqueuehandler.php | 18 |
21 files changed, 592 insertions, 296 deletions
diff --git a/_darcs/pristine/lib/Shorturl_api.php b/_darcs/pristine/lib/Shorturl_api.php index 7beae0ec6..f3f4f08df 100644 --- a/_darcs/pristine/lib/Shorturl_api.php +++ b/_darcs/pristine/lib/Shorturl_api.php @@ -22,11 +22,13 @@ if (!defined('LACONICA')) { exit(1); } class ShortUrlApi { protected $service_url; - function __construct($service_url) { + function __construct($service_url) + { $this->service_url = $service_url; } - function shorten($url) { + function shorten($url) + { if ($this->is_long($url)) return $this->shorten_imp($url); return $url; } @@ -68,7 +70,8 @@ class ShortUrlApi { } class LilUrl extends ShortUrlApi { - function __construct() { + function __construct() + { parent::__construct('http://ur1.ca/'); } @@ -86,7 +89,8 @@ class LilUrl extends ShortUrlApi { class PtitUrl extends ShortUrlApi { - function __construct() { + function __construct() + { parent::__construct('http://ptiturl.com/?creer=oui&action=Reduire&url='); } @@ -103,7 +107,8 @@ class PtitUrl extends ShortUrlApi { } class TightUrl extends ShortUrlApi { - function __construct() { + function __construct() + { parent::__construct('http://2tu.us/?save=y&url='); } diff --git a/_darcs/pristine/lib/common.php b/_darcs/pristine/lib/common.php index 3e162f781..74c992f1c 100644 --- a/_darcs/pristine/lib/common.php +++ b/_darcs/pristine/lib/common.php @@ -163,7 +163,8 @@ require_once(INSTALLDIR.'/lib/subs.php'); require_once(INSTALLDIR.'/lib/Shorturl_api.php'); require_once(INSTALLDIR.'/lib/twitter.php'); -function __autoload($class) { +function __autoload($class) +{ if ($class == 'OAuthRequest') { require_once('OAuth.php'); } else if (file_exists(INSTALLDIR.'/classes/' . $class . '.php')) { diff --git a/_darcs/pristine/lib/deleteaction.php b/_darcs/pristine/lib/deleteaction.php index a7de6b8fb..a6e365121 100644 --- a/_darcs/pristine/lib/deleteaction.php +++ b/_darcs/pristine/lib/deleteaction.php @@ -21,7 +21,8 @@ if (!defined('LACONICA')) { exit(1); } class DeleteAction extends Action { - function handle($args) { + function handle($args) + { parent::handle($args); $user = common_current_user(); $notice_id = $this->trimmed('notice'); @@ -43,7 +44,8 @@ class DeleteAction extends Action { } } - function show_top($arr=null) { + function show_top($arr=null) + { $instr = $this->get_instructions(); $output = common_markup_to_html($instr); common_element_start('div', 'instructions'); @@ -51,11 +53,13 @@ class DeleteAction extends Action { common_element_end('div'); } - function get_title() { + function get_title() + { return null; } - function show_header() { + function show_header() + { return; } } diff --git a/_darcs/pristine/lib/facebookaction.php b/_darcs/pristine/lib/facebookaction.php index 731460f12..43464b19b 100644 --- a/_darcs/pristine/lib/facebookaction.php +++ b/_darcs/pristine/lib/facebookaction.php @@ -23,17 +23,20 @@ require_once(INSTALLDIR.'/extlib/facebook/facebook.php'); class FacebookAction extends Action { - function handle($args) { + function handle($args) + { parent::handle($args); } - function get_facebook() { + function get_facebook() + { $apikey = common_config('facebook', 'apikey'); $secret = common_config('facebook', 'secret'); return new Facebook($apikey, $secret); } - function update_profile_box($facebook, $fbuid, $user) { + function update_profile_box($facebook, $fbuid, $user) + { $notice = $user->getCurrentNotice(); @@ -86,7 +89,8 @@ class FacebookAction extends Action { # Display methods - function show_header($selected ='Home') { + function show_header($selected ='Home') + { # Add a timestamp to the CSS file so Facebook cache wont ignore our changes $ts = filemtime(theme_file('facebookapp.css')); @@ -108,12 +112,14 @@ class FacebookAction extends Action { } - function show_footer() { + function show_footer() + { $footer = '</div>'; echo $footer; } - function show_login_form() { + function show_login_form() + { $loginform = ' <h2>To add the Identi.ca application, you need to log into your Identi.ca account.</h2>' @@ -148,7 +154,8 @@ class FacebookAction extends Action { echo $loginform; } - function render_notice($notice) { + function render_notice($notice) + { global $config; @@ -207,7 +214,8 @@ class FacebookAction extends Action { return $html; } - function source_link($source) { + function source_link($source) + { $source_name = _($source); $html = '<span class="noticesource">'; @@ -235,7 +243,8 @@ class FacebookAction extends Action { return $html; } - function pagination($have_before, $have_after, $page, $fbaction, $args=null) { + function pagination($have_before, $have_after, $page, $fbaction, $args=null) + { $html = ''; @@ -266,7 +275,8 @@ class FacebookAction extends Action { } } - function pagination_url($fbaction, $args=null) { + function pagination_url($fbaction, $args=null) + { global $config; $extra = ''; diff --git a/_darcs/pristine/lib/oauthstore.php b/_darcs/pristine/lib/oauthstore.php index 421b618b7..7ec3ca655 100644 --- a/_darcs/pristine/lib/oauthstore.php +++ b/_darcs/pristine/lib/oauthstore.php @@ -25,7 +25,8 @@ class LaconicaOAuthDataStore extends OAuthDataStore { # We keep a record of who's contacted us - function lookup_consumer($consumer_key) { + function lookup_consumer($consumer_key) + { $con = Consumer::staticGet('consumer_key', $consumer_key); if (!$con) { $con = new Consumer(); @@ -39,7 +40,8 @@ class LaconicaOAuthDataStore extends OAuthDataStore { return new OAuthConsumer($con->consumer_key, ''); } - function lookup_token($consumer, $token_type, $token_key) { + function lookup_token($consumer, $token_type, $token_key) + { $t = new Token(); $t->consumer_key = $consumer->key; $t->tok = $token_key; @@ -51,7 +53,8 @@ class LaconicaOAuthDataStore extends OAuthDataStore { } } - function lookup_nonce($consumer, $token, $nonce, $timestamp) { + function lookup_nonce($consumer, $token, $nonce, $timestamp) + { $n = new Nonce(); $n->consumer_key = $consumer->key; $n->tok = $token->key; @@ -66,7 +69,8 @@ class LaconicaOAuthDataStore extends OAuthDataStore { } } - function new_request_token($consumer) { + function new_request_token($consumer) + { $t = new Token(); $t->consumer_key = $consumer->key; $t->tok = common_good_rand(16); @@ -83,11 +87,13 @@ class LaconicaOAuthDataStore extends OAuthDataStore { # defined in OAuthDataStore, but not implemented anywhere - function fetch_request_token($consumer) { + function fetch_request_token($consumer) + { return $this->new_request_token($consumer); } - function new_access_token($token, $consumer) { + function new_access_token($token, $consumer) + { common_debug('new_access_token("'.$token->key.'","'.$consumer->key.'")', __FILE__); $rt = new Token(); $rt->consumer_key = $consumer->key; @@ -138,7 +144,8 @@ class LaconicaOAuthDataStore extends OAuthDataStore { # defined in OAuthDataStore, but not implemented anywhere - function fetch_access_token($consumer) { + function fetch_access_token($consumer) + { return $this->new_access_token($consumer); } } diff --git a/_darcs/pristine/lib/omb.php b/_darcs/pristine/lib/omb.php index 8199b0679..c07bedab5 100644 --- a/_darcs/pristine/lib/omb.php +++ b/_darcs/pristine/lib/omb.php @@ -43,7 +43,8 @@ define('OAUTH_AUTH_HEADER', OAUTH_NAMESPACE.'parameters/auth-header'); define('OAUTH_POST_BODY', OAUTH_NAMESPACE.'parameters/post-body'); define('OAUTH_HMAC_SHA1', OAUTH_NAMESPACE.'signature/HMAC-SHA1'); -function omb_oauth_consumer() { +function omb_oauth_consumer() +{ static $con = null; if (!$con) { $con = new OAuthConsumer(common_root_url(), ''); @@ -51,7 +52,8 @@ function omb_oauth_consumer() { return $con; } -function omb_oauth_server() { +function omb_oauth_server() +{ static $server = null; if (!$server) { $server = new OAuthServer(omb_oauth_datastore()); @@ -60,7 +62,8 @@ function omb_oauth_server() { return $server; } -function omb_oauth_datastore() { +function omb_oauth_datastore() +{ static $store = null; if (!$store) { $store = new LaconicaOAuthDataStore(); @@ -68,7 +71,8 @@ function omb_oauth_datastore() { return $store; } -function omb_hmac_sha1() { +function omb_hmac_sha1() +{ static $hmac_method = null; if (!$hmac_method) { $hmac_method = new OAuthSignatureMethod_HMAC_SHA1(); @@ -76,20 +80,24 @@ function omb_hmac_sha1() { return $hmac_method; } -function omb_get_services($xrd, $type) { +function omb_get_services($xrd, $type) +{ return $xrd->services(array(omb_service_filter($type))); } -function omb_service_filter($type) { +function omb_service_filter($type) +{ return create_function('$s', 'return omb_match_service($s, \''.$type.'\');'); } -function omb_match_service($service, $type) { +function omb_match_service($service, $type) +{ return in_array($type, $service->getTypes()); } -function omb_service_uri($service) { +function omb_service_uri($service) +{ if (!$service) { return null; } @@ -100,7 +108,8 @@ function omb_service_uri($service) { return $uris[0]; } -function omb_local_id($service) { +function omb_local_id($service) +{ if (!$service) { return null; } @@ -112,7 +121,8 @@ function omb_local_id($service) { return $service->parser->content($el); } -function omb_broadcast_remote_subscribers($notice) { +function omb_broadcast_remote_subscribers($notice) +{ # First, get remote users subscribed to this profile $rp = new Remote_profile(); @@ -142,11 +152,13 @@ function omb_broadcast_remote_subscribers($notice) { return true; } -function omb_post_notice($notice, $remote_profile, $subscription) { +function omb_post_notice($notice, $remote_profile, $subscription) +{ return omb_post_notice_keys($notice, $remote_profile->postnoticeurl, $subscription->token, $subscription->secret); } -function omb_post_notice_keys($notice, $postnoticeurl, $tk, $secret) { +function omb_post_notice_keys($notice, $postnoticeurl, $tk, $secret) +{ common_debug('Posting notice ' . $notice->id . ' to ' . $postnoticeurl, __FILE__); @@ -216,7 +228,8 @@ function omb_post_notice_keys($notice, $postnoticeurl, $tk, $secret) { } } -function omb_broadcast_profile($profile) { +function omb_broadcast_profile($profile) +{ # First, get remote users subscribed to this profile # XXX: use a join here rather than looping through results $sub = new Subscription(); @@ -236,7 +249,8 @@ function omb_broadcast_profile($profile) { } } -function omb_update_profile($profile, $remote_profile, $subscription) { +function omb_update_profile($profile, $remote_profile, $subscription) +{ global $config; # for license URL $user = User::staticGet($profile->id); $con = omb_oauth_consumer(); diff --git a/_darcs/pristine/lib/openid.php b/_darcs/pristine/lib/openid.php index 3ca359fa1..1e7f318fb 100644 --- a/_darcs/pristine/lib/openid.php +++ b/_darcs/pristine/lib/openid.php @@ -31,7 +31,8 @@ require_once('Auth/OpenID/MySQLStore.php'); define('OPENID_COOKIE_EXPIRY', round(365.25 * 24 * 60 * 60)); define('OPENID_COOKIE_KEY', 'lastusedopenid'); -function oid_store() { +function oid_store() +{ static $store = null; if (!$store) { # Can't be called statically @@ -42,23 +43,27 @@ function oid_store() { return $store; } -function oid_consumer() { +function oid_consumer() +{ $store = oid_store(); $consumer = new Auth_OpenID_Consumer($store); return $consumer; } -function oid_clear_last() { +function oid_clear_last() +{ oid_set_last(''); } -function oid_set_last($openid_url) { +function oid_set_last($openid_url) +{ common_set_cookie(OPENID_COOKIE_KEY, $openid_url, time() + OPENID_COOKIE_EXPIRY); } -function oid_get_last() { +function oid_get_last() +{ $openid_url = $_COOKIE[OPENID_COOKIE_KEY]; if ($openid_url && strlen($openid_url) > 0) { return $openid_url; @@ -67,7 +72,8 @@ function oid_get_last() { } } -function oid_link_user($id, $canonical, $display) { +function oid_link_user($id, $canonical, $display) +{ $oid = new User_openid(); $oid->user_id = $id; @@ -84,7 +90,8 @@ function oid_link_user($id, $canonical, $display) { return true; } -function oid_get_user($openid_url) { +function oid_get_user($openid_url) +{ $user = null; $oid = User_openid::staticGet('canonical', $openid_url); if ($oid) { @@ -93,7 +100,8 @@ function oid_get_user($openid_url) { return $user; } -function oid_check_immediate($openid_url, $backto=null) { +function oid_check_immediate($openid_url, $backto=null) +{ if (!$backto) { $action = $_REQUEST['action']; $args = common_copy_args($_GET); @@ -113,7 +121,8 @@ function oid_check_immediate($openid_url, $backto=null) { true); } -function oid_authenticate($openid_url, $returnto, $immediate=false) { +function oid_authenticate($openid_url, $returnto, $immediate=false) +{ $consumer = oid_consumer(); @@ -190,7 +199,8 @@ function oid_authenticate($openid_url, $returnto, $immediate=false) { # Half-assed attempt at a module-private function -function _oid_print_instructions() { +function _oid_print_instructions() +{ common_element('div', 'instructions', _('This form should automatically submit itself. '. 'If not, click the submit button to go to your '. @@ -199,7 +209,8 @@ function _oid_print_instructions() { # update a user from sreg parameters -function oid_update_user(&$user, &$sreg) { +function oid_update_user(&$user, &$sreg) +{ $profile = $user->getProfile(); diff --git a/_darcs/pristine/lib/personal.php b/_darcs/pristine/lib/personal.php index 7ff9305f1..34ebe6894 100644 --- a/_darcs/pristine/lib/personal.php +++ b/_darcs/pristine/lib/personal.php @@ -21,16 +21,19 @@ if (!defined('LACONICA')) { exit(1); } class PersonalAction extends Action { - function is_readonly() { + function is_readonly() + { return true; } - function handle($args) { + function handle($args) + { parent::handle($args); common_set_returnto($this->self_url()); } - function views_menu() { + function views_menu() + { $user = null; $action = $this->trimmed('action'); @@ -85,7 +88,8 @@ class PersonalAction extends Action { common_element_end('ul'); } - function show_feeds_list($feeds) { + function show_feeds_list($feeds) + { common_element_start('div', array('class' => 'feeds')); common_element('p', null, 'Feeds:'); common_element_start('ul', array('class' => 'xoxo')); @@ -97,7 +101,8 @@ class PersonalAction extends Action { common_element_end('div'); } - function common_feed_item($feed) { + function common_feed_item($feed) + { $nickname = $this->trimmed('nickname'); switch($feed['item']) { @@ -181,7 +186,8 @@ class PersonalAction extends Action { } - function source_link($source) { + function source_link($source) + { $source_name = _($source); switch ($source) { case 'web': diff --git a/_darcs/pristine/lib/profilelist.php b/_darcs/pristine/lib/profilelist.php index 9929c8647..60737c3d4 100644 --- a/_darcs/pristine/lib/profilelist.php +++ b/_darcs/pristine/lib/profilelist.php @@ -28,13 +28,15 @@ class ProfileList { var $owner = null; var $action = null; - function __construct($profile, $owner=null, $action=null) { + function __construct($profile, $owner=null, $action=null) + { $this->profile = $profile; $this->owner = $owner; $this->action = $action; } - function show_list() { + function show_list() + { common_element_start('ul', array('id' => 'profiles', 'class' => 'profile_list')); @@ -53,7 +55,8 @@ class ProfileList { return $cnt; } - function show() { + function show() + { common_element_start('li', array('class' => 'profile_single', 'id' => 'profile-' . $this->profile->id)); @@ -159,11 +162,13 @@ class ProfileList { /* Override this in subclasses. */ - function show_owner_controls($profile) { + function show_owner_controls($profile) + { return; } - function highlight($text) { + function highlight($text) + { return htmlspecialchars($text); } }
\ No newline at end of file diff --git a/_darcs/pristine/lib/queuehandler.php b/_darcs/pristine/lib/queuehandler.php index ecf58f69f..48487f8e9 100644 --- a/_darcs/pristine/lib/queuehandler.php +++ b/_darcs/pristine/lib/queuehandler.php @@ -29,43 +29,53 @@ class QueueHandler extends Daemon { var $_id = 'generic'; - function QueueHandler($id=null) { + function QueueHandler($id=null) + { if ($id) { $this->set_id($id); } } - function class_name() { + function class_name() + { return ucfirst($this->transport()) . 'Handler'; } - function name() { + function name() + { return strtolower($this->class_name().'.'.$this->get_id()); } - function get_id() { + function get_id() + { return $this->_id; } - function set_id($id) { + function set_id($id) + { $this->_id = $id; } - function transport() { + function transport() + { return null; } - function start() { + function start() + { } - function finish() { + function finish() + { } - function handle_notice($notice) { + function handle_notice($notice) + { return true; } - function run() { + function run() + { if (!$this->start()) { return false; } @@ -110,13 +120,15 @@ class QueueHandler extends Daemon { return true; } - function idle($timeout=0) { + function idle($timeout=0) + { if ($timeout>0) { sleep($timeout); } } - function clear_old_claims() { + function clear_old_claims() + { $qi = new Queue_item(); $qi->transport = $this->transport(); $qi->whereAdd('now() - claimed > '.CLAIM_TIMEOUT); @@ -125,7 +137,8 @@ class QueueHandler extends Daemon { unset($qi); } - function log($level, $msg) { + function log($level, $msg) + { common_log($level, $this->class_name() . ' ('. $this->get_id() .'): '.$msg); } } diff --git a/_darcs/pristine/lib/rssaction.php b/_darcs/pristine/lib/rssaction.php index a21ce3a97..e02e1febb 100644 --- a/_darcs/pristine/lib/rssaction.php +++ b/_darcs/pristine/lib/rssaction.php @@ -26,11 +26,13 @@ class Rss10Action extends Action { # This will contain the details of each feed item's author and be used to generate SIOC data. var $creators = array(); - function is_readonly() { + function is_readonly() + { return true; } - function handle($args) { + function handle($args) + { parent::handle($args); $limit = (int) $this->trimmed('limit'); if ($limit == 0) { @@ -39,26 +41,31 @@ class Rss10Action extends Action { $this->show_rss($limit); } - function init() { + function init() + { return true; } - function get_notices() { + function get_notices() + { return array(); } - function get_channel() { + function get_channel() + { return array('url' => '', 'title' => '', 'link' => '', 'description' => ''); } - function get_image() { + function get_image() + { return null; } - function show_rss($limit=0) { + function show_rss($limit=0) + { if (!$this->init()) { return; @@ -78,7 +85,8 @@ class Rss10Action extends Action { $this->end_rss(); } - function show_channel($notices) { + function show_channel($notices) + { $channel = $this->get_channel(); $image = $this->get_image(); @@ -106,7 +114,8 @@ class Rss10Action extends Action { common_element_end('channel'); } - function show_image() { + function show_image() + { $image = $this->get_image(); if ($image) { $channel = $this->get_channel(); @@ -118,7 +127,8 @@ class Rss10Action extends Action { } } - function show_item($notice) { + function show_item($notice) + { $profile = Profile::staticGet($notice->profile_id); $nurl = common_local_url('shownotice', array('notice' => $notice->id)); $creator_uri = common_profile_uri($profile); @@ -136,7 +146,8 @@ class Rss10Action extends Action { $this->creators[$creator_uri] = $profile; } - function show_creators() { + function show_creators() + { foreach ($this->creators as $uri => $profile) { $id = $profile->id; $nickname = $profile->nickname; @@ -152,7 +163,8 @@ class Rss10Action extends Action { } } - function init_rss() { + function init_rss() + { $channel = $this->get_channel(); header('Content-Type: application/rdf+xml'); @@ -183,7 +195,8 @@ class Rss10Action extends Action { common_element_end('sioc:Site'); } - function end_rss() { + function end_rss() + { common_element_end('rdf:RDF'); } } diff --git a/_darcs/pristine/lib/search_engines.php b/_darcs/pristine/lib/search_engines.php index d53d7d8d8..e96570d63 100644 --- a/_darcs/pristine/lib/search_engines.php +++ b/_darcs/pristine/lib/search_engines.php @@ -23,19 +23,23 @@ class SearchEngine { protected $target; protected $table; - function __construct($target, $table) { + function __construct($target, $table) + { $this->target = $target; $this->table = $table; } - function query($q) { + function query($q) + { } - function limit($offset, $count, $rss = false) { + function limit($offset, $count, $rss = false) + { return $this->target->limit($offset, $count); } - function set_sort_mode($mode) { + function set_sort_mode($mode) + { if ('chron' === $mode) return $this->target->orderBy('created desc'); } @@ -45,7 +49,8 @@ class SphinxSearch extends SearchEngine { private $sphinx; private $connected; - function __construct($target, $table) { + function __construct($target, $table) + { $fp = @fsockopen(common_config('sphinx', 'server'), common_config('sphinx', 'port')); if (!$fp) { $this->connected = false; @@ -58,11 +63,13 @@ class SphinxSearch extends SearchEngine { $this->connected = true; } - function is_connected() { + function is_connected() + { return $this->connected; } - function limit($offset, $count, $rss = false) { + function limit($offset, $count, $rss = false) + { //FIXME without LARGEST_POSSIBLE, the most recent results aren't returned // this probably has a large impact on performance $LARGEST_POSSIBLE = 1e6; @@ -78,7 +85,8 @@ class SphinxSearch extends SearchEngine { return $this->target->limit(0, $count); } - function query($q) { + function query($q) + { $result = $this->sphinx->query($q, $this->table); if (!isset($result['matches'])) return false; $id_set = join(', ', array_keys($result['matches'])); @@ -86,7 +94,8 @@ class SphinxSearch extends SearchEngine { return true; } - function set_sort_mode($mode) { + function set_sort_mode($mode) + { if ('chron' === $mode) { $this->sphinx->SetSortMode(SPH_SORT_ATTR_DESC, 'created_ts'); return $this->target->orderBy('created desc'); @@ -95,7 +104,8 @@ class SphinxSearch extends SearchEngine { } class MySQLSearch extends SearchEngine { - function query($q) { + function query($q) + { if ('identica_people' === $this->table) return $this->target->whereAdd('MATCH(nickname, fullname, location, bio, homepage) ' . 'against (\''.addslashes($q).'\')'); @@ -106,7 +116,8 @@ class MySQLSearch extends SearchEngine { } class PGSearch extends SearchEngine { - function query($q) { + function query($q) + { if ('identica_people' === $this->table) return $this->target->whereAdd('textsearch @@ plainto_tsquery(\''.addslashes($q).'\')'); if ('identica_notices' === $this->table) diff --git a/_darcs/pristine/lib/searchaction.php b/_darcs/pristine/lib/searchaction.php index 3eec91832..12a44a861 100644 --- a/_darcs/pristine/lib/searchaction.php +++ b/_darcs/pristine/lib/searchaction.php @@ -21,16 +21,19 @@ if (!defined('LACONICA')) { exit(1); } class SearchAction extends Action { - function is_readonly() { + function is_readonly() + { return true; } - function handle($args) { + function handle($args) + { parent::handle($args); $this->show_form(); } - function show_top($arr=null) { + function show_top($arr=null) + { if ($arr) { $error = $arr[1]; } @@ -46,15 +49,18 @@ class SearchAction extends Action { $this->search_menu(); } - function get_title() { + function get_title() + { return null; } - function show_header($arr) { + function show_header($arr) + { return; } - function show_form($error=null) { + function show_form($error=null) + { global $config; $q = $this->trimmed('q'); @@ -91,7 +97,8 @@ class SearchAction extends Action { common_show_footer(); } - function search_menu() { + function search_menu() + { # action => array('prompt', 'title', $args) $action = $this->trimmed('action'); $menu = diff --git a/_darcs/pristine/lib/settingsaction.php b/_darcs/pristine/lib/settingsaction.php index 208d2a1b6..5979c11f0 100644 --- a/_darcs/pristine/lib/settingsaction.php +++ b/_darcs/pristine/lib/settingsaction.php @@ -21,7 +21,8 @@ if (!defined('LACONICA')) { exit(1); } class SettingsAction extends Action { - function handle($args) { + function handle($args) + { parent::handle($args); if (!common_logged_in()) { common_user_error(_('Not logged in.')); @@ -40,29 +41,34 @@ class SettingsAction extends Action { } # override! - function handle_post() { + function handle_post() + { return false; } - function show_form($msg=null, $success=false) { + function show_form($msg=null, $success=false) + { return false; } - function message($msg, $success) { + function message($msg, $success) + { if ($msg) { common_element('div', ($success) ? 'success' : 'error', $msg); } } - function form_header($title, $msg=null, $success=false) { + function form_header($title, $msg=null, $success=false) + { common_show_header($title, null, array($msg, $success), array($this, 'show_top')); } - function show_top($arr) { + function show_top($arr) + { $msg = $arr[0]; $success = $arr[1]; if ($msg) { @@ -77,7 +83,8 @@ class SettingsAction extends Action { $this->settings_menu(); } - function settings_menu() { + function settings_menu() + { # action => array('prompt', 'title') $menu = array('profilesettings' => diff --git a/_darcs/pristine/lib/stream.php b/_darcs/pristine/lib/stream.php index 2d45df2d3..45fbb9bd9 100644 --- a/_darcs/pristine/lib/stream.php +++ b/_darcs/pristine/lib/stream.php @@ -24,7 +24,8 @@ require_once(INSTALLDIR.'/lib/noticelist.php'); class StreamAction extends PersonalAction { - function public_views_menu() { + function public_views_menu() + { $action = $this->trimmed('action'); @@ -48,7 +49,8 @@ class StreamAction extends PersonalAction { } - function show_notice_list($notice) { + function show_notice_list($notice) + { $nl = new NoticeList($notice); return $nl->show(); } diff --git a/_darcs/pristine/lib/subs.php b/_darcs/pristine/lib/subs.php index 55e74e0b2..6fa1dcad3 100644 --- a/_darcs/pristine/lib/subs.php +++ b/_darcs/pristine/lib/subs.php @@ -25,7 +25,8 @@ require_once('XMPPHP/XMPP.php'); Returns true or an error message. */ -function subs_subscribe_user($user, $other_nickname) { +function subs_subscribe_user($user, $other_nickname) +{ $other = User::staticGet('nickname', $other_nickname); @@ -41,7 +42,8 @@ function subs_subscribe_user($user, $other_nickname) { * Because the other way is quite a bit more complicated. */ -function subs_subscribe_to($user, $other) { +function subs_subscribe_to($user, $other) +{ if ($user->isSubscribed($other)) { return _('Already subscribed!.'); @@ -82,14 +84,16 @@ function subs_subscribe_to($user, $other) { return true; } -function subs_notify($listenee, $listener) { +function subs_notify($listenee, $listener) +{ # XXX: add other notifications (Jabber, SMS) here # XXX: queue this and handle it offline # XXX: Whatever happens, do it in Twitter-like API, too subs_notify_email($listenee, $listener); } -function subs_notify_email($listenee, $listener) { +function subs_notify_email($listenee, $listener) +{ mail_subscribe_notify($listenee, $listener); } @@ -97,7 +101,8 @@ function subs_notify_email($listenee, $listener) { Returns true or an error message. */ -function subs_unsubscribe_user($user, $other_nickname) { +function subs_unsubscribe_user($user, $other_nickname) +{ $other = User::staticGet('nickname', $other_nickname); @@ -111,7 +116,8 @@ function subs_unsubscribe_user($user, $other_nickname) { /* Unsubscribe user $user from profile $other * NB: other can be a remote user. */ -function subs_unsubscribe_to($user, $other) { +function subs_unsubscribe_to($user, $other) +{ if (!$user->isSubscribed($other)) return _('Not subscribed!.'); diff --git a/_darcs/pristine/lib/theme.php b/_darcs/pristine/lib/theme.php index 346cff434..6f365bd99 100644 --- a/_darcs/pristine/lib/theme.php +++ b/_darcs/pristine/lib/theme.php @@ -19,12 +19,14 @@ if (!defined('LACONICA')) { exit(1); } -function theme_file($relative) { +function theme_file($relative) +{ $theme = common_config('site', 'theme'); return INSTALLDIR.'/theme/'.$theme.'/'.$relative; } -function theme_path($relative) { +function theme_path($relative) +{ $theme = common_config('site', 'theme'); $server = common_config('theme', 'server'); if ($server) { diff --git a/_darcs/pristine/lib/twitter.php b/_darcs/pristine/lib/twitter.php index 1212875ea..07871fb20 100644 --- a/_darcs/pristine/lib/twitter.php +++ b/_darcs/pristine/lib/twitter.php @@ -19,7 +19,8 @@ if (!defined('LACONICA')) { exit(1); } -function get_twitter_data($uri, $screen_name, $password) { +function get_twitter_data($uri, $screen_name, $password) +{ $options = array( CURLOPT_USERPWD => sprintf("%s:%s", $screen_name, $password), @@ -48,7 +49,8 @@ function get_twitter_data($uri, $screen_name, $password) { return $data; } -function twitter_user_info($screen_name, $password) { +function twitter_user_info($screen_name, $password) +{ $uri = "http://twitter.com/users/show/$screen_name.json"; $data = get_twitter_data($uri, $screen_name, $password); @@ -66,7 +68,8 @@ function twitter_user_info($screen_name, $password) { return $twit_user; } -function update_twitter_user($fuser, $twitter_id, $screen_name) { +function update_twitter_user($fuser, $twitter_id, $screen_name) +{ $original = clone($fuser); $fuser->nickname = $screen_name; @@ -81,7 +84,8 @@ function update_twitter_user($fuser, $twitter_id, $screen_name) { return true; } -function add_twitter_user($twitter_id, $screen_name) { +function add_twitter_user($twitter_id, $screen_name) +{ // Otherwise, create a new Twitter user $fuser = DB_DataObject::factory('foreign_user'); @@ -105,7 +109,8 @@ function add_twitter_user($twitter_id, $screen_name) { } // Creates or Updates a Twitter user -function save_twitter_user($twitter_id, $screen_name) { +function save_twitter_user($twitter_id, $screen_name) +{ // Check to see whether the Twitter user is already in the system, // and update its screen name and uri if so. @@ -129,7 +134,8 @@ function save_twitter_user($twitter_id, $screen_name) { return true; } -function retreive_twitter_friends($twitter_id, $screen_name, $password) { +function retreive_twitter_friends($twitter_id, $screen_name, $password) +{ $uri = "http://twitter.com/statuses/friends/$twitter_id.json?page="; $twitter_user = twitter_user_info($screen_name, $password); @@ -163,7 +169,8 @@ function retreive_twitter_friends($twitter_id, $screen_name, $password) { return $friends; } -function save_twitter_friends($user, $twitter_id, $screen_name, $password) { +function save_twitter_friends($user, $twitter_id, $screen_name, $password) +{ $friends = retreive_twitter_friends($twitter_id, $screen_name, $password); diff --git a/_darcs/pristine/lib/twitterapi.php b/_darcs/pristine/lib/twitterapi.php index ed86c77c4..3cddfa9c9 100644 --- a/_darcs/pristine/lib/twitterapi.php +++ b/_darcs/pristine/lib/twitterapi.php @@ -23,11 +23,13 @@ class TwitterapiAction extends Action { var $auth_user; - function handle($args) { + function handle($args) + { parent::handle($args); } - function twitter_user_array($profile, $get_notice=false) { + function twitter_user_array($profile, $get_notice=false) + { $twitter_user = array(); @@ -55,7 +57,8 @@ class TwitterapiAction extends Action { return $twitter_user; } - function twitter_status_array($notice, $include_user=true) { + function twitter_status_array($notice, $include_user=true) + { $profile = $notice->getProfile(); @@ -83,7 +86,8 @@ class TwitterapiAction extends Action { return $twitter_status; } - function twitter_rss_entry_array($notice) { + function twitter_rss_entry_array($notice) + { $profile = $notice->getProfile(); @@ -107,7 +111,8 @@ class TwitterapiAction extends Action { return $entry; } - function twitter_rss_dmsg_array($message) { + function twitter_rss_dmsg_array($message) + { $server = common_config('site', 'server'); $entry = array(); @@ -129,7 +134,8 @@ class TwitterapiAction extends Action { return $entry; } - function twitter_dmsg_array($message) { + function twitter_dmsg_array($message) + { $twitter_dm = array(); @@ -149,7 +155,8 @@ class TwitterapiAction extends Action { return $twitter_dm; } - function show_twitter_xml_status($twitter_status) { + function show_twitter_xml_status($twitter_status) + { common_element_start('status'); foreach($twitter_status as $element => $value) { switch ($element) { @@ -166,7 +173,8 @@ class TwitterapiAction extends Action { common_element_end('status'); } - function show_twitter_xml_user($twitter_user, $role='user') { + function show_twitter_xml_user($twitter_user, $role='user') + { common_element_start($role); foreach($twitter_user as $element => $value) { if ($element == 'status') { @@ -178,7 +186,8 @@ class TwitterapiAction extends Action { common_element_end($role); } - function show_twitter_rss_item($entry) { + function show_twitter_rss_item($entry) + { common_element_start('item'); common_element('title', null, $entry['title']); common_element('description', null, $entry['description']); @@ -188,7 +197,8 @@ class TwitterapiAction extends Action { common_element_end('item'); } - function show_twitter_atom_entry($entry) { + function show_twitter_atom_entry($entry) + { common_element_start('entry'); common_element('title', null, $entry['title']); common_element('content', array('type' => 'html'), $entry['content']); @@ -199,39 +209,45 @@ class TwitterapiAction extends Action { common_element_end('entry'); } - function show_json_objects($objects) { + function show_json_objects($objects) + { print(json_encode($objects)); } - function show_single_xml_status($notice) { + function show_single_xml_status($notice) + { $this->init_document('xml'); $twitter_status = $this->twitter_status_array($notice); $this->show_twitter_xml_status($twitter_status); $this->end_document('xml'); } - function show_single_json_status($notice) { + function show_single_json_status($notice) + { $this->init_document('json'); $status = $this->twitter_status_array($notice); $this->show_json_objects($status); $this->end_document('json'); } - function show_single_xml_dmsg($message) { + function show_single_xml_dmsg($message) + { $this->init_document('xml'); $dmsg = $this->twitter_dmsg_array($message); $this->show_twitter_xml_dmsg($dmsg); $this->end_document('xml'); } - function show_single_json_dmsg($message) { + function show_single_json_dmsg($message) + { $this->init_document('json'); $dmsg = $this->twitter_dmsg_array($message); $this->show_json_objects($dmsg); $this->end_document('json'); } - function show_twitter_xml_dmsg($twitter_dm) { + function show_twitter_xml_dmsg($twitter_dm) + { common_element_start('direct_message'); foreach($twitter_dm as $element => $value) { switch ($element) { @@ -249,7 +265,8 @@ class TwitterapiAction extends Action { common_element_end('direct_message'); } - function show_xml_timeline($notice) { + function show_xml_timeline($notice) + { $this->init_document('xml'); common_element_start('statuses', array('type' => 'array')); @@ -270,7 +287,8 @@ class TwitterapiAction extends Action { $this->end_document('xml'); } - function show_rss_timeline($notice, $title, $link, $subtitle, $suplink=null) { + function show_rss_timeline($notice, $title, $link, $subtitle, $suplink=null) + { $this->init_document('rss'); @@ -304,7 +322,8 @@ class TwitterapiAction extends Action { $this->end_twitter_rss(); } - function show_atom_timeline($notice, $title, $id, $link, $subtitle=null, $suplink=null) { + function show_atom_timeline($notice, $title, $id, $link, $subtitle=null, $suplink=null) + { $this->init_document('atom'); @@ -335,7 +354,8 @@ class TwitterapiAction extends Action { } - function show_json_timeline($notice) { + function show_json_timeline($notice) + { $this->init_document('json'); @@ -360,12 +380,14 @@ class TwitterapiAction extends Action { // Anyone know what date format this is? // Twitter's dates look like this: "Mon Jul 14 23:52:38 +0000 2008" -- Zach - function date_twitter($dt) { + function date_twitter($dt) + { $t = strtotime($dt); return date("D M d G:i:s O Y", $t); } - function replier_by_reply($reply_id) { + function replier_by_reply($reply_id) + { $notice = Notice::staticGet($reply_id); if ($notice) { $profile = $notice->getProfile(); @@ -381,7 +403,8 @@ class TwitterapiAction extends Action { } // XXX: Candidate for a general utility method somewhere? - function count_subscriptions($profile) { + function count_subscriptions($profile) + { $count = 0; $sub = new Subscription(); @@ -396,7 +419,8 @@ class TwitterapiAction extends Action { } } - function init_document($type='xml') { + function init_document($type='xml') + { switch ($type) { case 'xml': header('Content-Type: application/xml; charset=utf-8'); @@ -427,7 +451,8 @@ class TwitterapiAction extends Action { return; } - function end_document($type='xml') { + function end_document($type='xml') + { switch ($type) { case 'xml': common_end_xml(); @@ -453,7 +478,8 @@ class TwitterapiAction extends Action { return; } - function client_error($msg, $code = 400, $content_type = 'json') { + function client_error($msg, $code = 400, $content_type = 'json') + { static $status = array(400 => 'Bad Request', 401 => 'Unauthorized', @@ -501,27 +527,32 @@ class TwitterapiAction extends Action { } - function init_twitter_rss() { + function init_twitter_rss() + { common_start_xml(); common_element_start('rss', array('version' => '2.0')); } - function end_twitter_rss() { + function end_twitter_rss() + { common_element_end('rss'); common_end_xml(); } - function init_twitter_atom() { + function init_twitter_atom() + { common_start_xml(); common_element_start('feed', array('xmlns' => 'http://www.w3.org/2005/Atom', 'xml:lang' => 'en-US')); } - function end_twitter_atom() { + function end_twitter_atom() + { common_end_xml(); common_element_end('feed'); } - function show_profile($profile, $content_type='xml', $notice=null) { + function show_profile($profile, $content_type='xml', $notice=null) + { $profile_array = $this->twitter_user_array($profile, true); switch ($content_type) { case 'xml': @@ -537,7 +568,8 @@ class TwitterapiAction extends Action { return; } - function get_user($id, $apidata=null) { + function get_user($id, $apidata=null) + { if (!$id) { return $apidata['user']; } else if (is_numeric($id)) { @@ -548,7 +580,8 @@ class TwitterapiAction extends Action { } } - function get_profile($id) { + function get_profile($id) + { if (is_numeric($id)) { return Profile::staticGet($id); } else { @@ -561,7 +594,8 @@ class TwitterapiAction extends Action { } } - function source_link($source) { + function source_link($source) + { $source_name = _($source); switch ($source) { case 'web': @@ -580,7 +614,8 @@ class TwitterapiAction extends Action { return $source_name; } - function show_extended_profile($user, $apidata) { + function show_extended_profile($user, $apidata) + { $this->auth_user = $apidata['user']; diff --git a/_darcs/pristine/lib/util.php b/_darcs/pristine/lib/util.php index f0387ebe5..ed73b19e6 100644 --- a/_darcs/pristine/lib/util.php +++ b/_darcs/pristine/lib/util.php @@ -21,7 +21,8 @@ // Show a server error -function common_server_error($msg, $code=500) { +function common_server_error($msg, $code=500) +{ static $status = array(500 => 'Internal Server Error', 501 => 'Not Implemented', 502 => 'Bad Gateway', @@ -44,7 +45,8 @@ function common_server_error($msg, $code=500) { } // Show a user error -function common_user_error($msg, $code=400) { +function common_user_error($msg, $code=400) +{ static $status = array(400 => 'Bad Request', 401 => 'Unauthorized', 402 => 'Payment Required', @@ -80,7 +82,8 @@ function common_user_error($msg, $code=400) { $xw = null; // Start an HTML element -function common_element_start($tag, $attrs=null) { +function common_element_start($tag, $attrs=null) +{ global $xw; $xw->startElement($tag); if (is_array($attrs)) { @@ -92,7 +95,8 @@ function common_element_start($tag, $attrs=null) { } } -function common_element_end($tag) { +function common_element_end($tag) +{ static $empty_tag = array('base', 'meta', 'link', 'hr', 'br', 'param', 'img', 'area', 'input', 'col'); @@ -105,7 +109,8 @@ function common_element_end($tag) { } } -function common_element($tag, $attrs=null, $content=null) { +function common_element($tag, $attrs=null, $content=null) +{ common_element_start($tag, $attrs); global $xw; if (!is_null($content)) { @@ -114,7 +119,8 @@ function common_element($tag, $attrs=null, $content=null) { common_element_end($tag); } -function common_start_xml($doc=null, $public=null, $system=null, $indent=true) { +function common_start_xml($doc=null, $public=null, $system=null, $indent=true) +{ global $xw; $xw = new XMLWriter(); $xw->openURI('php://output'); @@ -125,13 +131,15 @@ function common_start_xml($doc=null, $public=null, $system=null, $indent=true) { } } -function common_end_xml() { +function common_end_xml() +{ global $xw; $xw->endDocument(); $xw->flush(); } -function common_init_locale($language=null) { +function common_init_locale($language=null) +{ if(!$language) { $language = common_language(); } @@ -144,7 +152,8 @@ function common_init_locale($language=null) { $language); } -function common_init_language() { +function common_init_language() +{ mb_internal_encoding('UTF-8'); $language = common_language(); // So we don't have to make people install the gettext locales @@ -160,7 +169,8 @@ function common_init_language() { define('PAGE_TYPE_PREFS', 'text/html,application/xhtml+xml,application/xml;q=0.3,text/xml;q=0.2'); -function common_show_header($pagetitle, $callable=null, $data=null, $headercall=null) { +function common_show_header($pagetitle, $callable=null, $data=null, $headercall=null) +{ global $config, $xw; global $action; /* XXX: kind of cheating here. */ @@ -243,7 +253,8 @@ function common_show_header($pagetitle, $callable=null, $data=null, $headercall= common_element_start('div', array('id' => 'content')); } -function common_start_html($type=null, $indent=true) { +function common_start_html($type=null, $indent=true) +{ if (!$type) { $httpaccept = isset($_SERVER['HTTP_ACCEPT']) ? $_SERVER['HTTP_ACCEPT'] : null; @@ -274,7 +285,8 @@ function common_start_html($type=null, $indent=true) { 'lang' => $language)); } -function common_show_footer() { +function common_show_footer() +{ global $xw, $config; common_element_end('div'); // content div common_foot_menu(); @@ -307,17 +319,20 @@ function common_show_footer() { common_end_xml(); } -function common_text($txt) { +function common_text($txt) +{ global $xw; $xw->text($txt); } -function common_raw($xml) { +function common_raw($xml) +{ global $xw; $xw->writeRaw($xml); } -function common_nav_menu() { +function common_nav_menu() +{ $user = common_current_user(); common_element_start('ul', array('id' => 'nav')); if ($user) { @@ -344,7 +359,8 @@ function common_nav_menu() { common_element_end('ul'); } -function common_foot_menu() { +function common_foot_menu() +{ common_element_start('ul', array('id' => 'nav_sub')); common_menu_item(common_local_url('doc', array('title' => 'help')), _('Help')); @@ -361,7 +377,8 @@ function common_foot_menu() { common_element_end('ul'); } -function common_menu_item($url, $text, $title=null, $is_selected=false) { +function common_menu_item($url, $text, $title=null, $is_selected=false) +{ $lattrs = array(); if ($is_selected) { $lattrs['class'] = 'current'; @@ -375,7 +392,8 @@ function common_menu_item($url, $text, $title=null, $is_selected=false) { common_element_end('li'); } -function common_input($id, $label, $value=null,$instructions=null) { +function common_input($id, $label, $value=null,$instructions=null) +{ common_element_start('p'); common_element('label', array('for' => $id), $label); $attrs = array('name' => $id, @@ -418,7 +436,8 @@ function common_checkbox($id, $label, $checked=false, $instructions=null, $value common_element_end('p'); } -function common_dropdown($id, $label, $content, $instructions=null, $blank_select=FALSE, $selected=null) { +function common_dropdown($id, $label, $content, $instructions=null, $blank_select=FALSE, $selected=null) +{ common_element_start('p'); common_element('label', array('for' => $id), $label); common_element_start('select', array('id' => $id, 'name' => $id)); @@ -438,14 +457,16 @@ function common_dropdown($id, $label, $content, $instructions=null, $blank_selec } common_element_end('p'); } -function common_hidden($id, $value) { +function common_hidden($id, $value) +{ common_element('input', array('name' => $id, 'type' => 'hidden', 'id' => $id, 'value' => $value)); } -function common_password($id, $label, $instructions=null) { +function common_password($id, $label, $instructions=null) +{ common_element_start('p'); common_element('label', array('for' => $id), $label); $attrs = array('name' => $id, @@ -459,7 +480,8 @@ function common_password($id, $label, $instructions=null) { common_element_end('p'); } -function common_submit($id, $label, $cls='submit') { +function common_submit($id, $label, $cls='submit') +{ global $xw; common_element_start('p'); common_element('input', array('type' => 'submit', @@ -470,7 +492,8 @@ function common_submit($id, $label, $cls='submit') { common_element_end('p'); } -function common_textarea($id, $label, $content=null, $instructions=null) { +function common_textarea($id, $label, $content=null, $instructions=null) +{ common_element_start('p'); common_element('label', array('for' => $id), $label); common_element('textarea', array('rows' => 3, @@ -484,7 +507,8 @@ function common_textarea($id, $label, $content=null, $instructions=null) { common_element_end('p'); } -function common_timezone() { +function common_timezone() +{ if (common_logged_in()) { $user = common_current_user(); if ($user->timezone) { @@ -496,7 +520,8 @@ function common_timezone() { return $config['site']['timezone']; } -function common_language() { +function common_language() +{ // If there is a user logged in and they've set a language preference // then return that one... @@ -521,12 +546,14 @@ function common_language() { } // salted, hashed passwords are stored in the DB -function common_munge_password($password, $id) { +function common_munge_password($password, $id) +{ return md5($password . $id); } // check if a username exists and has matching password -function common_check_user($nickname, $password) { +function common_check_user($nickname, $password) +{ // NEVER allow blank passwords, even if they match the DB if (mb_strlen($password) == 0) { return false; @@ -545,15 +572,18 @@ function common_check_user($nickname, $password) { } // is the current user logged in? -function common_logged_in() { +function common_logged_in() +{ return (!is_null(common_current_user())); } -function common_have_session() { +function common_have_session() +{ return (0 != strcmp(session_id(), '')); } -function common_ensure_session() { +function common_ensure_session() +{ if (!common_have_session()) { @session_start(); } @@ -568,7 +598,8 @@ function common_ensure_session() { $_cur = false; -function common_set_user($user) { +function common_set_user($user) +{ global $_cur; @@ -592,7 +623,8 @@ function common_set_user($user) { return false; } -function common_set_cookie($key, $value, $expiration=0) { +function common_set_cookie($key, $value, $expiration=0) +{ $path = common_config('site', 'path'); $server = common_config('site', 'server'); @@ -611,7 +643,8 @@ function common_set_cookie($key, $value, $expiration=0) { define('REMEMBERME', 'rememberme'); define('REMEMBERME_EXPIRY', 30 * 24 * 60 * 60); // 30 days -function common_rememberme($user=null) { +function common_rememberme($user=null) +{ if (!$user) { $user = common_current_user(); if (!$user) { @@ -650,7 +683,8 @@ function common_rememberme($user=null) { return true; } -function common_remembered_user() { +function common_remembered_user() +{ $user = null; @@ -715,12 +749,14 @@ function common_remembered_user() { // must be called with a valid user! -function common_forgetme() { +function common_forgetme() +{ common_set_cookie(REMEMBERME, '', 0); } // who is the current user? -function common_current_user() { +function common_current_user() +{ global $_cur; if ($_cur === false) { @@ -752,23 +788,27 @@ function common_current_user() { // cookie-stealing. So, we don't let them do certain things. New reg, // OpenID, and password logins _are_ real. -function common_real_login($real=true) { +function common_real_login($real=true) +{ common_ensure_session(); $_SESSION['real_login'] = $real; } -function common_is_real_login() { +function common_is_real_login() +{ return common_logged_in() && $_SESSION['real_login']; } // get canonical version of nickname for comparison -function common_canonical_nickname($nickname) { +function common_canonical_nickname($nickname) +{ // XXX: UTF-8 canonicalization (like combining chars) return strtolower($nickname); } // get canonical version of email for comparison -function common_canonical_email($email) { +function common_canonical_email($email) +{ // XXX: canonicalize UTF-8 // XXX: lcase the domain part return $email; @@ -776,7 +816,8 @@ function common_canonical_email($email) { define('URL_REGEX', '^|[ \t\r\n])((ftp|http|https|gopher|mailto|news|nntp|telnet|wais|file|prospero|aim|webcal):(([A-Za-z0-9$_.+!*(),;/?:@&~=-])|%[A-Fa-f0-9]{2}){2,}(#([a-zA-Z0-9][a-zA-Z0-9$_.+!*(),;/?:@&~=%-]*))?([A-Za-z0-9$_+!*();/?:~-]))'); -function common_render_content($text, $notice) { +function common_render_content($text, $notice) +{ $r = common_render_text($text); $id = $notice->profile_id; $r = preg_replace('/(^|\s+)@([A-Za-z0-9]{1,64})/e', "'\\1@'.common_at_link($id, '\\2')", $r); @@ -785,7 +826,8 @@ function common_render_content($text, $notice) { return $r; } -function common_render_text($text) { +function common_render_text($text) +{ $r = htmlspecialchars($text); $r = preg_replace('/[\x{0}-\x{8}\x{b}-\x{c}\x{e}-\x{19}]/', '', $r); @@ -795,7 +837,8 @@ function common_render_text($text) { return $r; } -function common_render_uri_thingy($matches) { +function common_render_uri_thingy($matches) +{ $uri = $matches[0]; $trailer = ''; @@ -829,20 +872,23 @@ function common_render_uri_thingy($matches) { return '<a href="' . $uri . '"' . $title . ' class="extlink">' . $uri . '</a>' . $trailer; } -function common_longurl($short_url) { +function common_longurl($short_url) +{ $long_url = common_shorten_link($short_url, true); if ($long_url === $short_url) return false; return $long_url; } -function common_longurl2($uri) { +function common_longurl2($uri) +{ $uri_e = urlencode($uri); $longurl = unserialize(file_get_contents("http://api.longurl.org/v1/expand?format=php&url=$uri_e")); if (empty($longurl['long_url']) || $uri === $longurl['long_url']) return false; return stripslashes($longurl['long_url']); } -function common_shorten_links($text) { +function common_shorten_links($text) +{ if (mb_strlen($text) <= 140) return $text; static $cache = array(); if (isset($cache[$text])) return $cache[$text]; @@ -850,7 +896,8 @@ function common_shorten_links($text) { return $cache[$text] = preg_replace('@https?://[^)\]>\s]+@e', "common_shorten_link('\\0')", $text); } -function common_shorten_link($url, $reverse = false) { +function common_shorten_link($url, $reverse = false) +{ static $url_cache = array(); if ($reverse) return isset($url_cache[$url]) ? $url_cache[$url] : $url; @@ -911,28 +958,33 @@ function common_shorten_link($url, $reverse = false) { return $url; } -function common_xml_safe_str($str) { +function common_xml_safe_str($str) +{ $xmlStr = htmlentities(iconv('UTF-8', 'UTF-8//IGNORE', $str), ENT_NOQUOTES, 'UTF-8'); // Replace control, formatting, and surrogate characters with '*', ala Twitter return preg_replace('/[\p{Cc}\p{Cf}\p{Cs}]/u', '*', $str); } -function common_tag_link($tag) { +function common_tag_link($tag) +{ $canonical = common_canonical_tag($tag); $url = common_local_url('tag', array('tag' => $canonical)); return '<a href="' . htmlspecialchars($url) . '" rel="tag" class="hashlink">' . htmlspecialchars($tag) . '</a>'; } -function common_canonical_tag($tag) { +function common_canonical_tag($tag) +{ return strtolower(str_replace(array('-', '_', '.'), '', $tag)); } -function common_valid_profile_tag($str) { +function common_valid_profile_tag($str) +{ return preg_match('/^[A-Za-z0-9_\-\.]{1,64}$/', $str); } -function common_at_link($sender_id, $nickname) { +function common_at_link($sender_id, $nickname) +{ $sender = Profile::staticGet($sender_id); $recipient = common_relative_profile($sender, common_canonical_nickname($nickname)); if ($recipient) { @@ -942,7 +994,8 @@ function common_at_link($sender_id, $nickname) { } } -function common_at_hash_link($sender_id, $tag) { +function common_at_hash_link($sender_id, $tag) +{ $user = User::staticGet($sender_id); if (!$user) { return $tag; @@ -958,7 +1011,8 @@ function common_at_hash_link($sender_id, $tag) { } } -function common_relative_profile($sender, $nickname, $dt=null) { +function common_relative_profile($sender, $nickname, $dt=null) +{ // Try to find profiles this profile is subscribed to that have this nickname $recipient = new Profile(); // XXX: use a join instead of a subquery @@ -995,7 +1049,8 @@ function common_relative_profile($sender, $nickname, $dt=null) { // where should the avatar go for this user? -function common_avatar_filename($id, $extension, $size=null, $extra=null) { +function common_avatar_filename($id, $extension, $size=null, $extra=null) +{ global $config; if ($size) { @@ -1005,16 +1060,19 @@ function common_avatar_filename($id, $extension, $size=null, $extra=null) { } } -function common_avatar_path($filename) { +function common_avatar_path($filename) +{ global $config; return INSTALLDIR . '/avatar/' . $filename; } -function common_avatar_url($filename) { +function common_avatar_url($filename) +{ return common_path('avatar/'.$filename); } -function common_avatar_display_url($avatar) { +function common_avatar_display_url($avatar) +{ $server = common_config('avatar', 'server'); if ($server) { return 'http://'.$server.'/'.$avatar->filename; @@ -1023,14 +1081,16 @@ function common_avatar_display_url($avatar) { } } -function common_default_avatar($size) { +function common_default_avatar($size) +{ static $sizenames = array(AVATAR_PROFILE_SIZE => 'profile', AVATAR_STREAM_SIZE => 'stream', AVATAR_MINI_SIZE => 'mini'); return theme_path('default-avatar-'.$sizenames[$size].'.png'); } -function common_local_url($action, $args=null, $fragment=null) { +function common_local_url($action, $args=null, $fragment=null) +{ $url = null; if (common_config('site','fancy')) { $url = common_fancy_url($action, $args); @@ -1043,7 +1103,8 @@ function common_local_url($action, $args=null, $fragment=null) { return $url; } -function common_fancy_url($action, $args=null) { +function common_fancy_url($action, $args=null) +{ switch (strtolower($action)) { case 'public': if ($args && isset($args['page'])) { @@ -1256,7 +1317,8 @@ function common_fancy_url($action, $args=null) { } } -function common_simple_url($action, $args=null) { +function common_simple_url($action, $args=null) +{ global $config; /* XXX: pretty URLs */ $extra = ''; @@ -1268,13 +1330,15 @@ function common_simple_url($action, $args=null) { return common_path("index.php?action=${action}${extra}"); } -function common_path($relative) { +function common_path($relative) +{ global $config; $pathpart = ($config['site']['path']) ? $config['site']['path']."/" : ''; return "http://".$config['site']['server'].'/'.$pathpart.$relative; } -function common_date_string($dt) { +function common_date_string($dt) +{ // XXX: do some sexy date formatting // return date(DATE_RFC822, $dt); $t = strtotime($dt); @@ -1308,7 +1372,8 @@ function common_date_string($dt) { } } -function common_exact_date($dt) { +function common_exact_date($dt) +{ static $_utc; static $_siteTz; @@ -1323,32 +1388,37 @@ function common_exact_date($dt) { return $d->format(DATE_RFC850); } -function common_date_w3dtf($dt) { +function common_date_w3dtf($dt) +{ $dateStr = date('d F Y H:i:s', strtotime($dt)); $d = new DateTime($dateStr, new DateTimeZone('UTC')); $d->setTimezone(new DateTimeZone(common_timezone())); return $d->format(DATE_W3C); } -function common_date_rfc2822($dt) { +function common_date_rfc2822($dt) +{ $dateStr = date('d F Y H:i:s', strtotime($dt)); $d = new DateTime($dateStr, new DateTimeZone('UTC')); $d->setTimezone(new DateTimeZone(common_timezone())); return $d->format('r'); } -function common_date_iso8601($dt) { +function common_date_iso8601($dt) +{ $dateStr = date('d F Y H:i:s', strtotime($dt)); $d = new DateTime($dateStr, new DateTimeZone('UTC')); $d->setTimezone(new DateTimeZone(common_timezone())); return $d->format('c'); } -function common_sql_now() { +function common_sql_now() +{ return strftime('%Y-%m-%d %H:%M:%S', time()); } -function common_redirect($url, $code=307) { +function common_redirect($url, $code=307) +{ static $status = array(301 => "Moved Permanently", 302 => "Found", 303 => "See Other", @@ -1364,7 +1434,8 @@ function common_redirect($url, $code=307) { exit; } -function common_save_replies($notice) { +function common_save_replies($notice) +{ // Alternative reply format $tname = false; if (preg_match('/^T ([A-Z0-9]{1,64}) /', $notice->content, $match)) { @@ -1447,7 +1518,8 @@ function common_save_replies($notice) { } } -function common_broadcast_notice($notice, $remote=false) { +function common_broadcast_notice($notice, $remote=false) +{ // Check to see if notice should go to Twitter $flink = Foreign_link::getByUserID($notice->profile_id, 1); // 1 == Twitter @@ -1474,7 +1546,8 @@ function common_broadcast_notice($notice, $remote=false) { } } -function common_twitter_broadcast($notice, $flink) { +function common_twitter_broadcast($notice, $flink) +{ global $config; $success = true; $fuser = $flink->getForeignUser(); @@ -1534,7 +1607,8 @@ function common_twitter_broadcast($notice, $flink) { // Stick the notice on the queue -function common_enqueue_notice($notice) { +function common_enqueue_notice($notice) +{ foreach (array('jabber', 'omb', 'sms', 'public') as $transport) { $qi = new Queue_item(); $qi->notice_id = $notice->id; @@ -1551,7 +1625,8 @@ function common_enqueue_notice($notice) { return $result; } -function common_dequeue_notice($notice) { +function common_dequeue_notice($notice) +{ $qi = Queue_item::staticGet($notice->id); if ($qi) { $result = $qi->delete(); @@ -1567,7 +1642,8 @@ function common_dequeue_notice($notice) { } } -function common_real_broadcast($notice, $remote=false) { +function common_real_broadcast($notice, $remote=false) +{ $success = true; if (!$remote) { // Make sure we have the OMB stuff @@ -1601,7 +1677,8 @@ function common_real_broadcast($notice, $remote=false) { return $success; } -function common_broadcast_profile($profile) { +function common_broadcast_profile($profile) +{ // XXX: optionally use a queue system like http://code.google.com/p/microapps/wiki/NQDQ require_once(INSTALLDIR.'/lib/omb.php'); omb_broadcast_profile($profile); @@ -1609,13 +1686,15 @@ function common_broadcast_profile($profile) { return true; } -function common_profile_url($nickname) { +function common_profile_url($nickname) +{ return common_local_url('showstream', array('nickname' => $nickname)); } // Don't call if nobody's logged in -function common_notice_form($action=null, $content=null) { +function common_notice_form($action=null, $content=null) +{ $user = common_current_user(); assert(!is_null($user)); common_element_start('form', array('id' => 'status_form', @@ -1647,14 +1726,16 @@ function common_notice_form($action=null, $content=null) { // Should make up a reasonable root URL -function common_root_url() { +function common_root_url() +{ return common_path(''); } // returns $bytes bytes of random data as a hexadecimal string // "good" here is a goal and not a guarantee -function common_good_rand($bytes) { +function common_good_rand($bytes) +{ // XXX: use random.org...? if (file_exists('/dev/urandom')) { return common_urandom($bytes); @@ -1663,7 +1744,8 @@ function common_good_rand($bytes) { } } -function common_urandom($bytes) { +function common_urandom($bytes) +{ $h = fopen('/dev/urandom', 'rb'); // should not block $src = fread($h, $bytes); @@ -1675,7 +1757,8 @@ function common_urandom($bytes) { return $enc; } -function common_mtrand($bytes) { +function common_mtrand($bytes) +{ $enc = ''; for ($i = 0; $i < $bytes; $i++) { $enc .= sprintf("%02x", mt_rand(0, 255)); @@ -1683,21 +1766,25 @@ function common_mtrand($bytes) { return $enc; } -function common_set_returnto($url) { +function common_set_returnto($url) +{ common_ensure_session(); $_SESSION['returnto'] = $url; } -function common_get_returnto() { +function common_get_returnto() +{ common_ensure_session(); return $_SESSION['returnto']; } -function common_timestamp() { +function common_timestamp() +{ return date('YmdHis'); } -function common_ensure_syslog() { +function common_ensure_syslog() +{ static $initialized = false; if (!$initialized) { global $config; @@ -1706,7 +1793,8 @@ function common_ensure_syslog() { } } -function common_log($priority, $msg, $filename=null) { +function common_log($priority, $msg, $filename=null) +{ $logfile = common_config('site', 'logfile'); if ($logfile) { $log = fopen($logfile, "a"); @@ -1723,7 +1811,8 @@ function common_log($priority, $msg, $filename=null) { } } -function common_debug($msg, $filename=null) { +function common_debug($msg, $filename=null) +{ if ($filename) { common_log(LOG_DEBUG, basename($filename).' - '.$msg); } else { @@ -1731,13 +1820,15 @@ function common_debug($msg, $filename=null) { } } -function common_log_db_error(&$object, $verb, $filename=null) { +function common_log_db_error(&$object, $verb, $filename=null) +{ $objstr = common_log_objstring($object); $last_error = &PEAR::getStaticProperty('DB_DataObject','lastError'); common_log(LOG_ERR, $last_error->message . '(' . $verb . ' on ' . $objstr . ')', $filename); } -function common_log_objstring(&$object) { +function common_log_objstring(&$object) +{ if (is_null($object)) { return "null"; } @@ -1750,11 +1841,13 @@ function common_log_objstring(&$object) { return $objstring; } -function common_valid_http_url($url) { +function common_valid_http_url($url) +{ return Validate::uri($url, array('allowed_schemes' => array('http', 'https'))); } -function common_valid_tag($tag) { +function common_valid_tag($tag) +{ if (preg_match('/^tag:(.*?),(\d{4}(-\d{2}(-\d{2})?)?):(.*)$/', $tag, $matches)) { return (Validate::email($matches[1]) || preg_match('/^([\w-\.]+)$/', $matches[1])); @@ -1764,7 +1857,8 @@ function common_valid_tag($tag) { // Does a little before-after block for next/prev page -function common_pagination($have_before, $have_after, $page, $action, $args=null) { +function common_pagination($have_before, $have_after, $page, $action, $args=null) +{ if ($have_before || $have_after) { common_element_start('div', array('id' => 'pagination')); @@ -1799,7 +1893,8 @@ function common_pagination($have_before, $have_after, $page, $action, $args=null /* Following functions are copied from MediaWiki GlobalFunctions.php * and written by Evan Prodromou. */ -function common_accept_to_prefs($accept, $def = '*/*') { +function common_accept_to_prefs($accept, $def = '*/*') +{ // No arg means accept anything (per HTTP spec) if(!$accept) { return array($def => 1); @@ -1823,7 +1918,8 @@ function common_accept_to_prefs($accept, $def = '*/*') { return $prefs; } -function common_mime_type_match($type, $avail) { +function common_mime_type_match($type, $avail) +{ if(array_key_exists($type, $avail)) { return $type; } else { @@ -1838,7 +1934,8 @@ function common_mime_type_match($type, $avail) { } } -function common_negotiate_type($cprefs, $sprefs) { +function common_negotiate_type($cprefs, $sprefs) +{ $combine = array(); foreach(array_keys($sprefs) as $type) { @@ -1874,12 +1971,14 @@ function common_negotiate_type($cprefs, $sprefs) { return $besttype; } -function common_config($main, $sub) { +function common_config($main, $sub) +{ global $config; return isset($config[$main][$sub]) ? $config[$main][$sub] : false; } -function common_copy_args($from) { +function common_copy_args($from) +{ $to = array(); $strip = get_magic_quotes_gpc(); foreach ($from as $k => $v) { @@ -1890,25 +1989,29 @@ function common_copy_args($from) { // Neutralise the evil effects of magic_quotes_gpc in the current request. // This is used before handing a request off to OAuthRequest::from_request. -function common_remove_magic_from_request() { +function common_remove_magic_from_request() +{ if(get_magic_quotes_gpc()) { $_POST=array_map('stripslashes',$_POST); $_GET=array_map('stripslashes',$_GET); } } -function common_user_uri(&$user) { +function common_user_uri(&$user) +{ return common_local_url('userbyid', array('id' => $user->id)); } -function common_notice_uri(&$notice) { +function common_notice_uri(&$notice) +{ return common_local_url('shownotice', array('notice' => $notice->id)); } // 36 alphanums - lookalikes (0, O, 1, I) = 32 chars = 5 bits -function common_confirmation_code($bits) { +function common_confirmation_code($bits) +{ // 36 alphanums - lookalikes (0, O, 1, I) = 32 chars = 5 bits static $codechars = '23456789ABCDEFGHJKLMNPQRSTUVWXYZ'; $chars = ceil($bits/5); @@ -1925,14 +2028,16 @@ function common_confirmation_code($bits) { // convert markup to HTML -function common_markup_to_html($c) { +function common_markup_to_html($c) +{ $c = preg_replace('/%%action.(\w+)%%/e', "common_local_url('\\1')", $c); $c = preg_replace('/%%doc.(\w+)%%/e', "common_local_url('doc', array('title'=>'\\1'))", $c); $c = preg_replace('/%%(\w+).(\w+)%%/e', 'common_config(\'\\1\', \'\\2\')', $c); return Markdown($c); } -function common_profile_avatar_url($profile, $size=AVATAR_PROFILE_SIZE) { +function common_profile_avatar_url($profile, $size=AVATAR_PROFILE_SIZE) +{ $avatar = $profile->getAvatar($size); if ($avatar) { return common_avatar_display_url($avatar); @@ -1941,7 +2046,8 @@ function common_profile_avatar_url($profile, $size=AVATAR_PROFILE_SIZE) { } } -function common_profile_uri($profile) { +function common_profile_uri($profile) +{ if (!$profile) { return null; } @@ -1958,13 +2064,15 @@ function common_profile_uri($profile) { return null; } -function common_canonical_sms($sms) { +function common_canonical_sms($sms) +{ // strip non-digits preg_replace('/\D/', '', $sms); return $sms; } -function common_error_handler($errno, $errstr, $errfile, $errline, $errcontext) { +function common_error_handler($errno, $errstr, $errfile, $errline, $errcontext) +{ switch ($errno) { case E_USER_ERROR: common_log(LOG_ERR, "[$errno] $errstr ($errfile:$errline)"); @@ -1985,7 +2093,8 @@ function common_error_handler($errno, $errstr, $errfile, $errline, $errcontext) return true; } -function common_session_token() { +function common_session_token() +{ common_ensure_session(); if (!array_key_exists('token', $_SESSION)) { $_SESSION['token'] = common_good_rand(64); @@ -1993,7 +2102,8 @@ function common_session_token() { return $_SESSION['token']; } -function common_disfavor_form($notice) { +function common_disfavor_form($notice) +{ common_element_start('form', array('id' => 'disfavor-' . $notice->id, 'method' => 'post', 'class' => 'disfavor', @@ -2020,7 +2130,8 @@ function common_disfavor_form($notice) { common_element_end('form'); } -function common_favor_form($notice) { +function common_favor_form($notice) +{ common_element_start('form', array('id' => 'favor-' . $notice->id, 'method' => 'post', 'class' => 'favor', @@ -2047,7 +2158,8 @@ function common_favor_form($notice) { common_element_end('form'); } -function common_nudge_form($profile) { +function common_nudge_form($profile) +{ common_element_start('form', array('id' => 'nudge', 'method' => 'post', 'action' => common_local_url('nudge', array('nickname' => $profile->nickname)))); common_hidden('token', common_session_token()); @@ -2056,11 +2168,13 @@ function common_nudge_form($profile) { 'value' => _('Send a nudge'))); common_element_end('form'); } -function common_nudge_response() { +function common_nudge_response() +{ common_element('p', array('id' => 'nudge_response'), _('Nudge sent!')); } -function common_subscribe_form($profile) { +function common_subscribe_form($profile) +{ common_element_start('form', array('id' => 'subscribe-' . $profile->id, 'method' => 'post', 'class' => 'subscribe', @@ -2076,7 +2190,8 @@ function common_subscribe_form($profile) { common_element_end('form'); } -function common_unsubscribe_form($profile) { +function common_unsubscribe_form($profile) +{ common_element_start('form', array('id' => 'unsubscribe-' . $profile->id, 'method' => 'post', 'class' => 'unsubscribe', @@ -2093,7 +2208,8 @@ function common_unsubscribe_form($profile) { } // XXX: Refactor this code -function common_profile_new_message_nudge ($cur, $profile) { +function common_profile_new_message_nudge ($cur, $profile) +{ $user = User::staticGet('id', $profile->id); if ($cur && $cur->id != $user->id && $cur->mutuallySubscribed($user)) { @@ -2110,17 +2226,20 @@ function common_profile_new_message_nudge ($cur, $profile) { } } -function common_cache_key($extra) { +function common_cache_key($extra) +{ return 'laconica:' . common_keyize(common_config('site', 'name')) . ':' . $extra; } -function common_keyize($str) { +function common_keyize($str) +{ $str = strtolower($str); $str = preg_replace('/\s/', '_', $str); return $str; } -function common_message_form($content, $user, $to) { +function common_message_form($content, $user, $to) +{ common_element_start('form', array('id' => 'message_form', 'method' => 'post', @@ -2160,7 +2279,8 @@ function common_message_form($content, $user, $to) { common_element_end('form'); } -function common_memcache() { +function common_memcache() +{ static $cache = null; if (!common_config('memcached', 'enabled')) { return null; @@ -2180,22 +2300,26 @@ function common_memcache() { } } -function common_compatible_license($from, $to) { +function common_compatible_license($from, $to) +{ // XXX: better compatibility check needed here! return ($from == $to); } /* These are almost identical, so we use a helper function */ -function common_block_form($profile, $args=null) { +function common_block_form($profile, $args=null) +{ common_blocking_form('block', _('Block'), $profile, $args); } -function common_unblock_form($profile, $args=null) { +function common_unblock_form($profile, $args=null) +{ common_blocking_form('unblock', _('Unblock'), $profile, $args); } -function common_blocking_form($type, $label, $profile, $args=null) { +function common_blocking_form($type, $label, $profile, $args=null) +{ common_element_start('form', array('id' => $type . '-' . $profile->id, 'method' => 'post', 'class' => $type, diff --git a/_darcs/pristine/lib/xmppqueuehandler.php b/_darcs/pristine/lib/xmppqueuehandler.php index 10c754a5b..0a73403f9 100644 --- a/_darcs/pristine/lib/xmppqueuehandler.php +++ b/_darcs/pristine/lib/xmppqueuehandler.php @@ -30,7 +30,8 @@ require_once(INSTALLDIR.'/lib/queuehandler.php'); class XmppQueueHandler extends QueueHandler { - function start() { + function start() + { # Low priority; we don't want to receive messages $this->log(LOG_INFO, "INITIALIZE"); $this->conn = jabber_connect($this->_id); @@ -43,12 +44,14 @@ class XmppQueueHandler extends QueueHandler { return !is_null($this->conn); } - function handle_reconnect(&$pl) { + function handle_reconnect(&$pl) + { $this->conn->processUntil('session_start'); $this->conn->presence(null, 'available', null, 'available', -1); } - function idle($timeout=0) { + function idle($timeout=0) + { # Process the queue for as long as needed try { if ($this->conn) { @@ -60,7 +63,8 @@ class XmppQueueHandler extends QueueHandler { } } - function forward_message(&$pl) { + function forward_message(&$pl) + { if ($pl['type'] != 'chat') { $this->log(LOG_DEBUG, 'Ignoring message of type ' . $pl['type'] . ' from ' . $pl['from']); return; @@ -74,14 +78,16 @@ class XmppQueueHandler extends QueueHandler { $this->conn->message($this->listener(), $pl['body'], 'chat', null, $this->ofrom($pl['from'])); } - function ofrom($from) { + function ofrom($from) + { $address = "<addresses xmlns='http://jabber.org/protocol/address'>\n"; $address .= "<address type='ofrom' jid='$from' />\n"; $address .= "</addresses>\n"; return $address; } - function listener() { + function listener() + { if (common_config('xmpp', 'listener')) { return common_config('xmpp', 'listener'); } else { |