Simplification des fichiers d'inclusions
This commit is contained in:
parent
c2afcadf0c
commit
288a87c184
@ -1,6 +1,5 @@
|
||||
<?php
|
||||
die();
|
||||
if( LOG_BENCH != 'NONE' )
|
||||
if ( LOG_BENCH != 'NONE')
|
||||
{
|
||||
$timer->setMarker('Fin du script (append.php)');
|
||||
$mem=memory_get_usage();
|
||||
@ -17,5 +16,4 @@ if( LOG_BENCH != 'NONE' )
|
||||
$timer->display();
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@ -11,13 +11,23 @@ ini_set('include_path',
|
||||
realpath(dirname(__FILE__) . '/../includes/')
|
||||
);
|
||||
|
||||
/**
|
||||
* Fonction globale récupérant le microtime de la machine en format float.
|
||||
* @return float Valeur courante du microtime() de la machine en format décimal
|
||||
*/
|
||||
function getmicrotime(){
|
||||
list($usec, $sec) = explode (' ', microtime());
|
||||
return ( (float)$sec + (float)$usec );
|
||||
require_once realpath(dirname(__FILE__)).'/config.inc';
|
||||
require_once 'debug/bench.php';
|
||||
|
||||
//Debuggage
|
||||
require_once 'FirePHPCore/FirePHP.class.php';
|
||||
ob_start();
|
||||
$firephp = FirePHP::getInstance(true);
|
||||
|
||||
if(ENVIRONNEMENT == 'PRD')
|
||||
{
|
||||
$firephp->setEnabled(false);
|
||||
ini_set('error_reporting', 0);
|
||||
}
|
||||
elseif(ENVIRONNEMENT == 'DEV')
|
||||
{
|
||||
$firephp->setEnabled(true); //Debuggage activé par defaut
|
||||
//ini_set('error_reporting', E_ALL ^ E_NOTICE);
|
||||
}
|
||||
|
||||
/** On ne prend l'heure qu'une seule fois par script PHP et on initialise des constantes.
|
||||
@ -38,105 +48,6 @@ define ('TODAY_FORMAT', substr(DATETIME,0,4).'-'.substr(DATETIME,4,2).'-'.substr
|
||||
define ('TODAY_AFF', substr(DATETIME,6,2).'/'.substr(DATETIME,4,2).'/'.substr(DATETIME,0,4));
|
||||
define ('NOW_FORMAT', substr(DATETIME,8,2).':'.substr(DATETIME,10,2).':'.substr(DATETIME,12,2));
|
||||
|
||||
/**
|
||||
* Les librairies suivantes sont chargées automatiquement car tous les scripts les utilisent !
|
||||
*/
|
||||
require_once 'phplib/db_mysql.inc';
|
||||
require_once 'auth/sessions.inc';
|
||||
require_once realpath(dirname(__FILE__)).'/config.inc';
|
||||
session_start();
|
||||
|
||||
//Debuggage
|
||||
require_once 'FirePHPCore/FirePHP.class.php';
|
||||
ob_start();
|
||||
$firephp = FirePHP::getInstance(true);
|
||||
|
||||
//Définition des options de configuration suivant le serveur
|
||||
if(ENVIRONNEMENT == 'PRD')
|
||||
{
|
||||
$firephp->setEnabled(false);
|
||||
ini_set('error_reporting', 0);
|
||||
}
|
||||
elseif(ENVIRONNEMENT == 'DEV')
|
||||
{
|
||||
$firephp->setEnabled(true); //Debuggage activé par defaut
|
||||
//ini_set('error_reporting', E_ALL ^ E_NOTICE);
|
||||
}
|
||||
|
||||
if ( LOG_BENCH != 'NONE' ){
|
||||
include_once ('Benchmark/Timer.php');
|
||||
}else{
|
||||
class Benchmark_Timer
|
||||
{
|
||||
function start() {}
|
||||
function setMarker() {}
|
||||
function stop() {}
|
||||
function getProfiling() {}
|
||||
function display() {}
|
||||
}
|
||||
}
|
||||
|
||||
/* @todo: A enlever pour la prod
|
||||
$timer = new Benchmark_Timer();
|
||||
$timer->start();
|
||||
$timer->setMarker('Debut du script (prepend.php)');
|
||||
*/
|
||||
|
||||
/** Instance de la connexion à la base de données
|
||||
* Cette instance est utilisée par tous les scripts pour accéder à la base de données
|
||||
*/
|
||||
|
||||
class DB extends DB_MySQL
|
||||
{
|
||||
function DB() {
|
||||
$this->Host = MYSQL_HOST;
|
||||
$this->Database = MYSQL_DB;
|
||||
$this->User = MYSQL_USER;
|
||||
$this->Password = MYSQL_PASS;
|
||||
}
|
||||
|
||||
function getRow() {
|
||||
$ret= $this->Record;
|
||||
for( $i= 0; $i<count($this->Record); $i++ ) { if( !isset($ret[$i]) ) break; unset($ret[$i]); }
|
||||
return $ret;
|
||||
}
|
||||
|
||||
function query($q) {
|
||||
if ( LOG_MYSQL != 'NONE' ) $time_start=getmicrotime();
|
||||
|
||||
$ret=DB_MySQL::query($q);
|
||||
|
||||
if ( LOG_MYSQL == 'NONE' ) return $ret;
|
||||
|
||||
$time_end= getmicrotime();
|
||||
$time_total= $time_end-$time_start;
|
||||
$time_total= substr((string)$time_total,0,10);
|
||||
$now= date('Y/m/d H:i:s', $time_start);
|
||||
if ($ret<1)
|
||||
$mysqlerror = mysql_errno() .' : '. mysql_error();
|
||||
else
|
||||
$mysqlerror = '';
|
||||
|
||||
$sqlAction=strtoupper(substr(trim($q),0,6));
|
||||
if ( LOG_MYSQL=='SELECT' && $sqlAction=='SELECT' )
|
||||
$logOption='_select';
|
||||
elseif ( LOG_MYSQL=='UPDATE' && ( $sqlAction=='UPDATE' || $sqlAction=='INSERT' || $sqlAction=='DELETE' ) )
|
||||
$logOption='_update';
|
||||
else
|
||||
$logOption='';
|
||||
|
||||
$fh=@fopen( PATH_LOGS . 'db_mysql'.$logOption.'.log', 'a+');
|
||||
if ($fh) {
|
||||
@fwrite($fh, "$now\t$time_total\t" . MYSQL_HOST ."\t". MYSQL_USER ."\t". MYSQL_DB ."\t$mysqlerror\t$q\r\n");
|
||||
@fclose($fh);
|
||||
}
|
||||
|
||||
$mySqlErrTab=explode(' : ', $mysqlerror);
|
||||
$mySqlErrno=(int)$mySqlErrTab[0];
|
||||
if ( $mySqlErrno > 0 && $mySqlErrno !=1062 ) {
|
||||
// mail_admin( 'Erreur MySQL '.$mySqlErrno, $mysqlerror ."\n\n". $q );
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
?>
|
Loading…
Reference in New Issue
Block a user