Tag Archives: PHP

plugin psnGallery2 version 1.3.1 available for download

The new version of the psnGallery2 has been released !

As announced, the new functionnalities are :

  • Display the last uploaded pictures from a specific Coppermine album
  • Display the most viewed pictures from a specific Coppermine album
  • Display the best rated pictures from a specific Coppermine album

They are available via tags in post and via php functions anywhere else.

The automatic install script will be soon available…

Continue reading plugin psnGallery2 version 1.3.1 available for download

psnGallery2 1.3.1 soon on your site

If I have time, the psnGallery2 version 1.3.1 will be available for download tonight (GMT+2).

It includes few fixes and the 3 new tags described in the previous post.

I have also scheduled for a near future to improve the install/upgrade procedure, it will be based on the WordPress install/upgrade script.

The install functionnalities will be :

  • Create the table “psnGallery” if doesn’t exist and/or update the structure if needed.
  • Look for the Coppermineconfig.inc.php” to extract the Coppermine configuration data
  • Create/Update all required “psnGallery2” parameters

I give no date for this but it could be soon (depending on the free time I will have in the coming days, weeks)

I will keep you posted on the evolution of that script.

psnGallery2 : Syntax clarification : Out of Post

Out of a post (eg: in index.php)

  • To display several random pictures from a specific Coppermine album (if -1 : from all albums) : CPGRndPicture($albumid, $count, $nSize,$before,$after, $activelink)
  • Generate tags to display a full album from a specific Coppermine album (if -1 : from all albums)… : CPGAlbum($albumid, $nCols, $nSize, $beforeCol, $afterCol, $beforeRow, $afterRow)
  • Get the name of an album : CPGAlbumName($albumid)
  • Get the name of a category : CPGCategoryName($categoryid)
  • Get the number of pictures within an album : CPGAlbumPicCount($albumid)
  • Get the album name list of a category : CPGAlbumListCategory($categoryid, $count, $nSize, $before, $after)
  • Display a picture (in some modes) : CPGPicture($pictureID, $nSize, $before, $after, $mode, $dummy)
  • Display the specific thumbnail associated with an album : CPGAlbumThumb ($albumid, $nSize, $before, $after)

Parameters explanation :

  • “$albumid” and the “$pictureid” can be found in the “psnGallery2” Administration page.
  • “$count” represents the number of pictures to display.
  • “$nSize” is the size of the picture to display (1=thumbnail, 2=normal size and 3 is the fullsize picture)
  • “$before” is the string (HTML) to insert before each picture
  • “$after” is the string (HTML) to insert after each picture
  • “$categoryid” is the category of the album to display
  • “$mode” will display different supplemental information on the picture according the mode (EXIF data, statistic, etc…).

psnGallery 2 Sticky information

What’s that ?

It provides you an “gateway” between your Coppermine Gallery and your WordPress Blog.

A lot of functionnalities for your Blog within a post or outside a post !

How to make it work ?

The main requirements are to have installed :

If those applications are up and running, only few steps are required :
Continue reading psnGallery 2 Sticky information

psnGeneric version 1.0.1 finally out !

the plugin “psnGeneric version 1.0.1 is finally out ! It was announced few weeks ago…But I had a lot of work to do that’s why it is out only today !

So what’s the plugin ?

Do you see the “quote” block on the left side of this site ? and the “download” filelist block (also on the left side) ? Both are done via the psnGeneric version 1.0.1

So in other word, it is something that display an extract or a full list of records based on a criteria.

For the “quote” example, here is the line added in my “index.php” : the_genRandom( 'QUOTE',1,'','','', ''); .
For the “download” example, the following code is used : genList( 'WPHACK',100,'','','', '');

How to create/manage those lists ?

I create a small administration page for that.

Three different actions are possible : editdeletecreate.

Everything is done via a very easy and intuitive tabular interface.

In order to fix a small mySQL syntax issue (for old mySQL versions), you have to update the line 94 of wp-admin/psnGENAdmin.php as below :

