Advanced search  

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Pages: [1] 2 3   Go Down

Author Topic: Formats Upload Modification - Associate a File with each Image  (Read 30564 times)

0 Members and 1 Guest are viewing this topic.

Garibaldi

  • Contributor
  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 100
    • Wisconsin Collector Car

I'd like to announce the release of the "Formats Upload" MOD for Coppermine 1.4.x. I needed a solution that would allow me to associate a zip file with each image on my site. This way I could include other files related to that image like an editable photoshop version, a text file with information about that image, etc. This modification adds that same functionality to your Coppermine install. It adds a new button on the Upload page, Edit File page, or Edit Files page. You can select the zip (or other file type) to associate with your image and it is added to the Custom User Field 1 and thus appears right below your image in your gallery for easy access. Here's an example:
http://wiscollectorcar.com/photogallery/albums/userpics/10301/normal_final.JPG

When you upload a file you're presented with this new "Add Formats" button. This same button appears when you click Edit on a picture or edit all the pictures in an album. When you click this button, a new window pops up where you can upload your associated file. Once finished hit done and it will be put automatically into the Other Formats field. You can then save your picture.
http://wiscollectorcar.com/photogallery/albums/userpics/10301/normal_upload.JPG

http://wiscollectorcar.com/photogallery/albums/userpics/10301/normal_upload1.JPG

http://wiscollectorcar.com/photogallery/albums/userpics/10301/normal_upload2.JPG

Here's an example of the similar functionality when you edit an image:
http://wiscollectorcar.com/photogallery/albums/userpics/10301/normal_edit_file.JPG

In addition, if you batch upload pictures, this modification will look for a .zip file in the formats_upload directory that has the same filename as each picture in your batch upload. If that file exists, it will be added automatically to each photo in the batch upload.

I've attached the zip of the files with install instructions.

*NEW* - version 1.2.x will delete the uploaded zip file associated with an image when you delete the image - to upgrade simply follow these instructions

A support topic for this modification is available on the Support Board

2009-07-30- version 1.2.0 now deletes the uploaded file when deleting a picture
2009-06-30- version 1.1.1 bugfix to correct the slashes in the upload URL for Windows servers

2009-06-01- version 1.1.0 added unique filenames for uploads

2009-04-17- version 1.0.0
« Last Edit: August 03, 2009, 05:06:13 pm by Garibaldi »
Logged

Garibaldi

  • Contributor
  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 100
    • Wisconsin Collector Car
Re: Formats Upload Modification - Associate a File with each Image
« Reply #1 on: April 17, 2009, 10:55:24 pm »

###############################################

## MOD Title: Formats Upload

## MOD Author: Garibaldi (Garibaldi@wiscollectorcar.com) http://www.wiscollectorcar.com

## MOD Description: Allows you to associate a file with each image in your gallery, e.g. a zip archive of files related to that image

## MOD Version: 1.1.1

## Installation Level: Easy

## Installation Time: 10 minutes

## Files To Edit: 7

##   upload.php

##   editpics.php

##   editOnePic.php

##   include/picmgmt.inc.php

##   lang/english.php

##   formats_upload.php

##   formats_helper.php

## Included Files:

##   formats_upload/

##   images/formats_upload.png

##   js/fileprogress.js

##   js/handlers.js

##   swfupload.js

##   swfupload.queue.js

##   swfupload.swf

##   swfuploadbutton.swf

## License: http://opensource.org/licenses/gpl-license.php GNU General Public License v2

##############################################################

## Author Notes:

## This modification uses the http://swfupload.org/ upload script

##############################################################

## MOD History:
## 2009-06-30- version 1.1.1 bugfix to correct the slashes in the upload URL for Windows servers

## 2009-06-01- version 1.1.0 added unique filenames for uploads

## 2009-04-17- version 1.0.0

##############################################################

## Before Adding This MOD To Your Coppermine install, You Should Back Up All Files Related To This MOD

##############################################################



#

#-----[ IN COPPERMINE ]---------------------------------

#

   Log in as an administrator and go to Config. Expand the section

   "Custom fields for image description (leave blank if unused)" and

   enter a name in "Field 1 name" like "Other Formats". Save the new

   configuration



#

#-----[ UPLOAD ]----------------------------------------

#

   Upload all files in this package to you Coppermine root directory



#

#-----[ OPEN ]------------------------------------------

#

   upload.php



#

#-----[ FIND ]------------------------------------------

#

       // Create a text box.
   

   echo <<<EOT   



#

#-----[ BEFORE, ADD ]-----------------------------------

