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

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 4 Guests are viewing this topic.

Joachim Müller

Quote from: Hooligan on July 13, 2005, 07:02:43 PM
Got Cpmfetch working in a test htm page, by adding a couple of line to my .htaccess:

RemoveHandler .html .htm
AddType application/x-httpd-php .php .htm .html
Your webhost won't be happy if you do this, I used a similar approach before on my personal page. My webhost notified me of some drawbacks and changed the policy for .htaccess files. Not a recommended method, has impact on server performance and security.

mikedown

sorry to double post but...

can i mod the random images so when i click the random image it opens a new browser for the image?
target="_blank" kinda thing

vuud

Quote from: mikedown on July 14, 2005, 03:11:14 PM
sorry to double post but...

can i mod the random images so when i click the random image it opens a new browser for the image?
target="_blank" kinda thing

Its inthe documentation

http://www.fistfullofcode.com/projects/copperminefetch/docs/readme.html#optionsarray
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

Hey all,

I took this offline with vuud but we weren't able to get this working, so I'm opening up my dilemma in hopes someone will point out what it is I'm mucking up here.

So, thanks to vuud, I managed to make an include file that pulls a random image and give me the file path and image name as a variable I include as the background of a page.  It ALSO pulls the image owner's username and stores that as a variable I use to print out on the page, so you can see a credit of whom has uploaded the random image. So far so good.

What I'd like to do now is simple use the owner's username ($ownername) in a query to the cpg133_users table to also pull their home page data.  This way I can ultimately include a link to their homepage along with their author credit. 

To that end, since I've got the username, I made an additional query in my include script:

$linky = mysql_connect("localhost", "xxxxxxxx", "xxxxxxxx");
mysql_select_db("xxxxxxxx", $linky);
$getweb = mysql_query("SELECT * FROM cp133_users WHERE user_name=$ownername", $linky);
$row = mysql_fetch_array($getweb, MYSQL_ASSOC);
$website = $row['user_website'];


Then, on whatever page includes the script, I just add this:
print $ownername;
print $website;


Ownername prints fine, but the $webstie does not, and fails me with this:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/fogpeopl/public_html/random.php on line 22

Line 22 is the $row line.  So, I'm connecting alright, I'm not sure if the query is working, but it's definitely munging something up between the query and massaging the results.  I realize this is almost entirely a PHP syntax issue, but since many of you have probably successfully queried the users table I thought I'd see if anyone else has had any unusual problems doing so.  I could use the help as I've tried every possible option I can think of and am relatively sure my code is correct.

Thanks!!!!
-michael

Nibbler

You need single quotes around the $ownername in the query. Without them, MySQL looks for a field with the name of the user, the quotes indicate you are trying to match a literal value.

Hooligan

Quote from: GauGau on July 14, 2005, 09:49:56 AM
Quote from: Hooligan on July 13, 2005, 07:02:43 PM
Got Cpmfetch working in a test htm page, by adding a couple of line to my .htaccess:

RemoveHandler .html .htm
AddType application/x-httpd-php .php .htm .html
Your webhost won't be happy if you do this, I used a similar approach before on my personal page. My webhost notified me of some drawbacks and changed the policy for .htaccess files. Not a recommended method, has impact on server performance and security.

<thud>

Can you provide any more detail?
You know, Hobbes, some days even my lucky rocketship underpants don't help.

fogpeople

Quote from: Nibbler on July 15, 2005, 02:56:01 AM
You need single quotes around the $ownername in the query. Without them, MySQL looks for a field with the name of the user, the quotes indicate you are trying to match a literal value.

Well, I did try this:


$linky = mysql_connect("localhost", "xxxxxxxx", "xxxxxxxx");
mysql_select_db("xxxxxxxx", $linky);
$getweb = mysql_query("SELECT * FROM 'cp133_users' WHERE user_name='$ownername'", $linky);
$row = mysql_fetch_array($getweb, MYSQL_ASSOC);
$website = $row['user_website'];


And another syntactical variation suggested by vuud which also include single quotes (I believe it was ' . $ownername . ' or some such.
All of which yield me this big fat goose egg:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/fogpeopl/public_html/random.php on line 22

Frankly I'm stumped.  I'm no PHP whiz kid by a long shot, but I wonder if the query is failing because it thinks the comparitive text isn't text for some reason?  This is definitely a case where I wouldn't mind getting totally schooled by an ace  :)


