code
stringlengths 17
296k
| docstring
stringlengths 30
30.3k
| func_name
stringlengths 1
89
| language
stringclasses 1
value | repo
stringlengths 7
63
| path
stringlengths 7
153
| url
stringlengths 51
209
| license
stringclasses 4
values |
---|---|---|---|---|---|---|---|
public function streaming_read_callback($curl_handle, $file_handle, $length)
{
// Once we've sent as much as we're supposed to send...
if ($this->read_stream_read >= $this->read_stream_size) {
// Send EOF
return '';
}
// If we're at the beginning of an upload and need to seek...
if ($this->read_stream_read == 0 && isset($this->seek_position) && $this->seek_position !== ftell($this->read_stream)) {
if (fseek($this->read_stream, $this->seek_position) !== 0) {
throw new RequestCore_Exception('The stream does not support seeking and is either not at the requested position or the position is unknown.');
}
}
$read = fread($this->read_stream, min($this->read_stream_size - $this->read_stream_read, $length)); // Remaining upload data or cURL's requested chunk size
$this->read_stream_read += strlen($read);
$out = $read === false ? '' : $read;
// Execute callback function
if ($this->registered_streaming_read_callback) {
call_user_func($this->registered_streaming_read_callback, $curl_handle, $file_handle, $out);
}
return $out;
} | A callback function that is invoked by cURL for streaming up.
@param resource $curl_handle (Required) The cURL handle for the request
@param resource $file_handle (Required) The open file handle resource
@param int $length (Required) The maximum number of bytes to read
@return binary binary data from a stream | streaming_read_callback | php | zblogcn/zblogphp | zb_users/plugin/CloudStorage/api/oss/lib/requestcore/requestcore.class.php | https://github.com/zblogcn/zblogphp/blob/master/zb_users/plugin/CloudStorage/api/oss/lib/requestcore/requestcore.class.php | MIT |
public function streaming_write_callback($curl_handle, $data)
{
$length = strlen($data);
$written_total = 0;
$written_last = 0;
while ($written_total < $length) {
$written_last = fwrite($this->write_stream, substr($data, $written_total));
if ($written_last === false) {
return $written_total;
}
$written_total += $written_last;
}
// Execute callback function
if ($this->registered_streaming_write_callback) {
call_user_func($this->registered_streaming_write_callback, $curl_handle, $written_total);
}
return $written_total;
} | A callback function that is invoked by cURL for streaming down.
@param resource $curl_handle (Required) The cURL handle for the request
@param binary $data (Required) The data to write
@return int the number of bytes written | streaming_write_callback | php | zblogcn/zblogphp | zb_users/plugin/CloudStorage/api/oss/lib/requestcore/requestcore.class.php | https://github.com/zblogcn/zblogphp/blob/master/zb_users/plugin/CloudStorage/api/oss/lib/requestcore/requestcore.class.php | MIT |
public function send_request($parse = false)
{
set_time_limit(0);
$curl_handle = $this->prep_request();
$this->response = curl_exec($curl_handle);
if ($this->response === false) {
throw new RequestCore_Exception('cURL resource: ' . (string) $curl_handle . '; cURL error: ' . curl_error($curl_handle) . ' (' . curl_errno($curl_handle) . ')');
} | Sends the request, calling necessary utility functions to update built-in properties.
@param bool $parse (Optional) Whether to parse the response with ResponseCore or not
@return string the resulting unparsed data from the request | send_request | php | zblogcn/zblogphp | zb_users/plugin/CloudStorage/api/oss/lib/requestcore/requestcore.class.php | https://github.com/zblogcn/zblogphp/blob/master/zb_users/plugin/CloudStorage/api/oss/lib/requestcore/requestcore.class.php | MIT |
public function get_response_header($header = null)
{
if ($header) {
return $this->response_headers[strtolower($header)];
}
return $this->response_headers;
} | Get the HTTP response headers from the request.
@param string $header (Optional) A specific header value to return. Defaults to all headers.
@return string|array all or selected header values | get_response_header | php | zblogcn/zblogphp | zb_users/plugin/CloudStorage/api/oss/lib/requestcore/requestcore.class.php | https://github.com/zblogcn/zblogphp/blob/master/zb_users/plugin/CloudStorage/api/oss/lib/requestcore/requestcore.class.php | MIT |
public function get_response_body()
{
return $this->response_body;
} | Get the HTTP response body from the request.
@return string the response body | get_response_body | php | zblogcn/zblogphp | zb_users/plugin/CloudStorage/api/oss/lib/requestcore/requestcore.class.php | https://github.com/zblogcn/zblogphp/blob/master/zb_users/plugin/CloudStorage/api/oss/lib/requestcore/requestcore.class.php | MIT |
public function get_response_code()
{
return $this->response_code;
} | Get the HTTP response code from the request.
@return string the HTTP response code | get_response_code | php | zblogcn/zblogphp | zb_users/plugin/CloudStorage/api/oss/lib/requestcore/requestcore.class.php | https://github.com/zblogcn/zblogphp/blob/master/zb_users/plugin/CloudStorage/api/oss/lib/requestcore/requestcore.class.php | MIT |
public function __construct($header, $body, $status = null)
{
$this->header = $header;
$this->body = $body;
$this->status = $status;
return $this;
} | Constructs a new instance of this class.
@param array $header (Required) Associative array of HTTP headers (typically returned by <RequestCore::get_response_header()>)
@param string $body (Required) XML-formatted response from AWS
@param int $status (Optional) HTTP response status code from the request
@return object contains an <php:array> `header` property (HTTP headers as an associative array), a <php:SimpleXMLElement> or <php:string> `body` property, and an <php:integer> `status` code | __construct | php | zblogcn/zblogphp | zb_users/plugin/CloudStorage/api/oss/lib/requestcore/requestcore.class.php | https://github.com/zblogcn/zblogphp/blob/master/zb_users/plugin/CloudStorage/api/oss/lib/requestcore/requestcore.class.php | MIT |
function ApiShowError()
{
$GLOBALS['hooks']['Filter_Plugin_Zbp_ShowError']['ApiShowError'] = PLUGIN_EXITSIGNAL_BREAK;
//主动跳过,直接throw
} | API ShowError函数 (ShowError接口已经在1.7.3不再使用了,使用ApiDebugHandler输出错误) | ApiShowError | php | zblogcn/zblogphp | zb_system/function/c_system_api.php | https://github.com/zblogcn/zblogphp/blob/master/zb_system/function/c_system_api.php | MIT |
function ApiAddDisallowMod($mod, $act = '')
{
global $zbp, $api_allow_mods_rule, $api_disallow_mods_rule;
$mod = strtolower($mod);
$act = strtolower($act);
$api_disallow_mods_rule[] = array($mod => $act);
} | 添加$mod,$act到Disallow Mods Rule. | ApiAddDisallowMod | php | zblogcn/zblogphp | zb_system/function/c_system_api.php | https://github.com/zblogcn/zblogphp/blob/master/zb_system/function/c_system_api.php | MIT |
function ApiRemoveDisallowMod($mod, $act = '')
{
global $zbp, $api_allow_mods_rule, $api_disallow_mods_rule;
$mod = strtolower($mod);
$act = strtolower($act);
foreach ($api_disallow_mods_rule as $k => $v) {
if (array_key_exists($mod, $v) && $v[$mod] === $act) {
unset($api_disallow_mods_rule[$k]);
}
}
} | 删除$mod,$act自Disallow Mods Rule. | ApiRemoveDisallowMod | php | zblogcn/zblogphp | zb_system/function/c_system_api.php | https://github.com/zblogcn/zblogphp/blob/master/zb_system/function/c_system_api.php | MIT |
function GetFilterPluginSignal($plugname)
{
$signal = GetFilterPluginAddition($plugname, 'signal');
SetFilterPluginAddition($plugname, 'signal', PLUGIN_EXITSIGNAL_NONE);
return $signal;
} | 获取 Filter 接口信号
由宿主调用而非插件,插件获取信号用GetPluginSignal
@param string $plugname 接口名称 | GetFilterPluginSignal | php | zblogcn/zblogphp | zb_system/function/c_system_plugin.php | https://github.com/zblogcn/zblogphp/blob/master/zb_system/function/c_system_plugin.php | MIT |
function SetFilterPluginSignal($plugname, $signal = PLUGIN_EXITSIGNAL_NONE)
{
return SetFilterPluginAddition($plugname, 'signal', $signal);
} | 设置 Filter 接口信号
由宿主调用而非插件,插件设置信号用SetPluginSignal
@param string $plugname 接口名称
@param string $signal 信号 | SetFilterPluginSignal | php | zblogcn/zblogphp | zb_system/function/c_system_plugin.php | https://github.com/zblogcn/zblogphp/blob/master/zb_system/function/c_system_plugin.php | MIT |
function Include_ShowError404($errorCode, $errorDescription = null, $file = null, $line = null)
{
global $zbp;
$signal = &$GLOBALS['hooks']['Filter_Plugin_Debug_Handler_ZEE']['Include_ShowError404'];
if (is_a($errorCode, 'ZbpErrorException')) {
if ($errorCode->getHttpCode() == 404) {
Http404();
$errorDescription = $errorCode->getMessage();
$file = $errorCode->getFile();
$line = $errorCode->getLine();
$errorCode = $errorCode->getCode();
$signal = PLUGIN_EXITSIGNAL_RETURN;
} elseif (in_array("Status: 404 Not Found", headers_list())) {
$signal = PLUGIN_EXITSIGNAL_RETURN;
} elseif (function_exists('http_response_code') && http_response_code() == 404) {
$signal = PLUGIN_EXITSIGNAL_RETURN;
} else {
return;
}
} elseif (in_array("Status: 404 Not Found", headers_list())) {
$signal = PLUGIN_EXITSIGNAL_RETURN;
} else {
return;
}
$zbp->template->SetTags('title', $zbp->title);
$zbp->template->SetTemplate('404');
$zbp->template->SetTags('type', '404');
$zbp->template->Display();
if (IS_CLI && (IS_WORKERMAN || IS_SWOOLE)) {
return true;
}
exit;
} | 显示404页面(内置插件函数).
可通过主题中的404.php模板自定义显示效果
@param $errorCode
@param $errorDescription
@param $file
@param $line
@api Filter_Plugin_Debug_Handler_ZEE
@throws Exception | Include_ShowError404 | php | zblogcn/zblogphp | zb_system/function/c_system_function.php | https://github.com/zblogcn/zblogphp/blob/master/zb_system/function/c_system_function.php | MIT |
function Include_ViewListPost_CheckRights_View($route)
{
global $zbp;
if (is_array($route)) {
$posttype = GetValueInArray($route, 'posttype', 0);
//没权限就返回
$actions = $zbp->GetPostType($posttype, 'actions');
if (!$zbp->CheckRights($actions['view'])) {
SetPluginSignal('Filter_Plugin_ViewList_Begin_V2', __FUNCTION__, PLUGIN_EXITSIGNAL_RETURN);
SetPluginSignal('Filter_Plugin_ViewPost_Begin_V2', __FUNCTION__, PLUGIN_EXITSIGNAL_RETURN);
return false;
}
}
} | 在ViewList,ViewPost中对view权限进行验证 | Include_ViewListPost_CheckRights_View | php | zblogcn/zblogphp | zb_system/function/c_system_function.php | https://github.com/zblogcn/zblogphp/blob/master/zb_system/function/c_system_function.php | MIT |
function Include_Admin_CheckMoblie()
{
if (function_exists('CheckIsMobile') && CheckIsMobile()) {
echo '<style>@media screen{body{font-size:16px}}@media screen and (max-width: 768px) {#divMain{padding:0 1px;overflow:scroll;}}@media screen and (max-width: 540px) {body{font-size:18px}}</style>';
}
} | Check Moblie and Response Style | Include_Admin_CheckMoblie | php | zblogcn/zblogphp | zb_system/function/c_system_admin_function.php | https://github.com/zblogcn/zblogphp/blob/master/zb_system/function/c_system_admin_function.php | MIT |
function ViewAuto_Call_Auto($route, $array)
{
$function = $route['call'];
$array['_route'] = $route;
return call_user_func(ParseFilterPlugin($function), $array);
} | ViewAuto的辅助函数
$route['call']参数,可以是1函数名 2类名::静态方法名 3全局变量名@动态方法名 4类名@动态方法名) 5全局匿名函数
借用了plugin里的ParseFilterPlugin函数去解析$function | ViewAuto_Call_Auto | php | zblogcn/zblogphp | zb_system/function/c_system_route.php | https://github.com/zblogcn/zblogphp/blob/master/zb_system/function/c_system_route.php | MIT |
function GetScheme($array)
{
$array = array_change_key_case($array, CASE_UPPER);
if (array_key_exists('REQUEST_SCHEME', $array) && (strtolower($array['REQUEST_SCHEME']) == 'https')) {
return 'https://';
} elseif (array_key_exists('HTTPS', $array) && (strtolower($array['HTTPS']) == 'on')) {
return 'https://';
} elseif (array_key_exists('SERVER_PORT', $array) && ($array['SERVER_PORT'] == 443)) {
return 'https://';
} elseif (array_key_exists('HTTP_X_FORWARDED_PORT', $array) && ($array['HTTP_X_FORWARDED_PORT'] == 443)) {
return 'https://';
} elseif (array_key_exists('HTTP_X_FORWARDED_PROTO', $array) && (strtolower($array['HTTP_X_FORWARDED_PROTO']) == 'https')) {
return 'https://';
} elseif (array_key_exists('HTTP_X_FORWARDED_PROTOCOL', $array) && (strtolower($array['HTTP_X_FORWARDED_PROTOCOL']) == 'https')) {
return 'https://';
} elseif (array_key_exists('HTTP_X_FORWARDED_SSL', $array) && (strtolower($array['HTTP_X_FORWARDED_SSL']) == 'on')) {
return 'https://';
} elseif (array_key_exists('HTTP_X_URL_SCHEME', $array) && (strtolower($array['HTTP_X_URL_SCHEME']) == 'https')) {
return 'https://';
} elseif (array_key_exists('HTTP_CF_VISITOR', $array) && (stripos($array['HTTP_CF_VISITOR'], 'https') !== false)) {
return 'https://';
} elseif (array_key_exists('HTTP_FROM_HTTPS', $array) && (strtolower($array['HTTP_FROM_HTTPS']) == 'on')) {
return 'https://';
} elseif (array_key_exists('HTTP_FRONT_END_HTTPS', $array) && (strtolower($array['HTTP_FRONT_END_HTTPS']) == 'on')) {
return 'https://';
} elseif (array_key_exists('SERVER_PORT_SECURE', $array) && ($array['SERVER_PORT_SECURE'] == 1)) {
return 'https://';
} elseif (array_key_exists('HTTP_X_CLIENT_SCHEME', $array) && (strtolower($array['HTTP_X_CLIENT_SCHEME']) == 'https')) {
return 'https://';
}
return 'http://';
} | 得到请求协议(考虑到不正确的配置反向代理等原因,未必准确)
如果想获取准确的值,请zbp->Load后使用$zbp->isHttps.
@param array $array
@return string | GetScheme | php | zblogcn/zblogphp | zb_system/function/c_system_common.php | https://github.com/zblogcn/zblogphp/blob/master/zb_system/function/c_system_common.php | MIT |
function GetVarsByDefault($name, $type = 'REQUEST', $default = null)
{
return GetVars($name, $type, $default);
} | 获取参数值(可设置默认返回值).本函数在1.7已经废弃了,改用GetVars!
@param string $name 数组key名
@param string $type 默认为REQUEST
@param string $default 默认为null
@return mixed|null
@since 1.3.140614 | GetVarsByDefault | php | zblogcn/zblogphp | zb_system/function/c_system_common.php | https://github.com/zblogcn/zblogphp/blob/master/zb_system/function/c_system_common.php | MIT |
function GetVarsFromEnv($name, $source = '', $default = '')
{
$value = $default;
$type = strtolower($source);
if ($type == '' || $type == 'all') {
$type = 'constant|env|server';
}
$type = '|' . $type . '|';
if ((strpos($type, '|constant|') !== false) && defined($name) && constant($name) != '') {
$value = constant($name);
return $value;
}
if (strpos($type, '|env|') !== false || strpos($type, '|getenv|') !== false) {
$value = Zbp_GetEnv($name, $default);
if ($value != $default) {
return $value;
}
}
if (strpos($type, '|environment|') !== false) {
if (function_exists('getenv') && getenv($name) !== false) {
return getenv($name);
} elseif (isset($_ENV[$name])) {
return $_ENV[$name];
}
}
if ((strpos($type, '|server|') !== false) && isset($_SERVER[$name]) && $_SERVER[$name] != '') {
$value = $_SERVER[$name];
return $value;
}
return $value;
} | 从一系列指定的环境变量获得参数值
$source = all,constant,env,server | GetVarsFromEnv | php | zblogcn/zblogphp | zb_system/function/c_system_common.php | https://github.com/zblogcn/zblogphp/blob/master/zb_system/function/c_system_common.php | MIT |
function Array_Isset(&$array, $key, $default)
{
if (!array_key_exists($key, $array)) {
$array[$key] = $default;
}
return true;
} | 判断数组是否已经有$key了,如果没有就set一次$default | Array_Isset | php | zblogcn/zblogphp | zb_system/function/c_system_common.php | https://github.com/zblogcn/zblogphp/blob/master/zb_system/function/c_system_common.php | MIT |
function Ucs2Utf8($matchs)
{
return iconv('UCS-2BE', 'UTF-8', pack('H4', $matchs[1]));
} | UCS-2BE 转 UTF-8,解决 JSON 中文转码问题.
@param $matchs
@return false|string | Ucs2Utf8 | php | zblogcn/zblogphp | zb_system/function/c_system_common.php | https://github.com/zblogcn/zblogphp/blob/master/zb_system/function/c_system_common.php | MIT |
function SerializeString2Array($list)
{
$array = array();
if (is_null($list) || empty($list)) {
return $array;
}
if (!is_string($list)) {
return $array;
}
$array = unserialize($list);
if (!is_array($array)) {
$array = array();
}
return $array;
} | 将序列化后的string还原为array(自动判断empty,null)
@param $list
@return array | SerializeString2Array | php | zblogcn/zblogphp | zb_system/function/c_system_common.php | https://github.com/zblogcn/zblogphp/blob/master/zb_system/function/c_system_common.php | MIT |
function JsonError($errorCode, $errorString, $data)
{
$exit = true;
if ($errorCode === 0) {
$exit = false;
}
$result = array(
'data' => $data,
'err' => array(
'code' => $errorCode,
'msg' => $errorString,
//'runtime' => RunTime(),
'timestamp' => time(),
),
);
@ob_clean();
echo json_encode($result);
if ($exit) {
exit;
}
} | 以JSON形式输出错误信息.(err code为(int)0认为是没有错误,所以把0转为1)
@param string $errorCode 错误编号
@param string $errorString 错误内容
@param object|array|null $data 具体内容 | JsonError | php | zblogcn/zblogphp | zb_system/function/c_system_common.php | https://github.com/zblogcn/zblogphp/blob/master/zb_system/function/c_system_common.php | MIT |
function Debug_PrintGlobals()
{
$a = array();
foreach ($GLOBALS as $n => $v) {
$a[] = $n;
}
return call_user_func('print_r', $a, true);
} | 显示全局变量.(下版转到debug页,虽然还没有做,但加了todo检查会报错)
@return mixed
@since 1.3.140614 | Debug_PrintGlobals | php | zblogcn/zblogphp | zb_system/function/c_system_debug.php | https://github.com/zblogcn/zblogphp/blob/master/zb_system/function/c_system_debug.php | MIT |
function Debug_PrintIncludefiles()
{
$a = array();
foreach (get_included_files() as $n => $v) {
$a[] = $v;
}
return call_user_func('print_r', $a, true);
} | 打印全局Include文件.(下版转到debug页,虽然还没有做,但加了todo检查会报错)
@return string
@since 1.3 | Debug_PrintIncludefiles | php | zblogcn/zblogphp | zb_system/function/c_system_debug.php | https://github.com/zblogcn/zblogphp/blob/master/zb_system/function/c_system_debug.php | MIT |
function Debug_PrintConstants()
{
$a = get_defined_constants(true);
if (isset($a['user'])) {
$a = $a['user'];
}
return call_user_func('print_r', $a, true);
} | 打印全局自定义常量.(下版转到debug页,虽然还没有做,但加了todo检查会报错)
@return string
@since 1.3 | Debug_PrintConstants | php | zblogcn/zblogphp | zb_system/function/c_system_debug.php | https://github.com/zblogcn/zblogphp/blob/master/zb_system/function/c_system_debug.php | MIT |
function Debug_IgnoreError($errno)
{
if (ZbpErrorControl::$iswarning == false) {
if ($errno == E_WARNING) {
return true;
}
if ($errno == E_USER_WARNING) {
return true;
}
}
if (ZbpErrorControl::$isstrict == false) {
if (PHP_VERSION_ID < 80400 && defined('E_STRICT') && $errno == constant("E_STRICT")) {
return true;
}
if ($errno == E_NOTICE) {
return true;
}
if ($errno == E_USER_NOTICE) {
return true;
}
}
// 屏蔽系统的错误,防ZBP报系统的错误,不过也有可能导致ZBP内的DEPRECATED错误也被屏蔽了
if ($errno == E_CORE_WARNING) {
return true;
}
if ($errno == E_COMPILE_WARNING) {
return true;
}
if (defined('E_DEPRECATED') && $errno == E_DEPRECATED) {
return true;
}
if (defined('E_USER_DEPRECATED') && $errno == E_USER_DEPRECATED) {
return true;
}
//E_USER_ERROR
//E_RECOVERABLE_ERROR
if (defined('ZBP_ERRORPROCESSING')) {
return true;
}
return false;
} | Return true if a error can be ignored.
@param int $errno
@return bool | Debug_IgnoreError | php | zblogcn/zblogphp | zb_system/function/c_system_debug.php | https://github.com/zblogcn/zblogphp/blob/master/zb_system/function/c_system_debug.php | MIT |
function hash_equals($known_string, $user_string)
{
if (func_num_args() !== 2) {
// handle wrong parameter count as the native implentation
trigger_error('hash_equals() expects exactly 2 parameters, ' . func_num_args() . ' given', E_USER_WARNING);
return null;
}
if (is_string($known_string) !== true) {
trigger_error('hash_equals(): Expected known_string to be a string, ' . gettype($known_string) . ' given', E_USER_WARNING);
return false;
}
$known_string_len = strlen($known_string);
$user_string_type_error = 'hash_equals(): Expected user_string to be a string, ' . gettype($user_string) . ' given'; // prepare wrong type error message now to reduce the impact of string concatenation and the gettype call
if (is_string($user_string) !== true) {
trigger_error($user_string_type_error, E_USER_WARNING);
// prevention of timing attacks might be still possible if we handle $user_string as a string of diffent length (the trigger_error() call increases the execution time a bit)
$user_string_len = strlen($user_string);
$user_string_len = $known_string_len + 1;
} else {
$user_string_len = $known_string_len + 1;
$user_string_len = strlen($user_string);
}
if ($known_string_len !== $user_string_len) {
$res = $known_string ^ $known_string; // use $known_string instead of $user_string to handle strings of diffrent length.
$ret = 1; // set $ret to 1 to make sure false is returned
} else {
$res = $known_string ^ $user_string;
$ret = 0;
}
for ($i = strlen($res) - 1; $i >= 0; $i--) {
$ret |= ord($res[$i]);
}
return $ret === 0;
} | Timing attack safe string comparison
Compares two strings using the same time whether they're equal or not.
This function should be used to mitigate timing attacks; for instance, when testing crypt() password hashes.
@param string $known_string The string of known length to compare against
@param string $user_string The user-supplied string
@return boolean Returns TRUE when the two strings are equal, FALSE otherwise. | hash_equals | php | zblogcn/zblogphp | zb_system/function/c_system_compat.php | https://github.com/zblogcn/zblogphp/blob/master/zb_system/function/c_system_compat.php | MIT |
public function SetPath($path = null)
{
global $zbp;
$template_dirname = $this->template_dirname;
if ($path == null) {
$path = $zbp->cachedir . 'compiled/' . $this->theme . '/';
}
$path = str_replace('\\', '/', $path);
if (substr($path, -1) != '/') {
$path = $path . '/';
}
//针对不同的模板目录创建不同的编译目录
if (!($template_dirname == '' || $template_dirname == 'template')) {
$path = substr($path, 0, (strlen($path) - 1)) . '___' . $template_dirname . '/';
}
$this->path = $path;
} | 设置路径
1.7改为可以为空,为空就是按系统设置去设path
@param $path | SetPath | php | zblogcn/zblogphp | zb_system/function/lib/template.php | https://github.com/zblogcn/zblogphp/blob/master/zb_system/function/lib/template.php | MIT |
public function setInterpolation($interpolate = true)
{
$this->interpolation = $interpolate;
return $this;
} | Enable/Disables the interpolation.
@param $interpolate bool True to enable, false to disable
@return ValidateCode | setInterpolation | php | zblogcn/zblogphp | zb_system/function/lib/validatecode.php | https://github.com/zblogcn/zblogphp/blob/master/zb_system/function/lib/validatecode.php | MIT |
public function setBackgroundColor($r, $g, $b)
{
$this->backgroundColor = array($r, $g, $b);
return $this;
} | Sets the background color to use. | setBackgroundColor | php | zblogcn/zblogphp | zb_system/function/lib/validatecode.php | https://github.com/zblogcn/zblogphp/blob/master/zb_system/function/lib/validatecode.php | MIT |
public function setIgnoreAllEffects($ignoreAllEffects)
{
$this->ignoreAllEffects = $ignoreAllEffects;
return $this;
} | Sets the ignoreAllEffects value.
@param bool $ignoreAllEffects
@return ValidateCode | setIgnoreAllEffects | php | zblogcn/zblogphp | zb_system/function/lib/validatecode.php | https://github.com/zblogcn/zblogphp/blob/master/zb_system/function/lib/validatecode.php | MIT |
public function setBackgroundImages(array $backgroundImages)
{
$this->backgroundImages = $backgroundImages;
return $this;
} | Sets the list of background images to use (one image is randomly selected). | setBackgroundImages | php | zblogcn/zblogphp | zb_system/function/lib/validatecode.php | https://github.com/zblogcn/zblogphp/blob/master/zb_system/function/lib/validatecode.php | MIT |
protected function writePhrase($image, $phrase, $font, $width, $height)
{
$length = strlen($phrase);
if ($length === 0) {
return imagecolorallocate($image, 0, 0, 0);
}
// Gets the text size and start position
$size = $this->fontsize;
$box = imagettfbbox($size, 0, $font, $phrase);
$textWidth = ($box[2] - $box[0]);
$textHeight = ($box[1] - $box[7]);
$x = (($width - $textWidth) / 2);
$y = (($height - $textHeight) / 2 + $size);
//if (isset($this->textCount) && is_array($this->textCount) && !count($this->textColor)) {
$textColor = array($this->rand(0, 150), $this->rand(0, 150), $this->rand(0, 150));
//} else {
// $textColor = $this->textColor;
//}
@$col = imagecolorallocate($image, $textColor[0], $textColor[1], $textColor[2]);
// Write the letters one by one, with random angle
for ($i = 0; $i < $length; $i++) {
$box = imagettfbbox($size, 0, $font, $phrase[$i]);
$w = ($box[2] - $box[0]);
$angle = $this->rand(-$this->maxAngle, $this->maxAngle);
$offset = $this->rand(-$this->maxOffset, $this->maxOffset);
imagettftext($image, $size, $angle, $x, ($y + $offset), $col, $font, $phrase[$i]);
$x += $w;
}
return $col;
} | Writes the phrase on the image. | writePhrase | php | zblogcn/zblogphp | zb_system/function/lib/validatecode.php | https://github.com/zblogcn/zblogphp/blob/master/zb_system/function/lib/validatecode.php | MIT |
protected function rand($min, $max)
{
if (!is_array($this->fingerprint)) {
$this->fingerprint = array();
}
if ($this->useFingerprint) {
$value = current($this->fingerprint);
next($this->fingerprint);
} else {
$value = mt_rand($min, $max);
$this->fingerprint[] = $value;
}
return $value;
} | Returns a random number or the next number in the
fingerprint. | rand | php | zblogcn/zblogphp | zb_system/function/lib/validatecode.php | https://github.com/zblogcn/zblogphp/blob/master/zb_system/function/lib/validatecode.php | MIT |
public function GetOriginal($key = null)
{
if (null == $key) {
return $this->original;
} else {
return $this->original[$key];
}
} | 获取原始数据(不设$key就返回整个original数组).
@return array | GetOriginal | php | zblogcn/zblogphp | zb_system/function/lib/base.php | https://github.com/zblogcn/zblogphp/blob/master/zb_system/function/lib/base.php | MIT |
protected function decodePart($input)
{
$n = self::INITIAL_N;
$i = 0;
$bias = self::INITIAL_BIAS;
$output = '';
$pos = strrpos($input, self::DELIMITER);
if ($pos !== false) {
$output = substr($input, 0, $pos++);
} else {
$pos = 0;
}
$outputLength = strlen($output);
$inputLength = strlen($input);
while ($pos < $inputLength) {
$oldi = $i;
$w = 1;
for ($k = self::BASE;; $k += self::BASE) {
$digit = self::$decodeTable[$input[$pos++]];
$i = ($i + ($digit * $w));
$t = $this->calculateThreshold($k, $bias);
if ($digit < $t) {
break;
}
$w = ($w * (self::BASE - $t));
}
$bias = $this->adapt(($i - $oldi), ++$outputLength, ($oldi === 0));
$n = ($n + (int) ($i / $outputLength));
$i = ($i % ($outputLength));
$output = mb_substr($output, 0, $i, $this->encoding) . $this->codePointToChar($n) . mb_substr($output, $i, ($outputLength - 1), $this->encoding);
$i++;
}
return $output;
} | Decode a part of domain name, such as tld.
@param string $input Part of a domain name
@return string Unicode domain part | decodePart | php | zblogcn/zblogphp | zb_system/function/lib/punycode.php | https://github.com/zblogcn/zblogphp/blob/master/zb_system/function/lib/punycode.php | MIT |
protected function calculateThreshold($k, $bias)
{
if ($k <= ($bias + self::TMIN)) {
return self::TMIN;
} elseif ($k >= ($bias + self::TMAX)) {
return self::TMAX;
}
return ($k - $bias);
} | Calculate the bias threshold to fall between TMIN and TMAX.
@param int $k
@param int $bias
@return int | calculateThreshold | php | zblogcn/zblogphp | zb_system/function/lib/punycode.php | https://github.com/zblogcn/zblogphp/blob/master/zb_system/function/lib/punycode.php | MIT |
protected function listCodePoints($input)
{
$codePoints = array(
'all' => array(),
'basic' => array(),
'nonBasic' => array(),
);
$length = mb_strlen($input, $this->encoding);
for ($i = 0; $i < $length; $i++) {
$char = mb_substr($input, $i, 1, $this->encoding);
$code = $this->charToCodePoint($char);
if ($code < 128) {
$codePoints['all'][] = $codePoints['basic'][] = $code;
} else {
$codePoints['all'][] = $codePoints['nonBasic'][] = $code;
}
}
return $codePoints;
} | List code points for a given input.
@param string $input
@return array Multi-dimension array with basic, non-basic and aggregated code points | listCodePoints | php | zblogcn/zblogphp | zb_system/function/lib/punycode.php | https://github.com/zblogcn/zblogphp/blob/master/zb_system/function/lib/punycode.php | MIT |
public function Del($name = null)
{
if ($name === null) {
return $this->Delete();
}
if ($name !== null) {
return $this->DelKey($name);
}
} | 双重意义的函数
$name为null就转向Delete()
$name不为null就转向DelKey()
删除KVData属性(数组)中的相应项
Del名称和数据库删除函数有冲突
@param string $name key名 | Del | php | zblogcn/zblogphp | zb_system/function/lib/config.php | https://github.com/zblogcn/zblogphp/blob/master/zb_system/function/lib/config.php | MIT |
public function Delete()
{
global $zbp;
$name = $this->GetItemName();
$sql = $this->db->sql->Delete($this->table, array(array('=', $this->datainfo['Name'][0], $name)));
$this->db->Delete($sql);
unset($zbp->configs[$name]);
return true;
} | 删除数据
Delete表示从数据库删除
从$zbp及数据库中删除该实例Config数据.
@return bool | Delete | php | zblogcn/zblogphp | zb_system/function/lib/config.php | https://github.com/zblogcn/zblogphp/blob/master/zb_system/function/lib/config.php | MIT |
public function LoadMembersInList($list, $mem_id_field = 'AuthorID')
{
$mem_ids_need_load = array();
foreach ($list as $obj) {
if (!isset($obj->$mem_id_field) || ($obj->$mem_id_field == null)) {
continue;
}
// 已经载入的用户不重新载入
if (isset($this->members[$obj->$mem_id_field])) {
continue;
}
$mem_ids_need_load[] = $obj->$mem_id_field;
}
$mem_ids_need_load = array_unique($mem_ids_need_load);
if (count($mem_ids_need_load) === 0) {
return true;
}
$array = $this->GetMemberList(null, array(array('IN', 'mem_ID', $mem_ids_need_load)));
return true;
} | 通过列表(文章/评论/……)一次性将用户预载入到 members 里.
@param array $list 文章/评论列表数组
@param string $mem_id_field 用户 ID 在对象中的字段名
@return boolean | LoadMembersInList | php | zblogcn/zblogphp | zb_system/function/lib/zblogphp.php | https://github.com/zblogcn/zblogphp/blob/master/zb_system/function/lib/zblogphp.php | MIT |
public function GetListType($classname, $sql)
{
if (is_object($sql) && get_parent_class($sql) == 'SQL__Global') {
$sql = $sql->sql;
}
$array = null;
$list = array();
$array = $this->db->Query($sql);
if (!isset($array)) {
return array();
}
foreach ($array as $a) {
if (is_array($a)) {
/** @var Base $l */
$l = new $classname();
$l->LoadInfoByAssoc($a);
if (is_subclass_of($classname, 'Base__Post') == true) {
$newtype = $this->GetPostType_ClassName($l->Type);
if ($newtype != $classname) {
unset($l);
$l = new $newtype;
$l->LoadInfoByAssoc($a);
}
}
$id = $l->GetIdName();
if ($this->CheckCache($classname, $l->$id) == false) {
$this->AddCache($l);
$list[] = $l;
} else {
$n = &$this->GetCache($classname, $l->$id);
$list[] = $n;
}
unset($l, $n);
}
}
return $list;
} | 已改名GetListType,1.5版中扔掉有歧义的GetList.
@param $classname
@param $sql
@return Base[] | GetListType | php | zblogcn/zblogphp | zb_system/function/lib/zblogphp.php | https://github.com/zblogcn/zblogphp/blob/master/zb_system/function/lib/zblogphp.php | MIT |
public function GetTagByAlias($name, $type = 0)
{
$ret = $this->GetSomeThingByAttr($this->tags_all, 'Tag', array('Alias', 'Type'), array($name, $type));
if (is_object($ret) && $ret->ID >= 0) {
return $ret;
}
$a = array();
$a[] = array('=', 'tag_Alias', $name);
$a[] = array('=', 'tag_Type', $type);
$array = $this->GetTagList('*', array($a), '', 1, '');
if (count($array) == 0) {
return new Tag();
} else {
return $array[0];
}
} | 通过tag别名获取tag实例.(先走cacheobject再走查数据库)
@param string $name
@param null $backKey
@return Tag|Base | GetTagByAlias | php | zblogcn/zblogphp | zb_system/function/lib/zblogphp.php | https://github.com/zblogcn/zblogphp/blob/master/zb_system/function/lib/zblogphp.php | MIT |
public function GetTagByName($name, $type = 0)
{
$ret = $this->GetSomeThingByAttr($this->tags_all, 'Tag', array('Name', 'Type'), array($name, $type));
if (is_object($ret) && $ret->ID >= 0) {
return $ret;
}
$a = array();
$a[] = array('=', 'tag_Name', $name);
$a[] = array('=', 'tag_Type', $type);
$array = $this->GetTagList('*', array($a), '', 1, '');
if (count($array) == 0) {
return new Tag();
} else {
return $array[0];
}
} | 通过tag名获取tag实例.(先走cacheobject再走查数据库)
@param string $name
@param null $backKey
@return Tag|Base | GetTagByName | php | zblogcn/zblogphp | zb_system/function/lib/zblogphp.php | https://github.com/zblogcn/zblogphp/blob/master/zb_system/function/lib/zblogphp.php | MIT |
public function GetTagByAliasOrName($name, $type = 0)
{
//return $this->GetTagByAlias($name, 'Name');
$a = array();
$a[] = array('tag_Alias', $name);
$a[] = array('tag_Name', $name);
$b = array('=', 'tag_Type', $type);
$array = $this->GetTagList('*', array(array('array', $a), $b), '', 1, '');
if (count($array) == 0) {
return new Tag();
} else {
return $array[0];
}
} | 通过tag的别名或是名称获取tag实例.(查数据库非走cacheobject)
@param string $name
@return Tag|Base | GetTagByAliasOrName | php | zblogcn/zblogphp | zb_system/function/lib/zblogphp.php | https://github.com/zblogcn/zblogphp/blob/master/zb_system/function/lib/zblogphp.php | MIT |
public function &GetCache($classname, $idvalue = null)
{
$cacheobject = &$this->cacheobject;
if (is_subclass_of($classname, 'Base__Post') == true) {
$classname = 'Post';
}
if (!isset($cacheobject[$classname])) {
$cacheobject[$classname] = array();
}
if (!is_null($idvalue)) {
if (array_key_exists($idvalue, $cacheobject[$classname])) {
return $cacheobject[$classname][$idvalue];
} else {
$null = null;
return $null;
}
}
return $cacheobject[$classname];
} | 获取指定classname的缓存数组,指定了$idvalue就返回单个的object,不指定就返回objects | GetCache | php | zblogcn/zblogphp | zb_system/function/lib/zblogphp.php | https://github.com/zblogcn/zblogphp/blob/master/zb_system/function/lib/zblogphp.php | MIT |
public function ConvertTagIDtoString($array)
{
$s = '';
foreach ($array as $a) {
$s .= '{' . $a . '}';
}
return $s;
} | 通过数组array[111,333,444,555,666]转换成存储串.
@param array $array 标签ID数组
@return string | ConvertTagIDtoString | php | zblogcn/zblogphp | zb_system/function/lib/zblogphp.php | https://github.com/zblogcn/zblogphp/blob/master/zb_system/function/lib/zblogphp.php | MIT |
private static function zbp_original_aes256gcm_encrypt($data, $password, $additional, $nonce)
{
$password = substr(str_pad($password, 32, '0'), 0, 32);
$nonce = substr(str_pad($nonce, 12, '0'), 0, 12);
$func_name = 'sodium_crypto_aead_aes256gcm_is_available';
if (function_exists($func_name) && $func_name()) {
$endata = sodium_crypto_aead_aes256gcm_encrypt($data, $additional, $nonce, $password);
} else {
$func_name = 'openssl_encrypt';
$tag = null;
$endata = $func_name($data, 'aes-256-gcm', $password, OPENSSL_RAW_DATA, $nonce, $tag, $additional, 16);
$endata .= $tag;
}
return base64_encode($endata);
} | 原始版本的输入密码,附加认证字符串,初始向量的aes256gcm加密函数 | zbp_original_aes256gcm_encrypt | php | zblogcn/zblogphp | zb_system/function/lib/zbpencrypt.php | https://github.com/zblogcn/zblogphp/blob/master/zb_system/function/lib/zbpencrypt.php | MIT |
private static function zbp_original_aes256gcm_decrypt($data, $password, $additional, $nonce)
{
$password = substr(str_pad($password, 32, '0'), 0, 32);
$nonce = substr(str_pad($nonce, 12, '0'), 0, 12);
$data = base64_decode($data);
$func_name = 'sodium_crypto_aead_aes256gcm_is_available';
if (function_exists($func_name) && $func_name()) {
$dedata = sodium_crypto_aead_aes256gcm_decrypt($data, $additional, $nonce, $password);
} else {
$tag = substr($data, -16);
$data = substr($data, 0, -16);
$func_name = 'openssl_decrypt';
$dedata = $func_name($data, 'aes-256-gcm', $password, OPENSSL_RAW_DATA, $nonce, $tag, $additional);
}
return $dedata;
} | 原始版本的输入密码,附加认证字符串,初始向量的aes256gcm解密函数 | zbp_original_aes256gcm_decrypt | php | zblogcn/zblogphp | zb_system/function/lib/zbpencrypt.php | https://github.com/zblogcn/zblogphp/blob/master/zb_system/function/lib/zbpencrypt.php | MIT |
private static function zbp_original_sm4_encrypt($data, $password, $iv, $mode = 'cbc')
{
$password = substr(str_pad($password, 32, '0'), 0, 32);
$nonce = substr(str_pad($iv, 16, '0'), 0, 16);
$mode = str_replace(array('sm4', '-', '_'), '', $mode);
$sm4_array = array('cbc', 'cfb', 'ctr', 'ecb', 'ofb');
if (!in_array($mode, $sm4_array)) {
$mode = "cbc";
}
$mode = "sm4-" . $mode;
if ($mode == 'sm4-ecb') {
$nonce = null;
}
$array = array($data, $mode, $password, OPENSSL_RAW_DATA, $nonce);
$endata = call_user_func_array('openssl_encrypt', $array);
return base64_encode($endata);
} | 原始版本的输入密码,初始向量,mode的sm4的5种模式加密 | zbp_original_sm4_encrypt | php | zblogcn/zblogphp | zb_system/function/lib/zbpencrypt.php | https://github.com/zblogcn/zblogphp/blob/master/zb_system/function/lib/zbpencrypt.php | MIT |
private static function zbp_original_sm4_decrypt($data, $password, $iv, $mode = 'cbc')
{
$password = substr(str_pad($password, 32, '0'), 0, 32);
$nonce = substr(str_pad($iv, 16, '0'), 0, 16);
$mode = str_replace(array('sm4', '-', '_'), '', $mode);
$sm4_array = array('cbc', 'cfb', 'ctr', 'ecb', 'ofb');
if (!in_array($mode, $sm4_array)) {
$mode = "cbc";
}
$mode = "sm4-" . $mode;
$endata = base64_decode($data);
if ($mode == 'sm4-ecb') {
$nonce = null;
}
$dedata = call_user_func('openssl_decrypt', $endata, $mode, $password, OPENSSL_RAW_DATA, $nonce);
return $dedata;
} | 原始版本的输入密码,初始向量,mode的sm4的5种模式解密 | zbp_original_sm4_decrypt | php | zblogcn/zblogphp | zb_system/function/lib/zbpencrypt.php | https://github.com/zblogcn/zblogphp/blob/master/zb_system/function/lib/zbpencrypt.php | MIT |
public function EscapeString($s)
{
return addslashes($s);
} | 对字符串进行转义,在指定的字符前添加反斜杠,即执行addslashes函数.
@param string $s
@return string | EscapeString | php | zblogcn/zblogphp | zb_system/function/lib/database/mysql.php | https://github.com/zblogcn/zblogphp/blob/master/zb_system/function/lib/database/mysql.php | MIT |
public function Open($array)
{
if ($this->isconnected) {
return true;
}
$this->ispersistent = $array[6];
if ($this->ispersistent == false) {
$db = @mysql_connect($array[0] . ':' . $array[5], $array[1], $array[2]);
} else {
$db = @mysql_pconnect($array[0] . ':' . $array[5], $array[1], $array[2]);
}
if (!$db) {
return false;
}
$myver = mysql_get_server_info($db);
$this->version = SplitAndGet($myver, '-', 0);
if (version_compare($this->version, '5.5.3') >= 0) {
$u = 'utf8mb4';
$c = 'utf8mb4_general_ci';
} else {
$u = 'utf8';
$c = 'utf8_general_ci';
}
if (mysql_set_charset($u, $db) == false) {
$u = 'utf8';
$c = 'utf8_general_ci';
mysql_set_charset($u, $db);
} else {
mysql_query("SET NAMES {$u} COLLATE {$c}", $db);
}
$this->charset = $u;
$this->collate = $c;
$this->db = $db;
if (mysql_select_db($array[3], $this->db)) {
$this->dbpre = $array[4];
$this->dbname = $array[3];
$this->dbengine = $array[7];
$this->isconnected = true;
return true;
} else {
$this->Close();
}
return false;
} | 连接数据库.
@param array $array 数据库连接配置
$array=array(
'dbmysql_server',
'dbmysql_username',
'dbmysql_password',
'dbmysql_name',
'dbmysql_pre',
'dbmysql_port',
'persistent'
'engine')
@return bool | Open | php | zblogcn/zblogphp | zb_system/function/lib/database/mysql.php | https://github.com/zblogcn/zblogphp/blob/master/zb_system/function/lib/database/mysql.php | MIT |
public function Open($array)
{
if ($this->isconnected) {
return true;
}
$array[3] = strtolower($array[3]);
$s = "pgsql:host={$array[0]};port={$array[5]};dbname={$array[3]};user={$array[1]};password={$array[2]};options='--client_encoding=UTF8'";
$this->ispersistent = $array[6];
if (false == $this->ispersistent) {
$db_link = new PDO($s);
} else {
$db_link = new PDO($s, null, null, array(PDO::ATTR_PERSISTENT => true));
}
$this->db = $db_link;
$this->dbpre = $array[4];
$this->dbname = $array[3];
$myver = $this->db->getAttribute(PDO::ATTR_SERVER_VERSION);
$this->version = SplitAndGet($myver, '-', 0);
$this->db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT);
//$this->db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$this->isconnected = true;
return true;
} | 连接数据库.
@param array $array 数据库连接配置
$array=array(
'pgsql_server',
'pgsql_username',
'pgsql_password',
'pgsql_name',
'pgsql_pre',
'pgsql_port',
'persistent')
)
@return bool | Open | php | zblogcn/zblogphp | zb_system/function/lib/database/pdo_postgresql.php | https://github.com/zblogcn/zblogphp/blob/master/zb_system/function/lib/database/pdo_postgresql.php | MIT |
public function EscapeString($s)
{
return addslashes($s);
} | 对字符串进行转义,在指定的字符前添加反斜杠,即执行addslashes函数.
@param string $s
@return string | EscapeString | php | zblogcn/zblogphp | zb_system/function/lib/database/mysqli.php | https://github.com/zblogcn/zblogphp/blob/master/zb_system/function/lib/database/mysqli.php | MIT |
public function Open($array)
{
if ($this->isconnected) {
return true;
}
$db = mysqli_init();
$this->ispersistent = $array[6];
if ($this->ispersistent == true) {
$array[0] = 'p:' . $array[0];
}
//mysqli_options($db,MYSQLI_READ_DEFAULT_GROUP,"max_allowed_packet=50M");
if (@mysqli_real_connect($db, $array[0], $array[1], $array[2], $array[3], $array[5])) {
$myver = mysqli_get_server_info($db);
$this->version = SplitAndGet($myver, '-', 0);
if (version_compare($this->version, '5.5.3') >= 0) {
$u = "utf8mb4";
$c = 'utf8mb4_general_ci';
} else {
$u = "utf8";
$c = 'utf8_general_ci';
}
if (mysqli_set_charset($db, $u) == false) {
$u = "utf8";
$c = 'utf8_general_ci';
mysqli_set_charset($db, $u);
} else {
mysqli_query($db, "SET NAMES {$u} COLLATE {$c}");
}
$this->charset = $u;
$this->collate = $c;
$this->db = $db;
$this->dbname = $array[3];
$this->dbpre = $array[4];
$this->dbengine = $array[7];
$this->isconnected = true;
return true;
}
return false;
} | 连接数据库.
@param array $array 数据库连接配置
$array=array(
'dbmysql_server',
'dbmysql_username',
'dbmysql_password',
'dbmysql_name',
'dbmysql_pre',
'dbmysql_port',
'persistent'
'engine')
@return bool | Open | php | zblogcn/zblogphp | zb_system/function/lib/database/mysqli.php | https://github.com/zblogcn/zblogphp/blob/master/zb_system/function/lib/database/mysqli.php | MIT |
public function EscapeString($s)
{
return pg_escape_string($this->db, $s);
} | 对字符串进行转义,在指定的字符前添加反斜杠,即执行addslashes函数.
@param string $s
@return string | EscapeString | php | zblogcn/zblogphp | zb_system/function/lib/database/postgresql.php | https://github.com/zblogcn/zblogphp/blob/master/zb_system/function/lib/database/postgresql.php | MIT |
public function Open($array)
{
if ($this->isconnected) {
return true;
}
$array[3] = strtolower($array[3]);
$s = "host={$array[0]} port={$array[5]} dbname={$array[3]} user={$array[1]} password={$array[2]} options='--client_encoding=UTF8'";
$this->ispersistent = $array[6];
if (!$this->ispersistent) {
$db_link = pg_connect($s);
} else {
$db_link = pg_pconnect($s);
}
if (!$db_link) {
return false;
} else {
$this->db = $db_link;
$this->dbpre = $array[4];
$this->dbname = $array[3];
$v = pg_version($db_link);
if (isset($v['client'])) {
$this->version = $v['client'];
}
if (isset($v['server'])) {
$this->version = $v['server'];
}
$this->isconnected = true;
return true;
}
} | 连接数据库.
@param array $array 数据库连接配置
$array=array(
'pgsql_server',
'pgsql_username',
'pgsql_password',
'pgsql_name',
'pgsql_pre',
'pgsql_port',
'persistent')
)
@return bool | Open | php | zblogcn/zblogphp | zb_system/function/lib/database/postgresql.php | https://github.com/zblogcn/zblogphp/blob/master/zb_system/function/lib/database/postgresql.php | MIT |
private function is_hex($hex)
{
// regex is for weenies
$hex = strtolower(trim(ltrim($hex, "0")));
if (empty($hex)) {
$hex = 0;
}
$dec = hexdec($hex);
return $hex == dechex($dec);
} | determine if a string can represent a number in hexadecimal.
@param string $hex
@return bool true if the string is a hex, otherwise false | is_hex | php | zblogcn/zblogphp | zb_system/function/lib/network/fsockopen.php | https://github.com/zblogcn/zblogphp/blob/master/zb_system/function/lib/network/fsockopen.php | MIT |
public function GetHashByMD5Path()
{
global $zbp;
return md5($this->Password . $zbp->guid);
} | 获取加路径盐的Hash密码 (其实并没有用path,而是用zbp->guid替代了).
@return string | GetHashByMD5Path | php | zblogcn/zblogphp | zb_system/function/lib/base/member.php | https://github.com/zblogcn/zblogphp/blob/master/zb_system/function/lib/base/member.php | MIT |
public function sqlPush($sql)
{
$this->pri_sql[] = $sql;
} | If we use $this->$getName directly, PHP will throw [Indirect modification of overloaded property]
So we have to wrap it.
It maybe a bug of PHP.
@see http://stackoverflow.com/questions/10454779/php-indirect-modification-of-overloaded-property
@param $sql | sqlPush | php | zblogcn/zblogphp | zb_system/function/lib/sql/global.php | https://github.com/zblogcn/zblogphp/blob/master/zb_system/function/lib/sql/global.php | MIT |
public static function shouldClosedResourceAssertionBeSkipped( $actual ) {
return ( ResourceHelper::isResourceStateReliable( $actual ) === false );
} | Helper function to determine whether an assertion regarding a resource's state should be skipped.
Due to some bugs in PHP itself, the "is closed resource" determination
cannot always be done reliably.
This method can determine whether or not the current value in combination with
the current PHP version on which the test is being run is affected by this.
Use this function to skip running a test using `assertIs[Not]ClosedResource()` or
to skip running just that particular assertion.
@param mixed $actual The variable to test.
@return bool | shouldClosedResourceAssertionBeSkipped | php | Yoast/PHPUnit-Polyfills | src/Polyfills/AssertClosedResource_Empty.php | https://github.com/Yoast/PHPUnit-Polyfills/blob/master/src/Polyfills/AssertClosedResource_Empty.php | BSD-3-Clause |
public static function set_up_before_class() {} | This method is called before the first test of this test class is run.
@return void | set_up_before_class | php | Yoast/PHPUnit-Polyfills | src/TestCases/TestCasePHPUnitGte8.php | https://github.com/Yoast/PHPUnit-Polyfills/blob/master/src/TestCases/TestCasePHPUnitGte8.php | BSD-3-Clause |
protected function set_up() {} | Sets up the fixture, for example, open a network connection.
This method is called before each test.
@return void | set_up | php | Yoast/PHPUnit-Polyfills | src/TestCases/TestCasePHPUnitGte8.php | https://github.com/Yoast/PHPUnit-Polyfills/blob/master/src/TestCases/TestCasePHPUnitGte8.php | BSD-3-Clause |
protected function assert_pre_conditions() {} | Performs assertions shared by all tests of a test case.
This method is called before the execution of a test starts and after set_up() is called.
@return void | assert_pre_conditions | php | Yoast/PHPUnit-Polyfills | src/TestCases/TestCasePHPUnitGte8.php | https://github.com/Yoast/PHPUnit-Polyfills/blob/master/src/TestCases/TestCasePHPUnitGte8.php | BSD-3-Clause |
protected function assert_post_conditions() {} | Performs assertions shared by all tests of a test case.
This method is called before the execution of a test ends and before tear_down() is called.
@return void | assert_post_conditions | php | Yoast/PHPUnit-Polyfills | src/TestCases/TestCasePHPUnitGte8.php | https://github.com/Yoast/PHPUnit-Polyfills/blob/master/src/TestCases/TestCasePHPUnitGte8.php | BSD-3-Clause |
protected function tear_down() {} | Tears down the fixture, for example, close a network connection.
This method is called after each test.
@return void | tear_down | php | Yoast/PHPUnit-Polyfills | src/TestCases/TestCasePHPUnitGte8.php | https://github.com/Yoast/PHPUnit-Polyfills/blob/master/src/TestCases/TestCasePHPUnitGte8.php | BSD-3-Clause |
public static function tear_down_after_class() {} | This method is called after the last test of this test class is run.
@return void | tear_down_after_class | php | Yoast/PHPUnit-Polyfills | src/TestCases/TestCasePHPUnitGte8.php | https://github.com/Yoast/PHPUnit-Polyfills/blob/master/src/TestCases/TestCasePHPUnitGte8.php | BSD-3-Clause |
public static function setUpBeforeClass() {
parent::setUpBeforeClass();
static::set_up_before_class();
} | This method is called before the first test of this test class is run.
@codeCoverageIgnore
@return void | setUpBeforeClass | php | Yoast/PHPUnit-Polyfills | src/TestCases/TestCasePHPUnitLte7.php | https://github.com/Yoast/PHPUnit-Polyfills/blob/master/src/TestCases/TestCasePHPUnitLte7.php | BSD-3-Clause |
protected function setUp() {
parent::setUp();
$this->set_up();
} | Sets up the fixture, for example, open a network connection.
This method is called before each test.
@return void | setUp | php | Yoast/PHPUnit-Polyfills | src/TestCases/TestCasePHPUnitLte7.php | https://github.com/Yoast/PHPUnit-Polyfills/blob/master/src/TestCases/TestCasePHPUnitLte7.php | BSD-3-Clause |
protected function assertPreConditions() {
parent::assertPreConditions();
$this->assert_pre_conditions();
} | Performs assertions shared by all tests of a test case.
This method is called before the execution of a test starts and after setUp() is called.
@since 0.2.0
@return void | assertPreConditions | php | Yoast/PHPUnit-Polyfills | src/TestCases/TestCasePHPUnitLte7.php | https://github.com/Yoast/PHPUnit-Polyfills/blob/master/src/TestCases/TestCasePHPUnitLte7.php | BSD-3-Clause |
protected function assertPostConditions() {
parent::assertPostConditions();
$this->assert_post_conditions();
} | Performs assertions shared by all tests of a test case.
This method is called before the execution of a test ends and before tearDown() is called.
@since 0.2.0
@return void | assertPostConditions | php | Yoast/PHPUnit-Polyfills | src/TestCases/TestCasePHPUnitLte7.php | https://github.com/Yoast/PHPUnit-Polyfills/blob/master/src/TestCases/TestCasePHPUnitLte7.php | BSD-3-Clause |
protected function tearDown() {
$this->tear_down();
parent::tearDown();
} | Tears down the fixture, for example, close a network connection.
This method is called after each test.
@return void | tearDown | php | Yoast/PHPUnit-Polyfills | src/TestCases/TestCasePHPUnitLte7.php | https://github.com/Yoast/PHPUnit-Polyfills/blob/master/src/TestCases/TestCasePHPUnitLte7.php | BSD-3-Clause |
public static function tearDownAfterClass() {
static::tear_down_after_class();
parent::tearDownAfterClass();
} | This method is called after the last test of this test class is run.
@codeCoverageIgnore
@return void | tearDownAfterClass | php | Yoast/PHPUnit-Polyfills | src/TestCases/TestCasePHPUnitLte7.php | https://github.com/Yoast/PHPUnit-Polyfills/blob/master/src/TestCases/TestCasePHPUnitLte7.php | BSD-3-Clause |
public static function set_up_before_class() {} | This method is called before the first test of this test class is run.
@return void | set_up_before_class | php | Yoast/PHPUnit-Polyfills | src/TestCases/TestCasePHPUnitLte7.php | https://github.com/Yoast/PHPUnit-Polyfills/blob/master/src/TestCases/TestCasePHPUnitLte7.php | BSD-3-Clause |
protected function set_up() {} | Sets up the fixture, for example, open a network connection.
This method is called before each test.
@return void | set_up | php | Yoast/PHPUnit-Polyfills | src/TestCases/TestCasePHPUnitLte7.php | https://github.com/Yoast/PHPUnit-Polyfills/blob/master/src/TestCases/TestCasePHPUnitLte7.php | BSD-3-Clause |
protected function assert_pre_conditions() {} | Performs assertions shared by all tests of a test case.
This method is called before the execution of a test starts and after set_up() is called.
@return void | assert_pre_conditions | php | Yoast/PHPUnit-Polyfills | src/TestCases/TestCasePHPUnitLte7.php | https://github.com/Yoast/PHPUnit-Polyfills/blob/master/src/TestCases/TestCasePHPUnitLte7.php | BSD-3-Clause |
protected function assert_post_conditions() {} | Performs assertions shared by all tests of a test case.
This method is called before the execution of a test ends and before tear_down() is called.
@return void | assert_post_conditions | php | Yoast/PHPUnit-Polyfills | src/TestCases/TestCasePHPUnitLte7.php | https://github.com/Yoast/PHPUnit-Polyfills/blob/master/src/TestCases/TestCasePHPUnitLte7.php | BSD-3-Clause |
protected function tear_down() {} | Tears down the fixture, for example, close a network connection.
This method is called after each test.
@return void | tear_down | php | Yoast/PHPUnit-Polyfills | src/TestCases/TestCasePHPUnitLte7.php | https://github.com/Yoast/PHPUnit-Polyfills/blob/master/src/TestCases/TestCasePHPUnitLte7.php | BSD-3-Clause |
public static function tear_down_after_class() {} | This method is called after the last test of this test class is run.
@return void | tear_down_after_class | php | Yoast/PHPUnit-Polyfills | src/TestCases/TestCasePHPUnitLte7.php | https://github.com/Yoast/PHPUnit-Polyfills/blob/master/src/TestCases/TestCasePHPUnitLte7.php | BSD-3-Clause |
public static function setUpFixturesBeforeClass() {
parent::setUpBeforeClass();
} | This method is called before the first test of this test class is run.
@beforeClass
@codeCoverageIgnore
@return void | setUpFixturesBeforeClass | php | Yoast/PHPUnit-Polyfills | src/TestCases/XTestCase.php | https://github.com/Yoast/PHPUnit-Polyfills/blob/master/src/TestCases/XTestCase.php | BSD-3-Clause |
protected function setUpFixtures() {
parent::setUp();
} | Sets up the fixture, for example, open a network connection.
This method is called before each test.
@before
@return void | setUpFixtures | php | Yoast/PHPUnit-Polyfills | src/TestCases/XTestCase.php | https://github.com/Yoast/PHPUnit-Polyfills/blob/master/src/TestCases/XTestCase.php | BSD-3-Clause |
protected function tearDownFixtures() {
parent::tearDown();
} | Tears down the fixture, for example, close a network connection.
This method is called after each test.
@after
@return void | tearDownFixtures | php | Yoast/PHPUnit-Polyfills | src/TestCases/XTestCase.php | https://github.com/Yoast/PHPUnit-Polyfills/blob/master/src/TestCases/XTestCase.php | BSD-3-Clause |
public static function tearDownFixturesAfterClass() {
parent::tearDownAfterClass();
} | This method is called after the last test of this test class is run.
@afterClass
@codeCoverageIgnore
@return void | tearDownFixturesAfterClass | php | Yoast/PHPUnit-Polyfills | src/TestCases/XTestCase.php | https://github.com/Yoast/PHPUnit-Polyfills/blob/master/src/TestCases/XTestCase.php | BSD-3-Clause |
private function usesNativePHPUnitAssertion() {
$phpunit_version = PHPUnit_Version::id();
return ( \version_compare( $phpunit_version, '10.1.0', '>=' )
|| ( \version_compare( $phpunit_version, '9.6.11', '>=' ) && \version_compare( $phpunit_version, '10.0.0', '<' ) )
);
} | Check whether native PHPUnit assertions will be used or the polyfill.
@return bool | usesNativePHPUnitAssertion | php | Yoast/PHPUnit-Polyfills | tests/Polyfills/AssertObjectPropertyTestCase.php | https://github.com/Yoast/PHPUnit-Polyfills/blob/master/tests/Polyfills/AssertObjectPropertyTestCase.php | BSD-3-Clause |
private function getKey( $pathname, $proj_id ) {
if ( \function_exists( 'ftok' ) ) {
return \ftok( $pathname, $proj_id );
}
// phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
$st = @\stat( $pathname );
if ( ! $st ) {
return -1;
}
return \sprintf( '%u', ( ( $st['ino'] & 0xffff ) | ( ( $st['dev'] & 0xff ) << 16 ) | ( ( $proj_id & 0xff ) << 24 ) ) );
} | Helper function: work round ftok() not always being available (on Windows).
@link https://www.php.net/manual/en/function.ftok.php#43309
@param string $pathname Path to file.
@param string $proj_id Project identifier.
@return string | getKey | php | Yoast/PHPUnit-Polyfills | tests/Polyfills/AssertClosedResourceShmopTestCase.php | https://github.com/Yoast/PHPUnit-Polyfills/blob/master/tests/Polyfills/AssertClosedResourceShmopTestCase.php | BSD-3-Clause |
public static function prepareResource() {
self::$openResource = \opendir( __DIR__ );
self::$closedResource = \opendir( __DIR__ );
\closedir( self::$closedResource );
} | Create some resources for use in the tests.
@beforeClass
@return void | prepareResource | php | Yoast/PHPUnit-Polyfills | tests/Polyfills/AssertContainsOnlyTestCase.php | https://github.com/Yoast/PHPUnit-Polyfills/blob/master/tests/Polyfills/AssertContainsOnlyTestCase.php | BSD-3-Clause |
public static function closeResource() {
\closedir( self::$openResource );
} | Clean up the previously created and still open resource.
@afterClass
@return void | closeResource | php | Yoast/PHPUnit-Polyfills | tests/Polyfills/AssertContainsOnlyTestCase.php | https://github.com/Yoast/PHPUnit-Polyfills/blob/master/tests/Polyfills/AssertContainsOnlyTestCase.php | BSD-3-Clause |
public static function dummyCallable() {
// Nothing to see here.
} | Dummy method to have a callable method available.
@return void | dummyCallable | php | Yoast/PHPUnit-Polyfills | tests/Polyfills/AssertContainsOnlyTestCase.php | https://github.com/Yoast/PHPUnit-Polyfills/blob/master/tests/Polyfills/AssertContainsOnlyTestCase.php | BSD-3-Clause |
public function isClosedResourceExpectExceptionOnOpenResource( $actual ) {
$pattern = '`^Failed asserting that .+? is of type ["]?resource \(closed\)["]?`';
$this->expectException( AssertionFailedError::class );
$this->expectExceptionMessageMatches( $pattern );
$this->assertIsClosedResource( $actual );
} | Helper method: Verify that an exception is thrown when `assertIsClosedResource()` is passed an open resource.
@param resource $actual The resource under test.
@return void | isClosedResourceExpectExceptionOnOpenResource | php | Yoast/PHPUnit-Polyfills | tests/Polyfills/AssertClosedResourceTestCase.php | https://github.com/Yoast/PHPUnit-Polyfills/blob/master/tests/Polyfills/AssertClosedResourceTestCase.php | BSD-3-Clause |
public function isNotClosedResourceExpectExceptionOnClosedResource( $actual ) {
/*
* PHPUnit itself will report closed resources as `NULL` prior to Exporter 3.0.4/4.1.4.
* See: https://github.com/sebastianbergmann/exporter/pull/37
*/
$pattern = '`^Failed asserting that (resource \(closed\)|NULL) is not of type ["]?resource \(closed\)["]?`';
$this->expectException( AssertionFailedError::class );
$this->expectExceptionMessageMatches( $pattern );
self::assertIsNotClosedResource( $actual );
} | Helper method: Verify that an exception is thrown when `assertIsNotClosedResource()` is passed a closed resource.
@param resource $actual The resource under test.
@return void | isNotClosedResourceExpectExceptionOnClosedResource | php | Yoast/PHPUnit-Polyfills | tests/Polyfills/AssertClosedResourceTestCase.php | https://github.com/Yoast/PHPUnit-Polyfills/blob/master/tests/Polyfills/AssertClosedResourceTestCase.php | BSD-3-Clause |
protected function set_up() {
$this->result = new TestResult();
$this->listener = new TestListenerImplementation();
$this->result->addListener( $this->listener );
} | Set up a test result and add the test listener to it.
@return void | set_up | php | Yoast/PHPUnit-Polyfills | tests/TestListeners/TestListenerTest.php | https://github.com/Yoast/PHPUnit-Polyfills/blob/master/tests/TestListeners/TestListenerTest.php | BSD-3-Clause |
public static function setUpFixturesBeforeClass() {
parent::setUpFixturesBeforeClass();
++self::$beforeClass;
} | This method is called before the first test of this test class is run.
@beforeClass
@return void | setUpFixturesBeforeClass | php | Yoast/PHPUnit-Polyfills | tests/TestCases/XTestCaseTest.php | https://github.com/Yoast/PHPUnit-Polyfills/blob/master/tests/TestCases/XTestCaseTest.php | BSD-3-Clause |
protected function setUpFixtures() {
parent::setUpFixtures();
++self::$before;
} | This method is called before each test.
@before
@return void | setUpFixtures | php | Yoast/PHPUnit-Polyfills | tests/TestCases/XTestCaseTest.php | https://github.com/Yoast/PHPUnit-Polyfills/blob/master/tests/TestCases/XTestCaseTest.php | BSD-3-Clause |
protected function tearDownFixtures() {
++self::$after;
parent::tearDownFixtures();
} | This method is called after each test.
@after
@return void | tearDownFixtures | php | Yoast/PHPUnit-Polyfills | tests/TestCases/XTestCaseTest.php | https://github.com/Yoast/PHPUnit-Polyfills/blob/master/tests/TestCases/XTestCaseTest.php | BSD-3-Clause |
public static function tearDownFixturesAfterClass() {
// Reset.
self::$beforeClass = 0;
self::$before = 0;
self::$after = 0;
parent::tearDownFixturesAfterClass();
} | This method is called after the last test of this test class is run.
@afterClass
@return void | tearDownFixturesAfterClass | php | Yoast/PHPUnit-Polyfills | tests/TestCases/XTestCaseTest.php | https://github.com/Yoast/PHPUnit-Polyfills/blob/master/tests/TestCases/XTestCaseTest.php | BSD-3-Clause |
public static function set_up_before_class() {
++self::$beforeClass;
} | This method is called before the first test of this test class is run.
@return void | set_up_before_class | php | Yoast/PHPUnit-Polyfills | tests/TestCases/TestCaseTest.php | https://github.com/Yoast/PHPUnit-Polyfills/blob/master/tests/TestCases/TestCaseTest.php | BSD-3-Clause |
protected function set_up() {
++self::$before;
} | This method is called before each test.
@return void | set_up | php | Yoast/PHPUnit-Polyfills | tests/TestCases/TestCaseTest.php | https://github.com/Yoast/PHPUnit-Polyfills/blob/master/tests/TestCases/TestCaseTest.php | BSD-3-Clause |
protected function assert_pre_conditions() {
++self::$preConditions;
} | This method is called before the execution of a test starts and after set_up() is called.
@return void | assert_pre_conditions | php | Yoast/PHPUnit-Polyfills | tests/TestCases/TestCaseTest.php | https://github.com/Yoast/PHPUnit-Polyfills/blob/master/tests/TestCases/TestCaseTest.php | BSD-3-Clause |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.