CpmFetch - Using CpmFetch on HTML pages via SSI CpmFetch - Using CpmFetch on HTML pages via SSI
 

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 - Using CpmFetch on HTML pages via SSI

Started by vuud, June 03, 2005, 06:24:43 PM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

vuud

http://cpmfetch.fistfullofcode.com - latest info, news, development versions, tips, etc
Also a sign up to my site for email notifications of new updates to cpmfetch.

This thread is dedicated to the issue surrounding using CpmFetch as a SSI (Server side include) on Apache.  I have no idea what they call it under IIS (Internet Infernal Services) on Windoze.  But the principle should be the same (maybe).

I plan on releasing a fully function cpmssi module in the future, but for now you easily accomplish the same effect other ways.

This is incredibly simple so I am sorry I did not post these solutions eariler

I will add in the information in the next posting...


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 just tried this and it works fine...

Here are some assumptions I use in this document, you can change them of course, but this will help you figure out which parts you can change.  You do not have to use these paths, please change them to whatever you want, just be consistent

Coppermine is installed into /cpg
CpmFetch has been installed into /cpmfetch
Your HTML page is in the root of the web site /
You create the new file in /cpmfetch

Here are the steps I went through:

1.  Get cpmfetch installed
A normal install, follow the directions.

2.  Make sure the cpmtest.php file is working
This is part of the directions, but thought it would be worth mentioning anyway

3.  Create a new file named randomimages.php file
The filename can be whatever you want, but must be .php

4.  Edit "randomimages.php" and add in the following code:



<?php 
include "./coppermine.php";
$objCpm = new cpm('/cpg');
$objCpm->cpm_viewLastAddedMedia(4,2); 
$objCpm->cpm_close(); 
?>




The cpm_viewLastAddedMedia can be altered to any of the function calls.  This is just my example.

Note:  The first and second lines will need to be edited to your specific installation.  The /cpg would be the same value you used to get cftest.php working.  The include is the path to where you installed the cpmfetch program.

5. Edit your HTML file
Include the following line (Apache users) where you want the HTML table to be inserted.



<!--#include virtual="/cpmfetch/ssitest.php" -->



6.  Tell the server its okay to execute SSI commands

Now you need to tell the server it is okay to execute commands inside the HTML.  This can be done a few ways.

* You can use .shtml on some servers instead of .html
* You can add a file named ".htaccess" with "XBitHack On" on it and change the permissions to execute (chmod 755)

Apache documentation for SSI can be found here:
http://httpd.apache.org/docs/howto/ssi.html

7.  Check it with your web browser...

It should work. 

If not, view the source... if you see <!--#include virtual="/cpmfetch/ssitest.php" --> in there still, then it means that your web server is not noticing it can execute.  Review step 6 and the apache documentation. 

If the #include is missing, then it means that your server is okay, your just not getting any pictures back.  Try executing the PHP file directly.

Please post comments or corrections... and if any IIS user wants to step up and note how to do it on IIS, that would be great!

Hope this helps

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

mustang_lex

#2
I am sooo lost.  What do you put in the HTML document to pull up the randomimages.php we created earlier?

UPDATE: I got it to  work. I missed changing /cpg to mine /showcase . and it works now.

Where can I get different varibles (setup of thumbnails ect.)

also I found it slow to do. Is there a faster way.
my .htaccess has

QuoteOptions +Includes
XBitHack on
chmod +x index2.html

Is there something different I should do
Alex
www.stangette.com/showcase
my Coppermine Gallery!

vuud

Quote from: mustang_lex on June 07, 2005, 06:58:19 PM
I am sooo lost.  What do you put in the HTML document to pull up the randomimages.php we created earlier?

UPDATE: I got it to  work. I missed changing /cpg to mine /showcase . and it works now.

Where can I get different varibles (setup of thumbnails ect.)

also I found it slow to do. Is there a faster way.
my .htaccess has

QuoteOptions +Includes
XBitHack on
chmod +x index2.html

