-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Ahmad Gneady
committed
Mar 3, 2022
1 parent
d1a8ab5
commit 9f02967
Showing
126 changed files
with
4,269 additions
and
2,565 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
<?php | ||
$currDir = dirname(__FILE__); | ||
require("{$currDir}/incCommon.php"); | ||
require(__DIR__ . '/incCommon.php'); | ||
|
||
if(!getLoggedAdmin()) exit; | ||
|
||
$status = $_REQUEST['status']; | ||
if(!csrf_token(true)) exit; | ||
|
||
$status = Request::val('status'); | ||
if($status == 'on') maintenance_mode(true); | ||
if($status == 'off') maintenance_mode(false); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
/* | ||
Manage stored SQL queries for admin user. | ||
Parameters: | ||
queries: (optional) a json string [{name, query}, ..]) to store. | ||
Response: | ||
stored queries (as a json string). | ||
queries are stored in the membership_users.data field for the current user, under the key 'storedQueries' | ||
*/ | ||
|
||
require(__DIR__ . '/incCommon.php'); | ||
|
||
if(!csrf_token(true)) { | ||
@header('HTTP/1.0 403 Access Denied'); | ||
die(); | ||
} | ||
|
||
// store queries if provided | ||
$queries = Request::val('queries', null); | ||
if($queries !== null) | ||
setUserData('storedQueries', $queries); | ||
|
||
echo getUserData('storedQueries'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
require(__DIR__ . '/incCommon.php'); | ||
|
||
if(!csrf_token(true)) { | ||
@header('HTTP/1.0 403 Access Denied'); | ||
die(); | ||
} | ||
|
||
$sql = trim(Request::val('sql')); | ||
if(!preg_match('/^SELECT\s+.*?\s+FROM\s+\S+/i', $sql)) { | ||
@header('HTTP/1.0 404 Not Found'); | ||
die("Invalid query"); | ||
} | ||
|
||
// force a limit of 1000 in case no limit specified | ||
if(!preg_match('/\s+limit\s+\d+(\s*,\s*\d+)?/i', $sql)) | ||
$sql .= ' LIMIT 1000'; | ||
|
||
$resp = ['titles' => [], 'data' => [], 'error' => '']; | ||
$eo = ['silentErrors' => true]; | ||
|
||
$res = sql($sql, $eo); | ||
if(!$res) | ||
$resp['error'] = $eo['error']; | ||
else while($row = db_fetch_assoc($res)) { | ||
if(!count($resp['titles'])) | ||
$resp['titles'] = array_keys($row); | ||
|
||
$resp['data'][] = array_map('htmlspecialchars', array_values($row)); | ||
} | ||
|
||
@header('Content-type: application/json'); | ||
echo json_encode($resp, JSON_PARTIAL_OUTPUT_ON_ERROR); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,7 @@ | ||
<?php | ||
$currDir = dirname(__FILE__); | ||
require("{$currDir}/incCommon.php"); | ||
require(__DIR__ . '/incCommon.php'); | ||
|
||
$GLOBALS['page_title'] = $Translation['app documentation']; | ||
include("{$currDir}/incHeader.php"); | ||
|
||
$app_title = 'OIM'; | ||
include(__DIR__ . '/incHeader.php'); | ||
|
||
include("{$currDir}/incFooter.php"); | ||
include(__DIR__ . '/incFooter.php'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,24 @@ | ||
<?php | ||
error_reporting(E_ERROR /*| E_WARNING*/ | E_PARSE); | ||
|
||
// incCommon.php is included only in the admin area, so if this flag is defined, this indicates we're in admin area | ||
define('ADMIN_AREA', true); | ||
|
||
if(!defined('datalist_db_encoding')) define('datalist_db_encoding', 'UTF-8'); | ||
ob_start(); | ||
$currDir = dirname(__FILE__); | ||
include_once("{$currDir}/../settings-manager.php"); | ||
|
||
include_once("{$currDir}/../defaultLang.php"); | ||
include_once("{$currDir}/../language.php"); | ||
$Translation = array_merge($TranslationEn, $Translation); | ||
|
||
include_once("{$currDir}/../db.php"); | ||
include_once(__DIR__ . '/../settings-manager.php'); | ||
|
||
// check if initial setup was performed or not | ||
detect_config(); | ||
migrate_config(); | ||
|
||
$adminConfig = config('adminConfig'); | ||
include_once("{$currDir}/incFunctions.php"); | ||
@include_once("{$currDir}/../hooks/__global.php"); | ||
|
||
checkAppRequirements(); | ||
|
||
// detecting classes not included above | ||
@spl_autoload_register(function($class) { | ||
$admin_dir = dirname(__FILE__); | ||
@include_once("{$admin_dir}/../resources/lib/{$class}.php"); | ||
}); | ||
|
||
/* trim $_POST, $_GET, $_REQUEST */ | ||
if(count($_POST)) $_POST = array_trim($_POST); | ||
if(count($_GET)) $_GET = array_trim($_GET); | ||
if(count($_REQUEST)) $_REQUEST = array_trim($_REQUEST); | ||
|
||
ob_start(); | ||
initSession(); | ||
|
||
// check if membership system exists | ||
setupMembership(); | ||
|
||
/* do we have a JWT auth header? */ | ||
jwt_check_login(); | ||
|
||
// renew remember-me token, if applicable | ||
if(!getLoggedAdmin()) $remember_check = RememberMe::check(); | ||
|
||
// is there a logged admin user? | ||
if(!($uname = getLoggedAdmin())) { | ||
// if no remember-me cookie, redirect to login page | ||
if(!$remember_check) die('<META HTTP-EQUIV="Refresh" CONTENT="0;url=../index.php">'); | ||
|
||
// get username from remeber-me cookie, set session and redirect to admin homepage | ||
$uname = makeSafe(strtolower(RememberMe::user())); | ||
$_SESSION['memberID'] = $uname; | ||
$_SESSION['memberGroupID'] = sqlValue("SELECT `groupID` FROM `membership_users` WHERE LCASE(`memberID`)='{$uname}'"); | ||
redirect('admin/pageHome.php'); | ||
} | ||
@include_once(__DIR__ . '/../hooks/__global.php'); | ||
|
||
?> | ||
if(!Authentication::getAdmin()) Authentication::signIn(); | ||
if(!Authentication::getAdmin()) redirect('index.php'); |
Oops, something went wrong.