[2] | 1 | <?php |
---|
| 2 | /*************************************************************************** |
---|
[26] | 3 | * waiting.php * |
---|
[2] | 4 | * ------------------- * |
---|
[26] | 5 | * application : PhpWebGallery 1.3 * |
---|
| 6 | * author : Pierrick LE GALL <pierrick@z0rglub.com> * |
---|
[2] | 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 | ***************************************************************************/ |
---|
[26] | 17 | include_once( './include/isadmin.inc.php' ); |
---|
| 18 | //--------------------------------------------------------------------- updates |
---|
| 19 | if ( isset( $_POST['submit'] ) ) |
---|
| 20 | { |
---|
| 21 | $query = 'SELECT id,cat_id,file,tn_ext'; |
---|
| 22 | $query.= ' FROM '.PREFIX_TABLE.'waiting'; |
---|
| 23 | $query.= " WHERE validated = 'false'"; |
---|
| 24 | $query.= ';'; |
---|
| 25 | $result = mysql_query( $query ); |
---|
| 26 | while ( $row = mysql_fetch_array( $result ) ) |
---|
| 27 | { |
---|
| 28 | $key = 'validate-'.$row['id']; |
---|
| 29 | if ( isset( $_POST[$key] ) ) |
---|
| 30 | { |
---|
| 31 | if ( $_POST[$key] == 'true' ) |
---|
| 32 | { |
---|
| 33 | // The uploaded element was validated, we have to set the |
---|
| 34 | // "validated" field to "true" |
---|
| 35 | $query = 'UPDATE '.PREFIX_TABLE.'waiting'; |
---|
| 36 | $query.= " SET validated = 'true'"; |
---|
| 37 | $query.= ' WHERE id = '.$row['id']; |
---|
| 38 | $query.= ';'; |
---|
| 39 | mysql_query( $query ); |
---|
| 40 | } |
---|
| 41 | else |
---|
| 42 | { |
---|
| 43 | // The uploaded element was refused, we have to delete its reference |
---|
| 44 | // in the database and to delete the element as well. |
---|
| 45 | $query = 'DELETE FROM '.PREFIX_TABLE.'waiting'; |
---|
| 46 | $query.= ' WHERE id = '.$row['id']; |
---|
| 47 | $query.= ';'; |
---|
| 48 | mysql_query( $query ); |
---|
| 49 | // deletion of the associated files |
---|
| 50 | $cat = get_cat_info( $row['cat_id'] ); |
---|
| 51 | unlink( '.'.$cat['dir'].$row['file'] ); |
---|
| 52 | if ( $row['tn_ext'] != '' ) |
---|
| 53 | { |
---|
| 54 | $thumbnail = $conf['prefix_thumbnail']; |
---|
| 55 | $thumbnail.= get_filename_wo_extension( $row['file'] ); |
---|
| 56 | $thumbnail.= '.'.$row['tn_ext']; |
---|
| 57 | $url = '.'.$cat['dir'].'thumbnail/'.$thumbnail; |
---|
| 58 | unlink( $url ); |
---|
| 59 | } |
---|
| 60 | } |
---|
| 61 | } |
---|
| 62 | } |
---|
| 63 | } |
---|
| 64 | //----------------------------------------------------- template initialization |
---|
| 65 | $sub = $vtp->Open( '../template/'.$user['template'].'/admin/waiting.vtp' ); |
---|
| 66 | $tpl = array( 'category','date','author','thumbnail','file','delete', |
---|
| 67 | 'submit' ); |
---|
| 68 | templatize_array( $tpl, 'lang', $sub ); |
---|
| 69 | //---------------------------------------------------------------- form display |
---|
| 70 | $cat_names = array(); |
---|
| 71 | $query = 'SELECT id,cat_id,file,username,mail_address,date,tn_ext'; |
---|
| 72 | $query.= ' FROM '.PREFIX_TABLE.'waiting'; |
---|
| 73 | $query.= " WHERE validated = 'false'"; |
---|
| 74 | $query.= ' ORDER BY cat_id'; |
---|
| 75 | $query.= ';'; |
---|
| 76 | $result = mysql_query( $query ); |
---|
| 77 | $i = 0; |
---|
| 78 | while ( $row = mysql_fetch_array( $result ) ) |
---|
| 79 | { |
---|
| 80 | $vtp->addSession( $sub, 'picture' ); |
---|
| 81 | $vtp->setVar( $sub, 'picture.id', $row['id'] ); |
---|
| 82 | if ( $i++ % 2 == 0 ) |
---|
| 83 | { |
---|
| 84 | $vtp->setVar( $sub, 'picture.class', 'row2' ); |
---|
| 85 | } |
---|
| 86 | if ( !isset( $cat_names[$row['cat_id']] ) ) |
---|
| 87 | { |
---|
| 88 | $cat = get_cat_info( $row['cat_id'] ); |
---|
| 89 | $cat_names[$row['cat_id']] = array(); |
---|
| 90 | $cat_names[$row['cat_id']]['dir'] = '.'.$cat['dir']; |
---|
| 91 | $cat_names[$row['cat_id']]['display_name'] = |
---|
| 92 | get_cat_display_name( $cat['name'], ' > ', 'font-weight:bold;' ); |
---|
| 93 | } |
---|
| 94 | // category name |
---|
| 95 | $vtp->setVar( $sub, 'picture.cat_name', |
---|
| 96 | $cat_names[$row['cat_id']]['display_name'] ); |
---|
| 97 | // date displayed like this (in English ) : |
---|
| 98 | // Sunday 15 June 2003 21:29 |
---|
| 99 | $date = $lang['day'][date( 'w', $row['date'] )]; // Sunday |
---|
| 100 | $date.= date( ' j ', $row['date'] ); // 15 |
---|
| 101 | $date.= $lang['month'][date( 'n', $row['date'] )]; // June |
---|
| 102 | $date.= date( ' Y G:i', $row['date'] ); // 2003 21:29 |
---|
| 103 | $vtp->setVar( $sub, 'picture.date', $date ); |
---|
| 104 | // file preview link |
---|
| 105 | $url = $cat_names[$row['cat_id']]['dir'].$row['file']; |
---|
| 106 | $vtp->setVar( $sub, 'picture.preview_url', $url ); |
---|
| 107 | // file name |
---|
| 108 | $vtp->setVar( $sub, 'picture.file', $row['file'] ); |
---|
| 109 | // is there an existing associated thumnail ? |
---|
| 110 | if ( $row['tn_ext'] != '' ) |
---|
| 111 | { |
---|
| 112 | $vtp->addSession( $sub, 'thumbnail' ); |
---|
| 113 | $thumbnail = $conf['prefix_thumbnail']; |
---|
| 114 | $thumbnail.= get_filename_wo_extension( $row['file'] ); |
---|
| 115 | $thumbnail.= '.'.$row['tn_ext']; |
---|
| 116 | $url = $cat_names[$row['cat_id']]['dir'].'thumbnail/'.$thumbnail; |
---|
| 117 | $vtp->setVar( $sub, 'thumbnail.preview_url', $url ); |
---|
| 118 | $vtp->setVar( $sub, 'thumbnail.file', $thumbnail ); |
---|
| 119 | $vtp->closeSession( $sub, 'thumbnail' ); |
---|
| 120 | } |
---|
| 121 | else |
---|
| 122 | { |
---|
| 123 | $vtp->addSession( $sub, 'no_thumbnail' ); |
---|
| 124 | $vtp->closeSession( $sub, 'no_thumbnail' ); |
---|
| 125 | } |
---|
| 126 | // username and associated mail address |
---|
| 127 | $vtp->setVar( $sub, 'picture.mail_address', $row['mail_address'] ); |
---|
| 128 | $vtp->setVar( $sub, 'picture.username', $row['username'] ); |
---|
| 129 | |
---|
| 130 | $vtp->closeSession( $sub, 'picture' ); |
---|
| 131 | } |
---|
| 132 | //----------------------------------------------------------- sending html code |
---|
| 133 | $vtp->Parse( $handle , 'sub', $sub ); |
---|
[2] | 134 | ?> |
---|