Nibbler

Let's add some debug code

$linky = mysql_connect("localhost", "xxxxxxxx", "xxxxxxxx");
var_dump($linky);
$db = mysql_select_db("xxxxxxxx", $linky);
var_dump($db);
var_dump("SELECT * FROM cp133_users WHERE user_name='$ownername'");
$getweb = mysql_query("SELECT * FROM cp133_users WHERE user_name='$ownername'", $linky);
var_dump($getweb);
var_dump(mysql_error());
var_dump(mysql_num_rows($getweb));
$row = mysql_fetch_array($getweb, MYSQL_ASSOC);
$website = $row['user_website'];


That should catch just about anything.

Also don't put single quotes around the table name, that's sure to screw up the query. Use backticks or nothing.

fogpeople

Quote from: Nibbler on July 15, 2005, 02:20:00 PM
Let's add some debug code

aHA!

I stand humbled before you.

Problem?  the table name is "cpg133_users" NOT "cp133_users".  I only looked at it about 5,000 times too.

I smother you and vuud with gratitude and add all of this to the meager knowledgebase that is my brain.

I'll be able to launch in no time now...thanks!
-michael

michiel

I earlier posted the following question:
QuoteI would like to include on my frontpage only the latest added pic (full size) , but no albums and other thumbnails..Albums would be approached through a link on the frontpage. How should I do this?

Gaugau answered:
Quotealblist and catlist has to remain in "the content of the main page" no matter what. Create a splash page using cpmFetch with only your last added pics, and send your users to this splash page before they're sent anywhere else (i.e. to the actual coppermine page).

I have installed cpmfetch, and technically, it works (http://www.dwaalgasten.nl/Foto/cpg1.3.3/cpg133/test.php). But the pic is still small, and I would like it to be fullsize. Compare: http://www.apparentlynothing.com/. Is there a way to achieve this? Thanks!

vuud

Quote from: michiel on July 17, 2005, 07:00:25 PM
I earlier posted the following question:
QuoteI would like to include on my frontpage only the latest added pic (full size) , but no albums and other thumbnails..Albums would be approached through a link on the frontpage. How should I do this?

Gaugau answered:
Quotealblist and catlist has to remain in "the content of the main page" no matter what. Create a splash page using cpmFetch with only your last added pics, and send your users to this splash page before they're sent anywhere else (i.e. to the actual coppermine page).

I have installed cpmfetch, and technically, it works (http://www.dwaalgasten.nl/Foto/cpg1.3.3/cpg133/test.php). But the pic is still small, and I would like it to be fullsize. Compare: http://www.apparentlynothing.com/. Is there a way to achieve this? Thanks!


The default for cpmfetch is to display thumbnails, but have hope... you can tell it to do different...

These two pages in the almost done new docs explain it...

http://www.fistfullofcode.com/projects/copperminefetch/manual/ch06.html
http://www.fistfullofcode.com/projects/copperminefetch/manual/ch06s02.html
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

michiel

thanks vuud; that manual will prove to be very useful. Thanks to the manual I have been able to vary the size of the pic, great. I am almost where I want to be. I would like to a) align the pic in the middle, rather than on the left, and b) add the background colour I use elsewehere on my website. From your manual, I understand this should be possible. However,  I am familiar with CSS, but know nothing about PHP. Can you give me a hint how I can change or include such variables (or CSS codes) in the PHP code? Thanks!

vuud

Quote from: michiel on July 18, 2005, 07:41:07 PM
thanks vuud; that manual will prove to be very useful. Thanks to the manual I have been able to vary the size of the pic, great. I am almost where I want to be. I would like to a) align the pic in the middle, rather than on the left, and b) add the background colour I use elsewehere on my website. From your manual, I understand this should be possible. However,  I am familiar with CSS, but know nothing about PHP. Can you give me a hint how I can change or include such variables (or CSS codes) in the PHP code? Thanks!

The easiest way is to define the CSS in your page, and then pass on the tags to cpmfetch for its table.

The section of the manual I forwarded has those listed...
http://www.fistfullofcode.com/projects/copperminefetch/manual/ch06s02.html

The ones with style in the name.....   like "cellstyle" => "photobox" will insert class="photobox" into all of the TD tags.  There are other ones there too


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


I forgot about it, but its already in there.

Assuming you have the objCpm already created, you just need to provide a timestamp.

$objCpm->cpm_getMediaCountAddedSince($timestamp);

