From: Daniel Hromada Date: Mon, 10 Oct 2011 22:41:52 +0000 (+0200) Subject: Debugged upload_data_file method unified for upload_data_file & add eventz and moved... X-Git-Url: https://git.harvie.cz/?p=mirrors%2FKyberia-bloodline.git;a=commitdiff_plain;h=84c1a47338e32ca67d4b6401cb7f2c3253011a0e Debugged upload_data_file method unified for upload_data_file & add eventz and moved to filez:: class. --- 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); + +} + } ?>