summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/action.php84
-rw-r--r--lib/common.php7
-rw-r--r--lib/galleryaction.php7
-rw-r--r--lib/groupminilist.php7
-rw-r--r--lib/jabber.php57
-rw-r--r--lib/language.php30
-rw-r--r--lib/logingroupnav.php20
-rw-r--r--lib/mail.php10
-rw-r--r--lib/mailbox.php3
-rw-r--r--lib/messageform.php10
-rw-r--r--lib/noticeform.php9
-rw-r--r--lib/noticelist.php9
-rw-r--r--lib/openid.php4
-rw-r--r--lib/ping.php85
-rw-r--r--lib/profileaction.php242
-rw-r--r--lib/profilelist.php22
-rw-r--r--lib/profileminilist.php2
-rw-r--r--lib/router.php43
-rw-r--r--lib/rssaction.php18
-rw-r--r--lib/search_engines.php34
-rw-r--r--lib/searchaction.php26
-rw-r--r--lib/settingsaction.php4
-rw-r--r--lib/twitter.php221
-rw-r--r--lib/twitterapi.php30
-rw-r--r--lib/util.php65
25 files changed, 772 insertions, 277 deletions
diff --git a/lib/action.php b/lib/action.php
index 45ce56ac0..cc98d4445 100644
--- a/lib/action.php
+++ b/lib/action.php
@@ -97,9 +97,18 @@ class Action extends HTMLOutputter // lawsuit
$this->startHTML();
Event::handle('EndShowHTML', array($this));
}
+ if (Event::handle('StartShowHead', array($this))) {
$this->showHead();
+ Event::handle('EndShowHead', array($this));
+ }
+ if (Event::handle('StartShowBody', array($this))) {
$this->showBody();
+ Event::handle('EndShowBody', array($this));
+ }
+ if (Event::handle('StartEndHTML', array($this))) {
$this->endHTML();
+ Event::handle('EndEndHTML', array($this));
+ }
}
/**
@@ -112,6 +121,7 @@ class Action extends HTMLOutputter // lawsuit
// XXX: attributes (profile?)
$this->elementStart('head');
$this->showTitle();
+ $this->showShortcutIcon();
$this->showStylesheets();
$this->showScripts();
$this->showOpenSearch();
@@ -148,6 +158,32 @@ class Action extends HTMLOutputter // lawsuit
}
/**
+ * Show themed shortcut icon
+ *
+ * @return nothing
+ */
+ function showShortcutIcon()
+ {
+ if (is_readable(INSTALLDIR . '/theme/' . common_config('site', 'theme') . '/favicon.ico')) {
+ $this->element('link', array('rel' => 'shortcut icon',
+ 'href' => theme_path('favicon.ico')));
+ } else {
+ $this->element('link', array('rel' => 'shortcut icon',
+ 'href' => common_path('favicon.ico')));
+ }
+
+ if (common_config('site', 'mobile')) {
+ if (is_readable(INSTALLDIR . '/theme/' . common_config('site', 'theme') . '/apple-touch-icon.png')) {
+ $this->element('link', array('rel' => 'apple-touch-icon',
+ 'href' => theme_path('apple-touch-icon.png')));
+ } else {
+ $this->element('link', array('rel' => 'apple-touch-icon',
+ 'href' => common_path('apple-touch-icon.png')));
+ }
+ }
+ }
+
+ /**
* Show stylesheets
*
* @return nothing
@@ -156,17 +192,12 @@ class Action extends HTMLOutputter // lawsuit
{
if (Event::handle('StartShowStyles', array($this))) {
if (Event::handle('StartShowLaconicaStyles', array($this))) {
-
$this->element('link', array('rel' => 'stylesheet',
'type' => 'text/css',
'href' => theme_path('css/display.css', 'base') . '?version=' . LACONICA_VERSION,
'media' => 'screen, projection, tv'));
$this->element('link', array('rel' => 'stylesheet',
'type' => 'text/css',
- 'href' => theme_path('css/modal.css', 'base') . '?version=' . LACONICA_VERSION,
- 'media' => 'screen, projection, tv'));
- $this->element('link', array('rel' => 'stylesheet',
- 'type' => 'text/css',
'href' => theme_path('css/display.css', null) . '?version=' . LACONICA_VERSION,
'media' => 'screen, projection, tv'));
if (common_config('site', 'mobile')) {
@@ -215,11 +246,6 @@ class Action extends HTMLOutputter // lawsuit
$this->element('script', array('type' => 'text/javascript',
'src' => common_path('js/jquery.form.js')),
' ');
-
- $this->element('script', array('type' => 'text/javascript',
- 'src' => common_path('js/jquery.simplemodal-1.2.2.pack.js')),
- ' ');
-
Event::handle('EndShowJQueryScripts', array($this));
}
if (Event::handle('StartShowLaconicaScripts', array($this))) {
@@ -232,14 +258,6 @@ class Action extends HTMLOutputter // lawsuit
// Frame-busting code to avoid clickjacking attacks.
$this->element('script', array('type' => 'text/javascript'),
'if (window.top !== window.self) { window.top.location.href = window.self.location.href; }');
-
- $this->element('script', array('type' => 'text/javascript',
- 'src' => common_path('js/flowplayer-3.0.5.min.js')),
- ' ');
-
- $this->element('script', array('type' => 'text/javascript',
- 'src' => common_path('js/video.js')),
- ' ');
Event::handle('EndShowLaconicaScripts', array($this));
}
Event::handle('EndShowScripts', array($this));
@@ -317,7 +335,9 @@ class Action extends HTMLOutputter // lawsuit
*/
function showBody()
{
- $this->elementStart('body', array('id' => $this->trimmed('action')));
+ $this->elementStart('body', (common_current_user()) ? array('id' => $this->trimmed('action'),
+ 'class' => 'user_in')
+ : array('id' => $this->trimmed('action')));
$this->elementStart('div', array('id' => 'wrap'));
if (Event::handle('StartShowHeader', array($this))) {
$this->showHeader();
@@ -391,13 +411,8 @@ class Action extends HTMLOutputter // lawsuit
if ($user) {
$this->menuItem(common_local_url('all', array('nickname' => $user->nickname)),
_('Home'), _('Personal profile and friends timeline'), false, 'nav_home');
- }
- $this->menuItem(common_local_url('peoplesearch'),
- _('Search'), _('Search for people or text'), false, 'nav_search');
- if ($user) {
$this->menuItem(common_local_url('profilesettings'),
_('Account'), _('Change your email, avatar, password, profile'), false, 'nav_account');
-
if (common_config('xmpp', 'enabled')) {
$this->menuItem(common_local_url('imsettings'),
_('Connect'), _('Connect to IM, SMS, Twitter'), false, 'nav_connect');
@@ -405,20 +420,28 @@ class Action extends HTMLOutputter // lawsuit
$this->menuItem(common_local_url('smssettings'),
_('Connect'), _('Connect to SMS, Twitter'), false, 'nav_connect');
}
+ $this->menuItem(common_local_url('invite'),
+ _('Invite'),
+ sprintf(_('Invite friends and colleagues to join you on %s'),
+ common_config('site', 'name')),
+ false, 'nav_invitecontact');
$this->menuItem(common_local_url('logout'),
_('Logout'), _('Logout from the site'), false, 'nav_logout');
- } else {
- $this->menuItem(common_local_url('login'),
- _('Login'), _('Login to the site'), false, 'nav_login');
+ }
+ else {
if (!common_config('site', 'closed')) {
$this->menuItem(common_local_url('register'),
_('Register'), _('Create an account'), false, 'nav_register');
}
$this->menuItem(common_local_url('openidlogin'),
_('OpenID'), _('Login with OpenID'), false, 'nav_openid');
+ $this->menuItem(common_local_url('login'),
+ _('Login'), _('Login to the site'), false, 'nav_login');
}
$this->menuItem(common_local_url('doc', array('title' => 'help')),
_('Help'), _('Help me!'), false, 'nav_help');
+ $this->menuItem(common_local_url('peoplesearch'),
+ _('Search'), _('Search for people or text'), false, 'nav_search');
Event::handle('EndPrimaryNav', array($this));
}
$this->elementEnd('ul');
@@ -595,7 +618,10 @@ class Action extends HTMLOutputter // lawsuit
{
$this->elementStart('div', array('id' => 'aside_primary',
'class' => 'aside'));
+ if (Event::handle('StartShowExportData', array($this))) {
$this->showExportData();
+ Event::handle('EndShowExportData', array($this));
+ }
if (Event::handle('StartShowSections', array($this))) {
$this->showSections();
Event::handle('EndShowSections', array($this));
@@ -910,11 +936,15 @@ class Action extends HTMLOutputter // lawsuit
*
* @return string current URL
*/
+
function selfUrl()
{
$action = $this->trimmed('action');
$args = $this->args;
unset($args['action']);
+ if (array_key_exists('submit', $args)) {
+ unset($args['submit']);
+ }
foreach (array_keys($_COOKIE) as $cookie) {
unset($args[$cookie]);
}
diff --git a/lib/common.php b/lib/common.php
index 7739d9475..b3882d207 100644
--- a/lib/common.php
+++ b/lib/common.php
@@ -19,7 +19,7 @@
if (!defined('LACONICA')) { exit(1); }
-define('LACONICA_VERSION', '0.7.1');
+define('LACONICA_VERSION', '0.7.3');
define('AVATAR_PROFILE_SIZE', 96);
define('AVATAR_STREAM_SIZE', 48);
@@ -87,6 +87,8 @@ $config =
'closed' => false,
'inviteonly' => false,
'private' => false,
+ 'ssl' => 'never',
+ 'sslserver' => null,
'dupelimit' => 60), # default for same person saying the same thing
'syslog' =>
array('appname' => 'laconica', # for syslog
@@ -151,6 +153,9 @@ $config =
array('notify' => array()),
'inboxes' =>
array('enabled' => true), # on by default for new sites
+ 'newuser' =>
+ array('subscribe' => null,
+ 'welcome' => null),
);
$config['db'] = &PEAR::getStaticProperty('DB_DataObject','options');
diff --git a/lib/galleryaction.php b/lib/galleryaction.php
index 25a5e3fd5..8e21d7393 100644
--- a/lib/galleryaction.php
+++ b/lib/galleryaction.php
@@ -50,7 +50,7 @@ class GalleryAction extends Action
if ($this->arg('page') && $this->arg('page') != 1) {
$args['page'] = $this->arg['page'];
}
- common_redirect(common_local_url('subscriptions', $args), 301);
+ common_redirect(common_local_url($this->trimmed('action'), $args), 301);
return false;
}
@@ -71,6 +71,7 @@ class GalleryAction extends Action
$this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
$this->tag = $this->trimmed('tag');
+ $this->q = $this->trimmed('q');
return true;
}
@@ -87,7 +88,7 @@ class GalleryAction extends Action
# Post from the tag dropdown; redirect to a GET
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
- common_redirect($this->selfUrl(), 307);
+ common_redirect($this->selfUrl(), 303);
return;
}
@@ -136,7 +137,7 @@ class GalleryAction extends Action
'method' => 'post'));
$this->dropdown('tag', _('Tag'), $content,
_('Choose a tag to narrow list'), false, $tag);
- $this->submit('go', _('Go'));
+ $this->submit('submit', _('Go'));
$this->elementEnd('form');
$this->elementEnd('li');
$this->elementEnd('ul');
diff --git a/lib/groupminilist.php b/lib/groupminilist.php
index fe38d0340..ae2d237f1 100644
--- a/lib/groupminilist.php
+++ b/lib/groupminilist.php
@@ -33,7 +33,7 @@ if (!defined('LACONICA')) {
require_once INSTALLDIR.'/lib/grouplist.php';
-define('GROUPS_PER_MINILIST', 80);
+define('GROUPS_PER_MINILIST', 27);
/**
* Widget to show a list of groups, good for sidebar
@@ -75,8 +75,9 @@ class GroupMiniList extends GroupList
'href' => $this->group->homeUrl(),
'rel' => 'contact group',
'class' => 'url'));
- $logo = ($this->group->stream_logo) ?
- $this->group->stream_logo : User_group::defaultLogo(AVATAR_STREAM_SIZE);
+
+ $logo = ($this->group->mini_logo) ?
+ $this->group->mini_logo : User_group::defaultLogo(AVATAR_MINI_SIZE);
$this->out->element('img', array('src' => $logo,
'width' => AVATAR_MINI_SIZE,
diff --git a/lib/jabber.php b/lib/jabber.php
index 3cd3b0d37..7d584ad01 100644
--- a/lib/jabber.php
+++ b/lib/jabber.php
@@ -163,50 +163,25 @@ function jabber_send_notice($to, $notice)
function jabber_format_entry($profile, $notice)
{
- // FIXME: notice url might be remote
-
- $noticeurl = common_local_url('shownotice',
- array('notice' => $notice->id));
-
- $msg = jabber_format_notice($profile, $notice);
-
- $self_url = common_local_url('userrss', array('nickname' => $profile->nickname));
-
- $entry = "\n<entry xmlns='http://www.w3.org/2005/Atom'>\n";
- $entry .= "<source>\n";
- $entry .= "<title>" . $profile->nickname . " - " . common_config('site', 'name') . "</title>\n";
- $entry .= "<link href='" . htmlspecialchars($profile->profileurl) . "'/>\n";
- $entry .= "<link rel='self' type='application/rss+xml' href='" . $self_url . "'/>\n";
- $entry .= "<author><name>" . $profile->nickname . "</name></author>\n";
- $entry .= "<icon>" . $profile->avatarUrl(AVATAR_PROFILE_SIZE) . "</icon>\n";
- $entry .= "</source>\n";
- $entry .= "<title>" . htmlspecialchars($msg) . "</title>\n";
- $entry .= "<summary>" . htmlspecialchars($msg) . "</summary>\n";
- $entry .= "<link rel='alternate' href='" . $noticeurl . "' />\n";
- $entry .= "<id>". $notice->uri . "</id>\n";
- $entry .= "<published>".common_date_w3dtf($notice->created)."</published>\n";
- $entry .= "<updated>".common_date_w3dtf($notice->modified)."</updated>\n";
- if ($notice->reply_to) {
- $replyurl = common_local_url('shownotice',
- array('notice' => $notice->reply_to));
- $entry .= "<link rel='related' href='" . $replyurl . "'/>\n";
+ $entry = $notice->asAtomEntry(true, true);
+
+ $xs = new XMLStringer();
+ $xs->elementStart('html', array('xmlns' => 'http://jabber.org/protocol/xhtml-im'));
+ $xs->elementStart('body', array('xmlns' => 'http://www.w3.org/1999/xhtml'));
+ $xs->element('a', array('href' => $profile->profileurl),
+ $profile->nickname);
+ $xs->text(": ");
+ if (!empty($notice->rendered)) {
+ $xs->raw($notice->rendered);
+ } else {
+ $xs->raw(common_render_content($notice->content, $notice));
}
- $entry .= "</entry>\n";
-
- $html = "\n<html xmlns='http://jabber.org/protocol/xhtml-im'>\n";
- $html .= "<body xmlns='http://www.w3.org/1999/xhtml'>\n";
- $html .= "<a href='".htmlspecialchars($profile->profileurl)."'>".$profile->nickname."</a>: ";
- $html .= ($notice->rendered) ? $notice->rendered : common_render_content($notice->content, $notice);
- $html .= "\n</body>\n";
- $html .= "\n</html>\n";
-
- $address = "<addresses xmlns='http://jabber.org/protocol/address'>\n";
- $address .= "<address type='replyto' jid='" . jabber_daemon_address() . "' />\n";
- $address .= "</addresses>\n";
+ $xs->elementEnd('body');
+ $xs->elementEnd('html');
- // FIXME: include a pubsub event, too.
+ $html = $xs->getString();
- return $html . $entry . $address;
+ return $html . ' ' . $entry;
}
/**
diff --git a/lib/language.php b/lib/language.php
index 79e9030ae..cd6498d30 100644
--- a/lib/language.php
+++ b/lib/language.php
@@ -104,33 +104,33 @@ function get_all_languages() {
'bg' => array('q' => 0.8, 'lang' => 'bg_BG', 'name' => 'Bulgarian', 'direction' => 'ltr'),
'ca' => array('q' => 0.5, 'lang' => 'ca_ES', 'name' => 'Catalan', 'direction' => 'ltr'),
'cs' => array('q' => 0.5, 'lang' => 'cs_CZ', 'name' => 'Czech', 'direction' => 'ltr'),
- 'de' => array('q' => 0.5, 'lang' => 'de_DE', 'name' => 'German', 'direction' => 'ltr'),
+ 'de' => array('q' => 0.8, 'lang' => 'de_DE', 'name' => 'German', 'direction' => 'ltr'),
'el' => array('q' => 0.1, 'lang' => 'el', 'name' => 'Greek', 'direction' => 'ltr'),
'en-us' => array('q' => 1, 'lang' => 'en_US', 'name' => 'English (US)', 'direction' => 'ltr'),
- 'en-gb' => array('q' => 0.3, 'lang' => 'en_GB', 'name' => 'English (British)', 'direction' => 'ltr'),
+ 'en-gb' => array('q' => 1, 'lang' => 'en_GB', 'name' => 'English (British)', 'direction' => 'ltr'),
'en' => array('q' => 1, 'lang' => 'en', 'name' => 'English', 'direction' => 'ltr'),
- 'es' => array('q' => 0.5, 'lang' => 'es', 'name' => 'Spanish', 'direction' => 'ltr'),
- 'fi' => array('q' => 0.5, 'lang' => 'fi', 'name' => 'Finnish', 'direction' => 'ltr'),
- 'fr-fr' => array('q' => 0.2, 'lang' => 'fr_FR', 'name' => 'French', 'direction' => 'ltr'),
+ 'es' => array('q' => 1, 'lang' => 'es', 'name' => 'Spanish', 'direction' => 'ltr'),
+ 'fi' => array('q' => 1, 'lang' => 'fi', 'name' => 'Finnish', 'direction' => 'ltr'),
+ 'fr-fr' => array('q' => 1, 'lang' => 'fr_FR', 'name' => 'French', 'direction' => 'ltr'),
'he' => array('q' => 0.5, 'lang' => 'he_IL', 'name' => 'Hebrew', 'direction' => 'rtl'),
- 'it' => array('q' => 0.9, 'lang' => 'it_IT', 'name' => 'Italian', 'direction' => 'ltr'),
+ 'it' => array('q' => 1, 'lang' => 'it_IT', 'name' => 'Italian', 'direction' => 'ltr'),
'jp' => array('q' => 0.5, 'lang' => 'ja_JP', 'name' => 'Japanese', 'direction' => 'ltr'),
-# 'ko' => array('q' => 0, 'lang' => 'ko', 'name' => 'Korean', 'direction' => 'ltr'),
+ 'ko' => array('q' => 0.9, 'lang' => 'ko_KR', 'name' => 'Korean', 'direction' => 'ltr'),
'mk' => array('q' => 0.5, 'lang' => 'mk_MK', 'name' => 'Macedonian', 'direction' => 'ltr'),
'nb' => array('q' => 0.1, 'lang' => 'nb_NO', 'name' => 'Norwegian (Bokmål)', 'direction' => 'ltr'),
'no' => array('q' => 0.1, 'lang' => 'nb_NO', 'name' => 'Norwegian (Bokmål)', 'direction' => 'ltr'),
- 'nn' => array('q' => 0.1, 'lang' => 'nn_NO', 'name' => 'Norwegian (Nynorsk)', 'direction' => 'ltr'),
+ 'nn' => array('q' => 1, 'lang' => 'nn_NO', 'name' => 'Norwegian (Nynorsk)', 'direction' => 'ltr'),
'nl' => array('q' => 0.5, 'lang' => 'nl_NL', 'name' => 'Dutch', 'direction' => 'ltr'),
'pl' => array('q' => 0.5, 'lang' => 'pl_PL', 'name' => 'Polish', 'direction' => 'ltr'),
-# 'pt' => array('q' => 0, 'lang' => 'pt', 'name' => 'Portuguese', 'direction' => 'ltr'),
- 'pt-br' => array('q' => 0.7, 'lang' => 'pt_BR', 'name' => 'Portuguese Brazil', 'direction' => 'ltr'),
- 'ru' => array('q' => 0.1, 'lang' => 'ru_RU', 'name' => 'Russian', 'direction' => 'ltr'),
- 'sv' => array('q' => 0.9, 'lang' => 'sv_SE', 'name' => 'Swedish', 'direction' => 'ltr'),
+ 'pt' => array('q' => 0.1, 'lang' => 'pt', 'name' => 'Portuguese', 'direction' => 'ltr'),
+ 'pt-br' => array('q' => 0.9, 'lang' => 'pt_BR', 'name' => 'Portuguese Brazil', 'direction' => 'ltr'),
+ 'ru' => array('q' => 0.9, 'lang' => 'ru_RU', 'name' => 'Russian', 'direction' => 'ltr'),
+ 'sv' => array('q' => 0.8, 'lang' => 'sv_SE', 'name' => 'Swedish', 'direction' => 'ltr'),
'te' => array('q' => 0.3, 'lang' => 'te_IN', 'name' => 'Telugu', 'direction' => 'ltr'),
'tr' => array('q' => 0.5, 'lang' => 'tr_TR', 'name' => 'Turkish', 'direction' => 'ltr'),
- 'uk' => array('q' => 0.7, 'lang' => 'uk_UA', 'name' => 'Ukrainian', 'direction' => 'ltr'),
- 'vi' => array('q' => 0.7, 'lang' => 'vi_VN', 'name' => 'Vietnamese', 'direction' => 'ltr'),
+ 'uk' => array('q' => 1, 'lang' => 'uk_UA', 'name' => 'Ukrainian', 'direction' => 'ltr'),
+ 'vi' => array('q' => 0.8, 'lang' => 'vi_VN', 'name' => 'Vietnamese', 'direction' => 'ltr'),
'zh-cn' => array('q' => 0.9, 'lang' => 'zh_CN', 'name' => 'Chinese (Simplified)', 'direction' => 'ltr'),
- 'zh-hant' => array('q' => 0.2, 'lang' => 'zh_hant', 'name' => 'Chinese (Taiwanese)', 'direction' => 'ltr'),
+ 'zh-hant' => array('q' => 0.2, 'lang' => 'zh_TW', 'name' => 'Chinese (Taiwanese)', 'direction' => 'ltr'),
);
}
diff --git a/lib/logingroupnav.php b/lib/logingroupnav.php
index fd909581f..f23985f3a 100644
--- a/lib/logingroupnav.php
+++ b/lib/logingroupnav.php
@@ -70,16 +70,16 @@ class LoginGroupNav extends Widget
function show()
{
// action => array('prompt', 'title')
- $menu =
- array('login' =>
- array(_('Login'),
- _('Login with a username and password')),
- 'register' =>
- array(_('Register'),
- _('Sign up for a new account')),
- 'openidlogin' =>
- array(_('OpenID'),
- _('Login or register with OpenID')));
+ $menu = array();
+
+ $menu['login'] = array(_('Login'),
+ _('Login with a username and password'));
+ if (!(common_config('site','closed') || common_config('site','inviteonly'))) {
+ $menu['register'] = array(_('Register'),
+ _('Sign up for a new account'));
+ }
+ $menu['openidlogin'] = array(_('OpenID'),
+ _('Login or register with OpenID'));
$action_name = $this->action->trimmed('action');
$this->action->elementStart('ul', array('class' => 'nav'));
diff --git a/lib/mail.php b/lib/mail.php
index dde7571eb..27a1d99dc 100644
--- a/lib/mail.php
+++ b/lib/mail.php
@@ -554,17 +554,19 @@ function mail_notify_fave($other, $user, $notice)
$body = sprintf(_("%1\$s just added your notice from %2\$s".
" as one of their favorites.\n\n" .
- "In case you forgot, you can see the text".
- " of your notice here:\n\n" .
+ "The URL of your notice is:\n\n" .
"%3\$s\n\n" .
- "You can see the list of %1\$s's favorites here:\n\n" .
+ "The text of your notice is:\n\n" .
"%4\$s\n\n" .
+ "You can see the list of %1\$s's favorites here:\n\n" .
+ "%5\$s\n\n" .
"Faithfully yours,\n" .
- "%5\$s\n"),
+ "%6\$s\n"),
$bestname,
common_exact_date($notice->created),
common_local_url('shownotice',
array('notice' => $notice->id)),
+ $notice->content,
common_local_url('showfavorites',
array('nickname' => $user->nickname)),
common_config('site', 'name'));
diff --git a/lib/mailbox.php b/lib/mailbox.php
index d77234549..01bbf5721 100644
--- a/lib/mailbox.php
+++ b/lib/mailbox.php
@@ -137,6 +137,9 @@ class MailboxAction extends PersonalAction
$message->free();
unset($message);
}
+ else {
+ $this->element('p', 'guide', _('You have no private messages. You can send private message to engage other users in conversation. People can send you messages for your eyes only.'));
+ }
}
function getMessages()
diff --git a/lib/messageform.php b/lib/messageform.php
index f41508305..b8878ec1f 100644
--- a/lib/messageform.php
+++ b/lib/messageform.php
@@ -132,20 +132,14 @@ class MessageForm extends Form
$mutual_users->free();
unset($mutual_users);
- $this->out->elementStart('ul', 'form_data');
- $this->out->elementStart('li', array('id' => 'notice_to'));
$this->out->dropdown('to', _('To'), $mutual, null, false,
($this->to) ? $this->to->id : null);
- $this->out->elementEnd('li');
- $this->out->elementStart('li', array('id' => 'notice_text'));
$this->out->element('textarea', array('id' => 'notice_data-text',
'cols' => 35,
'rows' => 4,
'name' => 'content'),
($this->content) ? $this->content : '');
- $this->out->elementEnd('li');
- $this->out->elementEnd('ul');
}
/**
@@ -156,14 +150,10 @@ class MessageForm extends Form
function formActions()
{
- $this->out->elementStart('ul', 'form_actions');
- $this->out->elementStart('li', array('id' => 'notice_submit'));
$this->out->element('input', array('id' => 'notice_action-submit',
'class' => 'submit',
'name' => 'message_send',
'type' => 'submit',
'value' => _('Send')));
- $this->out->elementEnd('li');
- $this->out->elementEnd('ul');
}
}
diff --git a/lib/noticeform.php b/lib/noticeform.php
index 0c991c969..606b5d028 100644
--- a/lib/noticeform.php
+++ b/lib/noticeform.php
@@ -134,9 +134,6 @@ class NoticeForm extends Form
function formData()
{
-
- $this->out->elementStart('ul', 'form_data');
- $this->out->elementStart('li', array('id' => 'notice_text'));
$this->out->element('label', array('for' => 'notice_data-text'),
sprintf(_('What\'s up, %s?'), $this->user->nickname));
// XXX: vary by defined max size
@@ -145,8 +142,6 @@ class NoticeForm extends Form
'rows' => 4,
'name' => 'status_textarea'),
($this->content) ? $this->content : '');
- $this->out->elementEnd('li');
- $this->out->elementEnd('ul');
$this->out->elementStart('dl', 'form_note');
$this->out->element('dt', null, _('Available characters'));
@@ -168,14 +163,10 @@ class NoticeForm extends Form
function formActions()
{
- $this->out->elementStart('ul', 'form_actions');
- $this->out->elementStart('li', array('id' => 'notice_submit'));
$this->out->element('input', array('id' => 'notice_action-submit',
'class' => 'submit',
'name' => 'status_submit',
'type' => 'submit',
'value' => _('Send')));
- $this->out->elementEnd('li');
- $this->out->elementEnd('ul');
}
}
diff --git a/lib/noticelist.php b/lib/noticelist.php
index 9fc0126b3..4182d8808 100644
--- a/lib/noticelist.php
+++ b/lib/noticelist.php
@@ -258,8 +258,12 @@ class NoticeListItem extends Widget
function showAuthor()
{
$this->out->elementStart('span', 'vcard author');
- $this->out->elementStart('a', array('href' => $this->profile->profileurl,
- 'class' => 'url'));
+ $attrs = array('href' => $this->profile->profileurl,
+ 'class' => 'url');
+ if (!empty($this->profile->fullname)) {
+ $attrs['title'] = $this->profile->fullname . ' (' . $this->profile->nickname . ') ';
+ }
+ $this->out->elementStart('a', $attrs);
$this->showAvatar();
$this->showNickname();
$this->out->elementEnd('a');
@@ -387,6 +391,7 @@ class NoticeListItem extends Widget
case 'xmpp':
case 'mail':
case 'omb':
+ case 'system':
case 'api':
$this->out->element('dd', null, $source_name);
break;
diff --git a/lib/openid.php b/lib/openid.php
index 3aa488b6d..3af7a39cf 100644
--- a/lib/openid.php
+++ b/lib/openid.php
@@ -160,7 +160,7 @@ function oid_authenticate($openid_url, $returnto, $immediate=false)
$auth_request->addExtension($sreg_request);
}
- $trust_root = common_path('');
+ $trust_root = common_root_url(true);
$process_url = common_local_url($returnto);
if ($auth_request->shouldSendRedirect()) {
@@ -171,7 +171,7 @@ function oid_authenticate($openid_url, $returnto, $immediate=false)
} else if (Auth_OpenID::isFailure($redirect_url)) {
return sprintf(_('Could not redirect to server: %s'), $redirect_url->message);
} else {
- common_redirect($redirect_url);
+ common_redirect($redirect_url, 303);
}
} else {
// Generate form markup and render it.
diff --git a/lib/ping.php b/lib/ping.php
index 32c0b9806..3de541e9a 100644
--- a/lib/ping.php
+++ b/lib/ping.php
@@ -1,7 +1,7 @@
<?php
/*
* Laconica - a distributed open-source microblogging tool
- * Copyright (C) 2008, Controlez-Vous, Inc.
+ * Copyright (C) 2009, Control Yourself, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@@ -20,49 +20,92 @@
if (!defined('LACONICA')) { exit(1); }
function ping_broadcast_notice($notice) {
+
if (!$notice->is_local) {
- return;
+ return true;
}
-
+
# Array of servers, URL => type
$notify = common_config('ping', 'notify');
$profile = $notice->getProfile();
$tags = ping_notice_tags($notice);
-
+
foreach ($notify as $notify_url => $type) {
switch ($type) {
case 'xmlrpc':
case 'extended':
$req = xmlrpc_encode_request('weblogUpdates.ping',
array($profile->nickname, # site name
- common_local_url('showstream',
+ common_local_url('showstream',
array('nickname' => $profile->nickname)),
common_local_url('shownotice',
array('notice' => $notice->id)),
- common_local_url('userrss',
+ common_local_url('userrss',
array('nickname' => $profile->nickname)),
$tags));
-
- # We re-use this tool's fetcher, since it's pretty good
-
- $fetcher = Auth_Yadis_Yadis::getHTTPFetcher();
- if (!$fetcher) {
- common_log(LOG_WARNING, 'Failed to initialize Yadis fetcher.', __FILE__);
- return false;
- }
-
- $result = $fetcher->post($notify_url,
- $req);
-
+ $context = stream_context_create(array('http' => array('method' => "POST",
+ 'header' =>
+ "Content-Type: text/xml\r\n".
+ "User-Agent: Laconica/".LACONICA_VERSION."\r\n",
+ 'content' => $req)));
+ $file = file_get_contents($notify_url, false, $context);
+
+ if ($file === false || mb_strlen($file) == 0) {
+ common_log(LOG_WARNING,
+ "XML-RPC empty results for ping ($notify_url, $notice->id) ");
+ continue;
+ }
+
+ $response = xmlrpc_decode($file);
+
+ if (xmlrpc_is_fault($response)) {
+ common_log(LOG_WARNING,
+ "XML-RPC error for ping ($notify_url, $notice->id) ".
+ "$response[faultString] ($response[faultCode])");
+ } else {
+ common_log(LOG_INFO,
+ "Ping success for $notify_url $notice->id");
+ }
+ break;
+
case 'get':
- case 'post':
+ case 'post':
+ $args = array('name' => $profile->nickname,
+ 'url' => common_local_url('showstream',
+ array('nickname' => $profile->nickname)),
+ 'changesURL' => common_local_url('userrss',
+ array('nickname' => $profile->nickname)));
+
+ $fetcher = Auth_Yadis_Yadis::getHTTPFetcher();
+
+ if ($type === 'get') {
+ $result = $fetcher->get($notify_url . '?' . http_build_query($args),
+ array('User-Agent: Laconica/'.LACONICA_VERSION));
+ } else {
+ $result = $fetcher->post($notify_url,
+ http_build_query($args),
+ array('User-Agent: Laconica/'.LACONICA_VERSION));
+ }
+ if ($result->status != '200') {
+ common_log(LOG_WARNING,
+ "Ping error for '$notify_url' ($notice->id): ".
+ "$result->body");
+ } else {
+ common_log(LOG_INFO,
+ "Ping success for '$notify_url' ($notice->id): ".
+ "'$result->body'");
+ }
+ break;
+
default:
common_log(LOG_WARNING, 'Unknown notify type for ' . $notify_url . ': ' . $type);
- }
+ }
}
+
+ return true;
}
-
+
function ping_notice_tags($notice) {
$tag = new Notice_tag();
$tag->notice_id = $notice->id;
diff --git a/lib/profileaction.php b/lib/profileaction.php
new file mode 100644
index 000000000..c81924e31
--- /dev/null
+++ b/lib/profileaction.php
@@ -0,0 +1,242 @@
+<?php
+/**
+ * Laconica, the distributed open-source microblogging tool
+ *
+ * Common parent of Personal and Profile actions
+ *
+ * PHP version 5
+ *
+ * LICENCE: This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @category Personal
+ * @package Laconica
+ * @author Evan Prodromou <evan@controlyourself.ca>
+ * @author Sarven Capadisli <csarven@controlyourself.ca>
+ * @copyright 2008-2009 Control Yourself, Inc.
+ * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
+ * @link http://laconi.ca/
+ */
+
+if (!defined('LACONICA')) {
+ exit(1);
+}
+
+require_once INSTALLDIR.'/lib/profileminilist.php';
+require_once INSTALLDIR.'/lib/groupminilist.php';
+
+/**
+ * Profile action common superclass
+ *
+ * Abstracts out common code from profile and personal tabs
+ *
+ * @category Personal
+ * @package Laconica
+ * @author Evan Prodromou <evan@controlyourself.ca>
+ * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
+ * @link http://laconi.ca/
+ */
+
+class ProfileAction extends Action
+{
+ var $user = null;
+ var $page = null;
+ var $profile = null;
+
+ function prepare($args)
+ {
+ parent::prepare($args);
+
+ $nickname_arg = $this->arg('nickname');
+ $nickname = common_canonical_nickname($nickname_arg);
+
+ // Permanent redirect on non-canonical nickname
+
+ if ($nickname_arg != $nickname) {
+ $args = array('nickname' => $nickname);
+ if ($this->arg('page') && $this->arg('page') != 1) {
+ $args['page'] = $this->arg['page'];
+ }
+ common_redirect(common_local_url($this->trimmed('action'), $args), 301);
+ return false;
+ }
+
+ $this->user = User::staticGet('nickname', $nickname);
+
+ if (!$this->user) {
+ $this->clientError(_('No such user.'), 404);
+ return false;
+ }
+
+ $this->profile = $this->user->getProfile();
+
+ if (!$this->profile) {
+ $this->serverError(_('User has no profile.'));
+ return false;
+ }
+
+ $this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
+
+ common_set_returnto($this->selfUrl());
+
+ return true;
+ }
+
+ function showSections()
+ {
+ $this->showSubscriptions();
+ $this->showSubscribers();
+ $this->showGroups();
+ $this->showStatistics();
+ }
+
+ function showSubscriptions()
+ {
+ $profile = $this->user->getSubscriptions(0, PROFILES_PER_MINILIST + 1);
+
+ $this->elementStart('div', array('id' => 'entity_subscriptions',
+ 'class' => 'section'));
+
+ $this->element('h2', null, _('Subscriptions'));
+
+ if ($profile) {
+ $pml = new ProfileMiniList($profile, $this->user, $this);
+ $cnt = $pml->show();
+ if ($cnt == 0) {
+ $this->element('p', null, _('(None)'));
+ }
+ }
+
+ if ($cnt > PROFILES_PER_MINILIST) {
+ $this->elementStart('p');
+ $this->element('a', array('href' => common_local_url('subscriptions',
+ array('nickname' => $this->profile->nickname)),
+ 'class' => 'more'),
+ _('All subscriptions'));
+ $this->elementEnd('p');
+ }
+
+ $this->elementEnd('div');
+ }
+
+ function showSubscribers()
+ {
+ $profile = $this->user->getSubscribers(0, PROFILES_PER_MINILIST + 1);
+
+ $this->elementStart('div', array('id' => 'entity_subscribers',
+ 'class' => 'section'));
+
+ $this->element('h2', null, _('Subscribers'));
+
+ if ($profile) {
+ $pml = new ProfileMiniList($profile, $this->user, $this);
+ $cnt = $pml->show();
+ if ($cnt == 0) {
+ $this->element('p', null, _('(None)'));
+ }
+ }
+
+ if ($cnt > PROFILES_PER_MINILIST) {
+ $this->elementStart('p');
+ $this->element('a', array('href' => common_local_url('subscribers',
+ array('nickname' => $this->profile->nickname)),
+ 'class' => 'more'),
+ _('All subscribers'));
+ $this->elementEnd('p');
+ }
+
+ $this->elementEnd('div');
+ }
+
+ function showStatistics()
+ {
+ // XXX: WORM cache this
+ $subs = new Subscription();
+ $subs->subscriber = $this->profile->id;
+ $subs_count = (int) $subs->count() - 1;
+
+ $subbed = new Subscription();
+ $subbed->subscribed = $this->profile->id;
+ $subbed_count = (int) $subbed->count() - 1;
+
+ $notices = new Notice();
+ $notices->profile_id = $this->profile->id;
+ $notice_count = (int) $notices->count();
+
+ $this->elementStart('div', array('id' => 'entity_statistics',
+ 'class' => 'section'));
+
+ $this->element('h2', null, _('Statistics'));
+
+ // Other stats...?
+ $this->elementStart('dl', 'entity_member-since');
+ $this->element('dt', null, _('Member since'));
+ $this->element('dd', null, date('j M Y',
+ strtotime($this->profile->created)));
+ $this->elementEnd('dl');
+
+ $this->elementStart('dl', 'entity_subscriptions');
+ $this->elementStart('dt');
+ $this->element('a', array('href' => common_local_url('subscriptions',
+ array('nickname' => $this->profile->nickname))),
+ _('Subscriptions'));
+ $this->elementEnd('dt');
+ $this->element('dd', null, (is_int($subs_count)) ? $subs_count : '0');
+ $this->elementEnd('dl');
+
+ $this->elementStart('dl', 'entity_subscribers');
+ $this->elementStart('dt');
+ $this->element('a', array('href' => common_local_url('subscribers',
+ array('nickname' => $this->profile->nickname))),
+ _('Subscribers'));
+ $this->elementEnd('dt');
+ $this->element('dd', 'subscribers', (is_int($subbed_count)) ? $subbed_count : '0');
+ $this->elementEnd('dl');
+
+ $this->elementStart('dl', 'entity_notices');
+ $this->element('dt', null, _('Notices'));
+ $this->element('dd', null, (is_int($notice_count)) ? $notice_count : '0');
+ $this->elementEnd('dl');
+
+ $this->elementEnd('div');
+ }
+
+ function showGroups()
+ {
+ $groups = $this->user->getGroups(0, GROUPS_PER_MINILIST + 1);
+
+ $this->elementStart('div', array('id' => 'entity_groups',
+ 'class' => 'section'));
+
+ $this->element('h2', null, _('Groups'));
+
+ if ($groups) {
+ $gml = new GroupMiniList($groups, $this->user, $this);
+ $cnt = $gml->show();
+ if ($cnt == 0) {
+ $this->element('p', null, _('(None)'));
+ }
+ }
+
+ if ($cnt > GROUPS_PER_MINILIST) {
+ $this->elementStart('p');
+ $this->element('a', array('href' => common_local_url('usergroups',
+ array('nickname' => $this->profile->nickname)),
+ 'class' => 'more'),
+ _('All groups'));
+ $this->elementEnd('p');
+ }
+
+ $this->elementEnd('div');
+ }
+} \ No newline at end of file
diff --git a/lib/profilelist.php b/lib/profilelist.php
index 766189ab4..a4cc23555 100644
--- a/lib/profilelist.php
+++ b/lib/profilelist.php
@@ -89,7 +89,7 @@ class ProfileList extends Widget
'id' => 'profile-' . $this->profile->id));
$user = common_current_user();
- $is_own = !is_null($user) && isset($this->user) && ($user->id === $this->user->id);
+ $is_own = !is_null($user) && isset($this->owner) && ($user->id === $this->owner->id);
$this->out->elementStart('div', 'entity_profile vcard');
@@ -109,7 +109,7 @@ class ProfileList extends Widget
$this->out->elementEnd('span');
$this->out->elementEnd('a');
- if ($this->profile->fullname !== '') {
+ if (!empty($this->profile->fullname)) {
$this->out->elementStart('dl', 'entity_fn');
$this->out->element('dt', null, 'Full name');
$this->out->elementStart('dd');
@@ -119,7 +119,7 @@ class ProfileList extends Widget
$this->out->elementEnd('dd');
$this->out->elementEnd('dl');
}
- if ($this->profile->location !== '') {
+ if (!empty($this->profile->location)) {
$this->out->elementStart('dl', 'entity_location');
$this->out->element('dt', null, _('Location'));
$this->out->elementStart('dd', 'label');
@@ -127,7 +127,7 @@ class ProfileList extends Widget
$this->out->elementEnd('dd');
$this->out->elementEnd('dl');
}
- if ($this->profile->homepage !== '') {
+ if (!empty($this->profile->homepage)) {
$this->out->elementStart('dl', 'entity_url');
$this->out->element('dt', null, _('URL'));
$this->out->elementStart('dd');
@@ -138,7 +138,7 @@ class ProfileList extends Widget
$this->out->elementEnd('dd');
$this->out->elementEnd('dl');
}
- if ($this->profile->bio !== '') {
+ if (!empty($this->profile->bio)) {
$this->out->elementStart('dl', 'entity_note');
$this->out->element('dt', null, _('Note'));
$this->out->elementStart('dd', 'note');
@@ -194,11 +194,12 @@ class ProfileList extends Widget
$this->out->elementStart('ul');
- if (!$is_own) {
- # XXX: special-case for user looking at own
- # subscriptions page
+ // Is this a logged-in user, looking at someone else's
+ // profile?
+
+ if (!empty($user) && $this->profile->id != $user->id) {
$this->out->elementStart('li', 'entity_subscribe');
- if (!is_null($user) && $user->isSubscribed($this->profile)) {
+ if ($user->isSubscribed($this->profile)) {
$usf = new UnsubscribeForm($this->out, $this->profile);
$usf->show();
} else {
@@ -207,6 +208,9 @@ class ProfileList extends Widget
}
$this->out->elementEnd('li');
$this->out->elementStart('li', 'entity_block');
+ if ($user->id == $this->owner->id) {
+ $this->showBlockForm();
+ }
$this->out->elementEnd('li');
}
diff --git a/lib/profileminilist.php b/lib/profileminilist.php
index 0d466bba8..57496d0e9 100644
--- a/lib/profileminilist.php
+++ b/lib/profileminilist.php
@@ -33,7 +33,7 @@ if (!defined('LACONICA')) {
require_once INSTALLDIR.'/lib/profilelist.php';
-define('PROFILES_PER_MINILIST', 80);
+define('PROFILES_PER_MINILIST', 27);
/**
* Widget to show a list of profiles, good for sidebar
diff --git a/lib/router.php b/lib/router.php
index 50d5a4ee1..6fb2f9487 100644
--- a/lib/router.php
+++ b/lib/router.php
@@ -68,8 +68,8 @@ class Router
}
}
- function initialize() {
-
+ function initialize()
+ {
$m = Net_URL_Mapper::getInstance();
// In the "root"
@@ -107,6 +107,9 @@ class Router
$m->connect('main/'.$a, array('action' => $a));
}
+ $m->connect('main/sup/:seconds', array('action' => 'sup'),
+ array('seconds' => '[0-9]+'));
+
$m->connect('main/tagother/:id', array('action' => 'tagother'));
// these take a code
@@ -136,10 +139,17 @@ class Router
foreach (array('group', 'people', 'notice') as $s) {
$m->connect('search/'.$s, array('action' => $s.'search'));
- $m->connect('search/'.$s.'?q=:q', array('action' => $s.'search'), array('q' => '.+'));
+ $m->connect('search/'.$s.'?q=:q',
+ array('action' => $s.'search'),
+ array('q' => '.+'));
}
+ // The second of these is needed to make the link work correctly
+ // when inserted into the page. The first is needed to match the
+ // route on the way in. Seems to be another Net_URL_Mapper bug to me.
$m->connect('search/notice/rss', array('action' => 'noticesearchrss'));
+ $m->connect('search/notice/rss?q=:q', array('action' => 'noticesearchrss'),
+ array('q' => '.+'));
// notice
@@ -156,7 +166,7 @@ class Router
array('notice' => '[0-9]+'));
$m->connect('message/new', array('action' => 'newmessage'));
- $m->connect('message/new?to=:to', array('action' => 'newmessage'), array('to' => '[A-Za-z0-9_-]'));
+ $m->connect('message/new?to=:to', array('action' => 'newmessage'), array('to' => '[A-Za-z0-9_-]+'));
$m->connect('message/:message',
array('action' => 'showmessage'),
array('message' => '[0-9]+'));
@@ -259,8 +269,8 @@ class Router
foreach (array('xml', 'json', 'rss', 'atom') as $e) {
$m->connect('api/direct_messages/sent.'.$e,
array('action' => 'api',
- 'apiaction' => 'direct_messages',
- 'method' => 'sent.'.$e));
+ 'apiaction' => 'direct_messages',
+ 'method' => 'sent.'.$e));
}
$m->connect('api/direct_messages/destroy/:argument',
@@ -324,9 +334,9 @@ class Router
foreach (array('xml', 'json', 'rss', 'atom') as $e) {
$m->connect('api/favorites.'.$e,
- array('action' => 'api',
- 'apiaction' => 'favorites',
- 'method' => 'favorites.'.$e));
+ array('action' => 'api',
+ 'apiaction' => 'favorites',
+ 'method' => 'favorites.'.$e));
}
// notifications
@@ -411,7 +421,7 @@ class Router
$match = $this->m->match($path);
} catch (Net_URL_Mapper_InvalidException $e) {
common_log(LOG_ERR, "Problem getting route for $path - " .
- $e->getMessage());
+ $e->getMessage());
$cac = new ClientErrorAction("Page not found.", 404);
$cac->showPage();
}
@@ -429,6 +439,17 @@ class Router
$args = $action_arg;
}
- return $this->m->generate($args, $params, $fragment);
+ $url = $this->m->generate($args, $params, $fragment);
+
+ // Due to a bug in the Net_URL_Mapper code, the returned URL may
+ // contain a malformed query of the form ?p1=v1?p2=v2?p3=v3. We
+ // repair that here rather than modifying the upstream code...
+
+ $qpos = strpos($url, '?');
+ if ($qpos !== false) {
+ $url = substr($url, 0, $qpos+1) .
+ str_replace('?', '&', substr($url, $qpos+1));
+ }
+ return $url;
}
}
diff --git a/lib/rssaction.php b/lib/rssaction.php
index 66c2d9e8c..ddba862dc 100644
--- a/lib/rssaction.php
+++ b/lib/rssaction.php
@@ -94,11 +94,11 @@ class Rss10Action extends Action
function handle($args)
{
- // Get the list of notices
- $this->notices = $this->getNotices();
// Parent handling, including cache check
parent::handle($args);
- $this->showRss($this->limit);
+ // Get the list of notices
+ $this->notices = $this->getNotices($this->limit);
+ $this->showRss();
}
/**
@@ -132,15 +132,13 @@ class Rss10Action extends Action
return null;
}
- function showRss($limit=0)
+ function showRss()
{
- $notices = $this->getNotices($limit);
-
$this->initRss();
- $this->showChannel($notices);
+ $this->showChannel();
$this->showImage();
- foreach ($notices as $n) {
+ foreach ($this->notices as $n) {
$this->showItem($n);
}
@@ -148,7 +146,7 @@ class Rss10Action extends Action
$this->endRss();
}
- function showChannel($notices)
+ function showChannel()
{
$channel = $this->getChannel();
@@ -167,7 +165,7 @@ class Rss10Action extends Action
$this->elementStart('items');
$this->elementStart('rdf:Seq');
- foreach ($notices as $notice) {
+ foreach ($this->notices as $notice) {
$this->element('sioct:MicroblogPost', array('rdf:resource' => $notice->uri));
}
diff --git a/lib/search_engines.php b/lib/search_engines.php
index 559107910..7b9dbb618 100644
--- a/lib/search_engines.php
+++ b/lib/search_engines.php
@@ -74,7 +74,7 @@ class SphinxSearch extends SearchEngine
{
//FIXME without LARGEST_POSSIBLE, the most recent results aren't returned
// this probably has a large impact on performance
- $LARGEST_POSSIBLE = 1e6;
+ $LARGEST_POSSIBLE = 1e6;
if ($rss) {
$this->sphinx->setLimits($offset, $count, $count, $LARGEST_POSSIBLE);
@@ -109,12 +109,25 @@ class MySQLSearch extends SearchEngine
{
function query($q)
{
- if ('identica_people' === $this->table)
- return $this->target->whereAdd('MATCH(nickname, fullname, location, bio, homepage) ' .
- 'against (\''.addslashes($q).'\')');
- if ('identica_notices' === $this->table)
- return $this->target->whereAdd('MATCH(content) ' .
- 'against (\''.addslashes($q).'\')');
+ if ('identica_people' === $this->table) {
+ $this->target->whereAdd('MATCH(nickname, fullname, location, bio, homepage) ' .
+ 'AGAINST (\''.addslashes($q).'\' IN BOOLEAN MODE)');
+ if (strtolower($q) != $q) {
+ $this->target->whereAdd('MATCH(nickname, fullname, location, bio, homepage) ' .
+ 'AGAINST (\''.addslashes(strtolower($q)).'\' IN BOOLEAN MODE)', 'OR');
+ }
+ return true;
+ } else if ('identica_notices' === $this->table) {
+ $this->target->whereAdd('MATCH(content) ' .
+ 'AGAINST (\''.addslashes($q).'\' IN BOOLEAN MODE)');
+ if (strtolower($q) != $q) {
+ $this->target->whereAdd('MATCH(content) ' .
+ 'AGAINST (\''.addslashes(strtolower($q)).'\' IN BOOLEAN MODE)', 'OR');
+ }
+ return true;
+ } else {
+ throw new ServerException('Unknown table: ' . $this->table);
+ }
}
}
@@ -122,10 +135,13 @@ class PGSearch extends SearchEngine
{
function query($q)
{
- if ('identica_people' === $this->table)
+ if ('identica_people' === $this->table) {
return $this->target->whereAdd('textsearch @@ plainto_tsquery(\''.addslashes($q).'\')');
- if ('identica_notices' === $this->table)
+ } else if ('identica_notices' === $this->table) {
return $this->target->whereAdd('to_tsvector(\'english\', content) @@ plainto_tsquery(\''.addslashes($q).'\')');
+ } else {
+ throw new ServerException('Unknown table: ' . $this->table);
+ }
}
}
diff --git a/lib/searchaction.php b/lib/searchaction.php
index c762db16f..e7ad4affd 100644
--- a/lib/searchaction.php
+++ b/lib/searchaction.php
@@ -133,5 +133,31 @@ class SearchAction extends Action
$this->showResults($q, $page);
}
}
+
+ function searchSuggestions($q) {
+ $qe = urlencode($q);
+ $message = sprintf(_(<<<E_O_T
+* Make sure all words are spelled correctly.
+* Try different keywords.
+* Try more general keywords.
+* Try fewer keywords.
+
+You can also try your search on other engines:
+
+* [Twingly](http://www.twingly.com/search?q=%s&content=microblog&site=identi.ca)
+* [Tweet scan](http://www.tweetscan.com/indexi.php?s=%s)
+* [Google](http://www.google.com/search?q=site%%3A%%%%site.server%%%%+%s)
+* [Yahoo](http://search.yahoo.com/search?p=site%%3A%%%%site.server%%%%+%s)
+
+
+E_O_T
+), $qe, $qe, $qe, $qe);
+ $this->elementStart('dl', array('id' => 'help_search', 'class' => 'help'));
+ $this->element('dt', null, _('Search help'));
+ $this->elementStart('dd', 'instructions');
+ $this->raw(common_markup_to_html($message));
+ $this->elementEnd('dd');
+ $this->elementEnd('div');
+ }
}
diff --git a/lib/settingsaction.php b/lib/settingsaction.php
index 53c807c6f..db20c5804 100644
--- a/lib/settingsaction.php
+++ b/lib/settingsaction.php
@@ -78,9 +78,9 @@ class SettingsAction extends Action
common_set_returnto($this->selfUrl());
$user = common_current_user();
if ($user->hasOpenID()) {
- common_redirect(common_local_url('openidlogin'));
+ common_redirect(common_local_url('openidlogin'), 303);
} else {
- common_redirect(common_local_url('login'));
+ common_redirect(common_local_url('login'), 303);
}
} else if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$this->handlePost();
diff --git a/lib/twitter.php b/lib/twitter.php
index 7abb40151..ccc6c93ca 100644
--- a/lib/twitter.php
+++ b/lib/twitter.php
@@ -19,7 +19,7 @@
if (!defined('LACONICA')) { exit(1); }
-define("TWITTER_SERVICE", 1); // Twitter is foreign_service ID 1
+define('TWITTER_SERVICE', 1); // Twitter is foreign_service ID 1
function get_twitter_data($uri, $screen_name, $password)
{
@@ -45,6 +45,10 @@ function get_twitter_data($uri, $screen_name, $password)
if ($errmsg) {
common_debug("Twitter bridge - cURL error: $errmsg - trying to load: $uri with user $screen_name.",
__FILE__);
+
+ if (defined('SCRIPT_DEBUG')) {
+ print "cURL error: $errmsg - trying to load: $uri with user $screen_name.\n";
+ }
}
curl_close($ch);
@@ -52,63 +56,141 @@ function get_twitter_data($uri, $screen_name, $password)
return $data;
}
-function twitter_user_info($screen_name, $password)
+function twitter_json_data($uri, $screen_name, $password)
{
+ $json_data = get_twitter_data($uri, $screen_name, $password);
- $uri = "http://twitter.com/users/show/$screen_name.json";
- $data = get_twitter_data($uri, $screen_name, $password);
-
- if (!$data) {
+ if (!$json_data) {
return false;
}
- $twit_user = json_decode($data);
+ $data = json_decode($json_data);
- if (!$twit_user) {
+ if (!$data) {
return false;
}
- return $twit_user;
+ return $data;
}
-function update_twitter_user($fuser, $twitter_id, $screen_name)
+function twitter_user_info($screen_name, $password)
{
+ $uri = "http://twitter.com/users/show/$screen_name.json";
+ return twitter_json_data($uri, $screen_name, $password);
+}
- $original = clone($fuser);
- $fuser->nickname = $screen_name;
- $fuser->uri = 'http://twitter.com/' . $screen_name;
- $result = $fuser->updateKeys($original);
+function twitter_friends_ids($screen_name, $password)
+{
+ $uri = "http://twitter.com/friends/ids/$screen_name.json";
+ return twitter_json_data($uri, $screen_name, $password);
+}
+
+function update_twitter_user($twitter_id, $screen_name)
+{
+ $uri = 'http://twitter.com/' . $screen_name;
+
+ $fuser = new Foreign_user();
+
+ $fuser->query('BEGIN');
+
+ // Dropping down to SQL because regular db_object udpate stuff doesn't seem
+ // to work so good with tables that have multiple column primary keys
+
+ // Any time we update the uri for a forein user we have to make sure there
+ // are no dupe entries first -- unique constraint on the uri column
+
+ $qry = 'UPDATE foreign_user set uri = \'\' WHERE uri = ';
+ $qry .= '\'' . $uri . '\'' . ' AND service = ' . TWITTER_SERVICE;
+
+ $result = $fuser->query($qry);
+
+ if ($result) {
+ common_debug("Removed uri ($uri) from another foreign_user who was squatting on it.");
+ if (defined('SCRIPT_DEBUG')) {
+ print("Removed uri ($uri) from another Twitter user who was squatting on it.\n");
+ }
+ }
+
+ // Update the user
+ $qry = 'UPDATE foreign_user SET nickname = ';
+ $qry .= '\'' . $screen_name . '\'' . ', uri = \'' . $uri . '\' ';
+ $qry .= 'WHERE id = ' . $twitter_id . ' AND service = ' . TWITTER_SERVICE;
+
+ $result = $fuser->query($qry);
if (!$result) {
+ common_log(LOG_WARNING,
+ "Couldn't update foreign_user data for Twitter user: $screen_name");
common_log_db_error($fuser, 'UPDATE', __FILE__);
+ if (defined('SCRIPT_DEBUG')) {
+ print "UPDATE failed: for Twitter user: $twitter_id - $screen_name. - ";
+ print common_log_objstring($fuser) . "\n";
+ $error = &PEAR::getStaticProperty('DB_DataObject','lastError');
+ print "DB_DataObject Error: " . $error->getMessage() . "\n";
+ }
return false;
}
+ $fuser->query('COMMIT');
+
+ $fuser->free();
+ unset($fuser);
+
return true;
}
function add_twitter_user($twitter_id, $screen_name)
{
+ $new_uri = 'http://twitter.com/' . $screen_name;
+
+ // Clear out any bad old foreign_users with the new user's legit URL
+ // This can happen when users move around or fakester accounts get
+ // repoed, and things like that.
+ $luser = new Foreign_user();
+ $luser->uri = $new_uri;
+ $luser->service = TWITTER_SERVICE;
+ $result = $luser->delete();
+
+ if ($result) {
+ common_log(LOG_WARNING,
+ "Twitter bridge - removed invalid Twitter user squatting on uri: $new_uri");
+ if (defined('SCRIPT_DEBUG')) {
+ print "Removed invalid Twitter user squatting on uri: $new_uri\n";
+ }
+ }
+
+ $luser->free();
+ unset($luser);
+
// Otherwise, create a new Twitter user
- $fuser = DB_DataObject::factory('foreign_user');
+ $fuser = new Foreign_user();
$fuser->nickname = $screen_name;
$fuser->uri = 'http://twitter.com/' . $screen_name;
$fuser->id = $twitter_id;
- $fuser->service = TWITTER_SERVICE; // Twitter
+ $fuser->service = TWITTER_SERVICE;
$fuser->created = common_sql_now();
$result = $fuser->insert();
if (!$result) {
- common_debug("Twitter bridge - failed to add new Twitter user: $twitter_id - $screen_name.");
+ common_log(LOG_WARNING,
+ "Twitter bridge - failed to add new Twitter user: $twitter_id - $screen_name.");
common_log_db_error($fuser, 'INSERT', __FILE__);
- return false;
+ if (defined('SCRIPT_DEBUG')) {
+ print "INSERT failed: could not add new Twitter user: $twitter_id - $screen_name. - ";
+ print common_log_objstring($fuser) . "\n";
+ $error = &PEAR::getStaticProperty('DB_DataObject','lastError');
+ print "DB_DataObject Error: " . $error->getMessage() . "\n";
+ }
+ } else {
+ common_debug("Twitter bridge - Added new Twitter user: $screen_name ($twitter_id).");
+ if (defined('SCRIPT_DEBUG')) {
+ print "Added new Twitter user: $screen_name ($twitter_id).\n";
+ }
}
- common_debug("Twitter bridge - Added new Twitter user: $screen_name ($twitter_id).");
-
- return true;
+ return $result;
}
// Creates or Updates a Twitter user
@@ -117,53 +199,87 @@ function save_twitter_user($twitter_id, $screen_name)
// Check to see whether the Twitter user is already in the system,
// and update its screen name and uri if so.
- $fuser = Foreign_user::getForeignUser($twitter_id, 1);
+ $fuser = Foreign_user::getForeignUser($twitter_id, TWITTER_SERVICE);
if ($fuser) {
+ $result = true;
+
// Only update if Twitter screen name has changed
if ($fuser->nickname != $screen_name) {
+ $result = update_twitter_user($twitter_id, $screen_name);
common_debug('Twitter bridge - Updated nickname (and URI) for Twitter user ' .
"$fuser->id to $screen_name, was $fuser->nickname");
- return update_twitter_user($fuser, $twitter_id, $screen_name);
+ if (defined('SCRIPT_DEBUG')) {
+ print 'Updated nickname (and URI) for Twitter user ' .
+ "$fuser->id to $screen_name, was $fuser->nickname\n";
+ }
}
+ return $result;
+
} else {
return add_twitter_user($twitter_id, $screen_name);
}
+ $fuser->free();
+ unset($fuser);
+
return true;
}
function retreive_twitter_friends($twitter_id, $screen_name, $password)
{
+ $friends = array();
$uri = "http://twitter.com/statuses/friends/$twitter_id.json?page=";
- $twitter_user = twitter_user_info($screen_name, $password);
+ $friends_ids = twitter_friends_ids($screen_name, $password);
+
+ if (!$friends_ids) {
+ return $friends;
+ }
+
+ if (defined('SCRIPT_DEBUG')) {
+ print "Twitter 'social graph' ids method says $screen_name has " .
+ count($friends_ids) . " friends.\n";
+ }
// Calculate how many pages to get...
- $pages = ceil($twitter_user->friends_count / 100);
+ $pages = ceil(count($friends_ids) / 100);
if ($pages == 0) {
- common_debug("Twitter bridge - Twitter user $screen_name has no friends! Lame.");
+ common_log(LOG_WARNING,
+ "Twitter bridge - $screen_name seems to have no friends.");
+ if (defined('SCRIPT_DEBUG')) {
+ print "$screen_name seems to have no friends.\n";
+ }
}
- $friends = array();
-
for ($i = 1; $i <= $pages; $i++) {
$data = get_twitter_data($uri . $i, $screen_name, $password);
if (!$data) {
- return null;
+ common_log(LOG_WARNING,
+ "Twitter bridge - Couldn't retrieve page $i of $screen_name's friends.");
+ if (defined('SCRIPT_DEBUG')) {
+ print "Couldn't retrieve page $i of $screen_name's friends.\n";
+ }
+ continue;
}
$more_friends = json_decode($data);
if (!$more_friends) {
- return null;
+
+ common_log(LOG_WARNING,
+ "Twitter bridge - No data for page $i of $screen_name's friends.");
+ if (defined('SCRIPT_DEBUG')) {
+ print "No data for page $i of $screen_name's friends.\n";
+ }
+ continue;
}
$friends = array_merge($friends, $more_friends);
@@ -177,19 +293,27 @@ function save_twitter_friends($user, $twitter_id, $screen_name, $password)
$friends = retreive_twitter_friends($twitter_id, $screen_name, $password);
- if (is_null($friends)) {
- common_debug("Twitter bridge - Couldn't get friends data from Twitter.");
+ if (empty($friends)) {
+ common_debug("Twitter bridge - Couldn't get friends data from Twitter for $screen_name.");
+ if (defined('SCRIPT_DEBUG')) {
+ print "Couldn't get friends data from Twitter for $screen_name.\n";
+ }
return false;
}
foreach ($friends as $friend) {
$friend_name = $friend->screen_name;
- $friend_id = $friend->id;
+ $friend_id = (int) $friend->id;
// Update or create the Foreign_user record
if (!save_twitter_user($friend_id, $friend_name)) {
- return false;
+ common_log(LOG_WARNING,
+ "Twitter bridge - couldn't save $screen_name's friend, $friend_name.");
+ if (defined('SCRIPT_DEBUG')) {
+ print "Couldn't save $screen_name's friend, $friend_name.\n";
+ }
+ continue;
}
// Check to see if there's a related local user
@@ -199,8 +323,20 @@ function save_twitter_friends($user, $twitter_id, $screen_name, $password)
// Get associated user and subscribe her
$friend_user = User::staticGet('id', $flink->user_id);
- subs_subscribe_to($user, $friend_user);
- common_debug("Twitter bridge - subscribed $friend_user->nickname to $user->nickname.");
+ if (!empty($friend_user)) {
+ $result = subs_subscribe_to($user, $friend_user);
+
+ if ($result === true) {
+ common_debug("Twitter bridge - subscribed $friend_user->nickname to $user->nickname.");
+ if (defined('SCRIPT_DEBUG')) {
+ print("Subscribed $friend_user->nickname to $user->nickname.\n");
+ }
+ } else {
+ if (defined('SCRIPT_DEBUG')) {
+ print "$result ($friend_user->nickname to $user->nickname)\n";
+ }
+ }
+ }
}
}
@@ -218,7 +354,7 @@ function is_twitter_bound($notice, $flink) {
return true;
}
}
-
+
return false;
}
@@ -226,10 +362,10 @@ function broadcast_twitter($notice)
{
$success = true;
- $flink = Foreign_link::getByUserID($notice->profile_id,
+ $flink = Foreign_link::getByUserID($notice->profile_id,
TWITTER_SERVICE);
-
- // XXX: Not sure WHERE to check whether a notice should go to
+
+ // XXX: Not sure WHERE to check whether a notice should go to
// Twitter. Should we even put in the queue if it shouldn't? --Zach
if (!is_null($flink) && is_twitter_bound($notice, $flink)) {
@@ -244,7 +380,7 @@ function broadcast_twitter($notice)
$options = array(
CURLOPT_USERPWD => "$twitter_user:$twitter_password",
CURLOPT_POST => true,
- CURLOPT_POSTFIELDS =>
+ CURLOPT_POSTFIELDS =>
array(
'status' => $statustxt,
'source' => common_config('integration', 'source')
@@ -292,7 +428,6 @@ function broadcast_twitter($notice)
$success = false;
}
}
-
+
return $success;
}
-
diff --git a/lib/twitterapi.php b/lib/twitterapi.php
index e7239acd5..b8357c688 100644
--- a/lib/twitterapi.php
+++ b/lib/twitterapi.php
@@ -238,21 +238,6 @@ class TwitterapiAction extends Action
$this->elementEnd('item');
}
- function show_twitter_atom_entry($entry)
- {
- $this->elementStart('entry');
- $this->element('title', null, $entry['title']);
- $this->element('content', array('type' => 'html'), $entry['content']);
- $this->element('id', null, $entry['id']);
- $this->element('published', null, $entry['published']);
- $this->element('updated', null, $entry['updated']);
- $this->element('link', array('href' => $entry['link'], 'rel' => 'alternate', 'type' => 'text/html'), null);
- $this->elementStart('author');
- $this->element('name', null, $entry['author']);
- $this->elementEnd('author');
- $this->elementEnd('entry');
- }
-
function show_json_objects($objects)
{
print(json_encode($objects));
@@ -383,7 +368,7 @@ class TwitterapiAction extends Action
}
if (!is_null($selfuri)) {
- $this->element('link', array('href' => $selfuri,
+ $this->element('link', array('href' => $selfuri,
'rel' => 'self', 'type' => 'application/atom+xml'), null);
}
@@ -392,13 +377,11 @@ class TwitterapiAction extends Action
if (is_array($notice)) {
foreach ($notice as $n) {
- $entry = $this->twitter_rss_entry_array($n);
- $this->show_twitter_atom_entry($entry);
+ $this->raw($n->asAtomEntry());
}
} else {
while ($notice->fetch()) {
- $entry = $this->twitter_rss_entry_array($notice);
- $this->show_twitter_atom_entry($entry);
+ $this->raw($notice->asAtomEntry());
}
}
@@ -578,13 +561,16 @@ class TwitterapiAction extends Action
function init_twitter_atom()
{
$this->startXML();
- $this->elementStart('feed', array('xmlns' => 'http://www.w3.org/2005/Atom', 'xml:lang' => 'en-US'));
+ // FIXME: don't hardcode the language here!
+ $this->elementStart('feed', array('xmlns' => 'http://www.w3.org/2005/Atom',
+ 'xml:lang' => 'en-US',
+ 'xmlns:thr' => 'http://purl.org/syndication/thread/1.0'));
}
function end_twitter_atom()
{
- $this->endXML();
$this->elementEnd('feed');
+ $this->endXML();
}
function show_profile($profile, $content_type='xml', $notice=null)
diff --git a/lib/util.php b/lib/util.php
index 19637d546..675ff51f0 100644
--- a/lib/util.php
+++ b/lib/util.php
@@ -480,18 +480,12 @@ function common_replace_urls_callback($text, $callback) {
function common_linkify($url) {
// It comes in special'd, so we unspecial it before passing to the stringifying
// functions
- $ext = pathinfo($url, PATHINFO_EXTENSION);
$url = htmlspecialchars_decode($url);
- $video_ext = array('mp4', 'flv', 'avi', 'mpg', 'mp3', 'ogg');
$display = $url;
$url = (!preg_match('#^([a-z]+://|(mailto|aim|tel):)#i', $url)) ? 'http://'.$url : $url;
$attrs = array('href' => $url, 'rel' => 'external');
- if (in_array($ext, $video_ext)) {
- $attrs['class'] = 'media';
- }
-
if ($longurl = common_longurl($url)) {
$attrs['title'] = $longurl;
}
@@ -587,10 +581,8 @@ function common_shorten_link($url, $reverse = false)
function common_xml_safe_str($str)
{
- $xmlStr = htmlentities(iconv('UTF-8', 'UTF-8//IGNORE', $str), ENT_NOQUOTES, 'UTF-8');
-
- // Replace control, formatting, and surrogate characters with '*', ala Twitter
- return preg_replace('/[\p{Cc}\p{Cf}\p{Cs}]/u', '*', $str);
+ // Neutralize control codes and surrogates
+ return preg_replace('/[\p{Cc}\p{Cs}]/u', '*', $str);
}
function common_tag_link($tag)
@@ -628,9 +620,13 @@ function common_at_link($sender_id, $nickname)
$url = $recipient->profileurl;
}
$xs = new XMLStringer(false);
+ $attrs = array('href' => $url,
+ 'class' => 'url');
+ if (!empty($recipient->fullname)) {
+ $attrs['title'] = $recipient->fullname . ' (' . $recipient->nickname . ')';
+ }
$xs->elementStart('span', 'vcard');
- $xs->elementStart('a', array('href' => $url,
- 'class' => 'url'));
+ $xs->elementStart('a', $attrs);
$xs->element('span', 'fn nickname', $nickname);
$xs->elementEnd('a');
$xs->elementEnd('span');
@@ -645,10 +641,14 @@ function common_group_link($sender_id, $nickname)
$sender = Profile::staticGet($sender_id);
$group = User_group::staticGet('nickname', common_canonical_nickname($nickname));
if ($group && $sender->isMember($group)) {
+ $attrs = array('href' => $group->permalink(),
+ 'class' => 'url');
+ if (!empty($group->fullname)) {
+ $attrs['title'] = $group->fullname . ' (' . $group->nickname . ')';
+ }
$xs = new XMLStringer();
$xs->elementStart('span', 'vcard');
- $xs->elementStart('a', array('href' => $group->permalink(),
- 'class' => 'url'));
+ $xs->elementStart('a', $attrs);
$xs->element('span', 'fn nickname', $nickname);
$xs->elementEnd('a');
$xs->elementEnd('span');
@@ -719,25 +719,46 @@ function common_relative_profile($sender, $nickname, $dt=null)
function common_local_url($action, $args=null, $params=null, $fragment=null)
{
+ static $sensitive = array('login', 'register', 'passwordsettings',
+ 'twittersettings', 'finishopenidlogin',
+ 'finishaddopenid', 'api');
+
$r = Router::get();
$path = $r->build($action, $args, $params, $fragment);
+ $ssl = in_array($action, $sensitive);
+
if (common_config('site','fancy')) {
- $url = common_path(mb_substr($path, 1));
+ $url = common_path(mb_substr($path, 1), $ssl);
} else {
if (mb_strpos($path, '/index.php') === 0) {
- $url = common_path(mb_substr($path, 1));
+ $url = common_path(mb_substr($path, 1), $ssl);
} else {
- $url = common_path('index.php'.$path);
+ $url = common_path('index.php'.$path, $ssl);
}
}
return $url;
}
-function common_path($relative)
+function common_path($relative, $ssl=false)
{
$pathpart = (common_config('site', 'path')) ? common_config('site', 'path')."/" : '';
- return "http://".common_config('site', 'server').'/'.$pathpart.$relative;
+
+ if (($ssl && (common_config('site', 'ssl') === 'sometimes'))
+ || common_config('site', 'ssl') === 'always') {
+ $proto = 'https';
+ if (is_string(common_config('site', 'sslserver')) &&
+ mb_strlen(common_config('site', 'sslserver')) > 0) {
+ $serverpart = common_config('site', 'sslserver');
+ } else {
+ $serverpart = common_config('site', 'server');
+ }
+ } else {
+ $proto = 'http';
+ $serverpart = common_config('site', 'server');
+ }
+
+ return $proto.'://'.$serverpart.'/'.$pathpart.$relative;
}
function common_date_string($dt)
@@ -827,7 +848,7 @@ function common_redirect($url, $code=307)
303 => "See Other",
307 => "Temporary Redirect");
- header("Status: ${code} $status[$code]");
+ header('HTTP/1.1 '.$code.' '.$status[$code]);
header("Location: $url");
$xo = new XMLOutputter();
@@ -929,9 +950,9 @@ function common_profile_url($nickname)
// Should make up a reasonable root URL
-function common_root_url()
+function common_root_url($ssl=false)
{
- return common_path('');
+ return common_path('', $ssl);
}
// returns $bytes bytes of random data as a hexadecimal string