From 84c1a47338e32ca67d4b6401cb7f2c3253011a0e Mon Sep 17 00:00:00 2001 From: Daniel Hromada Date: Tue, 11 Oct 2011 00:41:52 +0200 Subject: [PATCH] Debugged upload_data_file method unified for upload_data_file & add eventz and moved to filez:: class. --- wwwroot/inc/eventz/add.inc | 4 ++-- wwwroot/inc/eventz/upload_data_file.inc | 17 ++++------------- wwwroot/inc/filez.inc | 14 ++++++++++++++ 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/wwwroot/inc/eventz/add.inc b/wwwroot/inc/eventz/add.inc index f77499d..e4b68d0 100644 --- a/wwwroot/inc/eventz/add.inc +++ b/wwwroot/inc/eventz/add.inc @@ -106,8 +106,8 @@ function add() { } if ($_FILES['data_file']['tmp_name']) { - copy($_FILES['data_file']['tmp_name'], FILE_DIR.$_SESSION['user_id'].'/'.$node_id.".$suffix"); - symlink(FILE_DIR.$_SESSION['user_id'].'/'.$node_id.".$suffix",FILE_DIR.'/'.$node_id); + require(INCLUDE_DIR.'filez.inc'); + filez::upload_data_file($node_id); } //substitute @@@ token by a node_id of a newly created node diff --git a/wwwroot/inc/eventz/upload_data_file.inc b/wwwroot/inc/eventz/upload_data_file.inc index 7c21f3a..3af0a93 100644 --- a/wwwroot/inc/eventz/upload_data_file.inc +++ b/wwwroot/inc/eventz/upload_data_file.inc @@ -14,18 +14,8 @@ function upload_data_file() { } $node_id=$node['node_id']; - - if ( !filez::upload_filename_secure($_FILES['data_file']['name'])) { - $error = 'bad, naughty file type. Cruise missile launched.'; - return false; - } - - if (!is_dir(FILE_DIR.$_SESSION['user_id'])) { - mkdir(FILE_DIR.$_SESSION['user_id']); - } - - $suffix = array_pop(explode('.', basename($_FILES['data_file']['name']))); - + filez::upload_data_file($node_id); +/* if ($suffix=='zip' && $_POST['unzip']) { mkdir(TMP."/".$_FILES['data_file']['name']); @@ -92,7 +82,8 @@ function upload_data_file() { copy($_FILES['data_file']['tmp_name'], FILE_DIR.$_SESSION['user_id'].'/'.$node['node_id'].".$suffix"); symlink(FILE_DIR.$_SESSION['user_id'].'/'.$node['node_id'].".$suffix", - SYSTEM_ROOT.'/files/'.$node['node_id']); + FILE_DIR.'/'.$node['node_id']); } +*/ } ?> diff --git a/wwwroot/inc/filez.inc b/wwwroot/inc/filez.inc index a7fcd39..09bd11a 100644 --- a/wwwroot/inc/filez.inc +++ b/wwwroot/inc/filez.inc @@ -18,5 +18,19 @@ public static function upload_filename_secure($name){ return true; } +public static function upload_data_file($node_id) { + if ( !filez::upload_filename_secure($_FILES['data_file']['name'])) { + $error = 'bad, naughty file type. Cruise missile launched.'; + return false; + } + if (!is_dir(FILE_DIR.$_SESSION['user_id'])) { + mkdir(FILE_DIR.$_SESSION['user_id']); + } + $suffix = array_pop(explode('.', basename($_FILES['data_file']['name']))); + copy($_FILES['data_file']['tmp_name'], FILE_DIR.$_SESSION['user_id'].'/'.$node_id.".$suffix"); + symlink(FILE_DIR.$_SESSION['user_id'].'/'.$node_id.".$suffix",FILE_DIR.'/'.$node_id); + +} + } ?> -- 2.30.2