-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcommon.php
41 lines (34 loc) · 1.05 KB
/
common.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
<?php
include('config.php');
define('GUEST_USER', 0);
define('LINKS_TABLE', $db_prefix . 'linked_providers');
define('NOTIFICATIONS_TABLE', $db_prefix . 'notifications');
define('SESSION_TABLE', $db_prefix . 'sessions');
define('SUBSCRIPTION_TABLE', $db_prefix . 'subscriptions');
define('USER_TABLE', $db_prefix . 'users');
define('VERSION_TABLE', $db_prefix . 'version_info');
define('PROVIDER_NULL', 0);
define('PROVIDER_GITHUB', 1);
define('PROVIDER_GITLAB', 2);
define('PROVIDER_GOOGLE', 3);
$provider_maps['github'] = PROVIDER_GITHUB;
$provider_maps['gitlab'] = PROVIDER_GITLAB;
$provider_maps['google'] = PROVIDER_GOOGLE;
// Connect to the database
$dsn = "mysql:host=$db_host;dbname=$db_name";
if (empty($db_port)){
$dsn .= ";port=3306";
} else {
$dsn .= ';port=' . (int) $db_port;
}
$options = array(
PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8mb4',
);
try {
$db = new PDO($dsn, $db_user, $db_password, $options);
} catch (PDOException $e) {
echo 'Connection failed: ' . $e->getMessage();
exit;
}
unset($db_user);
unset($db_password);