$sql = "SELECT lid, cid, title, description, date, hits, downloadratingsummary, totalvotes, totalcomments, filesize, version, homepage FROM ".$prefix."_downloads_downloads WHERE date LIKE '%$newdownloadDB%' ORDER BY title ASC";
if ($orderby != "titleA" AND $orderby != "dateA" AND $orderby != "hitsA" AND $orderby != "ratingA" AND $orderby != "titleD" AND $orderby != "dateD" AND $orderby != "hitsD" AND $orderby != "ratingD") {
Header("Location: index.php");
die();
}
if ($orderby == "titleA") $orderby = "title ASC";
if ($orderby == "dateA") $orderby = "date ASC";
if ($orderby == "hitsA") $orderby = "hits ASC";
if ($orderby == "ratingA") $orderby = "downloadratingsummary ASC";
if ($orderby == "titleD") $orderby = "title DESC";
if ($orderby == "dateD") $orderby = "date DESC";
if ($orderby == "hitsD") $orderby = "hits DESC";
if ($orderby == "ratingD") $orderby = "downloadratingsummary DESC";
return $orderby;
}
function convertorderbytrans($orderby) {
if ($orderby != "hits ASC" AND $orderby != "hits DESC" AND $orderby != "title ASC" AND $orderby != "title DESC" AND $orderby != "date ASC" AND $orderby != "date DESC" AND $orderby != "downloadratingsummary ASC" AND $orderby != "downloadratingsummary DESC") {
Header("Location: index.php");
die();
}
if ($orderby == "hits ASC") $orderbyTrans = ""._POPULARITY1."";
if ($orderby == "hits DESC") $orderbyTrans = ""._POPULARITY2."";
if ($orderby == "title ASC") $orderbyTrans = ""._TITLEAZ."";
if ($orderby == "title DESC") $orderbyTrans = ""._TITLEZA."";
if ($orderby == "date ASC") $orderbyTrans = ""._DDATE1."";
if ($orderby == "date DESC") $orderbyTrans = ""._DDATE2."";
if ($orderby == "downloadratingsummary ASC") $orderbyTrans = ""._RATING1."";
if ($orderby == "downloadratingsummary DESC") $orderbyTrans = ""._RATING2."";
return $orderbyTrans;
}
function convertorderbyout($orderby) {
if ($orderby != "title ASC" AND $orderby != "date ASC" AND $orderby != "hits ASC" AND $orderby != "downloadratingsummary ASC" AND $orderby != "title DESC" AND $orderby != "date DESC" AND $orderby != "hits DESC" AND $orderby != "downloadratingsummary DESC") {
Header("Location: index.php");
die();
}
if ($orderby == "title ASC") $orderby = "titleA";
if ($orderby == "date ASC") $orderby = "dateA";
if ($orderby == "hits ASC") $orderby = "hitsA";
if ($orderby == "downloadratingsummary ASC") $orderby = "ratingA";
if ($orderby == "title DESC") $orderby = "titleD";
if ($orderby == "date DESC") $orderby = "dateD";
if ($orderby == "hits DESC") $orderby = "hitsD";
if ($orderby == "downloadratingsummary DESC") $orderby = "ratingD";
return $orderby;
}
function getit($lid) {
global $prefix, $db;
$lid = intval($lid);
$db->sql_query("update ".$prefix."_downloads_downloads set hits=hits+1 WHERE lid='$lid'");
update_points(17);
$result = $db->sql_query("SELECT url FROM ".$prefix."_downloads_downloads WHERE lid='$lid'");
list($url) = $db->sql_fetchrow($result);
Header("Location: $url");
}
function search($query, $min, $orderby, $show) {
global $prefix, $db, $admin, $bgcolor2, $module_name;
include("modules/$module_name/d_config.php");
include("header.php");
if (!isset($min)) $min=0;
if (!isset($max)) $max=$min+$downloadsresults;
if(isset($orderby)) {
$orderby = convertorderbyin($orderby);
} else {
$orderby = "title ASC";
}
if ($show!="") {
$downloadsresults = $show;
} else {
$show=$downloadsresults;
}
$query = check_html($query, nohtml);
$query = addslashes($query);
$result = $db->sql_query("SELECT lid, cid, title, url, description, date, hits, downloadratingsummary, totalvotes, totalcomments, filesize, version, homepage FROM ".$prefix."_downloads_downloads WHERE title LIKE '%$query%' OR description LIKE '%$query%' ORDER BY $orderby LIMIT $min,$downloadsresults");
$fullcountresult = $db->sql_query("SELECT lid, title, description, date, hits, downloadratingsummary, totalvotes, totalcomments FROM ".$prefix."_downloads_downloads WHERE title LIKE '%$query%' OR description LIKE '%$query%' ");
global $prefix, $db, $admin, $bgcolor2, $module_name;
include("header.php");
include("modules/$module_name/d_config.php");
menu(1);
echo "<br>";
$lid = intval(trim($lid));
$result=$db->sql_query("SELECT ratinguser, rating, ratingcomments, ratingtimestamp FROM ".$prefix."_downloads_votedata WHERE ratinglid = '$lid' AND ratingcomments != '' ORDER BY ratingtimestamp DESC");
$result=$db->sql_query("SELECT * FROM ".$prefix."_downloads_votedata WHERE ratinglid='$ratinglid' AND ratinguser='$anonymous' AND ratinghostname = '$ip' AND TO_DAYS(NOW()) - TO_DAYS(ratingtimestamp) < '$anonwaitdays'");
$anonvotecount = $db->sql_numrows($result);
if ($anonvotecount >= 1) {
$error = "anonflood";
completevote($error);
$passtest = "no";
}
}
/* Check if OUTSIDE user is trying to vote more than once per day. */
$result=$db->sql_query("SELECT * FROM ".$prefix."_downloads_votedata WHERE ratinglid='$ratinglid' AND ratinguser='outside' AND ratinghostname = '$ip' AND TO_DAYS(NOW()) - TO_DAYS(ratingtimestamp) < '$outsidewaitdays'");
$outsidevotecount = $db->sql_numrows($result);
if ($outsidevotecount >= 1) {
$error = "outsideflood";
completevote($error);
$passtest = "no";
}
}
/* Passed Tests */
if ($passtest == "yes") {
$comment = stripslashes($comment);
if ($comment != "") {
update_points(19);
}
update_points(18);
/* All is well. Add to Line Item Rate to DB. */
$ratinglid = intval($ratinglid);
$rating = intval($rating);
$db->sql_query("INSERT into ".$prefix."_downloads_votedata values (NULL,'$ratinglid', '$ratinguser', '$rating', '$ip', '$ratingcomments', now())");
/* All is well. Calculate Score & Add to Summary (for quick retrieval & sorting) to DB. */
/* NOTE: If weight is modified, ALL downloads need to be refreshed with new weight. */
/* Running a SQL statement with your modded calc for ALL downloads will accomplish this. */
$voteresult = $db->sql_query("SELECT rating, ratinguser, ratingcomments FROM ".$prefix."_downloads_votedata WHERE ratinglid = '$ratinglid'");
$totalvotesDB = $db->sql_numrows($voteresult);
include ("modules/$module_name/voteinclude.php");
$finalrating = intval($finalrating);
$totalvotesDB = intval($totalvotesDB);
$truecomments = intval($truecomments);
$ratinglid = intval($ratinglid);
$db->sql_query("UPDATE ".$prefix."_downloads_downloads SET downloadratingsummary='$finalrating',totalvotes='$totalvotesDB',totalcomments='$truecomments' WHERE lid = '$ratinglid'");