X-Git-Url: https://defaria.com/gitweb/?a=blobdiff_plain;f=maps%2Fphp%2FMAPS.php;h=0def4ba6066246853738e4cd86b145c22574d820;hb=77368430a85b2979b903cba1f0a174f7d8bab2b6;hp=e676cf4a66c213af8572ef08005ceed3f44033e6;hpb=066348c5a08e728fd796b8a963d3f5eeb1459a28;p=clearscm.git
diff --git a/maps/php/MAPS.php b/maps/php/MAPS.php
index e676cf4..0def4ba 100755
--- a/maps/php/MAPS.php
+++ b/maps/php/MAPS.php
@@ -34,9 +34,13 @@ $Types = array (
"nulllist"
);
+$db;
+
function DBError($msg, $statement) {
- $errno = mysql_errno();
- $errmsg = mysql_error();
+ global $db;
+
+ $errno = mysqli_errno($db);
+ $errmsg = mysqli_error($db);
print "$msg
Error # $errno $errmsg";
print "
SQL Statement: $statement";
@@ -44,10 +48,12 @@ function DBError($msg, $statement) {
} // DBError
function OpenDB() {
- $db = mysql_connect("localhost", "maps", "spam")
+ global $db;
+
+ $db = mysqli_connect("localhost", "maps", "spam")
or DBError("OpenDB: Unable to connect to database server", "Connect");
- mysql_select_db("MAPS")
+ mysqli_select_db($db, "MAPS")
or DBError("OpenDB: Unable to select MAPS database", "adefaria_maps");
} // OpenDB
@@ -58,24 +64,28 @@ function SetContext($new_userid) {
} // SetContext
function Encrypt($password, $userid) {
+ global $db;
+
$statement = "select encode(\"$password\",\"$userid\")";
- $result = mysql_query($statement)
+ $result = mysqli_query($db, $statement)
or DBError("Encrypt: Unable to execute statement", $statement);
// Get return value, which should be the encoded password
- $row = mysql_fetch_array($result);
+ $row = mysqli_fetch_array($result);
return $row[0];
} // Encrypt
function UserExists($userid) {
+ global $db;
+
$statement = "select userid, password from user where userid = \"$userid\"";
- $result = mysql_query($statement)
+ $result = mysqli_query($db, $statement)
or DBError ("UserExists: Unable to execute statement", $statement);
- $row = mysql_fetch_array($result);
+ $row = mysqli_fetch_array($result);
$dbuserid = $row["userid"];
$dbpassword = $row["password"];
@@ -109,15 +119,15 @@ function Login($userid, $password) {
} // Login
function CountList ($type) {
- global $userid;
+ global $userid, $db;
$statement = "select count(*) as count from list where type=\"$type\" and userid=\"$userid\"";
- $result = mysql_query($statement)
+ $result = mysqli_query($db, $statement)
or DBError("CountList: Unable to count list: ", $statement);
// How many rows are there?
- $row = mysql_fetch_array($result);
+ $row = mysqli_fetch_array($result);
return $row["count"];
} // CountList
@@ -129,10 +139,10 @@ function FindList($type, $next, $lines) {
$statement = "select * from list where type=\"$type\" and userid=\"$userid\" order by sequence limit $next, $lines";
- $result = mysql_query($statement)
+ $result = mysqli_query($db, $statement)
or DBError ("FindList: Unable to execute query: ", $statement);
- $count = mysql_num_rows($result);
+ $count = mysqli_num_rows($result);
return array($count, $result);
} // FindList
@@ -142,13 +152,15 @@ function Today2SQLDatetime() {
} // Today2SQLDatetime
function countem($table, $condition) {
+ global $db;
+
$statement = "select count(distinct sender) as count from $table where $condition";
- $result = mysql_query($statement)
+ $result = mysqli_query($db, $statement)
or DBError("countem: Unable to perform query: ", $statement);
// How many rows are there?
- $row = mysql_fetch_array($result);
+ $row = mysqli_fetch_array($result);
return $row["count"];
} // countem
@@ -196,7 +208,7 @@ function GetStats($nbr_days, $date = "") {
function displayquickstats() {
$today = substr (Today2SQLDatetime(), 0, 10);
$dates = getquickstats($today);
- $current_time = date("g:i a");
+ $current_time = date("g:i:s a");
// Start quickstats
print "