Bravo List
Register
Go Back   > Bravo List > Source Code > Archived Trackers > Template Shares
Reply
  #1  
Old 9th May 2010, 20:46
saggy00 saggy00 is offline
Senior Member
 
Join Date: Jul 2009
Greece
Posts: 35
Default Images in Torrents
Hello! Can someone make this mod???


***EDIT****
- All changes I have made to this mod as found in Posts 11 & 19 below have been incorporated into this post.

- If you would prefer to NOT use the lightbox js script in this mod and would prefer to have a new page loaded with a full size image when a thumbnail is clicked on (as per the old version of the mod) see post 22 after following the instructions below.
************

Greetings ALL!

At the request of iceboxrj I have updated my original Upload 2 Images With Torrent to run with the 'TBDev Tracker 2009 (Final)' tracker...
Presenting 'Upload Image With Torrents'...
It has been at least 4 years since I made a modification and I also currently don't run any trackers.
To make this mod I simply downloaded the TBDev2009 Final tracker source, got a hold of my old mod, and coded until the thing was working with this latest source.
For those that have never seen it or never used it basically allows users to upload a specified number of images (of specified size and type) that will be displayed with their uploaded torrents.
When the torrent details page is loaded for a particular torrent that had images uploaded with it, the images are thumbnailed down, on the fly, and displayed with the rest of the details.
If a thumbnail is clicked on a 'lightbox' is loaded with the full size image in it.
When the torrent is deleted the images are also removed.

The images are stored in a specified folder on the server in the following format ID_X.EXT where:
- ID = the id of the torrent the images are uploaded with
- X = the number of the picture (0,1,2,3, etc)
- EXT = the extension of the picture (eg, .jpg, .gif)

Images:
Click the image to open in full size.
Click the image to open in full size.
Click the image to open in full size.

Also note, your server will need the GD Library installed to be able to make use of the auto thumbnail functionality.
As it's been such a long time since I last made a contribution to this site I am really unaware of what other image mods are available out there.
This may be crap in comparison, but I have tried to make it as simple as possible to install (there should only be one 'modification' required per file) and kept all the main control settings in one place.

Anyways, instructions are below... I hope you find this useful and I look forward to your comments.
As a side, I will try to help anyone having problems with the script but I make no guarantees. I am very busy and dont have heaps of time to be solving other ppls problems and theres also the fact I am only an amateur coder and may not be able to figure out your problem.

---------------------------------------

CHANGE SUMMARY:

SQL:
- NONE

Files To Be Edited:
- \include\bittorrent.php
- \lang\en\lang_details.php
- \lang\en\lang_edit.php
- \lang\en\lang_takeedit.php
- \lang\en\lang_takeupload.php
- \lang\en\lang_upload.php
- \delete.php
- \details.php
- \edit.php
- \takeedit.php
- \takeupload.php

Files To Be Added:
- \include\image_upload_settings.php
- \thumbnail.php
- \getimage.php

Folders To Be Added:
- 1x New folder for storing the uploaded images

The lightbox2.04 package will also be used

---------------------------------------

INSTALLATION INSTRUCTIONS

1. BACKUP YOUR OLD FILES!!!!
2. Go through and make each of the changes outlined below. Take careful note of whether you are 'ADDING AFTER' the specified code or 'REPLACING WITH'.
3. Create a new folder where you want all the images uploaded to be stored. Personally, I called mine 'torrents_images' and kept it in the TB root directory.
3. Edit the '\include\image_upload_settings.php' making all the appropriate settings changes for your server (including the location of the image storage folder you created in the previous step). You should not have to edit any other files.
4. GO! You should now be able to upload images with your torrents.
(If you wish to disable the mod at any time for any reason simply go to the \include\image_upload_settings.php and change $IMAGE_UPLOAD_ENABLED setting from TRUE to FALSE.. This *SHOULD* disable the modification from running.)

---------------------------------------

DOWNLOAD lightbox2.04.zip

EXTRACT the zip and upload the whole lightbox2.04 folder to the ROOT directory of your tb.

@file \lightbox2.04\js\lightbox.js

FIND:
PHP Code:
    fileLoadingImage:        'images/loading.gif',     
    
