aboutsummaryrefslogtreecommitdiff
path: root/p
diff options
context:
space:
mode:
authorGravatar Alexis Degrugillier <aledeg@users.noreply.github.com> 2025-09-05 09:56:46 -0400
committerGravatar GitHub <noreply@github.com> 2025-09-05 15:56:46 +0200
commit23ba48c71f0d41bbe012d668349f6516dad527b4 (patch)
treeb5680e834c2b87becdded07e0555227ade9d7629 /p
parent3d85eb19380021031e9d1193919ba516bbc99573 (diff)
Change how files are included (#7916)
1. `include`, `include_once`, `require` and `require_once` are expressions not functions, parentheses are not necessary. 2. to move up the directory tree, it's better to use the `dirname` function instead of relying on `/..`.
Diffstat (limited to 'p')
-rw-r--r--p/api/fever.php6
-rw-r--r--p/api/greader.php4
-rw-r--r--p/api/index.php4
-rw-r--r--p/api/misc.php4
-rw-r--r--p/api/pshb.php4
-rw-r--r--p/api/query.php6
-rw-r--r--p/ext.php6
-rw-r--r--p/f.php8
-rw-r--r--p/i/index.php8
-rw-r--r--p/index.php4
10 files changed, 27 insertions, 27 deletions
diff --git a/p/api/fever.php b/p/api/fever.php
index 92ddb82b8..01e6d7b61 100644
--- a/p/api/fever.php
+++ b/p/api/fever.php
@@ -16,8 +16,8 @@ header('X-Content-Type-Options: nosniff');
// ================================================================================================
// BOOTSTRAP FreshRSS
-require(__DIR__ . '/../../constants.php');
-require(LIB_PATH . '/lib_rss.php'); //Includes class autoloader
+require dirname(__DIR__, 2) . '/constants.php';
+require LIB_PATH . '/lib_rss.php'; //Includes class autoloader
FreshRSS_Context::initSystem();
// check if API is enabled globally
@@ -355,7 +355,7 @@ final class FeverAPI
return [];
}
- require_once(LIB_PATH . '/favicons.php');
+ require_once LIB_PATH . '/favicons.php';
$favicons = [];
$salt = FreshRSS_Context::systemConf()->salt;
diff --git a/p/api/greader.php b/p/api/greader.php
index 40fb5dc72..88afb3656 100644
--- a/p/api/greader.php
+++ b/p/api/greader.php
@@ -25,8 +25,8 @@ Server-side API compatible with Google Reader API layer 2
* https://github.com/bazqux/bazqux-api
*/
-require(__DIR__ . '/../../constants.php');
-require(LIB_PATH . '/lib_rss.php'); //Includes class autoloader
+require dirname(__DIR__, 2) . '/constants.php';
+require LIB_PATH . '/lib_rss.php'; //Includes class autoloader
header("Content-Security-Policy: default-src 'none'; frame-ancestors 'none'; sandbox");
header('X-Content-Type-Options: nosniff');
diff --git a/p/api/index.php b/p/api/index.php
index def8d4890..1db1273dc 100644
--- a/p/api/index.php
+++ b/p/api/index.php
@@ -13,8 +13,8 @@
<script src="../scripts/api.js" defer="defer"></script>
<script id="jsonVars" type="application/json">
<?php
-require(__DIR__ . '/../../constants.php');
-require(LIB_PATH . '/lib_rss.php'); //Includes class autoloader
+require dirname(__DIR__, 2) . '/constants.php';
+require LIB_PATH . '/lib_rss.php'; //Includes class autoloader
FreshRSS_Context::initSystem();
echo json_encode([
'greader' => Minz_Url::display('/api/greader.php', 'php', true),
diff --git a/p/api/misc.php b/p/api/misc.php
index 7724caa7a..fe75b5be7 100644
--- a/p/api/misc.php
+++ b/p/api/misc.php
@@ -5,8 +5,8 @@ declare(strict_types=1);
* `/api/misc.php/Extension%20name/` or `/api/misc.php?ext=Extension%20name`
*/
-require(__DIR__ . '/../../constants.php');
-require(LIB_PATH . '/lib_rss.php'); //Includes class autoloader
+require dirname(__DIR__, 2) . '/constants.php';
+require LIB_PATH . '/lib_rss.php'; //Includes class autoloader
function badRequest(): never {
header('HTTP/1.1 400 Bad Request');
diff --git a/p/api/pshb.php b/p/api/pshb.php
index b6cbc5089..37b3fe056 100644
--- a/p/api/pshb.php
+++ b/p/api/pshb.php
@@ -1,7 +1,7 @@
<?php
declare(strict_types=1);
-require(__DIR__ . '/../../constants.php');
-require(LIB_PATH . '/lib_rss.php'); //Includes class autoloader
+require dirname(__DIR__, 2) . '/constants.php';
+require LIB_PATH . '/lib_rss.php'; //Includes class autoloader
const MAX_PAYLOAD = 3_145_728;
diff --git a/p/api/query.php b/p/api/query.php
index 5d8fb3dec..8aedd8ecf 100644
--- a/p/api/query.php
+++ b/p/api/query.php
@@ -3,8 +3,8 @@ declare(strict_types=1);
header('X-Content-Type-Options: nosniff');
-require(__DIR__ . '/../../constants.php');
-require(LIB_PATH . '/lib_rss.php'); //Includes class autoloader
+require dirname(__DIR__, 2) . '/constants.php';
+require LIB_PATH . '/lib_rss.php'; //Includes class autoloader
Minz_Request::init();
@@ -48,7 +48,7 @@ if (!FreshRSS_Context::hasUserConf() || !FreshRSS_Context::userConf()->enabled)
usleep(rand(20, 200));
}
-require(LIB_PATH . '/http-conditional.php');
+require LIB_PATH . '/http-conditional.php';
$dateLastModification = max(
FreshRSS_UserDAO::ctime($user),
FreshRSS_UserDAO::mtime($user),
diff --git a/p/ext.php b/p/ext.php
index 6642ff2d1..71922ac01 100644
--- a/p/ext.php
+++ b/p/ext.php
@@ -1,7 +1,7 @@
<?php
declare(strict_types=1);
-require(__DIR__ . '/../constants.php');
-require(LIB_PATH . '/lib_rss.php'); //Includes class autoloader
+require dirname(__DIR__) . '/constants.php';
+require LIB_PATH . '/lib_rss.php'; //Includes class autoloader
function get_absolute_filename(string $file_name): string {
$core_extension = realpath(CORE_EXTENSIONS_PATH . '/' . $file_name);
@@ -103,7 +103,7 @@ if ($mtime === false) {
sendNotFoundResponse();
}
-require(LIB_PATH . '/http-conditional.php');
+require LIB_PATH . '/http-conditional.php';
if (file_exists(DATA_PATH . '/no-cache.txt') || !httpConditional($mtime, 604800, 2)) {
readfile($absolute_filename);
diff --git a/p/f.php b/p/f.php
index 0238e5846..5b7b7474b 100644
--- a/p/f.php
+++ b/p/f.php
@@ -1,9 +1,9 @@
<?php
declare(strict_types=1);
-require(__DIR__ . '/../constants.php');
-require(LIB_PATH . '/lib_rss.php'); //Includes class autoloader
-require(LIB_PATH . '/favicons.php');
-require(LIB_PATH . '/http-conditional.php');
+require dirname(__DIR__) . '/constants.php';
+require LIB_PATH . '/lib_rss.php'; //Includes class autoloader
+require LIB_PATH . '/favicons.php';
+require LIB_PATH . '/http-conditional.php';
header("Content-Security-Policy: default-src 'none'; frame-ancestors 'none'; sandbox");
header('X-Content-Type-Options: nosniff');
diff --git a/p/i/index.php b/p/i/index.php
index 55846b952..10407e2c1 100644
--- a/p/i/index.php
+++ b/p/i/index.php
@@ -22,20 +22,20 @@ declare(strict_types=1);
#
# ***** END LICENSE BLOCK *****
-require(__DIR__ . '/../../constants.php');
-require(LIB_PATH . '/lib_rss.php'); //Includes class autoloader
+require dirname(__DIR__, 2) . '/constants.php';
+require LIB_PATH . '/lib_rss.php'; //Includes class autoloader
$migrations_path = APP_PATH . '/migrations';
$applied_migrations_path = DATA_PATH . '/applied_migrations.txt';
if (!file_exists($applied_migrations_path)) {
- require(APP_PATH . '/install.php');
+ require APP_PATH . '/install.php';
} else {
session_cache_limiter('');
Minz_Session::init('FreshRSS');
Minz_Session::_param('keepAlive', 1); //To prevent the PHP session from expiring
- require(LIB_PATH . '/http-conditional.php');
+ require LIB_PATH . '/http-conditional.php';
$currentUser = Minz_User::name();
$dateLastModification = $currentUser === null ? time() : max(
FreshRSS_UserDAO::ctime($currentUser),
diff --git a/p/index.php b/p/index.php
index 76c43fb59..4a1f385e8 100644
--- a/p/index.php
+++ b/p/index.php
@@ -1,7 +1,7 @@
<?php
declare(strict_types=1);
-require(__DIR__ . '/../constants.php');
-require(LIB_PATH . '/lib_rss.php'); //Includes class autoloader
+require dirname(__DIR__) . '/constants.php';
+require LIB_PATH . '/lib_rss.php'; //Includes class autoloader
FreshRSS_Context::initSystem();
Minz_Request::forward(['c' => 'index', 'a' => 'index'], true);