Extension:Mediawiki Coppermine Photo Gallery random photo

This is the wiki page about Mediawiki Coppermine Photo Gallery random photo, an extension of Mediawiki. This extension can be downloaded from its home page and contains authoritative information about the project.

License: GNU GPL

Description: Shows random photo from Coppermine Gallery

Comments:
 * Need some cleaning (almost raw from dpLastPost),
 * Set your coding at the end of te code (return function).

Source code
<?php
 * 1) BASED on runphp Mediawiki Extension http://meta.wikimedia.org/wiki/Runphp
 * 2) BASED on dpLastPost from PostNuke


 * 1) To use extension type at your wiki:


 * 1) To activate the extension, include it from your LocalSettings.php
 * 2) with: include("extensions/galrand.php");


 * 1) Przemyslaw Stanislaw Knycz
 * 2) JID: djrzulf@kol.net.pl
 * 3) Written for http://czechowice.net/

$wgExtensionFunctions[] = "wfRunCoppermineRandom";

function wfRunCoppermineRandom { global $wgParser; $wgParser->setHook( "galrand", "GCR" ); }

function GCR { $ipb_path = "http://galeria.somewhere.at.net/"; $ipb_table_prefix = "prefix"; $ipb_dbhost = "localhost"; $ipb_dbuser = "dbuser"; $ipb_dbpass = "dbpass"; $ipb_dbname = "dbname";

$content = ''; $db_link = mysql_connect($ipb_dbhost, $ipb_dbuser, $ipb_dbpass); $sql = "SELECT pid, aid, filepath, filename, hits, owner_id, owner_name, title FROM " . $ipb_table_prefix."_pictures WHERE approved='YES' ORDER BY RAND DESC LIMIT 1"; mysql_select_db( $ipb_dbname, $db_link ); $result = mysql_db_query($ipb_dbname, $sql, $db_link);

$content .= ' ';

return mb_convert_encoding($content,'UTF-8', 'ISO-8859-2'); }

?>

Virtualization Blog
http://www.tricerat.com/blog If all computer networks were alike, triCerat wouldn’t exist to solve the mundane computer tasks that are necessary to keep today’s application delivery environments running. Virtualization Blog

I think this ist broken in a new mediawiki version. Info from another extension: At this stage it gets a bit tricky though due to the automatic caching of pages in MediaWiki. If you save a page with the source code above, the page will be created and placed in the cache with one of the lines in it. This will only change once the source code is changed again. To get around this, I invalidate every page that is older than one day (= 86400 seconds), this can be achieved by placing the following in LocalSettings.php: require("includes/GlobalFunctions.php"); $wgCacheEpoch = wfTimestamp( TS_MW, time - 86400 ); # 60*60*24 = 1 day

Of course it is possible to set this value to a lower number but keep in mind that this will have an impact on server load as pages are regenerated more often rather than pulled from cache.

Page
http://www.czechowice.net/wiki/Mediawiki_Coppermine_Photo_Gallery_random_photo