当前位置: 首页>>代码示例>>PHP>>正文


PHP Validator::instance方法代码示例

本文整理汇总了PHP中Validator::instance方法的典型用法代码示例。如果您正苦于以下问题:PHP Validator::instance方法的具体用法?PHP Validator::instance怎么用?PHP Validator::instance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Validator的用法示例。


在下文中一共展示了Validator::instance方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: Send

 public static function Send($to, $subject, $message, $from = null)
 {
     $ret = false;
     $santizer = Validator::instance();
     $to = $santizer->Sanitize("email", $to);
     $subject = $santizer->Sanitize("string", $subject);
     $message = $santizer->Sanitize("string", $message);
     $from = $from === null ? "noreply" : $santizer->Sanitize("string", $from);
     $domain = "@sitandbefitresearch.org";
     if (!$santizer->Validate("email", $to)) {
         echo "The 'To' address('{$to}') is not a valid email";
     } else {
         $from .= $domain;
         $headers = array();
         $headers[] = "From: {$from}";
         $headers[] = "Reply-To: {$from}";
         $headers[] = "X-Mailer: PHP/" . phpversion();
         $headers = implode("\r\n", $headers);
         if ($_SERVER['SERVER_NAME'] === "localhost") {
             echo "Headers:\n\t{$headers}\n\n";
             echo "To:\n\t{$to}\n";
             echo "From:\n\t{$from}\n";
             echo "Subject:\n\t{$subject}\n";
             echo "Message:\n\t{$message}\n";
         } else {
             $ret = mail($to, $subject, $message, $headers);
         }
     }
     return $ret;
 }
开发者ID:sam25,项目名称:website,代码行数:30,代码来源:Mailer.php

示例2: GetInstance

 public static function GetInstance()
 {
     if (!self::$instance) {
         self::$instance = new Validator();
     }
     return self::$instance;
 }
开发者ID:studywithyou,项目名称:sayHello2,代码行数:7,代码来源:Validator.php

示例3: singleton

 public static function singleton($keepolderror = false)
 {
     if (self::$instance == null) {
         self::$instance = new Validator();
     }
     if (!$keepolderror) {
         self::$instance->errors = null;
     }
     return self::$instance;
 }
开发者ID:quangbt2005,项目名称:vhost-kis,代码行数:10,代码来源:Validator.php

示例4: implode

                    $valid = true;
                    if (!$this->validate($element_value, 1 + $args['level'])) {
                        $valid = false;
                    }
                }
            }
        }
        if (0 < count($this->errors) && 0 === $args['level']) {
            Util::log_error("Validation Failed:\n\n\t- " . implode("\n\t- ", $this->errors));
        }
        return $valid;
    }
    /**
     * @param Object $object
     * @param integer $level
     *
     * @return boolean
     */
    function validate_object($object, $level = 0)
    {
        $valid = true;
        foreach ($object->get_properties() as $property_name => $property) {
            if (!$object->do_validate_value($property_name, $level)) {
                $valid = false;
            }
        }
        return $valid;
    }
}
Validator::$instance = new Validator();
开发者ID:wplib,项目名称:json-loader,代码行数:30,代码来源:validator.php

示例5:

<?php

require_once "header.php";
$msg = "";
$id = Validator::instance()->sanitize("int", $_GET['id']);
//get the ID from the link to prevent people from inserting their own ID
// ****************************** Activate the user by ID ***********************************************************************
$select = QueryFactory::Build("select");
$select->Select("id", "email", "created", "activated")->From("users")->Where(["id", "=", $id])->Limit();
$res = DatabaseManager::Query($select);
$res = $res->Result();
if ($res["activated"] === 1) {
    $msg = ["Your account is already activated!", 1];
}
$userActivationHash = sha1($res["id"] . $res["email"] . $res["created"]);
// get user hash from database to compare against the link
if ($userActivationHash === $_GET['link']) {
    if (UserModel::updateElement($res["id"], "activated", "1")) {
        // if acctivation is a success
        $msg = ["Account activation successful!", 1];
    } else {
        $msg = ["Your account is already activated!", 0];
    }
} else {
    $msg = ["Invalid link, please try again!", 0];
}
?>


<div class="background">
	<h2><center> Activation </center></h2>
开发者ID:sam25,项目名称:website,代码行数:31,代码来源:activation.php

示例6: do_validate_value

 /**
  * @param string $property_name
  * @param integer $level
  *
  * @return boolean
  */
 function do_validate_value($property_name, $level = 0)
 {
     $valid = true;
     $property_value = $this->get_value($property_name);
     $property = $this->get_property($property_name);
     if ($property_value instanceof Object) {
         $valid = Validator::instance()->validate_object($property_value, $level);
     } else {
         if ($property->required && empty($property_value)) {
             $error_msg = "Property \"{$property->property_name}\" is required for the \"%s\" %s";
             $error_msg = sprintf($error_msg, $this->get_unique_id(), get_class($this));
             if (is_array($property_value) && 0 === count($property_value)) {
                 Util::log_error("{$error_msg} to have array elements.");
                 $valid = false;
             } else {
                 if (is_null($property_value)) {
                     Util::log_error("{$error_msg} to have array elements.");
                     $valid = false;
                 }
             }
         }
     }
     return $valid;
 }
开发者ID:wplib,项目名称:json-loader,代码行数:30,代码来源:object.php

示例7: __callStatic

 /**
  * 魔术方法(对外只暴露这一个方法)
  * @param  string $name      方法名称
  * @param  array  $arguments 参数
  * @return void
  */
 public static function __callStatic($method, $arguments)
 {
     if (!self::$instance instanceof self) {
         self::$instance = new self();
     }
     $instance = self::$instance;
     $function = "_{$method}";
     if (!is_callable(array($instance, $function))) {
         throw new Exception(sprintf('Method %s::%s Not Found', __CLASS__, $method));
     }
     return call_user_func_array(array($instance, $function), $arguments);
 }
开发者ID:timy-life,项目名称:segments,代码行数:18,代码来源:Validator.php

示例8: User

         $activated = $_POST['activated' . $id];
         $update = QueryFactory::Build("update")->Table('users');
         $update->Set(["email", $email], ["pLevel", $level], ["activated", $activated]);
         $update->Where(["id", "=", $id]);
         $res = DatabaseManager::Query($update);
         $rows += $res->RowCount();
     }
     if ($rows < 1) {
         $msg = ["Error: User(s) were not updated or there were no changes to save.", 0];
     } else {
         $msg = ["Users were successfully updated.", 1];
     }
     unset($res, $update, $email, $ids, $id, $level, $activated);
 } else {
     if (isset($_GET['delete']) && isset($_POST['id'])) {
         $id = (int) Validator::instance()->Sanitize("int", $_POST['id']);
         if (is_int($id)) {
             $delete = QueryFactory::Build("delete")->From("users")->Where(["id", "=", $id]);
             $res = DatabaseManager::Query($delete);
             if ($res->RowCount() > 0) {
                 $msg = ["User successfully deleted", 1];
             } else {
                 $msg = ["Error deleting user or user does not exist", 0];
             }
         }
     } else {
         if (isset($_GET['adduser']) && isset($_POST)) {
             $activated = $_POST['activated'] === "1" ? 1 : 0;
             UserModel::Register($_POST['email'], $_POST['pass'], $activated, $_POST['accesslevel']);
         }
     }
开发者ID:sam25,项目名称:website,代码行数:31,代码来源:users.php


注:本文中的Validator::instance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。