#

   // s garibaldi

   global $lang_upload_php;

   if ($text == $CONFIG['user_field1_name']) {

      $text = $text . ' &nbsp; &nbsp; <input type="button" onclick="window.open(\'formats_upload.php\',\'user1\',\'status=0,toolbar=0,location=0,menubar=0,height=300,width=420,resizable=1\')" value="' . $lang_upload_php['other_formats_button'] . '" class="button" /> &nbsp; ';

   }

   // e garibaldi



#

#-----[ OPEN ]------------------------------------------

#

   editpics.php



#

#-----[ FIND ]------------------------------------------

#

    echo <<<EOT

        <tr>

            <td class="tableb" style="white-space: nowrap;">

                        $text

        </td>

        <td width="100%" class="tableb" valign="top">

                <input type="text" style="width: {$field_width}%" name="$name" maxlength="$max_length" value="$value" class="textinput" />

                </td>

        </tr>



EOT;



#

#-----[ REPLACE WITH ]----------------------------------

#

   // s garibaldi

   global $CONFIG, $lang_editpics_php;

   if ($text == $CONFIG['user_field1_name']) {//ereg($CONFIG['user_field1_name'], $text)) {

      $text = $text . ' &nbsp; &nbsp; <input type="button" onclick="window.open(\'formats_upload.php\',\'' . $name . '\',\'status=0,toolbar=0,location=0,menubar=0,height=300,width=420,resizable=1\')" value="' . $lang_editpics_php['other_formats_button'] . '" class="button" /> &nbsp; ';

   }



    echo <<<EOT

        <tr>

            <td class="tableb" style="white-space: nowrap;">

                        $text

        </td>

        <td width="100%" class="tableb" valign="top">

                <input type="text" style="width: {$field_width}%" id="$name" name="$name" maxlength="$max_length" value="$value" class="textinput" />

                </td>

        </tr>



EOT;

   // e garibaldi



#

#-----[ OPEN ]------------------------------------------

#

   editOnePic.php



#

#-----[ FIND ]------------------------------------------

#

echo <<<EOT

        <tr>

            <td class="tableb" style="white-space: nowrap;">

                {$CONFIG['user_field1_name']}

                </td>

                <td width="100%" class="tableb" valign="top">

                                <input type="text" style="width: 100%" name="user1" maxlength="255" value="{$CURRENT_PIC['user1']}" class="textinput" />

                        </td>

        </tr>

EOT;   



#

#-----[ REPLACE WITH ]----------------------------------

#

// s garibaldi

global $lang_editpics_php;

$other_formats = ' &nbsp; &nbsp; <input type="button" onclick="window.open(\'formats_upload.php\',\'user1\',\'status=0,toolbar=0,location=0,menubar=0,height=300,width=420,resizable=1\')" value="' . $lang_editpics_php['other_formats_button'] . '" class="button" /> &nbsp; ';

echo <<<EOT

        <tr>

            <td class="tableb" style="white-space: nowrap;">

                {$CONFIG['user_field1_name']}{$other_formats}

                </td>

                <td width="100%" class="tableb" valign="top">

                                <input type="text" style="width: 100%" id="user1" name="user1" maxlength="255" value="{$CURRENT_PIC['user1']}" class="textinput" />

                        </td>

        </tr>

EOT;

// e garibaldi



#

#-----[ OPEN ]------------------------------------------

#

   include/picmgmt.inc.php



#

#-----[ FIND ]------------------------------------------

#

    $image = $CONFIG['fullpath'] . $filepath . $filename;

    $normal = $CONFIG['fullpath'] . $filepath . $CONFIG['normal_pfx'] . $filename;

    $thumb = $CONFIG['fullpath'] . $filepath . $CONFIG['thumb_pfx'] . $filename;



#

#-----[ AFTER, ADD ]------------------------------------

#

   // s garibaldi

   

   // ******************** //

   // *** START CONFIG *** //

   // ******************** //

   $user1_path = "/var/htdocs/cpg14x/formats_upload/";   // NOTE: even if you are using Windows, use forward slashes "/" for paths - e.g. C:/windows/

   $user1_url = "http://mycpgroot.com/formats_upload/";

   $extension = "zip";

   // ******************** //

   // **** END CONFIG **** //

   // ******************** //

   

   $user1_file = substr($filename, 0, strlen($filename)-3) . $extension;

   // check to see if user1 not set already and exists in the specified dir

   if(($user1 == '') && is_file($user1_path . $user1_file)) {

         $user1 = $user1_url . $user1_file;

   }

   // e garibaldi



#

#-----[ NOTE ]------------------------------------------

#

   Edit the lines the lines after START CONFIG and before END CONFIG,

   adjusting the path of the upload folder for the files. This folder should

   not be inside your Coppermine albums folder. Its permissions may also need

   to be adjusted to 777 to allow upload. You can also adjust the type of files

   that can be uploaded. By default only .zip files are allowed



