Fix: Better error management in upload files

This commit is contained in:
Laurent Destailleur 2010-05-01 14:28:48 +00:00
parent 9e887c8980
commit 968addfad3
36 changed files with 739 additions and 591 deletions

View File

@ -212,6 +212,8 @@ if ($_REQUEST["action"] == 'confirm_sendinfo' && $_REQUEST["confirm"] == 'yes')
if ($_REQUEST["action"] == 'update' && ! $_POST["cancel"] && $user->rights->adherent->creer)
{
require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
$datenaiss='';
if (isset($_POST["naissday"]) && $_POST["naissday"]
&& isset($_POST["naissmonth"]) && $_POST["naissmonth"]
@ -293,7 +295,7 @@ if ($_REQUEST["action"] == 'update' && ! $_POST["cancel"] && $user->rights->adhe
if (@is_dir($dir))
{
$newfile=$dir.'/'.$_FILES['photo']['name'];
if (! dol_move_uploaded_file($_FILES['photo']['tmp_name'],$newfile,1) > 0)
if (! dol_move_uploaded_file($_FILES['photo']['tmp_name'],$newfile,1,0,$_FILES['photo']['error']) > 0)
{
$message .= '<div class="error">'.$langs->trans("ErrorFailedToSaveFile").'</div>';
}

View File

@ -51,6 +51,8 @@ $quality = 80;
if ( (isset($_POST["action"]) && $_POST["action"] == 'update')
|| (isset($_POST["action"]) && $_POST["action"] == 'updateedit') )
{
require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
dolibarr_set_const($db, "MAIN_INFO_SOCIETE_NOM",$_POST["nom"],'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_INFO_SOCIETE_ADRESSE",$_POST["address"],'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_INFO_SOCIETE_VILLE",$_POST["ville"],'chaine',0,'',$conf->entity);
@ -77,7 +79,7 @@ if ( (isset($_POST["action"]) && $_POST["action"] == 'update')
{
create_exdir($conf->mycompany->dir_output.'/logos/');
}
if (dol_move_uploaded_file($_FILES["logo"]["tmp_name"],$conf->mycompany->dir_output.'/logos/'.$original_file,1) > 0)
if (dol_move_uploaded_file($_FILES["logo"]["tmp_name"],$conf->mycompany->dir_output.'/logos/'.$original_file,1,0,$_FILES['logo']['error']) > 0)
{
dolibarr_set_const($db, "MAIN_INFO_SOCIETE_LOGO",$original_file,'chaine',0,'',$conf->entity);

View File

@ -68,40 +68,46 @@ if (isset($_POST["action"]) && $_POST["action"] == 'update')
*/
if ($_POST['addfile'] || $_POST['addfilehtml'])
{
require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
// Set tmp user directory
$vardir=$conf->user->dir_output."/".$user->id;
$upload_dir = $vardir.'/temp/';
if (! empty($_FILES['addedfile']['tmp_name']))
if (create_exdir($upload_dir) >= 0)
{
if (! is_dir($upload_dir)) create_exdir($upload_dir);
if (is_dir($upload_dir))
$resupload=dol_move_uploaded_file($_FILES['addedfile']['tmp_name'], $upload_dir . "/" . $_FILES['addedfile']['name'],0,0,$_FILES['addedfile']['error']);
if (is_numeric($resupload) && $resupload > 0)
{
$result = dol_move_uploaded_file($_FILES['addedfile']['tmp_name'], $upload_dir . "/" . $_FILES['addedfile']['name'],0);
if ($result > 0)
{
$message = '<div class="ok">'.$langs->trans("FileTransferComplete").'</div>';
//print_r($_FILES);
$mesg = '<div class="ok">'.$langs->trans("FileTransferComplete").'</div>';
include_once(DOL_DOCUMENT_ROOT.'/html.formmail.class.php');
$formmail = new FormMail($db);
$formmail->add_attached_files($upload_dir . "/" . $_FILES['addedfile']['name'],$_FILES['addedfile']['name'],$_FILES['addedfile']['type']);
}
else if ($result == -99)
include_once(DOL_DOCUMENT_ROOT.'/html.formmail.class.php');
$formmail = new FormMail($db);
$formmail->add_attached_files($upload_dir . "/" . $_FILES['addedfile']['name'],$_FILES['addedfile']['name'],$_FILES['addedfile']['type']);
}
else
{
$langs->load("errors");
if ($resupload < 0) // Unknown error
{
$mesg = '<div class="error">'.$langs->trans("ErrorFileNotUploaded").'</div>';
}
else if (preg_match('/ErrorFileIsInfectedWithAVirus/',$resupload)) // Files infected by a virus
{
// Files infected by a virus
$langs->load("errors");
$mesg = '<div class="error">'.$langs->trans("ErrorFileIsInfectedWithAVirus").'</div>';
}
else if ($result < 0)
else // Known error
{
// Echec transfert (fichier depassant la limite ?)
$mesg = '<div class="error">'.$langs->trans("ErrorFileNotUploaded").'</div>';
// print_r($_FILES);
$mesg = '<div class="error">'.$langs->trans($resupload).'</div>';
}
}
}
else
{
$langs->load("errors");
$mesg = '<div class="error">'.$langs->trans("ErrorFailToCreateDir",$upload_dir).'</div>';
}
if ($_POST['addfile']) $_GET["action"]='test';
if ($_POST['addfilehtml']) $_GET["action"]='testhtml';
}

View File

@ -42,29 +42,37 @@ $upload_dir=$conf->admin->dir_temp;
if ($_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC))
{
$result=create_exdir($upload_dir); // Create dir if not exists
require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
$result=create_exdir($upload_dir); // Create dir if not exists
if ($result >= 0)
{
$resupload=dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name'],1);
if (is_numeric($resupload) && $resupload > 0)
{
$mesg = '<div class="ok">'.$langs->trans("FileTransferComplete").'</div>';
//print_r($_FILES);
}
else if (is_numeric($resupload) && $resupload == -99)
{
// File infected by a virus
$langs->load("errors");
$mesg = '<div class="error">'.$langs->trans("ErrorFileIsInfectedWithAVirus").'</div>';
}
else
{
// Echec transfert (fichier depassant la limite ?)
$mesg = '<div class="error">'.$langs->trans("ErrorFileNotUploaded");
if (is_array($resupload)) $mesg.= '<br>'.dol_nl2br(join("\n",$resupload));
$mesg.= '</div>';
// print_r($_FILES);
}
$resupload=dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name'],1,0,$_FILES['userfile']['error']);
if (is_numeric($resupload) && $resupload > 0)
{
$mesg = '<div class="ok">'.$langs->trans("FileTransferComplete").'</div>';
include_once(DOL_DOCUMENT_ROOT.'/html.formmail.class.php');
$formmail = new FormMail($db);
$formmail->add_attached_files($upload_dir . "/" . $_FILES['addedfile']['name'],$_FILES['addedfile']['name'],$_FILES['addedfile']['type']);
}
else
{
$langs->load("errors");
if ($resupload < 0) // Unknown error
{
$mesg = '<div class="error">'.$langs->trans("ErrorFileNotUploaded").'</div>';
}
else if (preg_match('/ErrorFileIsInfectedWithAVirus/',$resupload)) // Files infected by a virus
{
$mesg = '<div class="error">'.$langs->trans("ErrorFileIsInfectedWithAVirus").'</div>';
}
else // Known error
{
$mesg = '<div class="error">'.$langs->trans($resupload).'</div>';
}
}
}
}
@ -261,8 +269,20 @@ print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print "<tr ".$bc[$var].">";
print '<td colspan="2">'.$langs->trans("AntiVirusCommand").'<br>';
print $langs->trans("AntiVirusCommandExample");
// Check command in inside safe_mode
print '</td>';
print '<td align="center" width="100">';
if (ini_get('safe_mode') && ! empty($conf->global->MAIN_ANTIVIRUS_COMMAND))
{
$langs->load("errors");
$basedir=preg_replace('/"/','',dirname($conf->global->MAIN_ANTIVIRUS_COMMAND));
$listdir=explode(';',ini_get('safe_mode_exec_dir'));
if (! in_array($basedir,$listdir))
{
print img_warning($langs->trans('WarningSafeModeOnCheckExecDir'));
dol_syslog("safe_mode is on, basedir is ".$basedir.", safe_mode_exec_dir is ".ini_get('safe_mode_exec_dir'), LOG_WARNING);
}
}
print '<input type="text" name="MAIN_ANTIVIRUS_COMMAND" size=80 value="'.htmlentities($conf->global->MAIN_ANTIVIRUS_COMMAND).'">';
print "</td>";
print '<td align="right">';

View File

@ -1018,6 +1018,8 @@ class Categorie
*/
function add_photo($sdir, $file, $maxWidth = 160, $maxHeight = 120)
{
require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
$dir = $sdir .'/'. get_exdir($this->id,2) . $this->id ."/";
$dir .= "photos/";
@ -1031,7 +1033,7 @@ class Categorie
$originImage = $dir . $file['name'];
// Cree fichier en taille origine
$result=dol_move_uploaded_file($file['tmp_name'], $originImage, 1);
$result=dol_move_uploaded_file($file['tmp_name'], $originImage, 1, 0, 0);
if (file_exists($originImage))
{

View File

@ -69,31 +69,33 @@ $pagenext = $page + 1;
*/
if ( $_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC))
{
/*
* Creation repertoire si n'existe pas
*/
$upload_dir = $conf->agenda->dir_output.'/'.dol_sanitizeFileName($objectid);
if (! is_dir($upload_dir)) create_exdir($upload_dir);
require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
if (is_dir($upload_dir))
// Creation repertoire si n'existe pas
$upload_dir = $conf->agenda->dir_output.'/'.dol_sanitizeFileName($objectid);
if (create_exdir($upload_dir) >= 0)
{
$result = dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name'],0);
if ($result > 0)
{
$mesg = '<div class="ok">'.$langs->trans("FileTransferComplete").'</div>';
//print_r($_FILES);
}
else if ($result == -99)
{
// Files infected by a virus
$langs->load("errors");
$mesg = '<div class="error">'.$langs->trans("ErrorFileIsInfectedWithAVirus").'</div>';
}
else if ($result < 0)
$resupload=dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name'],0,0,$_FILES['userfile']['error']);
if (is_numeric($resupload) && $resupload > 0)
{
// Echec transfert (fichier depassant la limite ?)
$mesg = '<div class="error">'.$langs->trans("ErrorFileNotUploaded").'</div>';
// print_r($_FILES);
$mesg = '<div class="ok">'.$langs->trans("FileTransferComplete").'</div>';
}
else
{
$langs->load("errors");
if ($resupload < 0) // Unknown error
{
$mesg = '<div class="error">'.$langs->trans("ErrorFileNotUploaded").'</div>';
}
else if (preg_match('/ErrorFileIsInfectedWithAVirus/',$resupload)) // Files infected by a virus
{
$mesg = '<div class="error">'.$langs->trans("ErrorFileIsInfectedWithAVirus").'</div>';
}
else // Known error
{
$mesg = '<div class="error">'.$langs->trans($resupload).'</div>';
}
}
}
}

View File

@ -442,6 +442,8 @@ if (! empty($_POST["removedfile"]))
// Action update emailing
if ($_POST["action"] == 'update' && empty($_POST["removedfile"]) && empty($_POST["cancel"]))
{
require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
$mil = new Mailing($db);
$mil->fetch($_POST["id"]);
@ -451,39 +453,37 @@ if ($_POST["action"] == 'update' && empty($_POST["removedfile"]) && empty($_POST
// If upload file
$i='';
//$i=0;
//while ($i < 4)
//{
if (! empty($_POST["addfile".$i]) && ! empty($conf->global->MAIN_UPLOAD_DOC))
if (! empty($_POST["addfile".$i]) && ! empty($conf->global->MAIN_UPLOAD_DOC))
{
$isupload=1;
if (! is_dir($upload_dir)) create_exdir($upload_dir);
if (is_dir($upload_dir))
{
$isupload=1;
if (! is_dir($upload_dir)) create_exdir($upload_dir);
if (is_dir($upload_dir))
$resupload = dol_move_uploaded_file($_FILES['addedfile'.$i]['tmp_name'], $upload_dir . "/" . $_FILES['addedfile'.$i]['name'],1,0,$_FILES['addedfile'.$i]['error']);
if (is_numeric($resupload) && $resupload > 0)
{
$result = dol_move_uploaded_file($_FILES['addedfile'.$i]['tmp_name'], $upload_dir . "/" . $_FILES['addedfile'.$i]['name'],1);
if ($result > 0)
{
$mesg = '<div class="ok">'.$langs->trans("FileTransferComplete").'</div>';
//print_r($_FILES);
}
else if ($result == -99)
{
// Files infected by a virus
$langs->load("errors");
$mesg = '<div class="error">'.$langs->trans("ErrorFileIsInfectedWithAVirus").'</div>';
}
else if ($result < 0)
$mesg = '<div class="ok">'.$langs->trans("FileTransferComplete").'</div>';
}
else
{
$langs->load("errors");
if ($resupload < 0) // Unknown error
{
// Echec transfert (fichier depassant la limite ?)
$mesg = '<div class="error">'.$langs->trans("ErrorFileNotUploaded").'</div>';
// print_r($_FILES);
}
else if (preg_match('/ErrorFileIsInfectedWithAVirus/',$resupload)) // Files infected by a virus
{
$mesg = '<div class="error">'.$langs->trans("ErrorFileIsInfectedWithAVirus").'</div>';
}
else // Known error
{
$mesg = '<div class="error">'.$langs->trans($resupload).'</div>';
}
}
}
// $i++;
//}
}
if (! $isupload)
{

View File

@ -279,7 +279,7 @@ if ($_POST['action'] == 'add' && $user->rights->propale->creer)
$propal->modelpdf = $_POST['model'];
$propal->author = $user->id; // deprecated
$propal->note = $_POST['note'];
$propal->origin = $_POST['origin'];
$propal->origin_id = $_POST['originid'];
@ -381,38 +381,41 @@ if ($_REQUEST['action'] == 'setstatut' && $user->rights->propale->cloturer)
*/
if ($_POST['addfile'])
{
require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
// Set tmp user directory
$vardir=$conf->user->dir_output."/".$user->id;
$upload_dir = $vardir.'/temp/';
if (! empty($_FILES['addedfile']['tmp_name']))
{
if (! is_dir($upload_dir)) create_exdir($upload_dir);
if (is_dir($upload_dir))
if (create_exdir($upload_dir) >= 0)
{
$result = dol_move_uploaded_file($_FILES['addedfile']['tmp_name'], $upload_dir . "/" . $_FILES['addedfile']['name'],0);
if ($result > 0)
$resupload=dol_move_uploaded_file($_FILES['addedfile']['tmp_name'], $upload_dir . "/" . $_FILES['addedfile']['name'],0,0,$_FILES['addedfile']['error']);
if (is_numeric($resupload) && $resupload > 0)
{
$mesg = '<div class="ok">'.$langs->trans("FileTransferComplete").'</div>';
//print_r($_FILES);
include_once(DOL_DOCUMENT_ROOT.'/html.formmail.class.php');
$formmail = new FormMail($db);
// Add file in list of files in session
$formmail->add_attached_files($upload_dir . "/" . $_FILES['addedfile']['name'],$_FILES['addedfile']['name'],$_FILES['addedfile']['type']);
}
else if ($result == -99)
else
{
// Files infected by a virus
$langs->load("errors");
$mesg = '<div class="error">'.$langs->trans("ErrorFileIsInfectedWithAVirus").'</div>';
}
else if ($result < 0)
{
// Echec transfert (fichier depassant la limite ?)
$mesg = '<div class="error">'.$langs->trans("ErrorFileNotUploaded").'</div>';
// print_r($_FILES);
if ($resupload < 0) // Unknown error
{
$mesg = '<div class="error">'.$langs->trans("ErrorFileNotUploaded").'</div>';
}
else if (preg_match('/ErrorFileIsInfectedWithAVirus/',$resupload)) // Files infected by a virus
{
$mesg = '<div class="error">'.$langs->trans("ErrorFileIsInfectedWithAVirus").'</div>';
}
else // Known error
{
$mesg = '<div class="error">'.$langs->trans($resupload).'</div>';
}
}
}
}
@ -1189,14 +1192,14 @@ if ($id > 0 || ! empty($ref))
if ($conf->projet->enabled) $rowspan++;
if ($conf->global->PROPALE_ADD_DELIVERY_ADDRESS) $rowspan++;
//Local taxes
if ($mysoc->pays_code=='ES' && $conf->global->MAIN_FEATURES_LEVEL >= 1)
{
if($mysoc->localtax1_assuj=="1") $rowspan++;
if($mysoc->localtax2_assuj=="1") $rowspan++;
}
// Notes
print '<td valign="top" colspan="2" width="50%" rowspan="'.$rowspan.'">'.$langs->trans('NotePublic').' :<br>'. nl2br($propal->note_public).'</td>';
print '</tr>';
@ -1371,7 +1374,7 @@ if ($id > 0 || ! empty($ref))
print '<tr><td height="10">'.$langs->trans('AmountVAT').'</td>';
print '<td align="right" colspan="2" nowrap>'.price($propal->total_tva).'</td>';
print '<td>'.$langs->trans("Currency".$conf->monnaie).'</td></tr>';
// Amount Local Taxes
if ($mysoc->pays_code=='ES' && $conf->global->MAIN_FEATURES_LEVEL >= 1)
{
@ -1388,7 +1391,7 @@ if ($id > 0 || ! empty($ref))
print '<td>'.$langs->trans("Currency".$conf->monnaie).'</td></tr>';
}
}
// Amount TTC
print '<tr><td height="10">'.$langs->trans('AmountTTC').'</td>';
print '<td align="right" colspan="2" nowrap>'.price($propal->total_ttc).'</td>';

View File

@ -68,34 +68,38 @@ $pagenext = $page + 1;
// Envoi fichier
if ($_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC))
{
require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
$propal = new Propal($db);
if ($propal->fetch($propalid))
{
$upload_dir = $conf->propale->dir_output . "/" . dol_sanitizeFileName($propal->ref);
if (! is_dir($upload_dir)) create_exdir($upload_dir);
if (is_dir($upload_dir))
{
$result = dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name'],0);
if ($result > 0)
{
$mesg = '<div class="ok">'.$langs->trans("FileTransferComplete").'</div>';
//print_r($_FILES);
}
else if ($result == -99)
{
// Files infected by a virus
$langs->load("errors");
$mesg = '<div class="error">'.$langs->trans("ErrorFileIsInfectedWithAVirus").'</div>';
}
else if ($result < 0)
{
// Echec transfert (fichier depassant la limite ?)
$mesg = '<div class="error">'.$langs->trans("ErrorFileNotUploaded").'</div>';
// print_r($_FILES);
}
}
if (create_exdir($upload_dir) >= 0)
{
$resupload=dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name'],0,0,$_FILES['userfile']['error']);
if (is_numeric($resupload) && $resupload > 0)
{
$mesg = '<div class="ok">'.$langs->trans("FileTransferComplete").'</div>';
}
else
{
$langs->load("errors");
if ($resupload < 0) // Unknown error
{
$mesg = '<div class="error">'.$langs->trans("ErrorFileNotUploaded").'</div>';
}
else if (preg_match('/ErrorFileIsInfectedWithAVirus/',$resupload)) // Files infected by a virus
{
$mesg = '<div class="error">'.$langs->trans("ErrorFileIsInfectedWithAVirus").'</div>';
}
else // Known error
{
$mesg = '<div class="error">'.$langs->trans($resupload).'</div>';
}
}
}
}
}

View File

@ -76,28 +76,32 @@ if (! $commande->fetch($_GET['id'],$_GET['ref']) > 0)
// Envoi fichier
if ($_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC))
{
$upload_dir = $conf->commande->dir_output . "/" . dol_sanitizeFileName($commande->ref);
if (! is_dir($upload_dir)) create_exdir($upload_dir);
require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
if (is_dir($upload_dir))
$upload_dir = $conf->commande->dir_output . "/" . dol_sanitizeFileName($commande->ref);
if (create_exdir($upload_dir) >= 0)
{
$result = dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name'],0);
if ($result > 0)
{
$mesg = '<div class="ok">'.$langs->trans("FileTransferComplete").'</div>';
//print_r($_FILES);
}
else if ($result == -99)
{
// Files infected by a virus
$langs->load("errors");
$mesg = '<div class="error">'.$langs->trans("ErrorFileIsInfectedWithAVirus").'</div>';
}
else if ($result < 0)
$resupload=dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name'],0,0,$_FILES['userfile']['error']);
if (is_numeric($resupload) && $resupload > 0)
{
// Echec transfert (fichier depassant la limite ?)
$mesg = '<div class="error">'.$langs->trans("ErrorFileNotUploaded").'</div>';
// print_r($_FILES);
$mesg = '<div class="ok">'.$langs->trans("FileTransferComplete").'</div>';
}
else
{
$langs->load("errors");
if ($resupload < 0) // Unknown error
{
$mesg = '<div class="error">'.$langs->trans("ErrorFileNotUploaded").'</div>';
}
else if (preg_match('/ErrorFileIsInfectedWithAVirus/',$resupload)) // Files infected by a virus
{
$mesg = '<div class="error">'.$langs->trans("ErrorFileIsInfectedWithAVirus").'</div>';
}
else // Known error
{
$mesg = '<div class="error">'.$langs->trans($resupload).'</div>';
}
}
}
}

View File

@ -774,40 +774,42 @@ if ($_REQUEST['action'] == 'remove_file')
*/
if ($_POST['addfile'])
{
require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
// Set tmp user directory
$vardir=$conf->user->dir_output."/".$user->id;
$upload_dir = $vardir.'/temp/';
if (! empty($_FILES['addedfile']['tmp_name']))
if (create_exdir($upload_dir) >= 0)
{
if (! is_dir($upload_dir)) create_exdir($upload_dir);
if (is_dir($upload_dir))
$resupload=dol_move_uploaded_file($_FILES['addedfile']['tmp_name'], $upload_dir . "/" . $_FILES['addedfile']['name'],0,0,$_FILES['addedfile']['error']);
if (is_numeric($resupload) && $resupload > 0)
{
$result = dol_move_uploaded_file($_FILES['addedfile']['tmp_name'], $upload_dir . "/" . $_FILES['addedfile']['name'],0);
if ($result > 0)
{
$mesg = '<div class="ok">'.$langs->trans("FileTransferComplete").'</div>';
//print_r($_FILES);
$mesg = '<div class="ok">'.$langs->trans("FileTransferComplete").'</div>';
include_once(DOL_DOCUMENT_ROOT.'/html.formmail.class.php');
$formmail = new FormMail($db);
$formmail->add_attached_files($upload_dir . "/" . $_FILES['addedfile']['name'],$_FILES['addedfile']['name'],$_FILES['addedfile']['type']);
}
else if ($result == -99)
include_once(DOL_DOCUMENT_ROOT.'/html.formmail.class.php');
$formmail = new FormMail($db);
// Add file in list of files in session
$formmail->add_attached_files($upload_dir . "/" . $_FILES['addedfile']['name'],$_FILES['addedfile']['name'],$_FILES['addedfile']['type']);
}
else
{
$langs->load("errors");
if ($resupload < 0) // Unknown error
{
$mesg = '<div class="error">'.$langs->trans("ErrorFileNotUploaded").'</div>';
}
else if (preg_match('/ErrorFileIsInfectedWithAVirus/',$resupload)) // Files infected by a virus
{
// Files infected by a virus
$langs->load("errors");
$mesg = '<div class="error">'.$langs->trans("ErrorFileIsInfectedWithAVirus").'</div>';
}
else if ($result < 0)
else // Known error
{
// Echec transfert (fichier depassant la limite ?)
$mesg = '<div class="error">'.$langs->trans("ErrorFileNotUploaded").'</div>';
// print_r($_FILES);
$mesg = '<div class="error">'.$langs->trans($resupload).'</div>';
}
}
}
$_GET["action"]='presend';
}
@ -1423,7 +1425,7 @@ else
*/
$nbrow=7;
if ($conf->projet->enabled) $nbrow++;
//Local taxes
if ($mysoc->pays_code=='ES' && $conf->global->MAIN_FEATURES_LEVEL >= 1)
{
@ -1674,7 +1676,7 @@ else
print '<td>'.$langs->trans("Currency".$conf->monnaie).'</td></tr>';
}
}
// Total TTC
print '<tr><td>'.$langs->trans('AmountTTC').'</td><td align="right">'.price($commande->total_ttc).'</td>';
print '<td>'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>';
@ -2245,7 +2247,7 @@ else
* Linked object block
*/
$commande->load_object_linked($commande->id,$commande->element);
foreach($commande->linked_object as $object => $objectid)
{
if($conf->$object->enabled && $object != $commande->element)
@ -2253,7 +2255,7 @@ else
$somethingshown=$commande->showLinkedObjectBlock($object,$objectid,$somethingshown);
}
}
print '</td><td valign="top" width="50%">';
// List of actions on element

View File

@ -672,15 +672,15 @@ if ($_POST['action'] == 'add' && $user->rights->facture->creer)
$element = $regs[1];
$subelement = $regs[2];
}
// For compatibility
if ($element == 'order') { $element = $subelement = 'commande'; }
if ($element == 'propal') { $element = 'comm/propal'; $subelement = 'propal'; }
if ($element == 'contract') { $element = $subelement = 'contrat'; }
$facture->origin = $_POST['origin'];
$facture->origin_id = $_POST['originid'];
$facid = $facture->create($user);
if ($facid > 0)
@ -695,7 +695,7 @@ if ($_POST['action'] == 'add' && $user->rights->facture->creer)
$lines = $object->lignes;
if (empty($lines) && method_exists($object,'fetch_lignes')) $lines = $object->fetch_lignes();
if (empty($lines) && method_exists($object,'fetch_lines')) $lines = $object->fetch_lines();
for ($i = 0 ; $i < sizeof($lines) ; $i++)
{
$desc=($lines[$i]->desc?$lines[$i]->desc:$lines[$i]->libelle);
@ -1089,40 +1089,43 @@ if ($_GET['action'] == 'down' && $user->rights->facture->creer)
*/
if ($_POST['addfile'])
{
require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
// Set tmp user directory
$vardir=$conf->user->dir_output."/".$user->id;
$upload_dir = $vardir.'/temp/';
if (! empty($_FILES['addedfile']['tmp_name']))
if (! is_dir($upload_dir)) create_exdir($upload_dir);
if (is_dir($upload_dir))
{
if (! is_dir($upload_dir)) create_exdir($upload_dir);
if (is_dir($upload_dir))
$resupload = dol_move_uploaded_file($_FILES['addedfile']['tmp_name'], $upload_dir . "/" . $_FILES['addedfile']['name'],0,0, $_FILES['addedfile']['error']);
if (is_numeric($resupload) && $resupload > 0)
{
$result = dol_move_uploaded_file($_FILES['addedfile']['tmp_name'], $upload_dir . "/" . $_FILES['addedfile']['name'],0);
if ($result > 0)
{
$mesg = '<div class="ok">'.$langs->trans("FileTransferComplete").'</div>';
//print_r($_FILES);
$mesg = '<div class="ok">'.$langs->trans("FileTransferComplete").'</div>';
include_once(DOL_DOCUMENT_ROOT.'/html.formmail.class.php');
$formmail = new FormMail($db);
$formmail->add_attached_files($upload_dir . "/" . $_FILES['addedfile']['name'],$_FILES['addedfile']['name'],$_FILES['addedfile']['type']);
}
else if ($result == -99)
include_once(DOL_DOCUMENT_ROOT.'/html.formmail.class.php');
$formmail = new FormMail($db);
$formmail->add_attached_files($upload_dir . "/" . $_FILES['addedfile']['name'],$_FILES['addedfile']['name'],$_FILES['addedfile']['type']);
}
else
{
$langs->load("errors");
if ($resupload < 0) // Unknown error
{
$mesg = '<div class="error">'.$langs->trans("ErrorFileNotUploaded").'</div>';
}
else if (preg_match('/ErrorFileIsInfectedWithAVirus/',$resupload)) // Files infected by a virus
{
// Files infected by a virus
$langs->load("errors");
$mesg = '<div class="error">'.$langs->trans("ErrorFileIsInfectedWithAVirus").'</div>';
}
else if ($result < 0)
else // Known error
{
// Echec transfert (fichier depassant la limite ?)
$mesg = '<div class="error">'.$langs->trans("ErrorFileNotUploaded").'</div>';
// print_r($_FILES);
$mesg = '<div class="error">'.$langs->trans($resupload).'</div>';
}
}
}
$_GET["action"]='presend';
}
@ -1416,7 +1419,7 @@ if ($_GET['action'] == 'create')
$object = new $classname($db);
$object->fetch($_GET['originid']);
$object->fetch_client();
$projectid = (!empty($object->fk_project)?$object->fk_project:'');
$ref_client = (!empty($object->ref_client)?$object->ref_client:'');
@ -1701,7 +1704,7 @@ if ($_GET['action'] == 'create')
$object->remise_percent=$remise_percent;
$object->update_price();
}
print "\n<!-- ".$classname." info -->";
print "\n";
print '<input type="hidden" name="amount" value="'.$object->total_ht.'">'."\n";

View File

@ -72,31 +72,35 @@ $pagenext = $page + 1;
// Envoi fichier
if ($_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC))
{
require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
$facture = new Facture($db);
if ($facture->fetch($facid))
{
$upload_dir = $conf->facture->dir_output . "/" . dol_sanitizeFileName($facture->ref);
if (! is_dir($upload_dir)) create_exdir($upload_dir);
if (is_dir($upload_dir))
if (create_exdir($upload_dir) >= 0)
{
$result = dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name'],0);
if ($result > 0)
$resupload=dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name'],0,0,$_FILES['userfile']['error']);
if (is_numeric($resupload) && $resupload > 0)
{
$mesg = '<div class="ok">'.$langs->trans("FileTransferComplete").'</div>';
//print_r($_FILES);
}
else if ($result == -99)
else
{
// Files infected by a virus
$langs->load("errors");
$mesg = '<div class="error">'.$langs->trans("ErrorFileIsInfectedWithAVirus").'</div>';
}
else if ($result < 0)
{
// Echec transfert (fichier depassant la limite ?)
$mesg = '<div class="error">'.$langs->trans("ErrorFileNotUploaded").'</div>';
// print_r($_FILES);
if ($resupload < 0) // Unknown error
{
$mesg = '<div class="error">'.$langs->trans("ErrorFileNotUploaded").'</div>';
}
else if (preg_match('/ErrorFileIsInfectedWithAVirus/',$resupload)) // Files infected by a virus
{
$mesg = '<div class="error">'.$langs->trans("ErrorFileIsInfectedWithAVirus").'</div>';
}
else // Known error
{
$mesg = '<div class="error">'.$langs->trans($resupload).'</div>';
}
}
}
}

View File

@ -54,6 +54,8 @@ if ($_POST["action"] == 'confirm_credite' && $_POST["confirm"] == yes)
if ($_POST["action"] == 'infotrans')
{
require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
$bon = new BonPrelevement($db,"");
$bon->fetch($_GET["id"]);

View File

@ -72,32 +72,32 @@ $modulepart='contract';
*/
if ($_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC))
{
/*
* Creation repertoire si n'existe pas
*/
if (! is_dir($upload_dir)) create_exdir($upload_dir);
require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
if (is_dir($upload_dir))
{
$result = dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name'],0);
if ($result > 0)
{
$mesg = '<div class="ok">'.$langs->trans("FileTransferComplete").'</div>';
//print_r($_FILES);
}
else if ($result == -99)
{
// Files infected by a virus
$langs->load("errors");
$mesg = '<div class="error">'.$langs->trans("ErrorFileIsInfectedWithAVirus").'</div>';
}
else if ($result < 0)
if (create_exdir($upload_dir) >= 0)
{
$resupload=dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name'],0,0,$_FILES['userfile']['error']);
if (is_numeric($resupload) && $resupload > 0)
{
// Echec transfert (fichier depassant la limite ?)
$mesg = '<div class="error">'.$langs->trans("ErrorFileNotUploaded").'</div>';
// print_r($_FILES);
$mesg = '<div class="ok">'.$langs->trans("FileTransferComplete").'</div>';
}
}
else
{
$langs->load("errors");
if ($resupload < 0) // Unknown error
{
$mesg = '<div class="error">'.$langs->trans("ErrorFileNotUploaded").'</div>';
}
else if (preg_match('/ErrorFileIsInfectedWithAVirus/',$resupload)) // Files infected by a virus
{
$mesg = '<div class="error">'.$langs->trans("ErrorFileIsInfectedWithAVirus").'</div>';
}
else // Known error
{
$mesg = '<div class="error">'.$langs->trans($resupload).'</div>';
}
}
}
}

View File

@ -91,32 +91,30 @@ $upload_dir = $conf->ecm->dir_output.'/'.$relativepath;
// Envoie fichier
if ( $_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC))
{
if (! is_dir($upload_dir))
{
$result=create_exdir($upload_dir);
}
require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
if (is_dir($upload_dir))
if (create_exdir($upload_dir) >= 0)
{
$result = dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name'],0);
if ($result > 0)
$resupload = dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name'],0,0,$_FILES['userfile']['error']);
if (is_numeric($resupload) && $resupload > 0)
{
//$mesg = '<div class="ok">'.$langs->trans("FileTransferComplete").'</div>';
//print_r($_FILES);
$result=$ecmdir->changeNbOfFiles('+');
}
else if ($result == -99)
else
{
// File infected by a virus
$langs->load("errors");
$mesg = '<div class="error">'.$langs->trans("ErrorFileIsInfectedWithAVirus").'</div>';
}
else if ($result < 0)
{
// Echec transfert (fichier depassant la limite ?)
$langs->load("errors");
$mesg = '<div class="error">'.$langs->trans("ErrorFileNotUploaded").'</div>';
// print_r($_FILES);
$langs->load("errors");
if ($resupload < 0) // Unknown error
{
$mesg = '<div class="error">'.$langs->trans("ErrorFileNotUploaded").'</div>';
}
else if (preg_match('/ErrorFileIsInfectedWithAVirus/',$resupload)) // Files infected by a virus
{
$mesg = '<div class="error">'.$langs->trans("ErrorFileIsInfectedWithAVirus").'</div>';
}
else // Known error
{
$mesg = '<div class="error">'.$langs->trans($resupload).'</div>';
}
}
}
else

View File

@ -46,28 +46,37 @@ $upload_dir = $conf->ecm->dir_output.'/'.$section;
// Envoie fichier
if ( $_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC))
{
if (! is_dir($upload_dir)) create_exdir($upload_dir);
require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
if (is_dir($upload_dir))
if (create_exdir($upload_dir) >= 0)
{
$result = dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name'],0);
if ($result > 0)
$resupload = dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name'],0,0,$_FILES['userfile']['error']);
if (is_numeric($resupload) && $resupload > 0)
{
$mesg = '<div class="ok">'.$langs->trans("FileTransferComplete").'</div>';
//print_r($_FILES);
}
else if ($result == -99)
{
// File infected by a virus
$langs->load("errors");
$mesg = '<div class="error">'.$langs->trans("ErrorFileIsInfectedWithAVirus").'</div>';
$result=$ecmdir->changeNbOfFiles('+');
}
else if ($result < 0)
{
// Echec transfert (fichier d?passant la limite ?)
$mesg = '<div class="error">'.$langs->trans("ErrorFileNotUploaded").'</div>';
// print_r($_FILES);
}
else
{
$langs->load("errors");
if ($resupload < 0) // Unknown error
{
$mesg = '<div class="error">'.$langs->trans("ErrorFileNotUploaded").'</div>';
}
else if (preg_match('/ErrorFileIsInfectedWithAVirus/',$resupload)) // Files infected by a virus
{
$mesg = '<div class="error">'.$langs->trans("ErrorFileIsInfectedWithAVirus").'</div>';
}
else // Known error
{
$mesg = '<div class="error">'.$langs->trans($resupload).'</div>';
}
}
}
else
{
// Echec transfert (fichier depassant la limite ?)
$langs->load("errors");
$mesg = '<div class="error">'.$langs->trans("ErrorFailToCreateDir",$upload_dir).'</div>';
}
}

View File

@ -87,6 +87,8 @@ if (! empty($_REQUEST["section"]))
// Envoie fichier
if ( $_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC))
{
require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
$result=$ecmdir->fetch($_REQUEST["section"]);
if (! $result > 0)
{
@ -96,37 +98,34 @@ if ( $_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC))
$relativepath=$ecmdir->getRelativePath();
$upload_dir = $conf->ecm->dir_output.'/'.$relativepath;
if (! is_dir($upload_dir))
if (create_exdir($upload_dir) >= 0)
{
$result=create_exdir($upload_dir);
}
if (is_dir($upload_dir))
{
$result = dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name'],0);
if ($result > 0)
$resupload = dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name'],0, 0, $_FILES['userfile']['error']);
if (is_numeric($resupload) && $resupload > 0)
{
//$mesg = '<div class="ok">'.$langs->trans("FileTransferComplete").'</div>';
//print_r($_FILES);
$result=$ecmdir->changeNbOfFiles('+');
}
else if ($result == -99)
{
// File infected by a virus
$langs->load("errors");
$mesg = '<div class="error">'.$langs->trans("ErrorFileIsInfectedWithAVirus").'</div>';
}
else if ($result < 0)
else
{
// Echec transfert (fichier depassant la limite ?)
$langs->load("errors");
$mesg = '<div class="error">'.$langs->trans("ErrorFileNotUploaded").'</div>';
// print_r($_FILES);
if ($resupload < 0) // Unknown error
{
$mesg = '<div class="error">'.$langs->trans("ErrorFileNotUploaded").'</div>';
}
else if (preg_match('/ErrorFileIsInfectedWithAVirus/',$resupload)) // Files infected by a virus
{
$mesg = '<div class="error">'.$langs->trans("ErrorFileIsInfectedWithAVirus").'</div>';
}
else // Known error
{
$mesg = '<div class="error">'.$langs->trans($resupload).'</div>';
}
}
}
else
{
// Echec transfert (fichier depassant la limite ?)
$langs->load("errors");
$mesg = '<div class="error">'.$langs->trans("ErrorFailToCreateDir",$upload_dir).'</div>';
}

View File

@ -69,32 +69,32 @@ $modulepart='fichinter';
*/
if ($_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC))
{
/*
* Creation repertoire si n'existe pas
*/
if (! is_dir($upload_dir)) create_exdir($upload_dir);
require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
if (is_dir($upload_dir))
{
$result = dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name'],0);
if ($result > 0)
{
$mesg = '<div class="ok">'.$langs->trans("FileTransferComplete").'</div>';
//print_r($_FILES);
}
else if ($result == -99)
{
// Files infected by a virus
$langs->load("errors");
$mesg = '<div class="error">'.$langs->trans("ErrorFileIsInfectedWithAVirus").'</div>';
}
else if ($result < 0)
if (create_exdir($upload_dir) >= 0)
{
$resupload=dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name'],0,0,$_FILES['userfile']['error']);
if (is_numeric($resupload) && $resupload > 0)
{
// Echec transfert (fichier depassant la limite ?)
$mesg = '<div class="error">'.$langs->trans("ErrorFileNotUploaded").'</div>';
// print_r($_FILES);
$mesg = '<div class="ok">'.$langs->trans("FileTransferComplete").'</div>';
}
}
else
{
$langs->load("errors");
if ($resupload < 0) // Unknown error
{
$mesg = '<div class="error">'.$langs->trans("ErrorFileNotUploaded").'</div>';
}
else if (preg_match('/ErrorFileIsInfectedWithAVirus/',$resupload)) // Files infected by a virus
{
$mesg = '<div class="error">'.$langs->trans("ErrorFileIsInfectedWithAVirus").'</div>';
}
else // Known error
{
$mesg = '<div class="error">'.$langs->trans($resupload).'</div>';
}
}
}
}

View File

@ -77,28 +77,32 @@ if ($commande->fetch($_GET['id'],$_GET['ref']) < 0)
// Envoi fichier
if ($_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC))
{
$upload_dir = $conf->fournisseur->dir_output . "/commande/" . dol_sanitizeFileName($commande->ref);
if (! is_dir($upload_dir)) create_exdir($upload_dir);
require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
if (is_dir($upload_dir))
$upload_dir = $conf->fournisseur->dir_output . "/commande/" . dol_sanitizeFileName($commande->ref);
if (create_exdir($upload_dir) >= 0)
{
$result = dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name'],0);
if ($result > 0)
{
$mesg = '<div class="ok">'.$langs->trans("FileTransferComplete").'</div>';
//print_r($_FILES);
}
else if ($result == -99)
{
// Files infected by a virus
$langs->load("errors");
$mesg = '<div class="error">'.$langs->trans("ErrorFileIsInfectedWithAVirus").'</div>';
}
else if ($result < 0)
$resupload=dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name'],0,0,$_FILES['userfile']['error']);
if (is_numeric($resupload) && $resupload > 0)
{
// Echec transfert (fichier depassant la limite ?)
$mesg = '<div class="error">'.$langs->trans("ErrorFileNotUploaded").'</div>';
// print_r($_FILES);
$mesg = '<div class="ok">'.$langs->trans("FileTransferComplete").'</div>';
}
else
{
$langs->load("errors");
if ($resupload < 0) // Unknown error
{
$mesg = '<div class="error">'.$langs->trans("ErrorFileNotUploaded").'</div>';
}
else if (preg_match('/ErrorFileIsInfectedWithAVirus/',$resupload)) // Files infected by a virus
{
$mesg = '<div class="error">'.$langs->trans("ErrorFileIsInfectedWithAVirus").'</div>';
}
else // Known error
{
$mesg = '<div class="error">'.$langs->trans($resupload).'</div>';
}
}
}
}

View File

@ -65,32 +65,35 @@ $pagenext = $page + 1;
// Envoi fichier
if ($_POST['sendit'] && ! empty($conf->global->MAIN_UPLOAD_DOC))
{
require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
$facture = new FactureFournisseur($db);
if ($facture->fetch($facid))
{
$upload_dir = $conf->fournisseur->dir_output.'/facture/'.get_exdir($facture->id,2).$facture->id;
if (! is_dir($upload_dir)) create_exdir($upload_dir);
if (is_dir($upload_dir))
if (create_exdir($upload_dir) >= 0)
{
$result = dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name'],0);
if ($result > 0)
$resupload=dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name'],0,0,$_FILES['userfile']['error']);
if (is_numeric($resupload) && $resupload > 0)
{
$mesg = '<div class="ok">'.$langs->trans("FileTransferComplete").'</div>';
//print_r($_FILES);
}
else if ($result == -99)
else
{
// Files infected by a virus
$langs->load("errors");
$mesg = '<div class="error">'.$langs->trans("ErrorFileIsInfectedWithAVirus").'</div>';
}
else if ($result < 0)
{
// Echec transfert (fichier depassant la limite ?)
$mesg = '<div class="error">'.$langs->trans("ErrorFileNotUploaded").'</div>';
// print_r($_FILES);
if ($resupload < 0) // Unknown error
{
$mesg = '<div class="error">'.$langs->trans("ErrorFileNotUploaded").'</div>';
}
else if (preg_match('/ErrorFileIsInfectedWithAVirus/',$resupload)) // Files infected by a virus
{
$mesg = '<div class="error">'.$langs->trans("ErrorFileIsInfectedWithAVirus").'</div>';
}
else // Known error
{
$mesg = '<div class="error">'.$langs->trans($resupload).'</div>';
}
}
}
}

View File

@ -86,6 +86,8 @@ $conn_id=0; // FTP connection ID
// Envoie fichier
if ( $_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC))
{
require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
$result=$ecmdir->fetch($_REQUEST["section"]);
if (! $result > 0)
{
@ -95,32 +97,29 @@ if ( $_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC))
$relativepath=$ecmdir->getRelativePath();
$upload_dir = $conf->ecm->dir_output.'/'.$relativepath;
if (! is_dir($upload_dir))
if (create_exdir($upload_dir) >= 0)
{
$result=create_exdir($upload_dir);
}
if (is_dir($upload_dir))
{
$result = dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name'],0);
if ($result > 0)
$resupload = dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name'],0);
if (is_numeric($resupload) && $resupload > 0)
{
//$mesg = '<div class="ok">'.$langs->trans("FileTransferComplete").'</div>';
//print_r($_FILES);
$result=$ecmdir->changeNbOfFiles('+');
}
else if ($result == -99)
{
// File infected by a virus
$langs->load("errors");
$mesg = '<div class="error">'.$langs->trans("ErrorFileIsInfectedWithAVirus").'</div>';
}
else if ($result < 0)
{
// Echec transfert (fichier depassant la limite ?)
else {
$langs->load("errors");
$mesg = '<div class="error">'.$langs->trans("ErrorFileNotUploaded").'</div>';
// print_r($_FILES);
if ($resupload < 0) // Unknown error
{
$mesg = '<div class="error">'.$langs->trans("ErrorFileNotUploaded").'</div>';
}
else if (preg_match('/ErrorFileIsInfectedWithAVirus/',$resupload)) // Files infected by a virus
{
$mesg = '<div class="error">'.$langs->trans("ErrorFileIsInfectedWithAVirus").'</div>';
}
else // Known error
{
$mesg = '<div class="error">'.$langs->trans($resupload).'</div>';
}
}
}
else

View File

@ -191,6 +191,8 @@ if ($action == 'add_import_model')
if ($step == 3 && $datatoimport)
{
require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
if ( $_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC))
{
create_exdir($conf->import->dir_temp);

View File

@ -107,7 +107,9 @@ class mailing_peche extends MailingTargets
function add_to_target($mailing_id,$filtersarray=array())
{
global $conf,$langs,$_FILES;
require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
// For compatibility with Unix, MS-Dos or Macintosh
ini_set('auto_detect_line_endings', true);
@ -115,13 +117,10 @@ class mailing_peche extends MailingTargets
$upload_dir=$conf->mailing->dir_temp;
// Save file
if (! is_dir($upload_dir)) create_exdir($upload_dir);
if (is_dir($upload_dir))
if (create_exdir($upload_dir) >= 0)
{
$result = dol_move_uploaded_file($_FILES['username']['tmp_name'], $upload_dir . "/" . $_FILES['username']['name'], 1);
if ($result > 0)
$resupload = dol_move_uploaded_file($_FILES['username']['tmp_name'], $upload_dir . "/" . $_FILES['username']['name'], 1, 0, $_FILES['username']['error']);
if (is_numeric($resupload) && $resupload > 0)
{
$cpt=0;
@ -186,22 +185,24 @@ class mailing_peche extends MailingTargets
dol_syslog(get_class($this)."::add_to_target mailing ".$cpt." targets found");
}
else if ($result == -99)
else
{
// Files infected by a virus
$langs->load("errors");
$this->error = $langs->trans("ErrorFileIsInfectedWithAVirus");
return -1;
}
else if ($result < 0)
{
// Echec transfert (fichier depassant la limite ?)
$this->error = $langs->trans("ErrorFileNotUploaded");
// print_r($_FILES);
return -1;
if ($resupload < 0) // Unknown error
{
$this->error = '<div class="error">'.$langs->trans("ErrorFileNotUploaded").'</div>';
}
else if (preg_match('/ErrorFileIsInfectedWithAVirus/',$resupload)) // Files infected by a virus
{
$this->error = '<div class="error">'.$langs->trans("ErrorFileIsInfectedWithAVirus").'</div>';
}
else // Known error
{
$this->error = '<div class="error">'.$langs->trans($resupload).'</div>';
}
}
}
ini_set('auto_detect_line_endings', false);
return parent::add_to_target($mailing_id, $cibles);

View File

@ -40,7 +40,13 @@ ErrorFileNotFound=File <b>%s</b> not found (Bad path, wrong permissions or acces
ErrorDirNotFound=Directory <b>%s</b> not found (Bad path, wrong permissions or access denied by PHP openbasedir or safe_mode parameter)
ErrorFunctionNotAvailableInPHP=Function <b>%s</b> is required for this feature but is not available in this version/setup of PHP.
ErrorDirAlreadyExists=A directory with this name already exists.
ErrorFileAlreadyExists=A file with this name already exists.
ErrorPartialFile=File not received completely by server.
ErrorNoTmpDir=Temporary directy %s does not exists.
ErrorUploadBlockedByAddon=Upload blocked by a PHP/Apache plugin.
ErrorFileSizeTooLarge=File size is too large.
ErrorFieldCanNotContainSpecialCharacters=Field <b>%s</b> must not contains special characters.
WarningSafeModeOnCheckExecDir=Warning, PHP option <b>safe_mode</b> is on so command must be stored inside a directory declared by php parameter <b>safe_mode_exec_dir</b>.
WarningAllowUrlFopenMustBeOn=Parameter <b>allow_url_fopen</b> must be set to <b>on</b> in filer <b>php.ini</b> for having this module working completely. You must modify this file manually.
WarningBuildScriptNotRunned=Script <b>%s</b> was not yet ran to build graphics, or there is no data to show.
WarningBookmarkAlreadyExists=A bookmark with this title or this target (URL) already exists.

View File

@ -41,7 +41,13 @@ ErrorFileNotFound=Fichier <b>%s</b> introuvable (Mauvais chemin, permissions inc
ErrorDirNotFound=Répertoire <b>%s</b> introuvable (Mauvais chemin, permissions incorrectes ou accès interdit par le paramètre PHP openbasedir ou safe_mode)
ErrorFunctionNotAvailableInPHP=La fonction <b>%s</b> est requise pour cette fonctionnalité mais n'est pas disponible dans cette version/installation de PHP.
ErrorDirAlreadyExists=Un répertoire portant ce nom existe déjà.
ErrorFileAlreadyExists=Un fichier portant ce nom existe déjà.
ErrorPartialFile=Fichier non reçu intégrallement par le serveur.
ErrorNoTmpDir=Répertoire temporaire de réception %s inexistant.
ErrorUploadBlockedByAddon=Upload bloqué par un plugin PHP/Apache.
ErrorFileSizeTooLarge=La taille du fichier est trop grande.
ErrorFieldCanNotContainSpecialCharacters=Le champ <b>%s</b> ne peut contenir de caractères spéciaux.
WarningSafeModeOnCheckExecDir=Attention, l'option PHP <b>safe_mode</b> est active, la commande doit dont etre dans un répertoire déclaré dans le paramètre php <b>safe_mode_exec_dir</b>.
WarningAllowUrlFopenMustBeOn=Attention, le paramètre <b>allow_url_fopen</b> doit être positionné à <b>on</b> dans le fichier <b>php.ini</b> pour que ce module soit pleinement opérationnel. Vous devez modifier ce fichier manuellement.
WarningBuildScriptNotRunned=Le script <b>%s</b> n'a pas encore été lancé pour générer les graphiques ou il n'y a aucune donnée à afficher.
WarningBookmarkAlreadyExists=Un marque-page avec ce titre ou cette destination (URL) existe déjà.

View File

@ -396,7 +396,6 @@ function dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $not
$sql.= $db->encrypt($name,1);
$sql.= ", ".$db->encrypt($value,1);
$sql.= ",'".$type."',".$visible.",'".addslashes($note)."',".$entity.")";
dol_syslog("admin.lib::dolibarr_set_const sql=".$sql, LOG_DEBUG);
$resql=$db->query($sql);
}

View File

@ -60,37 +60,19 @@ class AntiVir
$return = 0;
$maxreclevel = 5 ; // maximal recursion level
$maxfiles = 1000; // maximal number of files to be scanned within archive
$maxratio = 200; // maximal compression ratio
$bz2archivememlim = 0; // limit memory usage for bzip2 (0/1)
$maxfilesize = 10485760; // archived files larger than this value (in bytes) will not be scanned
@set_time_limit($cfg['ExecTimeLimit']);
$outputfile=$conf->admin->dir_temp.'/dol_avscan_file.out.'.session_id();
$command=$conf->global->MAIN_ANTIVIRUS_COMMAND;
$param=$conf->global->MAIN_ANTIVIRUS_PARAM;
$param=preg_replace('/%maxreclevel/',$maxreclevel,$param);
$param=preg_replace('/%maxfiles/',$maxfiles,$param);
$param=preg_replace('/%maxratio/',$maxratiod,$param);
$param=preg_replace('/%bz2archivememlim/',$bz2archivememlim,$param);
$param=preg_replace('/%maxfilesize/',$maxfilesize,$param);
$param=preg_replace('/%file/',trim($file),$param);
if (! preg_match('/%file/',$conf->global->MAIN_ANTIVIRUS_PARAM))
$param=$param." ".escapeshellarg(trim($file));
if (preg_match("/\s/",$command)) $command=escapeshellarg($command); // Use quotes on command
$fullcommand=$this->getCliCommand($file);
//$fullcommand='"c:\Program Files (x86)\ClamWin\bin\clamscan.exe" --database="C:\Program Files (x86)\ClamWin\lib" "c:\temp\aaa.txt"';
$output=array();
$return_var=0;
// Create a clean fullcommand
$fullcommand=$command.' '.$param.' 2>&1';
dol_syslog("AntiVir::dol_avscan_file Run command=".$fullcommand);
exec($fullcommand, $output, $return_var);
/*
$handle = fopen($outputfile, 'w');
if ($handle)
@ -139,6 +121,44 @@ class AntiVir
return 1;
}
/**
* \brief get full Command Line to run
* \param file File to scan
* \return string Full command line to run
*/
function getCliCommand($file)
{
global $conf;
$maxreclevel = 5 ; // maximal recursion level
$maxfiles = 1000; // maximal number of files to be scanned within archive
$maxratio = 200; // maximal compression ratio
$bz2archivememlim = 0; // limit memory usage for bzip2 (0/1)
$maxfilesize = 10485760; // archived files larger than this value (in bytes) will not be scanned
$command=$conf->global->MAIN_ANTIVIRUS_COMMAND;
$param=$conf->global->MAIN_ANTIVIRUS_PARAM;
$param=preg_replace('/%maxreclevel/',$maxreclevel,$param);
$param=preg_replace('/%maxfiles/',$maxfiles,$param);
$param=preg_replace('/%maxratio/',$maxratio,$param);
$param=preg_replace('/%bz2archivememlim/',$bz2archivememlim,$param);
$param=preg_replace('/%maxfilesize/',$maxfilesize,$param);
$param=preg_replace('/%file/',trim($file),$param);
if (! preg_match('/%file/',$conf->global->MAIN_ANTIVIRUS_PARAM))
$param=$param." ".escapeshellarg(trim($file));
if (preg_match("/\s/",$command)) $command=escapeshellarg($command); // Use quotes on command
$ret=$command.' '.$param;
//$ret=$command.' '.$param.' 2>&1';
return $ret;
}
}
?>

View File

@ -328,4 +328,124 @@ function dol_copy($srcfile, $destfile, $newmask=0, $overwriteifexists=1)
return $result;
}
/**
* \brief Move an uploaded file after some controls.
* If there is errors (virus found, antivir in error, bad filename), file is not moved.
* \param src_file Source full path filename ($_FILES['field']['tmp_name'])
* \param dest_file Target full path filename
* \param allowoverwrite 1=Overwrite target file if it already exists
* \param disablevirusscan 1=Disable virus scan
* \param uploaderrorcode Value of upload error code ($_FILES['field']['error'])
* \return int >0 if OK, <0 or string if KO
*/
function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disablevirusscan=0, $uploaderrorcode=0)
{
global $conf;
$file_name = $dest_file;
// If an upload error has been reported
if ($uploaderrorcode)
{
switch($uploaderrorcode)
{
case UPLOAD_ERR_INI_SIZE: // 1
return 'ErrorFileSizeTooLarge';
break;
case UPLOAD_ERR_FORM_SIZE: // 2
return 'ErrorFileSizeTooLarge';
break;
case UPLOAD_ERR_PARTIAL: // 3
return 'ErrorPartialFile';
break;
case UPLOAD_ERR_NO_TMP_DIR: //
return 'ErrorNoTmpDir';
break;
case UPLOAD_ERR_CANT_WRITE:
return 'ErrorFailedToWriteInDir';
break;
case UPLOAD_ERR_EXTENSION:
return 'ErrorUploadBlockedByAddon';
break;
default:
break;
}
}
// If we need to make a virus scan
if (empty($disablevirusscan) && file_exists($src_file) && $conf->global->MAIN_ANTIVIRUS_COMMAND)
{
require_once(DOL_DOCUMENT_ROOT.'/lib/security.lib.php');
require_once(DOL_DOCUMENT_ROOT.'/lib/antivir.class.php');
$antivir=new AntiVir($db);
$result = $antivir->dol_avscan_file($src_file);
if ($result < 0) // If virus or error, we stop here
{
$reterrors=$antivir->errors;
dol_syslog("Functions.lib::dol_move_uploaded_file File ".$file_name." KO with antivir", LOG_WARNING);
return 'ErrorFileIsInfectedWithAVirus: '.join(',',$reterrors);
}
}
// Security:
// Disallow file with some extensions. We renamed them.
// Car si on a mis le rep documents dans un rep de la racine web (pas bien), cela permet d'executer du code a la demande.
if (preg_match('/\.htm|\.html|\.php|\.pl|\.cgi$/i',$file_name))
{
$file_name.= '.noexe';
}
// Security:
// On interdit fichiers caches, remontees de repertoire ainsi que les pipes dans les noms de fichiers.
if (preg_match('/^\./',$src_file) || preg_match('/\.\./',$src_file) || preg_match('/[<>|]/',$src_file))
{
dol_syslog("Refused to deliver file ".$src_file, LOG_WARNING);
return -1;
}
// Security:
// On interdit fichiers caches, remontees de repertoire ainsi que les pipe dans
// les noms de fichiers.
if (preg_match('/^\./',$dest_file) || preg_match('/\.\./',$dest_file) || preg_match('/[<>|]/',$dest_file))
{
dol_syslog("Refused to deliver file ".$dest_file, LOG_WARNING);
return -2;
}
// The file functions must be in OS filesystem encoding.
$src_file_osencoded=dol_osencode($src_file);
$file_name_osencoded=dol_osencode($file_name);
// Check if destination dir is writable
// TODO
// Check if destination file already exists
if (! $allowoverwrite)
{
if (file_exists($file_name_osencoded))
{
dol_syslog("Functions.lib::dol_move_uploaded_file File ".$file_name." already exists", LOG_WARNING);
return 'ErrorFileAlreadyExists';
}
}
// Move file
$return=move_uploaded_file($src_file_osencoded, $file_name_osencoded);
if ($return)
{
if (! empty($conf->global->MAIN_UMASK)) @chmod($file_name_osencoded, octdec($conf->global->MAIN_UMASK));
dol_syslog("Functions.lib::dol_move_uploaded_file Success to move ".$src_file." to ".$file_name." - Umask=".$conf->global->MAIN_UMASK, LOG_DEBUG);
return 1; // Success
}
else
{
dol_syslog("Functions.lib::dol_move_uploaded_file Failed to move ".$src_file." to ".$file_name, LOG_ERR);
return -3; // Unknown error
}
return 1;
}
?>

View File

@ -1958,95 +1958,6 @@ function dol_print_error_email()
}
/**
* \brief Move an uploaded file after some controls.
* If there is errors (virus found, antivir in error, bad filename), file is not moved.
* \param src_file Source filename
* \param dest_file Target filename
* \param allowoverwrite Overwrite if exists
* \param disablevirusscan Disable virus scan
* \return int >0 if OK, <0 if KO (an array with virus or errors if virus found or errors)
*/
function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disablevirusscan=0)
{
global $conf;
$file_name = $dest_file;
// If we need to make a virus scan
if (empty($disablevirusscan) && file_exists($src_file) && $conf->global->MAIN_ANTIVIRUS_COMMAND)
{
require_once(DOL_DOCUMENT_ROOT.'/lib/security.lib.php');
require_once(DOL_DOCUMENT_ROOT.'/lib/antivir.class.php');
$antivir=new AntiVir($db);
$result = $antivir->dol_avscan_file($src_file);
if ($result < 0) // If virus or error, we stop here
{
$reterrors=$antivir->errors;
dol_syslog("Functions.lib::dol_move_uploaded_file File ".$file_name." KO with antivir", LOG_WARNING);
//return $reterrors;
return -99;
}
}
// Security:
// Disallow file with some extensions. We renamed them.
// Car si on a mis le rep documents dans un rep de la racine web (pas bien), cela permet d'executer du code a la demande.
if (preg_match('/\.htm|\.html|\.php|\.pl|\.cgi$/i',$file_name))
{
$file_name.= '.noexe';
}
// Security:
// On interdit fichiers caches, remontees de repertoire ainsi que les pipes dans les noms de fichiers.
if (preg_match('/^\./',$src_file) || preg_match('/\.\./',$src_file) || preg_match('/[<>|]/',$src_file))
{
dol_syslog("Refused to deliver file ".$src_file, LOG_WARNING);
return -1;
}
// Security:
// On interdit fichiers caches, remontees de repertoire ainsi que les pipe dans
// les noms de fichiers.
if (preg_match('/^\./',$dest_file) || preg_match('/\.\./',$dest_file) || preg_match('/[<>|]/',$dest_file))
{
dol_syslog("Refused to deliver file ".$dest_file, LOG_WARNING);
return -2;
}
// The file functions must be in OS filesystem encoding.
$src_file_osencoded=dol_osencode($src_file);
$file_name_osencoded=dol_osencode($file_name);
// Check if destination file already exists
if (! $allowoverwrite)
{
if (file_exists($file_name_osencoded))
{
dol_syslog("Functions.lib::dol_move_uploaded_file File ".$file_name." already exists", LOG_WARNING);
return -3;
}
}
// Move file
$return=move_uploaded_file($src_file_osencoded, $file_name_osencoded);
if ($return)
{
if (! empty($conf->global->MAIN_UMASK)) @chmod($file_name_osencoded, octdec($conf->global->MAIN_UMASK));
dol_syslog("Functions.lib::dol_move_uploaded_file Success to move ".$src_file." to ".$file_name." - Umask=".$conf->global->MAIN_UMASK, LOG_DEBUG);
return 1;
}
else
{
dol_syslog("Functions.lib::dol_move_uploaded_file Failed to move ".$src_file." to ".$file_name, LOG_ERR);
return -4;
}
return 1;
}
/**
* \brief Show title line of an array
* \param name libelle champ

View File

@ -2382,6 +2382,8 @@ class Product extends CommonObject
*/
function add_photo($sdir, $file, $maxWidth = 160, $maxHeight = 120)
{
require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
$dir = $sdir .'/'. get_exdir($this->id,2) . $this->id ."/photos";
create_exdir($dir);

View File

@ -77,32 +77,32 @@ $modulepart='produit';
if ($_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC))
{
/*
* Creation repertoire si n'existe pas
*/
if (! is_dir($upload_dir)) create_exdir($upload_dir);
require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
if (is_dir($upload_dir))
{
$result = dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name'],0);
if ($result > 0)
{
$mesg = '<div class="ok">'.$langs->trans("FileTransferComplete").'</div>';
//print_r($_FILES);
}
else if ($result == -99)
{
// Files infected by a virus
$langs->load("errors");
$mesg = '<div class="error">'.$langs->trans("ErrorFileIsInfectedWithAVirus").'</div>';
}
else if ($result < 0)
if (create_exdir($upload_dir) >= 0)
{
$resupload=dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name'],0,0,$_FILES['userfile']['error']);
if (is_numeric($resupload) && $resupload > 0)
{
// Echec transfert (fichier depassant la limite ?)
$mesg = '<div class="error">'.$langs->trans("ErrorFileNotUploaded").'</div>';
// print_r($_FILES);
$mesg = '<div class="ok">'.$langs->trans("FileTransferComplete").'</div>';
}
}
else
{
$langs->load("errors");
if ($resupload < 0) // Unknown error
{
$mesg = '<div class="error">'.$langs->trans("ErrorFileNotUploaded").'</div>';
}
else if (preg_match('/ErrorFileIsInfectedWithAVirus/',$resupload)) // Files infected by a virus
{
$mesg = '<div class="error">'.$langs->trans("ErrorFileIsInfectedWithAVirus").'</div>';
}
else // Known error
{
$mesg = '<div class="error">'.$langs->trans($resupload).'</div>';
}
}
}
}

View File

@ -69,28 +69,32 @@ if (! $project->fetch($_GET['id'],$_GET['ref']) > 0)
// Envoi fichier
if ($_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC))
{
$upload_dir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($project->ref);
if (! is_dir($upload_dir)) create_exdir($upload_dir);
require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
if (is_dir($upload_dir))
$upload_dir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($project->ref);
if (create_exdir($upload_dir) >= 0)
{
$result = dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name'],0);
if ($result > 0)
{
$mesg = '<div class="ok">'.$langs->trans("FileTransferComplete").'</div>';
//print_r($_FILES);
}
else if ($result == -99)
{
// Files infected by a virus
$langs->load("errors");
$mesg = '<div class="error">'.$langs->trans("ErrorFileIsInfectedWithAVirus").'</div>';
}
else if ($result < 0)
$resupload=dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name'],0,0,$_FILES['userfile']['error']);
if (is_numeric($resupload) && $resupload > 0)
{
// Echec transfert (fichier depassant la limite ?)
$mesg = '<div class="error">'.$langs->trans("ErrorFileNotUploaded").'</div>';
// print_r($_FILES);
$mesg = '<div class="ok">'.$langs->trans("FileTransferComplete").'</div>';
}
else
{
$langs->load("errors");
if ($resupload < 0) // Unknown error
{
$mesg = '<div class="error">'.$langs->trans("ErrorFileNotUploaded").'</div>';
}
else if (preg_match('/ErrorFileIsInfectedWithAVirus/',$resupload)) // Files infected by a virus
{
$mesg = '<div class="error">'.$langs->trans("ErrorFileIsInfectedWithAVirus").'</div>';
}
else // Known error
{
$mesg = '<div class="error">'.$langs->trans($resupload).'</div>';
}
}
}
}
@ -119,9 +123,9 @@ if ($id > 0 || ! empty($ref))
$company = new Societe($db);
$company->fetch($project->socid);
if ($project->societe->id > 0) $result=$project->societe->fetch($project->societe->id);
// To verify role of users
$userAccess = $project->restrictedProjectArea($user);
@ -135,7 +139,7 @@ if ($id > 0 || ! empty($ref))
{
$totalsize+=$file['size'];
}
if ($_GET["action"] == 'delete')
{
$ret=$form->form_confirm($_SERVER["PHP_SELF"]."?id=".$_GET["id"]."&urlfile=".$_GET['urlfile'],$langs->trans("DeleteAFile"),$langs->trans("ConfirmDeleteAFile"),"confirm_delete",'','',1);
@ -143,34 +147,34 @@ if ($id > 0 || ! empty($ref))
}
print '<table class="border" width="100%">';
// Ref
print '<tr><td width="30%">'.$langs->trans("Ref").'</td><td>';
print $form->showrefnav($project,'ref','',1,'ref','ref');
print '</td></tr>';
// Label
print '<tr><td>'.$langs->trans("Label").'</td><td>'.$project->title.'</td></tr>';
// Company
print '<tr><td>'.$langs->trans("Company").'</td><td>';
if (! empty($project->societe->id)) print $project->societe->getNomUrl(1);
else print '&nbsp;';
print '</td></tr>';
// Visibility
print '<tr><td>'.$langs->trans("Visibility").'</td><td>';
if ($project->public) print $langs->trans('SharedProject');
else print $langs->trans('PrivateProject');
print '</td></tr>';
// Statut
print '<tr><td>'.$langs->trans("Status").'</td><td>'.$project->getLibStatut(4).'</td></tr>';
// Files infos
print '<tr><td>'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.sizeof($filearray).'</td></tr>';
print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.$totalsize.' '.$langs->trans("bytes").'</td></tr>';
print "</table>\n";
print "</div>\n";

View File

@ -84,27 +84,30 @@ else
// Envoi fichier
if ($_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC))
{
if (! is_dir($upload_dir)) create_exdir($upload_dir);
require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
if (is_dir($upload_dir))
if (create_exdir($upload_dir) >= 0)
{
$result = dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name'],0);
if ($result > 0)
{
$mesg = '<div class="ok">'.$langs->trans("FileTransferComplete").'</div>';
//print_r($_FILES);
}
else if ($result == -99)
{
// Files infected by a virus
$langs->load("errors");
$mesg = '<div class="error">'.$langs->trans("ErrorFileIsInfectedWithAVirus").'</div>';
}
else if ($result < 0)
$resupload=dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name'],0,0,$_FILES['userfile']['error']);
if (is_numeric($resupload) && $resupload > 0)
{
// Echec transfert (fichier depassant la limite ?)
$mesg = '<div class="error">'.$langs->trans("ErrorFileNotUploaded").'</div>';
// print_r($_FILES);
$mesg = '<div class="ok">'.$langs->trans("FileTransferComplete").'</div>';
}
else
{
$langs->load("errors");
if ($resupload < 0) // Unknown error
{
$mesg = '<div class="error">'.$langs->trans("ErrorFileNotUploaded").'</div>';
}
else if (preg_match('/ErrorFileIsInfectedWithAVirus/',$resupload)) // Files infected by a virus
{
$mesg = '<div class="error">'.$langs->trans("ErrorFileIsInfectedWithAVirus").'</div>';
}
else // Known error
{
$mesg = '<div class="error">'.$langs->trans($resupload).'</div>';
}
}
}
}

View File

@ -73,27 +73,30 @@ $courrier_dir = $conf->societe->dir_output . "/courrier/" . get_exdir($socid) ;
// Envoie fichier
if ( $_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC))
{
if (! is_dir($upload_dir)) create_exdir($upload_dir);
require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
if (is_dir($upload_dir))
if (create_exdir($upload_dir) >= 0)
{
$result = dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name'],0);
if ($result > 0)
$resupload=dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name'],0,0,$_FILES['userfile']['error']);
if (is_numeric($resupload) && $resupload > 0)
{
$mesg = '<div class="ok">'.$langs->trans("FileTransferComplete").'</div>';
//print_r($_FILES);
}
else if ($result == -99)
{
// Files infected by a virus
$langs->load("errors");
$mesg = '<div class="error">'.$langs->trans("ErrorFileIsInfectedWithAVirus").'</div>';
}
else if ($result < 0)
else
{
// Echec transfert (fichier depassant la limite ?)
$mesg = '<div class="error">'.$langs->trans("ErrorFileNotUploaded").'</div>';
// print_r($_FILES);
$langs->load("errors");
if ($resupload < 0) // Unknown error
{
$mesg = '<div class="error">'.$langs->trans("ErrorFileNotUploaded").'</div>';
}
else if (preg_match('/ErrorFileIsInfectedWithAVirus/',$resupload)) // Files infected by a virus
{
$mesg = '<div class="error">'.$langs->trans("ErrorFileIsInfectedWithAVirus").'</div>';
}
else // Known error
{
$mesg = '<div class="error">'.$langs->trans($resupload).'</div>';
}
}
}
}

View File

@ -222,6 +222,8 @@ if ($_GET["action"] == 'removegroup' && $caneditfield)
if ($_POST["action"] == 'update' && ! $_POST["cancel"])
{
require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
if ($caneditfield) // Case we can edit all field
{
$message="";
@ -258,8 +260,7 @@ if ($_POST["action"] == 'update' && ! $_POST["cancel"])
$edituser->phenix_login = $_POST["phenix_login"];
$edituser->phenix_pass = $_POST["phenix_pass"];
$edituser->entity = $_POST["entity"];
$edituser->photo = $_FILES['photo']['name'];
if (! empty($_FILES['photo']['name'])) $edituser->photo = $_FILES['photo']['name'];
$ret=$edituser->update($user);
if ($ret < 0)
@ -295,7 +296,9 @@ if ($_POST["action"] == 'update' && ! $_POST["cancel"])
if (@is_dir($dir))
{
$newfile=$dir.'/'.$_FILES['photo']['name'];
if (! dol_move_uploaded_file($_FILES['photo']['tmp_name'],$newfile,1) > 0)
$result=dol_move_uploaded_file($_FILES['photo']['tmp_name'],$newfile,1,0,$_FILES['photo']['error']);
if (! $result > 0)
{
$message .= '<div class="error">'.$langs->trans("ErrorFailedToSaveFile").'</div>';
}