-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
209 lines (177 loc) · 8.31 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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
<?php
/*
Jaxboards. THE ULTIMATE 4UMS WOOOOOOO
By Sean John's son (2007 @ 4 AM)
*/
header("Cache-Control: no-cache, must-revalidate");
error_reporting(E_ALL ^ E_NOTICE);
$local=$_SERVER['REMOTE_ADDR']=='127.0.0.1';
$microtime=microtime(true);
/*get the config*/
require("config.php");
/*DB connect!*/
require_once "inc/classes/mysql.php";
$DB=new MySQL;
$DB->connect($CFG['sql_host'],$CFG['sql_username'],$CFG['sql_password'],$CFG['sql_db']);
/*Board Service Stuff, get the board as specified by URL*/
require_once "domaindefinitions.php";
/*Require the classes*/
foreach(Array("page","jax","sess") as $v) require_once "inc/classes/$v.php";
/*Initialize them*/
if($CFG['noboard']) die("board not found");
$PAGE=new PAGE;
$JAX=new JAX;
$SESS=new SESS($JAX->pick($JAX->c['sid'],$JAX->b['sessid']));
if(!$SESS->is_bot&&$JAX->c['uid']) $JAX->getUser($JAX->c['uid'],$JAX->c['pass']);
$USER=&$JAX->userData;
$PERMS=$JAX->getPerms();
/*fix ip if necessary*/
if($USER&&$SESS->ip!=$USER['ip']) $DB->update('members',Array('ip'=>$SESS->ip),'WHERE id='.$USER['id']);
/*load the theme*/
$PAGE->loadskin($JAX->pick($SESS->vars['skin_id'],$USER['skin_id']));
$PAGE->loadmeta("global");
/*skin selector*/
if(isset($JAX->b['skin_id'])) {
if(!$JAX->b['skin_id']) {
$SESS->delvar('skin_id');
$PAGE->JS("script","document.location='?'");
} else {
$SESS->addvar('skin_id',$JAX->b['skin_id']);
if($PAGE->jsaccess) $PAGE->JS("script","document.location='?'");
}
}
if($SESS->vars['skin_id']) $PAGE->append('NAVIGATION','<div class="success" style="position:fixed;bottom:0;left:0;width:100%;">Skin UCP setting being overriden. <a href="?skin_id=0">Revert</a></div>');
/*throw ads*/
$ads='';
if(false&&!$CFG['noads']) $ads=<<<HEREDOC
<div style="text-align:center;padding:10px;">
<script type="text/javascript">
ch_client = "seanj";
ch_width = 728;
ch_height = 90;
ch_type = "mpu";
ch_sid = "Chitika Default";
ch_backfill = 1;
ch_color_site_link = "#0000CC";
ch_color_title = "#0000CC";
ch_color_border = "#FFFFFF";
ch_color_text = "#000000";
ch_color_bg = "#FFFFFF";
JAX.adColorize()
</script>
<script src="http://scripts.chitika.net/eminimalls/amm.js" type="text/javascript">
</script>
</div>
HEREDOC;
// "Login"
// If they're logged in through cookies, (username & password)
// but the session variable has changed/been removed/not updated for some reason
// this fixes it.
if($JAX->userData&&!$SESS->is_bot){
if($JAX->userData['id']!=$SESS->uid) {
$SESS->clean($USER['id']);
$SESS->uid=$USER['id'];
$SESS->applychanges();
}
}
// If the user's navigated to a new page, change their action time (they're alive!)
if($PAGE->jsnewlocation||!$PAGE->jsaccess) {
$SESS->act($JAX->b['act']);
}
/*Set Navigation*/
$PAGE->path(Array($JAX->pick($CFG['boardname'],"Home")=>"?"));
$PAGE->append('TITLE',$JAX->pick($PAGE->meta('title'),$CFG['boardname'],"JaxBoards"));
if(!$PAGE->jsaccess) {
foreach(Array("sound_im","wysiwyg") as $v) $variables[]="$v:".($USER?($USER[$v]?1:0):1);
$variables[]="can_im:".($PERMS['can_im']?1:0);
$variables[]="groupid:".($JAX->pick($USER['group_id'],3));
$variables[]="username:'".addslashes($USER['display_name'])."'";
$variables[]="userid:".$JAX->pick($USER['id'],0);
$PAGE->append('SCRIPT',' <script type="text/javascript" src="http://www.google.com/recaptcha/api/js/recaptcha_ajax.js"></script>');
$PAGE->append('SCRIPT',' <script type="text/javascript">var globalsettings={'.implode(',',$variables).'}</script>');
$PAGE->append('SCRIPT',' <script type="text/javascript" src="'.($local?'Service':'http://jaxboards.com').'/jsnew.js?v=1"></script>');
$PAGE->append('SCRIPT',' <script type="text/javascript" src="'.($local?'Service':'http://jaxboards.com').'/jsrun.js"></script>');
$PAGE->append('SCRIPT','<!--[if IE]><style> img {behavior: url(Script/fiximgnatural.htc)}</style><![endif]-->');
if($PERMS['can_moderate']||$USER['mod']) {
$PAGE->append("SCRIPT",'<script type="text/javascript" src="?act=modcontrols&do=load"></script>');
}
$PAGE->append('CSS','<link rel="stylesheet" type="text/css" href="'.THEMEPATH.'css.css" />');
if($PAGE->meta('favicon')) $PAGE->append('CSS','<link rel="icon" href="'.$PAGE->meta('favicon').'">');
$PAGE->append('LOGO',$PAGE->meta("logo",$JAX->pick($CFG['logourl'],'http://jaxboards.com/Themes/Default/img/logo.png')));
$PAGE->append('NAVIGATION',$PAGE->meta("navigation",$PERMS['can_moderate']?'<li><a href="?act=modcontrols&do=cp">Mod CP</a></li>':'',$PERMS['can_access_acp']?'<li><a href="./acp/" target="_BLANK">ACP</a></li>':'',$CFG['navlinks']?$CFG['navlinks']:''));
if($USER&&$USER['id']) {
$DB->select("count(id)","messages","WHERE `read`=0 AND `to`=".$USER['id']);
$nummessages=array_pop($DB->row());
}
$PAGE->addvar('inbox',$nummessages);
if($nummessages) $PAGE->append('FOOTER','<div id="notification" class="newmessage" onclick="RUN.stream.location(\'?act=ucp&what=inbox\');this.style.display=\'none\'">You have '.$nummessages.' new message'.($nummessages==1?'':'s').'</div>');
if(!$CFG['nocopyright']) $PAGE->append('FOOTER','<div class="footer"><a href="http://jaxboards.com">Jaxboards 1.1.0</a> © 2007-'.date('Y').'</div>');
$PAGE->addvar('modlink',$PERMS['can_moderate']?$PAGE->meta('modlink'):'');
$PAGE->addvar('ismod',$PERMS['can_moderate']?1:0);
$PAGE->addvar('acplink',$PERMS['can_access_acp']?$PAGE->meta('acplink'):'');
$PAGE->addvar('isadmin',$PERMS['can_access_acp']?1:0);
$PAGE->addvar('boardname',$CFG['boardname']);
$PAGE->append('USERBOX',
($USER['id']?$PAGE->meta('userbox-logged-in',$PAGE->meta('user-link',$USER['id'],$USER['group_id'],$USER['display_name']),$JAX->smalldate($USER['last_visit']),$nummessages):$PAGE->meta('userbox-logged-out'))
);
} //end if jsaccess only
$PAGE->addvar('groupid',$JAX->pick($USER['group_id'],3));
$PAGE->addvar('userposts',$USER['posts']);
$PAGE->addvar('grouptitle',$PERMS['title']);
$PAGE->addvar('avatar',$JAX->pick($USER['avatar'],$PAGE->meta('default-avatar')));
$PAGE->addvar('username',$USER['display_name']);
$PAGE->addvar('userid',$JAX->pick($USER['id'],0));
if($JAX->b['act']!="logreg"&&$JAX->b['act']!="logreg2"&&$JAX->b['act']!="logreg4"&&$JAX->b['act']!="logreg3"){
if(!$PERMS['can_view_board']||$CFG['boardoffline']&&!$PERMS['can_view_offline_board']) $JAX->b['act']="boardoffline";
}
//include modules :3
foreach(glob("inc/modules/*.php") as $v) {
if(preg_match("/tag_(\w+)/",$v,$m)) {
if($JAX->b['module']==$m[1]||$PAGE->templatehas($m[1])) include $v;
} else if (preg_match("/cookie_(\w+)/",$v,$m)) {
if($JAX->b['module']==$m[1]||$JAX->c[$m[1]]) include $v;
} else include($v);
}
//looks like it's straight out of IPB, doesn't it
$actraw=strtolower($JAX->b['act']);
preg_match("@^[a-zA-Z_]+@",$actraw,$act);
$act=array_shift($act);
$actdefs=Array(
""=>"idx",
"vf"=>"forum",
"vt"=>"topic",
"vu"=>"userprofile",
);
if($actdefs[$act]) $act=$actdefs[$act];
if($act=="idx"&&$JAX->b['module']) {
//do nothing
} elseif($act&&is_file($act="inc/page/".$act.".php")) {
require $act;
} elseif(!$PAGE->jsaccess||$PAGE->jsnewlocation) {
$DB->select("page","pages","WHERE act=".$DB->evalue($actraw));
if($page=$DB->row()) {
$page['page']=$JAX->bbcodes($page['page']);
$PAGE->append("PAGE",$page['page']);
if($PAGE->jsnewlocation) $PAGE->JS("update","page",$page['page']);
} else $PAGE->location("?act=idx");
}
// Process temporary commands
if($PAGE->jsaccess&&$SESS->runonce){
$PAGE->JSRaw($SESS->runonce);
$SESS->runonce="";
}
// keeps people from leaving their windows open all night
if(($SESS->last_update-$SESS->last_action)>1200) $PAGE->JS("script","window.name=Math.random()");
//any changes to the session variables of the current user throughout the script are finally put into query form here
$SESS->applyChanges();
if(in_array($_SERVER['REMOTE_ADDR'],Array('127.0.0.1','192.168.1.1','75.191.183.57'))) {
$debug="";
foreach($DB->queryRuntime as $k=>$v) {$debug.="<b>$v</b> ".$DB->queryList[$k]."<br />";$qtime+=$v;}$debug.=$PAGE->debug()."<br />";
$PAGE->JS("update","#query .content",$debug);
$PAGE->append('FOOTER',$PAGE->collapsebox("Debug",$debug,"query")."<div id='debug2'></div><div id='pagegen'></div>");
$PAGE->JS("update","pagegen",($pagegen="Page Generated in ".round(1000*(microtime(true)-$microtime))." ms"));
}
$PAGE->append('DEBUG',"<div id='pagegen' style='text-align:center'>".$pagegen."</div><div id='debug' style='display:none'></div>");
if($PAGE->jsnewlocation) $PAGE->JS("title",htmlspecialchars_decode($PAGE->get('TITLE'),ENT_QUOTES));
$PAGE->out();
?>