CpmFetch 1.4 On... Displaying data and images from CPG on your website CpmFetch 1.4 On... Displaying data and images from CPG on your website
 

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]

Main Menu

CpmFetch 1.4 On... Displaying data and images from CPG on your website

Started by vuud, July 08, 2005, 06:43:10 AM

Previous topic - Next topic

0 Members and 5 Guests are viewing this topic.

vuud

Note: Stable release attached here / dev versions available at the homepage.

http://cpmfetch.fistfullofcode.com - latest info, news, development versions, tips, etc

This is a PHP object that allows you to easily display random or latest images from your coppermine gallery on external php and html pages.  It is being actively supported and developed by me.  Its simple, but I am also trying to make it as feature rich as I can without achieving bloat.  You can draw images (random or otherwise) from the entire gallery, a specific category or a single album.


:D Notifications of new releases

I added a sign up to my site for email notifications of new updates to cpmfetch.

http://www.fistfullofcode.com/projects/copperminefetch/index.php

A little ways down the page there is a signup entry.


??? What is this all about

Basically It takes criteria and returns tables containing thumbnails based on a row col combination you specify.  You tell it what kind of random images you want, in how many columns by how many rows (1 x 1 being a single image).  It gets the images and gives you back HTML code that displays them all.

??? What about private albums?  This library will not display any images that are not viewable by the world or are not in an approved state.  If you request the number of images in the gallery, it will count the private images in the number it returns. 

??? Reporting Problems?  Make sure you have the newest version!  Message me on this board or contact me via my website www.fistfullofcode.com.  Do me a favor and:


  • Include what version of coppermine you are using
  • a link to your website and gallery
  • a link to an example of the problem (if possible)
  • how computer savvy you are (newbie, intermediate, damn good)
  • what kind of web server you are running on (if known)
  • Include the syntax of the command you are using.

Also, try adding this to the top of your php page.  It will cause more errors and warnings to be displayed.

<?php 
error_reporting(E_ALL);
ini_set('display_errors',1);  // 0 is off, 1 is on
?>


??? What if its close to what you need, but not quite?.  Contact me and let me know what you think it needs.  I won't quarentee anything, but if it sounds reasonable I will probably do it.

??? Can I control the HTML it generates?  Currently you can control the tables and images it gives back via css settings and passing the css class to the object.  Future plans include adding titles and such.  Examples of CSS control are on the website (some are pretty cool)

Aside from images, it can also returns other data such as (note: the album names are links)

Since Friday, December 10 2004 we've added about 355 images

Category nameAlbumNew count
Haley - The early years (1999-2002)2000 Haley - the second year17 new 
  1999 Haley - the first year  69 new 
  2001 Haley - the third year   30 new
Haley, Christi and meOur furry friends 18 new
  May 2003 - Beckett Trip15 new
  Misc - Just don't fit anywhere11 new
     

More examples and downloads are here:
http://www.fistfullofcode.com/projects/copperminefetch/

Among the functions so far are stuff like this...  Many more have been added, so see the web site

Functions that return images

  • cpm_viewLastAddedMedia ($rows, $columns, [array $options = ""])
  • cpm_viewLastAddedMediaFromAlbum ( $rows,  $columns,  $albumid, [array $options = ""])
  • cpm_viewLastAddedMediaFromCategory ( $rows,  $columns,  $catid, [array $options = ""])
  • cpm_viewLastAddedMediaFrom ( $rows,  $columns,  $source, [array $options = ""])
  • cpm_viewRandomMedia ( $rows,  $columns, [array $options = ""])
  • cpm_viewRandomMediaFromAlbum ( $rows,  $columns,  $albumid, [array $options = ""])
  • cpm_viewRandomMediaFromCategory ( $rows,  $columns,  $catid, [array $options = ""])
  • cpm_viewRandomMediaFrom ( $rows,  $columns,  $source, [array $options = ""])

Functions that return textual statistics

  • cpm_formatStats ($format)
  • cpm_listMediaCount ()
  • cpm_getMediaCount ()
  • cpm_listMediaCountForAlbum ($albumid)
  • cpm_getMediaCountForAlbum ($albumid)

