Changeset 26 for trunk/admin/update.php
- Timestamp:
- Jul 21, 2003, 9:47:14 PM (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/update.php
r19 r26 188 188 $pictures = array(); 189 189 $tn_ext = ''; 190 if ( $opendir = opendir 191 { 192 while ( $file = readdir 190 if ( $opendir = opendir( $rep ) ) 191 { 192 while ( $file = readdir( $opendir ) ) 193 193 { 194 194 if ( is_file( $rep.'/'.$file ) and is_image( $rep.'/'.$file ) ) 195 195 { 196 196 // is the picture waiting for validation by an administrator ? 197 $query = 'SELECT id ';197 $query = 'SELECT id,validated,infos'; 198 198 $query.= ' FROM '.PREFIX_TABLE.'waiting'; 199 199 $query.= ' WHERE cat_id = '.$category_id; … … 201 201 $query.= ';'; 202 202 $result = mysql_query( $query ); 203 if ( mysql_num_rows( $result ) == 0 ) 203 $waiting = mysql_fetch_array( $result ); 204 if (mysql_num_rows( $result ) == 0 or $waiting['validated'] == 'true') 204 205 { 205 206 if ( $tn_ext = TN_exists( $rep, $file ) ) … … 215 216 { 216 217 $picture = array(); 217 $picture['file'] = $file;218 $picture['tn_ext'] = $tn_ext;218 $picture['file'] = $file; 219 $picture['tn_ext'] = $tn_ext; 219 220 $picture['date'] = date( 'Y-m-d', filemtime ( $rep.'/'.$file ) ); 220 221 $picture['filesize'] = floor( filesize( $rep.'/'.$file ) / 1024); 221 222 $image_size = @getimagesize( $rep.'/'.$file ); 222 $picture['width'] = $image_size[0]; 223 $picture['height'] = $image_size[1]; 223 $picture['width'] = $image_size[0]; 224 $picture['height'] = $image_size[1]; 225 if ( $waiting['validated'] == 'true' ) 226 { 227 // retrieving infos from the XML description of 228 // $waiting['infos'] 229 $infos = nl2br( $waiting['infos'] ); 230 $picture['author'] = getAttribute( $infos, 'author' ); 231 $picture['comment'] = getAttribute( $infos, 'comment' ); 232 $unixtime = getAttribute( $infos, 'date_creation' ); 233 $picture['date_creation'] = ''; 234 if ( $unixtime != '' ) 235 { 236 $picture['date_creation'] = date( 'Y-m-d', $unixtime ); 237 } 238 $picture['name'] = getAttribute( $infos, 'name' ); 239 // deleting the waiting element 240 $query = 'DELETE FROM '.PREFIX_TABLE.'waiting'; 241 $query.= ' WHERE id = '.$waiting['id']; 242 $query.= ';'; 243 mysql_query( $query ); 244 } 224 245 array_push( $pictures, $picture ); 225 246 } … … 243 264 foreach ( $pictures as $picture ) { 244 265 $query = 'INSERT INTO '.PREFIX_TABLE.'images'; 245 $query.= ' (file,cat_id,date_available,tn_ext,filesize,width,height)'; 266 $query.= ' (file,cat_id,date_available,tn_ext,filesize,width,height'; 267 $query.= ',name,author,comment,date_creation)'; 246 268 $query.= ' VALUES '; 247 269 $query.= "('".$picture['file']."','".$category_id."'"; 248 270 $query.= ",'".$picture['date']."','".$picture['tn_ext']."'"; 249 271 $query.= ",'".$picture['filesize']."','".$picture['width']."'"; 250 $query.= ",'".$picture['height']."')"; 251 $query.= ';'; 272 $query.= ",'".$picture['height']."','".$picture['name']."'"; 273 $query.= ",'".$picture['author']."','".$picture['comment']."'"; 274 if ( $picture['date_creation'] != '' ) 275 { 276 $query.= ",'".$picture['date_creation']."'"; 277 } 278 else 279 { 280 $query.= ',NULL'; 281 } 282 $query.= ');'; 252 283 mysql_query( $query ); 253 284 $count_new++; … … 284 315 285 316 $query = 'UPDATE '.PREFIX_TABLE.'categories'; 286 $query.= " SET date_ dernier= '".$date_last."'";317 $query.= " SET date_last = '".$date_last."'"; 287 318 $query.= ', nb_images = '.$nb_images; 288 319 $query.= ' where id = '.$category_id;
Note: See TracChangeset
for help on using the changeset viewer.