fileBottomNavCloseImage'images/closelabel.gif'
REPLACE with:
PHP Code:
    fileLoadingImage:        'lightbox2.04/images/loading.gif',     
    
fileBottomNavCloseImage'lightbox2.04/images/closelabel.gif'
@file \include\bittorrent.php

FIND:
PHP Code:
            <title>{$title}</title
ADD after:
HTML Code:
            <script type='text/javascript' src='lightbox2.04/js/prototype.js'></script>
            <script type='text/javascript' src='lightbox2.04/js/scriptaculous.js?load=effects,builder'></script>
            <script type='text/javascript' src='lightbox2.04/js/lightbox.js'></script>
            <link rel='stylesheet' href='lightbox2.04/css/lightbox.css' type='text/css' media='screen' />
@file \lang\en\lang_details.php

FIND:
PHP Code:
'details_details' => "Details for torrent "
ADD after:
PHP Code:
'details_images' => "Images"
@file \lang\en\lang_edit.php

FIND:
PHP Code:
'edit_delete' => "Delete it!"
ADD after:
PHP Code:
'edit_image' => "Image",
'edit_image_leave' => "Leave",
'edit_image_del' => "Delete",
'edit_image_up' => "Update:"
@file \lang\en\lang_takeedit.php

FIND:
PHP Code:
'takedit_log' => "Torrent %s (%s) was edited by %s" 
REPLACE with:
PHP Code:
'takedit_log' => "Torrent %s (%s) was edited by %s",
'takeedit_img_failed' => 'Image Update Failed!',
'takeedit_img_type' => "Image file is is invalid type.",
'takeedit_img_big' => "Image file is too big! Max 512,000 bytes.",
'takeedit_img_exists' => "An image already exists. Contact Admin for assistance.",
'takeedit_img_copyerror' => "An error occured copy the image to the image storage repository. Contact Admin for assistance."
@file \lang\en\lang_takeupload.php

FIND:
PHP Code:
'takeupload_log' => "Torrent %s (%s) was uploaded by %s"
ADD after:
PHP Code:
'takeupload_img_failed' => "Image upload failed",
'takeupload_img_type' => "Image file is is invalid type.",
'takeupload_img_big' => "Image file is too big! Max 512,000 bytes.",
'takeupload_img_exists' => "An image already exists. Contact Admin for assistance.",
'takeupload_img_copyerror' => "An error occured copy the image to the image storage repository. Contact Admin for assistance."
@file \lang\en\lang_upload.php

FIND:
PHP Code:
'upload_submit' => "Do it!"
ADD after:
PHP Code:
'upload_image' => "Upload Image",
'upload_image_info' => "<b>Optional.</b> Can be added or removed later."
@file \delete.php

FIND:
PHP Code:
    unlink("{$TBDEV['torrent_dir']}/$id.torrent"); 
ADD after:
PHP Code:
    // ---------------------------------------------------------------- \\
    // ----------- POINDA'S "UPLOAD IMAGE WITH TORRENT" MOD ----------- \\
    // ---------------------------------------------------------------- \\
    
require_once "include/image_upload_settings.php";
    if (
$IMAGE_UPLOAD_ENABLED) {

        
$IMAGE_DIR $IMAGE_MOD_SETTINGS['IMAGE_DIR'];
        
$image_array Get_Current_Images($id$IMAGE_MOD_SETTINGS);
        
        
// If images are found relating to the current torrent then delete them
        
if (!empty($image_array)) {
        
            foreach (
$image_array as $img) {
                if (
$img != 0) {
                    
$imgloc $IMAGE_DIR $img;
                    
unlink($imgloc);
                }
            }
        
        }

    }
    
// -------- POINDA'S "UPLOAD IMAGE WITH TORRENT" MOD - END -------- \\ 
@file \details.php

FIND:
PHP Code:
            $HTMLOUT .= "<tr><td style='vertical-align:top'>{$lang['details_description']}</td><td><div style='background-color:#d9e2ff;width:100%;height:150px;overflow: auto'>"str_replace(array("\n""  "), array("<br />\n""  "), format_comment$row["descr"] ))."</div></td></tr>"
