Source for file index.php
Documentation is available at index.php
* Fichier racine - porte d'entrée principale du site
* Ce fichier permet de faire appel aux différentes entités (documents), via leur id, leur
* identifier (lien permanent). Il permet aussi d'appeler un template particulier (via l'argument
* Voici des exemples d'utilisations
* index.php?/histoire/france/charlemagne-le-pieux
* index.php?do=view&idtype=2
* LODEL - Logiciel d'Edition ELectronique.
* Copyright (c) 2001-2002, Ghislain Picard, Marin Dacos
* Copyright (c) 2003, Ghislain Picard, Marin Dacos, Luc Santeramo, Nicolas Nutten, Anne Gentil-Beccot
* Copyright (c) 2004, Ghislain Picard, Marin Dacos, Luc Santeramo, Anne Gentil-Beccot, Bruno Cénou
* Copyright (c) 2005, Ghislain Picard, Marin Dacos, Luc Santeramo, Gautier Poupeau, Jean Lamy, Bruno Cénou
* Copyright (c) 2006, Marin Dacos, Luc Santeramo, Bruno Cénou, Jean Lamy, Mikaël Cixous, Sophie Malafosse
* Copyright (c) 2007, Marin Dacos, Bruno Cénou, Sophie Malafosse, Pierre-Alain Mignot
* Home page: http://www.lodel.org
* E-Mail: lodel@lodel.org
* 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., 675 Mass Ave, Cambridge, MA 02139, USA.
* @author Ghislain Picard
* @copyright 2005, Ghislain Picard, Marin Dacos, Luc Santeramo, Gautier Poupeau, Jean Lamy, Bruno Cénou
* @copyright 2006, Marin Dacos, Luc Santeramo, Bruno Cénou, Jean Lamy, Mikaël Cixous, Sophie Malafosse
* @copyright 2007, Marin Dacos, Bruno Cénou, Sophie Malafosse, Pierre-Alain Mignot
* @licence http://www.gnu.org/copyleft/gpl.html
require 'siteconfig.php';
// vérifie l'intégrité de l'url demandée
if('path' != URI && preg_match("/^". preg_quote($urlroot. $site, '/'). "\/(index|signaler|backend|logout|oai|search)(\d*)\.$extensionscripts(\?[^\/]*)?(\/.*)$/", $_SERVER['REQUEST_URI'])> 0) {
header("HTTP/1.0 403 Bad Request");
header("Status: 403 Bad Request");
include "../missing.html";
//gestion de l'authentification
// record the url if logged
if(empty($_POST)) { // pas d'utilisation du cache pour traiter correctement les formulaires
// get the view and check the cache.
if ($view->renderIfCacheIsValid()) {
// require 'textfunc.php';
$identifier = $_GET['identifier'];
$page = $_GET['page']; // get only
$do = $_POST['do'] ? $_POST['do'] : $_GET['do'];
$tpl = 'index'; // template by default.
// require_once 'connect.php';
require_once 'loginfunc.php';
$context['error_login'] = $err = 1;
//vérifie que le compte n'est pas en suspend. Si c'est le cas, on amène l'utilisateur à modifier son mdp, sinon on l'identifie
$context['error_expiration'] = $err = 1;
unset ($context['lodeluser']);
$context[$err] = $err = 1;
$context['passwd'] = $passwd = 0;
if($err) // une erreur : besoin de l'afficher, donc pas d'utilisation du cache
$_REQUEST['clearcache'] = 1;
if ($id || $identifier) {
// require_once 'connect.php';
$class = $db->getOne(lq("SELECT class FROM #_TP_objects WHERE id='$id'"));
header("HTTP/1.0 403 Internal Error");
header("Status: 403 Internal Error");
include $home. "../../missing.html";
header('Location: not-found.html');
$result = $db->execute(lq("SELECT * FROM #_TP_". $class. " WHERE id='". $id. "' AND status>0")) or dberror();
$context['type'] = $result->fields;
$view->renderCached($context, $result->fields['tplindex']);
} elseif ($page) { // call a special page (and template)
// require_once 'connect.php';
$view->renderCached($context, $page);
//Appel d'une action via le model MVC
if ($do == 'edit' || $do == 'view') {
if($_GET) {// to be sure nobody is going to modify something wrong
// check for the right to change this document
$idtype = $_POST['idtype'] ? intval($_POST['idtype']) : intval($_GET['idtype']) ;
die('ERROR: idtype must be given');
$vo = $dao->find("id='$idtype' and public>0 and status>0");
die("ERROR: you are not allow to add this kind of document");
$lodeluser['editor'] = 1;
$context['lodeluser'] = $lodeluser;
$accepted_logic = array('entities_edition');
$called_logic = 'entities_edition';
$Controler = new controler($accepted_logic, $called_logic);
die('ERROR: unknown action');
//tente de récupérer le path - parse la query string pour trouver l'entité
// require_once 'connect.php';
$query = preg_replace("/[&?](format|clearcache)=\w+/", '', $_SERVER['QUERY_STRING']);
if($query && !preg_match("/[^a-zA-Z0-9_\/-]/", $query)) {
// maybe a path to the document
$path = preg_split("#/#", $query, - 1, PREG_SPLIT_NO_EMPTY);
$view->renderCached($context, 'index');
* Affiche une entité grâce à son id, son identifiant. Appelle la vue associée
* @param integer $id identifiant de l'entité
* @param string $identifier l'identifiant littéral de l'entité
* @param array &$context le contexte par référence
global $lodeluser, $home, $db;
$context['classtype'] = 'entities';
$critere = $lodeluser['visitor'] ? 'AND #_TP_entities.status>-64' : 'AND #_TP_entities.status>0 AND #_TP_types.status>0';
// cherche le document, et le template
$where = "#_TP_entities.identifier='". $identifier. "' ". $critere;
$where = "#_TP_entities.id='". $id. "' ". $critere;
$row = $db->getRow(lq("SELECT #_TP_entities.*,tpl,type,class FROM #_entitiestypesjoin_ WHERE ". $where));
header("HTTP/1.0 403 Internal Error");
header("Status: 403 Internal Error");
include $home. "../../missing.html";
header('Location: not-found.html');
$base = $row['tpl']; // le template à utiliser pour l'affichage
} while (!$base && !$identifier && $id);
$row = $db->getRow(lq("SELECT * FROM #_TP_". $row['class']. " WHERE identity='". $row['id']. "'"));
header("HTTP/1.0 403 Internal Error");
header("Status: 403 Internal Error");
include $home. "../../missing.html";
header('Location: not-found.html');
if (!(@include_once('CACHE/filterfunc.php'))) {
require_once 'filterfunc.php';
//Merge $row et applique les filtres définis dans le ME
merge_and_filter_fields($context, $context['class'], $row);
getgenericfields($context); // met les champs génériques de l'entité dans le contexte
$view->renderCached($context, $base);
* Affichage d'un objet de type index
* @param integer $id identifiant numérique de l'index
* @param string $classtype type de la classe
* @param array &$context le context par référence
global $lodeluser, $home, $db;
$context['classtype'] = $classtype;
$typetable = '#_TP_persontypes';
$typetable = '#_TP_entrytypes';
die('ERROR: internal error in printIndex');
$critere = $lodeluser['visitor'] ? 'AND status>-64' : 'AND status>0';
$row = $db->getRow(lq("SELECT * FROM ". $table. " WHERE id='". $id. "' ". $critere));
header("HTTP/1.0 403 Internal Error");
header("Status: 403 Internal Error");
include $home. "../../missing.html";
header('Location: not-found.html');
$row = $db->getRow(lq("SELECT * FROM ". $typetable. " WHERE id='". $row['idtype']. "'". $critere));
header("HTTP/1.0 403 Internal Error");
header("Status: 403 Internal Error");
include $home. "../../missing.html";
header('Location: not-found.html');
// get the associated table
$row = $db->getRow(lq("SELECT * FROM #_TP_". $row['class']. " WHERE ". $longid. "='". $id. "'"));
die("ERROR: internal error");
if (!(@include_once("CACHE/filterfunc.php"))) {
require_once "filterfunc.php";
merge_and_filter_fields($context, $row['class'], $row);
#getgenericfields($context);
$view->renderCached($context, $base);
|