本文整理汇总了PHP中Error::Set方法的典型用法代码示例。如果您正苦于以下问题:PHP Error::Set方法的具体用法?PHP Error::Set怎么用?PHP Error::Set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Error
的用法示例。
在下文中一共展示了Error::Set方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: template_handler
function template_handler($resource_type, $resource_name, &$source_content, &$source_timestamp, &$smarty)
{
if ($filepath = Globe::Find($resource_name, array(APP_ROOT . SMARTY_TEMPLATE_DIR . DS, ENDO_ROOT . SMARTY_TEMPLATE_DIR . DS))) {
return set_resource($filepath, &$source_content, &$source_timestamp, &$smarty);
} else {
// not found. set error...
Error::Set("Template '" . Globe::CleanDir($filepath) . "' not found!");
return false;
}
}
示例2: signup
public function signup()
{
if ($this->data) {
if (!$this->data('email') || !$this->data('password')) {
Error::Set("Fields blank!", 'validation');
return false;
}
// create
$this->Model = AppModel::Create(CLASS_USER_MEMBER, $this->data);
// valid?
if ($this->Model->save()) {
$this->redirect('/users/login');
}
} else {
$this->assign(array('redirect_to' => null, 'email' => null));
}
}
示例3: SendEmail
static function SendEmail($to, $subject, $message)
{
if (Config::Get("email.use_PHPMailer")) {
require PLSPATH . 'classes/vendor/phpmailer/PHPMailerAutoload.php';
$mail = new PHPMailer();
if (Config::Get("email.use_smtp")) {
$mail->isSMTP();
}
$mail->Host = Config::Get("email.host");
$mail->Port = Config::Get("email.port");
$mail->SMTPAuth = Config::Get("email.smtp_auth");
$mail->Username = Config::Get("email.username");
$mail->Password = Config::Get("email.password");
$mail->SMTPSecure = Config::Get("email.smtp_secure");
$mail->From = Config::Get("email.from");
$mail->FromName = Config::Get("email.from_name");
$mail->addAddress($to);
$mail->Subject = $subject;
$mail->isHTML(true);
$mail->Body = $message;
if (!$mail->send()) {
Error::Set("mailer", "mailer");
return false;
} else {
return true;
}
} else {
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: ' . Config::Get("email.from_name") . ' <' . Config::Get("email.from") . '>';
if (!@mail($to, $subject, $message, $headers)) {
Error::Set("mailer", "mailer");
return false;
} else {
return true;
}
}
}
示例4: session_start
// --------------------------------------------------
require_once ENDO_ROOT . 'configure.php';
require_once ENDO_ROOT . INCLUDES_DIR . 'initialize.php';
require_once APP_ROOT . INCLUDES_DIR . 'initialize.php';
// Sessions
session_start();
// --------------------------------------------------
// URL
// --------------------------------------------------
Url::Parse(array_get($_REQUEST, 'url'));
// --------------------------------------------------
// Controller
// --------------------------------------------------
$Controller = Globe::Init(Url::$data['controller'], 'controller');
if (get_class($Controller) == 'stdClass') {
Error::Set("Create Controller '" . Url::$data['controllerName'] . "'!", 'fatal');
$Controller = Globe::Init('missing', 'controller');
}
// --------------------------------------------------
// Action
// --------------------------------------------------
// go through filters
$Controller->call_beforeFilter();
$Controller->call(Url::$data['action'], Url::$data['params'], Url::$data['type']);
$Controller->call_beforeRender();
if (!Error::IsFatal()) {
$Controller->render();
}
$Controller->call_afterRender();
$Controller->call_afterFilter();
// --------------------------------------------------
示例5: User
<?php
require_once '../config/init.php';
if (isset($_GET['id'])) {
$user = new User();
if (!$user->Load(array('id' => $_GET['id']))) {
Error::Set('user', 'usernotfound');
}
} else {
Error::Set('user', 'usernotfound');
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
</head>
<body style="text-align:center;margin:auto;width:300px;">
<?php
if (Error::HasErrors()) {
?>
<div class="message-box"> <!-- add your error class here -->
<ul><li><?php
echo Error::GetFirst();
?>
</li></ul>
</div>
<?php
} else {
?>
示例6: render
public function render()
{
// assign data
$this->assign($this->data);
// de-activate debug
if ($this->type != DEFAULT_REQUEST_TYPE) {
$this->View->debugging = false;
$this->View->error_reporting = false;
}
// render!
if (($template = $this->get_template()) != false) {
return $this->output = $this->View->fetch($template);
} else {
Error::Set('Couldn\'t render!');
return false;
}
}
示例7: AddUser
static function AddUser($fields, $use_captcha = false)
{
$data = array();
$validator = new Validate();
$result = $validator->AddValue('username', $fields['username'])->AddPattern('username-unique')->AddValue('email', $fields['email'])->AddPattern('email-unique')->Check();
if (isset($fields['password'])) {
$result = $validator->AddValue('password', $fields['password'])->AddPattern('password')->Check() && $result;
}
if (isset($fields['cpassword'])) {
$result = $validator->AddValue('cpassword', $fields['cpassword'])->AddRule('match', $fields['password'])->Check() && $result;
}
if ($use_captcha) {
$result = Validate::ValidCaptcha($fields['recaptcha_challenge_field'], $fields['recaptcha_response_field']) && $result;
}
if ($result) {
$data['username'] = $fields['username'];
$data['email'] = $fields['email'];
$data['password'] = isset($fields['password']) ? Validate::Encrypt($fields['password']) : '';
$data['user_type'] = isset($fields['user_type']) && $fields['user_type'] == 'admin' ? 'admin' : 'user';
$data['activation_state'] = isset($fields['activation_state']) && $fields['activation_state'] == '1' ? '1' : '0';
$info = array('phone', 'about', 'location', 'fullname', 'gender', 'social_id', 'social_type', 'activation_key', 'avatar');
foreach ($info as $value) {
$data[$value] = isset($fields[$value]) ? Validate::Escape($fields[$value]) : '';
}
$new_user = new User($data);
if ($new_user->Save()) {
return $new_user;
} else {
Error::Set("database", "databaseinsert");
}
}
return false;
}
示例8: Validator
private function Validator($name, $rules = array())
{
$value = array_shift($rules);
foreach ($rules as $rule => $rule_val) {
switch ($rule) {
case 'required':
if ($rule_val && empty($value)) {
Error::Set($name, $name . 'required');
return false;
}
break;
case 'min':
if (strlen($value) < $rule_val) {
Error::Set($name, $name . 'min');
return false;
}
break;
case 'max':
if (strlen($value) > $rule_val) {
Error::Set($name, $name . 'max');
return false;
}
break;
case 'unique':
$db = new Database();
if ($db->Select($name)->Where($name, $value)->Limit(1)->Get($rule_val)) {
Error::Set($name, $name . 'unique');
return false;
}
break;
case 'match':
if ($value !== $rule_val) {
Error::Set($name, $name . 'match');
return false;
}
break;
case 'contents':
switch ($rule_val) {
case 'nospecialchar':
if (!preg_match('/^[a-zA-Z0-9]+[a-zA-Z0-9\\_\\.]+[a-zA-Z0-9]+$/i', $value)) {
Error::Set($name, $name . 'contents');
return false;
}
break;
case 'email':
if (!filter_var($value, FILTER_VALIDATE_EMAIL)) {
Error::Set($name, $name . 'contents');
return false;
}
break;
case 'alphanumeric':
if (!ctype_alnum($value)) {
Error::Set($name, $name . 'contents');
return false;
}
break;
case 'numeric':
if (!ctype_digit($value)) {
Error::Set($name, $name . 'contents');
return false;
}
break;
default:
return false;
break;
}
break;
default:
return false;
break;
}
}
return true;
}
示例9: GetCurrent
/**
* This is basically the 'Login' function.
* It cycles through different possible locations for the user,
* lastly checking if a login is occurring.
*
* @return User object. FALSE on fail.
*/
static function GetCurrent()
{
// session?
if ($session = AppUser::GetSession()) {
if ($user = AppUser::FetchFromString($session)) {
return $user;
}
} elseif ($cookie = AppUser::GetCookie()) {
if ($user = AppUser::FetchFromString($cookie)) {
return $user;
}
} elseif (Url::GetRequest('check_data', false) && ($email = Url::GetRequest('email', false)) && ($password = Url::GetRequest('password', false))) {
// valid?
if (($user = AppUser::FetchUser($email)) && $user->validate($password)) {
return AppUser::SetCurrent($user);
} else {
Error::Set("Invalid Email and/or Password", 'validation');
}
}
// create Guest...
return AppModel::Create(AppUser::$levels[0]);
}
示例10: Find
static function Find($filename = '', $paths = array(), $hit_cache = true)
{
// read cache?
if ($hit_cache && empty(self::$caches[STR_FINDCACHE])) {
self::$caches[STR_FINDCACHE] = self::FileGetSplit(APP_ROOT . CACHES_DIR . STR_FINDCACHE);
}
// check cache
if ($hit_cache && array_key_exists($filename, self::$caches[STR_FINDCACHE])) {
// return found in cache!
return self::$caches[STR_FINDCACHE][$filename][0];
} else {
// else, cascade through paths
foreach ($paths as $path) {
if (file_exists($result = $path . $filename)) {
// save found to cache
if ($hit_cache) {
file_put_contents(APP_ROOT . CACHES_DIR . STR_FINDCACHE, $filename . "|" . $result . "\n", FILE_APPEND);
}
// return found!
return $result;
}
}
// else, check scaffolding
$scaffold_paths = array(APP_ROOT . SMARTY_SCAFFOLD_DIR . DS, ENDO_ROOT . SMARTY_SCAFFOLD_DIR . DS);
$scaffold_filename = ($ds_pos = strpos($filename, DS)) !== false ? substr($filename, $ds_pos + 1) : $filename;
foreach ($scaffold_paths as $path) {
if (file_exists($result = $path . $scaffold_filename)) {
// return scaffold!
return $result;
}
}
// not found. set error...
Error::Set("File '{$filename}' not found in cascade <pre>" . print_r(array_merge($paths, $scaffold_paths), true) . "</pre>");
return false;
}
}
示例11: TwitterOAuth
}
} else {
Error::Set('twitter', 'unexpectederror');
}
} else {
$connection = new TwitterOAuth($CONSUMER_KEY, $CONSUMER_SECRET);
$request_token = @$connection->getRequestToken($OAUTH_CALLBACK);
if (isset($request_token['oauth_token']) && isset($request_token['oauth_token_secret'])) {
$_SESSION['request_token'] = $request_token['oauth_token'];
$_SESSION['request_token_secret'] = $request_token['oauth_token_secret'];
if ($connection->http_code == 200) {
$url = $connection->getAuthorizeURL($request_token['oauth_token']);
header('Location: ' . $url);
}
} else {
Error::Set('twitter', 'Failed to validate oauth signature and token.');
}
}
} else {
header("Location: ../index.php");
}
}
}
}
if (Authentication::IsLogged()) {
header("Location: ../index.php");
}
?>
<!DOCTYPE html>
<html>
<head>
示例12: Crop
static function Crop()
{
if (Session::Get('current_user_temp_avatar')) {
$user = Session::Get('current_user');
$src = PLSPATH . Config::Get("avatar.upload_path") . Session::Get('current_user_temp_avatar');
$temp = explode(".", $src);
$extension = strtolower(end($temp));
switch ($extension) {
case 'jpeg':
case 'jpg':
$img_r = @imagecreatefromjpeg($src);
break;
case 'png':
$img_r = @imagecreatefrompng($src);
break;
case 'gif':
$img_r = @imagecreatefromgif($src);
break;
}
if (!$img_r) {
Error::Set('avatar', 'imagecorrupt');
return false;
} else {
$targ_w = $targ_h = Config::Get('avatar.resolution');
$dst_r = ImageCreateTrueColor($targ_w, $targ_h);
if ($extension == "png") {
imagealphablending($dst_r, false);
imagesavealpha($dst_r, true);
}
$size = getimagesize($src);
if ($_POST['w'] > 0 && $_POST['h'] > 0 && $_POST['w'] <= $size[0] && $_POST['h'] <= $size[1]) {
$x = $_POST['x'];
$y = $_POST['y'];
$width = $_POST['w'];
$height = $_POST['h'];
} else {
$min_size = min($size[0], $size[1]);
if ($size[0] > $size[1]) {
$x = $size[0] / 2 - $min_size / 2;
$y = 0;
} else {
$x = 0;
$y = $size[1] / 2 - $min_size / 2;
}
$width = $height = $min_size;
}
imagecopyresampled($dst_r, $img_r, 0, 0, $x, $y, $targ_w, $targ_h, $width, $height);
@unlink($src);
$filename = md5($user->Get('id')) . "." . $extension;
$filepath = Config::Get('base_url') . Config::Get('avatar.upload_path') . $filename;
$src = PLSPATH . Config::Get('avatar.upload_path') . $filename;
switch ($extension) {
case 'jpeg':
case 'jpg':
imagejpeg($dst_r, $src, 90);
break;
case 'png':
imagepng($dst_r, $src);
break;
case 'gif':
imagegif($dst_r, $src);
break;
}
unset($_SESSION['current_user_temp_avatar']);
$user->Set('avatar', $filepath . '?' . time());
return $user->Save();
}
}
}
示例13: Login
static function Login($fields, $encrypted = false)
{
$username = $fields['username'];
$password = $fields['password'];
$validator = new Validate();
$result = $validator->AddValue('usernameoremail', $username)->AddRule('required', true)->AddValue('password', $password)->AddRule('required', true)->Check();
if (!$encrypted) {
$password = Validate::Encrypt($password);
}
if ($result) {
if (strpos($username, '@') !== false) {
$type = "email";
} else {
$type = "username";
$username = Validate::Escape($username);
}
$user = new User();
$result = $user->Load(array($type => $username, 'password' => $password));
if ($result) {
if ($user->Get('activation_state') == '0') {
Error::Set("email", "notactivated");
} else {
if (isset($fields['rememberme'])) {
Cookie::Set($username, $password);
}
Session::Set("current_user", $user);
return true;
}
} else {
Error::Set("username", "usernotfound");
}
}
return false;
}