source: branches/beta/inc/html.php@ 463

Last change on this file since 463 was 463, checked in by amun, 16 years ago
File size: 8.4 KB
Line 
1<?php
2class Html {
3 private $values;
4 private $db;
5 // --
6 public function __construct($values,$db)
7 {
8 $this -> db = &$db;
9 // default config
10 $this -> html_cfg = array(
11 "charset" => "utf-8",
12 "author" => "Zork",
13 "copyright" => "(C) 2008 Heroes of Fantasy, All rights reserved.",
14 "favicon" => "imgs/fav",
15 "title" => "Heroes of Fantasy",
16 "description" => "Heroes of Fantasy free WoW server běžící na programu MaNGOS",
17 "keywords" => "wowserver, world of warcraft, free, wow, server, hof, heroes of fantasy, zdechov, mangos"
18 );
19 if (count($values) > 1 OR $values[0] != 0 AND $values[0] != "0")
20 {
21 $result_cfg = array_merge ($this -> html_cfg, $values);
22 foreach ($result_cfg as $name => $value)
23 {$this -> {$name} = $value;}
24 }
25 else
26 {
27 foreach ($this -> html_cfg as $name => $value)
28 {$this -> {$name} = $value;}
29 }
30
31 }
32 // --
33 private function CfgChck ($value)
34 {
35 if (isset($this -> {$value}))
36 {
37 return $this -> {$value};
38 }
39 else
40 {
41 return "Undefined";
42 }
43 }
44 public function Start()
45 {
46$code = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">
47<html>
48 <head>
49 <meta http-equiv=\"Content-Type\" content=\"text/html; charset=".$this->CfgChck("charset")."\" />
50 <meta http-equiv=\"Content-Language\" content=\"cs\" />
51 <meta http-equiv=\"Cache-Control\" content=\"no-cache\" />
52 <meta http-equiv='Pragma' content='no-cache' />
53 <meta http-equiv='Expires' content='-1' />
54 <meta name=\"author\" content=\"".$this->CfgChck("author")."\" />
55 <meta name=\"copyright\" content=\"".$this->CfgChck("copyright")."\" />
56 <meta name='robots' content='index,follow' />
57 <meta name='googlebot' content='index,follow,snippet,archive' />
58 <link href=\"".$this->CfgChck("favicon").".ico\" rel=\"shortcut icon\" />
59 <link href=\"inc/teamspeakdisplay/teamspeakdisplay.css\" rel=\"stylesheet\" type=\"text/css\">
60 <title>".$this->CfgChck("title")."</title>
61 <meta name=\"description\" content=\"".$this->CfgChck("description")."\" />
62 <meta name=\"keywords\" content=\"".$this->CfgChck("keywords")."\" />
63 <link rel=\"stylesheet\" type=\"text/css\" href=\"styles/style.css\" />
64 <!--[if IE]><link rel=\"stylesheet\" type=\"text/css\" href=\"styles/ie.css\" /><![endif]-->
65 </head>
66 <body>
67";
68 $this -> TimerStart();
69 echo $code;
70 }
71 // --
72 private function TimerStart()
73 {
74 $time_start = microtime();
75 $time_start = explode(" ",$time_start);
76 $time_start = $time_start[1] + $time_start[0];
77 $this -> time_start = $time_start;
78 }
79 // --
80 private function TimerStop()
81 {
82 $round = "100000";
83 $time_start = $this -> time_start;
84 $time_stop = microtime();
85 $time_stop = explode(" ",$time_stop);
86 $time_stop = $time_stop[1] + $time_stop[0];
87 $deltatime = $time_stop - $time_start;
88 $deltatime = (round(($deltatime*$round)))/$round;
89 return $deltatime;
90 }
91 // --
92 public function Stop()
93 {
94 $time = $this -> TimerStop();
95$code = "
96<!-- Vygenerováno za : ".$time." s -->
97 </body>
98</html>
99";
100 echo $code;
101 }
102 // --
103 public function Pager ($get,$dir_pages,$def)
104 {
105 $anti_ref = array (
106 "server" => "5",
107 "events" => "2",
108 "aukce" => "2",
109 "gmlog" => "300",
110 "online" => "2",
111 );
112 $site_show = "./".$dir_pages."/".$get.".php";
113 if (isset($anti_ref[$get]))
114 {
115 if (!$this -> Antirefresh($anti_ref[$get],$get))
116 {
117
118 if ($site_show != "" AND is_readable($site_show))
119 {return $site_show;}
120 else
121 {return "./".$dir_pages."/".$def.".php";}
122 }
123 else
124 {
125 $this -> RefreshMsg($this -> Antirefresh($anti_ref[$get],$get),$get);
126 return "./".$dir_pages."/free.php";
127 }
128 }
129 else
130 {
131 if ($site_show != "" AND is_readable($site_show))
132 {return $site_show;}
133 else
134 {return "./".$dir_pages."/".$def.".php";}
135 }
136 }
137 public function Antirefresh ($value,$page)
138 {
139 $hash = md5($page);
140 if (isset($_SESSION["rf".$hash."rsh"]))
141 {
142 $refresh = $_SESSION["rf".$hash."rsh"] + $value;
143 if (time() < $refresh)
144 {
145 $dif = $refresh - time();
146 return $dif;
147 }
148 }
149 $_SESSION["rf".$hash."rsh"] = time();
150 }
151 // --
152 public function RefreshMsg ($dif,$get)
153 {
154 if ($dif != 0)
155 {
156 if ($dif > 60)
157 {
158 $dif = round( $dif / 60)." min";
159 $refresh = 30;
160 }
161 else
162 {
163 $dif = $dif." s";
164 $refresh = 2;
165 }
166 echo "
167 <center><h3>Refresh omezení</h3></center>
168 Stránka nepovoluje tak krátký čas pro refresh (znovunačtení).<br />
169 Další načtení stránky <b>?page=".$get."</b> bude možné za <b>".$dif."</b>.<br />
170 Pokud tento čas vyčkáte budete přesměrován automaticky !
171 <meta http-equiv=\"refresh\" content=\"".$refresh.";url=\">
172 ";
173 }
174
175 }
176 // --
177 public function PrgStart()
178 {
179 echo "
180 <table align=\"center\" width=\"346\" height=\"417\" border=\"0\" style=\"background-image: url(imgs/web/prg.gif);\">
181 <tr height=\"80\">
182 <td width=\"20\"></td>
183 <td align=\"center\">
184 <h3>Správa účtu</h3>
185 </td>
186 <td width=\"20\"></td>
187 </tr>
188 <tr>
189 <td width=\"20\"></td>
190 <td align=\"center\" valign=\"top\">";
191 }
192 // --
193 public function PrgStop ()
194 {
195 echo "
196 </td>
197 <td width=\"20\"></td>
198 </tr>
199 <tr height=\"30\">
200 <td width=\"20\"></td>
201 <td></td>
202 <td width=\"20\"></td>
203 </tr>
204 </table>";
205 }
206 // --
207 public function ShowNews ($kategorie)
208 {
209 include("db.php");
210 if ($kategorie == "all")
211 {
212 $where = " ";
213 }
214 else
215 {
216 $where = "WHERE `category` = '".$kategorie."'";
217 }
218 $this -> db -> select_db($db_webu);
219 $sql = $this -> db -> query("SELECT * FROM `articles`".$where."ORDER BY `date` DESC;");
220 if ($sql -> num_rows > 0)
221 {
222 // TODO !!
223 while ($row = $sql -> fetch_array())
224 {
225 switch ($row["category"])
226 {
227 case 1:
228 $cat = "Server novinky";
229 $link = "servernews";
230 break;
231 case 2:
232 $cat = "GM novinky";
233 $link = "gmnews";
234 break;
235 case 3:
236 $cat = "In-game novinky";
237 $link = "gamenews";
238 break;
239 case 4:
240 $cat = "Články";
241 $link = "articles";
242 break;
243 }
244 $date_arr = explode(" ",$row["date"]);
245 $date = explode("-",$date_arr[0]);
246 $time = mktime(0,0,0,$date[1],$date[2],$date[0]);
247 $human_date = date ("d.m.Y",$time);
248 echo "
249 <table align=\"center\" border=\"1\" width=\"500\">
250 <tr>
251 <td><b>".$row["title"]."</b></td>
252 <td width=\"100\">".$human_date."</td>
253 </tr>
254 <tr>
255 <td colspan=\"2\">
256 ".$row["text"]."
257 </td>
258 </tr>
259 <tr>
260 <td>Sekce : <a href=\"?page=".$link."\">".$cat."</a></td>
261 <td>Zork</td>
262 </tr>
263 </table>
264 <br />
265 ";
266 }
267 }
268 else
269 {
270 echo "<center><h3>Žádný článek v této kategorii !</h3></center>";
271 }
272 }
273
274}
275?>
Note: See TracBrowser for help on using the repository browser.