// // Alternatively, the contents of this file may be used under the terms of // either the GNU General Public License Version 2 or later (the "GPL"), or // the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), // in which case the provisions of the GPL or the LGPL are applicable instead // of those above. If you wish to allow use of your version of this file only // under the terms of either the GPL or the LGPL, and not to allow others to // use your version of this file under the terms of the MPL, indicate your // decision by deleting the provisions above and replace them with the notice // and other provisions required by the GPL or the LGPL. If you do not delete // the provisions above, a recipient may use your version of this file under // the terms of any one of the MPL, the GPL or the LGPL. // // ***** END LICENSE BLOCK ***** //XXX -- Meta-Ratings not yet production ready. Disabled for Update 1.0. Bug 247144. exit("Meta-Ratings Disabled"); //Submit Review/Rating Feedback to Table 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_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"]); } //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; } //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_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"]; 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); if ($_GET["type"]=="E") { $type="extensions"; } else if ($_GET["type"]=="T") { $type="themes"; } $return_path="$type/moreinfo.php?id=$id&vid=$vid&".uriparams()."&page=comments&pageid=$_GET[pageid]#$commentid"; header("Location: http://$sitehostname/$return_path"); exit; ?>