/**
  * The constructor of BaseController
  *
  * @desc   The constructor of BaseController
  * @access public
  * @return void
  */
 public function __construct()
 {
     $this->_model = null;
     $this->_loadModel();
     $this->_viewVariables = array();
     $this->filter = Filter::getInstance();
 }
Esempio n. 2
0
 protected function _setUp()
 {
     $this->_filter = Filter::getInstance();
     $this->_phpmailerDir = $this->getPluginPath() . DS . "phpmailer" . DS;
     $this->_templateDir = getcwd() . DS . "framework" . DS . "mailTemplates" . DS;
     $this->_loadClasses();
     $this->_mail = new PHPMailer();
     $mailType = $this->_getOption("mailMethod");
     if ($mailType != null && $mailType == "smtp") {
         $this->_mail->IsSMTP();
         $this->_mail->SMTPAuth = $this->_getOption("enableSMTPAuthentication");
         $this->_mail->SMTPSecure = $this->_getOption("smtpSecurity");
         $this->_mail->Host = $this->_getOption("smtpHost");
         $this->_mail->Port = $this->_getOption("smtpPort");
         $this->_mail->Username = $this->_getOption("smtpUsername");
         $this->_mail->Password = $this->_getOption("smtpPassword");
         $from = $this->_getOption("from");
         $from = explode("|", $from);
         $fromMail = $from[0];
         $fromName = $from[1];
         $this->_mail->SetFrom($fromMail, $fromName);
         $replyTo = $this->_getOption("replyTo");
         if ($replyTo != null) {
             $replyTo = explode("|", $replyTo);
             $replyToMail = $replyTo[0];
             $replyToName = $replyTo[1];
             $this->_mail->AddReplyTo($replyToMail, $replyToName);
         }
     }
 }
Esempio n. 3
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     // Using factory
     // Getting an instance of a model User example
     $user = ModelFactory::getInstance('User');
     // Getting an instance of a Library String
     $stringLib = LibraryFactory::getInstance('String');
     // Getting an instance of a Filter DateRange
     $dateRange = FilterFactory::getInstance('DateRange');
     // Getting an instance of a Type User
     $userType = TypeFactory::getInstance('User');
     // Perform an access check
     AccessCheckFactory::getInstance('User')->canAccess(auth()->user()->id, 'view');
     // Using facade
     // Getting an instance of a model User example
     $user = \Model::getInstance('User');
     // Getting an instance of a Library String
     $stringLib = \Library::getInstance('String');
     // Getting an instance of a Filter DateRange
     $dateRange = \Filter::getInstance('DateRange');
     // Getting an instance of a Type User
     $userType = \Type::getInstance('User');
     // Passing data to view example
     $this->view->fullname = auth()->user()->fullname;
     // Perform an access check
     \AccessCheck::getInstance('User')->canAccess(1, 'view');
     return $this->view('dashboard');
 }
Esempio n. 4
0
 /**
  * Method to unserialize the input.
  *
  * @param   string  $input  The serialized input.
  *
  * @return  Input  The input object.
  */
 public function unserialize($input)
 {
     // Unserialize the executable, args, options, data, and inputs.
     list($this->executable, $this->args, $this->options, $this->data, $this->inputs) = unserialize($input);
     // Load the filter.
     if (isset($this->options['filter'])) {
         $this->filter = $this->options['filter'];
     } else {
         $this->filter = Filter::getInstance();
     }
 }
Esempio n. 5
0
 /**
  * The constructor of BasePlugin
  *
  * @param $options array An array of options for the plugin
  * @return void
  */
 public function __construct($options = array())
 {
     $this->_filter = Filter::getInstance();
     $this->_properties = array();
     $this->_viewVariables = array();
     $this->_options = array();
     if (count($options) > 0) {
         if (method_exists($this, "_setOptions")) {
             $this->_setOptions($options);
         }
     }
     if (method_exists($this, "_setUp")) {
         $this->_setUp();
     }
 }
Esempio n. 6
0
 /**
  * @param array $tokens
  * @return $this
  */
 public function tokens(array $tokens)
 {
     foreach ($tokens as $key => $regex) {
         $filter = Filter::getInstance();
         if (in_array($regex, $filter->getFiltersList())) {
             $tokens[$key] = $filter->getRegex($regex);
         }
     }
     $this->tokens = array_merge($this->tokens, $tokens);
     return $this;
 }
Esempio n. 7
0
 public function SOAPLogin($username, $password)
 {
     $status = 0;
     $filter = Filter::getInstance();
     if ($filter->isString($username)) {
         if ($username == null || strlen($username) < 6) {
             $status = 403;
         }
     }
     if ($filter->isString($password)) {
         if ($password == null || strlen($password) < 6) {
             $status = 403;
         }
     }
     if ($status != 403) {
         $db = DataBase::getInstance();
         $passSHA1 = sha1($password);
         $query = "SELECT * FROM User WHERE username='******' AND password='******' ";
         $db->query($query);
         $rows = $db->numRows();
         if ($rows == 0) {
             $status = 403;
         } else {
             $user = $db->fetchObject();
             if (intval($user->isBlocked) == 1) {
                 $status = 402;
             } else {
                 $status = 200;
                 try {
                     @session_destroy();
                     @session_start();
                     $username = $user->username;
                     $role = $user->role;
                     Session::set("authentication", true, "SOAP");
                     Session::set("username", $username, "SOAP");
                     Session::set("role", $role, "SOAP");
                     Session::set("foo", "BAR", "SOAP");
                 } catch (Exception $ex) {
                     $status = 500;
                 }
             }
         }
         return $status;
     }
     return $status;
 }
