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]   Go Down

Author Topic: Php script question (accessing coppermine photos)  (Read 4178 times)

0 Members and 1 Guest are viewing this topic.

eris667

  • Coppermine novice
  • *
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 47
    • http://www.strm.us/cpg15x/index.php
Php script question (accessing coppermine photos)
« on: August 06, 2009, 08:34:04 pm »

This is not Directly a coppermine question . . .
I have the following PHP script I would like to use to access a coppermine gallery

<?
//http://www.reconn.us/random_file.html
$imglist='';
//$img_folder is the variable that holds the path to the banner images. Mine is images/tutorials/
// see that you don't forget about the "/" at the end
$img_folder = "RandomImages/";

mt_srand((double)microtime()*1000);

//use the directory class
$imgs = dir($img_folder);

//read all files from the directory, checks if are images and ads them to a list (see below how to display flash banners)
while ($file = $imgs->read()) {
if (eregi("gif", $file) || eregi("jpg", $file) || eregi("png", $file))
$imglist .= "$file ";

} closedir($imgs->handle);

//put all images into an array
$imglist = explode(" ", $imglist);
$no = sizeof($imglist)-2;

//generate a random number between 0 and the number of images
$random = mt_rand(0, $no);
$image = $imglist[$random];

//display image
echo '<img src="'.$img_folder.$image.'" border=0>';
?>

My question is how to modify the script to use only the uploaded image (not thumb_ ect.)
I am assuming their is some kind of logic I can use to eliminate the files based on the prefix - any suggestions?
I know I will have to change the path in $img_folder to a gallery. . .

I appreciate any feedback,

Mike

Nibbler

  • Guest
Re: Php script question (accessing coppermine photos)
« Reply #1 on: August 06, 2009, 09:12:47 pm »

You'd probably be better off using cpmFetch. That's what it's for.
Logged

eris667

  • Coppermine novice
  • *
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 47
    • http://www.strm.us/cpg15x/index.php
Re: Php script question (accessing coppermine photos)
« Reply #2 on: August 07, 2009, 05:04:42 am »

I will look into it, cpmFetch looks like a lot bigger program than I need :D
thanks for the advise !

Mike

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: Php script question (accessing coppermine photos)
« Reply #3 on: August 07, 2009, 07:21:35 am »

My question is how to modify the script to use only the uploaded image (not thumb_ ect.)
You asked for the naming scheme of Coppermine, i.e. how to determine which files were created by coppermine, so here's the answer: the intermediate image and the thumbnail are being prefixed. The prefix can be configured, so this will not apply to all installs, but the default names will apply for most coppermine installs: normal_ is the prefix for intermediates and thumb_ is the prefix for thumbnails.
You would have to perform a string comparison. Sort out all files that are prefixed in a manner that you don't want.
Nibbler tried to be nice and not bash you, but quite frankly: your code leaves a lot of room for improvement ;). You should really look into the existing mods for content syndication, they are very easy to apply.
Logged

eris667

  • Coppermine novice
  • *
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 47
    • http://www.strm.us/cpg15x/index.php
Awesome Plugin
« Reply #4 on: October 01, 2009, 04:09:50 am »

I was originally looking to do this a different way. . .
http://forum.coppermine-gallery.net/index.php?topic=61062.new;topicseen#new

but luckily the great people here pointed me in the right direction !

My End Result. . .
http://www.strm.us/cpg14x/index.php
or
http://www.strm.us/

Excellent Plugin work, great documentation.

Thank you,

Mike Praeuner
Bartlett, TN

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: Awesome Plugin
« Reply #5 on: October 01, 2009, 07:44:22 am »

and which plugin id you use then? Maybe you could post reference to it for the benefit of others and to credit the author. Merging with your original thread.

Joachim

P.S. cpmFetch is not a plugin, as it doesn't use coppermine's plugin API.
Logged

eris667

  • Coppermine novice
  • *
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 47
    • http://www.strm.us/cpg15x/index.php
Re: Php script question (accessing coppermine photos)
« Reply #6 on: October 01, 2009, 08:00:47 am »

Sorry if I was not clear - I used CPMfetch (http://cpmfetch.fistfullofcode.com/)
I had posted here (http://forum.coppermine-gallery.net/index.php/board,87.0.html) in case the author monitored it, to say thank you.

The idea of CPMfetch being a plugin originally made me reluctant to try it out, but like you stated it is not a plugin, and it works great.

The documentation (http://cpmfetch.fistfullofcode.com/docs/index.php) is well worth the read, and very informative (including multiple examples)

Thank You for correcting me, and putting this post in a more useful place.

Mike
Pages: [1]   Go Up
 

Page created in 0.023 seconds with 19 queries.