Example #1
0
function phphoto_main($authorized = false)
{
    global $settings;
    $db = phphoto_db_connect();
    $admin = isset($_GET[GET_KEY_ADMIN_QUERY]) ? $_GET[GET_KEY_ADMIN_QUERY] : '';
    if ($authorized) {
        phphoto_admin_links($db);
    }
    if ($authorized && strlen($admin) > 0) {
        phphoto_admin($db, $settings, $admin);
    } else {
        phphoto_gallery($db);
    }
    phphoto_db_disconnect($db);
}
Example #2
0
    $db = phphoto_db_connect();
    if ($thumbnail) {
        $column = 'thumbnail';
    } else {
        $column = 'data';
        // update views counter
        if (!isset($_GET[GET_KEY_ADMIN_QUERY])) {
            // do not count administrative views
            if (!isset($_SESSION[SESSION_KEY_VIEWS]) || !isset($_SESSION[SESSION_KEY_VIEWS]["i{$id}"])) {
                phphoto_db_query($db, "UPDATE images SET views = views + 1 WHERE id = {$id}");
                $_SESSION[SESSION_KEY_VIEWS]["i{$id}"] = SESSION_VALUE_VIEWS;
            }
        }
    }
    $result = phphoto_db_query($db, "SELECT {$column} AS image, type FROM images WHERE id = {$id};");
    phphoto_db_disconnect($db);
    if (empty($result)) {
        not_valid_id($id, 'there is no image in the database with that id');
    }
    $image = $result[0]['image'];
    $type = $result[0]['type'];
    if ($thumbnail) {
        header('Content-type: image/png');
    } else {
        header('Content-type: ' . image_type_to_mime_type($type));
    }
    echo $image;
    exit;
} elseif (isset($_GET[GET_KEY_GALLERY_ID])) {
    $id = $_GET[GET_KEY_GALLERY_ID];
    if (!is_numeric($id)) {