From b1f29b67f6f004977c77ea1eb2dd0ef5b73cefee Mon Sep 17 00:00:00 2001 From: "mconnor%myrealbox.com" Date: Thu, 20 Jan 2005 21:14:13 +0000 Subject: [PATCH] various cleanup/formating fun git-svn-id: svn://10.0.0.236/trunk@168083 18797224-902f-48f8-a5cc-f745e15eee43 --- .../webtools/update/core/commenthelpful.php | 95 +++++----- mozilla/webtools/update/core/config.php | 37 ++-- .../update/core/inc_browserdetection.php | 12 +- mozilla/webtools/update/core/inc_global.php | 151 ++++++++-------- mozilla/webtools/update/core/inc_guids.php | 8 +- mozilla/webtools/update/core/inc_header.php | 2 +- mozilla/webtools/update/core/install.php | 102 +++++------ mozilla/webtools/update/core/postfeedback.php | 167 ++++++++++-------- .../webtools/update/core/reportcomment.php | 48 ++--- .../update/extensions/authorprofiles.php | 111 +++++++----- mozilla/webtools/update/rss/inc_rssfeed.php | 56 +++--- mozilla/webtools/update/rss/index.php | 14 +- 12 files changed, 436 insertions(+), 367 deletions(-) diff --git a/mozilla/webtools/update/core/commenthelpful.php b/mozilla/webtools/update/core/commenthelpful.php index 1c94d5785ba..71c98176063 100755 --- a/mozilla/webtools/update/core/commenthelpful.php +++ b/mozilla/webtools/update/core/commenthelpful.php @@ -45,62 +45,71 @@ require"../core/config.php"; //Check and see if the CommentID/ID is valid. -$sql = "SELECT `ID`, `CommentID` FROM `feedback` WHERE `ID` = '".escape_string($_GET[id])."' AND `CommentID`='".escape_string($_GET["commentid"])."' LIMIT 1"; +$sql = "SELECT `ID`, `CommentID` + FROM `feedback` + WHERE `ID` = '".escape_string($_GET[id])."' + AND `CommentID`='".escape_string($_GET["commentid"])."' + LIMIT 1"; $sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_ERROR); - if(mysql_num_rows($sql_result)=="0") { - unset($_GET["id"],$_GET["commentid"],$id,$commentid); - } else { - $id = escape_string($_GET["id"]); - $commentid = escape_string($_GET["commentid"]); - } +if(mysql_num_rows($sql_result)=="0") { + unset($_GET["id"],$_GET["commentid"],$id,$commentid); +} else { + $id = escape_string($_GET["id"]); + $commentid = escape_string($_GET["commentid"]); +} - //Make Sure action is as expected. - if ($_GET["action"]=="yes") { - $action="yes"; - } else if ($_GET["action"]=="no") { - $action="no"; - } +//Make Sure action is as expected. +if ($_GET["action"]=="yes") { + $action="yes"; +} else if ($_GET["action"]=="no") { + $action="no"; +} - if (!$commentid or !$action ) { - //No CommentID / Invalid Action --> Error. - page_error("4","No Comment ID or Action is Invalid"); - exit; - } +if (!$commentid or !$action ) { + //No CommentID / Invalid Action --> Error. + page_error("4","No Comment ID or Action is Invalid"); + exit; +} //Get Data for the Comment Record as it stands. -$sql = "SELECT `helpful-yes`,`helpful-no`,`helpful-rating` FROM `feedback` WHERE `CommentID` = '$commentid' LIMIT 1"; +$sql = "SELECT `helpful-yes`,`helpful-no`,`helpful-rating` + FROM `feedback` + WHERE `CommentID` = '$commentid' + LIMIT 1"; $sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_ERROR); - $row = mysql_fetch_array($sql_result); - $helpful_yes = $row["helpful-yes"]; - $helpful_no = $row["helpful-no"]; - $helpful_rating = $row["helpful-rating"]; +$row = mysql_fetch_array($sql_result); +$helpful_yes = $row["helpful-yes"]; +$helpful_no = $row["helpful-no"]; +$helpful_rating = $row["helpful-rating"]; - if ($action=="yes") { - $helpful_yes = $helpful_yes+1; - } else if ($action=="no") { - $helpful_no = $helpful_no+1; - } +if ($action=="yes") { + $helpful_yes = $helpful_yes+1; +} else if ($action=="no") { + $helpful_no = $helpful_no+1; +} - //Recompute the Helpful Rating for this Comment - $total = $helpful_yes+$helpful_no; - if ($total=="0") { - $helpful_rating=0; - } else { - if ($helpful_yes>$helpful_no) { - $helpful_rating = ($helpful_yes/$total)*100; - } else { - $helpful_rating = ($helpful_no/$total)*-100; - } - } - $sql = "UPDATE `feedback` SET `helpful-yes`='$helpful_yes',`helpful-no`='$helpful_no',`helpful-rating`='$helpful_rating' WHERE `CommentID`='$commentid' LIMIT 1"; - $sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE); +//Recompute the Helpful Rating for this Comment +$total = $helpful_yes+$helpful_no; +if ($total=="0") { + $helpful_rating=0; +} else { + if ($helpful_yes>$helpful_no) { + $helpful_rating = ($helpful_yes/$total)*100; + } else { + $helpful_rating = ($helpful_no/$total)*-100; + } +} +$sql = "UPDATE `feedback` + SET `helpful-yes`='$helpful_yes',`helpful-no`='$helpful_no',`helpful-rating`='$helpful_rating' + WHERE `CommentID`='$commentid' LIMIT 1"; +$sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE); if ($_GET["type"]=="E") { - $type="extensions"; + $type="extensions"; } else if ($_GET["type"]=="T") { - $type="themes"; + $type="themes"; } $return_path="$type/moreinfo.php?id=$id&vid=$vid&".uriparams()."&page=comments&pageid=$_GET[pageid]#$commentid"; diff --git a/mozilla/webtools/update/core/config.php b/mozilla/webtools/update/core/config.php index f9a3f2b7c8b..48fb9aff0ea 100644 --- a/mozilla/webtools/update/core/config.php +++ b/mozilla/webtools/update/core/config.php @@ -41,27 +41,40 @@ // MySQL Server Configuration Variables -include"dbconfig.php"; // Include Database Server Configuration File +include "dbconfig.php"; // Include Database Server Configuration File // General Website Configuration Variables -$websitepath = "/opt/update-beta"; // Local Path to Site Files -$repositorypath = "/opt/update-beta/files/"; //Path to XPI/JAR Respository -$sitehostname = $_SERVER["SERVER_NAME"]; // DNS Hostname, ex. "update.mozilla.org" -$ftpurl = "http://ftp.mozilla.org/pub/mozilla.org"; // URL to FTP site + +// Local Path to Site Files +$websitepath = "/opt/update-beta"; + +// Path to XPI/JAR Respository +$repositorypath = "/opt/update-beta/files/"; + +// DNS Hostname, ex. "update.mozilla.org" +$sitehostname = $_SERVER["SERVER_NAME"]; + +// URL to FTP site +$ftpurl = "http://ftp.mozilla.org/pub/mozilla.org"; // Page Header and Footer Path Variables -$page_header = "$websitepath/core/inc_header.php"; // Path to Page Header on Disk -$page_footer = "$websitepath/core/inc_footer.php"; // Path to Page Footer on Disk + +// Path to Page Header on Disk +$page_header = "$websitepath/core/inc_header.php"; + +// Path to Page Footer on Disk +$page_footer = "$websitepath/core/inc_footer.php"; //Function: getmicrotime() - Page Load Timing Debug Function function getmicrotime() { - list($usec, $sec) = explode(" ", microtime()); - return ((float)$usec + (float)$sec); + list($usec, $sec) = explode(" ", microtime()); + + return ((float)$usec + (float)$sec); } $time_start = getmicrotime(); // Update Core Include Files -include"inc_guids.php"; // GUID --> AppName Handler -include"inc_global.php"; // Global Functions - Variable Cleanup -include"inc_browserdetection.php"; //Browser Detection - App Variable Handling +include "inc_guids.php"; // GUID --> AppName Handler +include "inc_global.php"; // Global Functions - Variable Cleanup +include "inc_browserdetection.php"; //Browser Detection - App Variable Handling ?> diff --git a/mozilla/webtools/update/core/inc_browserdetection.php b/mozilla/webtools/update/core/inc_browserdetection.php index 2cd48c1ad03..c5055a5dd04 100644 --- a/mozilla/webtools/update/core/inc_browserdetection.php +++ b/mozilla/webtools/update/core/inc_browserdetection.php @@ -135,7 +135,11 @@ if (!$application) { $application="firefox"; } //Default App is Firefox //App_Version //Get Max Version for Application Specified if (!$app_version) { - $sql = "SELECT `major`,`minor`,`release`,`SubVer` FROM `applications` WHERE `AppName` = '$application' ORDER BY `major` DESC, `minor` DESC, `release` DESC, `SubVer` DESC LIMIT 1"; + $sql = "SELECT `major`,`minor`,`release`,`SubVer` + FROM `applications` + WHERE `AppName` = '$application' + ORDER BY `major` DESC, `minor` DESC, `release` DESC, `SubVer` DESC + LIMIT 1"; $sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE); $row = mysql_fetch_array($sql_result); $release = "$row[major].$row[minor]"; @@ -152,7 +156,11 @@ if (!$app_version) { //Check for Internal Versioning for the $app_version - $sql = "SELECT `int_version`,`major`,`minor`,`release`,`SubVer` FROM `applications` WHERE `AppName`='$application' AND `int_version` IS NOT NULL ORDER BY `major` DESC, `minor` DESC, `release` DESC, `SubVer` DESC"; + $sql = "SELECT `int_version`,`major`,`minor`,`release`,`SubVer` + FROM `applications` + WHERE `AppName`='$application' + AND `int_version` IS NOT NULL + ORDER BY `major` DESC, `minor` DESC, `release` DESC, `SubVer` DESC"; $sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE); while ($row = mysql_fetch_array($sql_result)) { $release = "$row[major].$row[minor]"; diff --git a/mozilla/webtools/update/core/inc_global.php b/mozilla/webtools/update/core/inc_global.php index 7a3b7ec9ec5..764f2090643 100644 --- a/mozilla/webtools/update/core/inc_global.php +++ b/mozilla/webtools/update/core/inc_global.php @@ -40,13 +40,13 @@ //Cache Control Headers if ($nocache==TRUE) { -$expstr = gmdate("D, d M Y H:i:s", time() - 1800) . " GMT"; -header("Expires: $expstr"); -header("Cache-Control: public, max-age=0"); + $expstr = gmdate("D, d M Y H:i:s", time() - 1800) . " GMT"; + header("Expires: $expstr"); + header("Cache-Control: public, max-age=0"); } else { -$expstr = gmdate("D, d M Y H:i:s", time() + 1800) . " GMT"; -header("Expires: $expstr"); -header("Cache-Control: public, max-age=1800"); + $expstr = gmdate("D, d M Y H:i:s", time() + 1800) . " GMT"; + header("Expires: $expstr"); + header("Cache-Control: public, max-age=1800"); } // --------------------------- @@ -54,47 +54,52 @@ header("Cache-Control: public, max-age=1800"); // --------------------------- function escape_string($value) { - // Stripslashes if we need to - if (get_magic_quotes_gpc()) { - $value = stripslashes($value); - } + // Stripslashes if we need to + if (get_magic_quotes_gpc()) { + $value = stripslashes($value); + } - // Quote it if it's not an integer - if (!is_numeric($value)) { - $value = mysql_real_escape_string($value); - } + // Quote it if it's not an integer + if (!is_numeric($value)) { + $value = mysql_real_escape_string($value); + } - return $value; + return $value; } //Remove HTML tags and escape enities from GET/POST vars. foreach ($_GET as $key => $val) { - $_GET["$key"] = htmlentities(str_replace("\\","",strip_tags($_GET["$key"]))); + $_GET["$key"] = htmlentities(str_replace("\\","",strip_tags($_GET["$key"]))); } foreach ($_POST as $key => $val) { - if (!is_array($_POST["$key"])) { - $_POST["$key"] = htmlentities(str_replace("\\","",strip_tags($_POST["$key"]))); - } + if (!is_array($_POST["$key"])) { + $_POST["$key"] = htmlentities(str_replace("\\","",strip_tags($_POST["$key"]))); + } } // Bug 250596 Fixes for incoming $_GET variables. if ($_GET["application"]) { -$_GET["application"] = escape_string(strtolower($_GET["application"])); -$sql = "SELECT AppID FROM `applications` WHERE `AppName` = '".ucwords(strtolower($_GET["application"]))."' LIMIT 1"; - $sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE); - if (mysql_num_rows($sql_result)===0) {unset($_GET["application"]);} + $_GET["application"] = escape_string(strtolower($_GET["application"])); + $sql = "SELECT AppID FROM `applications` + WHERE `AppName` = '".ucwords(strtolower($_GET["application"]))."' + LIMIT 1"; + $sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE); + if (mysql_num_rows($sql_result)===0) {unset($_GET["application"]);} } if ($_GET["category"] AND $_GET["category"] !=="All" - AND $_GET["category"] !=="Editors Pick" AND $_GET["category"] !=="Popular" - AND $_GET["category"] !=="Top Rated" AND $_GET["category"] !=="Newest") { -$sql = "SELECT CatName FROM `categories` WHERE `CatName` = '".escape_string(ucwords(strtolower($_GET["category"])))."' LIMIT 1"; - $sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE); - if (mysql_num_rows($sql_result)===0) {unset($_GET["category"]);} +AND $_GET["category"] !=="Editors Pick" AND $_GET["category"] !=="Popular" +AND $_GET["category"] !=="Top Rated" AND $_GET["category"] !=="Newest") { + $sql = "SELECT CatName + FROM `categories` + WHERE `CatName` = '".escape_string(ucwords(strtolower($_GET["category"])))."' + LIMIT 1"; + $sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE); + if (mysql_num_rows($sql_result)===0) {unset($_GET["category"]);} } if (!is_numeric($_GET["id"])) { unset($_GET["id"]); } @@ -105,46 +110,46 @@ if (!is_numeric($_GET["numpg"])) { unset($_GET["numpg"]); } // page_error() function function page_error($reason, $custom_message) { - global $page_header, $page_footer; + global $page_header, $page_footer; - echo"Mozilla Update :: Error\n"; + echo"Mozilla Update :: Error\n"; - include"$page_header"; - echo"
"; - echo"

