From ada9628bbca72bea82b1f4aa358bc1262071250b Mon Sep 17 00:00:00 2001 From: hickert Date: Wed, 17 Nov 2010 09:15:15 +0000 Subject: [PATCH] Updated handling of uploaded files, thanks to bcooksley git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@20243 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../addons/ldapmanager/class_csvimport.inc | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/gosa-plugins/ldapmanager/addons/ldapmanager/class_csvimport.inc b/gosa-plugins/ldapmanager/addons/ldapmanager/class_csvimport.inc index 6006edf7d..2dfabee20 100644 --- a/gosa-plugins/ldapmanager/addons/ldapmanager/class_csvimport.inc +++ b/gosa-plugins/ldapmanager/addons/ldapmanager/class_csvimport.inc @@ -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 { -- 2.30.2