Example #1
0
 /**
  * Initializes the route.
  * Prevents browser from trying to load a physical file.
  */
 private function route()
 {
     Route::init();
     // Checks if the browser tried to load a physical file who doesn't exists
     $error = false;
     $query = Route::getQuery();
     $length = strlen($query);
     if (substr($query, $length - 3, 1) == '.') {
         $ext = substr($query, $length - 2, 2);
         if ($ext == 'js') {
             $error = true;
         }
     } else {
         if (substr($query, $length - 4, 1) == '.') {
             $ext = substr($query, $length - 3, 3);
             if (in_array($ext, array('css', 'png', 'jpg', 'gif', 'ico', 'svg', 'eot', 'ttf'))) {
                 $error = true;
             }
         } else {
             if (substr($query, $length - 5, 1) == '.') {
                 $ext = substr($query, $length - 4, 4);
                 if (in_array($ext, array('jpeg', 'woff'))) {
                     $error = true;
                 }
             }
         }
     }
     $this->is404 = $error;
 }
Example #2
0
 public static function run()
 {
     require_once 'Database.php';
     require_once 'Route.php';
     require_once 'Load.php';
     require_once 'Engine.php';
     DB::init('localhost', 'icourse', 'root', '');
     Route::init();
     Load::$path = OBJ_ROOT . Route::$class . '.php';
     Load::init();
     foreach ($_REQUEST as $key => $val) {
         Engine::$oil[$key] = $val;
     }
     Engine::$class = Route::$class;
     Engine::$function = Route::$function;
     Engine::init();
 }
Example #3
0
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 */
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
$ini = parse_ini_file("./config.ini");
//-----------------------------------------------------------------------------
require_once './app/autoload.php';
//-----------------------------------------------------------------------------
Render::init();
$tmplData = Template::init();
$initedOK = Route::init();
if ($initedOK == false) {
    Render::antiTampering($tmplData);
}
//-----------------------------------------------------------------------------
if ($_GET['logoff']) {
    //echo "Logoff.";
    Session::logoff();
    Render::login($tmplData);
} elseif ($_POST['login'] && Session::login($tmplData) == false) {
    //echo "Login Failed.";
    Render::login($tmplData);
}
if (Session::isLoggedIn() === false) {
    //echo "Not logged in.";
    Render::login($tmplData);
Example #4
0
<?php

require_once 'controller.php';
require_once 'model.php';
require_once 'route.php';
$app = new Route();
$app->init();
Example #5
0
$_GET['id'] = '19';
$_GET['login'] = '';
$_GET['nick'] = 'userNick19 updated!';
$_GET['email'] = '';
*/
/* getbyid test
$_GET['action'] = 'getbyid';
$_GET['id'] = '286';
*/
/* add test
$_GET['action'] = 'add';
$_GET['data'] = array('login'=>'test1221');
*/
/* update test
$_GET['action'] = 'update';
$_GET['id'] = '6';
$_GET['data'] = array('nick'=>'test2222');
*/
/* delete test
$_GET['action'] = 'delete';
$_GET['id'] = '7';
*/
/* заглушка авторизации
$_GET['authorization'] = array('login'=>'test', 'pass'=>'test');
$_POST['authorization'] = array('login'=>'test', 'pass'=>'test');
*/
try {
    Route::init()->run();
} catch (Exception $e) {
    echo $e->getMessage() . '<br>';
}
Example #6
0
<?php

ob_start();
//session_set_cookie_params(172800);
include_once MAIN_DIR . DS . ENGINE_DIR_PREFIX . 'core/defines.php';
include_once CLASS_DIR . DS . 'Load.class.php';
Load::file(array('Temp.class.php', 'File.class.php'), CLASS_DIR);
spl_autoload_register('Load::autoLoadClasses');
register_shutdown_function('Core::shutDown');
//Debug::start();
//$GLOBALS['_SESSION'] = new SessionArray();
Load::getClasses();
Route::init();
App::load(Request::get('app'));
Example #7
0
 /**
  * Создание роута работающего через любой
  * @param $params
  * @throws \Exception
  */
 protected static function makeRouteAny($params)
 {
     $route = new Route();
     static::addRoute($route->init($params, 'any'));
 }
Example #8
0
 /**
  * __construct
  * @param array $config optional
  **/
 public function __construct($config = array())
 {
     self::$instance = $this;
     //** Config
     $this->config = new Config();
     if (is_array($config) && count($config)) {
         while (list($key, $value) = each($config)) {
             $this->config->set($key, $value);
         }
     }
     //-- End Config
     if ($this->config->get('path.basepath') == '') {
         $this->config->set('path.basepath', getcwd() . '/');
     }
     self::$header[] = $_SERVER["SERVER_PROTOCOL"] . ' ' . Route::$HTTP_RESPONSE[200];
     $this->route = new Route();
     Route::init();
     Route::$BASEPATH = $this->config->get('path.basepath');
     $this->url = new Url(Route::$PROTOCOL, Route::$BASEURL, Route::$BASEPATH);
     $this->assets = new Assets($this->url);
     $this->request = new Request();
     //** ID: Memasukan Libary/Pustaka berdasarkan config | EN: Load Dynamic Libraries from config
     $libraries = $this->config->get('libraries');
     if (is_array($libraries) && count($libraries) > 0) {
         while (list($library, $params) = each($libraries)) {
             $clsLibrary = 'Kecik\\' . $library;
             if (class_exists($clsLibrary)) {
                 if (isset($params['enable']) && $params['enable'] === TRUE) {
                     $library = strtolower($library);
                     //** ID: Untuk Library/Pustaka tanpa parameter
                     //** EN: For Library without parameter
                     if (!isset($params['config']) && !isset($params['params'])) {
                         //** ID: Untuk Library/Pustaka DIC | EN: For DIC Library
                         if ($library == 'dic') {
                             $this->container = new DIC();
                         } elseif ($library == 'mvc') {
                             if (isset($this->db)) {
                                 MVC::setDB($this->db);
                             }
                         } else {
                             // ID: Untuk Library/Pustaka lain | EN: Other Library
                             $this->{$library} = new $clsLibrary();
                         }
                         //** ID: Untuk Library/Pustaka dengan parameter Kelas Kecik
                         //** EN: For Library with parameter of Kecik CLass
                     } elseif (isset($params['config'])) {
                         //** ID: Buat variabel config
                         //** EN: Create config variable
                         while (list($key, $value) = each($params['config'])) {
                             $this->config->set($library . '.' . $key, $value);
                         }
                         //** ID: untuk Library/Pustaka Database | EN: For Database Library
                         if ($library == 'database') {
                             $this->db = new Database();
                             if (class_exists('MVC')) {
                                 MVC::setDB($this->db);
                             }
                         } else {
                             //** ID: untuk Library/Pustaka lain | EN: For Other library
                             $this->{$library} = new $clsLibrary();
                         }
                         //** ID: Untuk Library/Pustaka tanpa parameter Kelas Kecik
                         //** EN: For Library without parameter of Kecik CLass
                     } elseif (isset($params['params'])) {
                         $this->{$library} = new $clsLibrary($params['params']);
                     }
                 }
             }
         }
     }
     //-- ID: Akhir untuk memasukan library/pustaka secara dinamis
     //-- EN: End Load Dynamic Library
     spl_autoload_register(array($this, 'autoload'), true, true);
 }