免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 3820 | 回复: 0
打印 上一主题 下一主题

discuz核心函数库function_core的函数注释 [复制链接]

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

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP