Database Error in announce.php on line 379: BIGINT UNSIGNED value is out of range in '`db1`.`torrents`.`leechers` - 1'. Query was: UPDATE torrents SET leechers = leechers - 1,seeders = seeders + 1,visible = 'yes',last_action = '2020-06-08 20:46:39' WHERE id=1017
"Madness85, post: 68333, member: 20433":
I agree, bvlist is a bit dated and could do with an upgrade.
That being said, this attempt didn't go very far. Nobody uploaded any sources.
function imageResize($imageSrc, $imageWidth, $imageHeight)
{
$newImageWidth = 200;
$newImageHeight = 200;
$newImageLayer = imagecreatetruecolor($newImageWidth, $newImageHeight);
imagecopyresampled($newImageLayer, $imageSrc, 0, 0, 0, 0, $newImageWidth, $newImageHeight, $imageWidth, $imageHeight);
return $newImageLayer;
}
<?
require_once 'backend/functions.php';
if (isset($_POST['submit'], $_POST['username'], $_POST['password'])) {
if (is_array($_FILES)) {
$uploadedFile = $_FILES['avatar']['tmp_name'];
$sourceProperties = getimagesize($uploadedFile);
$newFileName = sha1_file($uploadedFile);
$dirPath = "images/avatars/";
$ext = pathinfo($_FILES['avatar']['name'], PATHINFO_EXTENSION);
$imageType = $sourceProperties[2];
switch ($imageType) {
case IMAGETYPE_PNG:
$imageSrc = imagecreatefrompng($uploadedFile);
$tmp = imageResize($imageSrc, $sourceProperties[0], $sourceProperties[1]);
imagepng($tmp, $dirPath . $newFileName . "_thumb." . $ext);
break;
case IMAGETYPE_JPEG:
$imageSrc = imagecreatefromjpeg($uploadedFile);
$tmp = imageResize($imageSrc, $sourceProperties[0], $sourceProperties[1]);
imagejpeg($tmp, $dirPath . $newFileName . "_thumb." . $ext);
break;
case IMAGETYPE_GIF:
$imageSrc = imagecreatefromgif($uploadedFile);
$tmp = imageResize($imageSrc, $sourceProperties[0], $sourceProperties[1]);
imagegif($tmp, $dirPath . $newFileName . "_thumb." . $ext);
break;
default:
echo "Invalid avatar image. Please <a href='" . $site_config['SITEURL'] . "/signup/'>go back</a> and try again.";
exit;
break;
}
move_uploaded_file($uploadedFile, $dirPath . $newFileName . "." . $ext);
}
try {
$dsn = 'mysql:dbname=database;host=localhost';
$user = 'username';
$password = 'password';
$conn = new PDO($dsn, $user, $password);
if (function_exists("filter_var")) {
$username = filter_input(INPUT_POST, 'username', FILTER_SANITIZE_STRING);
$email = filter_input(INPUT_POST, 'email', FILTER_SANITIZE_EMAIL);
} else {
echo "Filter extension for PHP " . phpversion() . " not found. Using unsafe instead.";
$username = $_POST["username"];
$email = $_POST["email"];
}
$avatar = $dirPath . $newFileName . "." . $ext;
$avatar_thumb = $dirPath . $newFileName . "_thumb." . $ext;
$password = $_POST["password"];
$saltstr = '_salt56789012345678901';
$salt = password_hash($password, PASSWORD_BCRYPT, array(
'salt' => $saltstr
));
$cryptedPassword = password_hash($password, PASSWORD_BCRYPT, array(
'cost' => 11
));
$sql = "INSERT INTO users (username, password, secret, email, status, added, last_access, age, country, gender, client, stylesheet, language, class, avatar, avatar_thumb) VALUES (:username, :cryptedPassword, :secret, :email, 'confirmed', NOW(), NOW(), 29, 1, 'Male', 'uTorrent', 1, 1, 1, :avatar, :avatar_thumb)";
$stmt = $conn->prepare($sql);
if ($stmt) {
$stmt->bindParam(":username", $username);
$stmt->bindParam(":cryptedPassword", $cryptedPassword);
$stmt->bindParam(":email", $email);
$stmt->bindParam(":secret", $salt);
$stmt->bindParam(":avatar", $avatar);
$stmt->bindParam(":avatar_thumb", $avatar_thumb);
$result = $stmt->execute();
echo $result ? 'ok' : 'Query successful';
} else {
throw new Exception('Preparing Query Failed');
}
}
catch (Exception $e) {
echo $e->getMessage();
}
}
?>
<?
require_once("backend/functions.php");
dbconn(true); stdhead("Sign Up"); begin_frame("Register");
?>
<form method="POST" enctype="multipart/form-data" action="/register.php" autocomplete="off">
<input type="text" name="username" placeholder="Your Username" /><br><br>
<input type="email" name="email" placeholder="Your E-mail" /><br><br>
<input type="password" name="password" placeholder="Your Password" /><br><br>
<input type="file" name="avatar" accept="image/*"><br><br>
<button type="submit" name="submit">Sign Up</button>
</form>
<? end_frame(); stdfoot(); ?>
"shadows, post: 68691, member: 20311":
Remove for loop from regex it is performance hungry.
if (preg_match("/(\.php*|\.htm*|\.pl|\.cgi|\.htaccess)/i", $_FILES['file']['name'])) {
exit;
}
<?
/* AJAX Torrent Uploader - May 27, 2020
Using Parsing class - Torrent()->object()
Replaces old torrents-upload.php and related classes: BDecode(), BEncode()
Triggered by AJAX call.
Accepts .torrent: Parses data => Inserts to DB => Redirects to edit page
STorrents @ TorrentTrader.xyz
*/
// Required for successful redirect
error_reporting(0);
$blacklist = array(
".php",
".phtml",
".php3",
".php4",
".pl",
".html",
".cgi",
".htaccess"
);
foreach ($blacklist as $item) {
if (preg_match("/$item$/i", $_FILES['file']['name'])) {
exit;
}
}
if (0 < $_FILES['file']['error']) {
echo 'Error: ' . $_FILES['file']['error'] . '<br>';
} else {
require_once('backend/class.parse.php');
$parsepath = 'uploads/' . $_FILES['file']['name'];
$torrent = new Torrent($parsepath);
$torr_hash = $torrent->hash_info();
$torr_announce = $torrent->announce();
$torr_size = $torrent->size();
$torr_saveas = $torrent->name();
$torr_private = $torrent->is_private() ? 'yes' : 'no';
$userid = (int) $_POST['userid'];
require_once 'backend/functions.php';
try {
$dsn = 'mysql:dbname=database;host=localhost';
$user = 'username';
$password = 'password';
$conn = new PDO($dsn, $user, $password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
catch (PDOException $e) {
die('Error: Unable to connect to database');
}
$sql = "INSERT INTO torrents (filename, owner, name, descr, image1, image2, category, added, info_hash, size, numfiles, save_as, announce, external, nfo, torrentlang, anon, visible, last_action)
VALUES ('" . $torr_saveas . ".torrent', " . $userid . ", '" . $torr_saveas . "', '" . $torr_saveas . " is currently being updated.', '', '', '1', NOW(), '" . $torr_hash . "', '" . $torr_size . "', 3, '" . $torr_saveas . ".torrent', '" . $torr_announce . "', '" . $torr_private . "', 'no', 1, 'no', 'yes', NOW())";
$query = $conn->prepare($sql);
$query->execute();
$id = $conn->lastInsertId();
$rename = "uploads/" . $id . ".torrent";
if (move_uploaded_file($_FILES['file']['tmp_name'], $rename)) {
echo $site_config["SITEURL"] . '/torrent-edit.php?id=' . $id;
}
}
?>
<script>
// AJAX Torrent Upload
$(document).ready(function(a) {
$("#form-torupload").on("change", function(a) {
var file_data = $('#uploadTorrent').prop('files')[0];
var form_data = new FormData();
form_data.append('file', file_data);
$.ajax({
url: "ajax_torrentupload.php",
dataType: 'html',
cache: false,
contentType: false,
processData: false,
data: form_data,
type: "POST",
beforeSend: function () {
$("#upload-progress").html("Uploading Torrent...").delay(3000).fadeIn().delay(4000).fadeOut();
},
success: function(torrent_complete){
window.location.href = torrent_complete;
}
});
});
});
</script>
"Propaganda, post: 68673, member: 60":
Thanks ST, changed, and once more here is the error log on this one. typed t'est and the attached error appeared.
"Propaganda, post: 68669, member: 60":
Updating your Signature field, either from you profile or from your account page would not work. It Throws the following error :
Warning: Cannot modify header information - headers already sent by (output started at site/views/themes/u2torrents/topnavbar.php:53) in site/helpers/exception_helper.php on line 94 Call Stack: 0.0142 597408 1. handleUncaughtException() site/helpers/exception_helper.php:0 0.0142 597488 2. header() site/helpers/exception_helper.php:94 Warning: error_log(exception_log.txt): failed to open stream: Permission denied in site/helpers/exception_helper.php on line 104 Call Stack: 0.0142 597408 1. handleUncaughtException() site/helpers/exception_helper.php:0 0.0144 599456 2. error_log() site/helpers/exception_helper.php:104
This seems to be related to the "[color=rgb(250, 197, 28)] ' [/color]" character. Inserting Text, works. Inserting Te'xt throws the error.
In the same area, clicking on the "javascript:popMoreTags();" (HTML is not allowed. [url='https://www.torrenttrader.xyz/javascript%3APopMoreTags();']Click here[/url] for available tags) link - does not popup the tags, but instead loads index.php in popup.
$smarty->assign('username', $CURUSER["username"]);require_once(BACKEND."/languages.php");
// Smarty PHP Compiling Template Engine 3.1.34 (latest dev)
require_once(BACKEND."/Smarty/Smarty.class.php");
$smarty = new Smarty();
$smarty->setTemplateDir('../templates/');
$smarty->setCompileDir('../templates_c/');
$smarty->setConfigDir('../configs/');
$smarty->setCacheDir('../cache/');
<?
require_once 'backend/functions.php';
dbconn(true);
// PDO Connection
$db = new PDO("mysql:host={$dbHost};dbname={$dbName};charset=utf8", $dbUsername, $dbPassword);
$db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true);
$admin = $CURUSER["class"] == 7;
$avatar = $CURUSER["avatar"];
$class = $CURUSER["class"];
$themename = mysql_fetch_assoc(SQL_Query_exec("SELECT uri FROM stylesheets WHERE id='" . ( $CURUSER ? $CURUSER['stylesheet'] : $site_config['default_theme'] ) . "'"));
$theme = $themename['uri'];
$siteurl = $site_config["SITEURL"];
$torrentid = $id;
$userid = $CURUSER["id"];
$date_time = get_date_time(gmtime()-(3600*24));
$usersadded = number_format(get_row_count("users", "WHERE users.added>='$date_time'"));
if (stripos($_SERVER['PHP_SELF'],'index.php')) {
$indexonly = true;
}
// Messages
$mail = $db->prepare("SELECT COUNT(id) FROM messages WHERE receiver = :userid AND unread = 'yes' AND location IN ('in','both') LIMIT 1");
$mail->bindParam(":userid", $userid, PDO::PARAM_INT);
$mail->execute();
$messages = $mail->fetchColumn();
// Conditions
$smarty->assign('loggedin', $CURUSER);
$smarty->assign('admin', $admin);
$smarty->assign('avatar', $avatar);
$smarty->assign('theme', $theme);
$smarty->assign('unreadmail', $messages);
$theme = $site_config['default_theme_name'];
if ($CURUSER){
$lastchance = isset($_GET['lc']);
$maxslot = avail_slots($userid, $class);
$userslots = number_format($maxslot) . "/0";
$userratio = number_format($CURUSER["uploaded"] / $CURUSER["downloaded"], 2);
}
// Spotlight
$spotlight = $db->prepare("SELECT id, name, cover1 FROM torrents ORDER BY added DESC LIMIT 8");
$spotlight->execute();
$spotlight->setFetchMode(PDO::FETCH_ASSOC);
// Languages
$language = $db->prepare("SELECT id, name, uri FROM languages");
$language->execute();
$language->setFetchMode(PDO::FETCH_ASSOC);
// Stylesheets (legacy)
$stylesheet = $db->prepare("SELECT id, name FROM stylesheets");
$stylesheet->execute();
$stylesheet->setFetchMode(PDO::FETCH_ASSOC);
// Torrent Comments
$comments = $db->prepare("SELECT comments.id, comments.text, comments.user, comments.added, users.avatar, signature, username, title, class, uploaded, downloaded, privacy, donated FROM comments LEFT JOIN users ON comments.user = users.id WHERE torrent = torrents.id ORDER BY comments.id LIMIT 2");
$comments->execute();
$comments->setFetchMode(PDO::FETCH_ASSOC);
// Torrent Table
$results = 13;
$torrenttable = $db->prepare("SELECT torrents.id, torrents.hits, torrents.views, torrents.image1, torrents.anon, torrents.announce, torrents.category, torrents.leechers, torrents.nfo, torrents.seeders, torrents.name, torrents.times_completed, torrents.size, torrents.added, torrents.comments AS commentcount, torrents.numfiles, torrents.filename, torrents.owner, torrents.external, torrents.freeleech, categories.name AS cat_name, categories.image AS cat_pic, categories.parent_cat AS cat_parent, users.username, users.avatar, users.privacy, IF(torrents.numratings < 1, NULL, ROUND(torrents.ratingsum / torrents.numratings, 1)) AS rating FROM torrents LEFT JOIN categories ON category = categories.id LEFT JOIN users ON torrents.owner = users.id WHERE visible = 'yes' AND banned = 'no' ORDER BY torrents.added DESC LIMIT :limit");
$torrenttable->bindParam(":limit", $results, PDO::PARAM_INT);
if ($CURUSER)
$db->query("UPDATE users SET last_browse=" . gmtime() . " WHERE id=$CURUSER[id]");
$torrenttable->execute();
$torrenttable->setFetchMode(PDO::FETCH_BOTH);
// Assign
$smarty->assign('username', $CURUSER["username"]);
$smarty->assign('userid', $CURUSER["id"]);
$smarty->assign('avatar', $avatar);
$smarty->assign('url', $siteurl);
$smarty->assign('indexonly', $indexonly);
$smarty->assign('lastchance', $lastchance);
$smarty->assign('torrentid', $torrentid);
$smarty->assign('usersadded', $usersadded);
$smarty->assign('languages', $language);
$smarty->assign('stylesheet', $stylesheet);
$smarty->assign('spotlight', $spotlight);
$smarty->assign('comments', $comments);
$smarty->assign('slots', $userslots);
$smarty->assign('ratio', $userratio);
$smarty->assign('torrenttable', $torrenttable); // torrenttable
// Display
$smarty->display('index.tpl');
?>
{include file='header.tpl'}
{include file='footer.tpl'}
<!-- HTML footer -->
{* MAIN HEADER *}
<!DOCTYPE html>
<html lang="en-US"
itemscope
itemtype="http://schema.org/WebSite"
prefix="og: http://ogp.me/ns#" >
<head>
{include file='header_resource.tpl'}
<style>
{include file='header_extracss.tpl'}
</style>
<script>
{include file='header_javascript.tpl'}
</script>
</head>
<body>
{include file='header_nav.tpl'}
<div class="container-main">
<div class="primary"><!-- *** START PRIMARY *** -->
{if $loggedin}
<!-- logged in HTML -->
{include file='ajax_shoutbox.tpl'}
{/if}
<div class="content-inner">
<!-- Migrate -->
<div class='myTable'>
<div class='myTrow'>
<div class='main'>
<table width='100%' border='0' cellspacing='10' cellpadding='0'>
<tr>
<td valign='top'>
{include file='torrentindex.tpl'}
{* MAIN TORRENT INDEX *}
{foreach $torrenttable as $item}
<a href="{$url}/torrents-details.php?id={$item.id}">
<img src="{$url}/uploads/images/{$item.image1}" />
<span>{$item.added|date_format} by <a href='{$url}/user/?id={$item.owner}'> {$item.username}</a> <img src='{$url}/{$item.avatar}' /></span>
<span>{$item.views}</span>
<span>{$item.hits}</span>
<span>{$item.speed}</span>
<a title="{$item.name}" href="/details/{$item.id}/">{$item.name|truncate:29}</a>
<span>{if $item.rating}{$item.rating} / 5.0{/if}</span>
<span><a href='{$url}/cat/{$item.category}/' title='Browse {$item.category} Torrents'>{$item.cat_name}</a></span>
<span>{$item.size|filesize}</span>
<span>{$item.seeders}</span>
<span>{$item.leechers}</span>
{/foreach}
"m-jay, post: 68645, member: 20288":
noticed a error with this mod when updating
in config we use
$site_config['autoclean_interval'] = 600; // time to cleanup (10 minutes)
we need new config time
$site_config['add_bonus'] = 3600; // time to add bonus (1 hour)
so bonus is not correct its more like this
You recieve X points per 10 minutes the system registers you as a seeder by torrent.
so in mybonus change
floor($site_config['autoclean_interval'] / 10),
to [color=rgb(250, 197, 28)]should be 60 for seconds[/color]
floor($site_config['add_bonus'] / 60),
then we put new condition on cleanup - the auto cleanup 10 minutes the seedbonus 1 hour
// Seedbonus Mod
$now = gmtime();
$dobonus = 0;
$res = SQL_Query_exec("SELECT last_time FROM tasks WHERE task='bonus'");
while ( $row = mysqli_fetch_object($res) )
if (!$row) {
SQL_Query_exec("INSERT INTO tasks (task, last_time) VALUES ('bonus',$now)");
// write_log("theres was no row silly we need one to start");
}
$ts = $row['last_time']; // $row['0'] returned null
if ($ts + $site_config['add_bonus'] < $now){
$qry = "SELECT DISTINCT userid as peer, (
SELECT DISTINCT COUNT( torrent )
FROM peers
WHERE seeder = 'yes' AND userid = peer) AS count
FROM peers WHERE seeder = 'yes'";
$res1 = SQL_Query_exec($qry);
while ( $row = mysqli_fetch_object($res) )
{
SQL_Query_exec("UPDATE users SET seedbonus = seedbonus + '" . ($site_config["bonuspertime"] * $row->count) . "' WHERE id = '" . $row->peer . "'");
SQL_Query_exec("UPDATE tasks SET last_time=$now WHERE task='bonus'");
// write_log("bonus and task inserted every hour");
}
}
// End
use the writelog function to log cleanups to makes sure its correct
// write_log("bonus and task inserted every hour");
"shadows, post: 68643, member: 20311":
This is SQL injectable.
$torrentid = $_GET['id'];
$stmt = $conn->prepare("SELECT id, announce, info_hash FROM torrents WHERE external = 'yes' AND id = $torrentid LIMIT 1");
[ICODE]yoursite.com/trader-scrape.php?id='1;UPDATE users SET email = "shadows@mail.com" WHERE id = 1'[/ICODE]