From fdd9d34481c1ea543c89bee33e7958e00cc395b7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 5 Jan 2010 23:01:25 +0000 Subject: [PATCH] New: First change to support all antiviruses --- htdocs/admin/security_other.php | 178 +++++++++++++++++--------------- htdocs/langs/en_US/admin.lang | 1 + htdocs/langs/fr_FR/admin.lang | 1 + htdocs/product/document.php | 5 +- 4 files changed, 102 insertions(+), 83 deletions(-) diff --git a/htdocs/admin/security_other.php b/htdocs/admin/security_other.php index 389387c359b..3d60db2e9ef 100644 --- a/htdocs/admin/security_other.php +++ b/htdocs/admin/security_other.php @@ -25,6 +25,7 @@ require("./pre.inc.php"); require_once(DOL_DOCUMENT_ROOT."/lib/admin.lib.php"); +require_once(DOL_DOCUMENT_ROOT."/html.formfile.class.php"); $langs->load("users"); $langs->load("admin"); @@ -32,10 +33,38 @@ $langs->load("other"); if (!$user->admin) accessforbidden(); +$upload_dir=$conf->admin->dir_temp; + /* * Actions */ + +if ($_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC)) +{ + /* + * Creation repertoire si n'existe pas + */ + if (! is_dir($upload_dir)) create_exdir($upload_dir); + + if (is_dir($upload_dir)) + { + @dol_delete_file($upload_dir . "/" . $_FILES['userfile']['name'],1); + + if (dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name'],0) > 0) + { + $mesg = '
'.$langs->trans("FileTransferComplete").'
'; + //print_r($_FILES); + } + else + { + // Echec transfert (fichier depassant la limite ?) + $mesg = '
'.$langs->trans("ErrorFileNotUploaded").'
'; + // print_r($_FILES); + } + } +} + if ($_GET["action"] == 'set_main_upload_doc') { if (! dolibarr_set_const($db, 'MAIN_UPLOAD_DOC',$_POST["MAIN_UPLOAD_DOC"],'chaine',0,'',$conf->entity)) @@ -89,11 +118,20 @@ else if ($_GET["action"] == 'disable_avscan') exit; } +if ($_GET["action"] == 'MAIN_ANTIVIRUS_COMMAND') +{ + dolibarr_set_const($db, "MAIN_ANTIVIRUS_COMMAND", $_POST["MAIN_ANTIVIRUS_COMMAND"],'chaine',0,'',$conf->entity); + Header("Location: security_other.php"); + exit; +} + /* * Affichage onglet */ +$form = new Form($db); + llxHeader('',$langs->trans("Miscellanous")); print_fiche_titre($langs->trans("SecuritySetup"),'','setup'); @@ -101,55 +139,21 @@ print_fiche_titre($langs->trans("SecuritySetup"),'','setup'); print $langs->trans("MiscellanousDesc")."
\n"; print "
\n"; - $head=security_prepare_head(); dol_fiche_head($head, 'misc', $langs->trans("Security")); -$var=false; -$form = new Form($db); - +// Timeout +$var=true; print ''; print ''; -print ''; +print ''; print ''; print ''; print "\n"; - -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; - -$var=!$var; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; - $var=!$var; if (empty($conf->global->MAIN_SESSION_TIMEOUT)) $conf->global->MAIN_SESSION_TIMEOUT=ini_get("session.gc_maxlifetime"); print ''; @@ -161,7 +165,7 @@ print ''; print ''; -print ''; print ''; @@ -172,7 +176,6 @@ print '
'; // Other Options - $var=true; print '
'.$langs->trans("Parameter").''.$langs->trans("Parameters").''.$langs->trans("Value").' 
'.$langs->trans("MaxSizeForUploadedFiles").'.'; -$max=@ini_get('upload_max_filesize'); -if ($max) print ' '.$langs->trans("MustBeLowerThanPHPLimit",$max*1024,$langs->trans("Kb")).'.'; -else print ' '.$langs->trans("NoMaxSizeByPHPLimit").'.'; -print ''; -print ' '.$langs->trans("Kb"); -print ''; -print ''; -print '
'.$langs->trans("UMask").''; -print $form->textwithpicto('',$langs->trans("UMaskExplanation")); -print ''; -print ''; -print ''; -print ''; -print '
'; print ' '.$langs->trans("seconds"); print ''; +print ''; print ''; print '
'; @@ -220,64 +223,77 @@ print '
'; print '
'; -// Antivirus options -$var=true; +// Upload options +$var=false; print ''; print ''; -print ''; -print ''; -print ''; +print ''; +print ''; print ''; -// Enable AV scanner -$var=!$var; -print ""; -print ''; +print ''; -print ''; +print ''; +print ''; + +$var=!$var; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; + +// Use anti virus +$var=!$var; +print ''; +print ""; +print ''; print '"; - +print ''; print ""; +print ''; print ''; +print ''; print '
'.$langs->trans("AntiVirus").''.$langs->trans("Activated").''.$langs->trans("Action").''.$langs->trans("Parameters").''.$langs->trans("Value").'
'.$langs->trans("UseAvToScanUploadedFiles"); -if($conf->global->MAIN_USE_AVSCAN == 1) -{ - print ' : '; - // Clamav - if (function_exists("cl_scanfile")) - { - print cl_info(); - } -} +print '
'; +print ''; +print '
'.$langs->trans("MaxSizeForUploadedFiles").'.'; +$max=@ini_get('upload_max_filesize'); +if ($max) print ' '.$langs->trans("MustBeLowerThanPHPLimit",$max*1024,$langs->trans("Kb")).'.'; +else print ' '.$langs->trans("NoMaxSizeByPHPLimit").'.'; print ''; -if($conf->global->MAIN_USE_AVSCAN == 1) -{ - print img_tick(); -} +print ''; +print ' '.$langs->trans("Kb"); +print ''; +print ''; +print '
'.$langs->trans("UMask").''; +print $form->textwithpicto('',$langs->trans("UMaskExplanation")); +print ''; +print ''; +print ''; +print ''; +print '
'.$langs->trans("AntiVirusCommand").'
'; +print $langs->trans("AntiVirusCommandExample"); print '
'; -if (function_exists("cl_scanfile")) // Clamav -{ - if ($conf->global->MAIN_USE_AVSCAN == 0) - { - print ''.$langs->trans("Activate").''; - } - if($conf->global->MAIN_USE_AVSCAN == 1) - { - print ''.$langs->trans("Disable").''; - } -} -else -{ - $html = new Form($db); - $desc = $html->textwithpicto('',$langs->transnoentities("EnablePhpAVModuleDesc"),1,'warning'); - print $desc; -} -print "'; +print ''; +print '
'; print ''; + +// Form to test upload +if ($mesg) print $mesg; + +// Affiche formulaire upload +print '
'; +$formfile=new FormFile($db); +$formfile->form_attach_new_file(DOL_URL_ROOT.'/admin/security_other.php',$langs->trans("FormToTestFileUploadForm"),0,0,1); + + $db->close(); llxFooter('$Date$ - $Revision$'); diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 413626b5178..16337edcdbd 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -34,6 +34,7 @@ ExternalUsers=External users GlobalSetup=Global setup GUISetup=Display SetupArea=Setup area +FormToTestFileUploadForm=Form to test file upload (according to setup) IfModuleEnabled=Note: yes is effective only if module %s is enabled RemoveLock=Remove file %s if it exists to allow the update tool. RestoreLock=Replace a file %s with read permission only on file to disable any usage of update tool. diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang index a14178036f9..a35ee7936e8 100644 --- a/htdocs/langs/fr_FR/admin.lang +++ b/htdocs/langs/fr_FR/admin.lang @@ -34,6 +34,7 @@ ExternalUsers = Utilisateurs externes GlobalSetup = Général GUISetup = Affichage SetupArea = Espace configuration +FormToTestFileUploadForm=Formulaire de test d'upload de fichier (selon options choisies) IfModuleEnabled = Rem: oui est effectif uniquement si le module %s est activé RemoveLock = Effacer le fichier %s s'il existe afin d'autoriser l'outil de mise a jour. RestoreLock = Replacer un fichier %s en ne donnant des droits que de lecture sur ce fichier afin d'interdire à nouveau les mises à jour. diff --git a/htdocs/product/document.php b/htdocs/product/document.php index 9f8939b3c0a..9be98fe6326 100755 --- a/htdocs/product/document.php +++ b/htdocs/product/document.php @@ -74,10 +74,11 @@ $modulepart='produit'; /* * Action envoie fichier */ + if ($_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC)) { /* - * Creation r�pertoire si n'existe pas + * Creation repertoire si n'existe pas */ if (! is_dir($upload_dir)) create_exdir($upload_dir); @@ -90,7 +91,7 @@ if ($_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC)) } else { - // Echec transfert (fichier d�passant la limite ?) + // Echec transfert (fichier depassant la limite ?) $mesg = '
'.$langs->trans("ErrorFileNotUploaded").'
'; // print_r($_FILES); }