# HG changeset patch # User Dan # Date 1186677084 14400 # Node ID ebd7003e73c6151b66f5b015ee17ace4ad12c2e9 # Parent 8490ce0cdd8c9c1018e0150443cc7087af5ec840 Snapr now works with Enano's HTML/gzip optimization switches (1.0 compatibility broken, need 1.0.1 now) diff -r 8490ce0cdd8c -r ebd7003e73c6 plugins/Gallery.php diff -r 8490ce0cdd8c -r ebd7003e73c6 plugins/gallery/browser.php --- a/plugins/gallery/browser.php Thu Jul 26 14:43:45 2007 -0400 +++ b/plugins/gallery/browser.php Thu Aug 09 12:31:24 2007 -0400 @@ -352,7 +352,8 @@ { if ( !isset($first_row['folder_id']) ) { - $first_row['folder_id'] =& $first_row['img_id']; + // $first_row['folder_id'] =& $first_row['img_id']; + $first_row['folder_id'] = 'NULL'; } if ( !isset($first_row['folder_id']) ) { @@ -488,8 +489,21 @@ $per_page = $rows_in_browser * 5; - $html = paginate($img_query, '{img_id}', $db->numrows($img_query), makeUrl($paths->fullpage, 'sort=' . $sort_column . '&order=' . $sort_order . '&start=%s', true), $start, $per_page, $callers, '', '
'); - echo $html; + if ( $db->numrows($img_query) < 1 ) + { + $html = ''; + if ( $session->user_level >= USER_LEVEL_ADMIN ) + { + $html .= '

Upload an image

'; + } + + echo '

There are no items in this folder.

' . $html; + } + else + { + $html = paginate($img_query, '{img_id}', $db->numrows($img_query), makeUrl($paths->fullpage, 'sort=' . $sort_column . '&order=' . $sort_order . '&start=%s', true), $start, $per_page, $callers, '', '
'); + echo $html; + } if ( $session->user_level >= USER_LEVEL_ADMIN ) { diff -r 8490ce0cdd8c -r ebd7003e73c6 plugins/gallery/fetcher.php --- a/plugins/gallery/fetcher.php Thu Jul 26 14:43:45 2007 -0400 +++ b/plugins/gallery/fetcher.php Thu Aug 09 12:31:24 2007 -0400 @@ -50,7 +50,7 @@ $type = 'preview'; } - $q = $db->sql_query('SELECT img_filename, img_time_mod, is_folder FROM '.table_prefix.'gallery WHERE img_id=' . $id . ';'); + $q = $db->sql_query('SELECT img_title, img_filename, img_time_mod, is_folder FROM '.table_prefix.'gallery WHERE img_id=' . $id . ';'); if ( !$q ) $db->_die(); @@ -64,10 +64,12 @@ case 'thumb': $filename = ENANO_ROOT . '/cache/' . $row['img_filename'] . '-thumb.jpg'; $mimetype = 'image/jpeg'; + $ext = "jpg"; break; case 'preview': $filename = ENANO_ROOT . '/cache/' . $row['img_filename'] . '-preview.jpg'; $mimetype = 'image/jpeg'; + $ext = "jpg"; break; case 'full': $filename = ENANO_ROOT . '/files/' . $row['img_filename']; @@ -109,8 +111,23 @@ header('Content-length: ' . strlen($contents)); header('Last-Modified: ' . date('r', $row['img_time_mod'])); + if ( isset($_GET['download']) ) + { + // determine an appropriate non-revealing filename + $filename = str_replace(' ', '_', $row['img_title']); + $filename = preg_replace('/([^\w\._-]+)/', '-', $filename); + $filename = trim($filename, '-'); + $filename .= ".$ext"; + header('Content-disposition: attachment; filename=' . $filename); + } + echo $contents; + gzip_output(); + + $db->close(); + exit; + } ?> diff -r 8490ce0cdd8c -r ebd7003e73c6 plugins/gallery/viewimage.php --- a/plugins/gallery/viewimage.php Thu Jul 26 14:43:45 2007 -0400 +++ b/plugins/gallery/viewimage.php Thu Aug 09 12:31:24 2007 -0400 @@ -36,7 +36,7 @@ $img_id = intval($page->page_id); if ( !$img_id ) return false; - $q = $db->sql_query('SELECT img_id, img_title, img_desc, print_sizes, img_time_upload, img_time_mod, folder_parent FROM '.table_prefix.'gallery WHERE img_id=' . $img_id . ';'); + $q = $db->sql_query('SELECT img_id, img_title, img_desc, print_sizes, img_time_upload, img_time_mod, img_filename, folder_parent FROM '.table_prefix.'gallery WHERE img_id=' . $img_id . ';'); if ( !$q ) $db->_die(); } @@ -61,7 +61,7 @@ $folders = array_reverse($folders); // This is one of the best MySQL tricks on the market. We're going to reverse-travel a folder path using LEFT JOIN and the incredible power of metacoded SQL - $sql = 'SELECT g0.img_id, g0.img_title, g0.img_desc, g0.print_sizes, g0.img_time_upload, g0.img_time_mod, g0.folder_parent FROM '.table_prefix.'gallery AS g0'; + $sql = 'SELECT g0.img_id, g0.img_title, g0.img_desc, g0.print_sizes, g0.img_time_upload, g0.img_time_mod, g0.img_filename, g0.folder_parent FROM '.table_prefix.'gallery AS g0'; $where = "\n " . 'WHERE g0.img_title=\'' . $db->escape($folders[0]) . '\''; foreach ( $folders as $i => $folder ) { @@ -257,9 +257,14 @@ // By the time I got to this point, it was 1:32AM (I was on vacation) and my 5-hour playlist on my iPod had been around about 3 times today. // So I'm glad this is like the last thing on the list tonight. + $ext = get_file_extension($row['img_filename']); + $ext = strtoupper($ext); + echo 'Image details'; echo 'Uploaded:' . date('F d, Y h:i a', $row['img_time_upload']) . ''; echo 'Last modified:' . date('F d, Y h:i a', $row['img_time_mod']) . ''; + echo 'Original format:' . $ext . ''; + echo 'Download image'; echo '';