From 1f598960c3520cf90eefef9ba2cf75a7903f9b9c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 28 Sep 2010 17:35:49 +0000 Subject: [PATCH] Qual: Uniformize code --- htdocs/cashdesk/affIndex.php | 6 +++-- htdocs/cashdesk/deconnexion.php | 29 ++++++++--------------- htdocs/cashdesk/facturation_dhtml.php | 2 +- htdocs/cashdesk/facturation_verif.php | 8 ++++--- htdocs/cashdesk/include/environnement.php | 14 ++--------- htdocs/cashdesk/index.php | 18 ++------------ htdocs/cashdesk/index_verif.php | 6 ++--- htdocs/cashdesk/validation_ticket.php | 2 +- htdocs/cashdesk/validation_verif.php | 14 +++++------ 9 files changed, 35 insertions(+), 64 deletions(-) diff --git a/htdocs/cashdesk/affIndex.php b/htdocs/cashdesk/affIndex.php index bd1f50cb80f..0d9190aa5b2 100644 --- a/htdocs/cashdesk/affIndex.php +++ b/htdocs/cashdesk/affIndex.php @@ -24,8 +24,10 @@ * \brief First page of point of sale module * \version $Id$ */ -include_once('../master.inc.php'); -require_once('include/environnement.php'); +require('../main.inc.php'); +require_once(DOL_DOCUMENT_ROOT.'/cashdesk/include/environnement.php'); + +// Test if already logged if ( $_SESSION['uid'] <= 0 ) { header ('Location: index.php'); exit; diff --git a/htdocs/cashdesk/deconnexion.php b/htdocs/cashdesk/deconnexion.php index ad4f493368a..d3e87af63b8 100644 --- a/htdocs/cashdesk/deconnexion.php +++ b/htdocs/cashdesk/deconnexion.php @@ -16,27 +16,18 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -// Add real path in session -$realpath=''; -if ( preg_match('/^([^.]+)\/htdocs\//i', realpath($_SERVER["SCRIPT_FILENAME"]), $regs)) $realpath = isset($regs[1])?$regs[1]:''; +//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Uncomment creates pb to relogon after a disconnect +if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); +if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); +if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); +if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); -// Init session. Name of session is specific to Dolibarr instance. -$sessionname='DOLSESSID_'.md5($_SERVER["SERVER_NAME"].$_SERVER["DOCUMENT_ROOT"].$realpath); -$sessiontimeout='DOLSESSTIMEOUT_'.md5($_SERVER["SERVER_NAME"].$_SERVER["DOCUMENT_ROOT"].$realpath); -if (! empty($_COOKIE[$sessiontimeout])) ini_set('session.gc_maxlifetime',$_COOKIE[$sessiontimeout]); -session_name($sessionname); -session_start(); +require_once("../main.inc.php"); -include('../master.inc.php'); +// This destroy tag that say "Point of Sale session is on". +unset($_SESSION['uid']); -// Destroy session -$sessionname='DOLSESSID_'.md5($_SERVER["SERVER_NAME"].$_SERVER["DOCUMENT_ROOT"].$realpath); -$sessiontimeout='DOLSESSTIMEOUT_'.md5($_SERVER["SERVER_NAME"].$_SERVER["DOCUMENT_ROOT"].$realpath); -if (! empty($_COOKIE[$sessiontimeout])) ini_set('session.gc_maxlifetime',$_COOKIE[$sessiontimeout]); -session_name($sessionname); -session_destroy(); -dol_syslog("End of session ".$sessionname); +header ('Location: '.DOL_URL_ROOT.'/cashdesk/index.php'); +exit; - -header ('Location: index.php'); ?> \ No newline at end of file diff --git a/htdocs/cashdesk/facturation_dhtml.php b/htdocs/cashdesk/facturation_dhtml.php index 1e27a12141e..482299c4d93 100644 --- a/htdocs/cashdesk/facturation_dhtml.php +++ b/htdocs/cashdesk/facturation_dhtml.php @@ -36,7 +36,7 @@ if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); // Change this following line to use the correct relative path (../, ../../, etc) require("../main.inc.php"); -require(DOL_DOCUMENT_ROOT.'/cashdesk/include/environnement.php'); +require_once(DOL_DOCUMENT_ROOT.'/cashdesk/include/environnement.php'); //header("Content-type: text/html; charset=UTF-8"); header("Content-type: text/html; charset=".$conf->file->character_set_client); diff --git a/htdocs/cashdesk/facturation_verif.php b/htdocs/cashdesk/facturation_verif.php index 52d7bb254a7..b228a08f59b 100644 --- a/htdocs/cashdesk/facturation_verif.php +++ b/htdocs/cashdesk/facturation_verif.php @@ -17,9 +17,9 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -require ('../master.inc.php'); -require (DOL_DOCUMENT_ROOT.'/cashdesk/include/environnement.php'); -require (DOL_DOCUMENT_ROOT.'/cashdesk/class/Facturation.class.php'); +require('../main.inc.php'); +require_once(DOL_DOCUMENT_ROOT.'/cashdesk/include/environnement.php'); +require_once(DOL_DOCUMENT_ROOT.'/cashdesk/class/Facturation.class.php'); $obj_facturation = unserialize ($_SESSION['serObjFacturation']); unset ($_SESSION['serObjFacturation']); @@ -132,4 +132,6 @@ switch ( $_GET['action'] ) $_SESSION['serObjFacturation'] = serialize ($obj_facturation); header ('Location: '.$redirection); +exit; + ?> diff --git a/htdocs/cashdesk/include/environnement.php b/htdocs/cashdesk/include/environnement.php index 68bfb3d1c56..f898cd54acd 100644 --- a/htdocs/cashdesk/include/environnement.php +++ b/htdocs/cashdesk/include/environnement.php @@ -17,18 +17,8 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -// Add real path in session -$realpath=''; -if ( preg_match('/^([^.]+)\/htdocs\//i', realpath($_SERVER["SCRIPT_FILENAME"]), $regs)) $realpath = isset($regs[1])?$regs[1]:''; - -// Init session. Name of session is specific to Dolibarr instance. -$sessionname='DOLSESSID_'.md5($_SERVER["SERVER_NAME"].$_SERVER["DOCUMENT_ROOT"].$realpath); -$sessiontimeout='DOLSESSTIMEOUT_'.md5($_SERVER["SERVER_NAME"].$_SERVER["DOCUMENT_ROOT"].$realpath); -if (! empty($_COOKIE[$sessiontimeout])) ini_set('session.gc_maxlifetime',$_COOKIE[$sessiontimeout]); -session_name($sessionname); -session_start(); -dol_syslog("Start session name=".$sessionname." Session id()=".session_id().", _SESSION['dol_login']=".$_SESSION["dol_login"].", ".ini_get("session.gc_maxlifetime")); - +// This file initializes more variables to already initialized variables with main.inc.php +// So include of this file must be always done after include to main.inc.php $conf_db_type = $dolibarr_main_db_type; diff --git a/htdocs/cashdesk/index.php b/htdocs/cashdesk/index.php index 67f0bf8485c..5a5389c0a85 100644 --- a/htdocs/cashdesk/index.php +++ b/htdocs/cashdesk/index.php @@ -23,25 +23,11 @@ * \version $Id$ */ -// This is to make Dolibarr working with Plesk -set_include_path($_SERVER['DOCUMENT_ROOT'].'/htdocs'); - -// Add real path in session -$realpath=''; -if ( preg_match('/^([^.]+)\/htdocs\//i', realpath($_SERVER["SCRIPT_FILENAME"]), $regs)) $realpath = isset($regs[1])?$regs[1]:''; - -// Init session. Name of session is specific to Dolibarr instance. -$sessionname='DOLSESSID_'.md5($_SERVER["SERVER_NAME"].$_SERVER["DOCUMENT_ROOT"].$realpath); -$sessiontimeout='DOLSESSTIMEOUT_'.md5($_SERVER["SERVER_NAME"].$_SERVER["DOCUMENT_ROOT"].$realpath); -if (! empty($_COOKIE[$sessiontimeout])) ini_set('session.gc_maxlifetime',$_COOKIE[$sessiontimeout]); -session_name($sessionname); -session_start(); - // Set and init common variables // This include will set: config file variable $dolibarr_xxx, $conf, $langs and $mysoc objects -require_once("../master.inc.php"); - +require_once("../main.inc.php"); +// Test if user logged if ( $_SESSION['uid'] > 0 ) { header ('Location: '.DOL_URL_ROOT.'/cashdesk/affIndex.php'); diff --git a/htdocs/cashdesk/index_verif.php b/htdocs/cashdesk/index_verif.php index aa66cd77f0b..3beefafa6ec 100644 --- a/htdocs/cashdesk/index_verif.php +++ b/htdocs/cashdesk/index_verif.php @@ -20,9 +20,9 @@ * We set here login choices into session. */ -include('../master.inc.php'); -require('include/environnement.php'); -require('class/Auth.class.php'); +include('../main.inc.php'); +require_once(DOL_DOCUMENT_ROOT.'/cashdesk/include/environnement.php'); +require_once(DOL_DOCUMENT_ROOT.'/cashdesk/class/Auth.class.php'); $langs->load("main"); diff --git a/htdocs/cashdesk/validation_ticket.php b/htdocs/cashdesk/validation_ticket.php index 9beb68dac43..8502642f5db 100644 --- a/htdocs/cashdesk/validation_ticket.php +++ b/htdocs/cashdesk/validation_ticket.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2007-2008 Jeremie Ollivier * * 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 diff --git a/htdocs/cashdesk/validation_verif.php b/htdocs/cashdesk/validation_verif.php index aaa9cdc3755..caee15aa890 100644 --- a/htdocs/cashdesk/validation_verif.php +++ b/htdocs/cashdesk/validation_verif.php @@ -17,14 +17,14 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -require ('../master.inc.php'); -require (DOL_DOCUMENT_ROOT.'/cashdesk/include/environnement.php'); -require (DOL_DOCUMENT_ROOT.'/cashdesk/class/Facturation.class.php'); -require (DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'); -require (DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'); -require (DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'); +require('../main.inc.php'); +require_once(DOL_DOCUMENT_ROOT.'/cashdesk/include/environnement.php'); +require_once(DOL_DOCUMENT_ROOT.'/cashdesk/class/Facturation.class.php'); +require_once(DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'); +require_once(DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'); +require_once(DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'); -$obj_facturation = unserialize ($_SESSION['serObjFacturation']); +$obj_facturation = unserialize($_SESSION['serObjFacturation']); unset ($_SESSION['serObjFacturation']); switch ( $_GET['action'] )