Example #1
0
 * DEBUG_MODE flag to enable easier debugging and development
 * CACHE_ID   unique string to bust js/css browser caching for a new build
 * SITE_ID    random site id used for page keys
 */
define('APP_PATH', '');
define('DEBUG_MODE', true);
define('CACHE_ID', '');
define('SITE_ID', '');
/* show all warnings in debug mode */
if (DEBUG_MODE) {
    error_reporting(E_ALL | E_STRICT);
}
/* config file location */
define('CONFIG_FILE', APP_PATH . 'hm3.rc');
/* don't let anything output content until we are ready */
ob_start();
/* set default TZ */
date_default_timezone_set('UTC');
/* get includes */
require APP_PATH . 'lib/framework.php';
/* get configuration */
$config = new Hm_Site_Config_File(CONFIG_FILE);
/* setup ini settings */
require APP_PATH . 'lib/ini_set.php';
/* process the request */
new Hm_Dispatch($config);
/* log some debug stats about the page */
if (DEBUG_MODE) {
    Hm_Debug::load_page_stats();
    Hm_Debug::show('log');
}
Example #2
0
 /**
  * Perform an HTTP redirect
  * @param string $url url to redirect to
  * @param int $status current HTTP status
  * @return void
  */
 public static function page_redirect($url, $status = false)
 {
     if (DEBUG_MODE) {
         Hm_Debug::add(sprintf('Redirecting to %s', $url));
         Hm_Debug::load_page_stats();
         Hm_Debug::show('log');
     }
     if ($status == 303) {
         Hm_Debug::add('Redirect loop found');
         Hm_Functions::cease('Redirect loop discovered');
     }
     Hm_Functions::header('HTTP/1.1 303 Found');
     Hm_Functions::header('Location: ' . $url);
     return Hm_Functions::cease();
 }
Example #3
0
File: module.php Project: R-J/hm3
 /**
  * Validate a form key. If this is a non-empty POST form from an
  * HTTP request or AJAX update, it will take the user to the home
  * page if the page_key value is either not present or not valid
  * @return void
  */
 public function process_key()
 {
     if (empty($this->request->post)) {
         return false;
     }
     $key = array_key_exists('hm_page_key', $this->request->post) ? $this->request->post['hm_page_key'] : false;
     $valid = Hm_Request_Key::validate($key);
     if (!$valid) {
         if ($this->request->type == 'AJAX') {
             if (DEBUG_MODE) {
                 Hm_Debug::add('REQUEST KEY check failed');
                 Hm_Debug::load_page_stats();
                 Hm_Debug::show('log');
             }
             Hm_Functions::cease(json_encode(array('status' => 'not callable')));
             return 'exit';
         } else {
             if ($this->session->loaded) {
                 $this->session->destroy($this->request);
             }
             Hm_Debug::add('REQUEST KEY check failed');
             Hm_Dispatch::page_redirect('?page=home');
             return 'redirect';
         }
     }
     return false;
 }