X-Git-Url: https://defaria.com/gitweb/?a=blobdiff_plain;f=maps%2Fphp%2FMAPS.php;h=49d7ca4d837b710a62f5949baa8cb6108632a21f;hb=290e8df6876439cd18325d55b6dc8e2e5e1fc8f2;hp=b7189358b44fdd70284068785e17096e0e35a464;hpb=b5be44d98985746b6319309d8272b297674b540c;p=clearscm.git
diff --git a/maps/php/MAPS.php b/maps/php/MAPS.php
index b718935..49d7ca4 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,13 +48,23 @@ function DBError($msg, $statement) {
} // DBError
function OpenDB() {
- $db = mysql_connect("localhost", "mapsadmin", "mapsadmin")
+ global $db;
+
+ $db = mysqli_connect("127.0.0.1", "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
+function CloseDB() {
+ global $db;
+
+ if (isset ($db)) {
+ mysqli_close($db);
+ } // if
+} // CloseDB
+
function SetContext($new_userid) {
global $userid;
@@ -58,24 +72,28 @@ function SetContext($new_userid) {
} // SetContext
function Encrypt($password, $userid) {
- $statement = "select encode(\"$password\",\"$userid\")";
+ global $db;
+
+ $statement = "select hex(aes_encrypt(\"$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 +127,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 +147,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 +160,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,12 +216,12 @@ 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 "
as of $current_time
"; + print "as of $current_time
"; $processed = $dates[$today]["processed"]; $returned = $dates[$today]["returned"]; @@ -219,58 +239,60 @@ function displayquickstats() { $nulllist_pct = $processed == 0 ? 0 : number_format ($nulllist / $processed * 100, 1, ".", ""); - $returned_link = $returned == 0 ? 0 : - "$returned"; - $whitelist_link = $whitelist == 0 ? 0 : - "$whitelist"; - $blacklist_link = $blacklist == 0 ? 0 : - "$blacklist"; - $registered_link = $registered == 0 ? 0 : - "$registered"; - $mailloop_link = $mailloop == 0 ? 0 : - "$mailloop"; - $nulllist_link = $nulllist == 0 ? 0 : - "$nulllist"; + $returned_link = $returned == 0 ? '' : + ""; + $whitelist_link = $whitelist == 0 ? '' : + ""; + $blacklist_link = $blacklist == 0 ? '' : + ""; + $registered_link = $registered == 0 ? '' : + ""; + $mailloop_link = $mailloop == 0 ? '' : + "\""; + $nulllist_link = $nulllist == 0 ? '' : + ""; print <<Processed | +Processed | $processed | n/a | |
Returned | -$returned_link + | ${nulllist_link}Nulllist | +$nulllist | +$nulllist_pct% | +
${returned_link}Returned | +$returned | $returned_pct% | ||
Whitelist | -$whitelist_link + | ${whitelist_link}Whitelist | +$whitelist | $whitelist_pct% |
Blacklist | -$blacklist_link + | ${blacklist_link}Blacklist | +$blacklist | $blacklist_pct% |
Registered | -$registered_link + | ${registered_link}Registered | +$registered | n/a |
Mailloop | -$mailloop_link + | ${mailloop_link}Mailloop | +$mailloop | n/a |
Nulllist | -$nulllist_link - | $nulllist_pct% | -