|
#1
|
|||
|
|||
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`; Code:
tr("Torrent file", "<input type=file name=file size=80>\n", 1); 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); Code:
tr("Images", "Max File Size: 500kb Accepted Formats: .gif .jpg Image 1:  <input type=file name=image0 size=80> Image 2:  <input type=file name=image1 size=80>\n", 1); Code:
<tr><td align="center" colspan="2"><input type="submit" class=btn value="Do it!" /></td></tr> 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"])) Code:
if (!isset($_FILES["tfile"])) Code:
$f = $_FILES["file"]; Code:
$f = $_FILES["tfile"]; Code:
// Replace punctuation characters with spaces 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; } } ////////////////////////////////////////////// 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); Code:
tr("Images", "<input type=radio name=img1action value='keep' checked>Keep Image 1  "."<input type=radio name=img1action value='delete'>Delete Image 1  "."<input type=radio name=img1action value='update'>Update Image 1 Image 1:  <input type=file name=image0 size=80> <input type=radio name=img2action value='keep' checked>Keep Image 2  "."<input type=radio name=img2action value='delete'>Delete Image 2  "."<input type=radio name=img2action value='update'>Update Image 2 Image 2:  <input type=file name=image1 size=80>", 1); Code:
function bark($msg) { genbark($msg, "Edit failed!"); } 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; } } //////////////////////////////////////////////// Code:
$res = mysql_query("SELECT owner, filename, save_as FROM torrents WHERE id = $id"); Code:
$res = mysql_query("SELECT owner, filename, save_as, image1, image2 FROM torrents WHERE id = $id"); Code:
$dname = $row["save_as"]; 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 = ''"; } } Code:
$res = mysql_query("SELECT name,owner,seeders FROM torrents WHERE id = $id"); Code:
$res = mysql_query("SELECT name,owner,seeders,image1,image2 FROM torrents WHERE id = $id"); Code:
deletetorrent($id); 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); } 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(); 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(); Code:
if (!empty($row["descr"])) tr("Description", str_replace(array("\n", " "), array(" \n", " "), format_urls(htmlspecialchars($row["descr"]))), 1); 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 . "  " . $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); ?> 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(); ?> |
#2
|
|||
|
|||
thanks
Thanks man !
|
#3
|
||||
|
||||
viewimage.php
not working for me
__________________
Hello All |
#4
|
||||
|
||||
did you edit
Code:
define(IMAGE_BASE, '/home/vixbit/public_html/trader/torrents/images/');
__________________
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/ |
#5
|
||||
|
||||
yes i edit thumbail and wievimages not working...
__________________
Hello All |
#6
|
||||
|
||||
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/ |
#7
|
||||
|
||||
works here boys :-D
|
#8
|
|||
|
|||
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 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:  <input type=file name=image0 size=80> Image 2:  <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"); |
#9
|
|||
|
|||
upload.php
Code:
tr("Torrent file", "<input type=file name=file size=80>\n", 1); |
#10
|
|||
|
|||
THank you
Last edited by al_ltoticmat; 15th October 2008 at 04:47. |
Tags |
images , torrent , upload |
|
|
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 |