Functions that return gallery level images and text

  • cpm_listMediaAddedOverLastDays ($numberOfDays, [ array $options=""])
  • cpm_viewLastCommentedImages($rows,$columns, [ array $options=""])
  • cpm_showCategoriesUpdatedOverLastDays($numberOfDays,$options="")
  • cpm_showAlbumsUpdatedOverLastDays($numberOfDays,$options="")

Functions that control this program and its behavior

  • cpm ($urltocpm)
  • cpm_init ( Depreciated old constructor )
  • cpm_close ()
  • cpm_setFilter($filter)
  • cpm_setReturnType($type)
  • cpm_unlockPrivate($bool)
  • cpm_OverridePathToCoppermine($newpath_)
  • cpm_OverrideUrlToCoppermine($newpath_)
  • cpm_setDebugMode($bool)


Brief explanation of some of the above parameters

$albumid - is always the numerical id of the album
$catid - is always the numerical if of the category
$source - this is a new way of specifying albums and categories at the same time
$rows,$columns - the combination determine how many total to show and in what orientaion
$columns - how many columns of images to show
$options - this is an array of options (covered below)
$format - text to display interspersed with placeholders for variables



Some features are:


  • Limiting what kinds of media to return (not music, etc)
  • Multimedia images returned for video, sound, etc (unless overridden with custom media)
  • Last added media by album and category
  • Access override into private albums
  • Option to link images to album or fullsize image
  • Option to link to intermediate image
  • Text reporting on how many added, how many comments, etc, since...
  • Improved documentation - Ongoing
  • Docs on how to use this for random avatars
  • Alt and title tag formatting
  • Clean html output

