public function dologinAction() { Db::connect(); $bean = R::dispense('user'); // the redbean model $required = ['Name' => 'name', 'Email' => 'email', 'User_Name' => ['rmnl', 'az_lower'], 'Password' => 'password_hash']; \RedBeanFVM\RedBeanFVM::registerAutoloader(); // for future use $fvm = \RedBeanFVM\RedBeanFVM::getInstance(); $fvm->generate_model($bean, $required); //the magic R::store($bean); $val = new validation(); $val->addSource($_POST)->addRule('email', 'email', true, 1, 255, true)->addRule('password', 'string', true, 10, 150, false); $val->run(); if (count($val->errors)) { Debug::r($val->errors); foreach ($val->errors as $error) { Notification::setMessage($error, Notification::TYPE_ERROR); } $this->redirect(Request::createUrl('login', 'login')); } else { Notification::setMessage("Welcome back !", Notification::TYPE_SUCCESS); Debug::r($val->sanitized); session::set('user', ['sanil']); $this->redirect(Request::createUrl('index', 'index')); } }
/** * Run the application * @param type $appBasePath */ public function run($appBasePath) { /** * Define application base path */ defined('APP_BASE_PATH') or define('APP_BASE_PATH', $appBasePath); /** * get controller and action from from url */ $controller = Request::getController(); $action = Request::getAction(); /** * prepare controller class and path according to convention */ $controllerClass = $controller . 'Controller'; $controllerPath = APP_BASE_PATH . '/controllers/' . $controllerClass . '.php'; /** * check if requested controller file and class exists * @todo use error controller and action to display errors */ if (file_exists($controllerPath)) { /** * Include requested controller */ include_once $controllerPath; if (class_exists($controllerClass)) { $Controller = new $controllerClass(); } else { $msg = $controllerClass . ' class not found!'; exit($msg); } } else { $msg = $controllerPath . ' not found!'; exit($msg); } /** * prepare method */ $methodName = $action . 'Action'; if (!method_exists($Controller, $methodName)) { $msg = " Method {$methodName} not found on {$controllerClass} Class "; exit($msg); } /** * execute appropriate contoller's action method */ try { $Controller->{$methodName}(); } catch (Exception $exc) { Debug::r($exc->getMessage(), 'application-exception.txt'); } }
<?php Debug::r($this->msg);
<?php Debug::r($this->data); echo Request::getBaseUrl(true);
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous"> <style> .wrapper{ width: 768px; margin: 50px auto; } </style> </head> <body> <div class="wrapper"> <h1>Database Analyse</h1> <section> <h2>Basic Info</h2> <h3>Database</h3> <?php echo Debug::r($database); ?> <h3>Tables</h3> <?php echo $table->listing($tables); ?> <h3>Columns</h3> <?php foreach ($tables as $name) { echo "<h4>{$name}</h4>"; $cols = $dbh->columns($name); echo $table->multi($cols); $tableInfo[$name] = new DBTable($name, $cols); } ?> </section>