-
Notifications
You must be signed in to change notification settings - Fork 23
/
index.php
104 lines (102 loc) · 4.02 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
<?php
require('lib/header.php');
require_once('lib/lib_morph_pools.php');
require_once('lib/lib_stats.php');
require_once('lib/lib_ne.php');
if (GET('rand', false)) {
$r = sql_fetch_array(sql_query("SELECT sent_id FROM sentences ORDER BY RAND() LIMIT 1", 0));
header("Location:sentence.php?id=".$r['sent_id']);
return;
}
switch ($page = GET('page', '')) {
case 'about':
case 'team':
case 'publications':
$smarty->assign('active_page','about');
$smarty->display('static/' . $page . '.tpl');
break;
case 'downloads':
$smarty->assign('active_page', 'downloads');
$smarty->setCaching(Smarty::CACHING_LIFETIME_SAVED);
$smarty->setCacheLifetime(600);
if (!is_cached('static/downloads.tpl')) {
$smarty->assign('dl', get_downloads_info());
$smarty->assign('stats', get_common_stats());
}
$smarty->display('static/downloads.tpl');
break;
case 'top100':
$smarty->assign('stats', get_top100_info(GET('what', 'ngrams'), GET('type')));
$smarty->display('top100.tpl');
break;
case 'stats':
$uid = isset($_SESSION['user_id']) ? $_SESSION['user_id'] : 0;
$weekly = (bool)GET('weekly', 0);
$smarty->assign('active_page', 'stats');
$smarty->setCaching(Smarty::CACHING_LIFETIME_SAVED);
$smarty->setCacheLifetime(300);
$cache_key = $uid.'@'.(int)$weekly.(int)GET('team', 0);
if (!is_cached('stats.tpl', $cache_key)) {
$smarty->assign('user_stats', get_user_stats($weekly, GET('team', 0)));
$smarty->assign('ma_count', count_all_answers());
}
$smarty->display('stats.tpl', $cache_key);
break;
case 'tag_stats':
$smarty->assign('active_page', 'stats');
$smarty->assign('stats', get_tag_stats());
$smarty->display('tag_stats.tpl');
break;
case 'genre_stats':
$smarty->assign('active_page', 'stats');
$smarty->assign('stats', get_common_stats());
$smarty->display('genre_stats.tpl');
break;
case 'charts':
$smarty->setCaching(Smarty::CACHING_LIFETIME_SAVED);
$smarty->setCacheLifetime(300);
$days = GET('days', 90);
if (!is_cached('charts.tpl', $days)) {
$smarty->assign('words_chart', get_word_stats_for_chart($days));
$smarty->assign('ambig_chart', get_ambiguity_stats_for_chart($days));
$smarty->assign('pools_stats', get_pools_stats());
$smarty->assign('annot_chart', get_annot_stats_for_chart($days));
$smarty->assign('sentence_chart', get_sentence_stats());
}
$smarty->display('charts.tpl', $days);
break;
case 'pool_charts':
$smarty->assign('main', get_extended_pools_stats());
$smarty->assign('moder', get_moderation_stats());
$smarty->display('ext_charts.tpl');
break;
case 'export':
$smarty->assign('active_page','downloads');
$smarty->display('static/doc/export.tpl');
break;
case 'faq':
$smarty->assign('active_page','about');
$smarty->assign('content', get_wiki_page('FAQ'));
$smarty->assign('title', 'FAQ');
$smarty->display('static/faq.tpl');
break;
case 'achievements':
$am = new AchievementsManager($_SESSION['user_id']);
$smarty->assign('stats', $am->pull_stats());
$smarty->assign('manager', $am);
$smarty->display('achievements/all_achievements.tpl');
break;
default:
if (!is_admin()) {
if (is_logged()) {
$smarty->assign('available', get_available_tasks($_SESSION['user_id'], true, $config['misc']['mainpage_tasks_limit'], true));
$tagset_id = get_current_tagset();
$smarty->assign('ner_tagset_id', $tagset_id);
$smarty->assign('ner_tasks', get_books_with_NE($tagset_id));
}
$smarty->assign('answer_count', count_all_answers());
}
$smarty->display('index.tpl');
}
log_timing();
?>