public function defaultaction() { if (!auth::isloggedin()) { lib::sendto('/login'); } else { $contacts = new contactscollection(lib::getitem('user')); $contacts->getwithdata(); echo view::show('contacts/browse', array('contacts' => $contacts)); } }
public function processdelete() { $controller = lib::getitem('controller'); if (empty($controller->params[0])) { lib::sendto(); } else { $userid = (int) $controller->params[0]; $connection = db::factory('mysql'); $sql = "\r\n delete u.*, c.*, g.*, m.* from user u\r\n left join contact c on c.ownerid = u.id\r\n left join contactgroup g on g.contactid=c.id\r\n left join contactmethod m on g.id=m.contactgroupid\r\n where u.id = {$userid}\r\n "; $connection->execute($sql); lib::sendto('/users'); } }
<?php /** * Created by PhpStorm. * User: Administrator * Date: 2015/12/11 * Time: 14:28 */ require 'includes/autoloader.php'; require 'includes/exceptions.php'; session_start(); $view = new view(); lib::setitem('controller', new controller($_GET['u'])); lib::getitem('controller')->render(); $content = $view->finish(); echo view::show('shell', array('body' => $content));
<div id="loginbox"> <h1>Login</h1> <?php echo view::show('standard/errors'); ?> <form action="/login/process" method="post"> <div class="row"><label for="username">Username:</label><input type="text" name="username" id="username" value="<?php echo lib::getitem('username'); ?> " /></div> <div class="row"><label for="password">Password:</label><input type="password" name="password" id="password" /></div> <div class="row"><label for="submit"> </label><input id="submit" type="submit" value="login" class="submitbutton" /></div> </form> </div>
public static function isadmin() { return self::isloggedin() && 1 == lib::getitem('user')->admin; }
<?php /** * Created by PhpStorm. * User: Administrator * Date: 2015/12/14 * Time: 14:26 */ $errors = lib::getitem('error', lib::NO_PERSISTENT_STORAGE); if (is_array($errors)) { print '<ul class="error"><li>' . implode('</li><li>', $errors) . '</li></ul>'; }