Mozilla Update :: Error

\n"; - echo"\n"; - echo"Mozilla Update has encountered an error and is unable to fulfill your request. Please try your request again later. If the - problem continues, please contact the Mozilla Update staff. More information about the error may be found at the end of this - message.

- Error $reason: $custom_message

-    «« Go Back to Previous Page"; - echo"
\n"; - echo"
\n"; - include"$page_footer"; - echo"\n\n"; - exit; + include"$page_header"; + echo"
"; + echo"

Mozilla Update :: Error

\n"; + echo"\n"; + echo"Mozilla Update has encountered an error and is unable to fulfill your request. Please try your request again later. If the + problem continues, please contact the Mozilla Update staff. More information about the error may be found at the end of this + message.

+ Error $reason: $custom_message

+    «« Go Back to Previous Page"; + echo"
\n"; + echo"
\n"; + include"$page_footer"; + echo"\n\n"; + exit; } function writeFormKey() { - $sql = "SELECT UserPass FROM userprofiles WHERE UserID = '".$_SESSION["uid"]."'"; - $res = mysql_query($sql) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE); - $row = mysql_fetch_array($res); - echo "\n"; + $sql = "SELECT UserPass FROM userprofiles WHERE UserID = '".$_SESSION["uid"]."'"; + $res = mysql_query($sql) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE); + $row = mysql_fetch_array($res); + echo "\n"; } function checkFormKey() { - $key = $_POST["formkey"]; - $sql = "SELECT UserPass FROM userprofiles WHERE UserID = '".$_SESSION["uid"]."'"; - $res = mysql_query($sql) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE); - $row = mysql_fetch_array($res); - if ($key != md5($row["UserPass"])) - { - echo "
WARNING: FORMKEY MISMATCH!
\n"; - return false; - } - return true; + $key = $_POST["formkey"]; + $sql = "SELECT UserPass FROM userprofiles WHERE UserID = '".$_SESSION["uid"]."'"; + $res = mysql_query($sql) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE); + $row = mysql_fetch_array($res); + if ($key != md5($row["UserPass"])) + { + echo "
WARNING: FORMKEY MISMATCH!
\n"; + return false; + } + return true; } // ----------------------------- @@ -153,27 +158,27 @@ function checkFormKey() // ----------------------------- function uriparams() { - global $app_version, $application, $items_per_page, $category, $OS, $uriparams_skip; - $uriparams = ""; + global $app_version, $application, $items_per_page, $category, $OS, $uriparams_skip; + $uriparams = ""; - if ($application and $uriparams_skip !="application") { $uriparams .="application=$application&"; } - if ($app_version and $uriparams_skip !="application") { $uriparams .="version=$app_version&"; } - if ($OS) { $uriparams .="os=$OS&"; } - if ($category and $uriparams_skip !="category") { $uriparams .="category=$category&"; } - if ($items_per_page) { $uriparams .="numpg=$items_per_page"; } - if (substr($uriparams, -1)==";") { - $uriparams = substr($uriparams,0,strlen($uriparams)-5); - } - return $uriparams; + if ($application and $uriparams_skip !="application") { $uriparams .="application=$application&"; } + if ($app_version and $uriparams_skip !="application") { $uriparams .="version=$app_version&"; } + if ($OS) { $uriparams .="os=$OS&"; } + if ($category and $uriparams_skip !="category") { $uriparams .="category=$category&"; } + if ($items_per_page) { $uriparams .="numpg=$items_per_page"; } + if (substr($uriparams, -1)==";") { + $uriparams = substr($uriparams,0,strlen($uriparams)-5); + } + return $uriparams; } // ----------------------------- // function installtrigger() -- print installtrigger function for extension/theme installation on page. -// Usage null uriparams(string functionname) +// Usage null uriparams(string functionname) // ----------------------------- function installtrigger($functionname) { - if ($functionname=="extensions") { + if ($functionname=="extensions") { echo' '; - } + } } ?> \ No newline at end of file diff --git a/mozilla/webtools/update/core/inc_guids.php b/mozilla/webtools/update/core/inc_guids.php index d6e35256d8e..47e569f74cd 100644 --- a/mozilla/webtools/update/core/inc_guids.php +++ b/mozilla/webtools/update/core/inc_guids.php @@ -38,12 +38,10 @@ //Reset GUIDs to something human-readable if ($_GET["application"]=="{ec8030f7-c20a-464f-9b0e-13a3a9e97384}") { -$_GET["application"]="firefox"; - + $_GET["application"]="firefox"; } else if ($_GET["application"]=="{3550f703-e582-4d05-9a08-453d09bdfdc6}") { -$_GET["application"]="thunderbird"; - + $_GET["application"]="thunderbird"; } else if ($_GET["application"]=="{86c18b42-e466-45a9-ae7a-9b95ba6f5640}") { -$_GET["application"]="mozilla"; + $_GET["application"]="mozilla"; } ?> \ No newline at end of file diff --git a/mozilla/webtools/update/core/inc_header.php b/mozilla/webtools/update/core/inc_header.php index 38f3c139d9e..839df10ea42 100644 --- a/mozilla/webtools/update/core/inc_header.php +++ b/mozilla/webtools/update/core/inc_header.php @@ -37,7 +37,7 @@ // ***** END LICENSE BLOCK ***** ?> - + diff --git a/mozilla/webtools/update/core/install.php b/mozilla/webtools/update/core/install.php index a96e4e9f592..538fa68e0fc 100755 --- a/mozilla/webtools/update/core/install.php +++ b/mozilla/webtools/update/core/install.php @@ -43,79 +43,79 @@ require"../core/config.php"; $uri = escape_string(str_replace(" ","+",$_GET["uri"])); $sql = "SELECT `vID`, TM.ID, `URI` FROM `version` TV INNER JOIN `main` TM ON TM.ID=TV.ID WHERE `URI`='$uri' LIMIT 1"; $sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE); - if (mysql_num_rows($sql_result)=="0") { - exit("Invalid URI cannot Continue"); - } +if (mysql_num_rows($sql_result)=="0") { + exit("Invalid URI cannot Continue"); +} - $row = mysql_fetch_array($sql_result); - $uri=$row["URI"]; - $id = $row["ID"]; - $vid = $row["vID"]; +$row = mysql_fetch_array($sql_result); +$uri=$row["URI"]; +$id = $row["ID"]; +$vid = $row["vID"]; // New DownloadCount management Code.. //Check for user, to see if they recently accessed this file (filters duplicate/triplicate+ requests in a short period). $maxlife = date("YmdHis", mktime(date("H"), date("i")-10, date("s"), date("m"), date("d"), date("Y"))); //Are we behind a proxy and given the IP via an alternate enviroment variable? If so, use it. - if ($_SERVER["HTTP_X_FORWARDED_FOR"]) { - $remote_addr = $_SERVER["HTTP_X_FORWARDED_FOR"]; - } else { - $remote_addr = $_SERVER["REMOTE_ADDR"]; - } +if ($_SERVER["HTTP_X_FORWARDED_FOR"]) { + $remote_addr = $_SERVER["HTTP_X_FORWARDED_FOR"]; +} else { + $remote_addr = $_SERVER["REMOTE_ADDR"]; +} $sql = "SELECT `dID` FROM `downloads` WHERE `ID`='$id' AND `vID`='$vid' AND `user_ip`='$remote_addr' AND `user_agent` = '$_SERVER[HTTP_USER_AGENT]' AND `date`>'$maxlife' AND `type`='download' LIMIT 1"; $sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE); - if (mysql_num_rows($sql_result)=="0") { - //Insert a record of this download for the next 10 minutes anyway. :-) - $today=date("YmdHis"); +if (mysql_num_rows($sql_result)=="0") { + //Insert a record of this download for the next 10 minutes anyway. :-) + $today=date("YmdHis"); - $sql = "INSERT INTO `downloads` (`ID`,`date`,`vID`, `user_ip`, `user_agent`, `type`) VALUES ('$id','$today','$vid', '$remote_addr', '$_SERVER[HTTP_USER_AGENT]', 'download');"; - $sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE); + $sql = "INSERT INTO `downloads` (`ID`,`date`,`vID`, `user_ip`, `user_agent`, `type`) VALUES ('$id','$today','$vid', '$remote_addr', '$_SERVER[HTTP_USER_AGENT]', 'download');"; + $sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE); - //Cleanup the Individual Downloads part of the table for old records - $sql = "DELETE FROM `downloads` WHERE `date`<'$maxlife' AND `type`='download'"; - $sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE); + //Cleanup the Individual Downloads part of the table for old records + $sql = "DELETE FROM `downloads` WHERE `date`<'$maxlife' AND `type`='download'"; + $sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE); - $today=date("Ymd")."000000"; + $today=date("Ymd")."000000"; - //Per day download tracking -- Record hits for this day in the record (if it doesn't exist create it) - $sql = "SELECT `dID` FROM `downloads` WHERE `ID`='$id' AND `date`='$today' AND `type`='count' LIMIT 1"; - $sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE); - if (mysql_num_rows($sql_result)=="0") { - $sql = "INSERT INTO `downloads` (`ID`,`date`,`downloadcount`,`type`) VALUES ('$id','$today','1','count');"; - } else { - $row = mysql_fetch_array($sql_result); - $sql = "UPDATE `downloads` SET `downloadcount`=downloadcount+1 WHERE `dID`='$row[dID]' LIMIT 1"; - } + //Per day download tracking -- Record hits for this day in the record (if it doesn't exist create it) + $sql = "SELECT `dID` FROM `downloads` WHERE `ID`='$id' AND `date`='$today' AND `type`='count' LIMIT 1"; + $sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE); + if (mysql_num_rows($sql_result)=="0") { + $sql = "INSERT INTO `downloads` (`ID`,`date`,`downloadcount`,`type`) VALUES ('$id','$today','1','count');"; + } else { + $row = mysql_fetch_array($sql_result); + $sql = "UPDATE `downloads` SET `downloadcount`=downloadcount+1 WHERE `dID`='$row[dID]' LIMIT 1"; + } - $sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE); + $sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE); - //Download Statistic Management Code -- Maintain the last 7 days record count - $mindate = date("Ymd", mktime(0, 0, 0, date("m"), date("d")-7, date("Y")))."000000"; - $downloadcount="0"; - $sql = "SELECT `downloadcount` FROM `downloads` WHERE `ID`='$id' AND `date`>='$mindate' AND `type`='count' ORDER BY `date` DESC"; - $sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE); - while ($row = mysql_fetch_array($sql_result)) { - $downloadcount = $downloadcount+$row["downloadcount"]; - } + //Download Statistic Management Code -- Maintain the last 7 days record count + $mindate = date("Ymd", mktime(0, 0, 0, date("m"), date("d")-7, date("Y")))."000000"; + $downloadcount="0"; + $sql = "SELECT `downloadcount` FROM `downloads` WHERE `ID`='$id' AND `date`>='$mindate' AND `type`='count' ORDER BY `date` DESC"; + $sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE); + while ($row = mysql_fetch_array($sql_result)) { + $downloadcount = $downloadcount+$row["downloadcount"]; + } - //Update the 7 day count in the main record. - $sql = "UPDATE `main` SET `downloadcount`='$downloadcount' WHERE `ID`='$id' LIMIT 1"; - $sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE); + //Update the 7 day count in the main record. + $sql = "UPDATE `main` SET `downloadcount`='$downloadcount' WHERE `ID`='$id' LIMIT 1"; + $sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE); - //Update the total downloadcount in the main record. - $sql = "UPDATE `main` SET `TotalDownloads`=TotalDownloads+1 WHERE `ID`='$id' LIMIT 1"; - $sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE); + //Update the total downloadcount in the main record. + $sql = "UPDATE `main` SET `TotalDownloads`=TotalDownloads+1 WHERE `ID`='$id' LIMIT 1"; + $sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE); - //Clean up the Counts per day for >8 days. - $sql = "DELETE FROM `downloads` WHERE `ID`='$id' AND `date`<'$mindate' AND `type`='count'"; - $sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE); - - } + //Clean up the Counts per day for >8 days. + $sql = "DELETE FROM `downloads` WHERE `ID`='$id' AND `date`<'$mindate' AND `type`='count'"; + $sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE); + +} //Send User on their way to the file, if requested... if ($_GET["passthrough"]=="yes") { - header("Location: $uri"); + header("Location: $uri"); } ?> \ No newline at end of file diff --git a/mozilla/webtools/update/core/postfeedback.php b/mozilla/webtools/update/core/postfeedback.php index 267f8905bb5..982e74f4288 100644 --- a/mozilla/webtools/update/core/postfeedback.php +++ b/mozilla/webtools/update/core/postfeedback.php @@ -43,36 +43,36 @@ require"../core/config.php"; //Check and see if the ID/vID is valid. $sql = "SELECT TM.ID, TV.vID FROM `main` TM INNER JOIN `version` TV ON TM.ID=TV.ID WHERE TM.ID = '".escape_string($_POST[id])."' AND `vID`='".escape_string($_POST["vid"])."' LIMIT 1"; $sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_ERROR); - if(mysql_num_rows($sql_result)=="0") { - unset($_POST["id"],$_POST["vid"],$id,$vid); - } else { - $id = escape_string($_POST["id"]); - $vid = escape_string($_POST["vid"]); - } +if(mysql_num_rows($sql_result)=="0") { + unset($_POST["id"],$_POST["vid"],$id,$vid); +} else { + $id = escape_string($_POST["id"]); + $vid = escape_string($_POST["vid"]); +} - $name = escape_string(strip_tags($_POST["name"])); - $title = escape_string(strip_tags($_POST["title"])); - $rating = escape_string($_POST["rating"]); - $comments = nl2br(strip_tags(escape_string($_POST["comments"]))); - $email = escape_string($_POST["email"]); - if (!$name) { - $name="Anonymous"; - } - if (!$title) { - $title="No Title"; - } +$name = escape_string(strip_tags($_POST["name"])); +$title = escape_string(strip_tags($_POST["title"])); +$rating = escape_string($_POST["rating"]); +$comments = nl2br(strip_tags(escape_string($_POST["comments"]))); +$email = escape_string($_POST["email"]); +if (!$name) { + $name="Anonymous"; +} +if (!$title) { + $title="No Title"; +} - //Make Sure Rating is as expected. - if (is_numeric($rating) and $rating<=5 and $rating>=0) { - } else { - unset($rating); - } +//Make Sure Rating is as expected. +if (is_numeric($rating) and $rating<=5 and $rating>=0) { +} else { + unset($rating); +} - if (!$rating or !$comments ) { - //No Rating or Comment Defined, throw an error. - page_error("3","Comment is Blank or Rating is Null."); - exit; - } +if (!$rating or !$comments ) { + //No Rating or Comment Defined, throw an error. + page_error("3","Comment is Blank or Rating is Null."); + exit; +} //Compile Info about What Version of the item this comment is about. @@ -81,78 +81,93 @@ $sql = "SELECT TV.Version, `OSName`, `AppName` FROM `version` TV INNER JOIN `applications` TA ON TA.AppID=TV.AppID WHERE TV.ID = '$id' AND TV.vID='$vid' LIMIT 1"; $sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_ERROR); - $row = mysql_fetch_array($sql_result); - $version = $row["Version"]; - $os = $row["OSName"]; - $appname = $row["AppName"]; - $versiontagline = "version $version for $appname"; - if ($os !=="ALL") {$versiontagline .=" on $os"; } +$row = mysql_fetch_array($sql_result); +$version = $row["Version"]; +$os = $row["OSName"]; +$appname = $row["AppName"]; +$versiontagline = "version $version for $appname"; +if ($os !=="ALL") {$versiontagline .=" on $os"; } //Are we behind a proxy and given the IP via an alternate enviroment variable? If so, use it. - if ($_SERVER["HTTP_X_FORWARDED_FOR"]) { - $remote_addr = $_SERVER["HTTP_X_FORWARDED_FOR"]; - } else { - $remote_addr = $_SERVER["REMOTE_ADDR"]; - } +if ($_SERVER["HTTP_X_FORWARDED_FOR"]) { + $remote_addr = $_SERVER["HTTP_X_FORWARDED_FOR"]; +} else { + $remote_addr = $_SERVER["REMOTE_ADDR"]; +} //Check the Formkey against the DB, and see if this has already been posted... $formkey = escape_string($_POST["formkey"]); $date = date("Y-m-d H:i:s", mktime(0, 0, 0, date("m"), date("d")-1, date("Y"))); -$sql = "SELECT `CommentID` FROM `feedback` WHERE `formkey` = '$formkey' AND `CommentDate`>='$date'"; +$sql = "SELECT `CommentID` + FROM `feedback` + WHERE `formkey` = '$formkey' + AND `CommentDate`>='$date'"; $sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_ERROR); if (mysql_num_rows($sql_result)=="0") { - //FormKey check passed, now let's see if this IP is banned... - $sql = "SELECT `bID` from `feedback_ipbans` WHERE `beginip` <= '$remote_addr' AND `endip` >='$remote_addr' LIMIT 1"; - $sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_ERROR); - if (mysql_num_rows($sql_result)=="0") { + //FormKey check passed, now let's see if this IP is banned... + $sql = "SELECT `bID` + FROM `feedback_ipbans` + WHERE `beginip` <= '$remote_addr' + AND `endip` >='$remote_addr' + LIMIT 1"; + $sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_ERROR); + if (mysql_num_rows($sql_result)=="0") { //No Bans Returned, Proceed... - - - //FormKey doesn't exist, go ahead and add their comment. - $sql = "INSERT INTO `feedback` (`ID`, `CommentName`, `CommentVote`, `CommentTitle`, `CommentNote`, `CommentDate`, `commentip`, `email`, `formkey`, `VersionTagline`) VALUES ('$id', '$name', '$rating', '$title', '$comments', NOW(NULL), '$remote_addr', '$email', '$formkey', '$versiontagline');"; - $sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE); - //Get Rating Data and Create $ratingarray - $date = date("Y-m-d H:i:s", mktime(0, 0, 0, date("m"), date("d")-30, date("Y"))); - $sql = "SELECT ID, CommentVote FROM `feedback` WHERE `ID` = '$id' AND `CommentDate`>='$date' AND `CommentVote` IS NOT NULL"; - $sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE); - while ($row = mysql_fetch_array($sql_result)) { - $ratingarray[$row[ID]][] = $row["CommentVote"]; - } - - //Compile Rating Average - if (!$ratingarray[$id]) { - $ratingarray[$id] = array(); - } - $numratings = count($ratingarray[$id]); - $sumratings = array_sum($ratingarray[$id]); - - if ($numratings>0) { - $rating = round($sumratings/$numratings, 1); - } else { - $rating="2.5"; //Default Rating - } + //FormKey doesn't exist, go ahead and add their comment. + $sql = "INSERT INTO `feedback` (`ID`, `CommentName`, `CommentVote`, `CommentTitle`, `CommentNote`, `CommentDate`, `commentip`, `email`, `formkey`, `VersionTagline`) + VALUES ('$id', '$name', '$rating', '$title', '$comments', NOW(NULL), '$remote_addr', '$email', '$formkey', '$versiontagline');"; + $sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE); - $sql = "UPDATE `main` SET `Rating`='$rating' WHERE `ID`='$id' LIMIT 1"; - $sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE); - } else { - //User is Banned, Add Param to URI to throw an error about this... - $action="ipbanned"; + //Get Rating Data and Create $ratingarray + $date = date("Y-m-d H:i:s", mktime(0, 0, 0, date("m"), date("d")-30, date("Y"))); + $sql = "SELECT ID, CommentVote + FROM `feedback` + WHERE `ID` = '$id' + AND `CommentDate`>='$date' + AND `CommentVote` IS NOT NULL"; + $sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE); + while ($row = mysql_fetch_array($sql_result)) { + $ratingarray[$row[ID]][] = $row["CommentVote"]; } + + //Compile Rating Average + if (!$ratingarray[$id]) { + $ratingarray[$id] = array(); + } + $numratings = count($ratingarray[$id]); + $sumratings = array_sum($ratingarray[$id]); + + if ($numratings > 0) { + $rating = round($sumratings/$numratings, 1); + } else { + $rating = "2.5"; //Default Rating + } + + + $sql = "UPDATE `main` + SET `Rating`='$rating' + WHERE `ID`='$id' + LIMIT 1"; + $sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE); + } else { + //User is Banned, Add Param to URI to throw an error about this... + $action="ipbanned"; + } } if ($_POST["type"]=="E") { - $type="extensions"; + $type="extensions"; } else if ($_POST["type"]=="T") { - $type="themes"; + $type="themes"; } if (!$action) { - $action="successful"; + $action="successful"; } $return_path="$type/moreinfo.php?id=$id&vid=$vid&page=comments&action=$action"; diff --git a/mozilla/webtools/update/core/reportcomment.php b/mozilla/webtools/update/core/reportcomment.php index f3477680fba..b237cb76149 100755 --- a/mozilla/webtools/update/core/reportcomment.php +++ b/mozilla/webtools/update/core/reportcomment.php @@ -41,36 +41,43 @@ require"../core/config.php"; //Check and see if the CommentID/ID is valid. -$sql = "SELECT `ID`, `CommentID` FROM `feedback` WHERE `ID` = '".escape_string($_GET[id])."' AND `CommentID`='".escape_string($_GET["commentid"])."' LIMIT 1"; +$sql = "SELECT `ID`, `CommentID` + FROM `feedback` + WHERE `ID` = '".escape_string($_GET[id])."' + AND `CommentID`='".escape_string($_GET["commentid"])."' + LIMIT 1"; $sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_ERROR); - if(mysql_num_rows($sql_result)=="0") { - unset($_GET["id"],$_GET["commentid"],$id,$commentid); - } else { - $id = escape_string($_GET["id"]); - $commentid = escape_string($_GET["commentid"]); - } +if(mysql_num_rows($sql_result)=="0") { + unset($_GET["id"],$_GET["commentid"],$id,$commentid); +} else { + $id = escape_string($_GET["id"]); + $commentid = escape_string($_GET["commentid"]); +} - //Make Sure action is as expected. - if ($_GET["action"]=="report") { - $action="yes"; - } +//Make Sure action is as expected. +if ($_GET["action"]=="report") { + $action="yes"; +} - if (!$commentid or !$action ) { - //No CommentID / Invalid Action --> Error. - page_error("4","No Comment ID or Action is Invalid"); - exit; - } +if (!$commentid or !$action ) { + //No CommentID / Invalid Action --> Error. + page_error("4","No Comment ID or Action is Invalid"); + exit; +} //Set Flag on the Comment Record - $sql = "UPDATE `feedback` SET `flag`='YES' WHERE `CommentID`='$commentid' LIMIT 1"; - $sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE); +$sql = "UPDATE `feedback` + SET `flag`='YES' + WHERE `CommentID`='$commentid' + LIMIT 1"; +$sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE); if ($_GET["type"]=="E") { - $type="extensions"; + $type="extensions"; } else if ($_GET["type"]=="T") { - $type="themes"; + $type="themes"; } $return_path="$type/moreinfo.php?id=$id&vid=$vid&".uriparams()."&page=comments&pageid=$_GET[pageid]#$commentid"; @@ -80,6 +87,7 @@ $return_path="$type/moreinfo.php?id=$id&vid=$vid&".uriparams()."&page=comments&p Mozilla Update :: Report a Comment +

