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/editOnePic.php,v $
|
|
|
15 |
$Revision: 1.12 $
|
|
|
16 |
$Author: gaugau $
|
|
|
17 |
$Date: 2005/04/19 03:17:10 $
|
|
|
18 |
**********************************************/
|
|
|
19 |
|
|
|
20 |
define('IN_COPPERMINE', true);
|
|
|
21 |
define('EDITPICS_PHP', true);
|
|
|
22 |
require('include/init.inc.php');
|
|
|
23 |
|
|
|
24 |
if (!(GALLERY_ADMIN_MODE || USER_ADMIN_MODE)) cpg_die(ERROR, $lang_errors['access_denied'], __FILE__, __LINE__);
|
|
|
25 |
|
|
|
26 |
|
|
|
27 |
if (isset($_REQUEST['id'])) {
|
|
|
28 |
$pid = (int)$_REQUEST['id'];
|
|
|
29 |
} else {
|
|
|
30 |
$pid = -1;
|
|
|
31 |
}
|
|
|
32 |
|
|
|
33 |
|
|
|
34 |
$title = $lang_editpics_php['edit_pics'];
|
|
|
35 |
|
|
|
36 |
pageheader($title);
|
|
|
37 |
|
|
|
38 |
function process_post_data()
|
|
|
39 |
{
|
|
|
40 |
global $HTTP_POST_VARS, $CONFIG;
|
|
|
41 |
global $lang_errors;
|
|
|
42 |
|
|
|
43 |
$pid = (int)$HTTP_POST_VARS['id'];
|
|
|
44 |
$aid = (int)$HTTP_POST_VARS['aid'];
|
|
|
45 |
$pwidth = (int)$HTTP_POST_VARS['pwidth'];
|
|
|
46 |
$pheight = (int)$HTTP_POST_VARS['pheight'];
|
|
|
47 |
$title = $HTTP_POST_VARS['title'];
|
|
|
48 |
$caption = $HTTP_POST_VARS['caption'];
|
|
|
49 |
$keywords = $HTTP_POST_VARS['keywords'];
|
|
|
50 |
$user1 = $HTTP_POST_VARS['user1'];
|
|
|
51 |
$user2 = $HTTP_POST_VARS['user2'];
|
|
|
52 |
$user3 = $HTTP_POST_VARS['user3'];
|
|
|
53 |
$user4 = $HTTP_POST_VARS['user4'];
|
|
|
54 |
|
|
|
55 |
$read_exif = isset($HTTP_POST_VARS['read_exif']);
|
|
|
56 |
$reset_vcount = isset($HTTP_POST_VARS['reset_vcount']);
|
|
|
57 |
$reset_votes = isset($HTTP_POST_VARS['reset_votes']);
|
|
|
58 |
$del_comments = isset($HTTP_POST_VARS['del_comments']) || $delete;
|
|
|
59 |
|
|
|
60 |
$query = "SELECT category, filepath, filename FROM {$CONFIG['TABLE_PICTURES']}, {$CONFIG['TABLE_ALBUMS']} WHERE {$CONFIG['TABLE_PICTURES']}.aid = {$CONFIG['TABLE_ALBUMS']}.aid AND pid='$pid'";
|
|
|
61 |
$result = db_query($query);
|
|
|
62 |
if (!mysql_num_rows($result)) cpg_die(CRITICAL_ERROR, $lang_errors['non_exist_ap'], __FILE__, __LINE__);
|
|
|
63 |
$pic = mysql_fetch_array($result);
|
|
|
64 |
mysql_free_result($result);
|
|
|
65 |
|
|
|
66 |
if (!(GALLERY_ADMIN_MODE || USER_ADMIN_MODE)) {
|
|
|
67 |
if ($pic['category'] != FIRST_USER_CAT + USER_ID) cpg_die(ERROR, $lang_errors['perm_denied']."<br />(picture category = {$pic['category']}/ $pid)", __FILE__, __LINE__);
|
|
|
68 |
if (!isset($user_album_set[$aid])) cpg_die(ERROR, $lang_errors['perm_denied']."<br />(target album = $aid)", __FILE__, __LINE__);
|
|
|
69 |
}
|
|
|
70 |
|
|
|
71 |
$update = "aid = '".$aid."'";
|
|
|
72 |
if (is_movie($pic['filename'])) {
|
|
|
73 |
$update .= ", pwidth = ".$pwidth;
|
|
|
74 |
$update .= ", pheight = ".$pheight;
|
|
|
75 |
}
|
|
|
76 |
$update .= ", title = '".addslashes($title)."'";
|
|
|
77 |
$update .= ", caption = '".addslashes($caption)."'";
|
|
|
78 |
$update .= ", keywords = '".addslashes($keywords)."'";
|
|
|
79 |
$update .= ", user1 = '".addslashes($user1)."'";
|
|
|
80 |
$update .= ", user2 = '".addslashes($user2)."'";
|
|
|
81 |
$update .= ", user3 = '".addslashes($user3)."'";
|
|
|
82 |
$update .= ", user4 = '".addslashes($user4)."'";
|
|
|
83 |
|
|
|
84 |
if ($reset_vcount) $update .= ", hits = '0'";
|
|
|
85 |
if ($reset_votes) $update .= ", pic_rating = '0', votes = '0'";
|
|
|
86 |
|
|
|
87 |
if ($del_comments) {
|
|
|
88 |
$query = "DELETE FROM {$CONFIG['TABLE_COMMENTS']} WHERE pid='$pid'";
|
|
|
89 |
$result =db_query($query);
|
|
|
90 |
|
|
|
91 |
} else {
|
|
|
92 |
$query = "UPDATE {$CONFIG['TABLE_PICTURES']} SET $update WHERE pid='$pid' LIMIT 1";
|
|
|
93 |
$result = db_query($query);
|
|
|
94 |
}
|
|
|
95 |
|
|
|
96 |
}
|
|
|
97 |
|
|
|
98 |
function get_user_albums($user_id)
|
|
|
99 |
{
|
|
|
100 |
global $CONFIG, $USER_ALBUMS_ARRAY, $user_albums_list;
|
|
|
101 |
|
|
|
102 |
if (!isset($USER_ALBUMS_ARRAY[$user_id])) {
|
|
|
103 |
$user_albums = db_query("SELECT aid, title FROM {$CONFIG['TABLE_ALBUMS']} WHERE category='".(FIRST_USER_CAT + $user_id)."' ORDER BY title");
|
|
|
104 |
if (mysql_num_rows($user_albums)) {
|
|
|
105 |
$user_albums_list=db_fetch_rowset($user_albums);
|
|
|
106 |
} else {
|
|
|
107 |
$user_albums_list = array();
|
|
|
108 |
}
|
|
|
109 |
mysql_free_result($user_albums);
|
|
|
110 |
$USER_ALBUMS_ARRAY[$user_id] = $user_albums_list;
|
|
|
111 |
} else {
|
|
|
112 |
$user_albums_list = &$USER_ALBUMS_ARRAY[$user_id];
|
|
|
113 |
}
|
|
|
114 |
}
|
|
|
115 |
|
|
|
116 |
function form_alb_list_box()
|
|
|
117 |
{
|
|
|
118 |
global $CONFIG, $CURRENT_PIC;
|
|
|
119 |
global $user_albums_list, $public_albums_list, $lang_editpics_php;
|
|
|
120 |
$sel_album = $CURRENT_PIC['aid'];
|
|
|
121 |
|
|
|
122 |
echo <<<EOT
|
|
|
123 |
<tr>
|
|
|
124 |
<td class="tableb" style="white-space: nowrap;">
|
|
|
125 |
{$lang_editpics_php['album']}
|
|
|
126 |
</td>
|
|
|
127 |
<td class="tableb" valign="top">
|
|
|
128 |
<select name="aid" class="listbox">
|
|
|
129 |
EOT;
|
|
|
130 |
if (count($public_albums_list) + count($user_albums_list) == 0){
|
|
|
131 |
echo "<option value=\"{$CURRENT_PIC['aid']}\" selected>{$title}</option>";
|
|
|
132 |
}
|
|
|
133 |
|
|
|
134 |
|
|
|
135 |
foreach($public_albums_list as $album) {
|
|
|
136 |
echo ' <option value="' . $album['aid'] . '"' . ($album['aid'] == $sel_album ? ' selected="selected"' : '') . '>' . $album['cat_title'] . "</option>\n";
|
|
|
137 |
}
|
|
|
138 |
foreach($user_albums_list as $album){
|
|
|
139 |
echo ' <option value="'.$album['aid'].'"'.($album['aid'] == $sel_album ? ' selected="selected"' : '').'>* '.$album['title'] . "</option>\n";
|
|
|
140 |
}
|
|
|
141 |
echo <<<EOT
|
|
|
142 |
</select>
|
|
|
143 |
</td>
|
|
|
144 |
</tr>
|
|
|
145 |
|
|
|
146 |
EOT;
|
|
|
147 |
|
|
|
148 |
|
|
|
149 |
}
|
|
|
150 |
|
|
|
151 |
if (isset($HTTP_POST_VARS['submitDescription'])) process_post_data();
|
|
|
152 |
|
|
|
153 |
$result = db_query("SELECT * FROM {$CONFIG['TABLE_PICTURES']} WHERE pid = '$pid'");
|
|
|
154 |
$CURRENT_PIC = mysql_fetch_array($result);
|
|
|
155 |
mysql_free_result($result);
|
|
|
156 |
|
|
|
157 |
if (!(GALLERY_ADMIN_MODE || $CURRENT_PIC['owner_id'] == USER_ID)) cpg_die(ERROR, $lang_errors['access_denied'], __FILE__, __LINE__);
|
|
|
158 |
|
|
|
159 |
$thumb_url = get_pic_url($CURRENT_PIC, 'thumb');
|
|
|
160 |
$thumb_link = 'displayimage.php?pos='.(-$CURRENT_PIC['pid']);
|
|
|
161 |
$filename = htmlspecialchars($CURRENT_PIC['filename']);
|
|
|
162 |
|
|
|
163 |
$THUMB_ROWSPAN=5;
|
|
|
164 |
if ($CONFIG['user_field1_name'] != '') $THUMB_ROWSPAN++;
|
|
|
165 |
if ($CONFIG['user_field2_name'] != '') $THUMB_ROWSPAN++;
|
|
|
166 |
if ($CONFIG['user_field3_name'] != '') $THUMB_ROWSPAN++;
|
|
|
167 |
if ($CONFIG['user_field4_name'] != '') $THUMB_ROWSPAN++;
|
|
|
168 |
|
|
|
169 |
|
|
|
170 |
if (GALLERY_ADMIN_MODE) {
|
|
|
171 |
$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");
|
|
|
172 |
if (mysql_num_rows($public_albums)) {
|
|
|
173 |
$public_albums_list=db_fetch_rowset($public_albums);
|
|
|
174 |
} else {
|
|
|
175 |
$public_albums_list = array();
|
|
|
176 |
}
|
|
|
177 |
mysql_free_result($public_albums);
|
|
|
178 |
} else {
|
|
|
179 |
$public_albums_list = array();
|
|
|
180 |
}
|
|
|
181 |
|
|
|
182 |
get_user_albums($CURRENT_PIC['owner_id']);
|
|
|
183 |
|
|
|
184 |
echo <<<EOT
|
|
|
185 |
<script type="JavaScript">
|
|
|
186 |
function textCounter(field, maxlimit) {
|
|
|
187 |
if (field.value.length > maxlimit) // if too long...trim it!
|
|
|
188 |
field.value = field.value.substring(0, maxlimit);
|
|
|
189 |
}
|
|
|
190 |
</script>
|
|
|
191 |
<form method="post" action="editOnePic.php">
|
|
|
192 |
<input type="hidden" name="id" value="{$CURRENT_PIC['pid']}" />
|
|
|
193 |
EOT;
|
|
|
194 |
|
|
|
195 |
starttable("100%", $lang_editpics_php['desc'], 3);
|
|
|
196 |
|
|
|
197 |
//$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']);
|
|
|
198 |
|
|
|
199 |
if (!is_movie($CURRENT_PIC['filename'])) {
|
|
|
200 |
$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']);
|
|
|
201 |
} else {
|
|
|
202 |
$pic_info = sprintf($lang_editpics_php['pic_info_str'], '<input type="text" name="pwidth" value="'.$CURRENT_PIC['pwidth'].'" size="5" maxlength="5" class="textinput" />', '<input type="text" name="pheight" value="'.$CURRENT_PIC['pheight'].'" size="5" maxlength="5" class="textinput" />', ($CURRENT_PIC['filesize'] >> 10), $CURRENT_PIC['hits'], $CURRENT_PIC['votes']);
|
|
|
203 |
}
|
|
|
204 |
|
|
|
205 |
if (defined('UPLOAD_APPROVAL_MODE')) {
|
|
|
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 |
print <<<EOT
|
|
|
212 |
<tr>
|
|
|
213 |
<td class="tableh2" colspan="3">
|
|
|
214 |
<b>$filename</b>
|
|
|
215 |
</td>
|
|
|
216 |
</tr>
|
|
|
217 |
<tr>
|
|
|
218 |
<td class="tableb" style="white-space: nowrap;">
|
|
|
219 |
{$lang_editpics_php['pic_info']}
|
|
|
220 |
</td>
|
|
|
221 |
<td class="tableb">
|
|
|
222 |
$pic_info
|
|
|
223 |
</td>
|
|
|
224 |
<td class="tableb" align="center" rowspan="$THUMB_ROWSPAN">
|
|
|
225 |
<a href="$thumb_link"><img src="$thumb_url" class="image" border="0" alt="{$CURRENT_PIC['title']}"/></a><br />
|
|
|
226 |
</td>
|
|
|
227 |
</tr>
|
|
|
228 |
EOT;
|
|
|
229 |
|
|
|
230 |
form_alb_list_box();
|
|
|
231 |
|
|
|
232 |
print <<<EOT
|
|
|
233 |
<tr>
|
|
|
234 |
<td class="tableb" style="white-space: nowrap;">
|
|
|
235 |
{$lang_editpics_php['title']}
|
|
|
236 |
</td>
|
|
|
237 |
<td width="100%" class="tableb" valign="top">
|
|
|
238 |
<input type="text" style="width: 100%" name="title" maxlength="255" value="{$CURRENT_PIC['title']}" class="textinput" />
|
|
|
239 |
</td>
|
|
|
240 |
</tr>
|
|
|
241 |
EOT;
|
|
|
242 |
echo <<<EOT
|
|
|
243 |
<tr>
|
|
|
244 |
<td class="tableb" valign="top" style="white-space: nowrap;">
|
|
|
245 |
{$lang_editpics_php['desc']}
|
|
|
246 |
</td>
|
|
|
247 |
<td class="tableb" valign="top">
|
|
|
248 |
<textarea name="caption" rows="5" cols="40" class="textinput" style="width: 100%;" onkeydown="textCounter(this, {$CONFIG['max_img_desc_length']});" onkeyup="textCounter(this, {$CONFIG['max_img_desc_length']});">{$CURRENT_PIC['caption']}</textarea>
|
|
|
249 |
</td>
|
|
|
250 |
</tr>
|
|
|
251 |
<tr>
|
|
|
252 |
<td class="tableb" style="white-space: nowrap;">
|
|
|
253 |
{$lang_editpics_php['keywords']}
|
|
|
254 |
</td>
|
|
|
255 |
<td width="100%" class="tableb" valign="top">
|
|
|
256 |
<input type="text" style="width: 100%" name="keywords" maxlength="255" value="{$CURRENT_PIC['keywords']}" class="textinput" />
|
|
|
257 |
</td>
|
|
|
258 |
</tr>
|
|
|
259 |
|
|
|
260 |
EOT;
|
|
|
261 |
if ($CONFIG['user_field1_name'] != ''){
|
|
|
262 |
echo <<<EOT
|
|
|
263 |
<tr>
|
|
|
264 |
<td class="tableb" style="white-space: nowrap;">
|
|
|
265 |
{$CONFIG['user_field1_name']}
|
|
|
266 |
</td>
|
|
|
267 |
<td width="100%" class="tableb" valign="top">
|
|
|
268 |
<input type="text" style="width: 100%" name="user1" maxlength="255" value="{$CURRENT_PIC['user1']}" class="textinput" />
|
|
|
269 |
</td>
|
|
|
270 |
</tr>
|
|
|
271 |
EOT;
|
|
|
272 |
}
|
|
|
273 |
if ($CONFIG['user_field2_name'] != ''){
|
|
|
274 |
echo <<<EOT
|
|
|
275 |
<tr>
|
|
|
276 |
<td class="tableb" style="white-space: nowrap;">
|
|
|
277 |
{$CONFIG['user_field2_name']}
|
|
|
278 |
</td>
|
|
|
279 |
<td width="100%" class="tableb" valign="top">
|
|
|
280 |
<input type="text" style="width: 100%" name="user2" maxlength="255" value="{$CURRENT_PIC['user2']}" class="textinput" />
|
|
|
281 |
</td>
|
|
|
282 |
</tr>
|
|
|
283 |
EOT;
|
|
|
284 |
}if ($CONFIG['user_field3_name'] != ''){
|
|
|
285 |
echo <<<EOT
|
|
|
286 |
<tr>
|
|
|
287 |
<td class="tableb" style="white-space: nowrap;">
|
|
|
288 |
{$CONFIG['user_field3_name']}
|
|
|
289 |
</td>
|
|
|
290 |
<td width="100%" class="tableb" valign="top">
|
|
|
291 |
<input type="text" style="width: 100%" name="user3" maxlength="255" value="{$CURRENT_PIC['user3']}" class="textinput" />
|
|
|
292 |
</td>
|
|
|
293 |
</tr>
|
|
|
294 |
EOT;
|
|
|
295 |
}if ($CONFIG['user_field4_name'] != ''){
|
|
|
296 |
echo <<<EOT
|
|
|
297 |
<tr>
|
|
|
298 |
<td class="tableb" style="white-space: nowrap;">
|
|
|
299 |
{$CONFIG['user_field4_name']}
|
|
|
300 |
</td>
|
|
|
301 |
<td width="100%" class="tableb" valign="top">
|
|
|
302 |
<input type="text" style="width: 100%" name="user4" maxlength="255" value="{$CURRENT_PIC['user4']}" class="textinput" />
|
|
|
303 |
</td>
|
|
|
304 |
</tr>
|
|
|
305 |
EOT;
|
|
|
306 |
}
|
|
|
307 |
print <<<EOT
|
|
|
308 |
<tr>
|
|
|
309 |
<td class="tableb" colspan="3" align="center">
|
|
|
310 |
<b><input type="checkbox" name="read_exif" value="1" class="checkbox" />{$lang_editpics_php['read_exif']}</b>
|
|
|
311 |
<b><input type="checkbox" name="reset_vcount" value="1" class="checkbox" />{$lang_editpics_php['reset_view_count']}</b>
|
|
|
312 |
<b><input type="checkbox" name="reset_votes" value="1" class="checkbox" />{$lang_editpics_php['reset_votes']}</b>
|
|
|
313 |
<b><input type="checkbox" name="del_comments" value="1" class="checkbox" />{$lang_editpics_php['del_comm']}</b>
|
|
|
314 |
</td>
|
|
|
315 |
</tr>
|
|
|
316 |
<tr>
|
|
|
317 |
<td colspan="3" align="center" class="tablef">
|
|
|
318 |
<input type="submit" value="{$lang_editpics_php['apply']}" name="submitDescription" class="button" />
|
|
|
319 |
</td>
|
|
|
320 |
</tr>
|
|
|
321 |
EOT;
|
|
|
322 |
|
|
|
323 |
endtable();
|
|
|
324 |
echo '</form>';
|
|
|
325 |
pagefooter();
|
|
|
326 |
ob_end_flush();
|
|
|
327 |
?>
|