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; }
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; } }