361
Mods & Plugins (Requests & Discussions) / New Pics in Category
« on: January 20, 2003, 11:24:27 PM »Quote from: ChrisTTian
May I ask you for another 5 min to write me the code please.
I don't have time to make this code clean, but at least it works... feel free clean it up and modify (and post here)
Code: [Select]
<?php
define('ROOT_PATH', './4images/');
include(ROOT_PATH.'global.php');
require(ROOT_PATH.'includes/sessions.php');
$user_access = get_permission();
$number_of_new_pics = 15;
$days_to_be_new = 1;
$new_cutoff = time() - 60 * 60 * 24 * $days_to_be_new;
$cat_id_sql = get_auth_cat_sql("auth_viewcat", "NOTIN");
$sql = "SELECT MAX(cat_id) as max_id FROM ".CATEGORIES_TABLE;
$row = $site_db->query_firstrow($sql);
$cat_max_id = (!empty($row['max_id'])) ? $row['max_id'] : 0;
for ($i = 0; $i <= $cat_max_id; $i++){
$sql = "SELECT i.image_id, i.cat_id, i.image_active, i.image_name, i.image_date, c.cat_name
FROM ".IMAGES_TABLE." i, ".CATEGORIES_TABLE." c
WHERE i.image_active = 1 AND i.image_date >= $new_cutoff AND c.cat_id = i.cat_id AND i.cat_id = $i";
$result = $site_db->query($sql);
$row = $site_db->fetch_array($result);
$images_in_category = $site_db->get_numrows($result);
$category_name = ($row['cat_name']);
$category_id = ($row['cat_id']);
$category_link = ("<a href=\"" . ROOT_PATH . "categories.php?cat_id=" . $category_id . "\">");
if ($images_in_category) { echo "Found <b>$images_in_category</b> new images in category <b>$category_name</b> $category_link ...view category </a><br>"; }
$sql = "SELECT i.image_id, i.cat_id, i.image_active, i.image_name, i.image_date, c.cat_name, u.user_name
FROM ".IMAGES_TABLE." i, ".CATEGORIES_TABLE." c
LEFT JOIN ".USERS_TABLE." u ON u.user_id = i.user_id
WHERE i.image_active = 1 AND i.image_date >= $new_cutoff AND c.cat_id = i.cat_id AND i.cat_id = $i
ORDER BY i.image_date DESC
LIMIT $number_of_new_pics";
$result = $site_db->query($sql);
while ($row = $site_db->fetch_array($result)) {
$image_name = ($row['image_name']);
$image_id = ($row['image_id']);
$category_name = ($row['cat_name']);
$user_name = ($row['user_name']);
$media_path = ($row['image_media_file']);
$image_link = ("<a href=\"" . ROOT_PATH . "details.php?image_id=" . $image_id . "\">");
$allnew_link = ("<a href=\"" . ROOT_PATH . "search.php?search_new_images=1" . "\">");
echo "<ul><b>$image_name</b> uploaded by <b>$user_name</b> $image_link ...view image </a></ul>";
}
}
echo "$allnew_link Show all new images? </a>";
?>