Fix Dockerfile compatibility
This commit is contained in:
@@ -0,0 +1,92 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ar" dir="rtl">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>فحص الـ API - منصة صقل</title>
|
||||
<style>
|
||||
body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; background-color: #f4f7f6; margin: 0; padding: 20px; color: #333; }
|
||||
h1, h2 { text-align: center; }
|
||||
.card { background: white; padding: 20px; margin: 20px auto; max-width: 600px; border-radius: 8px; box-shadow: 0 4px 6px rgba(0,0,0,0.1); }
|
||||
.form-group { margin-bottom: 15px; }
|
||||
label { display: block; margin-bottom: 5px; font-weight: bold; }
|
||||
input, select { width: 100%; padding: 8px; border: 1px solid #ccc; border-radius: 4px; box-sizing: border-box; }
|
||||
button { background-color: #27ae60; color: white; border: none; padding: 10px 15px; cursor: pointer; border-radius: 4px; font-weight: bold; margin-bottom: 5px; }
|
||||
button:hover { background-color: #2ecc71; }
|
||||
pre { background: #2c3e50; color: #ecf0f1; padding: 15px; border-radius: 4px; overflow-x: auto; direction: ltr; text-align: left; max-height: 300px; }
|
||||
.btn-info { background-color: #3498db; }
|
||||
.btn-info:hover { background-color: #2980b9; }
|
||||
.nav { text-align: center; margin-bottom: 20px; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="nav">
|
||||
<a href="index.html">العودة للرئيسية</a>
|
||||
</div>
|
||||
<h1>أداة فحص الواجهات البرمجية (Pure PHP API Tester)</h1>
|
||||
|
||||
<div class="card">
|
||||
<h2>فحص الاتصال والسرعة (Ping)</h2>
|
||||
<button onclick="testPing()" class="btn-info">فحص /api/ping</button>
|
||||
|
||||
<h3>النتيجة:</h3>
|
||||
<pre id="ping-result">في انتظار التنفيذ...</pre>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<h2>تسجيل الدخول (Login)</h2>
|
||||
<div class="form-group">
|
||||
<label>البريد الإلكتروني:</label>
|
||||
<input type="email" id="login-email" value="test@example.com">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>كلمة المرور:</label>
|
||||
<input type="password" id="login-password" value="secret">
|
||||
</div>
|
||||
<button onclick="testLogin()">تسجيل الدخول</button>
|
||||
|
||||
<h3>النتيجة:</h3>
|
||||
<pre id="login-result">في انتظار التنفيذ...</pre>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
async function testPing() {
|
||||
const resultBox = document.getElementById('ping-result');
|
||||
resultBox.innerHTML = 'جاري الاتصال بـ /index.php/api/ping...';
|
||||
|
||||
try {
|
||||
// Notice we route through index.php since we haven't set up htaccess rewrite rules yet
|
||||
const response = await fetch('/index.php/api/ping');
|
||||
const data = await response.json();
|
||||
resultBox.innerHTML = JSON.stringify(data, null, 2);
|
||||
} catch (error) {
|
||||
resultBox.innerHTML = 'خطأ في الاتصال: ' + error.message;
|
||||
}
|
||||
}
|
||||
|
||||
async function testLogin() {
|
||||
const email = document.getElementById('login-email').value;
|
||||
const password = document.getElementById('login-password').value;
|
||||
const resultBox = document.getElementById('login-result');
|
||||
|
||||
resultBox.innerHTML = 'جاري الاتصال بـ /index.php/api/auth/login...';
|
||||
|
||||
try {
|
||||
const response = await fetch('/index.php/api/auth/login', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({ email, password })
|
||||
});
|
||||
|
||||
const data = await response.json();
|
||||
resultBox.innerHTML = JSON.stringify(data, null, 2);
|
||||
} catch (error) {
|
||||
resultBox.innerHTML = 'خطأ في الاتصال: ' + error.message;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,28 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ar" dir="rtl">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>منصة صقل - الرئيسية</title>
|
||||
<style>
|
||||
body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; text-align: center; margin: 0; padding: 0; background-color: #f4f7f6; color: #333; }
|
||||
header { background-color: #2c3e50; color: white; padding: 2rem 0; }
|
||||
h1 { margin: 0; font-size: 2.5rem; }
|
||||
p { font-size: 1.2rem; }
|
||||
.container { padding: 3rem 1rem; }
|
||||
.btn { display: inline-block; background-color: #3498db; color: white; padding: 10px 20px; text-decoration: none; border-radius: 5px; font-weight: bold; margin-top: 20px; transition: 0.3s; }
|
||||
.btn:hover { background-color: #2980b9; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<h1>منصة صقل</h1>
|
||||
<p>المنصة التعليمية الأولى لتطوير المهارات (Pure PHP)</p>
|
||||
</header>
|
||||
<div class="container">
|
||||
<h2>مرحباً بك في منصة صقل</h2>
|
||||
<p>النظام الأساسي (Backend) يعمل بنجاح تام وبسرعة فائقة!</p>
|
||||
<a href="api-test.html" class="btn">الانتقال لصفحة فحص الـ API</a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
header("Content-Type: application/json; charset=UTF-8");
|
||||
header("Access-Control-Allow-Origin: *");
|
||||
header("Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS");
|
||||
header("Access-Control-Allow-Headers: Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With");
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') {
|
||||
http_response_code(200);
|
||||
exit();
|
||||
}
|
||||
|
||||
// Auto-loader for classes (simple version)
|
||||
spl_autoload_register(function ($class) {
|
||||
$prefix = 'Saqel\\';
|
||||
$base_dir = __DIR__ . '/../src/';
|
||||
$len = strlen($prefix);
|
||||
if (strncmp($prefix, $class, $len) !== 0) {
|
||||
return;
|
||||
}
|
||||
$relative_class = substr($class, $len);
|
||||
$file = $base_dir . str_replace('\\', '/', $relative_class) . '.php';
|
||||
if (file_exists($file)) {
|
||||
require $file;
|
||||
}
|
||||
});
|
||||
|
||||
use Saqel\Router;
|
||||
use Saqel\Database;
|
||||
|
||||
$router = new Router();
|
||||
|
||||
$router->add('GET', '/', function() {
|
||||
echo json_encode([
|
||||
'status' => 'success',
|
||||
'message' => 'Saqel API is running in Pure PHP mode!'
|
||||
]);
|
||||
});
|
||||
|
||||
$router->add('GET', '/api/ping', function() {
|
||||
$time_start = microtime(true);
|
||||
|
||||
// Test DB connection
|
||||
$db = Database::getInstance()->getConnection();
|
||||
$stmt = $db->query("SELECT 1");
|
||||
$dbStatus = $stmt ? 'connected' : 'failed';
|
||||
|
||||
$time_end = microtime(true);
|
||||
$execution_time = ($time_end - $time_start) * 1000;
|
||||
|
||||
echo json_encode([
|
||||
'status' => 'success',
|
||||
'message' => 'Saqel Pure PHP Backend is running incredibly fast!',
|
||||
'database' => $dbStatus,
|
||||
'execution_time_ms' => round($execution_time, 2)
|
||||
]);
|
||||
});
|
||||
|
||||
// Example route for user login (Mock)
|
||||
$router->add('POST', '/api/auth/login', function() {
|
||||
$data = json_decode(file_get_contents("php://input"), true);
|
||||
|
||||
// In a real app, query Database here and verify password
|
||||
if (isset($data['email']) && isset($data['password'])) {
|
||||
echo json_encode([
|
||||
'access_token' => bin2hex(random_bytes(16)),
|
||||
'token_type' => 'Bearer',
|
||||
'user' => [
|
||||
'email' => $data['email'],
|
||||
'role' => 'student'
|
||||
]
|
||||
]);
|
||||
} else {
|
||||
header("HTTP/1.0 400 Bad Request");
|
||||
echo json_encode(['error' => 'Missing email or password']);
|
||||
}
|
||||
});
|
||||
|
||||
$router->dispatch($_SERVER['REQUEST_METHOD'], $_SERVER['REQUEST_URI']);
|
||||
Reference in New Issue
Block a user