Skip to content

Commit 637accc

Browse files
committed
all comments are removed
1 parent d53c206 commit 637accc

File tree

198 files changed

+1496
-6974
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

198 files changed

+1496
-6974
lines changed

.htaccess

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,24 @@
1-
# /.htaccess (Final, Clean Version)
2-
3-
# Prevent automatic directory slash append
1+
2+
43
DirectorySlash Off
54

65
RewriteEngine On
7-
8-
# Prevent redirect loops for admin and login
6+
97
RewriteCond %{ENV:REDIRECT_STATUS} 200
108
RewriteRule ^ - [L]
11-
12-
# ----------------------------------------------------------------------
13-
# Rule 1: Redirect requests from "file.php" to "/file"
14-
# ----------------------------------------------------------------------
15-
# This cleans up the URL in the user's browser for direct page access.
16-
RewriteCond %{THE_REQUEST} \s/+(.+?)\.php[\s?] [NC]
17-
# IGNORE specific files and critical folders
9+
10+
11+
12+
13+
RewriteCond %{THE_REQUEST} \s/+(.+?)\.php[\s?] [NC]
1814
RewriteCond %{REQUEST_URI} !^/(google_callback|github_callback|admin-create|seed)\.php$ [NC]
1915
RewriteCond %{REQUEST_URI} !^/ajax/ [NC]
2016
RewriteCond %{REQUEST_URI} !^/admin/util/ [NC]
2117
RewriteCond %{REQUEST_URI} !^/config/ [NC]
2218
RewriteRule ^ /%1 [R=301,L]
23-
24-
# ----------------------------------------------------------------------
25-
# Rule 2: Front Controller for clean URLs
26-
# ----------------------------------------------------------------------
19+
20+
21+
2722
RewriteCond %{REQUEST_FILENAME} !-f
2823
RewriteCond %{REQUEST_URI} !^/ajax/ [NC]
2924
RewriteCond %{REQUEST_URI} !^/admin/util/ [NC]

admin-create.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
<?php
22
require_once(__DIR__ . '/config/config.php');
33

4-
// --- Create a new admin user ---
54

6-
// Temporary credentials
5+
6+
77
$temp_username = 'man1';
88
$temp_email = 'man@example.com';
9-
$temp_password = '135600'; // It's recommended to change this after first login
9+
$temp_password = '135600';
10+
1011

11-
// Hash the password for security
1212
$hashed_password = password_hash($temp_password, PASSWORD_DEFAULT);
1313

14-
// Check if the admin already exists
14+
1515
$check_query = $conn->prepare("SELECT * FROM admins WHERE username = ? OR email = ?");
1616
$check_query->bind_param("ss", $temp_username, $temp_email);
1717
$check_query->execute();
@@ -20,7 +20,7 @@
2020
if ($result->num_rows > 0) {
2121
echo "Admin user with this username or email already exists.";
2222
} else {
23-
// Insert the new admin into the database
23+
2424
$insert_query = $conn->prepare("INSERT INTO admins (username, email, password) VALUES (?, ?, ?)");
2525
$insert_query->bind_param("sss", $temp_username, $temp_email, $hashed_password);
2626

admin-router.php

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
<?php
2-
// /admin-router.php (Final version with clean URL support)
2+
33

44
if (session_status() === PHP_SESSION_NONE) {
55
session_start();
66
}
77

8-
// Function to check if an admin is logged in
8+
99
function isAdminAuthenticated() {
10-
return isset($_SESSION['admins_id']); // Use your actual admin session variable
10+
return isset($_SESSION['admins_id']);
1111
}
1212

1313
$request_uri = strtok($_SERVER['REQUEST_URI'], '?');
1414

15-
// --- Main Admin Routing Logic ---
15+
1616
switch (true) {
17-
// 1. Handle the login page
17+
1818
case preg_match('#^/admin/login/?$#', $request_uri):
1919
if (isAdminAuthenticated()) {
2020
header('Location: /admin');
@@ -23,7 +23,7 @@ function isAdminAuthenticated() {
2323
include __DIR__ . '/admin/login.php';
2424
break;
2525

26-
// 2. Handle AJAX requests for page content (e.g., /admin/pages/category)
26+
2727
case preg_match('#^/admin/pages/([a-zA-Z0-9-_]+)$#', $request_uri, $matches):
2828
if (!isAdminAuthenticated()) {
2929
http_response_code(401);
@@ -34,7 +34,7 @@ function isAdminAuthenticated() {
3434
$page = $matches[1];
3535
$page_file = __DIR__ . '/admin/pages/' . $page . '.php';
3636

37-
// Security: Whitelist allowed pages
37+
3838

3939
$allowed_pages = [
4040
'dashboard', 'view-ads', 'pending-ads', 'reported-ads', 'category', 'add-ad-category', 'sub-cat',
@@ -45,38 +45,38 @@ function isAdminAuthenticated() {
4545

4646

4747
if (in_array($page, $allowed_pages) && file_exists($page_file)) {
48-
include $page_file; // Respond with just the content
48+
include $page_file;
4949
} else {
5050
http_response_code(404);
5151
echo 'Page content not found.';
5252
}
5353
break;
5454

55-
// =================================================================
56-
// 3. NEW: Handle clean admin URLs like /admin/category or just /admin
57-
// This is the primary router for all admin page views.
58-
// =================================================================
55+
56+
57+
58+
5959
case preg_match('#^/admin(/([a-zA-Z0-9-_]+))?/?$#', $request_uri, $matches):
6060
if (!isAdminAuthenticated()) {
6161
header('Location: /admin/login');
6262
exit;
6363
}
6464

65-
// The second part of the URL ($matches[2]) is our page name.
66-
// If it's not present (i.e., the user visited just /admin), default to 'dashboard'.
65+
66+
6767
$page = $matches[2] ?? 'dashboard';
6868

69-
// Pass the page name to the admin shell via a $_GET variable.
70-
// The JavaScript will use this to know which content to load initially.
69+
70+
7171
$_GET['page'] = $page;
7272

73-
// Always load the main admin "shell" page.
73+
7474
include __DIR__ . '/admin/admin-page.php';
7575
break;
7676

7777
default:
7878
http_response_code(404);
79-
include __DIR__ . '/admin/pages/404.php'; // A proper 404 page
79+
include __DIR__ . '/admin/pages/404.php';
8080
break;
8181
}
8282
?>

0 commit comments

Comments
 (0)