index.php 1.22 KB
<?php


define('BASEURL', dirname($_SERVER['SCRIPT_NAME']));

 ob_start();

 // Afficher les erreurs à l'écran
ini_set('display_errors', 1);
// Enregistrer les erreurs dans un fichier de log
ini_set('log_errors', 1);
// Nom du fichier qui enregistre les logs (attention aux droits à l'écriture)
ini_set('error_log', dirname(__file__) . '/log_error_php.txt');
// Afficher les erreurs et les avertissements
//error_reporting(e_all);

include 'struct.php';

//$db= structFunctions::load_histogram_db();


if(isset($_SERVER['PATH_INFO'])) {

	$args = explode('/', $_SERVER['PATH_INFO']);
	$found = false;
	if(count($args) >= 3) {
		$controller = $args[1];
		$method = $args[2];
		$params = array();
		for ($i=3; $i < count($args); $i++) {
			$params[] = $args[$i];
		}
		$controller_file = dirname(__FILE__).'/controller/rssi_'.$controller.'.php';
		if (is_file($controller_file)) {
			require_once $controller_file;
			$controller_name = 'Controller_'.ucfirst($controller);
			if (class_exists($controller_name)) {
				$c = new $controller_name;
				if (method_exists($c, $method)) {
					$found = true;
					call_user_func_array(array($c, $method), $params);
				}
			}
		}
	}

	if (!$found) {
		//echo print_r($db);
		echo 'not found';
	}
}
?>