summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZach Copley <zach@controlyourself.ca>2009-02-22 17:03:41 -0800
committerZach Copley <zach@controlyourself.ca>2009-02-22 17:03:41 -0800
commit8e0508dad3bb888b0c01834614b1aa7e16cfe583 (patch)
tree04f2734597377942fbbfc5b4f133e951ccc645a5
parentcdab8d55a96b61ce6cfbec697d95e3223751fd3f (diff)
parentda532bae9131b6dec8f5c0d67ce77c4ad1736f7d (diff)
Merge branch '0.7.x' of git@gitorious.org:laconica/dev into 0.7.x
-rw-r--r--.gitignore3
-rw-r--r--actions/finishopenidlogin.php17
-rw-r--r--actions/grouprss.php15
-rw-r--r--actions/login.php6
-rw-r--r--actions/tagother.php3
-rw-r--r--actions/twitapistatuses.php2
-rw-r--r--actions/userrss.php11
-rw-r--r--classes/User.php18
-rw-r--r--index.php11
-rw-r--r--lib/grouplist.php2
-rw-r--r--lib/noticesection.php2
-rw-r--r--lib/omb.php6
-rw-r--r--lib/openid.php3
-rw-r--r--lib/popularnoticesection.php2
-rw-r--r--lib/profilelist.php2
-rw-r--r--lib/router.php10
-rw-r--r--lib/searchaction.php3
-rw-r--r--lib/util.php4
18 files changed, 63 insertions, 57 deletions
diff --git a/.gitignore b/.gitignore
index f2e96d3eb..83a53dfa3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,8 +1,10 @@
avatar/*
files/*
_darcs/*
+logs/*
config.php
.htaccess
+httpd.conf
*.tmproj
dataobject.ini
*~
@@ -10,3 +12,4 @@ dataobject.ini
*.orig
*.rej
.#*
+*.swp
diff --git a/actions/finishopenidlogin.php b/actions/finishopenidlogin.php
index 1e7b73a7f..6d92cb9aa 100644
--- a/actions/finishopenidlogin.php
+++ b/actions/finishopenidlogin.php
@@ -83,7 +83,7 @@ class FinishopenidloginAction extends Action
function showContent()
{
- if ($this->message_text) {
+ if (!empty($this->message_text)) {
$this->element('p', null, $this->message);
return;
}
@@ -232,7 +232,8 @@ class FinishopenidloginAction extends Action
return;
}
- if ($sreg['country']) {
+ $location = '';
+ if (!empty($sreg['country'])) {
if ($sreg['postcode']) {
# XXX: use postcode to get city and region
# XXX: also, store postcode somewhere -- it's valuable!
@@ -242,12 +243,16 @@ class FinishopenidloginAction extends Action
}
}
- if ($sreg['fullname'] && mb_strlen($sreg['fullname']) <= 255) {
+ if (!empty($sreg['fullname']) && mb_strlen($sreg['fullname']) <= 255) {
$fullname = $sreg['fullname'];
+ } else {
+ $fullname = '';
}
- if ($sreg['email'] && Validate::email($sreg['email'], true)) {
+ if (!empty($sreg['email']) && Validate::email($sreg['email'], true)) {
$email = $sreg['email'];
+ } else {
+ $email = '';
}
# XXX: add language
@@ -328,7 +333,7 @@ class FinishopenidloginAction extends Action
# Try the passed-in nickname
- if ($sreg['nickname']) {
+ if (!empty($sreg['nickname'])) {
$nickname = $this->nicknamize($sreg['nickname']);
if ($this->isNewNickname($nickname)) {
return $nickname;
@@ -337,7 +342,7 @@ class FinishopenidloginAction extends Action
# Try the full name
- if ($sreg['fullname']) {
+ if (!empty($sreg['fullname'])) {
$fullname = $this->nicknamize($sreg['fullname']);
if ($this->isNewNickname($fullname)) {
return $fullname;
diff --git a/actions/grouprss.php b/actions/grouprss.php
index 1a7b858b1..de76a5960 100644
--- a/actions/grouprss.php
+++ b/actions/grouprss.php
@@ -111,13 +111,13 @@ class groupRssAction extends Rss10Action
{
$group = $this->group;
-
+
if (is_null($group)) {
return null;
}
-
+
$notice = $group->getNotices(0, ($limit == 0) ? NOTICES_PER_PAGE : $limit);
-
+
while ($notice->fetch()) {
$notices[] = clone($notice);
}
@@ -141,13 +141,4 @@ class groupRssAction extends Rss10Action
{
return $this->group->homepage_logo;
}
-
- # override parent to add X-SUP-ID URL
-
- function initRss($limit=0)
- {
- $url = common_local_url('sup', null, $this->group->id);
- header('X-SUP-ID: '.$url);
- parent::initRss($limit);
- }
}
diff --git a/actions/login.php b/actions/login.php
index 71e467929..b049791fb 100644
--- a/actions/login.php
+++ b/actions/login.php
@@ -108,13 +108,15 @@ class LoginAction extends Action
$nickname = common_canonical_nickname($this->trimmed('nickname'));
$password = $this->arg('password');
- if (!common_check_user($nickname, $password)) {
+ $user = common_check_user($nickname, $password);
+
+ if (!$user) {
$this->showForm(_('Incorrect username or password.'));
return;
}
// success!
- if (!common_set_user($nickname)) {
+ if (!common_set_user($user)) {
$this->serverError(_('Error setting user.'));
return;
}
diff --git a/actions/tagother.php b/actions/tagother.php
index 79151c911..0d18945a0 100644
--- a/actions/tagother.php
+++ b/actions/tagother.php
@@ -135,7 +135,8 @@ class TagotherAction extends Action
'id' => 'form_tag_user',
'class' => 'form_settings',
'name' => 'tagother',
- 'action' => $this->selfUrl()));
+ 'action' => common_local_url('tagother', array('id' => $this->profile->id))));
+
$this->elementStart('fieldset');
$this->element('legend', null, _('Tag user'));
$this->hidden('token', common_session_token());
diff --git a/actions/twitapistatuses.php b/actions/twitapistatuses.php
index 18e24c0f5..51c256589 100644
--- a/actions/twitapistatuses.php
+++ b/actions/twitapistatuses.php
@@ -204,7 +204,7 @@ class TwitapistatusesAction extends TwitterapiAction
# FriendFeed's SUP protocol
# Also added RSS and Atom feeds
- $suplink = common_local_url('sup', null, $user->id);
+ $suplink = common_local_url('sup', null, null, $user->id);
header('X-SUP-ID: '.$suplink);
# XXX: since
diff --git a/actions/userrss.php b/actions/userrss.php
index 04855ccca..a3e5a3aab 100644
--- a/actions/userrss.php
+++ b/actions/userrss.php
@@ -46,13 +46,13 @@ class UserrssAction extends Rss10Action
{
$user = $this->user;
-
+
if (is_null($user)) {
return null;
}
-
+
$notice = $user->getNotices(0, ($limit == 0) ? NOTICES_PER_PAGE : $limit);
-
+
while ($notice->fetch()) {
$notices[] = clone($notice);
}
@@ -87,10 +87,10 @@ class UserrssAction extends Rss10Action
}
# override parent to add X-SUP-ID URL
-
+
function initRss($limit=0)
{
- $url = common_local_url('sup', null, $this->user->id);
+ $url = common_local_url('sup', null, null, $this->user->id);
header('X-SUP-ID: '.$url);
parent::initRss($limit);
}
@@ -100,4 +100,3 @@ class UserrssAction extends Rss10Action
return true;
}
}
-
diff --git a/classes/User.php b/classes/User.php
index 495a98236..40cf18df6 100644
--- a/classes/User.php
+++ b/classes/User.php
@@ -183,16 +183,16 @@ class User extends Memcached_DataObject
$profile->nickname = $nickname;
$profile->profileurl = common_profile_url($nickname);
- if ($fullname) {
+ if (!empty($fullname)) {
$profile->fullname = $fullname;
}
- if ($homepage) {
+ if (!empty($homepage)) {
$profile->homepage = $homepage;
}
- if ($bio) {
+ if (!empty($bio)) {
$profile->bio = $bio;
}
- if ($location) {
+ if (!empty($location)) {
$profile->location = $location;
}
@@ -200,7 +200,7 @@ class User extends Memcached_DataObject
$id = $profile->insert();
- if (!$id) {
+ if (empty($id)) {
common_log_db_error($profile, 'INSERT', __FILE__);
return false;
}
@@ -210,13 +210,13 @@ class User extends Memcached_DataObject
$user->id = $id;
$user->nickname = $nickname;
- if ($password) { # may not have a password for OpenID users
+ if (!empty($password)) { # may not have a password for OpenID users
$user->password = common_munge_password($password, $id);
}
# Users who respond to invite email have proven their ownership of that address
- if ($code) {
+ if (!empty($code)) {
$invite = Invitation::staticGet($code);
if ($invite && $invite->address && $invite->address_type == 'email' && $invite->address == $email) {
$user->email = $invite->address;
@@ -253,7 +253,7 @@ class User extends Memcached_DataObject
return false;
}
- if ($email && !$user->email) {
+ if (!empty($email) && !$user->email) {
$confirm = new Confirm_address();
$confirm->code = common_confirmation_code(128);
@@ -268,7 +268,7 @@ class User extends Memcached_DataObject
}
}
- if ($code && $user->email) {
+ if (!empty($code) && $user->email) {
$user->emailChanged();
}
diff --git a/index.php b/index.php
index b180e2b65..914ba5bde 100644
--- a/index.php
+++ b/index.php
@@ -27,12 +27,13 @@ $action = null;
function getPath($req)
{
- if (common_config('site', 'fancy')) {
+ if ((common_config('site', 'fancy') || !array_key_exists('PATH_INFO', $_SERVER))
+ && array_key_exists('p', $req)) {
return $req['p'];
- } else if ($_SERVER['PATH_INFO']) {
+ } else if (array_key_exists('PATH_INFO', $_SERVER)) {
return $_SERVER['PATH_INFO'];
} else {
- return $req['p'];
+ return null;
}
}
@@ -115,8 +116,8 @@ function main()
// XXX: find somewhere for this little block to live
- if ($config['db']['mirror'] && $action_obj->isReadOnly()) {
- if (is_array($config['db']['mirror'])) {
+ if (common_config('db', 'mirror') && $action_obj->isReadOnly()) {
+ if (is_array(common_config('db', 'mirror'))) {
// "load balancing", ha ha
$k = array_rand($config['db']['mirror']);
diff --git a/lib/grouplist.php b/lib/grouplist.php
index 6801ab426..1b8547499 100644
--- a/lib/grouplist.php
+++ b/lib/grouplist.php
@@ -151,7 +151,7 @@ class GroupList extends Widget
# If we're on a list with an owner (subscriptions or subscribers)...
- if ($user && $user->id == $this->owner->id) {
+ if (!empty($user) && !empty($this->owner) && $user->id == $this->owner->id) {
$this->showOwnerControls();
}
diff --git a/lib/noticesection.php b/lib/noticesection.php
index 97b517529..b31f18744 100644
--- a/lib/noticesection.php
+++ b/lib/noticesection.php
@@ -96,7 +96,7 @@ class NoticeSection extends Section
$this->out->elementStart('p', 'entry-content');
$this->out->raw($notice->rendered);
$this->out->elementEnd('p');
- if ($notice->value) {
+ if (!empty($notice->value)) {
$this->out->elementStart('p');
$this->out->text($notice->value);
$this->out->elementEnd('p');
diff --git a/lib/omb.php b/lib/omb.php
index f2dbef5ba..29e14c75f 100644
--- a/lib/omb.php
+++ b/lib/omb.php
@@ -239,7 +239,7 @@ function omb_broadcast_profile($profile)
while ($sub->fetch()) {
$rp = Remote_profile::staticGet('id', $sub->subscriber);
if ($rp) {
- if (!$updated[$rp->updateprofileurl]) {
+ if (!array_key_exists($rp->updateprofileurl, $updated)) {
if (omb_update_profile($profile, $rp, $sub)) {
$updated[$rp->updateprofileurl] = true;
}
@@ -295,7 +295,9 @@ function omb_update_profile($profile, $remote_profile, $subscription)
common_debug('Got HTTP result "'.print_r($result,true).'"', __FILE__);
- if ($result->status == 403) { # not authorized, don't send again
+ if (empty($result) || $result) {
+ common_debug("Unable to contact " . $req->get_normalized_http_url());
+ } else if ($result->status == 403) { # not authorized, don't send again
common_debug('403 result, deleting subscription', __FILE__);
$subscription->delete();
return false;
diff --git a/lib/openid.php b/lib/openid.php
index 860573702..5c3d460da 100644
--- a/lib/openid.php
+++ b/lib/openid.php
@@ -64,6 +64,9 @@ function oid_set_last($openid_url)
function oid_get_last()
{
+ if (empty($_COOKIE[OPENID_COOKIE_KEY])) {
+ return null;
+ }
$openid_url = $_COOKIE[OPENID_COOKIE_KEY];
if ($openid_url && strlen($openid_url) > 0) {
return $openid_url;
diff --git a/lib/popularnoticesection.php b/lib/popularnoticesection.php
index 5380563b9..c7c7f0215 100644
--- a/lib/popularnoticesection.php
+++ b/lib/popularnoticesection.php
@@ -31,8 +31,6 @@ if (!defined('LACONICA')) {
exit(1);
}
-define('NOTICES_PER_SECTION', 5);
-
/**
* Base class for sections showing lists of notices
*
diff --git a/lib/profilelist.php b/lib/profilelist.php
index 8bef49dce..c2040fbc2 100644
--- a/lib/profilelist.php
+++ b/lib/profilelist.php
@@ -34,8 +34,6 @@ if (!defined('LACONICA')) {
require_once INSTALLDIR.'/lib/widget.php';
-define('PROFILES_PER_PAGE', 20);
-
/**
* Widget to show a list of profiles
*
diff --git a/lib/router.php b/lib/router.php
index 9d0d3a3f0..e842604e9 100644
--- a/lib/router.php
+++ b/lib/router.php
@@ -47,7 +47,7 @@ require_once 'Net/URL/Mapper.php';
class Router
{
- static $m = null;
+ var $m = null;
static $inst = null;
static function get()
@@ -98,12 +98,14 @@ class Router
$main = array('login', 'logout', 'register', 'subscribe',
'unsubscribe', 'confirmaddress', 'recoverpassword',
'invite', 'favor', 'disfavor', 'sup',
- 'tagother', 'block');
+ 'block');
foreach ($main as $a) {
$m->connect('main/'.$a, array('action' => $a));
}
+ $m->connect('main/tagother/:id', array('action' => 'tagother'));
+
// these take a code
foreach (array('register', 'confirmaddress', 'recoverpassword') as $c) {
@@ -370,7 +372,7 @@ class Router
return $match;
}
- function build($action, $args=null, $fragment=null)
+ function build($action, $args=null, $params=null, $fragment=null)
{
$action_arg = array('action' => $action);
@@ -380,6 +382,6 @@ class Router
$args = $action_arg;
}
- return $this->m->generate($args, null, $fragment);
+ return $this->m->generate($args, $params, $fragment);
}
} \ No newline at end of file
diff --git a/lib/searchaction.php b/lib/searchaction.php
index fdfb8dc5a..df6876445 100644
--- a/lib/searchaction.php
+++ b/lib/searchaction.php
@@ -79,10 +79,11 @@ class SearchAction extends Action
function showTop($arr=null)
{
+ $error = null;
if ($arr) {
$error = $arr[1];
}
- if ($error) {
+ if (!empty($error)) {
$this->element('p', 'error', $error);
} else {
$instr = $this->getInstructions();
diff --git a/lib/util.php b/lib/util.php
index 46aa7b9df..5345a08bb 100644
--- a/lib/util.php
+++ b/lib/util.php
@@ -705,10 +705,10 @@ function common_relative_profile($sender, $nickname, $dt=null)
return null;
}
-function common_local_url($action, $args=null, $fragment=null)
+function common_local_url($action, $args=null, $params=null, $fragment=null)
{
$r = Router::get();
- $path = $r->build($action, $args, $fragment);
+ $path = $r->build($action, $args, $params, $fragment);
if ($path) {
}
if (common_config('site','fancy')) {