Bravo List
Register
Go Back   > Bravo List > Source Code > Archived Trackers > TBDev > Mods & Themes
Reply
  #1  
Old 30th July 2008, 22:27
Nilsons Nilsons is offline
Senior Member
 
Join Date: Dec 2007
Latvia
Posts: 40
Default Upload 2 Images With Torrent
Files to be edited:
upload.php
takeupload.php
edit.php
takeedit.php
delete.php
details.php

Files to be added:
thumbnail.php
viewimage.php


in database add this
Code:
ALTER TABLE `torrents` ADD `image1` TEXT NOT NULL AFTER `ori_descr` ,
ADD `image2` TEXT NOT NULL AFTER `image1`;
in upload.php find
Code:
tr("Torrent file", "<input type=file name=file size=80>\n", 1);
replace with
Code:
tr("Torrent file", "<input type=file name=tfile size=80>\n", 1);

find
Code:
tr("Torrent name", "<input type=\"text\" name=\"name\" size=\"80\" />
(Taken from filename if not specified. Please use descriptive names.)\n", 1);
add after or somewere near
Code:
tr("Images", "Max File Size: 500kb
Accepted Formats: .gif .jpg
Image 1:&nbsp&nbsp<input type=file name=image0 size=80>
Image 2:&nbsp&nbsp<input type=file name=image1 size=80>\n", 1);
find
Code:
<tr><td align="center" colspan="2"><input type="submit" class=btn value="Do it!" /></td></tr>
replace with
Code:
<tr><td align="center" colspan="2"><input type="submit" class=btn value="Do it!" />
Click once only! - Uploading an image will require more loading time</td></tr>

in takeupload find
Code:
if (!isset($_FILES["file"]))
replace with
Code:
if (!isset($_FILES["tfile"]))
find
Code:
$f = $_FILES["file"];
replace with
Code:
$f = $_FILES["tfile"];
find
Code:
// Replace punctuation characters with spaces
add before
Code:
//////////////////////////////////////////////
//////////////Take Image Uploads//////////////

$maxfilesize = 512000; // 500kb

$allowed_types = array(
"image/gif" => "gif",
"image/pjpeg" => "jpg",
"image/jpeg" => "jpg",
"image/jpg" => "jpg"
// Add more types here if you like
);

for ($x=0; $x < 2; $x++) {

if (!($_FILES[image.$x]['name'] == "")) {
$y = $x + 1;

// Is valid filetype?
if (!array_key_exists($_FILES[image.$x]['type'], $allowed_types))
bark("Invalid file type! Image $y");

// Is within allowed filesize?
if ($_FILES[image.$x]['size'] > $maxfilesize)
bark("Invalid file size! Image $y - Must be less than 500kb");

// Where to upload?
// Update for your own server. Make sure the folder has chmod write permissions. Remember this director
$uploaddir = "/home/user/public_html/trackerdir/torrents/images/";

// What is the temporary file name?
$ifile = $_FILES[image.$x]['tmp_name'];

// Calculate what the next torrent id will be
$ret = mysql_query("SHOW TABLE STATUS LIKE 'torrents'");
$row = mysql_fetch_array($ret);
$next_id = $row['Auto_increment'];

// By what filename should the tracker associate the image with?
$ifilename = $next_id . $x . substr($_FILES[image.$x]['name'], strlen($_FILES[image.$x]['name'])-4, 4);

// Upload the file
$copy = copy($ifile, $uploaddir.$ifilename);

if (!$copy)
bark("Error occured uploading image! - Image $y");

$inames[] = $ifilename;

}

}

//////////////////////////////////////////////
find (may be broken into more than one line):
Code:
$ret = mysql_query("INSERT INTO torrents (search_text, filename, owner, visible, info_hash, name, size, numfiles, type, descr, ori_descr, category, save_as, added, last_action, nfo) VALUES (" . implode(",", array_map("sqlesc", array(searchfield("$shortfname $dname $torrent"), $fname, $CURUSER["id"], "no", $infohash, $torrent, $totallen, count($filelist), $type, $descr, $descr, 0 + $_POST["type"], $dname))) . ", '" . get_date_time() . "', '" . get_date_time() . "', $nfo)");

replace with
Code:
$ret = mysql_query("INSERT INTO torrents (search_text, filename, owner, visible, info_hash, name, size, numfiles, type, descr, ori_descr, image1, image2, category, save_as, added, last_action, nfo) VALUES (" . implode(",", array_map("sqlesc", array(searchfield("$shortfname $dname $torrent"), $fname, $CURUSER["id"], "no", $infohash, $torrent, $totallen, count($filelist), $type, $descr, $descr, $inames[0], $inames[1], 0 + $_POST["type"], $dname))) . ", '" . get_date_time() . "', '" . get_date_time() . "', $nfo)");


in edit.php find
Code:
tr("Torrent name", "<input type=\"text\" name=\"name\" value=\"" . htmlspecialchars($row["name"]) . "\" size=\"80\" />", 1);
add after or near
Code:
tr("Images", "<input type=radio name=img1action value='keep' checked>Keep Image 1&nbsp&nbsp"."<input type=radio name=img1action value='delete'>Delete Image 1&nbsp&nbsp"."<input type=radio name=img1action value='update'>Update Image 1
Image 1:&nbsp&nbsp<input type=file name=image0 size=80> 

 <input type=radio name=img2action value='keep' checked>Keep Image 2&nbsp&nbsp"."<input type=radio name=img2action value='delete'>Delete Image 2&nbsp&nbsp"."<input type=radio name=img2action value='update'>Update Image 2
Image 2:&nbsp&nbsp<input type=file name=image1 size=80>", 1);
in takeedit.php find
Code:
function bark($msg) {
    genbark($msg, "Edit failed!");
}
add after
Code:
////////////////////////////////////////////////
function uploadimage($x, $imgname, $tid) {

$maxfilesize = 512000; // 500kb

$allowed_types = array(
"image/gif" => "gif",
"image/pjpeg" => "jpg",
"image/jpeg" => "jpg",
"image/jpg" => "jpg"
// Add more types here if you like
);

if (!($_FILES[image.$x]['name'] == "")) {

if ($imgname != "") {
// Make sure is same as in takeedit.php (except for the $imgname bit)
$img = "/home/user/public_html/trackerdir/torrents/images/$imgname";
$del = unlink($img);
}

$y = $x + 1;

// Is valid filetype?
if (!array_key_exists($_FILES[image.$x]['type'], $allowed_types))
bark("Invalid file type! Image $y");

// Is within allowed filesize?
if ($_FILES[image.$x]['size'] > $maxfilesize)
bark("Invalid file size! Image $y - Must be less than 500kb");

// Where to upload?
// Make sure is same as on takeupload.php
$uploaddir = "/home/user/public_html/trackerdir/torrents/images/";

// What is the temporary file name?
$ifile = $_FILES[image.$x]['tmp_name'];

// By what filename should the tracker associate the image with?
$ifilename = $tid . $x . substr($_FILES[image.$x]['name'], strlen($_FILES[image.$x]['name'])-4, 4);

// Upload the file
$copy = copy($ifile, $uploaddir.$ifilename);

if (!$copy)
bark("Error occured uploading image! - Image $y");

return $ifilename;

}

}
////////////////////////////////////////////////
find
Code:
$res = mysql_query("SELECT owner, filename, save_as FROM torrents WHERE id = $id");
replace with
Code:
$res = mysql_query("SELECT owner, filename, save_as, image1, image2 FROM torrents WHERE id = $id");
find
Code:
$dname = $row["save_as"];
add after
Code:
$img1action = $_POST['img1action'];
if ($img1action == "update")
$updateset[] = "image1 = " .sqlesc(uploadimage(0, $row[image1], $id));
if ($img1action == "delete") {
if ($row[image1]) {
$del = unlink("/home/user/public_html/trackerdir/torrents/images/$row[image1]");
$updateset[] = "image1 = ''";
}
}

$img2action = $_POST['img2action'];
if ($img2action == "update")
$updateset[] = "image2 = " .sqlesc(uploadimage(1, $row[image2], $id));
if ($img2action == "delete") {
if ($row[image2]) {
$del = unlink("/home/user/public_html/trackerdir/torrents/images/$row[image2]");
$updateset[] = "image2 = ''";
}
}
in delete.php find
Code:
$res = mysql_query("SELECT name,owner,seeders FROM torrents WHERE id = $id");
replace with
Code:
$res = mysql_query("SELECT name,owner,seeders,image1,image2 FROM torrents WHERE id = $id");
find
Code:
deletetorrent($id);
add after
Code:
if ($row["image1"]) {
 $img1 = "/home/vixbit/public_html/trader/torrents/images/$row[image1]";
 $del = unlink($img1);
}
if ($row["image2"]) {
 $img2 = "/home/vixbit/public_html/trader/torrents/images/$row[image2]";
 $del = unlink($img2);
}
in details.php find may be broken in more tha 1 line
Code:
$res = mysql_query("SELECT torrents.seeders, torrents.banned, torrents.leechers, torrents.info_hash, torrents.filename, LENGTH(torrents.nfo) AS nfosz, UNIX_TIMESTAMP() - UNIX_TIMESTAMP(torrents.last_action) AS lastseed, torrents.numratings, torrents.name, IF(torrents.numratings < $minvotes, NULL, ROUND(torrents.ratingsum / torrents.numratings, 1)) AS rating, torrents.owner, torrents.save_as, torrents.descr, torrents.visible, torrents.size, torrents.added, torrents.views, torrents.hits, torrents.times_completed, torrents.id, torrents.type, torrents.numfiles, torrents.nfo, torrents.category, categories.name AS cat_name, users.username FROM torrents LEFT JOIN categories ON torrents.category = categories.id LEFT JOIN users ON torrents.owner = users.id WHERE torrents.id = $id") or sqlerr();
replace with
Code:
$res = mysql_query("SELECT torrents.seeders, torrents.banned, torrents.leechers, torrents.info_hash, torrents.filename, LENGTH(torrents.nfo) AS nfosz, UNIX_TIMESTAMP() - UNIX_TIMESTAMP(torrents.last_action) AS lastseed, torrents.numratings, torrents.name, IF(torrents.numratings < $minvotes, NULL, ROUND(torrents.ratingsum / torrents.numratings, 1)) AS rating, torrents.owner, torrents.save_as, torrents.descr, torrents.visible, torrents.size, torrents.added, torrents.views, torrents.hits, torrents.times_completed, torrents.id, torrents.type, torrents.numfiles, torrents.nfo, torrents.image1, torrents.image2, torrents.category, categories.name AS cat_name, users.username FROM torrents LEFT JOIN categories ON torrents.category = categories.id LEFT JOIN users ON torrents.owner = users.id WHERE torrents.id = $id") or sqlerr();
find
Code:
if (!empty($row["descr"]))
 tr("Description", str_replace(array("\n", "  "), array("
\n", " "), format_urls(htmlspecialchars($row["descr"]))), 1);
add after
Code:
if ($row["image1"] != "" OR $row["image2"] != "") {
     if ($row["image1"] != "")
    $img1 = "[img]thumbnail.php?$row[image1][/img]";
     if ($row["image2"] != "")
    $img2 = "[img]thumbnail.php?$row[image2][/img]";
     tr("Images", $img1 . "&nbsp&nbsp" . $img2, 1);
 }

create a new php document called 'thumbnail.php' - Add into
Code:
<?php
# Constants
define(IMAGE_BASE, '/home/vixbit/public_html/trader/torrents/images/');
define(MAX_WIDTH, 150);
define(MAX_HEIGHT, 150);

# Get image location
$image_file = str_replace('..', '', $_SERVER['QUERY_STRING']);
$image_path = IMAGE_BASE . "/$image_file";

# Load image
$img = null;
$ext = strtolower(end(explode('.', $image_path)));
if ($ext == 'jpg' || $ext == 'jpeg') {
$img = @imagecreatefromjpeg($image_path);
} else if ($ext == 'png') {
$img = @imagecreatefrompng($image_path);
# Only if your version of GD includes GIF support
} else if ($ext == 'gif') {
$img = @imagecreatefromgif($image_path);
}

# If an image was successfully loaded, test the image for size
if ($img) {

# Get image size and scale ratio
$width = imagesx($img);
$height = imagesy($img);
$scale = min(MAX_WIDTH/$width, MAX_HEIGHT/$height);

# If the image is larger than the max shrink it
if ($scale < 1) {
$new_width = floor($scale*$width);
$new_height = floor($scale*$height);

# Create a new temporary image
$tmp_img = imagecreatetruecolor($new_width, $new_height);

# Copy and resize old image into new image
imagecopyresized($tmp_img, $img, 0, 0, 0, 0,
$new_width, $new_height, $width, $height);
imagedestroy($img);
$img = $tmp_img;
}
}

# Create error image if necessary
if (!$img) {
$img = imagecreate(MAX_WIDTH, MAX_HEIGHT);
imagecolorallocate($img,0,0,0);
$c = imagecolorallocate($img,70,70,70);
imageline($img,0,0,MAX_WIDTH,MAX_HEIGHT,$c2);
imageline($img,MAX_WIDTH,0,0,MAX_HEIGHT,$c2);
}

# Display the image
header("Content-type: image/jpeg");
imagejpeg($img);
?>
create a new php document called 'viewimage.php' - Add into
Code:
<?
require "include/bittorrent.php";
dbconn(false);

loggedinorreturn();

$pic = $_GET["pic"];

stdhead("View Image");
print("<h1>$pic</h1>\n");
print("<p align=center>[img]torrents/images/$pic[/img]</p>\n");
?>

<h3 align=center>Back</h3>

<?
stdfoot();
?>
Reply With Quote
  #2  
Old 20th September 2008, 14:40
Dexter1 Dexter1 is offline
Member
 
Join Date: Aug 2008
Posts: 1
Default thanks
Thanks man !
Reply With Quote
  #3  
Old 1st October 2008, 13:16
Grom's Avatar
Grom Grom is offline
Senior Member
 
Join Date: Aug 2008
Posts: 73
Default
viewimage.php
not working for me
__________________
Hello All
Reply With Quote
  #4  
Old 1st October 2008, 15:17
joeroberts's Avatar
joeroberts joeroberts is offline
BT.Manager Owner
 
Join Date: Jan 2008
United States
Posts: 2,113
Default
Quote:
Originally Posted by Grom View Post
viewimage.php
not working for me
did you edit
Code:
define(IMAGE_BASE, '/home/vixbit/public_html/trader/torrents/images/');
in thumbnail.php??
__________________
Do not ask me to help you work on your site that is not phpMyBitTorrent
Do not ask me to make a mod for any other source
Do not Ask me to setup your site.
I will no longer help you setup your site, there is a setup script if you have trouble with it post in the forum here or in BT.Manager™ forum
My Current Demo is here http://demo.btmanager.org/
Reply With Quote
  #5  
Old 1st October 2008, 18:01
Grom's Avatar
Grom Grom is offline
Senior Member
 
Join Date: Aug 2008
Posts: 73
Default
yes i edit thumbail and wievimages not working...
__________________
Hello All
Reply With Quote
  #6  
Old 9th October 2008, 07:09
joeroberts's Avatar
joeroberts joeroberts is offline
BT.Manager Owner
 
Join Date: Jan 2008
United States
Posts: 2,113
Default
Quote:
Originally Posted by Grom View Post
yes i edit thumbail and wievimages not working...
what do you see when you open wievimages.php?
__________________
Do not ask me to help you work on your site that is not phpMyBitTorrent
Do not ask me to make a mod for any other source
Do not Ask me to setup your site.
I will no longer help you setup your site, there is a setup script if you have trouble with it post in the forum here or in BT.Manager™ forum
My Current Demo is here http://demo.btmanager.org/
Reply With Quote
  #7  
Old 14th October 2008, 09:33
Subzero's Avatar
Subzero Subzero is offline
Coder
 
Join Date: Jul 2008
P2P
Posts: 190
Default
works here boys :-D
Reply With Quote
  #8  
Old 14th October 2008, 13:19
al_ltoticmat al_ltoticmat is offline
Senior Member
 
Join Date: Oct 2008
Posts: 44
Default
Code:
Parse error: syntax error, unexpected '/', expecting T_STRING or T_VARIABLE or T_NUM_STRING in /public_html/th/viewimage.php on line 11
Also, It doesn't appear at upload.php.

I put it here
Code:
tr("" .TORRENT_FILE. "", "<input type=file name=tfile size=80>\n", 1);
tr("" .TORRENT_NAME. "", "<input type=\"text\" name=\"name\" size=\"80\" /><br />" .NAME_DESC. "\n", 1);
tr("" .SMALL_DESC. "", "<input type=\"text\" name=\"description\" size=\"80\" /><b></b><br>" .DESC_INFO. "", 1);
tr("Images", "Max File Size: 500kb
Accepted Formats: .gif .jpg
Image 1:&nbsp&nbsp<input type=file name=image0 size=80>
Image 2:&nbsp&nbsp<input type=file name=image1 size=80>\n", 1);
tr("" .NFO_FILE. "", "<input type=file name=nfo size=80><br>(<b>" .REQUIRED. ".</b> " .ONLY_PU. ")\n", 1);
print("</td></tr>\n");
Reply With Quote
  #9  
Old 14th October 2008, 14:06
wMan wMan is offline
Banned
 
Join Date: Feb 2008
P2P
Posts: 1,433
Default
upload.php

Code:
tr("Torrent file", "<input type=file name=file size=80>\n", 1);
Reply With Quote
  #10  
Old 15th October 2008, 04:24
al_ltoticmat al_ltoticmat is offline
Senior Member
 
Join Date: Oct 2008
Posts: 44
Default
THank you

Last edited by al_ltoticmat; 15th October 2008 at 04:47.
Reply With Quote
Reply

Tags
images , torrent , upload

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Upload 2 images on torrent saggy00 Template Shares 5 23rd January 2010 14:47
Torrent Upload Naureenc Yuna Scatari Edition (YSE) 1 5th January 2010 14:36
upload torrent tunad Template Shares 1 6th October 2009 14:38
Extra images upload saggy00 Template Shares 8 14th September 2009 21:42
[REQ]Scrolling Latest Images Of Torrent On Index GauravJ123 xBTiT 0 25th July 2009 12:25



All times are GMT +2. The time now is 15:51. vBulletin skin by ForumMonkeys. Powered by vBulletin® Version 3.8.11 Beta 3
Copyright ©2000 - 2024, vBulletin Solutions Inc.