ZBlog 其他函数

摘要:SWoole 及 Workerman 相关函数将 swoole 和 workerman 下的$request 数组转换为$GLOBALS 全局数组http_request_convert_to_global($request)获取 swoole 或 workerman 或标

SWoole 及 Workerman 相关函数
将 swoole 和 workerman 下的$request 数组转换为$GLOBALS 全局数组
http_request_convert_to_global($request)

获取 swoole 或 workerman 或标准 php 环境下的原始 post data
get_http_raw_post_data(&$request = null)

错误输出及记录函数
以 JSON 形式输出错误信息(用于 ShowError 接口)
JsonError4ShowErrorHook($errorCode, $errorString, $file, $line)

以 JSON 形式输出错误信息.(err code 为(int)0 认为是没有错误,所以把 0 转为 1)
JsonError($errorCode, $errorString, $data)

当代码正常运行时,以 JSON 形式输出信息
JsonReturn($data)

XML-RPC 应答错误页面
RespondError($errorCode, $errorString = '', $file = '', $line = '')

Script 脚本错误页面
ScriptError($errorCode, $errorText = '', $file = '', $line = '')

记录日志
Logs($logString, $level = 'INFO', $source = 'system')

Logs 指定的变量的值
Logs_Dump()

系统其它类函数
初始化统计信息
RunTime_Begin()

输出页面运行时长
RunTime($isOutput = true)

获取 Guid
GetGuid()

获取随机的 sqlite 数据库名
GetDbName()

安全检测判断类函数
简易版本的字符串加扰函数
zbp_string_auth_code($data, $operation, $password, $additional = null)

验证 Web Token 是否合法
VerifyWebToken($webTokenString, $webTokenId, $key = '')

创建 Web Token
CreateWebToken($webTokenId, $time, $key = '')

检测来源是否合法,这包括 CSRF 检测,在开启增强安全模式时加入来源检测
CheckIsRefererValid()

验证 CSRF Token 是否合法
CheckCSRFTokenValid($fieldName = 'csrfToken', $methods = array('get', 'post'))

检测 HTTP Referer 是否合法
CheckHTTPRefererValid()

zbp 限流函数 (依赖 zbp_cache 插件)
zbp_throttle($name = 'default', $max_reqs = 60, $period = 60)

加解密类的函数
1.7.3 开始系统集成了 ZbpEncrypt 加密类