-
Notifications
You must be signed in to change notification settings - Fork 0
/
db_init.php
61 lines (52 loc) · 1.76 KB
/
db_init.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
50
51
52
53
54
55
56
57
58
59
60
<?php
if (file_exists('./config.php' )){
require './config.php';
} else {
if (file_exists('./../config.php' )){
require './../config.php';
} else {
die('config.php - не найден. Проверьте целостность репозитория');
}
}
// DB Connection init
$link = mysqli_connect($db_server, $db_user, $db_password, $db_database);
if(!$link){
print('<div align="center">Проблемы с подключением к базе! Пните админа! )))</div>');
} else {
// Setting read mode to unicode
mysqli_query($link, "SET sql_mode = ''");
mysqli_query($link, 'SET NAMES utf8mb4');
// -----------------------------------------
// Building empty tables, if not exist in db
// The main arts table
mysqli_query($link, "CREATE TABLE IF NOT EXISTS `arts_pub` (
`aid` int(11) NOT NULL,
`title` text,
`file_name` text NOT NULL,
`thumb` text,
`da_page` text,
`author` text,
`category` int(11) NOT NULL DEFAULT '1',
`rating` int(11) NOT NULL DEFAULT '0',
`addate` text NOT NULL,
`da_id` text,
`da_tags` text
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_unicode_ci;");
// Virtual categories table
mysqli_query($link, 'CREATE TABLE IF NOT EXISTS `categories` (
`cat_id` int(11) NOT NULL,
`cat_name` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;');
// Subscribers table (urrently not used in code)
mysqli_query($link, 'CREATE TABLE IF NOT EXISTS `subscribers` (
`uid` int(11) NOT NULL,
`email` text,
`subscribed` text
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;');
// Vistors tracking table (used to store statistic only)
mysqli_query($link, 'CREATE TABLE IF NOT EXISTS `visitors` (
`ip` text,
`visits` int(11) DEFAULT NULL,
`date` text
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;');
}