-
Notifications
You must be signed in to change notification settings - Fork 46
/
index.php
147 lines (133 loc) · 5.95 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
<?php
/***************************************************************************
* For license information see doc/license.txt
*
* Unicode Reminder メモ
*
* Display some status information about the server and Opencaching
***************************************************************************/
require('./lib2/web.inc.php');
$sUserCountry = $login->getUserCountry();
$tpl->name = 'start';
$tpl->menuitem = MNU_START;
$tpl->caching = true;
$tpl->cache_lifetime = 300;
$tpl->cache_id = $sUserCountry;
if (!$tpl->is_cached())
{
// news entries
$tpl->assign('news_onstart', $opt['news']['onstart'] );
if ($opt['news']['include'] == '')
{
$news = array();
$rs = sql_slave('SELECT `news`.`date_created` `date`, `news`.`content` `content`, `news_topics`.`name` `topic` FROM `news` INNER JOIN `news_topics` ON (`news`.`topic` = `news_topics`.`id`) WHERE `news`.`display`=1 ORDER BY `news`.`date_created` DESC LIMIT 0, 6');
$tpl->assign_rs('news', $rs);
sql_free_result($rs);
$tpl->assign('extern_news', false);
}
else
{
$url = $opt['news']['include'];
$url = str_replace('{style}', $opt['template']['style'], $url);
$newscontent = read_file($url, $opt['news']['maxsize']);
$tpl->assign('news', $newscontent);
$tpl->assign('extern_news', true);
}
/*
// forum entries
if (file_exists($opt['rootpath'] . 'cache2/phpbb.inc.php'))
require_once($opt['rootpath'] . 'cache2/phpbb.inc.php');
else
*/
$phpbb_topics = array();
$tpl->assign('phpbb_topics', $phpbb_topics);
$tpl->assign('phpbb_enabled', ($opt['cron']['phpbbtopics']['url'] != ''));
$tpl->assign('phpbb_name', $opt['cron']['phpbbtopics']['name']);
$tpl->assign('phpbb_link', $opt['cron']['phpbbtopics']['link']);
// current cache and log-counters
$tpl->assign('count_hiddens', sql_value_slave('SELECT COUNT(*) AS `hiddens` FROM `caches` WHERE `status`=1', 0));
$tpl->assign('count_founds', sql_value_slave('SELECT COUNT(*) AS `founds` FROM `cache_logs` WHERE `type`=1', 0));
$tpl->assign('count_users', sql_value_slave('SELECT COUNT(*) AS `users` FROM (SELECT DISTINCT `user_id` FROM `cache_logs` UNION DISTINCT SELECT DISTINCT `user_id` FROM `caches`) AS `t`', 0));
// new events
$events = array();
$rs = sql_slave("SELECT `user`.`user_id` `user_id`,
`user`.`username` `username`,
`caches`.`cache_id` `cache_id`,
`caches`.`name` `name`,
`caches`.`date_hidden`,
`cache_location`.`adm1`,
`cache_location`.`adm2`,
`cache_location`.`adm3`,
`cache_location`.`adm4`
FROM `caches`
INNER JOIN `user` ON `user`.`user_id`=`caches`.`user_id`
LEFT JOIN `cache_location` ON `caches`.`cache_id`=`cache_location`.`cache_id`
WHERE `caches`.`country`='&1' AND
`caches`.`date_hidden` >= curdate() AND
`caches`.`type` = 6 AND
`caches`.`status`=1
ORDER BY `date_hidden` ASC LIMIT 0, 10",
$sUserCountry);
$tpl->assign_rs('events', $rs);
sql_free_result($rs);
// new caches
$rs = sql_slave("SELECT `user`.`user_id` `user_id`,
`user`.`username` `username`,
`caches`.`cache_id` `cache_id`,
`caches`.`name` `name`,
`caches`.`date_created` `date_created`,
`caches`.`type`,
`cache_location`.`adm1`,
`cache_location`.`adm2`,
`cache_location`.`adm3`,
`cache_location`.`adm4`
FROM `caches`
INNER JOIN `user` ON `user`.`user_id`=`caches`.`user_id`
LEFT JOIN `cache_location` ON `caches`.`cache_id`=`cache_location`.`cache_id`
WHERE `caches`.`country`='&1' AND
`caches`.`type` != 6 AND
`caches`.`status` = 1
ORDER BY `caches`.`date_created` DESC LIMIT 0, 10",
$sUserCountry);
$tpl->assign_rs('newcaches', $rs);
sql_free_result($rs);
// last 30 days' top ratings
//
// 2012-08-24 following
// optimized by adding rating_date field to cache_rating, so we don't need the log table.
$rs = sql_slave("SELECT COUNT(`cache_rating`.`user_id`) AS `cRatings`,
MAX(`cache_rating`.`rating_date`) AS `dLastLog`,
`user`.`user_id` AS `user_id`,
`user`.`username` AS `username`,
`caches`.`cache_id` AS `cache_id`,
`caches`.`name` AS `name`,
`caches`.`type`,
`cache_location`.`adm1`,
`cache_location`.`adm2`,
`cache_location`.`adm3`,
`cache_location`.`adm4`
FROM `cache_rating`
INNER JOIN `caches` ON `caches`.`cache_id`=`cache_rating`.`cache_id`
INNER JOIN `user` ON `user`.`user_id`=`cache_rating`.`user_id`
LEFT JOIN `cache_location` ON `cache_rating`.`cache_id`=`cache_location`.`cache_id`
WHERE `caches`.`country`='&1' AND
`cache_rating`.`rating_date`>DATE_SUB(NOW(), INTERVAL 30 DAY) AND
`caches`.`type`!=6 AND
`caches`.`status`=1
GROUP BY `cache_rating`.`cache_id`
ORDER BY `cRatings` DESC,
`dLastLog` DESC,
`cache_id` DESC
LIMIT 0, 10",
$sUserCountry);
$tpl->assign_rs('topratings', $rs);
sql_free_result($rs);
$sUserCountryName = sql_value("SELECT IFNULL(`sys_trans_text`.`text`, `countries`.`name`)
FROM `countries`
LEFT JOIN `sys_trans` ON `countries`.`trans_id`=`sys_trans`.`id`
LEFT JOIN `sys_trans_text` ON `sys_trans`.`id`=`sys_trans_text`.`trans_id` AND `sys_trans_text`.`lang`='&2'
WHERE `countries`.`short`='&1'", '', $sUserCountry, $opt['template']['locale']);
$tpl->assign('usercountry', $sUserCountryName);
}
$tpl->display();
?>