Subversion Repositories svnkaklik

Rev

Go to most recent revision | Details | Last modification | View Log

Rev Author Line No. Line
6 kaklik 1
<?php
2
// +-----------------------------------------------------------------------+
3
// | PhpWebGallery - a PHP based picture gallery                           |
4
// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
5
// | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net |
6
// +-----------------------------------------------------------------------+
7
// | branch        : BSF (Best So Far)
8
// | file          : $RCSfile: waiting.php,v $
9
// | last update   : $Date: 2005/01/16 17:31:18 $
10
// | last modifier : $Author: plg $
11
// | revision      : $Revision: 1.18 $
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
if( !defined("PHPWG_ROOT_PATH") )
28
{
29
  die ("Hacking attempt!");
30
}
31
include_once( PHPWG_ROOT_PATH.'admin/include/isadmin.inc.php');
32
//--------------------------------------------------------------------- updates
33
if ( isset( $_POST['submit'] ) )
34
{
35
  $query = 'SELECT * FROM '.WAITING_TABLE;
36
  $query.= " WHERE validated = 'false';";
37
  $result = pwg_query( $query );
38
  while ( $row = mysql_fetch_array( $result ) )
39
  {
40
    $key = 'validate-'.$row['id'];
41
    if ( isset( $_POST[$key] ) )
42
    {
43
      if ( $_POST[$key] == 'true' )
44
      {
45
        // The uploaded element was validated, we have to set the
46
        // "validated" field to "true"
47
        $query = 'UPDATE '.WAITING_TABLE;
48
        $query.= " SET validated = 'true'";
49
        $query.= ' WHERE id = '.$row['id'];
50
        $query.= ';';
51
        pwg_query( $query );
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 '.WAITING_TABLE;
58
        $query.= ' WHERE id = '.$row['id'];
59
        $query.= ';';
60
        pwg_query( $query );
61
        // deletion of the associated files
62
        $dir = get_complete_dir( $row['storage_category_id'] );
63
        unlink( $dir.$row['file'] );
64
        if (isset($row['tn_ext']) and $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
 
77
//----------------------------------------------------- template initialization
78
$template->set_filenames(array('waiting'=>'admin/waiting.tpl'));
79
$template->assign_vars(array(
80
  'L_WAITING_CONFIRMATION'=>$lang['waiting_update'],
81
  'L_AUTHOR'=>$lang['author'],
82
  'L_THUMBNAIL'=>$lang['thumbnail'],
83
  'L_DATE'=>$lang['date'],
84
  'L_FILE'=>$lang['file'],
85
  'L_CATEGORY'=>$lang['category'],
86
  'L_SUBMIT'=>$lang['submit'],
87
  'L_RESET'=>$lang['reset'],
88
  'L_DELETE'=>$lang['delete'],
89
 
90
  'F_ACTION'=>add_session_id(str_replace( '&', '&amp;', $_SERVER['REQUEST_URI'] ))
91
  ));
92
 
93
//-------------------------------------------------------- confirmation message
94
if (isset($_POST['submit']))
95
{
96
  $template->assign_block_vars('confirmation' ,array());
97
}
98
//---------------------------------------------------------------- form display
99
$cat_names = array();
100
$query = 'SELECT * FROM '.WAITING_TABLE;
101
$query.= " WHERE validated = 'false'";
102
$query.= ' ORDER BY storage_category_id';
103
$query.= ';';
104
$result = pwg_query( $query );
105
$i = 0;
106
while ( $row = mysql_fetch_array( $result ) )
107
{
108
  if ( !isset( $cat_names[$row['storage_category_id']] ) )
109
  {
110
    $cat = get_cat_info( $row['storage_category_id'] );
111
    $cat_names[$row['storage_category_id']] = array();
112
    $cat_names[$row['storage_category_id']]['dir'] =
113
      PHPWG_ROOT_PATH.get_complete_dir( $row['storage_category_id'] );
114
    $cat_names[$row['storage_category_id']]['display_name'] =
115
      get_cat_display_name($cat['name']);
116
  }
117
  $preview_url = PHPWG_ROOT_PATH.$cat_names[$row['storage_category_id']]['dir'].$row['file'];
118
  $class='row1';
119
  if ( $i++ % 2== 0 ) $class='row2';
120
 
121
  $template->assign_block_vars('picture' ,array(
122
    'WAITING_CLASS'=>$class,
123
    'CATEGORY_IMG'=>$cat_names[$row['storage_category_id']]['display_name'],
124
    'ID_IMG'=>$row['id'],
125
	'DATE_IMG'=>format_date( $row['date'], 'unix', true ),
126
	'FILE_IMG'=>$row['file'],
127
	'PREVIEW_URL_IMG'=>$preview_url, 
128
	'UPLOAD_EMAIL'=>$row['mail_address'],
129
	'UPLOAD_USERNAME'=>$row['username']
130
	));
131
 
132
  // is there an existing associated thumnail ?
133
  if ( !empty( $row['tn_ext'] ))
134
  {
135
    $thumbnail = $conf['prefix_thumbnail'];
136
    $thumbnail.= get_filename_wo_extension( $row['file'] );
137
    $thumbnail.= '.'.$row['tn_ext'];
138
	$url = $cat_names[$row['storage_category_id']]['dir'];
139
    $url.= 'thumbnail/'.$thumbnail;
140
 
141
    $template->assign_block_vars('picture.thumbnail' ,array(
142
	  'PREVIEW_URL_TN_IMG'=>$url,
143
	  'FILE_TN_IMG'=>$thumbnail
144
	  ));
145
  }
146
}
147
//----------------------------------------------------------- sending html code
148
$template->assign_var_from_handle('ADMIN_CONTENT', 'waiting');
149
?>