Author Profile »

-$usermode_text\n"; } ?> +$usermode_text\n"; + +?> Homepage: $userwebsite"; @@ -110,23 +120,28 @@ echo"$useremail";  

All Extensions and Themes by

$name"; -echo"$description
\n"; -} + echo"

$name

"; + echo"$description
\n"; + } } if ($numresults=="0") { -echo"No Extensions or Themes in the Database for $username"; + echo"No Extensions or Themes in the Database for $username"; } ?> diff --git a/mozilla/webtools/update/rss/inc_rssfeed.php b/mozilla/webtools/update/rss/inc_rssfeed.php index 301163080bb..3f20c03e076 100644 --- a/mozilla/webtools/update/rss/inc_rssfeed.php +++ b/mozilla/webtools/update/rss/inc_rssfeed.php @@ -36,59 +36,57 @@ // the terms of any one of the MPL, the GPL or the LGPL. // // ***** END LICENSE BLOCK ***** -?> -\n"; echo "\n"; -echo " " . htmlspecialchars($sitetitle,ENT_NOQUOTES,UTF-8) . "::" . htmlspecialchars($list,ENT_NOQUOTES,UTF-8) . " " . $listType . "\n"; +echo " " . htmlspecialchars($sitetitle,ENT_NOQUOTES,"UTF-8") . "::" . htmlspecialchars($list,ENT_NOQUOTES,"UTF-8") . " " . $listType . "\n"; echo " " . $siteurl . "\n"; -echo " " . htmlspecialchars($sitedescription,ENT_NOQUOTES,UTF-8) . -"\n"; +echo " " . htmlspecialchars($sitedescription,ENT_NOQUOTES,"UTF-8") . "\n"; echo " " . $sitelanguage . "\n"; -echo " " . htmlspecialchars($sitecopyright,ENT_NOQUOTES,UTF-8) . "\n"; +echo " " . htmlspecialchars($sitecopyright,ENT_NOQUOTES,"UTF-8") . "\n"; echo " " . $currenttime . "\n"; echo " " . $rssttl . "\n"; echo " \n"; -echo " " . htmlspecialchars($sitetitle,ENT_NOQUOTES,UTF-8) . "\n"; +echo " " . htmlspecialchars($sitetitle,ENT_NOQUOTES,"UTF-8") . "\n"; echo " " . $siteurl . "\n"; echo " " . $siteicon . "\n"; echo " 16\n"; echo " 16\n"; echo " \n"; - $sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE); - while ($row = mysql_fetch_array($sql_result)) { - $id = $row["ID"]; - $title = htmlspecialchars($row["Title"],ENT_NOQUOTES,UTF-8); - $description = htmlspecialchars($row["Description"],ENT_NOQUOTES,UTF-8); - $dateupdated = gmdate("r", strtotime($row["DateStamp"])); - $version = htmlspecialchars($row["Version"],ENT_NOQUOTES,UTF-8); - $vid = $row["vID"]; - $appname = htmlspecialchars($row["AppName"],ENT_NOQUOTES,UTF-8); +$sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE); +while ($row = mysql_fetch_array($sql_result)) { + $id = $row["ID"]; + $title = htmlspecialchars($row["Title"],ENT_NOQUOTES,"UTF-8"); + $description = htmlspecialchars($row["Description"],ENT_NOQUOTES,"UTF-8"); + $dateupdated = gmdate("r", strtotime($row["DateStamp"])); + $version = htmlspecialchars($row["Version"],ENT_NOQUOTES,"UTF-8"); + $vid = $row["vID"]; + $appname = htmlspecialchars($row["AppName"],ENT_NOQUOTES,"UTF-8"); - echo " \n"; - echo " " . $dateupdated . "\n"; - echo " " . $title . " " . $version . " for " . $appname . "\n"; - echo " http://$sitehostname/" . strtolower($listType) . "/moreinfo.php?id=" . $id . "&vid=" . $vid . "\n"; - echo " " . $description . "\n"; - echo " \n"; + echo " \n"; + echo " " . $dateupdated . "\n"; + echo " " . $title . " " . $version . " for " . $appname . "\n"; + echo " http://$sitehostname/" . strtolower($listType) . "/moreinfo.php?id=" . $id . "&vid=" . $vid . "\n"; + echo " " . $description . "\n"; + echo " \n"; - } +} echo "\n"; echo "\n"; diff --git a/mozilla/webtools/update/rss/index.php b/mozilla/webtools/update/rss/index.php index bffdf1b3aeb..204675de880 100644 --- a/mozilla/webtools/update/rss/index.php +++ b/mozilla/webtools/update/rss/index.php @@ -44,14 +44,14 @@ $app = strtolower($_GET["application"]); // Firefox, Thunderbird, Mozilla $type = escape_string($_GET["type"]); //E, T, [P] $list = ucwords(strtolower($_GET["list"])); // Newest, Updated, [Editors], Popular -$sitetitle = "Mozilla Update"; -$siteicon = "http://www.mozilla.org/images/mozilla-16.png"; -$siteurl = $_SERVER["SERVER_NAME"]; +$sitetitle = "Mozilla Update"; +$siteicon = "http://www.mozilla.org/images/mozilla-16.png"; +$siteurl = $_SERVER["SERVER_NAME"]; $sitedescription = "the way to keep your mozilla software up-to-date"; -$sitelanguage = "en-US"; -$sitecopyright = "Copyright 2004-2005 The Mozilla Organization"; -$currenttime = gmdate(r);// GMT -$rssttl = "120"; //Life of feed in minutes +$sitelanguage = "en-US"; +$sitecopyright = "Copyright 2004-2005 The Mozilla Organization"; +$currenttime = gmdate(r);// GMT +$rssttl = "120"; //Life of feed in minutes header("Content-Type: application/xml; charset=utf-8");