Mode maintenance en commentaire
This commit is contained in:
parent
fe0eb8f274
commit
333a524adb
8
config/update/update-sql-20110103.sql
Normal file
8
config/update/update-sql-20110103.sql
Normal file
@ -0,0 +1,8 @@
|
||||
CREATE TABLE IF NOT EXISTS `maintenance` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`mode` int(11) NOT NULL,
|
||||
`message` int(11) NOT NULL,
|
||||
`countMaintenance` int(11) NOT NULL,
|
||||
`dateEven` datetime NOT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1
|
93
includes/maintenance/maintenance.php
Normal file
93
includes/maintenance/maintenance.php
Normal file
@ -0,0 +1,93 @@
|
||||
<?php
|
||||
|
||||
function maintenanceActive()
|
||||
{
|
||||
if (!maintenanceMode()){
|
||||
$link = mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_PASS);
|
||||
if (!$link) {
|
||||
return false;
|
||||
}
|
||||
$sql = "INSERT INTO sdv1.maintenance (mode, countMaintenance, dateEven) ".
|
||||
"VALUES (1, 0, '".date('Y-m-d H:i:s')."')";
|
||||
if (mysql_query($sql, $link)){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function maintenanceDesactive()
|
||||
{
|
||||
if(maintenanceMode()){
|
||||
$link = mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_PASS);
|
||||
if (!$link) {
|
||||
return false;
|
||||
}
|
||||
$sql = "INSERT INTO sdv1.maintenance (mode, countMaintenance, dateEven) ".
|
||||
"VALUES (0, 0, '".date('Y-m-d H:i:s')."')";
|
||||
if (mysql_query($sql, $link)){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function maintenanceMode($error = false)
|
||||
{
|
||||
$countEvenMax = 70;
|
||||
$link = mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_PASS);
|
||||
if (!$link) {
|
||||
return false;
|
||||
}
|
||||
$sql = 'SELECT * FROM sdv1.maintenance ORDER BY dateEven DESC, LIMIT 1';
|
||||
$result = mysql_query($sql, $link);
|
||||
if (!$result) {
|
||||
return false;
|
||||
}
|
||||
if (mysql_num_rows($result) == 0){
|
||||
return false;
|
||||
}
|
||||
$info = mysql_fetch_assoc($result);
|
||||
if ($info[0]['countMaintenance']>=$countEventMax || $info[0]['mode']==1){
|
||||
if ($error &&
|
||||
$info[0]['countMaintenance']>=$countEventMax && $info[0]['mode']==0)
|
||||
{
|
||||
$sql = "UPDATE sdv1.maintenance SET mode=1, ".
|
||||
"dateEven=".date('Y-m-d H:i:s').
|
||||
" WHERE ".$info[0]['id'];
|
||||
if (mysql_query($sql, $link)){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function maintenanceIncrement()
|
||||
{
|
||||
$link = mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_PASS);
|
||||
if (!$link) {
|
||||
return false;
|
||||
}
|
||||
$sql = 'SELECT id FROM sdv1.maintenance ORDER BY dateEven DESC, LIMIT 1';
|
||||
$result = mysql_query($sql, $link);
|
||||
if (!$result) {
|
||||
return false;
|
||||
}
|
||||
if (mysql_num_rows($result)==0){
|
||||
$sql = "INSERT INTO sdv1.maintenance (mode, countMaintenance, dateEven) ".
|
||||
"VALUES (0, 0, '".date('Y-m-d H:i:s')."')";
|
||||
$result = mysql_query($sql, $link);
|
||||
}
|
||||
$info = mysql_fetch_assoc($result);
|
||||
$sql = "UPDATE sdv1.maintenance SET countMaintenance=countMaintenance+1, ".
|
||||
"dateEven=".date('Y-m-d H:i:s');
|
||||
" WHERE ".$info[0]['id'];
|
||||
if (mysql_query($sql, $link)){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -20,6 +20,8 @@ function processSoapFault($clientSoap, $fault, $tabInfo, $debug = FALSE){
|
||||
|
||||
global $firephp;
|
||||
|
||||
//maintenanceMode(true);
|
||||
|
||||
$message = 'Request : '. $clientSoap->__getLastRequest() . '\n\n' .
|
||||
'Response : '.$clientSoap->__getLastResponse() . '\n\n';
|
||||
|
||||
|
@ -7,6 +7,7 @@ require_once '../config/prepend.php';
|
||||
require_once 'index.fct.php';
|
||||
require_once 'fwk.php';
|
||||
require_once 'default/_includes/mysql.php';
|
||||
require_once 'maintenance/maintenance.php';
|
||||
require_once 'index_auth.php';
|
||||
require_once 'user/user.php';
|
||||
|
||||
|
@ -1,5 +1,10 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
if (maintenanceMode()) {
|
||||
require_once 'maintenance.php';
|
||||
exit;
|
||||
}
|
||||
*/
|
||||
$cle_cookie = 'sdjglsdkhmsoL68';
|
||||
|
||||
// Connection Login/IP
|
||||
@ -241,6 +246,8 @@ if ((isset($_REQUEST['action']) && $_REQUEST['action'] == 'logon') ||
|
||||
//Erreur SOAP
|
||||
catch (SoapFault $fault)
|
||||
{
|
||||
//maintenanceMode(true);
|
||||
|
||||
if($fault->faultcode!='900')
|
||||
{
|
||||
require_once 'soaperror.php';
|
||||
|
@ -1,3 +1,3 @@
|
||||
<?php
|
||||
header('Location: '.EXTRANET_URL.'?page=main&action=logon&login=testreunica&checkIp=only');
|
||||
header('Location: '.EXTRANET_URL.'?page=main&action=logon&login=testreunica&checkIp=only');
|
||||
?>
|
39
www/maintenance.php
Normal file
39
www/maintenance.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
/*
|
||||
Si la page est appellée directement avec les paramètres suivant
|
||||
|
||||
Placer en mode maintenance // toujours avant que cela ne fonctionne plus ?
|
||||
maintenance.php?active&login=user&pass=password
|
||||
|
||||
Supprimer le mode maintenance
|
||||
maintenance.php?desactive&login=user&pass=password
|
||||
|
||||
*/
|
||||
|
||||
//Affichage message de maintenance
|
||||
$title = "Maintenance";
|
||||
?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr" dir="ltr">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=<?=CHARSET?>" />
|
||||
<title>Extranet Scores & Décisions - <?=$title?></title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="container">
|
||||
<div id="left"></div>
|
||||
<div id="content">
|
||||
<div id="page">
|
||||
<div id="center">
|
||||
Maintenance en cours...<br/>
|
||||
Le service est momentanément indisponible.<br/>
|
||||
</div>
|
||||
<div id="footer">
|
||||
<?php include('pagefooter.php');?>
|
||||
</div>
|
||||
</div> <!-- //page -->
|
||||
</div> <!-- //content -->
|
||||
</div> <!-- //container -->
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user