• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

PHP error_code函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中error_code函数的典型用法代码示例。如果您正苦于以下问题:PHP error_code函数的具体用法?PHP error_code怎么用?PHP error_code使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: trigger

 /**
  * Is used as error handler
  *
  * @param int			$level	Error level
  * @param null|string	$string	Error message
  */
 function trigger($level, $string = null)
 {
     if (!$this->error) {
         return;
     }
     $string = xap($string);
     $dump = 'null';
     $debug_backtrace = debug_backtrace();
     if (isset($debug_backtrace[0]['file'], $debug_backtrace[0]['file'])) {
         $file = $debug_backtrace[0]['file'];
         $line = $debug_backtrace[0]['line'];
     } else {
         $file = $debug_backtrace[1]['file'];
         $line = $debug_backtrace[1]['line'];
     }
     if (DEBUG) {
         $dump = _json_encode($debug_backtrace);
     }
     unset($debug_backtrace);
     $log_file = LOGS . '/' . date('d-m-Y') . '_' . strtr(date_default_timezone_get(), '/', '_');
     $time = date('d-m-Y h:i:s') . ' [' . microtime(true) . ']';
     switch ($level) {
         case E_USER_ERROR:
         case E_ERROR:
             ++$this->num;
             file_put_contents($log_file, "E {$time} {$string} Occurred: {$file}:{$line} Dump: {$dump}\n", LOCK_EX | FILE_APPEND);
             unset($dump);
             $this->errors_list[] = "E {$time} {$string} Occurred: {$file}:{$line}";
             error_code(500);
             /**
              * If Index instance exists - execution will be stopped there, otherwise in Page instance
              */
             Index::instance(true)->__finish();
             Page::instance()->error();
             break;
         case E_USER_WARNING:
         case E_WARNING:
             ++$this->num;
             file_put_contents($log_file, "W {$time} {$string} Occurred: {$file}:{$line} Dump: {$dump}\n", LOCK_EX | FILE_APPEND);
             unset($dump);
             $this->errors_list[] = "W {$time} {$string} Occurred: {$file}:{$line}";
             break;
         default:
             file_put_contents($log_file, "N {$time} {$string} Occurred: {$file}:{$line} Dump: {$dump}\n", LOCK_EX | FILE_APPEND);
             unset($dump);
             $this->errors_list[] = "N {$time} {$string} Occurred: {$file}:{$line}";
             break;
     }
     /**
      * If too many non-critical errors - also stop execution
      */
     if ($this->num >= 100) {
         /**
          * If Index instance exists - execution will be stopped there, otherwise in Page instance
          */
         Index::instance(true)->__finish();
         Page::instance()->error();
     }
 }
开发者ID:hypnomez,项目名称:opir.org,代码行数:65,代码来源:Error.php


示例2: error_code

if (!isset($_POST['stream_code'], $_POST['lat'], $_POST['lng'])) {
    error_code(400);
    return;
}
$User = User::instance();
if (!in_array(STREAMER_GROUP, $User->get_groups())) {
    error_code(403);
    return;
}
$stream_code = trim($_POST['stream_code']);
if (preg_match('/ustream.tv\\/(channel|embed)\\/([0-9]+)/', $stream_code, $m)) {
    $stream_code = "https://www.ustream.tv/embed/{$m['2']}";
} elseif (preg_match('/(youtube.com\\/embed\\/|youtube.com\\/watch\\?v=)([0-9a-z\\-]+)/i', $stream_code, $m)) {
    $stream_code = "https://www.youtube.com/embed/{$m['2']}";
} elseif ($stream_code != '') {
    error_code(400);
    return;
}
$User->set_data('stream_url', $stream_code);
$Events = Events::instance();
$event = $User->get_data('stream_event');
if ($event) {
    $Events->del($event);
}
if ($stream_code) {
    $event = Events::instance()->add(STREAM_CATEGORY, 120, $_POST['lat'], $_POST['lng'], 0, "stream:{$stream_code}", 'urgent', 2, 30, '');
    if (!$event) {
        error_code(500);
    }
    $User->set_data('stream_event', $event);
}
开发者ID:hypnomez,项目名称:opir.org,代码行数:31,代码来源:stream.put.php


