本文整理汇总了PHP中Error::set方法的典型用法代码示例。如果您正苦于以下问题:PHP Error::set方法的具体用法?PHP Error::set怎么用?PHP Error::set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Error
的用法示例。
在下文中一共展示了Error::set方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: char
public function char($str = '', $limit = 500, $endChar = '...', $stripTags = false, $encoding = "utf-8")
{
if (!is_string($str)) {
return Error::set(lang('Error', 'stringParameter', 'str'));
}
if (!is_numeric($limit)) {
$limit = 500;
}
if (!is_string($endChar)) {
$endChar = '...';
}
if (!is_bool($stripTags)) {
$stripTags = true;
}
$str = trim($str);
if (empty($str)) {
return $str;
}
if ($stripTags === true) {
$str = strip_tags($str);
}
$str = preg_replace("/\\s+/", ' ', str_replace(array("\r\n", "\r", "\n", " "), ' ', $str));
if (strlen($str) <= $limit) {
return $str;
} else {
return mb_substr($str, 0, $limit, $encoding) . $endChar;
}
}
示例2: decodeArray
public function decodeArray($data = '', $length = 512)
{
if (!is_string($data)) {
return Error::set('Error', 'stringParameter', '1.(data)');
}
return json_decode($data, true, $length);
}
示例3: index
public function index($arguments)
{
$news = new news(ConnectionFactory::get('mongo'));
$articles = new articles(ConnectionFactory::get('mongo'));
$notices = new notices(ConnectionFactory::get('redis'));
$irc = new irc(ConnectionFactory::get('redis'));
$quotes = new quotes(ConnectionFactory::get('mongo'));
$forums = new forums(ConnectionFactory::get('redis'));
// Set all site-wide notices.
foreach ($notices->getAll() as $notice) {
Error::set($notice, true);
}
// Fetch the easy data.
$this->view['news'] = $news->getNewPosts();
$this->view['shortNews'] = $news->getNewPosts(true);
$this->view['newArticles'] = $articles->getNewPosts('new', 1, 5);
$this->view['ircOnline'] = $irc->getOnline();
$this->view['randomQuote'] = $quotes->getRandom();
$this->view['fPosts'] = $forums->getNew();
// Get online users.
$apc = new APCIterator('user', '/' . Cache::PREFIX . 'user_.*/');
$this->view['onlineUsers'] = array();
while ($apc->valid()) {
$current = $apc->current();
array_push($this->view['onlineUsers'], substr($current['key'], strlen(Cache::PREFIX) + 5));
$apc->next();
}
// Set title.
Layout::set('title', 'Home');
}
示例4: word
public function word($string = '', $badWords = '', $changeChar = '[badwords]')
{
if (!isValue($string)) {
return Error::set(lang('Error', 'valueParameter', 'string'));
}
if (!is_array($badWords)) {
if (empty($badWords)) {
return $string;
}
return $string = Regex::replace($badWords, $changeChar, $string, 'xi');
}
$ch = '';
$i = 0;
if (!empty($badWords)) {
foreach ($badWords as $value) {
if (!is_array($changeChar)) {
$ch = $changeChar;
} else {
if (isset($changeChar[$i])) {
$ch = $changeChar[$i];
$i++;
}
}
$string = Regex::replace($value, $ch, $string, 'xi');
}
}
return $string;
}
示例5: uncompress
public function uncompress($data = '', $small = 0)
{
if (!isValue($data)) {
return Error::set(lang('Error', 'valueParameter', '1.(data)'));
}
return lzf_decompress($data);
}
示例6: check
public function check()
{
$this->setView('reclaim/index');
if (Session::isLoggedIn()) {
return Error::set('You\'re logged in!');
}
$this->view['valid'] = true;
$this->view['publicKey'] = Config::get('recaptcha:publicKey');
if (empty($_POST['recaptcha_challenge_field']) || empty($_POST['recaptcha_response_field'])) {
return Error::set('We could not find the captcha validation fields!');
}
$recaptcha = Recaptcha::check($_POST['recaptcha_challenge_field'], $_POST['recaptcha_response_field']);
if (is_string($recaptcha)) {
return Error::set(Recaptcha::$errors[$recaptcha]);
}
if (empty($_POST['username']) || empty($_POST['password'])) {
return Error::set('All forms are required.');
}
$reclaims = new reclaims(ConnectionFactory::get('mongo'));
$good = $reclaims->authenticate($_POST['username'], $_POST['password']);
if (!$good) {
return Error::set('Invalid username/password.');
}
$reclaims->import($_POST['username'], $_POST['password']);
$users = new users(ConnectionFactory::get('mongo'));
$users->authenticate($_POST['username'], $_POST['password']);
header('Location: ' . Url::format('/'));
}
示例7: _init
private static function _init($access_type, $category_name)
{
$access_id = $category_id = 0;
if (!strlen($access_type)) {
Error::set(MISSING_ACCESS_TYPE);
return false;
} else {
$access_id = self::getAccessTypeId($access_type);
if (!$access_id) {
Error::set(NOT_MATCHING_ACCESS_TYPE);
return false;
}
}
if (!strlen($category_name)) {
Error::set(MISSING_CATEGORY_NAME);
return false;
} else {
$category_id = self::getCategoryId($category_name);
if (!$category_id) {
Error::set(NOT_MATCHING_CATEGORY_NAME);
return false;
}
}
if ($category_id && $access_id) {
$db = new Db();
$category_id = $db->quote($category_id);
$access_id = $db->quote($access_id);
$query = "SELECT * FROM menu where category_id = {$category_id} AND access_type = {$access_id} AND active = 1 order by menu_order ASC";
return $db->select($query);
}
return false;
}
示例8: save
public function save()
{
if (is_numeric($this->page_id) && is_string($this->page_name)) {
$db = new Db();
$id = $db->quote($this->page_id);
$category_id = $db->quote($this->category_id);
$name = $db->quote($this->page_name);
$url = $db->quote($this->url);
$top_description = $db->quote($this->top_description);
$bottem_description = $db->quote($this->bottom_description);
$keyword = $db->quote($this->keyword);
$title = $db->quote($this->title);
$description = $db->quote($this->description);
$access_type = $db->quote($this->access_type);
$active = $db->quote($this->page_status);
$author = $db->quote(1);
$modified = $db->quote(1);
$query = "INSERT INTO " . $this->tableName() . " (page_id, category_id, name, url, top_description, bottem_description, \n Keyword, title, description, author, modified_by, access_type, active) \n VALUES({$id}, {$category_id}, {$name}, {$url}, {$top_description}, {$bottem_description}, {$keyword}, {$title}, {$description},\n {$author}, {$modified}, {$access_type}, {$active})\n ON DUPLICATE KEY UPDATE \n name= {$name}, category_id={$category_id}, url={$url},top_description={$top_description}, bottem_description={$bottem_description}, \n Keyword={$keyword}, title={$title}, description={$description}, author={$author}, modified_by={$modified}, \n active={$active}, access_type={$access_type}";
if ($db->query($query)) {
return true;
} else {
Error::set($db->error());
}
}
return false;
}
示例9: word
public function word($string = '', $badWords = '', $changeChar = '[badwords]')
{
if (!is_scalar($string)) {
return Error::set('Error', 'valueParameter', 'string');
}
return str_ireplace($badWords, $changeChar, $string);
}
示例10: confirm
public function confirm($arguments)
{
if (Session::isLoggedIn()) {
return Error::set(self::ERR_LOGGED_IN);
}
if (empty($arguments[0])) {
return Error::set(self::ERR_NO_LOST_ID);
}
if (empty($arguments[1]) || $arguments[1] != 'auth' && $arguments[1] != 'password') {
return Error::set(self::ERR_INIVALID_MODE);
}
$passReset = new passwordReset(ConnectionFactory::get('redis'));
$info = $passReset->get($arguments[0], $arguments[1] == 'auth' ? true : false);
if (is_string($info)) {
return Error::set($info);
}
$users = new users(ConnectionFactory::get('mongo'));
if ($arguments[1] == 'auth') {
$users->changeAuth($info[1], true, false, false, false);
$this->view['password'] = false;
} else {
$password = $users->resetPassword($info[1]);
$this->view['password'] = $password;
}
}
示例11: data
public function data($str = '', $data = array())
{
if (!is_string($str)) {
return Error::set(lang('Error', 'stringParameter', 'str'));
}
$bladeChars = array('{{{' => '<?php echo "', '}}}' => '" ?>', '{{--' => '<!-- ', '--}}' => ' -->', '{{' => '<?php echo ', '}}' => ' ?>', '{[' => '<?php', ']}' => '?>');
$endKeywords = array('foreach', 'for', 'while', 'if', 'switch');
$newData = str_replace(array_keys($bladeChars), array_values($bladeChars), $str);
$newDatas = array();
preg_match_all('/\\B@.+\\B/', $newData, $matchData);
if (!empty($matchData[0])) {
foreach ($matchData[0] as $val) {
$new = str_replace('@', '??', $val);
preg_match('/\\w+/', $new, $matchKeyword);
$matchKeyword = isset($matchKeyword[0]) ? $matchKeyword[0] : NULL;
if (in_array(strtolower(trim($matchKeyword)), $endKeywords) && !strstr($new, ':')) {
$new .= ':';
}
$newDatas[$val] = $new . ' ?>';
}
}
$newData = str_replace(array_keys($newDatas), array_values($newDatas), $newData);
$newData = preg_replace('/\\?\\?/', '<?php ', $newData);
if (is_array($data)) {
extract($data, EXTR_OVERWRITE, 'extract');
}
ob_start();
eval("?>{$newData}");
$content = ob_get_contents();
ob_end_clean();
return $content;
}
示例12: error
public function error()
{
if (isset($this->error)) {
return Error::set($this->error);
} else {
return false;
}
}
示例13: type
public function type($type = 'text/css')
{
if (!is_string($type)) {
Error::set('Error', 'stringParameter', 'type');
return $this;
}
$this->type = $type;
return $this;
}
示例14: type
public function type($type = 'text/javascript')
{
if (!is_string($type)) {
Error::set(lang('Error', 'stringParameter', 'type'));
return $this;
}
$this->type = $type;
return $this;
}
示例15: data
public function data($string = '', $data = array())
{
// Parametre konrolleri sağlanıyor.
if (!is_string($string)) {
return Error::set('Error', 'stringParameter', 'string');
}
$eol = eol();
// Veri dizisi boş değilse işlemleri gerçekleştir.
if (!empty($data)) {
$space = '\\s*';
$all = '.*';
foreach ($data as $key => $val) {
// Eleman dizi değilse değiştirme işlemi gerçekleştir.
if (!is_array($val)) {
$key = $this->ldel . $space . $key . $space . $this->rdel;
$string = preg_replace('/' . $key . '/', $val, $string);
} else {
$allString = '';
$newResult = '';
if (!empty($val)) {
$kstart = $this->ldel . $space . $key . $space . $this->rdel;
$kend = $this->ldel . $space . '\\/' . $space . $key . $space . $this->rdel;
preg_match('/' . $kstart . $all . $kend . '/s', $string, $result);
if (!empty($result)) {
// Bloğu değiştirme ve çoğalatma
// işlemi gerçekleştir.
foreach ($result as $res) {
// Değiştirme işlemlerini gerçekleştir.
foreach ($data[$key] as $item) {
$newResult = preg_replace('/' . $kstart . '/', '', $res);
$newResult = preg_replace('/' . $kend . '/', '', $newResult);
$allString .= $this->data($newResult, $item) . $eol;
}
$string = str_replace($res, $allString, $string);
}
}
}
}
}
}
$regexChar = '(([^@]|(\'|\\").*?(\'|\\"))*)';
$htmlRegexChar = '.*?';
$pattern = array('/\\s*\\#end(\\w+)/i' => '</$1>', '/\\#\\#(\\!*\\w+)\\s*\\((' . $htmlRegexChar . ')\\)/i' => '<$1 $2>', '/\\s*\\#\\#(\\w+)/i' => '</$1>', '/\\#(\\!*\\w+)\\s*\\((' . $htmlRegexChar . ')(\\s*\\,\\s*(' . $htmlRegexChar . '))*\\)/i' => '<$1 $4>$2</$1>', '/\\#(\\!*\\w+)\\s*(\\[(' . $htmlRegexChar . ')\\])*\\s*/i' => '<$1 $3>', '/\\<(\\!*\\w+)\\s+\\>/i' => '<$1>', '/\\$\\(\'\\s*\\<(.*?)\\>\\s*\'\\)/i' => '$(\'#$1\')', '/\\$\\(\\"\\s*\\<(.*?)\\>\\s*\\"\\)/i' => '$("#$1")', '/@(if)\\s*(\\(' . $htmlRegexChar . '\\))' . $eol . '\\s*/' => '<?php $1$2: ?>', '/\\s*@(elseif)\\s*(\\(' . $htmlRegexChar . '\\))' . $eol . '\\s*/' => '<?php $1$2: ?>', '/\\s*@(endif)/' => '<?php $1 ?>', '/@(foreach)\\s*(\\(' . $htmlRegexChar . '\\))' . $eol . '\\s*/' => '<?php $1$2: ?>', '/\\s*@(endforeach)/' => '<?php $1 ?>', '/@(for)\\s*(\\(' . $htmlRegexChar . '\\))' . $eol . '\\s*/' => '<?php $1$2: ?>', '/\\s*@(endfor)/' => '<?php $1 ?>', '/@(while)\\s*(\\(' . $htmlRegexChar . '\\))' . $eol . '\\s*/' => '<?php $1$2: ?>', '/\\s*@(endswhile)/' => '<?php $1 ?>', '/@(break)/' => '<?php $1 ?>', '/@(continue)/' => '<?php $1 ?>', '/@(default)/' => '<?php $1: ?>', '/@@((\\w+|\\$|::|\\s*\\-\\>\\s*)*\\s*\\(' . $regexChar . '\\))/' => '<?php echo $1 ?>', '/@((\\w+|\\$|::|\\s*\\-\\>\\s*)*\\s*\\(' . $regexChar . '\\))/' => '<?php $1 ?>', '/@(\\$\\w+(\\$|::|\\s*\\-\\>\\s*|\\(' . $regexChar . '\\))*)/' => '<?php echo $1 ?>', '/\\{\\-\\-\\s*(' . $htmlRegexChar . ')\\s*\\-\\-\\}/' => '<!--$1-->', '/\\{\\{\\{\\s*(' . $htmlRegexChar . ')\\s*\\}\\}\\}/' => '<?php echo htmlentities($1) ?>', '/\\{\\{(\\s*' . $htmlRegexChar . ')\\s*\\}\\}/' => '<?php echo $1 ?>', '/\\{\\[\\s*(' . $htmlRegexChar . ')\\s*\\]\\}/' => '<?php $1 ?>');
$string = preg_replace(array_keys($pattern), array_values($pattern), $string);
if (is_array($data)) {
extract($data, EXTR_OVERWRITE);
}
ob_start();
@eval("?>{$string}");
$content = ob_get_contents();
ob_end_clean();
if ($lastError = Error::last()) {
Exceptions::table('', $lastError['message'], '', $lastError['line']);
} else {
return $content;
}
}