channelunit.helper.php
21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
<?php if(!defined('DEDEINC')) exit('dedecms');
/**
* 文档小助手
*
* @version $Id: channelunit.helper.php 1 16:49 2010年7月6日Z tianya $
* @package DedeCMS.Helpers
* @copyright Copyright (c) 2007 - 2010, DesDev, Inc.
* @license http://help.dedecms.com/usersguide/license.html
* @link http://www.dedecms.com
*/
/**
* 用星表示软件或Flash的等级
*
* @param string $rank 星星数
* @return string
*/
if ( ! function_exists('GetRankStar'))
{
function GetRankStar($rank)
{
$nstar = "";
for($i=1;$i<=$rank;$i++)
{
$nstar .= "★";
}
for($i;$i<=5;$i++)
{
$nstar .= "☆";
}
return $nstar;
}
}
/**
* 获得文章网址
* 如果要获得文件的路径,直接用
* GetFileUrl($aid,$typeid,$timetag,$title,$ismake,$rank,$namerule,$typedir,$money)
* 即是不指定站点参数则返回相当对根目录的真实路径
*
* @param int $aid 文档ID
* @param int $typeid 栏目ID
* @param int $timetag 时间戳
* @param string $title 标题
* @param int $ismake 是否生成
* @param int $rank 阅读权限
* @param string $namerule 名称规则
* @param string $typedir 栏目dir
* @param string $money 需要金币
* @param string $filename 文件名称
* @param string $moresite 多站点
* @param string $siteurl 站点地址
* @param string $sitepath 站点路径
* @return string
*/
if ( ! function_exists('GetFileUrl'))
{
function GetFileUrl($aid,$typeid,$timetag,$title,$ismake=0,$rank=0,$namerule='',$typedir='',
$money=0, $filename='',$moresite=0,$siteurl='',$sitepath='')
{
$articleUrl = GetFileName($aid,$typeid,$timetag,$title,$ismake,$rank,$namerule,$typedir,$money,$filename);
$sitepath = MfTypedir($sitepath);
//是否强制使用绝对网址
if($GLOBALS['cfg_multi_site']=='Y')
{
if($siteurl=='')
{
$siteurl = $GLOBALS['cfg_basehost'];
}
if($moresite==1)
{
$articleUrl = preg_replace("#^".$sitepath.'#', '', $articleUrl);
}
if(!preg_match("/http:/", $articleUrl))
{
$articleUrl = $siteurl.$articleUrl;
}
}
return $articleUrl;
}
}
/**
* 获得新文件名(本函数会自动创建目录)
*
* @param int $aid 文档ID
* @param int $typeid 栏目ID
* @param int $timetag 时间戳
* @param string $title 标题
* @param int $ismake 是否生成
* @param int $rank 阅读权限
* @param string $namerule 名称规则
* @param string $typedir 栏目dir
* @param string $money 需要金币
* @param string $filename 文件名称
* @return string
*/
if ( ! function_exists('GetFileNewName'))
{
function GetFileNewName($aid,$typeid,$timetag,$title,$ismake=0,$rank=0,$namerule='',$typedir='',$money=0,$filename='')
{
global $cfg_arc_dirname;
$articlename = GetFileName($aid,$typeid,$timetag,$title,$ismake,$rank,$namerule,$typedir,$money,$filename);
if(preg_match("/\?/", $articlename))
{
return $articlename;
}
if($cfg_arc_dirname=='Y' && preg_match("/\/$/", $articlename))
{
$articlename = $articlename."index.html";
}
$slen = strlen($articlename)-1;
for($i=$slen;$i>=0;$i--)
{
if($articlename[$i]=='/')
{
$subpos = $i;
break;
}
}
$okdir = substr($articlename,0,$subpos);
CreateDir($okdir);
return $articlename;
}
}
/**
* 获得文件相对于主站点根目录的物理文件名(动态网址返回url)
*
* @param int $aid 文档ID
* @param int $typeid 栏目ID
* @param int $timetag 时间戳
* @param string $title 标题
* @param int $ismake 是否生成
* @param int $rank 阅读权限
* @param string $namerule 名称规则
* @param string $typedir 栏目dir
* @param string $money 需要金币
* @param string $filename 文件名称
* @return string
*/
if ( ! function_exists('GetFileName'))
{
function GetFileName($aid,$typeid,$timetag,$title,$ismake=0,$rank=0,$namerule='',$typedir='',$money=0,$filename='')
{
global $cfg_rewrite, $cfg_cmspath, $cfg_arcdir, $cfg_special, $cfg_arc_dirname;
//没指定栏目时用固定规则(专题)
if(empty($namerule)) {
$namerule = $cfg_special.'/arc-{aid}.html';
$typeid = -1;
}
if($rank!=0 || $ismake==-1 || $typeid==0 || $money>0)
{
//动态文章
if($cfg_rewrite == 'Y')
{
return $GLOBALS["cfg_plus_dir"]."/view-".$aid.'-1.html';
}
else
{
return $GLOBALS['cfg_phpurl']."/view.php?aid=$aid";
}
}
else
{
$articleDir = MfTypedir($typedir);
$articleRule = strtolower($namerule);
if($articleRule=='')
{
$articleRule = strtolower($GLOBALS['cfg_df_namerule']);
}
if($typedir=='')
{
$articleDir = $GLOBALS['cfg_cmspath'].$GLOBALS['cfg_arcdir'];
}
$dtime = GetDateMk($timetag);
list($y, $m, $d) = explode('-', $dtime);
$arr_rpsource = array('{typedir}','{y}','{m}','{d}','{timestamp}','{aid}','{cc}');
$arr_rpvalues = array($articleDir,$y, $m, $d, $timetag, $aid, dd2char($m.$d.$aid.$y));
if($filename != '')
{
$articleRule = dirname($articleRule).'/'.$filename.$GLOBALS['cfg_df_ext'];
}
$articleRule = str_replace($arr_rpsource,$arr_rpvalues,$articleRule);
if(preg_match("/\{p/", $articleRule))
{
$articleRule = str_replace('{pinyin}',GetPinyin($title).'_'.$aid,$articleRule);
$articleRule = str_replace('{py}',GetPinyin($title,1).'_'.$aid,$articleRule);
}
$articleUrl = '/'.preg_replace("/^\//", '', $articleRule);
if(preg_match("/index\.html/", $articleUrl) && $cfg_arc_dirname=='Y')
{
$articleUrl = str_replace('index.html', '', $articleUrl);
}
return $articleUrl;
}
}
}
/**
* 获得指定类目的URL链接
* 对于使用封面文件和单独页面的情况,强制使用默认页名称
*
* @param int $typeid 栏目ID
* @param string $typedir 栏目目录
* @param int $isdefault 是否默认
* @param string $defaultname 默认名称
* @param int $ispart 栏目属性
* @param string $namerule2 名称规则
* @param string $moresite 多站点
* @param string $siteurl 站点地址
* @param string $sitepath 站点目录
* @return string
*/
if ( ! function_exists('GetTypeUrl'))
{
function GetTypeUrl($typeid,$typedir,$isdefault,$defaultname,$ispart,$namerule2,$moresite=0,$siteurl='',$sitepath='')
{
global $cfg_typedir_df;
$typedir = MfTypedir($typedir);
$sitepath = MfTypedir($sitepath);
if($isdefault==-1)
{
//动态
$reurl = $GLOBALS['cfg_phpurl']."/list.php?tid=".$typeid;
}
else if($ispart==2)
{
//跳转网址
$reurl = $typedir;
return $reurl;
}
else
{
if($isdefault==0 && $ispart==0)
{
$reurl = str_replace("{page}","1",$namerule2);
$reurl = str_replace("{tid}",$typeid,$reurl);
$reurl = str_replace("{typedir}",$typedir,$reurl);
}
else
{
if($cfg_typedir_df=='N' || $isdefault==0) $reurl = $typedir.'/'.$defaultname;
else $reurl = $typedir.'/';
}
}
if( !preg_match("/^http:\/\//",$reurl) ) {
$reurl = preg_replace("/\/{1,}/i", '/', $reurl);
}
if($GLOBALS['cfg_multi_site']=='Y')
{
if($siteurl=='') {
$siteurl = $GLOBALS['cfg_basehost'];
}
if($moresite==1 ) {
$reurl = preg_replace("#^".$sitepath."#", '', $reurl);
}
if( !preg_match("/^http:\/\//", $reurl) ) {
$reurl = $siteurl.$reurl;
}
}
return $reurl;
}
}
/**
* 魔法变量,用于获取两个可变的值
*
* @param string $v1 第一个变量
* @param string $v2 第二个变量
* @return string
*/
if ( ! function_exists('MagicVar'))
{
function MagicVar($v1,$v2)
{
return $GLOBALS['autoindex']%2==0 ? $v1 : $v2;
}
}
/**
* 获取某个类目的所有上级栏目id
*
* @param int $tid 栏目ID
* @return string
*/
if ( ! function_exists('GetTopids'))
{
function GetTopids($tid)
{
$arr = GetParentIds($tid);
return join(',',$arr);
}
}
/**
* 获取上级ID列表
*
* @access public
* @param string $tid 栏目ID
* @return string
*/
if ( ! function_exists('GetParentIds'))
{
function GetParentIds($tid)
{
global $cfg_Cs;
$GLOBALS['pTypeArrays'][] = $tid;
if(!is_array($cfg_Cs))
{
require_once(DEDEDATA."/cache/inc_catalog_base.inc");
}
if(!isset($cfg_Cs[$tid]) || $cfg_Cs[$tid][0]==0)
{
return $GLOBALS['pTypeArrays'];
}
else
{
return GetParentIds($cfg_Cs[$tid][0]);
}
}
}
/**
* 检测栏目是否是另一个栏目的父目录
*
* @access public
* @param string $sid 顶级目录id
* @param string $pid 下级目录id
* @return bool
*/
if ( ! function_exists('IsParent'))
{
function IsParent($sid, $pid)
{
$pTypeArrays = GetParentIds($sid);
return in_array($pid, $pTypeArrays);
}
}
/**
* 获取一个类目的顶级类目id
*
* @param string $tid 栏目ID
* @return string
*/
if ( ! function_exists('GetTopid'))
{
function GetTopid($tid)
{
global $cfg_Cs;
if(!is_array($cfg_Cs))
{
require_once(DEDEDATA."/cache/inc_catalog_base.inc");
}
if(!isset($cfg_Cs[$tid][0]) || $cfg_Cs[$tid][0]==0)
{
return $tid;
}
else
{
return GetTopid($cfg_Cs[$tid][0]);
}
}
}
/**
* 获得某id的所有下级id
*
* @param string $id 栏目id
* @param string $channel 模型ID
* @param string $addthis 是否包含本身
* @return string
*/
function GetSonIds($id,$channel=0,$addthis=true)
{
global $cfg_Cs;
$GLOBALS['idArray'] = array();
if( !is_array($cfg_Cs) )
{
require_once(DEDEDATA."/cache/inc_catalog_base.inc");
}
GetSonIdsLogic($id,$cfg_Cs,$channel,$addthis);
$rquery = join(',',$GLOBALS['idArray']);
$rquery = preg_replace("/,$/", '', $rquery);
return $rquery;
}
//递归逻辑
function GetSonIdsLogic($id,$sArr,$channel=0,$addthis=false)
{
if($id!=0 && $addthis)
{
$GLOBALS['idArray'][$id] = $id;
}
if(is_array($sArr))
{
foreach($sArr as $k=>$v)
{
if( $v[0]==$id && ($channel==0 || $v[1]==$channel ))
{
GetSonIdsLogic($k,$sArr,$channel,true);
}
}
}
}
/**
* 栏目目录规则
*
* @param string $typedir 栏目目录
* @return string
*/
function MfTypedir($typedir)
{
if(preg_match("/^http:|^ftp:/i", $typedir)) return $typedir;
$typedir = str_replace("{cmspath}",$GLOBALS['cfg_cmspath'],$typedir);
$typedir = preg_replace("/\/{1,}/", "/", $typedir);
return $typedir;
}
/**
* 模板目录规则
*
* @param string $tmpdir 模板目录
* @return string
*/
function MfTemplet($tmpdir)
{
$tmpdir = str_replace("{style}", $GLOBALS['cfg_df_style'], $tmpdir);
$tmpdir = preg_replace("/\/{1,}/", "/", $tmpdir);
return $tmpdir;
}
/**
* 清除用于js的空白块
*
* @param string $atme 字符
* @return string
*/
function FormatScript($atme)
{
return $atme==' ' ? '' : $atme;
}
/**
* 给属性默认值
*
* @param array $atts 属性
* @param array $attlist 属性列表
* @return string
*/
function FillAttsDefault(&$atts, $attlist)
{
$attlists = explode(',', $attlist);
for($i=0; isset($attlists[$i]); $i++)
{
list($k, $v) = explode('|', $attlists[$i]);
if(!isset($atts[$k]))
{
$atts[$k] = $v;
}
}
}
/**
* 给块标记赋值
*
* @param object $dtp 模板解析引擎
* @param object $refObj 实例化对象
* @param object $parfield
* @return string
*/
function MakeOneTag(&$dtp, &$refObj, $parfield='Y')
{
global $cfg_disable_tags;
$cfg_disable_tags = isset($cfg_disable_tags)? $cfg_disable_tags : 'php';
$disable_tags = explode(',', $cfg_disable_tags);
$alltags = array();
$dtp->setRefObj($refObj);
//读取自由调用tag列表
$dh = dir(DEDEINC.'/taglib');
while($filename = $dh->read())
{
if(preg_match("/\.lib\./", $filename))
{
$alltags[] = str_replace('.lib.php','',$filename);
}
}
$dh->Close();
//遍历tag元素
if(!is_array($dtp->CTags))
{
return '';
}
foreach($dtp->CTags as $tagid=>$ctag)
{
$tagname = $ctag->GetName();
if($tagname=='field' && $parfield=='Y')
{
$vname = $ctag->GetAtt('name');
if( $vname=='array' && isset($refObj->Fields) )
{
$dtp->Assign($tagid,$refObj->Fields);
}
else if(isset($refObj->Fields[$vname]))
{
$dtp->Assign($tagid,$refObj->Fields[$vname]);
}
else if($ctag->GetAtt('noteid') != '')
{
if( isset($refObj->Fields[$vname.'_'.$ctag->GetAtt('noteid')]) )
{
$dtp->Assign($tagid, $refObj->Fields[$vname.'_'.$ctag->GetAtt('noteid')]);
}
}
continue;
}
//由于考虑兼容性,原来文章调用使用的标记别名统一保留,这些标记实际调用的解析文件为inc_arclist.php
if(preg_match("/^(artlist|likeart|hotart|imglist|imginfolist|coolart|specart|autolist)$/", $tagname))
{
$tagname='arclist';
}
if($tagname=='friendlink')
{
$tagname='flink';
}
if(in_array($tagname,$alltags))
{
if(in_array($tagname, $disable_tags))
{
if(DEBUG_LEVEL) echo 'DedeCMS Error:Tag disabled:"'.$tagname.'" <a href="http://help.dedecms.com/install-use/apply/2013/0711/2324.html" target="_blank">more...</a>!';
continue;
}
if (DEBUG_LEVEL==TRUE) {
$ttt1 = ExecTime();
}
$filename = DEDEINC.'/taglib/'.$tagname.'.lib.php';
include_once($filename);
$funcname = 'lib_'.$tagname;
$dtp->Assign($tagid,$funcname($ctag,$refObj));
if (DEBUG_LEVEL==TRUE) {
$queryTime = ExecTime() - $ttt1;
echo '标签:'.$tagname.'载入花费时间:'.$queryTime."<br />\r\n";
}
}
}
}
/**
* 获取某栏目的url
*
* @param array $typeinfos 栏目信息
* @return string
*/
function GetOneTypeUrlA($typeinfos)
{
return GetTypeUrl($typeinfos['id'],MfTypedir($typeinfos['typedir']),$typeinfos['isdefault'],$typeinfos['defaultname'],
$typeinfos['ispart'],$typeinfos['namerule2'],$typeinfos['moresite'],$typeinfos['siteurl'],$typeinfos['sitepath']);
}
/**
* 设置全局环境变量
*
* @param int $typeid 栏目ID
* @param string $typename 栏目名称
* @param string $aid 文档ID
* @param string $title 标题
* @param string $curfile 当前文件
* @return string
*/
function SetSysEnv($typeid=0,$typename='',$aid=0,$title='',$curfile='')
{
global $_sys_globals;
if(empty($_sys_globals['curfile']))
{
$_sys_globals['curfile'] = $curfile;
}
if(empty($_sys_globals['typeid']))
{
$_sys_globals['typeid'] = $typeid;
}
if(empty($_sys_globals['typename']))
{
$_sys_globals['typename'] = $typename;
}
if(empty($_sys_globals['aid']))
{
$_sys_globals['aid'] = $aid;
}
}
/**
* 获得图书的URL
*
* @param string $bid 书籍ID
* @param string $title 标题
* @param string $gdir
* @return string
*/
function GetBookUrl($bid,$title,$gdir=0)
{
global $cfg_cmspath;
$bookurl = $gdir==1 ?
"{$cfg_cmspath}/book/".DedeID2Dir($bid) : "{$cfg_cmspath}/book/".DedeID2Dir($bid).'/'.GetPinyin($title).'-'.$bid.'.html';
return $bookurl;
}
/**
* 根据ID生成目录
*
* @param string $aid 内容ID
* @return int
*/
function DedeID2Dir($aid)
{
$n = ceil($aid / 1000);
return $n;
}
/**
* 获得自由列表的网址
*
* @param string $lid 列表id
* @param string $namerule 命名规则
* @param string $listdir 列表目录
* @param string $defaultpage 默认页面
* @param string $nodefault 没有默认页面
* @return string
*/
function GetFreeListUrl($lid,$namerule,$listdir,$defaultpage,$nodefault){
$listdir = str_replace('{cmspath}',$GLOBALS['cfg_cmspath'],$listdir);
if($nodefault==1)
{
$okfile = str_replace('{page}','1',$namerule);
$okfile = str_replace('{listid}',$lid,$okfile);
$okfile = str_replace('{listdir}',$listdir,$okfile);
}
else
{
$okfile = $GLOBALS['cfg_phpurl']."/freelist.php?lid=$lid";
return $okfile;
}
$okfile = str_replace("\\","/",$okfile);
$okfile = str_replace("//","/",$okfile);
$trueFile = $GLOBALS['cfg_basedir'].$okfile;
if(!@file_exists($trueFile))
{
$okfile = $GLOBALS['cfg_phpurl']."/freelist.php?lid=$lid";
}
return $okfile;
}
/**
* 获取网站搜索的热门关键字
*
* @param string $dsql
* @param string $num 获取数目
* @param string $nday 天数
* @param string $klen 关键词字数
* @param string $orderby 排列顺序
* @return string
*/
function GetHotKeywords(&$dsql,$num=8,$nday=365,$klen=16,$orderby='count')
{
global $cfg_phpurl,$cfg_cmspath;
$nowtime = time();
$num = @intval($num);
$nday = @intval($nday);
$klen = @intval($klen);
if(empty($nday))
{
$nday = 365;
}
if(empty($num))
{
$num = 6;
}
if(empty($klen))
{
$klen = 16;
}
$klen = $klen+1;
$mintime = $nowtime - ($nday * 24 * 3600);
if(empty($orderby))
{
$orderby = 'count';
}
$dsql->SetQuery("SELECT keyword FROM #@__search_keywords WHERE lasttime>$mintime AND length(keyword)<$klen ORDER BY $orderby DESC LIMIT 0,$num");
$dsql->Execute('hw');
$hotword = "";
while($row=$dsql->GetArray('hw'))
{
$hotword .= " <a href='".$cfg_phpurl."/search.php?keyword=".urlencode($row['keyword'])."&searchtype=titlekeyword'>".$row['keyword']."</a> ";
}
return $hotword;
}
/**
* 使用绝对网址
*
* @param string $gurl 地址
* @return string
*/
function Gmapurl($gurl)
{
return preg_replace("/http:\/\//i", $gurl) ? $gurl : $GLOBALS['cfg_basehost'].$gurl;
}
/**
* 引用回复标记处理
*
* @param string $quote
* @return string
*/
function Quote_replace($quote)
{
$quote = str_replace('{quote}','<div class="decmt-box">',$quote);
$quote = str_replace('{title}','<div class="decmt-title"><span class="username">',$quote);
$quote = str_replace('{/title}','</span></div>',$quote);
$quote = str_replace('<br/>','<br>',$quote);
$quote = str_replace('<', '<', $quote);
$quote = str_replace('>', '>', $quote);
$quote = str_replace('{content}','<div class="decmt-content">',$quote);
$quote = str_replace('{/content}','</div>',$quote);
$quote = str_replace('{/quote}','</div>',$quote);
return $quote;
}
/**
* 获取、写入指定cacheid的块
*
* @param string $cacheid 缓存ID
* @return string
*/
function GetCacheBlock($cacheid)
{
global $cfg_puccache_time;
$cachefile = DEDEDATA.'/cache/'.$cacheid.'.inc';
if(!file_exists($cachefile) || filesize($cachefile)==0 ||
$cfg_puccache_time==0 || time() - filemtime($cachefile) > $cfg_puccache_time)
{
return '';
}
$fp = fopen($cachefile, 'r');
$str = @fread($fp, filesize($cachefile));
fclose($fp);
return $str;
}
/**
* 写入缓存块
*
* @param string $cacheid 缓存ID
* @param string $str 字符串信息
* @return string
*/
function WriteCacheBlock($cacheid, $str)
{
$cachefile = DEDEDATA.'/cache/'.$cacheid.'.inc';
$fp = fopen($cachefile, 'w');
$str = fwrite($fp, $str);
fclose($fp);
}