ADD after:
PHP Code:
    // ---------------------------------------------------------------- \\
    // ----------- POINDA'S "UPLOAD IMAGE WITH TORRENT" MOD ----------- \\
    // ---------------------------------------------------------------- \\
    
require_once "include/image_upload_settings.php";
    if (
$IMAGE_UPLOAD_ENABLED) {

        
$IMAGE_DIR $IMAGE_MOD_SETTINGS['IMAGE_DIR'];
        
$image_array Get_Current_Images($id$IMAGE_MOD_SETTINGS);

        
// If images are found relating to the current torrent then display them
        
if (!empty($image_array)) {
        
            
$display_image_row 0;
            
            foreach (
$image_array as $img) {
                if (
$img != 0) {
                    if (
$display_image_row != 1) {
                        
$display_image_row 1;
                        
$HTMLOUT .= "<tr><td style='vertical-align:top'>{$lang['details_images']}</td><td>";
                    }
                    
$imgloc $IMAGE_DIR $img;
                    
$HTMLOUT .= "<p><a href='$imgloc' rel='lightbox[imageSet]' title='<a href=getimage.php?file=$img>Download Image</a>'><img src='thumbnail.php?$img'></a></p>";
                }
            }
        
            if (
$display_image_row == 1)
                
$HTMLOUT .= "</td></tr>\n";
        }

    }
    
// -------- POINDA'S "UPLOAD IMAGE WITH TORRENT" MOD - END -------- \\ 
@file \edit.php

FIND:
PHP Code:
    $HTMLOUT  .= tr($lang['edit_torrent_name'], "<input type='text' name='name' value='" htmlspecialchars($row["name"]) . "' size='80' />"1); 
ADD after:
PHP Code:
    // ---------------------------------------------------------------- \\
    // ----------- POINDA'S "UPLOAD IMAGE WITH TORRENT" MOD ----------- \\
    // ---------------------------------------------------------------- \\
    
