summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/apiauth.php53
-rw-r--r--lib/common.php2
-rw-r--r--lib/default.php1
-rw-r--r--lib/stompqueuemanager.php3
-rw-r--r--lib/uapplugin.php204
5 files changed, 240 insertions, 23 deletions
diff --git a/lib/apiauth.php b/lib/apiauth.php
index ad9651ff2..c684a6cae 100644
--- a/lib/apiauth.php
+++ b/lib/apiauth.php
@@ -57,7 +57,6 @@ class ApiAuthAction extends ApiAction
var $auth_user_password = null;
var $access_token = null;
var $oauth_source = null;
- var $auth_user = null;
/**
* Take arguments for running, and output basic auth header if needed
@@ -82,18 +81,26 @@ class ApiAuthAction extends ApiAction
if (!empty($this->access_token)) {
$this->checkOAuthRequest();
} else {
- $this->checkBasicAuthUser();
+ $this->checkBasicAuthUser(true);
}
+ } else {
- // Reject API calls with the wrong access level
+ // Check to see if a basic auth user is there even
+ // if one's not required
- if ($this->isReadOnly($args) == false) {
- if ($this->access != self::READ_WRITE) {
- $msg = 'API resource requires read-write access, ' .
- 'but you only have read access.';
- $this->clientError($msg, 401, $this->format);
- exit();
- }
+ if (empty($this->access_token)) {
+ $this->checkBasicAuthUser(false);
+ }
+ }
+
+ // Reject API calls with the wrong access level
+
+ if ($this->isReadOnly($args) == false) {
+ if ($this->access != self::READ_WRITE) {
+ $msg = _('API resource requires read-write access, ' .
+ 'but you only have read access.');
+ $this->clientError($msg, 401, $this->format);
+ exit;
}
}
@@ -170,7 +177,7 @@ class ApiAuthAction extends ApiAction
($this->access = self::READ_WRITE) ?
'read-write' : 'read-only'
));
- return true;
+ return;
} else {
throw new OAuthException('Bad access token.');
}
@@ -206,13 +213,13 @@ class ApiAuthAction extends ApiAction
* @return boolean true or false
*/
- function checkBasicAuthUser()
+ function checkBasicAuthUser($required = true)
{
$this->basicAuthProcessHeader();
$realm = common_config('site', 'name') . ' API';
- if (!isset($this->auth_user_nickname)) {
+ if (!isset($this->auth_user_nickname) && $required) {
header('WWW-Authenticate: Basic realm="' . $realm . '"');
// show error if the user clicks 'cancel'
@@ -226,7 +233,11 @@ class ApiAuthAction extends ApiAction
$this->auth_user_password);
if (Event::handle('StartSetApiUser', array(&$user))) {
- $this->auth_user = $user;
+
+ if (!empty($user)) {
+ $this->auth_user = $user;
+ }
+
Event::handle('EndSetApiUser', array($user));
}
@@ -234,18 +245,18 @@ class ApiAuthAction extends ApiAction
$this->access = self::READ_WRITE;
- if (empty($this->auth_user)) {
+ if (empty($this->auth_user) && $required) {
// basic authentication failed
list($proxy, $ip) = common_client_ip();
- common_log(
- LOG_WARNING,
- 'Failed API auth attempt, nickname = ' .
- "$nickname, proxy = $proxy, ip = $ip."
- );
-
+ $msg = sprintf(_('Failed API auth attempt, nickname = %1$s, ' .
+ 'proxy = %2$s, ip = %3$s'),
+ $this->auth_user_nickname,
+ $proxy,
+ $ip);
+ common_log(LOG_WARNING, $msg);
$this->showAuthError();
exit;
}
diff --git a/lib/common.php b/lib/common.php
index ada48b339..b4e4a653c 100644
--- a/lib/common.php
+++ b/lib/common.php
@@ -22,7 +22,7 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }
//exit with 200 response, if this is checking fancy from the installer
if (isset($_REQUEST['p']) && $_REQUEST['p'] == 'check-fancy') { exit; }
-define('STATUSNET_VERSION', '0.9.0beta3');
+define('STATUSNET_VERSION', '0.9.0beta4');
define('LACONICA_VERSION', STATUSNET_VERSION); // compatibility
define('STATUSNET_CODENAME', 'Stand');
diff --git a/lib/default.php b/lib/default.php
index 10ea34864..c729193b5 100644
--- a/lib/default.php
+++ b/lib/default.php
@@ -87,6 +87,7 @@ $default =
'monitor' => null, // URL to monitor ping endpoint (work in progress)
'softlimit' => '90%', // total size or % of memory_limit at which to restart queue threads gracefully
'debug_memory' => false, // true to spit memory usage to log
+ 'inboxes' => true, // true to do inbox distribution & output queueing from in background via 'distrib' queue
),
'license' =>
array('type' => 'cc', # can be 'cc', 'allrightsreserved', 'private'
diff --git a/lib/stompqueuemanager.php b/lib/stompqueuemanager.php
index 89f3d74cc..19e8c49b5 100644
--- a/lib/stompqueuemanager.php
+++ b/lib/stompqueuemanager.php
@@ -178,7 +178,8 @@ class StompQueueManager extends QueueManager
$result = $this->con->send($this->queueName($queue),
$msg, // BODY of the message
- array ('created' => common_sql_now()));
+ array ('created' => common_sql_now(),
+ 'persistent' => 'true'));
if (!$result) {
common_log(LOG_ERR, "Error sending $rep to $queue queue");
diff --git a/lib/uapplugin.php b/lib/uapplugin.php
new file mode 100644
index 000000000..ef35bafbf
--- /dev/null
+++ b/lib/uapplugin.php
@@ -0,0 +1,204 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * UAP (Universal Ad Package) plugin
+ *
+ * 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 Action
+ * @package StatusNet
+ * @author Sarven Capadisli <csarven@status.net>
+ * @author Evan Prodromou <evan@status.net>
+ * @copyright 2010 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);
+}
+
+/**
+ * Abstract superclass for advertising plugins
+ *
+ * Plugins for showing ads should derive from this plugin.
+ *
+ * Outputs the following ad types (based on UAP):
+ *
+ * Medium Rectangle 300x250
+ * Rectangle 180x150
+ * Leaderboard 728x90
+ * Wide Skyscraper 160x600
+ *
+ * @category Plugin
+ * @package StatusNet
+ * @author Sarven Capadisli <csarven@status.net>
+ * @author Evan Prodromou <evan@status.net>
+ * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
+ * @link http://status.net/
+ */
+
+abstract class UAPPlugin extends Plugin
+{
+ public $mediumRectangle = null;
+ public $rectangle = null;
+ public $leaderboard = null;
+ public $wideSkyscraper = null;
+
+ /**
+ * Output our dedicated stylesheet
+ *
+ * @param Action $action Action being shown
+ *
+ * @return boolean hook flag
+ */
+
+ function onEndShowStatusNetStyles($action)
+ {
+ // XXX: allow override by theme
+ $action->cssLink('css/uap.css', 'base', 'screen, projection, tv');
+ return true;
+ }
+
+ /**
+ * Add a medium rectangle ad at the beginning of sidebar
+ *
+ * @param Action $action Action being shown
+ *
+ * @return boolean hook flag
+ */
+
+ function onStartShowAside($action)
+ {
+ if (!is_null($this->mediumRectangle)) {
+
+ $action->elementStart('div',
+ array('id' => 'ad_medium-rectangle',
+ 'class' => 'ad'));
+
+ $this->showMediumRectangle($action);
+
+ $action->elementEnd('div');
+ }
+
+ return true;
+ }
+
+ /**
+ * Add a leaderboard in the header
+ *
+ * @param Action $action Action being shown
+ *
+ * @return boolean hook flag
+ */
+
+ function onEndShowHeader($action)
+ {
+ if (!is_null($this->leaderboard)) {
+ $action->elementStart('div',
+ array('id' => 'ad_leaderboard',
+ 'class' => 'ad'));
+ $this->showLeaderboard($action);
+ $action->elementEnd('div');
+ }
+
+ return true;
+ }
+
+ /**
+ * Add a rectangle before aside sections
+ *
+ * @param Action $action Action being shown
+ *
+ * @return boolean hook flag
+ */
+
+ function onStartShowSections($action)
+ {
+ if (!is_null($this->rectangle)) {
+ $action->elementStart('div',
+ array('id' => 'ad_rectangle',
+ 'class' => 'ad'));
+ $this->showRectangle($action);
+ $action->elementEnd('div');
+ }
+
+ return true;
+ }
+
+ /**
+ * Add a wide skyscraper after the aside
+ *
+ * @param Action $action Action being shown
+ *
+ * @return boolean hook flag
+ */
+
+ function onEndShowAside($action)
+ {
+ if (!is_null($this->wideSkyscraper)) {
+ $action->elementStart('div',
+ array('id' => 'ad_wide-skyscraper',
+ 'class' => 'ad'));
+
+ $this->showWideSkyscraper($action);
+
+ $action->elementEnd('div');
+ }
+ return true;
+ }
+
+ /**
+ * Show a medium rectangle ad
+ *
+ * @param Action $action Action being shown
+ *
+ * @return void
+ */
+
+ abstract protected function showMediumRectangle($action);
+
+ /**
+ * Show a rectangle ad
+ *
+ * @param Action $action Action being shown
+ *
+ * @return void
+ */
+
+ abstract protected function showRectangle($action);
+
+ /**
+ * Show a wide skyscraper ad
+ *
+ * @param Action $action Action being shown
+ *
+ * @return void
+ */
+
+ abstract protected function showWideSkyscraper($action);
+
+ /**
+ * Show a leaderboard ad
+ *
+ * @param Action $action Action being shown
+ *
+ * @return void
+ */
+
+ abstract protected function showLeaderboard($action);
+}