Subversion Repositories eFlore/Applications.del

Rev

Rev 700 | Rev 1567 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 700 Rev 1564
1
<?php
1
<?php
2
// Encodage : UTF-8
2
// Encodage : UTF-8
3
// Permet d'afficher le temps d'execution du service
3
// Permet d'afficher le temps d'execution du service
4
$temps_debut = (isset($_GET['chrono']) && $_GET['chrono'] == 1) ? microtime(true) : '';
4
$temps_debut = (isset($_GET['chrono']) && $_GET['chrono'] == 1) ? microtime(true) : '';
5
// +-------------------------------------------------------------------------------------------------------------------+
5
// +-------------------------------------------------------------------------------------------------------------------+
6
/**
6
/**
7
* Serveur
7
* Serveur
8
*
8
*
9
* Description : initialise le chargement et l'exécution des services web.
9
* Description : initialise le chargement et l'exécution des services web.
10
*
10
*
11
//Auteur original :
11
//Auteur original :
12
* @author       auteur <aut@tela-botanica.org>
12
* @author       auteur <aut@tela-botanica.org>
13
* @copyright    Tela-Botanica 1999-2008
13
* @copyright    Tela-Botanica 1999-2008
14
* @licence      GPL v3 & CeCILL v2
14
* @licence      GPL v3 & CeCILL v2
15
* @version      $Id$
15
* @version      $Id$
16
*/
16
*/
17
// +-------------------------------------------------------------------------------------------------------------------+
17
// +-------------------------------------------------------------------------------------------------------------------+
-
 
18
 
-
 
19
// Autoloader pour les namespaces, à base de routes
-
 
20
function __autoload($nom_classe) {
-
 
21
	//echo "AUTOLOAD\n";
-
 
22
	$dernierAS = strrpos($nom_classe, "\\");
-
 
23
	$ns = substr($nom_classe, 0, $dernierAS);
-
 
24
	$nom = substr($nom_classe, strrpos($nom_classe, "\\") + 1);
-
 
25
	//echo "Recherche : $nom / $ns\n";
-
 
26
	// Routes selon les namespaces
-
 
27
	$routes = array(
-
 
28
			'TelaBotanica\Del\Commun' => '..' . DS . 'commun'
-
 
29
	);
-
 
30
	if (array_key_exists($ns, $routes)) {
-
 
31
		//echo "Route trouvée: " . $routes[$ns] . "\n";
-
 
32
		$fichier_a_inclure = dirname(__FILE__) . DS . $routes[$ns] . DS . $nom . '.php';
-
 
33
		if (file_exists($fichier_a_inclure)) {
-
 
34
			include_once $fichier_a_inclure;
-
 
35
			return null;
-
 
36
		}
-
 
37
	}
-
 
38
}
18
 
39
 
19
// Le fichier autoload.inc.php du Framework de Tela Botanica doit être appelée avant tout autre chose dans l'application.
40
// Le fichier autoload.inc.php du Framework de Tela Botanica doit être appelée avant tout autre chose dans l'application.
20
// Sinon, rien ne sera chargé.
41
// Sinon, rien ne sera chargé.
21
// Chemin du fichier chargeant le framework requis
42
// Chemin du fichier chargeant le framework requis
22
$framework = dirname(__FILE__).DIRECTORY_SEPARATOR.'framework.php';
43
$framework = dirname(__FILE__).DIRECTORY_SEPARATOR.'framework.php';
23
if (!file_exists($framework)) {
44
if (!file_exists($framework)) {
24
    $e = "Veuillez paramétrer l'emplacement et la version du Framework dans le fichier $framework";
45
    $e = "Veuillez paramétrer l'emplacement et la version du Framework dans le fichier $framework";
25
    trigger_error($e, E_USER_ERROR);
46
    trigger_error($e, E_USER_ERROR);
26
} else {
47
} else {
27
    // Inclusion du Framework
48
    // Inclusion du Framework
28
    require_once $framework;
49
    require_once $framework;
29
    // Ajout d'information concernant cette application
50
    // Ajout d'information concernant cette application
30
    Framework::setCheminAppli(__FILE__);// Obligatoire
51
    Framework::setCheminAppli(__FILE__);// Obligatoire
31
    Framework::setInfoAppli(Config::get('info'));
52
    Framework::setInfoAppli(Config::get('info'));
32
   
53
 
33
    // Initialisation et lancement du serveur
54
    // Initialisation et lancement du serveur
34
    $Serveur = new RestServeur();
55
    $Serveur = new RestServeur();
35
    $Serveur->executer();
56
    $Serveur->executer();
36
   
57
   
37
    // Affiche le temps d'execution du service
58
    // Affiche le temps d'execution du service
38
    if (isset($_GET['chrono']) && $_GET['chrono'] == 1) {
59
    if (isset($_GET['chrono']) && $_GET['chrono'] == 1) {
39
        $temps_fin = microtime(true);
60
        $temps_fin = microtime(true);
40
        echo 'Temps d\'execution : '.round($temps_fin - $temps_debut, 4);
61
        echo 'Temps d\'execution : '.round($temps_fin - $temps_debut, 4);
41
    }
62
    }
42
}
63
}
43
?>
64
?>