require_once "include/image_upload_settings.php";
    if (
$IMAGE_UPLOAD_ENABLED) {

        
$IMAGE_DIR $IMAGE_MOD_SETTINGS['IMAGE_DIR'];
        
$MAX_IMAGES $IMAGE_MOD_SETTINGS['MAX_IMAGES'];
        
$UPLOAD_DIRECTORY $IMAGE_MOD_SETTINGS['UPLOAD_DIRECTORY'];

        
// Work out if there are any images uploaded for the current torrent
        
$image_array Get_Current_Images($id$IMAGE_MOD_SETTINGS);
        
        
// Display upload/delete image boxes (taking into account those images already uploaded)
        
for ($x=0$x $MAX_IMAGES$x++) {

            
$y $x 1;

            
// If there is already an image existing for the particular image number then allow to delete or leave along
            
if ($image_array[$x] != 0)
                
$HTMLOUT  .= tr($lang['edit_image'] . " #$y""<p><a href='$IMAGE_DIR$image_array[$x]' rel='lightbox[imageSet]'><img src='thumbnail.php?$image_array[$x]'></a></p><input type='radio' name='image$x' value='leave' checked='checked' />{$lang['edit_image_leave']}"  " "<input type='radio' name='image$x' value='delete' />{$lang['edit_image_del']}<br /><input type='radio' name='image$x' value='update' />{$lang['edit_image_up']}<br /><input type='file' name='image$x' size='80' />"1);
            else
                
$HTMLOUT  .= tr($lang['edit_image'] . " #$y""<input type='radio' name='image$x' value='leave' checked='checked' />{$lang['edit_image_leave']}<br /><input type='radio' name='image$x' value='update' />{$lang['edit_image_up']}<br /><input type='file' name='image$x' size='80' />"1);
        
        }

    }
    
// -------- POINDA'S "UPLOAD IMAGE WITH TORRENT" MOD - END -------- \\ 
@file \takeedit.php

FIND:
PHP Code:
   $updateset[] = "visible = '" . ( isset($_POST['visible']) ? 'yes' 'no') . "'"
ADD after:
PHP Code:
    // ---------------------------------------------------------------- \\
    // ----------- POINDA'S "UPLOAD IMAGE WITH TORRENT" MOD ----------- \\
    // ---------------------------------------------------------------- \\
    
require_once "include/image_upload_settings.php";
    if (
$IMAGE_UPLOAD_ENABLED) {

        
$allowed_types $IMAGE_MOD_SETTINGS['ALLOWED_TYPES'];
        
$IMAGE_DIR $IMAGE_MOD_SETTINGS['IMAGE_DIR'];
        
$MAX_IMAGES $IMAGE_MOD_SETTINGS['MAX_IMAGES'];
        
$MAX_FILE_SIZE $IMAGE_MOD_SETTINGS['MAX_FILE_SIZE'];
        
$UPLOAD_DIRECTORY $IMAGE_MOD_SETTINGS['UPLOAD_DIRECTORY'];
        
        
// For each image check what action is to be taken
        
for ($x=0$x $MAX_IMAGES$x++) {
            
            
$cur_img "image" $x;
            
$imgname $id "_" $x;

            
// Check if the particular image is to be updated or deleted
            
if (($_POST[$cur_img] == "update") || ($_POST[$cur_img] == "delete")) {

                
// First delete the particular image if it already exists regardless of update or delete
                
foreach ($allowed_types as $ext) {
                    
$image_name $imgname "." $ext;
                    
$image_loc $UPLOAD_DIRECTORY $image_name;
                    if (
file_exists($image_loc)) {
                        
unlink($image_loc);
                        break;
                    }
                }

                
// If the user wanted to add/update an image, process the image upload
                
if ($_POST[$cur_img] == "update") {
                    
                    if (!(
$_FILES[$cur_img]['name'] == "")) {

                        
$imgname basename($_FILES[$cur_img]['name']);

                        
// Check if the file is a valid type
                        
if (!array_key_exists($_FILES[$cur_img]['type'], $allowed_types))
                            
stderr($lang['takeedit_img_failed'], $lang['takeedit_img_type'] . " ($x)");

                        
// Check if the file is within the allowed size range
                        
if ($_FILES[$cur_img]["size"] > $MAX_FILE_SIZE
                            
stderr($lang['takeedit_img_failed'], $lang['takeedit_img_big'] . " ($x)");

                        
// 'Calculate' what the image name will be
                        
$img_ext substr($imgnamestrrpos($imgname'.') + 1);
                        
$image_name $id "_" $x "." $img_ext;

                        
// Determine the path where the image will be saved
                        
$newname $UPLOAD_DIRECTORY.$image_name;
                        
                        
//Check if a file with the same name already exists on the server
                        
if (!file_exists($newname)) {
                        
                            
//Attempt to move the uploaded file to it's new location
                            
if (!(move_uploaded_file($_FILES[$cur_img]['tmp_name'],$newname))) {
                                
stderr($lang['takeedit_img_failed'], $lang['takeedit_img_copyerror'] . " ($x)");
                            }

                        } else {
                            
stderr($lang['takeedit_img_failed'], $lang['takeedit_img_exists'] . " ($x)");
                        }

                    }
                }
            }
        }

    }
    
// -------- POINDA'S "UPLOAD IMAGE WITH TORRENT" MOD - END -------- \\ 

@file \takeupload.php

FIND:
PHP Code:
      stderr($lang['takeupload_failed'], $lang['takeupload_no_cat']); 
ADD after:
PHP Code:
    // ---------------------------------------------------------------- \\
    // ----------- POINDA'S "UPLOAD IMAGE WITH TORRENT" MOD ----------- \\
    // ---------------------------------------------------------------- \\
    
require_once "include/image_upload_settings.php";
    if (
$IMAGE_UPLOAD_ENABLED) {

        
$allowed_types $IMAGE_MOD_SETTINGS['ALLOWED_TYPES'];
        
$MAX_IMAGES $IMAGE_MOD_SETTINGS['MAX_IMAGES'];
        
$MAX_FILE_SIZE $IMAGE_MOD_SETTINGS['MAX_FILE_SIZE'];
        
$UPLOAD_DIRECTORY $IMAGE_MOD_SETTINGS['UPLOAD_DIRECTORY'];

        for (
$x=0$x $MAX_IMAGES$x++) {

            
// Calculate the index of the image file in the _FILES array
            
$img_index "image" $x;
            
            
// If an image was actually specified in the particular image upload box proceed with the image processing
            
if (!($_FILES[$img_index]['name'] == "")) {

                
$imgname basename($_FILES[$img_index]['name']);

                
// Check if the file is a valid type
                
if (!array_key_exists($_FILES[$img_index]['type'], $allowed_types))
                    
stderr($lang['takeupload_img_failed'], $lang['takeupload_img_type'] . " ($x)");

                
// Check if the file is within the allowed size range
                
if ($_FILES[$img_index]["size"] > $MAX_FILE_SIZE
                    
stderr($lang['takeupload_img_failed'], $lang['takeupload_img_big'] . " ($x)");

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

                
// 'Calculate' what the image name will be
                
$img_ext substr($imgnamestrrpos($imgname'.') + 1);
                
$image_name $next_id "_" $x "." $img_ext;

                
// Determine the path where the image will be saved
                
$newname $UPLOAD_DIRECTORY.$image_name;
                
                
//Check if a file with the same name already exists on the server
                
if (!file_exists($newname)) {
                
                    
//Attempt to move the uploaded file to it's new location
                    
if (!(move_uploaded_file($_FILES[$img_index]['tmp_name'],$newname))) {
                        
stderr($lang['takeupload_img_failed'], $lang['takeupload_img_copyerror'] . " ($x)");
                    }

                } else {
                    
stderr($lang['takeupload_img_failed'], $lang['takeupload_img_exists'] . " ($x)");
                }

            }

        }

    }
    
// -------- POINDA'S "UPLOAD IMAGE WITH TORRENT" MOD - END -------- \\ 
@file \upload.php

FIND:
PHP Code:
   $HTMLOUT .= "<table border='1' cellspacing='0' cellpadding='10'>
    <tr>
      <td class='heading' valign='top' align='right'>
{$lang['upload_torrent']}</td>
      <td valign='top' align='left'><input type='file' name='file' size='80' /></td>
    </tr>
    <tr>
      <td class='heading' valign='top' align='right'>
{$lang['upload_name']}</td>
      <td valign='top' align='left'><input type='text' name='name' size='80' /><br />(
{$lang['upload_filename']})</td>
    </tr>
    <tr>
      <td class='heading' valign='top' align='right'>
{$lang['upload_nfo']}</td>
      <td valign='top' align='left'><input type='file' name='nfo' size='80' /><br />(
{$lang['upload_nfo_info']})</td>
    </tr>
    <tr>
      <td class='heading' valign='top' align='right'>
{$lang['upload_description']}</td>
      <td valign='top' align='left'><textarea name='descr' rows='10' cols='80'></textarea>
      <br />(
{$lang['upload_html_bbcode']})</td>
    </tr>"

REPLACE with:
PHP Code:
    // ---------------------------------------------------------------- \\
    // ----------- POINDA'S "UPLOAD IMAGE WITH TORRENT" MOD ----------- \\
    // ---------------------------------------------------------------- \\
    
require_once "include/image_upload_settings.php";
    if (
$IMAGE_UPLOAD_ENABLED) {

        
$MAX_IMAGES $IMAGE_MOD_SETTINGS['MAX_IMAGES'];
    
        
$HTMLOUT .= "<table border='1' cellspacing='0' cellpadding='10'>
        <tr>
          <td class='heading' valign='top' align='right'>
{$lang['upload_torrent']}</td>
          <td valign='top' align='left'><input type='file' name='file' size='80' /></td>
        </tr>
        <tr>
          <td class='heading' valign='top' align='right'>
{$lang['upload_name']}</td>
          <td valign='top' align='left'><input type='text' name='name' size='80' /><br />(
{$lang['upload_filename']})</td>
        </tr>"
;

        for (
$x=0$x $MAX_IMAGES$x++) {
            
$y $x 1;
            
$HTMLOUT .= "<tr>
              <td class='heading' valign='top' align='right'>
{$lang['upload_image']} #$y</td>
              <td valign='top' align='left'><input type='file' name='image
$x' size='80' /><br />({$lang['upload_image_info']})</td>
            </tr>"
;

        }

        
$HTMLOUT .= "<tr>
          <td class='heading' valign='top' align='right'>
{$lang['upload_nfo']}</td>
          <td valign='top' align='left'><input type='file' name='nfo' size='80' /><br />(
{$lang['upload_nfo_info']})</td>
        </tr>
        <tr>
          <td class='heading' valign='top' align='right'>
{$lang['upload_description']}</td>
          <td valign='top' align='left'><textarea name='descr' rows='10' cols='80'></textarea>
          <br />(
{$lang['upload_html_bbcode']})</td>
        </tr>"
;
    
    } else {

        
$HTMLOUT .= "<table border='1' cellspacing='0' cellpadding='10'>
        <tr>
          <td class='heading' valign='top' align='right'>
{$lang['upload_torrent']}</td>
          <td valign='top' align='left'><input type='file' name='file' size='80' /></td>
        </tr>
        <tr>
          <td class='heading' valign='top' align='right'>
{$lang['upload_name']}</td>
          <td valign='top' align='left'><input type='text' name='name' size='80' /><br />(
{$lang['upload_filename']})</td>
        </tr><tr>
          <td class='heading' valign='top' align='right'>
{$lang['upload_nfo']}</td>
          <td valign='top' align='left'><input type='file' name='nfo' size='80' /><br />(
{$lang['upload_nfo_info']})</td>
        </tr>
        <tr>
          <td class='heading' valign='top' align='right'>
{$lang['upload_description']}</td>
          <td valign='top' align='left'><textarea name='descr' rows='10' cols='80'></textarea>
          <br />(
{$lang['upload_html_bbcode']})</td>
        </tr>"
;

    }
    
// -------- POINDA'S "UPLOAD IMAGE WITH TORRENT" MOD - END -------- \\ 
NEW FILE - \include\image_upload_settings.php

PHP Code:
<?

// CODED BY POINDA .. 27th March 2010
// Email: [email]email@poinda.com[/email]

// To disable the mod completely change this to FALSE
$IMAGE_UPLOAD_ENABLED TRUE;

// ---------------------------------------------------------------- \\
// --------------- MODIFY ANY OF THE SETTINGS BELOW --------------- \\
// ---------------------------------------------------------------- \\

if ($IMAGE_UPLOAD_ENABLED) {

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

        
// The location of the directory where the images are stored relative to the directory
        
'IMAGE_DIR' => "torrents_images/",
        
        
// The number of images you wish you users to be allowed to upload per torrent
        
'MAX_IMAGES' => 2,
        
        
// The maximum file size for individual uploads (in bytes). Default 512kb
        
'MAX_FILE_SIZE' => 512000,
        
        
// The directory where you will store the uploaded images
        
'UPLOAD_DIRECTORY' => "/home/myaccount/public_html/TBDev2009/torrents_images/",
    );

}

// ---------------------------------------------------------------- \\
// ---- YOU SHOULD NOT NEED TO MODIFY ANYTHING BELOW THIS LINE ---- \\
// ---------------------------------------------------------------- \\

function Get_Current_Images($torrent_id$settings) {

    
$allowed_types $settings['ALLOWED_TYPES'];
    
$MAX_IMAGES $settings['MAX_IMAGES'];
    
$UPLOAD_DIRECTORY $settings['UPLOAD_DIRECTORY'];
    
    
$image_array = array();
    
    
// Work out if there are any images uploaded for the current torrent
    
for ($x=0$x $MAX_IMAGES$x++) {
        
        
$image_array[$x] = 0;
        
$imgname $torrent_id "_" $x ".";
        
        
// loop through each possible image file name (given the number of allowed images and each extension type)
        
foreach ($allowed_types as $ext) {

            
$image_name $imgname $ext;
            
$image_loc $UPLOAD_DIRECTORY $image_name;

            if (
file_exists($image_loc)) {

                
// if the the particular image has not already been found to exist, then add it to the array of current images
                
if (!in_array($image_name$image_array))
                    
$image_array[$x] = $image_name;
                
            }
        }
    }

    return 
$image_array;

}

?>
NEW FILE - \thumbnail.php

PHP Code:
<?php

// ---------------------------------------------------------------- \\
// ----------- POINDA'S "UPLOAD IMAGE WITH TORRENT" MOD ----------- \\
// ---------------------------------------------------------------- \\

require_once "include/image_upload_settings.php";
if (
$IMAGE_UPLOAD_ENABLED) {

    
$UPLOAD_DIRECTORY $IMAGE_MOD_SETTINGS['UPLOAD_DIRECTORY'];

    
# Constants
    
define(IMAGE_BASE$UPLOAD_DIRECTORY);
    
define(MAX_WIDTH250);
    
define(MAX_HEIGHT250);

    
# 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/$widthMAX_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$img0000,
            
$new_width$new_height$width$height);
            
imagedestroy($img);
            
$img $tmp_img;
        }
    }

    
