diff --git a/cron.php b/cron.php index ad6dd77..467b11d 100644 --- a/cron.php +++ b/cron.php @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -require_once("config.php"); -require_once("mail_templates.php"); -require_once("database.php"); +require_once(__DIR__ . "/config.php"); +require_once(__DIR__ . "/mail_templates.php"); +require_once(__DIR__ . "/database.php"); $sql = "SELECT id, first_name, last_name, username, email, state, note, verify_token, admin_token FROM registrations " . "WHERE state = " . RegisterState::PendingEmailSend @@ -46,7 +46,7 @@ foreach ($mx_db->query($sql) as $row) { } break; case RegisterState::PendingAdminSend: - require_once("MatrixConnection.php"); + require_once(__DIR__ . "/MatrixConnection.php"); $adminUrl = $config["webroot"] . "/verify_admin.php?t=" . $row["admin_token"]; $mxConn = new MatrixConnection($config["homeserver"], $config["access_token"]); $mxMsg = new MatrixMessage(); diff --git a/database.php b/database.php index fef634c..6c0c689 100644 --- a/database.php +++ b/database.php @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -require_once("config.php"); +require_once(__DIR__ . "/config.php"); if (!isset($config["databaseURI"])) { throw new Exception("malformed configuration: databaseURI not defined"); } diff --git a/internal/directory_search.php b/internal/directory_search.php index 2149a82..2620b32 100644 --- a/internal/directory_search.php +++ b/internal/directory_search.php @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -require_once("../database.php"); +require_once(__DIR__ . "/../database.php"); $response = [ "limited" => false, "result" => [], diff --git a/internal/identity_bulk.php b/internal/identity_bulk.php index 8c87e12..0255528 100644 --- a/internal/identity_bulk.php +++ b/internal/identity_bulk.php @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -require_once("../database.php"); +require_once(__DIR__ . "/../database.php"); $response = [ "lookup" => [] ]; diff --git a/internal/identity_single.php b/internal/identity_single.php index fde3dd8..96c816a 100644 --- a/internal/identity_single.php +++ b/internal/identity_single.php @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -require_once("../database.php"); +require_once(__DIR__ . "/../database.php"); $response = new stdClass; try { $inputJSON = file_get_contents('php://input'); diff --git a/internal/intercept_change_password.php b/internal/intercept_change_password.php index 4b937e4..0d03811 100644 --- a/internal/intercept_change_password.php +++ b/internal/intercept_change_password.php @@ -44,14 +44,14 @@ try { throw new Exception('"new_password" is not defined'); } - require_once("../helpers.php"); + require_once(__DIR__ . "/../helpers.php"); $localpart = stripLocalpart($input["auth"]["user"]); if (empty($localpart)) { throw new Exception("localpart cannot be identified"); } - require_once("../database.php"); + require_once(__DIR__ . "/../database.php"); if (!$mx_db->updatePassword( $localpart, $input["auth"]["password"], $input["new_password"] )) { diff --git a/internal/login.php b/internal/login.php index 9f44dbe..72380ea 100644 --- a/internal/login.php +++ b/internal/login.php @@ -20,7 +20,7 @@ $response = [ ] ]; -require_once("../database.php"); +require_once(__DIR__ . "/../database.php"); abstract class LoginRequester { @@ -56,7 +56,7 @@ try { // prefer the localpart attribute of mxisd. But in case of matrix-synapse-rest-auth // we have to parse it on our own if (empty($localpart)) { - require_once("../helpers.php"); + require_once(__DIR__ . "/../helpers.php"); $localpart = stripLocalpart($mxid); } diff --git a/lang/mail.de-de.php b/lang/mail.de-de.php index 3201f39..42eaaec 100644 --- a/lang/mail.de-de.php +++ b/lang/mail.de-de.php @@ -14,7 +14,7 @@ * limitations under the License. */ function send_mail($receiver, $subject, $body) { - include("../config.php"); + include(__DIR__ . "/../config.php"); $headers = "From: " . $config["register_email"] . "\r\n" . "Content-Type: text/plain;charset=utf-8"; return mail($receiver, $subject, $body, $headers); diff --git a/lang/mail.en-gb.php b/lang/mail.en-gb.php index f156b7c..b77a285 100644 --- a/lang/mail.en-gb.php +++ b/lang/mail.en-gb.php @@ -14,7 +14,7 @@ * limitations under the License. */ function send_mail($receiver, $subject, $body) { - include("../config.php"); + include(__DIR__ . "/../config.php"); $headers = "From: " . $config["register_email"] . "\r\n" . "Content-Type: text/plain;charset=utf-8"; return mail($receiver, $subject, $body, $headers); diff --git a/language.php b/language.php index 14fe117..f927350 100644 --- a/language.php +++ b/language.php @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -require_once("config.php"); +require_once(__DIR__ . "/config.php"); $lang = $config["defaultLanguage"]; if (isset($_GET['lang'])) { @@ -25,7 +25,7 @@ if (!file_exists($lang_file)) { error_log("Translation for " . $lang . " not found. Fallback to 'de-de'"); $lang = "de-de"; } -$lang_file = dirname(__FILE__) . "/lang/lang." . $lang . ".php"; +$lang_file = __DIR__ . "/lang/lang." . $lang . ".php"; require_once($lang_file); unset($lang_file); ?> diff --git a/mail_templates.php b/mail_templates.php index 3d62e3c..3383ea0 100644 --- a/mail_templates.php +++ b/mail_templates.php @@ -14,17 +14,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -require_once("config.php"); +require_once(__DIR__ . "/config.php"); $lang = $config["defaultLanguage"]; if (isset($_GET['lang'])) { $lang = filter_var($_GET['lang'], FILTER_SANITIZE_STRING); } -$lang_file = dirname(__FILE__) . "/lang/mail." . $lang . ".php"; +$lang_file = __DIR__ . "/lang/mail." . $lang . ".php"; if (!file_exists($lang_file)) { error_log("Mail templates for '" . $lang . "' not found. Fallback to 'de-de'"); $lang = "de-de"; } -$lang_file = dirname(__FILE__) . "/lang/mail." . $lang . ".php"; +$lang_file = __DIR__ . "/lang/mail." . $lang . ".php"; require_once($lang_file); unset($lang_file); ?> diff --git a/public/index.php b/public/index.php index df9db26..32b5d5d 100644 --- a/public/index.php +++ b/public/index.php @@ -19,12 +19,12 @@ if (!isset($_SERVER['HTTPS'])) { exit(); } -require_once "../language.php"; +require_once(__DIR__ . "/../language.php"); if (!file_exists("../config.php")) { print($language["NO_CONFIGURATION"]); exit(); } -require_once "../config.php"; +require_once(__DIR__ . "/../config.php"); // this values will not be used when using the register operation type $storeFirstLastName = false; @@ -86,7 +86,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") { $note = filter_var($_POST["note"], FILTER_SANITIZE_STRING); $email = filter_var($_POST["email"], FILTER_VALIDATE_EMAIL); - require_once("../database.php"); + require_once(__DIR__ . "/../database.php"); $res = $mx_db->addRegistration($first_name, $last_name, $username, $note, $email); if (!isset($res["verify_token"])) { @@ -96,7 +96,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") { $verify_token = $res["verify_token"]; $verify_url = $config["webroot"] . "/verify.php?t=" . $verify_token; - require_once "../mail_templates.php"; + require_once(__DIR__ . "/../mail_templates.php"); $success = send_mail_pending_verification( $config["homeserver"], $storeFirstLastName ? $first_name . " " . $last_name : $username, $email, $verify_url); @@ -246,4 +246,4 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") { - \ No newline at end of file + diff --git a/public/verify.php b/public/verify.php index 35b9af0..a383b97 100644 --- a/public/verify.php +++ b/public/verify.php @@ -13,13 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -require_once "../language.php"; +require_once(__DIR__ . "/../language.php"); if (!file_exists("../config.php")) { print($language["NO_CONFIGURATION"]); exit(); } -require_once "../config.php"; -require_once "../mail_templates.php"; +require_once(__DIR__ . "/../config.php"); +require_once(__DIR__ . "/../mail_templates.php"); // enforce admin via https if (!isset($_SERVER['HTTPS'])) { @@ -38,7 +38,7 @@ try { } $token = filter_var($_GET["t"], FILTER_SANITIZE_STRING); - require_once("../database.php"); + require_once(__DIR__ . "/../database.php"); $user = $mx_db->getUserForVerify($token); if ($user == NULL) { @@ -51,7 +51,7 @@ try { $email = $user["email"]; $admin_token = $user["admin_token"]; - require_once("../MatrixConnection.php"); + require_once(__DIR__ . "/../MatrixConnection.php"); $adminUrl = $config["webroot"] . "/verify_admin.php?t=" . $admin_token; $mxConn = new MatrixConnection($config["homeserver"], $config["access_token"]); $mxMsg = new MatrixMessage(); diff --git a/public/verify_admin.php b/public/verify_admin.php index 9e98375..0b7a890 100644 --- a/public/verify_admin.php +++ b/public/verify_admin.php @@ -13,13 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -require_once "../language.php"; +require_once(__DIR__ . "/../language.php"); if (!file_exists("../config.php")) { print($language["NO_CONFIGURATION"]); exit(); } -require_once "../config.php"; -require_once "../mail_templates.php"; +require_once(__DIR__ . "/../config.php"); +require_once(__DIR__ . "/../mail_templates.php"); // enforce admin via https if (!isset($_SERVER['HTTPS'])) { @@ -38,7 +38,7 @@ try { } $token = filter_var($_GET["t"], FILTER_SANITIZE_STRING); - require_once("../database.php"); + require_once(__DIR__ . "/../database.php"); $action = NULL; if (isset($_GET["allow"])) { @@ -67,7 +67,7 @@ try { $mx_db->setRegistrationStateAdmin(RegisterState::PendingRegistration, $token); // register user - require_once("../MatrixConnection.php"); + require_once(__DIR__ . "/../MatrixConnection.php"); $mxConn = new MatrixConnection($config["homeserver"], $config["access_token"]); $password = NULL; @@ -205,5 +205,5 @@ try { print("" . $language["JUMP_TO_HOMEPAGE"] . ""); } ?> - < /body> - + +