From 2dd5a5f86d5242362499c381c8d9519f40a8925b Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Thu, 27 Aug 2009 12:06:45 -0400 Subject: Do not used named capturing groups I'm not sure all php 5.2's are compiled with a PCRE library that supported named captures. --- lib/util.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/util.php b/lib/util.php index 7c1e21913..1e7834057 100644 --- a/lib/util.php +++ b/lib/util.php @@ -413,7 +413,7 @@ function common_replace_urls_callback($text, $callback, $notice_id = null) { // Start off with a regex $regex = '#'. '(?:^|[\s\(\)\[\]\{\}\\\'\\\";]+)(?![\@\!\#])'. - '(?P'. + '('. '(?:'. '(?:'. //Known protocols '(?:'. @@ -454,7 +454,7 @@ function common_replace_urls_callback($text, $callback, $notice_id = null) { } function callback_helper($matches, $callback, $notice_id) { - $url=$matches['url']; + $url=$matches[1]; $left = strpos($matches[0],$url); $right = $left+strlen($url); -- cgit v1.2.3-54-g00ecf From 6ff00c9404cb2b2dddcd12d63c497c85d9d087d8 Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Thu, 27 Aug 2009 22:55:32 -0400 Subject: Implement the is_member and membership group api's --- actions/api.php | 2 + actions/twitapigroups.php | 95 ++++++++++++++++++++++++++++++++++++++++++++++- lib/twitterapi.php | 46 +++++++++++++++++++++++ 3 files changed, 142 insertions(+), 1 deletion(-) diff --git a/actions/api.php b/actions/api.php index 93e33085f..f425a8dcd 100644 --- a/actions/api.php +++ b/actions/api.php @@ -133,6 +133,8 @@ class ApiAction extends Action 'groups/show', 'groups/timeline', 'groups/list_all', + 'groups/membership', + 'groups/is_member', 'groups/timeline'); static $bareauth = array('statuses/user_timeline', diff --git a/actions/twitapigroups.php b/actions/twitapigroups.php index 214fa8214..1740a33b5 100644 --- a/actions/twitapigroups.php +++ b/actions/twitapigroups.php @@ -21,7 +21,7 @@ * * @category Twitter * @package StatusNet - * @author Craig Andrews + * @author Craig Andrews * @author Zach Copley * @copyright 2009 StatusNet, Inc. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 @@ -233,4 +233,97 @@ require_once INSTALLDIR.'/lib/twitterapi.php'; } } + function membership($args, $apidata) + { + parent::handle($args); + + common_debug("in groups api action"); + + $this->auth_user = $apidata['user']; + $group = $this->get_group($apidata['api_arg'], $apidata); + + if (empty($group)) { + $this->clientError('Not Found', 404, $apidata['content-type']); + return; + } + + $sitename = common_config('site', 'name'); + $title = sprintf(_("Members of %s group"), $group->nickname); + $taguribase = common_config('integration', 'taguri'); + $id = "tag:$taguribase:GroupMembership:".$group->id; + $link = common_local_url('showgroup', + array('nickname' => $group->nickname)); + $subtitle = sprintf(_('Members of %1$s on %2$s'), + $group->nickname, $sitename); + + $page = (int)$this->arg('page', 1); + $count = (int)$this->arg('count', 20); + $max_id = (int)$this->arg('max_id', 0); + $since_id = (int)$this->arg('since_id', 0); + $since = $this->arg('since'); + + $member = $group->getMembers(($page-1)*$count, + $count, $since_id, $max_id, $since); + + switch($apidata['content-type']) { + case 'xml': + $this->show_twitter_xml_users($member); + break; + //TODO implement the RSS and ATOM content types + /*case 'rss': + $this->show_rss_users($member, $title, $link, $subtitle); + break;*/ + /*case 'atom': + if (isset($apidata['api_arg'])) { + $selfuri = common_root_url() . + 'api/statusnet/groups/membership/' . + $apidata['api_arg'] . '.atom'; + } else { + $selfuri = common_root_url() . + 'api/statusnet/groups/membership.atom'; + } + $this->show_atom_users($member, $title, $id, $link, + $subtitle, null, $selfuri); + break;*/ + case 'json': + $this->show_json_users($member); + break; + default: + $this->clientError(_('API method not found!'), $code = 404); + } + } + + function is_member($args, $apidata) + { + parent::handle($args); + + common_debug("in groups api action"); + + $this->auth_user = $apidata['user']; + $group = User_group::staticGet($args['group_id']); + if(! $group){ + $this->clientError(_('Group not found'), $code = 500); + } + $user = User::staticGet('id', $args['user_id']); + if(! $user){ + $this->clientError(_('User not found'), $code = 500); + } + + $is_member=$user->isMember($group); + + switch($apidata['content-type']) { + case 'xml': + $this->init_document('xml'); + $this->element('is_member', null, $is_member); + $this->end_document('xml'); + break; + case 'json': + $this->init_document('json'); + $this->show_json_objects(array('is_member'=>$is_member)); + $this->end_document('json'); + break; + default: + $this->clientError(_('API method not found!'), $code = 404); + } + } } diff --git a/lib/twitterapi.php b/lib/twitterapi.php index c8099978f..638efba24 100644 --- a/lib/twitterapi.php +++ b/lib/twitterapi.php @@ -791,6 +791,52 @@ class TwitterapiAction extends Action $this->end_document('xml'); } + function show_twitter_xml_users($user) + { + + $this->init_document('xml'); + $this->elementStart('users', array('type' => 'array')); + + if (is_array($user)) { + foreach ($group as $g) { + $twitter_user = $this->twitter_user_array($g); + $this->show_twitter_xml_user($twitter_user,'user'); + } + } else { + while ($user->fetch()) { + $twitter_user = $this->twitter_user_array($user); + $this->show_twitter_xml_user($twitter_user); + } + } + + $this->elementEnd('users'); + $this->end_document('xml'); + } + + function show_json_users($user) + { + + $this->init_document('json'); + + $users = array(); + + if (is_array($user)) { + foreach ($user as $u) { + $twitter_user = $this->twitter_user_array($u); + array_push($users, $twitter_user); + } + } else { + while ($user->fetch()) { + $twitter_user = $this->twitter_user_array($user); + array_push($users, $twitter_user); + } + } + + $this->show_json_objects($users); + + $this->end_document('json'); + } + function show_single_json_group($group) { $this->init_document('json'); -- cgit v1.2.3-54-g00ecf From 70fc32c5b93a6cd71cf33212ac792c38632bbdb3 Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Thu, 27 Aug 2009 22:56:54 -0400 Subject: added my email address next to my name at the top of the files --- actions/twitapigroups.php | 2 +- actions/twitapitags.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/actions/twitapigroups.php b/actions/twitapigroups.php index 1740a33b5..4deb1b764 100644 --- a/actions/twitapigroups.php +++ b/actions/twitapigroups.php @@ -41,7 +41,7 @@ require_once INSTALLDIR.'/lib/twitterapi.php'; * * @category Twitter * @package StatusNet - * @author Craig Andrews + * @author Craig Andrews * @author Zach Copley * @copyright 2009 StatusNet, Inc. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 diff --git a/actions/twitapitags.php b/actions/twitapitags.php index 2bb7ee01a..0bcc55d37 100644 --- a/actions/twitapitags.php +++ b/actions/twitapitags.php @@ -21,7 +21,7 @@ * * @category Twitter * @package StatusNet - * @author Craig Andrews + * @author Craig Andrews * @author Zach Copley * @copyright 2009 StatusNet, Inc. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 @@ -41,7 +41,7 @@ require_once INSTALLDIR.'/lib/twitterapi.php'; * * @category Twitter * @package StatusNet - * @author Craig Andrews + * @author Craig Andrews * @author Zach Copley * @copyright 2009 StatusNet, Inc. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 -- cgit v1.2.3-54-g00ecf From 0056b635c661c4aaf6bce08795af925388e35f5c Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 27 Aug 2009 20:06:03 -0700 Subject: reformat curry() to make my editor happy --- lib/util.php | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/lib/util.php b/lib/util.php index cedb70873..79a219fd6 100644 --- a/lib/util.php +++ b/lib/util.php @@ -457,7 +457,7 @@ function callback_helper($matches, $callback, $notice_id) { $url=$matches[1]; $left = strpos($matches[0],$url); $right = $left+strlen($url); - + $groupSymbolSets=array( array( 'left'=>'(', @@ -491,9 +491,7 @@ function callback_helper($matches, $callback, $notice_id) { $url=substr($url,0,-1); } }while($original_url!=$url); - - - + if(empty($notice_id)){ $result = call_user_func_array($callback,$url); }else{ @@ -508,16 +506,13 @@ function curry($fn) { array_shift($args); $id = uniqid('_partial'); $GLOBALS[$id] = array($fn, $args); - return create_function( - '', - ' - $args = func_get_args(); - return call_user_func_array( - $GLOBALS["'.$id.'"][0], - array_merge( - $args, - $GLOBALS["'.$id.'"][1])); - '); + return create_function('', + '$args = func_get_args(); '. + 'return call_user_func_array('. + '$GLOBALS["'.$id.'"][0],'. + 'array_merge('. + '$args,'. + '$GLOBALS["'.$id.'"][1]));'); } function common_linkify($url) { -- cgit v1.2.3-54-g00ecf From 34ce75c71d37754fa941233c805c042a47910184 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 27 Aug 2009 20:09:07 -0700 Subject: remove duplicate save of Notice and streamline attachment detection --- classes/Notice.php | 13 +------------ lib/util.php | 41 ++++++++++++----------------------------- 2 files changed, 13 insertions(+), 41 deletions(-) diff --git a/classes/Notice.php b/classes/Notice.php index e59712864..28d5b8ddf 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -58,7 +58,7 @@ class Notice extends Memcached_DataObject /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE - /* Notice types */ + /* Notice types */ const LOCAL_PUBLIC = 1; const REMOTE_OMB = 0; const LOCAL_NONPUBLIC = -1; @@ -248,17 +248,6 @@ class Notice extends Memcached_DataObject $notice->saveUrls(); - // FIXME: why do we have to re-render the content? - // Remove this if it's not necessary. - - $orig2 = clone($notice); - - $notice->rendered = common_render_content($final, $notice); - if (!$notice->update($orig2)) { - common_log_db_error($notice, 'UPDATE', __FILE__); - return _('Problem saving notice.'); - } - $notice->query('COMMIT'); Event::handle('EndNoticeSave', array($notice)); diff --git a/lib/util.php b/lib/util.php index 79a219fd6..070b4232c 100644 --- a/lib/util.php +++ b/lib/util.php @@ -542,8 +542,7 @@ function common_linkify($url) { $attachment_id = null; $has_thumb = false; - // Check to see whether there's a filename associated with this URL. - // If there is, it's an upload and qualifies as an attachment + // Check to see whether this is a known "attachment" URL. $localfile = File::staticGet('url', $longurl); @@ -551,33 +550,17 @@ function common_linkify($url) { if (isset($localfile->filename)) { $is_attachment = true; $attachment_id = $localfile->id; - } - } - - // if this URL is an attachment, then we set class='attachment' and id='attahcment-ID' - // where ID is the id of the attachment for the given URL. - // - // we need a better test telling what can be shown as an attachment - // we're currently picking up oembeds only. - // I think the best option is another file_view table in the db - // and associated dbobject. - - $query = "select file_oembed.file_id as file_id from file join file_oembed on file.id = file_oembed.file_id where file.url='$longurl'"; - $file = new File; - $file->query($query); - $file->fetch(); - - if (!empty($file->file_id)) { - $is_attachment = true; - $attachment_id = $file->file_id; - - $query = "select file_thumbnail.file_id as file_id from file join file_thumbnail on file.id = file_thumbnail.file_id where file.url='$longurl'"; - $file2 = new File; - $file2->query($query); - $file2->fetch(); - - if (!empty($file2)) { - $has_thumb = true; + } else { // if it has OEmbed info, it's an attachment, too + $foe = File_oembed::staticGet('file_id', $localfile->id); + if (!empty($foe)) { + $is_attachment = true; + $attachment_id = $localfile->id; + + $thumb = File_thumbnail::staticGet('file_id', $localfile->id); + if (!empty($thumb)) { + $has_thumb = true; + } + } } } -- cgit v1.2.3-54-g00ecf From c0d03fc2799c7b0c57d05166b404a3d13427f497 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 27 Aug 2009 20:23:31 -0700 Subject: make URL analyzer save new info on URLs --- classes/File.php | 8 +++++--- lib/util.php | 21 +++++++++++++-------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/classes/File.php b/classes/File.php index 0cebfc55e..f4d0a3a48 100644 --- a/classes/File.php +++ b/classes/File.php @@ -85,7 +85,7 @@ class File extends Memcached_DataObject return $x; } - function processNew($given_url, $notice_id) { + function processNew($given_url, $notice_id=null) { if (empty($given_url)) return -1; // error, no url to process $given_url = File_redirection::_canonUrl($given_url); if (empty($given_url)) return -1; // error, no url to process @@ -96,7 +96,7 @@ class File extends Memcached_DataObject $redir_data = File_redirection::where($given_url); $redir_url = $redir_data['url']; // TODO: max field length - if ($redir_url === $given_url || strlen($redir_url) > 255) { + if ($redir_url === $given_url || strlen($redir_url) > 255) { $x = File::saveNew($redir_data, $given_url); $file_id = $x->id; } else { @@ -119,7 +119,9 @@ class File extends Memcached_DataObject } } - File_to_post::processNew($file_id, $notice_id); + if (!empty($notice_id)) { + File_to_post::processNew($file_id, $notice_id); + } return $x; } diff --git a/lib/util.php b/lib/util.php index 070b4232c..8a56be55d 100644 --- a/lib/util.php +++ b/lib/util.php @@ -520,7 +520,7 @@ function common_linkify($url) { // functions $url = htmlspecialchars_decode($url); - if(strpos($url, '@')!==false && strpos($url, ':')===false){ + if(strpos($url, '@') !== false && strpos($url, ':') === false) { //url is an email address without the mailto: protocol return XMLStringer::estring('a', array('href' => "mailto:$url", 'rel' => 'external'), $url); } @@ -544,19 +544,24 @@ function common_linkify($url) { // Check to see whether this is a known "attachment" URL. - $localfile = File::staticGet('url', $longurl); + $f = File::staticGet('url', $longurl); - if (!empty($localfile)) { - if (isset($localfile->filename)) { + if (empty($f)) { + // XXX: this writes to the database. :< + $f = File::processNew($longurl); + } + + if (!empty($f)) { + if (isset($f->filename)) { $is_attachment = true; - $attachment_id = $localfile->id; + $attachment_id = $f->id; } else { // if it has OEmbed info, it's an attachment, too - $foe = File_oembed::staticGet('file_id', $localfile->id); + $foe = File_oembed::staticGet('file_id', $f->id); if (!empty($foe)) { $is_attachment = true; - $attachment_id = $localfile->id; + $attachment_id = $f->id; - $thumb = File_thumbnail::staticGet('file_id', $localfile->id); + $thumb = File_thumbnail::staticGet('file_id', $f->id); if (!empty($thumb)) { $has_thumb = true; } -- cgit v1.2.3-54-g00ecf From 51adf00bd80253322b473ab199e5b97dd4951d5c Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Fri, 28 Aug 2009 04:36:47 +0000 Subject: Renable basic auth posting to Twitter for users who already have a bridge setup --- lib/twitter.php | 176 +++++++++++++++++++++++++++++++++------------ lib/twitteroauthclient.php | 9 +++ 2 files changed, 141 insertions(+), 44 deletions(-) diff --git a/lib/twitter.php b/lib/twitter.php index 7546ffa98..d63384fc9 100644 --- a/lib/twitter.php +++ b/lib/twitter.php @@ -154,80 +154,168 @@ function broadcast_twitter($notice) TWITTER_SERVICE); if (is_twitter_bound($notice, $flink)) { + if (TwitterOAuthClient::isPackedToken($flink->credentials)) { + return broadcast_oauth($notice, $flink); + } else { + return broadcast_basicauth($notice, $flink); + } + } +} - $user = $flink->getUser(); +function broadcast_oauth($notice, $flink) { - // XXX: Hack to get around PHP cURL's use of @ being a a meta character - $statustxt = preg_replace('/^@/', ' @', $notice->content); + $user = $flink->getUser(); + $statustxt = format_status($notice); + $token = TwitterOAuthClient::unpackToken($flink->credentials); + $client = new TwitterOAuthClient($token->key, $token->secret); + $status = null; - $token = TwitterOAuthClient::unpackToken($flink->credentials); + try { + $status = $client->statusesUpdate($statustxt); + } catch (OAuthClientCurlException $e) { - $client = new TwitterOAuthClient($token->key, $token->secret); + if ($e->getMessage() == 'The requested URL returned error: 401') { - $status = null; + $errmsg = sprintf('User %1$s (user id: %2$s) has an invalid ' . + 'Twitter OAuth access token.', + $user->nickname, $user->id); + common_log(LOG_WARNING, $errmsg); - try { - $status = $client->statusesUpdate($statustxt); - } catch (OAuthClientCurlException $e) { + // Bad auth token! We need to delete the foreign_link + // to Twitter and inform the user. - if ($e->getMessage() == 'The requested URL returned error: 401') { + remove_twitter_link($flink); + return true; - $errmsg = sprintf('User %1$s (user id: %2$s) has an invalid ' . - 'Twitter OAuth access token.', - $user->nickname, $user->id); - common_log(LOG_WARNING, $errmsg); + } else { - // Bad auth token! We need to delete the foreign_link - // to Twitter and inform the user. + // Some other error happened, so we should probably + // try to send again later. - remove_twitter_link($flink); - return true; + $errmsg = sprintf('cURL error trying to send notice to Twitter ' . + 'for user %1$s (user id: %2$s) - ' . + 'code: %3$s message: $4$s.', + $user->nickname, $user->id, + $e->getCode(), $e->getMessage()); + common_log(LOG_WARNING, $errmsg); - } else { + return false; + } + } - // Some other error happened, so we should probably - // try to send again later. + if (empty($status)) { - $errmsg = sprintf('cURL error trying to send notice to Twitter ' . - 'for user %1$s (user id: %2$s) - ' . - 'code: %3$s message: $4$s.', - $user->nickname, $user->id, - $e->getCode(), $e->getMessage()); - common_log(LOG_WARNING, $errmsg); + // This could represent a failure posting, + // or the Twitter API might just be behaving flakey. - return false; - } - } + $errmsg = sprintf('No data returned by Twitter API when ' . + 'trying to send update for %1$s (user id %2$s).', + $user->nickname, $user->id); + common_log(LOG_WARNING, $errmsg); - if (empty($status)) { + return false; + } - // This could represent a failure posting, - // or the Twitter API might just be behaving flakey. + // Notice crossed the great divide - $errmsg = sprint('No data returned by Twitter API when ' . - 'trying to send update for %1$s (user id %2$s).', - $user->nickname, $user->id); - common_log(LOG_WARNING, $errmsg); + $msg = sprintf('Twitter bridge posted notice %s to Twitter.', + $notice->id); + common_log(LOG_INFO, $msg); - return false; - } + return true; +} + +function broadcast_basicauth($notice, $flink) +{ + $user = $flink->getUser(); + $fuser = $flink->getForeignUser(); + $twitter_user = $fuser->nickname; + $twitter_password = $flink->credentials; + $uri = 'http://www.twitter.com/statuses/update.json'; + $statustxt = format_status($notice); + + $options = array(CURLOPT_USERPWD => "$twitter_user:$twitter_password", + CURLOPT_POST => true, + CURLOPT_POSTFIELDS => + array( + 'status' => $statustxt, + 'source' => common_config('integration', 'source') + ), + CURLOPT_RETURNTRANSFER => true, + CURLOPT_FAILONERROR => true, + CURLOPT_HEADER => false, + CURLOPT_FOLLOWLOCATION => true, + CURLOPT_USERAGENT => "StatusNet", + CURLOPT_CONNECTTIMEOUT => 120, + CURLOPT_TIMEOUT => 120, + + # Twitter is strict about accepting invalid "Expect" headers + CURLOPT_HTTPHEADER => array('Expect:')); + + $ch = curl_init($uri); + curl_setopt_array($ch, $options); + $data = curl_exec($ch); + $errmsg = curl_error($ch); + + if ($errmsg == 'The requested URL returned error: 401') { + + $errmsg = sprintf('User %1$s (user id: %2$s) has an invalid ' . + 'Twitter basic auth username/password.', + $user->nickname, $user->id); + common_log(LOG_WARNING, $errmsg); + + // Bad credentials. We need to delete the foreign_link + // to Twitter and inform the user. + + remove_twitter_link($flink); + return true; + + } elseif (!empty($errmsg)) { + + $code = curl_errno($ch); + + $msg = "cURL error: $code, '$errmsg' - trying to send notice $notice->id " . + "to Twitter using basic auth."; + + common_log(LOG_WARNING, $msg); + + return false; + } - // Notice crossed the great divide + curl_close($ch); - $msg = sprintf('Twitter bridge posted notice %s to Twitter.', - $notice->id); - common_log(LOG_INFO, $msg); + $status = json_decode($data); + + if (empty($status)) { + + $errmsg = sprintf('No data returned by Twitter API when ' . + 'trying to send update for %1$s (user id %2$s) ' . + 'using basic auth.', + $user->nickname, $user->id); + common_log(LOG_WARNING, $errmsg); + + return false; } + $msg = sprintf('Twitter bridge posted notice %s to Twitter using basic auth.', + $notice->id); + common_log(LOG_INFO, $msg); + return true; } +function format_status($notice) +{ + // XXX: Hack to get around PHP cURL's use of @ being a a meta character + return preg_replace('/^@/', ' @', $notice->content); +} + function remove_twitter_link($flink) { $user = $flink->getUser(); common_log(LOG_INFO, 'Removing Twitter bridge Foreign link for ' . - "user $user->nickname (user id: $user->id)."); + "user $user->nickname (user id: $user->id)."); $result = $flink->delete(); diff --git a/lib/twitteroauthclient.php b/lib/twitteroauthclient.php index 3da522fc5..9821a491e 100644 --- a/lib/twitteroauthclient.php +++ b/lib/twitteroauthclient.php @@ -81,6 +81,15 @@ class TwitterOAuthClient extends OAuthClient return new OAuthToken($vals[0], $vals[1]); } + static function isPackedToken($str) + { + if (strpos($str, chr(0)) === false) { + return false; + } else { + return true; + } + } + /** * Builds a link to Twitter's endpoint for authorizing a request token * -- cgit v1.2.3-54-g00ecf From 36b6ef8d05bf6e4290894f9677cc9618a9bfd486 Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Fri, 28 Aug 2009 06:00:30 +0000 Subject: Abstract the Twitter basic auth stuff into its own client class --- lib/twitter.php | 77 +++++--------- lib/twitterbasicauthclient.php | 236 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 262 insertions(+), 51 deletions(-) create mode 100644 lib/twitterbasicauthclient.php diff --git a/lib/twitter.php b/lib/twitter.php index d63384fc9..b734d22d8 100644 --- a/lib/twitter.php +++ b/lib/twitter.php @@ -218,7 +218,7 @@ function broadcast_oauth($notice, $flink) { // Notice crossed the great divide - $msg = sprintf('Twitter bridge posted notice %s to Twitter.', + $msg = sprintf('Twitter bridge posted notice %s to Twitter using OAuth.', $notice->id); common_log(LOG_INFO, $msg); @@ -228,70 +228,44 @@ function broadcast_oauth($notice, $flink) { function broadcast_basicauth($notice, $flink) { $user = $flink->getUser(); - $fuser = $flink->getForeignUser(); - $twitter_user = $fuser->nickname; - $twitter_password = $flink->credentials; - $uri = 'http://www.twitter.com/statuses/update.json'; + $statustxt = format_status($notice); - $options = array(CURLOPT_USERPWD => "$twitter_user:$twitter_password", - CURLOPT_POST => true, - CURLOPT_POSTFIELDS => - array( - 'status' => $statustxt, - 'source' => common_config('integration', 'source') - ), - CURLOPT_RETURNTRANSFER => true, - CURLOPT_FAILONERROR => true, - CURLOPT_HEADER => false, - CURLOPT_FOLLOWLOCATION => true, - CURLOPT_USERAGENT => "StatusNet", - CURLOPT_CONNECTTIMEOUT => 120, - CURLOPT_TIMEOUT => 120, - - # Twitter is strict about accepting invalid "Expect" headers - CURLOPT_HTTPHEADER => array('Expect:')); - - $ch = curl_init($uri); - curl_setopt_array($ch, $options); - $data = curl_exec($ch); - $errmsg = curl_error($ch); - - if ($errmsg == 'The requested URL returned error: 401') { - - $errmsg = sprintf('User %1$s (user id: %2$s) has an invalid ' . - 'Twitter basic auth username/password.', - $user->nickname, $user->id); - common_log(LOG_WARNING, $errmsg); + $client = new TwitterBasicAuthClient($flink); + $status = null; - // Bad credentials. We need to delete the foreign_link - // to Twitter and inform the user. + try { + $status = $client->statusesUpdate($statustxt); + } catch (BasicAuthCurlException $e) { - remove_twitter_link($flink); - return true; + if ($e->getMessage() == 'The requested URL returned error: 401') { - } elseif (!empty($errmsg)) { + $errmsg = sprintf('User %1$s (user id: %2$s) has an invalid ' . + 'Twitter screen_name/password combo.', + $user->nickname, $user->id); + common_log(LOG_WARNING, $errmsg); - $code = curl_errno($ch); + remove_twitter_link($flink); + return true; - $msg = "cURL error: $code, '$errmsg' - trying to send notice $notice->id " . - "to Twitter using basic auth."; + } else { - common_log(LOG_WARNING, $msg); + $errmsg = sprintf('cURL error trying to send notice to Twitter ' . + 'for user %1$s (user id: %2$s) - ' . + 'code: %3$s message: $4$s.', + $user->nickname, $user->id, + $e->getCode(), $e->getMessage()); + common_log(LOG_WARNING, $errmsg); - return false; + return false; + } } - curl_close($ch); - - $status = json_decode($data); - if (empty($status)) { $errmsg = sprintf('No data returned by Twitter API when ' . - 'trying to send update for %1$s (user id %2$s) ' . - 'using basic auth.', - $user->nickname, $user->id); + 'trying to send update for %1$s (user id %2$s).', + $user->nickname, $user->id); common_log(LOG_WARNING, $errmsg); return false; @@ -302,6 +276,7 @@ function broadcast_basicauth($notice, $flink) common_log(LOG_INFO, $msg); return true; + } function format_status($notice) diff --git a/lib/twitterbasicauthclient.php b/lib/twitterbasicauthclient.php new file mode 100644 index 000000000..82359d93d --- /dev/null +++ b/lib/twitterbasicauthclient.php @@ -0,0 +1,236 @@ +. + * + * @category Integration + * @package StatusNet + * @author Zach Copley + * @copyright 2009 StatusNet, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ + +if (!defined('STATUSNET') && !defined('LACONICA')) { + exit(1); +} + +/** + * Exception wrapper for cURL errors + * + * @category Integration + * @package StatusNet + * @author Zach Copley + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + * + */ +class BasicAuthCurlException extends Exception +{ +} + +/** + * Class for talking to the Twitter API with HTTP Basic Auth. + * + * @category Integration + * @package StatusNet + * @author Zach Copley + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + * + */ +class TwitterBasicAuthClient +{ + var $screen_name = null; + var $password = null; + + /** + * constructor + * + * @param Foreign_link $flink a Foreign_link storing the + * Twitter user's password, etc. + */ + function __construct($flink) + { + $fuser = $flink->getForeignUser(); + $this->screen_name = $fuser->nickname; + $this->password = $flink->credentials; + } + + /** + * Calls Twitter's /stutuses/update API method + * + * @param string $status text of the status + * @param int $in_reply_to_status_id optional id of the status it's + * a reply to + * + * @return mixed the status + */ + function statusesUpdate($status, $in_reply_to_status_id = null) + { + $url = 'https://twitter.com/statuses/update.json'; + $params = array('status' => $status, + 'source' => common_config('integration', 'source'), + 'in_reply_to_status_id' => $in_reply_to_status_id); + $response = $this->httpRequest($url, $params, true); + $status = json_decode($response); + return $status; + } + + /** + * Calls Twitter's /stutuses/friends_timeline API method + * + * @param int $since_id show statuses after this id + * @param int $max_id show statuses before this id + * @param int $cnt number of statuses to show + * @param int $page page number + * + * @return mixed an array of statuses + */ + function statusesFriendsTimeline($since_id = null, $max_id = null, + $cnt = null, $page = null) + { + $url = 'https://twitter.com/statuses/friends_timeline.json'; + $params = array('since_id' => $since_id, + 'max_id' => $max_id, + 'count' => $cnt, + 'page' => $page); + $qry = http_build_query($params); + + if (!empty($qry)) { + $url .= "?$qry"; + } + + $response = $this->httpRequest($url, null, true); + $statuses = json_decode($response); + return $statuses; + } + + /** + * Calls Twitter's /stutuses/friends API method + * + * @param int $id id of the user whom you wish to see friends of + * @param int $user_id numerical user id + * @param int $screen_name screen name + * @param int $page page number + * + * @return mixed an array of twitter users and their latest status + */ + function statusesFriends($id = null, $user_id = null, $screen_name = null, + $page = null) + { + $url = "https://twitter.com/statuses/friends.json"; + + $params = array('id' => $id, + 'user_id' => $user_id, + 'screen_name' => $screen_name, + 'page' => $page); + $qry = http_build_query($params); + + if (!empty($qry)) { + $url .= "?$qry"; + } + + $response = $this->httpRequest($url); + $friends = json_decode($response); + return $friends; + } + + /** + * Calls Twitter's /stutuses/friends/ids API method + * + * @param int $id id of the user whom you wish to see friends of + * @param int $user_id numerical user id + * @param int $screen_name screen name + * @param int $page page number + * + * @return mixed a list of ids, 100 per page + */ + function friendsIds($id = null, $user_id = null, $screen_name = null, + $page = null) + { + $url = "https://twitter.com/friends/ids.json"; + + $params = array('id' => $id, + 'user_id' => $user_id, + 'screen_name' => $screen_name, + 'page' => $page); + $qry = http_build_query($params); + + if (!empty($qry)) { + $url .= "?$qry"; + } + + $response = $this->httpRequest($url); + $ids = json_decode($response); + return $ids; + } + + /** + * Make a HTTP request using cURL. + * + * @param string $url Where to make the request + * @param array $params post parameters + * + * @return mixed the request + */ + function httpRequest($url, $params = null, $auth = false) + { + $options = array( + CURLOPT_RETURNTRANSFER => true, + CURLOPT_FAILONERROR => true, + CURLOPT_HEADER => false, + CURLOPT_FOLLOWLOCATION => true, + CURLOPT_USERAGENT => 'StatusNet', + CURLOPT_CONNECTTIMEOUT => 120, + CURLOPT_TIMEOUT => 120, + CURLOPT_HTTPAUTH => CURLAUTH_ANY, + CURLOPT_SSL_VERIFYPEER => false, + + // Twitter is strict about accepting invalid "Expect" headers + + CURLOPT_HTTPHEADER => array('Expect:') + ); + + if (isset($params)) { + $options[CURLOPT_POST] = true; + $options[CURLOPT_POSTFIELDS] = $params; + } + + if ($auth) { + $options[CURLOPT_USERPWD] = $this->screen_name . + ':' . $this->password; + } + + $ch = curl_init($url); + curl_setopt_array($ch, $options); + $response = curl_exec($ch); + + if ($response === false) { + $msg = curl_error($ch); + $code = curl_errno($ch); + throw new BasicAuthCurlException($msg, $code); + } + + curl_close($ch); + + return $response; + } + +} -- cgit v1.2.3-54-g00ecf From 36c104fb34d7128a0372dd3f77504c0b2f76ba80 Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Fri, 28 Aug 2009 07:02:27 +0000 Subject: Make SyncTwitterFriends and TwitterStatusFetcher daemons use both HTTP Basic Auth as well as OAuth --- lib/oauthclient.php | 2 +- lib/twitterbasicauthclient.php | 6 +++--- lib/twitteroauthclient.php | 2 +- scripts/synctwitterfriends.php | 17 +++++++++++++---- scripts/twitterqueuehandler.php | 2 ++ scripts/twitterstatusfetcher.php | 21 +++++++++++++++------ 6 files changed, 35 insertions(+), 15 deletions(-) diff --git a/lib/oauthclient.php b/lib/oauthclient.php index cc10cea8f..f1827726e 100644 --- a/lib/oauthclient.php +++ b/lib/oauthclient.php @@ -22,7 +22,7 @@ * @category Action * @package StatusNet * @author Zach Copley - * @copyright 2008 StatusNet, Inc. + * @copyright 2009 StatusNet, Inc. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ */ diff --git a/lib/twitterbasicauthclient.php b/lib/twitterbasicauthclient.php index 82359d93d..66bb01e53 100644 --- a/lib/twitterbasicauthclient.php +++ b/lib/twitterbasicauthclient.php @@ -88,7 +88,7 @@ class TwitterBasicAuthClient $params = array('status' => $status, 'source' => common_config('integration', 'source'), 'in_reply_to_status_id' => $in_reply_to_status_id); - $response = $this->httpRequest($url, $params, true); + $response = $this->httpRequest($url, $params); $status = json_decode($response); return $status; } @@ -117,7 +117,7 @@ class TwitterBasicAuthClient $url .= "?$qry"; } - $response = $this->httpRequest($url, null, true); + $response = $this->httpRequest($url); $statuses = json_decode($response); return $statuses; } @@ -190,7 +190,7 @@ class TwitterBasicAuthClient * * @return mixed the request */ - function httpRequest($url, $params = null, $auth = false) + function httpRequest($url, $params = null, $auth = true) { $options = array( CURLOPT_RETURNTRANSFER => true, diff --git a/lib/twitteroauthclient.php b/lib/twitteroauthclient.php index 9821a491e..e37fa05f0 100644 --- a/lib/twitteroauthclient.php +++ b/lib/twitteroauthclient.php @@ -22,7 +22,7 @@ * @category Integration * @package StatusNet * @author Zach Copley - * @copyright 2008 StatusNet, Inc. + * @copyright 2009 StatusNet, Inc. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ */ diff --git a/scripts/synctwitterfriends.php b/scripts/synctwitterfriends.php index 545cb23b3..2cb7525ea 100755 --- a/scripts/synctwitterfriends.php +++ b/scripts/synctwitterfriends.php @@ -19,6 +19,8 @@ */ define('INSTALLDIR', realpath(dirname(__FILE__) . '/..')); +define('STATUSNET', true); +define('LACONICA', true); // compatibility $shortoptions = 'di::'; $longoptions = array('id::', 'debug'); @@ -142,13 +144,20 @@ class SyncTwitterFriendsDaemon extends ParallelizingDaemon { $friends = array(); - $token = TwitterOAuthClient::unpackToken($flink->credentials); + $client = null; - $client = new TwitterOAuthClient($token->key, $token->secret); + if (TwitterOAuthClient::isPackedToken($flink->credentials)) { + $token = TwitterOAuthClient::unpackToken($flink->credentials); + $client = new TwitterOAuthClient($token->key, $token->secret); + common_debug($this->name() . '- Grabbing friends IDs with OAuth.'); + } else { + $client = new TwitterBasicAuthClient($flink); + common_debug($this->name() . '- Grabbing friends IDs with basic auth.'); + } try { $friends_ids = $client->friendsIds(); - } catch (OAuthCurlException $e) { + } catch (Exception $e) { common_log(LOG_WARNING, $this->name() . ' - cURL error getting friend ids ' . $e->getCode() . ' - ' . $e->getMessage()); @@ -177,7 +186,7 @@ class SyncTwitterFriendsDaemon extends ParallelizingDaemon try { $more_friends = $client->statusesFriends(null, null, null, $i); - } catch (OAuthCurlException $e) { + } catch (Exception $e) { common_log(LOG_WARNING, $this->name() . ' - cURL error getting Twitter statuses/friends ' . "page $i - " . $e->getCode() . ' - ' . diff --git a/scripts/twitterqueuehandler.php b/scripts/twitterqueuehandler.php index ce4d824d0..992141f9d 100755 --- a/scripts/twitterqueuehandler.php +++ b/scripts/twitterqueuehandler.php @@ -19,6 +19,8 @@ */ define('INSTALLDIR', realpath(dirname(__FILE__) . '/..')); +define('STATUSNET', true); +define('LACONICA', true); // compatibility $shortoptions = 'i::'; $longoptions = array('id::'); diff --git a/scripts/twitterstatusfetcher.php b/scripts/twitterstatusfetcher.php index 68f7e9bf7..6dca6f75b 100755 --- a/scripts/twitterstatusfetcher.php +++ b/scripts/twitterstatusfetcher.php @@ -19,6 +19,8 @@ */ define('INSTALLDIR', realpath(dirname(__FILE__) . '/..')); +define('STATUSNET', true); +define('LACONICA', true); // compatibility // Tune number of processes and how often to poll Twitter // XXX: Should these things be in config.php? @@ -148,9 +150,9 @@ class TwitterStatusFetcher extends ParallelizingDaemon function getTimeline($flink) { - if (empty($flink)) { + if (empty($flink)) { common_log(LOG_WARNING, $this->name() . - " - Can't retrieve Foreign_link for foreign ID $fid"); + " - Can't retrieve Foreign_link for foreign ID $fid"); return; } @@ -161,17 +163,24 @@ class TwitterStatusFetcher extends ParallelizingDaemon // to start importing? How many statuses? Right now I'm going // with the default last 20. - $token = TwitterOAuthClient::unpackToken($flink->credentials); + $client = null; - $client = new TwitterOAuthClient($token->key, $token->secret); + if (TwitterOAuthClient::isPackedToken($flink->credentials)) { + $token = TwitterOAuthClient::unpackToken($flink->credentials); + $client = new TwitterOAuthClient($token->key, $token->secret); + common_debug($this->name() . ' - Grabbing friends timeline with OAuth.'); + } else { + $client = new TwitterBasicAuthClient($flink); + common_debug($this->name() . ' - Grabbing friends timeline with basic auth.'); + } $timeline = null; try { $timeline = $client->statusesFriendsTimeline(); - } catch (OAuthClientCurlException $e) { + } catch (Exception $e) { common_log(LOG_WARNING, $this->name() . - ' - OAuth client unable to get friends timeline for user ' . + ' - Twitter client unable to get friends timeline for user ' . $flink->user_id . ' - code: ' . $e->getCode() . 'msg: ' . $e->getMessage()); } -- cgit v1.2.3-54-g00ecf From e277c856d65885a487b4d7f090a10cf817da836a Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 28 Aug 2009 20:00:55 +1200 Subject: fix for SQL error: ERROR: syntax error at or near ")" at character 45 http://laconi.ca/trac/ticket/1735 --- classes/Notice.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/classes/Notice.php b/classes/Notice.php index 28d5b8ddf..89afe9d1d 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -732,6 +732,10 @@ class Notice extends Memcached_DataObject return new ArrayWrapper($notices); } else { $notice = new Notice(); + if (empty($ids)) { + //if no IDs requested, just return the notice object + return $notice; + } $notice->whereAdd('id in (' . implode(', ', $ids) . ')'); $notice->orderBy('id DESC'); -- cgit v1.2.3-54-g00ecf From 06514aa001f8c567918a5e5533b3d4a24f427439 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 28 Aug 2009 20:00:55 +1200 Subject: fix for SQL error: ERROR: syntax error at or near ")" at character 45 http://laconi.ca/trac/ticket/1735 --- classes/Notice.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/classes/Notice.php b/classes/Notice.php index e569d8305..c3c8d13c8 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -755,6 +755,10 @@ class Notice extends Memcached_DataObject return new ArrayWrapper($notices); } else { $notice = new Notice(); + if (empty($ids)) { + //if no IDs requested, just return the notice object + return $notice; + } $notice->whereAdd('id in (' . implode(', ', $ids) . ')'); $notice->orderBy('id DESC'); -- cgit v1.2.3-54-g00ecf From a0e41693e48be87feb0baa378c74e8309146c9c5 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 28 Aug 2009 20:33:49 +1200 Subject: added config table --- db/statusnet_pg.sql | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/db/statusnet_pg.sql b/db/statusnet_pg.sql index 5b4d0485a..dbfd50098 100644 --- a/db/statusnet_pg.sql +++ b/db/statusnet_pg.sql @@ -549,3 +549,13 @@ create index noticecontent_idx on notice using gist(to_tsvector('english',conten create trigger textsearchupdate before insert or update on profile for each row execute procedure tsvector_update_trigger(textsearch, 'pg_catalog.english', nickname, fullname, location, bio, homepage); + +create table config ( + + section varchar(32) /* comment 'configuration section'*/, + setting varchar(32) /* comment 'configuration setting'*/, + value varchar(255) /* comment 'configuration value'*/, + + primary key (section, setting) + +); -- cgit v1.2.3-54-g00ecf From f4117119ffca76b0d7ff14bd1f99b607f248151b Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 28 Aug 2009 20:35:35 +1200 Subject: added the user_role table --- db/statusnet_pg.sql | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/db/statusnet_pg.sql b/db/statusnet_pg.sql index dbfd50098..672877ddf 100644 --- a/db/statusnet_pg.sql +++ b/db/statusnet_pg.sql @@ -559,3 +559,13 @@ create table config ( primary key (section, setting) ); + +create table user_role ( + + user_id integer not null /* comment 'user having the role'*/ references "user" (id), + role varchar(32) not null /* comment 'string representing the role'*/, + created timestamp /* not null comment 'date the role was granted'*/, + + primary key (user_id, role) + +); -- cgit v1.2.3-54-g00ecf From b833b725a8b1da1ddbe3ff8f05dd1ccd660955a1 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 28 Aug 2009 20:42:13 +1200 Subject: make use of common_database_tablename() --- classes/User.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/classes/User.php b/classes/User.php index 58f9a6874..618e2d6aa 100644 --- a/classes/User.php +++ b/classes/User.php @@ -103,10 +103,7 @@ class User extends Memcached_DataObject } $toupdate = implode(', ', $parts); - $table = $this->tableName(); - if(common_config('db','quote_identifiers')) { - $table = '"' . $table . '"'; - } + $table = common_database_tablename($this->tableName()); $qry = 'UPDATE ' . $table . ' SET ' . $toupdate . ' WHERE id = ' . $this->id; $orig->decache(); -- cgit v1.2.3-54-g00ecf From b9ea2bf1bc96629c91bfb41d665e5a6954fa9b06 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 28 Aug 2009 20:44:11 +1200 Subject: used standard SQL that mysql and pgsql both like --- classes/User.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/classes/User.php b/classes/User.php index 618e2d6aa..060cd8005 100644 --- a/classes/User.php +++ b/classes/User.php @@ -627,11 +627,7 @@ class User extends Memcached_DataObject 'ORDER BY subscription.created DESC '; if ($offset) { - if (common_config('db','type') == 'pgsql') { - $qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset; - } else { - $qry .= ' LIMIT ' . $offset . ', ' . $limit; - } + $qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset; } $profile = new Profile(); -- cgit v1.2.3-54-g00ecf From 815630fe6377824fd94c93463938603aed5f6ea8 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 28 Aug 2009 20:45:12 +1200 Subject: used standard SQL that mysql and pgsql both like --- classes/User.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/classes/User.php b/classes/User.php index 060cd8005..11cb4f08b 100644 --- a/classes/User.php +++ b/classes/User.php @@ -650,11 +650,7 @@ class User extends Memcached_DataObject 'AND subscription.subscribed != subscription.subscriber ' . 'ORDER BY subscription.created DESC '; - if (common_config('db','type') == 'pgsql') { - $qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset; - } else { - $qry .= ' LIMIT ' . $offset . ', ' . $limit; - } + $qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset; $profile = new Profile(); -- cgit v1.2.3-54-g00ecf From 53ec4223e4f175d19d158a9e487e7c6d447d76de Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 28 Aug 2009 21:04:15 +1200 Subject: fix for postgres - was using a non-existent variable to work out if should write quote_identifiers=true --- install.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.php b/install.php index 4c5bc38ae..f4dcef2e8 100644 --- a/install.php +++ b/install.php @@ -624,7 +624,7 @@ function writeConf($sitename, $server, $path, $fancy, $db) // database "\$config['db']['database'] = '{$db['database']}';\n\n". - ($type == 'pgsql' ? "\$config['db']['quote_identifiers'] = true;\n\n":''). + ($db['type'] == 'pgsql' ? "\$config['db']['quote_identifiers'] = true;\n\n":''). "\$config['db']['type'] = '{$db['type']}';\n\n". "?>"; -- cgit v1.2.3-54-g00ecf From e04e009ddb51cf8327744a2d642b793a3d9716cd Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Fri, 28 Aug 2009 06:13:47 -0700 Subject: stutuses -> statuses --- lib/twitterbasicauthclient.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/twitterbasicauthclient.php b/lib/twitterbasicauthclient.php index 66bb01e53..fd331fbdc 100644 --- a/lib/twitterbasicauthclient.php +++ b/lib/twitterbasicauthclient.php @@ -74,7 +74,7 @@ class TwitterBasicAuthClient } /** - * Calls Twitter's /stutuses/update API method + * Calls Twitter's /statuses/update API method * * @param string $status text of the status * @param int $in_reply_to_status_id optional id of the status it's @@ -94,7 +94,7 @@ class TwitterBasicAuthClient } /** - * Calls Twitter's /stutuses/friends_timeline API method + * Calls Twitter's /statuses/friends_timeline API method * * @param int $since_id show statuses after this id * @param int $max_id show statuses before this id @@ -123,7 +123,7 @@ class TwitterBasicAuthClient } /** - * Calls Twitter's /stutuses/friends API method + * Calls Twitter's /statuses/friends API method * * @param int $id id of the user whom you wish to see friends of * @param int $user_id numerical user id @@ -153,7 +153,7 @@ class TwitterBasicAuthClient } /** - * Calls Twitter's /stutuses/friends/ids API method + * Calls Twitter's /statuses/friends/ids API method * * @param int $id id of the user whom you wish to see friends of * @param int $user_id numerical user id @@ -163,7 +163,7 @@ class TwitterBasicAuthClient * @return mixed a list of ids, 100 per page */ function friendsIds($id = null, $user_id = null, $screen_name = null, - $page = null) + $page = null) { $url = "https://twitter.com/friends/ids.json"; -- cgit v1.2.3-54-g00ecf From b4ca06edb286a4518b0a59e2a59e50e1c4b6ecb1 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Fri, 28 Aug 2009 08:43:28 -0700 Subject: fix 'callback_helper' --- lib/util.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/util.php b/lib/util.php index 8a56be55d..87d5800f6 100644 --- a/lib/util.php +++ b/lib/util.php @@ -450,7 +450,7 @@ function common_replace_urls_callback($text, $callback, $notice_id = null) { '#ixu'; preg_match_all($regex,$text,$matches); //print_r($matches); - return preg_replace_callback($regex, curry(callback_helper,$callback,$notice_id) ,$text); + return preg_replace_callback($regex, curry('callback_helper',$callback,$notice_id) ,$text); } function callback_helper($matches, $callback, $notice_id) { -- cgit v1.2.3-54-g00ecf From c628029ef124698fe39522a5038af3f3e1a11a26 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Fri, 28 Aug 2009 10:42:34 -0700 Subject: Status_network had wrong ini file --- classes/Status_network.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/Status_network.php b/classes/Status_network.php index d526cb4d6..fe4f0b0c5 100644 --- a/classes/Status_network.php +++ b/classes/Status_network.php @@ -54,7 +54,7 @@ class Status_network extends DB_DataObject global $config; $config['db']['database_'.$dbname] = "mysqli://$dbuser:$dbpass@$dbhost/$dbname"; - $config['db']['ini_'.$dbname] = INSTALLDIR.'/classes/statusnet.ini'; + $config['db']['ini_'.$dbname] = INSTALLDIR.'/classes/status_network.ini'; $config['db']['table_status_network'] = $dbname; self::$cache = new Memcache(); -- cgit v1.2.3-54-g00ecf From a0a376bf0eca00cce974de12c2f275006c1281ee Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Fri, 28 Aug 2009 17:55:58 +0000 Subject: Take out unnecessary defines --- scripts/synctwitterfriends.php | 2 -- scripts/twitterqueuehandler.php | 2 -- scripts/twitterstatusfetcher.php | 2 -- 3 files changed, 6 deletions(-) diff --git a/scripts/synctwitterfriends.php b/scripts/synctwitterfriends.php index 2cb7525ea..b30e700a1 100755 --- a/scripts/synctwitterfriends.php +++ b/scripts/synctwitterfriends.php @@ -19,8 +19,6 @@ */ define('INSTALLDIR', realpath(dirname(__FILE__) . '/..')); -define('STATUSNET', true); -define('LACONICA', true); // compatibility $shortoptions = 'di::'; $longoptions = array('id::', 'debug'); diff --git a/scripts/twitterqueuehandler.php b/scripts/twitterqueuehandler.php index 992141f9d..ce4d824d0 100755 --- a/scripts/twitterqueuehandler.php +++ b/scripts/twitterqueuehandler.php @@ -19,8 +19,6 @@ */ define('INSTALLDIR', realpath(dirname(__FILE__) . '/..')); -define('STATUSNET', true); -define('LACONICA', true); // compatibility $shortoptions = 'i::'; $longoptions = array('id::'); diff --git a/scripts/twitterstatusfetcher.php b/scripts/twitterstatusfetcher.php index 6dca6f75b..3cdf1867a 100755 --- a/scripts/twitterstatusfetcher.php +++ b/scripts/twitterstatusfetcher.php @@ -19,8 +19,6 @@ */ define('INSTALLDIR', realpath(dirname(__FILE__) . '/..')); -define('STATUSNET', true); -define('LACONICA', true); // compatibility // Tune number of processes and how often to poll Twitter // XXX: Should these things be in config.php? -- cgit v1.2.3-54-g00ecf From 6e570a8440108ac0d16253d35543be19b1c2a713 Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Fri, 28 Aug 2009 14:42:51 -0400 Subject: Added 2 new events: StartApiRss and StartApiAtom --- EVENTS.txt | 7 +++++++ lib/twitterapi.php | 10 +++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/EVENTS.txt b/EVENTS.txt index 05d172585..121ae175d 100644 --- a/EVENTS.txt +++ b/EVENTS.txt @@ -247,3 +247,10 @@ StartLoadDoc: before loading a help doc (hook this to show your own documentatio EndLoadDoc: after loading a help doc (hook this to modify other documentation) - $title: title of the document - $output: HTML output to show + +StartApiRss: after the rss element is started +- $action: action object being shown + +StartApiAtom: after the element is started +- $action: action object being shown + diff --git a/lib/twitterapi.php b/lib/twitterapi.php index 9055d8b98..4612f74e9 100644 --- a/lib/twitterapi.php +++ b/lib/twitterapi.php @@ -595,7 +595,6 @@ class TwitterapiAction extends Action $this->init_document('rss'); - $this->elementStart('channel'); $this->element('title', null, $title); $this->element('link', null, $link); if (!is_null($suplink)) { @@ -621,7 +620,6 @@ class TwitterapiAction extends Action } } - $this->elementEnd('channel'); $this->end_twitter_rss(); } @@ -668,7 +666,6 @@ class TwitterapiAction extends Action $this->init_document('rss'); - $this->elementStart('channel'); $this->element('title', null, $title); $this->element('link', null, $link); $this->element('description', null, $subtitle); @@ -687,7 +684,6 @@ class TwitterapiAction extends Action } } - $this->elementEnd('channel'); $this->end_twitter_rss(); } @@ -944,11 +940,14 @@ class TwitterapiAction extends Action function init_twitter_rss() { $this->startXML(); - $this->elementStart('rss', array('version' => '2.0')); + $this->elementStart('rss', array('version' => '2.0', 'xmlns:atom'=>'http://www.w3.org/2005/Atom')); + $this->elementStart('channel'); + Event::handle('StartApiRss', array($this)); } function end_twitter_rss() { + $this->elementEnd('channel'); $this->elementEnd('rss'); $this->endXML(); } @@ -960,6 +959,7 @@ class TwitterapiAction extends Action $this->elementStart('feed', array('xmlns' => 'http://www.w3.org/2005/Atom', 'xml:lang' => 'en-US', 'xmlns:thr' => 'http://purl.org/syndication/thread/1.0')); + Event::handle('StartApiAtom', array($this)); } function end_twitter_atom() -- cgit v1.2.3-54-g00ecf From 72a60d63814188c7e282d678e281070070be5df2 Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Fri, 28 Aug 2009 14:43:31 -0400 Subject: Added a PubSubHubBub plugin --- plugins/PubSubHubBub/PubSubHubBubPlugin.php | 122 ++++++++++++++++++++++++++++ plugins/PubSubHubBub/publisher.php | 86 ++++++++++++++++++++ 2 files changed, 208 insertions(+) create mode 100644 plugins/PubSubHubBub/PubSubHubBubPlugin.php create mode 100644 plugins/PubSubHubBub/publisher.php diff --git a/plugins/PubSubHubBub/PubSubHubBubPlugin.php b/plugins/PubSubHubBub/PubSubHubBubPlugin.php new file mode 100644 index 000000000..013a234d7 --- /dev/null +++ b/plugins/PubSubHubBub/PubSubHubBubPlugin.php @@ -0,0 +1,122 @@ +. + * + * @category Plugin + * @package StatusNet + * @author Craig Andrews + * @copyright 2009 Craig Andrews http://candrews.integralblue.com + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ + +if (!defined('STATUSNET')) { + exit(1); +} + +define('DEFAULT_HUB','http://2pubsubhubbub.appspot.com'); + +require_once(INSTALLDIR.'/plugins/PubSubHubBub/publisher.php'); + +class PubSubHubBubPlugin extends Plugin +{ + private $hub; + + function __construct() + { + parent::__construct(); + } + + function onInitializePlugin(){ + $this->hub = common_config('PubSubHubBub', 'hub'); + if(empty($this->hub)){ + $this->hub = DEFAULT_HUB; + } + } + + function onStartApiAtom($action){ + $action->element('link',array('rel'=>'hub','href'=>$this->hub),null); + } + + function onStartApiRss($action){ + $action->element('atom:link',array('rel'=>'hub','href'=>$this->hub),null); + } + + function onEndNoticeSave($notice){ + $publisher = new Publisher($this->hub); + + $feeds = array(); + + //public timeline feeds + $feeds[]=common_local_url('api',array('apiaction' => 'statuses','method' => 'public_timeline.rss')); + $feeds[]=common_local_url('api',array('apiaction' => 'statuses','method' => 'public_timeline.atom')); + + //author's own feeds + $user = User::staticGet('id',$notice->profile_id); + $feeds[]=common_local_url('api',array('apiaction' => 'statuses','method' => 'user_timeline','argument' => $user->nickname.'.rss')); + $feeds[]=common_local_url('api',array('apiaction' => 'statuses','method' => 'user_timeline','argument' => $user->nickname.'.atom')); + + //tag feeds + $tag = new Notice_tag(); + $tag->notice_id = $notice->id; + if ($tag->find()) { + while ($tag->fetch()) { + $feeds[]=common_local_url('api',array('apiaction' => 'tags','method' => 'timeline', 'argument'=>$tag->tag.'.atom')); + $feeds[]=common_local_url('api',array('apiaction' => 'tags','method' => 'timeline', 'argument'=>$tag->tag.'.rss')); + } + } + + //group feeds + $group_inbox = new Group_inbox(); + $group_inbox->notice_id = $notice->id; + if ($group_inbox->find()) { + while ($group_inbox->fetch()) { + $group = User_group::staticGet('id',$group_inbox->group_id); + $feeds[]=common_local_url('api',array('apiaction' => 'groups','method' => 'timeline','argument' => $group->nickname.'.rss')); + $feeds[]=common_local_url('api',array('apiaction' => 'groups','method' => 'timeline','argument' => $group->nickname.'.atom')); + } + } + + //feed of each user that subscribes to the notice's author + $notice_inbox = new Notice_inbox(); + $notice_inbox->notice_id = $notice->id; + if ($notice_inbox->find()) { + while ($notice_inbox->fetch()) { + $user = User::staticGet('id',$notice_inbox->user_id); + $feeds[]=common_local_url('api',array('apiaction' => 'statuses','method' => 'user_timeline','argument' => $user->nickname.'.rss')); + $feeds[]=common_local_url('api',array('apiaction' => 'statuses','method' => 'user_timeline','argument' => $user->nickname.'.atom')); + } + } + + /* TODO: when the reply page gets RSS and ATOM feeds, implement this + //feed of user replied to + if($notice->reply_to){ + $user = User::staticGet('id',$notice->reply_to); + $feeds[]=common_local_url('api',array('apiaction' => 'statuses','method' => 'user_timeline','argument' => $user->nickname.'.rss')); + $feeds[]=common_local_url('api',array('apiaction' => 'statuses','method' => 'user_timeline','argument' => $user->nickname.'.atom')); + }*/ + + foreach(array_unique($feeds) as $feed){ + if(! $publisher->publish_update($feed)){ + common_log_line(LOG_WARNING,$feed.' was not published to hub at '.$this->hub.':'.$publisher->last_response()); + } + } + } +} diff --git a/plugins/PubSubHubBub/publisher.php b/plugins/PubSubHubBub/publisher.php new file mode 100644 index 000000000..f176a9b8a --- /dev/null +++ b/plugins/PubSubHubBub/publisher.php @@ -0,0 +1,86 @@ +hub_url = $hub_url; + } + + // accepts either a single url or an array of urls + public function publish_update($topic_urls, $http_function = false) { + if (!isset($topic_urls)) + throw new Exception('Please specify a topic url'); + + // check that we're working with an array + if (!is_array($topic_urls)) { + $topic_urls = array($topic_urls); + } + + // set the mode to publish + $post_string = "hub.mode=publish"; + // loop through each topic url + foreach ($topic_urls as $topic_url) { + + // lightweight check that we're actually working w/ a valid url + if (!preg_match("|^https?://|i",$topic_url)) + throw new Exception('The specified topic url does not appear to be valid: '.$topic_url); + + // append the topic url parameters + $post_string .= "&hub.url=".urlencode($topic_url); + } + + // make the http post request and return true/false + // easy to over-write to use your own http function + if ($http_function) + return $http_function($this->hub_url,$post_string); + else + return $this->http_post($this->hub_url,$post_string); + } + + // returns any error message from the latest request + public function last_response() { + return $this->last_response; + } + + // default http function that uses curl to post to the hub endpoint + private function http_post($url, $post_string) { + + // add any additional curl options here + $options = array(CURLOPT_URL => $url, + CURLOPT_POST => true, + CURLOPT_POSTFIELDS => $post_string, + CURLOPT_USERAGENT => "PubSubHubbub-Publisher-PHP/1.0"); + + $ch = curl_init(); + curl_setopt_array($ch, $options); + + $response = curl_exec($ch); + $this->last_response = $response; + $info = curl_getinfo($ch); + + curl_close($ch); + + // all good + if ($info['http_code'] == 204) + return true; + return false; + } +} + +?> \ No newline at end of file -- cgit v1.2.3-54-g00ecf From 3368452ebf3c738933b05e902c277296684e280b Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Fri, 28 Aug 2009 16:18:05 -0400 Subject: Add % and ~ as valid characters in the path, querystring, and fragment parts of URLs --- lib/util.php | 10 +++++----- tests/URLDetectionTest.php | 4 ++++ 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/util.php b/lib/util.php index 8a56be55d..edc08d4c1 100644 --- a/lib/util.php +++ b/lib/util.php @@ -421,7 +421,7 @@ function common_replace_urls_callback($text, $callback, $notice_id = null) { '|'. '(?:(?:mailto|aim|tel|xmpp):)'. ')'. - '(?:[\pN\pL\-\_\+]+(?::[\pN\pL\-\_\+]+)?\@)?'. //user:pass@ + '(?:[\pN\pL\-\_\+\%\~]+(?::[\pN\pL\-\_\+\%\~]+)?\@)?'. //user:pass@ '(?:'. '(?:'. '\[[\pN\pL\-\_\:\.]+(?127.0.0.1:99'), array('127.0.0.1/test.php', '127.0.0.1/test.php'), + array('127.0.0.1/~test', + '127.0.0.1/~test'), + array('127.0.0.1/test%20stuff', + '127.0.0.1/test%20stuff'), array('http://[::1]:99/test.php', 'http://[::1]:99/test.php'), array('http://::1/test.php', -- cgit v1.2.3-54-g00ecf From b562ff1f2c6bca7e200034dac78b6debdcc0b214 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Fri, 28 Aug 2009 13:35:28 -0700 Subject: change version to 0.8.2dev --- lib/common.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/common.php b/lib/common.php index 39d4ffc9b..88d77732f 100644 --- a/lib/common.php +++ b/lib/common.php @@ -19,7 +19,7 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } -define('STATUSNET_VERSION', '0.8.1'); +define('STATUSNET_VERSION', '0.8.2dev'); define('LACONICA_VERSION', STATUSNET_VERSION); // compatibility define('STATUSNET_CODENAME', 'Second Guessing'); -- cgit v1.2.3-54-g00ecf From 8689955e0879d160f3fea31c3abdb97d64bc294f Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 29 Aug 2009 09:48:30 +1200 Subject: added missing parts to postgres update, and the config+user_role tables to both upgrade scripts --- db/08to09.sql | 20 ++++++++++++++++++++ db/08to09_pg.sql | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) diff --git a/db/08to09.sql b/db/08to09.sql index 223a99fa3..953e0e5f4 100644 --- a/db/08to09.sql +++ b/db/08to09.sql @@ -12,3 +12,23 @@ alter table user_group alter table file_oembed add column mimetype varchar(50) comment 'mime type of resource'; + +create table config ( + + section varchar(32) comment 'configuration section', + setting varchar(32) comment 'configuration setting', + value varchar(255) comment 'configuration value', + + constraint primary key (section, setting) + +) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin; + +create table user_role ( + + user_id integer not null comment 'user having the role' references user (id), + role varchar(32) not null comment 'string representing the role', + created datetime not null comment 'date the role was granted', + + constraint primary key (user_id, role) + +) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin; diff --git a/db/08to09_pg.sql b/db/08to09_pg.sql index 892df4a39..492b3ebb9 100644 --- a/db/08to09_pg.sql +++ b/db/08to09_pg.sql @@ -1,2 +1,40 @@ // SQL commands to update an 0.8.x version of Laconica // to 0.9.x. + +--these are just comments +/* +alter table notice + modify column content text comment 'update content'; + +alter table message + modify column content text comment 'message content'; + +alter table profile + modify column bio text comment 'descriptive biography'; + +alter table user_group + modify column description text comment 'group description'; +*/ + +alter table file_oembed + add column mimetype varchar(50) /*comment 'mime type of resource'*/; + +create table config ( + + section varchar(32) /* comment 'configuration section'*/, + setting varchar(32) /* comment 'configuration setting'*/, + value varchar(255) /* comment 'configuration value'*/, + + primary key (section, setting) + +); + +create table user_role ( + + user_id integer not null /* comment 'user having the role'*/ references "user" (id), + role varchar(32) not null /* comment 'string representing the role'*/, + created timestamp /* not null comment 'date the role was granted'*/, + + primary key (user_id, role) + +); \ No newline at end of file -- cgit v1.2.3-54-g00ecf From c02e8a46878ba3ba1ea24f746db8ef0039d19612 Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Sat, 29 Aug 2009 06:20:19 +0000 Subject: Fix error in log msg format specifier --- lib/twitter.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/twitter.php b/lib/twitter.php index b734d22d8..655525194 100644 --- a/lib/twitter.php +++ b/lib/twitter.php @@ -194,7 +194,7 @@ function broadcast_oauth($notice, $flink) { $errmsg = sprintf('cURL error trying to send notice to Twitter ' . 'for user %1$s (user id: %2$s) - ' . - 'code: %3$s message: $4$s.', + 'code: %3$s message: %4$s.', $user->nickname, $user->id, $e->getCode(), $e->getMessage()); common_log(LOG_WARNING, $errmsg); @@ -252,7 +252,7 @@ function broadcast_basicauth($notice, $flink) $errmsg = sprintf('cURL error trying to send notice to Twitter ' . 'for user %1$s (user id: %2$s) - ' . - 'code: %3$s message: $4$s.', + 'code: %3$s message: %4$s.', $user->nickname, $user->id, $e->getCode(), $e->getMessage()); common_log(LOG_WARNING, $errmsg); -- cgit v1.2.3-54-g00ecf From fb447f713acb48ad81ea7e8005894ff9aa83c342 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 31 Aug 2009 11:01:01 +1200 Subject: fixed up some invalid comment syntax - this is ANSI SQL --- db/08to09_pg.sql | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/db/08to09_pg.sql b/db/08to09_pg.sql index 492b3ebb9..9e37314aa 100644 --- a/db/08to09_pg.sql +++ b/db/08to09_pg.sql @@ -1,5 +1,5 @@ -// SQL commands to update an 0.8.x version of Laconica -// to 0.9.x. +-- SQL commands to update an 0.8.x version of Laconica +-- to 0.9.x. --these are just comments /* @@ -37,4 +37,4 @@ create table user_role ( primary key (user_id, role) -); \ No newline at end of file +); -- cgit v1.2.3-54-g00ecf From b54a25c8951e48b675bc314d9d18d14b1957f56e Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 31 Aug 2009 10:59:50 +1200 Subject: some typoes in comments that annoyed me, fixed now --- lib/twitteroauthclient.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/twitteroauthclient.php b/lib/twitteroauthclient.php index 3da522fc5..e4a89c4e9 100644 --- a/lib/twitteroauthclient.php +++ b/lib/twitteroauthclient.php @@ -109,7 +109,7 @@ class TwitterOAuthClient extends OAuthClient } /** - * Calls Twitter's /stutuses/update API method + * Calls Twitter's /statuses/update API method * * @param string $status text of the status * @param int $in_reply_to_status_id optional id of the status it's @@ -128,7 +128,7 @@ class TwitterOAuthClient extends OAuthClient } /** - * Calls Twitter's /stutuses/friends_timeline API method + * Calls Twitter's /statuses/friends_timeline API method * * @param int $since_id show statuses after this id * @param int $max_id show statuses before this id @@ -158,7 +158,7 @@ class TwitterOAuthClient extends OAuthClient } /** - * Calls Twitter's /stutuses/friends API method + * Calls Twitter's /statuses/friends API method * * @param int $id id of the user whom you wish to see friends of * @param int $user_id numerical user id @@ -188,7 +188,7 @@ class TwitterOAuthClient extends OAuthClient } /** - * Calls Twitter's /stutuses/friends/ids API method + * Calls Twitter's /statuses/friends/ids API method * * @param int $id id of the user whom you wish to see friends of * @param int $user_id numerical user id -- cgit v1.2.3-54-g00ecf From 20423af689fbf4dd139e1254dc49ae3df1db0de2 Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Mon, 31 Aug 2009 10:33:37 -0400 Subject: Allow :'s in the path, query string, and fragment parts of the url (Mediawiki URLs often do this) --- lib/util.php | 6 +++--- tests/URLDetectionTest.php | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/util.php b/lib/util.php index 7228b3fe3..6e79ffda4 100644 --- a/lib/util.php +++ b/lib/util.php @@ -442,9 +442,9 @@ function common_replace_urls_callback($text, $callback, $notice_id = null) { ')'. '(?:'. '(?:\:\d+)?'. //:port - '(?:/[\pN\pL$\[\]\,\!\(\)\.\-\_\+\/\=\&\;\%\~]*)?'. // /path - '(?:\?[\pN\pL\$\[\]\,\!\(\)\.\-\_\+\/\=\&\;\%\~\/]*)?'. // ?query string - '(?:\#[\pN\pL$\[\]\,\!\(\)\.\-\_\+\/\=\&\;\%\~\/\?\#]*)?'. // #fragment + '(?:/[\pN\pL$\[\]\,\!\(\)\.\:\-\_\+\/\=\&\;\%\~]*)?'. // /path + '(?:\?[\pN\pL\$\[\]\,\!\(\)\.\:\-\_\+\/\=\&\;\%\~\/]*)?'. // ?query string + '(?:\#[\pN\pL$\[\]\,\!\(\)\.\:\-\_\+\/\=\&\;\%\~\/\?\#]*)?'. // #fragment ')(?127.0.0.1'), array('127.0.0.1:99', '127.0.0.1:99'), - array('127.0.0.1/test.php', - '127.0.0.1/test.php'), + array('127.0.0.1/Name:test.php', + '127.0.0.1/Name:test.php'), array('127.0.0.1/~test', '127.0.0.1/~test'), array('127.0.0.1/test%20stuff', -- cgit v1.2.3-54-g00ecf From 9f372da3da4bd445175eda9155fa7fdd13d3c85e Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Mon, 31 Aug 2009 17:52:45 +0000 Subject: Removed
structure from MailboxAction::showMessage. Same as committ e0b877b26c5e93809b2a53b6c46326d5e31fa0e8. --- lib/mailbox.php | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/lib/mailbox.php b/lib/mailbox.php index a09bf1060..e1d384a06 100644 --- a/lib/mailbox.php +++ b/lib/mailbox.php @@ -213,26 +213,20 @@ class MailboxAction extends CurrentUserDesignAction } $this->elementStart('div', 'entry-content'); - $this->elementStart('dl', 'timestamp'); - $this->element('dt', null, _('Published')); - $this->elementStart('dd', null); - $dt = common_date_iso8601($message->created); $this->elementStart('a', array('rel' => 'bookmark', + 'class' => 'timestamp', 'href' => $messageurl)); + $dt = common_date_iso8601($message->created); $this->element('abbr', array('class' => 'published', 'title' => $dt), common_date_string($message->created)); $this->elementEnd('a'); - $this->elementEnd('dd'); - $this->elementEnd('dl'); if ($message->source) { - $this->elementStart('dl', 'device'); - $this->elementStart('dt'); - $this->text(_('From')); - $this->elementEnd('dt'); - $this->showSource($message->source); - $this->elementEnd('dl'); + $this->elementStart('span', 'source'); + $this->text(_('from')); + $this->element('span', 'device', $this->showSource($message->source)); + $this->elementEnd('span'); } $this->elementEnd('div'); @@ -277,18 +271,18 @@ class MailboxAction extends CurrentUserDesignAction case 'mail': case 'omb': case 'api': - $this->element('dd', null, $source_name); + $this->element('span', 'device', $source_name); break; default: $ns = Notice_source::staticGet($source); if ($ns) { - $this->elementStart('dd', null); + $this->elementStart('span', 'device'); $this->element('a', array('href' => $ns->url, - 'rel' => 'external'), - $ns->name); - $this->elementEnd('dd'); + 'rel' => 'external'), + $ns->name); + $this->elementEnd('span'); } else { - $this->element('dd', null, $source_name); + $this->out->element('span', 'device', $source_name); } break; } -- cgit v1.2.3-54-g00ecf From 951a787877f450fc7f225cba4331f0763b71dbc2 Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Mon, 31 Aug 2009 15:33:23 -0400 Subject: Fix attachment saving --- lib/util.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/util.php b/lib/util.php index 6e79ffda4..f4ba3a6c2 100644 --- a/lib/util.php +++ b/lib/util.php @@ -495,7 +495,7 @@ function callback_helper($matches, $callback, $notice_id) { if(empty($notice_id)){ $result = call_user_func_array($callback,$url); }else{ - $result = call_user_func_array($callback, array($url,$notice_id) ); + $result = call_user_func_array($callback, array(array($url,$notice_id)) ); } return substr($matches[0],0,$left) . $result . substr($matches[0],$right); } -- cgit v1.2.3-54-g00ecf From 3fd0a9693dc666478b29c85a045be3b084bc37e2 Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Mon, 31 Aug 2009 15:49:11 -0400 Subject: Fix typo in Stomp Thanks Marcel|HSD --- extlib/Stomp.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extlib/Stomp.php b/extlib/Stomp.php index 9e1c97b3b..abd9cba62 100644 --- a/extlib/Stomp.php +++ b/extlib/Stomp.php @@ -454,7 +454,7 @@ class Stomp */ public function disconnect () { - $header = array(); + $headers = array(); if ($this->clientId != null) { $headers["client-id"] = $this->clientId; -- cgit v1.2.3-54-g00ecf From 00032e11122463a3b69babc464caa26783c7c644 Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Mon, 31 Aug 2009 22:16:49 -0400 Subject: Allow the oEmbed tag to be split across lines --- extlib/Services/oEmbed.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extlib/Services/oEmbed.php b/extlib/Services/oEmbed.php index 7d507b6f6..b05e3a1d1 100644 --- a/extlib/Services/oEmbed.php +++ b/extlib/Services/oEmbed.php @@ -303,7 +303,7 @@ class Services_oEmbed // Find all tags that have a valid oembed type set. We then // extract the href attribute for each type. $regexp = '#]*)type="' . - '(application/json|text/xml)\+oembed"([^>]*)>#i'; + '(application/json|text/xml)\+oembed"([^>]*)>#im'; $m = $ret = array(); if (!preg_match_all($regexp, $body, $m)) { -- cgit v1.2.3-54-g00ecf From e0e30552cf069e71453f3c3bcf8dce960cf6b553 Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Tue, 1 Sep 2009 19:00:18 +0000 Subject: Stop requeuing notices not bound for Twitter. --- lib/twitter.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/twitter.php b/lib/twitter.php index 655525194..455f7e7ef 100644 --- a/lib/twitter.php +++ b/lib/twitter.php @@ -160,6 +160,8 @@ function broadcast_twitter($notice) return broadcast_basicauth($notice, $flink); } } + + return true; } function broadcast_oauth($notice, $flink) { -- cgit v1.2.3-54-g00ecf From aa7bda4677f1fe7a6168665d4d5e29e8fa2db68c Mon Sep 17 00:00:00 2001 From: Carlos Perilla Date: Tue, 1 Sep 2009 09:19:10 -0500 Subject: Fixes foaf notices, use Profile for information that's missing in Remote_profile --- actions/foaf.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/actions/foaf.php b/actions/foaf.php index 4dae9dfc1..356393304 100644 --- a/actions/foaf.php +++ b/actions/foaf.php @@ -146,8 +146,10 @@ class FoafAction extends Action while ($sub->fetch()) { if ($sub->token) { $other = Remote_profile::staticGet('id', $sub->subscriber); + $profile = Profile::staticGet('id', $sub->subscriber); } else { $other = User::staticGet('id', $sub->subscriber); + $profile = Profile::staticGet('id', $sub->subscriber); } if (!$other) { common_debug('Got a bad subscription: '.print_r($sub,true)); @@ -158,12 +160,15 @@ class FoafAction extends Action } else { $person[$other->uri] = array(LISTENER, $other->id, - $other->nickname, + $profile->nickname, (empty($sub->token)) ? 'User' : 'Remote_profile'); } $other->free(); $other = null; unset($other); + $profile->free(); + $profile = null; + unset($profile); } } @@ -254,8 +259,10 @@ class FoafAction extends Action while ($sub->fetch()) { if (!empty($sub->token)) { $other = Remote_profile::staticGet('id', $sub->subscribed); + $profile = Profile::staticGet('id', $sub->subscribed); } else { $other = User::staticGet('id', $sub->subscribed); + $profile = Profile::staticGet('id', $sub->subscribed); } if (empty($other)) { common_debug('Got a bad subscription: '.print_r($sub,true)); @@ -264,11 +271,14 @@ class FoafAction extends Action $this->element('sioc:follows', array('rdf:resource' => $other->uri.'#acct')); $person[$other->uri] = array(LISTENEE, $other->id, - $other->nickname, + $profile->nickname, (empty($sub->token)) ? 'User' : 'Remote_profile'); $other->free(); $other = null; unset($other); + $profile->free(); + $profile = null; + unset($profile); } } -- cgit v1.2.3-54-g00ecf From 5668959399dc953bb59b28e46690e51066d6ab3d Mon Sep 17 00:00:00 2001 From: Carlos Perilla Date: Tue, 11 Aug 2009 19:09:51 -0500 Subject: Let users join and drop group membership from xmpp --- lib/command.php | 105 ++++++++++++++++++++++++++++++++++++++++++++- lib/commandinterpreter.php | 20 +++++++++ 2 files changed, 124 insertions(+), 1 deletion(-) diff --git a/lib/command.php b/lib/command.php index 91a20b810..01b14f83e 100644 --- a/lib/command.php +++ b/lib/command.php @@ -114,7 +114,6 @@ class StatsCommand extends Command class FavCommand extends Command { - var $other = null; function __construct($user, $other) @@ -158,6 +157,108 @@ class FavCommand extends Command $channel->output($this->user, _('Notice marked as fave.')); } + +} +class JoinCommand extends Command +{ + var $other = null; + + function __construct($user, $other) + { + parent::__construct($user); + $this->other = $other; + } + + function execute($channel) + { + + $nickname = common_canonical_nickname($this->other); + $group = User_group::staticGet('nickname', $nickname); + $cur = $this->user; + + if (!$group) { + $channel->error($cur, _('No such group.')); + return; + } + + if ($cur->isMember($group)) { + $channel->error($cur, _('You are already a member of that group')); + return; + } + if (Group_block::isBlocked($group, $cur->getProfile())) { + $channel->error($cur, _('You have been blocked from that group by the admin.')); + return; + } + + $member = new Group_member(); + + $member->group_id = $group->id; + $member->profile_id = $cur->id; + $member->created = common_sql_now(); + + $result = $member->insert(); + if (!$result) { + common_log_db_error($member, 'INSERT', __FILE__); + $channel->error($cur, sprintf(_('Could not join user %s to group %s'), + $cur->nickname, $group->nickname)); + return; + } + + $channel->output($cur, sprintf(_('%s joined group %s'), + $cur->nickname, + $group->nickname)); + } + +} +class DropCommand extends Command +{ + var $other = null; + + function __construct($user, $other) + { + parent::__construct($user); + $this->other = $other; + } + + function execute($channel) + { + + $nickname = common_canonical_nickname($this->other); + $group = User_group::staticGet('nickname', $nickname); + $cur = $this->user; + + if (!$group) { + $channel->error($cur, _('No such group.')); + return; + } + + if (!$cur->isMember($group)) { + $channel->error($cur, _('You are not a member of that group.')); + return; + } + + $member = new Group_member(); + + $member->group_id = $group->id; + $member->profile_id = $cur->id; + + if (!$member->find(true)) { + $channel->error($cur,_('Could not find membership record.')); + return; + } + $result = $member->delete(); + if (!$result) { + common_log_db_error($member, 'INSERT', __FILE__); + $channel->error($cur, sprintf(_('Could not remove user %s to group %s'), + $cur->nickname, $group->nickname)); + return; + } + + $channel->output($cur, sprintf(_('%s left group %s'), + $cur->nickname, + $group->nickname)); + } + } class WhoisCommand extends Command @@ -392,6 +493,8 @@ class HelpCommand extends Command "get - get last notice from user\n". "whois - get profile info on user\n". "fav - add user's last notice as a 'fave'\n". + "join - join group\n". + "drop - leave group\n". "stats - get your stats\n". "stop - same as 'off'\n". "quit - same as 'off'\n". diff --git a/lib/commandinterpreter.php b/lib/commandinterpreter.php index ac6bf73c8..6e4340e5d 100644 --- a/lib/commandinterpreter.php +++ b/lib/commandinterpreter.php @@ -70,6 +70,26 @@ class CommandInterpreter } else { return new OffCommand($user); } + case 'join': + if (!$arg) { + return null; + } + list($other, $extra) = explode(' ', $arg, 2); + if ($extra) { + return null; + } else { + return new JoinCommand($user, $other); + } + case 'drop': + if (!$arg) { + return null; + } + list($other, $extra) = explode(' ', $arg, 2); + if ($extra) { + return null; + } else { + return new DropCommand($user, $other); + } case 'follow': case 'sub': if (!$arg) { -- cgit v1.2.3-54-g00ecf From 4c812bf8a983f18da99b558d7159ccb58e27422e Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Sun, 30 Aug 2009 18:35:44 -0300 Subject: Convert !group tags to #hash tags when bridging outgoing notices to Twitter http://status.net/trac/ticket/1672 --- lib/twitter.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/twitter.php b/lib/twitter.php index 7546ffa98..4fff58fd2 100644 --- a/lib/twitter.php +++ b/lib/twitter.php @@ -160,6 +160,9 @@ function broadcast_twitter($notice) // XXX: Hack to get around PHP cURL's use of @ being a a meta character $statustxt = preg_replace('/^@/', ' @', $notice->content); + // Convert !groups to #hashes + $statustxt = preg_replace('/(^|\s)!([A-Za-z0-9]{1,64})/', "\\1#\\2", $statustxt); + $token = TwitterOAuthClient::unpackToken($flink->credentials); $client = new TwitterOAuthClient($token->key, $token->secret); -- cgit v1.2.3-54-g00ecf From f949c2c9d9afa63496f26b33d0309f8d06f77520 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Sun, 30 Aug 2009 18:22:43 -0300 Subject: Typo fix in error case: we probably wanted to call sprintf() not sprint() --- lib/twitter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/twitter.php b/lib/twitter.php index 4fff58fd2..2d2b08f73 100644 --- a/lib/twitter.php +++ b/lib/twitter.php @@ -207,7 +207,7 @@ function broadcast_twitter($notice) // This could represent a failure posting, // or the Twitter API might just be behaving flakey. - $errmsg = sprint('No data returned by Twitter API when ' . + $errmsg = sprintf('No data returned by Twitter API when ' . 'trying to send update for %1$s (user id %2$s).', $user->nickname, $user->id); common_log(LOG_WARNING, $errmsg); -- cgit v1.2.3-54-g00ecf From e929bdc2ba156c615a1cac9bcff087e7a34132cb Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Tue, 1 Sep 2009 19:43:56 -0300 Subject: fix some double-escaped %s leading to broken links right smack on the main page --- actions/public.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/actions/public.php b/actions/public.php index 86b0d6f56..73fad182a 100644 --- a/actions/public.php +++ b/actions/public.php @@ -225,10 +225,10 @@ class PublicAction extends Action function showAnonymousMessage() { if (! (common_config('site','closed') || common_config('site','inviteonly'))) { - $m = _('This is %%%%site.name%%%%, a [micro-blogging](http://en.wikipedia.org/wiki/Micro-blogging) service ' . + $m = _('This is %%site.name%%, a [micro-blogging](http://en.wikipedia.org/wiki/Micro-blogging) service ' . 'based on the Free Software [StatusNet](http://status.net/) tool. ' . - '[Join now](%%%%action.register%%%%) to share notices about yourself with friends, family, and colleagues! ' . - '([Read more](%%%%doc.help%%%%))'); + '[Join now](%%action.register%%) to share notices about yourself with friends, family, and colleagues! ' . + '([Read more](%%doc.help%%))'); } else { $m = _('This is %%site.name%%, a [micro-blogging](http://en.wikipedia.org/wiki/Micro-blogging) service ' . 'based on the Free Software [StatusNet](http://status.net/) tool.'); -- cgit v1.2.3-54-g00ecf From 8b040eba4062bcb464f49e3e04d7a172a1d55c1e Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Wed, 2 Sep 2009 00:24:30 +0000 Subject: Fixed bug in which you cannot turn off importing friends timelines flag --- actions/twittersettings.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/actions/twittersettings.php b/actions/twittersettings.php index 563d867a4..89169941e 100644 --- a/actions/twittersettings.php +++ b/actions/twittersettings.php @@ -165,7 +165,7 @@ class TwittersettingsAction extends ConnectSettingsAction ($flink->noticesync & FOREIGN_NOTICE_RECV) : false); $this->elementEnd('li'); - + } else { // preserve setting even if bidrection bridge toggled off if ($flink && ($flink->noticesync & FOREIGN_NOTICE_RECV)) { -- cgit v1.2.3-54-g00ecf From f86fed357c07f1c1d2c633e8c2c730f205187e1a Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Wed, 2 Sep 2009 00:50:41 +0000 Subject: Better error handling --- lib/twitter.php | 100 ++++++++++++++++++++++++-------------------------------- 1 file changed, 42 insertions(+), 58 deletions(-) diff --git a/lib/twitter.php b/lib/twitter.php index 455f7e7ef..676c9b20a 100644 --- a/lib/twitter.php +++ b/lib/twitter.php @@ -175,34 +175,7 @@ function broadcast_oauth($notice, $flink) { try { $status = $client->statusesUpdate($statustxt); } catch (OAuthClientCurlException $e) { - - if ($e->getMessage() == 'The requested URL returned error: 401') { - - $errmsg = sprintf('User %1$s (user id: %2$s) has an invalid ' . - 'Twitter OAuth access token.', - $user->nickname, $user->id); - common_log(LOG_WARNING, $errmsg); - - // Bad auth token! We need to delete the foreign_link - // to Twitter and inform the user. - - remove_twitter_link($flink); - return true; - - } else { - - // Some other error happened, so we should probably - // try to send again later. - - $errmsg = sprintf('cURL error trying to send notice to Twitter ' . - 'for user %1$s (user id: %2$s) - ' . - 'code: %3$s message: %4$s.', - $user->nickname, $user->id, - $e->getCode(), $e->getMessage()); - common_log(LOG_WARNING, $errmsg); - - return false; - } + return process_error($e, $flink); } if (empty($status)) { @@ -210,9 +183,9 @@ function broadcast_oauth($notice, $flink) { // This could represent a failure posting, // or the Twitter API might just be behaving flakey. - $errmsg = sprintf('No data returned by Twitter API when ' . - 'trying to send update for %1$s (user id %2$s).', - $user->nickname, $user->id); + $errmsg = sprintf('Twitter bridge - No data returned by Twitter API when ' . + 'trying to send update for %1$s (user id %2$s).', + $user->nickname, $user->id); common_log(LOG_WARNING, $errmsg); return false; @@ -220,7 +193,7 @@ function broadcast_oauth($notice, $flink) { // Notice crossed the great divide - $msg = sprintf('Twitter bridge posted notice %s to Twitter using OAuth.', + $msg = sprintf('Twitter bridge - posted notice %s to Twitter using OAuth.', $notice->id); common_log(LOG_INFO, $msg); @@ -239,46 +212,57 @@ function broadcast_basicauth($notice, $flink) try { $status = $client->statusesUpdate($statustxt); } catch (BasicAuthCurlException $e) { - - if ($e->getMessage() == 'The requested URL returned error: 401') { - - $errmsg = sprintf('User %1$s (user id: %2$s) has an invalid ' . - 'Twitter screen_name/password combo.', - $user->nickname, $user->id); - common_log(LOG_WARNING, $errmsg); - - remove_twitter_link($flink); - return true; - - } else { - - $errmsg = sprintf('cURL error trying to send notice to Twitter ' . - 'for user %1$s (user id: %2$s) - ' . - 'code: %3$s message: %4$s.', - $user->nickname, $user->id, - $e->getCode(), $e->getMessage()); - common_log(LOG_WARNING, $errmsg); - - return false; - } + return process_error($e, $flink); } if (empty($status)) { - $errmsg = sprintf('No data returned by Twitter API when ' . - 'trying to send update for %1$s (user id %2$s).', - $user->nickname, $user->id); + $errmsg = sprintf('Twitter bridge - No data returned by Twitter API when ' . + 'trying to send update for %1$s (user id %2$s).', + $user->nickname, $user->id); common_log(LOG_WARNING, $errmsg); return false; } - $msg = sprintf('Twitter bridge posted notice %s to Twitter using basic auth.', + $msg = sprintf('Twitter bridge - posted notice %s to Twitter using basic auth.', $notice->id); common_log(LOG_INFO, $msg); return true; +} + +function process_error($e, $flink) +{ + $user = $flink->getUser(); + $errmsg = $e->getMessage(); + $delivered = false; + + switch($errmsg) { + case 'The requested URL returned error: 401': + $logmsg = sprintf('Twiter bridge - User %1$s (user id: %2$s) has an invalid ' . + 'Twitter screen_name/password combo or an invalid acesss token.', + $user->nickname, $user->id); + $delivered = true; + remove_twitter_link($flink); + break; + case 'The requested URL returned error: 403': + $logmsg = sprintf('Twitter bridge - User %1$s (user id: %2$s) has exceeded ' . + 'his/her Twitter request limit.', + $user->nickname, $user->id); + break; + default: + $logmsg = sprintf('Twitter bridge - cURL error trying to send notice to Twitter ' . + 'for user %1$s (user id: %2$s) - ' . + 'code: %3$s message: %4$s.', + $user->nickname, $user->id, + $e->getCode(), $e->getMessage()); + break; + } + + common_log(LOG_WARNING, $logmsg); + return $delivered; } function format_status($notice) -- cgit v1.2.3-54-g00ecf From efcfd209ef737f4dbe99401df282e7a341176ea7 Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Tue, 1 Sep 2009 23:02:03 -0400 Subject: Check "Files" of type 'application/xhtml+xml' for oEmbed in addition to just text/html --- classes/File.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/File.php b/classes/File.php index f4d0a3a48..96a4de6e8 100644 --- a/classes/File.php +++ b/classes/File.php @@ -78,7 +78,7 @@ class File extends Memcached_DataObject $file_id = $x->insert(); if (isset($redir_data['type']) - && ('text/html' === substr($redir_data['type'], 0, 9)) + && (('text/html' === substr($redir_data['type'], 0, 9) || 'application/xhtml+xml' === substr($redir_data['type'], 0, 21))) && ($oembed_data = File_oembed::_getOembed($given_url))) { File_oembed::saveNew($oembed_data, $file_id); } -- cgit v1.2.3-54-g00ecf From 29d0dd740c329c2674de58bec172419148a1b495 Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Tue, 1 Sep 2009 23:17:45 -0400 Subject: Allow whitespace before and after the = and require space before the href in html --- extlib/Services/oEmbed.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/extlib/Services/oEmbed.php b/extlib/Services/oEmbed.php index b05e3a1d1..0dc8f01b2 100644 --- a/extlib/Services/oEmbed.php +++ b/extlib/Services/oEmbed.php @@ -256,7 +256,7 @@ class Services_oEmbed $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); if (substr($code, 0, 1) != '2') { - throw new Services_oEmbed_Exception('Non-200 code returned'); + throw new Services_oEmbed_Exception('Non-200 code returned. Got code ' . $code); } curl_close($ch); @@ -302,7 +302,7 @@ class Services_oEmbed // Find all tags that have a valid oembed type set. We then // extract the href attribute for each type. - $regexp = '#]*)type="' . + $regexp = '#]*)type[\s\n]*=[\s\n]*"' . '(application/json|text/xml)\+oembed"([^>]*)>#im'; $m = $ret = array(); @@ -314,7 +314,7 @@ class Services_oEmbed foreach ($m[0] as $i => $link) { $h = array(); - if (preg_match('/href="([^"]+)"/i', $link, $h)) { + if (preg_match('/[\s\n]+href[\s\n]*=[\s\n]*"([^"]+)"/im', $link, $h)) { $ret[$m[2][$i]] = $h[1]; } } @@ -347,7 +347,7 @@ class Services_oEmbed $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); if (substr($code, 0, 1) != '2') { - throw new Services_oEmbed_Exception('Non-200 code returned'); + throw new Services_oEmbed_Exception('Non-200 code returned. Got code ' . $code); } return $result; -- cgit v1.2.3-54-g00ecf From 637182e7546e1721a1a5746088cc96b1e1611536 Mon Sep 17 00:00:00 2001 From: Christopher Vollick Date: Thu, 3 Sep 2009 17:57:08 -0400 Subject: Updated Location of Bug Tracker in Contact Page. --- doc-src/contact | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc-src/contact b/doc-src/contact index 31f3a4d2b..c63fcd01a 100644 --- a/doc-src/contact +++ b/doc-src/contact @@ -13,7 +13,7 @@ Bugs ---- If you think you've found a bug in the [StatusNet](http://status.net/) software, -or if there's a new feature you'd like to see, add it into the [StatusNet bug database](http://status.net/PITS/HomePage). Don't forget to check the list of +or if there's a new feature you'd like to see, add it into the [StatusNet bug database](http://status.net/bugs/). Don't forget to check the list of existing bugs to make sure it hasn't already been reported! Email -- cgit v1.2.3-54-g00ecf From 0ae4c7a80ce4869faac102386ed33f97a401ca0f Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Wed, 2 Sep 2009 13:33:54 -0400 Subject: The 'tidy' extension is a requirement Fixes http://status.net/trac/ticket/1844 --- install.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.php b/install.php index a59b9469d..c49043e5c 100644 --- a/install.php +++ b/install.php @@ -230,7 +230,7 @@ function checkPrereqs() } $reqs = array('gd', 'curl', - 'xmlwriter', 'mbstring'); + 'xmlwriter', 'mbstring','tidy'); foreach ($reqs as $req) { if (!checkExtension($req)) { -- cgit v1.2.3-54-g00ecf From 0c95734a6874608ea5ed44608cabeda7c3a1b4ea Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Wed, 2 Sep 2009 13:39:05 -0400 Subject: Add Tidy requirement to the README --- README | 1 + 1 file changed, 1 insertion(+) diff --git a/README b/README index 3dd365e1f..756219981 100644 --- a/README +++ b/README @@ -146,6 +146,7 @@ Your PHP installation must include the following PHP extensions: - GD. For scaling down avatar images. - mbstring. For handling Unicode (UTF-8) encoded strings. - gettext. For multiple languages. Default on many PHP installs. +- tidy. Used to clean up HTML/URLs for the URL shortener to consume. For some functionality, you will also need the following extensions: -- cgit v1.2.3-54-g00ecf From beae3db41375879e725af053edf8041bbd76ac8c Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Thu, 3 Sep 2009 14:58:50 -0400 Subject: Pluginize the URL shorteners --- actions/othersettings.php | 27 ++++++------ lib/Shorturl_api.php | 66 ++--------------------------- lib/plugin.php | 14 +++++++ lib/util.php | 56 ++++--------------------- plugins/LilUrl/LilUrlPlugin.php | 64 ++++++++++++++++++++++++++++ plugins/PtitUrl/PtitUrlPlugin.php | 62 +++++++++++++++++++++++++++ plugins/SimpleUrl/SimpleUrlPlugin.php | 79 +++++++++++++++++++++++++++++++++++ plugins/TightUrl/TightUrlPlugin.php | 62 +++++++++++++++++++++++++++ 8 files changed, 305 insertions(+), 125 deletions(-) create mode 100644 plugins/LilUrl/LilUrlPlugin.php create mode 100644 plugins/PtitUrl/PtitUrlPlugin.php create mode 100644 plugins/SimpleUrl/SimpleUrlPlugin.php create mode 100644 plugins/TightUrl/TightUrlPlugin.php diff --git a/actions/othersettings.php b/actions/othersettings.php index 8b674161a..4ccef8412 100644 --- a/actions/othersettings.php +++ b/actions/othersettings.php @@ -91,19 +91,20 @@ class OthersettingsAction extends AccountSettingsAction $this->elementStart('fieldset'); $this->hidden('token', common_session_token()); - // I18N - - $services = array( - '' => 'None', - 'ur1.ca' => 'ur1.ca (free service)', - '2tu.us' => '2tu.us (free service)', - 'ptiturl.com' => 'ptiturl.com', - 'bit.ly' => 'bit.ly', - 'tinyurl.com' => 'tinyurl.com', - 'is.gd' => 'is.gd', - 'snipr.com' => 'snipr.com', - 'metamark.net' => 'metamark.net' - ); + $services=array(); + global $_shorteners; + if($_shorteners){ + foreach($_shorteners as $name=>$value) + { + $services[$name]=$name; + if($value['info']['freeService']){ + // I18N + $services[$name].=' (free service)'; + } + } + } + asort($services); + $services['']='None'; $this->elementStart('ul', 'form_data'); $this->elementStart('li'); diff --git a/lib/Shorturl_api.php b/lib/Shorturl_api.php index 6402dbc09..18ae7719b 100644 --- a/lib/Shorturl_api.php +++ b/lib/Shorturl_api.php @@ -19,7 +19,7 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } -class ShortUrlApi +abstract class ShortUrlApi { protected $service_url; protected $long_limit = 27; @@ -35,11 +35,9 @@ class ShortUrlApi return $url; } - protected function shorten_imp($url) { - return "To Override"; - } + protected abstract function shorten_imp($url); - private function is_long($url) { + protected function is_long($url) { return strlen($url) >= common_config('site', 'shorturllength'); } @@ -71,61 +69,3 @@ class ShortUrlApi } } -class LilUrl extends ShortUrlApi -{ - function __construct() - { - parent::__construct('http://ur1.ca/'); - } - - protected function shorten_imp($url) { - $data['longurl'] = $url; - $response = $this->http_post($data); - if (!$response) return $url; - $y = @simplexml_load_string($response); - if (!isset($y->body)) return $url; - $x = $y->body->p[0]->a->attributes(); - if (isset($x['href'])) return $x['href']; - return $url; - } -} - - -class PtitUrl extends ShortUrlApi -{ - function __construct() - { - parent::__construct('http://ptiturl.com/?creer=oui&action=Reduire&url='); - } - - protected function shorten_imp($url) { - $response = $this->http_get($url); - if (!$response) return $url; - $response = $this->tidy($response); - $y = @simplexml_load_string($response); - if (!isset($y->body)) return $url; - $xml = $y->body->center->table->tr->td->pre->a->attributes(); - if (isset($xml['href'])) return $xml['href']; - return $url; - } -} - -class TightUrl extends ShortUrlApi -{ - function __construct() - { - parent::__construct('http://2tu.us/?save=y&url='); - } - - protected function shorten_imp($url) { - $response = $this->http_get($url); - if (!$response) return $url; - $response = $this->tidy($response); - $y = @simplexml_load_string($response); - if (!isset($y->body)) return $url; - $xml = $y->body->p[0]->code[0]->a->attributes(); - if (isset($xml['href'])) return $xml['href']; - return $url; - } -} - diff --git a/lib/plugin.php b/lib/plugin.php index 87d7be5a7..59bf3ba9d 100644 --- a/lib/plugin.php +++ b/lib/plugin.php @@ -76,4 +76,18 @@ class Plugin { return true; } + + /* + * the name of the shortener + * shortenerInfo associative array with additional information. One possible element is 'freeService' which can be true or false + * shortener array, first element is the name of the class, second element is an array to be passed as constructor parameters to the class + */ + function registerUrlShortener($name, $shortenerInfo, $shortener) + { + global $_shorteners; + if(!is_array($_shorteners)){ + $_shorteners=array(); + } + $_shorteners[$name]=array('info'=>$shortenerInfo, 'callInfo'=>$shortener); + } } diff --git a/lib/util.php b/lib/util.php index 9cf462515..0a25907c4 100644 --- a/lib/util.php +++ b/lib/util.php @@ -1373,57 +1373,15 @@ function common_shorten_url($long_url) } else { $svc = $user->urlshorteningservice; } - - $curlh = curl_init(); - curl_setopt($curlh, CURLOPT_CONNECTTIMEOUT, 20); // # seconds to wait - curl_setopt($curlh, CURLOPT_USERAGENT, 'StatusNet'); - curl_setopt($curlh, CURLOPT_RETURNTRANSFER, true); - - switch($svc) { - case 'ur1.ca': - require_once INSTALLDIR.'/lib/Shorturl_api.php'; - $short_url_service = new LilUrl; - $short_url = $short_url_service->shorten($long_url); - break; - - case '2tu.us': - $short_url_service = new TightUrl; - require_once INSTALLDIR.'/lib/Shorturl_api.php'; - $short_url = $short_url_service->shorten($long_url); - break; - - case 'ptiturl.com': - require_once INSTALLDIR.'/lib/Shorturl_api.php'; - $short_url_service = new PtitUrl; - $short_url = $short_url_service->shorten($long_url); - break; - - case 'bit.ly': - curl_setopt($curlh, CURLOPT_URL, 'http://bit.ly/api?method=shorten&long_url='.urlencode($long_url)); - $short_url = current(json_decode(curl_exec($curlh))->results)->hashUrl; - break; - - case 'is.gd': - curl_setopt($curlh, CURLOPT_URL, 'http://is.gd/api.php?longurl='.urlencode($long_url)); - $short_url = curl_exec($curlh); - break; - case 'snipr.com': - curl_setopt($curlh, CURLOPT_URL, 'http://snipr.com/site/snip?r=simple&link='.urlencode($long_url)); - $short_url = curl_exec($curlh); - break; - case 'metamark.net': - curl_setopt($curlh, CURLOPT_URL, 'http://metamark.net/api/rest/simple?long_url='.urlencode($long_url)); - $short_url = curl_exec($curlh); - break; - case 'tinyurl.com': - curl_setopt($curlh, CURLOPT_URL, 'http://tinyurl.com/api-create.php?url='.urlencode($long_url)); - $short_url = curl_exec($curlh); - break; - default: - $short_url = false; + global $_shorteners; + if(! $_shorteners[$svc]){ + //the user selected service doesn't exist, so default to ur1.ca + $svc = 'ur1.ca'; } - curl_close($curlh); + $reflectionObj = new ReflectionClass($_shorteners[$svc]['callInfo'][0]); + $short_url_service = $reflectionObj->newInstanceArgs($_shorteners[$svc]['callInfo'][1]); + $short_url = $short_url_service->shorten($long_url); return $short_url; } diff --git a/plugins/LilUrl/LilUrlPlugin.php b/plugins/LilUrl/LilUrlPlugin.php new file mode 100644 index 000000000..7665b6c1e --- /dev/null +++ b/plugins/LilUrl/LilUrlPlugin.php @@ -0,0 +1,64 @@ +. + * + * @category Plugin + * @package StatusNet + * @author Craig Andrews + * @copyright 2009 Craig Andrews http://candrews.integralblue.com + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ + +if (!defined('STATUSNET')) { + exit(1); +} + +require_once(INSTALLDIR.'/lib/Shorturl_api.php'); + +class LilUrlPlugin extends Plugin +{ + function __construct() + { + parent::__construct(); + } + + function onInitializePlugin(){ + $this->registerUrlShortener( + 'ur1.ca', + array('freeService'=>true), + array('LilUrl',array('http://ur1.ca/')) + ); + } +} + +class LilUrl extends ShortUrlApi +{ + protected function shorten_imp($url) { + $data['longurl'] = $url; + $response = $this->http_post($data); + if (!$response) return $url; + $y = @simplexml_load_string($response); + if (!isset($y->body)) return $url; + $x = $y->body->p[0]->a->attributes(); + if (isset($x['href'])) return $x['href']; + return $url; + } +} diff --git a/plugins/PtitUrl/PtitUrlPlugin.php b/plugins/PtitUrl/PtitUrlPlugin.php new file mode 100644 index 000000000..f00d3e2f2 --- /dev/null +++ b/plugins/PtitUrl/PtitUrlPlugin.php @@ -0,0 +1,62 @@ +. + * + * @category Plugin + * @package StatusNet + * @author Craig Andrews + * @copyright 2009 Craig Andrews http://candrews.integralblue.com + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ + +if (!defined('STATUSNET')) { + exit(1); +} + +class PtitUrlPlugin extends Plugin +{ + function __construct() + { + parent::__construct(); + } + + function onInitializePlugin(){ + $this->registerUrlShortener( + 'ptiturl.com', + array(), + array('PtitUrl',array('http://ptiturl.com/?creer=oui&action=Reduire&url=')) + ); + } +} + +class PtitUrl extends ShortUrlApi +{ + protected function shorten_imp($url) { + $response = $this->http_get($url); + if (!$response) return $url; + $response = $this->tidy($response); + $y = @simplexml_load_string($response); + if (!isset($y->body)) return $url; + $xml = $y->body->center->table->tr->td->pre->a->attributes(); + if (isset($xml['href'])) return $xml['href']; + return $url; + } +} diff --git a/plugins/SimpleUrl/SimpleUrlPlugin.php b/plugins/SimpleUrl/SimpleUrlPlugin.php new file mode 100644 index 000000000..82d772048 --- /dev/null +++ b/plugins/SimpleUrl/SimpleUrlPlugin.php @@ -0,0 +1,79 @@ +. + * + * @category Plugin + * @package StatusNet + * @author Craig Andrews + * @copyright 2009 Craig Andrews http://candrews.integralblue.com + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ + +if (!defined('STATUSNET')) { + exit(1); +} + +class SimpleUrlPlugin extends Plugin +{ + function __construct() + { + parent::__construct(); + } + + function onInitializePlugin(){ + $this->registerUrlShortener( + 'is.gd', + array(), + array('SimpleUrl',array('http://is.gd/api.php?longurl=')) + ); + $this->registerUrlShortener( + 'snipr.com', + array(), + array('SimpleUrl',array('http://snipr.com/site/snip?r=simple&link=')) + ); + $this->registerUrlShortener( + 'metamark.net', + array(), + array('SimpleUrl',array('http://metamark.net/api/rest/simple?long_url=')) + ); + $this->registerUrlShortener( + 'tinyurl.com', + array(), + array('SimpleUrl',array('http://tinyurl.com/api-create.php?url=')) + ); + } +} + +class SimpleUrl extends ShortUrlApi +{ + protected function shorten_imp($url) { + $curlh = curl_init(); + curl_setopt($curlh, CURLOPT_CONNECTTIMEOUT, 20); // # seconds to wait + curl_setopt($curlh, CURLOPT_USERAGENT, 'StatusNet'); + curl_setopt($curlh, CURLOPT_RETURNTRANSFER, true); + + curl_setopt($curlh, CURLOPT_URL, $this->service_url.urlencode($url)); + $short_url = curl_exec($curlh); + + curl_close($curlh); + return $short_url; + } +} diff --git a/plugins/TightUrl/TightUrlPlugin.php b/plugins/TightUrl/TightUrlPlugin.php new file mode 100644 index 000000000..48efb355f --- /dev/null +++ b/plugins/TightUrl/TightUrlPlugin.php @@ -0,0 +1,62 @@ +. + * + * @category Plugin + * @package StatusNet + * @author Craig Andrews + * @copyright 2009 Craig Andrews http://candrews.integralblue.com + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ + +if (!defined('STATUSNET')) { + exit(1); +} + +class TightUrlPlugin extends Plugin +{ + function __construct() + { + parent::__construct(); + } + + function onInitializePlugin(){ + $this->registerUrlShortener( + '2tu.us', + array('freeService'=>true), + array('TightUrl',array('http://2tu.us/?save=y&url=')) + ); + } +} + +class TightUrl extends ShortUrlApi +{ + protected function shorten_imp($url) { + $response = $this->http_get($url); + if (!$response) return $url; + $response = $this->tidy($response); + $y = @simplexml_load_string($response); + if (!isset($y->body)) return $url; + $xml = $y->body->p[0]->code[0]->a->attributes(); + if (isset($xml['href'])) return $xml['href']; + return $url; + } +} -- cgit v1.2.3-54-g00ecf From 0d7d4dfe5d258d2018f601f8116d629577105864 Mon Sep 17 00:00:00 2001 From: mEDI Date: Thu, 3 Sep 2009 19:32:27 +0200 Subject: add basic auth support for cgi servers on the api (trac #1832) --- actions/api.php | 46 +++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 41 insertions(+), 5 deletions(-) diff --git a/actions/api.php b/actions/api.php index f425a8dcd..f624d6b69 100644 --- a/actions/api.php +++ b/actions/api.php @@ -27,6 +27,8 @@ class ApiAction extends Action var $api_arg; var $api_method; var $api_action; + var $auth_user; + var $auth_pw; function handle($args) { @@ -35,6 +37,7 @@ class ApiAction extends Action $this->api_action = $this->arg('apiaction'); $method = $this->arg('method'); $argument = $this->arg('argument'); + $this->basic_auth_process_header(); if (isset($argument)) { $cmdext = explode('.', $argument); @@ -50,7 +53,7 @@ class ApiAction extends Action } if ($this->requires_auth()) { - if (!isset($_SERVER['PHP_AUTH_USER'])) { + if (!isset($this->auth_user)) { # This header makes basic auth go header('WWW-Authenticate: Basic realm="StatusNet API"'); @@ -58,8 +61,8 @@ class ApiAction extends Action # If the user hits cancel -- bam! $this->show_basic_auth_error(); } else { - $nickname = $_SERVER['PHP_AUTH_USER']; - $password = $_SERVER['PHP_AUTH_PW']; + $nickname = $this->auth_user; + $password = $this->auth_pw; $user = common_check_user($nickname, $password); if ($user) { @@ -76,8 +79,8 @@ class ApiAction extends Action } else { // Caller might give us a username even if not required - if (isset($_SERVER['PHP_AUTH_USER'])) { - $user = User::staticGet('nickname', $_SERVER['PHP_AUTH_USER']); + if (isset($this->auth_user)) { + $user = User::staticGet('nickname', $this->auth_user); if ($user) { $this->user = $user; } @@ -203,6 +206,39 @@ class ApiAction extends Action } } + function basic_auth_process_header() + { + if(isset($_SERVER['AUTHORIZATION']) || isset($_SERVER['HTTP_AUTHORIZATION'])) + { + $authorization_header = isset($_SERVER['HTTP_AUTHORIZATION'])?$_SERVER['HTTP_AUTHORIZATION']:$_SERVER['AUTHORIZATION']; + } + + if(isset($_SERVER['PHP_AUTH_USER'])) + { + $this->auth_user = $_SERVER['PHP_AUTH_USER']; + $this->auth_pw = $_SERVER['PHP_AUTH_PW']; + } + elseif ( isset($authorization_header) && strstr(substr($authorization_header, 0,5),'Basic') ) + { + // decode the HTTP_AUTHORIZATION header on php-cgi server self + // on fcgid server is the header name AUTHORIZATION + + $auth_hash = base64_decode( substr($authorization_header, 6) ); + list($this->auth_user, $this->auth_pw) = explode(':', $auth_hash); + + // set all to NULL on a emty basic auth request + if($this->auth_user == "") { + $this->auth_user = NULL; + $this->auth_pw = NULL; + } + } + else + { + $this->auth_user = NULL; + $this->auth_pw = NULL; + } + } + function show_basic_auth_error() { header('HTTP/1.1 401 Unauthorized'); -- cgit v1.2.3-54-g00ecf From ebcbd3820e10e70ab2ed1bff9839a03f2948ee8f Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Thu, 3 Sep 2009 15:30:19 -0400 Subject: Fix spelling --- actions/api.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/actions/api.php b/actions/api.php index f624d6b69..c236378bc 100644 --- a/actions/api.php +++ b/actions/api.php @@ -221,12 +221,12 @@ class ApiAction extends Action elseif ( isset($authorization_header) && strstr(substr($authorization_header, 0,5),'Basic') ) { // decode the HTTP_AUTHORIZATION header on php-cgi server self - // on fcgid server is the header name AUTHORIZATION + // on fcgid server the header name is AUTHORIZATION $auth_hash = base64_decode( substr($authorization_header, 6) ); list($this->auth_user, $this->auth_pw) = explode(':', $auth_hash); - // set all to NULL on a emty basic auth request + // set all to NULL on a empty basic auth request if($this->auth_user == "") { $this->auth_user = NULL; $this->auth_pw = NULL; -- cgit v1.2.3-54-g00ecf From 277b464054b24f8d680ddbe762c9e438f6679592 Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Thu, 3 Sep 2009 19:42:50 +0000 Subject: Created autofocus method to give focus to an element (primarily a form control) on page onload. Updated some of the pages to use autofocus. --- actions/avatarsettings.php | 2 ++ actions/editgroup.php | 6 ++++++ actions/emailsettings.php | 6 ++++++ actions/grouplogo.php | 2 ++ actions/groupsearch.php | 6 ++++++ actions/invite.php | 6 ++++++ actions/login.php | 8 ++++++++ actions/noticesearch.php | 6 ++++++ actions/openidlogin.php | 6 ++++++ actions/openidsettings.php | 6 ++++++ actions/othersettings.php | 6 ++++++ actions/passwordsettings.php | 6 ++++++ actions/peoplesearch.php | 6 ++++++ actions/profilesettings.php | 8 ++++++++ actions/register.php | 6 ++++++ actions/smssettings.php | 6 ++++++ actions/subscriptions.php | 6 ++++++ lib/designsettings.php | 2 ++ lib/htmloutputter.php | 25 +++++++++++++++++++++++++ 19 files changed, 125 insertions(+) diff --git a/actions/avatarsettings.php b/actions/avatarsettings.php index 0bc439ff1..02a684b38 100644 --- a/actions/avatarsettings.php +++ b/actions/avatarsettings.php @@ -399,5 +399,7 @@ class AvatarsettingsAction extends AccountSettingsAction $this->script('js/jcrop/jquery.Jcrop.min.js'); $this->script('js/jcrop/jquery.Jcrop.go.js'); } + + $this->autofocus('avatarfile'); } } diff --git a/actions/editgroup.php b/actions/editgroup.php index cac910e9b..e7ba836a0 100644 --- a/actions/editgroup.php +++ b/actions/editgroup.php @@ -160,6 +160,12 @@ class EditgroupAction extends GroupDesignAction } } + function showScripts() + { + parent::showScripts(); + $this->autofocus('nickname'); + } + function trySave() { $cur = common_current_user(); diff --git a/actions/emailsettings.php b/actions/emailsettings.php index af528a892..6eff06c0d 100644 --- a/actions/emailsettings.php +++ b/actions/emailsettings.php @@ -71,6 +71,12 @@ class EmailsettingsAction extends AccountSettingsAction return _('Manage how you get email from %%site.name%%.'); } + function showScripts() + { + parent::showScripts(); + $this->autofocus('email'); + } + /** * Content area of the page * diff --git a/actions/grouplogo.php b/actions/grouplogo.php index c6f376915..63ba769c7 100644 --- a/actions/grouplogo.php +++ b/actions/grouplogo.php @@ -445,6 +445,8 @@ class GrouplogoAction extends GroupDesignAction $this->script('js/jcrop/jquery.Jcrop.min.js'); $this->script('js/jcrop/jquery.Jcrop.go.js'); } + + $this->autofocus('avatarfile'); } function showLocalNav() diff --git a/actions/groupsearch.php b/actions/groupsearch.php index bbd4c3a74..be15efc47 100644 --- a/actions/groupsearch.php +++ b/actions/groupsearch.php @@ -91,6 +91,12 @@ class GroupsearchAction extends SearchAction $user_group->free(); } } + + function showScripts() + { + parent::showScripts(); + $this->autofocus('q'); + } } class GroupSearchResults extends GroupList diff --git a/actions/invite.php b/actions/invite.php index ab43a2491..9fa6a76f6 100644 --- a/actions/invite.php +++ b/actions/invite.php @@ -98,6 +98,12 @@ class InviteAction extends CurrentUserDesignAction $this->showPage(); } + function showScripts() + { + parent::showScripts(); + $this->autofocus('addresses'); + } + function title() { if ($this->mode == 'sent') { diff --git a/actions/login.php b/actions/login.php index 37f3c54ff..ac8c40c3e 100644 --- a/actions/login.php +++ b/actions/login.php @@ -22,6 +22,7 @@ * @category Login * @package StatusNet * @author Evan Prodromou + * @author Sarven Capadisli * @copyright 2008-2009 StatusNet, Inc. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ @@ -37,6 +38,7 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { * @category Personal * @package StatusNet * @author Evan Prodromou + * @author Sarven Capadisli * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ */ @@ -162,6 +164,12 @@ class LoginAction extends Action $this->showPage(); } + function showScripts() + { + parent::showScripts(); + $this->autofocus('nickname'); + } + /** * Title of the page * diff --git a/actions/noticesearch.php b/actions/noticesearch.php index 1188e7e10..1cd987df3 100644 --- a/actions/noticesearch.php +++ b/actions/noticesearch.php @@ -137,6 +137,12 @@ class NoticesearchAction extends SearchAction $this->pagination($page > 1, $cnt > NOTICES_PER_PAGE, $page, 'noticesearch', array('q' => $q)); } + + function showScripts() + { + parent::showScripts(); + $this->autofocus('q'); + } } class SearchNoticeList extends NoticeList { diff --git a/actions/openidlogin.php b/actions/openidlogin.php index 4b5338694..9b7deefb6 100644 --- a/actions/openidlogin.php +++ b/actions/openidlogin.php @@ -86,6 +86,12 @@ class OpenidloginAction extends Action } } + function showScripts() + { + parent::showScripts(); + $this->autofocus('openid_url'); + } + function title() { return _('OpenID Login'); diff --git a/actions/openidsettings.php b/actions/openidsettings.php index 13da64a4f..30725fc1b 100644 --- a/actions/openidsettings.php +++ b/actions/openidsettings.php @@ -72,6 +72,12 @@ class OpenidsettingsAction extends AccountSettingsAction ' Manage your associated OpenIDs from here.'); } + function showScripts() + { + parent::showScripts(); + $this->autofocus('openid_url'); + } + /** * Show the form for OpenID management * diff --git a/actions/othersettings.php b/actions/othersettings.php index 8b674161a..f898e2207 100644 --- a/actions/othersettings.php +++ b/actions/othersettings.php @@ -71,6 +71,12 @@ class OthersettingsAction extends AccountSettingsAction return _('Manage various other options.'); } + function showScripts() + { + parent::showScripts(); + $this->autofocus('urlshorteningservice'); + } + /** * Content area of the page * diff --git a/actions/passwordsettings.php b/actions/passwordsettings.php index ec842600f..cd4beac3f 100644 --- a/actions/passwordsettings.php +++ b/actions/passwordsettings.php @@ -69,6 +69,12 @@ class PasswordsettingsAction extends AccountSettingsAction return _('Change your password.'); } + function showScripts() + { + parent::showScripts(); + $this->autofocus('oldpassword'); + } + /** * Content area of the page * diff --git a/actions/peoplesearch.php b/actions/peoplesearch.php index ba0f71e39..38135ecbd 100644 --- a/actions/peoplesearch.php +++ b/actions/peoplesearch.php @@ -85,6 +85,12 @@ class PeoplesearchAction extends SearchAction $profile->free(); } } + + function showScripts() + { + parent::showScripts(); + $this->autofocus('q'); + } } /** diff --git a/actions/profilesettings.php b/actions/profilesettings.php index f9c16351d..2d66e9946 100644 --- a/actions/profilesettings.php +++ b/actions/profilesettings.php @@ -23,6 +23,7 @@ * @package StatusNet * @author Evan Prodromou * @author Zach Copley + * @author Sarven Capadisli * @copyright 2008-2009 StatusNet, Inc. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ @@ -41,6 +42,7 @@ require_once INSTALLDIR.'/lib/accountsettingsaction.php'; * @package StatusNet * @author Evan Prodromou * @author Zach Copley + * @author Sarven Capadisli * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ */ @@ -70,6 +72,12 @@ class ProfilesettingsAction extends AccountSettingsAction 'so people know more about you.'); } + function showScripts() + { + parent::showScripts(); + $this->autofocus('nickname'); + } + /** * Content area of the page * diff --git a/actions/register.php b/actions/register.php index c431aeee3..eefbc340a 100644 --- a/actions/register.php +++ b/actions/register.php @@ -140,6 +140,12 @@ class RegisterAction extends Action } } + function showScripts() + { + parent::showScripts(); + $this->autofocus('nickname'); + } + /** * Try to register a user * diff --git a/actions/smssettings.php b/actions/smssettings.php index b956cceba..672abcef8 100644 --- a/actions/smssettings.php +++ b/actions/smssettings.php @@ -69,6 +69,12 @@ class SmssettingsAction extends ConnectSettingsAction return _('You can receive SMS messages through email from %%site.name%%.'); } + function showScripts() + { + parent::showScripts(); + $this->autofocus('sms'); + } + /** * Content area of the page * diff --git a/actions/subscriptions.php b/actions/subscriptions.php index b1c668228..cc7b38ee4 100644 --- a/actions/subscriptions.php +++ b/actions/subscriptions.php @@ -107,6 +107,12 @@ class SubscriptionsAction extends GalleryAction array('nickname' => $this->user->nickname)); } + function showScripts() + { + parent::showScripts(); + $this->autofocus('tag'); + } + function showEmptyListMessage() { if (common_logged_in()) { diff --git a/lib/designsettings.php b/lib/designsettings.php index fe4222597..fdc05562e 100644 --- a/lib/designsettings.php +++ b/lib/designsettings.php @@ -327,6 +327,8 @@ class DesignSettingsAction extends AccountSettingsAction $this->script('js/farbtastic/farbtastic.js'); $this->script('js/farbtastic/farbtastic.go.js'); $this->script('js/userdesign.go.js'); + + $this->autofocus('design_background-image_file'); } /** diff --git a/lib/htmloutputter.php b/lib/htmloutputter.php index 8ad7dc20f..aa01f6b1d 100644 --- a/lib/htmloutputter.php +++ b/lib/htmloutputter.php @@ -412,4 +412,29 @@ class HTMLOutputter extends XMLOutputter $this->element('p', 'form_guide', $instructions); } } + + + /** + * Internal script to autofocus the given element on page onload. + * + * @param string $id element ID, must refer to an existing element + * + * @return void + * + */ + function autofocus($id) + { + $this->elementStart('script', array('type' => 'text/javascript')); + $this->raw(' + + '); + $this->elementEnd('script'); + } } -- cgit v1.2.3-54-g00ecf From 5974871b7b00bd8e3f28dc5f5a9465a9eec0d3d3 Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Thu, 3 Sep 2009 18:34:30 -0400 Subject: Improve OAuth CGI compatibility Fixes http://status.net/trac/ticket/1822 Reported upstream at http://code.google.com/p/oauth/issues/detail?id=118 --- extlib/OAuth.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/extlib/OAuth.php b/extlib/OAuth.php index 029166175..fd4853554 100644 --- a/extlib/OAuth.php +++ b/extlib/OAuth.php @@ -199,7 +199,8 @@ class OAuthRequest {/*{{{*/ } else { // collect request parameters from query string (GET) and post-data (POST) if appropriate (note: POST vars have priority) $req_parameters = $_GET; - if ($http_method == "POST" && @strstr($request_headers["Content-Type"], "application/x-www-form-urlencoded") ) { + if ($http_method == "POST" && + ( @strstr($request_headers["Content-Type"], "application/x-www-form-urlencoded") || @strstr($_ENV["CONTENT_TYPE"], "application/x-www-form-urlencoded") )) { $req_parameters = array_merge($req_parameters, $_POST); } -- cgit v1.2.3-54-g00ecf From 80b7e54ca2cebcfd7c2c5e63b4ef604106a42aca Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Fri, 4 Sep 2009 11:30:29 -0400 Subject: Added additional characters as allowed in URLs. --- lib/util.php | 6 +++--- tests/URLDetectionTest.php | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/lib/util.php b/lib/util.php index f4ba3a6c2..79611af2c 100644 --- a/lib/util.php +++ b/lib/util.php @@ -442,9 +442,9 @@ function common_replace_urls_callback($text, $callback, $notice_id = null) { ')'. '(?:'. '(?:\:\d+)?'. //:port - '(?:/[\pN\pL$\[\]\,\!\(\)\.\:\-\_\+\/\=\&\;\%\~]*)?'. // /path - '(?:\?[\pN\pL\$\[\]\,\!\(\)\.\:\-\_\+\/\=\&\;\%\~\/]*)?'. // ?query string - '(?:\#[\pN\pL$\[\]\,\!\(\)\.\:\-\_\+\/\=\&\;\%\~\/\?\#]*)?'. // #fragment + '(?:/[\pN\pL$\[\]\,\!\(\)\.\:\-\_\+\/\=\&\;\%\~\*\$\+\'\"]*)?'. // /path + '(?:\?[\pN\pL\$\[\]\,\!\(\)\.\:\-\_\+\/\=\&\;\%\~\*\$\+\'\"\/]*)?'. // ?query string + '(?:\#[\pN\pL$\[\]\,\!\(\)\.\:\-\_\+\/\=\&\;\%\~\*\$\+\'\"\/\?\#]*)?'. // #fragment ')(?127.0.0.1/Name:test.php'), array('127.0.0.1/~test', '127.0.0.1/~test'), + array('127.0.0.1/+test', + '127.0.0.1/+test'), + array('127.0.0.1/$test', + '127.0.0.1/$test'), + array('127.0.0.1/\'test', + '127.0.0.1/\'test'), + array('127.0.0.1/"test', + '127.0.0.1/"test'), + array('127.0.0.1/-test', + '127.0.0.1/-test'), + array('127.0.0.1/_test', + '127.0.0.1/_test'), + array('127.0.0.1/!test', + '127.0.0.1/!test'), + array('127.0.0.1/*test', + '127.0.0.1/*test'), array('127.0.0.1/test%20stuff', '127.0.0.1/test%20stuff'), array('http://[::1]:99/test.php', -- cgit v1.2.3-54-g00ecf From b237dc21ba672957d38daeb0ce1ddf501a3ede3f Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Fri, 4 Sep 2009 15:59:27 +0000 Subject: Updated layout for filter by tag form --- lib/galleryaction.php | 5 ++++- theme/base/css/display.css | 22 ++++++++++++---------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/lib/galleryaction.php b/lib/galleryaction.php index 18cc7b929..31e36803a 100644 --- a/lib/galleryaction.php +++ b/lib/galleryaction.php @@ -132,13 +132,16 @@ class GalleryAction extends OwnerDesignAction $this->elementEnd('li'); $this->elementStart('li', array('id'=>'filter_tags_item')); $this->elementStart('form', array('name' => 'bytag', - 'id' => 'bytag', + 'id' => 'form_filter_bytag', 'action' => common_path('?action=' . $this->trimmed('action')), 'method' => 'post')); + $this->elementStart('fieldset'); + $this->element('legend', null, _('Select tag to filter')); $this->dropdown('tag', _('Tag'), $content, _('Choose a tag to narrow list'), false, $tag); $this->hidden('nickname', $this->user->nickname); $this->submit('submit', _('Go')); + $this->elementEnd('fieldset'); $this->elementEnd('form'); $this->elementEnd('li'); $this->elementEnd('ul'); diff --git a/theme/base/css/display.css b/theme/base/css/display.css index 6f1a29f4a..d770f3868 100644 --- a/theme/base/css/display.css +++ b/theme/base/css/display.css @@ -156,7 +156,8 @@ font-weight:bold; #form_notice_delete legend, #form_password_recover legend, #form_password_change legend, -.form_entity_block legend { +.form_entity_block legend, +#form_filter_bytag legend { display:none; } @@ -1049,36 +1050,37 @@ display:none; #filter_tags ul { list-style-type:none; } -#filter_tags ul li { +#filter_tags li { float:left; margin-left:7px; padding-left:7px; border-left-width:1px; border-left-style:solid; } -#filter_tags ul li.child_1 { +#filter_tags #filter_tags_all { margin-left:0; border-left:0; padding-left:0; } -#filter_tags ul li#filter_tags_all a { +#filter_tags_all a { font-weight:bold; margin-top:7px; float:left; } -#filter_tags ul li#filter_tags_item label { +#filter_tags_item label { margin-right:7px; } -#filter_tags ul li#filter_tags_item label, -#filter_tags ul li#filter_tags_item select { -display:inline; +#filter_tags_item label, +#filter_tags_item select { +float:left; } -#filter_tags ul li#filter_tags_item p { +#filter_tags_item p { float:left; +clear:both; margin-left:38px; } -#filter_tags ul li#filter_tags_item input { +#filter_tags_item .submit { position:relative; top:3px; left:3px; -- cgit v1.2.3-54-g00ecf From f218d7fd588660fb6d4def782c64abd8b991e4a7 Mon Sep 17 00:00:00 2001 From: brenda Date: Sat, 5 Sep 2009 16:11:38 +1200 Subject: more info in error message, to help next person who has to debug locales --- lib/util.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/util.php b/lib/util.php index 79611af2c..3dcd077a7 100644 --- a/lib/util.php +++ b/lib/util.php @@ -59,7 +59,7 @@ function common_init_language() textdomain("statusnet"); setlocale(LC_CTYPE, 'C'); if(!$locale_set) { - common_log(LOG_INFO,'Language requested:'.$language.' - locale could not be set:',__FILE__); + common_log(LOG_INFO, 'Language requested:' . $language . ' - locale could not be set. Perhaps that system locale is not installed.', __FILE__); } } -- cgit v1.2.3-54-g00ecf From 8438724296dadf9e5b26e4a2220403d494de62d0 Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Mon, 7 Sep 2009 14:51:10 +0000 Subject: Updated identica and default theme to use processing indicator --- theme/default/css/display.css | 7 ++----- theme/identica/css/display.css | 3 ++- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/theme/default/css/display.css b/theme/default/css/display.css index a1c4a2171..86369cb99 100644 --- a/theme/default/css/display.css +++ b/theme/default/css/display.css @@ -94,10 +94,11 @@ background:transparent url(../../base/images/icons/twotone/green/clip-01.gif) no opacity:0; } -#form_notice.processing #notice_action-submit { +#wrap form.processing input.submit { background:#FFFFFF url(../../base/images/icons/icon_processing.gif) no-repeat 47% 47%; cursor:wait; text-indent:-9999px; +outline:none; } #content { @@ -223,10 +224,6 @@ background:transparent url(../../base/images/icons/twotone/green/favourite.gif) .notice-options form.form_disfavor input.submit { background:transparent url(../../base/images/icons/twotone/green/disfavourite.gif) no-repeat 0 45%; } -.notice-options form.form_favor.processing input.submit, -.notice-options form.form_disfavor.processing input.submit { -background:transparent url(../../base/images/icons/icon_processing.gif) no-repeat 0 45%; -} .notice-options .notice_delete { background:transparent url(../../base/images/icons/twotone/green/trash.gif) no-repeat 0 45%; } diff --git a/theme/identica/css/display.css b/theme/identica/css/display.css index 51286657e..9fc97180d 100644 --- a/theme/identica/css/display.css +++ b/theme/identica/css/display.css @@ -94,10 +94,11 @@ background:transparent url(../../base/images/icons/twotone/green/clip-01.gif) no opacity:0; } -#form_notice.processing #notice_action-submit { +#wrap form.processing input.submit { background:#FFFFFF url(../../base/images/icons/icon_processing.gif) no-repeat 47% 47%; cursor:wait; text-indent:-9999px; +outline:none; } #content { -- cgit v1.2.3-54-g00ecf From c77c0d88cea4b26c9ede432eea728c2af72d2821 Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Mon, 7 Sep 2009 15:14:05 +0000 Subject: Setting max width limit to select form control on inbox and outbox pages --- theme/base/css/display.css | 1 + 1 file changed, 1 insertion(+) diff --git a/theme/base/css/display.css b/theme/base/css/display.css index d770f3868..1f37a7637 100644 --- a/theme/base/css/display.css +++ b/theme/base/css/display.css @@ -511,6 +511,7 @@ margin-top:7px; margin-bottom:7px; margin-left:18px; float:left; +max-width:322px; } #form_notice .error, #form_notice .success { -- cgit v1.2.3-54-g00ecf From 6020d85191bdd838acbeb40ab17035e378b0aee1 Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Mon, 7 Sep 2009 22:36:01 -0400 Subject: Don't "hightlight" search terms (by surrounding them in $term) when the term appears in an HTML attribute Fixes http://status.net/trac/ticket/1852 --- actions/noticesearch.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/actions/noticesearch.php b/actions/noticesearch.php index 1cd987df3..69dcd1a46 100644 --- a/actions/noticesearch.php +++ b/actions/noticesearch.php @@ -198,7 +198,7 @@ class SearchNoticeListItem extends NoticeListItem { $result = preg_replace($pattern, '\\1', $text); /* Remove highlighting from inside links, loop incase multiple highlights in links */ - $pattern = '/(href="[^"]*)('.$options.')<\/strong>([^"]*")/iU'; + $pattern = '/(\w+="[^"]*)('.$options.')<\/strong>([^"]*")/iU'; do { $result = preg_replace($pattern, '\\1\\2\\3', $result, -1, $count); } while ($count); -- cgit v1.2.3-54-g00ecf From afe1b8ec3df8d231ae9c6699da3a3947da285c00 Mon Sep 17 00:00:00 2001 From: CiaranG Date: Tue, 8 Sep 2009 11:27:37 +0100 Subject: Use a non-error-generating array key check to a) improve performance and b) not fill the log file with crud --- lib/omb.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/omb.php b/lib/omb.php index 0d6244599..7dca760c6 100644 --- a/lib/omb.php +++ b/lib/omb.php @@ -135,7 +135,7 @@ function omb_broadcast_remote_subscribers($notice) $posted = array(); while ($rp->fetch()) { - if (!$posted[$rp->postnoticeurl]) { + if (!array_key_exists($rp->postnoticeurl, $posted)) { common_log(LOG_DEBUG, 'Posting to ' . $rp->postnoticeurl); if (omb_post_notice_keys($notice, $rp->postnoticeurl, $rp->token, $rp->secret)) { common_log(LOG_DEBUG, 'Finished to ' . $rp->postnoticeurl); -- cgit v1.2.3-54-g00ecf From 52a197b235c4347e0fe6b14609098c0a0e444319 Mon Sep 17 00:00:00 2001 From: CiaranG Date: Tue, 8 Sep 2009 13:25:59 +0100 Subject: Linkback Plugin: check result properly so failures are not reported as a success in the log. Also logs (debug only) when an attempt is being made --- plugins/LinkbackPlugin.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/plugins/LinkbackPlugin.php b/plugins/LinkbackPlugin.php index c49f70de0..60f7a60c7 100644 --- a/plugins/LinkbackPlugin.php +++ b/plugins/LinkbackPlugin.php @@ -75,6 +75,8 @@ class LinkbackPlugin extends Plugin function linkbackUrl($url) { + common_log(LOG_DEBUG,"Attempting linkback for " . $url); + $orig = $url; $url = htmlspecialchars_decode($orig); $scheme = parse_url($url, PHP_URL_SCHEME); @@ -134,15 +136,20 @@ class LinkbackPlugin extends Plugin "User-Agent: " . $this->userAgent(), 'content' => $request))); $file = file_get_contents($endpoint, false, $context); - $response = xmlrpc_decode($file); - if (xmlrpc_is_fault($response)) { + if (!$file) { common_log(LOG_WARNING, + "Pingback request failed for '$url' ($endpoint)"); + } else { + $response = xmlrpc_decode($file); + if (xmlrpc_is_fault($response)) { + common_log(LOG_WARNING, "Pingback error for '$url' ($endpoint): ". "$response[faultString] ($response[faultCode])"); - } else { - common_log(LOG_INFO, + } else { + common_log(LOG_INFO, "Pingback success for '$url' ($endpoint): ". "'$response'"); + } } } -- cgit v1.2.3-54-g00ecf From 153b647f0b06b8053141589aa42c1231c20f6c61 Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Wed, 9 Sep 2009 12:57:27 +0200 Subject: Updated biz theme. --- theme/biz/css/base.css | 25 ++++------- theme/biz/css/display.css | 110 +++++++++++++++++++++++++++++----------------- 2 files changed, 78 insertions(+), 57 deletions(-) diff --git a/theme/biz/css/base.css b/theme/biz/css/base.css index 5245ea5d2..6357e55b4 100644 --- a/theme/biz/css/base.css +++ b/theme/biz/css/base.css @@ -849,6 +849,10 @@ float:left; font-size:1.025em; } +.notice div.entry-content .timestamp { +display:inline-block; +} + .notice div.entry-content dl, .notice div.entry-content dt, .notice div.entry-content dd { @@ -866,15 +870,12 @@ display:inline-block; text-transform:lowercase; } - .notice-options { -padding-left:2%; -float:left; -width:50%; position:relative; font-size:0.95em; -width:12.5%; +width:90px; float:right; +margin-right:11px; } .notice-options a { @@ -897,38 +898,28 @@ left:29px; .notice-options .notice_delete { right:0; } -.notice-options .notice_reply dt { -display:none; -} - .notice-options input, .notice-options a { text-indent:-9999px; outline:none; } - -.notice-options .notice_reply a, .notice-options input.submit { display:block; border:0; } -.notice-options .notice_reply a, -.notice-options .notice_delete a { +.notice-options .notice_reply, +.notice-options .notice_delete { text-decoration:none; padding-left:16px; } - .notice-options form input.submit { width:16px; padding:2px 0; } - -.notice-options .notice_delete dt, .notice-options .form_favor legend, .notice-options .form_disfavor legend { display:none; } -.notice-options .notice_delete fieldset, .notice-options .form_favor fieldset, .notice-options .form_disfavor fieldset { border:0; diff --git a/theme/biz/css/display.css b/theme/biz/css/display.css index 240060b10..7ea451576 100644 --- a/theme/biz/css/display.css +++ b/theme/biz/css/display.css @@ -30,10 +30,10 @@ font-family: "Lucida Sans Unicode", "Lucida Grande", sans-serif; } input, textarea, select, .entity_remote_subscribe { -border-color:#aaa; +border-color:#AAAAAA; } #filter_tags ul li { -border-color:#ddd; +border-color:#DDDDDD; } .form_settings input.form_action-primary { @@ -50,11 +50,14 @@ background-color:#9BB43E; input:focus, textarea:focus, select:focus, #form_notice.warning #notice_data-text { border-color:#9BB43E; +box-shadow:3px 3px 3px rgba(194, 194, 194, 0.3); +-moz-box-shadow:3px 3px 3px rgba(194, 194, 194, 0.3); +-webkit-box-shadow:3px 3px 3px rgba(194, 194, 194, 0.3); } input.submit, .entity_remote_subscribe, #site_nav_local_views a { -color:#fff; +color:#FFFFFF; } a, @@ -62,10 +65,13 @@ a, div.notice-options input, .form_user_block input.submit, .form_user_unblock input.submit, +.form_group_block input.submit, +.form_group_unblock input.submit, .entity_send-a-message a, .form_user_nudge input.submit, .entity_nudge p, -.form_settings input.form_action-primary { +.form_settings input.form_action-primary, +.form_make_admin input.submit { color:#002E6E; } @@ -82,13 +88,6 @@ border-top-color:#CEE1E9; border-top-color:#87B4C8; } -#content .notice p.entry-content a:visited { -background-color:#fcfcfc; -} -#content .notice p.entry-content .vcard a { -background-color:#fcfffc; -} - .aside .section { background-color:#F1F5F8; background-position:100% 0; @@ -97,10 +96,10 @@ background-repeat:no-repeat; } #notice_text-count { -color:#333; +color:#333333; } #form_notice.warning #notice_text-count { -color:#000; +color:#000000; } #form_notice label[for=notice_data-attach] { background:transparent url(../../base/images/icons/twotone/green/clip-01.gif) no-repeat 0 45%; @@ -109,28 +108,43 @@ background:transparent url(../../base/images/icons/twotone/green/clip-01.gif) no opacity:0; } -#form_notice.processing #notice_action-submit { -background:#fff url(../../base/images/icons/icon_processing.gif) no-repeat 47% 47%; +#wrap form.processing input.submit { +background:#FFFFFF url(../../base/images/icons/icon_processing.gif) no-repeat 47% 47%; cursor:wait; text-indent:-9999px; +outline:none; } +#content { +box-shadow:5px 7px 7px rgba(194, 194, 194, 0.3); +-moz-box-shadow:5px 7px 7px rgba(194, 194, 194, 0.3); +-webkit-box-shadow:5px 7px 7px rgba(194, 194, 194, 0.3); +} #content, #site_nav_local_views a, .aside .section { -border-color:#fff; +border-color:#FFFFFF; } #content, #site_nav_local_views .current a { -background-color:#fff; +background-color:#FFFFFF; } +#site_nav_local_views li { +box-shadow:3px 7px 5px rgba(194, 194, 194, 0.5); +-moz-box-shadow:3px 7px 5px rgba(194, 194, 194, 0.5); +-webkit-box-shadow:3px 7px 5px rgba(194, 194, 194, 0.5); +} #site_nav_local_views a { -background-color:rgba(135, 180, 200, 0.3); +background-color:rgba(194, 194, 194, 0.5); } #site_nav_local_views a:hover { background-color:rgba(255, 255, 255, 0.7); } +#site_nav_local_views .current a { +text-shadow: rgba(194,194,194,0.5) 1px 1px 1px; +} + .error { background-color:#F7E8E8; @@ -140,10 +154,7 @@ background-color:#EFF3DC; } #anon_notice { -color:#fff; -} - -#showstream #anon_notice { +color:#FFFFFF; } #export_data li a { @@ -165,7 +176,10 @@ background-image:url(../../base/images/icons/icon_foaf.gif); .form_user_nudge input.submit, .form_user_block input.submit, .form_user_unblock input.submit, -.entity_nudge p { +.form_group_block input.submit, +.form_group_unblock input.submit, +.entity_nudge p, +.form_make_admin input.submit { background-position: 0 40%; background-repeat: no-repeat; background-color:transparent; @@ -175,7 +189,7 @@ background-color:transparent; .form_user_subscribe input.submit, .form_user_unsubscribe input.submit { background-color:#9BB43E; -color:#fff; +color:#FFFFFF; } .form_user_unsubscribe input.submit, .form_group_leave input.submit, @@ -194,20 +208,23 @@ background-image:url(../../base/images/icons/twotone/green/quote.gif); background-image:url(../../base/images/icons/twotone/green/mail.gif); } .form_user_block input.submit, -.form_user_unblock input.submit { +.form_user_unblock input.submit, +.form_group_block input.submit, +.form_group_unblock input.submit { background-image:url(../../base/images/icons/twotone/green/shield.gif); } +.form_make_admin input.submit { +background-image:url(../../base/images/icons/twotone/green/admin.gif); +} /* NOTICES */ -.notices li.over { -background-color:#fcfcfc; +.notice .attachment { +background:transparent url(../../base/images/icons/twotone/green/clip-02.gif) no-repeat 0 45%; } - -.notice-options .notice_reply a, -.notice-options form input.submit { -background-color:transparent; +#attachments .attachment { +background:none; } -.notice-options .notice_reply a { +.notice-options .notice_reply { background:transparent url(../../base/images/icons/twotone/green/reply.gif) no-repeat 0 45%; } .notice-options form.form_favor input.submit { @@ -216,7 +233,7 @@ background:transparent url(../../base/images/icons/twotone/green/favourite.gif) .notice-options form.form_disfavor input.submit { background:transparent url(../../base/images/icons/twotone/green/disfavourite.gif) no-repeat 0 45%; } -.notice-options .notice_delete a { +.notice-options .notice_delete { background:transparent url(../../base/images/icons/twotone/green/trash.gif) no-repeat 0 45%; } @@ -224,19 +241,32 @@ background:transparent url(../../base/images/icons/twotone/green/trash.gif) no-r .notices div.notice-options { opacity:0.4; } -.notices li.hover div.entry-content, -.notices li.hover div.notice-options { +.notices li:hover div.entry-content, +.notices li:hover div.notice-options { opacity:1; } -div.entry-content { -color:#333; -} div.notice-options a, div.notice-options input { font-family:sans-serif; } -.notices li.hover { -background-color:#fcfcfc; +#content .notices li:hover { +background-color:rgba(240, 240, 240, 0.2); +} +#conversation .notices li:hover { +background-color:transparent; +} + +.notices .notices { +background-color:rgba(200, 200, 200, 0.050); +} +.notices .notices .notices { +background-color:rgba(200, 200, 200, 0.100); +} +.notices .notices .notices .notices { +background-color:rgba(200, 200, 200, 0.150); +} +.notices .notices .notices .notices .notices { +background-color:rgba(200, 200, 200, 0.300); } /*END: NOTICES */ -- cgit v1.2.3-54-g00ecf From 7a910961b6e2b5f1fe21a4a9d0b66f5a7d911250 Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Wed, 9 Sep 2009 13:04:05 +0200 Subject: Updated biz, cloudy, h4ck3r, pigeonthoughts themes default logos --- theme/biz/logo.png | Bin 2228 -> 6389 bytes theme/cloudy/logo.png | Bin 2228 -> 6389 bytes theme/h4ck3r/logo.png | Bin 2228 -> 6389 bytes theme/pigeonthoughts/logo.png | Bin 2228 -> 6389 bytes 4 files changed, 0 insertions(+), 0 deletions(-) diff --git a/theme/biz/logo.png b/theme/biz/logo.png index fdead6c4a..550d373fe 100644 Binary files a/theme/biz/logo.png and b/theme/biz/logo.png differ diff --git a/theme/cloudy/logo.png b/theme/cloudy/logo.png index fdead6c4a..550d373fe 100644 Binary files a/theme/cloudy/logo.png and b/theme/cloudy/logo.png differ diff --git a/theme/h4ck3r/logo.png b/theme/h4ck3r/logo.png index fdead6c4a..550d373fe 100644 Binary files a/theme/h4ck3r/logo.png and b/theme/h4ck3r/logo.png differ diff --git a/theme/pigeonthoughts/logo.png b/theme/pigeonthoughts/logo.png index fdead6c4a..550d373fe 100644 Binary files a/theme/pigeonthoughts/logo.png and b/theme/pigeonthoughts/logo.png differ -- cgit v1.2.3-54-g00ecf From aecdba1ded89b45f32d0b7615ce6b103478403dd Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Wed, 9 Sep 2009 16:57:11 -0400 Subject: :: isn't a valid IPv6 address for our purposes --- lib/util.php | 4 ++-- tests/URLDetectionTest.php | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/util.php b/lib/util.php index 3dcd077a7..256acf199 100644 --- a/lib/util.php +++ b/lib/util.php @@ -432,7 +432,7 @@ function common_replace_urls_callback($text, $callback, $notice_id = null) { ')'. '|(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)'. //IPv4 '|(?:'. //IPv6 - '\[?(?:(?:(?:[0-9A-Fa-f]{1,4}:){7}(?:(?:[0-9A-Fa-f]{1,4})|:))|(?:(?:[0-9A-Fa-f]{1,4}:){6}(?::|(?:(?:25[0-5]|2[0-4]\d|[01]?\d{1,2})(?:\.(?:25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})|(?::[0-9A-Fa-f]{1,4})))|(?:(?:[0-9A-Fa-f]{1,4}:){5}(?:(?::(?:(?:25[0-5]|2[0-4]\d|[01]?\d{1,2})(?:\.(?:25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})?)|(?:(?::[0-9A-Fa-f]{1,4}){1,2})))|(?:(?:[0-9A-Fa-f]{1,4}:){4}(?::[0-9A-Fa-f]{1,4}){0,1}(?:(?::(?:(?:25[0-5]|2[0-4]\d|[01]?\d{1,2})(?:\.(?:25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})?)|(?:(?::[0-9A-Fa-f]{1,4}){1,2})))|(?:(?:[0-9A-Fa-f]{1,4}:){3}(?::[0-9A-Fa-f]{1,4}){0,2}(?:(?::(?:(?:25[0-5]|2[0-4]\d|[01]?\d{1,2})(?:\.(?:25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})?)|(?:(?::[0-9A-Fa-f]{1,4}){1,2})))|(?:(?:[0-9A-Fa-f]{1,4}:){2}(?::[0-9A-Fa-f]{1,4}){0,3}(?:(?::(?:(?:25[0-5]|2[0-4]\d|[01]?\d{1,2})(?:\.(?:25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})?)|(?:(?::[0-9A-Fa-f]{1,4}){1,2})))|(?:(?:[0-9A-Fa-f]{1,4}:)(?::[0-9A-Fa-f]{1,4}){0,4}(?:(?::(?:(?:25[0-5]|2[0-4]\d|[01]?\d{1,2})(?:\.(?:25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})?)|(?:(?::[0-9A-Fa-f]{1,4}){1,2})))|(?::(?::[0-9A-Fa-f]{1,4}){0,5}(?:(?::(?:(?:25[0-5]|2[0-4]\d|[01]?\d{1,2})(?:\.(?:25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})?)|(?:(?::[0-9A-Fa-f]{1,4}){1,2})))|(?:(?:(?:25[0-5]|2[0-4]\d|[01]?\d{1,2})(?:\.(?:25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})))\]?'. + '\[?(?:(?:(?:[0-9A-Fa-f]{1,4}:){7}(?:(?:[0-9A-Fa-f]{1,4})|:))|(?:(?:[0-9A-Fa-f]{1,4}:){6}(?::|(?:(?:25[0-5]|2[0-4]\d|[01]?\d{1,2})(?:\.(?:25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})|(?::[0-9A-Fa-f]{1,4})))|(?:(?:[0-9A-Fa-f]{1,4}:){5}(?:(?::(?:(?:25[0-5]|2[0-4]\d|[01]?\d{1,2})(?:\.(?:25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})?)|(?:(?::[0-9A-Fa-f]{1,4}){1,2})))|(?:(?:[0-9A-Fa-f]{1,4}:){4}(?::[0-9A-Fa-f]{1,4}){0,1}(?:(?::(?:(?:25[0-5]|2[0-4]\d|[01]?\d{1,2})(?:\.(?:25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})?)|(?:(?::[0-9A-Fa-f]{1,4}){1,2})))|(?:(?:[0-9A-Fa-f]{1,4}:){3}(?::[0-9A-Fa-f]{1,4}){0,2}(?:(?::(?:(?:25[0-5]|2[0-4]\d|[01]?\d{1,2})(?:\.(?:25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})?)|(?:(?::[0-9A-Fa-f]{1,4}){1,2})))|(?:(?:[0-9A-Fa-f]{1,4}:){2}(?::[0-9A-Fa-f]{1,4}){0,3}(?:(?::(?:(?:25[0-5]|2[0-4]\d|[01]?\d{1,2})(?:\.(?:25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})?)|(?:(?::[0-9A-Fa-f]{1,4}){1,2})))|(?:(?:[0-9A-Fa-f]{1,4}:)(?::[0-9A-Fa-f]{1,4}){0,4}(?:(?::(?:(?:25[0-5]|2[0-4]\d|[01]?\d{1,2})(?:\.(?:25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})?)|(?:(?::[0-9A-Fa-f]{1,4}){1,2})))|(?::(?::[0-9A-Fa-f]{1,4}){0,5}(?:(?::(?:(?:25[0-5]|2[0-4]\d|[01]?\d{1,2})(?:\.(?:25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})?)|(?:(?::[0-9A-Fa-f]{1,4}){1,2})))|(?:(?:(?:25[0-5]|2[0-4]\d|[01]?\d{1,2})(?:\.(?:25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})))\]?(?http://127.0.0.1'), array('127.0.0.1', -- cgit v1.2.3-54-g00ecf From e2848eb8621dd645fa68cb1641c0af1df5530408 Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Wed, 9 Sep 2009 22:57:15 -0400 Subject: If a shortened URL begins with http://, don't include it in the shortened url. Saves 7 characters, which is pretty awesome for 140 character max length notices. --- lib/util.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/util.php b/lib/util.php index 256acf199..3e95d2bea 100644 --- a/lib/util.php +++ b/lib/util.php @@ -1414,6 +1414,9 @@ function common_shorten_url($long_url) curl_close($curlh); + if(substr($short_url,0,7)=='http://'){ + $short_url = substr($short_url,7); + } return $short_url; } -- cgit v1.2.3-54-g00ecf From 4181c6f04ad6a2321b2957d8784abc7dfef5779f Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Sun, 13 Sep 2009 17:53:15 -0700 Subject: bug 1814: installer now only offers DB types which are available. Abstracted a couple of hardcoded lists of mysql/pgsql checks and radio button creation to use a nice little array of names, installer funcs, and modules to check. Only those DB types whose modules are present will be presented in the installer; if all are missing, we throw an error and list out all the possibilities we were looking for. --- install.php | 52 +++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 37 insertions(+), 15 deletions(-) diff --git a/install.php b/install.php index e828fa814..092172d35 100644 --- a/install.php +++ b/install.php @@ -181,6 +181,18 @@ $external_libraries=array( 'check_class'=>'Validate' ) ); +$dbModules = array( + 'mysql' => array( + 'name' => 'MySQL', + 'check_module' => 'mysql', // mysqli? + 'installer' => 'mysql_db_installer', + ), + 'pgsql' => array( + 'name' => 'PostgreSQL', + 'check_module' => 'pgsql', + 'installer' => 'pgsql_db_installer', + ), +); function main() { @@ -238,8 +250,18 @@ function checkPrereqs() $pass = false; } } - if (!checkExtension('pgsql') && !checkExtension('mysql')) { - ?>

Cannot find mysql or pgsql extension. You need one or the other:

$info) { + if (!checkExtension($info['check_module'])) { + $missingExtensions[] = $info['check_module']; + } + } + if (count($missingExtensions) == count($dbModules)) { + $req = implode(', ', $missingExtensions); + ?>

Cannot find database support. You need at least one of these PHP extensions installed:

$info) { + if (checkExtension($info['check_module'])) { + $dbRadios .= " $info[name]
\n"; + $checked = ''; + } + } echo<< @@ -376,8 +407,7 @@ function showForm()
  • - MySQL
    - PostgreSQL
    + $dbRadios

    Database type

  • @@ -465,17 +495,9 @@ function handlePost() return; } - // FIXME: use PEAR::DB or PDO instead of our own switch - - switch($dbtype) { - case 'mysql': - $db = mysql_db_installer($host, $database, $username, $password); - break; - case 'pgsql': - $db = pgsql_db_installer($host, $database, $username, $password); - break; - default: - } + global $dbModules; + $db = call_user_func($dbModules[$dbtype]['installer'], + $host, $database, $username, $password); if (!$db) { // database connection failed, do not move on to create config file. -- cgit v1.2.3-54-g00ecf From 222ef4d1869485426e893f85caf8a3014f814faa Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 13 Sep 2009 17:43:02 +1200 Subject: added doxygen tags --- install.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/install.php b/install.php index 092172d35..5754c717a 100644 --- a/install.php +++ b/install.php @@ -1,5 +1,5 @@ . + * + * @category Installation + * @package Installation + * @license GNU Affero General Public License http://www.gnu.org/licenses/ + * */ + + define('INSTALLDIR', dirname(__FILE__)); -- cgit v1.2.3-54-g00ecf From 711fe39700e868ad2cea595b109d2958752d4aa6 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 13 Sep 2009 17:43:48 +1200 Subject: changed curly bracks on if, else, foreach to match pear code styles --- install.php | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/install.php b/install.php index 5754c717a..75646c852 100644 --- a/install.php +++ b/install.php @@ -203,14 +203,13 @@ $dbModules = array( function main() { - if (!checkPrereqs()) - { + if (!checkPrereqs()) { return; } - if( $_GET['checklibs'] ){ + if ($_GET['checklibs']) { showLibs(); - }else{ + } else { if ($_SERVER['REQUEST_METHOD'] == 'POST') { handlePost(); } else { @@ -221,13 +220,13 @@ function main() function haveExternalLibrary($external_library) { - if(isset($external_library['include']) && ! include_once($external_library['include'])){ + if (isset($external_library['include']) && ! include_once $external_library['include'] ) { return false; } - if(isset($external_library['check_function']) && ! function_exists($external_library['check_function'])){ + if (isset($external_library['check_function']) && ! function_exists($external_library['check_function'])) { return false; } - if(isset($external_library['check_class']) && ! class_exists($external_library['check_class'])){ + if (isset($external_library['check_class']) && ! class_exists($external_library['check_class'])) { return false; } return true; @@ -309,10 +308,10 @@ function showLibs() global $external_libraries; $present_libraries=array(); $absent_libraries=array(); - foreach($external_libraries as $external_library){ - if(haveExternalLibrary($external_library)){ + foreach ($external_libraries as $external_library){ + if (haveExternalLibrary($external_library)) { $present_libraries[]=$external_library; - }else{ + } else { $absent_libraries[]=$external_library; } } -- cgit v1.2.3-54-g00ecf From c2e156dc492925d6aa94b91d5cee9ceb615bc2ab Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 13 Sep 2009 17:44:22 +1200 Subject: added doxygen for main() --- install.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/install.php b/install.php index 75646c852..221e4746f 100644 --- a/install.php +++ b/install.php @@ -201,6 +201,12 @@ $dbModules = array( ), ); +/** + * the actual installation. + * If call libraries are present, then install + * + * @return void + */ function main() { if (!checkPrereqs()) { -- cgit v1.2.3-54-g00ecf From 20764dc08b0231e4be07c4e181c8603b005c20b5 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 14 Sep 2009 19:05:14 +1200 Subject: removed most of the that was making this hard to read Conflicts: install.php --- install.php | 58 +++++++++++++++++++++++++++------------------------------- 1 file changed, 27 insertions(+), 31 deletions(-) diff --git a/install.php b/install.php index 221e4746f..6f8bff91e 100644 --- a/install.php +++ b/install.php @@ -240,17 +240,16 @@ function haveExternalLibrary($external_library) function checkPrereqs() { - $pass = true; + $pass = true; if (file_exists(INSTALLDIR.'/config.php')) { - ?>

    Config file "config.php" already exists.

    - Config file "config.php" already exists.

    '); $pass = false; } if (version_compare(PHP_VERSION, '5.2.3', '<')) { - ?>

    Require PHP version 5.2.3 or greater.

    Require PHP version 5.2.3 or greater.

    '); + $pass = false; } $reqs = array('gd', 'curl', @@ -258,11 +257,10 @@ function checkPrereqs() foreach ($reqs as $req) { if (!checkExtension($req)) { - ?>

    Cannot load required extension:

    Cannot load required extension: %s

    ', $req); + $pass = false; } - } - + } // Make sure we have at least one database module available global $dbModules; $missingExtensions = array(); @@ -273,30 +271,28 @@ function checkPrereqs() } if (count($missingExtensions) == count($dbModules)) { $req = implode(', ', $missingExtensions); - ?>

    Cannot find database support. You need at least one of these PHP extensions installed:

    Cannot find mysql or pgsql extension. You need one or the other: %s

    ', $req); + $pass = false; + } + + if (!is_writable(INSTALLDIR)) { + printf('

    Cannot write config file to: %s

    ', INSTALLDIR); + printf('

    On your server, try this command: chmod a+w %s', INSTALLDIR); + $pass = false; + } + + // Check the subdirs used for file uploads + $fileSubdirs = array('avatar', 'background', 'file'); + foreach ($fileSubdirs as $fileSubdir) { + $fileFullPath = INSTALLDIR."/$fileSubdir/"; + if (!is_writable($fileFullPath)) { + printf('

    Cannot write to %s directory: %s

    ', $fileSubdir, $fileFullPath); + printf('

    On your server, try this command: chmod a+w %s

    ', $fileFullPath); + $pass = false; + } } - if (!is_writable(INSTALLDIR)) { - ?>

    Cannot write config file to:

    -

    On your server, try this command: chmod a+w -

    Cannot write directory:

    -

    On your server, try this command: chmod a+w

    - Date: Sun, 13 Sep 2009 17:59:42 +1200 Subject: fixed missing semisolon --- install.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/install.php b/install.php index 6f8bff91e..64c8fd9b1 100644 --- a/install.php +++ b/install.php @@ -444,10 +444,8 @@ E_O_T; function updateStatus($status, $error=false) { -?> -
  • >
  • - -$status"; } function handlePost() -- cgit v1.2.3-54-g00ecf From 61d5d51cf55909e8fa2b4a362b47741a9cde25ae Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 13 Sep 2009 18:22:32 +1200 Subject: lotsa tabulation changed to 4 spaces --- install.php | 205 +++++++++++++++++++++++++++++++----------------------------- 1 file changed, 105 insertions(+), 100 deletions(-) diff --git a/install.php b/install.php index 64c8fd9b1..9d59f25b9 100644 --- a/install.php +++ b/install.php @@ -450,9 +450,6 @@ function updateStatus($status, $error=false) function handlePost() { -?> - - + echo <<
    Page notice
      -server_encoding != 'UTF8') { - updateStatus("StatusNet requires UTF8 character encoding. Your database is ". htmlentities($record->server_encoding)); - showForm(); - return false; - } - - updateStatus("Running database script..."); - //wrap in transaction; - pg_query($conn, 'BEGIN'); - $res = runDbScript(INSTALLDIR.'/db/statusnet_pg.sql', $conn, 'pgsql'); - - if ($res === false) { - updateStatus("Can't run database script.", true); - showForm(); - return false; - } - foreach (array('sms_carrier' => 'SMS carrier', + $connstring = "dbname=$database host=$host user=$username"; + + //No password would mean trust authentication used. + if (!empty($password)) { + $connstring .= " password=$password"; + } + updateStatus("Starting installation..."); + updateStatus("Checking database..."); + $conn = pg_connect($connstring); + + if ($conn ===false) { + updateStatus("Failed to connect to database: $connstring"); + showForm(); + return false; + } + + //ensure database encoding is UTF8 + $record = pg_fetch_object(pg_query($conn, 'SHOW server_encoding')); + if ($record->server_encoding != 'UTF8') { + updateStatus("StatusNet requires UTF8 character encoding. Your database is ". htmlentities($record->server_encoding)); + showForm(); + return false; + } + + updateStatus("Running database script..."); + //wrap in transaction; + pg_query($conn, 'BEGIN'); + $res = runDbScript(INSTALLDIR.'/db/statusnet_pg.sql', $conn, 'pgsql'); + + if ($res === false) { + updateStatus("Can't run database script.", true); + showForm(); + return false; + } + foreach (array('sms_carrier' => 'SMS carrier', 'notice_source' => 'notice source', 'foreign_services' => 'foreign service') as $scr => $name) { - updateStatus(sprintf("Adding %s data to database...", $name)); - $res = runDbScript(INSTALLDIR.'/db/'.$scr.'.sql', $conn, 'pgsql'); - if ($res === false) { - updateStatus(sprintf("Can't run %d script.", $name), true); - showForm(); - return false; - } - } - pg_query($conn, 'COMMIT'); - - if (empty($password)) { - $sqlUrl = "pgsql://$username@$host/$database"; - } - else { - $sqlUrl = "pgsql://$username:$password@$host/$database"; - } - - $db = array('type' => 'pgsql', 'database' => $sqlUrl); - - return $db; + updateStatus(sprintf("Adding %s data to database...", $name)); + $res = runDbScript(INSTALLDIR.'/db/'.$scr.'.sql', $conn, 'pgsql'); + if ($res === false) { + updateStatus(sprintf("Can't run %d script.", $name), true); + showForm(); + return false; + } + } + pg_query($conn, 'COMMIT'); + + if (empty($password)) { + $sqlUrl = "pgsql://$username@$host/$database"; + } + else { + $sqlUrl = "pgsql://$username:$password@$host/$database"; + } + + $db = array('type' => 'pgsql', 'database' => $sqlUrl); + + return $db; } function mysql_db_installer($host, $database, $username, $password) { - updateStatus("Starting installation..."); - updateStatus("Checking database..."); - - $conn = mysql_connect($host, $username, $password); - if (!$conn) { - updateStatus("Can't connect to server '$host' as '$username'.", true); - showForm(); - return false; - } - updateStatus("Changing to database..."); - $res = mysql_select_db($database, $conn); - if (!$res) { - updateStatus("Can't change to database.", true); - showForm(); - return false; - } - updateStatus("Running database script..."); - $res = runDbScript(INSTALLDIR.'/db/statusnet.sql', $conn); - if ($res === false) { - updateStatus("Can't run database script.", true); - showForm(); - return false; - } - foreach (array('sms_carrier' => 'SMS carrier', + updateStatus("Starting installation..."); + updateStatus("Checking database..."); + + $conn = mysql_connect($host, $username, $password); + if (!$conn) { + updateStatus("Can't connect to server '$host' as '$username'.", true); + showForm(); + return false; + } + updateStatus("Changing to database..."); + $res = mysql_select_db($database, $conn); + if (!$res) { + updateStatus("Can't change to database.", true); + showForm(); + return false; + } + updateStatus("Running database script..."); + $res = runDbScript(INSTALLDIR.'/db/statusnet.sql', $conn); + if ($res === false) { + updateStatus("Can't run database script.", true); + showForm(); + return false; + } + foreach (array('sms_carrier' => 'SMS carrier', 'notice_source' => 'notice source', 'foreign_services' => 'foreign service') as $scr => $name) { - updateStatus(sprintf("Adding %s data to database...", $name)); - $res = runDbScript(INSTALLDIR.'/db/'.$scr.'.sql', $conn); - if ($res === false) { - updateStatus(sprintf("Can't run %d script.", $name), true); - showForm(); - return false; - } - } - - $sqlUrl = "mysqli://$username:$password@$host/$database"; - $db = array('type' => 'mysql', 'database' => $sqlUrl); - return $db; + updateStatus(sprintf("Adding %s data to database...", $name)); + $res = runDbScript(INSTALLDIR.'/db/'.$scr.'.sql', $conn); + if ($res === false) { + updateStatus(sprintf("Can't run %d script.", $name), true); + showForm(); + return false; + } + } + + $sqlUrl = "mysqli://$username:$password@$host/$database"; + $db = array('type' => 'mysql', 'database' => $sqlUrl); + return $db; } function writeConf($sitename, $server, $path, $fancy, $db) @@ -662,6 +659,14 @@ function writeConf($sitename, $server, $path, $fancy, $db) return $res; } +/** + * Install schema into the database + * + * @param filename $filename location of database schema file + * @param conn $conn connection to database + * @param type $type type of database, currently mysql or pgsql + * @return boolean - indicating success or failure + */ function runDbScript($filename, $conn, $type = 'mysql') { $sql = trim(file_get_contents($filename)); -- cgit v1.2.3-54-g00ecf From 36aa89d6959d0d03f3fe3c769f867f314aba8bf9 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 13 Sep 2009 18:29:10 +1200 Subject: many doxygen comments added --- install.php | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/install.php b/install.php index 9d59f25b9..787edb20f 100644 --- a/install.php +++ b/install.php @@ -224,6 +224,13 @@ function main() } } +/** + * checks if an external libary is present + * + * @param string $external_library Name of library + * + * @return boolean indicates if library present + */ function haveExternalLibrary($external_library) { if (isset($external_library['include']) && ! include_once $external_library['include'] ) { @@ -238,6 +245,11 @@ function haveExternalLibrary($external_library) return true; } +/** + * Check if all is ready for installation + * + * @return void + */ function checkPrereqs() { $pass = true; @@ -295,6 +307,13 @@ function checkPrereqs() return $pass; } +/** + * Checks if a php extension is both installed and loaded + * + * @param string $name of extension to check + * + * @return boolean whether extension is installed and loaded + */ function checkExtension($name) { if (!extension_loaded($name)) { @@ -305,6 +324,11 @@ function checkExtension($name) return true; } +/** + * Show list of libraries + * + * @return void + */ function showLibs() { global $external_libraries; @@ -356,9 +380,9 @@ E_O_T; foreach($present_libraries as $library) { echo '
    • '; - if($library['url']){ + if ($library['url']) { echo ''.htmlentities($library['name']).''; - }else{ + } else { echo htmlentities($library['name']); } echo '
    • '; -- cgit v1.2.3-54-g00ecf From f5b7ea739660cf15abb92f534b30fc1cfd5e07c6 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 13 Sep 2009 18:31:44 +1200 Subject: fixed up curly brackets and spaces around for, if, else --- install.php | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/install.php b/install.php index 787edb20f..30c6780ab 100644 --- a/install.php +++ b/install.php @@ -334,7 +334,7 @@ function showLibs() global $external_libraries; $present_libraries=array(); $absent_libraries=array(); - foreach ($external_libraries as $external_library){ + foreach ($external_libraries as $external_library) { if (haveExternalLibrary($external_library)) { $present_libraries[]=$external_library; } else { @@ -352,22 +352,21 @@ function showLibs()

      Absent Libraries

        E_O_T; - foreach($absent_libraries as $library) - { + foreach ($absent_libraries as $library) { echo '
      • '; - if($library['url']){ + if ($library['url']) { echo ''.htmlentities($library['name']).''; - }else{ + } else { echo htmlentities($library['name']); } echo '
          '; - if($library['deb']){ + if ($library['deb']) { echo '
        • deb: ' . htmlentities($library['deb']) . '
        • '; } - if($library['rpm']){ + if ($library['rpm']) { echo '
        • rpm: ' . htmlentities($library['rpm']) . '
        • '; } - if($library['pear']){ + if ($library['pear']) { echo '
        • pear: ' . htmlentities($library['pear']) . '
        • '; } echo '
        '; @@ -377,8 +376,7 @@ E_O_T;

        Installed Libraries

          E_O_T; - foreach($present_libraries as $library) - { + foreach ($present_libraries as $library) { echo '
        • '; if ($library['url']) { echo ''.htmlentities($library['name']).''; @@ -514,11 +512,11 @@ STR; if (empty($sitename)) { updateStatus("No sitename specified.", true); - $fail = true; + $fail = true; } - if($fail){ - showForm(); + if ($fail) { + showForm(); return; } @@ -603,8 +601,7 @@ function pgsql_db_installer($host, $database, $username, $password) { if (empty($password)) { $sqlUrl = "pgsql://$username@$host/$database"; - } - else { + } else { $sqlUrl = "pgsql://$username:$password@$host/$database"; } -- cgit v1.2.3-54-g00ecf From 93605dce99832868c3fdbb8af42db507a8005e97 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 13 Sep 2009 18:32:59 +1200 Subject: removed commented out code we no longer want --- install.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/install.php b/install.php index 30c6780ab..6e7e833a3 100644 --- a/install.php +++ b/install.php @@ -505,11 +505,6 @@ STR; $fail = true; } -// if (empty($password)) { -// updateStatus("No password specified.", true); -// $fail = true; -// } - if (empty($sitename)) { updateStatus("No sitename specified.", true); $fail = true; -- cgit v1.2.3-54-g00ecf From dbc08ef0a09e481e0884a38ee704f4d193edef6a Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 14 Sep 2009 19:08:05 +1200 Subject: most of code style errors gone Conflicts: install.php --- install.php | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/install.php b/install.php index 6e7e833a3..dea03fc5e 100644 --- a/install.php +++ b/install.php @@ -516,8 +516,7 @@ STR; } global $dbModules; - $db = call_user_func($dbModules[$dbtype]['installer'], - $host, $database, $username, $password); + $db = call_user_func($dbModules[$dbtype]['installer'], $host, $database, $username, $password); if (!$db) { // database connection failed, do not move on to create config file. @@ -540,12 +539,10 @@ STR; updateStatus("StatusNet has been installed at $link"); updateStatus("You can visit your new StatusNet site."); -?> - - Date: Sun, 13 Sep 2009 20:15:21 +1200 Subject: added most of the required doxygen --- index.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/index.php b/index.php index e2296549f..83c14c495 100644 --- a/index.php +++ b/index.php @@ -15,6 +15,10 @@ * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . + * + * @category StatusNet + * @package StatusNet + * @license GNU Affero General Public License http://www.gnu.org/licenses/ */ define('INSTALLDIR', dirname(__FILE__)); -- cgit v1.2.3-54-g00ecf From a2f4fe7fc80fa851dd9293d64c4727d4bb233b90 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 13 Sep 2009 20:16:07 +1200 Subject: fixed up if statements --- index.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.php b/index.php index 83c14c495..8f2a7cf7f 100644 --- a/index.php +++ b/index.php @@ -49,11 +49,11 @@ function handleError($error) } $logmsg = "PEAR error: " . $error->getMessage(); - if(common_config('site', 'logdebug')) { + if (common_config('site', 'logdebug')) { $logmsg .= " : ". $error->getDebugInfo(); } common_log(LOG_ERR, $logmsg); - if(common_config('site', 'logdebug')) { + if (common_config('site', 'logdebug')) { $bt = $error->getBacktrace(); foreach ($bt as $line) { common_log(LOG_ERR, $line); -- cgit v1.2.3-54-g00ecf From 738b6d1690ad595b85657fa282132459865fed93 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 13 Sep 2009 20:31:19 +1200 Subject: lotsa of multiline if statements and function calls changed style to meat pear code style --- index.php | 54 ++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 34 insertions(+), 20 deletions(-) diff --git a/index.php b/index.php index 8f2a7cf7f..71de39324 100644 --- a/index.php +++ b/index.php @@ -33,7 +33,8 @@ $action = null; function getPath($req) { if ((common_config('site', 'fancy') || !array_key_exists('PATH_INFO', $_SERVER)) - && array_key_exists('p', $req)) { + && array_key_exists('p', $req) + ) { return $req['p']; } else if (array_key_exists('PATH_INFO', $_SERVER)) { return $_SERVER['PATH_INFO']; @@ -59,18 +60,25 @@ function handleError($error) common_log(LOG_ERR, $line); } } - if ($error instanceof DB_DataObject_Error || - $error instanceof DB_Error) { - $msg = sprintf(_('The database for %s isn\'t responding correctly, '. - 'so the site won\'t work properly. '. - 'The site admins probably know about the problem, '. - 'but you can contact them at %s to make sure. '. - 'Otherwise, wait a few minutes and try again.'), - common_config('site', 'name'), - common_config('site', 'email')); + if ($error instanceof DB_DataObject_Error + || $error instanceof DB_Error + ) { + $msg = sprintf( + _( + 'The database for %s isn\'t responding correctly, '. + 'so the site won\'t work properly. '. + 'The site admins probably know about the problem, '. + 'but you can contact them at %s to make sure. '. + 'Otherwise, wait a few minutes and try again.' + ), + common_config('site', 'name'), + common_config('site', 'email') + ); } else { - $msg = _('An important error occured, probably related to email setup. '. - 'Check logfiles for more info..'); + $msg = _( + 'An important error occured, probably related to email setup. '. + 'Check logfiles for more info..' + ); } $dac = new DBErrorAction($msg, 500); @@ -131,10 +139,11 @@ function main() $_lighty_url = @parse_url($_lighty_url); if ($_lighty_url['path'] != '/index.php' && $_lighty_url['path'] != '/') { - $_lighty_path = preg_replace('/^'.preg_quote(common_config('site','path')).'\//', '', substr($_lighty_url['path'], 1)); + $_lighty_path = preg_replace('/^'.preg_quote(common_config('site', 'path')).'\//', '', substr($_lighty_url['path'], 1)); $_SERVER['QUERY_STRING'] = 'p='.$_lighty_path; - if ($_lighty_url['query']) + if ($_lighty_url['query']) { $_SERVER['QUERY_STRING'] .= '&'.$_lighty_url['query']; + } parse_str($_lighty_url['query'], $_lighty_query); foreach ($_lighty_query as $key => $val) { $_GET[$key] = $_REQUEST[$key] = $val; @@ -145,7 +154,7 @@ function main() $_SERVER['REDIRECT_URL'] = preg_replace("/\?.+$/", "", $_SERVER['REQUEST_URI']); // quick check for fancy URL auto-detection support in installer. - if (isset($_SERVER['REDIRECT_URL']) && (preg_replace("/^\/$/","",(dirname($_SERVER['REQUEST_URI']))) . '/check-fancy') === $_SERVER['REDIRECT_URL']) { + if (isset($_SERVER['REDIRECT_URL']) && (preg_replace("/^\/$/", "", (dirname($_SERVER['REQUEST_URI']))) . '/check-fancy') === $_SERVER['REDIRECT_URL']) { die("Fancy URL support detection succeeded. We suggest you enable this to get fancy (pretty) URLs."); } global $user, $action; @@ -153,8 +162,12 @@ function main() Snapshot::check(); if (!_have_config()) { - $msg = sprintf(_("No configuration file found. Try running ". - "the installation program first.")); + $msg = sprintf( + _( + "No configuration file found. Try running ". + "the installation program first." + ) + ); $sac = new ServerErrorAction($msg); $sac->showPage(); return; @@ -200,9 +213,10 @@ function main() // If the site is private, and they're not on one of the "public" // parts of the site, redirect to login - if (!$user && common_config('site', 'private') && - !isLoginAction($action) && - !preg_match('/rss$/', $action)) { + if (!$user && common_config('site', 'private') + && !isLoginAction($action) + && !preg_match('/rss$/', $action) + ) { common_redirect(common_local_url('login')); return; } -- cgit v1.2.3-54-g00ecf From 87c59fe8734479046c8433f74787f615484b3df7 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 13 Sep 2009 20:32:58 +1200 Subject: fixed indentation for the pear code styles --- index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.php b/index.php index 71de39324..b8d9c7c69 100644 --- a/index.php +++ b/index.php @@ -34,7 +34,7 @@ function getPath($req) { if ((common_config('site', 'fancy') || !array_key_exists('PATH_INFO', $_SERVER)) && array_key_exists('p', $req) - ) { + ) { return $req['p']; } else if (array_key_exists('PATH_INFO', $_SERVER)) { return $_SERVER['PATH_INFO']; -- cgit v1.2.3-54-g00ecf From 5ca90e2c8cbc76693cf0f2278d14f2a35da7e34e Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 14 Sep 2009 19:19:11 +1200 Subject: pulled @author from git logs Conflicts: install.php --- index.php | 14 ++++++++++++++ install.php | 21 ++++++++++++++++----- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/index.php b/index.php index b8d9c7c69..a1d983dce 100644 --- a/index.php +++ b/index.php @@ -19,6 +19,20 @@ * @category StatusNet * @package StatusNet * @license GNU Affero General Public License http://www.gnu.org/licenses/ + * @author Brenda Wallace + * @author Christopher Vollick + * @author CiaranG + * @author Craig Andrews + * @author Evan Prodromou + * @author Evan Prodromou + * @author Evan Prodromou + * @author Evan Prodromou + * @author Gina Haeussge + * @author Jeffery To + * @author Mike Cochrane + * @author Robin Millette + * @author Sarven Capadisli + * @author Tom Adams */ define('INSTALLDIR', dirname(__FILE__)); diff --git a/install.php b/install.php index dea03fc5e..07a7bfaaf 100644 --- a/install.php +++ b/install.php @@ -18,12 +18,22 @@ * * @category Installation * @package Installation - * @license GNU Affero General Public License http://www.gnu.org/licenses/ * + * @author Adrian Lang + * @author Brenda Wallace + * @author Brett Taylor + * @author Brion Vibber + * @author CiaranG + * @author Craig Andrews + * @author Eric Helgeson + * @author Evan Prodromou + * @author Evan Prodromou + * @author Robin Millette + * @author Sarven Capadisli + * @author Tom Adams + * @license GNU Affero General Public License http://www.gnu.org/licenses/ */ - - define('INSTALLDIR', dirname(__FILE__)); $external_libraries=array( @@ -281,6 +291,7 @@ function checkPrereqs() $missingExtensions[] = $info['check_module']; } } + if (count($missingExtensions) == count($dbModules)) { $req = implode(', ', $missingExtensions); printf('

          Cannot find mysql or pgsql extension. You need one or the other: %s

          ', $req); @@ -682,7 +693,7 @@ function writeConf($sitename, $server, $path, $fancy, $db) * * @return boolean - indicating success or failure */ -function runDbScript($filename, $conn, $type = 'mysql') +function runDbScript($filename, $conn, $type = 'mysqli') { $sql = trim(file_get_contents($filename)); $stmts = explode(';', $sql); @@ -693,7 +704,7 @@ function runDbScript($filename, $conn, $type = 'mysql') } // FIXME: use PEAR::DB or PDO instead of our own switch switch ($type) { - case 'mysql': + case 'mysqli': $res = mysql_query($stmt, $conn); if ($res === false) { $error = mysql_error(); -- cgit v1.2.3-54-g00ecf From 84da24aba41b459ad8b2735328e257275c0f6136 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 13 Sep 2009 21:27:34 +1200 Subject: cleaned up code style --- actions/all.php | 82 ++++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 58 insertions(+), 24 deletions(-) diff --git a/actions/all.php b/actions/all.php index 29a19afb6..e56e10c21 100644 --- a/actions/all.php +++ b/actions/all.php @@ -1,5 +1,5 @@ . + * + * @category Actions + * @package Actions + * @author Evan Prodromou + * @author Evan Prodromou + * @author Mike Cochrane + * @author Robin Millette + * @author Adrian Lang + * @author Meitar Moscovitz + * @author Sarven Capadisli + * @author Craig Andrews + * @author Evan Prodromou + * @author Evan Prodromou + * @author Jeffery To + * @author Zach Copley + * @author csarven + * @license GNU Affero General Public License http://www.gnu.org/licenses/ + * @link http://status.net */ -if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } +if (!defined('STATUSNET') && !defined('LACONICA')) { + exit(1); +} require_once INSTALLDIR.'/lib/personalgroupnav.php'; require_once INSTALLDIR.'/lib/noticelist.php'; @@ -43,8 +63,8 @@ class AllAction extends ProfileAction $this->notice = $this->user->noticesWithFriends(($this->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1); } - if($this->page > 1 && $this->notice->N == 0){ - $this->serverError(_('No such page'),$code=404); + if ($this->page > 1 && $this->notice->N == 0) { + $this->serverError(_('No such page'), $code = 404); } return true; @@ -73,20 +93,33 @@ class AllAction extends ProfileAction function getFeeds() { - return array(new Feed(Feed::RSS1, - common_local_url('allrss', array('nickname' => - $this->user->nickname)), - sprintf(_('Feed for friends of %s (RSS 1.0)'), $this->user->nickname)), - new Feed(Feed::RSS2, - common_local_url('api', array('apiaction' => 'statuses', - 'method' => 'friends_timeline', - 'argument' => $this->user->nickname.'.rss')), - sprintf(_('Feed for friends of %s (RSS 2.0)'), $this->user->nickname)), - new Feed(Feed::ATOM, - common_local_url('api', array('apiaction' => 'statuses', - 'method' => 'friends_timeline', - 'argument' => $this->user->nickname.'.atom')), - sprintf(_('Feed for friends of %s (Atom)'), $this->user->nickname))); + return array( + new Feed(Feed::RSS1, + common_local_url( + 'allrss', array( + 'nickname' => + $this->user->nickname) + ), + sprintf(_('Feed for friends of %s (RSS 1.0)'), $this->user->nickname)), + new Feed(Feed::RSS2, + common_local_url( + 'api', array( + 'apiaction' => 'statuses', + 'method' => 'friends_timeline', + 'argument' => $this->user->nickname.'.rss' + ) + ), + sprintf(_('Feed for friends of %s (RSS 2.0)'), $this->user->nickname)), + new Feed(Feed::ATOM, + common_local_url( + 'api', array( + 'apiaction' => 'statuses', + 'method' => 'friends_timeline', + 'argument' => $this->user->nickname.'.atom' + ) + ), + sprintf(_('Feed for friends of %s (Atom)'), $this->user->nickname)) + ); } function showLocalNav() @@ -106,8 +139,7 @@ class AllAction extends ProfileAction } else { $message .= sprintf(_('You can try to [nudge %s](../%s) from his profile or [post something to his or her attention](%%%%action.newnotice%%%%?status_textarea=%s).'), $this->user->nickname, $this->user->nickname, '@' . $this->user->nickname); } - } - else { + } else { $message .= sprintf(_('Why not [register an account](%%%%action.register%%%%) and then nudge %s or post a notice to his or her attention.'), $this->user->nickname); } @@ -126,17 +158,19 @@ class AllAction extends ProfileAction $this->showEmptyListMessage(); } - $this->pagination($this->page > 1, $cnt > NOTICES_PER_PAGE, - $this->page, 'all', array('nickname' => $this->user->nickname)); + $this->pagination( + $this->page > 1, $cnt > NOTICES_PER_PAGE, + $this->page, 'all', array('nickname' => $this->user->nickname) + ); } function showPageTitle() { $user =& common_current_user(); if ($user && ($user->id == $this->user->id)) { - $this->element('h1', NULL, _("You and friends")); + $this->element('h1', null, _("You and friends")); } else { - $this->element('h1', NULL, sprintf(_('%s and friends'), $this->user->nickname)); + $this->element('h1', null, sprintf(_('%s and friends'), $this->user->nickname)); } } -- cgit v1.2.3-54-g00ecf From fcff85bb3610a0f2a77bfa72cf26ce8019ec0378 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 13 Sep 2009 21:55:45 +1200 Subject: code style cleanup --- actions/api.php | 106 ++++++++++++++++++++++++++++++++------------------------ 1 file changed, 61 insertions(+), 45 deletions(-) diff --git a/actions/api.php b/actions/api.php index c236378bc..9b5f54807 100644 --- a/actions/api.php +++ b/actions/api.php @@ -1,5 +1,5 @@ . + * + * @category Actions + * @package Actions + * @author Evan Prodromou + * @author Evan Prodromou + * @author Brenda Wallace + * @author Jeffery To + * @author Robin Millette + * @author Tom Adams + * @author Christopher Vollick + * @author CiaranG + * @author Craig Andrews + * @author Evan Prodromou + * @author Evan Prodromou + * @author Gina Haeussge + * @author Mike Cochrane + * @author Sarven Capadisli + * @license GNU Affero General Public License http://www.gnu.org/licenses/ + * @link http://status.net */ -if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } +if (!defined('STATUSNET') && !defined('LACONICA')) { + exit(1); +} class ApiAction extends Action { @@ -37,7 +58,7 @@ class ApiAction extends Action $this->api_action = $this->arg('apiaction'); $method = $this->arg('method'); $argument = $this->arg('argument'); - $this->basic_auth_process_header(); + $this->basic_auth_process_header(); if (isset($argument)) { $cmdext = explode('.', $argument); @@ -46,7 +67,7 @@ class ApiAction extends Action $this->content_type = strtolower($cmdext[1]); } else { - # Requested format / content-type will be an extension on the method + //Requested format / content-type will be an extension on the method $cmdext = explode('.', $method); $this->api_method = $cmdext[0]; $this->content_type = strtolower($cmdext[1]); @@ -55,10 +76,10 @@ class ApiAction extends Action if ($this->requires_auth()) { if (!isset($this->auth_user)) { - # This header makes basic auth go + //This header makes basic auth go header('WWW-Authenticate: Basic realm="StatusNet API"'); - # If the user hits cancel -- bam! + //If the user hits cancel -- bam! $this->show_basic_auth_error(); } else { $nickname = $this->auth_user; @@ -69,7 +90,7 @@ class ApiAction extends Action $this->user = $user; $this->process_command(); } else { - # basic authentication failed + //basic authentication failed list($proxy, $ip) = common_client_ip(); common_log(LOG_WARNING, "Failed API auth attempt, nickname = $nickname, proxy = $proxy, ip = $ip."); @@ -84,7 +105,7 @@ class ApiAction extends Action if ($user) { $this->user = $user; } - # Twitter doesn't throw an error if the user isn't found + //Twitter doesn't throw an error if the user isn't found } $this->process_command(); @@ -97,7 +118,7 @@ class ApiAction extends Action $actionfile = INSTALLDIR."/actions/$action.php"; if (file_exists($actionfile)) { - require_once($actionfile); + include_once $actionfile; $action_class = ucfirst($action)."Action"; $action_obj = new $action_class(); @@ -113,10 +134,10 @@ class ApiAction extends Action call_user_func(array($action_obj, $this->api_method), $_REQUEST, $apidata); } else { - $this->clientError("API method not found!", $code=404); + $this->clientError("API method not found!", $code = 404); } } else { - $this->clientError("API method not found!", $code=404); + $this->clientError("API method not found!", $code = 404); } } @@ -184,10 +205,11 @@ class ApiAction extends Action $user_id = $this->arg('user_id'); $screen_name = $this->arg('screen_name'); - if (empty($this->api_arg) && - empty($id) && - empty($user_id) && - empty($screen_name)) { + if (empty($this->api_arg) + && empty($id) + && empty($user_id) + && empty($screen_name) + ) { return true; } else { return false; @@ -208,35 +230,29 @@ class ApiAction extends Action function basic_auth_process_header() { - if(isset($_SERVER['AUTHORIZATION']) || isset($_SERVER['HTTP_AUTHORIZATION'])) - { - $authorization_header = isset($_SERVER['HTTP_AUTHORIZATION'])?$_SERVER['HTTP_AUTHORIZATION']:$_SERVER['AUTHORIZATION']; - } - - if(isset($_SERVER['PHP_AUTH_USER'])) - { - $this->auth_user = $_SERVER['PHP_AUTH_USER']; - $this->auth_pw = $_SERVER['PHP_AUTH_PW']; - } - elseif ( isset($authorization_header) && strstr(substr($authorization_header, 0,5),'Basic') ) - { - // decode the HTTP_AUTHORIZATION header on php-cgi server self - // on fcgid server the header name is AUTHORIZATION - - $auth_hash = base64_decode( substr($authorization_header, 6) ); - list($this->auth_user, $this->auth_pw) = explode(':', $auth_hash); - - // set all to NULL on a empty basic auth request - if($this->auth_user == "") { - $this->auth_user = NULL; - $this->auth_pw = NULL; - } - } - else - { - $this->auth_user = NULL; - $this->auth_pw = NULL; - } + if (isset($_SERVER['AUTHORIZATION']) || isset($_SERVER['HTTP_AUTHORIZATION'])) { + $authorization_header = isset($_SERVER['HTTP_AUTHORIZATION'])? $_SERVER['HTTP_AUTHORIZATION'] : $_SERVER['AUTHORIZATION']; + } + + if (isset($_SERVER['PHP_AUTH_USER'])) { + $this->auth_user = $_SERVER['PHP_AUTH_USER']; + $this->auth_pw = $_SERVER['PHP_AUTH_PW']; + } elseif (isset($authorization_header) && strstr(substr($authorization_header, 0, 5), 'Basic')) { + // decode the HTTP_AUTHORIZATION header on php-cgi server self + // on fcgid server the header name is AUTHORIZATION + + $auth_hash = base64_decode(substr($authorization_header, 6)); + list($this->auth_user, $this->auth_pw) = explode(':', $auth_hash); + + // set all to null on a empty basic auth request + if ($this->auth_user == "") { + $this->auth_user = null; + $this->auth_pw = null; + } + } else { + $this->auth_user = null; + $this->auth_pw = null; + } } function show_basic_auth_error() @@ -252,7 +268,7 @@ class ApiAction extends Action $this->element('request', null, $_SERVER['REQUEST_URI']); $this->elementEnd('hash'); $this->endXML(); - } else if ($this->content_type == 'json') { + } else if ($this->content_type == 'json') { header('Content-Type: application/json; charset=utf-8'); $error_array = array('error' => $msg, 'request' => $_SERVER['REQUEST_URI']); print(json_encode($error_array)); -- cgit v1.2.3-54-g00ecf From 5bad7040b14bf61d84cc33c8b4cf2af3b5861d3b Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Mon, 14 Sep 2009 22:08:17 +0200 Subject: Fix bad merge d7ae0ed4fd755ebad0788a17d0f2fb6a6ca9d63b --- lib/omb.php | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/lib/omb.php b/lib/omb.php index 9133af7a0..0566701ff 100644 --- a/lib/omb.php +++ b/lib/omb.php @@ -80,14 +80,9 @@ function omb_broadcast_notice($notice) $posted = array(); while ($rp->fetch()) { - if (!array_key_exists($rp->postnoticeurl, $posted)) { - common_log(LOG_DEBUG, 'Posting to ' . $rp->postnoticeurl); - if (omb_post_notice_keys($notice, $rp->postnoticeurl, $rp->token, $rp->secret)) { - common_log(LOG_DEBUG, 'Finished to ' . $rp->postnoticeurl); - $posted[$rp->postnoticeurl] = true; - } else { - common_log(LOG_DEBUG, 'Failed posting to ' . $rp->postnoticeurl); - } + if (isset($posted[$rp->postnoticeurl])) { + /* We already posted to this url. */ + continue; } common_debug('Posting to ' . $rp->postnoticeurl, __FILE__); -- cgit v1.2.3-54-g00ecf From 4081ed79b02fd06f7c347803478e1f835311c2ab Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Tue, 15 Sep 2009 12:59:32 -0700 Subject: Make it impossible to delete self-subscriptions via the API --- actions/twitapifriendships.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/actions/twitapifriendships.php b/actions/twitapifriendships.php index f2ea46910..eea8945c3 100644 --- a/actions/twitapifriendships.php +++ b/actions/twitapifriendships.php @@ -99,6 +99,12 @@ class TwitapifriendshipsAction extends TwitterapiAction $other = $this->get_profile($id); $user = $apidata['user']; // Alwyas the auth user + if ($user->id == $other->id) { + $this->clientError(_("You cannot unfollow yourself!"), + 403, $apidata['content-type']); + return; + } + $sub = new Subscription(); $sub->subscriber = $user->id; $sub->subscribed = $other->id; -- cgit v1.2.3-54-g00ecf