#

#-----[ OPEN ]------------------------------------------

#

   lang/english.php



#

#-----[ FIND ]------------------------------------------

#

$log_date_fmt = '%B %d, %Y at %I:%M %p'; //cpg1.4



#

#-----[ AFTER, ADD ]------------------------------------

#

// s garibaldi

$other_formats_button="Add Formats";

// e garibaldi



#

#-----[ FIND ]------------------------------------------

#

  'forb_ext' => 'Forbidden file extension.',//cpg1.4



#

#-----[ AFTER, ADD ]------------------------------------

#

  'other_formats_button' => $other_formats_button,   // garibaldi



#

#-----[ FIND ]------------------------------------------

#

  'regenerate_dictionary' => 'Regenerate Dictionary', //cpg1.4



#

#-----[ AFTER, ADD ]------------------------------------

#

  'other_formats_button' => $other_formats_button,   // garibaldi



#

#-----[ NOTE ]------------------------------------------

#

   These same language modifications can be applied to other languages as well.

   Just replace the english text with your native language



#

#-----[ OPEN ]------------------------------------------

#

   formats_upload.php



#

#-----[ FIND ]------------------------------------------

#

   var upload_url = "http://mycpgroot.com/formats_upload/";



#

#-----[ EDIT ]------------------------------------------

#

   Change the URL to point to the formats_upload folder inside your Coppermine Root



#

#-----[ OPEN ]------------------------------------------

#

   formats_helper.php



#

#-----[ FIND ]------------------------------------------

#

   $save_path = "/var/htdocs/cpg14x/formats_upload/";



#

#-----[ EDIT ]------------------------------------------

#

   Edit the path to point to your system's path to the formats_upload folder. This

   looks like the above example on linux/unix servers and on Windows might look like

   C:\webserver\cpg14x\formats_upload



#

#-----[ SAVE/CLOSE ALL FILES ]--------------------------

#

# EoM
« Last Edit: July 01, 2009, 07:15:34 am by Garibaldi »
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47844
  • aka "GauGau"
    • gaugau.de
Re: Formats Upload Modification - Associate a File with each Image
« Reply #2 on: April 19, 2009, 09:11:41 am »

Thanks for your contribution. I have removed reference to the hotlinked images in your initial posting. We're not fond of hotlinking to external resources (and in fact the bbocde tag [ i m g ] has been deliberately disabled here) as per board rules. I have merged the hotlinked images into two actual files and attached them to your initial posting on this thread.
Logged

Garibaldi

  • Contributor
  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 100
    • Wisconsin Collector Car
Re: Formats Upload Modification - Associate a File with each Image
« Reply #3 on: April 19, 2009, 05:30:41 pm »

Thank you for fixing that for me
Logged

zelal

  • Coppermine newbie
  • Offline Offline
  • Posts: 8
Re: Formats Upload Modification - Associate a File with each Image
« Reply #4 on: May 29, 2009, 04:50:05 pm »

Dear Garibaldi,

Thanks for your great effort.

I added this feature to my site.

But unfortunately, when a user upload a zip file which has the same name of a previously uploaded (say, by another user) file it replaces the previously uploaded file.

For example, a user named John has taken a photo of Alaska Mountain. He made a jpg version and a BMP version. He wanted to give the BMP file (within Zip) beside the JPG file. Accordingly he zipped it and named "mountain.zip" and then uploaded it using your feature.

After some days, another user named Allan also published his similar image (Himalayan or Alaska or etc. mountain) with zip file whose name is same as earlierly uploaded (by John) zip file i.e. mountain.zip.

Since the upload folder is also same (i.e. /formats_upload/) the upload immediately replaces the earlier one i.e. John's file will no longer exist.

Could you please fix this?

Thanks in advance.

Zelal

Dear Muller, I apology in advance if break the forum rule(s) by posting this in this thread. I searched to have the solution, but I could not find. May be, my search was not proper.
Logged

Garibaldi

  • Contributor
  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 100
    • Wisconsin Collector Car
Re: Formats Upload Modification - Associate a File with each Image
« Reply #5 on: May 31, 2009, 01:03:16 am »

Hi Zelal,

Good point, the zip filenames should be unique. I'll make an update and post it soon. Glad to hear that you like the MOD!
Logged

Garibaldi

  • Contributor
  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 100
    • Wisconsin Collector Car
Re: Formats Upload Modification - Associate a File with each Image
« Reply #6 on: June 02, 2009, 05:38:00 am »

Hi Zelal,

