author | Dan |
Thu, 26 Jul 2007 12:39:29 -0400 | |
changeset 6 | 6c753cf22ee8 |
parent 4 | ad3b061a1c76 |
child 9 | ebd7003e73c6 |
permissions | -rw-r--r-- |
0
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
1 |
<?php |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
2 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
3 |
/* |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
4 |
* Snapr |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
5 |
* Version 0.1 beta 1 |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
6 |
* Copyright (C) 2007 Dan Fuhry |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
7 |
* |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
8 |
* This program is Free Software; you can redistribute and/or modify it under the terms of the GNU General Public License |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
9 |
* as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
10 |
* |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
11 |
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
12 |
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
13 |
*/ |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
14 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
15 |
## |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
16 |
## BROWSER INTERFACE |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
17 |
## |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
18 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
19 |
$plugins->attachHook('base_classes_initted', ' |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
20 |
global $paths; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
21 |
$paths->add_page(Array( |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
22 |
\'name\'=>\'Image gallery\', |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
23 |
\'urlname\'=>\'Gallery\', |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
24 |
\'namespace\'=>\'Special\', |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
25 |
\'special\'=>0,\'visible\'=>1,\'comments_on\'=>0,\'protected\'=>1,\'delvotes\'=>0,\'delvote_ips\'=>\'\', |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
26 |
)); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
27 |
'); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
28 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
29 |
/** |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
30 |
* Class to handle building the HTML for gallery pages. Called by the pagination function. |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
31 |
* @package Enano |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
32 |
* @subpackage Snapr |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
33 |
* @access private |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
34 |
*/ |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
35 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
36 |
class SnaprFormatter |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
37 |
{ |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
38 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
39 |
/** |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
40 |
* Counter for how many cells we've printed out in this row. |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
41 |
* @var int |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
42 |
*/ |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
43 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
44 |
var $cell_count = 0; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
45 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
46 |
/** |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
47 |
* Icons to print per row. |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
48 |
* @var int |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
49 |
*/ |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
50 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
51 |
var $icons_per_row = 5; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
52 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
53 |
/** |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
54 |
* Main render method, called from pagination function |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
55 |
* @access private |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
56 |
*/ |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
57 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
58 |
function render($column_crap, $row, $row_crap) |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
59 |
{ |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
60 |
global $db, $session, $paths, $template, $plugins; // Common objects |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
61 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
62 |
$out = ''; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
63 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
64 |
if ( $this->cell_count == $this->icons_per_row ) |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
65 |
{ |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
66 |
$out .= '</tr><tr>'; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
67 |
$this->cell_count = 0; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
68 |
} |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
69 |
$this->cell_count++; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
70 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
71 |
$title_safe = $row['img_title']; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
72 |
$title_safe = htmlspecialchars($title_safe); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
73 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
74 |
if ( $row['is_folder'] == 1 ) |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
75 |
{ |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
76 |
// It's a folder, show the icon |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
77 |
$f_url_particle = sanitize_page_id($row['img_title']); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
78 |
$f_url_particle = htmlspecialchars($f_url_particle); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
79 |
$image_link = makeUrl( $paths->fullpage . '/' . $f_url_particle ); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
80 |
$image_url = scriptPath . '/plugins/gallery/folder.png'; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
81 |
} |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
82 |
else |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
83 |
{ |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
84 |
// It's an image, show a thumbnail |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
85 |
$image_link = makeUrlNS('Gallery', $row['img_id']); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
86 |
$image_url = makeUrlNS('Special', 'GalleryFetcher/thumb/' . $row['img_id']); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
87 |
} |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
88 |
|
4 | 89 |
if ( isset($row['score']) ) |
90 |
{ |
|
91 |
$row['score'] = number_format($row['score'], 2); |
|
92 |
} |
|
93 |
||
0
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
94 |
$image_url_js = addslashes($image_link); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
95 |
$jsclick = ( $session->user_level < USER_LEVEL_ADMIN ) ? ' onclick="window.location=\'' . $image_url_js . '\'"' : ''; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
96 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
97 |
$out .= '<td style="text-align: center;"> |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
98 |
<div class="gallery_icon"' . $jsclick . '>'; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
99 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
100 |
$out .= '<a href="' . $image_link . '"><img alt="<Thumbnail>" class="gallery_thumb" src="' . $image_url . '" /></a>'; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
101 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
102 |
if ( $session->user_level < USER_LEVEL_ADMIN ) |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
103 |
{ |
4 | 104 |
$out .= $title_safe . ( isset($row['score']) ? "<br /><small>Relevance: {$row['score']}</small>" : '' ); |
0
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
105 |
} |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
106 |
else if ( $session->user_level >= USER_LEVEL_ADMIN ) |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
107 |
{ |
4 | 108 |
$out .= '<div class="menu_nojs" style="text-align: center;"><a href="#" onclick="return false;" style="width: 74px;">' . $title_safe . ( isset($row['score']) ? "<br /><small>Relevance: {$row['score']}</small>" : '' ) . '</a>'; |
0
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
109 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
110 |
$url_delete = makeUrlNS('Special', 'GalleryUpload', 'rm=' . $row['img_id'], true); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
111 |
$url_edit = makeUrlNS('Special', 'GalleryUpload', 'edit_img=' . $row['img_id'], true); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
112 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
113 |
// Tools menu |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
114 |
$out .= '<ul style="text-align: left;">'; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
115 |
$out .= '<li><a href="' . $url_delete . '">Delete ' . ( $row['is_folder'] == 1 ? 'this folder and all contents' : 'this image' ) . '</a></li>'; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
116 |
$out .= '<li><a href="' . $url_edit . '">Rename, move, or edit description</a></li>'; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
117 |
$out .= '</ul>'; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
118 |
$out .= '</div>'; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
119 |
$out .= '<span class="menuclear"></span>'; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
120 |
} |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
121 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
122 |
$out .= ' </div>'; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
123 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
124 |
$out .= '</td>'; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
125 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
126 |
return $out; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
127 |
} |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
128 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
129 |
} |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
130 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
131 |
function page_Special_Gallery() |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
132 |
{ |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
133 |
global $db, $session, $paths, $template, $plugins; // Common objects |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
134 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
135 |
// die('<pre>' . print_r(gallery_folder_hierarchy(), true) . '</pre>'); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
136 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
137 |
$sort_column = ( isset($_GET['sort']) && in_array($_GET['sort'], array('img_title', 'img_time_upload', 'img_time_mod')) ) ? $_GET['sort'] : 'img_title'; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
138 |
$sort_order = ( isset($_GET['order']) && in_array($_GET['order'], array('ASC', 'DESC')) ) ? $_GET['order'] : 'ASC'; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
139 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
140 |
// Determine number of pictures per page |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
141 |
$template->load_theme(); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
142 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
143 |
global $theme; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
144 |
$fn = ENANO_ROOT . '/themes/' . $template->theme . '/theme.cfg'; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
145 |
require( $fn ); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
146 |
if ( isset($theme['snapr_gallery_rows']) ) |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
147 |
{ |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
148 |
$rows_in_browser = intval($theme['snapr_gallery_rows']); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
149 |
if ( empty($rows_in_browser) ) |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
150 |
{ |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
151 |
$rows_in_browser = 5; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
152 |
} |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
153 |
} |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
154 |
else |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
155 |
{ |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
156 |
$rows_in_browser = 5; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
157 |
} |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
158 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
159 |
$where = 'WHERE folder_parent IS NULL ' . "\n ORDER BY is_folder DESC, $sort_column $sort_order, img_title ASC"; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
160 |
$parms = $paths->getAllParams(); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
161 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
162 |
$sql = "SELECT img_id, img_title, is_folder FROM ".table_prefix."gallery $where;"; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
163 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
164 |
// Breadcrumb browser |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
165 |
$breadcrumbs = array(); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
166 |
$breadcrumbs[] = '<a href="' . makeUrlNS('Special', 'Gallery') . '">Gallery index</a>'; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
167 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
168 |
$breadcrumb_urlcache = ''; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
169 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
170 |
// CSS for gallery browser |
2
88c954d2846c
Added search functionality (WiP); removed stray .marks file
Dan
parents:
0
diff
changeset
|
171 |
// Moved to search.php |
88c954d2846c
Added search functionality (WiP); removed stray .marks file
Dan
parents:
0
diff
changeset
|
172 |
//$template->add_header('<link rel="stylesheet" href="' . scriptPath . '/plugins/gallery/browser.css" type="text/css" />'); |
88c954d2846c
Added search functionality (WiP); removed stray .marks file
Dan
parents:
0
diff
changeset
|
173 |
//$template->add_header('<link rel="stylesheet" href="' . scriptPath . '/plugins/gallery/dropdown.css" type="text/css" />'); |
0
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
174 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
175 |
$header = $template->getHeader(); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
176 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
177 |
if ( !empty($parms) ) |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
178 |
{ |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
179 |
$parms = dirtify_page_id($parms); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
180 |
if ( strstr($parms, '/') ) |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
181 |
{ |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
182 |
$folders = explode('/', $parms); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
183 |
} |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
184 |
else |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
185 |
{ |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
186 |
$folders = array(0 => $parms); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
187 |
} |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
188 |
foreach ( $folders as $i => $_crap ) |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
189 |
{ |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
190 |
$folder =& $folders[$i]; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
191 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
192 |
$f_url = sanitize_page_id($folder); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
193 |
$breadcrumb_urlcache .= '/' . $f_url; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
194 |
$breadcrumb_url = makeUrlNS('Special', 'Gallery' . $breadcrumb_urlcache); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
195 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
196 |
$folder = str_replace('_', ' ', $folder); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
197 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
198 |
if ( $i == ( count($folders) - 1 ) ) |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
199 |
{ |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
200 |
$breadcrumbs[] = htmlspecialchars($folder); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
201 |
} |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
202 |
else |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
203 |
{ |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
204 |
$breadcrumbs[] = '<a href="' . $breadcrumb_url . '">' . htmlspecialchars($folder) . '</a>'; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
205 |
} |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
206 |
} |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
207 |
unset($folder); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
208 |
$folders = array_reverse($folders); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
209 |
// 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 |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
210 |
$sql = 'SELECT gm.img_id, gm.img_title, gm.is_folder, g0.img_title AS folder_name, g0.img_id AS folder_id FROM '.table_prefix.'gallery AS gm' . "\n " . 'LEFT JOIN '.table_prefix.'gallery AS g0' . "\n " . 'ON ( gm.folder_parent = g0.img_id )'; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
211 |
$where = "\n " . 'WHERE g0.img_title=\'' . $db->escape($folders[0]) . '\''; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
212 |
foreach ( $folders as $i => $folder ) |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
213 |
{ |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
214 |
if ( $i == 0 ) |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
215 |
continue; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
216 |
$i_dec = $i - 1; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
217 |
$folder = $db->escape($folder); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
218 |
$sql .= "\n LEFT JOIN ".table_prefix."gallery AS g{$i}\n ON ( g{$i}.img_id=g{$i_dec}.folder_parent AND g{$i}.img_title='$folder' )"; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
219 |
$where .= "\n ".'AND g'.$i.'.img_id IS NOT NULL'; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
220 |
} |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
221 |
$where .= "\n AND g{$i}.folder_parent IS NULL"; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
222 |
$sql .= $where . "\n ORDER BY is_folder DESC, gm.$sort_column $sort_order, gm.img_title ASC" . ';'; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
223 |
} |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
224 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
225 |
$img_query = $db->sql_query($sql); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
226 |
if ( !$img_query ) |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
227 |
$db->_die('The folder ID could not be selected.'); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
228 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
229 |
if ( $db->numrows() < 1 ) |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
230 |
{ |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
231 |
// Nothing in this folder, for one of two reasons: |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
232 |
// 1) The folder doesn't exist |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
233 |
// 2) The folder exists but doesn't have any images in it |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
234 |
|
2
88c954d2846c
Added search functionality (WiP); removed stray .marks file
Dan
parents:
0
diff
changeset
|
235 |
if ( sizeof($folders) < 1 ) |
88c954d2846c
Added search functionality (WiP); removed stray .marks file
Dan
parents:
0
diff
changeset
|
236 |
{ |
88c954d2846c
Added search functionality (WiP); removed stray .marks file
Dan
parents:
0
diff
changeset
|
237 |
// Nothing in the root folder |
88c954d2846c
Added search functionality (WiP); removed stray .marks file
Dan
parents:
0
diff
changeset
|
238 |
|
88c954d2846c
Added search functionality (WiP); removed stray .marks file
Dan
parents:
0
diff
changeset
|
239 |
$first_row['folder_id'] = 'NULL'; |
88c954d2846c
Added search functionality (WiP); removed stray .marks file
Dan
parents:
0
diff
changeset
|
240 |
if ( $session->user_level >= USER_LEVEL_ADMIN && isset($_POST['create_folder']) && isset($first_row['folder_id']) ) |
88c954d2846c
Added search functionality (WiP); removed stray .marks file
Dan
parents:
0
diff
changeset
|
241 |
{ |
88c954d2846c
Added search functionality (WiP); removed stray .marks file
Dan
parents:
0
diff
changeset
|
242 |
if ( empty($_POST['create_folder']) ) |
88c954d2846c
Added search functionality (WiP); removed stray .marks file
Dan
parents:
0
diff
changeset
|
243 |
{ |
88c954d2846c
Added search functionality (WiP); removed stray .marks file
Dan
parents:
0
diff
changeset
|
244 |
$f_errors[] = 'Please enter a folder name.'; |
88c954d2846c
Added search functionality (WiP); removed stray .marks file
Dan
parents:
0
diff
changeset
|
245 |
} |
88c954d2846c
Added search functionality (WiP); removed stray .marks file
Dan
parents:
0
diff
changeset
|
246 |
if ( $_POST['create_folder'] == '_id' ) |
88c954d2846c
Added search functionality (WiP); removed stray .marks file
Dan
parents:
0
diff
changeset
|
247 |
{ |
88c954d2846c
Added search functionality (WiP); removed stray .marks file
Dan
parents:
0
diff
changeset
|
248 |
$f_errors[] = 'The name "_id" is reserved for internal functions and cannot be used on any image or folder.'; |
88c954d2846c
Added search functionality (WiP); removed stray .marks file
Dan
parents:
0
diff
changeset
|
249 |
} |
88c954d2846c
Added search functionality (WiP); removed stray .marks file
Dan
parents:
0
diff
changeset
|
250 |
if ( count($f_errors) < 1 ) |
88c954d2846c
Added search functionality (WiP); removed stray .marks file
Dan
parents:
0
diff
changeset
|
251 |
{ |
88c954d2846c
Added search functionality (WiP); removed stray .marks file
Dan
parents:
0
diff
changeset
|
252 |
$q = $db->sql_query('INSERT INTO '.table_prefix.'gallery(img_title, is_folder, folder_parent) VALUES(\'' . $db->escape($_POST['create_folder']) . '\', 1, ' . $first_row['folder_id'] . ');'); |
88c954d2846c
Added search functionality (WiP); removed stray .marks file
Dan
parents:
0
diff
changeset
|
253 |
if ( !$q ) |
88c954d2846c
Added search functionality (WiP); removed stray .marks file
Dan
parents:
0
diff
changeset
|
254 |
$db->_die(); |
88c954d2846c
Added search functionality (WiP); removed stray .marks file
Dan
parents:
0
diff
changeset
|
255 |
redirect(makeUrl($paths->fullpage), 'Folder created', 'The folder "' . htmlspecialchars($_POST['create_folder']) . '" has been created. Redirecting to last viewed folder...', 2); |
88c954d2846c
Added search functionality (WiP); removed stray .marks file
Dan
parents:
0
diff
changeset
|
256 |
} |
88c954d2846c
Added search functionality (WiP); removed stray .marks file
Dan
parents:
0
diff
changeset
|
257 |
} |
88c954d2846c
Added search functionality (WiP); removed stray .marks file
Dan
parents:
0
diff
changeset
|
258 |
|
88c954d2846c
Added search functionality (WiP); removed stray .marks file
Dan
parents:
0
diff
changeset
|
259 |
$html = ''; |
88c954d2846c
Added search functionality (WiP); removed stray .marks file
Dan
parents:
0
diff
changeset
|
260 |
if ( $session->user_level >= USER_LEVEL_ADMIN ) |
88c954d2846c
Added search functionality (WiP); removed stray .marks file
Dan
parents:
0
diff
changeset
|
261 |
{ |
88c954d2846c
Added search functionality (WiP); removed stray .marks file
Dan
parents:
0
diff
changeset
|
262 |
$html .= '<p><a href="' . makeUrlNS('Special', 'GalleryUpload') . '">Upload an image</a></p>'; |
88c954d2846c
Added search functionality (WiP); removed stray .marks file
Dan
parents:
0
diff
changeset
|
263 |
$html .= '<div class="select-outer">Create new folder'; |
88c954d2846c
Added search functionality (WiP); removed stray .marks file
Dan
parents:
0
diff
changeset
|
264 |
$html .= '<div class="select-inner" style="padding-top: 4px;">'; |
88c954d2846c
Added search functionality (WiP); removed stray .marks file
Dan
parents:
0
diff
changeset
|
265 |
$html .= '<form action="' . makeUrl($paths->fullpage) . '" method="post">'; |
88c954d2846c
Added search functionality (WiP); removed stray .marks file
Dan
parents:
0
diff
changeset
|
266 |
$html .= '<input type="text" name="create_folder" size="30" /> <input type="submit" value="Create" />'; |
88c954d2846c
Added search functionality (WiP); removed stray .marks file
Dan
parents:
0
diff
changeset
|
267 |
$html .= '</form></div>'; |
88c954d2846c
Added search functionality (WiP); removed stray .marks file
Dan
parents:
0
diff
changeset
|
268 |
$html .= '</div><div class="select-pad"> </div><br />'; |
88c954d2846c
Added search functionality (WiP); removed stray .marks file
Dan
parents:
0
diff
changeset
|
269 |
} |
88c954d2846c
Added search functionality (WiP); removed stray .marks file
Dan
parents:
0
diff
changeset
|
270 |
|
88c954d2846c
Added search functionality (WiP); removed stray .marks file
Dan
parents:
0
diff
changeset
|
271 |
die_friendly('No images', '<p>No images have been uploaded to the gallery yet.</p>' . $html); |
88c954d2846c
Added search functionality (WiP); removed stray .marks file
Dan
parents:
0
diff
changeset
|
272 |
} |
88c954d2846c
Added search functionality (WiP); removed stray .marks file
Dan
parents:
0
diff
changeset
|
273 |
|
0
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
274 |
/* |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
275 |
$folders_old = $folders; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
276 |
$folders = array( |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
277 |
0 => $folders_old[0] |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
278 |
); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
279 |
$x = $folders_old; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
280 |
unset($x[0]); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
281 |
$folders = array_merge($folders, $x); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
282 |
unset($x); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
283 |
*/ |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
284 |
// die('<pre>' . print_r($folders, true) . '</pre>'); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
285 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
286 |
// This next query will try to determine if the folder itself exists |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
287 |
$sql = 'SELECT g0.img_id, g0.img_title FROM '.table_prefix.'gallery AS g0'; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
288 |
$where = "\n " . 'WHERE g0.img_title=\'' . $db->escape($folders[0]) . '\''; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
289 |
foreach ( $folders as $i => $folder ) |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
290 |
{ |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
291 |
if ( $i == 0 ) |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
292 |
continue; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
293 |
$i_dec = $i - 1; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
294 |
$folder = $db->escape($folder); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
295 |
$sql .= "\n LEFT JOIN ".table_prefix."gallery AS g{$i}\n ON ( g{$i}.img_id=g{$i_dec}.folder_parent AND g{$i}.img_title='$folder' )"; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
296 |
$where .= "\n ".'AND g'.$i.'.img_id IS NOT NULL'; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
297 |
} |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
298 |
$where .= "\n AND g{$i}.folder_parent IS NULL"; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
299 |
$where .= "\n AND g0.is_folder=1"; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
300 |
$sql .= $where . ';'; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
301 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
302 |
$nameq = $db->sql_query($sql); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
303 |
if ( !$nameq ) |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
304 |
$db->_die(); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
305 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
306 |
if ( $db->numrows($nameq) < 1 ) |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
307 |
{ |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
308 |
die_friendly('Folder not found', '<p>The folder you requested doesn\'t exist. Please check the URL and try again, or return to the <a href="' . makeUrlNS('Special', 'Gallery') . '">gallery index</a>.</p>'); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
309 |
} |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
310 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
311 |
$row = $db->fetchrow($nameq); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
312 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
313 |
// Generate title |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
314 |
$title = dirtify_page_id($row['img_title']); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
315 |
$title = str_replace('_', ' ', $title); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
316 |
$title = htmlspecialchars($title); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
317 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
318 |
$template->tpl_strings['PAGE_NAME'] = $title; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
319 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
320 |
$first_row = $row; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
321 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
322 |
$db->sql_data_seek(0, $img_query); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
323 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
324 |
/* $folders = $folders_old; */ |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
325 |
} |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
326 |
else if ( !empty($parms) ) |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
327 |
{ |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
328 |
$row = $db->fetchrow($img_query); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
329 |
$first_row = $row; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
330 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
331 |
// Generate title |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
332 |
$title = htmlspecialchars($row['folder_name']); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
333 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
334 |
$template->tpl_strings['PAGE_NAME'] = $title; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
335 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
336 |
$db->sql_data_seek(0, $img_query); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
337 |
} |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
338 |
else |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
339 |
{ |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
340 |
$row = $db->fetchrow($img_query); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
341 |
$first_row = $row; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
342 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
343 |
$template->tpl_strings['PAGE_NAME'] = 'Image Gallery'; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
344 |
$breadcrumbs = array('<b>Gallery index</b>'); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
345 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
346 |
$db->sql_data_seek(0, $img_query); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
347 |
} |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
348 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
349 |
$f_errors = array(); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
350 |
|
2
88c954d2846c
Added search functionality (WiP); removed stray .marks file
Dan
parents:
0
diff
changeset
|
351 |
if ( $session->user_level >= USER_LEVEL_ADMIN && isset($_POST['create_folder']) ) |
0
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
352 |
{ |
2
88c954d2846c
Added search functionality (WiP); removed stray .marks file
Dan
parents:
0
diff
changeset
|
353 |
if ( !isset($first_row['folder_id']) ) |
88c954d2846c
Added search functionality (WiP); removed stray .marks file
Dan
parents:
0
diff
changeset
|
354 |
{ |
88c954d2846c
Added search functionality (WiP); removed stray .marks file
Dan
parents:
0
diff
changeset
|
355 |
$first_row['folder_id'] =& $first_row['img_id']; |
88c954d2846c
Added search functionality (WiP); removed stray .marks file
Dan
parents:
0
diff
changeset
|
356 |
} |
88c954d2846c
Added search functionality (WiP); removed stray .marks file
Dan
parents:
0
diff
changeset
|
357 |
if ( !isset($first_row['folder_id']) ) |
88c954d2846c
Added search functionality (WiP); removed stray .marks file
Dan
parents:
0
diff
changeset
|
358 |
{ |
88c954d2846c
Added search functionality (WiP); removed stray .marks file
Dan
parents:
0
diff
changeset
|
359 |
$f_errors[] = 'Internal error getting parent folder ID'; |
88c954d2846c
Added search functionality (WiP); removed stray .marks file
Dan
parents:
0
diff
changeset
|
360 |
} |
0
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
361 |
if ( empty($_POST['create_folder']) ) |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
362 |
{ |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
363 |
$f_errors[] = 'Please enter a folder name.'; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
364 |
} |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
365 |
if ( $_POST['create_folder'] == '_id' ) |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
366 |
{ |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
367 |
$f_errors[] = 'The name "_id" is reserved for internal functions and cannot be used on any image or folder.'; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
368 |
} |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
369 |
if ( count($f_errors) < 1 ) |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
370 |
{ |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
371 |
$q = $db->sql_query('INSERT INTO '.table_prefix.'gallery(img_title, is_folder, folder_parent) VALUES(\'' . $db->escape($_POST['create_folder']) . '\', 1, ' . $first_row['folder_id'] . ');'); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
372 |
if ( !$q ) |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
373 |
$db->_die(); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
374 |
redirect(makeUrl($paths->fullpage), 'Folder created', 'The folder "' . htmlspecialchars($_POST['create_folder']) . '" has been created. Redirecting to last viewed folder...', 2); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
375 |
} |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
376 |
} |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
377 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
378 |
echo $header; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
379 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
380 |
if ( count($f_errors) > 0 ) |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
381 |
{ |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
382 |
echo '<div class="error-box">Error creating folder:<ul><li>' . implode('</li><li>', $f_errors) . '</li></ul></div>'; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
383 |
} |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
384 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
385 |
// From here, this breadcrumb stuff is a piece of... sourdough French bread :-) *smacks lips* |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
386 |
echo '<div class="tblholder" style="padding: 4px; margin-bottom: 7px;">'; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
387 |
// Upload image link for admins |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
388 |
if ( $session->user_level >= USER_LEVEL_ADMIN ) |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
389 |
{ |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
390 |
echo '<div style="float: right; font-size: smaller;">'; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
391 |
echo '<b><a href="' . makeUrlNS('Special', 'GalleryUpload') . '">Upload new image(s)</a></b>'; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
392 |
echo '</div>'; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
393 |
} |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
394 |
// The actual breadcrumbs |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
395 |
echo '<b><small>' . implode(' » ', $breadcrumbs) . '</small></b>'; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
396 |
echo '</div>'; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
397 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
398 |
// "Edit all" link |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
399 |
if ( $row = $db->fetchrow($img_query) && $session->user_level >= USER_LEVEL_ADMIN ) |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
400 |
{ |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
401 |
$img_list = array(); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
402 |
$fol_list = array(); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
403 |
$all_list = array(); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
404 |
do |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
405 |
{ |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
406 |
if ( $row === true && isset($first_row) ) |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
407 |
{ |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
408 |
$row = $first_row; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
409 |
} |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
410 |
// die('<pre>' . var_dump($row) . $db->sql_backtrace() . '</pre>'); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
411 |
if ( !$row['img_id'] ) |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
412 |
break; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
413 |
$all_list[] = $row['img_id']; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
414 |
if ( $row['is_folder'] == 1 ) |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
415 |
$fol_list[] = $row['img_id']; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
416 |
else |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
417 |
$img_list[] = $row['img_id']; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
418 |
} |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
419 |
while ( $row = $db->fetchrow($img_query) ); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
420 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
421 |
$all_list = implode(',', $all_list); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
422 |
$fol_list = implode(',', $fol_list); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
423 |
$img_list = implode(',', $img_list); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
424 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
425 |
if ( !empty($all_list) ) |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
426 |
{ |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
427 |
echo '<div style="float: right;"> |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
428 |
Edit all in this folder: '; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
429 |
if ( !empty($img_list) ) |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
430 |
{ |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
431 |
$edit_link = makeUrlNS('Special', 'GalleryUpload', 'edit_img=' . $img_list, true); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
432 |
echo "<a href=\"$edit_link\">images</a> "; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
433 |
} |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
434 |
if ( !empty($fol_list) ) |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
435 |
{ |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
436 |
$edit_link = makeUrlNS('Special', 'GalleryUpload', 'edit_img=' . $fol_list, true); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
437 |
echo "<a href=\"$edit_link\">folders</a> "; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
438 |
} |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
439 |
if ( !empty($img_list) && !empty($fol_list) ) |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
440 |
{ |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
441 |
$edit_link = makeUrlNS('Special', 'GalleryUpload', 'edit_img=' . $all_list, true); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
442 |
echo "<a href=\"$edit_link\">both</a> "; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
443 |
} |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
444 |
// " Bypass stupid jEdit bug |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
445 |
echo '</div>'; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
446 |
} |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
447 |
} |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
448 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
449 |
$url_sort_name_asc = makeUrl($paths->fullpage, 'sort=img_title&order=ASC', true); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
450 |
$url_sort_name_desc = makeUrl($paths->fullpage, 'sort=img_title&order=DESC', true); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
451 |
$url_sort_upl_asc = makeUrl($paths->fullpage, 'sort=img_time_upload&order=ASC', true); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
452 |
$url_sort_mod_asc = makeUrl($paths->fullpage, 'sort=img_time_mod&order=ASC', true); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
453 |
$url_sort_upl_desc = makeUrl($paths->fullpage, 'sort=img_time_upload&order=DESC', true); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
454 |
$url_sort_mod_desc = makeUrl($paths->fullpage, 'sort=img_time_mod&order=DESC', true); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
455 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
456 |
// "Sort by" selector (pure CSS!) |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
457 |
echo '<div class="select-outer"> |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
458 |
<span>Sort by...</span> |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
459 |
<div class="select-inner"> |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
460 |
<a href="' . $url_sort_name_asc . '">Image title (A-Z) <b>(default)</b></a> |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
461 |
<a href="' . $url_sort_name_desc . '">Image title (Z-A)</a> |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
462 |
<a href="' . $url_sort_upl_desc . '">Time first uploaded (newest first)</a> |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
463 |
<a href="' . $url_sort_upl_asc . '">Time first uploaded (oldest first)</a> |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
464 |
<a href="' . $url_sort_mod_desc . '">Date of last modification (newest first)</a> |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
465 |
<a href="' . $url_sort_mod_asc . '">Date of last modification (oldest first)</a> |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
466 |
</div> |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
467 |
</div> |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
468 |
<div class="select-pad"> </div>'; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
469 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
470 |
$db->sql_data_seek(0, $img_query); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
471 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
472 |
// |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
473 |
// Main fetcher |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
474 |
// |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
475 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
476 |
$renderer = new SnaprFormatter(); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
477 |
$callers = array( |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
478 |
'img_id' => array($renderer, 'render') |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
479 |
); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
480 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
481 |
$renderer->icons_per_row = $rows_in_browser; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
482 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
483 |
$start = 0; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
484 |
if ( isset($_GET['start']) && preg_match('/^[0-9]+$/', $_GET['start']) ) |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
485 |
{ |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
486 |
$start = intval($_GET['start']); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
487 |
} |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
488 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
489 |
$per_page = $rows_in_browser * 5; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
490 |
|
2
88c954d2846c
Added search functionality (WiP); removed stray .marks file
Dan
parents:
0
diff
changeset
|
491 |
$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, '<table border="0" cellspacing="8"><tr>', '</tr></table>'); |
0
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
492 |
echo $html; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
493 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
494 |
if ( $session->user_level >= USER_LEVEL_ADMIN ) |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
495 |
{ |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
496 |
echo '<div class="select-outer">Create new folder'; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
497 |
echo '<div class="select-inner" style="padding-top: 4px;">'; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
498 |
echo '<form action="' . makeUrl($paths->fullpage) . '" method="post">'; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
499 |
echo '<input type="text" name="create_folder" size="30" /> <input type="submit" value="Create" />'; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
500 |
echo '</form></div>'; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
501 |
echo '</div><div class="select-pad"> </div><br />'; |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
502 |
} |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
503 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
504 |
$template->footer(); |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
505 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
506 |
} |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
507 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
508 |
?> |