Is there something different I should do


You don't need the chmod in the .htaccess file...  You just need to do it to the file once...

I don't understand what you mean by "slow" and by "variables"?

You can do anything the documentation says you can do...  just pick the function...
http://cpmfetch.fistfullofcode.com/projects/copperminefetch/docs.php

As for slow... you really only need to create the include file once, then you can use it anywhere on your web site.  If you still think that is slow, try coding up all the sql and formatting code and inserting that... I think you underestimate how much time this is saving you









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

mustang_lex

Ya it only happened once . Every other time it was fast. Thank you for the assistence. Its greatly appreciated!!!!
Alex
www.stangette.com/showcase
my Coppermine Gallery!

vuud

Quote from: mustang_lex on June 08, 2005, 02:00:56 AM
Ya it only happened once . Every other time it was fast. Thank you for the assistence. Its greatly appreciated!!!!

Well, thats good to know.  The delay would be one or more of the following things:

1. PHP Engine / Webserver is overloaded
2. Internet Congestion in getting the images
3. MySQL database slowing for some reason

None of which I can take credit for :)

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

#6

Background: the concept of making a page randomly grab and change the image shown every x days was posed in a different thread.  Here are my thoughts on doing it.

I guess this would work for an SSI, or normal PHP page...

Here is what you would do in PHP either as an SSI Include or directly on your page

* Check for the existance of a data file in that directory
file_exists ( string filename );

* If there is no file, or the date stamp on the file is older than x days:
stat ( string filename ) or fstat (file pointer)

* Grab the name of the image from CpmFetch
You will need to cpm_setReturnType("html") so you can grab it into a variable

* Write the name to a data file

* Use that name to show the image

* IF the file was within the date range

* Read the contents of the file, which is the image to be displayed

Yeah, thats it.  Crazy enough that it just might work.  Not sure why you would want to... but thats how, in a nutshell to do it...










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

Gary B

Ok I have the cftest.php working with no errors but I am not doing something right with getting it into an HTML page. I have the following in my randomimages.php file

<?php
include "./coppermine.php";
$objCpm = new cpm('/library');
$objCpm->cpm_viewLastAddedMedia(4,2);
$objCpm->cpm_close();
?>

Coopermine is installed in a folder called library cpmfetch is installed in a folder named cpmfetch

When I try and run the randomimages.php I get the following error messages:

Warning: main(./coppermine.php): failed to open stream: No such file or directory in public_html/cpmfetch/randomimages.php on line 2
Warning: main(./coppermine.php): failed to open stream: No such file or directory in public_html/cpmfetch/randomimages.php on line 2
Warning: main(): Failed opening './coppermine.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in public_html/cpmfetch/randomimages.php on line 2
Fatal error: Cannot instantiate non-existent class: cpm in public_html/cpmfetch/randomimages.php on line 3

I did remove two directories that seemed to show my account name for that area...but other than that this is what I see....

Help!

and Thanks!
Gary





vuud


According to what you told me, your:

include "./coppermine.php";

should really be

include "./cpmfetch/cpmfetch.php";

The ./ may need to be changed depending on where you are calling it from.  But you should be able to see your problem there.


Quote from: bungargp on November 26, 2005, 08:15:02 AM
Ok I have the cftest.php working with no errors but I am not doing something right with getting it into an HTML page. I have the following in my randomimages.php file

<?php
include "./coppermine.php";
$objCpm = new cpm('/library');
$objCpm->cpm_viewLastAddedMedia(4,2);
$objCpm->cpm_close();
?>

Coopermine is installed in a folder called library cpmfetch is installed in a folder named cpmfetch

When I try and run the randomimages.php I get the following error messages:

