forked from bbdoc/PoracleWeb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
session.php
48 lines (34 loc) · 977 Bytes
/
session.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
<?php
include "./config.php";
include "./functions.php";
set_locale();
if(session_status() == PHP_SESSION_NONE){
session_start();
}
$dbnames = explode(",", $dbname);
foreach ($dbnames as &$db) {
$conn = new mysqli($dbhost.":".$dbport, $dbuser, $dbpass, $db);
// Check connection
if ($conn->connect_errno) {
echo "Failed to connect to MySQL: " . $conn->connect_error;
exit();
}
$sql = "SELECT * from humans WHERE id = '".$_SESSION['id']."'";
$result = $conn->query($sql) or die(mysqli_error($conn));
if ( $result->num_rows > 0 ) {
$_SESSION['dbname'] = $db;
}
}
// Set Admin Variables
if (isset($admin_id)) {
$admins = explode(",", $admin_id);
}
foreach ($admins as &$admin) {
if ($_SESSION['id'] == $admin)
{
$_SESSION['admin_id'] = $_SESSION['id'];
$_SESSION['admin_username'] = $_SESSION['username'];
$_SESSION['admin_dbname'] = $_SESSION['dbname'];
$_SESSION['admin_type'] = $_SESSION['type'];
}
}