// START RANDOM PIC MOD
/**************************************************************************
* *
* 4images - A Web Based Image Gallery Management System *
* ---------------------------------------------------------------- *
* *
* File: none *
* Copyright: (C) 2002 Jan Sorgalla *
* Email: jan@4homepages.de *
* Web: http://www.4homepages.de *
* MOD for 4images 1.7 & phpBB 2.0.2 *
* *
* Never released without support from: Nicky (http://www.nicky.net) *
* *
**************************************************************************
* *
* 4images ist KEINE Freeware. Bitte lesen Sie die Lizenz- *
* bedingungen (http://www.4homepages.de/4images/lizenz.php) für *
* weitere Informationen. *
* --------------------------------------------------------------- *
* 4images is NOT freeware! Please read the Copyright Notice *
* (http://www.4homepages.de/4images/lizenz_e.php) for further *
* information. *
* *
*************************************************************************/
// Set here the URL to your 4images Gallery. WITH trailing slash!
define('SCRIPT_URL', 'http://YOUR-URL-TO/4images/');
// Set here your THUMBNAIL directory. Normally no need to change. WITHOUT trailing slash!
define('THUMB_DIR', 'data/thumbnails');
function is_remote($file_name) {
return (preg_match('#^https?\\:\\/\\/[a-z0-9\-]+\.([a-z0-9\-]+\.)?[a-z]+#i', $file_name)) ? 1 : 0;
}
// In following queries CHANGE 4images table PREFIX if it doesn't match (Standard "4images_")!
$sql = "SELECT COUNT(*) as total_images
FROM 4images_images a, 4images_categories b
WHERE a.image_active=1
AND a.cat_id = b.cat_id
AND b.auth_viewcat=0
AND b.auth_viewimage=0
";
if ( !($result = $db->sql_query($sql)) )
{
return false;
}
$row = $db->sql_fetchrow($result);
$total_images = $row['total_images'];
mt_srand((double)microtime() * 1000000);
$number = ($total_images > 1) ? mt_rand(0, $total_images - 1) : 0;
$sql = "SELECT a.image_id, a.cat_id, a.image_name, a.image_active, a.image_thumb_file, a.image_comments
FROM 4images_images a, 4images_categories b
WHERE a.image_active=1
AND a.cat_id = b.cat_id
AND b.auth_viewcat=0
AND b.auth_viewimage=0
LIMIT $number, 1";
if ( !($result = $db->sql_query($sql)) )
{
return false;
}
$row = $db->sql_fetchrow($result);
$image_id = $row['image_id'];
$cat_id = $row['cat_id'];
$image_name = $row['image_name'];
$image_comments = $row['image_comments'];
$thumb_src = (is_remote($row['image_thumb_file'])) ? $row['image_thumb_file'] : SCRIPT_URL.THUMB_DIR."/".$cat_id."/".$row['image_thumb_file'];
$randompic = "
Image Name: $image_name
Comments: $image_comments\n";
// HAVE FUN
// END RANDOM PIC MOD