# Create error image if necessary
    
if (!$img) {
        
$img imagecreate(MAX_WIDTHMAX_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);

}

// -------- POINDA'S "UPLOAD IMAGE WITH TORRENT" MOD - END -------- \\

?>
NEW FILE - \getimage.php

PHP Code:
<?

/////////////////////// POINDA'S UPLOAD IMAGE WITH TORRENT MOD ////////////////////////
require_once "include/image_upload_settings.php";
if (
$IMAGE_UPLOAD_ENABLED) {

    
$IMAGE_DIR $IMAGE_MOD_SETTINGS['IMAGE_DIR'];
    
    
$filename $_GET['file'];
    
$image $IMAGE_DIR $filename;

    if(
ini_get('zlib.output_compression'))
        
ini_set('zlib.output_compression''Off');

    
$file_extension strtolower(substr(strrchr($filename,"."),1));

    if (
$filename == "") {
        echo 
"<b>No file specified</b>";
        exit;
    } elseif (!
file_exists($image)) {
        echo 
"<b>Cannot find file</b>";
        exit;
    }

    
$mimetype array_search($file_extension$allowed_types);

    if (
$mimetype == "") {
        echo 
"<b>Invalid file type</b>";
        exit;
    }

    
header("Pragma: public");
    
header("Expires: 0");
    
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
    
header("Cache-Control: private",false);
    
header("Content-Type: $mimetype");
    
header("Content-Disposition: attachment; filename=\"".basename($filename)."\";" );
    
header("Content-Transfer-Encoding: binary");
    
header("Content-Length: ".filesize($image));
    
readfile("$image");
    exit();

}
/////////////////////// POINDA'S UPLOAD IMAGE WITH TORRENT MOD - END ////////////////////////

