static function router() { /* echo "Hola me llamo Pedro y estoy probando la function router"; Coder::code(self::$controller); Coder::code(self::$action); */ // if exists the controller then make and instance of controller $contr_call = self::$controller != "" ? self::$controller : 'Home'; $action_call = self::$action != "" ? self::$action : 'Home'; $filename = $contr_call . '.php'; $filecontroller = APP . 'controllers' . DS . ucfirst($filename); Coder::code(self::$controller); Coder::code(self::$action); if (is_readable($filecontroller)) { $cont = new $contr_call(); //check if action is an object method if (is_callable(array($cont, $action_call))) { call_user_func(array($cont, $action_call)); } else { // no function echo 'No action!'; } } else { // no function echo 'No controller!'; } }
private function model2view(&$model) { foreach ($model as $key => $value) { Coder::cleanData($model[$key]); } User::fillDisplayName($model); return $model; }
public function changePwd($email, $ucode, $newPwd) { $query = "select count(1) from user_registration where emailaddress=\"" . Coder::cleanXSS($this->db, $email) . "\" and uniqCode=\"{$ucode}\""; if ($this->db->query($query) != 1) { throw new Exception("Invalid URL", -1); } else { $newPwd = Auth::encrypt($newPwd); $query = "update user_registration set pwd=\"{$newPwd}\" where \n\t\t\t\temailaddress=\"{$email}\" and uniqCode=\"{$ucode}\" limit 1"; $this->db->query($query); } }
static function init() { echo $_SERVER['REQUEST_URI']; Request::retrieve(); $controller = Request::getCont(); Coder::code($controller); //echo $controller."<br>"; $action = Request::getAct(); Coder::code($action); $params = Request::getparams(); Coder::code($params); }
static function getParams() { //primer comprovar que queda algo if (count(self::$query) > 0) { //comprovar si és parell if (count(self::$query) % 2 == 0) { Coder::codear(self::$query); return self::$query; } else { echo 'ERROR in params array'; } } }
static function init() { // recuperar la request echo $_SERVER['REQUEST_URI']; // extract all the components un URI Request::retrieve(); $controller = Request::getCont(); Coder::code($controller); $action = Request::getAct(); Coder::code($action); $params = Request::getParams(); Coder::codear($params); }
public function __construct() { $config = Registry::getInstance(); $dbconf = (array) $config->dbconf; $dsn = $dbconf['driver'] . ':host=' . $dbconf['dbhost'] . ';dbname=' . $dbconf['dbname']; $user = $dbconf['dbuser']; $pass = $dbconf['dbpass']; Coder::codear($dbconf); try { parent::__construct($dsn, $user, $pass); } catch (PDOException $e) { echo $e->getMessage(); } }
function create($dbname) { $dbhost = $this->conf->dbhost; $dbuser = $this->conf->dbuser; $dbpass = $this->conf->dbpass; $file = ROOT . 'install/app.sql'; //$this->import($dbhost,$dbuser,$dbpass,$dbname,$sql); try { $conn = new PDO($this->conf->driver . ':host=' . $dbhost, $dbuser, $dbpass); //$stmt = $conn->query("SHOW DATABASES"); //var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); $sql = 'CREATE Database ' . $dbname . ' CHARACTER SET utf8 COLLATE utf8_general_ci'; $stmt = $conn->query($sql); } catch (PDOException $e) { die('Could not connect: ' . $e->getMessage()); } //disconnect PDO connection $conn = null; //now connecting with new DSN $dsn = $this->conf->driver . ':host=' . $dbhost . ';dbname=' . $dbname; Coder::code($dsn); try { $conn = new PDO($dsn, $dbuser, $dbpass); } catch (PDOException $e) { die('Problem with connection' . $e->getMessage()); } echo 'Processing SQL script'; $query = file_get_contents($file); $sqlList = SQLParser::parse($query); Coder::code_var($sqlList); try { foreach ($sqlList as $sqlline) { // Perform the query $conn->query($sqlline); } } catch (PDOException $e) { echo $e->getMessage(); die; } echo 'Final'; return true; }
public function login($emailaddress, $password) { $emailaddress = Coder::cleanXSS($this->db, $emailaddress); //$password = Coder::cleanXSS($this->db, $password); $password = Auth::encrypt($password); $query = "select userID, userStatus from user_registration where emailaddress=\"{$emailaddress}\" and pwd=\"{$password}\""; //and userStatus='active'"; $result = $this->db->query($query); if (!is_array($result) || count($result) < 1 || !isset($result[0]["userID"])) { throw new Exception("incorrect email address or password", -1); } if ($result[0]["userStatus"] != 'active') { throw new Exception("user's email address is not verified", -1); } $userID = $result[0]["userID"]; if ($userID <= 0) { throw new Exception("current user is not allowed to login", -1); } $this->setupSession($userID); return $this; }
static function router() { //if exists controller the //make an instance of controller $contr_call = self::$controller != "" ? self::$controller : 'home'; $action_call = self::$action != "" ? self::$action : 'home'; $filename = $contr_call . 'php'; $filecontroller = APP . 'controllers' . DS . $filename; Coder::code($filecontroller); if (is_readable($filecontroller)) { //$cont=new action_controller (self::$params); //call_user_func(OBJ,function); $cont = new $contr_call(); if (is_callable(array($cont, $action_call))) { call_user_func(array($cont, $action_call)); } else { echo 'NO action!'; } } else { echo 'NO controller!'; } }
<?php //first phase //environment //development ini_set('display_errors', 'on'); //informe de errores error_reporting(E_ALL); include 'config.php'; require 'sys/helper.php'; require 'sys/sesion.php'; sesion::sesion_start(); sesion::set_session_variable('Marti', 'PROBANDO'); $sesion = sesion::get_session_variable('Marti'); echo $sesion . '<br>'; sesion::borrar_variable('Marti'); sesion::borrarsesion(); echo '<br>'; $conf = Registry::getInstance(); $conf->Welcome = "hola"; Coder::codear($conf); Core::init();
private function createLocalUser($fields) { if (!isset($fields['emailaddress']) || !isset($fields['displayName']) || !isset($fields['pwd'])) { throw new Exception("incorrect parameters", -11); } $keys = $values = "("; foreach ($fields as $key => $value) { $key = Coder::cleanXSS($this->db, $key); if ($key == 'pwd') { $value = Auth::encrypt($value); } else { $value = Coder::cleanXSS($this->db, $value); } $fields[$key] = $value; $keys .= "{$key}, "; $values .= "\"{$value}\", "; } /* * Function: disable email verification * Date: 2016/03/01 $uniqCode = Coder::createRandomCode(); $mailer = new Mailer(); $result = $mailer->sendVerification($fields['emailaddress'], $fields['displayName'], $uniqCode); if ($result == false) throw new Exception("failed to send verification email", -1); $keys .= "uniqCode, userStatus, createdDateTime, updatedDateTime)"; $values .= "\"$uniqCode\", \"pending\", now(), now())"; */ $keys .= "uniqCode, userStatus, createdDateTime, updatedDateTime)"; $values .= "\"{$uniqCode}\", \"active\", now(), now())"; $query = "insert into user_registration {$keys} values {$values}"; return $this->db->query($query); }
private function view2model() { $model = $this->replyResult["reply"]; Coder::cleanXSS($this->db, $model["parentReplyID"], "int"); Coder::cleanXSS($this->db, $model["newsID"], "int"); Coder::cleanXSS($this->db, $model["userID"], "int"); Coder::cleanXSS($this->db, $model["replyStatement"]); Coder::cleanXSS($this->db, $model["replyContent"]); Coder::cleanXSS($this->db, $model["replyType"]); return $model; }
protected function model2view(&$model) { foreach ($model as $key => $value) { Coder::cleanData($model[$key]); } Coder::dbstr2date($model["nacreatedDateTime"]); Coder::htmldecode($model["newsContent"]); return $model; }