- 论坛徽章:
- 0
|
discuz核心函数库function_core的函数注释 - Php代码
- 1./**
- 2. * 系统错误处理
- 3. * @param <type> $message 错误信息
- 4. * @param <type> $show 是否显示信息
- 5. * @param <type> $save 是否存入日志
- 6. * @param <type> $halt 是否中断访问
- 7. */
- 8.function system_error($message, $show = true, $save = true, $halt = true) {
- 9. ......
- 10.}
- 11.
- 12./**
- 13. * 更新 session
- 14. * @global <type> $_G
- 15. * @staticvar boolean $updated
- 16. * @param boolean $force
- 17. * @return boolean
- 18. */
- 19.function updatesession($force = false) {
- 20. ......
- 21.}
- 22.
- 23./**
- 24. * 获取 microtime float 数值,为了兼容php4
- 25. * @return <float>
- 26. */
- 27.function dmicrotime() {
- 28. ......
- 29.}
- 30.
- 31./**
- 32. * 设置全局 $_G 中的变量
- 33. * @global <array> $_G
- 34. * @param <string> $key 键
- 35. * @param <string> $value 值
- 36. * @param <mix> $group 组(准备废弃,尽量不用)
- 37. * @return true
- 38. *
- 39. * @example
- 40. * setglobal('test', 1); // $_G['test'] = 1;
- 41. * setglobal('config/test/abc') = 2; //$_G['config']['test']['abc'] = 2;
- 42. *
- 43. */
- 44.function setglobal($key , $value, $group = null) {
- 45. ......
- 46.}
- 47.
- 48./**
- 49. * 获取全局变量 $_G 当中的某个数值
- 50. * @global $_G
- 51. * @param <type> $key
- 52. * @param <type> $group 计划废弃的参数,不建议使用
- 53. * @return <mix>
- 54. *
- 55. * $v = getglobal('test'); // $v = $_G['test']
- 56. * $v = getglobal('test/hello/ok'); // $v = $_G['test']['hello']['ok']
- 57. */
- 58.function getglobal($key, $group = null) {
- 59. ......
- 60.}
- 61.
- 62./**
- 63. * 取出 get, post, cookie 当中的某个变量
- 64. *
- 65. * @param string $k key 值
- 66. * @param string $type 类型
- 67. * @return mix
- 68. */
- 69.function getgpc($k, $type='GP') {
- 70. ......
- 71.}
- 72.
- 73./**
- 74. * 根据uid 获取用户基本数据
- 75. * @staticvar array $users 存放已经获取的用户的信息,避免重复查库
- 76. * @param <int> $uid
- 77. * @return <array>
- 78. */
- 79.function getuserbyuid($uid) {
- 80. ......
- 81.}
- 82.
- 83./**
- 84.* 获取当前用户的扩展资料
- 85.* @param $field 字段
- 86.*/
- 87.function getuserprofile($field) {
- 88. ......
- 89.}
- 90.
- 91./**
- 92. * 对字符串或者输入进行 addslashes 操作
- 93. * @param <mix> $string
- 94. * @param <int> $force
- 95. * @return <mix>
- 96. */
- 97.function daddslashes($string, $force = 1) {
- 98. ......
- 99.}
- 100.
- 101./**
- 102. * 对字符串进行加密和解密
- 103. * @param <string> $string
- 104. * @param <string> $operation DECODE 解密 | ENCODE 加密
- 105. * @param <string> $key 当为空的时候,取全局密钥
- 106. * @param <int> $expiry 有效期,单位秒
- 107. * @return <string>
- 108. */
- 109.function authcode($string, $operation = 'DECODE', $key = '', $expiry = 0) {
- 110. ......
- 111.}
- 112.
- 113./**
- 114. * 远程文件文件请求兼容函数
- 115. */
- 116.function dfsockopen($url, $limit = 0, $post = '', $cookie = '', $bysocket = FALSE, $ip = '', $timeout = 15, $block = TRUE) {
- 117. ......
- 118.}
- 119.
- 120./**
- 121.* HTML转义字符
- 122.* @param $string - 字符串
- 123.* @return 返回转义好的字符串
- 124.*/
- 125.function dhtmlspecialchars($string) {
- 126. ......
- 127.}
- 128.
- 129./**
- 130. * 退出程序 同 exit 的区别, 对输出数据会进行 重新加工和处理
- 131. * 通常情况下,我们建议使用本函数终止程序, 除非有特别需求
- 132. * @param <type> $message
- 133. */
- 134.function dexit($message = '') {
- 135. ......
- 136.}
- 137.
- 138./**
- 139. * 同 php header函数, 针对 location 跳转做了特殊处理
- 140. * @param <type> $string
- 141. * @param <type> $replace
- 142. * @param <type> $http_response_code
- 143. */
- 144.function dheader($string, $replace = true, $http_response_code = 0) {
- 145. ......
- 146.}
- 147.
- 148./**
- 149.* 设置cookie
- 150.* @param $var - 变量名
- 151.* @param $value - 变量值
- 152.* @param $life - 生命期
- 153.* @param $prefix - 前缀
- 154.* @param $httponly - 安全属性
- 155.*/
- 156.function dsetcookie($var, $value = '', $life = 0, $prefix = 1, $httponly = false) {
- 157. ......
- 158.}
- 159.
- 160./**
- 161. * 获取cookie
- 162. * @param $key - cookie名称,不需要带前缀
- 163. */
- 164.function getcookie($key) {
- 165. ......
- 166.}
- 167.
- 168./**
- 169. * 获取文件扩展名
- 170. * @param $filename 文件名
- 171. */
- 172.function fileext($filename) {
- 173. ......
- 174.}
- 175.
- 176./**
- 177.* 检查是否是以手机浏览器进入(IN_MOBILE)
- 178.*/
- 179.function checkmobile() {
- 180. ......
- 181.}
- 182.
- 183./**
- 184. * 字符串方式实现 preg_match("/(s1|s2|s3)/", $string, $match)
- 185. * @param string $string 源字符串
- 186. * @param array $arr 要查找的字符串 如array('s1', 's2', 's3')
- 187. * @param bool $returnvalue 是否返回找到的值
- 188. * @return bool
- 189. */
- 190.function dstrpos($string, &$arr, $returnvalue = false) {
- 191. ......
- 192.}
- 193.
- 194./**
- 195.* 检查邮箱是否有效
- 196.* @param $email 要检查的邮箱
- 197.* @param 返回结果
- 198.*/
- 199.function isemail($email) {
- 200. ......
- 201.}
- 202.
- 203./**
- 204.* 问题答案加密
- 205.* @param $questionid - 问题
- 206.* @param $answer - 答案
- 207.* @return 返回加密的字串
- 208.*/
- 209.function quescrypt($questionid, $answer) {
- 210. ......
- 211.}
- 212.
- 213./**
- 214.* 产生随机码
- 215.* @param $length - 要多长
- 216.* @param $numberic - 数字还是字符串
- 217.* @return 返回字符串
- 218.*/
- 219.function random($length, $numeric = 0) {
- 220. ......
- 221.}
- 222.
- 223./**
- 224. * 判断一个字符串是否在另一个字符串中存在
- 225. *
- 226. * @param string 原始字串 $string
- 227. * @param string 查找 $find
- 228. * @return boolean
- 229. */
- 230.function strexists($string, $find) {
- 231. ......
- 232.}
- 233.
- 234./**
- 235. * 获取头像
- 236. *
- 237. * @param int $uid 需要获取的用户UID值
- 238. * @param string $size 获取尺寸 'small', 'middle', 'big'
- 239. * @param boolean $returnsrc 是否直接返回图片src
- 240. * @param boolean $real 是否返回真实图片
- 241. * @param boolean $static 是否返回真实路径
- 242. * @param string $ucenterurl 强制uc路径
- 243. */
- 244.function avatar($uid, $size = 'middle', $returnsrc = FALSE, $real = FALSE, $static = FALSE, $ucenterurl = '') {
- 245. ......
- 246.}
- 247.
- 248./**
- 249.* 加载语言
- 250.* 语言文件统一为 $lang = array();
- 251.* @param $file - 语言文件,可包含路径如 forum/xxx home/xxx
- 252.* @param $langvar - 语言文字索引
- 253.* @param $vars - 变量替换数组
- 254.* @param $default - 指定默认值,当找不到对应言包时生效
- 255.* @return 语言文字
- 256.*/
- 257.function lang($file, $langvar = null, $vars = array(), $default = null) {
- 258. ......
- 259.}
- 260.
- 261./**
- 262.* 检查模板源文件是否更新
- 263.* 当编译文件不存时强制重新编译
- 264.* 当 tplrefresh = 1 时检查文件
- 265.* 当 tplrefresh > 1 时,则根据 tplrefresh 取余,无余时则检查更新
- 266.*
- 267.*/
- 268.function checktplrefresh($maintpl, $subtpl, $timecompare, $templateid, $cachefile, $tpldir, $file) {
- 269. ......
- 270.}
- 271.
- 272./**
- 273.* 解析模板
- 274.* @return 返回域名
- 275.*/
- 276.function template($file, $templateid = 0, $tpldir = '', $gettplfile = 0, $primaltpl='') {
- 277. ......
- 278.}
- 279.
- 280./**
- 281. * 对某id进行个性化md5
- 282. */
- 283.function modauthkey($id) {
- 284. ......
- 285.}
- 286.
- 287./**
- 288. * 获得当前应用页面选中的导航id
- 289. */
- 290.function getcurrentnav() {
- 291. ......
- 292.}
- 293.
- 294./**
- 295.* 读取缓存
- 296.* @param $cachenames - 缓存名称数组或字串
- 297.*/
- 298.function loadcache($cachenames, $force = false) {
- 299. ......
- 300.}
- 301.
- 302./**
- 303. * 通过memcache\mysql\file等几种手段读缓存
- 304. * @param mixed $cachenames 缓存名的数组或字串
- 305. */
- 306.function cachedata($cachenames) {
- 307. ......
- 308.}
- 309.
- 310./**
- 311.* 格式化时间
- 312.* @param $timestamp - 时间戳
- 313.* @param $format - dt=日期时间 d=日期 t=时间 u=个性化 其他=自定义
- 314.* @param $timeoffset - 时区
- 315.* @return string
- 316.*/
- 317.function dgmdate($timestamp, $format = 'dt', $timeoffset = '9999', $uformat = '') {
- 318. ......
- 319.}
- 320.
- 321./**
- 322. 得到时间戳
- 323.*/
- 324.function dmktime($date) {
- 325. ......
- 326.}
- 327.
- 328./**
- 329.* 更新缓存
- 330.* @param $cachename - 缓存名称
- 331.* @param $data - 缓存数据
- 332.*/
- 333.function save_syscache($cachename, $data) {
- 334. ......
- 335.}
- 336.
- 337./**
- 338.* Portal模块
- 339.* @param $parameter - 参数集合
- 340.*/
- 341.function block_get($parameter) {
- 342. ......
- 343.}
- 344.
- 345./**
- 346.* Portal 模块显示
- 347.*
- 348.* @param $parameter - 参数集合
- 349.*/
- 350.function block_display($bid) {
- 351. ......
- 352.}
- 353.
- 354./**
- 355.* 返回库文件的全路径
- 356.*
- 357.* @param string $libname 库文件分类及名称
- 358.* @param string $folder 模块目录'module','include','class'
- 359.* @return string
- 360.*
- 361.* @example require DISCUZ_ROOT.'./source/function/function_cache.php'
- 362.* @example 我们可以利用此函数简写为:require libfile('function/cache');
- 363.*
- 364.*/
- 365.function libfile($libname, $folder = '') {
- 366. ......
- 367.}
- 368.
- 369./**
- 370. * 针对uft-8进行特殊处理的strlen
- 371. * @param string $str
- 372. * @return int
- 373. */
- 374.function dstrlen($str) {
- 375. ......
- 376.}
- 377.
- 378./**
- 379.* 根据中文裁减字符串
- 380.* @param $string - 字符串
- 381.* @param $length - 长度
- 382.* @param $doc - 缩略后缀
- 383.* @return 返回带省略号被裁减好的字符串
- 384.*/
- 385.function cutstr($string, $length, $dot = ' ...') {
- 386. ......
- 387.}
- 388.
- 389./**
- 390.* 论坛 aid url 生成
- 391.*/
- 392.function aidencode($aid, $type = 0, $tid = 0) {
- 393. ......
- 394.}
- 395.
- 396./**
- 397. * 返回论坛缩放附件图片的地址 url
- 398. */
- 399.function getforumimg($aid, $nocache = 0, $w = 140, $h = 140, $type = '') {
- 400. ......
- 401.}
- 402.
- 403.
- 404./**
- 405. * 获取rewrite字符串
- 406. * @param string $type 需要获取的rewite
- 407. * @param boolean $returntype true:直接返回href, false:返回a标签
- 408. * @param string $host 可选网站域名
- 409. * @return string
- 410. */
- 411.function rewriteoutput($type, $returntype, $host) {
- 412. ......
- 413.}
- 414.
- 415./**
- 416.* 手机模式下替换所有链接为mobile=yes形式
- 417.* @param $file - 正则匹配到的文件字符串
- 418.* @param $file - 要被替换的字符串
- 419.* @$replace 替换后字符串
- 420.*/
- 421.function mobilereplace($file, $replace) {
- 422. ......
- 423.}
- 424.
- 425./**
- 426.* 手机的output函数
- 427.*/
- 428.function mobileoutput() {
- 429. ......
- 430.}
- 431.
- 432./**
- 433.* 系统输出
- 434.* @return 返回内容
- 435.*/
- 436.function output() {
- 437. ......
- 438.}
- 439.
- 440./**
- 441. * ajax footer使用输出页面内容
- 442. */
- 443.function output_ajax() {
- 444. ......
- 445.}
- 446.
- 447./**
- 448. * 运行钩子
- 449. */
- 450.function runhooks() {
- 451. ......
- 452.}
- 453.
- 454./**
- 455. * 执行插件脚本
- 456. */
- 457.function hookscript($script, $hscript, $type = 'funcs', $param = array(), $func = '') {
- 458. ......
- 459.}
- 460.
- 461./**
- 462. * 获取插件模块
- 463. */
- 464.function pluginmodule($pluginid, $type) {
- 465. ......
- 466.}
- 467.
- 468./**
- 469. * 执行积分规则
- 470. * @param String $action: 规则action名称
- 471. * @param Integer $uid: 操作用户
- 472. * @param array $extrasql: common_member_count的额外操作字段数组格式为 array('extcredits1' => '1')
- 473. * @param String $needle: 防重字符串
- 474. * @param Integer $coef: 积分放大倍数
- 475. * @param Integer $update: 是否执行更新操作
- 476. * @param Integer $fid: 版块ID
- 477. * @return 返回积分策略
- 478. */
- 479.function updatecreditbyaction($action, $uid = 0, $extrasql = array(), $needle = '', $coef = 1, $update = 1, $fid = 0) {
- 480. ......
- 481.}
- 482.
- 483./**
- 484.* 检查积分下限
- 485.* @param string $action: 策略动作Action或者需要检测的操作积分值使如extcredits1积分进行减1操作检测array('extcredits1' => -1)
- 486.* @param Integer $uid: 用户UID
- 487.* @param Integer $coef: 积分放大倍数/负数为减分操作
- 488.* @param Integer $returnonly: 只要返回结果,不用中断程序运行
- 489.*/
- 490.function checklowerlimit($action, $uid = 0, $coef = 1, $fid = 0, $returnonly = 0) {
- 491. ......
- 492.}
- 493.
- 494./**
- 495. * 批量执行某一条策略规则
- 496. * @param String $action: 规则action名称
- 497. * @param Integer $uids: 操作用户可以为单个uid或uid数组
- 498. * @param array $extrasql: common_member_count的额外操作字段数组格式为 array('extcredits1' => '1')
- 499. * @param Integer $coef: 积分放大倍数,当为负数时为反转操作
- 500. * @param Integer $fid: 版块ID
复制代码 |
|