-
Notifications
You must be signed in to change notification settings - Fork 1
/
functions-db-sets.inc.php
56 lines (40 loc) · 1.69 KB
/
functions-db-sets.inc.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
<?php
// Add a username as a main admin.
function AddMainAdmin($username) {
// Check that the account does not already exist
$result =& DBQuery("SELECT count(*) as idcount FROM ".SCHEMANAME."vtcal_adminuser WHERE (id='".sqlescape($username)."')");
// Return the error message if the SELECT failed.
if (is_string($result)) return $result;
$record =& $result->fetchRow(DB_FETCHMODE_ASSOC, 0);
if ($record['idcount'] != "0") {
// Return false since the user already exists.
return false;
}
$result->free();
// Insert the account if it does not exist.
$result =& DBQuery("INSERT INTO ".SCHEMANAME."vtcal_adminuser (id) VALUES ('".sqlescape($username)."')");
// Return the error message if the INSERT failed.
if (is_string($result)) return $result;
// Return that the user was added successfully.
return true;
}
// Add a local DB user account.
function AddUser($username, $password, $email = "") {
// Check that the account does not already exist
$result =& DBQuery("SELECT count(*) as idcount FROM ".SCHEMANAME."vtcal_user WHERE (id='".sqlescape($username)."')");
// Return the error message if the SELECT failed.
if (is_string($result)) return $result;
$record =& $result->fetchRow(DB_FETCHMODE_ASSOC, 0);
if ($record['idcount'] != "0") {
// Return false since the user already exists.
return false;
}
$result->free();
// Insert the account if it does not exist.
$result =& DBQuery("INSERT INTO ".SCHEMANAME."vtcal_user (id, password, email) VALUES ('".sqlescape($username)."','".sqlescape(crypt($password))."','')");
// Return the error message if the INSERT failed.
if (is_string($result)) return $result;
// Return that the user was added successfully.
return true;
}
?>