예제 #1
0
파일: Template.php 프로젝트: Kloadut/cheryl
 public static function show()
 {
     $res = self::build(Cheryl::me()->config->includes, Cheryl::me()->config->templateName, true);
     if (!$res) {
         ob_start();
         /* <TEMPLATE_CONTENT> */
         $res = ob_get_contents();
         ob_end_clean();
     }
     return $res;
 }
예제 #2
0
파일: User.php 프로젝트: Kloadut/cheryl
 public static function login()
 {
     if (Cheryl::me()->request['__username']) {
         // log in attempt
         if (Cheryl::me()->request['__hash']) {
             $pass = Cheryl::me()->request['__hash'];
         } else {
             $pass = self::password(Cheryl::me()->request['__password']);
         }
     } else {
         return false;
     }
     $type = strtolower(Cheryl::me()->config->authentication->type);
     // simple authentication. store users in an array
     if ($type == 'simple') {
         foreach (self::users() as $user) {
             if ($user->username == Cheryl::me()->request['__username']) {
                 $u = $user;
                 break;
             }
         }
         if ($u && (!$u->password || $pass == $u->password)) {
             // successfuly send username and password
             return new Cheryl_User($u);
         }
         return false;
         // use php data objects only if we have the libs
     } elseif ($type == 'pdo' && class_exists('PDO')) {
         $q = Cheryl::me()->config->authentication->pdo->prepare('SELECT * FROM ' . Cheryl::me()->config->authentication->user_table . ' WHERE user=:username AND hash=:hash LIMIT 1');
         $q->bindValue(':username', Cheryl::me()->request['__username'], PDO::PARAM_STR);
         $q->bindValue(':hash', $pass, PDO::PARAM_STR);
         $q->execute();
         $rows = $q->fetchAll(PDO::FETCH_ASSOC);
         if (count($rows)) {
             return new Cheryl_User($rows[0]);
         }
         // use php data objects only if we have the libs
     } elseif ($type == 'mysql' && function_exists('mysql_connect')) {
         // @todo #18
     } else {
         return false;
     }
 }
예제 #3
0
파일: Extras.php 프로젝트: Kloadut/cheryl
<?php

// if this wasnt defined, then automaticly run the script asuming this is standalone
if (!defined('CHERYL_CONTROL')) {
    $cheryl = new Cheryl();
    $cheryl->go();
}
예제 #4
0
파일: index.php 프로젝트: Kloadut/cheryl
<?php

/**
 * Basic Cheryl example of using a separate index script
 *
 * uses static cheryl methods
 *
 */
// if CHERYL_CONFIG is defined, the script will not automatilcy run
define('CHERYL_CONTROL', true);
// if you want better password hashing, put something here
define('CHERYL_SALT', 'SOMETHING/NOT/COOL/AND/RANDOM');
// include the Cheryl libraries
require_once '../../build/Cheryl.php';
// give Cheryl our config. this will merge with the default config
Cheryl::init(array('root' => '../files', 'users' => array(array('username' => 'admin', 'password' => Cheryl::password('password'), 'permissions' => 'all'))));
// manualy run the script since were using a custom config
Cheryl::go();
예제 #5
0
파일: Cheryl.php 프로젝트: Kloadut/cheryl
 public function accept()
 {
     return Cheryl::iteratorFilter($this->current());
 }