FIX autoload

This commit is contained in:
Krivchikov Dmitry 2014-04-03 13:32:49 +04:00
parent 0f0af9877a
commit 11d488fd78
2 changed files with 9 additions and 19 deletions

View File

@ -81,10 +81,10 @@ class App
} }
} }
public static function error404() public static function error404($message = '')
{ {
header("HTTP/1.0 404 Not Found"); header("HTTP/1.0 404 Not Found");
die('404'); die('Error 404 '.$message);
} }
public static function redirect($url) public static function redirect($url)

View File

@ -2,27 +2,17 @@
// Поехали! // Поехали!
$dirname = dirname(__FILE__) . '/../'; function __autoload($className)
foreach (glob($dirname . "ground/classes/*.php") as $filename)
{ {
include_once $filename; $dirname = dirname(__FILE__) . '/../';
} $fileName = strpos($className, 'Controller') ? $dirname . 'ground/controllers/' . $className . '.php' : $dirname . 'ground/classes/' . strtolower($className) . '.php';
spl_autoload_register('autoload');
function autoload($className)
{
$fileName = dirname(__FILE__) . '/../ground/controllers/' . $className . '.php';
if (file_exists($fileName)) if (file_exists($fileName))
include $fileName; include $fileName;
else else
App::error404 (); App::error404 ('load class '.$className);
} }
include_once $dirname . 'ground/app.php'; include_once dirname(__FILE__) . '/../ground/app.php';
include_once $dirname . 'ground/config.php'; include_once dirname(__FILE__) . '/../ground/config.php';
App::run($config); App::run($config);
// И немного магии