diff --git a/actions/apistatusesshow.php b/actions/apistatusesshow.php
index ea3453948b..704efbdbff 100644
--- a/actions/apistatusesshow.php
+++ b/actions/apistatusesshow.php
@@ -1,26 +1,24 @@
.
+
/**
- * StatusNet, the distributed open-source microblogging tool
- *
* 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 .
- *
* @category API
- * @package StatusNet
+ * @package GNUsocial
* @author Craig Andrews
* @author Evan Prodromou
* @author Jeffery To
@@ -30,31 +28,29 @@
* @author Zach Copley
* @copyright 2009 StatusNet, Inc.
* @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
- * @link http://status.net/
+ * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
-if (!defined('GNUSOCIAL')) { exit(1); }
+defined('GNUSOCIAL') || die();
/**
* Returns the notice specified by id as a Twitter-style status and inline user
*
- * @category API
- * @package StatusNet
- * @author Craig Andrews
- * @author Evan Prodromou
- * @author Jeffery To
- * @author Tom Blankenship
- * @author Mike Cochrane
- * @author Robin Millette
- * @author Zach Copley
- * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
- * @link http://status.net/
+ * @category API
+ * @package GNUsocial
+ * @author Craig Andrews
+ * @author Evan Prodromou
+ * @author Jeffery To
+ * @author Tom Blankenship
+ * @author Mike Cochrane
+ * @author Robin Millette
+ * @author Zach Copley
+ * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
class ApiStatusesShowAction extends ApiPrivateAuthAction
{
- var $notice_id = null;
- var $notice = null;
+ public $notice_id = null;
+ public $notice = null;
/**
* Take arguments for running
@@ -131,7 +127,7 @@ class ApiStatusesShowAction extends ApiPrivateAuthAction
*
* @return void
*/
- function showNotice()
+ public function showNotice()
{
switch ($this->format) {
case 'xml':
@@ -158,9 +154,9 @@ class ApiStatusesShowAction extends ApiPrivateAuthAction
* @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
*/
- function lastModified()
+ public function lastModified()
{
return strtotime($this->notice->created);
}
@@ -181,7 +177,7 @@ class ApiStatusesShowAction extends ApiPrivateAuthAction
*
* @return string etag
*/
- function etag()
+ public function etag()
{
return '"' . implode(
':',
@@ -194,7 +190,7 @@ class ApiStatusesShowAction extends ApiPrivateAuthAction
. '"';
}
- function deleteNotice()
+ public function deleteNotice()
{
if ($this->format != 'atom') {
// 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?
- header('HTTP/1.1 200 OK');
+ http_response_code(200);
header('Content-Type: text/plain');
// TRANS: Confirmation of notice deletion in API. %d is the ID (number) of the deleted notice.
print(sprintf(_('Deleted notice %d'), $this->notice->id));
diff --git a/actions/apitimelineuser.php b/actions/apitimelineuser.php
index 78e7412992..e6bc51e617 100644
--- a/actions/apitimelineuser.php
+++ b/actions/apitimelineuser.php
@@ -1,26 +1,24 @@
.
+
/**
- * StatusNet, the distributed open-source microblogging tool
- *
* 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 .
- *
* @category API
- * @package StatusNet
+ * @package GNUsocial
* @author Craig Andrews
* @author Evan Prodromou
* @author Jeffery To
@@ -30,30 +28,26 @@
* @author Zach Copley
* @copyright 2009 StatusNet, Inc.
* @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
- * @link http://status.net/
+ * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
-if (!defined('GNUSOCIAL')) {
- exit(1);
-}
+defined('GNUSOCIAL') || die();
/**
* Returns the most recent notices (default 20) posted by the authenticating
* user. Another user's timeline can be requested via the id parameter. This
* is the API equivalent of the user profile web page.
*
- * @category API
- * @package StatusNet
- * @author Craig Andrews
- * @author Evan Prodromou
- * @author Jeffery To
- * @author mac65
- * @author Mike Cochrane
- * @author Robin Millette
- * @author Zach Copley
- * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
- * @link http://status.net/
+ * @category API
+ * @package GNUsocial
+ * @author Craig Andrews
+ * @author Evan Prodromou
+ * @author Jeffery To
+ * @author mac65
+ * @author Mike Cochrane
+ * @author Robin Millette
+ * @author Zach Copley
+ * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
class ApiTimelineUserAction extends ApiBareAuthAction
{
@@ -101,16 +95,14 @@ class ApiTimelineUserAction extends ApiBareAuthAction
if (!empty($this->notices) && (count($this->notices) > 0)) {
$last = count($this->notices) - 1;
- return '"' . implode(
- ':',
- array($this->arg('action'),
- common_user_cache_hash($this->scoped),
- common_language(),
- $this->target->getID(),
- strtotime($this->notices[0]->created),
- strtotime($this->notices[$last]->created))
- )
- . '"';
+ return '"' . implode(':', [
+ $this->arg('action'),
+ common_user_cache_hash($this->scoped),
+ common_language(),
+ $this->target->getID(),
+ strtotime($this->notices[0]->created),
+ strtotime($this->notices[$last]->created),
+ ]) . '"';
}
return null;
@@ -250,7 +242,7 @@ class ApiTimelineUserAction extends ApiBareAuthAction
}
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(),
'format' => 'atom')));
$this->showSingleAtomStatus($stored);
diff --git a/classes/Status_network.php b/classes/Status_network.php
index 770de50d93..f6812c175c 100644
--- a/classes/Status_network.php
+++ b/classes/Status_network.php
@@ -1,25 +1,27 @@
.
+
/**
* Table Definition for status_network
*
- * 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 .
+ * @copyright 2009 StatusNet, Inc.
+ * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
-if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }
+defined('GNUSOCIAL') || die();
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 $logo; // varchar(191) not 255 because utf8mb4 takes more space
public $created; // datetime() not_null
- public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
+ public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
/* 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
- $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
// 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
public static $cache = null;
public static $cacheInitialized = false;
- static $base = null;
- static $wildcard = null;
+ public static $base = null;
+ public static $wildcard = null;
/**
* @param string $dbhost
@@ -70,8 +73,13 @@ class Status_network extends Safe_DataObject
* @param string $dbname
* @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;
$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;
if (!is_array($servers)) {
$servers = array($servers);
- }
- foreach($servers as $server) {
+ }
+ foreach ($servers as $server) {
$parts = explode(':', $server);
$server = $parts[0];
if (count($parts) > 1) {
@@ -112,11 +120,12 @@ class Status_network extends Safe_DataObject
self::$base = $dbname;
}
- static function cacheKey($k, $v) {
+ public static function cacheKey($k, $v)
+ {
return 'gnusocial:' . self::$base . ':status_network:'.$k.':'.$v;
}
- static function memGet($k, $v)
+ public static function memGet($k, $v)
{
if (!self::$cache) {
return self::getKV($k, $v);
@@ -136,7 +145,7 @@ class Status_network extends Safe_DataObject
return $sn;
}
- function decache()
+ public function decache()
{
if (self::$cache) {
$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)) {
- $dataObject->decache(); # might be different keys
+ // might be different keys
+ $dataObject->decache();
}
return parent::update($dataObject);
}
@@ -158,7 +168,7 @@ class Status_network extends Safe_DataObject
/**
* DB_DataObject doesn't allow updating keys (even non-primary)
*/
- function updateKeys(&$orig)
+ public function updateKeys(&$orig)
{
$this->_connect();
foreach (array('hostname', 'pathname') as $k) {
@@ -183,9 +193,10 @@ class Status_network extends Safe_DataObject
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);
}
@@ -194,7 +205,7 @@ class Status_network extends Safe_DataObject
* @param string $wildcard hostname suffix to match wildcard config
* @return mixed Status_network or null
*/
- static function getFromHostname($servername, $wildcard)
+ public static function getFromHostname($servername, $wildcard)
{
$sn = null;
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 $wildcard hostname suffix to match wildcard config
*/
- static function setupSite($servername, $pathname, $wildcard)
+ public static function setupSite($servername, $pathname, $wildcard)
{
global $config;
@@ -241,10 +252,14 @@ class Status_network extends Safe_DataObject
empty($_SERVER['HTTPS']) &&
0 != strcasecmp($sn->hostname, $servername)) {
$sn->redirectTo('http://'.$sn->hostname.$_SERVER['REQUEST_URI']);
- } else if (!empty($_SERVER['HTTPS']) &&
- 0 != strcasecmp($sn->hostname, $servername) &&
- 0 != strcasecmp($sn->nickname.'.'.$wildcard, $servername)) {
- $sn->redirectTo('https://'.$sn->nickname.'.'.$wildcard.$_SERVER['REQUEST_URI']);
+ } elseif (
+ !empty($_SERVER['HTTPS'])
+ && strcasecmp($sn->hostname, $servername) !== 0
+ && strcasecmp($sn->nickname . '.' . $wildcard, $servername) !== 0
+ ) {
+ $sn->redirectTo(
+ "https://{$sn->nickname}.{$wildcard}{$_SERVER['REQUEST_URI']}"
+ );
}
$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/
// LGPL
- function redirectTo($destination)
+ public function redirectTo($destination)
{
$old = 'http'.
(($_SERVER['HTTPS'] == 'on') ? 'S' : '').
@@ -295,15 +310,15 @@ class Status_network extends Safe_DataObject
return false;
}
- header('HTTP/1.1 301 Moved Permanently');
- header("Location: $destination");
+ http_response_code(301);
+ header("Location: {$destination}");
- print "$destination\n";
+ echo "{$destination}\n";
exit;
}
- function getServerName()
+ public function getServerName()
{
if (!empty($this->hostname)) {
return $this->hostname;
@@ -316,7 +331,7 @@ class Status_network extends Safe_DataObject
* Return site meta-info tags as an array
* @return array of strings
*/
- function getTags()
+ public function getTags()
{
return Status_network_tag::getTags($this->site_id);
}
@@ -326,7 +341,7 @@ class Status_network extends Safe_DataObject
* @param array tags
* @fixme only add/remove differentials
*/
- function setTags(array $tags)
+ public function setTags(array $tags)
{
$this->clearTags();
foreach ($tags as $tag) {
@@ -347,13 +362,13 @@ class Status_network extends Safe_DataObject
return true;
}
- function clearTags()
+ public function clearTags()
{
$tag = new Status_network_tag();
$tag->site_id = $this->site_id;
if ($tag->find()) {
- while($tag->fetch()) {
+ while ($tag->fetch()) {
$tag->delete();
}
}
@@ -366,7 +381,7 @@ class Status_network extends Safe_DataObject
* @param string $tag
* @return bool
*/
- function hasTag($tag)
+ public function hasTag($tag)
{
return in_array($tag, $this->getTags());
}
diff --git a/lib/action/action.php b/lib/action/action.php
index ffc74294f9..874222607b 100644
--- a/lib/action/action.php
+++ b/lib/action/action.php
@@ -150,11 +150,9 @@ class action extends HTMLOutputter // lawsuit
$code = 400;
}
- $status_string = ClientErrorAction::$status[$code];
-
switch ($format) {
case 'xml':
- header("HTTP/1.1 {$code} {$status_string}");
+ http_response_code($code);
$this->initDocument('xml');
$this->elementStart('hash');
$this->element('error', null, $msg);
@@ -164,7 +162,7 @@ class action extends HTMLOutputter // lawsuit
break;
case 'json':
if (!isset($this->callback)) {
- header("HTTP/1.1 {$code} {$status_string}");
+ http_response_code($code);
}
$this->initDocument('json');
$error_array = ['error' => $msg, 'request' => $_SERVER['REQUEST_URI']];
@@ -172,7 +170,7 @@ class action extends HTMLOutputter // lawsuit
$this->endDocument('json');
break;
case 'text':
- header("HTTP/1.1 {$code} {$status_string}");
+ http_response_code($code);
header('Content-Type: text/plain; charset=utf-8');
echo $msg;
break;
@@ -411,7 +409,7 @@ class action extends HTMLOutputter // lawsuit
// If this check fails, ignore the if-modified-since below.
$checked = true;
if ($this->_hasEtag($etag, $if_none_match)) {
- header('HTTP/1.1 304 Not Modified');
+ http_response_code(304);
// Better way to do this?
exit(0);
}
@@ -422,7 +420,7 @@ class action extends HTMLOutputter // lawsuit
$if_modified_since = $_SERVER['HTTP_IF_MODIFIED_SINCE'];
$ims = strtotime($if_modified_since);
if ($lm <= $ims) {
- header('HTTP/1.1 304 Not Modified');
+ http_response_code(304);
// Better way to do this?
exit(0);
}
@@ -505,11 +503,9 @@ class action extends HTMLOutputter // lawsuit
$code = 500;
}
- $status_string = ServerErrorAction::$status[$code];
-
switch ($format) {
case 'xml':
- header("HTTP/1.1 {$code} {$status_string}");
+ http_response_code($code);
$this->initDocument('xml');
$this->elementStart('hash');
$this->element('error', null, $msg);
@@ -519,7 +515,7 @@ class action extends HTMLOutputter // lawsuit
break;
case 'json':
if (!isset($this->callback)) {
- header("HTTP/1.1 {$code} {$status_string}");
+ http_response_code($code);
}
$this->initDocument('json');
$error_array = ['error' => $msg, 'request' => $_SERVER['REQUEST_URI']];
@@ -1743,9 +1739,14 @@ class action extends HTMLOutputter // lawsuit
*
* @return void
*/
- public function menuItem(string $url, $text, ?string $title = null, bool $is_selected = false,
- ?string $id = null, $class = null): void
- {
+ public function menuItem(
+ string $url,
+ $text,
+ ?string $title = null,
+ bool $is_selected = false,
+ ?string $id = null,
+ $class = null
+ ): void {
// Added @id to li for some control.
// XXX: We might want to move this to htmloutputter.php
$lattrs = [];
diff --git a/lib/action/servererroraction.php b/lib/action/servererroraction.php
index da2a337109..ebb77e760f 100644
--- a/lib/action/servererroraction.php
+++ b/lib/action/servererroraction.php
@@ -1,37 +1,31 @@
.
/**
* Server error action.
*
- * PHP version 5
- *
- * @category Action
- * @package StatusNet
- * @author Evan Prodromou
- * @author Zach Copley
- * @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 .
+ * @category Action
+ * @package GNUsocial
+ * @author Evan Prodromou
+ * @author Zach Copley
+ * @copyright 2008, 2009 StatusNet, Inc.
+ * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
-if (!defined('GNUSOCIAL')) {
- exit(1);
-}
+defined('GNUSOCIAL') || die();
/**
* Class for displaying HTTP server errors
@@ -44,22 +38,23 @@ if (!defined('GNUSOCIAL')) {
*
* See: http://tools.ietf.org/html/rfc2616#section-10
*
- * @category Action
- * @package StatusNet
- * @author Zach Copley
- * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
- * @link http://status.net/
+ * @category Action
+ * @package GNUsocial
+ * @author Zach Copley
+ * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
class ServerErrorAction extends ErrorAction
{
- static $status = [500 => 'Internal Server Error',
- 501 => 'Not Implemented',
- 502 => 'Bad Gateway',
- 503 => 'Service Unavailable',
- 504 => 'Gateway Timeout',
- 505 => 'HTTP Version Not Supported'];
+ public static $status = [
+ 500 => 'Internal Server Error',
+ 501 => 'Not Implemented',
+ 502 => 'Bad Gateway',
+ 503 => 'Service Unavailable',
+ 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);
@@ -88,10 +83,9 @@ class ServerErrorAction extends ErrorAction
*
* @return void
*/
- function extraHeaders()
+ public function extraHeaders()
{
- $status_string = self::$status[$this->code];
- header('HTTP/1.1 ' . $this->code . ' ' . $status_string);
+ http_response_code($this->code);
}
/**
@@ -100,9 +94,8 @@ class ServerErrorAction extends ErrorAction
* @return string page title
*/
- function title()
+ public function title()
{
return self::$status[$this->code];
}
-
}
diff --git a/lib/feeds/rss10action.php b/lib/feeds/rss10action.php
index 6940ab4319..120c364535 100644
--- a/lib/feeds/rss10action.php
+++ b/lib/feeds/rss10action.php
@@ -1,34 +1,31 @@
.
+
/**
- * StatusNet, the distributed open-source microblogging tool
- *
* 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 .
- *
* @category Mail
- * @package StatusNet
+ * @package GNUsocial
* @author Evan Prodromou
* @author Earle Martin
- * @copyright 2008-9 StatusNet, Inc.
- * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
- * @link http://status.net/
+ * @copyright 2008, 2009 StatusNet, Inc.
+ * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
-if (!defined('GNUSOCIAL')) { exit(1); }
+defined('GNUSOCIAL') || die();
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.
- var $creators = array();
- var $limit = DEFAULT_RSS_LIMIT;
- var $notices = null;
- var $tags_already_output = array();
+ public $creators = [];
+ public $limit = DEFAULT_RSS_LIMIT;
+ public $notices = null;
+ public $tags_already_output = [];
public function isReadOnly($args)
{
@@ -88,9 +85,9 @@ class Rss10Action extends ManagedAction
// 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');
$this->startXML();
$this->elementStart('hash');
@@ -119,20 +116,22 @@ class Rss10Action extends ManagedAction
* @return array
*/
- function getChannel()
+ public function getChannel()
{
- return array('url' => '',
- 'title' => '',
- 'link' => '',
- 'description' => '');
+ return [
+ 'url' => '',
+ 'title' => '',
+ 'link' => '',
+ 'description' => '',
+ ];
}
- function getImage()
+ public function getImage()
{
return null;
}
- function showPage()
+ public function showPage()
{
$this->initRss();
$this->showChannel();
@@ -154,9 +153,8 @@ class Rss10Action extends ManagedAction
$this->endRss();
}
- function showChannel()
+ public function showChannel()
{
-
$channel = $this->getChannel();
$image = $this->getImage();
@@ -164,7 +162,9 @@ class Rss10Action extends ManagedAction
$this->element('title', null, $channel['title']);
$this->element('link', null, $channel['link']);
$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) {
$this->element('image', array('rdf:resource' => $image));
@@ -185,7 +185,7 @@ class Rss10Action extends ManagedAction
$this->elementEnd('channel');
}
- function showImage()
+ public function showImage()
{
$image = $this->getImage();
if ($image) {
@@ -198,7 +198,7 @@ class Rss10Action extends ManagedAction
}
}
- function showItem($notice)
+ public function showItem($notice)
{
$profile = $notice->getProfile();
$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));
}
if (!empty($notice->conversation)) {
- $conversationurl = common_local_url('conversation',
- array('id' => $notice->conversation));
- $this->element('sioc:has_discussion', array('rdf:resource' => $conversationurl));
+ $conversationurl = common_local_url(
+ 'conversation',
+ ['id' => $notice->conversation]
+ );
+ $this->element('sioc:has_discussion', [
+ 'rdf:resource' => $conversationurl,
+ ]);
}
$attachments = $notice->attachments();
- if($attachments){
- foreach($attachments as $attachment){
+ if ($attachments) {
+ foreach ($attachments as $attachment) {
try {
$enclosure = $attachment->getEnclosure();
$attribs = array('rdf:resource' => $enclosure->url);
@@ -274,7 +278,7 @@ class Rss10Action extends ManagedAction
while ($tag->fetch()) {
$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'));
continue;
}
@@ -294,7 +298,7 @@ class Rss10Action extends ManagedAction
$this->creators[$creator_uri] = $profile;
}
- function showCreators()
+ public function showCreators()
{
foreach ($this->creators as $uri => $profile) {
$id = $profile->id;
@@ -311,7 +315,7 @@ class Rss10Action extends ManagedAction
}
}
- function initRss()
+ public function initRss()
{
$channel = $this->getChannel();
header('Content-Type: application/rdf+xml');
@@ -351,7 +355,7 @@ class Rss10Action extends ManagedAction
$this->elementEnd('sioc:Site');
}
- function endRss()
+ public function endRss()
{
$this->elementEnd('rdf:RDF');
}
@@ -361,7 +365,7 @@ class Rss10Action extends ManagedAction
*
*/
- function lastModified()
+ public function lastModified()
{
if (empty($this->notices)) {
return null;
@@ -376,4 +380,3 @@ class Rss10Action extends ManagedAction
return strtotime($this->notices[0]->created);
}
}
-
diff --git a/lib/modules/Realtime/actions/closechannel.php b/lib/modules/Realtime/actions/closechannel.php
index dd4a87bc45..54d6c58195 100644
--- a/lib/modules/Realtime/actions/closechannel.php
+++ b/lib/modules/Realtime/actions/closechannel.php
@@ -82,7 +82,7 @@ class ClosechannelAction extends Action
{
$this->channel->decrement();
- header('HTTP/1.1 204 No Content');
+ http_response_code(204);
return;
}
diff --git a/lib/modules/Realtime/actions/keepalivechannel.php b/lib/modules/Realtime/actions/keepalivechannel.php
index 0a397beec3..0409a28200 100644
--- a/lib/modules/Realtime/actions/keepalivechannel.php
+++ b/lib/modules/Realtime/actions/keepalivechannel.php
@@ -1,48 +1,39 @@
.
- *
- * @category Realtime
- * @package StatusNet
- * @author Evan Prodromou
- * @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);
-}
+// 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 .
/**
* Action periodically pinged by a page to keep a channel alive
*
* @category Realtime
- * @package StatusNet
+ * @package GNUsocial
* @author Evan Prodromou
* @copyright 2011 StatusNet, Inc.
- * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
- * @link http://status.net/
+ * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
+ */
+
+defined('GNUSOCIAL') || die();
+
+/**
+ * Action periodically pinged by a page to keep a channel alive
+ *
+ * @category Realtime
+ * @package GNUsocial
+ * @author Evan Prodromou
+ * @copyright 2011 StatusNet, Inc.
+ * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
class KeepalivechannelAction extends Action
{
@@ -92,7 +83,7 @@ class KeepalivechannelAction extends Action
{
$this->channel->touch();
- header('HTTP/1.1 204 No Content');
+ http_response_code(204);
return;
}
diff --git a/lib/ui/clienterroraction.php b/lib/ui/clienterroraction.php
index 5c4ef37d18..ec4a4112c1 100644
--- a/lib/ui/clienterroraction.php
+++ b/lib/ui/clienterroraction.php
@@ -1,66 +1,64 @@
.
+
/**
* Client error action.
*
- * PHP version 5
- *
- * @category Action
- * @package StatusNet
- * @author Evan Prodromou
- * @author Zach Copley
- * @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 .
+ * @category Action
+ * @package GNUsocial
+ * @author Evan Prodromou
+ * @author Zach Copley
+ * @copyright 2008-2010 StatusNet, Inc.
+ * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
-if (!defined('GNUSOCIAL')) { exit(1); }
+defined('GNUSOCIAL') || die();
/**
* Class for displaying HTTP client errors
*
- * @category Action
- * @package StatusNet
- * @author Zach Copley
- * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
- * @link http://status.net/
+ * @category Action
+ * @package GNUsocial
+ * @author Zach Copley
+ * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
class ClientErrorAction extends ErrorAction
{
- static $status = array(400 => 'Bad Request',
- 401 => 'Unauthorized',
- 402 => 'Payment Required',
- 403 => 'Forbidden',
- 404 => 'Not Found',
- 405 => 'Method Not Allowed',
- 406 => 'Not Acceptable',
- 407 => 'Proxy Authentication Required',
- 408 => 'Request Timeout',
- 409 => 'Conflict',
- 410 => 'Gone',
- 411 => 'Length Required',
- 412 => 'Precondition Failed',
- 413 => 'Request Entity Too Large',
- 414 => 'Request-URI Too Long',
- 415 => 'Unsupported Media Type',
- 416 => 'Requested Range Not Satisfiable',
- 417 => 'Expectation Failed');
+ public static $status = [
+ 400 => 'Bad Request',
+ 401 => 'Unauthorized',
+ 402 => 'Payment Required',
+ 403 => 'Forbidden',
+ 404 => 'Not Found',
+ 405 => 'Method Not Allowed',
+ 406 => 'Not Acceptable',
+ 407 => 'Proxy Authentication Required',
+ 408 => 'Request Timeout',
+ 409 => 'Conflict',
+ 410 => 'Gone',
+ 411 => 'Length Required',
+ 412 => 'Precondition Failed',
+ 413 => 'Request Entity Too Large',
+ 414 => 'Request-URI Too Long',
+ 415 => 'Unsupported Media Type',
+ 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);
$this->default = 400;
@@ -78,10 +76,9 @@ class ClientErrorAction extends ErrorAction
*
* @return void
*/
- function extraHeaders()
+ public function extraHeaders()
{
- $status_string = @self::$status[$this->code];
- header('HTTP/1.1 '.$this->code.' '.$status_string);
+ http_response_code($this->code);
}
/**
@@ -90,7 +87,7 @@ class ClientErrorAction extends ErrorAction
* @return page title
*/
- function title()
+ public function title()
{
return @self::$status[$this->code];
}
diff --git a/lib/util/util.php b/lib/util/util.php
index 1570332046..f2d1659162 100644
--- a/lib/util/util.php
+++ b/lib/util/util.php
@@ -1659,15 +1659,11 @@ function common_sql_weight($column, $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",
- 302 => "Found",
- 303 => "See Other",
- 307 => "Temporary Redirect"];
-
- header('HTTP/1.1 '.$code.' '.$status[$code]);
- header("Location: $url");
+ assert(in_array($code, [301, 302, 303, 307]));
+ http_response_code($code);
+ header("Location: {$url}");
header("Connection: close");
$xo = new XMLOutputter();
@@ -1678,7 +1674,7 @@ function common_redirect($url, $code=307)
);
$xo->element('a', ['href' => $url], $url);
$xo->endXML();
- exit;
+ die();
}
// Stick the notice on the queue
diff --git a/plugins/DomainStatusNetwork/actions/globalapi.php b/plugins/DomainStatusNetwork/actions/globalapi.php
index 7a9e4fe92d..063e93e62e 100644
--- a/plugins/DomainStatusNetwork/actions/globalapi.php
+++ b/plugins/DomainStatusNetwork/actions/globalapi.php
@@ -1,53 +1,44 @@
.
+
/**
- * StatusNet - the distributed open-source microblogging tool
- * Copyright (C) 2011, StatusNet, Inc.
- *
* 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 .
*
* @category DomainStatusNetwork
- * @package StatusNet
+ * @package GNUsocial
* @author Evan Prodromou
* @copyright 2011 StatusNet, Inc.
- * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
- * @link http://status.net/
+ * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
-if (!defined('STATUSNET')) {
- // This check helps protect against security problems;
- // your code file can't be executed directly from the web.
- exit(1);
-}
+defined('GNUSOCIAL') || die();
/**
* An action that requires an API key
*
* @category General
- * @package StatusNet
+ * @package GNUsocial
* @author Evan Prodromou
* @copyright 2011 StatusNet, Inc.
- * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
- * @link http://status.net/
+ * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
class GlobalApiAction extends Action
{
- var $email;
+ public $email;
/**
* 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
*/
- function prepare(array $args = array())
+ public function prepare(array $args = [])
{
GNUsocial::setApi(true); // reduce exception reports to aid in debugging
@@ -96,12 +87,12 @@ class GlobalApiAction extends Action
return true;
}
- function showError($message, $code=400)
+ public function showError($message, $code = 400)
{
$this->showOutput(array('error' => $message), $code);
}
- function showSuccess($values=null, $code=200)
+ public function showSuccess($values = null, $code = 200)
{
if (empty($values)) {
$values = array();
@@ -110,19 +101,17 @@ class GlobalApiAction extends Action
$this->showOutput($values, $code);
}
- function showOutput($values, $code)
+ public function showOutput($values, $code)
{
- if (array_key_exists($code, ClientErrorAction::$status)) {
- $status_string = ClientErrorAction::$status[$code];
- } else if (array_key_exists($code, ServerErrorAction::$status)) {
- $status_string = ServerErrorAction::$status[$code];
- } else {
+ if (
+ !array_key_exists($code, ClientErrorAction::$status)
+ && !array_key_exists($code, ServerErrorAction::$status)
+ ) {
// bad code!
$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');
print(json_encode($values));
diff --git a/plugins/OStatus/actions/pushhub.php b/plugins/OStatus/actions/pushhub.php
index 8cc9cbc302..91fb376292 100644
--- a/plugins/OStatus/actions/pushhub.php
+++ b/plugins/OStatus/actions/pushhub.php
@@ -1,31 +1,28 @@
.
- */
+// 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 .
/**
* Integrated WebSub hub; lets us only ping them what need it.
- * @package Hub
- * @maintainer Brion Vibber
+ * @package Hub
+ * @author Brion Vibber
+ * @copyright 2010 StatusNet, Inc.
+ * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
-if (!defined('STATUSNET')) {
- exit(1);
-}
+defined('GNUSOCIAL') || die();
/**
* Things to consider...
@@ -38,7 +35,7 @@ if (!defined('STATUSNET')) {
*/
class PushHubAction extends Action
{
- function arg($arg, $def=null)
+ public function arg($arg, $def = null)
{
// PHP converts '.'s in incoming var names to '_'s.
// 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);
}
- protected function prepare(array $args=array())
+ protected function prepare(array $args = [])
{
GNUsocial::setApi(true); // reduce exception reports to aid in debugging
return parent::prepare($args);
@@ -62,11 +59,17 @@ class PushHubAction extends Action
$this->subunsub($mode);
break;
case "publish":
- // TRANS: Client exception.
- throw new ClientException(_m('Publishing outside feeds not supported.'), 400);
+ throw new ClientException(
+ // TRANS: Client exception.
+ _m('Publishing outside feeds not supported.'),
+ 400
+ );
default:
- // TRANS: Client exception. %s is a mode.
- throw new ClientException(sprintf(_m('Unrecognized mode "%s".'),$mode), 400);
+ throw new ClientException(sprintf(
+ // 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
* 400 Bad Request - rejecting this (not specifically spec'd)
*/
- function subunsub($mode)
+ public function subunsub($mode)
{
$callback = $this->argUrl('hub.callback');
@@ -87,22 +90,31 @@ class PushHubAction extends Action
$topic = $this->argUrl('hub.topic');
if (!$this->recognizedFeed($topic)) {
common_debug('WebSub hub request had unrecognized feed topic=='._ve($topic));
- // TRANS: Client exception. %s is a topic.
- throw new ClientException(sprintf(_m('Unsupported hub.topic %s this hub only serves local user and group Atom feeds.'),$topic));
+ throw new ClientException(sprintf(
+ // 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);
if ($mode == 'subscribe' && $lease != '' && !preg_match('/^\d+$/', $lease)) {
common_debug('WebSub hub request had invalid lease_seconds=='._ve($lease));
// 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);
if ($secret != '' && strlen($secret) >= 200) {
common_debug('WebSub hub request had invalid secret=='._ve($secret));
- // TRANS: Client exception. %s is the invalid hub secret.
- throw new ClientException(sprintf(_m('Invalid hub.secret "%s". It must be under 200 bytes.'),$secret));
+ throw new ClientException(sprintf(
+ // 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);
@@ -126,10 +138,10 @@ class PushHubAction extends Action
$token = $this->arg('hub.verify_token', null); // TODO: deprecated
if ($verify == 'sync') { // pre-0.4 PuSH
$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
$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):
$user = User::getKV('id', $id);
if (!$user instanceof User) {
- // TRANS: Client exception. %s is a feed URL.
- throw new ClientException(sprintf(_m('Invalid hub.topic "%s". User does not exist.'),$feed));
+ throw new ClientException(sprintf(
+ // TRANS: Client exception. %s is a feed URL.
+ _m('Invalid hub.topic "%s". User does not exist.'),
+ $feed
+ ));
}
return true;
case common_local_url('ApiTimelineGroup', $params):
$group = Local_group::getKV('group_id', $id);
if (!$group instanceof Local_group) {
- // TRANS: Client exception. %s is a feed URL.
- throw new ClientException(sprintf(_m('Invalid hub.topic "%s". Local_group does not exist.'),$feed));
+ throw new ClientException(sprintf(
+ // TRANS: Client exception. %s is a feed URL.
+ _m('Invalid hub.topic "%s". Local_group does not exist.'),
+ $feed
+ ));
}
return true;
}
@@ -183,8 +201,11 @@ class PushHubAction extends Action
$list = Profile_list::getKV('id', $id);
$user = User::getKV('id', $user);
if (!$list instanceof Profile_list || !$user instanceof User || $list->tagger != $user->id) {
- // TRANS: Client exception. %s is a feed URL.
- throw new ClientException(sprintf(_m('Invalid hub.topic %s; list does not exist.'),$feed));
+ throw new ClientException(sprintf(
+ // TRANS: Client exception. %s is a feed URL.
+ _m('Invalid hub.topic %s; list does not exist.'),
+ $feed
+ ));
}
return true;
}
@@ -207,9 +228,13 @@ class PushHubAction extends Action
'allowed_schemes' => array('http', 'https'));
$validate = new Validate();
if (!$validate->uri($url, $params)) {
- // TRANS: Client exception.
- // TRANS: %1$s is this argument to the method this exception occurs in, %2$s is a URL.
- throw new ClientException(sprintf(_m('Invalid URL passed for %1$s: "%2$s"'),$arg,$url));
+ throw new ClientException(sprintf(
+ // TRANS: Client exception.
+ // 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));
diff --git a/plugins/OpenID/actions/openidserver.php b/plugins/OpenID/actions/openidserver.php
index 6cc3061edd..a1c2a3cc68 100644
--- a/plugins/OpenID/actions/openidserver.php
+++ b/plugins/OpenID/actions/openidserver.php
@@ -1,73 +1,67 @@
.
+
/**
- * StatusNet, the distributed open-source microblogging tool
- *
* 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 .
- *
* @category Settings
- * @package StatusNet
- * @author Craig Andrews
+ * @package GNUsocial
+ * @author Craig Andrews
* @copyright 2008-2009 StatusNet, Inc.
* @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
- * @link http://status.net/
+ * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
-if (!defined('STATUSNET')) {
- exit(1);
-}
+defined('GNUSOCIAL') || die();
-require_once INSTALLDIR.'/plugins/OpenID/openid.php';
+require_once INSTALLDIR . '/plugins/OpenID/openid.php';
/**
* Settings for OpenID
*
* Lets users add, edit and delete OpenIDs from their account
*
- * @category Settings
- * @package StatusNet
- * @author Craig Andrews
+ * @category Settings
+ * @package GNUsocial
+ * @author Craig Andrews
* @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
- * @link http://status.net/
+ * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
class OpenidserverAction extends Action
{
- var $oserver;
+ public $oserver;
- function prepare(array $args = array())
+ public function prepare(array $args = [])
{
parent::prepare($args);
$this->oserver = oid_server();
return true;
}
- function handle()
+ public function handle()
{
parent::handle();
$request = $this->oserver->decodeRequest();
if (in_array($request->mode, array('checkid_immediate',
'checkid_setup'))) {
if (!$this->scoped instanceof Profile) {
- if($request->immediate){
+ if ($request->immediate) {
//cannot prompt the user to login in immediate mode, so answer false
$response = $this->generateDenyResponse($request);
- }else{
+ } else {
// Go log in, and then come back.
//
// Note: 303 redirect rather than 307 to avoid
@@ -76,14 +70,19 @@ class OpenidserverAction extends Action
common_set_returnto($_SERVER['REQUEST_URI']);
common_redirect(common_local_url('login'), 303);
}
- } elseif (in_array($request->identity, $this->scoped->getAliases()) || $request->idSelect()) {
- $user_openid_trustroot = User_openid_trustroot::pkeyGet(
- array('user_id'=>$this->scoped->getID(), 'trustroot'=>$request->trust_root));
- if(empty($user_openid_trustroot)){
- if($request->immediate){
+ } elseif (
+ in_array($request->identity, $this->scoped->getAliases())
+ || $request->idSelect()
+ ) {
+ $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
$response = $this->generateDenyResponse($request);
- }else{
+ } else {
common_ensure_session();
$_SESSION['openid_trust_root'] = $request->trust_root;
$allowResponse = $this->generateAllowResponse($request, $this->scoped);
@@ -108,51 +107,61 @@ class OpenidserverAction extends Action
$response = $this->generateDenyResponse($request);
} else {
//invalid
- // TRANS: OpenID plugin client error given trying to add an unauthorised OpenID to a user (403).
- // TRANS: %s is a request identity.
- $this->clientError(sprintf(_m('You are not authorized to use the identity %s.'),$request->identity),$code=403);
+ $this->clientError(sprintf(
+ // TRANS: OpenID plugin client error given trying to add an unauthorised OpenID to a user (403).
+ // TRANS: %s is a request identity.
+ _m('You are not authorized to use the identity %s.'),
+ $request->identity
+ ), 403);
}
} else {
$response = $this->oserver->handleRequest($request);
}
- if($response){
+ if ($response) {
$response = $this->oserver->encodeResponse($response);
if ($response->code != AUTH_OPENID_HTTP_OK) {
- header(sprintf("HTTP/1.1 %d ", $response->code),
- true, $response->code);
+ http_response_code($response->code);
}
- if($response->headers){
+ if ($response->headers) {
foreach ($response->headers as $k => $v) {
header("$k: $v");
}
}
$this->raw($response->body);
- }else{
- // TRANS: OpenID plugin client error given when not getting a response for a given OpenID provider (500).
- $this->clientError(_m('Just an OpenID provider. Nothing to see here, move along...'),$code=500);
+ } else {
+ $this->clientError(
+ // 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());
$user = $profile->getUser();
- $sreg_data = array(
+ $sreg_data = [
'fullname' => $profile->getFullname(),
'nickname' => $profile->getNickname(),
'email' => $user->email, // FIXME: Should we make the email optional?
'language' => $user->language,
- 'timezone' => $user->timezone);
+ 'timezone' => $user->timezone,
+ ];
$sreg_request = Auth_OpenID_SRegRequest::fromOpenIDRequest($request);
$sreg_response = Auth_OpenID_SRegResponse::extractResponse(
- $sreg_request, $sreg_data);
+ $sreg_request,
+ $sreg_data
+ );
$sreg_response->toMessage($response->fields);
return $response;
}
- function generateDenyResponse($request){
+ public function generateDenyResponse($request)
+ {
$response = $request->answer(false);
return $response;
}
diff --git a/plugins/RSSCloud/actions/loggingaggregator.php b/plugins/RSSCloud/actions/loggingaggregator.php
index 7ef9e65cbf..598df8d191 100644
--- a/plugins/RSSCloud/actions/loggingaggregator.php
+++ b/plugins/RSSCloud/actions/loggingaggregator.php
@@ -1,36 +1,31 @@
.
+
/**
* This test class pretends to be an RSS aggregator. It logs notifications
* from the cloud.
*
- * PHP version 5
- *
- * @category Plugin
- * @package StatusNet
- * @author Zach Copley
- * @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 .
+ * @category Plugin
+ * @package GNUsocial
+ * @author Zach Copley
+ * @copyright 2009 StatusNet, Inc.
+ * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
-if (!defined('STATUSNET')) {
- exit(1);
-}
+defined('GNUSOCIAL') || die();
/**
* 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
* may be useful for developing the plugin further.
*
- * @category Plugin
- * @package StatusNet
- * @author Zach Copley
- * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
- * @link http://status.net/
+ * @category Plugin
+ * @package GNUsocial
+ * @author Zach Copley
+ * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
class LoggingAggregatorAction extends Action
{
- var $challenge = null;
- var $url = null;
+ public $challenge = null;
+ public $url = null;
/**
* Initialization.
@@ -57,7 +51,7 @@ class LoggingAggregatorAction extends Action
*
* @return boolean false if user doesn't exist
*/
- function prepare(array $args = array())
+ public function prepare(array $args = [])
{
parent::prepare($args);
@@ -77,7 +71,7 @@ class LoggingAggregatorAction extends Action
*
* @return void
*/
- function handle()
+ public function handle()
{
parent::handle();
@@ -106,7 +100,7 @@ class LoggingAggregatorAction extends Action
}
header('Content-Type: text/xml');
- Echo "\n";
+ echo "\n";
}
$this->ip = $_SERVER['REMOTE_ADDR'];
@@ -123,9 +117,9 @@ class LoggingAggregatorAction extends Action
*
* @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');
echo "\n";
echo "\n";