I've made the necessary changes tonight and tested it on my site. The modification now takes your uploaded file, e.g. myFile.zip, and adds a random number before the extension, like myFile1295.zip. This way, even identically selected files are made unique. I've updated the script with these changes in the first post of this thread. You just have to upload the formats_upload.php and formats_helper.php files after editing their settings as appropriate for your site
Logged

zelal

  • Coppermine newbie
  • Offline Offline
  • Posts: 8
Re: Formats Upload Modification - Associate a File with each Image
« Reply #7 on: June 03, 2009, 11:01:35 am »

Hi Garibaldi,

Thank you so much for your nice work. I think many people will like it.

Regards.

Zelal
Logged

mushipkw

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 25
Re: Formats Upload Modification - Associate a File with each Image
« Reply #8 on: June 29, 2009, 10:48:21 am »

Shows me the error
Parse error: parse error in C:\wamp\www\include\picmgmt.inc.php on line 42

Im trying this on Wamp, My directory structure is C:\wamp\www\[All Coppermine files]\
Here's what I have done in picmgmt.inc.php

// s garibaldi
   
   // ******************** //
   // *** START CONFIG *** //
   // ******************** //
   $user1_path = "C:\wamp\www\formats_upload\";
   $user1_url = "http://localhost/formats_upload/";
   $extension = "zip";
   // ******************** //
   // **** END CONFIG **** //
   // ******************** //

What is the solution?
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47844
  • aka "GauGau"
    • gaugau.de
Re: Formats Upload Modification - Associate a File with each Image
« Reply #9 on: June 29, 2009, 11:12:08 am »

If you get a parse error you simply haven't followed the instructions to a T. Undo your edits and re-apply them thoroughly.
Logged

mushipkw

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 25
Re: Formats Upload Modification - Associate a File with each Image
« Reply #10 on: June 29, 2009, 11:50:32 am »

I have redone the whole procedur, still getting the same error. Have I inputted the correct values in picmgmt.inc.php
Logged

Garibaldi

  • Contributor
  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 100
    • Wisconsin Collector Car
Re: Formats Upload Modification - Associate a File with each Image
« Reply #11 on: June 29, 2009, 05:02:24 pm »

It looks like an issue with Windows parsing the slashes as escape characters. Try replacing the double quotes in line 42 with single quotes. This will tell php to treat it completely as a string. If that doesn't work, for each slash "\", replace it with 3 slashes "\\\". I believe that will escape it correctly.
Logged

Nibbler

  • Guest
Re: Formats Upload Modification - Associate a File with each Image
« Reply #12 on: June 29, 2009, 05:07:58 pm »

2 slashes.
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47844
  • aka "GauGau"
    • gaugau.de
Re: Formats Upload Modification - Associate a File with each Image
« Reply #13 on: June 29, 2009, 06:21:35 pm »

A slash actually looks like this: /
What you're refering to ( \ ) is actually a backslash.
Logged

Garibaldi

  • Contributor
  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 100
    • Wisconsin Collector Car
Re: Formats Upload Modification - Associate a File with each Image
« Reply #14 on: June 29, 2009, 10:49:07 pm »

Sorry, yes 2 backslashes. I was thinking 3 from when I recently had to escape a backslash followed by a quote
Logged

mushipkw

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 25
Re: Formats Upload Modification - Associate a File with each Image
« Reply #15 on: June 30, 2009, 02:01:57 pm »

Thanks guys got it working,  actually used front slashes instead of back slashes in the path.
Logged

Garibaldi

  • Contributor
  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 100
    • Wisconsin Collector Car
Re: Formats Upload Modification - Associate a File with each Image
« Reply #16 on: June 30, 2009, 05:00:32 pm »

Great glad to hear it! It may be the case that although windows uses backslashes for paths, php replaces those with regular slashes for windows paths to avoid this problem of unintentional escape characters
Logged

Garibaldi

  • Contributor
  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 100
    • Wisconsin Collector Car
Re: Formats Upload Modification - Associate a File with each Image
« Reply #17 on: July 01, 2009, 07:17:15 am »

I added information about this issue to the package attached to the first post and the instructions in the second post
Logged

mushipkw

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 25
Re: Formats Upload Modification - Associate a File with each Image
« Reply #18 on: July 23, 2009, 04:55:17 pm »

I would like to add more extensions i.e rar for supported upload. How can I do that?
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47844
  • aka "GauGau"
    • gaugau.de
Re: Formats Upload Modification - Associate a File with each Image
« Reply #19 on: July 23, 2009, 05:46:45 pm »

How to add other file types (extensions) is beyond the scope of this mod, but has been explained often already. Please use the search. If you can't find good results after performing a thorough search start a thread of your own on the support board, providing the needed details.
Logged
Pages: [1] 2 3   Go Up
 

Page created in 0.027 seconds with 19 queries.