1 | <? |
---|
2 | require_once( "config.php" ); |
---|
3 | require_once( "class.killboard.php" ); |
---|
4 | require_once( "class.session.php" ); |
---|
5 | |
---|
6 | class Page |
---|
7 | { |
---|
8 | |
---|
9 | function Page( $title = "", $cachable = true ) |
---|
10 | { |
---|
11 | $this->title_ = $title; |
---|
12 | $this->admin_ = false; |
---|
13 | |
---|
14 | if ( substr( $_SERVER['HTTP_USER_AGENT'], 0, 15 ) == "EVE-minibrowser" ) |
---|
15 | $this->igb_ = true; |
---|
16 | else |
---|
17 | $this->igb_ = false; |
---|
18 | |
---|
19 | $this->timestart_ = strtok(microtime(), ' ') + strtok(''); |
---|
20 | |
---|
21 | $this->killboard_ = new Killboard( KB_SITE ); |
---|
22 | |
---|
23 | $this->session_ = new Session( $_COOKIE['EVK_COOKIE'], |
---|
24 | $_SERVER['REMOTE_ADDR'] ); |
---|
25 | |
---|
26 | $this->cachable_ = $cachable; |
---|
27 | $this->cachetime_ = 5; |
---|
28 | } |
---|
29 | |
---|
30 | function setContent( $html ) |
---|
31 | { |
---|
32 | $this->contenthtml_ = $html; |
---|
33 | } |
---|
34 | |
---|
35 | function addContext( $html ) |
---|
36 | { |
---|
37 | $this->contexthtml_ .= $html; |
---|
38 | } |
---|
39 | |
---|
40 | function generate() |
---|
41 | { |
---|
42 | $html = "<html>"; |
---|
43 | $html .= "<head>"; |
---|
44 | $html .= "<title>".KB_TITLE." Killboard - ".$this->title_."</title>\n"; |
---|
45 | $html .= "<link rel=\"stylesheet\" type=\"text/css\" href=\"".STYLE_URL."/common.css\">"; |
---|
46 | $config = $this->killboard_->getConfig(); |
---|
47 | $style = $config->getStyleName(); |
---|
48 | $html .= "<link rel=\"stylesheet\" type=\"text/css\" href=\"".STYLE_URL."/".$style."/style.css\">"; |
---|
49 | |
---|
50 | if ( !$this->igb_ ) |
---|
51 | $html .= "<script language=javascript src=\"".COMMON_URL."/generic.js\"></script>"; |
---|
52 | $html .= "</head>\n"; |
---|
53 | $html .= "<body bgcolor=\"#222222\""; |
---|
54 | if ( $this->onload_ ) |
---|
55 | $html .= " onload=\"".$this->onload_."\""; |
---|
56 | |
---|
57 | $html .= ">\n"; |
---|
58 | |
---|
59 | // header |
---|
60 | $html .= "<table class=main-table height=\"100%\" align=\"center\" bgcolor=\"#111111\" border=\"0\" cellspacing=\"1\"><tr><td valign=\"top\" height=\"100%\">\n"; |
---|
61 | if ( !$this->igb_ ) { |
---|
62 | $html .= "<div id=header>\n"; |
---|
63 | $html .= "<img src=\""; |
---|
64 | $banner = $config->getStyleBanner(); |
---|
65 | if ( $banner != "custom" ) |
---|
66 | $html .= IMG_URL."/banners/".$banner.".jpg"; |
---|
67 | else |
---|
68 | $html .= "kb-banner.jpg"; |
---|
69 | |
---|
70 | $html .= "\" border=\"0\">"; |
---|
71 | |
---|
72 | $html .= "</div>\n"; |
---|
73 | $contracts = $this->killboard_->hasContracts(); |
---|
74 | $campaigns = $this->killboard_->hasCampaigns(); |
---|
75 | $w = "\"10%\""; |
---|
76 | if ( $contracts || $campaigns ) $w = "\"9%\""; |
---|
77 | if ( $contracts && $campaigns ) $w = "\"8%\""; |
---|
78 | $html .= "<table class=navigation width=\"100%\" height=\"25\" border=\"0\" cellspacing=\"1\"><tr class=kb-table-row-odd>\n"; |
---|
79 | $html .= "<td width=".$w." align=\"center\"><a class=link href=\"?a=home\">Home</a></td>"; |
---|
80 | |
---|
81 | if ( $contracts ) |
---|
82 | $html .= "<td width=".$w." align=\"center\"><a class=link href=\"?a=contracts\">Contracts</a></td>"; |
---|
83 | |
---|
84 | if ( $campaigns ) |
---|
85 | $html .= "<td width=".$w." align=\"center\"><a class=link href=\"?a=campaigns\">Campaigns</a></td>"; |
---|
86 | |
---|
87 | $html .= "<td width=".$w." align=\"center\"><a class=link href=\"?a=kills\">Kills</a></td>"; |
---|
88 | $html .= "<td width=".$w." align=\"center\"><a class=link href=\"?a=losses\">Losses</a></td>"; |
---|
89 | $html .= "<td width=".$w." align=\"center\"><a class=link href=\"?a=post\">Post mail</a></td>"; |
---|
90 | $html .= "<td width=".$w." align=\"center\"><a class=link href=\""; |
---|
91 | |
---|
92 | if ( CORP_ID ) $html .= "?a=corp_detail&crp_id=".CORP_ID; |
---|
93 | if ( ALLIANCE_ID ) $html .= "?a=alliance_detail&all_id=".ALLIANCE_ID; |
---|
94 | |
---|
95 | $html .= "\">Stats</a></td>"; |
---|
96 | |
---|
97 | $html .= "<td width=".$w." align=\"center\"><a class=link href=\"?a=awards\">Awards</a></td>"; |
---|
98 | $html .= "<td width=".$w." align=\"center\"><a class=link href=\"?a=search\">Search</a></td>"; |
---|
99 | $html .= "<td width=".$w." align=\"center\"><a class=link href=\"?a=admin\">Admin</a></td>"; |
---|
100 | $html .= "<td width=".$w." align=\"center\"><a class=link href=\"?a=about\">About</a></td>"; |
---|
101 | |
---|
102 | $html .= "\n</tr></table>\n"; |
---|
103 | } |
---|
104 | $html .= "<div id=page-title>".$this->title_."</div>"; |
---|
105 | $html .= "<table cellpadding=0 cellspacing=0 width=\"100%\" border=\"0\"><tr>"; |
---|
106 | $html .= "<td valign=top><div id=content>\n"; |
---|
107 | $html .= $this->contenthtml_; |
---|
108 | $this->timeend_ = strtok(microtime(), ' ') + strtok(''); |
---|
109 | $this->processingtime_ = $this->timeend_ - $this->timestart_; |
---|
110 | $html .= "</div></td>"; |
---|
111 | if ( $this->contexthtml_ != "" ) { |
---|
112 | $html .= "<td valign=top align=right><div id=context>\n"; |
---|
113 | $html .= $this->contexthtml_; |
---|
114 | $html .= "</div></td>\n"; |
---|
115 | } |
---|
116 | $html .= "</tr></table>"; |
---|
117 | |
---|
118 | if ( KB_PROFILE > 0 ) |
---|
119 | $html .= "<table class=kb-subtable width=\"99%\" border=0><tr><td height=100% align=right valign=bottom>".$this->processingtime_."s</td></tr></table>\n"; |
---|
120 | else |
---|
121 | $html .= "<!-- ".$this->processingtime_."s -->"; |
---|
122 | |
---|
123 | $html .= "</td></tr></table>\n"; |
---|
124 | $html .= "</body></html>\n"; |
---|
125 | |
---|
126 | //ob_start( "ob_gzhandler" ); |
---|
127 | echo $html; |
---|
128 | //ob_end_flush(); |
---|
129 | } |
---|
130 | |
---|
131 | function igb() |
---|
132 | { |
---|
133 | return $this->igb_; |
---|
134 | } |
---|
135 | |
---|
136 | function setOnLoad( $onload ) |
---|
137 | { |
---|
138 | $this->onload_ = $onload; |
---|
139 | } |
---|
140 | |
---|
141 | function setTitle( $title ) |
---|
142 | { |
---|
143 | $this->title_ = $title; |
---|
144 | } |
---|
145 | |
---|
146 | function setAdmin() |
---|
147 | { |
---|
148 | if ( !$this->session_->isAdmin() ) |
---|
149 | Header( "Location: ?a=login" ); |
---|
150 | } |
---|
151 | |
---|
152 | function setSuperAdmin() |
---|
153 | { |
---|
154 | if ( !$this->session_->isSuperAdmin() ) |
---|
155 | Header( "Location: ?a=login" ); |
---|
156 | } |
---|
157 | |
---|
158 | function setCachable( $cachable ) |
---|
159 | { |
---|
160 | $this->cachable_ = $cachable; |
---|
161 | } |
---|
162 | |
---|
163 | function setCacheTime( $cachetime ) |
---|
164 | { |
---|
165 | $this->cachetime_ = $cachetime; |
---|
166 | } |
---|
167 | |
---|
168 | function error( $errormsg ) |
---|
169 | { |
---|
170 | echo $errormsg; |
---|
171 | exit; |
---|
172 | } |
---|
173 | } |
---|
174 | |
---|
175 | ?> |
---|