Bravo List

Bravo List (http://www.bvlist.com/index.php)
-   Mods & Themes (http://www.bvlist.com/forumdisplay.php?f=109)
-   -   Upload 2 Images With Torrent (http://www.bvlist.com/showthread.php?t=724)


replace with
Code:



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", "", 1);
add after or near
Code:

tr("Images", "Keep Image 1&nbsp&nbsp"."Delete Image 1&nbsp&nbsp"."Update Image 1
Image 1:&nbsp&nbsp

 Keep Image 2&nbsp&nbsp"."Delete Image 2&nbsp&nbsp"."Update Image 2
Image 2:&nbsp&nbsp", 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:

# 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("

$pic

\n");
print("

[img]torrents/images/$pic[/img]

\n");
?>

Back



stdfoot();
?>

Nilsons 30th July 2008 22:27

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", "\n", 1);
replace with
Code:

tr("Torrent file", "\n", 1);

find
Code:

tr("Torrent name", "
(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
Image 2:&nbsp&nbsp\n", 1);

find
Code:


Click once only! - Uploading an image will require more loading time

Dexter1 20th September 2008 14:40

thanks
 
Thanks man ! :chch:

Grom 1st October 2008 13:16

viewimage.php
not working for me

joeroberts 1st October 2008 15:17

Quote:

Originally Posted by Grom (Post 4608)
viewimage.php
not working for me

did you edit
Code:

define(IMAGE_BASE, '/home/vixbit/public_html/trader/torrents/images/');
in thumbnail.php??

Grom 1st October 2008 18:01

yes i edit thumbail and wievimages not working...

joeroberts 9th October 2008 07:09

Quote:

Originally Posted by Grom (Post 4612)
yes i edit thumbail and wievimages not working...

what do you see when you open wievimages.php?

Subzero 14th October 2008 09:33

works here boys :-D

\n");
al_ltoticmat 14th October 2008 13:19

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. "", "\n", 1);
tr("" .TORRENT_NAME. "", "" .NAME_DESC. "\n", 1);
tr("" .SMALL_DESC. "", "" .DESC_INFO. "", 1);
tr("Images", "Max File Size: 500kb
Accepted Formats: .gif .jpg
Image 1:&nbsp&nbsp
Image 2:&nbsp&nbsp\n", 1);
tr("" .NFO_FILE. "", "(" .REQUIRED. ". " .ONLY_PU. ")\n", 1);
print("

wMan 14th October 2008 14:06

upload.php

Code:

tr("Torrent file", "\n", 1);

al_ltoticmat 15th October 2008 04:24

THank you

psychodo 15th October 2008 10:12

probelm
 
my english is not perfect

the image i don

al_ltoticmat 15th October 2008 10:21

/home/user/public_html/trackerdir/torrents/images/$row[image2]
/home/user/public_html/trackerdir/torrents/images/$row[image1]

You should edit this.

psychodo 15th October 2008 10:25

Quote:

Originally Posted by al_ltoticmat (Post 5351)
/home/user/public_html/trackerdir/torrents/images/$row[image2]
/home/user/public_html/trackerdir/torrents/images/$row[image1]

You should edit this.


yes i have this change

Night_Owl 21st July 2009 03:02

havin issue's
 
Code:

Parse error:  syntax error, unexpected T_LOGICAL_OR in /dir/dir/dir/public_html/details.php on line 109


were usin the strikemulti version i seen someone else tryed it on another version other then tbdev and it still worked any idea's on how to fix this line 109

Code:

or sqlerr();

is that this is the section its in

PHP 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();
    or 
sqlerr();
$row mysql_fetch_array($res);

$owned $moderator 0;
    if (
get_user_class() >= UC_MODERATOR)
        
$owned $moderator 1;
    elseif (
$CURUSER["id"] == $row["owner"])
        
$owned 1;
//} 


pdq 21st July 2009 03:13

delete the line with:
PHP Code:

or sqlerr(); 

=]

Night_Owl 21st July 2009 03:24

thank you
 
ill give it a try didnt know if i could comment it out delete which ever not really to good with php


:drink:

ok now the only error im gettin sence i got all the folder locations right is this

Invalid file type! Image 1

the file type im tryin is jpg and png which i added where it says can add more if i want any ideas ?

joeroberts 23rd January 2010 09:23

Quote:

Originally Posted by Night_Owl (Post 13579)
ill give it a try didnt know if i could comment it out delete which ever not really to good with php


:drink:

ok now the only error im gettin sence i got all the folder locations right is this

Invalid file type! Image 1

the file type im tryin is jpg and png which i added where it says can add more if i want any ideas ?

pleas show how you did it.

rootKID 14th September 2012 08:11

thanks man...
will try to Convert it into U-232 of my later...

-thanks :)...

DND 22nd March 2013 16:57

converted this to 09 version. but i can't see the thumbnails or the images.
it says that the image has errors.
they are uploading them on the server, everything works fine except showing them

Tedmorris 16th December 2018 03:24

How does viewimage.php work? Theres no code that calls for viewimage.php to load. Im assuming its supposed to load viewimage.php when you click on the thumbnail so you can see the full size rather thsn the 150x150 thumbnail?


All times are GMT +2. The time now is 02:03.

Powered by vBulletin® Version 3.8.11 Beta 3
Copyright ©2000 - 2024, vBulletin Solutions Inc.