Warning: main(./coppermine.php): failed to open stream: No such file or directory in public_html/cpmfetch/randomimages.php on line 2
Warning: main(./coppermine.php): failed to open stream: No such file or directory in public_html/cpmfetch/randomimages.php on line 2
Warning: main(): Failed opening './coppermine.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in public_html/cpmfetch/randomimages.php on line 2
Fatal error: Cannot instantiate non-existent class: cpm in public_html/cpmfetch/randomimages.php on line 3

I did remove two directories that seemed to show my account name for that area...but other than that this is what I see....

Help!

and Thanks!
Gary





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

Gary B

Thanks!! Because of your help I have a random image now displaying. I know I read it somewhere but how do I change the size of the thumbnail displayed to the intermediate photo or normal photo and also how to get rid of he border?

Thanks so very much!
Gary

vuud

Quote from: bungargp on November 26, 2005, 07:04:16 PM
Thanks!! Because of your help I have a random image now displaying. I know I read it somewhere but how do I change the size of the thumbnail displayed to the intermediate photo or normal photo and also how to get rid of he border?

Thanks so very much!
Gary

All that is handled through the options array:

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

The border is set by your browser but can be overridden through HTML CSS stuff.  This example does not do that, but does some neat stuff with the borders and you can probably use it as a starting point to remove the borders all together.

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

Hope this helps
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

Gary B

#11
Ok so I am impaired with PHP...but I am trying to learn...

I have the following saved as test1.css saved in the cpmfetch folder

<style type="text/css">
.test1 {  border-style:none }
</style>

I have the following saved as randomimages.php in the same cpmfetch folder

<?php
include "cpmfetch.php";
$objCpm = new cpm('/library');
$objCpm->cpm_viewRandomMedia(4,1,array("tablestyle" => "test1","imagestyle" => "test1"));
$objCpm->cpm_close();
?>

So far I can not get it to see the css file....and I still have borders...also can you tell me what line I need to add to get it to display the intermediate sized photos?


WAIT...I just figured out the display size....the following seems to display a random image of 200px wide...

<?php
include "cpmfetch.php";
$objCpm = new cpm('/library');
$objCpm->cpm_viewRandomMedia(1,1,array("tablestyle" => "test1",'imagewidth' => '200',"imagestyle" => "test1","imagesize" => "int"));
$objCpm->cpm_close();
?>


I guess all I need to figure out now is still how to rid myself of the borders.
Thank you once again!
Gary


vuud


Well, the imagewidth does not select an image that is 200px wide, but instead instructs the browser to render them at 200px wide.  Browsers are not as bad as they used to be at that (the first web browsers out were awful at that).

As for the CSS, you still need to tell your web page to load that CSS file.  I am not sure if you did that...

Something like this:
<link rel="stylesheet" type="text/css" href="http://....whatever ure here...." />

The css entries into cpmfetch just tells cpmfetch what to include as the class statement.

Hopefully that fixes you.

Vuud



Quote from: bungargp on November 27, 2005, 03:21:55 AM
Ok so I am impaired with PHP...but I am trying to learn...

I have the following saved as test1.css saved in the cpmfetch folder

<style type="text/css">
.test1 {  border-style:none }
</style>

I have the following saved as randomimages.php in the same cpmfetch folder

<?php
include "cpmfetch.php";
$objCpm = new cpm('/library');
$objCpm->cpm_viewRandomMedia(4,1,array("tablestyle" => "test1","imagestyle" => "test1"));
$objCpm->cpm_close();
?>

So far I can not get it to see the css file....and I still have borders...also can you tell me what line I need to add to get it to display the intermediate sized photos?


WAIT...I just figured out the display size....the following seems to display a random image of 200px wide...

<?php
include "cpmfetch.php";
$objCpm = new cpm('/library');
$objCpm->cpm_viewRandomMedia(1,1,array("tablestyle" => "test1",'imagewidth' => '200',"imagestyle" => "test1","imagesize" => "int"));
$objCpm->cpm_close();
?>


I guess all I need to figure out now is still how to rid myself of the borders.
Thank you once again!
Gary


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

Gary B

