From 8fc1142e81a45c348ef713e9c4e89778c27480e3 Mon Sep 17 00:00:00 2001
From: ipranjal
Date: Sun, 22 Sep 2024 03:26:20 +0530
Subject: [PATCH 01/17] feat: remove toro, serve now uses Http\Request and
returns Http\Response
---
Idno/Common/Page.php | 15 +++++----
Idno/Core/Hook.php | 40 +++++++++++++++++++++++
Idno/Core/Http/Request.php | 11 +++++++
Idno/Core/Http/Response.php | 11 +++++++
Idno/Core/Idno.php | 27 +++++++++++++++
Idno/Core/PageHandler.php | 65 ++++++++++++++++++++++++++++++++++++-
composer.json | 2 +-
composer.lock | 16 ++++-----
index.php | 7 ++--
9 files changed, 175 insertions(+), 19 deletions(-)
create mode 100644 Idno/Core/Hook.php
create mode 100644 Idno/Core/Http/Request.php
create mode 100644 Idno/Core/Http/Response.php
diff --git a/Idno/Common/Page.php b/Idno/Common/Page.php
index 32ccf31a91..30fab515c7 100644
--- a/Idno/Common/Page.php
+++ b/Idno/Common/Page.php
@@ -18,6 +18,7 @@
namespace Idno\Common {
use Idno\Entities\User;
+ use Idno\Core\Http\Response;
abstract class Page extends \Idno\Common\Component
{
@@ -166,7 +167,8 @@ function setResponse(int $code)
{
$code = (int)$code;
$this->response = $code;
- http_response_code($this->response);
+ \Idno\Core\Idno::site()->response()->setStatusCode($code);
+
}
/**
@@ -818,14 +820,15 @@ function goneContent()
function noContent()
{
$this->setResponse(404);
- http_response_code($this->response);
+
+ // http_response_code($this->response);
+ \Idno\Core\Idno::site()->response()->headers->remove('X-Known-CSRF-Ts');
+ \Idno\Core\Idno::site()->response()->headers->remove('X-Known-CSRF-Token');
- header_remove('X-Known-CSRF-Ts');
- header_remove('X-Known-CSRF-Token');
$t = \Idno\Core\Idno::site()->template();
- $t->__(array('body' => $t->draw('pages/404'), 'title' => \Idno\Core\Idno::site()->language()->_('This page can\'t be found.')))->drawPage();
- exit;
+ $content = $t->__(array('body' => $t->draw('pages/404'), 'title' => \Idno\Core\Idno::site()->language()->_('This page can\'t be found.')))->drawPage(false);
+ \Idno\Core\Idno::site()->response()->setContent($content);
}
/**
diff --git a/Idno/Core/Hook.php b/Idno/Core/Hook.php
new file mode 100644
index 0000000000..302daa6c2b
--- /dev/null
+++ b/Idno/Core/Hook.php
@@ -0,0 +1,40 @@
+hooks[$hook_name][] = $fn;
+ }
+
+ public static function fire($hook_name, $params = null)
+ {
+ $instance = self::get_instance();
+ if (isset($instance->hooks[$hook_name])) {
+ foreach ($instance->hooks[$hook_name] as $fn) {
+ call_user_func_array($fn, array(&$params));
+ }
+ }
+ }
+
+ public static function get_instance()
+ {
+ if (empty(self::$instance)) {
+ self::$instance = new Hook();
+ }
+ return self::$instance;
+ }
+ }
+}
\ No newline at end of file
diff --git a/Idno/Core/Http/Request.php b/Idno/Core/Http/Request.php
new file mode 100644
index 0000000000..3affe5cd3b
--- /dev/null
+++ b/Idno/Core/Http/Request.php
@@ -0,0 +1,11 @@
+request = Request::createFromGlobals();
+ $this->response = new \Idno\Core\Http\Response();
$this->routes = new PageHandler();
$this->dispatcher = new EventDispatcher();
$this->config = new Config();
@@ -307,6 +314,26 @@ function &events() : ?EventDispatcher
return $this->dispatcher;
}
+ /**
+ * Return the request object loaded as part of this site
+ *
+ * @return \Idno\Core\Http\Request
+ */
+ function &request() : ?Request
+ {
+ return $this->request;
+ }
+
+ /**
+ * Return the response object loaded as part of this site
+ *
+ * @return \Idno\Core\Http\Response
+ */
+ function &response() : ?Response
+ {
+ return $this->response;
+ }
+
/**
* Access to the EventQueue for dispatching events
* asynchronously
diff --git a/Idno/Core/PageHandler.php b/Idno/Core/PageHandler.php
index 93cbb463e0..b6ce8e5faf 100644
--- a/Idno/Core/PageHandler.php
+++ b/Idno/Core/PageHandler.php
@@ -12,7 +12,7 @@
/**
* Routing class.
*/
- class PageHandler extends \Toro implements \ArrayAccess, \Iterator
+ class PageHandler implements \ArrayAccess, \Iterator
{
private $routes = [];
@@ -28,6 +28,69 @@ function routeTokens()
);
}
+ public static function serve($routes): \Idno\Core\Http\Response
+ {
+ Hook::fire('before_request', compact('routes'));
+
+ $request_method = strtolower(Idno::site()->request()->getMethod());
+ $path_info = '/';
+
+ if (! empty(Idno::site()->request()->getPathInfo())) {
+ $path_info = Idno::site()->request()->getPathInfo();
+ }
+
+ $discovered_handler = null;
+ $regex_matches = array();
+
+ if (isset($routes[$path_info])) {
+ $discovered_handler = $routes[$path_info];
+ } elseif ($routes) {
+ $tokens = array(
+ ':string' => '([a-zA-Z]+)',
+ ':number' => '([0-9]+)',
+ ':alpha' => '([a-zA-Z0-9-_]+)'
+ );
+ foreach ($routes as $pattern => $handler_name) {
+ $pattern = strtr($pattern, $tokens);
+ if (preg_match('#^/?' . $pattern . '/?$#', $path_info, $matches)) {
+ $discovered_handler = $handler_name;
+ $regex_matches = $matches;
+ break;
+ }
+ }
+ }
+
+ $result = null;
+ $handler_instance = null;
+
+ if ($discovered_handler) {
+ if (is_string($discovered_handler)) {
+ $handler_instance = new $discovered_handler();
+ } elseif (is_callable($discovered_handler)) {
+ $handler_instance = $discovered_handler();
+ }
+ }
+
+ if ($handler_instance) {
+ unset($regex_matches[0]);
+
+
+ if (method_exists($handler_instance, $request_method)) {
+ Hook::fire('before_handler', compact('routes', 'discovered_handler', 'request_method', 'regex_matches'));
+ $result = call_user_func_array(array($handler_instance, $request_method), $regex_matches);
+ Hook::fire('after_handler', compact('routes', 'discovered_handler', 'request_method', 'regex_matches', 'result'));
+ } else {
+ Hook::fire('404', compact('routes', 'discovered_handler', 'request_method', 'regex_matches'));
+ }
+ } else {
+ Hook::fire('404', compact('routes', 'discovered_handler', 'request_method', 'regex_matches'));
+ }
+
+ Hook::fire('after_request', compact('routes', 'discovered_handler', 'request_method', 'regex_matches', 'result'));
+
+ return Idno::site()->response();
+ }
+
/**
* Registers a page handler for a given pattern, using Toro
* page handling syntax
diff --git a/composer.json b/composer.json
index 16efca8ef5..52faa9265d 100644
--- a/composer.json
+++ b/composer.json
@@ -37,7 +37,7 @@
"tinymce/tinymce": "~6.2",
"symfony/event-dispatcher": "~7.0",
"symfony/console": "~6.1",
- "symfony/http-foundation": "~7.0",
+ "symfony/http-foundation": "^7.1",
"symfony/cache": "~7.0",
"simplepie/simplepie": "1.8.0",
"mapkyca/mrclay_autop_known": "^1.0",
diff --git a/composer.lock b/composer.lock
index e43f52677a..0ccee32b0d 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "4b11c5586f4bbaa12e5539653c5b99a5",
+ "content-hash": "065bdf72bb684997eb83e298a2759adb",
"packages": [
{
"name": "brick/math",
@@ -3283,16 +3283,16 @@
},
{
"name": "symfony/http-foundation",
- "version": "v7.0.7",
+ "version": "v7.1.5",
"source": {
"type": "git",
"url": "https://github.com/symfony/http-foundation.git",
- "reference": "0194e064b8bdc29381462f790bab04e1cac8fdc8"
+ "reference": "e30ef73b1e44eea7eb37ba69600a354e553f694b"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/http-foundation/zipball/0194e064b8bdc29381462f790bab04e1cac8fdc8",
- "reference": "0194e064b8bdc29381462f790bab04e1cac8fdc8",
+ "url": "https://api.github.com/repos/symfony/http-foundation/zipball/e30ef73b1e44eea7eb37ba69600a354e553f694b",
+ "reference": "e30ef73b1e44eea7eb37ba69600a354e553f694b",
"shasum": ""
},
"require": {
@@ -3340,7 +3340,7 @@
"description": "Defines an object-oriented layer for the HTTP specification",
"homepage": "https://symfony.com",
"support": {
- "source": "https://github.com/symfony/http-foundation/tree/v7.0.7"
+ "source": "https://github.com/symfony/http-foundation/tree/v7.1.5"
},
"funding": [
{
@@ -3356,7 +3356,7 @@
"type": "tidelift"
}
],
- "time": "2024-04-18T09:29:19+00:00"
+ "time": "2024-09-20T08:28:38+00:00"
},
{
"name": "symfony/polyfill-ctype",
@@ -7026,5 +7026,5 @@
"ext-gettext": "*"
},
"platform-dev": [],
- "plugin-api-version": "2.6.0"
+ "plugin-api-version": "2.3.0"
}
diff --git a/index.php b/index.php
index 52da9ef52f..f171cae5dd 100644
--- a/index.php
+++ b/index.php
@@ -50,13 +50,14 @@
\Idno\Core\PageHandler::hook(
'404', function ($params = array()) {
- http_response_code(404);
$t = \Idno\Core\Idno::site()->template();
// Take over page detection
\Idno\Core\Idno::site()->template()->autodetectTemplateType();
- (new \Idno\Pages\Homepage())->noContent();
+ (new \Idno\Pages\Homepage())->noContent();
}
);
-\Idno\Core\PageHandler::serve($routes);
+
+$response = \Idno\Core\PageHandler::serve($routes);
+$response->send();
From 002ea35fb76c4dc5273ba0dfebbb99397e5d4997 Mon Sep 17 00:00:00 2001
From: ipranjal
Date: Sun, 22 Sep 2024 04:40:17 +0530
Subject: [PATCH 02/17] feat: integrate HttpFoundation with \Common\Page
---
Idno/Common/Page.php | 150 +++++++++---------
Idno/Core/Http/RedirectResponse.php | 10 ++
Idno/Core/Http/Response.php | 7 +
Idno/Core/Idno.php | 228 ++++++++++++++++------------
Idno/Core/PageHandler.php | 4 +-
index.php | 3 +-
6 files changed, 227 insertions(+), 175 deletions(-)
create mode 100644 Idno/Core/Http/RedirectResponse.php
diff --git a/Idno/Common/Page.php b/Idno/Common/Page.php
index 30fab515c7..7498da2438 100644
--- a/Idno/Common/Page.php
+++ b/Idno/Common/Page.php
@@ -62,9 +62,10 @@ abstract class Page extends \Idno\Common\Component
function init()
{
if (!defined('KNOWN_UNIT_TEST')) { // Don't do header stuff in unit tests
- header('X-Powered-By: https://withknown.com');
- header('X-Clacks-Overhead: GNU Terry Pratchett');
- header('X-Known-Build-Fingerprint: ' . \Idno\Core\TokenProvider::truncateToken(\Idno\Core\Version::fingerprint()));
+ \Idno\Core\Idno::site()->response()->headers->set('X-Powered-By', 'https://withknown.com');
+ \Idno\Core\Idno::site()->response()->headers->set('X-Clacks-Overhead', 'GNU Terry Pratchett');
+ \Idno\Core\Idno::site()->response()->headers->set('X-Known-Version', \Idno\Core\Version::version());
+
}
if ($template = $this->getInput('_t')) {
if (\Idno\Core\Idno::site()->template()->templateTypeExists($template)) {
@@ -74,8 +75,8 @@ function init()
\Idno\Core\Idno::site()->setCurrentPage($this);
// Set referrer, and ensure it's not blank
- $this->referrer = $_SERVER['HTTP_REFERER']??'';
- $_SERVER['HTTP_REFERER'] = $_SERVER['HTTP_REFERER']??''; // Ensure that the $_SERVER['HTTP_REFERER'] is never blank
+ $this->referrer =\Idno\Core\Idno::site()->request()->server->get('HTTP_REFERER')??'';
+ \Idno\Core\Idno::site()->request()->server->set('HTTP_REFERER',$this->referrer);
// Default exception handler
set_exception_handler(
@@ -137,7 +138,6 @@ function getInput($name, $default = null, callable $filter = null)
function exception($e)
{
$this->setResponse(500);
- http_response_code($this->response);
\Idno\Core\Idno::site()->logging()->critical($e->getMessage() . " [".$e->getFile().":".$e->getLine()."]");
@@ -153,8 +153,8 @@ function exception($e)
}
$t = \Idno\Core\Idno::site()->template();
- $t->__(array('body' => $t->__(array('exception' => $e))->draw('pages/500'), 'title' => 'Exception'))->drawPage();
- exit;
+ $content = $t->__(array('body' => $t->__(array('exception' => $e))->draw('pages/500'), 'title' => 'Exception'))->drawPage(false);
+ \Idno\Core\Idno::site()->response()->setContent($content);
}
/**
@@ -214,7 +214,7 @@ function head()
$this->getContent();
//if (http_response_code() != 200)
- http_response_code($this->response);
+ $this->setResponse($this->response);
}
/**
@@ -325,8 +325,8 @@ function get($params = array())
$this->getContent();
- if (http_response_code() != 200) {
- http_response_code($this->response);
+ if (\Idno\Core\Idno::site()->response()->getStatusCode() != 200) {
+ \Idno\Core\Idno::site()->response()->setStatusCode($this->response);
}
}
@@ -334,24 +334,24 @@ protected function debugLogToken()
{
$ts = "";
- if (empty($_REQUEST['__bTs'])) {
+ if (empty(\Idno\Core\Idno::site()->request()->request->get('__bTs'))) {
\Idno\Core\Idno::site()->logging()->error("__bTs timestamp is missing");
} else {
- $ts = $_REQUEST['__bTs'];
+ $ts = \Idno\Core\Idno::site()->request()->request->get('__bTs');
}
$ta = "";
- if (empty($_REQUEST['__bTa'])) {
+ if (empty(\Idno\Core\Idno::site()->request()->request->get('__bTa'))) {
\Idno\Core\Idno::site()->logging()->warning("__bTa action is missing");
} else {
- $ta = $_REQUEST['__bTa'];
+ $ta = \Idno\Core\Idno::site()->request()->request->get('__bTa');
}
$tk = "";
- if (empty($_REQUEST['__bTk'])) {
+ if (empty(\Idno\Core\Idno::site()->request()->request->get('__bTk'))) {
\Idno\Core\Idno::site()->logging()->error("__bTk token is missing");
} else {
- $tk = $_REQUEST['__bTk'];
+ $tk = \Idno\Core\Idno::site()->request()->request->get('__bTk');
}
$debug = [
@@ -424,7 +424,7 @@ function post()
// API currently doesn't explicitly handle this situation (bad), but we don't want to forward (worse). Some plugins will still
// forward to / in some situations, these will need rewriting.
if ($return === null) {
- if (http_response_code() == 200) {
+ if (\Idno\Core\Idno::site()->response()->getStatusCode() == 200) {
$this->setResponse(400);
}
@@ -435,23 +435,25 @@ function post()
}
$t = \Idno\Core\Idno::site()->template();
- echo $t->drawPage();
+ $content = $t->drawPage(false);
+ \Idno\Core\Idno::site()->response()->setContent($content);
} else {
// We have a return value, and response hasn't been explicitly set. Assume false is error, everything else is ok
- if (($return === false) && (http_response_code() == 200)) {
+ if (($return === false) && (\Idno\Core\Idno::site()->response()->getStatusCode() == 200)) {
$this->setResponse(400);
}
$t = \Idno\Core\Idno::site()->template();
- echo $t->__(['result' => $return])->drawPage();
+ $content = $t->__(['result' => $return])->drawPage(false);
+ \Idno\Core\Idno::site()->response()->setContent($content);
}
} else {
$this->forward(); // If we haven't forwarded yet, do so (if we can)
}
//if (http_response_code() != 200) {
- http_response_code($this->response);
+ \Idno\Core\Idno::site()->response()->setStatusCode($this->response);
//}
}
@@ -469,8 +471,7 @@ function postContent()
function options()
{
- header(
- 'Access-Control-Allow-Methods: ' . implode(
+ \Idno\Core\Idno::site()->response()->headers->set('Access-Control-Allow-Methods', implode(
', ', [
'GET',
'POST',
@@ -479,12 +480,13 @@ function options()
'PUT',
'DELETE'
]
- )
- );
+ ));
+
+
+ \Idno\Core\Idno::site()->response()->headers->set('Access-Control-Max-Age', '86400');
- header('Access-Control-Max-Age: 86400');
+ \Idno\Core\Idno::site()->response()->setStatusCode(204);
- http_response_code(204);
}
/**
@@ -564,11 +566,12 @@ function forward(string $location = '', bool $exit = true)
if (!empty($call_trace)) {
$location['trace'] = $call_trace;
}
- echo json_encode($location);
+ \Idno\Core\Idno::site()->response()->setJsonContent($location);
} elseif (!\Idno\Core\Idno::site()->session()->isAPIRequest() || $this->response == 200) {
if (!empty($call_trace)) { header('X-Known-Forward-Trace: ' . $call_trace);
}
- header('Location: ' . $location);
+
+ \Idno\Core\Idno::site()->redirect($location);
}
if ($exit) {
@@ -641,7 +644,7 @@ function put()
// Ensure we always get a meaningful response from the api
if ($return === null) {
- if (http_response_code() == 200) {
+ if (\Idno\Core\Idno::site()->response()->getStatusCode() == 200) {
$this->setResponse(400);
}
@@ -652,24 +655,26 @@ function put()
}
$t = \Idno\Core\Idno::site()->template();
- echo $t->drawPage();
+ $content = $t->drawPage(false);
+ \Idno\Core\Idno::site()->response()->setContent($content);
} else {
// We have a return value, and response hasn't been explicitly set. Assume false is error, everything else is ok
- if (($return === false) && (http_response_code() == 200)) {
+ if (($return === false) && (\Idno\Core\Idno::site()->response()->getStatusCode() == 200)) {
$this->setResponse(400);
}
$t = \Idno\Core\Idno::site()->template();
- echo $t->__(['result' => $return])->drawPage();
+ $content = $t->__(['result' => $return])->drawPage(false);
+ \Idno\Core\Idno::site()->response()->setContent($content);
}
} else {
$this->forward(); // If we haven't forwarded yet, do so (if we can)
}
- if (http_response_code() != 200) {
- http_response_code($this->response);
+ if (\Idno\Core\Idno::site()->response()->getStatusCode() != 200) {
+ \Idno\Core\Idno::site()->response()->setStatusCode($this->response);
}
}
@@ -730,7 +735,7 @@ function delete()
// Ensure we always get a meaningful response from the api
if ($return === null) {
- if (http_response_code() == 200) {
+ if (\Idno\Core\Idno::site()->response()->getStatusCode() == 200) {
$this->setResponse(400);
}
@@ -741,24 +746,26 @@ function delete()
}
$t = \Idno\Core\Idno::site()->template();
- echo $t->drawPage();
+ $content = $t->drawPage(false);
+ \Idno\Core\Idno::site()->response()->setContent($content);
} else {
// We have a return value, and response hasn't been explicitly set. Assume false is error, everything else is ok
- if (($return === false) && (http_response_code() == 200)) {
+ if (($return === false) && (\Idno\Core\Idno::site()->response()->getStatusCode() == 200)) {
$this->setResponse(400);
}
$t = \Idno\Core\Idno::site()->template();
- echo $t->__(['result' => $return])->drawPage();
+ $content = $t->__(['result' => $return])->drawPage(false);
+ \Idno\Core\Idno::site()->response()->setContent($content);
}
} else {
$this->forward(); // If we haven't forwarded yet, do so (if we can)
}
- if (http_response_code() != 200) {
- http_response_code($this->response);
+ if (\Idno\Core\Idno::site()->response()->getStatusCode() != 200) {
+ \Idno\Core\Idno::site()->response()->setStatusCode($this->response);
}
}
@@ -804,14 +811,16 @@ function webmentionContent($source, $target, $source_response, $source_mf2)
function goneContent()
{
$this->setResponse(410);
- http_response_code($this->response);
+ \Idno\Core\Idno::site()->response()->setStatusCode($this->response);
+
+ \Idno\Core\Idno::site()->response()->headers->remove('X-Known-CSRF-Ts');
+ \Idno\Core\Idno::site()->response()->headers->remove('X-Known-CSRF-Token');
- header_remove('X-Known-CSRF-Ts');
- header_remove('X-Known-CSRF-Token');
$t = \Idno\Core\Idno::site()->template();
- $t->__(array('body' => $t->draw('pages/410'), 'title' => \Idno\Core\Idno::site()->language()->_('This content isn\'t here.')))->drawPage();
- exit;
+ $content = $t->__(array('body' => $t->draw('pages/410'), 'title' => \Idno\Core\Idno::site()->language()->_('This content isn\'t here.')))->drawPage(false);
+ \Idno\Core\Idno::site()->response()->setContent($content);
+ \Idno\Core\Idno::site()->sendResponse();
}
/**
@@ -829,10 +838,12 @@ function noContent()
$t = \Idno\Core\Idno::site()->template();
$content = $t->__(array('body' => $t->draw('pages/404'), 'title' => \Idno\Core\Idno::site()->language()->_('This page can\'t be found.')))->drawPage(false);
\Idno\Core\Idno::site()->response()->setContent($content);
+ \Idno\Core\Idno::site()->sendResponse();
}
/**
* Flushes content to the browser and continues page working asynchronously.
+ * Depricate ?
*/
function flushBrowser()
{
@@ -863,14 +874,13 @@ function createGatekeeper()
function deniedContent($title = '')
{
$this->setResponse(403);
- http_response_code($this->response);
-
- header_remove('X-Known-CSRF-Ts');
- header_remove('X-Known-CSRF-Token');
+ \Idno\Core\Idno::site()->response()->setStatusCode($this->response);
+ \Idno\Core\Idno::site()->response()->headers->remove('X-Known-CSRF-Ts');
+ \Idno\Core\Idno::site()->response()->headers->remove('X-Known-CSRF-Token');
$t = \Idno\Core\Idno::site()->template();
- $t->__(array('body' => $t->draw('pages/403'), 'title' => $title))->drawPage();
- exit;
+ $content = $t->__(array('body' => $t->draw('pages/403'), 'title' => $title))->drawPage();
+ \Idno\Core\Idno::site()->response()->setContent($content);
}
/**
@@ -1002,10 +1012,8 @@ function sslGatekeeper()
$url = str_replace('http://', 'https://', $this->currentUrl());
- header("HTTP/1.1 307 Temporary Redirect");
- header("Location: $url");
+ \Idno\Core\Idno::site()->redirect($url);
- exit;
}
}
@@ -1016,18 +1024,13 @@ function sslGatekeeper()
*/
static function isSSL()
{
- if (isset($_SERVER['HTTPS'])) {
- if ($_SERVER['HTTPS'] == '1') {
+ if (\Idno\Core\Idno::site()->request()->isSecure()) {
return true;
- }
- if (strtolower($_SERVER['HTTPS']) == 'on') {
- return true;
- }
- } else if (isset($_SERVER['SERVER_PORT']) && ($_SERVER['SERVER_PORT'] == '443')) {
+ } else if (\Idno\Core\Idno::site()->request()->server->has('SERVER_PORT') && (\Idno\Core\Idno::site()->request()->server->get('SERVER_PORT') == '443')) {
return true;
}
- if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && strtolower($_SERVER['HTTP_X_FORWARDED_PROTO']) == 'https') {
+ if (\Idno\Core\Idno::site()->request()->server->has('HTTP_X_FORWARDED_PROTO') && strtolower(\Idno\Core\Idno::site()->request()->server->get('HTTP_X_FORWARDED_PROTO')) == 'https') {
return true;
}
@@ -1043,7 +1046,7 @@ static function isSSL()
public function currentUrl($tokenise = false)
{
$url = parse_url(\Idno\Core\Idno::site()->config()->url);
- $url['path'] = $_SERVER['REQUEST_URI'];
+ $url['path'] = \Idno\Core\Idno::site()->request()->getPathInfo();
if ($tokenise) {
return $url;
@@ -1133,7 +1136,7 @@ function setInput($name, $value)
function getReferrer()
{
- $referrer = $_SERVER['HTTP_REFERER'];
+ $referrer = \Idno\Core\Idno::site()->request()->server->get('HTTP_REFERER');
if (empty($referrer)) {
// TODO: Try other ways - e.g. for nginx
@@ -1202,7 +1205,7 @@ function isAcceptedContentType($contentType, $ignore_priority = false)
static function getallheaders()
{
$headers = array();
- foreach ($_SERVER as $name => $value) {
+ foreach (\Idno\Core\Idno::site()->request()->headers->all() as $name => $value) {
if (substr($name, 0, 14) == 'REDIRECT_HTTP_') {
$name = substr($name, 9);
}
@@ -1325,9 +1328,9 @@ function setOwner($user)
*/
public function setNoCache()
{
- header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
- header("Cache-Control: post-check=0, pre-check=0", false);
- header("Pragma: no-cache");
+ \Idno\Core\Idno::site()->response()->headers->set('Cache-Control', 'no-store, no-cache, must-revalidate, max-age=0');
+ \Idno\Core\Idno::site()->response()->headers->set('Cache-Control', 'post-check=0, pre-check=0', false);
+ \Idno\Core\Idno::site()->response()->headers->set('Pragma', 'no-cache');
}
/**
@@ -1338,7 +1341,8 @@ public function setNoCache()
*/
public function setLastModifiedHeader(int $timestamp)
{
- header('Last-Modified: ' . \Idno\Core\Time::timestampToRFC2616($timestamp));
+ \Idno\Core\Idno::site()->response()->headers->set('Last-Modified', \Idno\Core\Time::timestampToRFC2616($timestamp));
+ \Idno\Core\Idno::site()->sendResponse();
}
/**
@@ -1352,8 +1356,8 @@ public function lastModifiedGatekeeper($timestamp)
$headers = self::getallheaders();
if (isset($headers['If-Modified-Since'])) {
if (strtotime($headers['If-Modified-Since']) <= $timestamp) {
- header('HTTP/1.1 304 Not Modified');
- exit;
+ \Idno\Core\Idno::site()->response()->setStatusCode(304);
+ \Idno\Core\Idno::site()->sendResponse();
}
}
}
diff --git a/Idno/Core/Http/RedirectResponse.php b/Idno/Core/Http/RedirectResponse.php
new file mode 100644
index 0000000000..932018d567
--- /dev/null
+++ b/Idno/Core/Http/RedirectResponse.php
@@ -0,0 +1,10 @@
+headers->set('Content-Type', 'application/json');
+ $this->setContent(json_encode($content));
+ return $this;
+ }
+
}
}
\ No newline at end of file
diff --git a/Idno/Core/Idno.php b/Idno/Core/Idno.php
index bc70ccfc0f..32259ee889 100644
--- a/Idno/Core/Idno.php
+++ b/Idno/Core/Idno.php
@@ -1,15 +1,16 @@
request = Request::createFromGlobals();
- $this->response = new \Idno\Core\Http\Response();
- $this->routes = new PageHandler();
+ self::$site = $this;
+ $this->request = Request::createFromGlobals();
+ $this->response = new \Idno\Core\Http\Response();
+ $this->routes = new PageHandler();
$this->dispatcher = new EventDispatcher();
- $this->config = new Config();
+ $this->config = new Config();
if ($this->config->isDefaultConfig()) {
header('Location: ./warmup/');
exit; // Load the installer
@@ -119,17 +120,17 @@ function init()
$this->logging->setLogLevel($this->config->loglevel);
}
- $this->session = new Session();
- $this->actions = new Actions();
+ $this->session = new Session();
+ $this->actions = new Actions();
$this->site_details = $this->site_details();
- $this->template = $this->componentFactory($this->config->template, Template::class, "Idno\\Core\\", HybridTwigTemplate::class);
- $this->language = new Language();
- $this->language()->register(new GetTextTranslation()); // Register default gettext translations
- $this->syndication = new Syndication();
- $this->reader = new Reader();
+ $this->template = $this->componentFactory($this->config->template, Template::class, "Idno\\Core\\", HybridTwigTemplate::class);
+ $this->language = new Language();
+ $this->language()->register(new GetTextTranslation()); // Register default gettext translations
+ $this->syndication = new Syndication();
+ $this->reader = new Reader();
$this->helper_robot = new HelperRobot();
- $this->queue = $this->componentFactory($this->config->event_queue, "Idno\\Core\\EventQueue", "Idno\\Core\\", "Idno\\Core\\SynchronousQueue");
- $this->statistics = $this->componentFactory($this->config->statistics_collector, "Idno\\Stats\\StatisticsCollector", "Idno\\Stats\\", "Idno\\Stats\\DummyStatisticsCollector");
+ $this->queue = $this->componentFactory($this->config->event_queue, "Idno\\Core\\EventQueue", "Idno\\Core\\", "Idno\\Core\\SynchronousQueue");
+ $this->statistics = $this->componentFactory($this->config->statistics_collector, "Idno\\Stats\\StatisticsCollector", "Idno\\Stats\\", "Idno\\Stats\\DummyStatisticsCollector");
// Log some page statistics
\Idno\Stats\Timer::start('script');
@@ -151,7 +152,8 @@ function () {
// No URL is a critical error, default base fallback is now a warning (Refs #526)
if (!defined('KNOWN_CONSOLE')) {
- if (!$this->config->url) { throw new \Idno\Exceptions\ConfigurationException('Known was unable to work out your base URL! You might try setting url="http://yourdomain.com/" in your config.ini');
+ if (!$this->config->url) {
+ throw new \Idno\Exceptions\ConfigurationException('Known was unable to work out your base URL! You might try setting url="http://yourdomain.com/" in your config.ini');
}
if ($this->config->url == '/') {
$this->logging->warning(
@@ -167,11 +169,12 @@ function () {
if (empty(site()->session()->hub_connect)) {
site()->session()->hub_connect = 0;
}
- if (!empty($this->config->known_hub)
+ if (
+ !empty($this->config->known_hub)
&& !substr_count($_SERVER['REQUEST_URI'], '.')
&& $this->config->known_hub != $this->config->url
) {
- site()->session()->hub_connect = time();
+ site()->session()->hub_connect = time();
\Idno\Core\Idno::site()->known_hub = new \Idno\Core\Hub($this->config->known_hub);
\Idno\Core\Idno::site()->hub()->connect();
}
@@ -188,7 +191,7 @@ function registerPages()
/**
* Homepage
- */
+ */
$this->routes()->addRoute('/?', '\Idno\Pages\Homepage');
$this->routes()->addRoute('/feed\.xml', '\Idno\Pages\Feed');
$this->routes()->addRoute('/feed/?', '\Idno\Pages\Feed');
@@ -197,7 +200,7 @@ function registerPages()
/**
* Individual entities / posting / deletion
- */
+ */
$this->routes()->addRoute('/view/:id/?', '\Idno\Pages\Entity\View');
$this->routes()->addRoute('/s/:id/?', '\Idno\Pages\Entity\Shortlink');
$this->routes()->addRoute($permalink_route . '/?', '\Idno\Pages\Entity\View');
@@ -209,32 +212,32 @@ function registerPages()
/**
* Annotations
- */
+ */
$this->routes()->addRoute('/view/:id/annotations/:id?', '\Idno\Pages\Annotation\View');
$this->routes()->addRoute($permalink_route . '/annotations/:id?', '\Idno\Pages\Annotation\View');
$this->routes()->addRoute($permalink_route . '/annotations/:id/delete/?', '\Idno\Pages\Annotation\Delete'); // Delete annotation
- $this->routes()->addRoute($permalink_route .'/annotation/delete/?', '\Idno\Pages\Annotation\Delete'); // Delete annotation alternate
+ $this->routes()->addRoute($permalink_route . '/annotation/delete/?', '\Idno\Pages\Annotation\Delete'); // Delete annotation alternate
$this->routes()->addRoute('/annotation/post/?', '\Idno\Pages\Annotation\Post');
/**
* Bookmarklets and sharing
- */
+ */
$this->routes()->addRoute('/share/?', '\Idno\Pages\Entity\Share');
$this->routes()->addRoute('/bookmarklet\.js', '\Idno\Pages\Entity\Bookmarklet', true);
/**
* Mobile integrations
- */
+ */
$this->routes()->addRoute('/chrome/manifest\.json', '\Idno\Pages\Chrome\Manifest', true);
/**
* Service worker
- */
+ */
$this->routes()->addRoute('/service-worker(\.min)?\.js', '\Idno\Pages\Chrome\ServiceWorker', true);
/**
* Files
- */
+ */
$this->routes()->addRoute('/file/mint/?', \Idno\Pages\File\Mint::class);
$this->routes()->addRoute('/file/upload/?', '\Idno\Pages\File\Upload', true);
$this->routes()->addRoute('/file/picker/?', '\Idno\Pages\File\Picker', true);
@@ -243,7 +246,7 @@ function registerPages()
/**
* Users
- */
+ */
$this->routes()->addRoute('/profile/([^\/]+)/?', '\Idno\Pages\User\View');
$this->routes()->addRoute('/profile/([^\/]+)/edit/?', '\Idno\Pages\User\Edit');
$this->routes()->addRoute('/profile/([^\/]+)/([A-Za-z\-\/]+)+', '\Idno\Pages\User\View');
@@ -251,7 +254,7 @@ function registerPages()
/**
* Search
- */
+ */
$this->routes()->addRoute('/search/?', '\Idno\Pages\Search\Forward');
$this->routes()->addRoute('/search/mentions\.json', '\Idno\Pages\Search\Mentions');
$this->routes()->addRoute('/tag/([^\s]+)\/?', '\Idno\Pages\Search\Tags');
@@ -259,17 +262,17 @@ function registerPages()
/**
* robots.txt
- */
+ */
$this->routes()->addRoute('/robots\.txt', '\Idno\Pages\Txt\Robots');
/**
* Autosave / preview
- */
+ */
$this->routes()->addRoute('/autosave/?', '\Idno\Pages\Entity\Autosave');
/**
* Installation / first use
- */
+ */
$this->routes()->addRoute('/begin/?', '\Idno\Pages\Onboarding\Begin', true);
$this->routes()->addRoute('/begin/register/?', '\Idno\Pages\Onboarding\Register', true);
$this->routes()->addRoute('/begin/profile/?', '\Idno\Pages\Onboarding\Profile');
@@ -279,7 +282,7 @@ function registerPages()
/**
* Add some services
- */
+ */
$this->routes()->addRoute('/service/db/optimise/?', '\Idno\Pages\Service\Db\Optimise');
$this->routes()->addRoute('/service/vendor/messages/?', '\Idno\Pages\Service\Vendor\Messages');
$this->routes()->addRoute('/service/security/csrftoken/?', '\Idno\Pages\Service\Security\CSRFToken');
@@ -291,7 +294,7 @@ function registerPages()
// These must be loaded last
$this->plugins = new Plugins();
- $this->themes = new Themes();
+ $this->themes = new Themes();
}
/**
@@ -299,7 +302,7 @@ function registerPages()
*
* @return \Idno\Core\DataConcierge
*/
- function &db() : ?DataConcierge
+ function &db(): ?DataConcierge
{
return $this->db;
}
@@ -309,7 +312,7 @@ function &db() : ?DataConcierge
*
* @return \Idno\Core\EventDispatcher
*/
- function &events() : ?EventDispatcher
+ function &events(): ?EventDispatcher
{
return $this->dispatcher;
}
@@ -319,20 +322,41 @@ function &events() : ?EventDispatcher
*
* @return \Idno\Core\Http\Request
*/
- function &request() : ?Request
+ function &request(): ?Request
{
return $this->request;
}
/**
- * Return the response object loaded as part of this site
- *
- * @return \Idno\Core\Http\Response
- */
- function &response() : ?Response
- {
- return $this->response;
- }
+ * Return the response object loaded as part of this site
+ *
+ * @return \Idno\Core\Http\Response
+ */
+ function &response(): ?Response
+ {
+ return $this->response;
+ }
+
+ /**
+ * Redirect to a new URL
+ *
+ * @param string $url
+ */
+ function &redirect($url)
+ {
+ $this->response = new RedirectResponse($url);
+ \Idno\Core\Idno::site()->sendResponse();
+
+ }
+
+
+ /**
+ * Send the response
+ */
+ function &sendResponse()
+ {
+ $this->response->send();
+ }
/**
* Access to the EventQueue for dispatching events
@@ -340,7 +364,7 @@ function &response() : ?Response
*
* @return \Idno\Core\EventQueue
*/
- function &queue() : ?EventQueue
+ function &queue(): ?EventQueue
{
return $this->queue;
}
@@ -350,7 +374,7 @@ function &queue() : ?EventQueue
*
* @return \Idno\Files\FileSystem
*/
- function &filesystem() : ? \Idno\Files\FileSystem
+ function &filesystem(): ?\Idno\Files\FileSystem
{
return $this->filesystem;
}
@@ -360,7 +384,7 @@ function &filesystem() : ? \Idno\Files\FileSystem
*
* @return \Idno\Core\Hub
*/
- function &hub() : ?Hub
+ function &hub(): ?Hub
{
return $this->known_hub;
}
@@ -370,7 +394,7 @@ function &hub() : ?Hub
*
* @return \Idno\Core\Logging
*/
- function &logging() : ?Logging
+ function &logging(): ?Logging
{
return $this->logging;
}
@@ -380,7 +404,7 @@ function &logging() : ?Logging
*
* @return \Idno\Caching\PersistentCache
*/
- function &cache() : ?\Idno\Caching\PersistentCache
+ function &cache(): ?\Idno\Caching\PersistentCache
{
return $this->cache;
}
@@ -390,7 +414,7 @@ function &cache() : ?\Idno\Caching\PersistentCache
*
* @return \Idno\Stats\StatisticsCollector
*/
- function &statistics() : ?\Idno\Stats\StatisticsCollector
+ function &statistics(): ?\Idno\Stats\StatisticsCollector
{
return $this->statistics;
}
@@ -400,7 +424,7 @@ function &statistics() : ?\Idno\Stats\StatisticsCollector
*
* @return \Idno\Core\PageHandler
*/
- function &routes() : ?PageHandler
+ function &routes(): ?PageHandler
{
return $this->routes;
}
@@ -427,7 +451,7 @@ function &config($setting = false)
*
* @return \Idno\Core\Syndication
*/
- function &syndication() : ?Syndication
+ function &syndication(): ?Syndication
{
return $this->syndication;
}
@@ -437,7 +461,7 @@ function &syndication() : ?Syndication
*
* @return \Idno\Core\Session
*/
- function &session() : ?Session
+ function &session(): ?Session
{
return $this->session;
}
@@ -447,7 +471,7 @@ function &session() : ?Session
*
* @return \Idno\Core\Plugins
*/
- function &plugins() : ?Plugins
+ function &plugins(): ?Plugins
{
return $this->plugins;
}
@@ -457,7 +481,7 @@ function &plugins() : ?Plugins
*
* @return \Idno\Core\Themes
*/
- function &themes() : ?Themes
+ function &themes(): ?Themes
{
return $this->themes;
}
@@ -468,7 +492,7 @@ function &themes() : ?Themes
* @return \Idno\Core\Template
*/
- function &template() : ?Template
+ function &template(): ?Template
{
return $this->template;
}
@@ -478,7 +502,7 @@ function &template() : ?Template
*
* @return \Idno\Core\Language
*/
- function &language() : ?Language
+ function &language(): ?Language
{
if (empty($this->language)) {
$this->language = new Language();
@@ -492,7 +516,7 @@ function &language() : ?Language
*
* @return \Idno\Core\Actions
*/
- function &actions() : ?Actions
+ function &actions(): ?Actions
{
return $this->actions;
}
@@ -502,7 +526,7 @@ function &actions() : ?Actions
*
* @return \Idno\Core\Reader
*/
- function &reader() : ?Reader
+ function &reader(): ?Reader
{
return $this->reader;
}
@@ -510,7 +534,7 @@ function &reader() : ?Reader
/**
* Return the site object for the current site, creating a new entry if one doesn't exist.
*/
- function &site_details() : ? Site
+ function &site_details(): ?Site
{
if (empty($this->site_details)) {
@@ -518,7 +542,7 @@ function &site_details() : ? Site
if (!empty($domain) && !empty($this->session())) {
- $this->site_details = Site::getOne([ 'domain' => $domain ]);
+ $this->site_details = Site::getOne(['domain' => $domain]);
if (empty($this->site_details)) {
@@ -572,7 +596,8 @@ function currentPage()
*/
function canEdit($user_id = '')
{
- if (!\Idno\Core\Idno::site()->session()->isLoggedOn()) { return false;
+ if (!\Idno\Core\Idno::site()->session()->isLoggedOn()) {
+ return false;
}
if (empty($user_id)) {
@@ -582,11 +607,13 @@ function canEdit($user_id = '')
if ($user = \Idno\Entities\User::getByUUID($user_id)) {
return \Idno\Core\Idno::site()->events()->triggerEvent(
- 'canEdit/site', [
- 'object' => $this,
- 'user_id' => $user_id,
- 'user' => $user
- ], (function () use ($user) {
+ 'canEdit/site',
+ [
+ 'object' => $this,
+ 'user_id' => $user_id,
+ 'user' => $user
+ ],
+ (function () use ($user) {
if ($user->isAdmin()) {
return true;
@@ -611,7 +638,8 @@ function canEdit($user_id = '')
*/
function canWrite($user_id = '')
{
- if (!\Idno\Core\Idno::site()->session()->isLoggedOn()) { return false;
+ if (!\Idno\Core\Idno::site()->session()->isLoggedOn()) {
+ return false;
}
if (empty($user_id)) {
@@ -622,11 +650,13 @@ function canWrite($user_id = '')
// Make site level canWrite extensible
return \Idno\Core\Idno::site()->events()->triggerEvent(
- 'canWrite/site', [
- 'object' => $this,
- 'user_id' => $user_id,
- 'user' => $user
- ], (function () use ($user) {
+ 'canWrite/site',
+ [
+ 'object' => $this,
+ 'user_id' => $user_id,
+ 'user' => $user
+ ],
+ (function () use ($user) {
// Remote users can't ever create anything :( - for now
if ($user instanceof \Idno\Entities\RemoteUser) {
@@ -672,23 +702,23 @@ function canRead($user_id = '')
*
* @returns array An associative array of various icons => url
*/
- function getSiteIcons() : array
+ function getSiteIcons(): array
{
$icons = [];
// Set our defaults (TODO: Set these cleaner, perhaps through the template system)
$icons['defaults'] = [
- 'default' => \Idno\Core\Idno::site()->config()->getStaticURL() . 'gfx/logos/logo_k.png',
- 'default_16' => \Idno\Core\Idno::site()->config()->getStaticURL() . 'gfx/logos/logo_k_16.png',
- 'default_32' => \Idno\Core\Idno::site()->config()->getStaticURL() . 'gfx/logos/logo_k_32.png',
- 'default_36' => \Idno\Core\Idno::site()->config()->getStaticURL() . 'gfx/logos/logo_k_36.png',
- 'default_48' => \Idno\Core\Idno::site()->config()->getStaticURL() . 'gfx/logos/logo_k_48.png',
- 'default_64' => \Idno\Core\Idno::site()->config()->getStaticURL() . 'gfx/logos/logo_k_64.png',
- 'default_96' => \Idno\Core\Idno::site()->config()->getStaticURL() . 'gfx/logos/logo_k_96.png',
+ 'default' => \Idno\Core\Idno::site()->config()->getStaticURL() . 'gfx/logos/logo_k.png',
+ 'default_16' => \Idno\Core\Idno::site()->config()->getStaticURL() . 'gfx/logos/logo_k_16.png',
+ 'default_32' => \Idno\Core\Idno::site()->config()->getStaticURL() . 'gfx/logos/logo_k_32.png',
+ 'default_36' => \Idno\Core\Idno::site()->config()->getStaticURL() . 'gfx/logos/logo_k_36.png',
+ 'default_48' => \Idno\Core\Idno::site()->config()->getStaticURL() . 'gfx/logos/logo_k_48.png',
+ 'default_64' => \Idno\Core\Idno::site()->config()->getStaticURL() . 'gfx/logos/logo_k_64.png',
+ 'default_96' => \Idno\Core\Idno::site()->config()->getStaticURL() . 'gfx/logos/logo_k_96.png',
// Apple logos
- 'default_57' => \Idno\Core\Idno::site()->config()->getStaticURL() . 'gfx/logos/apple-icon-57x57.png',
- 'default_72' => \Idno\Core\Idno::site()->config()->getStaticURL() . 'gfx/logos/apple-icon-72x72.png',
+ 'default_57' => \Idno\Core\Idno::site()->config()->getStaticURL() . 'gfx/logos/apple-icon-57x57.png',
+ 'default_72' => \Idno\Core\Idno::site()->config()->getStaticURL() . 'gfx/logos/apple-icon-72x72.png',
'default_114' => \Idno\Core\Idno::site()->config()->getStaticURL() . 'gfx/logos/apple-icon-114x114.png',
'default_144' => \Idno\Core\Idno::site()->config()->getStaticURL() . 'gfx/logos/apple-icon-144x144.png',
@@ -743,12 +773,14 @@ function upgrade()
if ($last_update < $machine_version) {
- if ($this->events()->triggerEvent(
- 'upgrade', [
- 'last_update' => $last_update,
- 'new_version' => $machine_version
- ]
- )
+ if (
+ $this->events()->triggerEvent(
+ 'upgrade',
+ [
+ 'last_update' => $last_update,
+ 'new_version' => $machine_version
+ ]
+ )
) {
// Save updated
@@ -777,7 +809,7 @@ function __sleep()
*
* @return \Idno\Core\Idno $site
*/
- static function &site() : ?Idno
+ static function &site(): ?Idno
{
return self::$site;
}
@@ -791,7 +823,7 @@ static function &site() : ?Idno
* @param string $defaultClassNameBase If a full namespace is not provided in $configValue, use this value as base class namespace
* @param string $defaultClass If class could not be constructed, return a new instance of this class name
*/
- public function componentFactory($className, $expectedBaseClass = "Idno\\Common\\Component" , $defaultClassNameBase = "Idno\\Core\\", $defaultClass = null)
+ public function componentFactory($className, $expectedBaseClass = "Idno\\Common\\Component", $defaultClassNameBase = "Idno\\Core\\", $defaultClass = null)
{
$component = null;
@@ -830,7 +862,7 @@ public function componentFactory($className, $expectedBaseClass = "Idno\\Common\
// validate
if (!is_subclass_of($component, $expectedBaseClass)) {
- $component = null;
+ $component = null;
}
}
}
@@ -855,7 +887,7 @@ public function getVersion()
* @deprecated Use \Idno\Core\Idno::site()
* @return \Idno\Core\Idno $site
*/
- function &site() : Idno
+ function &site(): Idno
{
return \Idno\Core\Idno::site();
}
diff --git a/Idno/Core/PageHandler.php b/Idno/Core/PageHandler.php
index b6ce8e5faf..cb8ef99c6b 100644
--- a/Idno/Core/PageHandler.php
+++ b/Idno/Core/PageHandler.php
@@ -28,7 +28,7 @@ function routeTokens()
);
}
- public static function serve($routes): \Idno\Core\Http\Response
+ public static function serve($routes)
{
Hook::fire('before_request', compact('routes'));
@@ -88,7 +88,7 @@ public static function serve($routes): \Idno\Core\Http\Response
Hook::fire('after_request', compact('routes', 'discovered_handler', 'request_method', 'regex_matches', 'result'));
- return Idno::site()->response();
+ \Idno\Core\Idno::site()->sendResponse();
}
/**
diff --git a/index.php b/index.php
index f171cae5dd..bf7a80480f 100644
--- a/index.php
+++ b/index.php
@@ -59,5 +59,4 @@
}
);
-$response = \Idno\Core\PageHandler::serve($routes);
-$response->send();
+\Idno\Core\PageHandler::serve($routes);
From cf1fef86f1abf684f4fb047193f91a386eea22f0 Mon Sep 17 00:00:00 2001
From: ipranjal
Date: Sun, 22 Sep 2024 05:58:43 +0530
Subject: [PATCH 03/17] feat : replace echo with setResponse() on non template
pages
---
Idno/Common/Page.php | 4 ++--
Idno/Core/Bonita/Templates.php | 19 +++++++++++--------
Idno/Pages/Account/Export/RSS.php | 19 +++++++++++++------
Idno/Pages/Account/Notifications.php | 2 +-
Idno/Pages/Account/Password.php | 3 ++-
Idno/Pages/Account/Register.php | 5 +++--
Idno/Pages/Account/Settings/Tools.php | 5 +++--
Idno/Pages/Admin/Diagnostics.php | 7 ++++---
Idno/Pages/Admin/Export/RSS.php | 20 ++++++++++++++------
Idno/Pages/Admin/Logs.php | 5 +++--
Idno/Pages/Admin/Plugins.php | 16 ++++++++--------
Idno/Pages/Admin/Statistics.php | 5 +++--
Idno/Pages/Chrome/Manifest.php | 2 +-
Idno/Pages/Chrome/ServiceWorker.php | 6 +++---
Idno/Pages/Entity/Bookmarklet.php | 2 +-
Idno/Pages/Entity/Withdraw.php | 15 +++++++++------
Idno/Pages/File/Mint.php | 4 ++--
Idno/Pages/File/Picker.php | 5 +++--
Idno/Pages/File/Upload.php | 2 +-
Idno/Pages/Hub/Register/Site.php | 4 ++--
Idno/Pages/Hub/Register/User.php | 4 ++--
Idno/Pages/Onboarding/Begin.php | 5 +++--
Idno/Pages/Onboarding/Connect.php | 3 ++-
Idno/Pages/Onboarding/Profile.php | 3 ++-
Idno/Pages/Pubsubhubbub/Callback.php | 4 ++--
Idno/Pages/Search/Mentions.php | 3 +--
Idno/Pages/Search/User.php | 3 ++-
Idno/Pages/Service/Db/Optimise.php | 2 +-
Idno/Pages/Service/Geo/Geocoder.php | 8 ++++----
Idno/Pages/Service/Security/CSRFToken.php | 5 ++---
Idno/Pages/Service/Vendor/Messages.php | 2 +-
Idno/Pages/Service/Web/RemovePreview.php | 3 +--
Idno/Pages/Service/Web/UrlUnfurl.php | 11 +++++------
Idno/Pages/Txt/Robots.php | 2 +-
Idno/Pages/Webfinger/View.php | 3 ++-
Idno/Pages/Webmentions/Endpoint.php | 7 ++++---
36 files changed, 124 insertions(+), 94 deletions(-)
diff --git a/Idno/Common/Page.php b/Idno/Common/Page.php
index 7498da2438..08a40f45b8 100644
--- a/Idno/Common/Page.php
+++ b/Idno/Common/Page.php
@@ -6,7 +6,7 @@
* Developers should extend the getContent, postContent and dataContent
* methods as follows:
*
- * getContent: echoes HTML to the page
+ * getContent: set content for the page using \Idno\Core\Idno::site()->response()->setContent()
*
* postContent: handles content submitted to the page (assuming that form
* elements were correctly signed)
@@ -879,7 +879,7 @@ function deniedContent($title = '')
\Idno\Core\Idno::site()->response()->headers->remove('X-Known-CSRF-Token');
$t = \Idno\Core\Idno::site()->template();
- $content = $t->__(array('body' => $t->draw('pages/403'), 'title' => $title))->drawPage();
+ $content = $t->__(array('body' => $t->draw('pages/403'), 'title' => $title))->drawPage(false);
\Idno\Core\Idno::site()->response()->setContent($content);
}
diff --git a/Idno/Core/Bonita/Templates.php b/Idno/Core/Bonita/Templates.php
index b9a4acb7b8..188275b252 100644
--- a/Idno/Core/Bonita/Templates.php
+++ b/Idno/Core/Bonita/Templates.php
@@ -195,18 +195,21 @@ function process($content, $processor = 'text')
function drawPage($echo = true, $shell = 'shell')
{
if ($echo) {
+ // For Backward Compatibility reasons
+ \Idno\Core\Idno::site()->response()->setContent($this->draw($shell));
+ \Idno\Core\Idno::site()->sendResponse();
- $content = $this->draw($shell);
- header('Content-Length: ' . strlen($content));
+ // $content = $this->draw($shell);
+ // header('Content-Length: ' . strlen($content));
- // Break long output to avoid an Apache performance bug
- $split_output = str_split($content, 1024);
+ // // Break long output to avoid an Apache performance bug
+ // $split_output = str_split($content, 1024);
- foreach ($split_output as $chunk) {
- echo $chunk;
- }
+ // foreach ($split_output as $chunk) {
+ // echo $chunk;
+ // }
- exit;
+ // exit;
} else {
return $this->draw($shell);
}
diff --git a/Idno/Pages/Account/Export/RSS.php b/Idno/Pages/Account/Export/RSS.php
index 597a094a44..31111bbd0a 100644
--- a/Idno/Pages/Account/Export/RSS.php
+++ b/Idno/Pages/Account/Export/RSS.php
@@ -5,6 +5,8 @@
use Idno\Common\Page;
use Idno\Core\Idno;
use Idno\Core\Migration;
+ use Symfony\Component\HttpFoundation\HeaderUtils;
+
class RSS extends Page
{
@@ -16,8 +18,13 @@ function postContent()
set_time_limit(0);
- header('Content-type: text/rss');
- header('Content-disposition: attachment; filename=user_export.rss');
+ \Idno\Core\Idno::site()->response()->headers->set('Content-type', 'text/rss');
+ $disposition = HeaderUtils::makeDisposition(
+ HeaderUtils::DISPOSITION_ATTACHMENT,
+ 'user_export.rss'
+ );
+
+ \Idno\Core\Idno::site()->response()->headers->set('Content-Disposition', $disposition);
$hide_private = true;
if ($private = $this->getInput('allposts')) {
@@ -28,13 +35,13 @@ function postContent()
$stats = fstat($f);
- header('Content-Length: ' . $stats['size']);
-
+ \Idno\Core\Idno::site()->response()->headers->set('Content-Length:', $stats['size']);
+ $file = '';
while ($content = fgets($f)) {
- echo $content;
+ $file.=$content;
}
-
fclose($f);
+ \Idno\Core\Idno::site()->response()->setContent($file);
}
exit;
diff --git a/Idno/Pages/Account/Notifications.php b/Idno/Pages/Account/Notifications.php
index c1214a77ee..588610c88e 100644
--- a/Idno/Pages/Account/Notifications.php
+++ b/Idno/Pages/Account/Notifications.php
@@ -51,7 +51,7 @@ function getContent($params = array())
$notif->save();
}
- echo $page;
+ \Idno\Core\Idno::site()->response()->setContent($page);
}
}
diff --git a/Idno/Pages/Account/Password.php b/Idno/Pages/Account/Password.php
index 9f9c404927..6da4dd5b37 100644
--- a/Idno/Pages/Account/Password.php
+++ b/Idno/Pages/Account/Password.php
@@ -29,7 +29,8 @@ function getContent()
$t->title = \Idno\Core\Idno::site()->language()->_('Recover password');
}
- echo $t->draw('shell');
+ $content = $t->draw('shell');
+ \Idno\Core\Idno::site()->response()->setContent($content);
}
diff --git a/Idno/Pages/Account/Register.php b/Idno/Pages/Account/Register.php
index c317f3f54c..0ec766b85b 100644
--- a/Idno/Pages/Account/Register.php
+++ b/Idno/Pages/Account/Register.php
@@ -37,7 +37,7 @@ function getContent()
if (empty($onboarding)) {
$t->body = $t->__(array('email' => $email, 'code' => $code))->draw('account/register');
$t->title = \Idno\Core\Idno::site()->language()->_('Create a new account');
- echo $t->draw('shell');
+ $content = $t->draw('shell');
} else {
$t->body = $t->__(
array(
@@ -47,8 +47,9 @@ function getContent()
'messages' => \Idno\Core\Idno::site()->session()->getAndFlushMessages())
)->draw('onboarding/register');
$t->title = \Idno\Core\Idno::site()->language()->_('Create a new account');
- echo $t->draw('shell/simple');
+ $content = $t->draw('shell/simple');
}
+ \Idno\Core\Idno::site()->response()->setContent($content);
}
function postContent()
diff --git a/Idno/Pages/Account/Settings/Tools.php b/Idno/Pages/Account/Settings/Tools.php
index 399013e256..182ac34cfd 100644
--- a/Idno/Pages/Account/Settings/Tools.php
+++ b/Idno/Pages/Account/Settings/Tools.php
@@ -19,12 +19,13 @@ function getContent()
if ($this->xhr) {
\Idno\Core\Actions::validateToken('/account/settings/tools/');
$user = \Idno\Core\Idno::site()->session()->currentUser();
- echo json_encode($user->getAPIkey());
+ \Idno\Core\Idno::site()->response()->setJsonContent(json_encode($user->getAPIkey()));
} else {
$t = \Idno\Core\Idno::site()->template();
$t->body = $t->draw('account/settings/tools');
$t->title = \Idno\Core\Idno::site()->language()->_('Tools and Apps');
- $t->drawPage();
+ $content = $t->drawPage(false);
+ \Idno\Core\Idno::site()->response()->setContent($content);
}
}
diff --git a/Idno/Pages/Admin/Diagnostics.php b/Idno/Pages/Admin/Diagnostics.php
index ef9ce53c1e..be677a9d0a 100644
--- a/Idno/Pages/Admin/Diagnostics.php
+++ b/Idno/Pages/Admin/Diagnostics.php
@@ -49,13 +49,14 @@ function getContent()
// Hook so other plugins and subsystems can add their own data to the report.
$report = \Idno\Core\Idno::site()->events()->triggerEvent('diagnostics/report', [], $report);
- echo $report;
- exit;
+ \Idno\Core\Idno::site()->response()->setContent($report);
+ \Idno\Core\Idno::site()->sendResponse();
} else {
$t = \Idno\Core\Idno::site()->template();
$t->body = $t->__(['basics' => $basics])->draw('admin/diagnostics');
$t->title = \Idno\Core\Idno::site()->language()->_('Diagnostics');
- $t->drawPage();
+ $content = $t->drawPage(false);
+ \Idno\Core\Idno::site()->response()->setContent($content);
}
}
diff --git a/Idno/Pages/Admin/Export/RSS.php b/Idno/Pages/Admin/Export/RSS.php
index ad2d141d5a..3c3f1ec1f2 100644
--- a/Idno/Pages/Admin/Export/RSS.php
+++ b/Idno/Pages/Admin/Export/RSS.php
@@ -4,6 +4,8 @@
use Idno\Common\Page;
use Idno\Core\Migration;
+ use Symfony\Component\HttpFoundation\HeaderUtils;
+
class RSS extends Page
{
@@ -15,8 +17,13 @@ function postContent()
set_time_limit(0);
- header('Content-type: text/rss');
- header('Content-disposition: attachment; filename=export.rss');
+ \Idno\Core\site()->response()->headers->set('Content-type', 'text/rss');
+ $disposition = HeaderUtils::makeDisposition(
+ HeaderUtils::DISPOSITION_ATTACHMENT,
+ 'export.rss'
+ );
+
+ \Idno\Core\site()->response()->headers->set('Content-Disposition', $disposition);
$hide_private = true;
if ($private = $this->getInput('allposts')) {
@@ -27,15 +34,16 @@ function postContent()
$stats = fstat($f);
- header('Content-Length: ' . $stats['size']);
-
+ \Idno\Core\site()->response()->headers->set('Content-Length:', $stats['size']);
+ $file = '';
while ($content = fgets($f)) {
- echo $content;
+ $file .= $content;
}
fclose($f);
+ \Idno\Core\site()->response()->setContent($file);
}
- exit;
+ \Idno\Core\site()->sendResponse();
}
diff --git a/Idno/Pages/Admin/Logs.php b/Idno/Pages/Admin/Logs.php
index 786207238d..843cb91d69 100644
--- a/Idno/Pages/Admin/Logs.php
+++ b/Idno/Pages/Admin/Logs.php
@@ -11,13 +11,14 @@ function getContent()
// Retrieved via API, so just dump logs
if ($this->xhr || \Idno\Core\Idno::site()->session()->isAPIRequest()) {
- echo file_get_contents(\Idno\Core\Idno::site()->config()->getTempDir() . \Idno\Core\Idno::site()->config()->host . '.log');
+ \Idno\Core\Idno::site()->response()->setJsonContent(file_get_contents(\Idno\Core\Idno::site()->config()->getTempDir() . \Idno\Core\Idno::site()->config()->host . '.log'));
} else {
$t = \Idno\Core\Idno::site()->template();
$t->body = $t->__([])->draw('admin/logs');
$t->title = \Idno\Core\Idno::site()->language()->_('Log capture');
- $t->drawPage();
+ $content = $t->drawPage(false);
+ \Idno\Core\Idno::site()->response()->setContent($content);
}
}
diff --git a/Idno/Pages/Admin/Plugins.php b/Idno/Pages/Admin/Plugins.php
index b9044f989e..f1997dcc12 100644
--- a/Idno/Pages/Admin/Plugins.php
+++ b/Idno/Pages/Admin/Plugins.php
@@ -42,14 +42,14 @@ function postContent()
if (\Idno\Core\Idno::site()->plugins()->enable($plugin)) {
\Idno\Core\Idno::site()->session()->addMessage(\Idno\Core\Idno::site()->language()->_('The plugin was enabled.'));
- echo json_encode(
+ \Idno\Core\Idno::site()->response()->setJsonContent(json_encode(
[
'action' => $action,
'status' => true,
'message' => \Idno\Core\Idno::site()->language()->_('The plugin was enabled.')
]
- );
- exit;
+ ));
+ \Idno\Core\Idno::site()->sendResponse();
}
break;
@@ -58,14 +58,14 @@ function postContent()
if (\Idno\Core\Idno::site()->plugins()->disable($plugin)) {
\Idno\Core\Idno::site()->session()->addMessage(\Idno\Core\Idno::site()->language()->_('The plugin was disabled.'));
- echo json_encode(
+ \Idno\Core\Idno::site()->response()->setJsonContent( json_encode(
[
'action' => $action,
'status' => true,
'message' => \Idno\Core\Idno::site()->language()->_('The plugin was disabled.')
]
- );
- exit;
+ ));
+ \Idno\Core\Idno::site()->sendResponse();
}
break;
@@ -73,12 +73,12 @@ function postContent()
}
- echo json_encode(
+ \Idno\Core\Idno::site()->response()->setJsonContent( json_encode(
[
'action' => $action,
'status' => false,
]
- );
+ ));
//$this->forward(\Idno\Core\Idno::site()->config()->getDisplayURL() . 'admin/plugins/');
}
diff --git a/Idno/Pages/Admin/Statistics.php b/Idno/Pages/Admin/Statistics.php
index 0eb1a46e38..0ef974ef40 100644
--- a/Idno/Pages/Admin/Statistics.php
+++ b/Idno/Pages/Admin/Statistics.php
@@ -20,13 +20,14 @@ function getContent()
header('Content-type: application/json');
- echo json_encode($stats);
+ \Idno\Core\Idno::site()->response()->setJsonContent(json_encode($stats));
} else {
$t = \Idno\Core\Idno::site()->template();
$t->body = $t->__(['statistics' => $stats, 'tab' => $this->getInput('tab', $report)])->draw('admin/statistics');
$t->title = \Idno\Core\Idno::site()->language()->_('Statistics');
- $t->drawPage();
+ $content = $t->drawPage();
+ \Idno\Core\Idno::site()->response()->setContent($content);
}
}
diff --git a/Idno/Pages/Chrome/Manifest.php b/Idno/Pages/Chrome/Manifest.php
index 9cbae8e724..e2b53b9972 100644
--- a/Idno/Pages/Chrome/Manifest.php
+++ b/Idno/Pages/Chrome/Manifest.php
@@ -10,7 +10,7 @@ class Manifest extends Page
function getContent()
{
- echo \Idno\Core\Idno::site()->template()->draw('chrome/manifest');
+ \Idno\Core\Idno::site()->response()->setContent(\Idno\Core\Idno::site()->template()->draw('chrome/manifest'));
}
diff --git a/Idno/Pages/Chrome/ServiceWorker.php b/Idno/Pages/Chrome/ServiceWorker.php
index d83957bbd7..b31d2fdbfc 100644
--- a/Idno/Pages/Chrome/ServiceWorker.php
+++ b/Idno/Pages/Chrome/ServiceWorker.php
@@ -17,11 +17,11 @@ class ServiceWorker extends Page
function getContent()
{
- header('Content-Type: application/javascript');
+ \Idno\Core\Idno::site()->response()->headers->set('Content-Type', 'application/javascript');
if (!empty($this->arguments[0])) {
- echo file_get_contents(\Idno\Core\Idno::site()->config()->path . '/js/service-worker.min.js');
+ \Idno\Core\Idno::site()->response()->setContent(file_get_contents(\Idno\Core\Idno::site()->config()->path . '/js/service-worker.min.js'));
} else {
- echo file_get_contents(\Idno\Core\Idno::site()->config()->path . '/js/service-worker.js');
+ \Idno\Core\Idno::site()->response()->setContent(file_get_contents(\Idno\Core\Idno::site()->config()->path . '/js/service-worker.js'));
}
}
diff --git a/Idno/Pages/Entity/Bookmarklet.php b/Idno/Pages/Entity/Bookmarklet.php
index 20d7707e56..39b90b9e73 100644
--- a/Idno/Pages/Entity/Bookmarklet.php
+++ b/Idno/Pages/Entity/Bookmarklet.php
@@ -16,7 +16,7 @@ function getContent()
{
$t = \Idno\Core\Idno::site()->template();
- echo $t->draw('entity/bookmarklet');
+ Idno\Core\Idno::site()->response->setContent(($t->draw('entity/bookmarklet')));
}
diff --git a/Idno/Pages/Entity/Withdraw.php b/Idno/Pages/Entity/Withdraw.php
index bfb05f7080..168cca9c67 100644
--- a/Idno/Pages/Entity/Withdraw.php
+++ b/Idno/Pages/Entity/Withdraw.php
@@ -19,8 +19,9 @@ function getContent()
}
if (empty($object)) {
$this->setResponse(404);
- echo \Idno\Core\Idno::site()->template()->__(array('body' => \Idno\Core\Idno::site()->template()->draw('404'), 'title' => 'Not found'))->drawPage();
- exit;
+ $content = \Idno\Core\Idno::site()->template()->__(array('body' => \Idno\Core\Idno::site()->template()->draw('404'), 'title' => 'Not found'))->drawPage(false);
+ \Idno\Core\Idno::site()->response()->setContent($content);
+ \Idno\Core\Idno::site()->sendResponse();
}
}
@@ -33,14 +34,16 @@ function postContent()
}
if (empty($object)) {
$this->setResponse(404);
- echo \Idno\Core\Idno::site()->template()->__(array('body' => \Idno\Core\Idno::site()->template()->draw('404'), 'title' => 'Not found'))->drawPage();
- exit;
+ $content = \Idno\Core\Idno::site()->template()->__(array('body' => \Idno\Core\Idno::site()->template()->draw('404'), 'title' => 'Not found'))->drawPage(false);
+ \Idno\Core\Idno::site()->response()->setContent($content);
+ \Idno\Core\Idno::site()->sendResponse();
}
if (!$object->canEdit()) {
$this->setResponse(403);
- echo \Idno\Core\Idno::site()->template()->__(array('body' => \Idno\Core\Idno::site()->template()->draw('403'), 'title' => 'Permission denied'))->drawPage();
- exit;
+ $content = \Idno\Core\Idno::site()->template()->__(array('body' => \Idno\Core\Idno::site()->template()->draw('403'), 'title' => 'Permission denied'))->drawPage(false);
+ \Idno\Core\Idno::site()->response()->setContent($content);
+ \Idno\Core\Idno::site()->sendResponse();
}
$object->unsyndicate();
diff --git a/Idno/Pages/File/Mint.php b/Idno/Pages/File/Mint.php
index fcc10d5d3e..58364e44cf 100644
--- a/Idno/Pages/File/Mint.php
+++ b/Idno/Pages/File/Mint.php
@@ -53,10 +53,10 @@ public function postContent()
// Mint an ID
// Lets tell people about where to stick the data
- echo json_encode(
+ \Idno\Core\Idno::site()->response()->setJsonContent(json_encode(
[
'uploadUrl' => $upload_url
]
- );
+ ));
}
}
diff --git a/Idno/Pages/File/Picker.php b/Idno/Pages/File/Picker.php
index 5f4165be77..4e6d4b5a34 100644
--- a/Idno/Pages/File/Picker.php
+++ b/Idno/Pages/File/Picker.php
@@ -50,8 +50,9 @@ function post()
if ($return) {
$t = \Idno\Core\Idno::site()->template();
$t->file = $file;
- echo $t->draw('file/picker/donejs');
- exit;
+ $content = $t->draw('file/picker/donejs');
+ \Idno\Core\Idno::site()->response()->setContent($content);
+ \Idno\Core\Idno::site()->sendResponse();
}
} else {
Idno::site()->session()->addErrorMessage(\Idno\Core\Idno::site()->language()->_("You can only upload images."));
diff --git a/Idno/Pages/File/Upload.php b/Idno/Pages/File/Upload.php
index 0808256292..77da0d7dd0 100644
--- a/Idno/Pages/File/Upload.php
+++ b/Idno/Pages/File/Upload.php
@@ -22,7 +22,7 @@ function post()
exit;
}
if ($file = \Idno\Entities\File::createFromFile($_FILES['file']['tmp_name'], $_FILES['file']['name'], $_FILES['file']['type'], true, true)) {
- echo json_encode(\Idno\Core\Idno::site()->config()->url . 'file/' . $file->file['_id']);
+ \Idno\Core\Idno::site()->response()->setJsonContent( json_encode(\Idno\Core\Idno::site()->config()->url . 'file/' . $file->file['_id']));
}
}
}
diff --git a/Idno/Pages/Hub/Register/Site.php b/Idno/Pages/Hub/Register/Site.php
index 7528efc02b..83b8c95501 100644
--- a/Idno/Pages/Hub/Register/Site.php
+++ b/Idno/Pages/Hub/Register/Site.php
@@ -38,8 +38,8 @@ function post()
}
- echo json_encode($result);
- exit;
+ \Idno\Core\Idno::site()->response()->setJsonContent( json_encode($result));
+ \Idno\Core\Idno::site()->sendResponse();
}
diff --git a/Idno/Pages/Hub/Register/User.php b/Idno/Pages/Hub/Register/User.php
index 4b45a625fa..8363b34f38 100644
--- a/Idno/Pages/Hub/Register/User.php
+++ b/Idno/Pages/Hub/Register/User.php
@@ -49,8 +49,8 @@ function post()
$result = array('status' => 'fail', 'message' => 'Signature does not match: ' . $signature . ', ' . $hmac);
}
- echo json_encode($result);
- exit;
+ \Idno\Core\Idno::site()->response()->setJsonContent(json_encode($result));
+ \Idno\Core\Idno::site()->sendResponse();
}
diff --git a/Idno/Pages/Onboarding/Begin.php b/Idno/Pages/Onboarding/Begin.php
index c1dfaaf396..b6edea1424 100644
--- a/Idno/Pages/Onboarding/Begin.php
+++ b/Idno/Pages/Onboarding/Begin.php
@@ -18,13 +18,14 @@ function getContent()
}
$t = \Idno\Core\Idno::site()->template();
- echo $t->__(
+ $content = $t->__(
array(
'body' => $t->draw('onboarding/begin'),
'title' => \Idno\Core\Idno::site()->language()->_('Welcome to Known'),
'messages' => \Idno\Core\Idno::site()->session()->getAndFlushMessages()
)
- )->draw('shell/simple');
+ )->draw('shell/simple')
+ \Idno\Core\Idno::site()->response()->setContent($content);
}
diff --git a/Idno/Pages/Onboarding/Connect.php b/Idno/Pages/Onboarding/Connect.php
index 4f5e649d3a..7ccf05c24a 100644
--- a/Idno/Pages/Onboarding/Connect.php
+++ b/Idno/Pages/Onboarding/Connect.php
@@ -20,7 +20,7 @@ function getContent()
$_SESSION['onboarding_passthrough'] = true;
$t = \Idno\Core\Idno::site()->template();
- echo $t->__(
+ $content = $t->__(
array(
'title' => \Idno\Core\Idno::site()->language()->_("Connect some networks"),
@@ -29,6 +29,7 @@ function getContent()
)
)->draw('shell/simple');
+ \Idno\Core\Idno::site()->response()->setContent($content);
//} else {
// $this->forward(\Idno\Core\Idno::site()->config()->getURL() . 'begin/publish');
//}
diff --git a/Idno/Pages/Onboarding/Profile.php b/Idno/Pages/Onboarding/Profile.php
index 50521bf74c..cc502fd339 100644
--- a/Idno/Pages/Onboarding/Profile.php
+++ b/Idno/Pages/Onboarding/Profile.php
@@ -17,7 +17,7 @@ function getContent()
$user = \Idno\Core\Idno::site()->session()->currentUser();
$t = \Idno\Core\Idno::site()->template();
- echo $t->__(
+ $content = $t->__(
array(
'title' => \Idno\Core\Idno::site()->language()->_("Create your profile"),
@@ -26,6 +26,7 @@ function getContent()
)
)->draw('shell/simple');
+ \Idno\Core\Idno::site()->response()->setContent($content);
}
diff --git a/Idno/Pages/Pubsubhubbub/Callback.php b/Idno/Pages/Pubsubhubbub/Callback.php
index 1673ecf612..6a8191151a 100644
--- a/Idno/Pages/Pubsubhubbub/Callback.php
+++ b/Idno/Pages/Pubsubhubbub/Callback.php
@@ -50,8 +50,8 @@ function getContent()
$subscriber->save();
\Idno\Core\Idno::site()->logging()->debug("Pubsub: $hub_challenge");
- echo $hub_challenge;
- exit;
+ \Idno\Core\Idno::site()->response()->setContent($hub_challenge);
+ \Idno\Core\Idno::site()->sendResponse();
}
break;
}
diff --git a/Idno/Pages/Search/Mentions.php b/Idno/Pages/Search/Mentions.php
index a3209a1136..c35f0ffdd0 100644
--- a/Idno/Pages/Search/Mentions.php
+++ b/Idno/Pages/Search/Mentions.php
@@ -34,8 +34,7 @@ function getContent()
}
}
- header('Content-type: text/json');
- echo json_encode($results);
+ \Idno\Core\Idno::site()->response()->setJsonContent(json_encode($results));
}
diff --git a/Idno/Pages/Search/User.php b/Idno/Pages/Search/User.php
index af72d72cc8..f7320ba2d5 100644
--- a/Idno/Pages/Search/User.php
+++ b/Idno/Pages/Search/User.php
@@ -59,7 +59,8 @@ public function getContent()
$results['rendered'] .= $template_postponed_link_actions;
}
- echo json_encode($results); exit;
+ \Idno\Core\Idno::site()->response()->setJsonContent(json_encode($results));
+ \Idno\Core\Idno::site()->sendResponse();
}
}
diff --git a/Idno/Pages/Service/Db/Optimise.php b/Idno/Pages/Service/Db/Optimise.php
index b25bc39243..6635982a7d 100644
--- a/Idno/Pages/Service/Db/Optimise.php
+++ b/Idno/Pages/Service/Db/Optimise.php
@@ -16,7 +16,7 @@ function getContent()
\Idno\Core\Idno::site()->config()->dboptimized = $time;
\Idno\Core\Idno::site()->config()->save();
- echo json_encode('optimised');
+ \Idno\Core\Idno::site()->response()->setJsonContent(json_encode('optimised'));
}
}
diff --git a/Idno/Pages/Service/Geo/Geocoder.php b/Idno/Pages/Service/Geo/Geocoder.php
index b032e5c342..053e0f6bd5 100644
--- a/Idno/Pages/Service/Geo/Geocoder.php
+++ b/Idno/Pages/Service/Geo/Geocoder.php
@@ -22,14 +22,14 @@ function getContent()
$lat = $this->getInput('lat');
$long = $this->getInput('long');
if (!empty($lat) && (!empty($long))) {
- echo json_encode($geocoder->queryLatLong($lat, $long), JSON_PRETTY_PRINT);
- exit;
+ \Idno\Core\Idno::site()->response()->setJsonContent(json_encode($geocoder->queryLatLong($lat, $long), JSON_PRETTY_PRINT));
+ \Idno\Core\Idno::site()->sendResponse();
}
$address = $this->getInput('address');
if (!empty($address)) {
- echo json_encode($geocoder->queryAddress($address), JSON_PRETTY_PRINT);
- exit;
+ \Idno\Core\Idno::site()->response()->setJsonContent(json_encode($geocoder->queryAddress($address), JSON_PRETTY_PRINT));
+ \Idno\Core\Idno::site()->sendResponse();
}
}
diff --git a/Idno/Pages/Service/Security/CSRFToken.php b/Idno/Pages/Service/Security/CSRFToken.php
index 5b1313ceab..7413ad3512 100644
--- a/Idno/Pages/Service/Security/CSRFToken.php
+++ b/Idno/Pages/Service/Security/CSRFToken.php
@@ -22,13 +22,12 @@ function getContent()
$time = time();
$token = \Idno\Core\Bonita\Forms::token($action, $time);
- header('Content-type: application/json');
- echo json_encode(
+ \Idno\Core\Idno::site()->response()->setJsonContent(json_encode(
[
'time' => $time,
'token' => $token
]
- );
+ ));
}
}
diff --git a/Idno/Pages/Service/Vendor/Messages.php b/Idno/Pages/Service/Vendor/Messages.php
index 9f3e059eeb..c1cb394666 100644
--- a/Idno/Pages/Service/Vendor/Messages.php
+++ b/Idno/Pages/Service/Vendor/Messages.php
@@ -11,7 +11,7 @@ function getContent()
$this->setNoCache();
if ($messages = \Idno\Core\Vendor::getMessages()) {
- echo json_encode($messages);
+ \Idno\Core\Idno::site()->response()->setJsonContent(json_encode($messages));
}
}
diff --git a/Idno/Pages/Service/Web/RemovePreview.php b/Idno/Pages/Service/Web/RemovePreview.php
index 65bea718d2..6a4b84c349 100644
--- a/Idno/Pages/Service/Web/RemovePreview.php
+++ b/Idno/Pages/Service/Web/RemovePreview.php
@@ -11,7 +11,6 @@ function postContent()
$this->gatekeeper();
\Idno\Core\Idno::site()->template()->setTemplateType('json');
- header('Content-type: application/json');
if (!empty($this->arguments[0])) {
$object = \Idno\Common\Entity::getByID($this->arguments[0]);
@@ -29,7 +28,7 @@ function postContent()
$object->hide_preview = true;
- echo json_encode($object->save());
+ \Idno\Core\Idno::site()->response()->setContent(json_encode($object->save()));
}
diff --git a/Idno/Pages/Service/Web/UrlUnfurl.php b/Idno/Pages/Service/Web/UrlUnfurl.php
index 0c04239943..cc5ecdb92a 100644
--- a/Idno/Pages/Service/Web/UrlUnfurl.php
+++ b/Idno/Pages/Service/Web/UrlUnfurl.php
@@ -9,7 +9,6 @@ function deleteContent()
{
\Idno\Core\Idno::site()->template()->setTemplateType('json');
- header('Content-type: application/json');
$this->xhrGatekeeper();
$this->tokenGatekeeper();
@@ -22,12 +21,12 @@ function deleteContent()
// Try and get UnfurledURL entity
if ($object = \Idno\Entities\UnfurledUrl::getBySourceURL($url)) {
- echo json_encode(
+ \Idno\Core\Idno::site()->response()->setJsonContent( json_encode(
[
'url' => $url,
'status' => $object->delete()
]
- );
+ ));
} else {
$this->noContent();
}
@@ -59,9 +58,9 @@ function getContent()
$unfurled['id'] = $object->getID();
$unfurled['rendered'] = $template->__(['object' => $object])->draw('entity/UnfurledUrl');
- echo json_encode($unfurled, JSON_PRETTY_PRINT);
+ \Idno\Core\Idno::site()->response()->setJsonContent( json_encode($unfurled, JSON_PRETTY_PRINT));
- exit;
+ \Idno\Core\Idno::site()->sendResponse();
}
if (empty($object)) {
@@ -83,7 +82,7 @@ function getContent()
$unfurled['id'] = $object->getID();
$unfurled['rendered'] = $template->__(['object' => $object])->draw('entity/UnfurledUrl');
- echo json_encode($unfurled, JSON_PRETTY_PRINT);
+ \Idno\Core\Idno::site()->response()->setJsonContent(json_encode($unfurled, JSON_PRETTY_PRINT));
}
}
diff --git a/Idno/Pages/Txt/Robots.php b/Idno/Pages/Txt/Robots.php
index 18a8bb4edf..9d4a5d1048 100644
--- a/Idno/Pages/Txt/Robots.php
+++ b/Idno/Pages/Txt/Robots.php
@@ -15,7 +15,7 @@ class Robots extends \Idno\Common\Page
function getContent()
{
$t = \Idno\Core\Idno::site()->template();
- echo $t->draw('txt/robots');
+ \Idno\Core\Idno::site()->response()->setContent($t->draw('txt/robots'));
}
}
diff --git a/Idno/Pages/Webfinger/View.php b/Idno/Pages/Webfinger/View.php
index c10a60e1df..ea82d57bf5 100644
--- a/Idno/Pages/Webfinger/View.php
+++ b/Idno/Pages/Webfinger/View.php
@@ -30,7 +30,7 @@ function getContent()
}
$t = \Idno\Core\Idno::site()->template();
$t->setTemplateType('json');
- echo $t->__(
+ $content = $t->__(
array(
'properties' => [
'http://webfinger.example/ns/name' => $user->getName(),
@@ -39,6 +39,7 @@ function getContent()
'links' => $links
)
)->draw('shell');
+ \Idno\Core\Idno::site()->response()->setContent($content);
}
function postContent()
diff --git a/Idno/Pages/Webmentions/Endpoint.php b/Idno/Pages/Webmentions/Endpoint.php
index 2b9da3942f..7003f4f9d2 100644
--- a/Idno/Pages/Webmentions/Endpoint.php
+++ b/Idno/Pages/Webmentions/Endpoint.php
@@ -15,12 +15,13 @@ class Endpoint extends \Idno\Common\Page
function getContent()
{
$t = \Idno\Core\Idno::site()->template();
- $t->__(
+ $content = $t->__(
[
'title' => \Idno\Core\Idno::site()->language()->_('Webmention endpoint'),
'body' => $t->draw('pages/webmention')
]
- )->drawPage();
+ )->drawPage(false);
+ \Idno\Core\Idno::site()->response()->setContent($content);
}
function post()
@@ -103,7 +104,7 @@ function post()
$error = 'unknown_error';
$error_text = 'Not all the required webmention variables were set.';
}
- echo json_encode(array('error' => $error, 'error_text' => $error_text));
+ \Idno\Core\Idno::site()->response()->setJsonContent(json_encode(array('error' => $error, 'error_text' => $error_text)));
}
}
From c3211c15e32f7a536062bb896e6079607b19c70e Mon Sep 17 00:00:00 2001
From: ipranjal
Date: Sun, 22 Sep 2024 06:03:36 +0530
Subject: [PATCH 04/17] feat: Dispatch event to modify response before sending
---
Idno/Core/Idno.php | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/Idno/Core/Idno.php b/Idno/Core/Idno.php
index 32259ee889..cd82a4f120 100644
--- a/Idno/Core/Idno.php
+++ b/Idno/Core/Idno.php
@@ -355,7 +355,8 @@ function &redirect($url)
*/
function &sendResponse()
{
- $this->response->send();
+ $response = \Idno\Core\Idno::site()->events()->triggerEvent('response/before', ['response' => $this->response()],$this->response());
+ $response->send();
}
/**
From 5bbf215f5a6c7a71a81b5913036233f469f26c30 Mon Sep 17 00:00:00 2001
From: ipranjal
Date: Sun, 22 Sep 2024 06:57:54 +0530
Subject: [PATCH 05/17] feat: symfony and PSR7 conversion support
---
Idno/Core/Http/Request.php | 24 +++++++++++
Idno/Core/Http/Response.php | 18 +++++++-
Idno/Core/Idno.php | 21 ++++++++-
composer.json | 3 +-
composer.lock | 85 ++++++++++++++++++++++++++++++++++++-
index.php | 2 +-
6 files changed, 147 insertions(+), 6 deletions(-)
diff --git a/Idno/Core/Http/Request.php b/Idno/Core/Http/Request.php
index 3affe5cd3b..db04cd6b93 100644
--- a/Idno/Core/Http/Request.php
+++ b/Idno/Core/Http/Request.php
@@ -3,9 +3,33 @@
namespace Idno\Core\http {
use Symfony\Component\HttpFoundation\Request as SymfonyRequest;
+ use Symfony\Bridge\PsrHttpMessage\Factory\HttpFoundationFactory;
class Request extends SymfonyRequest{
+ public static function createFromSymfonyRequest(SymfonyRequest $request)
+ {
+ $newRequest = new self(
+ $request->query->all(),
+ $request->request->all(),
+ $request->attributes->all(),
+ $request->cookies->all(),
+ $request->files->all(),
+ $request->server->all(),
+ $request->getContent()
+ );
+
+ return $newRequest;
+ }
+
+ public static function createFromPSR7Request(\Psr\Http\Message\ServerRequestInterface $psrRequest)
+ {
+ $httpFoundationFactory = new HttpFoundationFactory();
+ $symfonyRequest = $httpFoundationFactory->createRequest($psrRequest);
+ return self::createFromSymfonyRequest($symfonyRequest);
+
+ }
+
}
}
\ No newline at end of file
diff --git a/Idno/Core/Http/Response.php b/Idno/Core/Http/Response.php
index 9eee0e0eb6..ec37724b42 100644
--- a/Idno/Core/Http/Response.php
+++ b/Idno/Core/Http/Response.php
@@ -4,9 +4,13 @@
use Symfony\Component\HttpFoundation\Response as SymfonyResponse;
-
class Response extends SymfonyResponse{
+ private bool $sendPsr7Response = false;
+ private $psrHttpFactory = null;
+
+ private $delaySend = false;
+
public function setJsonContent($content)
{
$this->headers->set('Content-Type', 'application/json');
@@ -14,5 +18,17 @@ public function setJsonContent($content)
return $this;
}
+ public function delaySend()
+ {
+ $this->delaySend = true;
+ }
+
+ public function isDelayed()
+ {
+ return $this->delaySend;
+ }
+
+
+
}
}
\ No newline at end of file
diff --git a/Idno/Core/Idno.php b/Idno/Core/Idno.php
index cd82a4f120..80aa882c05 100644
--- a/Idno/Core/Idno.php
+++ b/Idno/Core/Idno.php
@@ -349,14 +349,31 @@ function &redirect($url)
}
+ function &createRequest($request=null)
+ {
+ if($request instanceof \Symfony\Component\HttpFoundation\Request){
+ $this->request = Request::createFromSymfonyRequest($request);
+ } elseif ($request instanceof \Psr\Http\Message\ServerRequestInterface) {
+ $this->request = Request::createFromPsr7Request($request);
+ }
+ else {
+ $this->request = Request::createFromGlobals();
+ }
+ }
+
/**
* Send the response
*/
function &sendResponse()
{
- $response = \Idno\Core\Idno::site()->events()->triggerEvent('response/before', ['response' => $this->response()],$this->response());
- $response->send();
+ $this->response = \Idno\Core\Idno::site()->events()->triggerEvent('response/before', ['response' => $this->response()],$this->response());
+ // Delay sending response so that it can be modified if required
+ if(!$this->response->isDelayed()){
+ $this->response->send();
+ }
+ \Idno\Core\Idno::site()->events()->triggerEvent('response/delayed', ['response' => $this->response()]);
+
}
/**
diff --git a/composer.json b/composer.json
index 52faa9265d..5b1f069331 100644
--- a/composer.json
+++ b/composer.json
@@ -58,7 +58,8 @@
"npm-asset/eonasdan-bootstrap-datetimepicker": "^6.2",
"composer/installers": "^2",
"vlucas/phpdotenv": "^5.3",
- "landrok/activitypub": "^0.7.1"
+ "landrok/activitypub": "^0.7.1",
+ "symfony/psr-http-message-bridge": "^7.1"
},
"license": "Apache-2.0",
"prefer-stable": true,
diff --git a/composer.lock b/composer.lock
index 0ccee32b0d..cc2227a4eb 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "065bdf72bb684997eb83e298a2759adb",
+ "content-hash": "89ff0b9a11e06e8340fa07a33812984a",
"packages": [
{
"name": "brick/math",
@@ -4070,6 +4070,89 @@
],
"time": "2024-01-29T20:11:03+00:00"
},
+ {
+ "name": "symfony/psr-http-message-bridge",
+ "version": "v7.1.4",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/psr-http-message-bridge.git",
+ "reference": "405a7bcd872f1563966f64be19f1362d94ce71ab"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/symfony/psr-http-message-bridge/zipball/405a7bcd872f1563966f64be19f1362d94ce71ab",
+ "reference": "405a7bcd872f1563966f64be19f1362d94ce71ab",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=8.2",
+ "psr/http-message": "^1.0|^2.0",
+ "symfony/http-foundation": "^6.4|^7.0"
+ },
+ "conflict": {
+ "php-http/discovery": "<1.15",
+ "symfony/http-kernel": "<6.4"
+ },
+ "require-dev": {
+ "nyholm/psr7": "^1.1",
+ "php-http/discovery": "^1.15",
+ "psr/log": "^1.1.4|^2|^3",
+ "symfony/browser-kit": "^6.4|^7.0",
+ "symfony/config": "^6.4|^7.0",
+ "symfony/event-dispatcher": "^6.4|^7.0",
+ "symfony/framework-bundle": "^6.4|^7.0",
+ "symfony/http-kernel": "^6.4|^7.0"
+ },
+ "type": "symfony-bridge",
+ "autoload": {
+ "psr-4": {
+ "Symfony\\Bridge\\PsrHttpMessage\\": ""
+ },
+ "exclude-from-classmap": [
+ "/Tests/"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Fabien Potencier",
+ "email": "fabien@symfony.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "https://symfony.com/contributors"
+ }
+ ],
+ "description": "PSR HTTP message bridge",
+ "homepage": "https://symfony.com",
+ "keywords": [
+ "http",
+ "http-message",
+ "psr-17",
+ "psr-7"
+ ],
+ "support": {
+ "source": "https://github.com/symfony/psr-http-message-bridge/tree/v7.1.4"
+ },
+ "funding": [
+ {
+ "url": "https://symfony.com/sponsor",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/fabpot",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2024-08-15T22:48:53+00:00"
+ },
{
"name": "symfony/service-contracts",
"version": "v3.5.0",
diff --git a/index.php b/index.php
index bf7a80480f..a1a140c5d2 100644
--- a/index.php
+++ b/index.php
@@ -30,7 +30,7 @@
require_once dirname(__FILE__) . '/Idno/start.php';
// Get page routes
-
+\Idno\Core\Idno::site()->createRequest();
$routes = \Idno\Core\Idno::site()->routes();
// Get subdirectory
From a958c070d5556c362e12bbe914e3f88013796e93 Mon Sep 17 00:00:00 2001
From: ipranjal
Date: Sun, 22 Sep 2024 10:14:57 +0530
Subject: [PATCH 06/17] fix : onboarding issues
---
Idno/Common/Page.php | 1 -
Idno/Core/Bonita/Templates.php | 23 ++++---
Idno/Core/Http/RedirectResponse.php | 64 ++++++++++++++++++-
Idno/Core/Idno.php | 12 ++--
Idno/Core/IdnoFoundation.php | 34 ++++++++++
Idno/Core/Input.php | 4 +-
Idno/Core/PageHandler.php | 4 +-
Idno/Data/MySQL.php | 6 +-
Idno/Pages/Onboarding/Begin.php | 2 +-
Idno/Pages/Onboarding/Register.php | 1 +
Idno/Pages/User/View.php | 5 ++
Idno/start.php | 35 +++++-----
index.php | 3 +
templates/default/settings-shell/css.tpl.php | 2 +-
.../default/settings-shell/javascript.tpl.php | 2 +-
templates/default/shell/css.tpl.php | 2 +-
templates/default/shell/javascript.tpl.php | 2 +-
.../templates/default/pages/settings.tpl.php | 10 +--
18 files changed, 164 insertions(+), 48 deletions(-)
create mode 100644 Idno/Core/IdnoFoundation.php
diff --git a/Idno/Common/Page.php b/Idno/Common/Page.php
index 08a40f45b8..f35ac8bdc4 100644
--- a/Idno/Common/Page.php
+++ b/Idno/Common/Page.php
@@ -1342,7 +1342,6 @@ public function setNoCache()
public function setLastModifiedHeader(int $timestamp)
{
\Idno\Core\Idno::site()->response()->headers->set('Last-Modified', \Idno\Core\Time::timestampToRFC2616($timestamp));
- \Idno\Core\Idno::site()->sendResponse();
}
/**
diff --git a/Idno/Core/Bonita/Templates.php b/Idno/Core/Bonita/Templates.php
index 188275b252..d7361488b0 100644
--- a/Idno/Core/Bonita/Templates.php
+++ b/Idno/Core/Bonita/Templates.php
@@ -196,20 +196,23 @@ function drawPage($echo = true, $shell = 'shell')
{
if ($echo) {
// For Backward Compatibility reasons
- \Idno\Core\Idno::site()->response()->setContent($this->draw($shell));
- \Idno\Core\Idno::site()->sendResponse();
+
+ \Idno\Core\Idno::site()->response()->setContent($this->draw($shell));
+ \Idno\Core\Idno::site()->sendResponse();
+
+ // $content = $this->draw($shell);
+ // header('Content-Length: ' . strlen($content));
- // $content = $this->draw($shell);
- // header('Content-Length: ' . strlen($content));
+ // // Break long output to avoid an Apache performance bug
+ // $split_output = str_split($content, 1024);
- // // Break long output to avoid an Apache performance bug
- // $split_output = str_split($content, 1024);
+ // foreach ($split_output as $chunk) {
+ // echo $chunk;
+ // }
+
+ // exit;
- // foreach ($split_output as $chunk) {
- // echo $chunk;
- // }
- // exit;
} else {
return $this->draw($shell);
}
diff --git a/Idno/Core/Http/RedirectResponse.php b/Idno/Core/Http/RedirectResponse.php
index 932018d567..e8dd9a007e 100644
--- a/Idno/Core/Http/RedirectResponse.php
+++ b/Idno/Core/Http/RedirectResponse.php
@@ -2,9 +2,69 @@
namespace Idno\Core\http {
- use Symfony\Component\HttpFoundation\RedirectResponse as SymfonyRedirectResponse;
- class RedirectResponse extends SymfonyRedirectResponse{
+ class RedirectResponse extends Response
+ {
+ private string $targetUrl;
+
+ public function __construct(string $url, int $status = 302, array $headers = [])
+ {
+ parent::__construct('', $status, $headers);
+
+ $this->setTargetUrl($url);
+
+ if (!$this->isRedirect()) {
+ throw new \InvalidArgumentException(sprintf('The HTTP status code is not a redirect ("%s" given).', $status));
+ }
+
+ if (301 == $status && !\array_key_exists('cache-control', array_change_key_case($headers, \CASE_LOWER))) {
+ $this->headers->remove('cache-control');
+ }
+ }
+
+ /**
+ * Returns the target URL.
+ */
+ public function getTargetUrl(): string
+ {
+ return $this->targetUrl;
+ }
+
+ /**
+ * Sets the redirect target of this response.
+ *
+ * @return $this
+ *
+ * @throws \InvalidArgumentException
+ */
+ public function setTargetUrl(string $url): static
+ {
+ if ('' === $url) {
+ throw new \InvalidArgumentException('Cannot redirect to an empty URL.');
+ }
+
+ $this->targetUrl = $url;
+
+ $this->setContent(
+ sprintf('
+
+
+
+
+
+ Redirecting to %1$s
+
+
+ Redirecting to %1$s .
+
+ ', htmlspecialchars($url, \ENT_QUOTES, 'UTF-8'))
+ );
+
+ $this->headers->set('Location', $url);
+ $this->headers->set('Content-Type', 'text/html; charset=utf-8');
+
+ return $this;
+ }
}
}
\ No newline at end of file
diff --git a/Idno/Core/Idno.php b/Idno/Core/Idno.php
index 80aa882c05..b822622932 100644
--- a/Idno/Core/Idno.php
+++ b/Idno/Core/Idno.php
@@ -64,8 +64,8 @@ function init()
$this->dispatcher = new EventDispatcher();
$this->config = new Config();
if ($this->config->isDefaultConfig()) {
- header('Location: ./warmup/');
- exit; // Load the installer
+ $this->redirect('./warmup/');
+ $this->sendResponse(); // Load the installer
}
// We need to load initial values from the .ini files
@@ -825,10 +825,14 @@ function __sleep()
/**
* Helper method that returns the current site object
*
- * @return \Idno\Core\Idno $site
+ * @return \Idno\Core\Idno | \Idno\Core\IdnoFoundation $site
*/
- static function &site(): ?Idno
+ static function &site():Idno|IdnoFoundation
{
+ // Workaround for wormup to work
+ if(empty(self::$site)){
+ self::$site = new IdnoFoundation();
+ }
return self::$site;
}
diff --git a/Idno/Core/IdnoFoundation.php b/Idno/Core/IdnoFoundation.php
new file mode 100644
index 0000000000..0a3ee2b972
--- /dev/null
+++ b/Idno/Core/IdnoFoundation.php
@@ -0,0 +1,34 @@
+request = Request::createFromGlobals();
+ $this->response = new \Idno\Core\Http\Response();
+ }
+
+ public function &request()
+ {
+ return $this->request;
+ }
+
+ public function &response()
+ {
+ return $this->response;
+ }
+
+ function &sendResponse()
+ {
+ $this->response->send();
+
+ }
+ }
+}
\ No newline at end of file
diff --git a/Idno/Core/Input.php b/Idno/Core/Input.php
index f1ed34c5e7..a4ca5ff089 100644
--- a/Idno/Core/Input.php
+++ b/Idno/Core/Input.php
@@ -26,8 +26,8 @@ public static function getInput($name, $default = null, callable $filter = null)
{
if (!empty($name)) {
$value = null;
- if (isset($_REQUEST[$name])) {
- $value = $_REQUEST[$name];
+ if (\Idno\Core\Idno::site()->request()->request->has($name)) {
+ $value = \Idno\Core\Idno::site()->request()->request->get($name);
}
if (($value===null) && ($default!==null)) {
$value = $default;
diff --git a/Idno/Core/PageHandler.php b/Idno/Core/PageHandler.php
index cb8ef99c6b..45fb0f6c0a 100644
--- a/Idno/Core/PageHandler.php
+++ b/Idno/Core/PageHandler.php
@@ -38,6 +38,8 @@ public static function serve($routes)
if (! empty(Idno::site()->request()->getPathInfo())) {
$path_info = Idno::site()->request()->getPathInfo();
}
+
+
$discovered_handler = null;
$regex_matches = array();
@@ -60,6 +62,7 @@ public static function serve($routes)
}
}
+
$result = null;
$handler_instance = null;
@@ -87,7 +90,6 @@ public static function serve($routes)
}
Hook::fire('after_request', compact('routes', 'discovered_handler', 'request_method', 'regex_matches', 'result'));
-
\Idno\Core\Idno::site()->sendResponse();
}
diff --git a/Idno/Data/MySQL.php b/Idno/Data/MySQL.php
index 1259d21696..fc42f7c77a 100644
--- a/Idno/Data/MySQL.php
+++ b/Idno/Data/MySQL.php
@@ -13,6 +13,7 @@
class MySQL extends AbstractSQL
{
+ private $database;
function init()
{
@@ -27,11 +28,12 @@ function init()
} catch (\Exception $e) {
error_log($e->getMessage());
if (!empty(\Idno\Core\Idno::site()->config()->forward_on_empty)) {
- header('Location: ' . \Idno\Core\Idno::site()->config()->forward_on_empty);
- exit;
+ \Idno\Core\Idno::site()->redirect(\Idno\Core\Idno::site()->config()->forward_on_empty);
+ \Idno\Core\Idno::site()->sendResponse();
} else {
http_response_code(500);
+
if (\Idno\Core\Idno::site()->config()->debug) {
$message = '' . $e->getMessage() . '
';
diff --git a/Idno/Pages/Onboarding/Begin.php b/Idno/Pages/Onboarding/Begin.php
index b6edea1424..bce0c60eb0 100644
--- a/Idno/Pages/Onboarding/Begin.php
+++ b/Idno/Pages/Onboarding/Begin.php
@@ -24,7 +24,7 @@ function getContent()
'title' => \Idno\Core\Idno::site()->language()->_('Welcome to Known'),
'messages' => \Idno\Core\Idno::site()->session()->getAndFlushMessages()
)
- )->draw('shell/simple')
+ )->draw('shell/simple');
\Idno\Core\Idno::site()->response()->setContent($content);
}
diff --git a/Idno/Pages/Onboarding/Register.php b/Idno/Pages/Onboarding/Register.php
index 338d025b05..aac0567091 100644
--- a/Idno/Pages/Onboarding/Register.php
+++ b/Idno/Pages/Onboarding/Register.php
@@ -12,6 +12,7 @@ class Register extends \Idno\Common\Page
function getContent()
{
+
$set_name = $this->getInput('set_name');
if (!empty($set_name)) {
\Idno\Core\Idno::site()->session()->set('set_name', $set_name);
diff --git a/Idno/Pages/User/View.php b/Idno/Pages/User/View.php
index 59c49b1fa8..84c37fdb4e 100644
--- a/Idno/Pages/User/View.php
+++ b/Idno/Pages/User/View.php
@@ -28,6 +28,7 @@ function getContent()
$this->noContent();
}
+
// Users own their own profiles
$this->setOwner($user);
$this->setPermalink(true, $user); // This is a permalink
@@ -52,6 +53,7 @@ function getContent()
} else {
$types = ['IdnoPlugins\Status\Status', 'IdnoPlugins\Text\Entry'];
}
+
$offset = (int)$this->getInput('offset');
$count = \Idno\Common\Entity::countFromX($types, array('owner' => $user->getUUID(), 'publish_status' => 'published'));
$feed = \Idno\Common\Entity::getFromX($types, array('owner' => $user->getUUID(), 'publish_status' => 'published'), array(), \Idno\Core\Idno::site()->config()->items_per_page, $offset);
@@ -62,8 +64,10 @@ function getContent()
$last_modified = $feed[0]->updated;
}
}
+
$this->setLastModifiedHeader($last_modified);
+
$t = \Idno\Core\Idno::site()->template();
$t->__(
array(
@@ -76,6 +80,7 @@ function getContent()
)->drawPage();
}
+
// Handle POST requests to the entity
function postContent()
diff --git a/Idno/start.php b/Idno/start.php
index e118f5393a..bc903610a5 100644
--- a/Idno/start.php
+++ b/Idno/start.php
@@ -71,22 +71,25 @@ function () {
);
// This is a good time to see if we're running in a subdirectory
- if (!defined('KNOWN_UNIT_TEST')) {
- if (!empty($_SERVER['PHP_SELF'])) {
- if ($subdir = dirname($_SERVER['PHP_SELF'])) {
- if ($subdir != DIRECTORY_SEPARATOR) {
- if (substr($subdir, -1) == DIRECTORY_SEPARATOR) {
- $subdir = substr($subdir, 0, -1);
- }
- if (substr($subdir, 0, 1) == DIRECTORY_SEPARATOR) {
- $subdir = substr($subdir, 1);
- }
- $subdir = str_replace(DIRECTORY_SEPARATOR, '/', $subdir);
- define('KNOWN_SUBDIRECTORY', $subdir);
- }
- }
- }
- }
+ // if (!defined('KNOWN_UNIT_TEST')) {
+ // if (!empty($_SERVER['PHP_SELF'])) {
+ // print_r($_SERVER['PHP_SELF'].' ');
+
+ // if ($subdir = dirname($_SERVER['PHP_SELF'])) {
+ // if ($subdir != DIRECTORY_SEPARATOR) {
+ // if (substr($subdir, -1) == DIRECTORY_SEPARATOR) {
+ // $subdir = substr($subdir, 0, -1);
+ // }
+ // if (substr($subdir, 0, 1) == DIRECTORY_SEPARATOR) {
+ // $subdir = substr($subdir, 1);
+ // }
+ // $subdir = str_replace(DIRECTORY_SEPARATOR, '/', $subdir);
+ // define('KNOWN_SUBDIRECTORY', $subdir);
+
+ // }
+ // }
+ // }
+ // }
// Set time limit if we're using less
if (ini_get('max_execution_time') < 120 && ini_get('safe_mode')) {
diff --git a/index.php b/index.php
index a1a140c5d2..f91e70e35f 100644
--- a/index.php
+++ b/index.php
@@ -14,6 +14,9 @@
* @subpackage core
*/
+ error_reporting(E_ALL );
+
+
// Check PHP version first of all
if (version_compare(phpversion(), '7.2', '<')) {
http_response_code(500);
diff --git a/templates/default/settings-shell/css.tpl.php b/templates/default/settings-shell/css.tpl.php
index e0d4181c46..ca8f259f66 100644
--- a/templates/default/settings-shell/css.tpl.php
+++ b/templates/default/settings-shell/css.tpl.php
@@ -1,4 +1,4 @@
-
+
-
+
diff --git a/templates/default/shell/css.tpl.php b/templates/default/shell/css.tpl.php
index 70daf0523c..f56045c942 100644
--- a/templates/default/shell/css.tpl.php
+++ b/templates/default/shell/css.tpl.php
@@ -1,4 +1,4 @@
-
+
-
+
diff --git a/warmup/templates/default/pages/settings.tpl.php b/warmup/templates/default/pages/settings.tpl.php
index cc7ebc2200..41347b6eb1 100644
--- a/warmup/templates/default/pages/settings.tpl.php
+++ b/warmup/templates/default/pages/settings.tpl.php
@@ -73,7 +73,7 @@
-
@@ -93,7 +93,7 @@ class="profile-input" id="site_title">
MySQL database name
-
@@ -101,7 +101,7 @@ class="profile-input" required>
MySQL username
-
@@ -116,7 +116,7 @@ class="profile-input" required>
MySQL server name
-
@@ -137,7 +137,7 @@ class="profile-input" required>
+ value="" class="profile-input" required>
From f5b8c7fdb99c6107dba73c51a3850d7b651d6c6d Mon Sep 17 00:00:00 2001
From: ipranjal
Date: Sun, 22 Sep 2024 17:51:37 +0530
Subject: [PATCH 07/17] replace $_SESSSION superglobal
---
Idno/Common/Page.php | 6 ++---
Idno/Core/Bonita/Main.php | 4 ++--
Idno/Core/Config.php | 18 +++++++--------
Idno/Core/Hub.php | 8 +++----
Idno/Core/Idno.php | 12 +++++-----
Idno/Core/Language.php | 6 ++---
Idno/Core/Logging.php | 12 +++++-----
Idno/Core/Service.php | 3 ++-
Idno/Core/Session.php | 22 +++++++++----------
Idno/Core/Templating/Classes.php | 2 +-
Idno/Core/Templating/Urls.php | 2 +-
Idno/Pages/Account/Password/Reset.php | 2 +-
Idno/Pages/Account/Register.php | 2 +-
Idno/Pages/Account/Settings.php | 2 +-
.../Settings/Following/Bookmarklet.php | 2 +-
Idno/Pages/Account/Settings/Notifications.php | 2 +-
Idno/Pages/Account/Settings/Tools.php | 2 +-
Idno/Pages/Admin/Diagnostics.php | 2 +-
Idno/Pages/Annotation/Post.php | 2 +-
Idno/Pages/Entity/Attachment/Delete.php | 2 +-
Idno/Pages/Entity/Delete.php | 2 +-
Idno/Pages/Entity/View.php | 4 ++--
Idno/Pages/File/Picker.php | 2 +-
Idno/Pages/File/View.php | 4 ++--
Idno/Pages/Robot/Remove.php | 2 +-
Idno/Pages/Session/Logout.php | 2 +-
Idno/Pages/User/View.php | 4 ++--
Tests/_bootstrap.php | 16 +++++++-------
.../default/cherwell/admin/menu.tpl.php | 2 +-
.../templates/default/account/menu.tpl.php | 8 +++----
.../default/account/settings/menu.tpl.php | 6 ++---
templates/default/account/login.tpl.php | 4 ++--
templates/default/pages/403.tpl.php | 2 +-
templates/default/shell/simple.tpl.php | 2 +-
templates/email/shell.tpl.php | 2 +-
warmup/WebInstaller.php | 6 ++---
36 files changed, 91 insertions(+), 90 deletions(-)
diff --git a/Idno/Common/Page.php b/Idno/Common/Page.php
index f35ac8bdc4..b17f4edd51 100644
--- a/Idno/Common/Page.php
+++ b/Idno/Common/Page.php
@@ -225,15 +225,15 @@ function parseJSONPayload()
{
// First, let's see if we've been sent anything in form input
- if (!empty($_REQUEST['json'])) {
- $json = trim($_REQUEST['json']);
+ if ( \Idno\Core\Idno::site()->request()->request->has('json')) {
+ $json = trim(\Idno\Core\Idno::site()->request()->request->get('json'));
$json = str_replace('[]"', '"', $json); // Fake PHP's array conversion
if ($parsed = @json_decode($json, true)) {
$this->data = array_merge($parsed, $this->data());
}
}
- if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'GET') {
+ if ( \Idno\Core\Idno->request()->getMethod() != 'GET') {
$body = @file_get_contents('php://input');
$body = trim($body);
$body = str_replace('[]"', '"', $body); // Fake PHP's array conversion
diff --git a/Idno/Core/Bonita/Main.php b/Idno/Core/Bonita/Main.php
index 26df72dbaa..381e7a916d 100644
--- a/Idno/Core/Bonita/Main.php
+++ b/Idno/Core/Bonita/Main.php
@@ -105,10 +105,10 @@ public static function getSiteSecret()
*/
static function detectDevice()
{
- if (empty($_SERVER['HTTP_USER_AGENT'])) {
+ if (!\Idno\Core\Idno::site()->request()->server->has('HTTP_USER_AGENT')) {
return 'default';
}
- $ua = $_SERVER['HTTP_USER_AGENT'];
+ $ua = \Idno\Core\Idno::site()->request()->server->get('HTTP_USER_AGENT');
// Android
if (preg_match('/android/i', $ua)) {
diff --git a/Idno/Core/Config.php b/Idno/Core/Config.php
index 8ff0d42cb7..8700c44e69 100644
--- a/Idno/Core/Config.php
+++ b/Idno/Core/Config.php
@@ -241,7 +241,7 @@ function loadIniFiles()
}
// Check environment variables and set as appropriate
- foreach ($_SERVER as $name => $val) {
+ foreach (\Idno\Core\Idno::site()->request()->server->all() as $name => $val) {
if (substr($name, 0, 6) == 'KNOWN_') {
$name = strtolower(str_replace('KNOWN_', '', $name));
$val = $val;
@@ -377,17 +377,17 @@ protected function detectBaseURL()
{
// Otherwise, use the standard server name header
- if (!empty($_SERVER['SERVER_NAME'])) {
+ if (\Idno\Core\Idno::site()->request()->server->has('SERVER_NAME')) {
// Servername specified, so we can construct things in the normal way.
- $url = (\Idno\Common\Page::isSSL() ? 'https://' : 'http://') . $_SERVER['SERVER_NAME'];
- if (!empty($_SERVER['HTTP_X_FORWARDED_PORT'])) {
- if ($_SERVER['HTTP_X_FORWARDED_PORT'] != 80 && $_SERVER['HTTP_X_FORWARDED_PORT'] != 443) {
- $url .= ':' . $_SERVER['HTTP_X_FORWARDED_PORT'];
+ $url = (\Idno\Common\Page::isSSL() ? 'https://' : 'http://') . \Idno\Core\Idno::site()->request()->server->get('SERVER_NAME');
+ if (\Idno\Core\Idno::site()->request()->server->has('HTTP_X_FORWARDED_PORT')) {
+ if (\Idno\Core\Idno::site()->request()->server->get('HTTP_X_FORWARDED_PORT') != 80 && \Idno\Core\Idno::site()->request()->server->get('HTTP_X_FORWARDED_PORT') != 443) {
+ $url .= ':' . \Idno\Core\Idno::site()->request()->server->get('HTTP_X_FORWARDED_PORT');
}
- } else if (!empty($_SERVER['SERVER_PORT'])) {
- if ($_SERVER['SERVER_PORT'] != 80 && $_SERVER['SERVER_PORT'] != 443) {
- $url .= ':' . $_SERVER['SERVER_PORT'];
+ } else if (\Idno\Core\Idno::site()->request()->server->has('SERVER_PORT')) {
+ if (\Idno\Core\Idno::site()->request()->server->get('SERVER_PORT') != 80 && \Idno\Core\Idno::site()->request()->server->get('SERVER_PORT') != 443) {
+ $url .= ':' . \Idno\Core\Idno::site()->request()->server->get('SERVER_PORT');
}
}
if (defined('KNOWN_SUBDIRECTORY')) {
diff --git a/Idno/Core/Hub.php b/Idno/Core/Hub.php
index db3436d577..e2702ab024 100644
--- a/Idno/Core/Hub.php
+++ b/Idno/Core/Hub.php
@@ -99,7 +99,7 @@ function registerUser($user = false)
* Load the locally stored auth token & secret details, or register with the hub if no details have been
* saved
*
- * @return bool
+ * @return mixed
*/
function loadDetails()
{
@@ -144,9 +144,9 @@ function connect()
$details = $this->loadDetails();
if (!empty($details['auth_token'])) {
// Apply pre-stored auth details and connect to server
- } else if (!substr_count($_SERVER['REQUEST_URI'], 'callback')
- && !substr_count($_SERVER['REQUEST_URI'], '.')
- && !substr_count($_SERVER['REQUEST_URI'], '/file/')
+ } else if (!substr_count(\Idno\Core\Idno::site()->request()->getRequestUri(), 'callback')
+ && !substr_count(\Idno\Core\Idno::site()->request()->getRequestUri(), '.')
+ && !substr_count(\Idno\Core\Idno::site()->request()->getRequestUri(), '/file/')
) {
// Establish auth details, save them, and then connect
if ($details = $this->register()) {
diff --git a/Idno/Core/Idno.php b/Idno/Core/Idno.php
index b822622932..20f2040dc7 100644
--- a/Idno/Core/Idno.php
+++ b/Idno/Core/Idno.php
@@ -80,12 +80,12 @@ function init()
$this->db = new \Idno\Data\MySQL();
break;
case 'beanstalk-mysql': // A special instance of MYSQL designed for use with Amazon Elastic Beanstalk
- $this->config->dbhost = $_SERVER['RDS_HOSTNAME'];
- $this->config->dbuser = $_SERVER['RDS_USERNAME'];
- $this->config->dbpass = $_SERVER['RDS_PASSWORD'];
- $this->config->dbport = $_SERVER['RDS_PORT'];
+ $this->config->dbhost = \Idno\Core\Idno::site()->request()->server->get('RDS_HOSTNAME'); ;
+ $this->config->dbuser = \Idno\Core\Idno::site()->request()->server->get('RDS_USERNAME');
+ $this->config->dbpass = \Idno\Core\Idno::site()->request()->server->get('RDS_PASSWORD');
+ $this->config->dbport = \Idno\Core\Idno::site()->request()->server->get('RDS_PORT');
if (empty($this->config->dbname)) {
- $this->config->dbname = $_SERVER['RDS_DB_NAME'];
+ $this->config->dbname = \Idno\Core\Idno::site()->request()->server->get('RDS_DB_NAME');
}
$this->db = new \Idno\Data\MySQL();
break;
@@ -171,7 +171,7 @@ function () {
}
if (
!empty($this->config->known_hub)
- && !substr_count($_SERVER['REQUEST_URI'], '.')
+ && !substr_count(\Idno\Core\Idno::site()->request()->getRequestUri(), '.')
&& $this->config->known_hub != $this->config->url
) {
site()->session()->hub_connect = time();
diff --git a/Idno/Core/Language.php b/Idno/Core/Language.php
index 9ee7b7d084..b29cdbd6ab 100644
--- a/Idno/Core/Language.php
+++ b/Idno/Core/Language.php
@@ -213,12 +213,12 @@ public static function detectBrowserLanguage($full = true)
$lang = "";
- if (!empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
+ if (\Idno\Core\Idno::site()->request()->server->has('HTTP_ACCEPT_LANGUAGE')) {
if ($full) {
- $length = strpos($_SERVER['HTTP_ACCEPT_LANGUAGE'], ',');
+ $length = strpos(\Idno\Core\Idno::site()->request()->server->get('HTTP_ACCEPT_LANGUAGE'), ',');
}
- $lang = preg_replace("/[^a-zA-Z\-_\s]/", "", substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, $length));
+ $lang = preg_replace("/[^a-zA-Z\-_\s]/", "", substr(\Idno\Core\Idno::site()->request()->server->get('HTTP_ACCEPT_LANGUAGE'), 0, $length));
$lang = str_replace('-', '_', $lang);
}
diff --git a/Idno/Core/Logging.php b/Idno/Core/Logging.php
index 9046ee8b2e..d8de5fa65e 100644
--- a/Idno/Core/Logging.php
+++ b/Idno/Core/Logging.php
@@ -354,16 +354,16 @@ public static function oopsAlert($message, $title = "")
$vars['user'] = \Idno\Core\Idno::site()->session()->currentUserUUID();
}
- if (!empty($_SERVER['HTTP_USER_AGENT'])) {
- $vars['agent'] = $_SERVER['HTTP_USER_AGENT'];
+ if (\Idno\Core\Idno::site()->request()->server->has('HTTP_USER_AGENT')) {
+ $vars['agent'] = \Idno\Core\Idno::site()->request()->server->get('HTTP_USER_AGENT');
}
- if (!empty($_SERVER['QUERY_STRING'])) {
- $vars['qs'] = $_SERVER['QUERY_STRING'];
+ if (\Idno\Core\Idno::site()->request()->server->has('QUERY_STRING')) {
+ $vars['qs'] = \Idno\Core\Idno::site()->request()->server->get('QUERY_STRING');
}
- if (!empty($_SERVER['HTTP_REFERER'])) {
- $vars['referrer'] = $_SERVER['HTTP_REFERER'];
+ if (\Idno\Core\Idno::site()->request()->server->has('HTTP_REFERER')) {
+ $vars['referrer'] = \Idno\Core\Idno::site()->request()->server->get('HTTP_REFERER');
}
$email = new Email();
diff --git a/Idno/Core/Service.php b/Idno/Core/Service.php
index 46bc4829db..d2a463f6a6 100644
--- a/Idno/Core/Service.php
+++ b/Idno/Core/Service.php
@@ -20,7 +20,8 @@ class Service extends \Idno\Common\Component
*/
public static function gatekeeper()
{
- $service_signature = $_SERVER['HTTP_X_KNOWN_SERVICE_SIGNATURE'];
+
+ $service_signature = \Idno\Core\Idno::site()->request()->server->get('X-KNOWN-SERVICE-SIGNATURE');
if (empty($service_signature)) {
throw new \RuntimeException(\Idno\Core\Idno::site()->language()->_('Missing X-Known-Service-Signature, service call is not possible.'));
}
diff --git a/Idno/Core/Session.php b/Idno/Core/Session.php
index 70ca419f95..8bf00e8e96 100644
--- a/Idno/Core/Session.php
+++ b/Idno/Core/Session.php
@@ -497,7 +497,7 @@ function tryAuthUser()
$return = \Idno\Core\Idno::site()->events()->triggerEvent('user/auth/request', [], false);
// auth standard API requests
- if (!$return && !empty($_SERVER['HTTP_X_KNOWN_USERNAME']) && !empty($_SERVER['HTTP_X_KNOWN_SIGNATURE'])) {
+ if (!$return && \Idno\Core\Idno::site()->request()->server->has('HTTP_X_KNOWN_USERNAME') && !empty(\Idno\Core\Idno::site()->request()->server->has('HTTP_X_KNOWN_SIGNATURE'))) {
\Idno\Core\Idno::site()->logging()->debug("Attempting to auth via API credentials");
$this->setIsAPIRequest(true);
@@ -507,16 +507,16 @@ function tryAuthUser()
\Idno\Core\Idno::site()->template()->setTemplateType('json');
}
- $user = \Idno\Entities\User::getByHandle($_SERVER['HTTP_X_KNOWN_USERNAME']);
- if (empty($user)) { $user = \Idno\Entities\User::getByEmail($_SERVER['HTTP_X_KNOWN_USERNAME']);
+ $user = \Idno\Entities\User::getByHandle(\Idno\Core\Idno::site()->request()->server->get('HTTP_X_KNOWN_USERNAME'));
+ if (empty($user)) { $user = \Idno\Entities\User::getByEmail(\Idno\Core\Idno::site()->request()->server->get('HTTP_X_KNOWN_USERNAME'));
}
if (!empty($user)) {
- \Idno\Core\Idno::site()->logging()->debug("API auth found user by username: {$_SERVER['HTTP_X_KNOWN_USERNAME']} - " . $user->getName());
+ \Idno\Core\Idno::site()->logging()->debug("API auth found user by username: ".{\Idno\Core\Idno::site()->request()->server->has('HTTP_X_KNOWN_USERNAME')." - " . $user->getName());
$key = $user->getAPIkey();
- $hmac = trim($_SERVER['HTTP_X_KNOWN_SIGNATURE']);
+ $hmac = trim(\Idno\Core\Idno::site()->request()->server->has('HTTP_X_KNOWN_SIGNATURE'));
//$compare_hmac = base64_encode(hash_hmac('sha256', explode('?', $_SERVER['REQUEST_URI'])[0], $key, true));
- $compare_hmac = base64_encode(hash_hmac('sha256', ($_SERVER['REQUEST_URI']), $key, true));
+ $compare_hmac = base64_encode(hash_hmac('sha256', \Idno\Core\Idno::site()->request()->getUri(), $key, true));
if ($hmac == $compare_hmac) {
\Idno\Core\Idno::site()->logging()->debug("API auth verified signature for user: " . $user->getName());
@@ -524,11 +524,11 @@ function tryAuthUser()
$return = $this->refreshSessionUser($user);
} else {
\Idno\Core\Idno::site()->logging()->debug("API auth failed signature validation for user: " . $user->getName());
- \Idno\Core\Idno::site()->logging()->debug("Expected signature formed over base64_encode(hash_hmac('sha256', '{$_SERVER['REQUEST_URI']}', \$key, true)) = '$compare_hmac', but got '$hmac'. ");
+ \Idno\Core\Idno::site()->logging()->debug("Expected signature formed over base64_encode(hash_hmac('sha256', '{\Idno\Core\Idno::site()->request()->getRequestUri())}', \$key, true)) = '$compare_hmac', but got '$hmac'. ");
\Idno\Core\Idno::site()->logging()->debug("Please read http://docs.withknown.com/en/latest/developers/plugins/api/ for further details.");
}
} else {
- \Idno\Core\Idno::site()->logging()->debug("API User given in X_KNOWN_USERNAME ('{$_SERVER['HTTP_X_KNOWN_USERNAME']}') could not be found.");
+ \Idno\Core\Idno::site()->logging()->debug("API User given in X_KNOWN_USERNAME ('{\Idno\Core\Idno::site()->request()->server->get('HTTP_X_KNOW_USERNAME'))}') could not be found.");
}
}
@@ -544,9 +544,9 @@ function tryAuthUser()
}
// If this is an API request but we're not logged in, set page response code to access denied
if (!$return) {
- $ip = $_SERVER['REMOTE_ADDR'];
- if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
- $proxies = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']); // We are behind a proxy
+ $ip = \Idno\Core\Idno::site()->request()->server->get('REMOTE_ADDR');
+ if (\Idno\Core\Idno::site()->request()->server->has('HTTP_X_FORWARDED_FOR')) {
+ $proxies = explode(',', \Idno\Core\Idno::site()->request()->server->get('HTTP_X_FORWARDED_FOR')); // We are behind a proxy
$ip = trim($proxies[0]);
}
diff --git a/Idno/Core/Templating/Classes.php b/Idno/Core/Templating/Classes.php
index aab284943d..4d3c114214 100644
--- a/Idno/Core/Templating/Classes.php
+++ b/Idno/Core/Templating/Classes.php
@@ -15,7 +15,7 @@ function getBodyClasses()
{
$classes = '';
$classes .= (str_replace('\\', '_', strtolower(get_class(\Idno\Core\Idno::site()->currentPage()))));
- if ($path = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)) {
+ if ($path = parse_url(\Idno\Core\Idno::site()->request()->getUri(), PHP_URL_PATH)) {
if ($path == '/') {
$classes .= ' homepage';
}
diff --git a/Idno/Core/Templating/Urls.php b/Idno/Core/Templating/Urls.php
index 1b82777570..d9d12fa6e2 100644
--- a/Idno/Core/Templating/Urls.php
+++ b/Idno/Core/Templating/Urls.php
@@ -49,7 +49,7 @@ function getCurrentURL()
$path = substr($components['path'], 1);
}
}
- $request_uri = substr($_SERVER['REQUEST_URI'], 1);
+ $request_uri = substr(\Idno\Core\Idno::site()->request()->getUri(), 1);
if (!empty($path)) {
if (substr($request_uri, 0, strlen($path)) == $path) {
$request_uri = substr($request_uri, strlen($path));
diff --git a/Idno/Pages/Account/Password/Reset.php b/Idno/Pages/Account/Password/Reset.php
index 35a3cca2e0..be4fb9c202 100644
--- a/Idno/Pages/Account/Password/Reset.php
+++ b/Idno/Pages/Account/Password/Reset.php
@@ -61,7 +61,7 @@ function postContent()
}
} else {
\Idno\Core\Idno::site()->session()->addErrorMessage(\Idno\Core\Idno::site()->language()->_('Sorry, your passwords either don\'t match, or are too weak'));
- $this->forward($_SERVER['HTTP_REFERER']);
+ $this->forward(\Idno\Core\Idno::site()->request()->server->get('HTTP_REFERER'));
}
}
diff --git a/Idno/Pages/Account/Register.php b/Idno/Pages/Account/Register.php
index 0ec766b85b..a259d5fc6c 100644
--- a/Idno/Pages/Account/Register.php
+++ b/Idno/Pages/Account/Register.php
@@ -166,7 +166,7 @@ function postContent()
$this->forward();
} else {
\Idno\Core\Idno::site()->session()->addMessageAtStart(\Idno\Core\Idno::site()->language()->_("We couldn't register you."));
- $this->forward($_SERVER['HTTP_REFERER']);
+ $this->forward(\Idno\Core\Idno::site()->request()->server->get('HTTP_REFERER'));
}
}
diff --git a/Idno/Pages/Account/Settings.php b/Idno/Pages/Account/Settings.php
index 02de629d7e..417052e352 100644
--- a/Idno/Pages/Account/Settings.php
+++ b/Idno/Pages/Account/Settings.php
@@ -65,7 +65,7 @@ function postContent()
if ($user->save()) {
\Idno\Core\Idno::site()->session()->addMessage(\Idno\Core\Idno::site()->language()->_("Your details were saved."));
}
- $this->forward($_SERVER['HTTP_REFERER']);
+ $this->forward(\Idno\Core\Idno::site()->request()->server->get('HTTP_REFERER'));
}
}
diff --git a/Idno/Pages/Account/Settings/Following/Bookmarklet.php b/Idno/Pages/Account/Settings/Following/Bookmarklet.php
index 0f3cae281e..525ae4152b 100644
--- a/Idno/Pages/Account/Settings/Following/Bookmarklet.php
+++ b/Idno/Pages/Account/Settings/Following/Bookmarklet.php
@@ -69,7 +69,7 @@ function getContent()
}
// forward back
- $this->forward($_SERVER['HTTP_REFERER']);
+ $this->forward(\Idno\Core\Idno::site()->request()->server->get('HTTP_REFERER'));
}
/**
diff --git a/Idno/Pages/Account/Settings/Notifications.php b/Idno/Pages/Account/Settings/Notifications.php
index 96d2d3eab5..0ba76d286e 100644
--- a/Idno/Pages/Account/Settings/Notifications.php
+++ b/Idno/Pages/Account/Settings/Notifications.php
@@ -38,7 +38,7 @@ function postContent()
if ($user->save()) {
\Idno\Core\Idno::site()->session()->addMessage(\Idno\Core\Idno::site()->language()->_("Your notification preferences were saved."));
}
- $this->forward($_SERVER['HTTP_REFERER']);
+ $this->forward(\Idno\Core\Idno::site()->request()->server->get('HTTP_REFERER'));
}
}
diff --git a/Idno/Pages/Account/Settings/Tools.php b/Idno/Pages/Account/Settings/Tools.php
index 182ac34cfd..85edfc33a4 100644
--- a/Idno/Pages/Account/Settings/Tools.php
+++ b/Idno/Pages/Account/Settings/Tools.php
@@ -45,7 +45,7 @@ function postContent()
}
}
- $this->forward($_SERVER['HTTP_REFERER']);
+ $this->forward(\Idno\Core\Idno::site()->request()->server->get('HTTP_REFERER'));
}
}
diff --git a/Idno/Pages/Admin/Diagnostics.php b/Idno/Pages/Admin/Diagnostics.php
index be677a9d0a..42aa04e8c9 100644
--- a/Idno/Pages/Admin/Diagnostics.php
+++ b/Idno/Pages/Admin/Diagnostics.php
@@ -44,7 +44,7 @@ function getContent()
$report .= "\nRunning config:\n---------------\n" . var_export($config, true) . "\n\n";
$report .= "\$_SESSION:\n----------\n" . var_export($_SESSION, true) . "\n\n";
- $report .= "\$_SERVER:\n---------\n" . var_export($_SERVER, true) . "\n\n";
+ $report .= "\SERVER:\n---------\n" . var_export(\Idno\Core\Idno::site()->request()->server->all(), true) . "\n\n";
// Hook so other plugins and subsystems can add their own data to the report.
$report = \Idno\Core\Idno::site()->events()->triggerEvent('diagnostics/report', [], $report);
diff --git a/Idno/Pages/Annotation/Post.php b/Idno/Pages/Annotation/Post.php
index 427a9a358b..9c19e5ce8f 100644
--- a/Idno/Pages/Annotation/Post.php
+++ b/Idno/Pages/Annotation/Post.php
@@ -17,7 +17,7 @@ class Post extends \Idno\Common\Page
// Handle GET requests to a comment
function getContent()
{
- $this->forward($_SERVER['HTTP_REFERER']); // Send the user back to whence they came
+ $this->forward(\Idno\Core\Idno::site()->request()->server->get('HTTP_REFERER')); // Send the user back to whence they came
}
// Handle POST requests: this is where the interesting stuff happens
diff --git a/Idno/Pages/Entity/Attachment/Delete.php b/Idno/Pages/Entity/Attachment/Delete.php
index 902ae70a59..aa354f8406 100644
--- a/Idno/Pages/Entity/Attachment/Delete.php
+++ b/Idno/Pages/Entity/Attachment/Delete.php
@@ -34,7 +34,7 @@ function postContent()
$this->noContent();
}
- $this->forward($_SERVER['HTTP_REFERER']);
+ $this->forward(\Idno\Core\Idno::site()->request()->server->get('HTTP_REFERER'));
}
}
diff --git a/Idno/Pages/Entity/Delete.php b/Idno/Pages/Entity/Delete.php
index 51ddafb635..394d63f7da 100644
--- a/Idno/Pages/Entity/Delete.php
+++ b/Idno/Pages/Entity/Delete.php
@@ -55,7 +55,7 @@ function postContent()
if ($object->delete()) {
\Idno\Core\Idno::site()->session()->addMessage(\Idno\Core\Idno::site()->language()->esc_('%s was deleted.', [$object->getTitle()]));
}
- $this->forward($_SERVER['HTTP_REFERER']);
+ $this->forward(\Idno\Core\Idno::site()->request()->server->get('HTTP_REFERER'));
}
}
diff --git a/Idno/Pages/Entity/View.php b/Idno/Pages/Entity/View.php
index 45c4e9932d..568f794599 100644
--- a/Idno/Pages/Entity/View.php
+++ b/Idno/Pages/Entity/View.php
@@ -116,7 +116,7 @@ function postContent()
if ($object->saveDataFromInput()) {
$this->forward($object->getDisplayURL());
}
- $this->forward($_SERVER['HTTP_REFERER']);
+ $this->forward(\Idno\Core\Idno::site()->request()->server->get('HTTP_REFERER'));
}
// Handle DELETE requests to the entity
@@ -134,7 +134,7 @@ function deleteContent()
if ($object->delete()) {
\Idno\Core\Idno::site()->session()->addMessage(\Idno\Core\Idno::site()->language()->esc_('%s was deleted.', [$object->getTitle()]));
}
- $this->forward($_SERVER['HTTP_REFERER']);
+ $this->forward(\Idno\Core\Idno::site()->request()->server->get('HTTP_REFERER'));
}
}
diff --git a/Idno/Pages/File/Picker.php b/Idno/Pages/File/Picker.php
index 4e6d4b5a34..7df2a08f32 100644
--- a/Idno/Pages/File/Picker.php
+++ b/Idno/Pages/File/Picker.php
@@ -58,7 +58,7 @@ function post()
Idno::site()->session()->addErrorMessage(\Idno\Core\Idno::site()->language()->_("You can only upload images."));
}
}
- $this->forward($_SERVER['HTTP_REDIRECT']);
+ $this->forward(\Idno\Core\Idno::site()->request()->server->get('HTTP_REFERER'));
}
}
diff --git a/Idno/Pages/File/View.php b/Idno/Pages/File/View.php
index 9bb860cd18..a7e5bfe814 100644
--- a/Idno/Pages/File/View.php
+++ b/Idno/Pages/File/View.php
@@ -53,7 +53,7 @@ function getContent()
header('Accept-Ranges: bytes');
// Partial content
- if (isset($_SERVER['HTTP_RANGE'])) {
+ if (\Idno\Core\Idno::site()->request()->server->has('HTTP_RANGE')) {
$size = $object->getSize();
$start = 0;
@@ -63,7 +63,7 @@ function getContent()
$c_end = (empty($end)) ? ($size - 1) : min(abs(intval($end)), ($size - 1)); //$end;
// Parse range
- list(, $range) = explode('=', $_SERVER['HTTP_RANGE'], 2);
+ list(, $range) = explode('=', \Idno\Core\Idno::site()->request()->server->get('HTTP_RANGE'), 2);
if ($range[0] == '-') {
// Range form "-123"
diff --git a/Idno/Pages/Robot/Remove.php b/Idno/Pages/Robot/Remove.php
index 80b359a1c7..0f948b8ce9 100644
--- a/Idno/Pages/Robot/Remove.php
+++ b/Idno/Pages/Robot/Remove.php
@@ -17,7 +17,7 @@ function postContent()
$user = \Idno\Core\Idno::site()->session()->currentUser();
$user->robot_state = 0;
$user->save();
- $this->forward($_SERVER['HTTP_REFERER']);
+ $this->forward(\Idno\Core\Idno::site()->request()->server->get('HTTP_REFERER'));
}
diff --git a/Idno/Pages/Session/Logout.php b/Idno/Pages/Session/Logout.php
index 0eb7538707..1de71229e4 100644
--- a/Idno/Pages/Session/Logout.php
+++ b/Idno/Pages/Session/Logout.php
@@ -22,7 +22,7 @@ function postContent()
$result = \Idno\Core\Idno::site()->session()->logUserOff();
\Idno\Core\Idno::site()->session()->addMessage(\Idno\Core\Idno::site()->language()->_("You've signed out. See you soon!"));
- $this->forward($_SERVER['HTTP_REFERER']);
+ $this->forward(\Idno\Core\Idno::site()->request()->server->get('HTTP_REFERER'));
return $result;
}
diff --git a/Idno/Pages/User/View.php b/Idno/Pages/User/View.php
index 84c37fdb4e..02dfb8ebc0 100644
--- a/Idno/Pages/User/View.php
+++ b/Idno/Pages/User/View.php
@@ -96,7 +96,7 @@ function postContent()
}
$this->forward($user->getURL());
}
- $this->forward($_SERVER['HTTP_REFERER']);
+ $this->forward(\Idno\Core\Idno::site()->request()->server->get('HTTP_REFERER'));
}
// Handle DELETE requests to the entity
@@ -111,7 +111,7 @@ function deleteContent()
if ($object->delete()) {
\Idno\Core\Idno::site()->session()->addMessage(\Idno\Core\Idno::site()->language()->esc_('%s was deleted.', [$object->getTitle()]));
}
- $this->forward($_SERVER['HTTP_REFERER']);
+ $this->forward(\Idno\Core\Idno::site()->request()->server->get('HTTP_REFERER'));
}
/**
diff --git a/Tests/_bootstrap.php b/Tests/_bootstrap.php
index 70150dece4..3e59f3221b 100644
--- a/Tests/_bootstrap.php
+++ b/Tests/_bootstrap.php
@@ -16,24 +16,24 @@
// Set some environment: Use export KNOWN_DOMAIN / KNOWN_PORT to override from the command line
$domain = 'localhost';
-if (isset($_SERVER['KNOWN_DOMAIN'])) {
- $domain = $_SERVER['KNOWN_DOMAIN'];
+if (\Idno\Core\Idno::site()->request()->server->has('KNOWN_DOMAIN')) {
+ $domain = \Idno\Core\Idno::site()->request()->server->get('KNOWN_DOMAIN');
}
-if (!$domain && isset($_SERVER['SERVER_NAME'])) {
- $domain = $_SERVER['SERVER_NAME'];
+if (!$domain && \Idno\Core\Idno::site()->request()->server->has('SERVER_NAME')) {
+ $domain = \Idno\Core\Idno::site()->request()->server->get('SERVER_NAME');
}
-$_SERVER['SERVER_NAME'] = $domain;
+\Idno\Core\Idno::site()->request()->server->set('SERVER_NAME', $domain);
$port = getenv('KNOWN_PORT');
-if (!$port && isset($_SERVER['SERVER_PORT'])) {
- $port = $_SERVER['SERVER_PORT'];
+if (!$port && \Idno\Core\Idno::site()->request()->server->has('SERVER_PORT')) {
+ $port =\Idno\Core\Idno::site()->request()->server->get('SERVER_PORT');
}
if (!$port) {
$port = 80;
}
-$_SERVER['SERVER_PORT'] = $port;
+\Idno\Core\Idno::site()->request()->server->set('SERVER_PORT', $port);
try {
// Load Known framework
diff --git a/Themes/Cherwell/templates/default/cherwell/admin/menu.tpl.php b/Themes/Cherwell/templates/default/cherwell/admin/menu.tpl.php
index 9cb26651ab..121a318d8c 100644
--- a/Themes/Cherwell/templates/default/cherwell/admin/menu.tpl.php
+++ b/Themes/Cherwell/templates/default/cherwell/admin/menu.tpl.php
@@ -1 +1 @@
->= \Idno\Core\Idno::site()->language()->_('Set Background'); ?>
\ No newline at end of file
+request()->getPathInfo() == '/admin/cherwell/') echo 'class="active"'; ?>>= \Idno\Core\Idno::site()->language()->_('Set Background'); ?>
\ No newline at end of file
diff --git a/Themes/Fauvists/templates/default/account/menu.tpl.php b/Themes/Fauvists/templates/default/account/menu.tpl.php
index 5e04a33fa2..59f0351701 100644
--- a/Themes/Fauvists/templates/default/account/menu.tpl.php
+++ b/Themes/Fauvists/templates/default/account/menu.tpl.php
@@ -1,15 +1,15 @@
diff --git a/Themes/Fauvists/templates/default/account/settings/menu.tpl.php b/Themes/Fauvists/templates/default/account/settings/menu.tpl.php
index ef8bf75ef5..57c55067ae 100644
--- a/Themes/Fauvists/templates/default/account/settings/menu.tpl.php
+++ b/Themes/Fauvists/templates/default/account/settings/menu.tpl.php
@@ -1,15 +1,15 @@
diff --git a/templates/default/account/login.tpl.php b/templates/default/account/login.tpl.php
index f04d35a4f2..7492667d92 100644
--- a/templates/default/account/login.tpl.php
+++ b/templates/default/account/login.tpl.php
@@ -22,8 +22,8 @@
diff --git a/templates/default/pages/403.tpl.php b/templates/default/pages/403.tpl.php
index 26e96fb9e8..d025a584ab 100644
--- a/templates/default/pages/403.tpl.php
+++ b/templates/default/pages/403.tpl.php
@@ -2,7 +2,7 @@
// Display the login link, if the user is not currently logged in.
// If they're logged out, this is probably why they're denied.
- $login_url = \Idno\Core\Idno::site()->currentPage()->forwardToLogin($_SERVER['REQUEST_URI'], true);
+ $login_url = \Idno\Core\Idno::site()->currentPage()->forwardToLogin(\Idno\Core\Idno::site()->request()->getPathInfo(), true);
if (!\Idno\Core\Idno::site()->session()->isLoggedIn()) {
?>
diff --git a/templates/default/shell/simple.tpl.php b/templates/default/shell/simple.tpl.php
index aee8cc0f42..4f67eb7ad8 100644
--- a/templates/default/shell/simple.tpl.php
+++ b/templates/default/shell/simple.tpl.php
@@ -92,7 +92,7 @@
request()->getUri(), PHP_URL_PATH);
$path = str_replace('/', '_', $path);
?>
diff --git a/warmup/WebInstaller.php b/warmup/WebInstaller.php
index 5f24a3b066..59745bbbed 100644
--- a/warmup/WebInstaller.php
+++ b/warmup/WebInstaller.php
@@ -26,8 +26,8 @@ public function __construct()
*/
public function rewriteWorking()
{
- if (!empty($_SERVER['PHP_SELF'])) {
- if ($subdir = dirname(dirname($_SERVER['PHP_SELF']))) {
+ if (\Idno\Core\Idno::site()->request()->server->has('PHP_SELF')) {
+ if ($subdir = dirname(dirname(\Idno\Core\Idno::site()->request()->server->has('PHP_SELF')))) {
if ($subdir != DIRECTORY_SEPARATOR) {
if(substr($subdir, -1) == DIRECTORY_SEPARATOR) {
$subdir = substr($subdir, 0, -1);
@@ -45,7 +45,7 @@ public function rewriteWorking()
$subdir = '/' . $subdir;
}
- $host = strtolower($_SERVER['HTTP_HOST']);
+ $host = strtolower(\Idno\Core\Idno::site()->request()->getHost());
if (!empty(Idno\Common\Page::isSSL())) {
$schema = 'https://';
} else {
From e02b95bb23e9a40ed70bdb9e791791b9fbeb3a42 Mon Sep 17 00:00:00 2001
From: ipranjal
Date: Mon, 23 Sep 2024 19:18:16 +0530
Subject: [PATCH 08/17] fix: fixing issues
---
Idno/Common/Page.php | 8 +++++---
Idno/Core/PageHandler.php | 2 ++
Idno/Core/Session.php | 2 +-
Themes/Fauvists/templates/default/account/menu.tpl.php | 2 +-
index.php | 3 +--
templates/default/settings-shell/messages.tpl.php | 1 -
6 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/Idno/Common/Page.php b/Idno/Common/Page.php
index b17f4edd51..54b913d066 100644
--- a/Idno/Common/Page.php
+++ b/Idno/Common/Page.php
@@ -223,7 +223,6 @@ function head()
*/
function parseJSONPayload()
{
-
// First, let's see if we've been sent anything in form input
if ( \Idno\Core\Idno::site()->request()->request->has('json')) {
$json = trim(\Idno\Core\Idno::site()->request()->request->get('json'));
@@ -233,7 +232,8 @@ function parseJSONPayload()
}
}
- if ( \Idno\Core\Idno->request()->getMethod() != 'GET') {
+
+ if ( \Idno\Core\Idno::site()->request()->getMethod() != 'GET') {
$body = @file_get_contents('php://input');
$body = trim($body);
$body = str_replace('[]"', '"', $body); // Fake PHP's array conversion
@@ -245,6 +245,7 @@ function parseJSONPayload()
}
}
+
}
/**
@@ -310,19 +311,20 @@ function get_xhr()
function get($params = array())
{
+
\Idno\Core\Idno::site()->session()->publicGatekeeper();
\Idno\Core\Idno::site()->template()->autodetectTemplateType();
$this->parseJSONPayload();
+
$arguments = func_get_args();
if (!empty($arguments)) { $this->arguments = $arguments;
}
\Idno\Core\Idno::site()->events()->triggerEvent('page/head', array('page' => $this));
\Idno\Core\Idno::site()->events()->triggerEvent('page/get', array('page_class' => get_called_class(), 'arguments' => $arguments));
-
$this->getContent();
if (\Idno\Core\Idno::site()->response()->getStatusCode() != 200) {
diff --git a/Idno/Core/PageHandler.php b/Idno/Core/PageHandler.php
index 45fb0f6c0a..faceb3e448 100644
--- a/Idno/Core/PageHandler.php
+++ b/Idno/Core/PageHandler.php
@@ -80,7 +80,9 @@ public static function serve($routes)
if (method_exists($handler_instance, $request_method)) {
Hook::fire('before_handler', compact('routes', 'discovered_handler', 'request_method', 'regex_matches'));
+
$result = call_user_func_array(array($handler_instance, $request_method), $regex_matches);
+
Hook::fire('after_handler', compact('routes', 'discovered_handler', 'request_method', 'regex_matches', 'result'));
} else {
Hook::fire('404', compact('routes', 'discovered_handler', 'request_method', 'regex_matches'));
diff --git a/Idno/Core/Session.php b/Idno/Core/Session.php
index 8bf00e8e96..4736b2148c 100644
--- a/Idno/Core/Session.php
+++ b/Idno/Core/Session.php
@@ -511,7 +511,7 @@ function tryAuthUser()
if (empty($user)) { $user = \Idno\Entities\User::getByEmail(\Idno\Core\Idno::site()->request()->server->get('HTTP_X_KNOWN_USERNAME'));
}
if (!empty($user)) {
- \Idno\Core\Idno::site()->logging()->debug("API auth found user by username: ".{\Idno\Core\Idno::site()->request()->server->has('HTTP_X_KNOWN_USERNAME')." - " . $user->getName());
+ \Idno\Core\Idno::site()->logging()->debug("API auth found user by username: ".\Idno\Core\Idno::site()->request()->server->has('HTTP_X_KNOWN_USERNAME')." - " . $user->getName());
$key = $user->getAPIkey();
$hmac = trim(\Idno\Core\Idno::site()->request()->server->has('HTTP_X_KNOWN_SIGNATURE'));
diff --git a/Themes/Fauvists/templates/default/account/menu.tpl.php b/Themes/Fauvists/templates/default/account/menu.tpl.php
index 59f0351701..9309433aca 100644
--- a/Themes/Fauvists/templates/default/account/menu.tpl.php
+++ b/Themes/Fauvists/templates/default/account/menu.tpl.php
@@ -2,7 +2,7 @@
request()->getPathInfo() == '/account/settings/') echo 'class="active"'; ?>>= \Idno\Core\Idno::site()->language()->_('Settings'); ?>
request()->getPathInfo() == '/account/settings/notifications/') echo 'class="active"'; ?>>= \Idno\Core\Idno::site()->language()->_('Email notifications'); ?>
- request()->getPathInfo() == '/account/settings/tools/') echo 'class="active"'; ?>>= \Idno\Core\Idno::site()->language()->_('Tools and Apps'); ?>
+ request()->getPathInfo() == '/account/settings/tools/') echo 'class="active"'; ?>>= \Idno\Core\Idno::site()->language()->_('Tools and Apps'); ?>
session()->drawStructuredMessage($message);
From 921917016ffe0879d31082b5249d59418bf94169 Mon Sep 17 00:00:00 2001
From: ipranjal
Date: Mon, 23 Sep 2024 19:45:06 +0530
Subject: [PATCH 09/17] feat: replace $_REQUEST
---
Idno/Core/Bonita/Forms.php | 12 ++++++------
Idno/Core/Input.php | 2 +-
2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/Idno/Core/Bonita/Forms.php b/Idno/Core/Bonita/Forms.php
index 6c8f66e8cd..f30856fc94 100644
--- a/Idno/Core/Bonita/Forms.php
+++ b/Idno/Core/Bonita/Forms.php
@@ -44,18 +44,18 @@ public function draw($templateName, $returnBlank = true)
*/
public static function validateToken($action = '', $haltExecutionOnBadRequest = true)
{
- if (empty($_REQUEST['__bTs']) || empty($_REQUEST['__bTk'])) {
+ if (!\Idno\Core\Idno::site()->request()->request->has('__bTs') || !\Idno\Core\Idno::site()->request()->request->has('__bTk')) {
if ($haltExecutionOnBadRequest) {
exit;
}
return false;
}
- $time = $_REQUEST['__bTs'];
- $token = $_REQUEST['__bTk'];
+ $time = \Idno\Core\Idno::site()->request()->request->get('__bTs');
+ $token = \Idno\Core\Idno::site()->request()->request->get('__bTk');
if (empty($action)) {
- if (!empty($_REQUEST['__bTa'])) {
- $action = $_REQUEST['__bTa'];
+ if (\Idno\Core\Idno::site()->request()->request->has('__bTa')) {
+ $action = \Idno\Core\Idno::site()->request()->request->get('__bTa');
} else {
\Idno\Core\Idno::site()->logging()->debug("No action in token");
@@ -93,7 +93,7 @@ public static function validateToken($action = '', $haltExecutionOnBadRequest =
public static function formSubmitted()
{
- if (isset($_REQUEST['__bTk']) && isset($_REQUEST['__bTs'])) {
+ if (\Idno\Core\Idno::site()->request()->request->has('__bTk') && \Idno\Core\Idno::site()->request()->request->has('__bTs')) {
return true;
}
diff --git a/Idno/Core/Input.php b/Idno/Core/Input.php
index a4ca5ff089..a524ecaa06 100644
--- a/Idno/Core/Input.php
+++ b/Idno/Core/Input.php
@@ -13,7 +13,7 @@ class Input extends \Idno\Common\Component
{
/**
- * Retrieves input from $_REQUEST, and performs optional filtering.
+ * Retrieves input from http request, and performs optional filtering.
*
* @param string $name Name of the input variable
* @param mixed $default A default return value if no value specified (default: null)
From c4c7cc299c0318023814fbf70b8896465febd493 Mon Sep 17 00:00:00 2001
From: ipranjal
Date: Tue, 24 Sep 2024 00:24:01 +0530
Subject: [PATCH 10/17] replace $_FILES super global
---
Idno/Common/Page.php | 4 +++-
Idno/Core/Input.php | 39 +++++++++++++++++++++++----------
Idno/Entities/User.php | 19 +++++++++++-----
Idno/Pages/Admin/Import.php | 5 +++--
Idno/Pages/File/Picker.php | 10 +++++----
Idno/Pages/File/Upload.php | 5 +++--
Themes/Cherwell/Pages/Admin.php | 9 ++++----
7 files changed, 61 insertions(+), 30 deletions(-)
diff --git a/Idno/Common/Page.php b/Idno/Common/Page.php
index 54b913d066..e06da055db 100644
--- a/Idno/Common/Page.php
+++ b/Idno/Common/Page.php
@@ -111,6 +111,7 @@ function ($exception) {
function getInput($name, $default = null, callable $filter = null)
{
if (!empty($name)) {
+
$value = null;
$request = \Idno\Core\Input::getInput($name, $default, $filter);
if ($request !== null) {
@@ -121,13 +122,14 @@ function getInput($name, $default = null, callable $filter = null)
if (($value===null) && ($default!==null)) {
$value = $default;
}
+
+
if (!$value!==null) {
if (isset($filter) && is_callable($filter) && empty($request)) {
$value = call_user_func($filter, $name, $value);
}
// TODO, we may want to add some sort of system wide default filter for when $filter is null
-
return $value;
}
}
diff --git a/Idno/Core/Input.php b/Idno/Core/Input.php
index a524ecaa06..012a2947b8 100644
--- a/Idno/Core/Input.php
+++ b/Idno/Core/Input.php
@@ -25,10 +25,16 @@ class Input extends \Idno\Common\Component
public static function getInput($name, $default = null, callable $filter = null)
{
if (!empty($name)) {
+
$value = null;
if (\Idno\Core\Idno::site()->request()->request->has($name)) {
+ try{
$value = \Idno\Core\Idno::site()->request()->request->get($name);
+ }catch(\Exception $e){
+ $value = \Idno\Core\Idno::site()->request()->request->all($name);
+ }
}
+
if (($value===null) && ($default!==null)) {
$value = $default;
}
@@ -46,31 +52,42 @@ public static function getInput($name, $default = null, callable $filter = null)
return null;
}
+ /**
+ * Retrieve single file from input.
+ * Retrieve a formatted files array from input, if multiple files are found, this will be turned into
+ * a sensible structure.
+ *
+ * @param string $name
+ */
+ public static function getFile($name)
+ {
+ $file = \Idno\Core\Idno::site()->request()->files->get($name);
+ return ['name'=>$file->getClientOriginalName(),'type'=>$file->getClientMimeType(),'tmp_name'=>$file->getRealPath(),'error'=>$file->getError(),'size'=>$file->getSize()];
+ }
/**
* Retrieve files from input.
* Retrieve a formatted files array from input, if multiple files are found, this will be turned into
* a sensible structure.
*
- * @param type $name
+ * @param string $name
*/
public static function getFiles($name)
{
- $files = $_FILES[$name];
- if (!is_array($files['name'])) {
- return $files; // Short circuit if there's only one entry for a name
- }
+ $files = \Idno\Core\Idno::site()->request()->files->all($name);
+ // if (!is_array($files['name'])) {
+ // return $files; // Short circuit if there's only one entry for a name
+ // }
// Normalize file array,
// HT: https://gist.github.com/umidjons/9893735
$_files = [];
- $_files_count = count($files['name']);
- $_files_keys = array_keys($files);
+ // $_files_count = count($files['name']);
+ // $_files_keys = array_keys($files);
- for ($i = 0; $i < $_files_count; $i++) {
- foreach ($_files_keys as $key) {
- $_files[$i][$key] = $files[$key][$i];
- }
+ foreach ($files as $file) {
+ array_push($_files,['name'=>$file->getClientOriginalName(),'type'=>$file->getClientMimeType(),'tmp_name'=>$file->getRealPath(),'error'=>$file->getError(),'size'=>$file->getSize()]);
+
}
return $_files;
diff --git a/Idno/Entities/User.php b/Idno/Entities/User.php
index e31bd2255b..62084edf3b 100644
--- a/Idno/Entities/User.php
+++ b/Idno/Entities/User.php
@@ -1108,19 +1108,26 @@ function saveDataFromInput()
if (!$this->canEdit()) { return false;
}
+
$profile = \Idno\Core\Idno::site()->currentPage()->getInput('profile');
if (!empty($profile)) {
$this->profile = $profile;
}
- if ($name = \Idno\Core\Idno::site()->currentPage()->getInput('name')) {
+ $name = \Idno\Core\Idno::site()->currentPage()->getInput('name');
+
+ if (!empty($name)) {
$this->setName($name);
}
- if (!empty($_FILES['avatar'])) {
- if (in_array($_FILES['avatar']['type'], array('image/png', 'image/jpg', 'image/jpeg', 'image/gif'))) {
- if (getimagesize($_FILES['avatar']['tmp_name'])) {
- if ($icon = \Idno\Entities\File::createThumbnailFromFile($_FILES['avatar']['tmp_name'], $_FILES['avatar']['name'], 300, true)) {
+
+ if ( \Idno\Core\Idno::site()->request()->files->has('avatar')) {
+ $avatar = \Idno\Core\Input::getFile(name: 'avatar');
+
+
+ if (in_array($avatar['type'], array('image/png', 'image/jpg', 'image/jpeg', 'image/gif'))) {
+ if (getimagesize($avatar['tmp_name'])) {
+ if ($icon = \Idno\Entities\File::createThumbnailFromFile($avatar['tmp_name'], $avatar['name'], 300, true)) {
$this->icon = (string)$icon;
- } else if ($icon = \Idno\Entities\File::createFromFile($_FILES['avatar']['tmp_name'], $_FILES['avatar']['name'])) {
+ } else if ($icon = \Idno\Entities\File::createFromFile($avatar['tmp_name'], $avatar['name'])) {
$this->icon = (string)$icon;
}
}
diff --git a/Idno/Pages/Admin/Import.php b/Idno/Pages/Admin/Import.php
index 31abb3fbc2..e9f8bbcd69 100644
--- a/Idno/Pages/Admin/Import.php
+++ b/Idno/Pages/Admin/Import.php
@@ -30,10 +30,11 @@ function postContent()
define('KNOWN_NOMENTION', true);
$import_type = $this->getInput('import_type');
+ $import = \Idno\Core\Input::getFile('import');
- if (empty($_FILES['import'])) {
+ if (!\Idno\Core\Idno::site()->request()->files->has('import')) {
\Idno\Core\Idno::site()->session()->addErrorMessage(\Idno\Core\Idno::site()->language()->_("You need to upload an import file to continue."));
- } else if (!($xml = @file_get_contents($_FILES['import']['tmp_name']))) {
+ } else if (!($xml = @file_get_contents($import['tmp_name']))) {
\Idno\Core\Idno::site()->session()->addErrorMessage(\Idno\Core\Idno::site()->language()->_("We couldn't open the file you uploaded. Please try again."));
} else {
\Idno\Core\Idno::site()->session()->addMessage(\Idno\Core\Idno::site()->language()->_("Your import has started. We'll email you when it's done."));
diff --git a/Idno/Pages/File/Picker.php b/Idno/Pages/File/Picker.php
index 7df2a08f32..e577c45725 100644
--- a/Idno/Pages/File/Picker.php
+++ b/Idno/Pages/File/Picker.php
@@ -27,14 +27,16 @@ function getContent()
function post()
{
if (\Idno\Core\Idno::site()->session()->isLoggedOn()) {
- if (!empty($_FILES['file']['tmp_name'])) {
+ $tmp_file = \Idno\Core\Input::getFile('file');
+
+ if (!empty($tmp_file['tmp_name'])) {
if (!\Idno\Core\Idno::site()->events()->triggerEvent("file/upload", [], true)) {
exit;
}
- if (\Idno\Entities\File::isImage($_FILES['file']['tmp_name'])) {
+ if (\Idno\Entities\File::isImage($tmp_file['tmp_name'])) {
$return = false;
$file = false;
- if ($file = \Idno\Entities\File::createThumbnailFromFile($_FILES['file']['tmp_name'], $_FILES['file']['name'], 1024)) {
+ if ($file = \Idno\Entities\File::createThumbnailFromFile($tmp_file['tmp_name'], $tmp_file['name'], 1024)) {
\Idno\Core\Idno::site()->logging()->debug("Creating new file from thumbnail as {$file}");
@@ -42,7 +44,7 @@ function post()
$returnfile = new \stdClass;
$returnfile->file = ['_id' => $file];
$file = $returnfile;
- } else if ($file = \Idno\Entities\File::createFromFile($_FILES['file']['tmp_name'], $_FILES['file']['name'], $_FILES['file']['type'], true, true)) {
+ } else if ($file = \Idno\Entities\File::createFromFile($tmp_file['tmp_name'], $tmp_file['name'], $tmp_file['type'], true, true)) {
\Idno\Core\Idno::site()->logging()->debug("Creating new file");
$return = true;
diff --git a/Idno/Pages/File/Upload.php b/Idno/Pages/File/Upload.php
index 77da0d7dd0..887e337932 100644
--- a/Idno/Pages/File/Upload.php
+++ b/Idno/Pages/File/Upload.php
@@ -17,11 +17,12 @@ function getContent()
function post()
{
if (\Idno\Core\Idno::site()->session()->isLoggedOn()) {
- if (!empty($_FILES['file']['tmp_name'])) {
+ $tmp_file = \Idno\Core\Input::getFile('file');
+ if (!empty($tmp_file ['tmp_name'])) {
if (!\Idno\Core\Idno::site()->events()->triggerEvent("file/upload", [], true)) {
exit;
}
- if ($file = \Idno\Entities\File::createFromFile($_FILES['file']['tmp_name'], $_FILES['file']['name'], $_FILES['file']['type'], true, true)) {
+ if ($file = \Idno\Entities\File::createFromFile($tmp_file ['tmp_name'], $tmp_file ['name'], $tmp_file ['type'], true, true)) {
\Idno\Core\Idno::site()->response()->setJsonContent( json_encode(\Idno\Core\Idno::site()->config()->url . 'file/' . $file->file['_id']));
}
}
diff --git a/Themes/Cherwell/Pages/Admin.php b/Themes/Cherwell/Pages/Admin.php
index aa4c2ea0aa..dbc17ef1c6 100644
--- a/Themes/Cherwell/Pages/Admin.php
+++ b/Themes/Cherwell/Pages/Admin.php
@@ -29,10 +29,11 @@ function postContent()
if ($profile_user = $this->getInput('profile_user')) {
\Idno\Core\Idno::site()->config()->config['cherwell']['profile_user'] = $profile_user;
}
- if (!empty($_FILES['background']) && $this->getInput('action') != 'clear') {
- if (in_array($_FILES['background']['type'], array('image/png', 'image/jpg', 'image/jpeg', 'image/gif'))) {
- if (getimagesize($_FILES['background']['tmp_name'])) {
- if ($background = \Idno\Entities\File::createFromFile($_FILES['background']['tmp_name'], $_FILES['background']['name'])) {
+ if (\Idno\Core\Idno::site()->request()->files->has('background') && $this->getInput('action') != 'clear') {
+ $background_file = \Idno\Core\Input::getFile('background');
+ if (in_array($background_file['type'], array('image/png', 'image/jpg', 'image/jpeg', 'image/gif'))) {
+ if (getimagesize($background_file['tmp_name'])) {
+ if ($background = \Idno\Entities\File::createFromFile($background_file['tmp_name'], $background_file['name'])) {
// Remove previous bg
if (!empty(\Idno\Core\Idno::site()->config()->cherwell['bg_id'])) {
if ($file = File::getByID(\Idno\Core\Idno::site()->config()->cherwell['bg_id'])) {
From 3a6047b750a4d26ef9581148084df76742cf6a9d Mon Sep 17 00:00:00 2001
From: ipranjal
Date: Wed, 16 Oct 2024 14:35:34 +0530
Subject: [PATCH 11/17] chore: remove wrapper and use symfony components
directly
---
Idno/Core/Config.php | 2 +-
Idno/Core/Http/RedirectResponse.php | 70 -----------------------------
Idno/Core/Http/Request.php | 35 ---------------
Idno/Core/Http/Response.php | 34 --------------
Idno/Core/Idno.php | 28 +++---------
Idno/Core/IdnoFoundation.php | 6 +--
index.php | 2 -
7 files changed, 11 insertions(+), 166 deletions(-)
delete mode 100644 Idno/Core/Http/RedirectResponse.php
delete mode 100644 Idno/Core/Http/Request.php
delete mode 100644 Idno/Core/Http/Response.php
diff --git a/Idno/Core/Config.php b/Idno/Core/Config.php
index 8700c44e69..22780d966e 100644
--- a/Idno/Core/Config.php
+++ b/Idno/Core/Config.php
@@ -220,7 +220,7 @@ function loadIniFiles()
if (($cloudcube || $aws_s3) && (!empty($bucket))) {
$this->ini_config['filesystem'] = 'local';
- $this->ini_config['uploadpath'] = "s3://${bucket}${path}";
+ $this->ini_config['uploadpath'] = "s3://{$bucket}{$path}";
}
if (array_key_exists('KNOWN_AWS_S3_REGION', $_ENV)) {
diff --git a/Idno/Core/Http/RedirectResponse.php b/Idno/Core/Http/RedirectResponse.php
deleted file mode 100644
index e8dd9a007e..0000000000
--- a/Idno/Core/Http/RedirectResponse.php
+++ /dev/null
@@ -1,70 +0,0 @@
-setTargetUrl($url);
-
- if (!$this->isRedirect()) {
- throw new \InvalidArgumentException(sprintf('The HTTP status code is not a redirect ("%s" given).', $status));
- }
-
- if (301 == $status && !\array_key_exists('cache-control', array_change_key_case($headers, \CASE_LOWER))) {
- $this->headers->remove('cache-control');
- }
- }
-
- /**
- * Returns the target URL.
- */
- public function getTargetUrl(): string
- {
- return $this->targetUrl;
- }
-
- /**
- * Sets the redirect target of this response.
- *
- * @return $this
- *
- * @throws \InvalidArgumentException
- */
- public function setTargetUrl(string $url): static
- {
- if ('' === $url) {
- throw new \InvalidArgumentException('Cannot redirect to an empty URL.');
- }
-
- $this->targetUrl = $url;
-
- $this->setContent(
- sprintf('
-
-
-
-
-
- Redirecting to %1$s
-
-
- Redirecting to %1$s .
-
- ', htmlspecialchars($url, \ENT_QUOTES, 'UTF-8'))
- );
-
- $this->headers->set('Location', $url);
- $this->headers->set('Content-Type', 'text/html; charset=utf-8');
-
- return $this;
- }
- }
-}
\ No newline at end of file
diff --git a/Idno/Core/Http/Request.php b/Idno/Core/Http/Request.php
deleted file mode 100644
index db04cd6b93..0000000000
--- a/Idno/Core/Http/Request.php
+++ /dev/null
@@ -1,35 +0,0 @@
-query->all(),
- $request->request->all(),
- $request->attributes->all(),
- $request->cookies->all(),
- $request->files->all(),
- $request->server->all(),
- $request->getContent()
- );
-
- return $newRequest;
- }
-
- public static function createFromPSR7Request(\Psr\Http\Message\ServerRequestInterface $psrRequest)
- {
- $httpFoundationFactory = new HttpFoundationFactory();
- $symfonyRequest = $httpFoundationFactory->createRequest($psrRequest);
- return self::createFromSymfonyRequest($symfonyRequest);
-
- }
-
- }
-}
\ No newline at end of file
diff --git a/Idno/Core/Http/Response.php b/Idno/Core/Http/Response.php
deleted file mode 100644
index ec37724b42..0000000000
--- a/Idno/Core/Http/Response.php
+++ /dev/null
@@ -1,34 +0,0 @@
-headers->set('Content-Type', 'application/json');
- $this->setContent(json_encode($content));
- return $this;
- }
-
- public function delaySend()
- {
- $this->delaySend = true;
- }
-
- public function isDelayed()
- {
- return $this->delaySend;
- }
-
-
-
- }
-}
\ No newline at end of file
diff --git a/Idno/Core/Idno.php b/Idno/Core/Idno.php
index 20f2040dc7..d5e58ef466 100644
--- a/Idno/Core/Idno.php
+++ b/Idno/Core/Idno.php
@@ -10,10 +10,10 @@
namespace Idno\Core {
use Idno\Common\Page;
- use Idno\Core\http\RedirectResponse;
use Idno\Entities\User;
- use Idno\Core\Http\Request;
- use Idno\Core\Http\Response;
+ use Symfony\Component\HttpFoundation\Request;
+ use Symfony\Component\HttpFoundation\Response;
+ use Symfony\Component\HttpFoundation\RedirectResponse;
class Idno extends \Idno\Common\Component
{
@@ -59,7 +59,7 @@ function init()
{
self::$site = $this;
$this->request = Request::createFromGlobals();
- $this->response = new \Idno\Core\Http\Response();
+ $this->response = new Response();
$this->routes = new PageHandler();
$this->dispatcher = new EventDispatcher();
$this->config = new Config();
@@ -320,7 +320,7 @@ function &events(): ?EventDispatcher
/**
* Return the request object loaded as part of this site
*
- * @return \Idno\Core\Http\Request
+ * @return Request
*/
function &request(): ?Request
{
@@ -330,7 +330,7 @@ function &request(): ?Request
/**
* Return the response object loaded as part of this site
*
- * @return \Idno\Core\Http\Response
+ * @return Response
*/
function &response(): ?Response
{
@@ -349,17 +349,6 @@ function &redirect($url)
}
- function &createRequest($request=null)
- {
- if($request instanceof \Symfony\Component\HttpFoundation\Request){
- $this->request = Request::createFromSymfonyRequest($request);
- } elseif ($request instanceof \Psr\Http\Message\ServerRequestInterface) {
- $this->request = Request::createFromPsr7Request($request);
- }
- else {
- $this->request = Request::createFromGlobals();
- }
- }
/**
@@ -369,10 +358,7 @@ function &sendResponse()
{
$this->response = \Idno\Core\Idno::site()->events()->triggerEvent('response/before', ['response' => $this->response()],$this->response());
// Delay sending response so that it can be modified if required
- if(!$this->response->isDelayed()){
- $this->response->send();
- }
- \Idno\Core\Idno::site()->events()->triggerEvent('response/delayed', ['response' => $this->response()]);
+ $this->response->send();
}
diff --git a/Idno/Core/IdnoFoundation.php b/Idno/Core/IdnoFoundation.php
index 0a3ee2b972..9826605f2f 100644
--- a/Idno/Core/IdnoFoundation.php
+++ b/Idno/Core/IdnoFoundation.php
@@ -1,8 +1,8 @@
request = Request::createFromGlobals();
- $this->response = new \Idno\Core\Http\Response();
+ $this->response = new Response();
}
public function &request()
diff --git a/index.php b/index.php
index e382dfaa69..4070ab25ad 100644
--- a/index.php
+++ b/index.php
@@ -14,7 +14,6 @@
* @subpackage core
*/
-
// Check PHP version first of all
if (version_compare(phpversion(), '7.2', '<')) {
@@ -32,7 +31,6 @@
require_once dirname(__FILE__) . '/Idno/start.php';
// Get page routes
-\Idno\Core\Idno::site()->createRequest();
$routes = \Idno\Core\Idno::site()->routes();
// Get subdirectory
From 8c1668e3f23b01589b6b86594e26143d1ecfd11c Mon Sep 17 00:00:00 2001
From: ipranjal
Date: Wed, 16 Oct 2024 14:38:11 +0530
Subject: [PATCH 12/17] fix: checking isset of private variable ->logging
---
Idno/start.php | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/Idno/start.php b/Idno/start.php
index bc903610a5..a6d596380b 100644
--- a/Idno/start.php
+++ b/Idno/start.php
@@ -53,12 +53,8 @@ function () {
$stats->increment("error.fatal");
}
- if (isset(\Idno\Core\Idno::site()->logging) && \Idno\Core\Idno::site()->logging) {
- \Idno\Core\Idno::site()->logging()->error($error_message);
- } else {
error_log($error_message);
- }
-
+
try {
\Idno\Core\Logging::oopsAlert($error_message, 'Oh no! Known experienced a problem!');
} catch (Exception $ex) {
From 67e25bb0e4a52bdc225e3f0153a1dd1669c0a145 Mon Sep 17 00:00:00 2001
From: ipranjal
Date: Wed, 16 Oct 2024 14:53:14 +0530
Subject: [PATCH 13/17] chore: code cleanup
---
Idno/Core/Config.php | 3 +--
Idno/Core/Email.php | 10 +++++-----
Idno/Core/Idno.php | 4 +++-
Idno/Core/Language.php | 12 ++++++------
Idno/Core/Logging.php | 9 ++++-----
Idno/Core/PageHandler.php | 13 +++++++------
Idno/Core/Plugins.php | 2 ++
Idno/Core/TokenProvider.php | 6 +++---
Idno/Core/Version.php | 2 +-
Idno/Stats/Timer.php | 6 +++---
10 files changed, 35 insertions(+), 32 deletions(-)
diff --git a/Idno/Core/Config.php b/Idno/Core/Config.php
index 22780d966e..ec5af986b6 100644
--- a/Idno/Core/Config.php
+++ b/Idno/Core/Config.php
@@ -244,7 +244,6 @@ function loadIniFiles()
foreach (\Idno\Core\Idno::site()->request()->server->all() as $name => $val) {
if (substr($name, 0, 6) == 'KNOWN_') {
$name = strtolower(str_replace('KNOWN_', '', $name));
- $val = $val;
$this->ini_config[$name] = $val;
}
}
@@ -650,7 +649,7 @@ function emailIsBlocked($email)
*/
function hasSSL()
{
- if (substr_count(site()->config()->getURL(), 'https://') || !empty($this->config()->force_ssl)) {
+ if (substr_count(site()->config()->getURL(), 'https://') || !empty($this->config->force_ssl)) {
return true;
}
diff --git a/Idno/Core/Email.php b/Idno/Core/Email.php
index 1afaeeb18f..17f4ce4516 100644
--- a/Idno/Core/Email.php
+++ b/Idno/Core/Email.php
@@ -37,7 +37,7 @@ function setSubject($subject)
function setFrom($email, $name = '')
{
if (!empty($name)) {
- return $this->message->addFrom(array($name => $email));
+ return $this->message->addFrom($email,$name);
}
return $this->message->addFrom($email);
@@ -53,7 +53,7 @@ function setFrom($email, $name = '')
function addTo($email, $name = '')
{
if (!empty($name)) {
- return $this->message->addTo(array($name => $email));
+ return $this->message->addTo($email,$name);
}
return $this->message->addTo($email);
@@ -80,7 +80,7 @@ function addBcc($email)
function setReplyTo($email, $name = '')
{
if (!empty($name)) {
- return $this->message->addReplyTo(array($name => $email));
+ return $this->message->addReplyTo($email,$name);
}
return $this->message->addReplyTo($email);
@@ -126,8 +126,8 @@ function setHTMLBody($body, $shell = true, array $shellVars = [])
/**
* Set the text only component of an email.
*
- * @param type $template_name
- * @param type $vars
+ * @param string $template_name
+ * @param string $vars
* @return mixed
*/
function setTextBodyFromTemplate($template_name, $vars = array())
diff --git a/Idno/Core/Idno.php b/Idno/Core/Idno.php
index d5e58ef466..fe4c0ac945 100644
--- a/Idno/Core/Idno.php
+++ b/Idno/Core/Idno.php
@@ -44,6 +44,8 @@ class Idno extends \Idno\Common\Component
private $statistics;
private $site_details;
+ private $themes;
+
private $request;
private $response;
@@ -437,7 +439,7 @@ function &routes(): ?PageHandler
* Helper function that returns the current configuration object
* for this site (or a configuration setting value)
*
- * @param The configuration setting value to retrieve (optional)
+ * @param $setting The configuration setting value to retrieve (optional)
*
* @return \Idno\Core\Config|array
*/
diff --git a/Idno/Core/Language.php b/Idno/Core/Language.php
index b29cdbd6ab..d10d3681b6 100644
--- a/Idno/Core/Language.php
+++ b/Idno/Core/Language.php
@@ -10,21 +10,21 @@ class Language extends Component
/**
* Language associated array of translation objects.
*
- * @var type
+ * @var array
*/
private $translations = [];
/**
* Current language
*
- * @var type
+ * @var string
*/
private $language;
/**
* Construct a language object
*
- * @param type $language
+ * @param string $language
*/
public function __construct($language = null)
{
@@ -32,7 +32,7 @@ public function __construct($language = null)
if (!empty($session)) {
if ($user = \Idno\Core\Idno::site()->session()->currentUser()) {
if (!empty($user->language)) {
- return $user->language;
+ $language = $user->language;
}
}
}
@@ -67,7 +67,7 @@ function __get($string)
/**
* Return a translated string, substituting variables in subs in the format of sprintf.
*
- * @param type $string String to translate
+ * @param string $string String to translate
* @param array $subs List of substitution variables to be used in the translated string
* @return string
*/
@@ -79,7 +79,7 @@ public function _($string, array $subs = [])
/**
* Return an ESCAPED translated string, substituting variables in subs in the format of sprintf.
*
- * @param type $string String to translate
+ * @param string $string String to translate
* @param array $subs List of substitution variables to be used in the translated string
* @return string
*/
diff --git a/Idno/Core/Logging.php b/Idno/Core/Logging.php
index d8de5fa65e..806993b4a1 100644
--- a/Idno/Core/Logging.php
+++ b/Idno/Core/Logging.php
@@ -22,8 +22,8 @@ class Logging extends Component implements LoggerInterface
/**
* Create a basic logger to log to the PHP log.
*
- * @param type $loglevel_filter Log levels to show 0 - off, 1 - errors, 2 - errors & warnings, 3 - errors, warnings and info, 4 - 3 + debug
- * @param type $identifier Identify this site in the log (defaults to current domain)
+ * @param int $loglevel_filter Log levels to show 0 - off, 1 - errors, 2 - errors & warnings, 3 - errors, warnings and info, 4 - 3 + debug
+ * @param string $identifier Identify this site in the log (defaults to current domain)
*/
public function __construct($loglevel_filter = 0, $identifier = null)
{
@@ -74,7 +74,6 @@ function ($errno, $errstr, $errfile, $errline, $errcontext = []) {
case E_NOTICE:
case E_DEPRECATED:
case E_USER_DEPRECATED:
- case E_STRICT:
case E_USER_NOTICE:
$this->notice($message);
break;
@@ -320,8 +319,8 @@ public function debug($message, array $context = array()): void
/**
* (attempt) to send, if configured, a message when a fatal error occurs, or an exception is caught.
*
- * @param type $message
- * @param type $title
+ * @param string $message
+ * @param string $title
*/
public static function oopsAlert($message, $title = "")
{
diff --git a/Idno/Core/PageHandler.php b/Idno/Core/PageHandler.php
index faceb3e448..9947326bca 100644
--- a/Idno/Core/PageHandler.php
+++ b/Idno/Core/PageHandler.php
@@ -105,12 +105,13 @@ public static function serve($routes)
*/
function addRoute(string $pattern, string $handler, bool $public = false)
{
- if (defined('KNOWN_SUBDIRECTORY')) {
- if (substr($pattern, 0, 1) != '/') {
- $pattern = '/' . $pattern;
- }
- $pattern = '/' . KNOWN_SUBDIRECTORY . $pattern;
- }
+ // Known no longer support subdirectories
+ // if (defined('KNOWN_SUBDIRECTORY')) {
+ // if (substr($pattern, 0, 1) != '/') {
+ // $pattern = '/' . $pattern;
+ // }
+ // $pattern = '/' . KNOWN_SUBDIRECTORY . $pattern;
+ // }
$pattern = strtr($pattern, $this->routeTokens());
if (class_exists($handler)) {
$this->routes[$pattern] = $handler;
diff --git a/Idno/Core/Plugins.php b/Idno/Core/Plugins.php
index 3329b726e2..83a057b5b1 100644
--- a/Idno/Core/Plugins.php
+++ b/Idno/Core/Plugins.php
@@ -303,6 +303,8 @@ public function disable($plugin)
return true;
}
+
+ return false;
}
/**
diff --git a/Idno/Core/TokenProvider.php b/Idno/Core/TokenProvider.php
index c329ad8cf2..d3f6b96193 100644
--- a/Idno/Core/TokenProvider.php
+++ b/Idno/Core/TokenProvider.php
@@ -21,8 +21,8 @@ function generateHexToken($length)
/**
* Generate a cryptographically secure random token.
*
- * @param type $length Length in bytes
- * @return bytes
+ * @param int $length Length in bytes
+ * @return string bytes
* @throws \Exception If cryptographic functions are not strong enough.
*/
function generateToken($length)
@@ -43,7 +43,7 @@ function generateToken($length)
* to output the whole thing since all you really want to know is if they're similar to another.
*
* @param string $token
- * @return retacted token
+ * @return string retacted token
*/
public static function truncateToken($token)
{
diff --git a/Idno/Core/Version.php b/Idno/Core/Version.php
index fb6fdceb99..8dc18bb186 100644
--- a/Idno/Core/Version.php
+++ b/Idno/Core/Version.php
@@ -59,7 +59,7 @@ public static function version()
/**
* Return the machine version.
*
- * @return type
+ * @return string
*/
public static function build()
{
diff --git a/Idno/Stats/Timer.php b/Idno/Stats/Timer.php
index c618885f10..7bec976891 100644
--- a/Idno/Stats/Timer.php
+++ b/Idno/Stats/Timer.php
@@ -17,7 +17,7 @@ class Timer
/**
* Start a timer.
*
- * @param type $timer
+ * @param string $timer
*/
public static function start($timer)
{
@@ -27,7 +27,7 @@ public static function start($timer)
/**
* Retrieve the current number of seconds (with milliseconds) since $timer was started.
*
- * @param type $timer
+ * @param string $timer
*/
public static function value($timer)
{
@@ -44,7 +44,7 @@ public static function value($timer)
/**
* Shorthand to log a given timer to the debug log.
*
- * @param type $timer
+ * @param string $timer
*/
public static function logTimer($timer)
{
From 3e0a37ef80ed28c9841456610f955df7c55db043 Mon Sep 17 00:00:00 2001
From: ipranjal
Date: Wed, 16 Oct 2024 16:36:20 +0530
Subject: [PATCH 14/17] feat: replace $_SESSION global and use symfony session
---
Idno/Core/Idno.php | 6 +-
Idno/Core/Session.php | 217 +++++++++++-------
Idno/Entities/User.php | 7 +-
Idno/Pages/Onboarding/Begin.php | 2 +-
Idno/Pages/Onboarding/Connect.php | 3 +-
.../default/shell/simple/messages.tpl.php | 1 +
6 files changed, 140 insertions(+), 96 deletions(-)
diff --git a/Idno/Core/Idno.php b/Idno/Core/Idno.php
index fe4c0ac945..07a7b2b2dd 100644
--- a/Idno/Core/Idno.php
+++ b/Idno/Core/Idno.php
@@ -750,15 +750,15 @@ function getSiteIcons(): array
function embedded()
{
if (site()->currentPage()->getInput('unembed')) {
- $_SESSION['embedded'] = false;
+ $this->session->set('embedded', false);
return false;
}
- if (!empty($_SESSION['embedded'])) {
+ if ($this->session->has('embedded')) {
return true;
}
if (site()->currentPage()->getInput('embedded')) {
- $_SESSION['embedded'] = true;
+ $this->session->set('embedded', true);
return true;
}
diff --git a/Idno/Core/Session.php b/Idno/Core/Session.php
index 4736b2148c..27518908d3 100644
--- a/Idno/Core/Session.php
+++ b/Idno/Core/Session.php
@@ -10,20 +10,36 @@
namespace Idno\Core {
use Idno\Entities\User;
+ use Symfony\Component\HttpFoundation\Session\Session as SymfonySession;
+ use Symfony\Component\HttpFoundation\Session\Storage\SessionStorageInterface;
+
class Session extends \Idno\Common\Component
{
private $user;
+ private $session_engine;
+
+ private $storage;
+
private $storageHandler = false;
+ function __construct(?SessionStorageInterface $storage = null)
+ {
+
+ $this->storage = $storage;
+ parent::__construct();
+ }
+
function init()
{
+ $this->session_engine = new SymfonySession($this->storage);
+
ini_set('session.cookie_lifetime', 60 * 60 * 24 * 7); // Persistent cookies
ini_set('session.gc_maxlifetime', 60 * 60 * 24 * 7); // Garbage collection to match
- header('P3P: CP="CAO PSA OUR"');
+ \Idno\Core\Idno::site()->response()->headers->set('P3P', 'CP="CAO PSA OUR"');
ini_set('session.use_only_cookies', true); // Only cookies for session
ini_set('session.cookie_httponly', true); // Restrict cookies to HTTP only (help reduce XSS attack profile)
ini_set('session.use_strict_mode', true); // Help mitigate session fixation
@@ -37,45 +53,48 @@ function init()
ini_set('session.hash_function', $hash);
}
- $sessions_handled = false;
+ // Storage will now be handled bt symfony session
- // If we're storing sessions in the database, then try to store it.
- if ((!$sessions_handled) && (Idno::site()->config()->sessions_database)) {
- $db = Idno::site()->db();
- if ($db instanceof \Idno\Common\SessionStorageInterface) {
- if ($db->handleSession()) {
- $this->storageHandler = $db;
- $sessions_handled = true;
- }
- }
- }
+ // $sessions_handled = false;
- // Try a pluggable session storage handler
- if ((!$sessions_handled) && (Idno::site()->config()->sessions_storage)) {
- $storage_class = Idno::site()->config()->sessions_storage;
- if (class_exists("{$storage_class}")) {
- if (is_subclass_of($storage_class, "Idno\\Common\\SessionStorageInterface")) {
- $storage_class = new $storage_class();
- if ($storage_class->handleSession()) {
- $this->storageHandler = $storage_class;
- $sessions_handled = true;
- }
- }
- }
- }
+ // Todo - Make known schema compatible database session storage
+ // // If we're storing sessions in the database, then try to store it.
+ // if ((!$sessions_handled) && (Idno::site()->config()->sessions_database)) {
+ // $db = Idno::site()->db();
+ // if ($db instanceof \Idno\Common\SessionStorageInterface) {
+ // if ($db->handleSession()) {
+ // $this->storageHandler = $db;
+ // $sessions_handled = true;
+ // }
+ // }
+ // }
- // Fallback to files if no other session storage handler has been defined
- if (!$sessions_handled) {
- session_save_path(Idno::site()->config()->session_path);
- }
+ // Try a pluggable session storage handler
+ // if ((!$sessions_handled) && (Idno::site()->config()->sessions_storage)) {
+ // $storage_class = Idno::site()->config()->sessions_storage;
+ // if (class_exists("{$storage_class}")) {
+ // if (is_subclass_of($storage_class, "Idno\\Common\\SessionStorageInterface")) {
+ // $storage_class = new $storage_class();
+ // if ($storage_class->handleSession()) {
+ // $this->storageHandler = $storage_class;
+ // $sessions_handled = true;
+ // }
+ // }
+ // }
+ // }
+
+ // // Fallback to files if no other session storage handler has been defined
+ // if (!$sessions_handled) {
+ // session_save_path(Idno::site()->config()->session_path);
+ // }
// session_cache_limiter('public // TODO: Reintroduce when page endpoints have set no-expire as appropriate
- session_name(Idno::site()->config()->sessionname);
- session_start();
+ $this->session_engine->setName(Idno::site()->config()->sessionname);
+ $this->session_engine->start();
// Flag insecure sessions (so we can check state changes etc)
- if (!isset($_SESSION['secure'])) {
- $_SESSION['secure'] = \Idno\Common\Page::isSSL();
+ if (!$this->has('secure')) {
+ $this->set('secure', \Idno\Common\Page::isSSL());
}
// Validate session
@@ -86,7 +105,7 @@ function init()
\Idno\Core\Idno::site()->logging()->error('Error validating session', ['error' => $ex->getMessage()]);
header('X-KNOWN-DEBUG: Tilt!');
- $_SESSION = [];
+ $this->session_engine->clear();
session_destroy();
}
@@ -110,8 +129,8 @@ function init()
if ($object->getUUID() != $this->user->getUUID()) { return;
}
- if (!empty($_SESSION['user_uuid'])) {
- if ($object->getUUID() != $_SESSION['user_uuid']) { return;
+ if ($this->has('user_uuid')) {
+ if ($object->getUUID() != $this->get('user_uuid')) { return;
}
}
@@ -131,6 +150,7 @@ function () {
);
}
+
/**
* Validate the session.
*
@@ -145,6 +165,8 @@ protected function validate()
}*/
}
+
+
/**
* Kill the session.
*/
@@ -212,7 +234,7 @@ function isAdmin()
/**
* Returns the currently logged-in user, if any
*
- * @return \Idno\Entities\User
+ * @return bool|\Idno\Entities\User
*/
function currentUser()
@@ -233,10 +255,7 @@ function currentUser()
function addMessage($message, $message_type = 'alert-info')
{
- if (empty($_SESSION['messages'])) {
- $_SESSION['messages'] = array();
- }
- $_SESSION['messages'][] = $this->getStructuredMessage($message, $message_type);
+ $this->session_engine->getFlashBag()->add($message_type, $message);
}
/**
@@ -293,14 +312,14 @@ function addErrorMessage($message)
*
* @param string $message The text of the message
* @param string $message_type This type of message; this will be added to the displayed message class, or returned as data
+ * @deprecated message order is not guaranteed
*/
function addMessageAtStart($message, $message_type = 'alert-info')
{
- if (empty($_SESSION['messages'])) {
- $_SESSION['messages'] = array();
- }
- array_unshift($_SESSION['messages'], array('message' => $message, 'message_type' => $message_type));
+ //We cant force the order of messages in flashbag
+ $this->session_engine->getFlashBag()->add($message_type, $message);
+
}
/**
@@ -310,10 +329,15 @@ function addMessageAtStart($message, $message_type = 'alert-info')
*/
function getAndFlushMessages()
{
- $messages = $this->getMessages();
- $this->flushMessages();
- return $messages;
+ $messages = $this->session_engine->getFlashBag()->all();
+ $final_meassages = [];
+ foreach($messages as $type => $message){
+ foreach($message as $msg){
+ array_push($final_meassages, $this->getStructuredMessage($msg, $type));
+ }
+ }
+ return $final_meassages;
}
/**
@@ -323,11 +347,8 @@ function getAndFlushMessages()
*/
function getMessages()
{
- if (!empty($_SESSION['messages'])) {
- return $_SESSION['messages'];
- } else {
- return array();
- }
+ return $this->session_engine->getFlashBag()->all();
+
}
/**
@@ -335,9 +356,7 @@ function getMessages()
*/
function flushMessages()
{
- $messages = array();
- $_SESSION['messages'] = $messages;
- $_SESSION['last_message_flush'] = date('r', time());
+ //This is not required as flashbag will flush any messages after they are read
}
/**
@@ -416,11 +435,11 @@ function logUserOff()
)
);
- unset($_SESSION['user_uuid']);
- unset($this->user);
+ $this->remove('user_uuid');
+ $this->clear();
// Unset all session variables, as per PHP docs.
- $_SESSION = [];
+
// Really log the user off by destroying the cookie
// See https://secure.php.net/manual/en/function.session-destroy.php
@@ -429,7 +448,7 @@ function logUserOff()
if (ini_get("session.use_cookies")) {
$params = session_get_cookie_params();
setcookie(
- session_name(), '', time() - 42000,
+ $this->session_engine->getName(), '', time() - 42000,
$params["path"], $params["domain"],
$params["secure"], $params["httponly"]
);
@@ -442,30 +461,48 @@ function logUserOff()
return true;
}
+
+
/**
- * Set a piece of session data
+ * Retrieve the session data with key $name, if it exists
*
- * @param string $name
- * @param mixed $value
+ * @param string $name
+ * @return mixed
*/
- function set($name, $value)
+ function get($name)
{
- $_SESSION[$name] = $value;
+ return $this->session_engine->get($name,false);
+ }
+
+ /*
+ * Retrieve all session data
+ *
+ * @return array
+ */
+ function all(){
+ return $this->session_engine->all();
}
/**
- * Retrieve the session data with key $name, if it exists
+ * Check if the session has data with key $name
*
- * @param string $name
- * @return mixed
+ * @param $name
+ * @return bool
*/
- function get($name)
+ function has($name)
{
- if (!empty($_SESSION[$name])) {
- return $_SESSION[$name];
- } else {
- return false;
- }
+ return $this->session_engine->has($name);
+ }
+
+ /**
+ * Set data with key $name to $value in the session
+ *
+ * @param string $name
+ * @param mixed $value
+ */
+ function set($name, $value)
+ {
+ $this->session_engine->set($name, $value);
}
/**
@@ -475,7 +512,15 @@ function get($name)
*/
function remove($name)
{
- unset($_SESSION[$name]);
+ $this->session_engine->remove($name);
+ }
+
+ /**
+ * Clear the session
+ */
+ function clear()
+ {
+ $this->session_engine->clear();
}
/**
@@ -568,7 +613,7 @@ function tryAuthUser()
* Log the specified user on (note that this is NOT the same as taking the user's auth credentials)
*
* @param \Idno\Entities\User $user
- * @return \Idno\Entities\User
+ * @return \Idno\Entities\User|false
*/
function logUserOn(\Idno\Entities\User $user)
@@ -579,7 +624,7 @@ function logUserOn(\Idno\Entities\User $user)
return false;
}
$return = $this->refreshSessionUser($user);
- @session_regenerate_id(true);
+ $this->session_engine->migrate(true);
// user/auth/success event needs to be triggered here
$return = \Idno\Core\Idno::site()->events()->triggerEvent(
@@ -602,7 +647,7 @@ function logUserOn(\Idno\Entities\User $user)
* Refresh the user currently stored in the session
*
* @param \Idno\Entities\User $user
- * @return \Idno\Entities\User
+ * @return \Idno\Entities\User|false
*/
function refreshSessionUser(\Idno\Entities\User $user)
{
@@ -614,7 +659,7 @@ function refreshSessionUser(\Idno\Entities\User $user)
return false;
}
- $_SESSION['user_uuid'] = $user->getUUID();
+ $this->set('user_uuid', $user->getUUID());
$this->user = $user;
return $user;
@@ -628,8 +673,8 @@ function refreshSessionUser(\Idno\Entities\User $user)
*/
function refreshCurrentSessionuser()
{
- if (!$this->currentUser() && !empty($_SESSION['user_uuid'])) {
- if ($this->user = User::getByUUID($_SESSION['user_uuid'])) {
+ if (!$this->currentUser() && $this->has('user_uuid')) {
+ if ($this->user = User::getByUUID($this->get('user_uuid'))) {
if (\Idno\Core\Idno::site()->config()->emailIsBlocked($this->user->email)) {
$this->logUserOff();
}
@@ -651,8 +696,8 @@ function refreshCurrentSessionuser()
*/
function setIsAPIRequest($is_api_request)
{
- $is_api_request = (bool)$is_api_request;
- $_SESSION['is_api_request'] = $is_api_request;
+ $is_api_request = (bool)$is_api_request;
+ $this->set('is_api_request', $is_api_request);
}
/**
@@ -662,11 +707,7 @@ function setIsAPIRequest($is_api_request)
*/
function isAPIRequest()
{
- if (!empty($_SESSION['is_api_request'])) {
- return true;
- }
-
- return false;
+ return $this->has('is_api_request') ? $this->get('is_api_request') : false;
}
/**
diff --git a/Idno/Entities/User.php b/Idno/Entities/User.php
index 62084edf3b..7140aeeb4b 100644
--- a/Idno/Entities/User.php
+++ b/Idno/Entities/User.php
@@ -1105,6 +1105,7 @@ public function countUnreadNotifications()
function saveDataFromInput()
{
+
if (!$this->canEdit()) { return false;
}
@@ -1113,15 +1114,16 @@ function saveDataFromInput()
if (!empty($profile)) {
$this->profile = $profile;
}
+
$name = \Idno\Core\Idno::site()->currentPage()->getInput('name');
if (!empty($name)) {
$this->setName($name);
}
- if ( \Idno\Core\Idno::site()->request()->files->has('avatar')) {
+
+ if ( \Idno\Core\Idno::site()->request()->files->has('avatar') && \Idno\Core\Idno::site()->request()->files->get('avatar') !== null) {
$avatar = \Idno\Core\Input::getFile(name: 'avatar');
-
if (in_array($avatar['type'], array('image/png', 'image/jpg', 'image/jpeg', 'image/gif'))) {
if (getimagesize($avatar['tmp_name'])) {
@@ -1134,6 +1136,7 @@ function saveDataFromInput()
}
}
+
return $this->save();
}
diff --git a/Idno/Pages/Onboarding/Begin.php b/Idno/Pages/Onboarding/Begin.php
index bce0c60eb0..602411356b 100644
--- a/Idno/Pages/Onboarding/Begin.php
+++ b/Idno/Pages/Onboarding/Begin.php
@@ -14,7 +14,7 @@ function getContent()
$set_name = $this->getInput('set_name');
if (!empty($set_name)) {
- $_SESSION['set_name'] = $set_name;
+ \Idno\Core\Idno::site()->session()->set('set_name', $set_name);
}
$t = \Idno\Core\Idno::site()->template();
diff --git a/Idno/Pages/Onboarding/Connect.php b/Idno/Pages/Onboarding/Connect.php
index 7ccf05c24a..b409bc01d7 100644
--- a/Idno/Pages/Onboarding/Connect.php
+++ b/Idno/Pages/Onboarding/Connect.php
@@ -16,8 +16,7 @@ function getContent()
//if ($services = \Idno\Core\Idno::site()->syndication()->getServices()) {
$user = \Idno\Core\Idno::site()->session()->currentUser();
-
- $_SESSION['onboarding_passthrough'] = true;
+ \Idno\Core\Idno::site()->session()->set('onboarding_passthrough', true);
$t = \Idno\Core\Idno::site()->template();
$content = $t->__(
diff --git a/templates/default/shell/simple/messages.tpl.php b/templates/default/shell/simple/messages.tpl.php
index 244f5f40bf..094c6d2361 100644
--- a/templates/default/shell/simple/messages.tpl.php
+++ b/templates/default/shell/simple/messages.tpl.php
@@ -1,6 +1,7 @@
From 4804f681c596653fb55fe2e32822269567bf06a1 Mon Sep 17 00:00:00 2001
From: ipranjal
Date: Wed, 16 Oct 2024 16:46:07 +0530
Subject: [PATCH 15/17] chore: deps update
---
composer.lock | 504 ++++++++++++++++++++++----------------------------
1 file changed, 219 insertions(+), 285 deletions(-)
diff --git a/composer.lock b/composer.lock
index aed85c29d0..566b6d448d 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,8 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "89ff0b9a11e06e8340fa07a33812984a",
-
+ "content-hash": "f09bd73f823e88c17485ff0e9c20e5b2",
"packages": [
{
"name": "brick/math",
@@ -555,6 +554,7 @@
"issues": "https://github.com/ForkAwesome/Fork-Awesome/issues",
"source": "https://github.com/ForkAwesome/Fork-Awesome/tree/1.2"
},
+ "abandoned": true,
"time": "2021-08-26T18:46:39+00:00"
},
{
@@ -621,22 +621,22 @@
},
{
"name": "guzzlehttp/guzzle",
- "version": "7.8.1",
+ "version": "7.9.2",
"source": {
"type": "git",
"url": "https://github.com/guzzle/guzzle.git",
- "reference": "41042bc7ab002487b876a0683fc8dce04ddce104"
+ "reference": "d281ed313b989f213357e3be1a179f02196ac99b"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/guzzle/guzzle/zipball/41042bc7ab002487b876a0683fc8dce04ddce104",
- "reference": "41042bc7ab002487b876a0683fc8dce04ddce104",
+ "url": "https://api.github.com/repos/guzzle/guzzle/zipball/d281ed313b989f213357e3be1a179f02196ac99b",
+ "reference": "d281ed313b989f213357e3be1a179f02196ac99b",
"shasum": ""
},
"require": {
"ext-json": "*",
- "guzzlehttp/promises": "^1.5.3 || ^2.0.1",
- "guzzlehttp/psr7": "^1.9.1 || ^2.5.1",
+ "guzzlehttp/promises": "^1.5.3 || ^2.0.3",
+ "guzzlehttp/psr7": "^2.7.0",
"php": "^7.2.5 || ^8.0",
"psr/http-client": "^1.0",
"symfony/deprecation-contracts": "^2.2 || ^3.0"
@@ -647,9 +647,9 @@
"require-dev": {
"bamarni/composer-bin-plugin": "^1.8.2",
"ext-curl": "*",
- "php-http/client-integration-tests": "dev-master#2c025848417c1135031fdf9c728ee53d0a7ceaee as 3.0.999",
+ "guzzle/client-integration-tests": "3.0.2",
"php-http/message-factory": "^1.1",
- "phpunit/phpunit": "^8.5.36 || ^9.6.15",
+ "phpunit/phpunit": "^8.5.39 || ^9.6.20",
"psr/log": "^1.1 || ^2.0 || ^3.0"
},
"suggest": {
@@ -727,7 +727,7 @@
],
"support": {
"issues": "https://github.com/guzzle/guzzle/issues",
- "source": "https://github.com/guzzle/guzzle/tree/7.8.1"
+ "source": "https://github.com/guzzle/guzzle/tree/7.9.2"
},
"funding": [
{
@@ -743,20 +743,20 @@
"type": "tidelift"
}
],
- "time": "2023-12-03T20:35:24+00:00"
+ "time": "2024-07-24T11:22:20+00:00"
},
{
"name": "guzzlehttp/promises",
- "version": "2.0.2",
+ "version": "2.0.3",
"source": {
"type": "git",
"url": "https://github.com/guzzle/promises.git",
- "reference": "bbff78d96034045e58e13dedd6ad91b5d1253223"
+ "reference": "6ea8dd08867a2a42619d65c3deb2c0fcbf81c8f8"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/guzzle/promises/zipball/bbff78d96034045e58e13dedd6ad91b5d1253223",
- "reference": "bbff78d96034045e58e13dedd6ad91b5d1253223",
+ "url": "https://api.github.com/repos/guzzle/promises/zipball/6ea8dd08867a2a42619d65c3deb2c0fcbf81c8f8",
+ "reference": "6ea8dd08867a2a42619d65c3deb2c0fcbf81c8f8",
"shasum": ""
},
"require": {
@@ -764,7 +764,7 @@
},
"require-dev": {
"bamarni/composer-bin-plugin": "^1.8.2",
- "phpunit/phpunit": "^8.5.36 || ^9.6.15"
+ "phpunit/phpunit": "^8.5.39 || ^9.6.20"
},
"type": "library",
"extra": {
@@ -810,7 +810,7 @@
],
"support": {
"issues": "https://github.com/guzzle/promises/issues",
- "source": "https://github.com/guzzle/promises/tree/2.0.2"
+ "source": "https://github.com/guzzle/promises/tree/2.0.3"
},
"funding": [
{
@@ -826,20 +826,20 @@
"type": "tidelift"
}
],
- "time": "2023-12-03T20:19:20+00:00"
+ "time": "2024-07-18T10:29:17+00:00"
},
{
"name": "guzzlehttp/psr7",
- "version": "2.6.2",
+ "version": "2.7.0",
"source": {
"type": "git",
"url": "https://github.com/guzzle/psr7.git",
- "reference": "45b30f99ac27b5ca93cb4831afe16285f57b8221"
+ "reference": "a70f5c95fb43bc83f07c9c948baa0dc1829bf201"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/guzzle/psr7/zipball/45b30f99ac27b5ca93cb4831afe16285f57b8221",
- "reference": "45b30f99ac27b5ca93cb4831afe16285f57b8221",
+ "url": "https://api.github.com/repos/guzzle/psr7/zipball/a70f5c95fb43bc83f07c9c948baa0dc1829bf201",
+ "reference": "a70f5c95fb43bc83f07c9c948baa0dc1829bf201",
"shasum": ""
},
"require": {
@@ -854,8 +854,8 @@
},
"require-dev": {
"bamarni/composer-bin-plugin": "^1.8.2",
- "http-interop/http-factory-tests": "^0.9",
- "phpunit/phpunit": "^8.5.36 || ^9.6.15"
+ "http-interop/http-factory-tests": "0.9.0",
+ "phpunit/phpunit": "^8.5.39 || ^9.6.20"
},
"suggest": {
"laminas/laminas-httphandlerrunner": "Emit PSR-7 responses"
@@ -926,7 +926,7 @@
],
"support": {
"issues": "https://github.com/guzzle/psr7/issues",
- "source": "https://github.com/guzzle/psr7/tree/2.6.2"
+ "source": "https://github.com/guzzle/psr7/tree/2.7.0"
},
"funding": [
{
@@ -942,7 +942,7 @@
"type": "tidelift"
}
],
- "time": "2023-12-03T20:05:35+00:00"
+ "time": "2024-07-18T11:15:46+00:00"
},
{
"name": "idno/mentionjs",
@@ -1416,16 +1416,16 @@
},
{
"name": "monolog/monolog",
- "version": "3.6.0",
+ "version": "3.7.0",
"source": {
"type": "git",
"url": "https://github.com/Seldaek/monolog.git",
- "reference": "4b18b21a5527a3d5ffdac2fd35d3ab25a9597654"
+ "reference": "f4393b648b78a5408747de94fca38beb5f7e9ef8"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/Seldaek/monolog/zipball/4b18b21a5527a3d5ffdac2fd35d3ab25a9597654",
- "reference": "4b18b21a5527a3d5ffdac2fd35d3ab25a9597654",
+ "url": "https://api.github.com/repos/Seldaek/monolog/zipball/f4393b648b78a5408747de94fca38beb5f7e9ef8",
+ "reference": "f4393b648b78a5408747de94fca38beb5f7e9ef8",
"shasum": ""
},
"require": {
@@ -1501,7 +1501,7 @@
],
"support": {
"issues": "https://github.com/Seldaek/monolog/issues",
- "source": "https://github.com/Seldaek/monolog/tree/3.6.0"
+ "source": "https://github.com/Seldaek/monolog/tree/3.7.0"
},
"funding": [
{
@@ -1513,7 +1513,7 @@
"type": "tidelift"
}
],
- "time": "2024-04-12T21:02:21+00:00"
+ "time": "2024-06-28T09:40:51+00:00"
},
{
"name": "npm-asset/bootstrap-accessibility-plugin",
@@ -1705,24 +1705,24 @@
},
{
"name": "paragonie/constant_time_encoding",
- "version": "v2.6.3",
+ "version": "v3.0.0",
"source": {
"type": "git",
"url": "https://github.com/paragonie/constant_time_encoding.git",
- "reference": "58c3f47f650c94ec05a151692652a868995d2938"
+ "reference": "df1e7fde177501eee2037dd159cf04f5f301a512"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/paragonie/constant_time_encoding/zipball/58c3f47f650c94ec05a151692652a868995d2938",
- "reference": "58c3f47f650c94ec05a151692652a868995d2938",
+ "url": "https://api.github.com/repos/paragonie/constant_time_encoding/zipball/df1e7fde177501eee2037dd159cf04f5f301a512",
+ "reference": "df1e7fde177501eee2037dd159cf04f5f301a512",
"shasum": ""
},
"require": {
- "php": "^7|^8"
+ "php": "^8"
},
"require-dev": {
- "phpunit/phpunit": "^6|^7|^8|^9",
- "vimeo/psalm": "^1|^2|^3|^4"
+ "phpunit/phpunit": "^9",
+ "vimeo/psalm": "^4|^5"
},
"type": "library",
"autoload": {
@@ -1768,7 +1768,7 @@
"issues": "https://github.com/paragonie/constant_time_encoding/issues",
"source": "https://github.com/paragonie/constant_time_encoding"
},
- "time": "2022-06-14T06:56:20+00:00"
+ "time": "2024-05-08T12:36:18+00:00"
},
{
"name": "paragonie/random_compat",
@@ -1897,20 +1897,20 @@
},
{
"name": "phpseclib/phpseclib",
- "version": "3.0.37",
+ "version": "3.0.42",
"source": {
"type": "git",
"url": "https://github.com/phpseclib/phpseclib.git",
- "reference": "cfa2013d0f68c062055180dd4328cc8b9d1f30b8"
+ "reference": "db92f1b1987b12b13f248fe76c3a52cadb67bb98"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/cfa2013d0f68c062055180dd4328cc8b9d1f30b8",
- "reference": "cfa2013d0f68c062055180dd4328cc8b9d1f30b8",
+ "url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/db92f1b1987b12b13f248fe76c3a52cadb67bb98",
+ "reference": "db92f1b1987b12b13f248fe76c3a52cadb67bb98",
"shasum": ""
},
"require": {
- "paragonie/constant_time_encoding": "^1|^2",
+ "paragonie/constant_time_encoding": "^1|^2|^3",
"paragonie/random_compat": "^1.4|^2.0|^9.99.99",
"php": ">=5.6.1"
},
@@ -1987,7 +1987,7 @@
],
"support": {
"issues": "https://github.com/phpseclib/phpseclib/issues",
- "source": "https://github.com/phpseclib/phpseclib/tree/3.0.37"
+ "source": "https://github.com/phpseclib/phpseclib/tree/3.0.42"
},
"funding": [
{
@@ -2003,7 +2003,7 @@
"type": "tidelift"
}
],
- "time": "2024-03-03T02:14:58+00:00"
+ "time": "2024-09-16T03:06:04+00:00"
},
{
"name": "psr/cache",
@@ -2211,20 +2211,20 @@
},
{
"name": "psr/http-factory",
- "version": "1.0.2",
+ "version": "1.1.0",
"source": {
"type": "git",
"url": "https://github.com/php-fig/http-factory.git",
- "reference": "e616d01114759c4c489f93b099585439f795fe35"
+ "reference": "2b4765fddfe3b508ac62f829e852b1501d3f6e8a"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/php-fig/http-factory/zipball/e616d01114759c4c489f93b099585439f795fe35",
- "reference": "e616d01114759c4c489f93b099585439f795fe35",
+ "url": "https://api.github.com/repos/php-fig/http-factory/zipball/2b4765fddfe3b508ac62f829e852b1501d3f6e8a",
+ "reference": "2b4765fddfe3b508ac62f829e852b1501d3f6e8a",
"shasum": ""
},
"require": {
- "php": ">=7.0.0",
+ "php": ">=7.1",
"psr/http-message": "^1.0 || ^2.0"
},
"type": "library",
@@ -2248,7 +2248,7 @@
"homepage": "https://www.php-fig.org/"
}
],
- "description": "Common interfaces for PSR-7 HTTP message factories",
+ "description": "PSR-17: Common interfaces for PSR-7 HTTP message factories",
"keywords": [
"factory",
"http",
@@ -2260,9 +2260,9 @@
"response"
],
"support": {
- "source": "https://github.com/php-fig/http-factory/tree/1.0.2"
+ "source": "https://github.com/php-fig/http-factory"
},
- "time": "2023-04-10T20:10:41+00:00"
+ "time": "2024-04-15T12:06:14+00:00"
},
{
"name": "psr/http-message",
@@ -2969,16 +2969,16 @@
},
{
"name": "symfony/console",
- "version": "v6.4.3",
+ "version": "v6.4.12",
"source": {
"type": "git",
"url": "https://github.com/symfony/console.git",
- "reference": "2aaf83b4de5b9d43b93e4aec6f2f8b676f7c567e"
+ "reference": "72d080eb9edf80e36c19be61f72c98ed8273b765"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/console/zipball/2aaf83b4de5b9d43b93e4aec6f2f8b676f7c567e",
- "reference": "2aaf83b4de5b9d43b93e4aec6f2f8b676f7c567e",
+ "url": "https://api.github.com/repos/symfony/console/zipball/72d080eb9edf80e36c19be61f72c98ed8273b765",
+ "reference": "72d080eb9edf80e36c19be61f72c98ed8273b765",
"shasum": ""
},
"require": {
@@ -3043,7 +3043,7 @@
"terminal"
],
"support": {
- "source": "https://github.com/symfony/console/tree/v6.4.3"
+ "source": "https://github.com/symfony/console/tree/v6.4.12"
},
"funding": [
{
@@ -3059,7 +3059,7 @@
"type": "tidelift"
}
],
- "time": "2024-01-23T14:51:35+00:00"
+ "time": "2024-09-20T08:15:52+00:00"
},
{
"name": "symfony/deprecation-contracts",
@@ -3442,20 +3442,20 @@
},
{
"name": "symfony/polyfill-iconv",
- "version": "v1.29.0",
+ "version": "v1.31.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-iconv.git",
- "reference": "cd4226d140ecd3d0f13d32ed0a4a095ffe871d2f"
+ "reference": "48becf00c920479ca2e910c22a5a39e5d47ca956"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/polyfill-iconv/zipball/cd4226d140ecd3d0f13d32ed0a4a095ffe871d2f",
- "reference": "cd4226d140ecd3d0f13d32ed0a4a095ffe871d2f",
+ "url": "https://api.github.com/repos/symfony/polyfill-iconv/zipball/48becf00c920479ca2e910c22a5a39e5d47ca956",
+ "reference": "48becf00c920479ca2e910c22a5a39e5d47ca956",
"shasum": ""
},
"require": {
- "php": ">=7.1"
+ "php": ">=7.2"
},
"provide": {
"ext-iconv": "*"
@@ -3502,7 +3502,7 @@
"shim"
],
"support": {
- "source": "https://github.com/symfony/polyfill-iconv/tree/v1.29.0"
+ "source": "https://github.com/symfony/polyfill-iconv/tree/v1.31.0"
},
"funding": [
{
@@ -3518,24 +3518,24 @@
"type": "tidelift"
}
],
- "time": "2024-01-29T20:11:03+00:00"
+ "time": "2024-09-09T11:45:10+00:00"
},
{
"name": "symfony/polyfill-intl-grapheme",
- "version": "v1.29.0",
+ "version": "v1.31.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-intl-grapheme.git",
- "reference": "32a9da87d7b3245e09ac426c83d334ae9f06f80f"
+ "reference": "b9123926e3b7bc2f98c02ad54f6a4b02b91a8abe"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/32a9da87d7b3245e09ac426c83d334ae9f06f80f",
- "reference": "32a9da87d7b3245e09ac426c83d334ae9f06f80f",
+ "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/b9123926e3b7bc2f98c02ad54f6a4b02b91a8abe",
+ "reference": "b9123926e3b7bc2f98c02ad54f6a4b02b91a8abe",
"shasum": ""
},
"require": {
- "php": ">=7.1"
+ "php": ">=7.2"
},
"suggest": {
"ext-intl": "For best performance"
@@ -3580,7 +3580,7 @@
"shim"
],
"support": {
- "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.29.0"
+ "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.31.0"
},
"funding": [
{
@@ -3596,26 +3596,25 @@
"type": "tidelift"
}
],
- "time": "2024-01-29T20:11:03+00:00"
+ "time": "2024-09-09T11:45:10+00:00"
},
{
"name": "symfony/polyfill-intl-idn",
- "version": "v1.29.0",
+ "version": "v1.31.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-intl-idn.git",
- "reference": "a287ed7475f85bf6f61890146edbc932c0fff919"
+ "reference": "c36586dcf89a12315939e00ec9b4474adcb1d773"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/polyfill-intl-idn/zipball/a287ed7475f85bf6f61890146edbc932c0fff919",
- "reference": "a287ed7475f85bf6f61890146edbc932c0fff919",
+ "url": "https://api.github.com/repos/symfony/polyfill-intl-idn/zipball/c36586dcf89a12315939e00ec9b4474adcb1d773",
+ "reference": "c36586dcf89a12315939e00ec9b4474adcb1d773",
"shasum": ""
},
"require": {
- "php": ">=7.1",
- "symfony/polyfill-intl-normalizer": "^1.10",
- "symfony/polyfill-php72": "^1.10"
+ "php": ">=7.2",
+ "symfony/polyfill-intl-normalizer": "^1.10"
},
"suggest": {
"ext-intl": "For best performance"
@@ -3664,7 +3663,7 @@
"shim"
],
"support": {
- "source": "https://github.com/symfony/polyfill-intl-idn/tree/v1.29.0"
+ "source": "https://github.com/symfony/polyfill-intl-idn/tree/v1.31.0"
},
"funding": [
{
@@ -3680,24 +3679,24 @@
"type": "tidelift"
}
],
- "time": "2024-01-29T20:11:03+00:00"
+ "time": "2024-09-09T11:45:10+00:00"
},
{
"name": "symfony/polyfill-intl-normalizer",
- "version": "v1.29.0",
+ "version": "v1.31.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-intl-normalizer.git",
- "reference": "bc45c394692b948b4d383a08d7753968bed9a83d"
+ "reference": "3833d7255cc303546435cb650316bff708a1c75c"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/bc45c394692b948b4d383a08d7753968bed9a83d",
- "reference": "bc45c394692b948b4d383a08d7753968bed9a83d",
+ "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/3833d7255cc303546435cb650316bff708a1c75c",
+ "reference": "3833d7255cc303546435cb650316bff708a1c75c",
"shasum": ""
},
"require": {
- "php": ">=7.1"
+ "php": ">=7.2"
},
"suggest": {
"ext-intl": "For best performance"
@@ -3745,7 +3744,7 @@
"shim"
],
"support": {
- "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.29.0"
+ "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.31.0"
},
"funding": [
{
@@ -3761,7 +3760,7 @@
"type": "tidelift"
}
],
- "time": "2024-01-29T20:11:03+00:00"
+ "time": "2024-09-09T11:45:10+00:00"
},
{
"name": "symfony/polyfill-mbstring",
@@ -3843,79 +3842,6 @@
],
"time": "2024-09-09T11:45:10+00:00"
},
- {
- "name": "symfony/polyfill-php72",
- "version": "v1.29.0",
- "source": {
- "type": "git",
- "url": "https://github.com/symfony/polyfill-php72.git",
- "reference": "861391a8da9a04cbad2d232ddd9e4893220d6e25"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/861391a8da9a04cbad2d232ddd9e4893220d6e25",
- "reference": "861391a8da9a04cbad2d232ddd9e4893220d6e25",
- "shasum": ""
- },
- "require": {
- "php": ">=7.1"
- },
- "type": "library",
- "extra": {
- "thanks": {
- "name": "symfony/polyfill",
- "url": "https://github.com/symfony/polyfill"
- }
- },
- "autoload": {
- "files": [
- "bootstrap.php"
- ],
- "psr-4": {
- "Symfony\\Polyfill\\Php72\\": ""
- }
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "Nicolas Grekas",
- "email": "p@tchwork.com"
- },
- {
- "name": "Symfony Community",
- "homepage": "https://symfony.com/contributors"
- }
- ],
- "description": "Symfony polyfill backporting some PHP 7.2+ features to lower PHP versions",
- "homepage": "https://symfony.com",
- "keywords": [
- "compatibility",
- "polyfill",
- "portable",
- "shim"
- ],
- "support": {
- "source": "https://github.com/symfony/polyfill-php72/tree/v1.29.0"
- },
- "funding": [
- {
- "url": "https://symfony.com/sponsor",
- "type": "custom"
- },
- {
- "url": "https://github.com/fabpot",
- "type": "github"
- },
- {
- "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
- "type": "tidelift"
- }
- ],
- "time": "2024-01-29T20:11:03+00:00"
- },
{
"name": "symfony/polyfill-php80",
"version": "v1.31.0",
@@ -4316,16 +4242,16 @@
},
{
"name": "symfony/string",
- "version": "v7.0.3",
+ "version": "v7.1.5",
"source": {
"type": "git",
"url": "https://github.com/symfony/string.git",
- "reference": "524aac4a280b90a4420d8d6a040718d0586505ac"
+ "reference": "d66f9c343fa894ec2037cc928381df90a7ad4306"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/string/zipball/524aac4a280b90a4420d8d6a040718d0586505ac",
- "reference": "524aac4a280b90a4420d8d6a040718d0586505ac",
+ "url": "https://api.github.com/repos/symfony/string/zipball/d66f9c343fa894ec2037cc928381df90a7ad4306",
+ "reference": "d66f9c343fa894ec2037cc928381df90a7ad4306",
"shasum": ""
},
"require": {
@@ -4339,6 +4265,7 @@
"symfony/translation-contracts": "<2.5"
},
"require-dev": {
+ "symfony/emoji": "^7.1",
"symfony/error-handler": "^6.4|^7.0",
"symfony/http-client": "^6.4|^7.0",
"symfony/intl": "^6.4|^7.0",
@@ -4382,7 +4309,7 @@
"utf8"
],
"support": {
- "source": "https://github.com/symfony/string/tree/v7.0.3"
+ "source": "https://github.com/symfony/string/tree/v7.1.5"
},
"funding": [
{
@@ -4398,7 +4325,7 @@
"type": "tidelift"
}
],
- "time": "2024-01-29T15:41:16+00:00"
+ "time": "2024-09-20T08:28:38+00:00"
},
{
"name": "symfony/var-exporter",
@@ -4806,16 +4733,16 @@
},
{
"name": "doctrine/annotations",
- "version": "1.14.3",
+ "version": "1.14.4",
"source": {
"type": "git",
"url": "https://github.com/doctrine/annotations.git",
- "reference": "fb0d71a7393298a7b232cbf4c8b1f73f3ec3d5af"
+ "reference": "253dca476f70808a5aeed3a47cc2cc88c5cab915"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/doctrine/annotations/zipball/fb0d71a7393298a7b232cbf4c8b1f73f3ec3d5af",
- "reference": "fb0d71a7393298a7b232cbf4c8b1f73f3ec3d5af",
+ "url": "https://api.github.com/repos/doctrine/annotations/zipball/253dca476f70808a5aeed3a47cc2cc88c5cab915",
+ "reference": "253dca476f70808a5aeed3a47cc2cc88c5cab915",
"shasum": ""
},
"require": {
@@ -4826,11 +4753,11 @@
},
"require-dev": {
"doctrine/cache": "^1.11 || ^2.0",
- "doctrine/coding-standard": "^9 || ^10",
- "phpstan/phpstan": "~1.4.10 || ^1.8.0",
+ "doctrine/coding-standard": "^9 || ^12",
+ "phpstan/phpstan": "~1.4.10 || ^1.10.28",
"phpunit/phpunit": "^7.5 || ^8.5 || ^9.5",
- "symfony/cache": "^4.4 || ^5.4 || ^6",
- "vimeo/psalm": "^4.10"
+ "symfony/cache": "^4.4 || ^5.4 || ^6.4 || ^7",
+ "vimeo/psalm": "^4.30 || ^5.14"
},
"suggest": {
"php": "PHP 8.0 or higher comes with attributes, a native replacement for annotations"
@@ -4876,9 +4803,9 @@
],
"support": {
"issues": "https://github.com/doctrine/annotations/issues",
- "source": "https://github.com/doctrine/annotations/tree/1.14.3"
+ "source": "https://github.com/doctrine/annotations/tree/1.14.4"
},
- "time": "2023-02-01T09:20:38+00:00"
+ "time": "2024-09-05T10:15:52+00:00"
},
{
"name": "doctrine/cache",
@@ -5361,16 +5288,16 @@
},
{
"name": "myclabs/deep-copy",
- "version": "1.11.1",
+ "version": "1.12.0",
"source": {
"type": "git",
"url": "https://github.com/myclabs/DeepCopy.git",
- "reference": "7284c22080590fb39f2ffa3e9057f10a4ddd0e0c"
+ "reference": "3a6b9a42cd8f8771bd4295d13e1423fa7f3d942c"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/7284c22080590fb39f2ffa3e9057f10a4ddd0e0c",
- "reference": "7284c22080590fb39f2ffa3e9057f10a4ddd0e0c",
+ "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/3a6b9a42cd8f8771bd4295d13e1423fa7f3d942c",
+ "reference": "3a6b9a42cd8f8771bd4295d13e1423fa7f3d942c",
"shasum": ""
},
"require": {
@@ -5378,11 +5305,12 @@
},
"conflict": {
"doctrine/collections": "<1.6.8",
- "doctrine/common": "<2.13.3 || >=3,<3.2.2"
+ "doctrine/common": "<2.13.3 || >=3 <3.2.2"
},
"require-dev": {
"doctrine/collections": "^1.6.8",
"doctrine/common": "^2.13.3 || ^3.2.2",
+ "phpspec/prophecy": "^1.10",
"phpunit/phpunit": "^7.5.20 || ^8.5.23 || ^9.5.13"
},
"type": "library",
@@ -5408,7 +5336,7 @@
],
"support": {
"issues": "https://github.com/myclabs/DeepCopy/issues",
- "source": "https://github.com/myclabs/DeepCopy/tree/1.11.1"
+ "source": "https://github.com/myclabs/DeepCopy/tree/1.12.0"
},
"funding": [
{
@@ -5416,29 +5344,29 @@
"type": "tidelift"
}
],
- "time": "2023-03-08T13:26:56+00:00"
+ "time": "2024-06-12T14:39:25+00:00"
},
{
"name": "nikic/php-parser",
- "version": "v4.18.0",
+ "version": "v4.19.4",
"source": {
"type": "git",
"url": "https://github.com/nikic/PHP-Parser.git",
- "reference": "1bcbb2179f97633e98bbbc87044ee2611c7d7999"
+ "reference": "715f4d25e225bc47b293a8b997fe6ce99bf987d2"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/1bcbb2179f97633e98bbbc87044ee2611c7d7999",
- "reference": "1bcbb2179f97633e98bbbc87044ee2611c7d7999",
+ "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/715f4d25e225bc47b293a8b997fe6ce99bf987d2",
+ "reference": "715f4d25e225bc47b293a8b997fe6ce99bf987d2",
"shasum": ""
},
"require": {
"ext-tokenizer": "*",
- "php": ">=7.0"
+ "php": ">=7.1"
},
"require-dev": {
"ircmaxell/php-yacc": "^0.0.7",
- "phpunit/phpunit": "^6.5 || ^7.0 || ^8.0 || ^9.0"
+ "phpunit/phpunit": "^7.0 || ^8.0 || ^9.0"
},
"bin": [
"bin/php-parse"
@@ -5470,26 +5398,27 @@
],
"support": {
"issues": "https://github.com/nikic/PHP-Parser/issues",
- "source": "https://github.com/nikic/PHP-Parser/tree/v4.18.0"
+ "source": "https://github.com/nikic/PHP-Parser/tree/v4.19.4"
},
- "time": "2023-12-10T21:03:43+00:00"
+ "time": "2024-09-29T15:01:53+00:00"
},
{
"name": "phar-io/manifest",
- "version": "2.0.3",
+ "version": "2.0.4",
"source": {
"type": "git",
"url": "https://github.com/phar-io/manifest.git",
- "reference": "97803eca37d319dfa7826cc2437fc020857acb53"
+ "reference": "54750ef60c58e43759730615a392c31c80e23176"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/phar-io/manifest/zipball/97803eca37d319dfa7826cc2437fc020857acb53",
- "reference": "97803eca37d319dfa7826cc2437fc020857acb53",
+ "url": "https://api.github.com/repos/phar-io/manifest/zipball/54750ef60c58e43759730615a392c31c80e23176",
+ "reference": "54750ef60c58e43759730615a392c31c80e23176",
"shasum": ""
},
"require": {
"ext-dom": "*",
+ "ext-libxml": "*",
"ext-phar": "*",
"ext-xmlwriter": "*",
"phar-io/version": "^3.0.1",
@@ -5530,9 +5459,15 @@
"description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)",
"support": {
"issues": "https://github.com/phar-io/manifest/issues",
- "source": "https://github.com/phar-io/manifest/tree/2.0.3"
+ "source": "https://github.com/phar-io/manifest/tree/2.0.4"
},
- "time": "2021-07-20T11:28:43+00:00"
+ "funding": [
+ {
+ "url": "https://github.com/theseer",
+ "type": "github"
+ }
+ ],
+ "time": "2024-03-03T12:33:53+00:00"
},
{
"name": "phar-io/version",
@@ -5587,35 +5522,35 @@
},
{
"name": "phpunit/php-code-coverage",
- "version": "9.2.30",
+ "version": "9.2.32",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-code-coverage.git",
- "reference": "ca2bd87d2f9215904682a9cb9bb37dda98e76089"
+ "reference": "85402a822d1ecf1db1096959413d35e1c37cf1a5"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/ca2bd87d2f9215904682a9cb9bb37dda98e76089",
- "reference": "ca2bd87d2f9215904682a9cb9bb37dda98e76089",
+ "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/85402a822d1ecf1db1096959413d35e1c37cf1a5",
+ "reference": "85402a822d1ecf1db1096959413d35e1c37cf1a5",
"shasum": ""
},
"require": {
"ext-dom": "*",
"ext-libxml": "*",
"ext-xmlwriter": "*",
- "nikic/php-parser": "^4.18 || ^5.0",
+ "nikic/php-parser": "^4.19.1 || ^5.1.0",
"php": ">=7.3",
- "phpunit/php-file-iterator": "^3.0.3",
- "phpunit/php-text-template": "^2.0.2",
- "sebastian/code-unit-reverse-lookup": "^2.0.2",
- "sebastian/complexity": "^2.0",
- "sebastian/environment": "^5.1.2",
- "sebastian/lines-of-code": "^1.0.3",
- "sebastian/version": "^3.0.1",
- "theseer/tokenizer": "^1.2.0"
+ "phpunit/php-file-iterator": "^3.0.6",
+ "phpunit/php-text-template": "^2.0.4",
+ "sebastian/code-unit-reverse-lookup": "^2.0.3",
+ "sebastian/complexity": "^2.0.3",
+ "sebastian/environment": "^5.1.5",
+ "sebastian/lines-of-code": "^1.0.4",
+ "sebastian/version": "^3.0.2",
+ "theseer/tokenizer": "^1.2.3"
},
"require-dev": {
- "phpunit/phpunit": "^9.3"
+ "phpunit/phpunit": "^9.6"
},
"suggest": {
"ext-pcov": "PHP extension that provides line coverage",
@@ -5624,7 +5559,7 @@
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "9.2-dev"
+ "dev-main": "9.2.x-dev"
}
},
"autoload": {
@@ -5653,7 +5588,7 @@
"support": {
"issues": "https://github.com/sebastianbergmann/php-code-coverage/issues",
"security": "https://github.com/sebastianbergmann/php-code-coverage/security/policy",
- "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.30"
+ "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.32"
},
"funding": [
{
@@ -5661,7 +5596,7 @@
"type": "github"
}
],
- "time": "2023-12-22T06:47:57+00:00"
+ "time": "2024-08-22T04:23:01+00:00"
},
{
"name": "phpunit/php-file-iterator",
@@ -5906,45 +5841,45 @@
},
{
"name": "phpunit/phpunit",
- "version": "9.6.16",
+ "version": "9.6.21",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git",
- "reference": "3767b2c56ce02d01e3491046f33466a1ae60a37f"
+ "reference": "de6abf3b6f8dd955fac3caad3af7a9504e8c2ffa"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/3767b2c56ce02d01e3491046f33466a1ae60a37f",
- "reference": "3767b2c56ce02d01e3491046f33466a1ae60a37f",
+ "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/de6abf3b6f8dd955fac3caad3af7a9504e8c2ffa",
+ "reference": "de6abf3b6f8dd955fac3caad3af7a9504e8c2ffa",
"shasum": ""
},
"require": {
- "doctrine/instantiator": "^1.3.1 || ^2",
+ "doctrine/instantiator": "^1.5.0 || ^2",
"ext-dom": "*",
"ext-json": "*",
"ext-libxml": "*",
"ext-mbstring": "*",
"ext-xml": "*",
"ext-xmlwriter": "*",
- "myclabs/deep-copy": "^1.10.1",
- "phar-io/manifest": "^2.0.3",
- "phar-io/version": "^3.0.2",
+ "myclabs/deep-copy": "^1.12.0",
+ "phar-io/manifest": "^2.0.4",
+ "phar-io/version": "^3.2.1",
"php": ">=7.3",
- "phpunit/php-code-coverage": "^9.2.28",
- "phpunit/php-file-iterator": "^3.0.5",
+ "phpunit/php-code-coverage": "^9.2.32",
+ "phpunit/php-file-iterator": "^3.0.6",
"phpunit/php-invoker": "^3.1.1",
- "phpunit/php-text-template": "^2.0.3",
- "phpunit/php-timer": "^5.0.2",
- "sebastian/cli-parser": "^1.0.1",
- "sebastian/code-unit": "^1.0.6",
+ "phpunit/php-text-template": "^2.0.4",
+ "phpunit/php-timer": "^5.0.3",
+ "sebastian/cli-parser": "^1.0.2",
+ "sebastian/code-unit": "^1.0.8",
"sebastian/comparator": "^4.0.8",
- "sebastian/diff": "^4.0.3",
- "sebastian/environment": "^5.1.3",
- "sebastian/exporter": "^4.0.5",
- "sebastian/global-state": "^5.0.1",
- "sebastian/object-enumerator": "^4.0.3",
- "sebastian/resource-operations": "^3.0.3",
- "sebastian/type": "^3.2",
+ "sebastian/diff": "^4.0.6",
+ "sebastian/environment": "^5.1.5",
+ "sebastian/exporter": "^4.0.6",
+ "sebastian/global-state": "^5.0.7",
+ "sebastian/object-enumerator": "^4.0.4",
+ "sebastian/resource-operations": "^3.0.4",
+ "sebastian/type": "^3.2.1",
"sebastian/version": "^3.0.2"
},
"suggest": {
@@ -5989,7 +5924,7 @@
"support": {
"issues": "https://github.com/sebastianbergmann/phpunit/issues",
"security": "https://github.com/sebastianbergmann/phpunit/security/policy",
- "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.16"
+ "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.21"
},
"funding": [
{
@@ -6005,20 +5940,20 @@
"type": "tidelift"
}
],
- "time": "2024-01-19T07:03:14+00:00"
+ "time": "2024-09-19T10:50:18+00:00"
},
{
"name": "sebastian/cli-parser",
- "version": "1.0.1",
+ "version": "1.0.2",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/cli-parser.git",
- "reference": "442e7c7e687e42adc03470c7b668bc4b2402c0b2"
+ "reference": "2b56bea83a09de3ac06bb18b92f068e60cc6f50b"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/cli-parser/zipball/442e7c7e687e42adc03470c7b668bc4b2402c0b2",
- "reference": "442e7c7e687e42adc03470c7b668bc4b2402c0b2",
+ "url": "https://api.github.com/repos/sebastianbergmann/cli-parser/zipball/2b56bea83a09de3ac06bb18b92f068e60cc6f50b",
+ "reference": "2b56bea83a09de3ac06bb18b92f068e60cc6f50b",
"shasum": ""
},
"require": {
@@ -6053,7 +5988,7 @@
"homepage": "https://github.com/sebastianbergmann/cli-parser",
"support": {
"issues": "https://github.com/sebastianbergmann/cli-parser/issues",
- "source": "https://github.com/sebastianbergmann/cli-parser/tree/1.0.1"
+ "source": "https://github.com/sebastianbergmann/cli-parser/tree/1.0.2"
},
"funding": [
{
@@ -6061,7 +5996,7 @@
"type": "github"
}
],
- "time": "2020-09-28T06:08:49+00:00"
+ "time": "2024-03-02T06:27:43+00:00"
},
{
"name": "sebastian/code-unit",
@@ -6307,16 +6242,16 @@
},
{
"name": "sebastian/diff",
- "version": "4.0.5",
+ "version": "4.0.6",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/diff.git",
- "reference": "74be17022044ebaaecfdf0c5cd504fc9cd5a7131"
+ "reference": "ba01945089c3a293b01ba9badc29ad55b106b0bc"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/74be17022044ebaaecfdf0c5cd504fc9cd5a7131",
- "reference": "74be17022044ebaaecfdf0c5cd504fc9cd5a7131",
+ "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/ba01945089c3a293b01ba9badc29ad55b106b0bc",
+ "reference": "ba01945089c3a293b01ba9badc29ad55b106b0bc",
"shasum": ""
},
"require": {
@@ -6361,7 +6296,7 @@
],
"support": {
"issues": "https://github.com/sebastianbergmann/diff/issues",
- "source": "https://github.com/sebastianbergmann/diff/tree/4.0.5"
+ "source": "https://github.com/sebastianbergmann/diff/tree/4.0.6"
},
"funding": [
{
@@ -6369,7 +6304,7 @@
"type": "github"
}
],
- "time": "2023-05-07T05:35:17+00:00"
+ "time": "2024-03-02T06:30:58+00:00"
},
{
"name": "sebastian/environment",
@@ -6436,16 +6371,16 @@
},
{
"name": "sebastian/exporter",
- "version": "4.0.5",
+ "version": "4.0.6",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/exporter.git",
- "reference": "ac230ed27f0f98f597c8a2b6eb7ac563af5e5b9d"
+ "reference": "78c00df8f170e02473b682df15bfcdacc3d32d72"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/ac230ed27f0f98f597c8a2b6eb7ac563af5e5b9d",
- "reference": "ac230ed27f0f98f597c8a2b6eb7ac563af5e5b9d",
+ "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/78c00df8f170e02473b682df15bfcdacc3d32d72",
+ "reference": "78c00df8f170e02473b682df15bfcdacc3d32d72",
"shasum": ""
},
"require": {
@@ -6501,7 +6436,7 @@
],
"support": {
"issues": "https://github.com/sebastianbergmann/exporter/issues",
- "source": "https://github.com/sebastianbergmann/exporter/tree/4.0.5"
+ "source": "https://github.com/sebastianbergmann/exporter/tree/4.0.6"
},
"funding": [
{
@@ -6509,20 +6444,20 @@
"type": "github"
}
],
- "time": "2022-09-14T06:03:37+00:00"
+ "time": "2024-03-02T06:33:00+00:00"
},
{
"name": "sebastian/global-state",
- "version": "5.0.6",
+ "version": "5.0.7",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/global-state.git",
- "reference": "bde739e7565280bda77be70044ac1047bc007e34"
+ "reference": "bca7df1f32ee6fe93b4d4a9abbf69e13a4ada2c9"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/bde739e7565280bda77be70044ac1047bc007e34",
- "reference": "bde739e7565280bda77be70044ac1047bc007e34",
+ "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/bca7df1f32ee6fe93b4d4a9abbf69e13a4ada2c9",
+ "reference": "bca7df1f32ee6fe93b4d4a9abbf69e13a4ada2c9",
"shasum": ""
},
"require": {
@@ -6565,7 +6500,7 @@
],
"support": {
"issues": "https://github.com/sebastianbergmann/global-state/issues",
- "source": "https://github.com/sebastianbergmann/global-state/tree/5.0.6"
+ "source": "https://github.com/sebastianbergmann/global-state/tree/5.0.7"
},
"funding": [
{
@@ -6573,7 +6508,7 @@
"type": "github"
}
],
- "time": "2023-08-02T09:26:13+00:00"
+ "time": "2024-03-02T06:35:11+00:00"
},
{
"name": "sebastian/lines-of-code",
@@ -6809,16 +6744,16 @@
},
{
"name": "sebastian/resource-operations",
- "version": "3.0.3",
+ "version": "3.0.4",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/resource-operations.git",
- "reference": "0f4443cb3a1d92ce809899753bc0d5d5a8dd19a8"
+ "reference": "05d5692a7993ecccd56a03e40cd7e5b09b1d404e"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/0f4443cb3a1d92ce809899753bc0d5d5a8dd19a8",
- "reference": "0f4443cb3a1d92ce809899753bc0d5d5a8dd19a8",
+ "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/05d5692a7993ecccd56a03e40cd7e5b09b1d404e",
+ "reference": "05d5692a7993ecccd56a03e40cd7e5b09b1d404e",
"shasum": ""
},
"require": {
@@ -6830,7 +6765,7 @@
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "3.0-dev"
+ "dev-main": "3.0-dev"
}
},
"autoload": {
@@ -6851,8 +6786,7 @@
"description": "Provides a list of PHP built-in functions that operate on resources",
"homepage": "https://www.github.com/sebastianbergmann/resource-operations",
"support": {
- "issues": "https://github.com/sebastianbergmann/resource-operations/issues",
- "source": "https://github.com/sebastianbergmann/resource-operations/tree/3.0.3"
+ "source": "https://github.com/sebastianbergmann/resource-operations/tree/3.0.4"
},
"funding": [
{
@@ -6860,7 +6794,7 @@
"type": "github"
}
],
- "time": "2020-09-28T06:45:17+00:00"
+ "time": "2024-03-14T16:00:52+00:00"
},
{
"name": "sebastian/type",
@@ -6973,16 +6907,16 @@
},
{
"name": "squizlabs/php_codesniffer",
- "version": "3.10.2",
+ "version": "3.10.3",
"source": {
"type": "git",
"url": "https://github.com/PHPCSStandards/PHP_CodeSniffer.git",
- "reference": "86e5f5dd9a840c46810ebe5ff1885581c42a3017"
+ "reference": "62d32998e820bddc40f99f8251958aed187a5c9c"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/86e5f5dd9a840c46810ebe5ff1885581c42a3017",
- "reference": "86e5f5dd9a840c46810ebe5ff1885581c42a3017",
+ "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/62d32998e820bddc40f99f8251958aed187a5c9c",
+ "reference": "62d32998e820bddc40f99f8251958aed187a5c9c",
"shasum": ""
},
"require": {
@@ -7049,7 +6983,7 @@
"type": "open_collective"
}
],
- "time": "2024-07-21T23:26:44+00:00"
+ "time": "2024-09-18T10:38:58+00:00"
},
{
"name": "symfony/finder",
@@ -7115,16 +7049,16 @@
},
{
"name": "theseer/tokenizer",
- "version": "1.2.2",
+ "version": "1.2.3",
"source": {
"type": "git",
"url": "https://github.com/theseer/tokenizer.git",
- "reference": "b2ad5003ca10d4ee50a12da31de12a5774ba6b96"
+ "reference": "737eda637ed5e28c3413cb1ebe8bb52cbf1ca7a2"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/theseer/tokenizer/zipball/b2ad5003ca10d4ee50a12da31de12a5774ba6b96",
- "reference": "b2ad5003ca10d4ee50a12da31de12a5774ba6b96",
+ "url": "https://api.github.com/repos/theseer/tokenizer/zipball/737eda637ed5e28c3413cb1ebe8bb52cbf1ca7a2",
+ "reference": "737eda637ed5e28c3413cb1ebe8bb52cbf1ca7a2",
"shasum": ""
},
"require": {
@@ -7153,7 +7087,7 @@
"description": "A small library for converting tokenized PHP source code into XML and potentially other formats",
"support": {
"issues": "https://github.com/theseer/tokenizer/issues",
- "source": "https://github.com/theseer/tokenizer/tree/1.2.2"
+ "source": "https://github.com/theseer/tokenizer/tree/1.2.3"
},
"funding": [
{
@@ -7161,7 +7095,7 @@
"type": "github"
}
],
- "time": "2023-11-20T00:12:19+00:00"
+ "time": "2024-03-03T12:36:25+00:00"
}
],
"aliases": [],
From 7f883fc4487e928143530b062835fc93e6fbd72c Mon Sep 17 00:00:00 2001
From: ipranjal
Date: Wed, 16 Oct 2024 16:57:58 +0530
Subject: [PATCH 16/17] chore: fixing hook and removing toro dep
---
Idno/Core/PageHandler.php | 2 +-
Idno/Pages/Admin/Diagnostics.php | 2 +-
composer.json | 1 -
composer.lock | 80 +-------------------------------
4 files changed, 3 insertions(+), 82 deletions(-)
diff --git a/Idno/Core/PageHandler.php b/Idno/Core/PageHandler.php
index 9947326bca..8eea6b6158 100644
--- a/Idno/Core/PageHandler.php
+++ b/Idno/Core/PageHandler.php
@@ -239,7 +239,7 @@ function getRoute(string $path_info)
*/
static function hook(string $hookName, callable $callable)
{
- \ToroHook::add($hookName, $callable);
+ Hook::add($hookName, $callable);
}
// ArrayAccess & Iterator interfaces ////////
diff --git a/Idno/Pages/Admin/Diagnostics.php b/Idno/Pages/Admin/Diagnostics.php
index 42aa04e8c9..1c7ad5c7ca 100644
--- a/Idno/Pages/Admin/Diagnostics.php
+++ b/Idno/Pages/Admin/Diagnostics.php
@@ -43,7 +43,7 @@ function getContent()
$config->config['smtp_password'] = '** REDACTED **';
$report .= "\nRunning config:\n---------------\n" . var_export($config, true) . "\n\n";
- $report .= "\$_SESSION:\n----------\n" . var_export($_SESSION, true) . "\n\n";
+ $report .= "\$SESSION:\n----------\n" . var_export(\Idno\Core\Idno::site()->session()->all(), true) . "\n\n";
$report .= "\SERVER:\n---------\n" . var_export(\Idno\Core\Idno::site()->request()->server->all(), true) . "\n\n";
// Hook so other plugins and subsystems can add their own data to the report.
diff --git a/composer.json b/composer.json
index 313c24a890..7a22d089d2 100644
--- a/composer.json
+++ b/composer.json
@@ -27,7 +27,6 @@
"ext-gettext": "*",
"mapkyca/php-ogp": "^1.0",
"psr/log": "~3.0",
- "idno/torophp": "^3.0",
"mf2/mf2": "0.5.0",
"swiftmailer/swiftmailer": "6.3.0",
"forkawesome/fork-awesome": "1.2",
diff --git a/composer.lock b/composer.lock
index 566b6d448d..21abc0544f 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "f09bd73f823e88c17485ff0e9c20e5b2",
+ "content-hash": "f2feb77e48ec0562918476b390507d14",
"packages": [
{
"name": "brick/math",
@@ -969,84 +969,6 @@
},
"time": "2019-11-03T12:53:56+00:00"
},
- {
- "name": "idno/torophp",
- "version": "3.0.0",
- "source": {
- "type": "git",
- "url": "https://github.com/idno/torophp.git",
- "reference": "a98c653f37b2c074140c5296ef9740e0d39a176f"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/idno/torophp/zipball/a98c653f37b2c074140c5296ef9740e0d39a176f",
- "reference": "a98c653f37b2c074140c5296ef9740e0d39a176f",
- "shasum": ""
- },
- "require": {
- "php": ">=5.3.0"
- },
- "type": "library",
- "autoload": {
- "files": [
- "src/Toro.php"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "Kunal Anand",
- "email": "kunal.r.anand@gmail.com",
- "homepage": "http://kunalanand.com/",
- "role": "Developer"
- },
- {
- "name": "Danillo César de O. Melo",
- "email": "danillos@gmail.com",
- "homepage": "http://www.danillocesar.com.br/",
- "role": "Contributor"
- },
- {
- "name": "Martin Bean",
- "email": "martin@martinbean.co.uk",
- "homepage": "http://www.martinbean.co.uk",
- "role": "Developer"
- },
- {
- "name": "Robbie Coleman",
- "homepage": "http://robbie.robnrob.com",
- "role": "Contributor"
- },
- {
- "name": "John Kurkowski",
- "role": "Contributor"
- },
- {
- "name": "Berker Peksag",
- "homepage": "http://berkerpeksag.com",
- "role": "Developer"
- },
- {
- "name": "Jason Mooberry",
- "homepage": "http://jasonmooberry.com/",
- "role": "Developer"
- }
- ],
- "description": "Known adoption of Toro, a PHP router for developing RESTful web applications and APIs.",
- "homepage": "http://github.com/anandkunal/ToroPHP",
- "keywords": [
- "framework",
- "php",
- "router"
- ],
- "support": {
- "source": "https://github.com/idno/torophp/tree/3.0.0"
- },
- "time": "2019-11-03T12:27:44+00:00"
- },
{
"name": "indieweb/mention-client",
"version": "1.2.1",
From 13c95d09af9d2b087ac5ae14575032a2e80a3964 Mon Sep 17 00:00:00 2001
From: ipranjal
Date: Wed, 16 Oct 2024 17:09:11 +0530
Subject: [PATCH 17/17] tests: revert unwanted changes to test
---
Tests/_bootstrap.php | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/Tests/_bootstrap.php b/Tests/_bootstrap.php
index 3e59f3221b..3479a8f02b 100644
--- a/Tests/_bootstrap.php
+++ b/Tests/_bootstrap.php
@@ -16,24 +16,24 @@
// Set some environment: Use export KNOWN_DOMAIN / KNOWN_PORT to override from the command line
$domain = 'localhost';
-if (\Idno\Core\Idno::site()->request()->server->has('KNOWN_DOMAIN')) {
- $domain = \Idno\Core\Idno::site()->request()->server->get('KNOWN_DOMAIN');
+if (isset($_SERVER['KNOWN_DOMAIN'])) {
+ $domain = $_SERVER['KNOWN_DOMAIN'];
}
-if (!$domain && \Idno\Core\Idno::site()->request()->server->has('SERVER_NAME')) {
- $domain = \Idno\Core\Idno::site()->request()->server->get('SERVER_NAME');
+if (!$domain && isset($_SERVER['SERVER_NAME'])) {
+ $domain = $_SERVER['SERVER_NAME'];
}
-\Idno\Core\Idno::site()->request()->server->set('SERVER_NAME', $domain);
+$_SERVER['SERVER_NAME'] = $domain;
$port = getenv('KNOWN_PORT');
-if (!$port && \Idno\Core\Idno::site()->request()->server->has('SERVER_PORT')) {
- $port =\Idno\Core\Idno::site()->request()->server->get('SERVER_PORT');
+if (!$port && isset($_SERVER['SERVER_PORT'])) {
+ $port = $_SERVER['SERVER_PORT'];
}
if (!$port) {
$port = 80;
}
-\Idno\Core\Idno::site()->request()->server->set('SERVER_PORT', $port);
+$_SERVER['SERVER_PORT'] = $port;
try {
// Load Known framework
@@ -41,4 +41,4 @@
} catch (Exception $ex) {
echo $ex->getMessage();
-}
+}
\ No newline at end of file