diff options
author | z0rglub <z0rglub@piwigo.org> | 2003-07-21 19:47:14 +0000 |
---|---|---|
committer | z0rglub <z0rglub@piwigo.org> | 2003-07-21 19:47:14 +0000 |
commit | 2fa9252446a78d349ca2f50096430591cc5e012f (patch) | |
tree | bbf5cd282c8b9424b05d970c70e30610ea8b0e4f /admin/update.php | |
parent | 55a0a61aaf58a02e2ac5d2c489f81b1be4730cd8 (diff) |
*** empty log message ***
git-svn-id: http://piwigo.org/svn/trunk@26 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to '')
-rw-r--r-- | admin/update.php | 55 |
1 files changed, 43 insertions, 12 deletions
diff --git a/admin/update.php b/admin/update.php index bdd4d8a43..eefd913c1 100644 --- a/admin/update.php +++ b/admin/update.php @@ -187,20 +187,21 @@ function insert_local_image( $rep, $category_id ) // searching the new images in the directory $pictures = array(); $tn_ext = ''; - if ( $opendir = opendir ( $rep ) ) + if ( $opendir = opendir( $rep ) ) { - while ( $file = readdir ( $opendir ) ) + while ( $file = readdir( $opendir ) ) { if ( is_file( $rep.'/'.$file ) and is_image( $rep.'/'.$file ) ) { // is the picture waiting for validation by an administrator ? - $query = 'SELECT id'; + $query = 'SELECT id,validated,infos'; $query.= ' FROM '.PREFIX_TABLE.'waiting'; $query.= ' WHERE cat_id = '.$category_id; $query.= " AND file = '".$file."'"; $query.= ';'; $result = mysql_query( $query ); - if ( mysql_num_rows( $result ) == 0 ) + $waiting = mysql_fetch_array( $result ); + if (mysql_num_rows( $result ) == 0 or $waiting['validated'] == 'true') { if ( $tn_ext = TN_exists( $rep, $file ) ) { @@ -214,13 +215,33 @@ function insert_local_image( $rep, $category_id ) if ( mysql_num_rows( $result ) == 0 ) { $picture = array(); - $picture['file'] = $file; - $picture['tn_ext'] = $tn_ext; + $picture['file'] = $file; + $picture['tn_ext'] = $tn_ext; $picture['date'] = date( 'Y-m-d', filemtime ( $rep.'/'.$file ) ); $picture['filesize'] = floor( filesize( $rep.'/'.$file ) / 1024); $image_size = @getimagesize( $rep.'/'.$file ); - $picture['width'] = $image_size[0]; - $picture['height'] = $image_size[1]; + $picture['width'] = $image_size[0]; + $picture['height'] = $image_size[1]; + if ( $waiting['validated'] == 'true' ) + { + // retrieving infos from the XML description of + // $waiting['infos'] + $infos = nl2br( $waiting['infos'] ); + $picture['author'] = getAttribute( $infos, 'author' ); + $picture['comment'] = getAttribute( $infos, 'comment' ); + $unixtime = getAttribute( $infos, 'date_creation' ); + $picture['date_creation'] = ''; + if ( $unixtime != '' ) + { + $picture['date_creation'] = date( 'Y-m-d', $unixtime ); + } + $picture['name'] = getAttribute( $infos, 'name' ); + // deleting the waiting element + $query = 'DELETE FROM '.PREFIX_TABLE.'waiting'; + $query.= ' WHERE id = '.$waiting['id']; + $query.= ';'; + mysql_query( $query ); + } array_push( $pictures, $picture ); } } @@ -242,13 +263,23 @@ function insert_local_image( $rep, $category_id ) // inserting the pictures found in the directory foreach ( $pictures as $picture ) { $query = 'INSERT INTO '.PREFIX_TABLE.'images'; - $query.= ' (file,cat_id,date_available,tn_ext,filesize,width,height)'; + $query.= ' (file,cat_id,date_available,tn_ext,filesize,width,height'; + $query.= ',name,author,comment,date_creation)'; $query.= ' VALUES '; $query.= "('".$picture['file']."','".$category_id."'"; $query.= ",'".$picture['date']."','".$picture['tn_ext']."'"; $query.= ",'".$picture['filesize']."','".$picture['width']."'"; - $query.= ",'".$picture['height']."')"; - $query.= ';'; + $query.= ",'".$picture['height']."','".$picture['name']."'"; + $query.= ",'".$picture['author']."','".$picture['comment']."'"; + if ( $picture['date_creation'] != '' ) + { + $query.= ",'".$picture['date_creation']."'"; + } + else + { + $query.= ',NULL'; + } + $query.= ');'; mysql_query( $query ); $count_new++; @@ -283,7 +314,7 @@ function update_cat_info( $category_id ) $nb_images = $row['nb_images']; $query = 'UPDATE '.PREFIX_TABLE.'categories'; - $query.= " SET date_dernier = '".$date_last."'"; + $query.= " SET date_last = '".$date_last."'"; $query.= ', nb_images = '.$nb_images; $query.= ' where id = '.$category_id; $query.= ';'; |