forked from karllhughes/colleges
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
29 lines (25 loc) · 983 Bytes
/
index.php
File metadata and controls
29 lines (25 loc) · 983 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?php
include './vendor/autoload.php';
// Default parameters
$_SERVER['SCRIPT_NAME'] = "";
$_GET['page'] = $_GET['page'] ?? '1,100';
$_GET['order'] = $_GET['order'] ?? 'id';
// DB Connection
$api = new PHP_CRUD_API([
'dbengine' => $_ENV['DB_ENGINE'], // 'PostgreSQL' or 'MySQL'
'hostname' => $_ENV['DB_HOSTNAME'] ?: 'localhost', // Name of the database host
'username' => $_ENV['DB_USERNAME'] ?: '', // Database user
'password' => $_ENV['DB_PASSWORD'] ?: '', // Database password
'database' => $_ENV['DB_DATABASE'] ?: '', // Database name
'charset'=> $_ENV['DB_CHARSET'] ?: 'UTF8', // 'UTF8' or 'utf8'
'table_authorizer' => function($cmd, $db, $tab) {
return $tab !== "phinxlog"; // Ignores the migrations table
},
]);
if ($_SERVER['REQUEST_METHOD'] === "GET") {
$api->executeCommand();
} else {
header("HTTP/1.1 401 Unauthorized");
echo "Not authorized.";
exit;
}