Example #1
0
# This shows a list of the categories owned by the specified user.  If no
# user is specified, it shows everything.
#
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);
?>
	
	
Example #2
0
}
$ext = get_extension(strtolower($_FILES['file']['name']));
if (!in_array($ext, array("jpeg", "jpg", "png", "gif", "bmp", "tif", "tiff"))) {
    show_error_redirect_back("Sorry, {$ext} isn't an allowed file type.  Allowed extensions are JPEG, JPG, GIF, PNG, BMP, TIF, and TIFF<BR>");
}
# Generate the new filename
$rand = generate_salt();
$i = 0;
do {
    $newname = $me['username'] . "-" . $rand . "-{$i}.jpeg";
} while (file_exists("{$upload_directory}/{$newname}"));
# Copy it into the production folder, however, don't link it to the database yet.
resize_and_compress($max_width, $max_height, $jpeg_quality, $_FILES['file']['tmp_name'], "{$upload_directory}/{$newname}");
resize_and_compress($thumbnail_width, $thumbnail_height, $jpeg_quality, $_FILES['file']['tmp_name'], "{$upload_directory}/tn-{$newname}");
# Copy it into the preview folder
resize_and_compress($preview_width, $preview_height, 40, $_FILES['file']['tmp_name'], "{$preview_directory}/{$newname}");
# Set the filename in the session, which is used after confirmation
$_SESSION['image_filename'] = $newname;
# Get the list of categories, for displaying the combobox
$categories = get_categories_by_user_id($me['user_id'], true, $db);
if (count($categories) == 0) {
    show_error_redirect_back("You need to create a category first");
}
# Display
template_display_preview("{$preview_directory}/{$newname}", htmlentities($_FILES['file']['name']), $categories, $me['last_category']);
?>
	
	
	

Example #3
0
$db = get_db_read();
$_SESSION['back'] = $_SERVER['REQUEST_URI'];
if ($me) {
    $me['category_count'] = count(get_categories_by_user_id($me['user_id'], true, $db));
    $me['picture_count'] = count(get_pictures_by_user_id($me['user_id'], true, $db));
    $me['url'] = "show_user.php?user_id=" . $me['user_id'];
}
$users = get_all_users($me != null, $db);
# Set up the list of users (add appropriate information to the array)
$full_users = array();
$total_users = array();
$total_users['category_count'] = 0;
$total_users['picture_count'] = 0;
$total_users['url'] = "show_user.php";
while ($user_information = array_shift($users)) {
    $user_information['category_count'] = count(get_categories_by_user_id($user_information['user_id'], $me != null, $db));
    $user_information['picture_count'] = count(get_pictures_by_user_id($user_information['user_id'], $me != null, $db));
    $user_information['url'] = "show_user.php?user_id=" . $user_information['user_id'];
    array_push($full_users, $user_information);
    $total_users['category_count'] += $user_information['category_count'];
    $total_users['picture_count'] += $user_information['picture_count'];
    if (!$me) {
        $user_information['last_updated'] = $user_information['last_updated_public'];
    }
}
$unauthorized = get_unauthorized_users($db);
$new_unauthorized = array();
# Fix up the unauthorized list
foreach ($unauthorized as $user) {
    $user['url'] = "admin.php?action=authorize&user_id=" . $user['user_id'];
    array_push($new_unauthorized, $user);