<?php
/*
 * This file is part of the Easy-CMS project.
 * Easy-CMS 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; either version 2 of the License, or
 * (at your option) any later version.
 *
 * Easy-CMS is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * 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 Easy-CMS; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

// define the path context
chdir('..');
define('EASY_GUI_APP_DIR', '../');


include_once('config.inc.php');
include_once('classes/core/Site.class.php');
include_once('interface/egManager.class.php');

define('UPLOAD_DOCUMENT', 1);
define('UPLOAD_IMAGE', 2);

$site = &Site::getInstance(); 

//security check : user must be identified to upload some file
$user = $site->getCurrentUser();
if(!$user || $user->getUserId() == USER_ID_ANONYMOUS) {
	die("access denied");
	exit();
}

$user = $site->getCurrentUser();
$manager = &egManager::getInstance();
$browser = &$manager->browser;

$url = "http://".$site->getHostName();

$scriptPath = $site->getScriptPath();
if(strlen($scriptPath)) {
	$url .= "/".$scriptPath;
}

$url .= "/create_node.php?";
$url .= "mode=create_node";
$url .= "&type=file";
$url .= "&path=".$site->getSubmittedVar('path');
$url .= "&action=login";
$url .= "&login=".$user->getUserLogin();
$url .= "&password=".$user->getUserPassword();

$uploadType = $site->getSubmittedVar('upload_type', UPLOAD_DOCUMENT);

if($uploadType == UPLOAD_DOCUMENT) {
	$height = 470;
}
else {
	$height = 370;
}

if($browser->isBrowser(INTERNET_EXPLORER)) {
	$height += 6;
}

if ($UILanguage == LANG_FR) {
	$lang = 'fr';
}
else {
	$lang = 'en';
}

?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body style="border: 0; margin: 0; padding: 0;">
<applet code="wjhk.jupload2.JUploadApplet" archive="wjhk.jupload.jar" mayscript="" height="<?php echo $height;?>" width="640">
   <param name="postURL" value="<?php echo $url;?>">
<?php
	if($uploadType == UPLOAD_DOCUMENT) {
?>
   <param name="allowedFileExtensions" value="doc/pdf/txt/html/htm/xls/csv">

<?php
	}
	else {
?>
   <param name="uploadPolicy" value="PictureUploadPolicy">
   <param name="maxPicWidth" value="800">
   <param name="maxPicHeight" value="600">
   <param name="allowedFileExtensions" value="jpg/jpeg/png/gif">
<?php
	}
?>
   <param name="debugLevel" value="1">
   <param name="serverProtocol" value="HTTP/1.1">
   <param name="filenameEncoding" value="UTF-8">
   <param name="lang" value="<?php echo $lang;?>">
   <param name="nbFilesPerRequest" value="1">
   <param name="showStatusBar" value="false">
   <param name="maxFileSize" value="10000000">
Java 1.5 or higher plugin required.
</applet>
</body>
</html>