2003-05-09 14:42:42 +02:00
|
|
|
|
<?php
|
2004-02-07 20:36:44 +01:00
|
|
|
|
// +-----------------------------------------------------------------------+
|
2008-04-05 00:57:23 +02:00
|
|
|
|
// | Piwigo - a PHP based picture gallery |
|
|
|
|
|
// +-----------------------------------------------------------------------+
|
|
|
|
|
// | Copyright(C) 2008 Piwigo Team http://piwigo.org |
|
|
|
|
|
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
|
|
|
|
|
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
|
|
|
|
|
// +-----------------------------------------------------------------------+
|
|
|
|
|
// | This program is free software; you can redistribute it and/or modify |
|
|
|
|
|
// | it under the terms of the GNU General Public License as published by |
|
|
|
|
|
// | the Free Software Foundation |
|
|
|
|
|
// | |
|
|
|
|
|
// | This program is distributed in the hope that it will be useful, but |
|
|
|
|
|
// | WITHOUT ANY WARRANTY; without even the implied warranty of |
|
2004-02-07 20:36:44 +01:00
|
|
|
|
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
|
|
|
|
// | General Public License for more details. |
|
|
|
|
|
// | |
|
|
|
|
|
// | You should have received a copy of the GNU General Public License |
|
|
|
|
|
// | along with this program; if not, write to the Free Software |
|
|
|
|
|
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
|
|
|
|
|
// | USA. |
|
|
|
|
|
// +-----------------------------------------------------------------------+
|
2008-05-02 23:56:21 +02:00
|
|
|
|
|
2004-02-19 01:31:09 +01:00
|
|
|
|
define('PHPWG_ROOT_PATH','./');
|
2007-02-22 06:31:08 +01:00
|
|
|
|
|
2008-05-02 23:56:21 +02:00
|
|
|
|
// +-----------------------------------------------------------------------+
|
|
|
|
|
// | Includes |
|
|
|
|
|
// +-----------------------------------------------------------------------+
|
|
|
|
|
include_once(PHPWG_ROOT_PATH.'include/common.inc.php');
|
2004-02-02 01:55:18 +01:00
|
|
|
|
|
2008-05-02 23:56:21 +02:00
|
|
|
|
// +-----------------------------------------------------------------------+
|
|
|
|
|
// | Check Access and exit when user status is not ok |
|
|
|
|
|
// +-----------------------------------------------------------------------+
|
|
|
|
|
check_status($conf['upload_user_access']);
|
|
|
|
|
|
|
|
|
|
$username = !empty($_POST['username']) ? $_POST['username']:(is_classic_user() ? $user['username'] : '');
|
|
|
|
|
$mail_address = !empty($_POST['mail_address']) ? $_POST['mail_address'] : (is_classic_user() ? $user['email'] : '');
|
|
|
|
|
$name = !empty($_POST['name']) ? $_POST['name'] : '';
|
|
|
|
|
$author = !empty($_POST['author']) ? $_POST['author'] : (is_classic_user() ? $user['username'] : '');
|
|
|
|
|
$date_creation = !empty($_POST['date_creation']) ? $_POST['date_creation'] : '';
|
|
|
|
|
$comment = !empty($_POST['comment']) ? $_POST['comment'] : '';
|
2006-12-03 23:32:02 +01:00
|
|
|
|
|
2003-05-17 12:49:14 +02:00
|
|
|
|
//------------------------------------------------------------------- functions
|
2003-05-09 14:42:42 +02:00
|
|
|
|
// The validate_upload function checks if the image of the given path is valid.
|
|
|
|
|
// A picture is valid when :
|
|
|
|
|
// - width, height and filesize are not higher than the maximum
|
|
|
|
|
// filesize authorized by the administrator
|
|
|
|
|
// - the type of the picture is among jpg, gif and png
|
|
|
|
|
// The function returns an array containing :
|
|
|
|
|
// - $result['type'] contains the type of the image ('jpg', 'gif' or 'png')
|
|
|
|
|
// - $result['error'] contains an array with the different errors
|
|
|
|
|
// found with the picture
|
|
|
|
|
function validate_upload( $temp_name, $my_max_file_size,
|
|
|
|
|
$image_max_width, $image_max_height )
|
|
|
|
|
{
|
2006-12-03 23:32:02 +01:00
|
|
|
|
global $conf, $lang, $page, $mail_address;
|
|
|
|
|
|
2003-05-09 14:42:42 +02:00
|
|
|
|
$result = array();
|
|
|
|
|
$result['error'] = array();
|
|
|
|
|
//echo $_FILES['picture']['name']."<br />".$temp_name;
|
|
|
|
|
$extension = get_extension( $_FILES['picture']['name'] );
|
2004-10-25 22:35:35 +02:00
|
|
|
|
if (!in_array($extension, $conf['picture_ext']))
|
2003-05-09 14:42:42 +02:00
|
|
|
|
{
|
2006-12-03 23:32:02 +01:00
|
|
|
|
array_push( $result['error'], l10n('upload_advise_filetype') );
|
2003-05-09 14:42:42 +02:00
|
|
|
|
return $result;
|
|
|
|
|
}
|
|
|
|
|
if ( !isset( $_FILES['picture'] ) )
|
|
|
|
|
{
|
|
|
|
|
// do we even have a file?
|
2003-05-27 22:56:13 +02:00
|
|
|
|
array_push( $result['error'], "You did not upload anything!" );
|
2003-05-09 14:42:42 +02:00
|
|
|
|
}
|
|
|
|
|
else if ( $_FILES['picture']['size'] > $my_max_file_size * 1024 )
|
|
|
|
|
{
|
2003-05-27 22:56:13 +02:00
|
|
|
|
array_push( $result['error'],
|
2006-12-03 23:32:02 +01:00
|
|
|
|
l10n('upload_advise_filesize').$my_max_file_size.' KB' );
|
2003-05-09 14:42:42 +02:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// check if we are allowed to upload this file_type
|
|
|
|
|
// upload de la photo sous un nom temporaire
|
|
|
|
|
if ( !move_uploaded_file( $_FILES['picture']['tmp_name'], $temp_name ) )
|
|
|
|
|
{
|
2006-12-03 23:32:02 +01:00
|
|
|
|
array_push( $result['error'], l10n('upload_cannot_upload') );
|
2003-05-09 14:42:42 +02:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
$size = getimagesize( $temp_name );
|
|
|
|
|
if ( isset( $image_max_width )
|
2003-05-17 12:49:14 +02:00
|
|
|
|
and $image_max_width != ""
|
|
|
|
|
and $size[0] > $image_max_width )
|
2003-05-09 14:42:42 +02:00
|
|
|
|
{
|
2003-05-27 22:56:13 +02:00
|
|
|
|
array_push( $result['error'],
|
2006-12-03 23:32:02 +01:00
|
|
|
|
l10n('upload_advise_width').$image_max_width.' px' );
|
2003-05-09 14:42:42 +02:00
|
|
|
|
}
|
|
|
|
|
if ( isset( $image_max_height )
|
2003-05-17 12:49:14 +02:00
|
|
|
|
and $image_max_height != ""
|
|
|
|
|
and $size[1] > $image_max_height )
|
2003-05-09 14:42:42 +02:00
|
|
|
|
{
|
2003-05-27 22:56:13 +02:00
|
|
|
|
array_push( $result['error'],
|
2006-12-03 23:32:02 +01:00
|
|
|
|
l10n('upload_advise_height').$image_max_height.' px' );
|
2003-05-09 14:42:42 +02:00
|
|
|
|
}
|
|
|
|
|
// $size[2] == 1 means GIF
|
|
|
|
|
// $size[2] == 2 means JPG
|
|
|
|
|
// $size[2] == 3 means PNG
|
2003-05-27 22:56:13 +02:00
|
|
|
|
switch ( $size[2] )
|
2003-05-09 14:42:42 +02:00
|
|
|
|
{
|
2003-05-27 22:56:13 +02:00
|
|
|
|
case 1 : $result['type'] = 'gif'; break;
|
|
|
|
|
case 2 : $result['type'] = 'jpg'; break;
|
|
|
|
|
case 3 : $result['type'] = 'png'; break;
|
|
|
|
|
default :
|
2008-03-08 02:38:37 +01:00
|
|
|
|
array_push( $result['error'], l10n('upload_advise_filetype') );
|
2003-05-09 14:42:42 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if ( sizeof( $result['error'] ) > 0 )
|
|
|
|
|
{
|
|
|
|
|
// destruction de l'image avec le nom temporaire
|
|
|
|
|
@unlink( $temp_name );
|
|
|
|
|
}
|
2004-02-02 01:55:18 +01:00
|
|
|
|
else
|
|
|
|
|
{
|
2004-10-30 17:42:29 +02:00
|
|
|
|
@chmod( $temp_name, 0644);
|
2004-02-02 01:55:18 +01:00
|
|
|
|
}
|
2006-12-03 23:32:02 +01:00
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------ log informations
|
2007-02-20 23:07:52 +01:00
|
|
|
|
pwg_log();
|
2006-12-03 23:32:02 +01:00
|
|
|
|
|
2003-05-09 14:42:42 +02:00
|
|
|
|
return $result;
|
2006-12-03 23:32:02 +01:00
|
|
|
|
}
|
2004-02-02 01:55:18 +01:00
|
|
|
|
|
2003-05-09 14:42:42 +02:00
|
|
|
|
//-------------------------------------------------- access authorization check
|
2008-05-02 23:56:21 +02:00
|
|
|
|
if (isset($_POST['category']) and is_numeric($_POST['category']))
|
|
|
|
|
{
|
|
|
|
|
$page['category'] = $_POST['category'];
|
|
|
|
|
}
|
|
|
|
|
else
|
2007-06-12 23:52:46 +02:00
|
|
|
|
if (isset($_GET['cat']) and is_numeric($_GET['cat']))
|
2006-02-12 22:52:16 +01:00
|
|
|
|
{
|
2007-02-20 23:07:52 +01:00
|
|
|
|
$page['category'] = $_GET['cat'];
|
2006-02-12 22:52:16 +01:00
|
|
|
|
}
|
2008-05-02 23:56:21 +02:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
$page['category'] = null;
|
|
|
|
|
}
|
2006-02-12 22:52:16 +01:00
|
|
|
|
|
2008-05-02 23:56:21 +02:00
|
|
|
|
if (! empty($page['category']))
|
2003-05-09 14:42:42 +02:00
|
|
|
|
{
|
2008-05-02 23:56:21 +02:00
|
|
|
|
check_restrictions($page['category']);
|
|
|
|
|
$category = get_cat_info($page['category']);
|
|
|
|
|
$category['cat_dir'] = get_complete_dir($page['category']);
|
2008-03-08 02:38:37 +01:00
|
|
|
|
|
2007-02-27 02:56:16 +01:00
|
|
|
|
if (url_is_remote($category['cat_dir']) or !$category['uploadable'])
|
2004-12-30 09:10:46 +01:00
|
|
|
|
{
|
2008-03-08 02:38:37 +01:00
|
|
|
|
page_forbidden('upload not allowed');
|
2004-12-30 09:10:46 +01:00
|
|
|
|
}
|
2004-02-02 01:55:18 +01:00
|
|
|
|
}
|
2008-05-02 23:56:21 +02:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (isset($_POST['submit']))
|
|
|
|
|
{
|
|
|
|
|
// $page['category'] may be set by a futur plugin but without it
|
|
|
|
|
bad_request('invalid parameters');
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
$category = null;
|
|
|
|
|
}
|
2007-06-12 23:52:46 +02:00
|
|
|
|
}
|
2003-05-09 14:42:42 +02:00
|
|
|
|
|
|
|
|
|
$error = array();
|
|
|
|
|
$page['upload_successful'] = false;
|
|
|
|
|
if ( isset( $_GET['waiting_id'] ) )
|
|
|
|
|
{
|
|
|
|
|
$page['waiting_id'] = $_GET['waiting_id'];
|
|
|
|
|
}
|
2008-05-02 23:56:21 +02:00
|
|
|
|
|
2003-05-09 14:42:42 +02:00
|
|
|
|
//-------------------------------------------------------------- picture upload
|
2003-07-21 21:47:14 +02:00
|
|
|
|
// verfying fields
|
2003-05-17 12:49:14 +02:00
|
|
|
|
if ( isset( $_POST['submit'] ) and !isset( $_GET['waiting_id'] ) )
|
2003-05-09 14:42:42 +02:00
|
|
|
|
{
|
2007-02-27 02:56:16 +01:00
|
|
|
|
$path = $category['cat_dir'].$_FILES['picture']['name'];
|
2003-05-09 14:42:42 +02:00
|
|
|
|
if ( @is_file( $path ) )
|
|
|
|
|
{
|
2006-12-03 23:32:02 +01:00
|
|
|
|
array_push( $error, l10n('upload_file_exists') );
|
2003-05-09 14:42:42 +02:00
|
|
|
|
}
|
|
|
|
|
// test de la pr<70>sence des champs obligatoires
|
2004-02-22 03:43:13 +01:00
|
|
|
|
if ( empty($_FILES['picture']['name']))
|
2003-05-09 14:42:42 +02:00
|
|
|
|
{
|
2006-12-03 23:32:02 +01:00
|
|
|
|
array_push( $error, l10n('upload_filenotfound') );
|
2003-05-09 14:42:42 +02:00
|
|
|
|
}
|
|
|
|
|
if ( !ereg( "([_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)+)",
|
|
|
|
|
$_POST['mail_address'] ) )
|
|
|
|
|
{
|
2006-12-03 23:32:02 +01:00
|
|
|
|
array_push( $error, l10n('reg_err_mail_address') );
|
2003-05-09 14:42:42 +02:00
|
|
|
|
}
|
2004-02-22 03:43:13 +01:00
|
|
|
|
if ( empty($_POST['username']) )
|
2003-05-09 14:42:42 +02:00
|
|
|
|
{
|
2006-12-03 23:32:02 +01:00
|
|
|
|
array_push( $error, l10n('upload_err_username') );
|
2003-05-09 14:42:42 +02:00
|
|
|
|
}
|
2008-03-08 02:38:37 +01:00
|
|
|
|
|
2004-02-02 01:55:18 +01:00
|
|
|
|
$date_creation = '';
|
2004-02-22 03:43:13 +01:00
|
|
|
|
if ( !empty($_POST['date_creation']) )
|
2003-07-21 21:47:14 +02:00
|
|
|
|
{
|
|
|
|
|
list( $day,$month,$year ) = explode( '/', $_POST['date_creation'] );
|
|
|
|
|
// int checkdate ( int month, int day, int year)
|
2004-08-21 15:03:49 +02:00
|
|
|
|
if (checkdate($month, $day, $year))
|
2003-07-21 21:47:14 +02:00
|
|
|
|
{
|
2004-08-21 15:03:49 +02:00
|
|
|
|
$date_creation = $year.'-'.$month.'-'.$day;
|
2003-07-21 21:47:14 +02:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2006-12-03 23:32:02 +01:00
|
|
|
|
array_push( $error, l10n('err_date') );
|
2003-07-21 21:47:14 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// creation of the "infos" field :
|
|
|
|
|
// <infos author="Pierrick LE GALL" comment="my comment"
|
2004-08-21 15:03:49 +02:00
|
|
|
|
// date_creation="2004-08-14" name="" />
|
2008-08-23 03:21:42 +02:00
|
|
|
|
$xml_infos = '<infos ';
|
2006-02-28 02:13:16 +01:00
|
|
|
|
$xml_infos.= encodeAttribute('author', $_POST['author']);
|
|
|
|
|
$xml_infos.= encodeAttribute('comment', $_POST['comment']);
|
|
|
|
|
$xml_infos.= encodeAttribute('date_creation', $date_creation);
|
|
|
|
|
$xml_infos.= encodeAttribute('name', $_POST['name']);
|
2003-07-21 21:47:14 +02:00
|
|
|
|
$xml_infos.= ' />';
|
2004-02-02 01:55:18 +01:00
|
|
|
|
|
|
|
|
|
if ( !preg_match( '/^[a-zA-Z0-9-_.]+$/', $_FILES['picture']['name'] ) )
|
|
|
|
|
{
|
2006-12-03 23:32:02 +01:00
|
|
|
|
array_push( $error, l10n('update_wrong_dirname') );
|
2004-02-02 01:55:18 +01:00
|
|
|
|
}
|
2008-03-08 02:38:37 +01:00
|
|
|
|
|
2003-05-09 14:42:42 +02:00
|
|
|
|
if ( sizeof( $error ) == 0 )
|
|
|
|
|
{
|
|
|
|
|
$result = validate_upload( $path, $conf['upload_maxfilesize'],
|
|
|
|
|
$conf['upload_maxwidth'],
|
|
|
|
|
$conf['upload_maxheight'] );
|
|
|
|
|
for ( $j = 0; $j < sizeof( $result['error'] ); $j++ )
|
|
|
|
|
{
|
2003-07-21 21:47:14 +02:00
|
|
|
|
array_push( $error, $result['error'][$j] );
|
2003-05-09 14:42:42 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( sizeof( $error ) == 0 )
|
|
|
|
|
{
|
2004-02-22 03:43:13 +01:00
|
|
|
|
$query = 'insert into '.WAITING_TABLE;
|
2003-08-30 17:54:37 +02:00
|
|
|
|
$query.= ' (storage_category_id,file,username,mail_address,date,infos)';
|
|
|
|
|
$query.= ' values ';
|
2007-02-20 23:07:52 +01:00
|
|
|
|
$query.= '('.$page['category'].",'".$_FILES['picture']['name']."'";
|
2003-05-09 14:42:42 +02:00
|
|
|
|
$query.= ",'".htmlspecialchars( $_POST['username'], ENT_QUOTES)."'";
|
2003-07-21 21:47:14 +02:00
|
|
|
|
$query.= ",'".$_POST['mail_address']."',".time().",'".$xml_infos."')";
|
2003-05-09 14:42:42 +02:00
|
|
|
|
$query.= ';';
|
2004-10-30 17:42:29 +02:00
|
|
|
|
pwg_query( $query );
|
2003-05-09 14:42:42 +02:00
|
|
|
|
$page['waiting_id'] = mysql_insert_id();
|
2007-03-13 00:10:35 +01:00
|
|
|
|
|
|
|
|
|
if ($conf['email_admin_on_picture_uploaded'])
|
|
|
|
|
{
|
|
|
|
|
include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php');
|
|
|
|
|
|
2007-03-16 19:49:19 +01:00
|
|
|
|
$waiting_url = get_absolute_root_url().'admin.php?page=upload';
|
2007-03-13 00:10:35 +01:00
|
|
|
|
|
2007-03-16 00:20:41 +01:00
|
|
|
|
$keyargs_content = array
|
|
|
|
|
(
|
|
|
|
|
get_l10n_args('Category: %s', get_cat_display_name($category['upper_names'], null, false)),
|
|
|
|
|
get_l10n_args('Picture name: %s', $_FILES['picture']['name']),
|
|
|
|
|
get_l10n_args('User: %s', $_POST['username']),
|
|
|
|
|
get_l10n_args('Email: %s', $_POST['mail_address']),
|
|
|
|
|
get_l10n_args('Picture name: %s', $_POST['name']),
|
|
|
|
|
get_l10n_args('Author: %s', $_POST['author']),
|
|
|
|
|
get_l10n_args('Creation date: %s', $_POST['date_creation']),
|
|
|
|
|
get_l10n_args('Comment: %s', $_POST['comment']),
|
|
|
|
|
get_l10n_args('', ''),
|
|
|
|
|
get_l10n_args('Waiting page: %s', $waiting_url)
|
|
|
|
|
);
|
2007-03-13 00:10:35 +01:00
|
|
|
|
|
2007-03-16 00:20:41 +01:00
|
|
|
|
pwg_mail_notification_admins
|
2007-03-13 00:10:35 +01:00
|
|
|
|
(
|
2007-03-16 00:20:41 +01:00
|
|
|
|
get_l10n_args('Picture uploaded by %s', $_POST['username']),
|
|
|
|
|
$keyargs_content
|
2007-03-13 00:10:35 +01:00
|
|
|
|
);
|
|
|
|
|
}
|
2003-05-09 14:42:42 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
2004-02-22 03:43:13 +01:00
|
|
|
|
|
2003-05-09 14:42:42 +02:00
|
|
|
|
//------------------------------------------------------------ thumbnail upload
|
2003-05-17 12:49:14 +02:00
|
|
|
|
if ( isset( $_POST['submit'] ) and isset( $_GET['waiting_id'] ) )
|
2003-05-09 14:42:42 +02:00
|
|
|
|
{
|
|
|
|
|
// upload of the thumbnail
|
|
|
|
|
$query = 'select file';
|
2004-02-22 03:43:13 +01:00
|
|
|
|
$query.= ' from '.WAITING_TABLE;
|
2003-05-09 14:42:42 +02:00
|
|
|
|
$query.= ' where id = '.$_GET['waiting_id'];
|
|
|
|
|
$query.= ';';
|
2004-10-30 17:42:29 +02:00
|
|
|
|
$result= pwg_query( $query );
|
2003-05-09 14:42:42 +02:00
|
|
|
|
$row = mysql_fetch_array( $result );
|
|
|
|
|
$file = substr ( $row['file'], 0, strrpos ( $row['file'], ".") );
|
|
|
|
|
$extension = get_extension( $_FILES['picture']['name'] );
|
2006-12-03 23:32:02 +01:00
|
|
|
|
|
2007-02-27 02:56:16 +01:00
|
|
|
|
if (($path = mkget_thumbnail_dir($category['cat_dir'], $error)) != false)
|
2003-05-09 14:42:42 +02:00
|
|
|
|
{
|
2006-12-03 23:32:02 +01:00
|
|
|
|
$path.= '/'.$conf['prefix_thumbnail'].$file.'.'.$extension;
|
|
|
|
|
$result = validate_upload( $path, $conf['upload_maxfilesize'],
|
|
|
|
|
$conf['upload_maxwidth_thumbnail'],
|
|
|
|
|
$conf['upload_maxheight_thumbnail'] );
|
|
|
|
|
for ( $j = 0; $j < sizeof( $result['error'] ); $j++ )
|
|
|
|
|
{
|
|
|
|
|
array_push( $error, $result['error'][$j] );
|
|
|
|
|
}
|
2003-05-09 14:42:42 +02:00
|
|
|
|
}
|
2006-12-03 23:32:02 +01:00
|
|
|
|
|
2003-05-09 14:42:42 +02:00
|
|
|
|
if ( sizeof( $error ) == 0 )
|
|
|
|
|
{
|
2004-02-22 03:43:13 +01:00
|
|
|
|
$query = 'update '.WAITING_TABLE;
|
2003-05-09 14:42:42 +02:00
|
|
|
|
$query.= " set tn_ext = '".$extension."'";
|
|
|
|
|
$query.= ' where id = '.$_GET['waiting_id'];
|
|
|
|
|
$query.= ';';
|
2004-10-30 17:42:29 +02:00
|
|
|
|
pwg_query( $query );
|
2003-05-09 14:42:42 +02:00
|
|
|
|
$page['upload_successful'] = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2004-02-22 03:43:13 +01:00
|
|
|
|
//
|
|
|
|
|
// Start output of page
|
|
|
|
|
//
|
2006-12-03 23:32:02 +01:00
|
|
|
|
$title= l10n('upload_title');
|
|
|
|
|
$page['body_id'] = 'theUploadPage';
|
2004-02-22 03:43:13 +01:00
|
|
|
|
include(PHPWG_ROOT_PATH.'include/page_header.php');
|
|
|
|
|
$template->set_filenames(array('upload'=>'upload.tpl'));
|
|
|
|
|
|
2008-05-02 23:56:21 +02:00
|
|
|
|
// Load category list
|
|
|
|
|
$query = '
|
|
|
|
|
SELECT
|
|
|
|
|
id, name, uppercats, global_rank
|
|
|
|
|
FROM '.CATEGORIES_TABLE.' INNER JOIN '.USER_CACHE_CATEGORIES_TABLE.'
|
|
|
|
|
ON id = cat_id and user_id = '.$user['id'].'
|
|
|
|
|
WHERE
|
|
|
|
|
uploadable = \'true\'
|
|
|
|
|
'.get_sql_condition_FandF
|
|
|
|
|
(
|
|
|
|
|
array
|
|
|
|
|
(
|
|
|
|
|
'visible_categories' => 'id',
|
|
|
|
|
),
|
|
|
|
|
'AND'
|
|
|
|
|
).'
|
|
|
|
|
;';
|
|
|
|
|
display_select_cat_wrapper($query, array($page['category']), 'categories');
|
|
|
|
|
|
2007-02-20 23:07:52 +01:00
|
|
|
|
$u_form = PHPWG_ROOT_PATH.'upload.php?cat='.$page['category'];
|
2004-02-22 03:43:13 +01:00
|
|
|
|
if ( isset( $page['waiting_id'] ) )
|
|
|
|
|
{
|
|
|
|
|
$u_form.= '&waiting_id='.$page['waiting_id'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( isset( $page['waiting_id'] ) )
|
|
|
|
|
{
|
2008-05-02 23:56:21 +02:00
|
|
|
|
$advise_title = l10n('upload_advise_thumbnail').$_FILES['picture']['name'];
|
2004-02-22 03:43:13 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2008-05-02 23:56:21 +02:00
|
|
|
|
$advise_title = l10n('Choose an image');
|
2004-02-22 03:43:13 +01:00
|
|
|
|
}
|
|
|
|
|
|
2008-03-08 02:38:37 +01:00
|
|
|
|
$template->assign(
|
2006-03-15 23:44:35 +01:00
|
|
|
|
array(
|
|
|
|
|
'ADVISE_TITLE' => $advise_title,
|
|
|
|
|
'NAME' => $username,
|
|
|
|
|
'EMAIL' => $mail_address,
|
|
|
|
|
'NAME_IMG' => $name,
|
|
|
|
|
'AUTHOR_IMG' => $author,
|
|
|
|
|
'DATE_IMG' => $date_creation,
|
|
|
|
|
'COMMENT_IMG' => $comment,
|
2006-12-03 23:32:02 +01:00
|
|
|
|
|
2006-03-15 23:44:35 +01:00
|
|
|
|
'F_ACTION' => $u_form,
|
2004-02-22 03:43:13 +01:00
|
|
|
|
|
2007-02-27 02:56:16 +01:00
|
|
|
|
'U_RETURN' => make_index_url(array('category' => $category)),
|
2006-03-15 23:44:35 +01:00
|
|
|
|
)
|
|
|
|
|
);
|
2008-03-08 02:38:37 +01:00
|
|
|
|
|
|
|
|
|
$template->assign('errors', $error);
|
|
|
|
|
$template->assign('UPLOAD_SUCCESSFUL', $page['upload_successful'] );
|
|
|
|
|
|
2003-05-09 14:42:42 +02:00
|
|
|
|
if ( !$page['upload_successful'] )
|
|
|
|
|
{
|
|
|
|
|
//--------------------------------------------------------------------- advises
|
2004-02-22 03:43:13 +01:00
|
|
|
|
if ( !empty($conf['upload_maxfilesize']) )
|
2003-05-09 14:42:42 +02:00
|
|
|
|
{
|
2006-12-03 23:32:02 +01:00
|
|
|
|
$content = l10n('upload_advise_filesize');
|
2003-05-09 14:42:42 +02:00
|
|
|
|
$content.= $conf['upload_maxfilesize'].' KB';
|
2008-03-08 02:38:37 +01:00
|
|
|
|
$template->append('advises', $content);
|
2003-05-09 14:42:42 +02:00
|
|
|
|
}
|
2004-02-22 03:43:13 +01:00
|
|
|
|
|
2003-05-09 14:42:42 +02:00
|
|
|
|
if ( isset( $page['waiting_id'] ) )
|
|
|
|
|
{
|
|
|
|
|
if ( $conf['upload_maxwidth_thumbnail'] != '' )
|
|
|
|
|
{
|
2006-12-03 23:32:02 +01:00
|
|
|
|
$content = l10n('upload_advise_width');
|
2003-05-09 14:42:42 +02:00
|
|
|
|
$content.= $conf['upload_maxwidth_thumbnail'].' px';
|
2008-03-08 02:38:37 +01:00
|
|
|
|
$template->append('advises', $content);
|
2003-05-09 14:42:42 +02:00
|
|
|
|
}
|
|
|
|
|
if ( $conf['upload_maxheight_thumbnail'] != '' )
|
|
|
|
|
{
|
2006-12-03 23:32:02 +01:00
|
|
|
|
$content = l10n('upload_advise_height');
|
2003-05-09 14:42:42 +02:00
|
|
|
|
$content.= $conf['upload_maxheight_thumbnail'].' px';
|
2008-03-08 02:38:37 +01:00
|
|
|
|
$template->append('advises', $content);
|
2003-05-09 14:42:42 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if ( $conf['upload_maxwidth'] != '' )
|
|
|
|
|
{
|
2006-12-03 23:32:02 +01:00
|
|
|
|
$content = l10n('upload_advise_width');
|
2003-05-09 14:42:42 +02:00
|
|
|
|
$content.= $conf['upload_maxwidth'].' px';
|
2008-03-08 02:38:37 +01:00
|
|
|
|
$template->append('advises', $content);
|
2003-05-09 14:42:42 +02:00
|
|
|
|
}
|
|
|
|
|
if ( $conf['upload_maxheight'] != '' )
|
|
|
|
|
{
|
2006-12-03 23:32:02 +01:00
|
|
|
|
$content = l10n('upload_advise_height');
|
2003-05-09 14:42:42 +02:00
|
|
|
|
$content.= $conf['upload_maxheight'].' px';
|
2008-03-08 02:38:37 +01:00
|
|
|
|
$template->append('advises', $content);
|
2003-05-09 14:42:42 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
2008-03-08 02:38:37 +01:00
|
|
|
|
$template->append('advises', l10n('upload_advise_filetype'));
|
|
|
|
|
|
2003-05-09 14:42:42 +02:00
|
|
|
|
//----------------------------------------- optionnal username and mail address
|
|
|
|
|
if ( !isset( $page['waiting_id'] ) )
|
|
|
|
|
{
|
2008-03-08 02:38:37 +01:00
|
|
|
|
$template->assign('SHOW_FORM_FIELDS', true);
|
2003-05-09 14:42:42 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
2006-12-03 23:32:02 +01:00
|
|
|
|
|
2003-05-09 14:42:42 +02:00
|
|
|
|
//----------------------------------------------------------- html code display
|
2005-01-13 11:18:49 +01:00
|
|
|
|
$template->parse('upload');
|
2004-02-22 03:43:13 +01:00
|
|
|
|
include(PHPWG_ROOT_PATH.'include/page_tail.php');
|
2004-02-12 00:20:38 +01:00
|
|
|
|
?>
|