<% function DrawHeader() { echo "\n"; echo "\n"; echo "CANAV Books Archive\n"; echo "\n"; echo "\n"; virtual( "/Common/Header.php" ); echo "
\n"; echo "\n"; echo "\n"; } function DrawFooter() { virtual( "/Common/Footer.php" ); echo "
\n"; echo "\n"; echo "\n"; } $db_conn = pg_connect("dbname=canav user=canav"); DrawHeader(); if( !$db_conn ) { echo "Unable to connect!"; DrawFooter(); exit; } $group_id = $_POST["group_id"]; if( $group_id == "" ) { $group_id = $_GET["group_id"]; } if( $group_id == "" ) { // Try to get it from the query string $group_id = $_GET["group_id"]; } if( $group_id == "" ) { DrawFooter(); exit(); } $picture_id = $_POST["picture_id"]; if( $picture_id == "" ) { $picture_id = $_GET["picture_id"]; } if( $picture_id == "" ) { // No picture to display, so show the thumbnails // Grab the picture group information $group_query = "select * from picture_groups where group_id = $group_id"; $group_result = pg_exec( $db_conn, $group_query ); if( $group_result ) { $group_data = pg_fetch_object( $group_result, 0 ); $group_short_description = $group_data->short_description; $group_long_description = $group_data->long_description; if( $group_long_description != "" ) { echo "

"; echo $group_long_description; echo "

\n"; } else if( $group_short_description != "" ) { echo "

"; echo $group_short_description; echo "

\n"; } } $query = "select * from pictures where group_id = $group_id and display = 'Y' order by sort_priority, picture_id"; $result = pg_exec( $db_conn, $query ); $row = 0; while ($row < pg_numrows ($result)): $data = pg_fetch_object ($result, $row); $picture_id = $data->picture_id; $group_id = $data->group_id; $file_path = $data->url_path; if( $file_path[strlen($file_path)-1] != '/' ) { $file_path .= "/"; } $file_name = $data->file_name; $thumbnail_file_name = $data->thumbnail_file_name; $short_description = $data->short_description; $long_description = $data->long_description; $source = $data->source; /* if( $short_description == "" ) { $short_description = $long_description; } */ if( $thumbnail_file_name == "" ) { preg_match( "/^(.*)?(\..*)$/", $file_name, $matches ); $thumbnail_file_name = $matches[1] . "-small" . $matches[2]; } echo ""; echo "\"©"; echo "\n"; $row++; endwhile; } else { // Display one picture (full size) // Grab the group title $query = "select * from picture_groups where group_id = $group_id"; $result = pg_exec ($db_conn, $query); $data = pg_fetch_object ($result, $row); $group_desc = $data->short_description; $query = "select * from pictures where picture_id = $picture_id and display = 'Y' order by sort_priority"; $result = pg_exec ($db_conn, $query); if( result ) { $data = pg_fetch_object ($result, $row); $picture_id = $data->picture_id; $file_path = $data->url_path; if( $file_path[strlen($file_path)-1] != '/' ) { $file_path .= "/"; } $file_name = $data->file_name; $short_description = $data->short_description; $long_description = $data->long_description; $source = $data->source; if( $long_description == "" && $short_description != "" ) { $long_description = $short_description; } echo "
\n"; echo "

\n"; echo ""; echo "$group_desc\n"; echo "\n"; echo "

\n"; echo "\n"; echo "

\n"; echo ""; echo $long_description; echo "\n"; if( $source != "" ) { echo ""; echo "Photograph by " . $source; echo "\n"; } echo "

\n"; echo "
\n"; } } DrawFooter(); %>