?>

Last edited by joeroberts; 9th May 2010 at 21:03. Reason: place codes in box
Reply With Quote
The Following User Says Thank You to saggy00 For This Useful Post:
gogo999 (28th January 2013)
  #2  
Old 9th May 2010, 21:04
joeroberts's Avatar
joeroberts joeroberts is offline
BT.Manager Owner
 
Join Date: Jan 2008
United States
Posts: 2,113
Default
Please use code box nex time!!!
__________________
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
  #3  
Old 10th May 2010, 16:28
saggy00 saggy00 is offline
Senior Member
 
Join Date: Jul 2009
Greece
Posts: 35
Default
Ok then!! I will pay 20 $ for this convertion for 5.4.1 and for something other with the subs section
Reply With Quote
  #4  
Old 26th May 2010, 10:01
poinda poinda is offline
Member
 
Join Date: May 2010
P2P
Posts: 1
Default
alright then ill do it $20... after all I am the one that coded the mod :p

what exactly do you want?
Reply With Quote
  #5  
Old 27th January 2013, 21:19
DND DND is offline
VIP
 
Join Date: Dec 2008
Posts: 1,242
Default
this won't work anymore for 09
anyone has it working for 09 ? because if the code is in include/image_upload_settings .. it won't work. at least for me. but if it is in bittorent it works. almost.
because on details the thumbnail shows nothing and it says picture xx001 has errors.
Reply With Quote
Reply

Tags
images , torrents

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
having problem with some images wMan Community Cafe 0 22nd June 2009 14:17
Need new Images joeroberts BT.Manager (phpMyBitTorrent) 4 19th June 2009 02:02
Cool Rank Images azog2 Community Cafe 3 12th May 2009 16:36
Images, Baners.... x517530 Template Shares 5 7th November 2008 04:15



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