Change $psnSQLLimit = "LIMIT ".$psnLimit." OFFSET ".$psnOffset;
into $psnSQLLimit = "LIMIT ".$psnOffset.",".$psnLimit;

Thanks Bernd Pressler to notify me about this.

WPPlugin psnGeneric soon out

What’s psnGeneric ?

It allows you to display an extract (random or not) of several records based on a key from a table. This can be used to display a random quote, a list of file to download, a list of … in fact, what you want !

How does it work ?

Few functions that you can call from your “index.php”. There is no limitation except your imagination ! The “Quote of the day” and the “Download” sections displayed on this page use this functionnality. Here is the call for the “Quote” :

< ?php the_genRandom( 'QUOTE',1,'','','', ''); ?>

You manage the content via the WP-Admin area (as you can see below).

Nothing to display.

This is only a preview. It will be out and available for download end of this week-end.

Why idahocline.com and idahocline.info ?

Well, at first sight both sites are equal… In fact, idahocline.info was created in the hurry due to issue with the webhoster of idahocline.com. But normally, idahocline.info should have been created a little later.

In fact, I planned to create another site dedicated to Web Development with everything related. So let’s say that this site will be soon totally redesigned to be more developper oriented, with different areas, like :

  • CSS/xHTML : Templates / tutorials / links
  • Design : Ideas, discussions about Web Designs
  • PHP/mySQL : Tips and tricks for PHP, mySQL, …
  • WordPress : plugins, tips & tricks, …
  • Showcase : portfolio of several projects done or in progress
  • Testing area : do you really don’t know what it is ? 😉

Normally this site with architecture above will be online soon, probably end of June….

Of course, idahocline.com will stay online but will be more focused on my wife and I.

I am also working on several other WP plugins (with an administration page):

  • psnGeneric v1.0.0 : Random Item: Random Quotes, Books, … based on a table (Totaly generic)
  • psnGallery2 v1.3.0 : Coppermine Gallery (including all supported formats)
  • psnStat v1.0.0 : TFS WebStatistics

Further information on psnGallery2 tags/functions

Out of a post (eg: in index.php)

// Generate tags to display several random pictures from a specific Coppermine album (if -1 : from all albums)
function CPGRndPicture($aid=-1, $count =-1, $nSize=1,$before='',$after='', $activelink=true, $dummy='') // Generate tags to display a full album from a specific Coppermine album (if -1 : from all albums)...
function CPGAlbum($aid, $nCols=4, $nSize=1, $beforeCol="", $afterCol="", $beforeRow="", $afterRow="")

// Get the name of an album
function CPGAlbumName($aid)

// Get the name of a category
function CPGCategoryName($cid)

// Get the number of pictures within an album
function CPGAlbumPicCount($aid)

// Get the album name list of a category
function CPGAlbumListCategory($cid, $count=-1, $nSize=1, $before='', $after='')

// Display a picture (in some modes)
function CPGPicture($pictID, $nSize=1, $before='', $after='', $mode='picture', $dummy=0)

// Display the specific thumbnail associated with an album
function CPGAlbumThumb ($aid, $nSize=1, $before='', $after='')

Within POST

Tag defined Associated function Action

  • <cpg_album> => CPGAlbum($elems[ 0 ], $elems[ 1 ], $elems[ 2 ], $elems[ 3 ], $elems[ 4 ], $elems[ 5 ], $elems[ 6 ]);
  • <cpg_albumcatlist> => CPGAlbumListCategory($elems[ 0 ], $elems[ 1 ], $elems[ 2 ], $elems[ 3 ], $elems[ 4 ]);
  • <cpg_albumname> => CPGAlbumName($elems[ 0 ]) ;
  • <cpg_albumpiccount> => CPGAlbumPicCount($elems[ 0 ]);
  • <cpg_albumthumb> => CPGAlbumThumb($elems[ 0 ], $elems[ 1 ], $elems[ 2 ], $elems[ 3 ], $elems[ 4 ], $elems[ 5 ], $elems[ 6 ]);
  • <cpg_categoryname> => CPGCategoryName($elems[ 0 ]) ;
  • <cpg_gallery> => CPGRndPicture($elems[ 0 ], $elems[ 1 ], $elems[ 2 ], $elems[ 3 ], $elems[ 4 ], $elems[ 5 ], $elems[ 6 ]);
  • <cpg_picture> => CPGPicture($elems[ 0 ], $elems[ 1 ], $elems[ 2 ], $elems[ 3 ], $elems[ 4 ], $elems[ 5 ], $elems[ 6 ]);
  • <gallery> => CPGRndPicture($elems[ 0 ], $elems[ 1 ], $elems[ 2 ], $elems[ 3 ], $elems[ 4 ], $elems[ 5 ], $elems[ 6 ]);

