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 30563 times)

0 Members and 1 Guest are viewing this topic.

mushipkw

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 25
Re: Formats Upload Modification - Associate a File with each Image
« Reply #20 on: July 23, 2009, 06:12:41 pm »

[quote

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

   // *** 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 **** //

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

   

#-----[ 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

#

[/quote]

What Im asking about is how to add support for rar in this section?
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 #21 on: July 24, 2009, 10:01:01 am »

Do as I suggested:
start a thread of your own on the support board, providing the needed details.
Hint: what a needed detail is can be found out by reading the board rules.

Joachim

P.S. You should learn how to quote using bbcode
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 #22 on: July 24, 2009, 06:31:33 pm »

Sorry for my late response. I've created a support topic for this modification in the support forum. Here is a link:
http://forum.coppermine-gallery.net/index.php/topic,60768.0.html

I have posted a response to your question about alternate filetypes there.

Thanks,

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 #23 on: July 30, 2009, 09:53:15 pm »

I'm releasing an update that includes support for deleting the uploaded file when you delete a picture. To upgrade, simply follow these instructions:
Code: [Select]
#

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

#

delete.php



#

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

#

if (!is_writable($dir)) cpg_die(CRITICAL_ERROR, sprintf($lang_errors['directory_ro'], htmlspecialchars($dir)), __FILE__, __LINE__);



#

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

#

    // start garibaldi
    $g_query = "SELECT user1 FROM {$CONFIG['TABLE_PICTURES']} WHERE pid='$pid'";
    $g_result = cpg_db_query($g_query);
    $g_user2 = mysql_fetch_array($g_result);
    foreach($g_user2 as $key => $value) {
if (strpos($value, "http") === false) {
} else {
// if its the url, grab it and cut off the part we don't want and put on the server path
$path = str_replace($CONFIG['ecards_more_pic_target'], "", $value);
}
    }
    if (is_file($path)) {
    unlink($path);
    }
    // end garibaldi

You can download the full installation for this new version in the first post of this topic
Logged

mushipkw

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 25
Re: Formats Upload Modification - Associate a File with each Image
« Reply #24 on: August 07, 2009, 08:47:24 pm »

I tested it on my local server & website but its not working.
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 #25 on: August 07, 2009, 09:43:09 pm »

Can you find an image that you want to delete and edit it in Coppermine. Check the value of the Custom User 1 Field and send it back to me. It should be of the form http://yourcpg.com/formats_upload/myzip4895.zip . If that is the case, this script then cuts off the URL making it formats_upload/myzip4895.zip and then removes it. Make sure your upload directory (formats_upload) is 777.
Logged

mushipkw

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 25
Re: Formats Upload Modification - Associate a File with each Image
« Reply #26 on: August 07, 2009, 10:18:20 pm »

Here's what my Custom User 1 field contains http://www.wmskins.com/formats_upload/myAlienS2U22195.rar My directory is 777, it is accepting uploads.
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 #27 on: August 07, 2009, 10:41:06 pm »

I'll put some debug code together for you and have it up soon for you to test
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 #28 on: August 11, 2009, 10:39:52 pm »

Sorry for the late reply. Replace the code I posted a couple posts up with this in delete.php:
Code: [Select]
    // start garibaldi
    $g_query = "SELECT user1 FROM {$CONFIG['TABLE_PICTURES']} WHERE pid='$pid'";
    $g_result = cpg_db_query($g_query);
    $g_user2 = mysql_fetch_array($g_result);
    foreach($g_user2 as $key => $value) {
if (strpos($value, "http") === false) {
} else {
// if its the url, grab it and cut off the part we don't want and put on the server path
$path = str_replace($CONFIG['ecards_more_pic_target'], "", $value);
}
    }
   
    echo "Query: " . $g_query . "<br>Result: " . $g_result . "<br>User 1 Value: " . $g_user2 . "<br>Path: " . $path . "<br>";
   
    if (is_file($path)) {
    echo "Deleting: " . unlink($path);
    }
    // end garibaldi

Then, after you delete a photo on the page where it shows the green or red images for successful or failed deletions, it will print out some information above the table in this format:
Quote
Query: SELECT user1 FROM xxx_pictures WHERE pid='xx'
Result: Resource id #xx
User 1 Value: Array
Path: formats_upload/xxxxxx-23492.zip
Deleting: 1
Please copy and paste it back here and I'll take a look at it.
Logged

mushipkw

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 25
Re: Formats Upload Modification - Associate a File with each Image
« Reply #29 on: August 12, 2009, 01:49:58 pm »

Here's what it looks like on my local server.

Quote
Query: SELECT user1 FROM s2u2c_pictures WHERE pid='13'
Result: Resource id #57
User 1 Value: Array
Path: http://localhost/formats_upload/BetterBlogRoll5563.zip
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 #30 on: August 13, 2009, 04:48:04 am »

Ah yes, I see the problem. It appears that the ecards_more_pic_target field in your database is not setup correctly. It should contain the URL of your coppermine site (with trailing slash). If you can correct this in your configuration, you should be able to use the code as is. Otherwise, find:
Code: [Select]
$CONFIG['ecards_more_pic_target']and replace it with (in this case):
Code: [Select]
http://localhost/
After doing this, give it a try again and see if it works
Logged

mushipkw

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 25
Re: Formats Upload Modification - Associate a File with each Image
« Reply #31 on: August 13, 2009, 10:48:32 am »

Thank you got it working
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 #32 on: August 13, 2009, 04:27:17 pm »

Great! Glad to hear that you got it!
Logged

SpectroPro

  • Coppermine newbie
  • Offline Offline
  • Gender: Male
  • Posts: 18
    • Bluestream Airlines - Virtual
Re: Formats Upload Modification - Associate a File with each Image
« Reply #33 on: September 07, 2009, 09:29:47 am »

Something I noticed...and this is working ALMOST perfectly on my site.  But, when you delete a file from the EDIT FILES part of the albums list...the picture will be deleted..but the files are not.  The only way for them to be deleted currently, is by doing the delete from the lone file (picture) screen. 

I hope this makes sense...  If not, I can maybe explain better and show pictures of what I mean.

Can this be fixed so that no matter where you delete the picture from, it deletes the associated file(s)?

- Greg
Logged

mushipkw

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 25
Re: Formats Upload Modification - Associate a File with each Image
« Reply #34 on: September 07, 2009, 02:07:51 pm »

Correct, I would like to add on that,
Also when we edit file properties & upload another file from there, the previous file doesn't gets deleted.
Logged

SpectroPro

  • Coppermine newbie
  • Offline Offline
  • Gender: Male
  • Posts: 18
    • Bluestream Airlines - Virtual
Re: Formats Upload Modification - Associate a File with each Image
« Reply #35 on: September 07, 2009, 06:34:41 pm »

Correct, I would like to add on that,
Also when we edit file properties & upload another file from there, the previous file doesn't gets deleted.

I just noticed this as well.  Can't update or change the file associated with the pic by just uploading a new file.  Maybe a new button, 'Update File'??  This would simply delete the old and put in the new.

Also, curious as to why when you upload, the window wording shows File Queue....???  I can select multiple files, but it will only ever allow one file to upload at a time.  Then you select another.  Thus, no queue.   Just curious about this...am I missing a way to upload 2 or more files at once for a pic?

I am actually wanting, for my use of this....to have more than one pic per file more than one file per pic.  But I am very happy to have this as it is currently, because it will allow me to open my site (graphic object site...for 3d objects for use in games, sims, movies, etc...)  I can imagine it will only get better and more feature enhanced in the future.. 

Thank you very much for this add-on (mod)!!!!!!

- Greg
Logged

mushipkw

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 25
Re: Formats Upload Modification - Associate a File with each Image
« Reply #36 on: September 07, 2009, 09:26:40 pm »

I am trying to tweak a function that adds a random number at the end of filename. I tried to change it that it only adds the random number when a file already exists with the same name.

This is what I have tried but it doesn't work. Also the popup windows remains open when clicked Done & loads the main page.
Code: [Select]
function finish() {
var upload_url = "http://localhost/formats_upload/";
var filename = str_replace(" ", "%20", document.getElementById("fileNAME").value);

if (file_exists(upload_url + filename)) {
window.opener.document.getElementById(window.name).value = upload_url + substr(filename, 0, strlen(filename)-4) + document.getElementById("rand").value + substr(filename, strlen(filename)-4);
} else {
window.opener.document.getElementById(window.name).value = upload_url + substr(filename, 0, strlen(filename)-4) + substr(filename, strlen(filename)-4);
}
close();
}

How can i get it to work?
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 #37 on: September 08, 2009, 04:46:28 am »

What does this random number addition do that is different from how the modification already adds a random number to the end of the file string?
Logged

mushipkw

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 25
Re: Formats Upload Modification - Associate a File with each Image
« Reply #38 on: September 08, 2009, 05:36:26 am »

NO, NO you are getting it wrong.
I want that a random number is only added when a file exists with the same name, else the file name remains the same as uploaded.
But I can't seem to figure it out with my code.
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 #39 on: September 15, 2009, 05:09:47 am »

Try finding this code in formats_helper.php:
Code: [Select]
// Make it unique
$file_name = substr($file_name, 0, strlen($file_name)-4) . $_GET['rand'] . substr($file_name, strlen($file_name)-4);

Replace it with this:
Code: [Select]
// test if it already exists
if (exists($file_name)) {
// Make it unique
$file_name = substr($file_name, 0, strlen($file_name)-4) . $_GET['rand'] . substr($file_name, strlen($file_name)-4);
}
See if that works.
Logged
Pages: 1 [2] 3   Go Up
 

Page created in 0.226 seconds with 19 queries.