示例3: sleep

 */
if (!$Config->server['referer']['local'] || !$Config->server['ajax'] || !isset($_POST['verify_hash'], $_POST['new_password']) || !$User->user()) {
    sleep(1);
    error_code(403);
    return;
} elseif (!$_POST['new_password']) {
    error_code(400);
    $Page->error($L->please_type_new_password);
    return;
} elseif (hash('sha224', $User->password_hash . $User->get_session()) != $_POST['verify_hash']) {
    error_code(400);
    $Page->error($L->wrong_current_password);
    return;
} elseif (($new_password = xor_string($_POST['new_password'], $User->password_hash)) == $User->password_hash) {
    error_code(400);
    $Page->error($L->current_new_password_equal);
    return;
}
if ($new_password == hash('sha512', hash('sha512', '') . Core::instance()->public_key)) {
    error_code(400);
    $Page->error($L->please_type_new_password);
    return;
}
$id = $User->id;
if ($User->set('password_hash', $new_password)) {
    $User->add_session($id);
    $Page->json('OK');
} else {
    error_code(400);
    $Page->error($L->change_password_server_error);
}
开发者ID:hypnomez,项目名称:opir.org,代码行数:31,代码来源:change_password.php


示例4: error_code

<?php

/**
 * @package		CleverStyle CMS
 * @subpackage	System module
 * @category	modules
 * @author		Nazar Mokrynskyi <[email protected]>
 * @copyright	Copyright (c) 2011-2014, Nazar Mokrynskyi
 * @license		MIT License, see license.txt
 */
namespace cs;

$User = User::instance();
if ($User->guest()) {
    error_code(403);
    return;
}
$fields = ['id', 'login', 'username', 'language', 'timezone', 'avatar'];
$Page = Page::instance();
$id = $User->id;
$Page->json($User->get($fields, $id));
开发者ID:hypnomez,项目名称:opir.org,代码行数:21,代码来源:profile.get.php


示例5: error

 /**
  * Error pages processing
  *
  * @param null|string|string[]	$custom_text	Custom error text instead of text like "404 Not Found",
  * 												or array with two elements: [error, error_description]
  * @param bool					$json			Force JSON return format
  */
 function error($custom_text = null, $json = false)
 {
     static $error_showed = false;
     if ($error_showed) {
         return;
     }
     $error_showed = true;
     if (!defined('ERROR_CODE')) {
         error_code(500);
     }
     if (defined('API') && !API && ERROR_CODE == 403 && _getcookie('sign_out')) {
         header('Location: ' . Config::instance()->base_url(), true, 302);
         $this->Content = '';
         exit;
     }
     interface_off();
     $error = code_header(ERROR_CODE);
     if (is_array($custom_text)) {
         $error = $custom_text[0];
         $error_description = $custom_text[1];
     } else {
         $error_description = $custom_text ?: $error;
     }
     if (defined('API') && API || $json) {
         if ($json) {
             header('Content-Type: application/json; charset=utf-8', true);
             interface_off();
         }
         $this->json(['error' => $error, 'error_description' => $error_description]);
     } else {
         ob_start();
         if (!_include_once(THEMES . "/{$this->theme}/error.html", false) && !_include_once(THEMES . "/{$this->theme}/error.php", false)) {
             echo "<!doctype html>\n" . h::title(code_header($error)) . ($error_description ?: $error);
         }
         $this->Content = ob_get_clean();
     }
     $this->__finish();
     exit;
 }
开发者ID:hypnomez,项目名称:opir.org,代码行数:46,代码来源:Page.php


示例6: switch

<?php

/**
 * @package		Package
 * @category	modules
 * @author		Nazar Mokrynskyi <[email protected]>
 * @copyright	Copyright (c) 2014, Nazar Mokrynskyi
 * @license		MIT License, see license.txt
 */