Of course, $elems[ x ] will be replace by the according value:

In other words : <cpg_gallery>1|5|1</cpg_gallery> will become CPGRndPicture(1, 5, 1, ”, ”, ”, ”); and finally :

Another example : <cpg_picture>275|1</cpg_picture> will become CPGPicture(275, 1, ”, ”, ”, ”, ”) and finally :

cpg_picture quickfix

Well, I was too fast to deliver the psnGallery2…In the sql, included in the “package”. There is a “(” too much !

In order to fix the issue. Execute the following sql (eg, from phpMyAdmin) :

UPDATE wp_psnGallery SET value = 'CPGPicture($elems[ 0 ], $elems[ 1 ], $elems[ 2 ], $elems[ 3 ], $elems[ 4 ], $elems[ 5 ], $elems[ 6 ]);' WHERE "kind" = 'TAG' AND "key" = 'picture' LIMIT 1 ;

And here is sample of the display of one specific picture via the tag <cpg_picture>759|1</cpg_picture>


PHP Tag within a post

Based on the work of Stevarino and to answer to WordPress Forum, here is another version :

I found the problem….It comes the formatting functions which convert few “special” characters into more fancy one….

function run_phpinpost($data) {
$PHPTag = "phpcode";
$data = str_replace(array("rn","r"), "n", $data);
while (false !== strpos($data, "< ".$PHPTag .">")) {
$Before= substr($data, 0, strpos($data, "< ".$PHPTag.">"));
$After = substr($data, strpos($data, "")+(strlen($PHPTag)+3));
$Evaluate = substr($data, strpos($data, "< ".$PHPTag.">")+(strlen($PHPTag)+2));
$Evaluate = substr($Evaluate,0,strpos($Evaluate, "")-1);
$Evaluate = str_replace(array("’","‘"),"'", $Evaluate);
$Evaluate = str_replace(array("”","“"),'"', $Evaluate);
ob_start(); // run that data and grab what comes out
$data = $Before.ob_get_clean().$After;
} // end of while
return $data;
} // end of run_phpinpost

add_filter('the_content', 'run_phpinpost');

to use it, simply put the code above in “my-hacks.php”, and in your post use the tags :
<phpcode>php executable code </phpcode>

By the way if you are using an “old” PHP version, the function ob_get_clean() is not existing so :

// To add compatibility with earlier PHP version...(before 4.3.0)
if (!function_exists("ob_get_clean")) {
function ob_get_clean() {
$ob_contents = ob_get_contents();
return $ob_contents;

psnGallery2 1.2.1 changes overview

Well, I know it is always annoying to wait for news…. So here are some… 🙂

The most important addition/change with the release is the fact that all the configuration parameters are now stored in a table in the “wordpress” database (see below to have further information).

Here are the differents news functionnalities available with psnGallery2 1.2.1 :

  • User Defined tags for posting where you associate a tag to php code
  • Coppermine Albums viewer within WP-Admin area
  • Coppermine Pictures viewer within WP-Admin area
  • psnGallery2 parameters viewer within WP-Admin area
  • Fix of few bugs
  • etc…

In the future versions, I will add a “online” configuration of psnGallery2.

Continue reading psnGallery2 1.2.1 changes overview