Ok so I never got the style sheet info to work...all I want to do is to have the text displayed as Arial 10pt. Here is the code I am using so far...can I just add some sort of font tag to this code to make it arial 10?

<?php 
include "cpmfetch.php";
$objCpm = new cpm('/library');
$objCpm->cpm_viewRandomMedia(1,1,array("tablestyle" => "test1","subtitle" =>"This photo is from the %a album","imagesize" => "thumb","imagestyle" => "test1"));
$objCpm->cpm_close(); 
?>


Thanks for your help and patience!
Gary

yuvalr

I am sure I am very close to make it work but something is missing.
all I want is to display some pictures in my html pages.
i have done the following:
Installed cpfetch, checked that the cpmtest.php is working, created the  randomimages.php, and  checked that this is also working.
the next step is a bit unclear - i have created a new file and inserted the line as described:
<!--#include virtual="./gallery/cpmfetch/ssitest.php" -->
where gallery is my coppermine dir and cpmfetch is of course  my cpmfetch dir.

i want to add the ".htaccess" but I doubt my ISP will give me permission .
saving  the file as  .shtml lead to the following result:
Error processing SSI file

Please help




vuud

Quote from: yuvalr on January 16, 2006, 09:18:23 AM
I am sure I am very close to make it work but something is missing.
all I want is to display some pictures in my html pages.
i have done the following:
Installed cpfetch, checked that the cpmtest.php is working, created the  randomimages.php, and  checked that this is also working.
the next step is a bit unclear - i have created a new file and inserted the line as described:
<!--#include virtual="./gallery/cpmfetch/ssitest.php" -->
where gallery is my coppermine dir and cpmfetch is of course  my cpmfetch dir.

i want to add the ".htaccess" but I doubt my ISP will give me permission .
saving  the file as  .shtml lead to the following result:
Error processing SSI file

Please help


I'd check the error logs... or your access log file if they log to there...

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

radmofo

Hello I can't seem to find a better place to put this question so I hope here is OK. I have installed some of your code and it's visible on my SITE and it works great! There is only one thing that is strange, it will not pull random (or any) images from albums above number 25. If I force it to ViewRandomImageFrom (1,1,"album=26") or 27 28 etc I get nothing however 1-25 work perfect. I have racked my head on the wall long enough, any suggestions?

Kevin
Please give me some negative Karma. :)

iblazed

I have troubleshooted countless hours trying to get this to work and I feel like I almost have it. I got the cpmtest.php working. Also created randomimages.php, and that is also working.
I inserted the line <!--#include virtual="photos/cpmfetch/randomimages.php" -->
in my html file where I want the pictures to show up but instead of pictures I get this
cpm_viewLastAddedMedia(4,2); $objCpm->cpm_close();?>

Here is the code in my randomimages.php
<?php
include "./cpmfetch.php";
$objCpm = new cpm('/photos');
$objCpm->cpm_viewLastAddedMedia(4,2);
$objCpm->cpm_close();?>

I also edited the .htaccess file as needed.
Any help would be appreciated as I am at a loss here. Thanks

mottaguedes

Hi everyone!

I installed cpmfetch and got to pass all the tests BUT!, I am not seeing the little grid with images.
Instead I get the following messge:


QuoteTrying to display some images:

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

Unknown column 'u.user_website' in 'field list'
Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/fetiche/public_html/dressing4pleasure/cpmfetch/cpmfetch_dao.php on line 710

I've been looking hard in Cpmfetch documentation but with no luck.
Can anyone shed some light please?

Thanks!!!
MottaGuedes

vuud

Quote from: mottaguedes on May 19, 2006, 11:46:40 PM
Hi everyone!

I installed cpmfetch and got to pass all the tests BUT!, I am not seeing the little grid with images.
Instead I get the following messge:


I've been looking hard in Cpmfetch documentation but with no luck.
Can anyone shed some light please?

Thanks!!!

Oh my.  That does not sound good.  Maybe the README that came with it can help...

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