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"