Hi guys again,
i try again with another question, i get this error:“Error
A website error has occurred. The website administrator has been notified of the issue. Sorry for the temporary inconvenience.”.
How i can fix it please?
Thanks in advance
Test site link:https://ghhh.000webhostapp.com/
You will need to have a look at your web server’s error log to find the error message.
thank you sir for your time but i don’t find any log file and i try it too with wampserver and the error persist.
exception ‘RuntimeException’ with message ‘View cannot render login.php
because the template does not exist’ in C:\wamp64\www\vendor\slim\slim\Slim\View.php:272
Stack trace:
#0 C:\wamp64\www\vendor\slim\slim\Slim\View.php(255): Slim\View->render(‘login.php’, NULL)
#1 C:\wamp64\www\vendor\slim\slim\Slim\View.php(243): Slim\View->fetch(‘login.php’, NULL)
#2 C:\wamp64\www\vendor\slim\slim\Slim\Slim.php(755): Slim\View->display(‘login.php’)
#3 C:\wamp64\www\index.php(113): Slim\Slim->render(‘login.php’)
#4 [internal function]: {closure}()
#5 C:\wamp64\www\vendor\slim\slim\Slim\Route.php(468): call_user_func_array(Object(Closure), Array)
#6 C:\wamp64\www\vendor\slim\slim\Slim\Slim.php(1355): Slim\Route->dispatch()
#7 C:\wamp64\www\vendor\slim\slim\Slim\Middleware\Flash.php(85): Slim\Slim->call()
#8 C:\wamp64\www\vendor\slim\slim\Slim\Middleware\MethodOverride.php(92): Slim\Middleware\Flash->call()
#9 C:\wamp64\www\vendor\slim\slim\Slim\Middleware\SessionCookie.php(110): Slim\Middleware\MethodOverride->call()
#10 C:\wamp64\www\vendor\slim\slim\Slim\Middleware\ContentTypes.php(81): Slim\Middleware\SessionCookie->call()
#11 C:\wamp64\www\vendor\slim\slim\Slim\Slim.php(1300): Slim\Middleware\ContentTypes->call()
#12 C:\wamp64\www\index.php(154): Slim\Slim->run()
#13 {main}
That is the first place I’d look. According to the trace, on line 113 of C:\wamp64\www\index.php
you are calling ->render('login.php') but that file doesn't exist at that location. You will need to move your
login.php` file or change where you are telling it to look.
[details=Summary]<?php
require ‘/vendor/autoload.php’;
require ‘/config.php’;
use lib\Core;
use Gregwar\Captcha\CaptchaBuilder;
/**
-
@var PDO
/
$core = Core::getInstance();
/ - TODO guarda la struttura di https://github.com/slimphp/Slim-Skeleton/blob/master/public/index.php
- per spezzettare sto file eccessivamente ciccione
/
/*
*/
//$logWriter = new \Slim\LogWriter(fopen(’/var/www/html/slimlog’, ‘a’));
/**
-
@var $app \Slim\Slim
*/
$app = new \Slim\Slim(array(
‘debug’ => false,
‘log.enabled’ => true,
‘templates.path’ => ‘/templates’,
// ‘log.writer’ => $logWriter
’mode’ => ‘production’
));
$builder = new CaptchaBuilder;
$app->add(new \Slim\Middleware\SessionCookie(array(‘secret’ => ‘myappsecret’, ‘expires’ => ‘30 minutes’)));
$app->add(new \Slim\Middleware\ContentTypes());
const ROUTE_DIR = ‘/routes/’;
/**
- @param $app \Slim\Slim
-
@return Closure
*/
$authenticate = function ($app) {
return function () use ($app) {
if (!isset($_SESSION[‘id’])) {
$_SESSION[‘urlRedirect’] = $app->request()->getPathInfo();
if (in_array($_SESSION[‘urlRedirect’], array("/test", “/elenco-risultati”, “/test-attivi”, “/single-test-prepare1”, “/single-test-prepare2”, “/pretest1”, “/pretest2”,"/single-test", “/single-test-captcha”)))
$_SESSION[‘urlRedirect’] = ‘/’;
$app->flash(‘error’, ‘Login required’);
$app->redirect(’/login’);
}
};
};
/**
- @param $app \Slim\Slim
-
@return Closure
*/
$authenticateAdmin = function ($app) {
return function () use ($app) {
if (!isset($_SESSION[‘admin’])) {
$app->redirect(’/’);
} else {
if ($_SESSION[‘admin’] == false) {
$app->redirect(’/’);
}
}
};
};
$app->hook(‘slim.before.dispatch’, function() use ($app) {
$user = null;
if (isset($_SESSION[‘user’])) {
$user = $_SESSION[‘user’];
}
$app->view()->setData(‘user’, $user);
});
$app->get("/", function () use ($app, $core) {
if (isset($_SESSION[‘codice’]))
unset($_SESSION[‘codice’]);
if (isset($_SESSION[‘codiceazienda’]))
unset($_SESSION[‘codiceazienda’]);
try {
$sql = "SELECT value FROM `impostazioni` WHERE name = 'tsecp'";
$stmt = $core->dbh->prepare($sql);
if($stmt->execute()) {
$tsecp = $stmt->fetch(PDO::FETCH_ASSOC);
if(!empty($tsecp)) {
$var = doubleval($tsecp['value']);
$_SESSION['tsecp'] = $var;
}
}
} catch (PDOException $e) {
$errore = array('errore' => $e->getMessage());
$app->render('errore_db.php', $errore);
}
try {
$sql = "SELECT * FROM `impostazioni` WHERE type = 2";
$stmt = $core->dbh->prepare($sql);
if($stmt->execute()) {
$row = $stmt->fetchAll(PDO::FETCH_ASSOC);
foreach ($row as $_row) {
$_SESSION[$_row['name']] = intval($_row['value']);
}
}
} catch (PDOException $e) {
$errore = array('errore' => $e->getMessage());
$app->render('errore_db.php', $errore);
}
if (!isset($_SESSION['user'])) {
$app->render('login.php');
} else {
$app->render('index.php');
}
});
$app->get("/testsession", $authenticateAdmin($app), function () use ($app) {
echo ‘
’.print_r($_SESSION, true).’’;
});
$app->get("/showinput", $authenticate($app), function () use ($app) {
if (microtime(true) >= ($_SESSION['delaystarttime'] + $_SESSION['delaysec']))
printf(1);
else
printf(0);
});
$app->get("/errore", function() use ($app) {
$app->render(‘errore.php’);
});
// GestioneUtenti routes
require DIR . ROUTE_DIR . ‘GestioneUtenti.php’;
// SingleTest routes
require DIR . ROUTE_DIR . ‘SingleTest.php’;
// TestCollettivi routes
require DIR . ROUTE_DIR . ‘TestCollettivi.php’;
// Administration routes
require DIR . ROUTE_DIR . ‘Administration.php’;
// ClickAPremi routes
require DIR . ROUTE_DIR . ‘ClickAPremi.php’;
// REPORTS routes
require DIR . ROUTE_DIR . ‘Reports.php’;
$app->run();[/details]
this what i wrote from lines 112 to 116 :
if (!isset($_SESSION[‘user’])) {
$app->render(‘login.php’);
} else {
$app->render(‘index.php’);
}
And the path are:/Templates and there all files on there and i don’t any error