X-Git-Url: https://defaria.com/gitweb/?a=blobdiff_plain;ds=sidebyside;f=maps%2Fphp%2FMAPS.php;h=6f1a8bac713513482541e2155a6de3d1997e6281;hb=4e6bdcd021a72103bfab56bc3d5a4e11e81d375a;hp=7fd877b3067b8537afd57e661225a53d7f3a8854;hpb=e06c4b0f74af031952ecf6876c5dceb6886764a0;p=clearscm.git
diff --git a/maps/php/MAPS.php b/maps/php/MAPS.php
index 7fd877b..6f1a8ba 100755
--- a/maps/php/MAPS.php
+++ b/maps/php/MAPS.php
@@ -1,24 +1,24 @@
Error # $errno $errmsg";
print "
SQL Statement: $statement";
- exit ($errno);
+ exit($errno);
} // DBError
-function OpenDB () {
- $db = mysql_connect ("mysql.clearscm.com", "adefaria_admin", "adefaria_admin")
- or DBError ("OpenDB: Unable to connect to database server", "Connect");
+function OpenDB() {
+ global $db;
+
+ $db = mysqli_connect("127.0.0.1", "maps", "spam")
+ or DBError("OpenDB: Unable to connect to database server", "Connect");
- mysql_select_db ("adefaria_maps")
- or DBError ("OpenDB: Unable to select MAPS database", "adefaria_maps");
+ mysqli_select_db($db, "MAPS")
+ or DBError("OpenDB: Unable to select MAPS database", "adefaria_maps");
} // OpenDB
-function SetContext ($new_userid) {
+function CloseDB() {
+ global $db;
+
+ if (isset ($db)) {
+ mysqli_close($db);
+ } // if
+} // CloseDB
+
+function SetContext($new_userid) {
global $userid;
$userid = $new_userid;
} // SetContext
-function Encrypt ($password, $userid) {
- $statement = "select encode(\"$password\",\"$userid\")";
+function Encrypt($password, $userid) {
+ global $db;
+
+ $statement = "select hex(aes_encrypt(\"$password\",\"$userid\"))";
- $result = mysql_query ($statement)
- or DBError ("Encrypt: Unable to execute statement", $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];
+ return $row[0];
} // Encrypt
-function UserExists ($userid) {
+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"];
+ $dbuserid = $row["userid"];
+ $dbpassword = $row["password"];
if ($dbuserid != $userid) {
return -1;
@@ -87,11 +105,12 @@ function UserExists ($userid) {
} # if
} // UserExists
-function Login ($userid, $password) {
- $password = Encrypt ($password, $userid);
+function Login($userid, $password) {
+ $password = Encrypt($password, $userid);
// Check if user exists
- $dbpassword = UserExists ($userid);
+ $dbpassword = UserExists($userid);
+ print "dbpassword = $dbpassword
";
// Return -1 if user doesn't exist
if ($dbpassword == -1) {
@@ -102,200 +121,205 @@ function Login ($userid, $password) {
if ($password != $dbpassword) {
return -2;
} else {
- setcookie ("MAPSUser", $userid, time()+60*60*24*30, "/maps");
- SetContext ($userid);
+ setcookie("MAPSUser", $userid, time()+60*60*24*30, "/maps");
+ SetContext($userid);
return 0;
} // if
} // 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)
- or DBError ("CountList: Unable to count list: ", $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"];
+ return $row["count"];
} // CountList
-function FindList ($type, $next, $lines) {
+function FindList($type, $next, $lines) {
global $db;
global $userid;
global $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);
+ return array($count, $result);
} // FindList
-function Today2SQLDatetime () {
+function Today2SQLDatetime() {
return date ("Y-m-d H:i:s");
} // Today2SQLDatetime
-function countem ($table, $condition) {
+function countem($table, $condition) {
+ global $db;
+
$statement = "select count(distinct sender) as count from $table where $condition";
- $result = mysql_query ($statement)
- or DBError ("countem: Unable to perform 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"];
+ return $row["count"];
} // countem
-function countlog ($condition="") {
+function countlog($condition="") {
global $userid;
if ($condition != "") {
- return countem ("log", "userid=\"$userid\" and " . $condition);
+ return countem("log", "userid=\"$userid\" and " . $condition);
} else {
- return countem ("log", "userid=\"$userid\"");
+ return countem("log", "userid=\"$userid\"");
} // if
} // countlog
-function SubtractDays ($date, $nbr_days) {
-
+function SubtractDays($date, $nbr_days) {
+
} // SubtractDays
-function GetStats ($nbr_days, $date = "") {
+function GetStats($nbr_days, $date = "") {
global $Types;
if ($date == "") {
- $date = Today2SQLDatetime ();
+ $date = Today2SQLDatetime();
} // if
while ($nbr_days > 0) {
- $ymd = substr ($date, 0, 10);
+ $ymd = substr($date, 0, 10);
$sod = $ymd . " 00:00:00";
$eod = $ymd . " 23:59:59";
foreach ($Types as $type) {
$condition = "type=\"$type\" and (timestamp > \"$sod\" and timestamp < \"$eod\")";
- $stats[$type] = countlog ($condition);
+ $stats[$type] = countlog($condition);
} # foreach
$dates[$ymd] = &$stats;
- $date = SubtractDays ($date, 1);
+ $date = SubtractDays($date, 1);
$nbr_days--;
} # while
return $dates;
} # GetStats
-function displayquickstats () {
- $today = substr (Today2SQLDatetime (), 0, 10);
- $dates = getquickstats ($today);
- $current_time = date ("g:i a");
+function displayquickstats() {
+ $today = substr (Today2SQLDatetime(), 0, 10);
+ $dates = getquickstats($today);
+ $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"]; - $returned_pct = $processed == 0 ? 0 : + $processed = $dates[$today]["processed"]; + $returned = $dates[$today]["returned"]; + $returned_pct = $processed == 0 ? 0 : number_format ($returned / $processed * 100, 1, ".", ""); - $whitelist = $dates[$today]["whitelist"]; - $whitelist_pct = $processed == 0 ? 0 : + $whitelist = $dates[$today]["whitelist"]; + $whitelist_pct = $processed == 0 ? 0 : number_format ($whitelist / $processed * 100, 1, ".", ""); - $blacklist = $dates[$today]["blacklist"]; - $blacklist_pct = $processed == 0 ? 0 : + $blacklist = $dates[$today]["blacklist"]; + $blacklist_pct = $processed == 0 ? 0 : number_format ($blacklist / $processed * 100, 1, ".", ""); - $registered = $dates[$today]["registered"]; - $mailloop = $dates[$today]["mailloop"]; - $nulllist = $dates[$today]["nulllist"]; - $nulllist_pct = $processed == 0 ? 0 : + $registered = $dates[$today]["registered"]; + $mailloop = $dates[$today]["mailloop"]; + $nulllist = $dates[$today]["nulllist"]; + $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% | -