Exemple #1
0
 public function __construct()
 {
     parent::__construct();
     // Load helpers in the constructor.
     $this->session = $this->load->helper('session');
     $this->validate = $this->load->helper('validate');
     $this->string = $this->load->helper('string');
     // Load language.
     $this->lang = $this->load->lang(Pep::get_setting('language'));
 }
Exemple #2
0
 public function helper($name)
 {
     $file = APP_DIR . 'helpers/' . strtolower($name) . '.php';
     if (file_exists($file)) {
         require_once $file;
         $helper = new $name();
         return $helper;
     } else {
         Pep::show_error(sprintf('The helper file %s.php failed to load.', $name));
     }
 }
Exemple #3
0
 public function login($user, $pass)
 {
     if (Pep::auth_user($user, md5($pass))) {
         $data = $this->decrypt($_COOKIE[$this->cookie_name]);
         $data['user'] = $user;
         $data['pass'] = md5($pass);
         setcookie($this->cookie_name, $this->encrypt($data), $this->expires, '/', '', false, true);
         $this->logged_in = true;
     } else {
         $this->logged_in = false;
     }
     return $this->logged_in;
 }
Exemple #4
0
 private function render_view($data = null)
 {
     $language = Pep::get_setting('language');
     if (!empty($language)) {
         $file = APP_DIR . 'languages/' . strtolower($language) . '.php';
         if (file_exists($file)) {
             include $file;
         } else {
             Pep::show_error(sprintf('The language file %s.php does not exist.', $language));
         }
     }
     if ($data) {
         extract($data);
     }
     if (file_exists($this->template)) {
         $minified = Pep::get_setting('minify');
         $minified ? ob_start(array($this, 'minify')) : ob_start();
         require $this->template;
         ob_end_flush();
     } else {
         // No view exists at all.
         Pep::show_error(sprintf('The view file %s.php does not exist.', $this->view));
     }
 }
Exemple #5
0
 public function __construct()
 {
     parent::__construct();
     $this->description = 'Add, remove and edit users.';
     $this->fields = array('user_id' => array('type' => 'pk', 'name' => 'Key'), 'user' => array('type' => 'text', 'name' => 'User', 'validate' => array('required', 'alpha_num')), 'pass' => array('type' => 'password', 'name' => 'Pass', 'validate' => array('alpha_num_dash')), 'role' => array('type' => 'select', 'name' => 'Role', 'options' => Pep::get_roles()));
 }
Exemple #6
0
 * included in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 * OTHER DEALINGS IN THE SOFTWARE.
 *
 */
// Configure constants.
define('ROOT_DIR', realpath(dirname(__FILE__)) . '/');
define('APP_DIR', ROOT_DIR . 'system/application/');
define('DB_DIR', ROOT_DIR . 'system/database/');
define('CORE_DIR', ROOT_DIR . 'system/core/');
define('THEME_DIR', ROOT_DIR . 'themes/');
// Set to false for production.
define('DEV_MODE', true);
// Get required core classes.
require CORE_DIR . 'pep.php';
require CORE_DIR . 'model.php';
require CORE_DIR . 'view.php';
require CORE_DIR . 'controller.php';
require CORE_DIR . 'functions.php';
require CORE_DIR . 'auth.php';
require CORE_DIR . 'input.php';
require CORE_DIR . 'load.php';
Pep::init();
Exemple #7
0
<!DOCTYPE html>
<html>
	<head>
		<title><?php 
echo $title;
?>
</title>
		<meta name="description" content="<?php 
echo Pep::get_setting('site_description');
?>
" />
		<meta name="keywords" content="<?php 
echo Pep::get_setting('site_keywords');
?>
" />
	</head>
	<body>
		<?php 
if (DEV_MODE) {
    ?>
<p>Dev mode is on.</p><?php 
}
?>
		
Exemple #8
0
function segment($seg)
{
    return Pep::segment($seg);
}
Exemple #9
0
 /**
  * Authenticates a user. The password should be hashed with md5
  * before passing in as an argument.
  * 
  * @param 	string 	$username		The user to authenticate.
  * @param 	string 	$md5password	The hashed password to authenticate.
  * @return 	bool	True if valid user, otherwise false.
  * 
  */
 public static function auth_user($username, $md5pass)
 {
     self::$model->from('users');
     $users = self::$model->select('*');
     foreach ($users as $user) {
         if ($user['user'] == $username && $user['pass'] == $md5pass) {
             self::$authed_user = $user;
             return true;
         }
     }
     return false;
 }