-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.php
49 lines (42 loc) · 1.43 KB
/
config.php
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
// if anyone visit this page redirect to 404 page
if (basename($_SERVER['PHP_SELF']) == basename(__FILE__)) {
header("location: 404.php");
exit;
}
// mkdir and change permission upload folder in windows
$cmd = "mkdir uploads && icacls uploads /grant Everyone:F /t";
exec($cmd);
// mkdir and change permission upload folder in linux
$cmd = "mkdir uploads && chmod 777 uploads";
exec($cmd);
date_default_timezone_set('Asia/Manila');
// database connection
// Database connection
define('DB_SERVER', 'localhost');
define('DB_USERNAME', 'ccf_inventory');
define('DB_PASSWORD', 'CCFAlabang!');
define('DB_NAME', 'inventory');
define('DB_PORT', '3306');
// Get connection
$conn = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME, DB_PORT);
// Check connection
if ($conn === false) {
die("ERROR: Could not connect. " . mysqli_connect_error());
} else {
// create table if not exists
$sql = "CREATE TABLE IF NOT EXISTS assets (
id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
asset_tag text NOT NULL,
serial_number TEXT NOT NULL,
image_path text NOT NULL,
visible BOOLEAN DEFAULT 1,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
)";
if (mysqli_query($conn, $sql)) {
// echo "Table created successfully";
} else {
echo "Error creating table: " . mysqli_error($conn);
}
}
?>