(https://coppermine-gallery.com/forum/proxy.php?request=http%3A%2F%2Fwww.fistfullofcode.com%2Fprojects%2Fcopperminefetch%2Fcss_example_2.jpg&hash=c7bdf3a9b3101197032bd73f705ee6d368a4d494)

Example of usage:

The HTML version of the library only allows for one image to be retrieved at a time via an img tag.  To do this you simply point the image tag at the php page supplied and away you go.

img src="/cfimageget.php?category=7"

(https://coppermine-gallery.com/forum/proxy.php?request=http%3A%2F%2Fwww.fistfullofcode.com%2Fphp-lib%2Fcpmfetch%2Fcfimageget.php%3Fcategory%3D7&hash=d36af8760990186cacf839d00f5ec5b5bc73d6c6)
The above image was served up from my gallery via an img tag .


The following code shows how you would get 3 random images in a column from album #7

<?php 
include "../php-lib/cpmfetch/coppermine.php";
$objCpm = new cpm('/photos');
$objCpm->cpm_viewRandomMediaFromAlbum(1,3,7); 
$objCpm->cpm_close(); 
?>



A more intricate example passing some CSS info for the table is


<?php 
$options 
= array(
"tableStyle" => "photoclip",
"rowStyle" => "photoclip",
"cellStyle" => "photoclip",
"linkStyle" => "photoclip",
"altTag" => "One of the last photos submitted",
"imageStyle" => "photoclip",
                
"imagesize" => "int") ;

$objCpm->cpm_viewLastAddedMedia(4,2,$options); 
?>



??? Boy I am impressed!  I want to send you things... money, gifts, girls, etc... how can I do this?  Well, tell you what... the Coppermine people have put probably at least 2000x more work into Coppermine.  Why not send something to them instead. http://forum.coppermine-gallery.net/index.php?topic=14227.0 You could also always send a  donation to the www.eff.org instead. 

??? Whats coming up in the near future for this?  Well, basically I got it about as far as I think it will go...  for the basics anyway.  I am sure more features will be added on soon, and such - but can't say what they will be.  There is a lot there - and I am always open for suggestions.

Any advice, comments, request for something new in it, etc... pass them on, please

http://cpmfetch.fistfullofcode.com

See the readme.html enclosed for information, etc - or available online in the docs section of the website.  Toward the bottom a list will show you what has been added to new development versions since the stable.

The version attached below is the latest stable version.  However, there are always development versions available at the web site shown above... those should always work, and sometimes have neat new features added.   I only post the latest stable version here and remove old ones - sometimes I even forget to do that.  If you need an older version or want to make sure you have the latest, see the web site.
Please post for help to the forum... PM me only if you are sending security related items (passwords, security problems, etc).

cpmFetch - Images, RSS feeds from CPG from outside CPG
New release notification signup also. 
See http://cpmfetch.fistfullofco

Joachim Müller

Quote from: vuud on July 08, 2005, 06:43:10 AM
??? Boy I am impressed!  I want to send you things... money, gifts, girls, etc... how can I do this?  Well, tell you what... the Coppermine people have put probably at least 2000x more work into Coppermine.  Why not send something to them instead.  I tried finding a link on the site to send you too... couldn't - if you can't either, send a donation to the www.eff.org instead. 

This is the thread you have been looking for: We need your help  ;)




Great work! We (the coppermine dev team) want to thank you very much for the superb tool (and the support you're providing for it). CpmFetch is the one and only tool we recommend using to display coppermine content on non-coppermine pages.

freesouljah


vuud

Quote from: GauGau on July 08, 2005, 07:46:01 AM

This is the thread you have been looking for: We need your help  ;)




Great work! We (the coppermine dev team) want to thank you very much for the superb tool (and the support you're providing for it). CpmFetch is the one and only tool we recommend using to display coppermine content on non-coppermine pages.

Thanks, that means a lot to me!  That and the few emails I get from users just to say thanks makes it (mostly) worthwhile. :D   CPG 1.4 looks really nice - I will be upgrading at some point soon - but have already tested CpmFetch against the beta releases (so it will still work).

Take care all!





Please post for help to the forum... PM me only if you are sending security related items (passwords, security problems, etc).

cpmFetch - Images, RSS feeds from CPG from outside CPG
New release notification signup also. 
See http://cpmfetch.fistfullofco

fogpeople

This is a continuation from the locked thread, here's the quick backstory:

+ Trying to make CPMFetch work as a background random image puller AND post stats about said image on a page
+ Vuud posted some code to help the background image pull
+ Code no workee (I suspect user[me] error)

Here's the code suggested:

Here is how you can use 1.3.9 or better to accomplish this:  The comments are inserted for educational purposes

Code:
<?php

// This tells it you want the data back, not pretty html tables
$objCpm->cpm_setReturnType('resultset');

// This gets an assocative array of the 1 random image from anywhere public in the album
$data $objCpm->cpm_viewRandomMediaFrom (11"");

// This gets the image to display...
$imagename $objCpm->cpm->getImageToUse($data[0]['pFilepath'], $data[0]['pFilename'] ,"");

print 
"<img src='$imagename'>";

?>


You have to take the next step and figure out how to get $imagename into your background tag Smiley


I took this code and made it into a file (random.php), then used an include on the page to do the pull.  That looks like this:

<body background="<?php include 'random.php'?>" bgcolor="#000000" >

And voila'!  The error I get:

Fatal error: Call to a member function on a non-object in /home/fogpeopl/public_html/test/random.php on line 4

Is it me?  :-\\

-michael

vuud

Quote from: fogpeople on July 08, 2005, 07:27:55 PM

And voila'!  The error I get:

Fatal error: Call to a member function on a non-object in /home/fogpeopl/public_html/test/random.php on line 4

Is it me?  :-\\

-michael

Well, lets call it at "its a little of both of us".  You still need to start the object and close it after which I did not include because I do it on top and bottom of all my page.  but I should have included them for people not used to objects.

Anyway, before it add in

$objCpm = new cpmfetch( ** your partial url goes here **);

and after it add in

$objCpm->close();

Sorry about ommitting that stuff, its standard for anything you do with cpmfetch so it just slipped my mind.  Mia Culpa

Let us know how it works out

Please post for help to the forum... PM me only if you are sending security related items (passwords, security problems, etc).

cpmFetch - Images, RSS feeds from CPG from outside CPG
New release notification signup also. 
See http://cpmfetch.fistfullofco

fogpeople

Whoops, yeah that was my bad.  Got the open and close in now. 

When I use this code:
include "../cpmfetch/coppermine.php";

//        $objCpm = new cpmfetch("/bg");
$objCpm = new cpm("/bg");

// This tells it you want the data back, not pretty html tables
$objCpm->cpm_setReturnType('resultset');

// This gets an assocative array of the 1 random image from anywhere public in the album
$data = $objCpm->cpm_viewRandomMediaFrom (1, 1, "");

// This gets the image to display...
$imagename = $objCpm->cpm->getImageToUse($data[0]['pFilepath'], $data[0]['pFilename'] ,"");

print "'$imagename'";

$objCpm->cpm_close();


I get a page but no image, this is my source tag:
<body background="'/bg/images/'" bgcolor="#000000" >


When I use THIS code:
include "../cpmfetch/coppermine.php";

$objCpm = new cpmfetch("/bg");
// $objCpm = new cpm("/bg");

// This tells it you want the data back, not pretty html tables
$objCpm->cpm_setReturnType('resultset');

// This gets an assocative array of the 1 random image from anywhere public in the album
$data = $objCpm->cpm_viewRandomMediaFrom (1, 1, "");

// This gets the image to display...
$imagename = $objCpm->cpm->getImageToUse($data[0]['pFilepath'], $data[0]['pFilename'] ,"");

print "'$imagename'";

$objCpm->cpm_close();


I get this error message:

Fatal error: Cannot instantiate non-existent class: cpmfetch in /home/fogpeopl/public_html/test/random.php on line 4

It's close... so very close.  I uploaded 1.4 today, so that should be working right.  Any ideas?

MUCH thanks btw, this is helping a lot
-michael

marian

You set me on the right track and, after making the change u suggested and another I got all passes on cftest, but this was followed by the error message:
Trying to display some images:
ERROR: Path to Coppermine incorrect. (/home/bymnews/public_html//include/config.inc.php)

Your installation seems correct so far, you should see a small grid of thumbnails from your gallery

Fatal error: Call to a member function on a non-object in /home/bymnews/public_html/copperminefetch/cpmfetch/cpmfetch.php on line 737

I looked at cpmfetch.php but the answer to the problem doesn't seem to be there, though I figured it's something to do with the domain name????
Ur advice will be appreciated.

vuud

Hah, what a pair we make...

Yes it should be $objCpm = new cpm("/bg");  not new cpmFetch(...

If you uploaded 1.4, you need remove the coppermine.php and coppermine_dao.php from your web server
And change your include below to go for cpmfetch.php instead of coppermine.php

try that and then post back... I am going away tomorrow and would like to wrap this problem up before then.

You also need to do some PHP to get it into your background tag...  something like this, after you do the other stuff.  And you can remove the other print you had in your code.

<body background="<?php print $imagename; ?>" bgcolor="#000000" >

Quote from: fogpeople on July 08, 2005, 09:27:55 PM
Whoops, yeah that was my bad.  Got the open and close in now. 

When I use this code:
include "../cpmfetch/coppermine.php";

//        $objCpm = new cpmfetch("/bg");
$objCpm = new cpm("/bg");

// This tells it you want the data back, not pretty html tables
$objCpm->cpm_setReturnType('resultset');

// This gets an assocative array of the 1 random image from anywhere public in the album
$data = $objCpm->cpm_viewRandomMediaFrom (1, 1, "");

// This gets the image to display...
$imagename = $objCpm->cpm->getImageToUse($data[0]['pFilepath'], $data[0]['pFilename'] ,"");

print "'$imagename'";

$objCpm->cpm_close();


I get a page but no image, this is my source tag:
<body background="'/bg/images/'" bgcolor="#000000" >

It's close... so very close.  I uploaded 1.4 today, so that should be working right.  Any ideas?

MUCH thanks btw, this is helping a lot
-michael
Please post for help to the forum... PM me only if you are sending security related items (passwords, security problems, etc).

cpmFetch - Images, RSS feeds from CPG from outside CPG
New release notification signup also. 
See http://cpmfetch.fistfullofco

vuud

Quote from: marian on July 08, 2005, 09:36:52 PM
You set me on the right track and, after making the change u suggested and another I got all passes on cftest, but this was followed by the error message:
Trying to display some images:
ERROR: Path to Coppermine incorrect. (/home/bymnews/public_html//include/config.inc.php)

Your installation seems correct so far, you should see a small grid of thumbnails from your gallery

Fatal error: Call to a member function on a non-object in /home/bymnews/public_html/copperminefetch/cpmfetch/cpmfetch.php on line 737

I looked at cpmfetch.php but the answer to the problem doesn't seem to be there, though I figured it's something to do with the domain name????
Ur advice will be appreciated.

Can you point me to the cftest.php page?  PM me if you do not want it posted publically...

Please post for help to the forum... PM me only if you are sending security related items (passwords, security problems, etc).

cpmFetch - Images, RSS feeds from CPG from outside CPG
New release notification signup also. 
See http://cpmfetch.fistfullofco

smoke10010

I've been wracking my brain around cpmfetch for hours and i've got the basics down I think. unfortunately I'm not so adept at css which I should be learning. All i'd like to do is put everything into nice organized tables which I believe I can achieve through stylesheets

here's the layout I'm looking for if someone could at least tell me if it's possible then I'll keep at it.

|--------------------------------------------------
| Thumbnail | description  | rating    |
|---------------------------------------------------
|                         hits |uploaded by|
---------------------------------------------------

fogpeople

Quote from: vuud on July 08, 2005, 09:50:23 PM
Hah, what a pair we make...

You flatter me by comparison.  ;)

Made all the changes, and I am WORKING!  Thanks much for the help with that.

I think that was the hard part.  What I'd like to do now is display the image owner's name somewhere else on the page.  I assume it's just another print statement, but is the owner name attached to a variable in CPMFetch? 

vuud

Quote from: fogpeople on July 08, 2005, 10:55:08 PM
Quote from: vuud on July 08, 2005, 09:50:23 PM
Hah, what a pair we make...

You flatter me by comparison.  ;)

Made all the changes, and I am WORKING!  Thanks much for the help with that.

I think that was the hard part.  What I'd like to do now is display the image owner's name somewhere else on the page.  I assume it's just another print statement, but is the owner name attached to a variable in CPMFetch? 


Sure is my enthusiastic friend!

I'd recommend inserting a:

    print "<PRE>";
    print_r($data[0]);
   print "</PRE>";

Somewhere after you get the random image... that will display a list of what is included in there... there is an awful lot of cool data that you can take advantage of.  This is temopary so you can see whats in there... you need the PRE tag so it stays formatted in HTML.

Best of luck!







Please post for help to the forum... PM me only if you are sending security related items (passwords, security problems, etc).

cpmFetch - Images, RSS feeds from CPG from outside CPG
New release notification signup also. 
See http://cpmfetch.fistfullofco

vuud

Quote from: smoke10010 on July 08, 2005, 10:34:21 PM
I've been wracking my brain around cpmfetch for hours and i've got the basics down I think. unfortunately I'm not so adept at css which I should be learning. All i'd like to do is put everything into nice organized tables which I believe I can achieve through stylesheets

here's the layout I'm looking for if someone could at least tell me if it's possible then I'll keep at it.

|--------------------------------------------------
| Thumbnail | description  | rating    |
|---------------------------------------------------
|                         hits |uploaded by|
---------------------------------------------------

The thumbnail will be large and square, while description and rating will be much shorter... Maybe I am not envisioning it.

I have no idea if its possible via CSS with the tables CpmFetch returns, but you can always do something like what fogpeople there is doing and get the data back and build a table with it.

The thing with the default tables cpmfetch returns is that it only iterates a subtitle once, so its all on one like.

When you get it working, post an example and code if you are willing... someone else can benefit from it also then :)





Please post for help to the forum... PM me only if you are sending security related items (passwords, security problems, etc).

cpmFetch - Images, RSS feeds from CPG from outside CPG
New release notification signup also. 
See http://cpmfetch.fistfullofco

smoke10010

Quote from: vuud on July 08, 2005, 11:46:17 PM

The thumbnail will be large and square, while description and rating will be much shorter... Maybe I am not envisioning it.

I have no idea if its possible via CSS with the tables CpmFetch returns, but you can always do something like what fogpeople there is doing and get the data back and build a table with it.

The thing with the default tables cpmfetch returns is that it only iterates a subtitle once, so its all on one like.

When you get it working, post an example and code if you are willing... someone else can benefit from it also then :)








yeah if i can get it up then i'll post it for sure.. i think i might have figured something out.. but i guess 1 thing is how do i  get the subtitles to post to the right of the thumb instead of under

smoke10010

also when i use the subtitle function with

cpm_viewRandomTopRatedMediaFrom i get an error and the page doesn't load

Parse error: parse error, unexpected T_DOUBLE_ARROW in /home/tpimp/public_html/updates.php on line 355

fogpeople

Quote from: vuud on July 08, 2005, 11:42:47 PM
I'd recommend inserting a:

    print "<PRE>";
    print_r($data[0]);
   print "</PRE>";

Somewhere after you get the random image... that will display a list of what is included in there... there is an awful lot of cool

Frickin' awesome.  So I tried changing the data line to this:
print $imagename[pOwner_Name];
And I get a "/" displayed... do I need to change the original code in the include?
(this is very abridged, I did try to declare a variable and add the Owner_Name entry to the original function first  :)

vuud

Quote from: fogpeople on July 09, 2005, 12:48:47 AM
Quote from: vuud on July 08, 2005, 11:42:47 PM
I'd recommend inserting a:

    print "<PRE>";
    print_r($data[0]);
   print "</PRE>";

Somewhere after you get the random image... that will display a list of what is included in there... there is an awful lot of cool

Frickin' awesome.  So I tried changing the data line to this:
print $imagename[pOwner_Name];
And I get a "/" displayed... do I need to change the original code in the include?
(this is very abridged, I did try to declare a variable and add the Owner_Name entry to the original function first  :)

Here is the short short version of what all this means.  This is really PHP stuff, but I feel happy today - so what the heck.

After you get the random images (or what have you) the $data variable holds a list, even if you only want one picture, its still a list - just a list with 1 item in it.

Okay, computers start counting at 0 - not at one like us people.  So when you say $data[0] - that says on the list ($data) give me row 0 - which to the computer is the first.

With me so far?

Now, each item on the list is data about an image.  so $data[0] the first row on the list, is really made up of another list of things.  This list is called an associative array - that is a fancy way of saying that instead of having each item in this list be found by a number (like $data) we are going to give each entry a name or KEY.  So each KEY then points at an item on the list.

Confused yet?

So, if you want to get the owner name (pOwner_name) (which you my young padawan have successfully found - except Name is not capitalized) from the first image in the list of images ($data) you need to say something like:

Show me from the first image on my list, the entry for 'pOwner_name'

which translates to

$ownername = $data[0]['pOwner_name'];

This is similar to how we got the image name before and assigned it to imagename.

Just remember they are lists with lists.

Hope this helps, cause otherwise I have to refer you to a php book or something...

Php.net has some good page in the manual there if you are interested.

From here you should understand how to get any of the information out of there that you want!












Please post for help to the forum... PM me only if you are sending security related items (passwords, security problems, etc).

cpmFetch - Images, RSS feeds from CPG from outside CPG
New release notification signup also. 
See http://cpmfetch.fistfullofco

fogpeople

Quote from: vuud on July 09, 2005, 01:01:55 AM
$ownername = $data[0]['pOwner_name'];
From here you should understand how to get any of the information out of there that you want!

Lightbulb time for me.

Would you believe me if I told you I had that config at one point (minus the lowercase "n" of course) as I tried to work it out?  Honest! 

Well your help has truly been a gift today.  I'm mostly a "tweaker" of code, so those little syntax things get every dang time.  But I genuflect upon your gratitude today!!

-m

vuud


No problem... PM me the site when you get that working... I'd love to see it in action.

love the concept of changing the background :D



Quote from: fogpeople on July 09, 2005, 01:14:50 AM
Quote from: vuud on July 09, 2005, 01:01:55 AM
$ownername = $data[0]['pOwner_name'];
From here you should understand how to get any of the information out of there that you want!

Lightbulb time for me.

Would you believe me if I told you I had that config at one point (minus the lowercase "n" of course) as I tried to work it out?  Honest! 

Well your help has truly been a gift today.  I'm mostly a "tweaker" of code, so those little syntax things get every dang time.  But I genuflect upon your gratitude today!!

-m

Please post for help to the forum... PM me only if you are sending security related items (passwords, security problems, etc).

cpmFetch - Images, RSS feeds from CPG from outside CPG
New release notification signup also. 
See http://cpmfetch.fistfullofco