-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathcheck_db_access.php
More file actions
35 lines (29 loc) · 857 Bytes
/
check_db_access.php
File metadata and controls
35 lines (29 loc) · 857 Bytes
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
<?php
$username = "admin";
$password = "phplib";
require("phplib/prepend.php");
include("inc/config.php");
$db = new DB_probind;
if (!$db->connect()) {
echo "connect failed\n";
} else
if (!$tables = $db->table_names()) {
echo "Can't read table names\n";
} else {
$str = count($tables). " tables found in db $db->Database on $db->Server server $db->Host\n";
echo $str;
EventLog("Test DB",$str);
if ($db->query("SELECT count(*) FROM auth_user")) {
if ($db->next_record()) {
if ($db->f(0)==0) {
# no users in auth_user, let's make one.
$id = md5(uniqid("somestring"));
$hashpass = hash_auth($username,$password);
if ($db->query("INSERT INTO auth_user (user_id, username, password, perms) VALUES ('$id','$username','$hashpass','admin')")) {
echo "Created admin user with password $password\n";
}
}
}
}
}
?>