本文整理匯總了PHP中Filter::getInstance方法的典型用法代碼示例。如果您正苦於以下問題:PHP Filter::getInstance方法的具體用法?PHP Filter::getInstance怎麽用?PHP Filter::getInstance使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Filter
的用法示例。
在下文中一共展示了Filter::getInstance方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: __construct
/**
* 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();
}
示例2: _setUp
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);
}
}
}
示例3: index
/**
* 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');
}
示例4: unserialize
/**
* 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();
}
}
示例5: __construct
/**
* 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();
}
}
示例6: tokens
/**
* @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;
}
示例7: SOAPLogin
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='{$username}' AND password='{$passSHA1}' ";
$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;
}
示例8: _processPlugin
/**
* 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;
}
示例9: __construct
public function __construct()
{
$this->_config = Config::getInstance();
$this->_filter = Filter::getInstance();
}
示例10: _checkParam
/**
* 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);
}
}
}