本文整理汇总了PHP中ErrorHandler::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP ErrorHandler::getInstance方法的具体用法?PHP ErrorHandler::getInstance怎么用?PHP ErrorHandler::getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ErrorHandler
的用法示例。
在下文中一共展示了ErrorHandler::getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
public function init()
{
parent::init();
AuthController::getInstance()->requireLogin();
ErrorHandler::getInstance()->getUrlErrorMessage();
$this->setSmarty();
}
示例2: sendEmail
function sendEmail($recipient, $content, $subject = 'Notification', $includeStandardFooter = true)
{
$subject = 'lanlist.org - ' . $subject;
if (empty($content)) {
throw new Exception('Cannot send a blank email');
}
$content = wordwrap($content);
if ($includeStandardFooter) {
$content .= "\n\n- lanlist.org";
}
ErrorHandler::getInstance()->beLazy();
require_once 'Mail.php';
require_once 'Mail/smtp.php';
$host = 'ssl://smtp.gmail.com';
$username = 'xconspirisist@lanlist.org';
$password = 'ionicflame312';
$smtp = new Mail_smtp(array('host' => $host, 'port' => 465, 'auth' => true, 'username' => $username, 'password' => $password));
$headers = array('From' => '"lanlist.org" <mailer@lanlist.org>', 'To' => '<' . $recipient . '>', 'Subject' => $subject, 'Content-Type' => 'text/html');
$smtp->send('<' . $recipient . '>', $headers, $content);
ErrorHandler::getInstance()->beGreedy();
Logger::messageDebug('Sending email to ' . $recipient . ', subject: ' . $subject);
$sql = 'INSERT INTO email_log (subject, emailAddress, sent) VALUES (:subject, :emailAddress, now())';
$stmt = DatabaseFactory::getInstance()->prepare($sql);
$stmt->bindValue(':emailAddress', $recipient);
$stmt->bindValue(':subject', $subject);
$stmt->execute();
}
示例3: verify
/**
* Verifies a recaptcha
*
* @param $priv_key private recaptcha key
* @return true on success
*/
public function verify()
{
$error = ErrorHandler::getInstance();
$conf = RecaptchaConfig::getInstance();
if (empty($_POST['recaptcha_challenge_field']) || empty($_POST['recaptcha_response_field'])) {
$error->add('No captcha answer given.');
return false;
}
if (!$conf->getPublicKey() || !$conf->getPrivateKey()) {
die('ERROR - Get Recaptcha API key at http://recaptcha.net/api/getkey');
}
$params = array('privatekey' => $conf->getPrivateKey(), 'remoteip' => client_ip(), 'challenge' => $_POST['recaptcha_challenge_field'], 'response' => $_POST['recaptcha_response_field']);
$http = new HttpClient($this->api_url_verify);
$res = $http->post($params);
$answers = explode("\n", $res);
if (trim($answers[0]) == 'true') {
return true;
}
switch ($answers[1]) {
case 'incorrect-captcha-sol':
$e = 'Incorrect captcha solution';
break;
default:
$e = 'untranslated error: ' . $answers[1];
}
$error->add($e);
return false;
}
示例4: sendMail
/**
* Looks up user supplied email address / alias and sends a mail
*
* @param $email email address or username
*/
function sendMail($in)
{
$in = trim($in);
if (is_email($in)) {
$user_id = UserFinder::byEmail($in);
} else {
$user_id = UserFinder::byUsername($in);
}
$error = ErrorHandler::getInstance();
if (!$user_id) {
$error->add('Invalid email address or username');
return false;
}
$email = UserSetting::getEmail($user_id);
if (!$email) {
throw new \Exception('entered email not found');
}
$code = Token::generate($user_id, 'activation_code');
$pattern = array('/@USERNAME@/', '/@IP@/', '/@URL@/', '/@EXPIRETIME@/');
$user = User::get($user_id);
$page = XmlDocumentHandler::getInstance();
$url = $page->getUrl() . 'u/reset_pwd/' . $code;
$replacement = array($user->getName(), client_ip(), $url, shortTimePeriod($this->expire_time_email));
$msg = preg_replace($pattern, $replacement, $this->password_msg);
//d($msg);
$mail = SendMail::getInstance();
$mail->addRecipient($email);
$mail->setSubject('Forgot password');
$mail->send($msg);
return true;
}
示例5: onSubmit
function onSubmit($p)
{
$error = ErrorHandler::getInstance();
$res = base64_decode($p['data'], true);
if ($res === false) {
$error->add('Input is not base64 encoded');
return false;
}
echo dh($res);
}
示例6: uploadSubmit
function uploadSubmit($p)
{
if (!is_url($p['url'])) {
$error = ErrorHandler::getInstance();
$error->add('Not an url');
return false;
}
$eventId = TaskQueue::addTask(TASK_FETCH, $p['url']);
echo '<div class="okay">URL to process has been enqueued.</div><br/>';
echo ahref('queue/show/' . $eventId, 'Click here') . ' to perform further actions on this file.';
}
示例7: register
function register($username, $pwd1, $pwd2)
{
$error = ErrorHandler::getInstance();
$username = trim($username);
$pwd1 = trim($pwd1);
if (strlen($username) < $this->username_minlen) {
$error->add('Username must be at least ' . $this->username_minlen . ' characters long');
return false;
}
if (strlen($username) > $this->username_maxlen) {
$error->add('Username cant be longer than ' . $this->username_maxlen . ' characters long');
return false;
}
if (strlen($pwd1) < $this->password_minlen) {
$error->add('Password must be at least ' . $this->password_minlen . ' characters long');
return false;
}
if ($pwd1 != $pwd2) {
$error->add('Passwords dont match');
return false;
}
if ($username == $pwd1) {
$error->add('Username and password must be different');
return false;
}
if (User::getByName($username)) {
$error->add('Username taken');
return false;
}
if (ReservedWord::isReservedUsername($username)) {
$error->add('Username is reserved');
return false;
}
if (Password::isForbidden($pwd1)) {
$error->add('Your password is a very weak one and is forbidden to use');
return false;
}
$user_id = self::create($username, $pwd1);
if (!$user_id) {
$error->add('Failed to create user');
return false;
}
if ($this->post_reg_callback) {
call_user_func($this->post_reg_callback, $user_id);
}
return $user_id;
}
示例8: init
/**
* Initialize the application
*/
public function init()
{
// Load the application configuration
$this->singleton('conf', Conf::getInstance());
// Load the application error Handler
$this->singleton('errorHandler', ErrorHandler::getInstance());
// Load the application logger
$this->singleton('logger', Logger::getInstance());
// Load the filesystem library
$this->singleton('fs', FileSystem::getInstance());
// Load the application session
$this->singleton('session', Session::getInstance());
// Load the application router
$this->singleton('router', Router::getInstance());
// Load the application HTTP request
$this->singleton('request', Request::getInstance());
// Load the application HTTP response
$this->singleton('response', Response::getInstance());
// Load the application cache
$this->singleton('cache', Cache::getInstance());
}
示例9: handleSubmit
function handleSubmit($p)
{
$session = SessionHandler::getInstance();
$error = ErrorHandler::getInstance();
if (empty($p['comment'])) {
return false;
}
if (!$session->id) {
$error->add('Unauthorized submit');
return false;
}
$c = new Comment();
$c->type = $p['type'];
$c->msg = $p['comment'];
$c->private = 0;
$c->time_created = sql_datetime(time());
$c->owner = $p['owner'];
$c->creator = $session->id;
$c->creator_ip = client_ip();
$c->store();
redir($_SERVER['REQUEST_URI']);
}
示例10: render
public function render()
{
//available variables in the scope of the view
if (class_exists('\\cd\\ErrorHandler')) {
$error = ErrorHandler::getInstance();
}
if (class_exists('\\cd\\SessionHandler')) {
$session = SessionHandler::getInstance();
}
if (class_exists('\\cd\\SqlHandler')) {
$db = SqlHandler::getInstance();
}
if (class_exists('\\cd\\XhtmlHeader')) {
$header = XhtmlHeader::getInstance();
}
if (class_exists('\\cd\\XmlDocumentHandler')) {
$page = XmlDocumentHandler::getInstance();
}
if (class_exists('\\cd\\LocaleHandler')) {
$locale = LocaleHandler::getInstance();
}
if (class_exists('\\cd\\TempStore')) {
$temp = TempStore::getInstance();
}
// make reference to calling object available in the namespace of the view
$caller = $this->caller;
$file = $page->getCoreDevPath() . $this->template;
if (!file_exists($file)) {
// if not built in view, look in app dir
$file = $this->template;
if (!file_exists($file)) {
throw new \Exception('cannot find ' . $this->template);
}
}
ob_start();
require $file;
return ob_get_clean();
}
示例11: loadSettings
/**
* Retrieve main settings for application
* @return array
*/
public function loadSettings()
{
$cache = Cacher::getInstance();
if (($settings = $cache->load("settings")) === null) {
$settings = array();
foreach ($this->setting->findAll(new Criteria(), "`key`, `value`") as $row) {
$settings[$row['key']] = $row['value'];
}
$cache->save($settings, null, null, array("setting"));
}
foreach ($settings as $key => $value) {
Config::set($key, $value);
}
$rawUrl = parse_url(Config::get("siteRootUrl"));
Config::set("siteDomainUrl", "http://" . $rawUrl['host']);
$errorHandler = ErrorHandler::getInstance();
if (!Config::get('errorHandlerSaveToFileEnabled')) {
$errorHandler->setOption('saveToFile', false);
}
if (!Config::get('errorHandlerDisplayErrorEnabled')) {
$errorHandler->setOption('displayError', false);
}
}
示例12: writeDebug
/**
* Added informations for debug purposes only. In case the error it will showed and the result a node called "debug" will be added.
*
* @param string $key
* @param mixed $string
*/
public function writeDebug($key, $string)
{
if (is_null($this->responseDebug)) {
$this->responseDebug = new ResponseBag();
$this->response->add($this->responseDebug);
}
$this->responseDebug->add(['debug' => [$key => $string]]);
ErrorHandler::getInstance()->addExtraInfo($key, serialize($string));
}
示例13: microtime
<?php
/**
* Arfooo
*
* @package Arfooo
* @copyright Copyright (c) Arfooo Annuaire (fr) and Arfooo Directory (en)
* by Guillaume Hocine (c) 2007 - 2010
* http://www.arfooo.com/ (fr) and http://www.arfooo.net/ (en)
* @author Guillaume Hocine & Adrian Galewski
* @license http://creativecommons.org/licenses/by/2.0/fr/ Creative Commons
*/
$scriptStartTime = microtime(true);
ini_set("display_errors", "on");
ini_set("url_rewriter.tags", "");
error_reporting(E_ALL);
require_once CODE_ROOT_DIR . "config/main.php";
require_once Config::get('CORE_PATH') . "Core.php";
ErrorHandler::getInstance();
示例14: importImage
/**
* Helper function that imports a image file and shrinks it to max allowed dimensions
*/
public static function importImage($type, &$key, $category = 0, $blind = false, $max_width = 800, $max_height = 800)
{
$error = ErrorHandler::getInstance();
if (!file_exists($key['tmp_name'])) {
throw new \Exception('file ' . $key['tmp_name'] . ' dont exist!');
}
$info = getimagesize($key['tmp_name']);
switch ($info['mime']) {
case 'image/jpeg':
break;
case 'image/png':
break;
case 'image/gif':
break;
default:
$error->add('Uploaded file ' . $key['name'] . ' is not an image (mimetype ' . $info['mime'] . ')');
return false;
}
$fileId = self::import($type, $key, $category, $blind);
if (!$fileId) {
return false;
}
$im = new ImageResizer(File::get($fileId));
if ($im->width >= $max_width || $im->height >= $max_height) {
$im->resizeAspect($max_width, $max_height);
$im->render($im->mimetype, self::getUploadPath($fileId));
self::sync($fileId);
//updates tblFiles.size
}
return $fileId;
}
示例15: get_hint_messages
/**
* return the user interface error or succes messages
*/
public function get_hint_messages()
{
$error_hints = ErrorHandler::getInstance();
$error_hints->show_hint_messages();
}