-
Notifications
You must be signed in to change notification settings - Fork 9
/
home.php
158 lines (142 loc) · 6.09 KB
/
home.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
153
154
155
156
157
158
<?php
// translator ready
// addnews ready
// mail ready
if (isset($_POST['template'])){
$skin = $_POST['template'];
if ($skin > "") {
setcookie("template",$skin ,strtotime("+45 days"));
$_COOKIE['template']=$skin;
}
}
define("ALLOW_ANONYMOUS",true);
require_once("common.php");
require_once("lib/http.php");
if (!isset($session['loggedin'])) $session['loggedin']=false;
if ($session['loggedin']){
redirect("badnav.php");
}
if (!isset($session['message'])) $session['message']='';
tlschema("home");
$op = httpget('op');
page_header();
output("`cWelcome to Legend of the Green Dragon, a browser based role playing game, based on Seth Able's Legend of the Red Dragon.`n");
if (getsetting("homecurtime", 1)) {
output("`@The current time in %s is `%%s`@.`0`n", getsetting("villagename", LOCATION_FIELDS), getgametime());
}
if (getsetting("homenewdaytime", 1)) {
$secstonewday = secondstonextgameday();
output("`@Next new game day in: `\$%s (real time)`0`n`n",
date("G\\".translate_inline("h","datetime").", i\\".translate_inline("m","datetime").", s\\".translate_inline("s","datetime"),
$secstonewday));
}
if (getsetting("homenewestplayer", 1)) {
$name = "";
$newplayer = getsetting("newestplayer", "");
if ($newplayer != 0) {
$sql = "SELECT name FROM " . db_prefix("accounts") . " WHERE acctid='$newplayer'";
$result = db_query_cached($sql, "newest");
if (db_num_rows($result)>0) {
$row = db_fetch_assoc($result);
$name = $row['name'];
}
} else {
$name = $newplayer;
}
if ($name != "") {
output("`QThe newest resident of the realm is: `&%s`0`n`n", $name);
}
}
clearnav();
addnav("New to LoGD?");
addnav("Create a character","create.php");
addnav("Game Functions");
addnav("Forgotten Password","create.php?op=forgot");
addnav("List Warriors","list.php");
addnav("Daily News", "news.php");
addnav("Other Info");
addnav("About LoGD","about.php");
addnav("Game Setup Info", "about.php?op=setup");
addnav("LoGD Net","logdnet.php?op=list");
addnav("Legal");
if (getsetting('impressum','')!='') addnav("Imprint","about.php");
modulehook("index", array());
if (abs(getsetting("OnlineCountLast",0) - strtotime("now")) > 60){
$sql="SELECT count(acctid) as onlinecount FROM " . db_prefix("accounts") . " WHERE locked=0 AND loggedin=1 AND laston>'".date("Y-m-d H:i:s",strtotime("-".getsetting("LOGINTIMEOUT",900)." seconds"))."'";
$result = db_query($sql);
$onlinecount = db_fetch_assoc($result);
$onlinecount = $onlinecount ['onlinecount'];
savesetting("OnlineCount",$onlinecount);
savesetting("OnlineCountLast",strtotime("now"));
}else{
$onlinecount = getsetting("OnlineCount",0);
}
if ($onlinecount<getsetting("maxonline",0) || getsetting("maxonline",0)==0){
output("Enter your name and password to enter the realm.`n");
if ($op=="timeout"){
if (!isset($session['message'])) $session['message']='';
$session['message'].= translate_inline(" Your session has timed out, you must log in again.`n");
}
if (!isset($_COOKIE['lgi'])){
$session['message'].=translate_inline("It appears that you may be blocking cookies from this site. At least session cookies must be enabled in order to use this site.`n");
$session['message'].=translate_inline("`b`#If you are not sure what cookies are, please <a href='http://en.wikipedia.org/wiki/WWW_browser_cookie'>read this article</a> about them, and how to enable them.`b`n");
}
if (isset($session['message']) && $session['message']>"")
output_notl("`b`\$%s`b`n", $session['message'],true);
rawoutput("<script language='JavaScript' src='lib/md5.js'></script>");
rawoutput("<script language='JavaScript'>
<!--
function md5pass(){
//encode passwords before submission to protect them even from network sniffing attacks.
var passbox = document.getElementById('password');
if (passbox.value.substring(0, 5) != '!md5!') {
passbox.value = '!md5!' + hex_md5(passbox.value);
}
}
//-->
</script>");
$uname = translate_inline("<u>U</u>sername");
$pass = translate_inline("<u>P</u>assword");
$butt = translate_inline("Log in");
rawoutput("<form action='login.php' method='POST' onSubmit=\"md5pass();\">".templatereplace("login",array("username"=>$uname,"password"=>$pass,"button"=>$butt))."</form>");
output("Did you forget your password? Go <a href='create.php?op=forgot'>here</a> to retrieve a new one!`n",true);
output_notl("`c");
addnav("","login.php");
modulehook("index-login", array());
} else {
output("`\$`bServer full!`b`n`^Please wait until some users have logged out.`n`n`0");
if ($op=="timeout"){
$session['message'].= translate_inline(" Your session has timed out, you must log in again.`n");
}
if (!isset($_COOKIE['lgi'])){
$session['message'].=translate_inline("It appears that you may be blocking cookies from this site. At least session cookies must be enabled in order to use this site.`n");
$session['message'].=translate_inline("`b`#If you are not sure what cookies are, please <a href='http://en.wikipedia.org/wiki/WWW_browser_cookie'>read this article</a> about them, and how to enable them.`b`n");
}
if ($session['message']>"") output("`b`\$%s`b`n", $session['message'],true);
rawoutput(templatereplace("loginfull",array()));
output_notl("`c");
}
$msg = getsetting("loginbanner","*BETA* This is a BETA of this website, things are likely to change now and again, as it is under active development *BETA*");
output_notl("`n`c`b`&%s`0`b`c`n", $msg);
$session['message']="";
output("`c`2Game server running version: `@%s`0`c", $logd_version);
if (getsetting("homeskinselect", 1)) {
rawoutput("<form action='home.php' method='POST'>");
rawoutput("<table align='center'><tr><td>");
$form = array("template"=>"Choose a different display skin:,theme");
if (isset($_COOKIE['template'])) $prefs['template'] = $_COOKIE['template'];
else
$prefs['template'] = getsetting("defaultskin", "yarbrough.htm");
require_once("lib/showform.php");
showform($form, $prefs, true);
$submit = translate_inline("Choose");
rawoutput("</td><td><br> <input type='submit' class='button' value='$submit'></td>");
rawoutput("</tr></table></form>");
}
modulehook("index_bottom", array());
page_footer();
if ($op=="timeout") {
session_unset();
session_destroy(); // destroy if timeout
}
?>