Herself's Webtools

Scripts, HowTos, Templates, Plugins, Widgets, Tips and Useful Information

Archive for the ‘coppermine’ Category

How to add photos from Coppermine to any PHP page

without comments

Some asked how to add Coppermine photos to WordPress pages. This code will work for any page.

You need to replace MYSQL_SERVER with your database server, localhost usually works just fine.
USER_NAME is the user name for your Coppermine database
PASSWORD is the password for your Coppermine database
DATABASE_NAME is the name of your Coppermine database

Also replace YOUR_DOMAIN with the domain your Coppermine albums are hosted on. You might also need to change the path.

This code will give you a horizontal table of 3 thumbnail photos.


If you are using WordPress, you need to download any page from your theme. Change the file name to Coppermine and the Template name to Coppermine.

Remove the stuff in the middle. On my template that is everything between<div id=”content” class=”page”> and </div> but your template might be different.  The past this code into that section being sure to add your password, database etc.

When you are done, upload the new template to your theme directory.

Create a new page and choose Coppermine as the template.  All the work is done.  You can add text or anything else to the page.


<?php
if ( !($coppermine_db = mysql_connect( “MYSQL_SERVER”, “USER_NAME”, “PASSWORD” ))){
die ( “Can not connect to server” );
}else{
//select db
if ( !(mysql_select_db(“DATABASE_NAME”, $coppermine_db ))){
die ( “Can not select database” );
}
}

//ask mysql db for the path and file name of last five images uploaded
$coppermine_query = “select filepath, filename, ctime from cpg_pictures order by ctime desc limit 3;”;

$coppermine_result = mysql_query($coppermine_query);
$count = mysql_numrows( $coppermine_result );

//start link
$link =  “<center>”;

$link .= “<table border=3>”;
$link .=  “<th colspan=3><a href=\”http://YOUR_DOMAIN.com/coppermine/\”>Recent Photos</th><tr>”;
$i = 0;
while ( $i < $count ){

$path = mysql_result($coppermine_result, $i, “filepath” );
$name = mysql_result($coppermine_result, $i, “filename” );

$link .= “<td><img src=\”http://YOUR_DOMAIN.com/coppermine/albums/$path” . “thumb_$name\”></td>”;
$i++;
}

$link .= “</tr></table>”;
$link .= “</center>”;

//end link

//clean up
mysql_close();

print $link;

You can see an example of this code TimesToCome where I pull 3 photos from 3 different Coppermine albums onto the page.

Written by timestocome

September 22nd, 2008 at 4:24 pm

Yet another Coppermine MySQL injection flaw has been discovered

without comments

Coppermine 1.4.19 has been released to fix a MySQL injection flaw, again. This is how TimesToCome was hacked last April and why you now have all these shiny new security tools and information on this website.

I went to the Coppermine site only because there was a huge increase in cross site scripting attempts last night on the Coppermine albums.

Anyhow update if you have not.

Written by timestocome

August 6th, 2008 at 1:21 pm

Posted in coppermine, mysql, security

WordPress Blue-box theme converted for Coppermine users

without comments

Here is another popular Wordpress Theme ( Blue-Box) I converted to work with Coppermine. You should find it easy to tailor to your needs including adding in advertising to your sidebar. Coppermine Blue-Box WordPress adapted theme

Written by timestocome

May 12th, 2008 at 5:00 am