<?php
define('ROOT_PATH', './4images/');
define('SITE_URL', 'http://www.mygallery.com/');
include_once(ROOT_PATH.'config.php');
include_once(ROOT_PATH.'includes/db_mysql.php');
include_once(ROOT_PATH.'includes/constants.php');
define('PIC_CATEGORIES_TABLE', '4images_categories');
define('PIC_IMAGES_TABLE', '4images_images');
$pics_db = new Db($db_host, $db_user, $db_password, $db_name);
function is_remote($file_name) {
return (preg_match('#^https?\\:\\/\\/[a-z0-9\-]+\.([a-z0-9\-]+\.)?[a-z]+#i', $file_name)) ? 1 : 0;
}
switch (POTD_SELECT_MODE) {
case "by_rating" : $select_mode = "a.image_rating"; break;
case "by_votes" : $select_mode = "a.image_votes"; break;
case "by_comments" : $select_mode = "a.image_comments"; break;
case "by_downloads" : $select_mode = "a.image_downloads"; break;
case "by_hits" : $select_mode = "a.image_hits"; break;
}
$sql = "SELECT a.image_id, a.cat_id, a.image_name, a.image_active, a.image_thumb_file, a.image_comments, a.image_comments, a.image_downloads, a.image_votes, a.image_rating, a.image_hits
FROM ".PIC_IMAGES_TABLE." a, ".PIC_CATEGORIES_TABLE." b
WHERE a.image_active=1 AND a.cat_id = b.cat_id AND b.auth_viewcat=".AUTH_ALL." AND b.auth_viewimage=".AUTH_ALL."
ORDER BY $select_mode DESC
LIMIT 1";
$row = $pics_db->query_firstrow($sql);
$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'] : ROOT_PATH.THUMB_DIR."/".$cat_id."/".$row['image_thumb_file'];
echo "<a href=\"".SITE_URL."details.php?image_id=$image_id\"><img src=\"".$thumb_src."\" border=\"0\" vspace=\"2\" alt=\"$image_name\"></a><br>\n";
echo "<b><div class=\"ltgreytext\">$image_name</b></div>\n";
echo "Selected by rates<br>\n";
?>
save as potd.php and then include as <?php include("./potd.php"); ?> into your site index.php