Hi,
this is a mod, found by coincedence and some modifications by SLL (
http://www.4homepages.de/forum/index.php?topic=3529.msg25302#msg25302)
What this MOD will do:- Shows the
most rated picture
- Shows the
most voted picture
- Shows the
most commented picture
- Shows the
most downloaded picture
- Shows the
most viewed picture
on a page
outside of 4Images! I have used this mod in Wordpress!
ok, lets go:
1. Create a new .php file and name it something like "bestpictures.php" or something like that. Save it in the root folder of 4images.
so it would look like that: /4images/bestpictures.php
2. Put the following code in it:
<?php
// error_reporting(E_ALL);
define('ROOT_PATH', '../4images/');
define('SITE_URL', 'http://www.yourdomain.de/');
// Bild des Tages: für 24 Stunden wird einer der besten Bilder aus
// Datenbank gelesen und angezeigt. Nach 24 Stunden wechselt das Bild.
/**************************************************************************
* *
* 4images - A Web Based Image Gallery Management System *
* ---------------------------------------------------------------- *
* *
* File: potd.php *
* Copyright: (C) 2002 Jan Sorgalla *
* Email: jan@4homepages.de *
* Web: http://www.4homepages.de *
* Scriptversion: 1.0 for 4images 1.7 *
* *
* Never released without support from: Nicky (http://www.nicky.net) and SLL (; *
* *
**************************************************************************
* *
* Dieses Script ist KEINE Freeware. Bitte lesen Sie die Lizenz- *
* bedingungen (http://www.4homepages.de/4images/lizenz.php) für *
* weitere Informationen. *
* --------------------------------------------------------------- *
* This script is NOT freeware! Please read the Copyright Notice *
* (http://www.4homepages.de/4images/lizenz_e.php) for further *
* information. *
* *
*************************************************************************/
//Based on the Photo of the Day mod by SLL and V@no
//additional tweaking by Omnirayf 9-5-2003
// and c-bass ( 6. Juli 2007)
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;
}
echo "<table width=\"100%\" border=\"0\" cellspacing=\"1\" cellpadding=\"1\"><tr>\n";
# -----------------------------------------------------------------------------------------------------------------------------------
$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
ORDER BY a.image_rating 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 "<td><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>$image_name</b><br>\n";
echo "Most rated<br></td>\n";
# -----------------------------------------------------------------------------------------------------------------------------------
$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
ORDER BY a.image_votes 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 "<td><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>$image_name</b><br>\n";
echo "Most voted<br></td>\n";
# -----------------------------------------------------------------------------------------------------------------------------------
$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
ORDER BY a.image_comments 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 "<td><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>$image_name</b><br>\n";
echo "Most commented<br></td>\n";
# -----------------------------------------------------------------------------------------------------------------------------------
$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
ORDER BY a.image_downloads 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 "<td><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>$image_name</b><br>\n";
echo "Most downloaded<br></td>\n";
# -----------------------------------------------------------------------------------------------------------------------------------
$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
ORDER BY a.image_hits 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 "<td><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>$image_name</b><br>\n";
echo "Most viewed<br></td>\n";
# -----------------------------------------------------------------------------------------------------------------------------------
echo "</tr></table>\n";
?>
3. EDIT in the first lines of the code the domain and the path to your 4images installlation! It might be, if u have different database table name, that u also have to change them in the code.
If u dont want for example shown the most viewed pictures, comment the sql query in the code.
4.
Test the file by calling it directly over your browser like
http://www.yourdomain.de/4images/bestpictures.php5. Put this line of code, where u want to have the pictures.
<?php include("http://www.yourdomain.de/4images/bestpictures.php"); ?>