X-Git-Url: https://defaria.com/gitweb/?a=blobdiff_plain;ds=sidebyside;f=maps%2Fphp%2FMAPS.php;h=b7189358b44fdd70284068785e17096e0e35a464;hb=5b549cfe88e1ff05a22af5b9da6a72a0b77bb41a;hp=72e13904992d9f0da690577916966c52dc961fac;hpb=025390646f3f196f64f16f919a35ff1d7c02eaaa;p=clearscm.git
diff --git a/maps/php/MAPS.php b/maps/php/MAPS.php
index 72e1390..b718935 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 ("localhost", "mapsadmin", "mapsadmin")
- or DBError ("OpenDB: Unable to connect to database server", "Connect");
+function OpenDB() {
+ $db = mysql_connect("localhost", "mapsadmin", "mapsadmin")
+ or DBError("OpenDB: Unable to connect to database server", "Connect");
- mysql_select_db ("MAPS")
- or DBError ("OpenDB: Unable to select MAPS database", "adefaria_maps");
+ mysql_select_db("MAPS")
+ or DBError("OpenDB: Unable to select MAPS database", "adefaria_maps");
} // OpenDB
-function SetContext ($new_userid) {
+function SetContext($new_userid) {
global $userid;
$userid = $new_userid;
} // SetContext
-function Encrypt ($password, $userid) {
+function Encrypt($password, $userid) {
$statement = "select encode(\"$password\",\"$userid\")";
- $result = mysql_query ($statement)
- or DBError ("Encrypt: Unable to execute statement", $statement);
+ $result = mysql_query($statement)
+ or DBError("Encrypt: Unable to execute statement", $statement);
// Get return value, which should be the encoded password
- $row = mysql_fetch_array ($result);
+ $row = mysql_fetch_array($result);
- return $row [0];
+ return $row[0];
} // Encrypt
-function UserExists ($userid) {
+function UserExists($userid) {
$statement = "select userid, password from user where userid = \"$userid\"";
- $result = mysql_query ($statement)
+ $result = mysql_query($statement)
or DBError ("UserExists: Unable to execute statement", $statement);
- $row = mysql_fetch_array ($result);
+ $row = mysql_fetch_array($result);
- $dbuserid = $row ["userid"];
- $dbpassword = $row ["password"];
+ $dbuserid = $row["userid"];
+ $dbpassword = $row["password"];
if ($dbuserid != $userid) {
return -1;
@@ -87,11 +87,11 @@ 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);
// Return -1 if user doesn't exist
if ($dbpassword == -1) {
@@ -102,8 +102,8 @@ 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
@@ -113,110 +113,110 @@ function CountList ($type) {
$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 = mysql_query($statement)
+ or DBError("CountList: Unable to count list: ", $statement);
// How many rows are there?
- $row = mysql_fetch_array ($result);
+ $row = mysql_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 = mysql_query($statement)
or DBError ("FindList: Unable to execute query: ", $statement);
- $count = mysql_num_rows ($result);
+ $count = mysql_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) {
$statement = "select count(distinct sender) as count from $table where $condition";
- $result = mysql_query ($statement)
- or DBError ("countem: Unable to perform query: ", $statement);
+ $result = mysql_query($statement)
+ or DBError("countem: Unable to perform query: ", $statement);
// How many rows are there?
- $row = mysql_fetch_array ($result);
+ $row = mysql_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 a");
// Start quickstats
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 : @@ -274,23 +274,23 @@ print <<