Ejemplo n.º 1
0
 /**
  * Authenticate and login a user.
  */
 public function Login()
 {
     $form = new FormUserLogin($this);
     if ($form->Check() === false) {
         $this->AddMessage('error', 'You must fill in acronym and password.');
         $this->RedirectToController('login');
     }
     $this->views->SetTitle('Login')->AddInclude(HAL_INSTALL_PATH . '/view/userlogin.tpl.php', array('login_form' => $form, 'allow_create_user' => Hal::Instance()->config['create_new_users'], 'create_user_url' => $this->CreateUrl(null, 'create')));
 }
Ejemplo n.º 2
0
Archivo: Form.php Proyecto: rud0lph/HAL
 /**
  * Constructor
  *
  * @param string name of the element.
  * @param array attributes to set to the element. Default is an empty array.
  */
 public function __construct($name, $attributes = array())
 {
     $this->attributes = $attributes;
     $this['name'] = $name;
     if (is_callable('Hal::Instance()')) {
         $this->characterEncoding = Hal::Instance()->config['character_encoding'];
     } else {
         $this->characterEncoding = 'UTF-8';
     }
 }
Ejemplo n.º 3
0
 /**
  * Constructor, can be instantiated by sending in the $hal reference.
  */
 protected function __construct($hal = null)
 {
     if (!$hal) {
         $hal = Hal::Instance();
     }
     $this->hal =& $hal;
     $this->config =& $hal->config;
     $this->request =& $hal->request;
     $this->data =& $hal->data;
     $this->db =& $hal->db;
     $this->views =& $hal->views;
     $this->session =& $hal->session;
     $this->user =& $hal->user;
 }
Ejemplo n.º 4
0
<?php

//
// PHASE: BOOTSTRAP
//
define('HAL_INSTALL_PATH', dirname(__FILE__));
define('HAL_SITE_PATH', HAL_INSTALL_PATH . '/application');
require HAL_INSTALL_PATH . '/bootstrap.php';
$hal = Hal::Instance();
//
// PHASE: FRONTCONTROLLER ROUTE
//
$hal->FrontControllerRoute();
//
// PHASE: THEME ENGINE RENDER
//
$hal->ThemeEngineRender();
Ejemplo n.º 5
0
 /**
  * Create password.
  *
  * @param $plain string the password plain text to use as base.
  * @param $algorithm string stating what algorithm to use, plain, md5, md5salt, sha1, sha1salt. 
  * defaults to the settings of site/config.php.
  * @returns array with 'salt' and 'password'.
  */
 public function CreatePassword($plain, $algorithm = null)
 {
     $password = array('algorithm' => $algorithm ? $algoritm : Hal::Instance()->config['hashing_algorithm'], 'salt' => null);
     switch ($password['algorithm']) {
         case 'sha1salt':
             $password['salt'] = sha1(microtime());
             $password['password'] = sha1($password['salt'] . $plain);
             break;
         case 'md5salt':
             $password['salt'] = md5(microtime());
             $password['password'] = md5($password['salt'] . $plain);
             break;
         case 'sha1':
             $password['password'] = sha1($plain);
             break;
         case 'md5':
             $password['password'] = md5($plain);
             break;
         case 'plain':
             $password['password'] = $plain;
             break;
         default:
             throw new Exception('Unknown hashing algorithm');
     }
     return $password;
 }
Ejemplo n.º 6
0
/**
 * Check if region has views. Accepts variable amount of arguments as regions.
 *
 * @param $region string the region to draw the content in.
 */
function region_has_content($region = 'default')
{
    return Hal::Instance()->views->RegionHasView(func_get_args());
}
Ejemplo n.º 7
0
 /**
  * Callback to delete the content.
  */
 public function DoDelete($form, $content)
 {
     $content['id'] = $form['id']['value'];
     $content->Delete();
     Hal::Instance()->RedirectTo('content');
 }
Ejemplo n.º 8
0
/**
 * Helper, wrap html_entites with correct character encoding
 */
function htmlEnt($str, $flags = ENT_COMPAT)
{
    return htmlentities($str, $flags, Hal::Instance()->config['character_encoding']);
}