6 |
kaklik |
1 |
<?php
|
|
|
2 |
/*************************
|
|
|
3 |
Coppermine Photo Gallery
|
|
|
4 |
************************
|
|
|
5 |
Copyright (c) 2003-2005 Coppermine Dev Team
|
|
|
6 |
v1.1 originaly written by Gregory DEMAR
|
|
|
7 |
|
|
|
8 |
This program is free software; you can redistribute it and/or modify
|
|
|
9 |
it under the terms of the GNU General Public License as published by
|
|
|
10 |
the Free Software Foundation; either version 2 of the License, or
|
|
|
11 |
(at your option) any later version.
|
|
|
12 |
********************************************
|
|
|
13 |
Coppermine version: 1.3.3
|
|
|
14 |
$Source: /cvsroot/coppermine/stable/editpics.php,v $
|
|
|
15 |
$Revision: 1.8 $
|
|
|
16 |
$Author: gaugau $
|
|
|
17 |
$Date: 2005/04/19 03:17:10 $
|
|
|
18 |
**********************************************/
|
|
|
19 |
|
|
|
20 |
define('IN_COPPERMINE', true);
|
|
|
21 |
define('EDITPICS_PHP', true);
|
|
|
22 |
|
|
|
23 |
require('include/init.inc.php');
|
|
|
24 |
|
|
|
25 |
if (!(GALLERY_ADMIN_MODE || USER_ADMIN_MODE)) cpg_die(ERROR, $lang_errors['access_denied'], __FILE__, __LINE__);
|
|
|
26 |
|
|
|
27 |
define('UPLOAD_APPROVAL_MODE', isset($HTTP_GET_VARS['mode']));
|
|
|
28 |
define('EDIT_PICTURES_MODE', !isset($HTTP_GET_VARS['mode']));
|
|
|
29 |
|
|
|
30 |
if (isset($HTTP_GET_VARS['album'])) {
|
|
|
31 |
$album_id = (int)$HTTP_GET_VARS['album'];
|
|
|
32 |
} elseif (isset($HTTP_GET_VARS['album'])) {
|
|
|
33 |
$album_id = (int)$HTTP_POST_VARS['album'];
|
|
|
34 |
} else {
|
|
|
35 |
$album_id = -1;
|
|
|
36 |
}
|
|
|
37 |
|
|
|
38 |
if (UPLOAD_APPROVAL_MODE && !GALLERY_ADMIN_MODE) cpg_die(ERROR, $lang_errors['access_denied'], __FILE__, __LINE__);
|
|
|
39 |
|
|
|
40 |
if (EDIT_PICTURES_MODE) {
|
|
|
41 |
$result = db_query("SELECT title, category FROM {$CONFIG['TABLE_ALBUMS']} WHERE aid = '$album_id'");
|
|
|
42 |
if (!mysql_num_rows($result)) cpg_die(CRITICAL_ERROR, $lang_errors['non_exist_ap'], __FILE__, __LINE__);
|
|
|
43 |
$ALBUM_DATA=mysql_fetch_array($result);
|
|
|
44 |
mysql_free_result($result);
|
|
|
45 |
$cat = $ALBUM_DATA['category'];
|
|
|
46 |
$actual_cat = $cat;
|
|
|
47 |
if ($cat != FIRST_USER_CAT + USER_ID && !GALLERY_ADMIN_MODE) cpg_die(ERROR, $lang_errors['perm_denied'], __FILE__, __LINE__);
|
|
|
48 |
} else {
|
|
|
49 |
$ALBUM_DATA = array();
|
|
|
50 |
}
|
|
|
51 |
|
|
|
52 |
$THUMB_ROWSPAN=5;
|
|
|
53 |
if ($CONFIG['user_field1_name'] != '') $THUMB_ROWSPAN++;
|
|
|
54 |
if ($CONFIG['user_field2_name'] != '') $THUMB_ROWSPAN++;
|
|
|
55 |
if ($CONFIG['user_field3_name'] != '') $THUMB_ROWSPAN++;
|
|
|
56 |
if ($CONFIG['user_field4_name'] != '') $THUMB_ROWSPAN++;
|
|
|
57 |
|
|
|
58 |
$USER_ALBUMS_ARRAY=array(0 => array());
|
|
|
59 |
|
|
|
60 |
// Type 0 => input
|
|
|
61 |
// 1 => album list
|
|
|
62 |
// 2 => text_area
|
|
|
63 |
// 3 => picture information
|
|
|
64 |
$captionLabel = $lang_editpics_php['desc'];
|
|
|
65 |
if ($CONFIG['show_bbcode_help']) {$captionLabel .= '<hr />'.$lang_bbcode_help;}
|
|
|
66 |
$data = array(
|
|
|
67 |
array($lang_editpics_php['pic_info'], '', 3),
|
|
|
68 |
array($lang_editpics_php['album'], 'aid', 1),
|
|
|
69 |
array($lang_editpics_php['title'], 'title', 0, 255),
|
|
|
70 |
array($captionLabel, 'caption', 2, $CONFIG['max_img_desc_length']),
|
|
|
71 |
array($lang_editpics_php['keywords'], 'keywords', 0, 255),
|
|
|
72 |
array($CONFIG['user_field1_name'], 'user1', 0, 255),
|
|
|
73 |
array($CONFIG['user_field2_name'], 'user2', 0, 255),
|
|
|
74 |
array($CONFIG['user_field3_name'], 'user3', 0, 255),
|
|
|
75 |
array($CONFIG['user_field4_name'], 'user4', 0, 255),
|
|
|
76 |
array('', '', 4)
|
|
|
77 |
);
|
|
|
78 |
|
|
|
79 |
function get_post_var($var, $pid)
|
|
|
80 |
{
|
|
|
81 |
global $HTTP_POST_VARS, $lang_errors;
|
|
|
82 |
|
|
|
83 |
$var_name = $var.$pid;
|
|
|
84 |
if(!isset($HTTP_POST_VARS[$var_name])) cpg_die(CRITICAL_ERROR, $lang_errors['param_missing']." ($var_name)", __FILE__, __LINE__);
|
|
|
85 |
return $HTTP_POST_VARS[$var_name];
|
|
|
86 |
}
|
|
|
87 |
|
|
|
88 |
function process_post_data()
|
|
|
89 |
{
|
|
|
90 |
global $HTTP_POST_VARS, $CONFIG;
|
|
|
91 |
global $user_albums_list, $lang_errors;
|
|
|
92 |
|
|
|
93 |
$user_album_set = array();
|
|
|
94 |
foreach($user_albums_list as $album) $user_album_set[$album['aid']] = 1;
|
|
|
95 |
|
|
|
96 |
if (!is_array($HTTP_POST_VARS['pid'])) cpg_die(CRITICAL_ERROR, $lang_errors['param_missing'], __FILE__, __LINE__);
|
|
|
97 |
$pid_array = &$HTTP_POST_VARS['pid'];
|
|
|
98 |
foreach($pid_array as $pid){
|
|
|
99 |
$pid = (int)$pid;
|
|
|
100 |
|
|
|
101 |
$aid = (int)get_post_var('aid', $pid);
|
|
|
102 |
$title = get_post_var('title', $pid);
|
|
|
103 |
$caption = get_post_var('caption', $pid);
|
|
|
104 |
$keywords = get_post_var('keywords', $pid);
|
|
|
105 |
$user1 = get_post_var('user1', $pid);
|
|
|
106 |
$user2 = get_post_var('user2', $pid);
|
|
|
107 |
$user3 = get_post_var('user3', $pid);
|
|
|
108 |
$user4 = get_post_var('user4', $pid);
|
|
|
109 |
|
|
|
110 |
$delete = isset($HTTP_POST_VARS['delete'.$pid]);
|
|
|
111 |
$reset_vcount = isset($HTTP_POST_VARS['reset_vcount'.$pid]);
|
|
|
112 |
$reset_votes = isset($HTTP_POST_VARS['reset_votes'.$pid]);
|
|
|
113 |
$del_comments = isset($HTTP_POST_VARS['del_comments'.$pid]) || $delete;
|
|
|
114 |
|
|
|
115 |
$query = "SELECT category, filepath, filename FROM {$CONFIG['TABLE_PICTURES']}, {$CONFIG['TABLE_ALBUMS']} WHERE {$CONFIG['TABLE_PICTURES']}.aid = {$CONFIG['TABLE_ALBUMS']}.aid AND pid='$pid'";
|
|
|
116 |
$result = db_query($query);
|
|
|
117 |
if (!mysql_num_rows($result)) cpg_die(CRITICAL_ERROR, $lang_errors['non_exist_ap'], __FILE__, __LINE__);
|
|
|
118 |
$pic = mysql_fetch_array($result);
|
|
|
119 |
mysql_free_result($result);
|
|
|
120 |
|
|
|
121 |
if (!GALLERY_ADMIN_MODE) {
|
|
|
122 |
if ($pic['category'] != FIRST_USER_CAT + USER_ID) cpg_die(ERROR, $lang_errors['perm_denied']."<br />(picture category = {$pic['category']}/ $pid)", __FILE__, __LINE__);
|
|
|
123 |
if (!isset($user_album_set[$aid])) cpg_die(ERROR, $lang_errors['perm_denied']."<br />(target album = $aid)", __FILE__, __LINE__);
|
|
|
124 |
}
|
|
|
125 |
|
|
|
126 |
$update = "aid = '".$aid."'";
|
|
|
127 |
$update .= ", title = '".addslashes($title)."'";
|
|
|
128 |
$update .= ", caption = '".addslashes($caption)."'";
|
|
|
129 |
$update .= ", keywords = '".addslashes($keywords)."'";
|
|
|
130 |
$update .= ", user1 = '".addslashes($user1)."'";
|
|
|
131 |
$update .= ", user2 = '".addslashes($user2)."'";
|
|
|
132 |
$update .= ", user3 = '".addslashes($user3)."'";
|
|
|
133 |
$update .= ", user4 = '".addslashes($user4)."'";
|
|
|
134 |
if (is_movie($pic['filename'])) {
|
|
|
135 |
$pwidth = get_post_var('pwidth', $pid);
|
|
|
136 |
$pheight = get_post_var('pheight', $pid);
|
|
|
137 |
$update .= ", pwidth = " . (int) $pwidth;
|
|
|
138 |
$update .= ", pheight = " . (int) $pheight;
|
|
|
139 |
}
|
|
|
140 |
|
|
|
141 |
if ($reset_vcount) $update .= ", hits = '0'";
|
|
|
142 |
if ($reset_votes) $update .= ", pic_rating = '0', votes = '0'";
|
|
|
143 |
|
|
|
144 |
if (UPLOAD_APPROVAL_MODE) {
|
|
|
145 |
$approved = get_post_var('approved', $pid);
|
|
|
146 |
if ($approved == 'YES') {
|
|
|
147 |
$update .= ", approved = 'YES'";
|
|
|
148 |
} elseif ($approved == 'DELETE') {
|
|
|
149 |
$del_comments = 1;
|
|
|
150 |
$delete = 1;
|
|
|
151 |
}
|
|
|
152 |
}
|
|
|
153 |
|
|
|
154 |
if ($del_comments) {
|
|
|
155 |
$query = "DELETE FROM {$CONFIG['TABLE_COMMENTS']} WHERE pid='$pid'";
|
|
|
156 |
$result =db_query($query);
|
|
|
157 |
}
|
|
|
158 |
|
|
|
159 |
if ($delete) {
|
|
|
160 |
$dir=$CONFIG['fullpath'].$pic['filepath'];
|
|
|
161 |
$file=$pic['filename'];
|
|
|
162 |
|
|
|
163 |
if (!is_writable($dir)) cpg_die(CRITICAL_ERROR, sprintf($lang_errors['directory_ro'], $dir), __FILE__, __LINE__);
|
|
|
164 |
|
|
|
165 |
$files=array($dir.$file, $dir.$CONFIG['normal_pfx'].$file, $dir.$CONFIG['thumb_pfx'].$file);
|
|
|
166 |
foreach ($files as $currFile){
|
|
|
167 |
if (is_file($currFile)) @unlink($currFile);
|
|
|
168 |
}
|
|
|
169 |
|
|
|
170 |
$query = "DELETE FROM {$CONFIG['TABLE_PICTURES']} WHERE pid='$pid' LIMIT 1";
|
|
|
171 |
$result = db_query($query);
|
|
|
172 |
} else {
|
|
|
173 |
$query = "UPDATE {$CONFIG['TABLE_PICTURES']} SET $update WHERE pid='$pid' LIMIT 1";
|
|
|
174 |
$result = db_query($query);
|
|
|
175 |
}
|
|
|
176 |
}
|
|
|
177 |
}
|
|
|
178 |
|
|
|
179 |
function form_label($text)
|
|
|
180 |
{
|
|
|
181 |
global $CURENT_PIC;
|
|
|
182 |
|
|
|
183 |
echo <<<EOT
|
|
|
184 |
<tr>
|
|
|
185 |
<td class="tableh2" colspan="3">
|
|
|
186 |
<b>$text</b>
|
|
|
187 |
</td>
|
|
|
188 |
</tr>
|
|
|
189 |
|
|
|
190 |
EOT;
|
|
|
191 |
}
|
|
|
192 |
|
|
|
193 |
function form_pic_info($text)
|
|
|
194 |
{
|
|
|
195 |
global $CURRENT_PIC, $THUMB_ROWSPAN, $CONFIG, $lang_byte_units, $lang_editpics_php;
|
|
|
196 |
|
|
|
197 |
if (!is_movie($CURRENT_PIC['filename'])) {
|
|
|
198 |
$pic_info = sprintf($lang_editpics_php['pic_info_str'], $CURRENT_PIC['pwidth'], $CURRENT_PIC['pheight'], ($CURRENT_PIC['filesize'] >> 10), $CURRENT_PIC['hits'], $CURRENT_PIC['votes']);
|
|
|
199 |
} else {
|
|
|
200 |
$pic_info = sprintf($lang_editpics_php['pic_info_str'], '<input type="text" name="pwidth'.$CURRENT_PIC['pid'].'" value="'.$CURRENT_PIC['pwidth'].'" size="5" maxlength="5" class="textinput" />', '<input type="text" name="pheight'.$CURRENT_PIC['pid'].'" value="'.$CURRENT_PIC['pheight'].'" size="5" maxlength="5" class="textinput" />', ($CURRENT_PIC['filesize'] >> 10), $CURRENT_PIC['hits'], $CURRENT_PIC['votes']);
|
|
|
201 |
}
|
|
|
202 |
|
|
|
203 |
if (UPLOAD_APPROVAL_MODE) {
|
|
|
204 |
// Commented out by Omni; Duplicate of above
|
|
|
205 |
//$pic_info = $CURRENT_PIC['pwidth'].' × '.$CURRENT_PIC['pheight'].' - '.($CURRENT_PIC['filesize'] >> 10).$lang_byte_units[1];
|
|
|
206 |
if($CURRENT_PIC['owner_name']){
|
|
|
207 |
$pic_info .= ' - <a href ="profile.php?uid='.$CURRENT_PIC['owner_id'].'" target="_blank">'.$CURRENT_PIC['owner_name'].'</a>';
|
|
|
208 |
}
|
|
|
209 |
}
|
|
|
210 |
|
|
|
211 |
$thumb_url = get_pic_url($CURRENT_PIC, 'thumb');
|
|
|
212 |
$thumb_link = 'displayimage.php?&pos='.(-$CURRENT_PIC['pid']);
|
|
|
213 |
$filename = htmlspecialchars($CURRENT_PIC['filename']);
|
|
|
214 |
|
|
|
215 |
echo <<<EOT
|
|
|
216 |
<input type="hidden" name="pid[]" value="{$CURRENT_PIC['pid']}">
|
|
|
217 |
<tr>
|
|
|
218 |
<td class="tableh2" colspan="3">
|
|
|
219 |
<b>$filename</b>
|
|
|
220 |
</td>
|
|
|
221 |
</tr>
|
|
|
222 |
<tr>
|
|
|
223 |
<td class="tableb" style="white-space: nowrap;">
|
|
|
224 |
$text
|
|
|
225 |
</td>
|
|
|
226 |
<td class="tableb">
|
|
|
227 |
$pic_info
|
|
|
228 |
</td>
|
|
|
229 |
<td class="tableb" align="center" rowspan="$THUMB_ROWSPAN">
|
|
|
230 |
<a href="$thumb_link" target="_blank"><img src="$thumb_url" class="image" border="0"><br /></a>
|
|
|
231 |
</td>
|
|
|
232 |
</tr>
|
|
|
233 |
|
|
|
234 |
EOT;
|
|
|
235 |
}
|
|
|
236 |
|
|
|
237 |
function form_options()
|
|
|
238 |
{
|
|
|
239 |
global $CURRENT_PIC, $lang_editpics_php;
|
|
|
240 |
|
|
|
241 |
if (UPLOAD_APPROVAL_MODE) {
|
|
|
242 |
echo <<<EOT
|
|
|
243 |
<tr>
|
|
|
244 |
<td class="tableb" colspan="3" align="center">
|
|
|
245 |
<b><input type="radio" name="approved{$CURRENT_PIC['pid']}" value="YES" class="radio">{$lang_editpics_php['approve']}</b>
|
|
|
246 |
<b><input type="radio" name="approved{$CURRENT_PIC['pid']}" value="NO" class="radio" checked>{$lang_editpics_php['postpone_app']}</b>
|
|
|
247 |
<b><input type="radio" name="approved{$CURRENT_PIC['pid']}" value="DELETE" class="radio">{$lang_editpics_php['del_pic']}</b>
|
|
|
248 |
</td>
|
|
|
249 |
</tr>
|
|
|
250 |
|
|
|
251 |
EOT;
|
|
|
252 |
} else {
|
|
|
253 |
echo <<<EOT
|
|
|
254 |
<tr>
|
|
|
255 |
<td class="tableb" colspan="3" align="center">
|
|
|
256 |
<b><input type="checkbox" name="delete{$CURRENT_PIC['pid']}" value="1" class="checkbox">{$lang_editpics_php['del_pic']}</b>
|
|
|
257 |
<b><input type="checkbox" name="reset_vcount{$CURRENT_PIC['pid']}" value="1" class="checkbox">{$lang_editpics_php['reset_view_count']}</b>
|
|
|
258 |
<b><input type="checkbox" name="reset_votes{$CURRENT_PIC['pid']}" value="1" class="checkbox">{$lang_editpics_php['reset_votes']}</b>
|
|
|
259 |
<b><input type="checkbox" name="del_comments{$CURRENT_PIC['pid']}" value="1" class="checkbox">{$lang_editpics_php['del_comm']}</b>
|
|
|
260 |
</td>
|
|
|
261 |
</tr>
|
|
|
262 |
|
|
|
263 |
EOT;
|
|
|
264 |
}
|
|
|
265 |
}
|
|
|
266 |
|
|
|
267 |
function form_input($text, $name, $max_length,$field_width=100)
|
|
|
268 |
{
|
|
|
269 |
global $CURRENT_PIC;
|
|
|
270 |
|
|
|
271 |
$value = $CURRENT_PIC[$name];
|
|
|
272 |
$name .= $CURRENT_PIC['pid'];
|
|
|
273 |
if ($text == '') {
|
|
|
274 |
echo " <input type=\"hidden\" name=\"$name\" value=\"\">\n";
|
|
|
275 |
return;
|
|
|
276 |
}
|
|
|
277 |
|
|
|
278 |
echo <<<EOT
|
|
|
279 |
<tr>
|
|
|
280 |
<td class="tableb" style="white-space: nowrap;">
|
|
|
281 |
$text
|
|
|
282 |
</td>
|
|
|
283 |
<td width="100%" class="tableb" valign="top">
|
|
|
284 |
<input type="text" style="width: {$field_width}%" name="$name" maxlength="$max_length" value="$value" class="textinput">
|
|
|
285 |
</td>
|
|
|
286 |
</tr>
|
|
|
287 |
|
|
|
288 |
EOT;
|
|
|
289 |
}
|
|
|
290 |
|
|
|
291 |
|
|
|
292 |
function form_alb_list_box($text, $name)
|
|
|
293 |
{
|
|
|
294 |
global $CONFIG, $CURRENT_PIC;
|
|
|
295 |
global $user_albums_list, $public_albums_list;
|
|
|
296 |
|
|
|
297 |
$sel_album = $CURRENT_PIC['aid'];
|
|
|
298 |
|
|
|
299 |
$name .= $CURRENT_PIC['pid'];
|
|
|
300 |
echo <<<EOT
|
|
|
301 |
<tr>
|
|
|
302 |
<td class="tableb" style="white-space: nowrap;">
|
|
|
303 |
$text
|
|
|
304 |
</td>
|
|
|
305 |
<td class="tableb" valign="top">
|
|
|
306 |
<select name="$name" class="listbox">
|
|
|
307 |
|
|
|
308 |
EOT;
|
|
|
309 |
foreach($public_albums_list as $album) {
|
|
|
310 |
echo ' <option value="' . $album['aid'] . '"' . ($album['aid'] == $sel_album ? ' selected' : '') . '>' . $album['cat_title'] . "</option>\n";
|
|
|
311 |
}
|
|
|
312 |
foreach($user_albums_list as $album){
|
|
|
313 |
echo ' <option value="'.$album['aid'].'"'.($album['aid'] == $sel_album ? ' selected' : '').'>* '.$album['title'] . "</option>\n";
|
|
|
314 |
}
|
|
|
315 |
echo <<<EOT
|
|
|
316 |
</select>
|
|
|
317 |
</td>
|
|
|
318 |
</tr>
|
|
|
319 |
|
|
|
320 |
EOT;
|
|
|
321 |
}
|
|
|
322 |
|
|
|
323 |
function form_textarea($text, $name, $max_length)
|
|
|
324 |
{
|
|
|
325 |
global $ALBUM_DATA, $CURRENT_PIC;
|
|
|
326 |
|
|
|
327 |
$value = $CURRENT_PIC[$name];
|
|
|
328 |
|
|
|
329 |
$name .= $CURRENT_PIC['pid'];
|
|
|
330 |
echo <<<EOT
|
|
|
331 |
<tr>
|
|
|
332 |
<td class="tableb" valign="top" style="white-space: nowrap;">
|
|
|
333 |
$text
|
|
|
334 |
</td>
|
|
|
335 |
<td class="tableb" valign="top">
|
|
|
336 |
<textarea name="$name" ROWS="5" COLS="40" WRAP="virtual" class="textinput" STYLE="WIDTH: 100%;" onKeyDown="textCounter(this, $max_length);" onKeyUp="textCounter(this, $max_length);">$value</textarea>
|
|
|
337 |
</td>
|
|
|
338 |
</tr>
|
|
|
339 |
EOT;
|
|
|
340 |
}
|
|
|
341 |
|
|
|
342 |
function create_form(&$data)
|
|
|
343 |
{
|
|
|
344 |
foreach($data as $element){
|
|
|
345 |
if ((is_array($element))) {
|
|
|
346 |
switch($element[2]){
|
|
|
347 |
case 0 :
|
|
|
348 |
form_input($element[0], $element[1], $element[3]);
|
|
|
349 |
break;
|
|
|
350 |
case 1 :
|
|
|
351 |
form_alb_list_box($element[0], $element[1]);
|
|
|
352 |
break;
|
|
|
353 |
case 2 :
|
|
|
354 |
form_textarea($element[0], $element[1], $element[3]);
|
|
|
355 |
break;
|
|
|
356 |
case 3 :
|
|
|
357 |
form_pic_info($element[0]);
|
|
|
358 |
break;
|
|
|
359 |
case 4 :
|
|
|
360 |
form_options();
|
|
|
361 |
break;
|
|
|
362 |
default:
|
|
|
363 |
cpg_die(CRITICAL_ERROR, 'Invalid action for form creation', __FILE__, __LINE__);
|
|
|
364 |
} // switch
|
|
|
365 |
} else {
|
|
|
366 |
form_label($element);
|
|
|
367 |
}
|
|
|
368 |
}
|
|
|
369 |
}
|
|
|
370 |
|
|
|
371 |
function get_user_albums($user_id)
|
|
|
372 |
{
|
|
|
373 |
global $CONFIG, $USER_ALBUMS_ARRAY, $user_albums_list;
|
|
|
374 |
|
|
|
375 |
if (!isset($USER_ALBUMS_ARRAY[$user_id])) {
|
|
|
376 |
$user_albums = db_query("SELECT aid, title FROM {$CONFIG['TABLE_ALBUMS']} WHERE category='".(FIRST_USER_CAT + $user_id)."' ORDER BY title");
|
|
|
377 |
if (mysql_num_rows($user_albums)) {
|
|
|
378 |
$user_albums_list=db_fetch_rowset($user_albums);
|
|
|
379 |
} else {
|
|
|
380 |
$user_albums_list = array();
|
|
|
381 |
}
|
|
|
382 |
mysql_free_result($user_albums);
|
|
|
383 |
$USER_ALBUMS_ARRAY[$user_id] = $user_albums_list;
|
|
|
384 |
} else {
|
|
|
385 |
$user_albums_list = &$USER_ALBUMS_ARRAY[$user_id];
|
|
|
386 |
}
|
|
|
387 |
}
|
|
|
388 |
|
|
|
389 |
|
|
|
390 |
if (GALLERY_ADMIN_MODE) {
|
|
|
391 |
$public_albums = db_query("SELECT DISTINCT aid, title, IF(category = 0, CONCAT('> ', title), CONCAT(name,' < ',title)) AS cat_title FROM {$CONFIG['TABLE_ALBUMS']}, {$CONFIG['TABLE_CATEGORIES']} WHERE category < '" . FIRST_USER_CAT . "' AND (category = 0 OR category = cid) ORDER BY cat_title");
|
|
|
392 |
if (mysql_num_rows($public_albums)) {
|
|
|
393 |
$public_albums_list=db_fetch_rowset($public_albums);
|
|
|
394 |
} else {
|
|
|
395 |
$public_albums_list = array();
|
|
|
396 |
}
|
|
|
397 |
mysql_free_result($public_albums);
|
|
|
398 |
} else {
|
|
|
399 |
$public_albums_list = array();
|
|
|
400 |
}
|
|
|
401 |
|
|
|
402 |
get_user_albums(USER_ID);
|
|
|
403 |
|
|
|
404 |
if (count($HTTP_POST_VARS)) process_post_data();
|
|
|
405 |
|
|
|
406 |
$start = isset($HTTP_GET_VARS['start']) ? (int)$HTTP_GET_VARS['start'] : 0;
|
|
|
407 |
$count = isset($HTTP_GET_VARS['count']) ? (int)$HTTP_GET_VARS['count'] : 25;
|
|
|
408 |
$next_target = $PHP_SELF.'?album='.$album_id.'&start='.($start+$count).'&count='.$count.((UPLOAD_APPROVAL_MODE==1)?"&mode=upload_approval":"");
|
|
|
409 |
$prev_target = $PHP_SELF.'?album='.$album_id.'&start='.max(0,$start-$count).'&count='.$count.((UPLOAD_APPROVAL_MODE==1)?"&mode=upload_approval":"");
|
|
|
410 |
$s50 = $count == 50 ? 'selected' : '';
|
|
|
411 |
$s75 = $count == 75 ? 'selected' : '';
|
|
|
412 |
$s100 = $count == 100 ? 'selected' : '';
|
|
|
413 |
|
|
|
414 |
if (UPLOAD_APPROVAL_MODE) {
|
|
|
415 |
$result=db_query("SELECT count(*) FROM {$CONFIG['TABLE_PICTURES']} WHERE approved = 'NO'");
|
|
|
416 |
$nbEnr = mysql_fetch_array($result);
|
|
|
417 |
$pic_count = $nbEnr[0];
|
|
|
418 |
|
|
|
419 |
// Update user names for pictures
|
|
|
420 |
$sql = "SELECT pid, owner_id FROM {$CONFIG['TABLE_PICTURES']} WHERE owner_id != 0 AND owner_name = ''";
|
|
|
421 |
$result = db_query($sql);
|
|
|
422 |
while($row = mysql_fetch_array($result)){
|
|
|
423 |
if(defined('UDB_INTEGRATION')){
|
|
|
424 |
$owner_name = udb_get_user_name($row['owner_id']);
|
|
|
425 |
} else {
|
|
|
426 |
$result2 = db_query("SELECT user_name FROM {$CONFIG['TABLE_USERS']} WHERE user_id = '".$row['owner_id']."'");
|
|
|
427 |
if (mysql_num_rows($result2)){
|
|
|
428 |
$row2 = mysql_fetch_array($result2);
|
|
|
429 |
mysql_free_result($result2);
|
|
|
430 |
$owner_name = $row2['user_name'];
|
|
|
431 |
} else {
|
|
|
432 |
$owner_name = '';
|
|
|
433 |
}
|
|
|
434 |
}
|
|
|
435 |
|
|
|
436 |
if($owner_name){
|
|
|
437 |
db_query("UPDATE {$CONFIG['TABLE_PICTURES']} SET owner_name = '$owner_name' WHERE pid = {$row['pid']} LIMIT 1");
|
|
|
438 |
} else {
|
|
|
439 |
db_query("UPDATE {$CONFIG['TABLE_PICTURES']} SET owner_id = 0 WHERE pid = {$row['pid']} LIMIT 1");
|
|
|
440 |
}
|
|
|
441 |
}
|
|
|
442 |
mysql_free_result($result);
|
|
|
443 |
|
|
|
444 |
$sql = "SELECT * ".
|
|
|
445 |
"FROM {$CONFIG['TABLE_PICTURES']} ".
|
|
|
446 |
"WHERE approved = 'NO' ".
|
|
|
447 |
"ORDER BY pid ".
|
|
|
448 |
"LIMIT $start, $count";
|
|
|
449 |
$result = db_query($sql);
|
|
|
450 |
$form_target = $PHP_SELF.'?mode=upload_approval&start='.$start.'&count='.$count;
|
|
|
451 |
$title = $lang_editpics_php['upl_approval'];
|
|
|
452 |
} else {
|
|
|
453 |
$result=db_query("SELECT count(*) FROM {$CONFIG['TABLE_PICTURES']} WHERE aid = '$album_id'");
|
|
|
454 |
$nbEnr = mysql_fetch_array($result);
|
|
|
455 |
$pic_count = $nbEnr[0];
|
|
|
456 |
mysql_free_result($result);
|
|
|
457 |
|
|
|
458 |
$result = db_query("SELECT * FROM {$CONFIG['TABLE_PICTURES']} WHERE aid = '$album_id' ORDER BY filename LIMIT $start, $count");
|
|
|
459 |
$form_target = $PHP_SELF.'?album='.$album_id.'&start='.$start.'&count='.$count;
|
|
|
460 |
$title = $lang_editpics_php['edit_pics'];
|
|
|
461 |
}
|
|
|
462 |
|
|
|
463 |
if (!mysql_num_rows($result)) cpg_die(INFORMATION, $lang_errors['no_img_to_display'], __FILE__, __LINE__);
|
|
|
464 |
|
|
|
465 |
if ($start + $count < $pic_count) {
|
|
|
466 |
$next_link = "<a href=\"$next_target\"><b>{$lang_editpics_php['see_next']}</b></a> - ";
|
|
|
467 |
} else {
|
|
|
468 |
$next_link = '';
|
|
|
469 |
}
|
|
|
470 |
|
|
|
471 |
if ($start > 0) {
|
|
|
472 |
$prev_link = "<a href=\"$prev_target\"><b>{$lang_editpics_php['see_prev']}</b></a> - ";
|
|
|
473 |
} else {
|
|
|
474 |
$prev_link = '';
|
|
|
475 |
}
|
|
|
476 |
|
|
|
477 |
$pic_count_text = sprintf($lang_editpics_php['n_pic'], $pic_count);
|
|
|
478 |
|
|
|
479 |
pageheader($title);
|
|
|
480 |
starttable("100%", $title, 3);
|
|
|
481 |
echo <<<EOT
|
|
|
482 |
<SCRIPT LANGUAGE="JavaScript">
|
|
|
483 |
function textCounter(field, maxlimit) {
|
|
|
484 |
if (field.value.length > maxlimit) // if too long...trim it!
|
|
|
485 |
field.value = field.value.substring(0, maxlimit);
|
|
|
486 |
}
|
|
|
487 |
</script>
|
|
|
488 |
EOT;
|
|
|
489 |
$mode= (UPLOAD_APPROVAL_MODE==1) ? "&mode=upload_approval":"";
|
|
|
490 |
echo <<<EOT
|
|
|
491 |
<tr>
|
|
|
492 |
<td class="tableb" colspan="3" align="center">
|
|
|
493 |
<form method="post" action="$form_target$mode">
|
|
|
494 |
<b>$pic_count_text</b> -
|
|
|
495 |
$prev_link
|
|
|
496 |
$next_link
|
|
|
497 |
<b>{$lang_editpics_php['n_of_pic_to_disp']}</b>
|
|
|
498 |
<select onChange="if(this.options[this.selectedIndex].value) window.location.href='$PHP_SELF?album=$album_id$mode&start=$start&count='+this.options[this.selectedIndex].value;" name="count" class="listbox">
|
|
|
499 |
<option value="25">25</option>
|
|
|
500 |
<option value="50" $s50>50</option>
|
|
|
501 |
<option value="75" $s75>75</option>
|
|
|
502 |
<option value="100" $s100>100</option>
|
|
|
503 |
</select>
|
|
|
504 |
</td>
|
|
|
505 |
</tr>
|
|
|
506 |
|
|
|
507 |
EOT;
|
|
|
508 |
|
|
|
509 |
while($CURRENT_PIC = mysql_fetch_array($result)){
|
|
|
510 |
if (GALLERY_ADMIN_MODE) get_user_albums($CURRENT_PIC['owner_id']);
|
|
|
511 |
create_form($data);
|
|
|
512 |
flush();
|
|
|
513 |
} // while
|
|
|
514 |
mysql_free_result($result);
|
|
|
515 |
|
|
|
516 |
echo <<<EOT
|
|
|
517 |
<tr>
|
|
|
518 |
<td colspan="3" align="center" class="tablef">
|
|
|
519 |
<input type="submit" value="{$lang_editpics_php['apply']}" class="button">
|
|
|
520 |
</td>
|
|
|
521 |
</form>
|
|
|
522 |
</tr>
|
|
|
523 |
|
|
|
524 |
EOT;
|
|
|
525 |
endtable();
|
|
|
526 |
pagefooter();
|
|
|
527 |
ob_end_flush();
|
|
|
528 |
?>
|