source: extensions/upload_form/upload.php @ 4739

Revision 4739, 3.7 KB checked in by plg, 10 years ago (diff)

initial revision for the new upload form

Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | Piwigo - a PHP based picture gallery                                  |
4// +-----------------------------------------------------------------------+
5// | Copyright(C) 2009      Pierrick LE GALL             http://piwigo.org |
6// +-----------------------------------------------------------------------+
7// | This program is free software; you can redistribute it and/or modify  |
8// | it under the terms of the GNU General Public License as published by  |
9// | the Free Software Foundation                                          |
10// |                                                                       |
11// | This program is distributed in the hope that it will be useful, but   |
12// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
13// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
14// | General Public License for more details.                              |
15// |                                                                       |
16// | You should have received a copy of the GNU General Public License     |
17// | along with this program; if not, write to the Free Software           |
18// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
19// | USA.                                                                  |
20// +-----------------------------------------------------------------------+
21
22if( !defined("PHPWG_ROOT_PATH") )
23{
24  die ("Hacking attempt!");
25}
26
27include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
28include_once(UPLOAD_FORM_PATH.'include/functions_upload.inc.php');
29// load_language('plugin.lang', COMMUNITY_PATH);
30
31$admin_base_url = get_root_url().'admin.php?page=plugin&section=upload_form%2Fupload.php';
32
33// +-----------------------------------------------------------------------+
34// | Check Access and exit when user status is not ok                      |
35// +-----------------------------------------------------------------------+
36check_status(ACCESS_ADMINISTRATOR);
37
38// +-----------------------------------------------------------------------+
39// |                               functions                               |
40// +-----------------------------------------------------------------------+
41
42if (isset($_POST['submit_upload']))
43{
44  // echo '<pre>'; print_r($_FILES); echo '</pre>'; exit();
45 
46  $starttime = get_moment();
47 
48  foreach ($_FILES['image_upload']['error'] as $idx => $error)
49  {
50    if (UPLOAD_ERR_OK == $error)
51    {
52      $source_filepath = $_FILES['image_upload']['tmp_name'][$idx];
53      $name = $_FILES['image_upload']['name'][$idx];
54      add_uploaded_file($source_filepath, $name, array($_POST['category']));
55    }
56  }
57 
58  $endtime = get_moment();
59  $elapsed = ($endtime - $starttime) * 1000;
60  // printf('%.2f ms', $elapsed);
61}
62
63// +-----------------------------------------------------------------------+
64// |                             template init                             |
65// +-----------------------------------------------------------------------+
66
67$template->set_filenames(
68  array(
69    'plugin_admin_content' => dirname(__FILE__).'/upload.tpl'
70    )
71  );
72
73$template->assign(
74    array(
75      'F_ADD_ACTION'=> $admin_base_url,
76      'plugin_path' => UPLOAD_FORM_PATH,
77    )
78  );
79
80$query = '
81SELECT id,name,uppercats,global_rank
82  FROM '.CATEGORIES_TABLE.'
83;';
84
85display_select_cat_wrapper(
86  $query,
87  array(),
88  'category_options'
89  );
90
91// +-----------------------------------------------------------------------+
92// |                           sending html code                           |
93// +-----------------------------------------------------------------------+
94
95$template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
96?>
Note: See TracBrowser for help on using the repository browser.