namespace cs;

$rc = Config::instance()->route;
if (!isset($rc[0])) {
    return;
}
switch ($rc[0]) {
    case 'profile':
    case path(Language::instance()->profile):
        error_code(404);
}
开发者ID:hypnomez,项目名称:opir.org,代码行数:20,代码来源:index.php


示例7: init

 /**
  * Initialization: loading of module structure, including of necessary module files, inclusion of save file
  */
 protected function init()
 {
     $Config = Config::instance();
     $L = Language::instance();
     $Page = Page::instance();
     $User = User::instance();
     /**
      * Some routing preparations
      */
     $rc_path =& $this->route_path;
     $rc_ids =& $this->route_ids;
     foreach ($Config->route as &$item) {
         if (is_numeric($item)) {
             $rc_ids[] =& $item;
         } else {
             $rc_path[] =& $item;
         }
     }
     unset($item, $rc_path, $rc_ids);
     $rc =& $this->route_path;
     if ($Config->core['simple_admin_mode'] && file_exists(MFOLDER . '/index_simple.json')) {
         $structure_file = 'index_simple.json';
     } else {
         $structure_file = 'index.json';
     }
     if (file_exists(MFOLDER . "/{$structure_file}")) {
         $this->structure = file_get_json(MFOLDER . "/{$structure_file}");
         if (is_array($this->structure)) {
             foreach ($this->structure as $item => $value) {
                 if (!is_array($value)) {
                     $item = $value;
                 }
                 if ($User->get_permission($this->permission_group, $item)) {
                     $this->parts[] = $item;
                     if (isset($rc[0]) && $item == $rc[0] && is_array($value)) {
                         foreach ($value as $subpart) {
                             if ($User->get_permission($this->permission_group, "{$item}/{$subpart}")) {
                                 $this->subparts[] = $subpart;
                             } elseif (isset($rc[1]) && $rc[1] == $subpart) {
                                 error_code(403);
                                 return;
                             }
                         }
                     }
                 } elseif ($rc[0] == $item) {
                     error_code(403);
                     return;
                 }
             }
             unset($item, $value, $subpart);
         }
     } elseif (API && !file_exists(MFOLDER . '/index.php') && !file_exists(MFOLDER . "/index.{$this->request_method}.php")) {
         error_code(404);
         return;
     }
     unset($structure_file);
     _include_once(MFOLDER . '/index.php', false);
     if (API && $this->request_method) {
         _include_once(MFOLDER . "/index.{$this->request_method}.php", false);
     }
     if ($this->stop || defined('ERROR_CODE')) {
         return;
     }
     if ($this->parts) {
         if (!isset($rc[0]) || $rc[0] == '') {
             if (API) {
                 return;
             }
             $rc[0] = $this->parts[0];
             if (isset($this->structure[$rc[0]]) && is_array($this->structure[$rc[0]])) {
                 $this->subparts = $this->structure[$rc[0]];
             }
         } elseif ($rc[0] != '' && !empty($this->parts) && !in_array($rc[0], $this->parts)) {
             error_code(404);
             return;
         }
         /**
          * Saving of changes
          */
         if (IN_ADMIN && !_include_once(MFOLDER . "/{$rc['0']}/{$this->savefile}.php", false)) {
             _include_once(MFOLDER . "/{$this->savefile}.php", false);
         }
         IN_ADMIN && $this->title_auto && $Page->title($L->administration);
         if (!$this->api && $this->title_auto) {
             $Page->title($L->{HOME ? 'home' : MODULE});
         }
         if (!$this->api) {
             if (!HOME && $this->title_auto) {
                 $Page->title($L->{$rc}[0]);
             }
         }
         /**
          * Warning if site is closed
          */
         if (!$Config->core['site_mode']) {
             $Page->warning(get_core_ml_text('closed_title'));
         }
//.........这里部分代码省略.........
开发者ID:hypnomez,项目名称:opir.org,代码行数:101,代码来源:Index.php


示例8: define

<?php

// Database class folder path
define('DBPATH', dirname(__FILE__) . '/database/');
// erro reporting
error_reporting(E_ALL);
// get db environment variables
require_once DBPATH . 'config.php';
// include all databse classes
require_once DBPATH . 'index.php';
// include all databse classes
require_once DBPATH . 'function.php';
//check up to exsist of DB class
if (!class_exists('DB')) {
    error_code('can not find db class.', __FILE__, __LINE__);
}
//global db variable
$db = require_db();
// proceeding for request from mobile
require_once DBPATH . 'controlDB.php';
开发者ID:liming8964,项目名称:iOS_AlphaMail,代码行数:20,代码来源:index.php


示例9: construct

    /**
     * Loading of base system configuration, creating of missing directories
     */
    protected function construct()
    {
        if (!file_exists(CONFIG . '/main.json')) {
            error_code(500);
            Page::instance()->error(h::p('Config file not found, is system installed properly?') . h::a('How to install CleverStyle CMS', ['href' => 'https://github.com/nazar-pc/CleverStyle-CMS/wiki/Installation']));
            exit;
        }
        $this->config = file_get_json_nocomments(CONFIG . '/main.json');
        _include_once(CONFIG . '/main.php', false);
        defined('DEBUG') || define('DEBUG', false);
        define('DOMAIN', $this->config['domain']);
        date_default_timezone_set($this->config['timezone']);
        if ($clangs = Cache::instance()->{'languages/clangs'}) {
            if (is_array($clangs) && !empty($clangs)) {
                $clang = explode('/', trim($_SERVER['REQUEST_URI'], '/'), 2)[0];
                if (in_array($clang, $clangs)) {
                    $this->set('language', array_flip($clangs)[$clang]);
                    define('FIXED_LANGUAGE', true);
                }
                unset($clang);
            }
        }
        unset($clangs);
        if (!is_dir(STORAGE)) {
            @mkdir(STORAGE, 0755);
            file_put_contents(STORAGE . '/.htaccess', 'Allow From All');
        }
        if (!is_dir(CACHE)) {
            @mkdir(CACHE, 0700);
        }
        if (!is_dir(PCACHE)) {
            @mkdir(PCACHE, 0755);
            file_put_contents(PCACHE . '/.htaccess', '<FilesMatch "\\.(css|js)$">
	Allow From All
</FilesMatch>
<ifModule mod_expires.c>
	ExpiresActive On
	ExpiresDefault "access plus 1 month"
</ifModule>
<ifModule mod_headers.c>
	Header set Cache-Control "max-age=2592000, public"
</ifModule>
AddEncoding gzip .js
AddEncoding gzip .css
');
        }
        if (!is_dir(LOGS)) {
            @mkdir(LOGS, 0700);
        }
        if (!is_dir(TEMP)) {
            @mkdir(TEMP, 0755);
            file_put_contents(TEMP . '/.htaccess', 'Allow From All');
        }
        if (isset($_SERVER['CONTENT_TYPE']) && strpos($_SERVER['CONTENT_TYPE'], 'application/json') === 0) {
            $_POST = _json_decode(@file_get_contents('php://input')) ?: [];
            $_REQUEST = array_merge($_REQUEST, $_POST);
        } elseif (in_array(strtolower($_SERVER['REQUEST_METHOD']), ['head', 'put', 'delete'])) {
            if (isset($_SERVER['CONTENT_TYPE']) && strpos($_SERVER['CONTENT_TYPE'], 'application/x-www-form-urlencoded') === 0) {
                @parse_str(file_get_contents('php://input'), $_POST);
                $_REQUEST = array_merge($_REQUEST, $_POST);
            }
        }
        $this->constructed = true;
    }
开发者ID:hypnomez,项目名称:opir.org,代码行数:67,代码来源:Core.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP error_database函数代码示例发布时间:2022-05-15
下一篇:
PHP error_check函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap