This repository was archived by the owner on Jun 15, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathfunctions.php
More file actions
71 lines (59 loc) · 1.35 KB
/
functions.php
File metadata and controls
71 lines (59 loc) · 1.35 KB
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
61
62
63
64
65
66
67
68
69
70
71
<?php
function getDBObject($uri) {
$tmp = explode(':', $uri);
$proto = Trim($tmp[0]);
$pdata = Trim($tmp[1]);
if ($proto == 'file')
return new DatabaseFile( $pdata );
else
if ($proto == 'mysql')
return new DatabaseMySQL( $pdata );
return false;
}
function verify_user($db, $perm=false) {
if (array_key_exists('logged_in', $_SESSION)) {
if ($perm != false) {
if ($_SESSION['user_perms'] == '*')
return true;
else
return ($_SESSION['user_perms'] & $perm) ? true : false;
}
else
return true;
}
$logged_in = false;
if (array_key_exists('user', $_POST)) {
$perm = $db->verify_user($_POST['user'], $_POST['password']);
if (is_string($perm)) {
$logged_in = base64_encode("{$_POST['user']}\n{$_POST['password']}");
if ($perm == true) {
$_SESSION['user_perms'] = '*';
$_SESSION['logged_in'] = $logged_in;
}
else {
$_SESSION['user_perms'] = $perm;
$_SESSION['logged_in'] = $logged_in;
}
}
}
return $logged_in;
}
function get_languages()
{
$dh = opendir('lang');
if (!$dh)
return false;
$langs = array();
while (($file = readdir($dh)) !== false) {
if (strpos($file, '.php')) {
include('lang/'.$file);
$langs[] = array(
'name' => $lang_name,
'code' => $lang_code
);
}
}
closedir($dh);
return $langs;
}
?>