Set HTTP status codes with http_response_code()
This commit is contained in:
parent
3429a3644d
commit
1667d727b4
|
@ -1,26 +1,24 @@
|
||||||
<?php
|
<?php
|
||||||
|
// This file is part of GNU social - https://www.gnu.org/software/social
|
||||||
|
//
|
||||||
|
// GNU social 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.
|
||||||
|
//
|
||||||
|
// GNU social 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 GNU social. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* StatusNet, the distributed open-source microblogging tool
|
|
||||||
*
|
|
||||||
* Show a notice (as a Twitter-style status)
|
* Show a notice (as a Twitter-style status)
|
||||||
*
|
*
|
||||||
* 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 API
|
* @category API
|
||||||
* @package StatusNet
|
* @package GNUsocial
|
||||||
* @author Craig Andrews <candrews@integralblue.com>
|
* @author Craig Andrews <candrews@integralblue.com>
|
||||||
* @author Evan Prodromou <evan@status.net>
|
* @author Evan Prodromou <evan@status.net>
|
||||||
* @author Jeffery To <jeffery.to@gmail.com>
|
* @author Jeffery To <jeffery.to@gmail.com>
|
||||||
|
@ -30,31 +28,29 @@
|
||||||
* @author Zach Copley <zach@status.net>
|
* @author Zach Copley <zach@status.net>
|
||||||
* @copyright 2009 StatusNet, Inc.
|
* @copyright 2009 StatusNet, Inc.
|
||||||
* @copyright 2009 Free Software Foundation, Inc http://www.fsf.org
|
* @copyright 2009 Free Software Foundation, Inc http://www.fsf.org
|
||||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||||
* @link http://status.net/
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
defined('GNUSOCIAL') || die();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the notice specified by id as a Twitter-style status and inline user
|
* Returns the notice specified by id as a Twitter-style status and inline user
|
||||||
*
|
*
|
||||||
* @category API
|
* @category API
|
||||||
* @package StatusNet
|
* @package GNUsocial
|
||||||
* @author Craig Andrews <candrews@integralblue.com>
|
* @author Craig Andrews <candrews@integralblue.com>
|
||||||
* @author Evan Prodromou <evan@status.net>
|
* @author Evan Prodromou <evan@status.net>
|
||||||
* @author Jeffery To <jeffery.to@gmail.com>
|
* @author Jeffery To <jeffery.to@gmail.com>
|
||||||
* @author Tom Blankenship <mac65@mac65.com>
|
* @author Tom Blankenship <mac65@mac65.com>
|
||||||
* @author Mike Cochrane <mikec@mikenz.geek.nz>
|
* @author Mike Cochrane <mikec@mikenz.geek.nz>
|
||||||
* @author Robin Millette <robin@millette.info>
|
* @author Robin Millette <robin@millette.info>
|
||||||
* @author Zach Copley <zach@status.net>
|
* @author Zach Copley <zach@status.net>
|
||||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||||
* @link http://status.net/
|
|
||||||
*/
|
*/
|
||||||
class ApiStatusesShowAction extends ApiPrivateAuthAction
|
class ApiStatusesShowAction extends ApiPrivateAuthAction
|
||||||
{
|
{
|
||||||
var $notice_id = null;
|
public $notice_id = null;
|
||||||
var $notice = null;
|
public $notice = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Take arguments for running
|
* Take arguments for running
|
||||||
|
@ -131,7 +127,7 @@ class ApiStatusesShowAction extends ApiPrivateAuthAction
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function showNotice()
|
public function showNotice()
|
||||||
{
|
{
|
||||||
switch ($this->format) {
|
switch ($this->format) {
|
||||||
case 'xml':
|
case 'xml':
|
||||||
|
@ -158,9 +154,9 @@ class ApiStatusesShowAction extends ApiPrivateAuthAction
|
||||||
* @return boolean true
|
* @return boolean true
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function isReadOnly($args)
|
public function isReadOnly($args)
|
||||||
{
|
{
|
||||||
return ($_SERVER['REQUEST_METHOD'] == 'GET' || $_SERVER['REQUEST_METHOD'] == 'HEAD');
|
return in_array($_SERVER['REQUEST_METHOD'], ['GET', 'HEAD']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -168,7 +164,7 @@ class ApiStatusesShowAction extends ApiPrivateAuthAction
|
||||||
*
|
*
|
||||||
* @return string datestamp of the latest notice in the stream
|
* @return string datestamp of the latest notice in the stream
|
||||||
*/
|
*/
|
||||||
function lastModified()
|
public function lastModified()
|
||||||
{
|
{
|
||||||
return strtotime($this->notice->created);
|
return strtotime($this->notice->created);
|
||||||
}
|
}
|
||||||
|
@ -181,7 +177,7 @@ class ApiStatusesShowAction extends ApiPrivateAuthAction
|
||||||
*
|
*
|
||||||
* @return string etag
|
* @return string etag
|
||||||
*/
|
*/
|
||||||
function etag()
|
public function etag()
|
||||||
{
|
{
|
||||||
return '"' . implode(
|
return '"' . implode(
|
||||||
':',
|
':',
|
||||||
|
@ -194,7 +190,7 @@ class ApiStatusesShowAction extends ApiPrivateAuthAction
|
||||||
. '"';
|
. '"';
|
||||||
}
|
}
|
||||||
|
|
||||||
function deleteNotice()
|
public function deleteNotice()
|
||||||
{
|
{
|
||||||
if ($this->format != 'atom') {
|
if ($this->format != 'atom') {
|
||||||
// TRANS: Client error displayed when trying to delete a notice not using the Atom format.
|
// TRANS: Client error displayed when trying to delete a notice not using the Atom format.
|
||||||
|
@ -215,7 +211,7 @@ class ApiStatusesShowAction extends ApiPrivateAuthAction
|
||||||
|
|
||||||
// @fixme is there better output we could do here?
|
// @fixme is there better output we could do here?
|
||||||
|
|
||||||
header('HTTP/1.1 200 OK');
|
http_response_code(200);
|
||||||
header('Content-Type: text/plain');
|
header('Content-Type: text/plain');
|
||||||
// TRANS: Confirmation of notice deletion in API. %d is the ID (number) of the deleted notice.
|
// TRANS: Confirmation of notice deletion in API. %d is the ID (number) of the deleted notice.
|
||||||
print(sprintf(_('Deleted notice %d'), $this->notice->id));
|
print(sprintf(_('Deleted notice %d'), $this->notice->id));
|
||||||
|
|
|
@ -1,26 +1,24 @@
|
||||||
<?php
|
<?php
|
||||||
|
// This file is part of GNU social - https://www.gnu.org/software/social
|
||||||
|
//
|
||||||
|
// GNU social 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.
|
||||||
|
//
|
||||||
|
// GNU social 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 GNU social. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* StatusNet, the distributed open-source microblogging tool
|
|
||||||
*
|
|
||||||
* Show a user's timeline
|
* Show a user's timeline
|
||||||
*
|
*
|
||||||
* 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 API
|
* @category API
|
||||||
* @package StatusNet
|
* @package GNUsocial
|
||||||
* @author Craig Andrews <candrews@integralblue.com>
|
* @author Craig Andrews <candrews@integralblue.com>
|
||||||
* @author Evan Prodromou <evan@status.net>
|
* @author Evan Prodromou <evan@status.net>
|
||||||
* @author Jeffery To <jeffery.to@gmail.com>
|
* @author Jeffery To <jeffery.to@gmail.com>
|
||||||
|
@ -30,30 +28,26 @@
|
||||||
* @author Zach Copley <zach@status.net>
|
* @author Zach Copley <zach@status.net>
|
||||||
* @copyright 2009 StatusNet, Inc.
|
* @copyright 2009 StatusNet, Inc.
|
||||||
* @copyright 2009 Free Software Foundation, Inc http://www.fsf.org
|
* @copyright 2009 Free Software Foundation, Inc http://www.fsf.org
|
||||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||||
* @link http://status.net/
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('GNUSOCIAL')) {
|
defined('GNUSOCIAL') || die();
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the most recent notices (default 20) posted by the authenticating
|
* Returns the most recent notices (default 20) posted by the authenticating
|
||||||
* user. Another user's timeline can be requested via the id parameter. This
|
* user. Another user's timeline can be requested via the id parameter. This
|
||||||
* is the API equivalent of the user profile web page.
|
* is the API equivalent of the user profile web page.
|
||||||
*
|
*
|
||||||
* @category API
|
* @category API
|
||||||
* @package StatusNet
|
* @package GNUsocial
|
||||||
* @author Craig Andrews <candrews@integralblue.com>
|
* @author Craig Andrews <candrews@integralblue.com>
|
||||||
* @author Evan Prodromou <evan@status.net>
|
* @author Evan Prodromou <evan@status.net>
|
||||||
* @author Jeffery To <jeffery.to@gmail.com>
|
* @author Jeffery To <jeffery.to@gmail.com>
|
||||||
* @author mac65 <mac65@mac65.com>
|
* @author mac65 <mac65@mac65.com>
|
||||||
* @author Mike Cochrane <mikec@mikenz.geek.nz>
|
* @author Mike Cochrane <mikec@mikenz.geek.nz>
|
||||||
* @author Robin Millette <robin@millette.info>
|
* @author Robin Millette <robin@millette.info>
|
||||||
* @author Zach Copley <zach@status.net>
|
* @author Zach Copley <zach@status.net>
|
||||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||||
* @link http://status.net/
|
|
||||||
*/
|
*/
|
||||||
class ApiTimelineUserAction extends ApiBareAuthAction
|
class ApiTimelineUserAction extends ApiBareAuthAction
|
||||||
{
|
{
|
||||||
|
@ -101,16 +95,14 @@ class ApiTimelineUserAction extends ApiBareAuthAction
|
||||||
if (!empty($this->notices) && (count($this->notices) > 0)) {
|
if (!empty($this->notices) && (count($this->notices) > 0)) {
|
||||||
$last = count($this->notices) - 1;
|
$last = count($this->notices) - 1;
|
||||||
|
|
||||||
return '"' . implode(
|
return '"' . implode(':', [
|
||||||
':',
|
$this->arg('action'),
|
||||||
array($this->arg('action'),
|
common_user_cache_hash($this->scoped),
|
||||||
common_user_cache_hash($this->scoped),
|
common_language(),
|
||||||
common_language(),
|
$this->target->getID(),
|
||||||
$this->target->getID(),
|
strtotime($this->notices[0]->created),
|
||||||
strtotime($this->notices[0]->created),
|
strtotime($this->notices[$last]->created),
|
||||||
strtotime($this->notices[$last]->created))
|
]) . '"';
|
||||||
)
|
|
||||||
. '"';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
@ -250,7 +242,7 @@ class ApiTimelineUserAction extends ApiBareAuthAction
|
||||||
}
|
}
|
||||||
Event::handle('EndAtomPubNewActivity', array($activity, $this->target, $stored));
|
Event::handle('EndAtomPubNewActivity', array($activity, $this->target, $stored));
|
||||||
|
|
||||||
header('HTTP/1.1 201 Created');
|
http_response_code(201);
|
||||||
header("Location: " . common_local_url('ApiStatusesShow', array('id' => $stored->getID(),
|
header("Location: " . common_local_url('ApiStatusesShow', array('id' => $stored->getID(),
|
||||||
'format' => 'atom')));
|
'format' => 'atom')));
|
||||||
$this->showSingleAtomStatus($stored);
|
$this->showSingleAtomStatus($stored);
|
||||||
|
|
|
@ -1,25 +1,27 @@
|
||||||
<?php
|
<?php
|
||||||
|
// This file is part of GNU social - https://www.gnu.org/software/social
|
||||||
|
//
|
||||||
|
// GNU social 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.
|
||||||
|
//
|
||||||
|
// GNU social 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 GNU social. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Table Definition for status_network
|
* Table Definition for status_network
|
||||||
*
|
*
|
||||||
* StatusNet - the distributed open-source microblogging tool
|
* @copyright 2009 StatusNet, Inc.
|
||||||
* Copyright (C) 2009, StatusNet, Inc.
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||||
*
|
|
||||||
* 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/>.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }
|
defined('GNUSOCIAL') || die();
|
||||||
|
|
||||||
class Status_network extends Safe_DataObject
|
class Status_network extends Safe_DataObject
|
||||||
{
|
{
|
||||||
|
@ -39,12 +41,13 @@ class Status_network extends Safe_DataObject
|
||||||
public $theme; // varchar(191) not 255 because utf8mb4 takes more space
|
public $theme; // varchar(191) not 255 because utf8mb4 takes more space
|
||||||
public $logo; // varchar(191) not 255 because utf8mb4 takes more space
|
public $logo; // varchar(191) not 255 because utf8mb4 takes more space
|
||||||
public $created; // datetime() not_null
|
public $created; // datetime() not_null
|
||||||
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
|
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
||||||
|
|
||||||
/* Static get */
|
/* Static get */
|
||||||
static function getKV($k,$v=NULL) {
|
public static function getKV($k, $v = null)
|
||||||
|
{
|
||||||
// TODO: This must probably be turned into a non-static call
|
// TODO: This must probably be turned into a non-static call
|
||||||
$i = DB_DataObject::staticGet('Status_network',$k,$v);
|
$i = DB_DataObject::staticGet('Status_network', $k, $v);
|
||||||
|
|
||||||
// Don't use local process cache; if we're fetching multiple
|
// Don't use local process cache; if we're fetching multiple
|
||||||
// times it's because we're reloading it in a long-running
|
// times it's because we're reloading it in a long-running
|
||||||
|
@ -60,8 +63,8 @@ class Status_network extends Safe_DataObject
|
||||||
// XXX: made public so Status_network_tag can eff with it
|
// XXX: made public so Status_network_tag can eff with it
|
||||||
public static $cache = null;
|
public static $cache = null;
|
||||||
public static $cacheInitialized = false;
|
public static $cacheInitialized = false;
|
||||||
static $base = null;
|
public static $base = null;
|
||||||
static $wildcard = null;
|
public static $wildcard = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $dbhost
|
* @param string $dbhost
|
||||||
|
@ -70,8 +73,13 @@ class Status_network extends Safe_DataObject
|
||||||
* @param string $dbname
|
* @param string $dbname
|
||||||
* @param array $servers memcached servers to use for caching config info
|
* @param array $servers memcached servers to use for caching config info
|
||||||
*/
|
*/
|
||||||
static function setupDB($dbhost, $dbuser, $dbpass, $dbname, array $servers)
|
public static function setupDB(
|
||||||
{
|
$dbhost,
|
||||||
|
$dbuser,
|
||||||
|
$dbpass,
|
||||||
|
$dbname,
|
||||||
|
array $servers
|
||||||
|
) {
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
$config['db']['database_'.$dbname] = "mysqli://$dbuser:$dbpass@$dbhost/$dbname";
|
$config['db']['database_'.$dbname] = "mysqli://$dbuser:$dbpass@$dbhost/$dbname";
|
||||||
|
@ -95,8 +103,8 @@ class Status_network extends Safe_DataObject
|
||||||
$persist = php_sapi_name() != 'cli' || self::$cacheInitialized;
|
$persist = php_sapi_name() != 'cli' || self::$cacheInitialized;
|
||||||
if (!is_array($servers)) {
|
if (!is_array($servers)) {
|
||||||
$servers = array($servers);
|
$servers = array($servers);
|
||||||
}
|
}
|
||||||
foreach($servers as $server) {
|
foreach ($servers as $server) {
|
||||||
$parts = explode(':', $server);
|
$parts = explode(':', $server);
|
||||||
$server = $parts[0];
|
$server = $parts[0];
|
||||||
if (count($parts) > 1) {
|
if (count($parts) > 1) {
|
||||||
|
@ -112,11 +120,12 @@ class Status_network extends Safe_DataObject
|
||||||
self::$base = $dbname;
|
self::$base = $dbname;
|
||||||
}
|
}
|
||||||
|
|
||||||
static function cacheKey($k, $v) {
|
public static function cacheKey($k, $v)
|
||||||
|
{
|
||||||
return 'gnusocial:' . self::$base . ':status_network:'.$k.':'.$v;
|
return 'gnusocial:' . self::$base . ':status_network:'.$k.':'.$v;
|
||||||
}
|
}
|
||||||
|
|
||||||
static function memGet($k, $v)
|
public static function memGet($k, $v)
|
||||||
{
|
{
|
||||||
if (!self::$cache) {
|
if (!self::$cache) {
|
||||||
return self::getKV($k, $v);
|
return self::getKV($k, $v);
|
||||||
|
@ -136,7 +145,7 @@ class Status_network extends Safe_DataObject
|
||||||
return $sn;
|
return $sn;
|
||||||
}
|
}
|
||||||
|
|
||||||
function decache()
|
public function decache()
|
||||||
{
|
{
|
||||||
if (self::$cache) {
|
if (self::$cache) {
|
||||||
$keys = array('nickname', 'hostname', 'pathname');
|
$keys = array('nickname', 'hostname', 'pathname');
|
||||||
|
@ -147,10 +156,11 @@ class Status_network extends Safe_DataObject
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function update($dataObject=false)
|
public function update($dataObject = false)
|
||||||
{
|
{
|
||||||
if (is_object($dataObject)) {
|
if (is_object($dataObject)) {
|
||||||
$dataObject->decache(); # might be different keys
|
// might be different keys
|
||||||
|
$dataObject->decache();
|
||||||
}
|
}
|
||||||
return parent::update($dataObject);
|
return parent::update($dataObject);
|
||||||
}
|
}
|
||||||
|
@ -158,7 +168,7 @@ class Status_network extends Safe_DataObject
|
||||||
/**
|
/**
|
||||||
* DB_DataObject doesn't allow updating keys (even non-primary)
|
* DB_DataObject doesn't allow updating keys (even non-primary)
|
||||||
*/
|
*/
|
||||||
function updateKeys(&$orig)
|
public function updateKeys(&$orig)
|
||||||
{
|
{
|
||||||
$this->_connect();
|
$this->_connect();
|
||||||
foreach (array('hostname', 'pathname') as $k) {
|
foreach (array('hostname', 'pathname') as $k) {
|
||||||
|
@ -183,9 +193,10 @@ class Status_network extends Safe_DataObject
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
function delete($useWhere=false)
|
public function delete($useWhere = false)
|
||||||
{
|
{
|
||||||
$this->decache(); # while we still have the values!
|
// while we still have the values!
|
||||||
|
$this->decache();
|
||||||
return parent::delete($useWhere);
|
return parent::delete($useWhere);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -194,7 +205,7 @@ class Status_network extends Safe_DataObject
|
||||||
* @param string $wildcard hostname suffix to match wildcard config
|
* @param string $wildcard hostname suffix to match wildcard config
|
||||||
* @return mixed Status_network or null
|
* @return mixed Status_network or null
|
||||||
*/
|
*/
|
||||||
static function getFromHostname($servername, $wildcard)
|
public static function getFromHostname($servername, $wildcard)
|
||||||
{
|
{
|
||||||
$sn = null;
|
$sn = null;
|
||||||
if (0 == strncasecmp(strrev($wildcard), strrev($servername), strlen($wildcard))) {
|
if (0 == strncasecmp(strrev($wildcard), strrev($servername), strlen($wildcard))) {
|
||||||
|
@ -223,7 +234,7 @@ class Status_network extends Safe_DataObject
|
||||||
* @param string $pathname URL base path
|
* @param string $pathname URL base path
|
||||||
* @param string $wildcard hostname suffix to match wildcard config
|
* @param string $wildcard hostname suffix to match wildcard config
|
||||||
*/
|
*/
|
||||||
static function setupSite($servername, $pathname, $wildcard)
|
public static function setupSite($servername, $pathname, $wildcard)
|
||||||
{
|
{
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
|
@ -241,10 +252,14 @@ class Status_network extends Safe_DataObject
|
||||||
empty($_SERVER['HTTPS']) &&
|
empty($_SERVER['HTTPS']) &&
|
||||||
0 != strcasecmp($sn->hostname, $servername)) {
|
0 != strcasecmp($sn->hostname, $servername)) {
|
||||||
$sn->redirectTo('http://'.$sn->hostname.$_SERVER['REQUEST_URI']);
|
$sn->redirectTo('http://'.$sn->hostname.$_SERVER['REQUEST_URI']);
|
||||||
} else if (!empty($_SERVER['HTTPS']) &&
|
} elseif (
|
||||||
0 != strcasecmp($sn->hostname, $servername) &&
|
!empty($_SERVER['HTTPS'])
|
||||||
0 != strcasecmp($sn->nickname.'.'.$wildcard, $servername)) {
|
&& strcasecmp($sn->hostname, $servername) !== 0
|
||||||
$sn->redirectTo('https://'.$sn->nickname.'.'.$wildcard.$_SERVER['REQUEST_URI']);
|
&& strcasecmp($sn->nickname . '.' . $wildcard, $servername) !== 0
|
||||||
|
) {
|
||||||
|
$sn->redirectTo(
|
||||||
|
"https://{$sn->nickname}.{$wildcard}{$_SERVER['REQUEST_URI']}"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$dbhost = (empty($sn->dbhost)) ? 'localhost' : $sn->dbhost;
|
$dbhost = (empty($sn->dbhost)) ? 'localhost' : $sn->dbhost;
|
||||||
|
@ -282,7 +297,7 @@ class Status_network extends Safe_DataObject
|
||||||
// (C) 2006 by Heiko Richler http://www.richler.de/
|
// (C) 2006 by Heiko Richler http://www.richler.de/
|
||||||
// LGPL
|
// LGPL
|
||||||
|
|
||||||
function redirectTo($destination)
|
public function redirectTo($destination)
|
||||||
{
|
{
|
||||||
$old = 'http'.
|
$old = 'http'.
|
||||||
(($_SERVER['HTTPS'] == 'on') ? 'S' : '').
|
(($_SERVER['HTTPS'] == 'on') ? 'S' : '').
|
||||||
|
@ -295,15 +310,15 @@ class Status_network extends Safe_DataObject
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
header('HTTP/1.1 301 Moved Permanently');
|
http_response_code(301);
|
||||||
header("Location: $destination");
|
header("Location: {$destination}");
|
||||||
|
|
||||||
print "<a href='$destination'>$destination</a>\n";
|
echo "<a href='{$destination}'>{$destination}</a>\n";
|
||||||
|
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getServerName()
|
public function getServerName()
|
||||||
{
|
{
|
||||||
if (!empty($this->hostname)) {
|
if (!empty($this->hostname)) {
|
||||||
return $this->hostname;
|
return $this->hostname;
|
||||||
|
@ -316,7 +331,7 @@ class Status_network extends Safe_DataObject
|
||||||
* Return site meta-info tags as an array
|
* Return site meta-info tags as an array
|
||||||
* @return array of strings
|
* @return array of strings
|
||||||
*/
|
*/
|
||||||
function getTags()
|
public function getTags()
|
||||||
{
|
{
|
||||||
return Status_network_tag::getTags($this->site_id);
|
return Status_network_tag::getTags($this->site_id);
|
||||||
}
|
}
|
||||||
|
@ -326,7 +341,7 @@ class Status_network extends Safe_DataObject
|
||||||
* @param array tags
|
* @param array tags
|
||||||
* @fixme only add/remove differentials
|
* @fixme only add/remove differentials
|
||||||
*/
|
*/
|
||||||
function setTags(array $tags)
|
public function setTags(array $tags)
|
||||||
{
|
{
|
||||||
$this->clearTags();
|
$this->clearTags();
|
||||||
foreach ($tags as $tag) {
|
foreach ($tags as $tag) {
|
||||||
|
@ -347,13 +362,13 @@ class Status_network extends Safe_DataObject
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function clearTags()
|
public function clearTags()
|
||||||
{
|
{
|
||||||
$tag = new Status_network_tag();
|
$tag = new Status_network_tag();
|
||||||
$tag->site_id = $this->site_id;
|
$tag->site_id = $this->site_id;
|
||||||
|
|
||||||
if ($tag->find()) {
|
if ($tag->find()) {
|
||||||
while($tag->fetch()) {
|
while ($tag->fetch()) {
|
||||||
$tag->delete();
|
$tag->delete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -366,7 +381,7 @@ class Status_network extends Safe_DataObject
|
||||||
* @param string $tag
|
* @param string $tag
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
function hasTag($tag)
|
public function hasTag($tag)
|
||||||
{
|
{
|
||||||
return in_array($tag, $this->getTags());
|
return in_array($tag, $this->getTags());
|
||||||
}
|
}
|
||||||
|
|
|
@ -150,11 +150,9 @@ class action extends HTMLOutputter // lawsuit
|
||||||
$code = 400;
|
$code = 400;
|
||||||
}
|
}
|
||||||
|
|
||||||
$status_string = ClientErrorAction::$status[$code];
|
|
||||||
|
|
||||||
switch ($format) {
|
switch ($format) {
|
||||||
case 'xml':
|
case 'xml':
|
||||||
header("HTTP/1.1 {$code} {$status_string}");
|
http_response_code($code);
|
||||||
$this->initDocument('xml');
|
$this->initDocument('xml');
|
||||||
$this->elementStart('hash');
|
$this->elementStart('hash');
|
||||||
$this->element('error', null, $msg);
|
$this->element('error', null, $msg);
|
||||||
|
@ -164,7 +162,7 @@ class action extends HTMLOutputter // lawsuit
|
||||||
break;
|
break;
|
||||||
case 'json':
|
case 'json':
|
||||||
if (!isset($this->callback)) {
|
if (!isset($this->callback)) {
|
||||||
header("HTTP/1.1 {$code} {$status_string}");
|
http_response_code($code);
|
||||||
}
|
}
|
||||||
$this->initDocument('json');
|
$this->initDocument('json');
|
||||||
$error_array = ['error' => $msg, 'request' => $_SERVER['REQUEST_URI']];
|
$error_array = ['error' => $msg, 'request' => $_SERVER['REQUEST_URI']];
|
||||||
|
@ -172,7 +170,7 @@ class action extends HTMLOutputter // lawsuit
|
||||||
$this->endDocument('json');
|
$this->endDocument('json');
|
||||||
break;
|
break;
|
||||||
case 'text':
|
case 'text':
|
||||||
header("HTTP/1.1 {$code} {$status_string}");
|
http_response_code($code);
|
||||||
header('Content-Type: text/plain; charset=utf-8');
|
header('Content-Type: text/plain; charset=utf-8');
|
||||||
echo $msg;
|
echo $msg;
|
||||||
break;
|
break;
|
||||||
|
@ -411,7 +409,7 @@ class action extends HTMLOutputter // lawsuit
|
||||||
// If this check fails, ignore the if-modified-since below.
|
// If this check fails, ignore the if-modified-since below.
|
||||||
$checked = true;
|
$checked = true;
|
||||||
if ($this->_hasEtag($etag, $if_none_match)) {
|
if ($this->_hasEtag($etag, $if_none_match)) {
|
||||||
header('HTTP/1.1 304 Not Modified');
|
http_response_code(304);
|
||||||
// Better way to do this?
|
// Better way to do this?
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
@ -422,7 +420,7 @@ class action extends HTMLOutputter // lawsuit
|
||||||
$if_modified_since = $_SERVER['HTTP_IF_MODIFIED_SINCE'];
|
$if_modified_since = $_SERVER['HTTP_IF_MODIFIED_SINCE'];
|
||||||
$ims = strtotime($if_modified_since);
|
$ims = strtotime($if_modified_since);
|
||||||
if ($lm <= $ims) {
|
if ($lm <= $ims) {
|
||||||
header('HTTP/1.1 304 Not Modified');
|
http_response_code(304);
|
||||||
// Better way to do this?
|
// Better way to do this?
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
@ -505,11 +503,9 @@ class action extends HTMLOutputter // lawsuit
|
||||||
$code = 500;
|
$code = 500;
|
||||||
}
|
}
|
||||||
|
|
||||||
$status_string = ServerErrorAction::$status[$code];
|
|
||||||
|
|
||||||
switch ($format) {
|
switch ($format) {
|
||||||
case 'xml':
|
case 'xml':
|
||||||
header("HTTP/1.1 {$code} {$status_string}");
|
http_response_code($code);
|
||||||
$this->initDocument('xml');
|
$this->initDocument('xml');
|
||||||
$this->elementStart('hash');
|
$this->elementStart('hash');
|
||||||
$this->element('error', null, $msg);
|
$this->element('error', null, $msg);
|
||||||
|
@ -519,7 +515,7 @@ class action extends HTMLOutputter // lawsuit
|
||||||
break;
|
break;
|
||||||
case 'json':
|
case 'json':
|
||||||
if (!isset($this->callback)) {
|
if (!isset($this->callback)) {
|
||||||
header("HTTP/1.1 {$code} {$status_string}");
|
http_response_code($code);
|
||||||
}
|
}
|
||||||
$this->initDocument('json');
|
$this->initDocument('json');
|
||||||
$error_array = ['error' => $msg, 'request' => $_SERVER['REQUEST_URI']];
|
$error_array = ['error' => $msg, 'request' => $_SERVER['REQUEST_URI']];
|
||||||
|
@ -1743,9 +1739,14 @@ class action extends HTMLOutputter // lawsuit
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function menuItem(string $url, $text, ?string $title = null, bool $is_selected = false,
|
public function menuItem(
|
||||||
?string $id = null, $class = null): void
|
string $url,
|
||||||
{
|
$text,
|
||||||
|
?string $title = null,
|
||||||
|
bool $is_selected = false,
|
||||||
|
?string $id = null,
|
||||||
|
$class = null
|
||||||
|
): void {
|
||||||
// Added @id to li for some control.
|
// Added @id to li for some control.
|
||||||
// XXX: We might want to move this to htmloutputter.php
|
// XXX: We might want to move this to htmloutputter.php
|
||||||
$lattrs = [];
|
$lattrs = [];
|
||||||
|
|
|
@ -1,37 +1,31 @@
|
||||||
<?php
|
<?php
|
||||||
|
// This file is part of GNU social - https://www.gnu.org/software/social
|
||||||
|
//
|
||||||
|
// GNU social 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.
|
||||||
|
//
|
||||||
|
// GNU social 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 GNU social. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Server error action.
|
* Server error action.
|
||||||
*
|
*
|
||||||
* PHP version 5
|
* @category Action
|
||||||
*
|
* @package GNUsocial
|
||||||
* @category Action
|
* @author Evan Prodromou <evan@status.net>
|
||||||
* @package StatusNet
|
* @author Zach Copley <zach@status.net>
|
||||||
* @author Evan Prodromou <evan@status.net>
|
* @copyright 2008, 2009 StatusNet, Inc.
|
||||||
* @author Zach Copley <zach@status.net>
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||||
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
|
|
||||||
* @link http://status.net/
|
|
||||||
*
|
|
||||||
* StatusNet - the distributed open-source microblogging tool
|
|
||||||
* Copyright (C) 2008, 2009, StatusNet, 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
|
|
||||||
* 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/>.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('GNUSOCIAL')) {
|
defined('GNUSOCIAL') || die();
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class for displaying HTTP server errors
|
* Class for displaying HTTP server errors
|
||||||
|
@ -44,22 +38,23 @@ if (!defined('GNUSOCIAL')) {
|
||||||
*
|
*
|
||||||
* See: http://tools.ietf.org/html/rfc2616#section-10
|
* See: http://tools.ietf.org/html/rfc2616#section-10
|
||||||
*
|
*
|
||||||
* @category Action
|
* @category Action
|
||||||
* @package StatusNet
|
* @package GNUsocial
|
||||||
* @author Zach Copley <zach@status.net>
|
* @author Zach Copley <zach@status.net>
|
||||||
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||||
* @link http://status.net/
|
|
||||||
*/
|
*/
|
||||||
class ServerErrorAction extends ErrorAction
|
class ServerErrorAction extends ErrorAction
|
||||||
{
|
{
|
||||||
static $status = [500 => 'Internal Server Error',
|
public static $status = [
|
||||||
501 => 'Not Implemented',
|
500 => 'Internal Server Error',
|
||||||
502 => 'Bad Gateway',
|
501 => 'Not Implemented',
|
||||||
503 => 'Service Unavailable',
|
502 => 'Bad Gateway',
|
||||||
504 => 'Gateway Timeout',
|
503 => 'Service Unavailable',
|
||||||
505 => 'HTTP Version Not Supported'];
|
504 => 'Gateway Timeout',
|
||||||
|
505 => 'HTTP Version Not Supported'
|
||||||
|
];
|
||||||
|
|
||||||
function __construct($message = 'Error', $code = 500, $ex = null)
|
public function __construct($message = 'Error', $code = 500, $ex = null)
|
||||||
{
|
{
|
||||||
parent::__construct($message, $code);
|
parent::__construct($message, $code);
|
||||||
|
|
||||||
|
@ -88,10 +83,9 @@ class ServerErrorAction extends ErrorAction
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function extraHeaders()
|
public function extraHeaders()
|
||||||
{
|
{
|
||||||
$status_string = self::$status[$this->code];
|
http_response_code($this->code);
|
||||||
header('HTTP/1.1 ' . $this->code . ' ' . $status_string);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -100,9 +94,8 @@ class ServerErrorAction extends ErrorAction
|
||||||
* @return string page title
|
* @return string page title
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function title()
|
public function title()
|
||||||
{
|
{
|
||||||
return self::$status[$this->code];
|
return self::$status[$this->code];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,34 +1,31 @@
|
||||||
<?php
|
<?php
|
||||||
|
// This file is part of GNU social - https://www.gnu.org/software/social
|
||||||
|
//
|
||||||
|
// GNU social 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.
|
||||||
|
//
|
||||||
|
// GNU social 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 GNU social. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* StatusNet, the distributed open-source microblogging tool
|
|
||||||
*
|
|
||||||
* Base class for RSS 1.0 feed actions
|
* Base class for RSS 1.0 feed 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 Mail
|
* @category Mail
|
||||||
* @package StatusNet
|
* @package GNUsocial
|
||||||
* @author Evan Prodromou <evan@status.net>
|
* @author Evan Prodromou <evan@status.net>
|
||||||
* @author Earle Martin <earle@downlode.org>
|
* @author Earle Martin <earle@downlode.org>
|
||||||
* @copyright 2008-9 StatusNet, Inc.
|
* @copyright 2008, 2009 StatusNet, Inc.
|
||||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||||
* @link http://status.net/
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
defined('GNUSOCIAL') || die();
|
||||||
|
|
||||||
define('DEFAULT_RSS_LIMIT', 48);
|
define('DEFAULT_RSS_LIMIT', 48);
|
||||||
|
|
||||||
|
@ -36,10 +33,10 @@ class Rss10Action extends ManagedAction
|
||||||
{
|
{
|
||||||
// This will contain the details of each feed item's author and be used to generate SIOC data.
|
// This will contain the details of each feed item's author and be used to generate SIOC data.
|
||||||
|
|
||||||
var $creators = array();
|
public $creators = [];
|
||||||
var $limit = DEFAULT_RSS_LIMIT;
|
public $limit = DEFAULT_RSS_LIMIT;
|
||||||
var $notices = null;
|
public $notices = null;
|
||||||
var $tags_already_output = array();
|
public $tags_already_output = [];
|
||||||
|
|
||||||
public function isReadOnly($args)
|
public function isReadOnly($args)
|
||||||
{
|
{
|
||||||
|
@ -88,9 +85,9 @@ class Rss10Action extends ManagedAction
|
||||||
// for example if we need to set $this->target or something
|
// for example if we need to set $this->target or something
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_basic_auth_error()
|
public function show_basic_auth_error()
|
||||||
{
|
{
|
||||||
header('HTTP/1.1 401 Unauthorized');
|
http_response_code(401);
|
||||||
header('Content-Type: application/xml; charset=utf-8');
|
header('Content-Type: application/xml; charset=utf-8');
|
||||||
$this->startXML();
|
$this->startXML();
|
||||||
$this->elementStart('hash');
|
$this->elementStart('hash');
|
||||||
|
@ -119,20 +116,22 @@ class Rss10Action extends ManagedAction
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function getChannel()
|
public function getChannel()
|
||||||
{
|
{
|
||||||
return array('url' => '',
|
return [
|
||||||
'title' => '',
|
'url' => '',
|
||||||
'link' => '',
|
'title' => '',
|
||||||
'description' => '');
|
'link' => '',
|
||||||
|
'description' => '',
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
function getImage()
|
public function getImage()
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function showPage()
|
public function showPage()
|
||||||
{
|
{
|
||||||
$this->initRss();
|
$this->initRss();
|
||||||
$this->showChannel();
|
$this->showChannel();
|
||||||
|
@ -154,9 +153,8 @@ class Rss10Action extends ManagedAction
|
||||||
$this->endRss();
|
$this->endRss();
|
||||||
}
|
}
|
||||||
|
|
||||||
function showChannel()
|
public function showChannel()
|
||||||
{
|
{
|
||||||
|
|
||||||
$channel = $this->getChannel();
|
$channel = $this->getChannel();
|
||||||
$image = $this->getImage();
|
$image = $this->getImage();
|
||||||
|
|
||||||
|
@ -164,7 +162,9 @@ class Rss10Action extends ManagedAction
|
||||||
$this->element('title', null, $channel['title']);
|
$this->element('title', null, $channel['title']);
|
||||||
$this->element('link', null, $channel['link']);
|
$this->element('link', null, $channel['link']);
|
||||||
$this->element('description', null, $channel['description']);
|
$this->element('description', null, $channel['description']);
|
||||||
$this->element('cc:licence', array('rdf:resource' => common_config('license','url')));
|
$this->element('cc:licence', [
|
||||||
|
'rdf:resource' => common_config('license', 'url'),
|
||||||
|
]);
|
||||||
|
|
||||||
if ($image) {
|
if ($image) {
|
||||||
$this->element('image', array('rdf:resource' => $image));
|
$this->element('image', array('rdf:resource' => $image));
|
||||||
|
@ -185,7 +185,7 @@ class Rss10Action extends ManagedAction
|
||||||
$this->elementEnd('channel');
|
$this->elementEnd('channel');
|
||||||
}
|
}
|
||||||
|
|
||||||
function showImage()
|
public function showImage()
|
||||||
{
|
{
|
||||||
$image = $this->getImage();
|
$image = $this->getImage();
|
||||||
if ($image) {
|
if ($image) {
|
||||||
|
@ -198,7 +198,7 @@ class Rss10Action extends ManagedAction
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function showItem($notice)
|
public function showItem($notice)
|
||||||
{
|
{
|
||||||
$profile = $notice->getProfile();
|
$profile = $notice->getProfile();
|
||||||
$nurl = common_local_url('shownotice', array('notice' => $notice->id));
|
$nurl = common_local_url('shownotice', array('notice' => $notice->id));
|
||||||
|
@ -237,13 +237,17 @@ class Rss10Action extends ManagedAction
|
||||||
$this->element('sioc:reply_of', array('rdf:resource' => $replyurl));
|
$this->element('sioc:reply_of', array('rdf:resource' => $replyurl));
|
||||||
}
|
}
|
||||||
if (!empty($notice->conversation)) {
|
if (!empty($notice->conversation)) {
|
||||||
$conversationurl = common_local_url('conversation',
|
$conversationurl = common_local_url(
|
||||||
array('id' => $notice->conversation));
|
'conversation',
|
||||||
$this->element('sioc:has_discussion', array('rdf:resource' => $conversationurl));
|
['id' => $notice->conversation]
|
||||||
|
);
|
||||||
|
$this->element('sioc:has_discussion', [
|
||||||
|
'rdf:resource' => $conversationurl,
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
$attachments = $notice->attachments();
|
$attachments = $notice->attachments();
|
||||||
if($attachments){
|
if ($attachments) {
|
||||||
foreach($attachments as $attachment){
|
foreach ($attachments as $attachment) {
|
||||||
try {
|
try {
|
||||||
$enclosure = $attachment->getEnclosure();
|
$enclosure = $attachment->getEnclosure();
|
||||||
$attribs = array('rdf:resource' => $enclosure->url);
|
$attribs = array('rdf:resource' => $enclosure->url);
|
||||||
|
@ -274,7 +278,7 @@ class Rss10Action extends ManagedAction
|
||||||
while ($tag->fetch()) {
|
while ($tag->fetch()) {
|
||||||
$tagpage = common_local_url('tag', array('tag' => $tag->tag));
|
$tagpage = common_local_url('tag', array('tag' => $tag->tag));
|
||||||
|
|
||||||
if ( in_array($tag, $this->tags_already_output) ) {
|
if (in_array($tag, $this->tags_already_output)) {
|
||||||
$this->element('ctag:tagged', array('rdf:resource'=>$tagpage.'#concept'));
|
$this->element('ctag:tagged', array('rdf:resource'=>$tagpage.'#concept'));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -294,7 +298,7 @@ class Rss10Action extends ManagedAction
|
||||||
$this->creators[$creator_uri] = $profile;
|
$this->creators[$creator_uri] = $profile;
|
||||||
}
|
}
|
||||||
|
|
||||||
function showCreators()
|
public function showCreators()
|
||||||
{
|
{
|
||||||
foreach ($this->creators as $uri => $profile) {
|
foreach ($this->creators as $uri => $profile) {
|
||||||
$id = $profile->id;
|
$id = $profile->id;
|
||||||
|
@ -311,7 +315,7 @@ class Rss10Action extends ManagedAction
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function initRss()
|
public function initRss()
|
||||||
{
|
{
|
||||||
$channel = $this->getChannel();
|
$channel = $this->getChannel();
|
||||||
header('Content-Type: application/rdf+xml');
|
header('Content-Type: application/rdf+xml');
|
||||||
|
@ -351,7 +355,7 @@ class Rss10Action extends ManagedAction
|
||||||
$this->elementEnd('sioc:Site');
|
$this->elementEnd('sioc:Site');
|
||||||
}
|
}
|
||||||
|
|
||||||
function endRss()
|
public function endRss()
|
||||||
{
|
{
|
||||||
$this->elementEnd('rdf:RDF');
|
$this->elementEnd('rdf:RDF');
|
||||||
}
|
}
|
||||||
|
@ -361,7 +365,7 @@ class Rss10Action extends ManagedAction
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function lastModified()
|
public function lastModified()
|
||||||
{
|
{
|
||||||
if (empty($this->notices)) {
|
if (empty($this->notices)) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -376,4 +380,3 @@ class Rss10Action extends ManagedAction
|
||||||
return strtotime($this->notices[0]->created);
|
return strtotime($this->notices[0]->created);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -82,7 +82,7 @@ class ClosechannelAction extends Action
|
||||||
{
|
{
|
||||||
$this->channel->decrement();
|
$this->channel->decrement();
|
||||||
|
|
||||||
header('HTTP/1.1 204 No Content');
|
http_response_code(204);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,48 +1,39 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
// This file is part of GNU social - https://www.gnu.org/software/social
|
||||||
* StatusNet - the distributed open-source microblogging tool
|
//
|
||||||
* Copyright (C) 2011, StatusNet, Inc.
|
// GNU social is free software: you can redistribute it and/or modify
|
||||||
*
|
// it under the terms of the GNU Affero General Public License as published by
|
||||||
* action periodically pinged by a page to keep a channel alive
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
*
|
// (at your option) any later version.
|
||||||
* PHP version 5
|
//
|
||||||
*
|
// GNU social is distributed in the hope that it will be useful,
|
||||||
* This program is free software: you can redistribute it and/or modify
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* it under the terms of the GNU Affero General Public License as published by
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
// GNU Affero General Public License for more details.
|
||||||
* (at your option) any later version.
|
//
|
||||||
*
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
* This program is distributed in the hope that it will be useful,
|
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
|
||||||
* 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 Realtime
|
|
||||||
* @package StatusNet
|
|
||||||
* @author Evan Prodromou <evan@status.net>
|
|
||||||
* @copyright 2011 StatusNet, Inc.
|
|
||||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
|
|
||||||
* @link http://status.net/
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (!defined('STATUSNET')) {
|
|
||||||
// This check helps protect against security problems;
|
|
||||||
// your code file can't be executed directly from the web.
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Action periodically pinged by a page to keep a channel alive
|
* Action periodically pinged by a page to keep a channel alive
|
||||||
*
|
*
|
||||||
* @category Realtime
|
* @category Realtime
|
||||||
* @package StatusNet
|
* @package GNUsocial
|
||||||
* @author Evan Prodromou <evan@status.net>
|
* @author Evan Prodromou <evan@status.net>
|
||||||
* @copyright 2011 StatusNet, Inc.
|
* @copyright 2011 StatusNet, Inc.
|
||||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||||
* @link http://status.net/
|
*/
|
||||||
|
|
||||||
|
defined('GNUSOCIAL') || die();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Action periodically pinged by a page to keep a channel alive
|
||||||
|
*
|
||||||
|
* @category Realtime
|
||||||
|
* @package GNUsocial
|
||||||
|
* @author Evan Prodromou <evan@status.net>
|
||||||
|
* @copyright 2011 StatusNet, Inc.
|
||||||
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||||
*/
|
*/
|
||||||
class KeepalivechannelAction extends Action
|
class KeepalivechannelAction extends Action
|
||||||
{
|
{
|
||||||
|
@ -92,7 +83,7 @@ class KeepalivechannelAction extends Action
|
||||||
{
|
{
|
||||||
$this->channel->touch();
|
$this->channel->touch();
|
||||||
|
|
||||||
header('HTTP/1.1 204 No Content');
|
http_response_code(204);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,66 +1,64 @@
|
||||||
<?php
|
<?php
|
||||||
|
// This file is part of GNU social - https://www.gnu.org/software/social
|
||||||
|
//
|
||||||
|
// GNU social 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.
|
||||||
|
//
|
||||||
|
// GNU social 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 GNU social. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Client error action.
|
* Client error action.
|
||||||
*
|
*
|
||||||
* PHP version 5
|
* @category Action
|
||||||
*
|
* @package GNUsocial
|
||||||
* @category Action
|
* @author Evan Prodromou <evan@status.net>
|
||||||
* @package StatusNet
|
* @author Zach Copley <zach@status.net>
|
||||||
* @author Evan Prodromou <evan@status.net>
|
* @copyright 2008-2010 StatusNet, Inc.
|
||||||
* @author Zach Copley <zach@status.net>
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||||
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
|
|
||||||
* @link http://status.net/
|
|
||||||
*
|
|
||||||
* StatusNet - the distributed open-source microblogging tool
|
|
||||||
* Copyright (C) 2008-2010 StatusNet, 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
|
|
||||||
* 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/>.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
defined('GNUSOCIAL') || die();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class for displaying HTTP client errors
|
* Class for displaying HTTP client errors
|
||||||
*
|
*
|
||||||
* @category Action
|
* @category Action
|
||||||
* @package StatusNet
|
* @package GNUsocial
|
||||||
* @author Zach Copley <zach@status.net>
|
* @author Zach Copley <zach@status.net>
|
||||||
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||||
* @link http://status.net/
|
|
||||||
*/
|
*/
|
||||||
class ClientErrorAction extends ErrorAction
|
class ClientErrorAction extends ErrorAction
|
||||||
{
|
{
|
||||||
static $status = array(400 => 'Bad Request',
|
public static $status = [
|
||||||
401 => 'Unauthorized',
|
400 => 'Bad Request',
|
||||||
402 => 'Payment Required',
|
401 => 'Unauthorized',
|
||||||
403 => 'Forbidden',
|
402 => 'Payment Required',
|
||||||
404 => 'Not Found',
|
403 => 'Forbidden',
|
||||||
405 => 'Method Not Allowed',
|
404 => 'Not Found',
|
||||||
406 => 'Not Acceptable',
|
405 => 'Method Not Allowed',
|
||||||
407 => 'Proxy Authentication Required',
|
406 => 'Not Acceptable',
|
||||||
408 => 'Request Timeout',
|
407 => 'Proxy Authentication Required',
|
||||||
409 => 'Conflict',
|
408 => 'Request Timeout',
|
||||||
410 => 'Gone',
|
409 => 'Conflict',
|
||||||
411 => 'Length Required',
|
410 => 'Gone',
|
||||||
412 => 'Precondition Failed',
|
411 => 'Length Required',
|
||||||
413 => 'Request Entity Too Large',
|
412 => 'Precondition Failed',
|
||||||
414 => 'Request-URI Too Long',
|
413 => 'Request Entity Too Large',
|
||||||
415 => 'Unsupported Media Type',
|
414 => 'Request-URI Too Long',
|
||||||
416 => 'Requested Range Not Satisfiable',
|
415 => 'Unsupported Media Type',
|
||||||
417 => 'Expectation Failed');
|
416 => 'Requested Range Not Satisfiable',
|
||||||
|
417 => 'Expectation Failed'
|
||||||
|
];
|
||||||
|
|
||||||
function __construct($message='Error', $code=400)
|
public function __construct($message = 'Error', $code = 400)
|
||||||
{
|
{
|
||||||
parent::__construct($message, $code);
|
parent::__construct($message, $code);
|
||||||
$this->default = 400;
|
$this->default = 400;
|
||||||
|
@ -78,10 +76,9 @@ class ClientErrorAction extends ErrorAction
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function extraHeaders()
|
public function extraHeaders()
|
||||||
{
|
{
|
||||||
$status_string = @self::$status[$this->code];
|
http_response_code($this->code);
|
||||||
header('HTTP/1.1 '.$this->code.' '.$status_string);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -90,7 +87,7 @@ class ClientErrorAction extends ErrorAction
|
||||||
* @return page title
|
* @return page title
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function title()
|
public function title()
|
||||||
{
|
{
|
||||||
return @self::$status[$this->code];
|
return @self::$status[$this->code];
|
||||||
}
|
}
|
||||||
|
|
|
@ -1659,15 +1659,11 @@ function common_sql_weight($column, $dropoff)
|
||||||
return "SUM(EXP({$expr} / {$dropoff}))";
|
return "SUM(EXP({$expr} / {$dropoff}))";
|
||||||
}
|
}
|
||||||
|
|
||||||
function common_redirect($url, $code=307)
|
function common_redirect(string $url, int $code = 307): void
|
||||||
{
|
{
|
||||||
static $status = [301 => "Moved Permanently",
|
assert(in_array($code, [301, 302, 303, 307]));
|
||||||
302 => "Found",
|
http_response_code($code);
|
||||||
303 => "See Other",
|
header("Location: {$url}");
|
||||||
307 => "Temporary Redirect"];
|
|
||||||
|
|
||||||
header('HTTP/1.1 '.$code.' '.$status[$code]);
|
|
||||||
header("Location: $url");
|
|
||||||
header("Connection: close");
|
header("Connection: close");
|
||||||
|
|
||||||
$xo = new XMLOutputter();
|
$xo = new XMLOutputter();
|
||||||
|
@ -1678,7 +1674,7 @@ function common_redirect($url, $code=307)
|
||||||
);
|
);
|
||||||
$xo->element('a', ['href' => $url], $url);
|
$xo->element('a', ['href' => $url], $url);
|
||||||
$xo->endXML();
|
$xo->endXML();
|
||||||
exit;
|
die();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Stick the notice on the queue
|
// Stick the notice on the queue
|
||||||
|
|
|
@ -1,53 +1,44 @@
|
||||||
<?php
|
<?php
|
||||||
|
// This file is part of GNU social - https://www.gnu.org/software/social
|
||||||
|
//
|
||||||
|
// GNU social 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.
|
||||||
|
//
|
||||||
|
// GNU social 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 GNU social. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* StatusNet - the distributed open-source microblogging tool
|
|
||||||
* Copyright (C) 2011, StatusNet, Inc.
|
|
||||||
*
|
|
||||||
* An action that requires an API key
|
* An action that requires an API key
|
||||||
*
|
|
||||||
* PHP version 5
|
|
||||||
*
|
|
||||||
* 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 DomainStatusNetwork
|
* @category DomainStatusNetwork
|
||||||
* @package StatusNet
|
* @package GNUsocial
|
||||||
* @author Evan Prodromou <evan@status.net>
|
* @author Evan Prodromou <evan@status.net>
|
||||||
* @copyright 2011 StatusNet, Inc.
|
* @copyright 2011 StatusNet, Inc.
|
||||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||||
* @link http://status.net/
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('STATUSNET')) {
|
defined('GNUSOCIAL') || die();
|
||||||
// This check helps protect against security problems;
|
|
||||||
// your code file can't be executed directly from the web.
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An action that requires an API key
|
* An action that requires an API key
|
||||||
*
|
*
|
||||||
* @category General
|
* @category General
|
||||||
* @package StatusNet
|
* @package GNUsocial
|
||||||
* @author Evan Prodromou <evan@status.net>
|
* @author Evan Prodromou <evan@status.net>
|
||||||
* @copyright 2011 StatusNet, Inc.
|
* @copyright 2011 StatusNet, Inc.
|
||||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||||
* @link http://status.net/
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class GlobalApiAction extends Action
|
class GlobalApiAction extends Action
|
||||||
{
|
{
|
||||||
var $email;
|
public $email;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check for an API key, and throw an exception if it's not set
|
* Check for an API key, and throw an exception if it's not set
|
||||||
|
@ -57,7 +48,7 @@ class GlobalApiAction extends Action
|
||||||
* @return boolean continuation flag
|
* @return boolean continuation flag
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function prepare(array $args = array())
|
public function prepare(array $args = [])
|
||||||
{
|
{
|
||||||
GNUsocial::setApi(true); // reduce exception reports to aid in debugging
|
GNUsocial::setApi(true); // reduce exception reports to aid in debugging
|
||||||
|
|
||||||
|
@ -96,12 +87,12 @@ class GlobalApiAction extends Action
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function showError($message, $code=400)
|
public function showError($message, $code = 400)
|
||||||
{
|
{
|
||||||
$this->showOutput(array('error' => $message), $code);
|
$this->showOutput(array('error' => $message), $code);
|
||||||
}
|
}
|
||||||
|
|
||||||
function showSuccess($values=null, $code=200)
|
public function showSuccess($values = null, $code = 200)
|
||||||
{
|
{
|
||||||
if (empty($values)) {
|
if (empty($values)) {
|
||||||
$values = array();
|
$values = array();
|
||||||
|
@ -110,19 +101,17 @@ class GlobalApiAction extends Action
|
||||||
$this->showOutput($values, $code);
|
$this->showOutput($values, $code);
|
||||||
}
|
}
|
||||||
|
|
||||||
function showOutput($values, $code)
|
public function showOutput($values, $code)
|
||||||
{
|
{
|
||||||
if (array_key_exists($code, ClientErrorAction::$status)) {
|
if (
|
||||||
$status_string = ClientErrorAction::$status[$code];
|
!array_key_exists($code, ClientErrorAction::$status)
|
||||||
} else if (array_key_exists($code, ServerErrorAction::$status)) {
|
&& !array_key_exists($code, ServerErrorAction::$status)
|
||||||
$status_string = ServerErrorAction::$status[$code];
|
) {
|
||||||
} else {
|
|
||||||
// bad code!
|
// bad code!
|
||||||
$code = 500;
|
$code = 500;
|
||||||
$status_string = ServerErrorAction::$status[$code];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
header('HTTP/1.1 '.$code.' '.$status_string);
|
http_response_code($code);
|
||||||
|
|
||||||
header('Content-Type: application/json; charset=utf-8');
|
header('Content-Type: application/json; charset=utf-8');
|
||||||
print(json_encode($values));
|
print(json_encode($values));
|
||||||
|
|
|
@ -1,31 +1,28 @@
|
||||||
<?php
|
<?php
|
||||||
/*
|
// This file is part of GNU social - https://www.gnu.org/software/social
|
||||||
* StatusNet - the distributed open-source microblogging tool
|
//
|
||||||
* Copyright (C) 2010, StatusNet, Inc.
|
// GNU social is free software: you can redistribute it and/or modify
|
||||||
*
|
// it under the terms of the GNU Affero General Public License as published by
|
||||||
* This program is free software: you can redistribute it and/or modify
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
* it under the terms of the GNU Affero General Public License as published by
|
// (at your option) any later version.
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
//
|
||||||
* (at your option) any later version.
|
// GNU social is distributed in the hope that it will be useful,
|
||||||
*
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* This program is distributed in the hope that it will be useful,
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// GNU Affero General Public License for more details.
|
||||||
* 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 GNU social. If not, see <http://www.gnu.org/licenses/>.
|
||||||
* 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/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Integrated WebSub hub; lets us only ping them what need it.
|
* Integrated WebSub hub; lets us only ping them what need it.
|
||||||
* @package Hub
|
* @package Hub
|
||||||
* @maintainer Brion Vibber <brion@status.net>
|
* @author Brion Vibber <brion@status.net>
|
||||||
|
* @copyright 2010 StatusNet, Inc.
|
||||||
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('STATUSNET')) {
|
defined('GNUSOCIAL') || die();
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Things to consider...
|
* Things to consider...
|
||||||
|
@ -38,7 +35,7 @@ if (!defined('STATUSNET')) {
|
||||||
*/
|
*/
|
||||||
class PushHubAction extends Action
|
class PushHubAction extends Action
|
||||||
{
|
{
|
||||||
function arg($arg, $def=null)
|
public function arg($arg, $def = null)
|
||||||
{
|
{
|
||||||
// PHP converts '.'s in incoming var names to '_'s.
|
// PHP converts '.'s in incoming var names to '_'s.
|
||||||
// It also merges multiple values, which'll break hub.verify and hub.topic for publishing
|
// It also merges multiple values, which'll break hub.verify and hub.topic for publishing
|
||||||
|
@ -47,7 +44,7 @@ class PushHubAction extends Action
|
||||||
return parent::arg($arg, $def);
|
return parent::arg($arg, $def);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function prepare(array $args=array())
|
protected function prepare(array $args = [])
|
||||||
{
|
{
|
||||||
GNUsocial::setApi(true); // reduce exception reports to aid in debugging
|
GNUsocial::setApi(true); // reduce exception reports to aid in debugging
|
||||||
return parent::prepare($args);
|
return parent::prepare($args);
|
||||||
|
@ -62,11 +59,17 @@ class PushHubAction extends Action
|
||||||
$this->subunsub($mode);
|
$this->subunsub($mode);
|
||||||
break;
|
break;
|
||||||
case "publish":
|
case "publish":
|
||||||
// TRANS: Client exception.
|
throw new ClientException(
|
||||||
throw new ClientException(_m('Publishing outside feeds not supported.'), 400);
|
// TRANS: Client exception.
|
||||||
|
_m('Publishing outside feeds not supported.'),
|
||||||
|
400
|
||||||
|
);
|
||||||
default:
|
default:
|
||||||
// TRANS: Client exception. %s is a mode.
|
throw new ClientException(sprintf(
|
||||||
throw new ClientException(sprintf(_m('Unrecognized mode "%s".'),$mode), 400);
|
// TRANS: Client exception. %s is a mode.
|
||||||
|
_m('Unrecognized mode "%s".'), $mode),
|
||||||
|
400
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,7 +82,7 @@ class PushHubAction extends Action
|
||||||
* 204 No Content - already subscribed
|
* 204 No Content - already subscribed
|
||||||
* 400 Bad Request - rejecting this (not specifically spec'd)
|
* 400 Bad Request - rejecting this (not specifically spec'd)
|
||||||
*/
|
*/
|
||||||
function subunsub($mode)
|
public function subunsub($mode)
|
||||||
{
|
{
|
||||||
$callback = $this->argUrl('hub.callback');
|
$callback = $this->argUrl('hub.callback');
|
||||||
|
|
||||||
|
@ -87,22 +90,31 @@ class PushHubAction extends Action
|
||||||
$topic = $this->argUrl('hub.topic');
|
$topic = $this->argUrl('hub.topic');
|
||||||
if (!$this->recognizedFeed($topic)) {
|
if (!$this->recognizedFeed($topic)) {
|
||||||
common_debug('WebSub hub request had unrecognized feed topic=='._ve($topic));
|
common_debug('WebSub hub request had unrecognized feed topic=='._ve($topic));
|
||||||
// TRANS: Client exception. %s is a topic.
|
throw new ClientException(sprintf(
|
||||||
throw new ClientException(sprintf(_m('Unsupported hub.topic %s this hub only serves local user and group Atom feeds.'),$topic));
|
// TRANS: Client exception. %s is a topic.
|
||||||
|
_m('Unsupported hub.topic %s this hub only serves local user and group Atom feeds.'),
|
||||||
|
$topic
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
$lease = $this->arg('hub.lease_seconds', null);
|
$lease = $this->arg('hub.lease_seconds', null);
|
||||||
if ($mode == 'subscribe' && $lease != '' && !preg_match('/^\d+$/', $lease)) {
|
if ($mode == 'subscribe' && $lease != '' && !preg_match('/^\d+$/', $lease)) {
|
||||||
common_debug('WebSub hub request had invalid lease_seconds=='._ve($lease));
|
common_debug('WebSub hub request had invalid lease_seconds=='._ve($lease));
|
||||||
// TRANS: Client exception. %s is the invalid lease value.
|
// TRANS: Client exception. %s is the invalid lease value.
|
||||||
throw new ClientException(sprintf(_m('Invalid hub.lease "%s". It must be empty or positive integer.'),$lease));
|
throw new ClientException(sprintf(
|
||||||
|
_m('Invalid hub.lease "%s". It must be empty or positive integer.'),
|
||||||
|
$lease
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
$secret = $this->arg('hub.secret', null);
|
$secret = $this->arg('hub.secret', null);
|
||||||
if ($secret != '' && strlen($secret) >= 200) {
|
if ($secret != '' && strlen($secret) >= 200) {
|
||||||
common_debug('WebSub hub request had invalid secret=='._ve($secret));
|
common_debug('WebSub hub request had invalid secret=='._ve($secret));
|
||||||
// TRANS: Client exception. %s is the invalid hub secret.
|
throw new ClientException(sprintf(
|
||||||
throw new ClientException(sprintf(_m('Invalid hub.secret "%s". It must be under 200 bytes.'),$secret));
|
// TRANS: Client exception. %s is the invalid hub secret.
|
||||||
|
_m('Invalid hub.secret "%s". It must be under 200 bytes.'),
|
||||||
|
$secret
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
$sub = HubSub::getByHashkey($topic, $callback);
|
$sub = HubSub::getByHashkey($topic, $callback);
|
||||||
|
@ -126,10 +138,10 @@ class PushHubAction extends Action
|
||||||
$token = $this->arg('hub.verify_token', null); // TODO: deprecated
|
$token = $this->arg('hub.verify_token', null); // TODO: deprecated
|
||||||
if ($verify == 'sync') { // pre-0.4 PuSH
|
if ($verify == 'sync') { // pre-0.4 PuSH
|
||||||
$sub->verify($mode, $token);
|
$sub->verify($mode, $token);
|
||||||
header('HTTP/1.1 204 No Content');
|
http_response_code(204);
|
||||||
} else { // If $verify is not "sync", we might be using WebSub or PuSH 0.4
|
} else { // If $verify is not "sync", we might be using WebSub or PuSH 0.4
|
||||||
$sub->scheduleVerify($mode, $token); // If we were certain it's WebSub or PuSH 0.4, token could be removed
|
$sub->scheduleVerify($mode, $token); // If we were certain it's WebSub or PuSH 0.4, token could be removed
|
||||||
header('HTTP/1.1 202 Accepted');
|
http_response_code(202);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,16 +166,22 @@ class PushHubAction extends Action
|
||||||
case common_local_url('ApiTimelineUser', $params):
|
case common_local_url('ApiTimelineUser', $params):
|
||||||
$user = User::getKV('id', $id);
|
$user = User::getKV('id', $id);
|
||||||
if (!$user instanceof User) {
|
if (!$user instanceof User) {
|
||||||
// TRANS: Client exception. %s is a feed URL.
|
throw new ClientException(sprintf(
|
||||||
throw new ClientException(sprintf(_m('Invalid hub.topic "%s". User does not exist.'),$feed));
|
// TRANS: Client exception. %s is a feed URL.
|
||||||
|
_m('Invalid hub.topic "%s". User does not exist.'),
|
||||||
|
$feed
|
||||||
|
));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case common_local_url('ApiTimelineGroup', $params):
|
case common_local_url('ApiTimelineGroup', $params):
|
||||||
$group = Local_group::getKV('group_id', $id);
|
$group = Local_group::getKV('group_id', $id);
|
||||||
if (!$group instanceof Local_group) {
|
if (!$group instanceof Local_group) {
|
||||||
// TRANS: Client exception. %s is a feed URL.
|
throw new ClientException(sprintf(
|
||||||
throw new ClientException(sprintf(_m('Invalid hub.topic "%s". Local_group does not exist.'),$feed));
|
// TRANS: Client exception. %s is a feed URL.
|
||||||
|
_m('Invalid hub.topic "%s". Local_group does not exist.'),
|
||||||
|
$feed
|
||||||
|
));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -183,8 +201,11 @@ class PushHubAction extends Action
|
||||||
$list = Profile_list::getKV('id', $id);
|
$list = Profile_list::getKV('id', $id);
|
||||||
$user = User::getKV('id', $user);
|
$user = User::getKV('id', $user);
|
||||||
if (!$list instanceof Profile_list || !$user instanceof User || $list->tagger != $user->id) {
|
if (!$list instanceof Profile_list || !$user instanceof User || $list->tagger != $user->id) {
|
||||||
// TRANS: Client exception. %s is a feed URL.
|
throw new ClientException(sprintf(
|
||||||
throw new ClientException(sprintf(_m('Invalid hub.topic %s; list does not exist.'),$feed));
|
// TRANS: Client exception. %s is a feed URL.
|
||||||
|
_m('Invalid hub.topic %s; list does not exist.'),
|
||||||
|
$feed
|
||||||
|
));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -207,9 +228,13 @@ class PushHubAction extends Action
|
||||||
'allowed_schemes' => array('http', 'https'));
|
'allowed_schemes' => array('http', 'https'));
|
||||||
$validate = new Validate();
|
$validate = new Validate();
|
||||||
if (!$validate->uri($url, $params)) {
|
if (!$validate->uri($url, $params)) {
|
||||||
// TRANS: Client exception.
|
throw new ClientException(sprintf(
|
||||||
// TRANS: %1$s is this argument to the method this exception occurs in, %2$s is a URL.
|
// TRANS: Client exception.
|
||||||
throw new ClientException(sprintf(_m('Invalid URL passed for %1$s: "%2$s"'),$arg,$url));
|
// TRANS: %1$s is this argument to the method this exception occurs in, %2$s is a URL.
|
||||||
|
_m('Invalid URL passed for %1$s: "%2$s"'),
|
||||||
|
$arg,
|
||||||
|
$url
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
Event::handle('UrlBlacklistTest', array($url));
|
Event::handle('UrlBlacklistTest', array($url));
|
||||||
|
|
|
@ -1,73 +1,67 @@
|
||||||
<?php
|
<?php
|
||||||
|
// This file is part of GNU social - https://www.gnu.org/software/social
|
||||||
|
//
|
||||||
|
// GNU social 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.
|
||||||
|
//
|
||||||
|
// GNU social 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 GNU social. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* StatusNet, the distributed open-source microblogging tool
|
|
||||||
*
|
|
||||||
* Settings for OpenID
|
* Settings for OpenID
|
||||||
*
|
*
|
||||||
* 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 Settings
|
* @category Settings
|
||||||
* @package StatusNet
|
* @package GNUsocial
|
||||||
* @author Craig Andrews <candrews@integralblue.com>
|
* @author Craig Andrews <candrews@integralblue.com>
|
||||||
* @copyright 2008-2009 StatusNet, Inc.
|
* @copyright 2008-2009 StatusNet, Inc.
|
||||||
* @copyright 2009 Free Software Foundation, Inc http://www.fsf.org
|
* @copyright 2009 Free Software Foundation, Inc http://www.fsf.org
|
||||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||||
* @link http://status.net/
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('STATUSNET')) {
|
defined('GNUSOCIAL') || die();
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
require_once INSTALLDIR.'/plugins/OpenID/openid.php';
|
require_once INSTALLDIR . '/plugins/OpenID/openid.php';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Settings for OpenID
|
* Settings for OpenID
|
||||||
*
|
*
|
||||||
* Lets users add, edit and delete OpenIDs from their account
|
* Lets users add, edit and delete OpenIDs from their account
|
||||||
*
|
*
|
||||||
* @category Settings
|
* @category Settings
|
||||||
* @package StatusNet
|
* @package GNUsocial
|
||||||
* @author Craig Andrews <candrews@integralblue.com>
|
* @author Craig Andrews <candrews@integralblue.com>
|
||||||
* @copyright 2009 Free Software Foundation, Inc http://www.fsf.org
|
* @copyright 2009 Free Software Foundation, Inc http://www.fsf.org
|
||||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||||
* @link http://status.net/
|
|
||||||
*/
|
*/
|
||||||
class OpenidserverAction extends Action
|
class OpenidserverAction extends Action
|
||||||
{
|
{
|
||||||
var $oserver;
|
public $oserver;
|
||||||
|
|
||||||
function prepare(array $args = array())
|
public function prepare(array $args = [])
|
||||||
{
|
{
|
||||||
parent::prepare($args);
|
parent::prepare($args);
|
||||||
$this->oserver = oid_server();
|
$this->oserver = oid_server();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
parent::handle();
|
parent::handle();
|
||||||
$request = $this->oserver->decodeRequest();
|
$request = $this->oserver->decodeRequest();
|
||||||
if (in_array($request->mode, array('checkid_immediate',
|
if (in_array($request->mode, array('checkid_immediate',
|
||||||
'checkid_setup'))) {
|
'checkid_setup'))) {
|
||||||
if (!$this->scoped instanceof Profile) {
|
if (!$this->scoped instanceof Profile) {
|
||||||
if($request->immediate){
|
if ($request->immediate) {
|
||||||
//cannot prompt the user to login in immediate mode, so answer false
|
//cannot prompt the user to login in immediate mode, so answer false
|
||||||
$response = $this->generateDenyResponse($request);
|
$response = $this->generateDenyResponse($request);
|
||||||
}else{
|
} else {
|
||||||
// Go log in, and then come back.
|
// Go log in, and then come back.
|
||||||
//
|
//
|
||||||
// Note: 303 redirect rather than 307 to avoid
|
// Note: 303 redirect rather than 307 to avoid
|
||||||
|
@ -76,14 +70,19 @@ class OpenidserverAction extends Action
|
||||||
common_set_returnto($_SERVER['REQUEST_URI']);
|
common_set_returnto($_SERVER['REQUEST_URI']);
|
||||||
common_redirect(common_local_url('login'), 303);
|
common_redirect(common_local_url('login'), 303);
|
||||||
}
|
}
|
||||||
} elseif (in_array($request->identity, $this->scoped->getAliases()) || $request->idSelect()) {
|
} elseif (
|
||||||
$user_openid_trustroot = User_openid_trustroot::pkeyGet(
|
in_array($request->identity, $this->scoped->getAliases())
|
||||||
array('user_id'=>$this->scoped->getID(), 'trustroot'=>$request->trust_root));
|
|| $request->idSelect()
|
||||||
if(empty($user_openid_trustroot)){
|
) {
|
||||||
if($request->immediate){
|
$user_openid_trustroot = User_openid_trustroot::pkeyGet([
|
||||||
|
'user_id' => $this->scoped->getID(),
|
||||||
|
'trustroot' => $request->trust_root,
|
||||||
|
]);
|
||||||
|
if (empty($user_openid_trustroot)) {
|
||||||
|
if ($request->immediate) {
|
||||||
//cannot prompt the user to trust this trust root in immediate mode, so answer false
|
//cannot prompt the user to trust this trust root in immediate mode, so answer false
|
||||||
$response = $this->generateDenyResponse($request);
|
$response = $this->generateDenyResponse($request);
|
||||||
}else{
|
} else {
|
||||||
common_ensure_session();
|
common_ensure_session();
|
||||||
$_SESSION['openid_trust_root'] = $request->trust_root;
|
$_SESSION['openid_trust_root'] = $request->trust_root;
|
||||||
$allowResponse = $this->generateAllowResponse($request, $this->scoped);
|
$allowResponse = $this->generateAllowResponse($request, $this->scoped);
|
||||||
|
@ -108,51 +107,61 @@ class OpenidserverAction extends Action
|
||||||
$response = $this->generateDenyResponse($request);
|
$response = $this->generateDenyResponse($request);
|
||||||
} else {
|
} else {
|
||||||
//invalid
|
//invalid
|
||||||
// TRANS: OpenID plugin client error given trying to add an unauthorised OpenID to a user (403).
|
$this->clientError(sprintf(
|
||||||
// TRANS: %s is a request identity.
|
// TRANS: OpenID plugin client error given trying to add an unauthorised OpenID to a user (403).
|
||||||
$this->clientError(sprintf(_m('You are not authorized to use the identity %s.'),$request->identity),$code=403);
|
// TRANS: %s is a request identity.
|
||||||
|
_m('You are not authorized to use the identity %s.'),
|
||||||
|
$request->identity
|
||||||
|
), 403);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$response = $this->oserver->handleRequest($request);
|
$response = $this->oserver->handleRequest($request);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($response){
|
if ($response) {
|
||||||
$response = $this->oserver->encodeResponse($response);
|
$response = $this->oserver->encodeResponse($response);
|
||||||
if ($response->code != AUTH_OPENID_HTTP_OK) {
|
if ($response->code != AUTH_OPENID_HTTP_OK) {
|
||||||
header(sprintf("HTTP/1.1 %d ", $response->code),
|
http_response_code($response->code);
|
||||||
true, $response->code);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if($response->headers){
|
if ($response->headers) {
|
||||||
foreach ($response->headers as $k => $v) {
|
foreach ($response->headers as $k => $v) {
|
||||||
header("$k: $v");
|
header("$k: $v");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->raw($response->body);
|
$this->raw($response->body);
|
||||||
}else{
|
} else {
|
||||||
// TRANS: OpenID plugin client error given when not getting a response for a given OpenID provider (500).
|
$this->clientError(
|
||||||
$this->clientError(_m('Just an OpenID provider. Nothing to see here, move along...'),$code=500);
|
// TRANS: OpenID plugin client error given when not getting a response for a given OpenID provider (500).
|
||||||
|
_m('Just an OpenID provider. Nothing to see here, move along...'),
|
||||||
|
500
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function generateAllowResponse($request, Profile $profile){
|
public function generateAllowResponse($request, Profile $profile)
|
||||||
|
{
|
||||||
$response = $request->answer(true, null, $profile->getUrl());
|
$response = $request->answer(true, null, $profile->getUrl());
|
||||||
$user = $profile->getUser();
|
$user = $profile->getUser();
|
||||||
|
|
||||||
$sreg_data = array(
|
$sreg_data = [
|
||||||
'fullname' => $profile->getFullname(),
|
'fullname' => $profile->getFullname(),
|
||||||
'nickname' => $profile->getNickname(),
|
'nickname' => $profile->getNickname(),
|
||||||
'email' => $user->email, // FIXME: Should we make the email optional?
|
'email' => $user->email, // FIXME: Should we make the email optional?
|
||||||
'language' => $user->language,
|
'language' => $user->language,
|
||||||
'timezone' => $user->timezone);
|
'timezone' => $user->timezone,
|
||||||
|
];
|
||||||
$sreg_request = Auth_OpenID_SRegRequest::fromOpenIDRequest($request);
|
$sreg_request = Auth_OpenID_SRegRequest::fromOpenIDRequest($request);
|
||||||
$sreg_response = Auth_OpenID_SRegResponse::extractResponse(
|
$sreg_response = Auth_OpenID_SRegResponse::extractResponse(
|
||||||
$sreg_request, $sreg_data);
|
$sreg_request,
|
||||||
|
$sreg_data
|
||||||
|
);
|
||||||
$sreg_response->toMessage($response->fields);
|
$sreg_response->toMessage($response->fields);
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
function generateDenyResponse($request){
|
public function generateDenyResponse($request)
|
||||||
|
{
|
||||||
$response = $request->answer(false);
|
$response = $request->answer(false);
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,36 +1,31 @@
|
||||||
<?php
|
<?php
|
||||||
|
// This file is part of GNU social - https://www.gnu.org/software/social
|
||||||
|
//
|
||||||
|
// GNU social 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.
|
||||||
|
//
|
||||||
|
// GNU social 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 GNU social. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This test class pretends to be an RSS aggregator. It logs notifications
|
* This test class pretends to be an RSS aggregator. It logs notifications
|
||||||
* from the cloud.
|
* from the cloud.
|
||||||
*
|
*
|
||||||
* PHP version 5
|
* @category Plugin
|
||||||
*
|
* @package GNUsocial
|
||||||
* @category Plugin
|
* @author Zach Copley <zach@status.net>
|
||||||
* @package StatusNet
|
* @copyright 2009 StatusNet, Inc.
|
||||||
* @author Zach Copley <zach@status.net>
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||||
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
|
|
||||||
* @link http://status.net/
|
|
||||||
*
|
|
||||||
* StatusNet - the distributed open-source microblogging tool
|
|
||||||
* Copyright (C) 2009, StatusNet, 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
|
|
||||||
* 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/>.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('STATUSNET')) {
|
defined('GNUSOCIAL') || die();
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dummy aggregator that acts as a proper notification handler. It
|
* Dummy aggregator that acts as a proper notification handler. It
|
||||||
|
@ -39,16 +34,15 @@ if (!defined('STATUSNET')) {
|
||||||
* and easily test things end-to-end. I'm leaving it in here as it
|
* and easily test things end-to-end. I'm leaving it in here as it
|
||||||
* may be useful for developing the plugin further.
|
* may be useful for developing the plugin further.
|
||||||
*
|
*
|
||||||
* @category Plugin
|
* @category Plugin
|
||||||
* @package StatusNet
|
* @package GNUsocial
|
||||||
* @author Zach Copley <zach@status.net>
|
* @author Zach Copley <zach@status.net>
|
||||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||||
* @link http://status.net/
|
|
||||||
*/
|
*/
|
||||||
class LoggingAggregatorAction extends Action
|
class LoggingAggregatorAction extends Action
|
||||||
{
|
{
|
||||||
var $challenge = null;
|
public $challenge = null;
|
||||||
var $url = null;
|
public $url = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialization.
|
* Initialization.
|
||||||
|
@ -57,7 +51,7 @@ class LoggingAggregatorAction extends Action
|
||||||
*
|
*
|
||||||
* @return boolean false if user doesn't exist
|
* @return boolean false if user doesn't exist
|
||||||
*/
|
*/
|
||||||
function prepare(array $args = array())
|
public function prepare(array $args = [])
|
||||||
{
|
{
|
||||||
parent::prepare($args);
|
parent::prepare($args);
|
||||||
|
|
||||||
|
@ -77,7 +71,7 @@ class LoggingAggregatorAction extends Action
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
parent::handle();
|
parent::handle();
|
||||||
|
|
||||||
|
@ -106,7 +100,7 @@ class LoggingAggregatorAction extends Action
|
||||||
}
|
}
|
||||||
|
|
||||||
header('Content-Type: text/xml');
|
header('Content-Type: text/xml');
|
||||||
Echo "<notifyResult success='true' msg='Thanks for the update.' />\n";
|
echo "<notifyResult success='true' msg='Thanks for the update.' />\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->ip = $_SERVER['REMOTE_ADDR'];
|
$this->ip = $_SERVER['REMOTE_ADDR'];
|
||||||
|
@ -123,9 +117,9 @@ class LoggingAggregatorAction extends Action
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function showError($msg)
|
public function showError($msg)
|
||||||
{
|
{
|
||||||
header('HTTP/1.1 400 Bad Request');
|
http_response_code(400);
|
||||||
header('Content-Type: text/xml');
|
header('Content-Type: text/xml');
|
||||||
echo "<?xml version='1.0'?>\n";
|
echo "<?xml version='1.0'?>\n";
|
||||||
echo "<notifyResult success='false' msg='$msg' />\n";
|
echo "<notifyResult success='false' msg='$msg' />\n";
|
||||||
|
|
Loading…
Reference in New Issue
Block a user