Esempio n. 8
0
 /**
  * Process a Plugin Request
  *
  * @param $route SimpleXMLElement the route
  * @param $url string The URL
  * @return bool
  */
 private function _processPlugin($route, $url = "")
 {
     if (count($route["options"]) > 0) {
         $filter = Filter::getInstance();
         $options = $route["options"];
         $name = $options["plugin"];
         $action = $options["action"];
         $type = $route["type"];
         $this->_type = $type;
         $rparams = array("type" => $type, "name" => $name, "action" => $action);
         $this->_params = $rparams;
         $parameters = array();
         if (count($route["parameters"]) > 0) {
             foreach ($route["parameters"] as $parameter) {
                 $name = $parameter["name"];
                 $type = $parameter["type"];
                 $required = $parameter["required"];
                 $res = $this->_getParamValue($url, $name);
                 if (!$res) {
                     if ($required == "true") {
                         trigger_error("ROUTER | Parameter {$name} is required for {$route["path"]}", E_USER_WARNING);
                         return false;
                     }
                 } else {
                     $urlArr = explode("/", $url);
                     $urlArr = array_slice($urlArr, 3);
                     for ($pos = 0; $pos < count($urlArr); $pos++) {
                         if ($url[$pos] == $name) {
                             break;
                         }
                     }
                     $value = $this->_getParamValue($url, $name);
                     if (!empty($value)) {
                         try {
                             $value = trim($value);
                             if ($type == "string") {
                                 $res = $filter->isString($value);
                                 if (!$res) {
                                     trigger_error("ROUTER | Paramater {$name} must be type {$type} for {$route["path"]} using url {$url}", E_USER_WARNING);
                                     return false;
                                 } else {
                                     Request::registerParameter($name, $value);
                                 }
                             }
                             if ($type == "integer") {
                                 $res = $filter->isInteger($value);
                                 if ($res) {
                                     Request::registerParameter($name, $value);
                                 } else {
                                     trigger_error("ROUTER | Paramater {$name} must be type {$type} for {$route["path"]} using url {$url}", E_USER_WARNING);
                                     return false;
                                 }
                             }
                             if ($type == "float") {
                                 $res = $filter->isFloat($value);
                                 if ($res) {
                                     Request::registerParameter($name, $value);
                                 } else {
                                     trigger_error("ROUTER | Paramater {$name} must be type {$type} for {$route["path"]} using url {$url}", E_USER_WARNING);
                                     return false;
                                 }
                             }
                             if ($type == "boolean") {
                                 $res = $filter->isBoolean($value);
                                 if ($res) {
                                     Request::registerParameter($name, $value);
                                 } else {
                                     trigger_error("ROUTER | Paramater {$name} must be type {$type} for {$route["path"]} using url {$url}", E_USER_WARNING);
                                     return false;
                                 }
                             }
                         } catch (Exception $ex) {
                             trigger_error("ROUTER | An exception has been produced in the router {$ex->getMessage()} ", E_USER_WARNING);
                             return false;
                         }
                     }
                 }
                 $parameters[] = array("name" => $name, "type" => $type, "required" => $required);
             }
         }
         return true;
     }
     return false;
 }
Esempio n. 9
0
 public function __construct()
 {
     $this->_config = Config::getInstance();
     $this->_filter = Filter::getInstance();
 }
Esempio n. 10
0
 /**
  * Checks the parameter to be of a type
  *
  * @param $type string The type of the parameter
  * @param $value mixed The value of the parameter
  * @return bool
  */
 private function _checkParam($type, $value)
 {
     $filter = Filter::getInstance();
     if (!empty($value)) {
         try {
             $value = trim($value);
             if ($type == "string") {
                 $res = $filter->isString($value);
                 if (!$res) {
                     return false;
                 } else {
                     return true;
                 }
             }
             if ($type == "integer") {
                 $res = $filter->isInteger($value);
                 if ($res) {
                     return true;
                 } else {
                     return false;
                 }
             }
             if ($type == "float") {
                 $res = $filter->isFloat($value);
                 if ($res) {
                     return true;
                 } else {
                     return false;
                 }
             }
             if ($type == "boolean") {
                 $res = $filter->isBoolean($value);
                 if ($res) {
                     return true;
                 } else {
                     return false;
                 }
             }
         } catch (Exception $ex) {
             trigger_error("REST | Error while checking some parameter value of type={$type} and value={$value}: {$ex->getMessage()} ", E_USER_ERROR);
         }
     }
 }