Debugged upload_data_file method unified for upload_data_file & add eventz and moved...
authorDaniel Hromada <hromi@Aphrodité>
Mon, 10 Oct 2011 22:41:52 +0000 (00:41 +0200)
committerDaniel Hromada <hromi@Aphrodité>
Mon, 10 Oct 2011 22:41:52 +0000 (00:41 +0200)
wwwroot/inc/eventz/add.inc
wwwroot/inc/eventz/upload_data_file.inc
wwwroot/inc/filez.inc

index f77499df345a89fc8eb87bc4eee120d96d969e93..e4b68d03f65cc2e975ab867cf9a30c1f44b868a5 100644 (file)
@@ -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
index 7c21f3ae8b83bd0e84ceba2dffbb3889e0e5fee6..3af0a9381d2c6d094fcbc8f8a428dd0f44e14454 100644 (file)
@@ -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']);
        }
+*/
 }
 ?>
index a7fcd3943238e1abc73f0f3783461d187fd226f0..09bd11a37652709c1783c20bcdd3ea079ab792cd 100644 (file)
@@ -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);
+
+}
+
 }
 ?>
This page took 0.155147 seconds and 4 git commands to generate.