1 | <?php |
---|
2 | /*************************************************************************** |
---|
3 | * infos_images.php is a part of PhpWebGallery * |
---|
4 | * ------------------- * |
---|
5 | * last update : Wednesday, July 25, 2002 * |
---|
6 | * email : pierrick@z0rglub.com * |
---|
7 | * * |
---|
8 | ***************************************************************************/ |
---|
9 | |
---|
10 | /*************************************************************************** |
---|
11 | * * |
---|
12 | * This program is free software; you can redistribute it and/or modify * |
---|
13 | * it under the terms of the GNU General Public License as published by * |
---|
14 | * the Free Software Foundation; * |
---|
15 | * * |
---|
16 | ***************************************************************************/ |
---|
17 | function check_date_format ( $date ) |
---|
18 | { |
---|
19 | // la date arrive à ce format : JJ/MM/AAAA |
---|
20 | // checkdate ( int month, int day, int year) |
---|
21 | $tab_date = explode( "/", $date ); |
---|
22 | return checkdate ( $tab_date[1], $tab_date[0], $tab_date[2]); |
---|
23 | } |
---|
24 | |
---|
25 | function date_convert( $date ) |
---|
26 | { |
---|
27 | // la date arrive à ce format : JJ/MM/AAAA |
---|
28 | // il faut la transformer en AAAA-MM-JJ |
---|
29 | $tab_date = explode( "/", $date ); |
---|
30 | return $tab_date[2]."-".$tab_date[1]."-".$tab_date[0]; |
---|
31 | } |
---|
32 | |
---|
33 | function date_convert_back( $date ) |
---|
34 | { |
---|
35 | // la date arrive à ce format : AAAA-MM-JJ |
---|
36 | // il faut la transformer en JJ/MM/AAAA |
---|
37 | if ( $date != "" ) |
---|
38 | { |
---|
39 | $tab_date = explode( "-", $date ); |
---|
40 | return $tab_date[2]."/".$tab_date[1]."/".$tab_date[0]; |
---|
41 | } |
---|
42 | else |
---|
43 | { |
---|
44 | return ""; |
---|
45 | } |
---|
46 | } |
---|
47 | |
---|
48 | include_once( "./include/isadmin.inc.php" ); |
---|
49 | $page['nb_image_page'] = 5; |
---|
50 | check_cat_id( $HTTP_GET_VARS['cat_id'] ); |
---|
51 | if ( isset( $page['cat'] ) ) |
---|
52 | { |
---|
53 | //------------------------------------------------------------mises à jour |
---|
54 | // 1. options individuelles |
---|
55 | $query = "select id,file "; |
---|
56 | $query.= "from $prefixeTable"."images "; |
---|
57 | $query.= "where cat_id = ".$page['cat']." "; |
---|
58 | $result = mysql_query( $query ); |
---|
59 | $i = 1; |
---|
60 | while ( $row = mysql_fetch_array( $result ) ) |
---|
61 | { |
---|
62 | $name = "name-".$row['id']; |
---|
63 | $author = "author-".$row['id']; |
---|
64 | $comment = "comment-".$row['id']; |
---|
65 | $date_creation = "date_creation-".$row['id']; |
---|
66 | if ( isset( $HTTP_POST_VARS[$name] ) ) |
---|
67 | { |
---|
68 | $query = "update $prefixeTable"."images "; |
---|
69 | if ( $HTTP_POST_VARS[$name] == "" ) |
---|
70 | { |
---|
71 | $query.= "set name = NULL "; |
---|
72 | } |
---|
73 | else |
---|
74 | { |
---|
75 | $query.= "set name = '".htmlspecialchars( $HTTP_POST_VARS[$name], ENT_QUOTES )."' "; |
---|
76 | } |
---|
77 | if ( $HTTP_POST_VARS[$author] == "" ) |
---|
78 | { |
---|
79 | $query.= ", author = NULL "; |
---|
80 | } |
---|
81 | else |
---|
82 | { |
---|
83 | $query.= ", author = '".htmlspecialchars( $HTTP_POST_VARS[$author], ENT_QUOTES )."' "; |
---|
84 | } |
---|
85 | if ( $HTTP_POST_VARS[$comment] == "" ) |
---|
86 | { |
---|
87 | $query.= ", comment = NULL "; |
---|
88 | } |
---|
89 | else |
---|
90 | { |
---|
91 | $query.= ", comment = '".htmlspecialchars( $HTTP_POST_VARS[$comment], ENT_QUOTES )."' "; |
---|
92 | } |
---|
93 | if ( check_date_format( $HTTP_POST_VARS[$date_creation] ) ) |
---|
94 | { |
---|
95 | $date = date_convert( $HTTP_POST_VARS[$date_creation] ); |
---|
96 | $query.= ", date_creation = '$date' "; |
---|
97 | } |
---|
98 | else if ( $HTTP_POST_VARS[$date_creation] == "" ) |
---|
99 | { |
---|
100 | $query.= ", date_creation = NULL "; |
---|
101 | } |
---|
102 | $query.= "where id = '".$row['id']."';"; |
---|
103 | mysql_query( $query ); |
---|
104 | } |
---|
105 | } |
---|
106 | // 2. options générales |
---|
107 | if ( $HTTP_POST_VARS['use_common_author'] == 1 ) |
---|
108 | { |
---|
109 | $query = "update $prefixeTable"."images "; |
---|
110 | if ( $HTTP_POST_VARS['author_cat'] == "" ) |
---|
111 | { |
---|
112 | $query.= "set author = NULL "; |
---|
113 | } |
---|
114 | else |
---|
115 | { |
---|
116 | $query.= "set author = '".$HTTP_POST_VARS['author_cat']."' "; |
---|
117 | } |
---|
118 | $query.= "where cat_id = ".$page['cat'].";"; |
---|
119 | mysql_query( $query ); |
---|
120 | } |
---|
121 | if ( $HTTP_POST_VARS['use_common_date_creation'] == 1 ) |
---|
122 | { |
---|
123 | // la date arrive à ce format : JJ/MM/AAAA |
---|
124 | // il faut la transformer en AAAA-MM-JJ |
---|
125 | if ( check_date_format( $HTTP_POST_VARS['date_creation_cat'] ) ) |
---|
126 | { |
---|
127 | $date = date_convert( $HTTP_POST_VARS['date_creation_cat'] ); |
---|
128 | $query = "update $prefixeTable"."images "; |
---|
129 | if ( $HTTP_POST_VARS['date_creation_cat'] == "" ) |
---|
130 | { |
---|
131 | $query.= "set date_creation = NULL "; |
---|
132 | } |
---|
133 | else |
---|
134 | { |
---|
135 | $query.= "set date_creation = '$date' "; |
---|
136 | } |
---|
137 | $query.= "where cat_id = ".$page['cat'].";"; |
---|
138 | mysql_query( $query ); |
---|
139 | } |
---|
140 | else |
---|
141 | { |
---|
142 | echo $lang['infoimage_err_date']; |
---|
143 | } |
---|
144 | } |
---|
145 | //----------------------------------------------------affichage de la page |
---|
146 | // détection de la page en cours |
---|
147 | if( !isset( $HTTP_GET_VARS['start'] ) || !is_numeric( $HTTP_GET_VARS['start'] ) || ( is_numeric( $HTTP_GET_VARS['start'] ) && $HTTP_GET_VARS['start'] < 0 ) ) |
---|
148 | { |
---|
149 | $page['start'] = 0; |
---|
150 | } |
---|
151 | else |
---|
152 | { |
---|
153 | $page['start'] = $HTTP_GET_VARS['start']; |
---|
154 | } |
---|
155 | |
---|
156 | if ( is_numeric( $HTTP_GET_VARS['num'] ) && $HTTP_GET_VARS['num'] >= 0 ) |
---|
157 | { |
---|
158 | $page['start'] = floor( $HTTP_GET_VARS['num'] / $page['nb_image_page'] ) * $page['nb_image_page']; |
---|
159 | } |
---|
160 | // retrieving category information |
---|
161 | $result = get_cat_info( $page['cat'] ); |
---|
162 | $cat['local_dir'] = $result['local_dir']; |
---|
163 | $cat['dir'] = $result['dir']; |
---|
164 | $cat['name'] = $result['name']; |
---|
165 | $cat['site_id'] = $result['site_id']; |
---|
166 | $cat['nb_images'] = $result['nb_images']; |
---|
167 | |
---|
168 | $url = "./admin.php?page=infos_images&cat_id=".$page['cat']; |
---|
169 | $page['navigation_bar'] = create_navigation_bar( $url, $cat['nb_images'], $page['start'], $page['nb_image_page'], "" ); |
---|
170 | echo" |
---|
171 | <form method=\"post\" action=\"".add_session_id_to_url( "./admin.php?page=infos_images&cat_id=".$page['cat']."&start=".$page['start'] )."\"> |
---|
172 | <table width=\"100%\"> |
---|
173 | <tr> |
---|
174 | <th colspan=\"3\">".$lang['infoimage_general']." \"".get_cat_display_name( $cat['name'], " - ", "font-style:italic;" )."\"</th> |
---|
175 | </tr> |
---|
176 | <tr> |
---|
177 | <td><div style=\"margin-left:50px;\">".$lang['author']."</div></td> |
---|
178 | <td style=\"text-align:center;\"><input type=\"text\" name=\"author_cat\" value=\"\" maxlength=\"255\"/></td> |
---|
179 | <td style=\"text-align:left;\"><input type=\"checkbox\" name=\"use_common_author\" value=\"1\"/>".$lang['infoimage_useforall']."</td> |
---|
180 | </tr> |
---|
181 | <tr> |
---|
182 | <td><div style=\"margin-left:50px;\">".$lang['infoimage_creation_date']." [DD/MM/YYYY]</div></td> |
---|
183 | <td style=\"text-align:center;\"><input type=\"text\" name=\"date_creation_cat\" value=\"\" size=\"12\" maxlength=\"10\"/></td> |
---|
184 | <td style=\"text-align:left;\"><input type=\"checkbox\" name=\"use_common_date_creation\" value=\"1\"/>".$lang['infoimage_useforall']."</td> |
---|
185 | </tr> |
---|
186 | </table>"; |
---|
187 | echo" |
---|
188 | <table width=\"100%\"> |
---|
189 | <tr> |
---|
190 | <th colspan=\"5\">".$lang['infoimage_detailed']."</th> |
---|
191 | </tr> |
---|
192 | <tr> |
---|
193 | <td colspan=\"5\" align=\"center\">".$page['navigation_bar']."</td> |
---|
194 | </tr> |
---|
195 | <tr> |
---|
196 | <td class=\"row2\" style=\"text-align:center;\">".$lang['thumbnail']."</td> |
---|
197 | <td class=\"row2\" style=\"text-align:center;\">".$lang['infoimage_title']."</td> |
---|
198 | <td class=\"row2\" style=\"text-align:center;\">".$lang['author']."</td> |
---|
199 | <td class=\"row2\" style=\"text-align:center;\">".$lang['infoimage_comment']."</td> |
---|
200 | <td class=\"row2\" style=\"text-align:center;\">".$lang['infoimage_creation_date']."</td> |
---|
201 | </tr>"; |
---|
202 | $query = "select id,file,comment,author,tn_ext,name,date_creation"; |
---|
203 | $query.= " from $prefixeTable"."images"; |
---|
204 | $query.= " where cat_id = ".$page['cat']; |
---|
205 | $query.= $conf['order_by']; |
---|
206 | $query.= " limit ".$page['start'].",".$page['nb_image_page']; |
---|
207 | $query.= ";"; |
---|
208 | $result = mysql_query( $query ); |
---|
209 | $i = 1; |
---|
210 | while ( $row = mysql_fetch_array( $result ) ) |
---|
211 | { |
---|
212 | echo" |
---|
213 | <tr>"; |
---|
214 | // création des liens vers la miniature |
---|
215 | $file = substr ( $row['file'], 0, strrpos ( $row['file'], ".") ); |
---|
216 | if ( $cat['site_id'] == 1 ) |
---|
217 | { |
---|
218 | $lien_thumbnail = "../galleries/".$cat['local_dir']."/"; |
---|
219 | } |
---|
220 | else |
---|
221 | { |
---|
222 | $lien_thumbnail = $cat['dir']; |
---|
223 | } |
---|
224 | $lien_thumbnail.= "thumbnail/".$conf['prefixe_thumbnail'].$file.".".$row['tn_ext']; |
---|
225 | // création du "style" de la ligne |
---|
226 | $style = "style=\"text-align:center;\""; |
---|
227 | if ( $i%2 == 0 ) |
---|
228 | { |
---|
229 | $style.= " class=\"row2\""; |
---|
230 | } |
---|
231 | echo" |
---|
232 | <td $style><a name=\"".$row['id']."\"><img src=\"$lien_thumbnail\" alt=\"\" class=\"miniature\" title=\"".$row['file']."\"/></td> |
---|
233 | <td $style>$file<br /><input type=\"text\" name=\"name-".$row['id']."\" value=\"".$row['name']."\" maxlength=\"255\"/></td> |
---|
234 | <td $style><input type=\"text\" name=\"author-".$row['id']."\" value=\"".$row['author']."\" maxlength=\"255\"/></td> |
---|
235 | <td $style><textarea name=\"comment-".$row['id']."\" rows=\"3\" cols=\"40\" style=\"overflow:auto\">".$row['comment']."</textarea></td> |
---|
236 | <td $style><input type=\"text\" name=\"date_creation-".$row['id']."\" value=\"".date_convert_back( $row['date_creation'] )."\" maxlength=\"10\" size=\"12\"/></td>"; |
---|
237 | echo" |
---|
238 | </tr>"; |
---|
239 | $i++; |
---|
240 | } |
---|
241 | echo" |
---|
242 | <tr> |
---|
243 | <td colspan=\"5\" style=\"text-align:center;\"><input type=\"submit\" value=\"".$lang['submit']."\"/></td> |
---|
244 | </tr> |
---|
245 | </table> |
---|
246 | </form>"; |
---|
247 | } |
---|
248 | ?> |
---|