parent
2029bca7c4
commit
6a8447a255
Binary file not shown.
@ -1,23 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
use Fuel\Core\Controller;
|
|
||||||
use Fuel\Core\Response;
|
|
||||||
use Fuel\Core\Session;
|
|
||||||
|
|
||||||
class Controller_Index extends Controller
|
|
||||||
{
|
|
||||||
public function before()
|
|
||||||
{
|
|
||||||
$user = Session::get('user');
|
|
||||||
|
|
||||||
if(!$user)
|
|
||||||
Response::redirect('/login');
|
|
||||||
else
|
|
||||||
Response::redirect('/home');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function action_index()
|
|
||||||
{
|
|
||||||
// DO NOTHING
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,127 +1,226 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* Fuel is a fast, lightweight, community driven PHP5 framework.
|
* Fuel is a fast, lightweight, community driven PHP 5.4+ framework.
|
||||||
*
|
*
|
||||||
* @package Fuel
|
* @package Fuel
|
||||||
* @version 1.8
|
* @version 1.8.2
|
||||||
* @author Fuel Development Team
|
* @author Fuel Development Team
|
||||||
* @license MIT License
|
* @license MIT License
|
||||||
* @copyright 2010 - 2016 Fuel Development Team
|
* @copyright 2010 - 2019 Fuel Development Team
|
||||||
* @link http://fuelphp.com
|
* @link https://fuelphp.com
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set error reporting and display errors settings. You will want to change these when in production.
|
* -----------------------------------------------------------------------------
|
||||||
|
* Configure PHP Settings
|
||||||
|
* -----------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* -----------------------------------------------------------------------------
|
||||||
|
* Show error reporting
|
||||||
|
* -----------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
* Set error reporting and display errors settings.
|
||||||
|
* You will want to change these when in production.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
error_reporting(-1);
|
error_reporting(-1);
|
||||||
|
|
||||||
ini_set('display_errors', 1);
|
ini_set('display_errors', 1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Website document root
|
* -----------------------------------------------------------------------------
|
||||||
|
* Define constants
|
||||||
|
* -----------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* -----------------------------------------------------------------------------
|
||||||
|
* Website document root
|
||||||
|
* -----------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
define('DOCROOT', __DIR__.DIRECTORY_SEPARATOR);
|
define('DOCROOT', __DIR__.DIRECTORY_SEPARATOR);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Path to the application directory.
|
* -----------------------------------------------------------------------------
|
||||||
|
* Path to the application directory
|
||||||
|
* -----------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
define('APPPATH', realpath(__DIR__.'/../fuel/app/').DIRECTORY_SEPARATOR);
|
define('APPPATH', realpath(__DIR__.'/../fuel/app/').DIRECTORY_SEPARATOR);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Path to the default packages directory.
|
* -----------------------------------------------------------------------------
|
||||||
|
* Path to the default packages directory
|
||||||
|
* -----------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
define('PKGPATH', realpath(__DIR__.'/../fuel/packages/').DIRECTORY_SEPARATOR);
|
define('PKGPATH', realpath(__DIR__.'/../fuel/packages/').DIRECTORY_SEPARATOR);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The path to the framework core.
|
* -----------------------------------------------------------------------------
|
||||||
|
* The path to the framework core
|
||||||
|
* -----------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
define('COREPATH', realpath(__DIR__.'/../fuel/core/').DIRECTORY_SEPARATOR);
|
define('COREPATH', realpath(__DIR__.'/../fuel/core/').DIRECTORY_SEPARATOR);
|
||||||
|
|
||||||
// Get the start time and memory for use later
|
/**
|
||||||
|
* -----------------------------------------------------------------------------
|
||||||
|
* Profiling
|
||||||
|
* -----------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
defined('FUEL_START_TIME') or define('FUEL_START_TIME', microtime(true));
|
defined('FUEL_START_TIME') or define('FUEL_START_TIME', microtime(true));
|
||||||
defined('FUEL_START_MEM') or define('FUEL_START_MEM', memory_get_usage());
|
defined('FUEL_START_MEM') or define('FUEL_START_MEM', memory_get_usage());
|
||||||
|
|
||||||
// Load in the Fuel autoloader
|
/**
|
||||||
|
* -----------------------------------------------------------------------------
|
||||||
|
* Preparing the Application
|
||||||
|
* -----------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* -----------------------------------------------------------------------------
|
||||||
|
* Check for dependencies
|
||||||
|
* -----------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
if ( ! file_exists(COREPATH.'classes'.DIRECTORY_SEPARATOR.'autoloader.php'))
|
if ( ! file_exists(COREPATH.'classes'.DIRECTORY_SEPARATOR.'autoloader.php'))
|
||||||
{
|
{
|
||||||
die('No composer autoloader found. Please run composer to install the FuelPHP framework dependencies first!');
|
die('No composer autoloader found. Please run composer to install the FuelPHP framework dependencies first!');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Activate the framework class autoloader
|
/**
|
||||||
|
* -----------------------------------------------------------------------------
|
||||||
|
* Activate autoloader class
|
||||||
|
* -----------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
require COREPATH.'classes'.DIRECTORY_SEPARATOR.'autoloader.php';
|
require COREPATH.'classes'.DIRECTORY_SEPARATOR.'autoloader.php';
|
||||||
|
|
||||||
class_alias('Fuel\\Core\\Autoloader', 'Autoloader');
|
class_alias('Fuel\\Core\\Autoloader', 'Autoloader');
|
||||||
|
|
||||||
// Exception route processing closure
|
/**
|
||||||
$routerequest = function($route = null, $e = false)
|
* -----------------------------------------------------------------------------
|
||||||
|
* Route processing
|
||||||
|
* -----------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
* Exception route processing closure
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
$routerequest = function($request = null, $e = false)
|
||||||
{
|
{
|
||||||
Request::reset_request(true);
|
Request::reset_request(true);
|
||||||
|
|
||||||
$route = array_key_exists($route, Router::$routes) ? Router::$routes[$route]->translation : Config::get('routes.'.$route);
|
$route = array_key_exists($request, Router::$routes) ? Router::$routes[$request]->translation : Config::get('routes.'.$request);
|
||||||
|
|
||||||
if ($route instanceof Closure)
|
if ($route instanceof Closure)
|
||||||
{
|
{
|
||||||
$response = $route();
|
$response = $route();
|
||||||
|
|
||||||
if( ! $response instanceof Response)
|
if( ! $response instanceof Response)
|
||||||
{
|
{
|
||||||
$response = Response::forge($response);
|
$response = Response::forge($response);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elseif ($e === false)
|
elseif ($e === false)
|
||||||
{
|
{
|
||||||
$response = Request::forge()->execute()->response();
|
$response = Request::forge()->execute()->response();
|
||||||
}
|
}
|
||||||
elseif ($route)
|
elseif ($route)
|
||||||
{
|
{
|
||||||
$response = Request::forge($route, false)->execute(array($e))->response();
|
$response = Request::forge($route, false)->execute(array($e))->response();
|
||||||
}
|
}
|
||||||
else
|
elseif ($request)
|
||||||
{
|
{
|
||||||
throw $e;
|
$response = Request::forge($request)->execute(array($e))->response();
|
||||||
}
|
}
|
||||||
|
else
|
||||||
return $response;
|
{
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $response;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Generate the request, execute it and send the output.
|
/**
|
||||||
|
* -----------------------------------------------------------------------------
|
||||||
|
* Starting the Application
|
||||||
|
* -----------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* -----------------------------------------------------------------------------
|
||||||
|
* Start the engine
|
||||||
|
* -----------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
* Generate the request, execute it and send the output
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Boot the app...
|
// Boot the app...
|
||||||
require APPPATH.'bootstrap.php';
|
require APPPATH.'bootstrap.php';
|
||||||
|
|
||||||
// ... and execute the main request
|
// ... and execute the main request
|
||||||
$response = $routerequest();
|
$response = $routerequest();
|
||||||
}
|
}
|
||||||
catch (HttpBadRequestException $e)
|
catch (HttpBadRequestException $e)
|
||||||
{
|
{
|
||||||
$response = $routerequest('_400_', $e);
|
$response = $routerequest('_400_', $e);
|
||||||
}
|
}
|
||||||
catch (HttpNoAccessException $e)
|
catch (HttpNoAccessException $e)
|
||||||
{
|
{
|
||||||
$response = $routerequest('_403_', $e);
|
$response = $routerequest('_403_', $e);
|
||||||
}
|
}
|
||||||
catch (HttpNotFoundException $e)
|
catch (HttpNotFoundException $e)
|
||||||
{
|
{
|
||||||
$response = $routerequest('_404_', $e);
|
$response = $routerequest('_404_', $e);
|
||||||
}
|
}
|
||||||
catch (HttpServerErrorException $e)
|
catch (HttpServerErrorException $e)
|
||||||
{
|
{
|
||||||
$response = $routerequest('_500_', $e);
|
$response = $routerequest('_500_', $e);
|
||||||
}
|
}
|
||||||
|
|
||||||
// This will add the execution time and memory usage to the output.
|
|
||||||
// Comment this out if you don't use it.
|
|
||||||
$response->body((string) $response);
|
$response->body((string) $response);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* -----------------------------------------------------------------------------
|
||||||
|
* Start profiling
|
||||||
|
* -----------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
* This will add the execution time and memory usage to the output.
|
||||||
|
*
|
||||||
|
* Comment these out if you don't use it.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
if (strpos($response->body(), '{exec_time}') !== false or strpos($response->body(), '{mem_usage}') !== false)
|
if (strpos($response->body(), '{exec_time}') !== false or strpos($response->body(), '{mem_usage}') !== false)
|
||||||
{
|
{
|
||||||
$bm = Profiler::app_total();
|
$bm = Profiler::app_total();
|
||||||
$response->body(
|
|
||||||
str_replace(
|
$response->body(
|
||||||
array('{exec_time}', '{mem_usage}'),
|
str_replace(
|
||||||
array(round($bm[0], 4), round($bm[1] / pow(1024, 2), 3)),
|
array('{exec_time}', '{mem_usage}'),
|
||||||
$response->body()
|
array(round($bm[0], 4), round($bm[1] / pow(1024, 2), 3)),
|
||||||
)
|
$response->body()
|
||||||
);
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send the output to the client
|
/**
|
||||||
$response->send(true);
|
* -----------------------------------------------------------------------------
|
||||||
|
* Show the web page
|
||||||
|
* -----------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
* Send the output to the client
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
$response->send(true);
|
Loading…
Reference in new issue