<?
// Get search term
$searchTerm = $_GET['term']; // required for PDO & AJAX request - jQueryUI (autocomplete)
// New PDO VERSION - April 6, 2020 - Removed old MySQLi code & replaced all with PDO code, retaining the full array for HTML/compatibility
// Secure & faster search quering on larger result sets (query: the) for example.
try {
$conn = new PDO('mysql:host=localhost;dbname=database', 'user', 'password');
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$conn->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); // Prevent advanced injection by disabling emulated prepared statements
}
catch (PDOException $e) {
die('Unable to connect with the database');
}
$stmt = $conn->prepare('SELECT * FROM torrents WHERE name LIKE :keyword OR tags LIKE :tags'); // Added: search by tags too
$stmt->bindValue('keyword', '%' . $searchTerm . '%');
$stmt->bindValue('tags', '%' . $searchTerm . '%');
$stmt->execute();
$result = array();
while($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
$name = $row['name'];
$hits = $row['hits'];
$views = $row['views'];
$image1 = $row['image1'];
$image2 = $row['image2'];
$ratingsum = (int) $row['ratingsum'];
$numratings = (int) $row['numratings'];
$descr = $row['descr'];
$data['id'] = $row['id'];
$data['value'] = $name;
$data['result'] = '<a style="cursor:default;background:none;border:none" href="/details/'.$row['id'].'/" title=" ">
<!-- SVG loading animation for covers -->
<span style="background: url(https://website.com/images/loading-ellipsis.svg) 36px -0px no-repeat;border:none">
<img src="https://website.com/images/covers/'.$row['cover1'].'" style="width:107px;height:176px;vertical-align:middle;" />
</span>
<span style="position:absolute;top:-84px;left:170px;width:1000px;font-size:24px;text-overflow:ellipsis;overflow:hidden;white-space:nowrap;max-width:1200px">
<img src="https://website.com/images/ajax_search_result.png" style="height:15px;vertical-align:middle;margin-left:1px;margin-right:7px" /> '.$name.'<br /><span style="font-size:15px">'.$descr.'</span><br />
<img src="https://website.com/uploads/images/'.$row['image1'].'" style="margin-top:12px;width:85px;height:65px;vertical-align:middle;border-radius:5px" />
<img src="https://website.com/uploads/images/'.$row['image2'].'" style="margin-top:12px;width:85px;height:65px;vertical-align:middle;border-radius:5px" /><br />
<span style="font-size:15px"><span style="color:#ED2324;font-weight:bold">'.$views.'</span> views - <span style="color:#ED2324;font-weight:bold">'.$hits.'</span> downloads -
<span style="color:#ED2324;font-weight:bold">'.$ratingsum.'</span> <small>/ <span style="color:#ED2324;font-weight:bold">5</span></small> rating (by '.$numratings.' users)</span></span>
</a>';
array_push($result, $data);
// Alternate method: Does not work. Requires - PDO::FETCH_OBJ
//array_push($result, $title->name, $title->hits, $title->views, $title->image1, $title->image2, (int) $title->rating_sum, (int) $title->numratings, $title->descr, $title->id);
}
echo json_encode($result);
?>
//Message sur shout nouveau torrent
if ($CURUSER["xxx_filter"]){
$image = $inames[0];
$membre = ( $anon == 'yes' || $CURUSER['privacy'] == 'strong' ) ? 'Anonyme' : $CURUSER['username'];
$insert = sqlesc("
[img]http://".$site_config["SITEURL"]."/images/Torrents/NouveauTorrent.png[/img]\n".$torrent."\r[img1]".$site_config["SITEURL"]."/images/Torrents/3X.png[/img1]\nPartagé ".($anon == 'no' ? "Par " .$CURUSER['username']. "" : "")."
");
}else{
$insert = sqlesc("
[img]http://".$site_config["SITEURL"]."/images/Torrents/NouveauTorrent.png[/img]\n".$torrent."\r[img1]".$site_config["SITEURL"]."/uploads/images/".$image."[/img1]\nPartagé ".($anon == 'no' ? "Par " .$CURUSER['username']. "" : "")."
");
SQL_Query_exec("INSERT INTO ajshoutbox (uid, date, name, text) VALUES(0,NOW(), 'Robot Crazy' ,".$insert."".$wherex.")");
}
// Fin
if (array_key_exists("id", $_GET)) && trim($_GET["id"]) == 'YOUR-3X-CAT-ID-GOES-HERE' && $CURUSER["xxx_filter"] == 'yes') {
// Hide category
}else{
// Show category
}
if (!empty($row["cat_name"])) {
print("<a href=\"torrents.php?cat=" . $row["category"] . "\">");
if (!empty($row["cat_pic"]) && $row["cat_pic"] != "")
print("<img border=\"0\"src=\"" . $site_config['SITEURL'] . "/images/categories/" . $row["cat_pic"] . "\" alt=\"" . $row["cat_name"] . "\" />");
else
print($row["cat_parent"].": ".$row["cat_name"]);
print("</a>");
} else
print("-");
print("</td>\n");
stdhead(T_("HOME"));
// User hide welcome wizard - April 3, 2020
// is_string_improved() - Improved string checking function
if ($CURUSER && is_string_improved($_REQUEST["hidewizard"])) {
SQL_Query_exec("UPDATE users SET hidewizard='yes' WHERE id=$CURUSER[id]");
// Redirect to YOURSITE.com/?lc - "last chance" undo action - April 4, 2020
header("Location: https://YOURSITE.com/?lc");
exit();
}elseif ($CURUSER && is_string_improved($_REQUEST["showizard"])) {
SQL_Query_exec("UPDATE users SET hidewizard='no' WHERE id=$CURUSER[id]");
header("Location: https://YOURSITE.com/");
exit();
}
$site_config['theme_cache'] = false; // Enable/Disable CSS caching in browsers. MUST for updating theme files
$site_config['default_theme_name'] = "default";
// Improved string checking - Security
function is_string_improved($text) {
return (is_string($text) || (is_object($text) && method_exists($text, '__toString' )));
}
<table width='100%' border='0' cellspacing='10' cellpadding='0'>
<tr>
<td valign='top'>
<!-- START MAIN COLUM -->
<!-- BEGIN New Welcome User Wizard: Themes, Language -->
<?
// User welcome wizard - April 3, 2020
// Detect ?lc query string - "last chance" - restore update notification? - April 4, 2020
if (isset($_GET['lc'])) {
echo "<div>Site wizard has been hidden. <a href='" . $site_config["SITEURL"] . "/?shownotif'>Undo?</a></div>";
}
if (stripos($_SERVER['PHP_SELF'],'index.php') && $CURUSER["skipwizard"] == "no") {
$ss_r = SQL_Query_exec("SELECT * FROM stylesheets");
$ss_sa = array();
while ($ss_a = mysql_fetch_assoc($ss_r)) {
$ss_id = $ss_a["id"];
$ss_name = $ss_a["name"];
$ss_sa[$ss_name] = $ss_id;
}
ksort($ss_sa);
reset($ss_sa);
while (list($ss_name, $ss_id) = each($ss_sa)) {
if ($ss_id == $CURUSER["stylesheet"])
$ss = " selected='selected'";
else
$ss = "";
$stylesheets .= "<option value='$ss_id'$ss>$ss_name</option>\n";
}
$lang_r = SQL_Query_exec("SELECT * FROM languages");
$lang_sa = array();
while ($lang_a = mysql_fetch_assoc($lang_r)) {
$lang_id = $lang_a["id"];
$lang_name = $lang_a["name"];
$lang_sa[$lang_name] = $lang_id;
}
ksort($lang_sa);
reset($lang_sa);
while (list($lang_name, $lang_id) = each($lang_sa)) {
if ($lang_id == $CURUSER["language"])
$lang = " selected='selected'";
else
$lang = "";
$languages .= "<option value='$lang_id'$lang>$lang_name</option>\n";
}
?>
<div style="margin-left:13px;margin-top:25px;max-width:724px">
<article itemprop="itemListElement" itemscope="" itemtype="http://schema.org/Article" class="card responsive-img" style="height:168px;background:url(/images/index_wizard_bg.png) no-repeat center;">
<div style="color:#FFF;margin-top:-30px">
<h2 style="border-top:none">
<img src="/<? echo $CURUSER["avatar"]; ?>" border="0" style="width:55px;height:55px;border-radius:50%;vertical-align:bottom;padding-right:5px" /> Welcome, <? echo $CURUSER["username"]; ?>!
</h2>
</div>
<span style="padding-left:25px;color:#FFF;font-size:15px"><b>April</b> Update: You now have <b>Themes</b> & <b>Languages</b>. You can now theme YourSite to your liking.</span>
<form name="skip" method="post" action="?skipwizard" onsubmit="return validate();"></form>
<form method="post" name="wizard" action="<? echo $site_config[" SITEURL "]; ?>/take-theme.php" onsubmit="return validate();">
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="responsive-table">
<tr>
<td style="float:left;padding-left:20px">
<select name="stylesheet" style="width:180px;height:35px">
<? echo $stylesheets; ?>
</select>
<select name="language" style="width:180px;height:35px">
<? echo $languages; ?>
</select>
</td>
<td style="float:right;padding-right:20px">
<button class="btn btn-danger" onclick="document.forms.wizard.submit();">Set</button>
<button class="btn btn-danger" onclick="document.forms.skip.submit(); alert('You can update these in Account > Settings at any time.');">Skip</button>
</td>
</tr>
</table>
</form>
</article>
</div>
<!-- END New Welcome User Wizard: Themes, Language -->
<? } // End theme/lang ?>
ALTER TABLE users
ADD COLUMN skipwizard ENUM('yes','no') NOT NULL default 'no'
<?
if ($CURUSER) {
$name = mysql_fetch_assoc(SQL_Query_exec("SELECT uri FROM stylesheets WHERE id='" . ( $CURUSER ? $CURUSER['stylesheet'] : $site_config['default_theme'] ) . "'"));
$theme = $name['uri']; // signed in, retrieve theme name, or use default
if ($site_config['theme_cache'])
$cache = "?v=".rand(); // Prevents browsers caching CSS files
}else{
$theme = $site_config['default_theme_name']; // not signed in, always 'default'
}
?>
<link rel="stylesheet" type="text/css" href="<?php echo $site_config["SITEURL"]; ?>/themes/default/theme.css" /><link rel="stylesheet" href="<? echo $site_config["SITEURL"] . "/themes/" . $theme . "/theme.css" . $cache; ?>">
print("<div class='profile-stats'>
<ul>
<li><span><font><font>Themes</font></font></span><font><font><select name='stylesheet'>\n$stylesheets\n</select></font></font></a></li>
<li><span><font><font>Preferred Client</font></font></span><font><font><input type='text' size='20' maxlength='20' name='client' value=\"" . htmlspecialchars($CURUSER["client"]) . "\" /></font></font></a></li>
<li><span><font><font>Age</font></font></span><font><font><input type='text' size='3' maxlength='2' name='age' value=\"" . htmlspecialchars($CURUSER["age"]) . "\" /></font></font></a></li>
</ul>
<div class='clear'></div>
</div>");
print("<div class='profile-stats'>
<ul>
<li><span class='current-theme'><font><font>Themes</font></font></span><font><font><select name='stylesheet'>\n$stylesheets\n</select></font></font></a></li>
<li><span><font><font>Preferred Client</font></font></span><font><font><input type='text' size='20' maxlength='20' name='client' value=\"" . htmlspecialchars($CURUSER["client"]) . "\" /></font></font></a></li>
<li><span><font><font>Age</font></font></span><font><font><input type='text' size='3' maxlength='2' name='age' value=\"" . htmlspecialchars($CURUSER["age"]) . "\" /></font></font></a></li>
</ul>
<div class='clear'></div>
</div>");
.current-theme select {
background: rgba(38, 111, 48, 1); color: rgba(255, 255, 255, 1); height: 35px
}function timeAgo($time_ago)
{
$time_ago = strtotime($time_ago);
$cur_time = time();
$time_elapsed = $cur_time - $time_ago;
$seconds = $time_elapsed ;
$minutes = round($time_elapsed / 60 );
$hours = round($time_elapsed / 3600);
$days = round($time_elapsed / 86400 );
$weeks = round($time_elapsed / 604800);
$months = round($time_elapsed / 2600640 );
$years = round($time_elapsed / 31207680 );
// Seconds
if($seconds <= 60){
return "just now";
}
//Minutes
else if($minutes <=60){
if($minutes==1){
return "one minute ago";
}
else{
return "$minutes minutes ago";
}
}
//Hours
else if($hours <=24){
if($hours==1){
return "an hour ago";
}else{
return "$hours hrs ago";
}
}
//Days
else if($days <= 7){
if($days==1){
return "yesterday";
}else{
return "$days days ago";
}
}
//Weeks
else if($weeks <= 4.3){
if($weeks==1){
return "a week ago";
}else{
return "$weeks weeks ago";
}
}
//Months
else if($months <=12){
if($months==1){
return "a month ago";
}else{
return "$months months ago";
}
}
//Years
else{
if($years==1){
return "one year ago";
}else{
return "$years years ago";
}
}
}
$date = date('M d, Y', strtotime('-5 days', time()));
timeAgo($date);
//functions.php
$added = date("M d, Y", utc_to_tz_time($result2['added']));
/*
$last_access = $CURUSER["last_browse"];
$time_now = gmtime();
if ($last_access > $time_now || !is_numeric($last_access))
$last_access = $time_now;
if (sql_timestamp_to_unix_timestamp($result2["added"]) >= $last_access) {
*/
if (strtotime($added) >= strtotime("yesterday")){ // Only show for torrents 1 day old
$new = "New!";
}
//}
$new; // use this alongside $dispname $last_access = $CURUSER["last_browse"];
$time_now = gmtime();
if ($last_access > $time_now || !is_numeric($last_access))
$last_access = $time_now;
if (sql_timestamp_to_unix_timestamp($result2["added"]) >= $last_access) {
$disname .= "New!";
} "spiritblue, post: 68259, member: 401":
allo STorrents2020
You have to bandage to test with this renge there for the non vote?
// Rating
if ($count >= 1){
$rater .= '<span class="stars-rating" style="--rating: ' . $rating_1 . '"></span>Total: ' . $count . ' ' . $tense;
}elseif ($count == 0){
$rater .= '<span class="stars-rating" style="--rating: 0.0"></span>';
}else{
$rater .= '<span class="stars-rating" style="">0.0</span>';
}
//
I haven't tested your code on my test site, but it's an idea lol (y)
$rater .= '<div style="color:#242424;font-size:35px;font:arial,helvetica,sans-serif;margin-bottom:-48px;font-weight:400"><span style="font-weight:500">' . $count . '</span>/' . 5 . '</div>'; "DarkMaster, post: 68261, member: 1":
"spiritblue, post: 68259, member: 401":
allo STorrents2020
You have to bandage to test with this renge there for the non vote?
// Rating
if ($count >= 1){
$rater .= '<span class="stars-rating" style="--rating: ' . $rating_1 . '"></span>Total: ' . $count . ' ' . $tense;
}elseif ($count == 0){
$rater .= '<span class="stars-rating" style="--rating: 0.0"></span>';
}else{
$rater .= '<span class="stars-rating" style="">0.0</span>';
}
//
I haven't tested your code on my test site, but it's an idea lol (y)
// New AJAX Rating Feature - Jan 26, 2020
$total_votes = 0;
$total_value = 0;
$query = SQL_Query_exec("SELECT COUNT(torrent) as total_votes, SUM(rating) as total_value FROM `ratings` WHERE `torrent` = '$id'");
while ($rating = mysql_fetch_array($query)) {
$total_votes = $rating['total_votes'];
$total_value = $rating['total_value'];
}
$voted = get_row_count("ratings", "WHERE `torrent` = '" . $id . "' AND `user` = '" . $CURUSER["id"] . "'");
if ($total_votes < 1) { // Require at least 1 vote to show votes to all
$count = 0;
} else {
$count = $total_votes;
}
$current_rating = $total_value;
$tense = ($count == 1) ? "rating" : "ratings";
if (is_numeric($current_rating) && is_numeric($count)) {
$rating_width = number_format($current_rating / $count, 2) * 30;
$rating_1 = number_format($current_rating / $count, 1); // Vote result format: 2 = 5.00, 1 = 5.0, 0 = 5. - Jan 26 2020
$rating_2 = number_format($current_rating / $count, 1);
}
if (!$voted) {
$rater .= '<ul>';
$rater .= '<div style="color:#242424;font-size:35px;font:arial,helvetica,sans-serif;margin-bottom:-48px;font-weight:400"><span style="font-weight:500">' . $rating_2 . '</span>/' . 5 . '</div>'; // For SCORE next to rating (eg. 4.7/5) - UL must stay here to align!
for ($ncount = 1; $ncount <= 5; $ncount++) {
// New rating stars work
$rater .= '<li class="stars-rating" style="--rating: ' . $ncount . '; position:relative;" aria-label="rating: ' . $ncount . '/' . $units . '">
<div style="position:absolute;top:56px;left:12px;"><a title="' . $ncount . ' out of ' . 5 . '" href="' . $site_config["SITEURL"] . '/torrents-details.php?id=' . $id . '&takerating=yes&j=' . $ncount . '" style="text-decoration:none;color:transparent">
<span style="">?</span></a></div></li>';
}
$ncount = 0;
$rater .= '</ul>';
}
if ($voted) {
$static_rater = array();
$static_rater[] .= '<ul>';
$static_rater[] .= '<li class="stars-rating" style="--rating: ' . $rating_2 . '"><span style="color:#242424;font-size:35px;font:arial,helvetica,sans-serif;margin-bottom:-65px;font-weight:400"><span style="font-weight:500">' . $rating_2 . '</span>/' . 5 . '</span></li>';
$static_rater[] .= '</ul>';
$rater .= join("\n", $static_rater);
}
// rating
$rater .= '<span class="stars-rating" style="--rating: ' . $rating_1 . '"></span>Total: ' . $count . ' ' . $tense;// Rating
if ($count >= 1){
$rater .= '<span class="stars-rating" style="--rating: ' . $rating_1 . '"></span>Total: ' . $count . ' ' . $tense;
}elseif ($count == 0){
$rater .= '<span class="stars-rating" style="--rating: 0.0"></span>';
}