2
0
forked from Wavyzz/dolibarr

Directory to store files follow same tree than tree of sections

This commit is contained in:
Laurent Destailleur
2008-04-29 21:13:49 +00:00
parent 6ac4014849
commit 24bb2ca1d4
15 changed files with 1871 additions and 1807 deletions

View File

@@ -14,19 +14,17 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
* $Source$
*/ */
/** /**
\file htdocs/admin/tools/purge.php \file htdocs/admin/tools/purge.php
\brief Page de purge des fichiers temporaires \brief Page de purge des fichiers temporaires
\version $Revision$ \version $Id$
*/ */
require("./pre.inc.php"); require("./pre.inc.php");
include_once $dolibarr_main_document_root."/lib/databases/".$conf->db->type.".lib.php"; include_once(DOL_DOCUMENT_ROOT."/lib/databases/".$conf->db->type.".lib.php");
include_once(DOL_DOCUMENT_ROOT.'/lib/files.lib.php');
$langs->load("admin"); $langs->load("admin");
@@ -49,7 +47,7 @@ if ($_POST["action"]=='purge')
// Delete temporary files // Delete temporary files
if ($dolibarr_main_data_root) if ($dolibarr_main_data_root)
{ {
$filesarray=dolibarr_dir_list($dolibarr_main_data_root,"directories",1,'temp'); $filesarray=dol_dir_list($dolibarr_main_data_root,"directories",1,'temp');
} }
} }
@@ -58,7 +56,7 @@ if ($_POST["action"]=='purge')
// Delete all files // Delete all files
if ($dolibarr_main_data_root) if ($dolibarr_main_data_root)
{ {
$filesarray=dolibarr_dir_list($dolibarr_main_data_root,"all",0); $filesarray=dol_dir_list($dolibarr_main_data_root,"all",0);
} }
} }

View File

@@ -15,15 +15,13 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
*/ */
/** /**
\file htdocs/compta/clients.php \file htdocs/compta/clients.php
\ingroup compta \ingroup compta
\brief Page accueil des clients \brief Page accueil des clients
\version $Revision$ \version $Id$
*/ */
require_once("./pre.inc.php"); require_once("./pre.inc.php");

View File

@@ -16,6 +16,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
/** /**
\file htdoc/ecm/docmine.php \file htdoc/ecm/docmine.php
\ingroup ecm \ingroup ecm
@@ -23,7 +24,6 @@
\version $Id$ \version $Id$
\author Laurent Destailleur \author Laurent Destailleur
*/ */
require("./pre.inc.php"); require("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/html.formfile.class.php"); require_once(DOL_DOCUMENT_ROOT."/html.formfile.class.php");
require_once(DOL_DOCUMENT_ROOT."/ecm/ecmdirectory.class.php"); require_once(DOL_DOCUMENT_ROOT."/ecm/ecmdirectory.class.php");
@@ -39,16 +39,25 @@ $langs->load("other");
// Load permissions // Load permissions
$user->getrights('ecm'); $user->getrights('ecm');
// Get parameters // Security check
$socid = isset($_GET["socid"])?$_GET["socid"]:'';
// Permissions
if ($user->societe_id > 0) if ($user->societe_id > 0)
{ {
$action = ''; $action = '';
$socid = $user->societe_id; $socid = $user->societe_id;
} }
// Get parameters
$page=$_GET["page"];
$sortorder=$_GET["sortorder"];
$sortfield=$_GET["sortfield"];
if (! $sortorder) $sortorder="ASC";
if (! $sortfield) $sortfield="name";
if ($page == -1) { $page = 0 ; }
$offset = $conf->liste_limit * $page ;
$pageprev = $page - 1;
$pagenext = $page + 1;
$section=$_REQUEST["section"]; $section=$_REQUEST["section"];
if (! $section) if (! $section)
{ {
@@ -56,18 +65,22 @@ if (! $section)
exit; exit;
} }
// Load ecm object
$ecmdir = new ECMDirectory($db); $ecmdir = new ECMDirectory($db);
if (! empty($_REQUEST["section"])) if (empty($_REQUEST["section"]))
{
dolibarr_print_error('','Error, section parameter missing');
exit;
}
$result=$ecmdir->fetch($_REQUEST["section"]);
if (! $result > 0)
{ {
$result=$ecmdir->fetch($_REQUEST["section"]);
if (! $result > 0)
{
dolibarr_print_error($db,$ecmdir->error); dolibarr_print_error($db,$ecmdir->error);
exit; exit;
}
} }
$relativepath=$ecmdir->getRelativePath();
$upload_dir = $conf->ecm->dir_output.'/'.$ecmdir->label; $upload_dir = $conf->ecm->dir_output.'/'.$relativepath;
/******************************************************************* /*******************************************************************
@@ -132,33 +145,7 @@ $form=new Form($db);
// Construit liste des fichiers // Construit liste des fichiers
clearstatcache(); $filearray=dol_dir_list($upload_dir,"files",0,'','\.meta$',$sortfield,(strtolower($sortorder)=='desc'?SORT_ASC:SORT_DESC),1);
$totalsize=0;
$filearray=array();
$errorlevel=error_reporting();
error_reporting(0);
$handle=opendir($upload_dir);
error_reporting($errorlevel);
if ($handle)
{
$i=0;
while (($file = readdir($handle))!==false)
{
if (!is_dir($dir.$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')
{
$filearray[$i]->name=$file;
$filearray[$i]->size=filesize($upload_dir."/".$file);
$filearray[$i]->date=filemtime($upload_dir."/".$file);
$totalsize+=$filearray[$i]->size;
$i++;
}
}
closedir($handle);
}
else
{
// print '<div class="error">'.$langs->trans("ErrorCanNotReadDir",$upload_dir).'</div>';
}
$head = ecm_prepare_head($ecmdir); $head = ecm_prepare_head($ecmdir);
@@ -173,9 +160,10 @@ $result = 1;
while ($tmpecmdir && $result > 0) while ($tmpecmdir && $result > 0)
{ {
$tmpecmdir->ref=$tmpecmdir->label; $tmpecmdir->ref=$tmpecmdir->label;
$s=' -> '.$tmpecmdir->getNomUrl(1).$s; $s=$tmpecmdir->getNomUrl(1).$s;
if ($tmpecmdir->fk_parent) if ($tmpecmdir->fk_parent)
{ {
$s=' -> '.$s;
$result=$tmpecmdir->fetch($tmpecmdir->fk_parent); $result=$tmpecmdir->fetch($tmpecmdir->fk_parent);
} }
else else
@@ -183,7 +171,7 @@ while ($tmpecmdir && $result > 0)
$tmpecmdir=0; $tmpecmdir=0;
} }
} }
print img_picto('','object_dir').' <a href="'.DOL_URL_ROOT.'/ecm/index.php">'.$langs->trans("ECMRoot").'</a>'; //print img_picto('','object_dir').' <a href="'.DOL_URL_ROOT.'/ecm/index.php">'.$langs->trans("ECMRoot").'</a>';
print $s; print $s;
print '</td></tr>'; print '</td></tr>';
print '<tr><td>'.$langs->trans("Description").'</td><td>'; print '<tr><td>'.$langs->trans("Description").'</td><td>';
@@ -197,11 +185,20 @@ print '</td></tr>';
print '<tr><td>'.$langs->trans("ECMCreationDate").'</td><td>'; print '<tr><td>'.$langs->trans("ECMCreationDate").'</td><td>';
print dolibarr_print_date($ecmdir->date_c,'dayhour'); print dolibarr_print_date($ecmdir->date_c,'dayhour');
print '</td></tr>'; print '</td></tr>';
print '<tr><td>'.$langs->trans("ECMDirectoryForFiles").'</td><td>';
//print $conf->ecm->dir_output;
print '/ecm/'.$relativepath;
print '</td></tr>';
print '<tr><td>'.$langs->trans("ECMNbOfDocs").'</td><td>'; print '<tr><td>'.$langs->trans("ECMNbOfDocs").'</td><td>';
print sizeof($filearray); print sizeof($filearray);
print '</td></tr>'; print '</td></tr>';
print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td>'; print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td>';
print $totalsize; $totalsize=0;
foreach($filearray as $key => $file)
{
$totalsize+=$file['size'];
}
print dol_print_size($totalsize);
print '</td></tr>'; print '</td></tr>';
print '</table>'; print '</table>';
@@ -227,6 +224,7 @@ $formfile->form_attach_new_file(DOL_URL_ROOT.'/ecm/docmine.php','',0,$section);
// Affiche liste des documents existant // Affiche liste des documents existant
print_titre($langs->trans("AttachedFiles")); print_titre($langs->trans("AttachedFiles"));
/** /**
* TODO Mettre cette section dans une zone AJAX * TODO Mettre cette section dans une zone AJAX
*/ */
@@ -234,28 +232,26 @@ $modulepart='ecm';
$url=$_SERVER["PHP_SELF"]; $url=$_SERVER["PHP_SELF"];
print '<table width="100%" class="noborder">'; print '<table width="100%" class="noborder">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
$param='&amp;socid='.$socid; $param='&amp;section='.$section;
print_liste_field_titre($langs->trans("Document"),$_SERVER["PHP_SELF"],"name","",$param,'align="left"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Document"),$_SERVER["PHP_SELF"],"name","",$param,'align="left"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Size"),$_SERVER["PHP_SELF"],"size","",$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Size"),$_SERVER["PHP_SELF"],"size","",$param,'align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Date"),$_SERVER["PHP_SELF"],"date","",$param,'align="center"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Date"),$_SERVER["PHP_SELF"],"date","",$param,'align="center"',$sortfield,$sortorder);
print '<td>&nbsp;</td>'; print '<td>&nbsp;</td>';
print '</tr>'; print '</tr>';
usort($filearray,"dol_compare_file");
$var=true; $var=true;
foreach($filearray as $key => $file) foreach($filearray as $key => $file)
{ {
if (!is_dir($dir.$file->name) && substr($file->name, 0, 1) <> '.' && substr($file->name, 0, 3) <> 'CVS') if (!is_dir($dir.$file['name']) && substr($file['name'], 0, 1) <> '.' && substr($file['name'], 0, 3) <> 'CVS')
{ {
$var=!$var; $var=!$var;
print "<tr $bc[$var]><td>"; print "<tr $bc[$var]><td>";
echo '<a href="'.DOL_URL_ROOT.'/document.php?modulepart='.$modulepart.'&type=application/binary&file='.urlencode($prefix.$file->name).'">'.$file->name.'</a>'; echo '<a href="'.DOL_URL_ROOT.'/document.php?modulepart='.$modulepart.'&type=application/binary&file='.urlencode($prefix.$file['name']).'">'.$file['name'].'</a>';
print "</td>\n"; print "</td>\n";
print '<td align="right">'.$file->size.' '.$langs->trans("bytes").'</td>'; print '<td align="right">'.dol_print_size($file['size']).'</td>';
print '<td align="center">'.dolibarr_print_date($file->date,"dayhour").'</td>'; print '<td align="center">'.dolibarr_print_date($file['date'],"dayhour").'</td>';
print '<td align="center">'; print '<td align="center">';
echo '<a href="'.$url.'?section='.$_REQUEST["section"].'&amp;action=delete_file&urlfile='.urlencode($file->name).'">'.img_delete().'</a>'; echo '<a href="'.$url.'?section='.$_REQUEST["section"].'&amp;action=delete_file&urlfile='.urlencode($file['name']).'">'.img_delete().'</a>';
print "</td></tr>\n"; print "</td></tr>\n";
} }
} }

