forked from Wavyzz/dolibarr
Directory to store files follow same tree than tree of sections
This commit is contained in:
@@ -14,109 +14,107 @@
|
|||||||
* 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");
|
||||||
|
|
||||||
if (! $user->admin)
|
if (! $user->admin)
|
||||||
accessforbidden();
|
accessforbidden();
|
||||||
|
|
||||||
if ($_GET["msg"]) $message='<div class="error">'.$_GET["msg"].'</div>';
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
if ($_GET["msg"]) $message='<div class="error">'.$_GET["msg"].'</div>';
|
||||||
* Actions
|
|
||||||
*/
|
|
||||||
if ($_POST["action"]=='purge')
|
|
||||||
{
|
/*
|
||||||
$filesarray=array();
|
* Actions
|
||||||
|
*/
|
||||||
if ($_POST["choice"]=='tempfiles')
|
if ($_POST["action"]=='purge')
|
||||||
{
|
{
|
||||||
// Delete temporary files
|
$filesarray=array();
|
||||||
if ($dolibarr_main_data_root)
|
|
||||||
{
|
if ($_POST["choice"]=='tempfiles')
|
||||||
$filesarray=dolibarr_dir_list($dolibarr_main_data_root,"directories",1,'temp');
|
{
|
||||||
}
|
// Delete temporary files
|
||||||
}
|
if ($dolibarr_main_data_root)
|
||||||
|
{
|
||||||
if ($_POST["choice"]=='allfiles')
|
$filesarray=dol_dir_list($dolibarr_main_data_root,"directories",1,'temp');
|
||||||
{
|
}
|
||||||
// Delete all files
|
}
|
||||||
if ($dolibarr_main_data_root)
|
|
||||||
{
|
if ($_POST["choice"]=='allfiles')
|
||||||
$filesarray=dolibarr_dir_list($dolibarr_main_data_root,"all",0);
|
{
|
||||||
}
|
// Delete all files
|
||||||
}
|
if ($dolibarr_main_data_root)
|
||||||
|
{
|
||||||
$count=0;
|
$filesarray=dol_dir_list($dolibarr_main_data_root,"all",0);
|
||||||
if (sizeof($filesarray))
|
}
|
||||||
{
|
}
|
||||||
foreach($filesarray as $key => $value)
|
|
||||||
{
|
$count=0;
|
||||||
//print "x ".$filesarray[$key]['fullname']."<br>\n";
|
if (sizeof($filesarray))
|
||||||
$count+=dol_delete_dir_recursive($filesarray[$key]['fullname']);
|
{
|
||||||
}
|
foreach($filesarray as $key => $value)
|
||||||
|
{
|
||||||
}
|
//print "x ".$filesarray[$key]['fullname']."<br>\n";
|
||||||
|
$count+=dol_delete_dir_recursive($filesarray[$key]['fullname']);
|
||||||
if ($count) $message=$langs->trans("PurgeNDirectoriesDeleted",$count);
|
}
|
||||||
else $message=$langs->trans("PurgeNothingToDelete");
|
|
||||||
$message='<div class="ok">'.$message.'</div>';
|
}
|
||||||
}
|
|
||||||
|
if ($count) $message=$langs->trans("PurgeNDirectoriesDeleted",$count);
|
||||||
|
else $message=$langs->trans("PurgeNothingToDelete");
|
||||||
/*
|
$message='<div class="ok">'.$message.'</div>';
|
||||||
* Affichage page
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Affichage page
|
||||||
|
*/
|
||||||
|
|
||||||
llxHeader();
|
llxHeader();
|
||||||
|
|
||||||
$html=new Form($db);
|
$html=new Form($db);
|
||||||
|
|
||||||
print_fiche_titre($langs->trans("Purge"),'','setup');
|
print_fiche_titre($langs->trans("Purge"),'','setup');
|
||||||
print '<br>';
|
print '<br>';
|
||||||
|
|
||||||
print $langs->trans("PurgeAreaDesc",$dolibarr_main_data_root).'<br>';
|
print $langs->trans("PurgeAreaDesc",$dolibarr_main_data_root).'<br>';
|
||||||
print '<br>';
|
print '<br>';
|
||||||
|
|
||||||
if ($message)
|
if ($message)
|
||||||
{
|
{
|
||||||
print $message.'<br>';
|
print $message.'<br>';
|
||||||
print "\n";
|
print "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
|
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
|
||||||
|
|
||||||
print '<input type="hidden" name="action" value="purge">';
|
print '<input type="hidden" name="action" value="purge">';
|
||||||
|
|
||||||
print '<table class="border" width="100%"><tr><td>';
|
print '<table class="border" width="100%"><tr><td>';
|
||||||
print '<input type="radio" name="choice" value="tempfiles"';
|
print '<input type="radio" name="choice" value="tempfiles"';
|
||||||
print (! $_POST["choice"] || $_POST["choice"]=='tempfiles') ? ' checked="true"' : '';
|
print (! $_POST["choice"] || $_POST["choice"]=='tempfiles') ? ' checked="true"' : '';
|
||||||
print '> '.$langs->trans("PurgeDeleteTemporaryFiles").'<br>';
|
print '> '.$langs->trans("PurgeDeleteTemporaryFiles").'<br>';
|
||||||
print '<input type="radio" name="choice" value="allfiles"';
|
print '<input type="radio" name="choice" value="allfiles"';
|
||||||
print ($_POST["choice"] && $_POST["choice"]=='allfiles') ? ' checked="true"' : '';
|
print ($_POST["choice"] && $_POST["choice"]=='allfiles') ? ' checked="true"' : '';
|
||||||
print '> '.$langs->trans("PurgeDeleteAllFilesInDocumentsDir",$dolibarr_main_data_root).'<br>';
|
print '> '.$langs->trans("PurgeDeleteAllFilesInDocumentsDir",$dolibarr_main_data_root).'<br>';
|
||||||
print '</td></tr></table>';
|
print '</td></tr></table>';
|
||||||
|
|
||||||
print '<br>';
|
print '<br>';
|
||||||
print '<center><input class="button" type="submit" value="'.$langs->trans("PurgeRunNow").'"></center>';
|
print '<center><input class="button" type="submit" value="'.$langs->trans("PurgeRunNow").'"></center>';
|
||||||
|
|
||||||
|
|
||||||
print '</form>';
|
print '</form>';
|
||||||
|
|
||||||
llxFooter('$Date$ - $Revision$');
|
llxFooter('$Date$ - $Revision$');
|
||||||
?>
|
?>
|
||||||
@@ -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");
|
||||||
|
|||||||
@@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
$ecmdir = new ECMDirectory($db);
|
|
||||||
if (! empty($_REQUEST["section"]))
|
|
||||||
{
|
|
||||||
$result=$ecmdir->fetch($_REQUEST["section"]);
|
|
||||||
if (! $result > 0)
|
|
||||||
{
|
|
||||||
dolibarr_print_error($db,$ecmdir->error);
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$upload_dir = $conf->ecm->dir_output.'/'.$ecmdir->label;
|
// Load ecm object
|
||||||
|
$ecmdir = new ECMDirectory($db);
|
||||||
|
if (empty($_REQUEST["section"]))
|
||||||
|
{
|
||||||
|
dolibarr_print_error('','Error, section parameter missing');
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
$result=$ecmdir->fetch($_REQUEST["section"]);
|
||||||
|
if (! $result > 0)
|
||||||
|
{
|
||||||
|
dolibarr_print_error($db,$ecmdir->error);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
$relativepath=$ecmdir->getRelativePath();
|
||||||
|
$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='&socid='.$socid;
|
$param='&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> </td>';
|
print '<td> </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"].'&action=delete_file&urlfile='.urlencode($file->name).'">'.img_delete().'</a>';
|
echo '<a href="'.$url.'?section='.$_REQUEST["section"].'&action=delete_file&urlfile='.urlencode($file['name']).'">'.img_delete().'</a>';
|
||||||
print "</td></tr>\n";
|
print "</td></tr>\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -317,12 +311,12 @@ class EcmDirectory // extends CommonObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\brief Renvoie nom clicable (avec eventuellement le picto)
|
\brief Renvoie nom clicable (avec eventuellement le picto)
|
||||||
\param withpicto 0=Pas de picto, 1=Inclut le picto dans le lien, 2=Picto seul
|
\param withpicto 0=Pas de picto, 1=Inclut le picto dans le lien, 2=Picto seul
|
||||||
\param option Sur quoi pointe le lien
|
\param option Sur quoi pointe le lien
|
||||||
\return string Chaine avec URL
|
\return string Chaine avec URL
|
||||||
*/
|
*/
|
||||||
function getNomUrl($withpicto=0,$option='')
|
function getNomUrl($withpicto=0,$option='')
|
||||||
{
|
{
|
||||||
global $langs;
|
global $langs;
|
||||||
@@ -343,7 +337,44 @@ 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
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -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,23 +17,23 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\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;
|
||||||
var $error;
|
var $error;
|
||||||
|
|
||||||
// Cache arrays
|
// Cache arrays
|
||||||
var $cache_types_paiements=array();
|
var $cache_types_paiements=array();
|
||||||
var $cache_conditions_paiements=array();
|
var $cache_conditions_paiements=array();
|
||||||
@@ -50,28 +41,28 @@ class FormEcm
|
|||||||
var $tva_taux_value;
|
var $tva_taux_value;
|
||||||
var $tva_taux_libelle;
|
var $tva_taux_libelle;
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
\brief Constructeur
|
|
||||||
\param DB handler d'acc<63>s base de donn<6E>e
|
|
||||||
*/
|
|
||||||
function FormEcm($DB)
|
|
||||||
{
|
|
||||||
$this->db = $DB;
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
/**
|
||||||
/**
|
* \brief Constructeur
|
||||||
* \brief Retourne la liste des cat<61>gories du type choisi
|
* \param DB handler d'acc<63>s base de donn<6E>e
|
||||||
* \param selected Id categorie preselectionnee
|
*/
|
||||||
* \param select_name Nom formulaire HTML
|
function FormEcm($DB)
|
||||||
*/
|
{
|
||||||
function select_all_sections($selected='',$select_name='')
|
$this->db = $DB;
|
||||||
{
|
|
||||||
global $langs;
|
return 1;
|
||||||
$langs->load("ecm");
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Retourne la liste des cat<61>gories du type choisi
|
||||||
|
* \param selected Id categorie preselectionnee
|
||||||
|
* \param select_name Nom formulaire HTML
|
||||||
|
*/
|
||||||
|
function select_all_sections($selected='',$select_name='')
|
||||||
|
{
|
||||||
|
global $langs;
|
||||||
|
$langs->load("ecm");
|
||||||
|
|
||||||
if ($select_name=="") $select_name="catParent";
|
if ($select_name=="") $select_name="catParent";
|
||||||
|
|
||||||
@@ -101,7 +92,7 @@ class FormEcm
|
|||||||
}
|
}
|
||||||
$output.= '</select>';
|
$output.= '</select>';
|
||||||
$output.= "\n";
|
$output.= "\n";
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -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
|
||||||
@@ -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;
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,108 +1,141 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2008 Laurent Destailleur <eldy@users.sourceforge.net>
|
/* Copyright (C) 2008 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
*
|
*
|
||||||
* 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
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* 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.
|
||||||
* or see http://www.gnu.org/
|
* or see http://www.gnu.org/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\file htdocs/lib/security.lib.php
|
\file htdocs/lib/security.lib.php
|
||||||
\brief Ensemble de fonctions de securite de dolibarr sous forme de lib
|
\brief Ensemble de fonctions de securite de dolibarr sous forme de lib
|
||||||
\version $Id$
|
\version $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\brief Fonction pour initialiser un salt pour la fonction crypt
|
\brief Fonction pour initialiser un salt pour la fonction crypt
|
||||||
\param $type 2=>renvoi un salt pour cryptage DES
|
\param $type 2=>renvoi un salt pour cryptage DES
|
||||||
12=>renvoi un salt pour cryptage MD5
|
12=>renvoi un salt pour cryptage MD5
|
||||||
non defini=>renvoi un salt pour cryptage par defaut
|
non defini=>renvoi un salt pour cryptage par defaut
|
||||||
\return string Chaine salt
|
\return string Chaine salt
|
||||||
*/
|
*/
|
||||||
function makesalt($type=CRYPT_SALT_LENGTH)
|
function makesalt($type=CRYPT_SALT_LENGTH)
|
||||||
{
|
{
|
||||||
dolibarr_syslog("security.lib.php::makesalt type=".$type);
|
dolibarr_syslog("security.lib.php::makesalt type=".$type);
|
||||||
switch($type)
|
switch($type)
|
||||||
{
|
{
|
||||||
case 12: // 8 + 4
|
case 12: // 8 + 4
|
||||||
$saltlen=8; $saltprefix='$1$'; $saltsuffix='$'; break;
|
$saltlen=8; $saltprefix='$1$'; $saltsuffix='$'; break;
|
||||||
case 8: // 8 + 4 (Pour compatibilite, ne devrait pas etre utilis<69>)
|
case 8: // 8 + 4 (Pour compatibilite, ne devrait pas etre utilis<69>)
|
||||||
$saltlen=8; $saltprefix='$1$'; $saltsuffix='$'; break;
|
$saltlen=8; $saltprefix='$1$'; $saltsuffix='$'; break;
|
||||||
case 2: // 2
|
case 2: // 2
|
||||||
default: // by default, fall back on Standard DES (should work everywhere)
|
default: // by default, fall back on Standard DES (should work everywhere)
|
||||||
$saltlen=2; $saltprefix=''; $saltsuffix=''; break;
|
$saltlen=2; $saltprefix=''; $saltsuffix=''; break;
|
||||||
}
|
}
|
||||||
$salt='';
|
$salt='';
|
||||||
while(strlen($salt) < $saltlen) $salt.=chr(rand(64,126));
|
while(strlen($salt) < $saltlen) $salt.=chr(rand(64,126));
|
||||||
|
|
||||||
$result=$saltprefix.$salt.$saltsuffix;
|
$result=$saltprefix.$salt.$saltsuffix;
|
||||||
dolibarr_syslog("security.lib.php::makesalt return=".$result);
|
dolibarr_syslog("security.lib.php::makesalt return=".$result);
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\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)
|
||||||
{
|
{
|
||||||
$config = '';
|
$config = '';
|
||||||
|
|
||||||
if ($fp = fopen(DOL_DOCUMENT_ROOT.'/conf/conf.php','r'))
|
if ($fp = fopen(DOL_DOCUMENT_ROOT.'/conf/conf.php','r'))
|
||||||
{
|
{
|
||||||
while(!feof($fp))
|
while(!feof($fp))
|
||||||
{
|
{
|
||||||
$buffer = fgets($fp,4096);
|
$buffer = fgets($fp,4096);
|
||||||
|
|
||||||
if (strstr($buffer,"\$dolibarr_main_db_encrypted_pass") && $level == 0)
|
if (strstr($buffer,"\$dolibarr_main_db_encrypted_pass") && $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
|
||||||
{
|
{
|
||||||
$config .= $buffer;
|
$config .= $buffer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fclose($fp);
|
fclose($fp);
|
||||||
|
|
||||||
if ($fp = @fopen(DOL_DOCUMENT_ROOT.'/conf/conf.php','w'))
|
if ($fp = @fopen(DOL_DOCUMENT_ROOT.'/conf/conf.php','w'))
|
||||||
{
|
{
|
||||||
fputs($fp, $config, strlen($config));
|
fputs($fp, $config, strlen($config));
|
||||||
fclose($fp);
|
fclose($fp);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
\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;
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
@@ -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");
|
||||||
|
|||||||
Reference in New Issue
Block a user