if (isset($_GET['picture_id']) == false || is_numeric($_GET['picture_id']) == false) { show_error_redirect_back("Invalid picture"); } $picture_id = $_GET['picture_id']; # Get the current picture $picture = get_picture_from_picture_id($picture_id, $db) or show_error_redirect_back("Invalid picture"); # Get the category $category = get_category_by_category_id($picture['category_id'], $db) or show_error_redirect_back("Invalid picture"); # Get the user $user = get_user_by_user_id($category['user_id'], $db) or show_error_redirect_back("Invalid picture"); # Check if the category is private if (!$me && $category['private'] == '1') { show_error_redirect_back("Invalid picture"); } # Get the images in the category $pictures = get_pictures_by_category_id($category['category_id'], $db); $prev_picture = null; $next_picture = null; # Find the next and previous picture $done = false; while (!$done && ($this_picture = array_shift($pictures))) { if ($this_picture['picture_id'] == $picture_id) { if ($this_picture = array_shift($pictures)) { $next_picture = $this_picture; } $done = true; } else { $prev_picture = $this_picture; } } if ($next_picture) {
header('Pragma: no-cache'); require 'shared.php'; # Make a connection to the database $db = get_db_read(); $_SESSION['back'] = $_SERVER['REQUEST_URI']; # Read the user_id parameter $user_information = null; if (isset($_GET['user_id']) && is_numeric($_GET['user_id'])) { $user_information = get_user_by_user_id($_GET['user_id'], $db); } # Get the userinformation, get the category list and display the header if ($user_information != null) { $categories = get_categories_by_user_id($user_information['user_id'], $me, $db); } else { $categories = get_all_categories($me != null, $db); } # Display all the categories $new_categories = array(); foreach ($categories as $category) { $category['num_pictures'] = count(get_pictures_by_category_id($category['category_id'], $db)); $category['last_updated'] = $me ? $category['last_updated'] : $category['last_updated_public']; $category['url'] = "show_category.php?category_id=" . $category['category_id']; array_push($new_categories, $category); } template_display_category_list($me, $user_information, $new_categories); ?>
# header('Pragma: no-cache'); require 'shared.php'; $db = get_db_read(); $_SESSION['back'] = $_SERVER['REQUEST_URI']; if (isset($_GET['category_id']) == false || is_numeric($_GET['category_id']) == false) { show_error_redirect_back("No category_id specified"); } $category_id = $_GET['category_id']; $category_information = get_category_by_category_id($category_id, $db); if (!$category_information || !$me && $category_information['private'] != 0) { show_error_redirect_back("invalid category_id"); } $user_information = get_user_by_user_id($category_information['user_id'], $db); # Check if the category is private $pictures = get_pictures_by_category_id($category_id, $db); # Display the table of pictures $new_pictures = array(); foreach ($pictures as $picture) { $picture['url'] = "show_picture.php?picture_id=" . $picture['picture_id']; $picture['picture_url'] = "picture.php?picture_id=" . $picture['picture_id']; $picture['tn_url'] = "picture.php?tn=true&picture_id=" . $picture['picture_id']; $picture['num_comments'] = count(get_comments_by_picture_id($picture['picture_id'], $db)); array_push($new_pictures, $picture); } template_display_picture_list($me, $user_information, $category_information, $new_pictures, $thumbnail_height, $thumbnail_width); ?>