Commit 1343b8c3 authored by Skia's avatar Skia

Fix some PHP errors

parent a9ffcaa2
......@@ -208,7 +208,7 @@ if ( count($cts->wiki->index["childs"]) )
foreach($itm["childs"] as $sitm)
{
if (count($sitm["childs"]) )
$lst->add(make_index(&$sitm));
$lst->add(make_index($sitm));
else
$lst->add("<a href=\"#".$sitm["ancre"]."\">".$sitm["title"]."</a>");
}
......
......@@ -30,7 +30,9 @@ class cachedcontents extends stdcontents
public function is_cached()
{
return $this->redis->exists($this->uid) && !isset($_GET["__nocache"]);
if($this->redis != NULL)
return $this->redis->exists($this->uid) && !isset($_GET["__nocache"]);
return false;
}
public function get_cache()
......@@ -55,35 +57,44 @@ class cachedcontents extends stdcontents
$this->title = $contents->title;
$this->buffer = "<!-- C".date ("d/m/Y H:i:s")." -->".$contents->html_render();
if($contents->is_cachable())
if($contents->is_cachable() && $this->redis != NULL)
$this->redis->set ($this->uid, $this->title."\n".$this->buffer);
return $this;
}
public function set_contents_timeout ( &$contents, $timestamp )
{
$this->set_contents ($contents);
$this->redis->expireAt ($this->uid, $timestamp);
return $this;
if($this->redis != NULL) {
$this->set_contents ($contents);
$this->redis->expireAt ($this->uid, $timestamp);
return $this;
} else {
return false;
}
}
public function set_contents_until ( &$contents, $seconds )
{
$this->set_contents ($contents);
$this->redis->expire ($this->uid, $seconds);
return $this;
if($this->redis != NULL) {
$this->set_contents ($contents);
$this->redis->expire ($this->uid, $seconds);
return $this;
} else {
return false;
}
}
private function get_redis_instance ()
{
$redis = redis_open_connection ();
$redis->select (1);
return $redis;
}
/**
if($redis != NULL)
$redis->select (1);
return $redis;
}
/**
* Mise en cache automatique d'un stdcontent générant son code HTML uniquement
* lors de l'appel à html_render().
* C'est aussi un bon exemple de l'usage de cachedcontents.
......
......@@ -65,7 +65,7 @@ class calendar extends stdcontents
$this->db = $db;
$this->subclass=$subclass;
/* Si les paramètres temporels sont donnés, on les utilise */
if ($_GET['caldate'] != "")
if (isset($_GET['caldate']) && $_GET['caldate'] != "")
$this->date = strtotime($_GET['caldate']);
/* Sinon, on prend le timestamp courant */
......
......@@ -42,6 +42,13 @@ $conf=array(
'htmlok'=>false
);
$timing=array(
'all'=>0,
'site::start_page'=>0,
'render'=>0,
'mysql'=>0,
'mysql.counter'=>0);
/** Convertit la date en une chaîne human readable
*
......
......@@ -28,7 +28,8 @@
* 02111-1307, USA.
*/
$timing["all"] -= microtime(true);
if (isset($timing["all"])) $timing["all"] -= microtime(true);
else $timing["all"] = 0;
setlocale(LC_ALL, "fr_FR.UTF8");
......@@ -748,7 +749,7 @@ class interfaceweb
if ($this->get_param("backup_server", true)) {
$this->buffer .= "<div id=\"topalert\">";
$this->buffer .= "<img width=\"16\" height=\"16\" src=\"" . $wwwtopdir . "themes/default/images/exclamation.png\" />";
$this->buffer .= "Le système fonctionne actuellement sur le serveur de secours, " .
$this->buffer .= "Le système fonctionne actuellement en mode minimaliste, " .
"veuillez limiter vos actions au strict minimum.";
$this->buffer .= "</div>";
} elseif ($this->get_param("warning_enabled", true)) {
......@@ -868,7 +869,8 @@ class interfaceweb
while (list($id, $name) = $req->get_row())
$this->params[$id] = $name;
$this->params["backup_server"] = serialize($_SERVER["BACKUP_AE_SERVER"]);
if(isset($_SERVER["BACKUP_AE_SERVER"]))
$this->params["backup_server"] = serialize($_SERVER["BACKUP_AE_SERVER"]);
}
/**
......
<?php
/* Copyright 2011
* - Jeremie Laval <jeremie dot laval at gmail dot com>
/* Copyright 2012
* - Antoine Tenart <atenart at n0 dot pe>
*
* Ce fichier fait partie du site de l'Association des Étudiants de
* l'UTBM, http://ae.utbm.fr
......@@ -21,12 +21,20 @@
* 02111-1307, USA.
*/
require_once("globals.inc.php");
function redis_open_connection ()
{
$redis = new Redis ();
$redis->pconnect ('192.168.2.219');
$redis->auth ('plsqc');
return $redis;
try {
$redis = new Redis ();
$redis->pconnect ('192.168.2.219');
$redis->auth ('plsqc');
return $redis;
} catch (Exception $e) {
if($GLOBALS['taiste'])
echo $e;
return NULL;
}
}
?>
......@@ -21,12 +21,20 @@
* 02111-1307, USA.
*/
require_once("globals.inc.php");
function redis_open_connection ()
{
$redis = new Redis ();
$redis->pconnect ('192.168.2.219');
$redis->auth ('mdp_redis');
return $redis;
try {
$redis = new Redis ();
$redis->pconnect ('192.168.2.219');
$redis->auth ('mdp_redis');
return $redis;
} catch (Exception $e) {
if($GLOBALS['taiste'])
echo $e;
return NULL;
}
}
?>
......@@ -56,7 +56,8 @@ class site extends interfaceweb
{
global $timing;
$timing["includes"] = microtime(true)+$timing["all"];
$timing["site::site"] -= microtime(true);
if(isset($timing["site::site"])) $timing["site::site"] -= microtime(true);
else $timing["site::site"] = 0;
$this->siteae=$siteae;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment