Changeset 26 for trunk/admin/waiting.php
- Timestamp:
- Jul 21, 2003, 9:47:14 PM (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/waiting.php
r19 r26 1 1 <?php 2 2 /*************************************************************************** 3 * waiting.php is a part of PhpWebGallery*3 * waiting.php * 4 4 * ------------------- * 5 * last update : Monday, October 28, 2002*6 * email : pierrick@z0rglub.com*5 * application : PhpWebGallery 1.3 * 6 * author : Pierrick LE GALL <pierrick@z0rglub.com> * 7 7 * * 8 8 ***************************************************************************/ … … 15 15 * * 16 16 ***************************************************************************/ 17 include_once( "./include/isadmin.inc.php" ); 18 //-------------------------------------------------------------- mise à jour 19 if ( isset( $HTTP_POST_VARS['submit'] ) ) 20 { 21 $query = "select id,cat_id,file,tn_ext"; 22 $query.= " from PREFIX_TABLE"."waiting"; 23 $query.= ";"; 24 $result = mysql_query( $query ); 25 while ( $row = mysql_fetch_array( $result ) ) 26 { 27 $key = "validate-".$row['id']; 28 if ( isset( $HTTP_POST_VARS[$key] ) ) 29 { 30 $query = "delete from PREFIX_TABLE"."waiting"; 31 $query.= " where id = ".$row['id']; 32 $query.= ";"; 33 mysql_query( $query ); 34 if ( $HTTP_POST_VARS[$key] == "false" ) 35 { 36 // we have to delete the picture and the thumbnail if it exists 37 $cat = get_cat_info( $row['cat_id'] ); 38 unlink( ".".$cat['dir'].$row['file'] ); 39 if ( $row['tn_ext'] != "" ) 40 { 41 $file = substr ( $row['file'], 0, strrpos ( $row['file'], ".") ); 42 unlink( ".".$cat['dir']."thumbnail/".$conf['prefix_thumbnail'].$file.".".$row['tn_ext'] ); 43 } 44 } 45 } 46 } 47 } 48 //--------------------------------------------------------------- formulaire 49 $cat_names = array(); 50 echo " 51 <form action=\"".add_session_id_to_url( "./admin.php?page=waiting" )."\" method=\"post\"> 52 <table style=\"width:100%;\"> 53 <tr> 54 <th style=\"width:20%;\">".$lang['category']."</th> 55 <th style=\"width:20%;\">".$lang['date']."</th> 56 <th style=\"width:20%;\">".$lang['file']."</th> 57 <th style=\"width:20%;\">".$lang['thumbnail']."</th> 58 <th style=\"width:20%;\">".$lang['author']."</th> 59 <th style=\"width:1px;\"> </th> 60 </tr>"; 61 $query = "select id,cat_id,file,username,mail_address,date,tn_ext"; 62 $query.= " from PREFIX_TABLE"."waiting"; 63 $query.= " order by cat_id"; 64 $query.= ";"; 65 $result = mysql_query( $query ); 66 $i = 0; 67 while ( $row = mysql_fetch_array( $result ) ) 68 { 69 $style = ""; 70 if ( $i%2 == 0 ) 71 { 72 $style = "class=\"row2\""; 73 } 74 if ( !isset( $cat_names[$row['cat_id']] ) ) 75 { 76 $cat = get_cat_info( $row['cat_id'] ); 77 $cat_names[$row['cat_id']] = array(); 78 $cat_names[$row['cat_id']]['dir'] = ".".$cat['dir']; 79 $cat_names[$row['cat_id']]['display_name'] = get_cat_display_name( $cat['name'], " - ", "font-style:italic;" ); 80 } 81 echo " 82 <tr> 83 <td $style style=\"white-space:nowrap;\">".$cat_names[$row['cat_id']]['display_name']."</td> 84 <td $style style=\"white-space:nowrap;\">".$lang['day'][date( "w", $row['date'] )].date( " j ", $row['date'] ).$lang['month'][date( "n", $row['date'] )].date( " Y G:i", $row['date'] )."</td> 85 <td $style style=\"white-space:nowrap;\"> 86 <a target=\"_blank\" href=\"".$cat_names[$row['cat_id']]['dir'].$row['file']."\">".$row['file']."</td> 87 </td> 88 <td $style style=\"white-space:nowrap;\">"; 89 if ( $row['tn_ext'] != "" ) 90 { 91 $file = substr ( $row['file'], 0, strrpos ( $row['file'], ".") ); 92 echo "<a target=\"_blank\" href=\"".$cat_names[$row['cat_id']]['dir']."thumbnail/".$conf['prefix_thumbnail'].$file.".".$row['tn_ext']."\">".$conf['prefix_thumbnail'].$file.".".$row['tn_ext']; 93 } 94 else 95 { 96 echo " "; 97 } 98 echo " 99 </td> 100 <td $style style=\"white-space:nowrap;\"> 101 <a href=\"mailto:".$row['mail_address']."\">".$row['username']."</a> 102 </td> 103 <td $style style=\"white-space:nowrap;\"> 104 <input type=\"radio\" name=\"validate-".$row['id']."\" value=\"true\" />".$lang['submit']." 105 <input type=\"radio\" name=\"validate-".$row['id']."\" value=\"false\" />".$lang['delete']." 106 </td> 107 </tr>"; 108 $i++; 109 } 110 echo " 111 <tr> 112 <td colspan=\"5\" align=\"center\"><input type=\"submit\" name=\"submit\" value=\"".$lang['submit']."\" style=\"margin:5px;\" /></td> 113 </tr>"; 114 echo " 115 </table> 116 </form>"; 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 ); 117 134 ?>
Note: See TracChangeset
for help on using the changeset viewer.