AjaxHandler

* separated into appropriate subclasses
* unified sanitizing of $_GET and $_POST data using build in filter_input()
* index now always tries to resolve page calls with ajaxHandler first and as a page last

minor bug-fixes to bugs that wre not reported yet, because they didn't occur yet
(e.g.: nobody tried to compose a comment with >7500 characters yet)
This commit is contained in:
Sarjuuk
2015-11-08 18:53:44 +01:00
parent 141bc10901
commit 99fdad29dd
14 changed files with 1570 additions and 1297 deletions

View File

@@ -14,7 +14,6 @@ mb_internal_encoding('UTF-8');
require_once 'includes/defines.php';
require_once 'includes/libs/DbSimple/Generic.php'; // Libraray: http://en.dklab.ru/lib/DbSimple (using variant: https://github.com/ivan1986/DbSimple/tree/master)
require_once 'includes/utilities.php'; // misc™ data 'n func
require_once 'includes/ajaxHandler.class.php'; // handles ajax and jsonp requests
require_once 'includes/user.class.php';
require_once 'includes/markup.class.php'; // manipulate markup text
require_once 'includes/database.class.php'; // wrap DBSimple
@@ -34,18 +33,29 @@ spl_autoload_register(function ($class) {
if (preg_match('/[^\w]/i', $class)) // name should contain only letters
return;
if (strpos($class, 'list'))
if (stripos($class, 'list'))
{
if (!class_exists('BaseType'))
require_once 'includes/types/basetype.class.php';
require_once 'includes/basetype.class.php';
if (file_exists('includes/types/'.strtr($class, ['list' => '']).'.class.php'))
require_once 'includes/types/'.strtr($class, ['list' => '']).'.class.php';
else
throw new Exception('could not register type class: '.$class);
return;
}
else if (stripos($class, 'ajax') === 0)
{
require_once 'includes/ajaxHandler.class.php'; // handles ajax and jsonp requests
if (file_exists('pages/'.strtr($class, ['page' => '']).'.php'))
if (file_exists('includes/ajaxHandler/'.strtr($class, ['ajax' => '']).'.class.php'))
require_once 'includes/ajaxHandler/'.strtr($class, ['ajax' => '']).'.class.php';
else
throw new Exception('could not register ajaxHandler class: '.$class);
return;
}
else if (file_exists('pages/'.strtr($class, ['page' => '']).'.php'))
require_once 'pages/'.strtr($class, ['page' => '']).'.php';
});