voila
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


CpmFetch Announcements from FistFullOfCode.com
[The exact Center of the Internet]
----------------------------------------------------------------

* * * Development release 1.5.1 is ONLINE now * * *
[ code named:  Freaky Turkey ]

( get it at http://cpmfetch.fistfullofcode.com )

I have posted a new development release online.  Updating to this is purely up to you... 
If there is something you like here, go ahead.  If not stick with what you have.  If you think
you have a bug now, upgrade to this before reporting it (or else)



WHATS NEW

* DocBook documentation almost done
* Select photos by owner name (via owner= in source statement)
* Added %e  to display owners E-Mail
* Added %H  to display owners web site (Home page)
* Added %I  to display owners Interests
* Added %l  to display owners last visit (lower case L)
* Added %L  to display owners location
* Added %O  to display owners occupation
* Added %r to display owners registration date
* Internal refactoring of cpmfetch_dao

DOCBOOK DOCUMENTATION ALMOST DONE
This will replace the existing readme based documentation.  That will no longer be updated, as of
whenever I last updated it.  While the Docbook version is not 100% done, it does contain all
the old versions info and more.  Some is not formatted yet, but technically its in there.

See it here... updated daily
http://www.fistfullofcode.com/projects/copperminefetch/manual/index.html


SELECT PHOTOS BY OWNER NAME (VIA owner= IN SOURCE STATEMENT)
More information on doing this is available in the new, mostly finsihed docs.
http://www.fistfullofcode.com/projects/copperminefetch/manual/ch05s02.html

The new thing is that you can use owner= in addition to album= and cat=


SUBTITLE AND ALT TAG PLACEHOLDERS GALORE
User fogpeople mentioned to me that there is all this other data in here that I am ignoring, so I
went ahead and added in calls to get all that too.  Here are the new chunks of information you
can add into your subtitles and alt tags.

* Added %e  to display owners E-Mail
* Added %H  to display owners web site (Home page)
* Added %I  to display owners Interests
* Added %l  to display owners last visit (lower case L)
* Added %L  to display owners location
* Added %O  to display owners occupation
* Added %r to display owners registration date

INTERNAL REFACTORING OF CPMFETCH_DAO
Basically I removed a lot of redundant code... reducing the size of the file
by 5.1KB and 145 lines of SQL code.  What does this mean to you?  Well,
any function that ends with FromAlbum or FromCategory or does not have
any from (such as getRandomMedia) all call the same function in the backend -
the ones I added that use the $source statement (they all end in FROM).
It's been nagging me for awhile, so why not just go ahead and do it.


A WORD ABOUT DEV RELEASES
====================================
Typically development releases are done in software when new features are added... New features sometimes
introduce bugs (software errors) that the testing we do here misses.  If this happens, it is usually something
strange.  The dev releases here are generally very stable.  Changes sometimes even make the program
more stable, which adding new features.

Overall, In most circumstances, if your random thumbnail is not working for a few minutes when you upgrade
you are going to be okay.  If a dev release has something you like, give it a try.  I always have all the older versions up
for download so you can go back if it breaks.

If you do have a problem, PLEASE let me know.  That way I can fix it.  If I don't know about it, it could be
a long time before it gets fixed.

--------------------------------------------------------------
Sign up for email notifications at http://cpmfetch.fistfullofcode.com
This will get you:
* Emails for new releases and development releases
* Notifications of new tutorials and online help
* Security notification (if we ever have one)
* Email addresses held closely - no spam, not shared
-------------------------------------------------------------------------------------------------------
Thanks!

Bill@fistfullofcode.com
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

Hamsterpants

Please can someone let me know why:
The following works:
      <?php
         include "./cpmfetch/cpmfetch.php";
         $objCpm = new cpm("/photoalbum");
         $objCpm->cpm_viewRandomMedia(5,1);
         $objCpm->cpm_close();
      ?>

and the following doesn't:

      <?php
         include "./cpmfetch/cpmfetch.php";
         $objCpm = new cpm("/photoalbum");
         $objCpm->cpm_viewMostVotedMedia(5,1);
         $objCpm->cpm_close();
      ?>

Not sure I understand how this works, but all I need this function for is to display the most voted pics.
Thanks in advance
Dill
Dillon Weyer
dill@mystaffie.com

vuud

Quote from: Hamsterpants on July 20, 2005, 01:27:05 PM
Please can someone let me know why:
The following works:
      <?php
         include "./cpmfetch/cpmfetch.php";
         $objCpm = new cpm("/photoalbum");
         $objCpm->cpm_viewRandomMedia(5,1);
         $objCpm->cpm_close();
      ?>

and the following doesn't:

      <?php
         include "./cpmfetch/cpmfetch.php";
         $objCpm = new cpm("/photoalbum");
         $objCpm->cpm_viewMostVotedMedia(5,1);
         $objCpm->cpm_close();
      ?>

Not sure I understand how this works, but all I need this function for is to display the most voted pics.
Thanks in advance
Dill

Pants of hamster,

Try this call instead:
$objCpm->cpm_viewRandomMostViewedMediaFrom("",5,1);

The call you are trying does not exist.

See: http://www.fistfullofcode.com/projects/copperminefetch/manual/ch05s02.html
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

sinbinner

Would anyone be willling to give me a little help please?  I have smf 1.0.5, coppermine 1.3.3 and copperminefetch 1.4.1. Everything is installed and working properly. I used the <img src="/cfimageget.php?album=3"/> to pull a random image from a specified album to my forum index. What I want to do is pull 5 images at once from that specified album. The pictures are for a customized car website and would like to display the customized car of the week in a block on the forum index. Or display one image at a time with the option to click a next or previous button for more images from the album. My php skills suck so I'm fumbling in the dark on this.  My directory structure is setup as following.
root/cgp133/albums
root/forums/cpmfetch

vuud

Quote from: sinbinner on July 21, 2005, 04:53:01 AM
Would anyone be willling to give me a little help please?  I have smf 1.0.5, coppermine 1.3.3 and copperminefetch 1.4.1. Everything is installed and working properly. I used the <img src="/cfimageget.php?album=3"/> to pull a random image from a specified album to my forum index. What I want to do is pull 5 images at once from that specified album. The pictures are for a customized car website and would like to display the customized car of the week in a block on the forum index. Or display one image at a time with the option to click a next or previous button for more images from the album. My php skills suck so I'm fumbling in the dark on this.  My directory structure is setup as following.
root/cgp133/albums
root/forums/cpmfetch


The best you can do using cfimageget is the 5 photos at a time.  Yes, it can be done.  See this in the docs for how to do it.

http://www.fistfullofcode.com/projects/copperminefetch/manual/ch09s03.html

You can end up with double images though - since each call is completely different from the others.

Otherwise your next best hope is to work the normal PHP into the forum template.  I did that with my SMF forums.  Once you do that you can get five images. 

There are a few examples in the docs for the php you would need to do... not sure of your forum layout though.  If you want me to just do it for you, see the list of organizations you can donate to in the docs... prove you made a donation and I will go ahead and do it all. 

Otherwise try the php route (getting that into the template - its all cut and paste almost, so php is not really required, just reading of the docs and trying it) and let me know where you get stuck

Vuud




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

Hamsterpants

Thanks very much VUUD  :) perfect except on the forum. I have used that function in the my customer site header and the function works on the hime page /index.php and on the photoalbum /photoalbum, but when I go to the forum /forum, I get the following error, which I am sure it has to do with the way I am referencing the code, but my php is not that good. I have included the error below and also the code I use for including the images:

Error:
====
Warning: main(./cpmfetch/cpmfetch.php): failed to open stream: No such file or directory in /home/mystaffi/public_html/_header.php on line 28

Warning: main(./cpmfetch/cpmfetch.php): failed to open stream: No such file or directory in /home/mystaffi/public_html/_header.php on line 28

Warning: main(./cpmfetch/cpmfetch.php): failed to open stream: No such file or directory in /home/mystaffi/public_html/_header.php on line 28

Warning: main(): Failed opening './cpmfetch/cpmfetch.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/mystaffi/public_html/_header.php on line 28

Fatal error: Cannot instantiate non-existent class: cpm in /home/mystaffi/public_html/_header.php on line 29

Code:
===

      <?
         include "./cpmfetch/cpmfetch.php";
         $objCpm = new cpm("/photoalbum");
         #$objCpm->cpm_viewRandomMedia(5,1);
         #$objCpm->cpm_viewMostVotedMedia(1,1);
         $objCpm->cpm_viewRandomMostViewedMediaFrom("",5,1);
         $objCpm->cpm_close();
      ?>    
Dillon Weyer
dill@mystaffie.com