diff --git a/ChangeLog b/ChangeLog index 456ae4978f7..d5c337d80f1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -41,7 +41,9 @@ For users: - New: Increase page loading speed (all changes reported by Google PageSpeed tool has been added). - New: Add support of constant MAIN_ONLY_LOGIN_ALLOWED to allow to lock all - access to any users axcept the one defined in constant. + access to any users except the one defined in constant. +- New: Add an admin page of PHP sessions with a way to lock new connections + for other users than yourself. Can also purge existing sessions. - Fix: "Now" link works when date popup is not used. - Fix: Debug seriously the email notification module. - Fix: Error Call to a member function trans when refusing a supplier order. diff --git a/htdocs/admin/const.php b/htdocs/admin/const.php index ed85e140f7b..54b040c260c 100644 --- a/htdocs/admin/const.php +++ b/htdocs/admin/const.php @@ -41,7 +41,7 @@ $typeconst=array('yesno','texte','chaine'); */ if ($_POST["action"] == 'update' || $_POST["action"] == 'add') { - if (! dolibarr_set_const($db, $_POST["constname"],$_POST["constvalue"],$typeconst[$_POST["consttype"]],1,isset($_POST["constnote"])?$_POST["constnote"]:'',$_POST["entity"])); + if (dolibarr_set_const($db, $_POST["constname"],$_POST["constvalue"],$typeconst[$_POST["consttype"]],1,isset($_POST["constnote"])?$_POST["constnote"]:'',$_POST["entity"]) < 0) { print $db->error(); } @@ -49,7 +49,7 @@ if ($_POST["action"] == 'update' || $_POST["action"] == 'add') if ($_GET["action"] == 'delete') { - if (! dolibarr_del_const($db, $_GET["rowid"],$_GET["entity"])); + if (dolibarr_del_const($db, $_GET["rowid"],$_GET["entity"]) < 0) { print $db->error(); } diff --git a/htdocs/admin/tools/listevents.php b/htdocs/admin/tools/listevents.php index 46ab0f305b1..9b5e22ce297 100644 --- a/htdocs/admin/tools/listevents.php +++ b/htdocs/admin/tools/listevents.php @@ -100,7 +100,7 @@ if ($result) $num = $db->num_rows($result); $i = 0; - print_barre_liste($langs->trans("ListOfSecurityEvents"), $page, "listevents.php","",$sortfield,$sortorder,'',$num,0,'setup'); + print_barre_liste($langs->trans("ListOfSecurityEvents"), $page, $_SERVER["PHP_SELF"],"",$sortfield,$sortorder,'',$num,0,'setup'); if ($_GET["action"] == 'purge') { diff --git a/htdocs/admin/tools/listsessions.php b/htdocs/admin/tools/listsessions.php new file mode 100644 index 00000000000..e9c00e0b907 --- /dev/null +++ b/htdocs/admin/tools/listsessions.php @@ -0,0 +1,241 @@ + + * Copyright (C) 2005-2009 Regis Houssin + * + * 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +/** + * \file htdocs/admin/tools/listessions.php + * \ingroup core + * \brief List of PHP sessions + * \version $Id$ + */ + +require_once("./pre.inc.php"); +require_once(DOL_DOCUMENT_ROOT.'/lib/admin.lib.php'); + +if (! $user->admin) + accessforbidden(); + +// Security check +if ($user->societe_id > 0) +{ + $action = ''; + $socid = $user->societe_id; +} + +$langs->load("companies"); +$langs->load("users"); +$langs->load("other"); + +$page=$_GET["page"]; +$sortorder=$_GET["sortorder"]; +$sortfield=$_GET["sortfield"]; + +if (! $sortorder) $sortorder="DESC"; +if (! $sortfield) $sortfield="dateevent"; +if ($page == -1) { $page = 0 ; } +$offset = $conf->liste_limit * $page ; +$pageprev = $page - 1; +$pagenext = $page + 1; + + +/* + * Actions + */ + +// Purge sessions +if ($_REQUEST['action'] == 'confirm_purge' && $_REQUEST['confirm'] == 'yes' && $user->admin) +{ + $res=purgeSessions(session_id()); +} + +// Lock new sessions +if ($_REQUEST['action'] == 'confirm_lock' && $_REQUEST['confirm'] == 'yes' && $user->admin) +{ + if (dolibarr_set_const($db, 'MAIN_ONLY_LOGIN_ALLOWED', $user->login, 'text',1,'Logon is restricted to a particular user', 0) < 0) + { + dol_print_error($db); + } +} + +// Unlock new sessions +if ($_REQUEST['action'] == 'confirm_unlock' && $user->admin) +{ + if (dolibarr_del_const($db, 'MAIN_ONLY_LOGIN_ALLOWED', -1) < 0) + { + dol_print_error($db); + } +} + + + +/* +* View +*/ + +llxHeader(); + +$form=new Form($db); + +$userstatic=new User($db); +$usefilter=0; + +$listofsessions=listOfSessions(); + +print_barre_liste($langs->trans("Sessions"), $page, $_SERVER["PHP_SELF"],"",$sortfield,$sortorder,'',$num,0,'setup'); + +$savehandler=get_cfg_var("session.save_handler"); +$savepath=get_cfg_var("session.save_path"); + +print ''.$langs->trans("SessionSaveHandler").': '.$savehandler.'
'; +print ''.$langs->trans("SessionSavePath").': '.$savepath.'
'; +print '
'; + +if ($_GET["action"] == 'purge') +{ + $formquestion=array(); + $ret=$form->form_confirm($_SERVER["PHP_SELF"].'?noparam=noparam', $langs->trans('PurgeSessions'), $langs->trans('ConfirmPurgeSessions'),'confirm_purge',$formquestion,'no',2); + if ($ret == 'html') print '
'; +} +if ($_GET["action"] == 'lock') +{ + $formquestion=array(); + $ret=$form->form_confirm($_SERVER["PHP_SELF"].'?noparam=noparam', $langs->trans('LockNewSessions'), $langs->trans('ConfirmLockNewSessions',$user->login),'confirm_lock',$formquestion,'no',1); + if ($ret == 'html') print '
'; +} + +if ($savehandler == 'files') +{ + print ''; + print ''; + print_liste_field_titre($langs->trans("SessionId"),$_SERVER["PHP_SELF"],"id","","",'align="left"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("DateCreation"),$_SERVER["PHP_SELF"],"datec","","",'align="left"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("DateModification"),$_SERVER["PHP_SELF"],"datem","","",'align="left"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Age"),$_SERVER["PHP_SELF"],"age","","",'align="left"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Raw"),$_SERVER["PHP_SELF"],"raw","","",'align="left"',$sortfield,$sortorder); + print_liste_field_titre('','',''); + print "\n"; + + + // Lignes des champs de filtre + /* + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + + print "\n"; + print ''; + */ + + $var=True; + + foreach ($listofsessions as $key => $sessionentry) + { + $var=!$var; + + print ""; + + // ID + print ''; + + // Date creation + print ''; + + // Date modification + print ''; + + // Age + print ''; + + // Raw + print ''; + + print ''; + + print "\n"; + $i++; + } + + if (sizeof($listofsessions) == 0) + { + if ($usefilter) print ''; + else print ''; + } + print "
 '; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print '
'; + if ("$key" == session_id()) print $form->textwithpicto($key,$langs->trans("YourSession")); + else print $key; + print ''.dol_print_date($sessionentry['creation'],'%Y-%m-%d %H:%M:%S').''.dol_print_date($sessionentry['modification'],'%Y-%m-%d %H:%M:%S').''.$sessionentry['age'].''.dol_trunc($sessionentry['raw'],40,'middle').' 
'.$langs->trans("NoSessionsFound").'
'.$langs->trans("NoSessionFound").'
"; + +} +else +{ + print $langs->trans("NoSessionListWithThisHandler"); +} + +/* + * Buttons + */ + +print '
'; + + +if (empty($conf->global->MAIN_ONLY_LOGIN_ALLOWED)) +{ + print ''.$langs->trans("LockNewSessions").''; +} +else +{ + print ''.$langs->trans("UnlockNewSessions").''; +} + +if ($savehandler == 'files') +{ + if (sizeof($listofsessions)) + { + print ''.$langs->trans("PurgeSessions").''; + } +} + +print '
'; + + +$db->close(); + +llxFooter('$Date$ - $Revision$'); +?> diff --git a/htdocs/admin/tools/pre.inc.php b/htdocs/admin/tools/pre.inc.php index 0bee2e8e2b9..b11dc9bcbc9 100644 --- a/htdocs/admin/tools/pre.inc.php +++ b/htdocs/admin/tools/pre.inc.php @@ -41,7 +41,9 @@ function llxHeader($head = '', $title='', $help_url='') $menu->add(DOL_URL_ROOT."/admin/tools/update.php", $langs->trans("Upgrade"),1); if (function_exists('eaccelerator_info')) $menu->add(DOL_URL_ROOT."/admin/tools/eaccelerator.php", $langs->trans("EAccelerator"),1); $menu->add(DOL_URL_ROOT."/admin/tools/listevents.php", $langs->trans("Audit"),1); + $menu->add(DOL_URL_ROOT."/admin/tools/listsessions.php", $langs->trans("Sessions"),1); $menu->add(DOL_URL_ROOT."/admin/tools/purge.php", $langs->trans("Purge"),1); + $menu->add(DOL_URL_ROOT."/support/index.php", $langs->trans("HelpCenter"),1,1,'targethelp'); left_menu($menu->liste, $help_url); } diff --git a/htdocs/includes/menus/barre_left/auguria_backoffice.php b/htdocs/includes/menus/barre_left/auguria_backoffice.php index 32f31161079..c8c9072aa0f 100644 --- a/htdocs/includes/menus/barre_left/auguria_backoffice.php +++ b/htdocs/includes/menus/barre_left/auguria_backoffice.php @@ -32,10 +32,9 @@ /** - \class MenuLeft - \brief Classe permettant la gestion du menu du gauche Auguria + * \class MenuLeft + * \brief Classe permettant la gestion du menu du gauche Auguria */ - class MenuLeft { var $require_top=array("auguria_backoffice"); // Si doit etre en phase avec un gestionnaire de menu du haut particulier diff --git a/htdocs/includes/menus/barre_left/auguria_frontoffice.php b/htdocs/includes/menus/barre_left/auguria_frontoffice.php index 8cb6bd8574b..7038552be1f 100644 --- a/htdocs/includes/menus/barre_left/auguria_frontoffice.php +++ b/htdocs/includes/menus/barre_left/auguria_frontoffice.php @@ -32,10 +32,9 @@ /** - \class MenuLeft - \brief Classe permettant la gestion du menu du gauche Auguria -*/ - + * \class MenuLeft + * \brief Classe permettant la gestion du menu du gauche Auguria + */ class MenuLeft { var $require_top=array("auguria_frontoffice"); // Si doit etre en phase avec un gestionnaire de menu du haut particulier diff --git a/htdocs/includes/menus/barre_left/eldy_backoffice.php b/htdocs/includes/menus/barre_left/eldy_backoffice.php index e35d72ff104..c6157eb4153 100644 --- a/htdocs/includes/menus/barre_left/eldy_backoffice.php +++ b/htdocs/includes/menus/barre_left/eldy_backoffice.php @@ -161,6 +161,7 @@ class MenuLeft { if ($leftmenu=="admintools") $newmenu->add(DOL_URL_ROOT."/admin/tools/update.php", $langs->trans("Upgrade"),1); if ($leftmenu=="admintools" && function_exists('eaccelerator_info')) $newmenu->add(DOL_URL_ROOT."/admin/tools/eaccelerator.php", $langs->trans("EAccelerator"),1); if ($leftmenu=="admintools") $newmenu->add(DOL_URL_ROOT."/admin/tools/listevents.php", $langs->trans("Audit"),1); + if ($leftmenu=="admintools") $newmenu->add(DOL_URL_ROOT."/admin/tools/listsessions.php", $langs->trans("Sessions"),1); if ($leftmenu=="admintools") $newmenu->add(DOL_URL_ROOT."/admin/tools/purge.php", $langs->trans("Purge"),1); if ($leftmenu=="admintools") $newmenu->add(DOL_URL_ROOT."/support/index.php", $langs->trans("HelpCenter"),1,1,'targethelp'); } diff --git a/htdocs/includes/menus/barre_left/eldy_frontoffice.php b/htdocs/includes/menus/barre_left/eldy_frontoffice.php index 5848e4913c7..0e007014775 100644 --- a/htdocs/includes/menus/barre_left/eldy_frontoffice.php +++ b/htdocs/includes/menus/barre_left/eldy_frontoffice.php @@ -164,6 +164,7 @@ class MenuLeft { if ($leftmenu=="admintools") $newmenu->add(DOL_URL_ROOT."/admin/tools/update.php", $langs->trans("Upgrade"),1); if ($leftmenu=="admintools" && function_exists('eaccelerator_info')) $newmenu->add(DOL_URL_ROOT."/admin/tools/eaccelerator.php", $langs->trans("EAccelerator"),1); if ($leftmenu=="admintools") $newmenu->add(DOL_URL_ROOT."/admin/tools/listevents.php", $langs->trans("Audit"),1); + if ($leftmenu=="admintools") $newmenu->add(DOL_URL_ROOT."/admin/tools/listsessions.php", $langs->trans("Sessions"),1); if ($leftmenu=="admintools") $newmenu->add(DOL_URL_ROOT."/admin/tools/purge.php", $langs->trans("Purge"),1); if ($leftmenu=="admintools") $newmenu->add(DOL_URL_ROOT."/support/index.php", $langs->trans("HelpCenter"),1,1,'targethelp'); } diff --git a/htdocs/includes/menus/init_menu_auguria.sql b/htdocs/includes/menus/init_menu_auguria.sql index 79a6faf42dd..f62224cd839 100644 --- a/htdocs/includes/menus/init_menu_auguria.sql +++ b/htdocs/includes/menus/init_menu_auguria.sql @@ -7,7 +7,7 @@ -- This file is loaded when a menu handler auguria is activated -- -delete from llx_menu_const where fk_menu in (select rowid from llx_menu where menu_handler='auguria', __ENTITY__); +delete from llx_menu_const where fk_menu in (select rowid from llx_menu where menu_handler='auguria' and entity=__ENTITY__); delete from llx_menu where menu_handler='auguria'; -- @@ -57,8 +57,9 @@ insert into `llx_menu` (`enabled`, `menu_handler`, `type`, `rowid`, `mainmenu`, insert into `llx_menu` (`enabled`, `menu_handler`, `type`, `rowid`, `mainmenu`, `leftmenu`, `fk_menu`, `url`, `titre`, `level`, `langs`, perms, `target`, `user`, position, entity) values ('$leftmenu=="admintools"', 'auguria', 'left', 305__+MAX_llx_menu__, 'home', '', 300__+MAX_llx_menu__, '/admin/tools/update.php?leftmenu=admintools', 'Upgrade', 1, 'admin', '', '', 2, 2, __ENTITY__); insert into `llx_menu` (`enabled`, `menu_handler`, `type`, `rowid`, `mainmenu`, `leftmenu`, `fk_menu`, `url`, `titre`, `level`, `langs`, perms, `target`, `user`, position, entity) values ('$leftmenu=="admintools" && function_exists(\'eaccelerator_info\')', 'auguria', 'left', 304__+MAX_llx_menu__, 'home', '', 300__+MAX_llx_menu__, '/admin/tools/eaccelerator.php?leftmenu=admintools', 'EAccelerator', 1, 'admin', '', '', 2, 3, __ENTITY__); insert into `llx_menu` (`enabled`, `menu_handler`, `type`, `rowid`, `mainmenu`, `leftmenu`, `fk_menu`, `url`, `titre`, `level`, `langs`, perms, `target`, `user`, position, entity) values ('$leftmenu=="admintools"', 'auguria', 'left', 306__+MAX_llx_menu__, 'home', '', 300__+MAX_llx_menu__, '/admin/tools/listevents.php?leftmenu=admintools', 'Audit', 1, 'admin', '', '', 2, 4, __ENTITY__); -insert into `llx_menu` (`enabled`, `menu_handler`, `type`, `rowid`, `mainmenu`, `leftmenu`, `fk_menu`, `url`, `titre`, `level`, `langs`, perms, `target`, `user`, position, entity) values ('$leftmenu=="admintools"', 'auguria', 'left', 303__+MAX_llx_menu__, 'home', '', 300__+MAX_llx_menu__, '/admin/tools/purge.php?leftmenu=admintools', 'Purge', 1, 'admin', '', '', 2, 5, __ENTITY__); -insert into `llx_menu` (`enabled`, `menu_handler`, `type`, `rowid`, `mainmenu`, `leftmenu`, `fk_menu`, `url`, `titre`, `level`, `langs`, perms, `target`, `user`, position, entity) values ('$leftmenu=="admintools"', 'auguria', 'left', 307__+MAX_llx_menu__, 'home', '', 300__+MAX_llx_menu__, '/support/index.php?leftmenu=admintools', 'HelpCenter', 1, 'help', '', '', 2, 6, __ENTITY__); +insert into `llx_menu` (`enabled`, `menu_handler`, `type`, `rowid`, `mainmenu`, `leftmenu`, `fk_menu`, `url`, `titre`, `level`, `langs`, perms, `target`, `user`, position, entity) values ('$leftmenu=="admintools"', 'auguria', 'left', 308__+MAX_llx_menu__, 'home', '', 300__+MAX_llx_menu__, '/admin/tools/listsessions.php?leftmenu=admintools', 'Sessions', 1, 'admin', '', '', 2, 5, __ENTITY__); +insert into `llx_menu` (`enabled`, `menu_handler`, `type`, `rowid`, `mainmenu`, `leftmenu`, `fk_menu`, `url`, `titre`, `level`, `langs`, perms, `target`, `user`, position, entity) values ('$leftmenu=="admintools"', 'auguria', 'left', 303__+MAX_llx_menu__, 'home', '', 300__+MAX_llx_menu__, '/admin/tools/purge.php?leftmenu=admintools', 'Purge', 1, 'admin', '', '', 2, 6, __ENTITY__); +insert into `llx_menu` (`enabled`, `menu_handler`, `type`, `rowid`, `mainmenu`, `leftmenu`, `fk_menu`, `url`, `titre`, `level`, `langs`, perms, `target`, `user`, position, entity) values ('$leftmenu=="admintools"', 'auguria', 'left', 307__+MAX_llx_menu__, 'home', '', 300__+MAX_llx_menu__, '/support/index.php?leftmenu=admintools', 'HelpCenter', 1, 'help', '', '', 2, 7, __ENTITY__); insert into `llx_menu` (`enabled`, `menu_handler`, `type`, `rowid`, `mainmenu`, `leftmenu`, `fk_menu`, `url`, `titre`, `level`, `langs`, perms, `target`, `user`, position, entity) values (1, 'auguria', 'left', 400__+MAX_llx_menu__, 'home', '', 1__+MAX_llx_menu__, '/user/home.php?leftmenu=users', 'MenuUsersAndGroups', 0, 'users', '', '', 2, 3, __ENTITY__); insert into `llx_menu` (`enabled`, `menu_handler`, `type`, `rowid`, `mainmenu`, `leftmenu`, `fk_menu`, `url`, `titre`, `level`, `langs`, perms, `target`, `user`, position, entity) values ('$leftmenu=="users"', 'auguria', 'left', 401__+MAX_llx_menu__, 'home', '', 400__+MAX_llx_menu__, '/user/index.php?leftmenu=users', 'Users', 1, 'users', '$user->rights->user->user->lire || $user->admin', '', 2, 0, __ENTITY__); insert into `llx_menu` (`enabled`, `menu_handler`, `type`, `rowid`, `mainmenu`, `leftmenu`, `fk_menu`, `url`, `titre`, `level`, `langs`, perms, `target`, `user`, position, entity) values ('$leftmenu=="users"', 'auguria', 'left', 402__+MAX_llx_menu__, 'home', '', 401__+MAX_llx_menu__, '/user/fiche.php?leftmenu=users&action=create', 'NewUser', 2, 'users', '$user->rights->user->user->creer || $user->admin', '', 2, 0, __ENTITY__); @@ -98,8 +99,8 @@ insert into `llx_menu` (`enabled`, `menu_handler`, `type`, `rowid`, `mainmenu`, insert into `llx_menu` (`enabled`, `menu_handler`, `type`, `rowid`, `mainmenu`, `leftmenu`, `fk_menu`, `url`, `titre`, `level`, `langs`, perms, `target`, `user`, position, entity) values ('$conf->stock->enabled', 'auguria', 'left', 3104__+MAX_llx_menu__, 'products', '', 3100__+MAX_llx_menu__, '/product/stock/mouvement.php', 'Movements', 1, 'stocks', '$user->rights->stock->mouvement->lire', '', 2, 3, __ENTITY__); insert into `llx_menu` (`enabled`, `menu_handler`, `type`, `rowid`, `mainmenu`, `leftmenu`, `fk_menu`, `url`, `titre`, `level`, `langs`, perms, `target`, `user`, position, entity) values ('$conf->categorie->enabled', 'auguria', 'left', 3200__+MAX_llx_menu__, 'products', '', 3__+MAX_llx_menu__, '/categories/index.php?leftmenu=cat&type=0', 'Categories', 0, 'categories', '$user->rights->categorie>lire', '', 2, 4, __ENTITY__); insert into `llx_menu` (`enabled`, `menu_handler`, `type`, `rowid`, `mainmenu`, `leftmenu`, `fk_menu`, `url`, `titre`, `level`, `langs`, perms, `target`, `user`, position, entity) values ('$conf->categorie->enabled', 'auguria', 'left', 3201__+MAX_llx_menu__, 'products', '', 3200__+MAX_llx_menu__, '/categories/fiche.php?action=create&type=0', 'NewCat', 1, 'categories', '$user->rights->categorie>creer', '', 2, 0, __ENTITY__); -insert into `llx_menu` (`enabled`, `menu_handler`, `type`, `rowid`, `mainmenu`, `leftmenu`, `fk_menu`, `url`, `titre`, `level`, `langs`, perms, `target`, `user`, position, entity) values ('$conf->droitpret->enabled', 'auguria', 'left', 4800__+MAX_llx_menu__, 'products', '', 3__+MAX_llx_menu__, '/product/droitpret/index.php?leftmenu=droitpret', 'Droit de pr�t', 0, 'products', '$user->rights->droitpret->lire', '', 2, 5, __ENTITY__); -insert into `llx_menu` (`enabled`, `menu_handler`, `type`, `rowid`, `mainmenu`, `leftmenu`, `fk_menu`, `url`, `titre`, `level`, `langs`, perms, `target`, `user`, position, entity) values ('$conf->droitpret->enabled', 'auguria', 'left', 4801__+MAX_llx_menu__, 'products', '', 4800__+MAX_llx_menu__, '/product/droitpret/index.php?leftmenu=droitpret', 'G�n�rer rapport', 1, 'products', '$user->rights->droitpret->creer', '', 2, 1, __ENTITY__); +insert into `llx_menu` (`enabled`, `menu_handler`, `type`, `rowid`, `mainmenu`, `leftmenu`, `fk_menu`, `url`, `titre`, `level`, `langs`, perms, `target`, `user`, position, entity) values ('$conf->droitpret->enabled', 'auguria', 'left', 4800__+MAX_llx_menu__, 'products', '', 3__+MAX_llx_menu__, '/product/droitpret/index.php?leftmenu=droitpret', 'Droit de pret', 0, 'products', '$user->rights->droitpret->lire', '', 2, 5, __ENTITY__); +insert into `llx_menu` (`enabled`, `menu_handler`, `type`, `rowid`, `mainmenu`, `leftmenu`, `fk_menu`, `url`, `titre`, `level`, `langs`, perms, `target`, `user`, position, entity) values ('$conf->droitpret->enabled', 'auguria', 'left', 4801__+MAX_llx_menu__, 'products', '', 4800__+MAX_llx_menu__, '/product/droitpret/index.php?leftmenu=droitpret', 'Generer rapport', 1, 'products', '$user->rights->droitpret->creer', '', 2, 1, __ENTITY__); insert into `llx_menu` (`enabled`, `menu_handler`, `type`, `rowid`, `mainmenu`, `leftmenu`, `fk_menu`, `url`, `titre`, `level`, `langs`, perms, `target`, `user`, position, entity) values ('$conf->fournisseur->enabled', 'auguria', 'left', 3300__+MAX_llx_menu__, 'suppliers', '', 4__+MAX_llx_menu__, '/fourn/index.php?leftmenu=suppliers', 'Suppliers', 0, 'suppliers', '$user->rights->societe->lire && $user->rights->fournisseur->lire', '', 2, 0, __ENTITY__); insert into `llx_menu` (`enabled`, `menu_handler`, `type`, `rowid`, `mainmenu`, `leftmenu`, `fk_menu`, `url`, `titre`, `level`, `langs`, perms, `target`, `user`, position, entity) values ('$conf->fournisseur->enabled', 'auguria', 'left', 3301__+MAX_llx_menu__, 'suppliers', '', 3300__+MAX_llx_menu__, '/soc.php?leftmenu=suppliers&action=create&type=f', 'NewSupplier', 1, 'suppliers', '$user->rights->societe->creer && $user->rights->fournisseur->lire', '', 2, 0, __ENTITY__); diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index e4fa12eb2c7..df35461c8bd 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -18,6 +18,7 @@ LockNewSessions=Lock new connections ConfirmLockNewSessions=Are you sure you want to restrict any new Dolibarr connection to yourself. Only user %s will be able to connect after that. UnlockNewSessions=Remove connection lock YourSession=Your session +Sessions=Users session HTMLCharset=Charset for generated HTML pages DBStoringCharset=Database charset to store data DBSortingCharset=Database charset to sort data diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang index c61e6ac6152..e0314c0ebac 100644 --- a/htdocs/langs/fr_FR/admin.lang +++ b/htdocs/langs/fr_FR/admin.lang @@ -18,6 +18,7 @@ LockNewSessions=Bloquer nouvelles connections ConfirmLockNewSessions=Etes-vous sur de vouloir restreindre l'accès Dolibarr à votre utilisateur. Seul le login %s pourra se connecter après cela. UnlockNewSessions=Lever blocage des connections YourSession=Votre session +Sessions=Sessions utilisateurs HTMLCharset = Charset des pages HTML générées DBStoringCharset = Charset base pour stockage données DBSortingCharset = Charset base pour tri données diff --git a/htdocs/lib/admin.lib.php b/htdocs/lib/admin.lib.php index bce594e0d6a..ed5108263ce 100644 --- a/htdocs/lib/admin.lib.php +++ b/htdocs/lib/admin.lib.php @@ -297,12 +297,12 @@ function run_sql($sqlfile,$silent=1) /** - \brief Effacement d'une constante dans la base de donnees - \sa dolibarr_get_const, dolibarr_sel_const - \param db Handler d'acces base - \param name Nom ou rowid de la constante - \param entity Multi company id - \return int <0 si ko, >0 si ok + * \brief Effacement d'une constante dans la base de donnees + * \sa dolibarr_get_const, dolibarr_sel_const + * \param db Handler d'acces base + * \param name Nom ou rowid de la constante + * \param entity Multi company id, -1 for all entities + * \return int <0 if KO, >0 if OK */ function dolibarr_del_const($db, $name, $entity=1) { @@ -310,7 +310,7 @@ function dolibarr_del_const($db, $name, $entity=1) $sql = "DELETE FROM ".MAIN_DB_PREFIX."const"; $sql.=" WHERE (".$db->decrypt('name',$conf->db->dolibarr_main_db_encryption,$conf->db->dolibarr_main_db_cryptkey)." = '".addslashes($name)."' OR rowid = '".addslashes($name)."')"; - $sql.= " AND entity = ".$entity; + if ($entity >= 0) $sql.= " AND entity = ".$entity; dol_syslog("admin.lib::dolibarr_del_const sql=".$sql); $resql=$db->query($sql); @@ -321,6 +321,7 @@ function dolibarr_del_const($db, $name, $entity=1) } else { + $this->error=$db->lasterror(); return -1; } } @@ -447,4 +448,76 @@ function security_prepare_head() return $head; } + +/** + * Return list of session + * @return array Array list of sessions + */ +function listOfSessions() +{ + $arrayofSessions = array(); + $sessPath = get_cfg_var("session.save_path")."\\"; + dol_syslog('admin.lib:listOfSessions sessPath='.$sessPath); + + $dh = @opendir($sessPath); + while(($file = @readdir($dh)) !== false) + { + if ($file != "." && $file != "..") + { + $fullpath = $sessPath.$file; + if(! @is_dir($fullpath)) + { + $tmp=split('_', $file); + $idsess=$tmp[1]; + //print 'file='.$file.' id='.$idsess; + $sessValues = file_get_contents($fullpath); // get raw session data + $arrayofSessions[$idsess]["age"] = time()-filectime( $fullpath ); + $arrayofSessions[$idsess]["creation"] = filectime( $fullpath ); + $arrayofSessions[$idsess]["modification"] = filemtime( $fullpath ); + $arrayofSessions[$idsess]["raw"] = $sessValues; + } + } + } + @closedir($dh); + + return $arrayofSessions; +} + +/** + * Purge existing sessions + * @param mysessionid To avoid to try to delete my own session + * @return int >0 if OK, <0 if KO + */ +function purgeSessions($mysessionid) +{ + $arrayofSessions = array(); + $sessPath = get_cfg_var("session.save_path")."\\"; + + dol_syslog('admin.lib:purgeSessions mysessionid='.$mysessionid.' sessPath='.$sessPath); + + $error=0; + $dh = @opendir($sessPath); + while(($file = @readdir($dh)) !== false) + { + if ($file != "." && $file != "..") + { + $fullpath = $sessPath.$file; + if(! @is_dir($fullpath)) + { + $tmp=split('_', $file); + $idsess=$tmp[1]; + // We remove session if it's not ourself + if ($idsess != $mysessionid) + { + $res=@unlink($fullpath); + if (! $res) $error++; + } + } + } + } + @closedir($dh); + + if (! $error) return 1; + else return -$error; +} ?> \ No newline at end of file