1 | <?php |
---|
2 | // +-----------------------------------------------------------------------+ |
---|
3 | // | waiting.php | |
---|
4 | // +-----------------------------------------------------------------------+ |
---|
5 | // | application : PhpWebGallery <http://phpwebgallery.net> | |
---|
6 | // | branch : BSF (Best So Far) | |
---|
7 | // +-----------------------------------------------------------------------+ |
---|
8 | // | file : $RCSfile$ |
---|
9 | // | last update : $Date: 2004-02-11 23:20:38 +0000 (Wed, 11 Feb 2004) $ |
---|
10 | // | last modifier : $Author: z0rglub $ |
---|
11 | // | revision : $Revision: 362 $ |
---|
12 | // +-----------------------------------------------------------------------+ |
---|
13 | // | This program is free software; you can redistribute it and/or modify | |
---|
14 | // | it under the terms of the GNU General Public License as published by | |
---|
15 | // | the Free Software Foundation | |
---|
16 | // | | |
---|
17 | // | This program is distributed in the hope that it will be useful, but | |
---|
18 | // | WITHOUT ANY WARRANTY; without even the implied warranty of | |
---|
19 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
---|
20 | // | General Public License for more details. | |
---|
21 | // | | |
---|
22 | // | You should have received a copy of the GNU General Public License | |
---|
23 | // | along with this program; if not, write to the Free Software | |
---|
24 | // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
---|
25 | // | USA. | |
---|
26 | // +-----------------------------------------------------------------------+ |
---|
27 | include_once( './admin/include/isadmin.inc.php' ); |
---|
28 | //--------------------------------------------------------------------- updates |
---|
29 | if ( isset( $_POST['submit'] ) ) |
---|
30 | { |
---|
31 | $query = 'SELECT id,storage_category_id,file,tn_ext'; |
---|
32 | $query.= ' FROM '.PREFIX_TABLE.'waiting'; |
---|
33 | $query.= " WHERE validated = 'false'"; |
---|
34 | $query.= ';'; |
---|
35 | $result = mysql_query( $query ); |
---|
36 | while ( $row = mysql_fetch_array( $result ) ) |
---|
37 | { |
---|
38 | $key = 'validate-'.$row['id']; |
---|
39 | if ( isset( $_POST[$key] ) ) |
---|
40 | { |
---|
41 | if ( $_POST[$key] == 'true' ) |
---|
42 | { |
---|
43 | // The uploaded element was validated, we have to set the |
---|
44 | // "validated" field to "true" |
---|
45 | $query = 'UPDATE '.PREFIX_TABLE.'waiting'; |
---|
46 | $query.= " SET validated = 'true'"; |
---|
47 | $query.= ' WHERE id = '.$row['id']; |
---|
48 | $query.= ';'; |
---|
49 | mysql_query( $query ); |
---|
50 | // linking logically the picture to its storage category |
---|
51 | $query = 'INSERT INTO'; |
---|
52 | } |
---|
53 | else |
---|
54 | { |
---|
55 | // The uploaded element was refused, we have to delete its reference |
---|
56 | // in the database and to delete the element as well. |
---|
57 | $query = 'DELETE FROM '.PREFIX_TABLE.'waiting'; |
---|
58 | $query.= ' WHERE id = '.$row['id']; |
---|
59 | $query.= ';'; |
---|
60 | mysql_query( $query ); |
---|
61 | // deletion of the associated files |
---|
62 | $dir = get_complete_dir( $row['storage_category_id'] ); |
---|
63 | unlink( '.'.$dir.$row['file'] ); |
---|
64 | if ( $row['tn_ext'] != '' ) |
---|
65 | { |
---|
66 | $thumbnail = $conf['prefix_thumbnail']; |
---|
67 | $thumbnail.= get_filename_wo_extension( $row['file'] ); |
---|
68 | $thumbnail.= '.'.$row['tn_ext']; |
---|
69 | $url = '.'.$dir.'thumbnail/'.$thumbnail; |
---|
70 | unlink( $url ); |
---|
71 | } |
---|
72 | } |
---|
73 | } |
---|
74 | } |
---|
75 | } |
---|
76 | //----------------------------------------------------- template initialization |
---|
77 | $sub = $vtp->Open( './template/'.$user['template'].'/admin/waiting.vtp' ); |
---|
78 | $tpl = array( 'category','date','author','thumbnail','file','delete', |
---|
79 | 'submit','waiting_update' ); |
---|
80 | templatize_array( $tpl, 'lang', $sub ); |
---|
81 | //-------------------------------------------------------- confirmation message |
---|
82 | if ( isset( $_POST['submit'] ) ) |
---|
83 | { |
---|
84 | $vtp->addSession( $sub, 'confirmation' ); |
---|
85 | $vtp->closeSession( $sub, 'confirmation' ); |
---|
86 | } |
---|
87 | //---------------------------------------------------------------- form display |
---|
88 | $cat_names = array(); |
---|
89 | $query = 'SELECT id,storage_category_id,file,username,mail_address'; |
---|
90 | $query.= ',date,tn_ext'; |
---|
91 | $query.= ' FROM '.PREFIX_TABLE.'waiting'; |
---|
92 | $query.= " WHERE validated = 'false'"; |
---|
93 | $query.= ' ORDER BY storage_category_id'; |
---|
94 | $query.= ';'; |
---|
95 | $result = mysql_query( $query ); |
---|
96 | $i = 0; |
---|
97 | while ( $row = mysql_fetch_array( $result ) ) |
---|
98 | { |
---|
99 | $vtp->addSession( $sub, 'picture' ); |
---|
100 | $vtp->setVar( $sub, 'picture.id', $row['id'] ); |
---|
101 | if ( $i++ % 2 == 0 ) |
---|
102 | { |
---|
103 | $vtp->setVar( $sub, 'picture.class', 'row2' ); |
---|
104 | } |
---|
105 | if ( !isset( $cat_names[$row['storage_category_id']] ) ) |
---|
106 | { |
---|
107 | $cat = get_cat_info( $row['storage_category_id'] ); |
---|
108 | $cat_names[$row['storage_category_id']] = array(); |
---|
109 | $cat_names[$row['storage_category_id']]['dir'] = |
---|
110 | '.'.get_complete_dir( $row['storage_category_id'] ); |
---|
111 | $cat_names[$row['storage_category_id']]['display_name'] = |
---|
112 | get_cat_display_name( $cat['name'], ' > ', 'font-weight:bold;' ); |
---|
113 | } |
---|
114 | // category name |
---|
115 | $vtp->setVar( $sub, 'picture.cat_name', |
---|
116 | $cat_names[$row['storage_category_id']]['display_name'] ); |
---|
117 | // date displayed like this (in English ) : |
---|
118 | // Sunday 15 June 2003 21:29 |
---|
119 | $date = format_date( $row['date'], 'unix', true ); |
---|
120 | $vtp->setVar( $sub, 'picture.date', $date ); |
---|
121 | // file preview link |
---|
122 | $url = $cat_names[$row['storage_category_id']]['dir'].$row['file']; |
---|
123 | $vtp->setVar( $sub, 'picture.preview_url', $url ); |
---|
124 | // file name |
---|
125 | $vtp->setVar( $sub, 'picture.file', $row['file'] ); |
---|
126 | // is there an existing associated thumnail ? |
---|
127 | if ( isset( $row['tn_ext'] ) and $row['tn_ext'] != '' ) |
---|
128 | { |
---|
129 | $vtp->addSession( $sub, 'thumbnail' ); |
---|
130 | $thumbnail = $conf['prefix_thumbnail']; |
---|
131 | $thumbnail.= get_filename_wo_extension( $row['file'] ); |
---|
132 | $thumbnail.= '.'.$row['tn_ext']; |
---|
133 | $url = $cat_names[$row['storage_category_id']]['dir']; |
---|
134 | $url.= 'thumbnail/'.$thumbnail; |
---|
135 | $vtp->setVar( $sub, 'thumbnail.preview_url', $url ); |
---|
136 | $vtp->setVar( $sub, 'thumbnail.file', $thumbnail ); |
---|
137 | $vtp->closeSession( $sub, 'thumbnail' ); |
---|
138 | } |
---|
139 | else |
---|
140 | { |
---|
141 | $vtp->addSession( $sub, 'no_thumbnail' ); |
---|
142 | $vtp->closeSession( $sub, 'no_thumbnail' ); |
---|
143 | } |
---|
144 | // username and associated mail address |
---|
145 | $vtp->setVar( $sub, 'picture.mail_address', $row['mail_address'] ); |
---|
146 | $vtp->setVar( $sub, 'picture.username', $row['username'] ); |
---|
147 | |
---|
148 | $vtp->closeSession( $sub, 'picture' ); |
---|
149 | } |
---|
150 | //----------------------------------------------------------- sending html code |
---|
151 | $vtp->Parse( $handle , 'sub', $sub ); |
---|
152 | ?> |
---|