Hello boy,
i have a issue :
Why my framework function in “dashboard” directory but no in “public” ???
My index.php file in the “public” directory is :
/* inseriamo il file di configurazione del DB Connection */
require_once 'includes/db_conn.php';
/* richieste base del framework */
require_once '../vendor/autoload.php';
$app = new \Slim\Slim();
// file per l'autenticazione
require_once 'includes/authentication.php';
/* carico twig templates */
require_once '../vendor/twig/twig/lib/Twig/Autoloader.php';
Twig_Autoloader::register();
$loader = new Twig_Loader_Filesystem('../templates/public/');
$twig = new Twig_Environment($loader, array(
//'cache' => '../templates/dashboard/cache/',
);
/* includiamo tutti i file dentro la cartella includes */
require_once 'includes/load_all_files_be.php';
/* inizio procedure richieste */
/* pagina principale */
$app->get('/', $authenticate($app), function() use ($app) {
global $twig;
$db = getConnection();
echo $twig->render('not_active.php');
});
if i delete this : $authenticate($app)
in get of “pagine principale” it’s function… why ?
I think have a problem with authentication in “authenticate.php” file
<?php // codice per l'autenticazione $app->add(new \Slim\Middleware\SessionCookie(array( /*'expires' => '20 minutes', 'domain' => null, 'secure' => false, 'httponly' => false, 'name' => 'slim_session',*/ 'secret' => '123456, 'cipher' => MCRYPT_RIJNDAEL_256, 'cipher_mode' => MCRYPT_MODE_CBC*/ ))); //autenticazione in generele per accesso all'area di gestione/amministrazione sistema $authenticate = function ($app) { return function () use ($app) { if (!isset($_SESSION['username']) && !isset($_SESSION['userid'])) { //$_SESSION['urlRedirect'] = $app->request()->getPathInfo(); } else { $user_id = $_SESSION['userid']; $db = getConnection(); $type_user = $db->query("SELECT tipo_user, active FROM users WHERE id='$user_id'"); $t_user = $type_user->fetch(); $result = $t_user['active']; if ($result == 'no') { $app->redirect(WEB_ROOT_PUBLIC); } } }; }; I have solved this question. The authenticate procedure create a loop... i have modificed it. Thanks.