View File

@@ -26,12 +26,6 @@
\remarks Initialy built by build_class_from_table on 2008-02-24 19:24 \remarks Initialy built by build_class_from_table on 2008-02-24 19:24
*/ */
// Put here all includes required by your class file
//require_once(DOL_DOCUMENT_ROOT."/commonobject.class.php");
//require_once(DOL_DOCUMENT_ROOT."/societe.class.php");
//require_once(DOL_DOCUMENT_ROOT."/product.class.php");
/** /**
\class EcmDirectory \class EcmDirectory
\brief Class to manage ECM directories \brief Class to manage ECM directories
@@ -131,7 +125,7 @@ class EcmDirectory // extends CommonObject
} }
} }
/* /**
* \brief Update database * \brief Update database
* \param user User that modify * \param user User that modify
* \param notrigger 0=no, 1=yes (no update trigger) * \param notrigger 0=no, 1=yes (no update trigger)
@@ -186,7 +180,7 @@ class EcmDirectory // extends CommonObject
} }
/* /**
* \brief Update database * \brief Update database
* \sign '+' or '-' * \sign '+' or '-'
* \return int <0 if KO, >0 if OK * \return int <0 if KO, >0 if OK
@@ -214,7 +208,7 @@ class EcmDirectory // extends CommonObject
} }
/* /**
* \brief Load object in memory from database * \brief Load object in memory from database
* \param id id object * \param id id object
* \return int <0 if KO, >0 if OK * \return int <0 if KO, >0 if OK
@@ -268,7 +262,7 @@ class EcmDirectory // extends CommonObject
} }
/* /**
* \brief Delete object in database * \brief Delete object in database
* \param user User that delete * \param user User that delete
* \return int <0 if KO, >0 if OK * \return int <0 if KO, >0 if OK
@@ -343,6 +337,43 @@ class EcmDirectory // extends CommonObject
return $result; return $result;
} }
/**
\brief Return relative path of a directory on disk
\return string Relative physical path
*/
function getRelativePath()
{
$this->get_full_arbo();
$ret='';
$idtosearch=$this->id;
$i=0;
do {
// Get index cursor in this->cats for id_mere
$cursorindex=-1;
foreach ($this->cats as $key => $val)
{
if ($this->cats[$key]['id'] == $idtosearch)
{
$cursorindex=$key;
break;
}
}
//print "c=".$idtosearch."-".$cursorindex;
if ($cursorindex >= 0)
{
$ret=$this->cats[$cursorindex]['label'].'/'.$ret;
$idtosearch=$this->cats[$cursorindex]['id_mere'];
$i++;
}
}
while ($cursorindex >= 0 && ! empty($idtosearch) && $i < 100); // i avoid infinite loop
return $ret;
}
/** /**
* \brief Load this->motherof array * \brief Load this->motherof array
* \return int <0 if KO, >0 if OK * \return int <0 if KO, >0 if OK

View File

@@ -1,14 +1,5 @@
<?php <?php
/* Copyright (c) 2002-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2008 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
* Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005-2007 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
* Copyright (C) 2006 Marc Barilley/Ocebo <marc@ocebo.com>
* Copyright (C) 2007 Franky Van Liedekerke <franky.van.liedekerker@telenet.be>
* Copyright (C) 2007 Patrick Raguin <patrick.raguin@gmail.com>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@@ -26,18 +17,18 @@
*/ */
/** /**
\file htdocs/ecm/htmlecm.form.class.php * \file htdocs/ecm/htmlecm.form.class.php
\brief Fichier de la classe des fonctions pr<70>d<EFBFBD>finie de composants html * \brief Fichier de la classe des fonctions pr<70>d<EFBFBD>finie de composants html
\version $Id$ * \version $Id$
*/ */
require_once(DOL_DOCUMENT_ROOT."/ecm/ecmdirectory.class.php"); require_once(DOL_DOCUMENT_ROOT."/ecm/ecmdirectory.class.php");
/** /**
\class FormEcm * \class FormEcm
\brief Classe permettant la g<>n<EFBFBD>ration de composants html * \brief Classe permettant la g<>n<EFBFBD>ration de composants html
\remarks Only common components must be here. * \remarks Only common components must be here.
*/ */
class FormEcm class FormEcm
{ {
var $db; var $db;
@@ -52,8 +43,8 @@ class FormEcm
/** /**
\brief Constructeur * \brief Constructeur
\param DB handler d'acc<63>s base de donn<6E>e * \param DB handler d'acc<63>s base de donn<6E>e
*/ */
function FormEcm($DB) function FormEcm($DB)
{ {

View File

@@ -125,6 +125,7 @@ class FormFile
function show_documents($modulepart,$filename,$filedir,$urlsource,$genallowed,$delallowed=0,$modelselected='',$modelliste=array(),$forcenomultilang=0,$iconPDF=0) function show_documents($modulepart,$filename,$filedir,$urlsource,$genallowed,$delallowed=0,$modelselected='',$modelliste=array(),$forcenomultilang=0,$iconPDF=0)
{ {
// filedir = conf->...dir_ouput."/".get_exdir(id) // filedir = conf->...dir_ouput."/".get_exdir(id)
include_once(DOL_DOCUMENT_ROOT.'/lib/files.lib.php');
global $langs,$bc,$conf; global $langs,$bc,$conf;
$var=true; $var=true;
@@ -289,7 +290,7 @@ class FormFile
$png = '|\.png$'; $png = '|\.png$';
$filter = $filename.'.pdf'; $filter = $filename.'.pdf';
} }
$file_list=dolibarr_dir_list($filedir,'files',0,$filter,'\.meta$'.$png,'date',SORT_DESC); $file_list=dol_dir_list($filedir,'files',0,$filter,'\.meta$'.$png,'date',SORT_DESC);
// Affiche en-tete tableau si non deja affich<63> // Affiche en-tete tableau si non deja affich<63>
if (sizeof($file_list) && ! $headershown && !$iconPDF) if (sizeof($file_list) && ! $headershown && !$iconPDF)

View File

@@ -93,7 +93,11 @@ if ($_POST["action"] == "set" || $_POST["action"] == "upgrade")
// on d<>code le mot de passe de la base si besoin // on d<>code le mot de passe de la base si besoin
require_once(DOL_DOCUMENT_ROOT ."/lib/functions.lib.php"); require_once(DOL_DOCUMENT_ROOT ."/lib/functions.lib.php");
if (isset($dolibarr_main_db_encrypted_pass) && $dolibarr_main_db_encrypted_pass) $dolibarr_main_db_pass = dolibarr_decode($dolibarr_main_db_encrypted_pass); if (! empty($dolibarr_main_db_encrypted_pass))
{
require_once(DOL_DOCUMENT_ROOT ."/lib/security.lib.php");
$dolibarr_main_db_pass = dol_decode($dolibarr_main_db_encrypted_pass);
}
$conf->db->type = $dolibarr_main_db_type; $conf->db->type = $dolibarr_main_db_type;
$conf->db->host = $dolibarr_main_db_host; $conf->db->host = $dolibarr_main_db_host;

View File

@@ -77,8 +77,12 @@ if (! isset($_GET["action"]) || $_GET["action"] == "upgrade")
print '<table cellspacing="0" cellpadding="1" border="0" width="100%">'; print '<table cellspacing="0" cellpadding="1" border="0" width="100%">';
$error=0; $error=0;
// on d<>code le mot de passe de la base si besoin // decode database pass if needed
if (isset($dolibarr_main_db_encrypted_pass) && $dolibarr_main_db_encrypted_pass) $dolibarr_main_db_pass = dolibarr_decode($dolibarr_main_db_encrypted_pass); if (! empty($dolibarr_main_db_encrypted_pass))
{
require_once($dolibarr_main_document_root."/lib/security.lib.php");
$dolibarr_main_db_pass = dol_decode($dolibarr_main_db_encrypted_pass);
}
// $conf is already instancied inside inc.php // $conf is already instancied inside inc.php
$conf->db->type = $dolibarr_main_db_type; $conf->db->type = $dolibarr_main_db_type;

View File

@@ -75,7 +75,11 @@ if (isset($_POST['action']) && $_POST['action'] == 'upgrade')
print '<table cellspacing="0" cellpadding="1" border="0" width="100%">'; print '<table cellspacing="0" cellpadding="1" border="0" width="100%">';
// on decode le mot de passe de la base si besoin // on decode le mot de passe de la base si besoin
if (isset($dolibarr_main_db_encrypted_pass) && $dolibarr_main_db_encrypted_pass) $dolibarr_main_db_pass = dolibarr_decode($dolibarr_main_db_encrypted_pass); if (! empty($dolibarr_main_db_encrypted_pass))
{
require_once($dolibarr_main_document_root."/lib/security.lib.php");
$dolibarr_main_db_pass = dol_decode($dolibarr_main_db_encrypted_pass);
}
// $conf is already instancied inside inc.php // $conf is already instancied inside inc.php
$conf->db->type = $dolibarr_main_db_type; $conf->db->type = $dolibarr_main_db_type;

View File

@@ -20,8 +20,8 @@ ECMNewSection=New manual directory
ECMNewDocument=New document ECMNewDocument=New document
ECMCreationDate=Creation date ECMCreationDate=Creation date
ECMCreationUser=Creator ECMCreationUser=Creator
ECMArea=Electronic Content Management area ECMArea=ECM area
ECMAreaDesc=The Electronic Content Management area allows you to save, share and search quickly documents in Dolibarr. ECMAreaDesc=The ECM (Electronic Content Management) area allows you to save, share and search quickly all kind of documents in Dolibarr.
ECMAreaDesc2=* Automatic directories are filled automatically when adding documents from card of an element.<br>* Manual directories can be used to save documents not linked to a particular element. ECMAreaDesc2=* Automatic directories are filled automatically when adding documents from card of an element.<br>* Manual directories can be used to save documents not linked to a particular element.
ECMSectionWasRemoved=Directory <b>%s</b> has been deleted. ECMSectionWasRemoved=Directory <b>%s</b> has been deleted.
ECMDocumentsSection=Document of directory ECMDocumentsSection=Document of directory
@@ -41,3 +41,4 @@ ECMNoDirecotyYet=No directory created
ShowECMSection=Show directory ShowECMSection=Show directory
DeleteSection=Remove directory DeleteSection=Remove directory
ConfirmDeleteSection=Can you confirm you want to delete the directory <b>%s</b> ? ConfirmDeleteSection=Can you confirm you want to delete the directory <b>%s</b> ?
ECMDirectoryForFiles=Relative directory for files

View File

@@ -20,9 +20,9 @@ ECMNewSection=Nouvelle rubrique manuelle
ECMNewDocument=Nouveau document ECMNewDocument=Nouveau document
ECMCreationDate=Date cr<63>ation ECMCreationDate=Date cr<63>ation
ECMCreationUser=Cr<43>ateur ECMCreationUser=Cr<43>ateur
ECMArea=Espace Gestion de documents ECMArea=Espace GED
ECMAreaDesc=L'espace Gestion des documents vous permet de stocker et retrouver rapidement des documents dans Dolibarr. ECMAreaDesc=L'espace GED (Gestion Electronique de Documents) vous permet de stocker dans Dolibarr et retrouver rapidement tout type de documents.
ECMAreaDesc2=* Les rubriques automatiques sont aliment<6E>es automatiquement lors de l'ajout d'un document depuis une fiche objet.<br>* Les rubriques manuelles peuvent etre utilis<69>es pour stocker des documents li<EFBFBD>s <20> aucun <20>l<EFBFBD>ment particulier. ECMAreaDesc2=* Les rubriques automatiques sont aliment<6E>es automatiquement lors de l'ajout d'un document depuis une fiche objet (propal, facture, commande...).<br>* Les rubriques manuelles peuvent etre utilis<69>es pour stocker des documents divers, non li<6C>s <20> un objet particulier.
ECMSectionWasRemoved=La rubrique <b>%s</b> a <20>t<EFBFBD> effac<61>e. ECMSectionWasRemoved=La rubrique <b>%s</b> a <20>t<EFBFBD> effac<61>e.
ECMDocumentsSection=Document de la section ECMDocumentsSection=Document de la section
ECMSearchByKeywords=Recherche par mots cl<63>s ECMSearchByKeywords=Recherche par mots cl<63>s
@@ -41,3 +41,4 @@ ECMNoDirecotyYet=Aucune rubrique cr
ShowECMSection=Afficher rubrique ShowECMSection=Afficher rubrique
DeleteSection=Suppression rubrique DeleteSection=Suppression rubrique
ConfirmDeleteSection=Confirmez-vous la suppression de la rubique <b>%s</b> ? ConfirmDeleteSection=Confirmez-vous la suppression de la rubique <b>%s</b> ?
ECMDirectoryForFiles=R<>pertoire relatif pour les fichiers

View File

@@ -23,6 +23,109 @@
\version $Id$ \version $Id$
*/ */
/**
\brief Scan a directory and return a list of files/directories
\param $path Starting path from which to search
\param $types Can be "directories", "files", or "all"
\param $recursive Determines whether subdirectories are searched
\param $filter Regex for filter
\param $exludefilter Regex for exclude filter (example: '\.meta$')
\param $sortcriteria Sort criteria ("name","date","size")
\param $sortorder Sort order (SORT_ASC, SORT_DESC)
\param $mode 0=Return array of key need, 1=Force all key to be loaded
\return array Array of array('name'=>xxx,'date'=>yyy,'size'=>zzz)
*/
function dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter="", $sortcriteria="name", $sortorder=SORT_ASC, $mode=0)
{
dolibarr_syslog("files.lib.php::dol_dir_list $path");
$loaddate=$mode?true:false;
$loadsize=$mode?true:false;
// Clean parameters
$path=eregi_replace('[\\/]+$','',$path);
if (! is_dir($path)) return array();
if ($dir = opendir($path))
{
$file_list = array();
while (false !== ($file = readdir($dir)))
{
$qualified=1;
// Check if file is qualified
if (eregi('^\.',$file)) $qualified=0;
if ($excludefilter && eregi($excludefilter,$file)) $qualified=0;
if ($qualified)
{
// Check whether this is a file or directory and whether we're interested in that type
if (is_dir($path."/".$file) && (($types=="directories") || ($types=="all")))
{
// Add entry into file_list array
if ($loaddate || $sortcriteria == 'date') $filedate=filemtime($path."/".$file);
if ($loadsize || $sortcriteria == 'size') $filesize=filesize($path."/".$file);
if (! $filter || eregi($filter,$path.'/'.$file))
{
$file_list[] = array(
"name" => $file,
"fullname" => $path.'/'.$file,
"date" => $filedate,
"size" => $filesize
);
}
// if we're in a directory and we want recursive behavior, call this function again
if ($recursive)
{
$file_list = array_merge($file_list, dol_dir_list($path."/".$file."/", $types, $recursive, $filter, $excludefilter, $sortcriteria, $sortorder));
}
}
else if (! is_dir($path."/".$file) && (($types == "files") || ($types == "all")))
{
// Add file into file_list array
if ($loaddate || $sortcriteria == 'date') $filedate=filemtime($path."/".$file);
if ($loadsize || $sortcriteria == 'size') $filesize=filesize($path."/".$file);
if (! $filter || eregi($filter,$path.'/'.$file))
{
$file_list[] = array(
"name" => $file,
"fullname" => $path.'/'.$file,
"date" => $filedate,
"size" => $filesize
);
}
}
}
}
closedir($dir);
// Obtain a list of columns
$myarray=array();
foreach ($file_list as $key => $row)
{
$myarray[$key] = $row[$sortcriteria];
}
// Sort the data
array_multisort($myarray, $sortorder, $file_list);
return $file_list;
}
else
{
return false;
}
}
/**
* \brief Compare 2 files
*
* @param unknown_type $a File 1
* @param unknown_type $b File 2
* @return int 1, 0, 1
*/
function dol_compare_file($a, $b) function dol_compare_file($a, $b)
{ {
global $sortorder; global $sortorder;

View File

@@ -27,7 +27,7 @@
\file htdocs/lib/functions.lib.php \file htdocs/lib/functions.lib.php
\brief Ensemble de fonctions de base de dolibarr sous forme d'include \brief Ensemble de fonctions de base de dolibarr sous forme d'include
\version $Id$ \version $Id$
*/ */
// Pour compatibilit<69> lors de l'upgrade // Pour compatibilit<69> lors de l'upgrade
if (! defined('DOL_DOCUMENT_ROOT')) define('DOL_DOCUMENT_ROOT', '..'); if (! defined('DOL_DOCUMENT_ROOT')) define('DOL_DOCUMENT_ROOT', '..');
@@ -39,7 +39,7 @@ if (! defined('ADODB_DATE_VERSION')) include_once(DOL_DOCUMENT_ROOT."/includes/a
\brief Renvoi vrai si l'email est syntaxiquement valide \brief Renvoi vrai si l'email est syntaxiquement valide
\param address adresse email (Ex: "toto@titi.com", "John Do <johndo@titi.com>") \param address adresse email (Ex: "toto@titi.com", "John Do <johndo@titi.com>")
\return boolean true si email valide, false sinon \return boolean true si email valide, false sinon
*/ */
function ValidEmail($address) function ValidEmail($address)
{ {
if (ereg( ".*<(.+)>", $address, $regs)) { if (ereg( ".*<(.+)>", $address, $regs)) {
@@ -59,7 +59,7 @@ function ValidEmail($address)
\brief Renvoi vrai si l'email a un nom de domaine qui r<>soud via dns \brief Renvoi vrai si l'email a un nom de domaine qui r<>soud via dns
\param mail adresse email (Ex: "toto@titi.com", "John Do <johndo@titi.com>") \param mail adresse email (Ex: "toto@titi.com", "John Do <johndo@titi.com>")
\return boolean true si email valide, false sinon \return boolean true si email valide, false sinon
*/ */
function check_mail ($mail) function check_mail ($mail)
{ {
list($user, $domain) = split("@", $mail, 2); list($user, $domain) = split("@", $mail, 2);
@@ -77,7 +77,7 @@ function check_mail ($mail)
\brief Nettoie chaine de caractere iso des accents \brief Nettoie chaine de caractere iso des accents
\param str Chaine a nettoyer \param str Chaine a nettoyer
\return string Chaine nettoyee \return string Chaine nettoyee
*/ */
function unaccent_isostring($str) function unaccent_isostring($str)
{ {
$translation = array( $translation = array(
@@ -104,7 +104,7 @@ function unaccent_isostring($str)
\remarks Fonction appelee par exemple pour definir un nom de fichier depuis un identifiant chaine libre \remarks Fonction appelee par exemple pour definir un nom de fichier depuis un identifiant chaine libre
\param str Chaine a nettoyer \param str Chaine a nettoyer
\return string Chaine nettoyee (A-Z_) \return string Chaine nettoyee (A-Z_)
*/ */
function sanitize_string($str) function sanitize_string($str)
{ {
$forbidden_chars_to_underscore=array(" ","'","/","\\",":","*","?","\"","<",">","|","[","]",",",";","="); $forbidden_chars_to_underscore=array(" ","'","/","\\",":","*","?","\"","<",">","|","[","]",",",";","=");
@@ -127,7 +127,7 @@ function sanitize_string($str)
Si SYSLOG_FILE_NO_ERROR d<>fini, on ne g<>re pas erreur ecriture log Si SYSLOG_FILE_NO_ERROR d<>fini, on ne g<>re pas erreur ecriture log
\remarks On Windows LOG_ERR=4, LOG_WARNING=5, LOG_NOTICE=LOG_INFO=LOG_DEBUG=6 \remarks On Windows LOG_ERR=4, LOG_WARNING=5, LOG_NOTICE=LOG_INFO=LOG_DEBUG=6
On Linux LOG_ERR=3, LOG_WARNING=4, LOG_INFO=6, LOG_DEBUG=7 On Linux LOG_ERR=3, LOG_WARNING=4, LOG_INFO=6, LOG_DEBUG=7
*/ */
function dolibarr_syslog($message, $level=LOG_INFO) function dolibarr_syslog($message, $level=LOG_INFO)
{ {
global $conf,$user,$langs; global $conf,$user,$langs;
@@ -222,7 +222,7 @@ function dolibarr_syslog($message, $level=LOG_INFO)
\param active 0=onglet non actif, 1=onglet actif \param active 0=onglet non actif, 1=onglet actif
\param title Titre tabelau ("" par defaut) \param title Titre tabelau ("" par defaut)
\param notab 0=Add tab header, 1=no tab header \param notab 0=Add tab header, 1=no tab header
*/ */
function dolibarr_fiche_head($links, $active='0', $title='', $notab=0) function dolibarr_fiche_head($links, $active='0', $title='', $notab=0)
{ {
print "\n".'<div class="tabs">'."\n"; print "\n".'<div class="tabs">'."\n";
@@ -275,7 +275,7 @@ function dolibarr_fiche_head($links, $active='0', $title='', $notab=0)
Si non defini on sauve tous parametres du tableau tab Si non defini on sauve tous parametres du tableau tab
\param tab Tableau (cl<63>=>valeur) des param<61>tres a sauvegarder \param tab Tableau (cl<63>=>valeur) des param<61>tres a sauvegarder
\return int <0 si ko, >0 si ok \return int <0 si ko, >0 si ok
*/ */
function dolibarr_set_user_page_param($db, &$user, $url='', $tab) function dolibarr_set_user_page_param($db, &$user, $url='', $tab)
{ {
// Verification parametres // Verification parametres
@@ -340,7 +340,7 @@ function dolibarr_set_user_page_param($db, &$user, $url='', $tab)
\brief Formattage des nombres \brief Formattage des nombres
\param ca valeur a formater \param ca valeur a formater
\return int valeur format<61>e \return int valeur format<61>e
*/ */
function dolibarr_print_ca($ca) function dolibarr_print_ca($ca)
{ {
global $langs,$conf; global $langs,$conf;
@@ -372,7 +372,7 @@ function dolibarr_print_ca($ca)
\param duration_value Valeur de la dur<75>e a ajouter \param duration_value Valeur de la dur<75>e a ajouter
\param duration_unit Unit<69> de la dur<75>e a ajouter (d, m, y) \param duration_unit Unit<69> de la dur<75>e a ajouter (d, m, y)
\return int Nouveau timestamp \return int Nouveau timestamp
*/ */
function dolibarr_time_plus_duree($time,$duration_value,$duration_unit) function dolibarr_time_plus_duree($time,$duration_value,$duration_unit)
{ {
if ($duration_value == 0) return $time; if ($duration_value == 0) return $time;
@@ -394,7 +394,7 @@ function dolibarr_time_plus_duree($time,$duration_value,$duration_unit)
"%d/%m/%Y %H:%M:%S", "%d/%m/%Y %H:%M:%S",
"day", "daytext", "dayhour", "dayhourldap", "dayhourtext" "day", "daytext", "dayhour", "dayhourldap", "dayhourtext"
\return string Date format<61>e ou '' si time null \return string Date format<61>e ou '' si time null
*/ */
function dolibarr_print_date($time,$format='') function dolibarr_print_date($time,$format='')
{ {
global $conf; global $conf;
@@ -442,7 +442,7 @@ function dolibarr_print_date($time,$format='')
DD/MM/YY ou DD/MM/YYYY DD/MM/YY ou DD/MM/YYYY
DD/MM/YY HH:MM:SS ou DD/MM/YYYY HH:MM:SS DD/MM/YY HH:MM:SS ou DD/MM/YYYY HH:MM:SS
\return date Date \return date Date
*/ */
function dolibarr_stringtotime($string) function dolibarr_stringtotime($string)
{ {
if (eregi('^([0-9]+)\/([0-9]+)\/([0-9]+) ?([0-9]+)?:?([0-9]+)?:?([0-9]+)?',$string,$reg)) if (eregi('^([0-9]+)\/([0-9]+)\/([0-9]+) ?([0-9]+)?:?([0-9]+)?:?([0-9]+)?',$string,$reg))
@@ -495,7 +495,7 @@ function dolibarr_stringtotime($string)
'leap' => $leaf, 'leap' => $leaf,
'ndays' => $ndays 'ndays' => $ndays
\remarks PHP getdate is restricted to the years 1901-2038 on Unix and 1970-2038 on Windows \remarks PHP getdate is restricted to the years 1901-2038 on Unix and 1970-2038 on Windows
*/ */
function dolibarr_getdate($timestamp,$fast=false) function dolibarr_getdate($timestamp,$fast=false)
{ {
$usealternatemethod=false; $usealternatemethod=false;
@@ -527,7 +527,7 @@ function dolibarr_getdate($timestamp,$fast=false)
\param check No check on parameters (Can use day 32, etc...) \param check No check on parameters (Can use day 32, etc...)
\return timestamp Date en timestamp, '' if error \return timestamp Date en timestamp, '' if error
\remarks PHP mktime is restricted to the years 1901-2038 on Unix and 1970-2038 on Windows \remarks PHP mktime is restricted to the years 1901-2038 on Unix and 1970-2038 on Windows
*/ */
function dolibarr_mktime($hour,$minute,$second,$month,$day,$year,$gm=0,$check=1) function dolibarr_mktime($hour,$minute,$second,$month,$day,$year,$gm=0,$check=1)
{ {
//print "- ".$hour.",".$minute.",".$second.",".$month.",".$day.",".$year.",".$_SERVER["WINDIR"]." -"; //print "- ".$hour.",".$minute.",".$second.",".$month.",".$day.",".$year.",".$_SERVER["WINDIR"]." -";
@@ -575,7 +575,7 @@ function dolibarr_mktime($hour,$minute,$second,$month,$day,$year,$gm=0,$check=1)
\param timestamp Date. Exemple: Si timestamp=0 et gm=1, renvoi 01/01/1970 00:00:00 \param timestamp Date. Exemple: Si timestamp=0 et gm=1, renvoi 01/01/1970 00:00:00
\param gm 1 if timestamp was built with gmmktime, 0 if timestamp was build with mktime \param gm 1 if timestamp was built with gmmktime, 0 if timestamp was build with mktime
\return string Formated date \return string Formated date
*/ */
function dolibarr_date($fmt, $timestamp, $gm=0) function dolibarr_date($fmt, $timestamp, $gm=0)
{ {
$usealternatemethod=false; $usealternatemethod=false;
@@ -598,7 +598,7 @@ function dolibarr_date($fmt, $timestamp, $gm=0)
/** /**
\brief Affiche les informations d'un objet \brief Affiche les informations d'un objet
\param object objet a afficher \param object objet a afficher
*/ */
function dolibarr_print_object_info($object) function dolibarr_print_object_info($object)
{ {
global $langs; global $langs;
@@ -640,7 +640,7 @@ function dolibarr_print_object_info($object)
\param phone Num<75>ro de telephone a formater \param phone Num<75>ro de telephone a formater
\param country Pays selon lequel formatter \param country Pays selon lequel formatter
\return string Num<75>ro de t<>l<EFBFBD>phone format<61> \return string Num<75>ro de t<>l<EFBFBD>phone format<61>
*/ */
function dolibarr_print_phone($phone,$country="FR") function dolibarr_print_phone($phone,$country="FR")
{ {
$phone=trim($phone); $phone=trim($phone);
@@ -674,6 +674,20 @@ function dolibarr_print_phone($phone,$country="FR")
return $phone; return $phone;
} }
/**
* \brief Return string with formated size
* \param size Size to print
* \return string Link
*/
function dol_print_size($size)
{
global $langs;
return $size.' '.$langs->trans("Bytes");
}
/** /**
* \brief Show click to dial link * \brief Show click to dial link
* \param phone Phone to call * \param phone Phone to call
@@ -704,7 +718,7 @@ function dol_phone_link($phone,$option=0)
\param trunc Where to trunc: right, left, middle \param trunc Where to trunc: right, left, middle
\return string Truncated string \return string Truncated string
\remarks USE_SHORT_TITLE=0 can disable all truncings \remarks USE_SHORT_TITLE=0 can disable all truncings
*/ */
function dolibarr_trunc($string,$size=40,$trunc='right') function dolibarr_trunc($string,$size=40,$trunc='right')
{ {
if ($size==0) return $string; if ($size==0) return $string;
@@ -750,7 +764,7 @@ function dolibarr_trunc($string,$size=40,$trunc='right')
\param side 0=Compl<70>tion a droite, 1=Compl<70>tion a gauche \param side 0=Compl<70>tion a droite, 1=Compl<70>tion a gauche
\param char Chaine de compl<70>tion \param char Chaine de compl<70>tion
\return string Chaine compl<70>t<EFBFBD>e \return string Chaine compl<70>t<EFBFBD>e
*/ */
function dolibarr_pad($string,$size,$side,$char=' ') function dolibarr_pad($string,$size,$side,$char=' ')
{ {
$taille=sizeof($string); $taille=sizeof($string);
@@ -769,7 +783,7 @@ function dolibarr_pad($string,$size,$side,$char=' ')
\param alt Texte sur le alt de l'image \param alt Texte sur le alt de l'image
\param object Objet pour lequel il faut afficher le logo (exemple: user, group, action, bill, contract, propal, product, ...) \param object Objet pour lequel il faut afficher le logo (exemple: user, group, action, bill, contract, propal, product, ...)
\return string Retourne tag img \return string Retourne tag img
*/ */
function img_object($alt, $object) function img_object($alt, $object)
{ {
global $conf,$langs; global $conf,$langs;
@@ -783,7 +797,7 @@ function img_object($alt, $object)
\param options Attribut suppl<70>mentaire a la balise img \param options Attribut suppl<70>mentaire a la balise img
\param pictoisfullpath If 1, image path is a full path \param pictoisfullpath If 1, image path is a full path
\return string Retourne tag img \return string Retourne tag img
*/ */
function img_picto($alt, $picto, $options='', $pictoisfullpath=0) function img_picto($alt, $picto, $options='', $pictoisfullpath=0)
{ {
global $conf; global $conf;
@@ -797,7 +811,7 @@ function img_picto($alt, $picto, $options='', $pictoisfullpath=0)
\param alt Texte sur le alt de l'image \param alt Texte sur le alt de l'image
\param numaction Determine image action \param numaction Determine image action
\return string Retourne tag img \return string Retourne tag img
*/ */
function img_action($alt = "default", $numaction) function img_action($alt = "default", $numaction)
{ {
global $conf,$langs; global $conf,$langs;
@@ -816,7 +830,7 @@ function img_action($alt = "default", $numaction)
\brief Affiche logo fichier \brief Affiche logo fichier
\param alt Texte sur le alt de l'image \param alt Texte sur le alt de l'image
\return string Retourne tag img \return string Retourne tag img
*/ */
function img_file($alt = "default") function img_file($alt = "default")
{ {
global $conf,$langs; global $conf,$langs;
@@ -828,7 +842,7 @@ function img_file($alt = "default")
\brief Affiche logo refresh \brief Affiche logo refresh
\param alt Texte sur le alt de l'image \param alt Texte sur le alt de l'image
\return string Retourne tag img \return string Retourne tag img
*/ */
function img_refresh($alt = "default") function img_refresh($alt = "default")
{ {
global $conf,$langs; global $conf,$langs;
@@ -840,7 +854,7 @@ function img_refresh($alt = "default")
\brief Affiche logo dossier \brief Affiche logo dossier
\param alt Texte sur le alt de l'image \param alt Texte sur le alt de l'image
\return string Retourne tag img \return string Retourne tag img
*/ */
function img_folder($alt = "default") function img_folder($alt = "default")
{ {
global $conf,$langs; global $conf,$langs;
@@ -852,7 +866,7 @@ function img_folder($alt = "default")
\brief Affiche logo nouveau fichier \brief Affiche logo nouveau fichier
\param alt Texte sur le alt de l'image \param alt Texte sur le alt de l'image
\return string Retourne tag img \return string Retourne tag img
*/ */
function img_file_new($alt = "default") function img_file_new($alt = "default")
{ {
global $conf,$langs; global $conf,$langs;
@@ -865,7 +879,7 @@ function img_file_new($alt = "default")
\param alt Texte sur le alt de l'image \param alt Texte sur le alt de l'image
\param $size Taille de l'icone : 3 = 16x16px , 2 = 14x14px \param $size Taille de l'icone : 3 = 16x16px , 2 = 14x14px
\return string Retourne tag img \return string Retourne tag img
*/ */
function img_pdf($alt = "default",$size=3) function img_pdf($alt = "default",$size=3)
{ {
global $conf,$langs; global $conf,$langs;
@@ -877,7 +891,7 @@ function img_pdf($alt = "default",$size=3)
\brief Affiche logo vcard \brief Affiche logo vcard
\param alt Texte sur le alt de l'image \param alt Texte sur le alt de l'image
\return string Retourne tag img \return string Retourne tag img
*/ */
function img_vcard($alt = "default") function img_vcard($alt = "default")
{ {
global $conf,$langs; global $conf,$langs;
@@ -889,7 +903,7 @@ function img_vcard($alt = "default")
\brief Affiche logo + \brief Affiche logo +
\param alt Texte sur le alt de l'image \param alt Texte sur le alt de l'image
\return string Retourne tag img \return string Retourne tag img
*/ */
function img_edit_add($alt = "default") function img_edit_add($alt = "default")
{ {
global $conf,$langs; global $conf,$langs;
@@ -900,7 +914,7 @@ function img_edit_add($alt = "default")
\brief Affiche logo - \brief Affiche logo -
\param alt Texte sur le alt de l'image \param alt Texte sur le alt de l'image
\return string Retourne tag img \return string Retourne tag img
*/ */
function img_edit_remove($alt = "default") function img_edit_remove($alt = "default")
{ {
global $conf,$langs; global $conf,$langs;
@@ -913,7 +927,7 @@ function img_edit_remove($alt = "default")
\param alt Texte sur le alt de l'image \param alt Texte sur le alt de l'image
\param float Si il faut y mettre le style "float: right" \param float Si il faut y mettre le style "float: right"
\return string Retourne tag img \return string Retourne tag img
*/ */
function img_edit($alt = "default", $float=0, $other='') function img_edit($alt = "default", $float=0, $other='')
{ {
global $conf,$langs; global $conf,$langs;
@@ -929,7 +943,7 @@ function img_edit($alt = "default", $float=0, $other='')
\brief Affiche logo effacer \brief Affiche logo effacer
\param alt Texte sur le alt de l'image \param alt Texte sur le alt de l'image
\return string Retourne tag img \return string Retourne tag img
*/ */
function img_delete($alt = "default") function img_delete($alt = "default")
{ {
global $conf,$langs; global $conf,$langs;
@@ -941,7 +955,7 @@ function img_delete($alt = "default")
\brief Affiche logo d<>sactiver \brief Affiche logo d<>sactiver
\param alt Texte sur le alt de l'image \param alt Texte sur le alt de l'image
\return string Retourne tag img \return string Retourne tag img
*/ */
function img_disable($alt = "default") function img_disable($alt = "default")
{ {
global $conf,$langs; global $conf,$langs;
@@ -953,7 +967,7 @@ function img_disable($alt = "default")
/** /**
\brief Affiche logo help avec curseur "?" \brief Affiche logo help avec curseur "?"
\return string Retourne tag img \return string Retourne tag img
*/ */
function img_help($usehelpcursor=1,$usealttitle=1) function img_help($usehelpcursor=1,$usealttitle=1)
{ {
global $conf,$langs; global $conf,$langs;
@@ -968,7 +982,7 @@ function img_help($usehelpcursor=1,$usealttitle=1)
/** /**
\brief Affiche picto calendrier "?" \brief Affiche picto calendrier "?"
\return string Retourne tag img \return string Retourne tag img
*/ */
function img_cal() function img_cal()
{ {
global $conf,$langs; global $conf,$langs;
@@ -979,7 +993,7 @@ function img_cal()
\brief Affiche logo info \brief Affiche logo info
\param alt Texte sur le alt de l'image \param alt Texte sur le alt de l'image
\return string Retourne tag img \return string Retourne tag img
*/ */
function img_info($alt = "default") function img_info($alt = "default")
{ {
global $conf,$langs; global $conf,$langs;
@@ -991,7 +1005,7 @@ function img_info($alt = "default")
\brief Affiche logo calculatrice \brief Affiche logo calculatrice
\param alt Texte sur le alt de l'image \param alt Texte sur le alt de l'image
\return string Retourne tag img \return string Retourne tag img
*/ */
function img_calc($alt = "default") function img_calc($alt = "default")
{ {
global $conf,$langs; global $conf,$langs;
@@ -1004,7 +1018,7 @@ function img_calc($alt = "default")
\param alt Texte sur le alt de l'image \param alt Texte sur le alt de l'image
\param float Si il faut afficher le style "float: right" \param float Si il faut afficher le style "float: right"
\return string Retourne tag img \return string Retourne tag img
*/ */
function img_warning($alt = "default",$float=0) function img_warning($alt = "default",$float=0)
{ {
global $conf,$langs; global $conf,$langs;
@@ -1020,7 +1034,7 @@ function img_warning($alt = "default",$float=0)
\brief Affiche logo warning \brief Affiche logo warning
\param alt Texte sur le alt de l'image \param alt Texte sur le alt de l'image
\return string Retourne tag img \return string Retourne tag img
*/ */
function img_error($alt = "default") function img_error($alt = "default")
{ {
global $conf,$langs; global $conf,$langs;
@@ -1032,7 +1046,7 @@ function img_error($alt = "default")
\brief Affiche logo alerte \brief Affiche logo alerte
\param alt Texte sur le alt de l'image \param alt Texte sur le alt de l'image
\return string Retourne tag img \return string Retourne tag img
*/ */
function img_alerte($alt = "default") function img_alerte($alt = "default")
{ {
global $conf,$langs; global $conf,$langs;
@@ -1045,7 +1059,7 @@ function img_alerte($alt = "default")
\param alt Texte sur le alt de l'image \param alt Texte sur le alt de l'image
\param option Choose of logo \param option Choose of logo
\return string Retourne tag img \return string Retourne tag img
*/ */
function img_phone($alt = "default",$option=0) function img_phone($alt = "default",$option=0)
{ {
global $conf,$langs; global $conf,$langs;
@@ -1061,7 +1075,7 @@ function img_phone($alt = "default",$option=0)
\brief Affiche logo suivant \brief Affiche logo suivant
\param alt Texte sur le alt de l'image \param alt Texte sur le alt de l'image
\return string Retourne tag img \return string Retourne tag img
*/ */
function img_next($alt = "default") function img_next($alt = "default")
{ {
global $conf,$langs; global $conf,$langs;
@@ -1075,7 +1089,7 @@ function img_next($alt = "default")
\brief Affiche logo pr<70>c<EFBFBD>dent \brief Affiche logo pr<70>c<EFBFBD>dent
\param alt Texte sur le alt de l'image \param alt Texte sur le alt de l'image
\return string Retourne tag img \return string Retourne tag img
*/ */
function img_previous($alt = "default") function img_previous($alt = "default")
{ {
global $conf,$langs; global $conf,$langs;
@@ -1088,7 +1102,7 @@ function img_previous($alt = "default")
\param alt Texte sur le alt de l'image \param alt Texte sur le alt de l'image
\param selected Affiche version "selected" du logo \param selected Affiche version "selected" du logo
\return string Retourne tag img \return string Retourne tag img
*/ */
function img_down($alt = "default", $selected=0) function img_down($alt = "default", $selected=0)
{ {
global $conf,$langs; global $conf,$langs;
@@ -1102,7 +1116,7 @@ function img_down($alt = "default", $selected=0)
\param alt Texte sur le alt de l'image \param alt Texte sur le alt de l'image
\param selected Affiche version "selected" du logo \param selected Affiche version "selected" du logo
\return string Retourne tag img \return string Retourne tag img
*/ */
function img_up($alt = "default", $selected=0) function img_up($alt = "default", $selected=0)
{ {
global $conf,$langs; global $conf,$langs;
@@ -1116,7 +1130,7 @@ function img_up($alt = "default", $selected=0)
\param alt Texte sur le alt de l'image \param alt Texte sur le alt de l'image
\param selected Affiche version "selected" du logo \param selected Affiche version "selected" du logo
\return string Retourne tag img \return string Retourne tag img
*/ */
function img_left($alt = "default", $selected=0) function img_left($alt = "default", $selected=0)
{ {
global $conf,$langs; global $conf,$langs;
@@ -1130,7 +1144,7 @@ function img_left($alt = "default", $selected=0)
\param alt Texte sur le alt de l'image \param alt Texte sur le alt de l'image
\param selected Affiche version "selected" du logo \param selected Affiche version "selected" du logo
\return string Retourne tag img \return string Retourne tag img
*/ */
function img_right($alt = "default", $selected=0) function img_right($alt = "default", $selected=0)
{ {
global $conf,$langs; global $conf,$langs;
@@ -1143,7 +1157,7 @@ function img_right($alt = "default", $selected=0)
\brief Affiche logo tick \brief Affiche logo tick
\param alt Texte sur le alt de l'image \param alt Texte sur le alt de l'image
\return string Retourne tag img \return string Retourne tag img
*/ */
function img_tick($alt = "default") function img_tick($alt = "default")
{ {
global $conf,$langs; global $conf,$langs;
@@ -1155,7 +1169,7 @@ function img_tick($alt = "default")
\brief Affiche le logo tick si allow \brief Affiche le logo tick si allow
\param allow Authorise ou non \param allow Authorise ou non
\return string Retourne tag img \return string Retourne tag img
*/ */
function img_allow($allow) function img_allow($allow)
{ {
global $conf,$langs; global $conf,$langs;
@@ -1176,7 +1190,7 @@ function img_allow($allow)
\brief Return if a filename is file name of a supported image format \brief Return if a filename is file name of a supported image format
\param file Filename \param file Filename
\return int -1=Not image filename, 0=Image filename but format not supported by PHP, 1=Image filename with format supported \return int -1=Not image filename, 0=Image filename but format not supported by PHP, 1=Image filename with format supported
*/ */
function image_format_supported($file) function image_format_supported($file)
{ {
// Case filename is not a format image // Case filename is not a format image
@@ -1207,7 +1221,7 @@ function image_format_supported($file)
\param text Text info \param text Text info
\param infoonimgalt Info is shown on alt of star picto \param infoonimgalt Info is shown on alt of star picto
\return string String with info text \return string String with info text
*/ */
function info_admin($texte,$infoonimgalt=0) function info_admin($texte,$infoonimgalt=0)
{ {
global $conf,$langs; global $conf,$langs;
@@ -1234,7 +1248,7 @@ function info_admin($texte,$infoonimgalt=0)
\param feature Feature to check (in most cases, it's module name) \param feature Feature to check (in most cases, it's module name)
\param objectid Object ID if we want to check permission on on object (optionnal) \param objectid Object ID if we want to check permission on on object (optionnal)
\param dbtable Table name where object is stored. Not used if objectid is null (optionnel) \param dbtable Table name where object is stored. Not used if objectid is null (optionnel)
*/ */
function restrictedArea($user, $feature='societe', $objectid=0, $dbtablename='') function restrictedArea($user, $feature='societe', $objectid=0, $dbtablename='')
{ {
global $db; global $db;
@@ -1367,7 +1381,7 @@ function restrictedArea($user, $feature='societe', $objectid=0, $dbtablename='')
\param message Force error message \param message Force error message
\param printheader Affiche avant le header \param printheader Affiche avant le header
\remarks L'appel a cette fonction termine le code. \remarks L'appel a cette fonction termine le code.
*/ */
function accessforbidden($message='',$printheader=1) function accessforbidden($message='',$printheader=1)
{ {
global $user, $langs; global $user, $langs;
@@ -1405,7 +1419,7 @@ function accessforbidden($message='',$printheader=1)
renvoyer leur erreur par l'interm<72>diaire de leur propri<72>t<EFBFBD> "error". renvoyer leur erreur par l'interm<72>diaire de leur propri<72>t<EFBFBD> "error".
\param db Handler de base utilis<69> \param db Handler de base utilis<69>
\param error Chaine erreur ou tableau de chaines erreur compl<70>mentaires a afficher \param error Chaine erreur ou tableau de chaines erreur compl<70>mentaires a afficher
*/ */
function dolibarr_print_error($db='',$error='') function dolibarr_print_error($db='',$error='')
{ {
global $conf,$langs,$argv; global $conf,$langs,$argv;
@@ -1491,7 +1505,7 @@ function dolibarr_print_error($db='',$error='')
\param src_file fichier source \param src_file fichier source
\param dest_file fichier de destination \param dest_file fichier de destination
\return int true=Deplacement OK, false=Pas de deplacement ou KO \return int true=Deplacement OK, false=Pas de deplacement ou KO
*/ */
function dol_move_uploaded_file($src_file, $dest_file) function dol_move_uploaded_file($src_file, $dest_file)
{ {
global $conf; global $conf;
@@ -1547,7 +1561,7 @@ function dol_move_uploaded_file($src_file, $dest_file)
\param td options de l'attribut td ("" par defaut) \param td options de l'attribut td ("" par defaut)
\param sortfield nom du champ sur lequel est effectu<74> le tri du tableau \param sortfield nom du champ sur lequel est effectu<74> le tri du tableau
\param sortorder ordre du tri \param sortorder ordre du tri
*/ */
function print_liste_field_titre($name, $file, $field, $begin="", $options="", $td="", $sortfield="", $sortorder="") function print_liste_field_titre($name, $file, $field, $begin="", $options="", $td="", $sortfield="", $sortorder="")
{ {
global $conf; global $conf;
@@ -1601,7 +1615,7 @@ function print_liste_field_titre($name, $file, $field, $begin="", $options="", $
/** /**
\brief Affichage d'un titre \brief Affichage d'un titre
\param titre Le titre a afficher \param titre Le titre a afficher
*/ */
function print_titre($titre) function print_titre($titre)
{ {
print '<div class="titre">'.$titre.'</div>'; print '<div class="titre">'.$titre.'</div>';
@@ -1613,7 +1627,7 @@ function print_titre($titre)
\param mesg Message supl<70>mentaire a afficher a droite \param mesg Message supl<70>mentaire a afficher a droite
\param picto Picto pour ligne de titre \param picto Picto pour ligne de titre
\param pictoisfullpath 1=Picto is a full absolute url of image \param pictoisfullpath 1=Picto is a full absolute url of image
*/ */
function print_fiche_titre($titre, $mesg='', $picto='', $pictoisfullpath=0) function print_fiche_titre($titre, $mesg='', $picto='', $pictoisfullpath=0)
{ {
print "\n"; print "\n";
@@ -1633,7 +1647,7 @@ function print_fiche_titre($titre, $mesg='', $picto='', $pictoisfullpath=0)
\brief Effacement d'un fichier \brief Effacement d'un fichier
\param file Fichier a effacer ou masque de fichier a effacer \param file Fichier a effacer ou masque de fichier a effacer
\param boolean true if file deleted, false if error \param boolean true if file deleted, false if error
*/ */
function dol_delete_file($file) function dol_delete_file($file)
{ {
$ok=true; $ok=true;
@@ -1649,7 +1663,7 @@ function dol_delete_file($file)
/** /**
\brief Effacement d'un r<>pertoire \brief Effacement d'un r<>pertoire
\param file R<>pertoire a effacer \param file R<>pertoire a effacer
*/ */
function dol_delete_dir($dir) function dol_delete_dir($dir)
{ {
return rmdir($dir); return rmdir($dir);
@@ -1660,7 +1674,7 @@ function dol_delete_dir($dir)
\param file R<>pertoire a effacer \param file R<>pertoire a effacer
\param count Compteur pour comptage nb elements supprim<69>s \param count Compteur pour comptage nb elements supprim<69>s
\return int Nombre de fichier+rep<65>rtoires supprim<69>s \return int Nombre de fichier+rep<65>rtoires supprim<69>s
*/ */
function dol_delete_dir_recursive($dir,$count=0) function dol_delete_dir_recursive($dir,$count=0)
{ {
if ($handle = opendir("$dir")) if ($handle = opendir("$dir"))
@@ -1695,7 +1709,7 @@ function dol_delete_dir_recursive($dir,$count=0)
\brief Scan les fichiers avec un anti-virus \brief Scan les fichiers avec un anti-virus
\param file Fichier a scanner \param file Fichier a scanner
\return malware Nom du virus si infect<63> sinon retourne "null" \return malware Nom du virus si infect<63> sinon retourne "null"
*/ */
function dol_avscan_file($file) function dol_avscan_file($file)
{ {
$malware = ''; $malware = '';
@@ -1727,7 +1741,7 @@ function dol_avscan_file($file)
\param center chaine du centre ('' par defaut) \param center chaine du centre ('' par defaut)
\param num number of records found by select with limit+1 \param num number of records found by select with limit+1
\param totalnboflines Total number of records/lines for all pages (if known) \param totalnboflines Total number of records/lines for all pages (if known)
*/ */
function print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $center='', $num=-1, $totalnboflines=0) function print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $center='', $num=-1, $totalnboflines=0)
{ {
global $conf,$langs; global $conf,$langs;
@@ -1819,7 +1833,7 @@ function print_barre_liste($titre, $page, $file, $options='', $sortfield='', $so
\param options Autres parametres d'url a propager dans les liens ("" par defaut) \param options Autres parametres d'url a propager dans les liens ("" par defaut)
\param nextpage Faut-il une page suivante \param nextpage Faut-il une page suivante
\param betweenarraows HTML Content to show between arrows \param betweenarraows HTML Content to show between arrows
*/ */
function print_fleche_navigation($page,$file,$options='',$nextpage,$betweenarrows='') function print_fleche_navigation($page,$file,$options='',$nextpage,$betweenarrows='')
{ {
global $conf, $langs; global $conf, $langs;
@@ -1836,13 +1850,13 @@ function print_fleche_navigation($page,$file,$options='',$nextpage,$betweenarrow
/** /**
* \brief Fonction qui retourne un taux de tva format<61> pour visualisation * \brief Fonction qui retourne un taux de tva format<61> pour visualisation
* \remarks Fonction utilis<69>e dans les pdf et les pages html * \remarks Fonction utilis<69>e dans les pdf et les pages html
* \param rate Rate value to format (19.6 19,6 19.6% 19,6%,...) * \param rate Rate value to format (19.6 19,6 19.6% 19,6%,...)
* \param foundpercent Add a percent % sign in output * \param foundpercent Add a percent % sign in output
* \param info_bits Miscellanous information on vat * \param info_bits Miscellanous information on vat
* \return string Chaine avec montant format<61> (19,6 ou 19,6% ou 8.5% *) * \return string Chaine avec montant format<61> (19,6 ou 19,6% ou 8.5% *)
*/ */
function vatrate($rate,$foundpercent=false,$info_bits=0) function vatrate($rate,$foundpercent=false,$info_bits=0)
{ {
// Test for compatibility // Test for compatibility
@@ -1864,16 +1878,16 @@ function vatrate($rate,$foundpercent=false,$info_bits=0)
/** /**
* \brief Fonction qui retourne un montant mon<6F>taire format<61> pour visualisation * \brief Fonction qui retourne un montant mon<6F>taire format<61> pour visualisation
* \remarks Fonction utilis<69>e dans les pdf et les pages html * \remarks Fonction utilis<69>e dans les pdf et les pages html
* \param amount Montant a formater * \param amount Montant a formater
* \param html Formatage html ou pas (0 par defaut) * \param html Formatage html ou pas (0 par defaut)
* \param outlangs Objet langs pour formatage text * \param outlangs Objet langs pour formatage text
* \param trunc 1=Tronque affichage si trop de d<>cimales,0=Force le non troncage * \param trunc 1=Tronque affichage si trop de d<>cimales,0=Force le non troncage
* \param nbdecimal Nbre decimals minimum. * \param nbdecimal Nbre decimals minimum.
* \return string Chaine avec montant format<61> * \return string Chaine avec montant format<61>
* \seealso price2num Fonction inverse de price * \seealso price2num Fonction inverse de price
*/ */
function price($amount, $html=0, $outlangs='', $trunc=1, $nbdecimal=2) function price($amount, $html=0, $outlangs='', $trunc=1, $nbdecimal=2)
{ {
global $langs,$conf; global $langs,$conf;
@@ -1935,7 +1949,7 @@ function price($amount, $html=0, $outlangs='', $trunc=1, $nbdecimal=2)
''=No rounding ''=No rounding
\return string Montant au format num<75>rique PHP et SQL (Exemple: '99.99999') \return string Montant au format num<75>rique PHP et SQL (Exemple: '99.99999')
\seealso price Fonction inverse de price2num \seealso price Fonction inverse de price2num
*/ */
function price2num($amount,$rounding='') function price2num($amount,$rounding='')
{ {
global $conf; global $conf;
@@ -1958,8 +1972,8 @@ function price2num($amount,$rounding='')
/** /**
* \brief Return vat rate of a product in a particular selling country * \brief Return vat rate of a product in a particular selling country
*/ */
function get_product_vat_for_country($idprod, $countrycode) function get_product_vat_for_country($idprod, $countrycode)
{ {
global $db; global $db;
@@ -2057,7 +2071,7 @@ function get_default_npr($societe_vendeuse, $societe_acheteuse, $taux_produit)
\param yesno Variable pour test si oui ou non \param yesno Variable pour test si oui ou non
\param case 1=Yes/No, 0=yes/no \param case 1=Yes/No, 0=yes/no
\param color 0=texte only, 1=Text is format with a color font style \param color 0=texte only, 1=Text is format with a color font style
*/ */
function yn($yesno, $case=1, $color=0) function yn($yesno, $case=1, $color=0)
{ {
global $langs; global $langs;
@@ -2082,7 +2096,7 @@ function yn($yesno, $case=1, $color=0)
\param db handler d'acc<63>s base \param db handler d'acc<63>s base
\param code Code r<>gion \param code Code r<>gion
\param pays_id Id du pays \param pays_id Id du pays
*/ */
function departement_rowid($db,$code, $pays_id) function departement_rowid($db,$code, $pays_id)
{ {
$sql = "SELECT c.rowid FROM ".MAIN_DB_PREFIX."c_departements as c,".MAIN_DB_PREFIX."c_regions as r"; $sql = "SELECT c.rowid FROM ".MAIN_DB_PREFIX."c_departements as c,".MAIN_DB_PREFIX."c_regions as r";
@@ -2130,7 +2144,7 @@ function get_exdir($num,$level=3)
\brief Cr<43>ation de r<>pertoire recursive \brief Cr<43>ation de r<>pertoire recursive
\param $dir R<>pertoire a cr<63>er \param $dir R<>pertoire a cr<63>er
\return int < 0 si erreur, >= 0 si succ<63>s \return int < 0 si erreur, >= 0 si succ<63>s
*/ */
function create_exdir($dir) function create_exdir($dir)
{ {
dolibarr_syslog("functions.lib.php::create_exdir: dir=$dir",LOG_INFO); dolibarr_syslog("functions.lib.php::create_exdir: dir=$dir",LOG_INFO);
@@ -2180,103 +2194,13 @@ function create_exdir($dir)
} }
/**
\brief Scan a directory and return a list of files/directories
\param $path Starting path from which to search
\param $types Can be "directories", "files", or "all"
\param $recursive Determines whether subdirectories are searched
\param $filter Regex for filter
\param $exludefilter Regex for exclude filter
\param $sortcriteria Sort criteria ("name","date","size")
\param $sortorder Sort order (SORT_ASC, SORT_DESC)
\return array Array of array('name'=>xxx,'date'=>yyy,'size'=>zzz)
*/
function dolibarr_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter="", $sortcriteria="name", $sortorder=SORT_ASC)
{
dolibarr_syslog("functions.lib.php::dolibarr_dir_list $path");
$loaddate=false;
$loadsize=false;
if (! is_dir($path)) return array();
if ($dir = opendir($path))
{
$file_list = array();
while (false !== ($file = readdir($dir)))
{
$qualified=1;
// Check if file is qualified
if (eregi('^\.',$file)) $qualified=0;
if ($excludefilter && eregi($excludefilter,$file)) $qualified=0;
if ($qualified)
{
// Check whether this is a file or directory and whether we're interested in that type
if ((is_dir($path."/".$file)) && (($types=="directories") || ($types=="all")))
{
// Add entry into file_list array
if ($loaddate || $sortcriteria == 'date') $filedate=filemtime($path."/".$file);
if ($loadsize || $sortcriteria == 'size') $filesize=filesize($path."/".$file);
if (! $filter || eregi($filter,$path.'/'.$file))
{
$file_list[] = array(
"name" => $file,
"fullname" => $path.'/'.$file,
"date" => $filedate,
"size" => $filesize
);
}
// if we're in a directory and we want recursive behavior, call this function again
if ($recursive)
{
$file_list = array_merge($file_list, dolibarr_dir_list($path."/".$file."/", $types, $recursive, $filter, $excludefilter, $sortcriteria, $sortorder));
}
}
else if (($types == "files") || ($types == "all"))
{
// Add file into file_list array
if ($loaddate || $sortcriteria == 'date') $filedate=filemtime($path."/".$file);
if ($loadsize || $sortcriteria == 'size') $filesize=filesize($path."/".$file);
if (! $filter || eregi($filter,$path.'/'.$file))
{
$file_list[] = array(
"name" => $file,
"fullname" => $path.'/'.$file,
"date" => $filedate,
"size" => $filesize
);
}
}
}
}
closedir($dir);
// Obtain a list of columns
$myarray=array();
foreach ($file_list as $key => $row)
{
$myarray[$key] = $row[$sortcriteria];
}
// Sort the data
array_multisort($myarray, $sortorder, $file_list);
return $file_list;
}
else
{
return false;
}
}
/** /**
\brief Retourne le num<75>ro de la semaine par rapport a une date \brief Retourne le num<75>ro de la semaine par rapport a une date
\param time Date au format 'timestamp' \param time Date au format 'timestamp'
\return int Num<75>ro de semaine \return int Num<75>ro de semaine
*/ */
function numero_semaine($time) function numero_semaine($time)
{ {
$stime = strftime( '%Y-%m-%d',$time); $stime = strftime( '%Y-%m-%d',$time);
@@ -2351,10 +2275,12 @@ function numero_semaine($time)
return sprintf("%02d",$numeroSemaine); return sprintf("%02d",$numeroSemaine);
} }
/** /**
\brief Retourne le picto champ obligatoire \brief Retourne le picto champ obligatoire
\return string Chaine avec picto obligatoire \return string Chaine avec picto obligatoire
*/ */
function picto_required() function picto_required()
{ {
return '<b>*</b>'; return '<b>*</b>';
@@ -2365,7 +2291,7 @@ function picto_required()
\param from_unit int Unite originale en puissance de 10 \param from_unit int Unite originale en puissance de 10
\param to_unit int Nouvelle unite en puissance de 10 \param to_unit int Nouvelle unite en puissance de 10
\return float Masse convertie \return float Masse convertie
*/ */
function weight_convert($weight,&$from_unit,$to_unit) function weight_convert($weight,&$from_unit,$to_unit)
{ {
/* Pour convertire 320 gr en Kg appeler /* Pour convertire 320 gr en Kg appeler
@@ -2398,7 +2324,7 @@ function weight_convert($weight,&$from_unit,$to_unit)
\param measuring_style Le style de mesure : weight, volume,... \param measuring_style Le style de mesure : weight, volume,...
\return string Unite \return string Unite
\todo gerer les autres unit<69>s de mesure comme la livre, le gallon, le litre, ... \todo gerer les autres unit<69>s de mesure comme la livre, le gallon, le litre, ...
*/ */
function measuring_units_string($unit,$measuring_style='') function measuring_units_string($unit,$measuring_style='')
{ {
/* Note Rodo aux dev :) /* Note Rodo aux dev :)
@@ -2432,7 +2358,7 @@ function measuring_units_string($unit,$measuring_style='')
\param url Url \param url Url
\param http 1: keep http, 0: remove also http \param http 1: keep http, 0: remove also http
\return string CleanUrl \return string CleanUrl
*/ */
function clean_url($url,$http=1) function clean_url($url,$http=1)
{ {
if (eregi('^(https?:[\\\/]+)?([0-9A-Z\-\.]+\.[A-Z]{2,4})(:[0-9]+)?',$url,$regs)) if (eregi('^(https?:[\\\/]+)?([0-9A-Z\-\.]+\.[A-Z]{2,4})(:[0-9]+)?',$url,$regs))
@@ -2460,12 +2386,14 @@ function clean_url($url,$http=1)
} }
} }
/** /**
\brief Clean a string from all html tags \brief Clean a string from all html tags
\param StringHtml String to clean \param StringHtml String to clean
\param removelinefeed Replace also all lines feeds by a space \param removelinefeed Replace also all lines feeds by a space
\return string String cleaned \return string String cleaned
*/ */
function clean_html($StringHtml,$removelinefeed=1) function clean_html($StringHtml,$removelinefeed=1)
{ {
$pattern = "<[^>]+>"; $pattern = "<[^>]+>";
@@ -2490,7 +2418,7 @@ function clean_html($StringHtml,$removelinefeed=1)
\param pad Add 0 \param pad Add 0
\param upper Convert to tupper \param upper Convert to tupper
\return string x \return string x
*/ */
function binhex($bin, $pad=false, $upper=false){ function binhex($bin, $pad=false, $upper=false){
$last = strlen($bin)-1; $last = strlen($bin)-1;
for($i=0; $i<=$last; $i++){ $x += $bin[$last-$i] * pow(2,$i); } for($i=0; $i<=$last; $i++){ $x += $bin[$last-$i] * pow(2,$i); }
@@ -2504,7 +2432,7 @@ function binhex($bin, $pad=false, $upper=false){
\brief Convertir de l'h<>xad<61>cimal en binaire \brief Convertir de l'h<>xad<61>cimal en binaire
\param string hexa \param string hexa
\return string bin \return string bin
*/ */
function hexbin($hexa){ function hexbin($hexa){
$bin=''; $bin='';
for($i=0;$i<strlen($hexa);$i++) for($i=0;$i<strlen($hexa);$i++)
@@ -2516,11 +2444,11 @@ function hexbin($hexa){
/** /**
* \brief Replace CRLF in string with a HTML BR tag. * \brief Replace CRLF in string with a HTML BR tag.
* \param string2encode String to encode * \param string2encode String to encode
* \param nl2brmode 0=Adding br before \n, 1=Replacing \n by br * \param nl2brmode 0=Adding br before \n, 1=Replacing \n by br
* \return string String encoded * \return string String encoded
*/ */
function dol_nl2br($stringtoencode,$nl2brmode=0) function dol_nl2br($stringtoencode,$nl2brmode=0)
{ {
if (! $nl2brmode) return nl2br($stringtoencode); if (! $nl2brmode) return nl2br($stringtoencode);
@@ -2533,15 +2461,15 @@ function dol_nl2br($stringtoencode,$nl2brmode=0)
} }
/** /**
* \brief This function is called to encode a string into a HTML string * \brief This function is called to encode a string into a HTML string
* \param stringtoencode String to encode * \param stringtoencode String to encode
* \param nl2brmode 0=Adding br before \n, 1=Replacing \n by br (for use with FPDF writeHTMLCell function for example) * \param nl2brmode 0=Adding br before \n, 1=Replacing \n by br (for use with FPDF writeHTMLCell function for example)
* \remarks For PDF usage, you can show text by 2 ways: * \remarks For PDF usage, you can show text by 2 ways:
* - writeHTMLCell -> param must be encoded into HTML. * - writeHTMLCell -> param must be encoded into HTML.
* - MultiCell -> param must not be encoded into HTML. * - MultiCell -> param must not be encoded into HTML.
* Because writeHTMLCell convert also \n into <br>, if function * Because writeHTMLCell convert also \n into <br>, if function
* is used to build PDF, nl2brmode must be 1. * is used to build PDF, nl2brmode must be 1.
*/ */
function dol_htmlentitiesbr($stringtoencode,$nl2brmode=0) function dol_htmlentitiesbr($stringtoencode,$nl2brmode=0)
{ {
if (dol_textishtml($stringtoencode)) return $stringtoencode; if (dol_textishtml($stringtoencode)) return $stringtoencode;
@@ -2554,9 +2482,9 @@ function dol_htmlentitiesbr($stringtoencode,$nl2brmode=0)
} }
/* /*
* \brief This function is called to decode a HTML string * \brief This function is called to decode a HTML string
* \param stringtodecode String to decode * \param stringtodecode String to decode
*/ */
function dol_htmlentitiesbr_decode($stringtodecode) function dol_htmlentitiesbr_decode($stringtodecode)
{ {
$ret=html_entity_decode($stringtodecode); $ret=html_entity_decode($stringtodecode);
@@ -2571,7 +2499,7 @@ function dol_htmlentitiesbr_decode($stringtodecode)
\brief Decode le code html \brief Decode le code html
\param string StringHtml \param string StringHtml
\return string DecodeString \return string DecodeString
*/ */
function dol_entity_decode($StringHtml) function dol_entity_decode($StringHtml)
{ {
$DecodeString = html_entity_decode($StringHtml); $DecodeString = html_entity_decode($StringHtml);
@@ -2584,7 +2512,7 @@ function dol_entity_decode($StringHtml)
\remarks Example, if string contains euro symbol that has ascii code 128. \remarks Example, if string contains euro symbol that has ascii code 128.
\param s String to check \param s String to check
\return int 0 if bad iso, 1 if good iso \return int 0 if bad iso, 1 if good iso
*/ */
function dol_string_is_good_iso($s) function dol_string_is_good_iso($s)
{ {
$len=strlen($s); $len=strlen($s);
@@ -2599,39 +2527,6 @@ function dol_string_is_good_iso($s)
return $ok; return $ok;
} }
/**
\brief Encode une chaine de caract<63>re
\param chain chaine de caract<63>res a encoder
\return string_coded chaine de caract<63>res encod<6F>e
*/
function dolibarr_encode($chain)
{
for($i=0;$i<strlen($chain);$i++)
{
$output_tab[$i] = chr(ord(substr($chain,$i,1))+17);
}
$string_coded = base64_encode(implode ("",$output_tab));
return $string_coded;
}
/**
\brief Decode une chaine de caract<63>re
\param chain chaine de caract<63>res a decoder
\return string_coded chaine de caract<63>res decod<6F>e
*/
function dolibarr_decode($chain)
{
$chain = base64_decode($chain);
for($i=0;$i<strlen($chain);$i++)
{
$output_tab[$i] = chr(ord(substr($chain,$i,1))-17);
}
$string_decoded = implode ("",$output_tab);
return $string_decoded;
}
/** /**
\brief Fonction retournant le nombre de jour fieries samedis et dimanches entre 2 dates entrees en timestamp \brief Fonction retournant le nombre de jour fieries samedis et dimanches entre 2 dates entrees en timestamp
@@ -2639,7 +2534,7 @@ function dolibarr_decode($chain)
\param timestampStart Timestamp de debut \param timestampStart Timestamp de debut
\param timestampEnd Timestamp de fin \param timestampEnd Timestamp de fin
\return nbFerie Nombre de jours feries \return nbFerie Nombre de jours feries
*/ */
function num_public_holiday($timestampStart, $timestampEnd, $countrycode='FR') function num_public_holiday($timestampStart, $timestampEnd, $countrycode='FR')
{ {
$nbFerie = 0; $nbFerie = 0;
@@ -2737,7 +2632,7 @@ function num_public_holiday($timestampStart, $timestampEnd, $countrycode='FR')
\param timestampEnd Timestamp de fin \param timestampEnd Timestamp de fin
\param lastday On prend en compte le dernier jour, 0: non, 1:oui \param lastday On prend en compte le dernier jour, 0: non, 1:oui
\return nbjours Nombre de jours \return nbjours Nombre de jours
*/ */
function num_between_day($timestampStart, $timestampEnd, $lastday=0) function num_between_day($timestampStart, $timestampEnd, $lastday=0)
{ {
if ($timestampStart < $timestampEnd) if ($timestampStart < $timestampEnd)
@@ -2762,7 +2657,7 @@ function num_between_day($timestampStart, $timestampEnd, $lastday=0)
\param inhour 0: sort le nombre de jour , 1: sort le nombre d'heure (72 max) \param inhour 0: sort le nombre de jour , 1: sort le nombre d'heure (72 max)
\param lastday On prend en compte le dernier jour, 0: non, 1:oui \param lastday On prend en compte le dernier jour, 0: non, 1:oui
\return nbjours Nombre de jours ou d'heures \return nbjours Nombre de jours ou d'heures
*/ */
function num_open_day($timestampStart, $timestampEnd,$inhour=0,$lastday=0) function num_open_day($timestampStart, $timestampEnd,$inhour=0,$lastday=0)
{ {
global $langs; global $langs;
@@ -2786,7 +2681,7 @@ function num_open_day($timestampStart, $timestampEnd,$inhour=0,$lastday=0)
\brief Fonction retournant le nombre de lignes dans un texte format<61> \brief Fonction retournant le nombre de lignes dans un texte format<61>
\param texte Texte \param texte Texte
\return nblines Nombre de lignes \return nblines Nombre de lignes
*/ */
function num_lines($texte) function num_lines($texte)
{ {
$repTable = array("\t" => " ", "\n" => "<br>", "\r" => " ", "\0" => " ", "\x0B" => " "); $repTable = array("\t" => " ", "\n" => "<br>", "\r" => " ", "\0" => " ", "\x0B" => " ");
@@ -2798,9 +2693,9 @@ function num_lines($texte)
} }
/** /**
* \brief Fonction simple identique a microtime de PHP 5 mais compatible PHP 4 * \brief Fonction simple identique a microtime de PHP 5 mais compatible PHP 4
* \return float Time en millisecondes avec decimal pour microsecondes * \return float Time en millisecondes avec decimal pour microsecondes
*/ */
function dol_microtime_float() function dol_microtime_float()
{ {
list($usec, $sec) = explode(" ", microtime()); list($usec, $sec) = explode(" ", microtime());
@@ -2900,7 +2795,7 @@ function make_alpha_from_numbers($number)
\brief Retourne un tableau des mois ou le mois s<>lectionn<6E> \brief Retourne un tableau des mois ou le mois s<>lectionn<6E>
\param selected Mois <20> s<>lectionner ou -1 \param selected Mois <20> s<>lectionner ou -1
\return string or array Month string or array if selected < 0 \return string or array Month string or array if selected < 0
*/ */
function monthArrayOrSelected($selected=0) function monthArrayOrSelected($selected=0)
{ {
global $langs; global $langs;
@@ -2942,7 +2837,7 @@ function monthArrayOrSelected($selected=0)
\brief Returns formated reduction \brief Returns formated reduction
\param reduction Reduction percentage \param reduction Reduction percentage
\return string Formated reduction \return string Formated reduction
*/ */
function dolibarr_print_reduction($reduction=0) function dolibarr_print_reduction($reduction=0)
{ {
global $langs; global $langs;
@@ -2967,7 +2862,7 @@ function dolibarr_print_reduction($reduction=0)
\brief Returns formated reduction \brief Returns formated reduction
\param reduction Reduction percentage \param reduction Reduction percentage
\return int Return number of error messages shown \return int Return number of error messages shown
*/ */
function dol_htmloutput_errors($mesgstring='',$mesgarray='') function dol_htmloutput_errors($mesgstring='',$mesgarray='')
{ {
global $langs; global $langs;
@@ -3009,11 +2904,11 @@ function stopwithmem()
/** /**
* \brief Advanced sort array by second index function, which produces * \brief Advanced sort array by second index function, which produces
* ascending (default) or descending output and uses optionally * ascending (default) or descending output and uses optionally
* natural case insensitive sorting (which can be optionally case * natural case insensitive sorting (which can be optionally case
* sensitive as well). * sensitive as well).
*/ */
function dol_sort_array($array, $index, $order='asc', $natsort, $case_sensitive) function dol_sort_array($array, $index, $order='asc', $natsort, $case_sensitive)
{ {
// Clean parameters // Clean parameters

View File

@@ -53,8 +53,8 @@ function makesalt($type=CRYPT_SALT_LENGTH)
} }
/** /**
\brief Encode\decode le mot de passe de la base de donn<6E>es dans le fichier de conf \brief Encode\decode database password in config file
\param level niveau d'encodage : 0 non encod<EFBFBD>, 1 encod<EFBFBD> \param level Encode level : 0 no enconding, 1 encoding
*/ */
function encodedecode_dbpassconf($level=0) function encodedecode_dbpassconf($level=0)
{ {
@@ -70,14 +70,14 @@ function encodedecode_dbpassconf($level=0)
{ {
$passwd = strstr($buffer,"$dolibarr_main_db_encrypted_pass="); $passwd = strstr($buffer,"$dolibarr_main_db_encrypted_pass=");
$passwd = substr(substr($passwd,2),0,-3); $passwd = substr(substr($passwd,2),0,-3);
$passwd = dolibarr_decode($passwd); $passwd = dol_decode($passwd);
$config .= "\$dolibarr_main_db_pass=\"$passwd\";\n"; $config .= "\$dolibarr_main_db_pass=\"$passwd\";\n";
} }
else if (strstr($buffer,"\$dolibarr_main_db_pass") && $level == 1) else if (strstr($buffer,"\$dolibarr_main_db_pass") && $level == 1)
{ {
$passwd = strstr($buffer,"$dolibarr_main_db_pass="); $passwd = strstr($buffer,"$dolibarr_main_db_pass=");
$passwd = substr(substr($passwd,2),0,-3); $passwd = substr(substr($passwd,2),0,-3);
$passwd = dolibarr_encode($passwd); $passwd = dol_encode($passwd);
$config .= "\$dolibarr_main_db_encrypted_pass=\"$passwd\";\n"; $config .= "\$dolibarr_main_db_encrypted_pass=\"$passwd\";\n";
} }
else else
@@ -104,5 +104,38 @@ function encodedecode_dbpassconf($level=0)
} }
} }
/**
\brief Encode une chaine de caract<63>re
\param chain chaine de caract<63>res a encoder
\return string_coded chaine de caract<63>res encod<6F>e
*/
function dol_encode($chain)
{
for($i=0;$i<strlen($chain);$i++)
{
$output_tab[$i] = chr(ord(substr($chain,$i,1))+17);
}
$string_coded = base64_encode(implode ("",$output_tab));
return $string_coded;
}
/**
\brief Decode une chaine de caract<63>re
\param chain chaine de caract<63>res a decoder
\return string_coded chaine de caract<63>res decod<6F>e
*/
function dol_decode($chain)
{
$chain = base64_decode($chain);
for($i=0;$i<strlen($chain);$i++)
{
$output_tab[$i] = chr(ord(substr($chain,$i,1))-17);
}
$string_decoded = implode ("",$output_tab);
return $string_decoded;
}
?> ?>

View File

@@ -110,7 +110,11 @@ if (! file_exists(DOL_DOCUMENT_ROOT ."/lib/functions.lib.php"))
// on d<>code le mot de passe de la base si besoin // on d<>code le mot de passe de la base si besoin
require_once(DOL_DOCUMENT_ROOT ."/lib/functions.lib.php"); // Need 970ko memory (1.1 in 2.2) require_once(DOL_DOCUMENT_ROOT ."/lib/functions.lib.php"); // Need 970ko memory (1.1 in 2.2)
if (! empty($dolibarr_main_db_encrypted_pass)) $dolibarr_main_db_pass = dolibarr_decode($dolibarr_main_db_encrypted_pass); if (! empty($dolibarr_main_db_encrypted_pass))
{
require_once(DOL_DOCUMENT_ROOT ."/lib/security.lib.php");
$dolibarr_main_db_pass = dol_decode($dolibarr_main_db_encrypted_pass);
}
//print memory_get_usage(); //print memory_get_usage();
require_once(DOL_DOCUMENT_ROOT."/conf/conf.class.php"); require_once(DOL_DOCUMENT_ROOT."/conf/conf.class.php");