コード例 #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());
 }