-
Notifications
You must be signed in to change notification settings - Fork 7
/
news.php
142 lines (130 loc) · 4.54 KB
/
news.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
<?php
// translator ready
// addnews ready
// mail ready
define("ALLOW_ANONYMOUS",true);
require_once("common.php");
require_once("lib/http.php");
require_once("lib/villagenav.php");
tlschema("news");
modulehook("news-intercept",array());
if ($session['user']['loggedin']) checkday();
$newsperpage=50;
$offset = (int)httpget('offset');
$timestamp=strtotime((0-$offset)." days");
$sql = "SELECT count(newsid) AS c FROM " . db_prefix("news") . " WHERE newsdate='".date("Y-m-d",$timestamp)."'";
$result = db_query($sql);
$row = db_fetch_assoc($result);
$totaltoday=$row['c'];
$page = (int)httpget('page');
if (!$page) $page=1;
$pageoffset = $page;
if ($pageoffset>0) $pageoffset--;
$pageoffset*=$newsperpage;
$sql = "SELECT * FROM " . db_prefix("news") . " WHERE newsdate='".date("Y-m-d",$timestamp)."' ORDER BY newsid DESC LIMIT $pageoffset,$newsperpage";
$result = db_query($sql);
page_header("LoGD News");
$date=date("D, M j, Y",$timestamp);
$pagestr = "";
if ($totaltoday > $newsperpage) {
$pagestr = sprintf_translate("(Items %s - %s of %s)", $pageoffset+1,
min($pageoffset+$newsperpage,$totaltoday), $totaltoday);
}
$sql2 = "SELECT " . db_prefix("motd") . ".*,name AS motdauthorname FROM " . db_prefix("motd") . " LEFT JOIN " . db_prefix("accounts") . " ON " . db_prefix("accounts") . ".acctid = " . db_prefix("motd") . ".motdauthor ORDER BY motddate DESC LIMIT 1";
$result2 = db_query_cached($sql2, "lastmotd");
while ($row = db_fetch_assoc($result2)) {
require_once("lib/motd.php");
require_once("lib/nltoappon.php");
if ($row['motdauthorname']=="")
$row['motdauthorname']=translate_inline("`@Green Dragon Staff`0");
if ($row['motdtype']==0){
motditem($row['motdtitle'], $row['motdbody'],$row['motdauthorname'], $row['motddate'], "");
}else{
pollitem($row['motditem'], $row['motdtitle'], $row['motdbody'],$row['motdauthorname'],$row['motddate'], false);
}
}
output_notl("`n");
output("`c`b`!News for %s %s`0`b`c", $date, $pagestr);
while ($row = db_fetch_assoc($result)) {
output_notl("`c`2-=-`@=-=`2-=-`@=-=`2-=-`@=-=`2-=-`0`c");
if ($session['user']['superuser'] & SU_EDIT_COMMENTS){
$del = translate_inline("Del");
rawoutput("[ <a href='superuser.php?op=newsdelete&newsid=".$row['newsid']."&return=".URLEncode($_SERVER['REQUEST_URI'])."'>$del</a> ] ");
addnav("","superuser.php?op=newsdelete&newsid={$row['newsid']}&return=".URLEncode($_SERVER['REQUEST_URI']));
}
tlschema($row['tlschema']);
if ($row['arguments']>""){
$arguments = array();
$base_arguments = unserialize($row['arguments']);
array_push($arguments,$row['newstext']);
foreach ($base_arguments as $val) {
array_push($arguments,$val);
}
$news = call_user_func_array("sprintf_translate",$arguments);
rawoutput(tlbutton_clear());
}else{
$news = translate_inline($row['newstext']);
}
tlschema();
output_notl("`c".$news."`c`n");
}
if (db_num_rows($result)==0){
output_notl("`c`2-=-`@=-=`2-=-`@=-=`2-=-`@=-=`2-=-`0`c");
output("`1`b`c Nothing of note happened this day. All in all a boring day. `c`b`0");
}
output_notl("`c`2-=-`@=-=`2-=-`@=-=`2-=-`@=-=`2-=-`0`c");
if (!$session['user']['loggedin']) {
addnav("Login Screen", "index.php");
} else if ($session['user']['alive']){
villagenav();
}else{
tlschema("nav");
addnav("Log Out");
addnav("Log out","login.php?op=logout");
if($session['user']['sex'] == 1) {
addnav("`!`bYou're dead, Jane!`b`0");
} else {
addnav("`!`bYou're dead, Jim!`b`0");
}
addnav("S?Land of Shades","shades.php");
addnav("G?The Graveyard","graveyard.php");
require_once("lib/extended-battle.php");
suspend_companions("allowinshades", true);
tlschema();
}
addnav("News");
addnav("Previous News","news.php?offset=".($offset+1));
if ($offset>0){
addnav("Next News","news.php?offset=".($offset-1));
}
if ($session['user']['loggedin'])
addnav("Preferences","prefs.php");
addnav("About this game","about.php");
tlschema("nav");
if ($session['user']['superuser'] & SU_EDIT_COMMENTS){
addnav("Superuser");
addnav(",?Comment Moderation","moderate.php");
}
if ($session['user']['superuser']&~SU_DOESNT_GIVE_GROTTO){
addnav("Superuser");
addnav("X?Superuser Grotto","superuser.php");
}
if ($session['user']['superuser'] & SU_INFINITE_DAYS){
addnav("Superuser");
addnav("/?New Day","newday.php");
}
tlschema();
addnav("","news.php");
if ($totaltoday>$newsperpage){
addnav("Today's news");
for ($i=0;$i<$totaltoday;$i+=$newsperpage){
$pnum = $i/$newsperpage+1;
if ($pnum == $page) {
addnav(array("`b`#Page %s`0`b", $pnum),"news.php?offset=$offset&page=$pnum");
} else {
addnav(array("Page %s", $pnum),"news.php?offset=$offset&page=$pnum");
}
}
}
page_footer();
?>