-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.php
152 lines (142 loc) · 6.32 KB
/
index.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
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
<?php
// trackback module for XOOPS (user side code)
// $Id: index.php,v 1.16 2010/01/31 06:04:36 nobu Exp $
include("header.php");
include_once "functions.php";
$base = XOOPS_URL."/modules/".$xoopsModule->dirname();
$basedir = XOOPS_ROOT_PATH."/modules/".$xoopsModule->dirname();
$track_id = isset($_GET['id'])&&$_GET['id']!="all"?intval($_GET['id']):"all";
$page = isset($_GET['page'])?intval($_GET['page']):1;
$detail = isset($_GET['detail']);
$tblstyle="border='0' cellspacing='1' cellpadding='3' class='outer' width='100%'";
include(XOOPS_ROOT_PATH."/header.php");
$breadcrumbs = array();
$breadcrumbs[] = array('url'=>'index.php?id=list', 'name'=>_TB_INDEX);
if (!isset($xoopsModuleConfig['threshold'])) $xoopsModuleConfig['threshold'] = 1;
if ($track_id === "all") {
$xoopsOption['template_main'] = 'refpage_referer.html';
$order = "nref DESC";
$opt = "";
if (isset($_GET['order'])) {
switch ($_GET['order']) {
case 'time':
$order = "mtime DESC";
$opt .= "&order=time";
break;
}
}
$cond = "linked=1 AND track_id=track_from AND disable=0 AND nref>=".$xoopsModuleConfig['threshold'];
$title = "";
$result = $xoopsDB->query("SELECT COUNT(title) FROM ".TBR.",".TBL." WHERE $cond");
list($nrec) = $xoopsDB->fetchRow($result);
$start = ($page>1)?($page-1)*$xoopsModuleConfig['list_max']:0;
$breadcrumbs[] = array('name'=>_TB_ALLPAGE);
$xoopsTpl->assign('xoops_breadcrumbs', $breadcrumbs);
$result = $xoopsDB->query("SELECT * FROM ".TBR.",".TBL." WHERE $cond ORDER BY $order", $xoopsModuleConfig['list_max'], $start);
if ($nrec) {
$popt = ($page>1)?"&page=$page":"";
$ordstr = sprintf($order=="nref DESC"?"<b>%s</b>":"<a href='index.php?id=all$popt'>%s</a>",_TB_ORDER_NREF).
" | ".sprintf($order=="mtime DESC"?"<b>%s</b>":"<a href='index.php?id=all&order=time$popt'>%s</a>",_TB_ORDER_TIME);
$xoopsTpl->assign('page_control', make_page_index("$ordstr - "._TB_PAGE, $nrec, $page, " <a href='index.php?id=$track_id$opt&page=%d'>(%d)</a>"));
$referers = array();
while ($data=$xoopsDB->fetchArray($result)) {
$data['seq'] = ++$start;
$data['cdate'] = formatTimestamp($data['since'], "m");
$data['mdate'] = formatTimestamp($data['mtime'], "m");
$data['linkto'] = uri_to_name($data['track_uri']);
if (empty($data['title'])) $data['title'] = myurldecode($data['ref_url']);
$referers[] = $data;
}
$xoopsTpl->assign('referers', $referers);
}
} elseif ( empty($track_id) ) {
// list of tracking pages
$cond = "track_id=track_from AND disable=0 AND linked=1 AND nref>=".$xoopsModuleConfig['threshold']." GROUP BY track_from ";
$result = $xoopsDB->query("SELECT track_from FROM ".TBL.",".TBR." WHERE $cond");
$nrec = $xoopsDB->getRowsNum($result);
$start = ($page>1)?($page-1)*$xoopsModuleConfig['list_max']:0;
$result = $xoopsDB->query("SELECT track_id AS tid, track_uri AS uri, COUNT(ref_id) AS refs FROM ".TBL.",".TBR." WHERE $cond ORDER BY track_uri", $xoopsModuleConfig['list_max'], $start);
if ($nrec) {
$xoopsOption['template_main'] = 'refpage_index.html';
$xoopsTpl->assign('page_control', make_page_index(_TB_PAGE, $nrec, $page, " <a href='index.php?id=0&page=%d'>(%d)</a>"));
$pages = array();
while ($pg=$xoopsDB->fetchArray($result)) {
$start++;
$pg['seq'] = $start;
$pg['name'] = uri_to_name($pg['uri']);
$pages[] = $pg;
}
$xoopsTpl->assign('pages', $pages);
}
} else {
// a tracking page
$xoopsOption['template_main'] = 'refpage_referer.html';
$order = "nref DESC";
$opt = "";
if (isset($_GET['order'])) {
switch ($_GET['order']) {
case 'time':
$order = "mtime DESC";
$opt .= "&order=time";
break;
}
}
$result = $xoopsDB->query("SELECT track_uri,disable FROM ".TBL." WHERE track_id=$track_id");
list($uri, $disable) = $xoopsDB->fetchRow($result);
if (!isset($disable) || $disable) {
redirect_header("index.php",1,_TB_NOPAGE);
exit();
}
$cond = "track_from=$track_id AND linked=1 AND nref>=".$xoopsModuleConfig['threshold'];
if ($detail) {
$sql = "SELECT COUNT(ref_id) FROM ".TBR." WHERE $cond";
$result = $xoopsDB->query($sql);
list($nrec) = $xoopsDB->fetchRow($result);
} else {
$sql = "SELECT title, count(1) FROM ".TBR." WHERE $cond GROUP BY title";
$result = $xoopsDB->query($sql);
$nrec = $xoopsDB->GetRowsNum($result);
}
$start = ($page>1)?($page-1)*$xoopsModuleConfig['list_max']:0;
$breadcrumbs[] = array('name'=>uri_to_name($uri));
$xoopsTpl->assign('xoops_breadcrumbs', $breadcrumbs);
if ($detail) { // summary by "title"
$sql = "SELECT * FROM ".TBR." WHERE $cond ORDER BY $order";
} else {
$sql = "SELECT SUM(nref) nref,COUNT(ref_id) n, title, ".
" MAX(mtime) mtime, MIN(since) since,".
" MIN(ref_url) ref_url, MAX(context) context".
" FROM ".TBR." WHERE $cond".
" GROUP BY title ORDER BY $order";
}
$result = $xoopsDB->query($sql, $xoopsModuleConfig['list_max'], $start);
if ($nrec) {
$popt = ($page>1)?"&page=$page":"";
$ordstr = sprintf($order=="nref DESC"?"<b>%s</b>":"<a href='index.php?id=$track_id$popt'>%s</a>",_TB_ORDER_NREF).
" | ".sprintf($order=="mtime DESC"?"<b>%s</b>":"<a href='index.php?id=$track_id&order=time$popt'>%s</a>",_TB_ORDER_TIME);
$xoopsTpl->assign('page_control', make_page_index("$ordstr - "._TB_PAGE, $nrec, $page, " <a href='index.php?id=$track_id$opt&page=%d'>(%d)</a>"));
$referers = array();
while ($data=$xoopsDB->fetchArray($result)) {
$data['seq'] = ++$start;
$data['cdate'] = formatTimestamp($data['since'], "m");
$data['mdate'] = formatTimestamp($data['mtime'], "m");
if (!$detail && $data['n']>1) { // url list
$rsub = $xoopsDB->query("SELECT nref, ref_url, mtime FROM ".TBR." WHERE $cond AND title=".$xoopsDB->quoteString($data['title'])." ORDER BY $order", 20);
$refs = array();
$refn = array();
while (list($nref, $url)=$xoopsDB->fetchRow($rsub)) {
$refs[] = $url;
$refn[] = $nref;
}
$data["refs"] = $refs;
$data["refn"] = $refn;
$data["ref_url"] = $refs[0];
}
if (empty($data['title'])) $data['title'] = myurldecode($data['ref_url']);
$referers[] = $data;
}
$xoopsTpl->assign('referers', $referers);
}
}
include (XOOPS_ROOT_PATH."/footer.php");
?>