Code

Updated handling of uploaded files, thanks to bcooksley
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 17 Nov 2010 09:15:15 +0000 (09:15 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 17 Nov 2010 09:15:15 +0000 (09:15 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@20243 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-plugins/ldapmanager/addons/ldapmanager/class_csvimport.inc

index 6006edf7d3bff80b8702bdbe68d9ef15a3c56a22..2dfabee202f8ea500bc7ba3e1e96966d1c5cc6be 100644 (file)
@@ -336,26 +336,28 @@ class csvimport extends plugin
 
         $handle = NULL;
 
+        $filename = gosa_file_name($_FILES['userfile']['tmp_name']);
+
         if((!isset($_FILES['userfile']['name']))||(!isset($_POST['fileup'])))
         {
-         msg_dialog::display(_("Error"), sprintf(_("Cannot read uploaded file: %s"), _("file not found")), ERROR_DIALOG);
-          $smarty->assign("LDIFError",TRUE);
+            msg_dialog::display(_("Error"), sprintf(_("Cannot read uploaded file: %s"), _("file not found")), ERROR_DIALOG);
+            $smarty->assign("LDIFError",TRUE);
         }
         elseif(!$_FILES['userfile']['size'] > 0 )
         {
-         msg_dialog::display(_("Error"), sprintf(_("Cannot read uploaded file: %s"), _("file is empty")), ERROR_DIALOG);
-          $smarty->assign("LDIFError",TRUE);
+            msg_dialog::display(_("Error"), sprintf(_("Cannot read uploaded file: %s"), _("file is empty")), ERROR_DIALOG);
+            $smarty->assign("LDIFError",TRUE);
         }
         /* Is there a tmp file, which we can use ? */
-        elseif(!file_exists($_FILES['userfile']['tmp_name']))
+        elseif(!file_exists($filename))
         {
-         msg_dialog::display(_("Error"), sprintf(_("Cannot read uploaded file: %s"), _("file not found")), ERROR_DIALOG);
-          $smarty->assign("LDIFError",TRUE);
+            msg_dialog::display(_("Error"), sprintf(_("Cannot read uploaded file: %s"), _("file not found")), ERROR_DIALOG);
+            $smarty->assign("LDIFError",TRUE);
         }
-        elseif(!$handle = @fopen($_FILES['userfile']['tmp_name'],"r"))
+        elseif(!$handle = @fopen($filename,"r"))
         {
-         msg_dialog::display(_("Error"), sprintf(_("Cannot read uploaded file: %s"), _("file not readable")), ERROR_DIALOG);
-          $smarty->assign("LDIFError",TRUE);
+            msg_dialog::display(_("Error"), sprintf(_("Cannot read uploaded file: %s"), _("file not readable")), ERROR_DIALOG);
+            $smarty->assign("LDIFError",TRUE);
         }
         else
         {