-
Notifications
You must be signed in to change notification settings - Fork 0
/
js.php
executable file
·86 lines (71 loc) · 2.02 KB
/
js.php
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
<?php
/*
[UCenter Home] (C) 2007-2008 Comsenz Inc.
$Id: js.php 9055 2008-10-21 06:22:45Z liguode $
*/
@define('IN_UCHOME', TRUE);
$id = empty($_GET['id'])?0:intval($_GET['id']);
$adid = empty($_GET['adid'])?0:intval($_GET['adid']);
if($id) {
//模块
include_once('./data/data_block.php');
if(!isset($_SGLOBAL['block'][$id])) {
echo 'document.write(\'No data.\')';
exit();
}
$updatetime = $_SGLOBAL['block'][$id];
//缓存
$cachefile = "./data/block_cache/block_$id.js";
if($updatetime > 0 && file_exists($cachefile) && (time() - filemtime($cachefile) < $updatetime)) {
if(@$fp = fopen($cachefile, 'r')) {
@$content = fread($fp, filesize($cachefile));
fclose($fp);
} else {
$content = 'document.writeln(\'No data.\')';
}
echo $content;
exit();
}
//读取数据
include('./common.php');
//外链接禁止显示导航条
$_SCONFIG['linkguide'] = 0;
//禁止缓存
$_SCONFIG['allowcache'] = 0;
include template("data/blocktpl/$id");
$obcontent = ob_get_contents();
obclean();
$s = array("/(\r|\n)/", "/\<div\s+class=\"pages\"\>.+?\<\/div\>/is", "/\s+(href|src)=\"(.+?)\"/ie");
$r = array("\n", '', 'js_mkurl("\\1", "\\2")');
$content = '';
if($obcontent) {
$obcontent = preg_replace($s, $r, $obcontent);
$lines = explode("\n", $obcontent);
foreach ($lines as $line) {
$line = addcslashes(trim($line), '/\'\\');
$content .= "document.writeln('$line');\n";
}
} else {
$content .= "document.writeln('NO DATA')";
}
if($updatetime > 0) swritefile($cachefile, $content);
echo $content;
} elseif ($adid) {
//读取广告文件
$file = './data/adtpl/'.$adid.'.htm';
if(@$lines = file($file)) {
foreach ($lines as $line) {
$line = addcslashes(trim($line), '/\'\\');
echo "document.writeln('$line');\n";
}
} else {
echo "document.writeln('NO AD.')";
}
}
function js_mkurl($tag, $url) {
if(!preg_match("/^(http\:\/\/|ftp\:\/\/|https\:\/\/|\/)/i", $url)) {
$url = getsiteurl().$url;
}
return " {$tag}=\"$url\"";
}
?>