<?php
/**
  @licence GPL 2005-2011  The osCSS developers - osCSS Open Source E-commerce
  @portion code Copyright (c) 2002 osCommerce
  @package osCSS-2 <www http://www.oscss.org>
  @version 2.1.0
  @date  27/03/11, 16:53
  @author oscim <mail aurelien@oscim.fr> <www http://www.oscim.fr>
  @encode UTF-8
*/
require_once('config_tinybrowser.php');
require_once('fns_tinybrowser.php');

// Check hash is correct (workaround for Flash session bug, to stop external form posting)
if($_GET['obfuscate'] != md5($_SERVER['DOCUMENT_ROOT'].$tinybrowser['obfuscate'])) { echo 'Error! obfuscate'; exit; }

// Check  and assign get variables
if(isset($_GET['type'])) { $typenow = $_GET['type']; } else { echo 'Error! type'; exit; }
if(isset($_GET['folder'])) { $dest_folder = urldecode($_GET['folder']); } else { echo 'Error! folder'; exit; }

// Check file extension isn't prohibited
$nameparts = explode('.',$_FILES['Filedata']['name']);
$ext = end($nameparts);

if(!validateExtension($ext, $tinybrowser['prohibited'])) { echo 'Error! prohibited'; exit; }

// Check file data
if ($_FILES['Filedata']['tmp_name'] && $_FILES['Filedata']['name'])
	{
	$source_file = $_FILES['Filedata']['tmp_name'];
	$file_name = stripslashes($_FILES['Filedata']['name']);
	$dest_folder=((!empty($dest_folder)) ? $dest_folder :'' );
	if($tinybrowser['cleanfilename']) $file_name = clean_filename($file_name);

	if(is_dir(DIR_FS_WORK)) {

		$success = copy($source_file,DIR_FS_WORK.$file_name.'_');
	      }

	if($success)
		{

		header('HTTP/1.1 200 OK');
header('Content-type: text/plain');

echo  'File Upload Success' ;
    return true;
		?>
<?php
		}
	}
?>
