source: trunk/inc/html.php@ 481

Last change on this file since 481 was 470, checked in by amun, 16 years ago

Zabezpečení administrace - podle gmlevelu
Přidáno Upravování NOVINEK a FINANCÍ

File size: 9.1 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 <script type=\"text/javascript\" src=\"styles/global.js\"></script>
65 <!--[if IE]><link rel=\"stylesheet\" type=\"text/css\" href=\"styles/ie.css\" /><![endif]-->
66 </head>
67 <body>
68";
69 $this -> TimerStart();
70 echo $code;
71 }
72 // --
73 private function TimerStart()
74 {
75 $time_start = microtime();
76 $time_start = explode(" ",$time_start);
77 $time_start = $time_start[1] + $time_start[0];
78 $this -> time_start = $time_start;
79 }
80 // --
81 private function TimerStop()
82 {
83 $round = "100000";
84 $time_start = $this -> time_start;
85 $time_stop = microtime();
86 $time_stop = explode(" ",$time_stop);
87 $time_stop = $time_stop[1] + $time_stop[0];
88 $deltatime = $time_stop - $time_start;
89 $deltatime = (round(($deltatime*$round)))/$round;
90 return $deltatime;
91 }
92 // --
93 public function Stop()
94 {
95 $time = $this -> TimerStop();
96$code = "
97<!-- Vygenerováno za : ".$time." s -->
98 </body>
99</html>
100";
101 echo $code;
102 }
103 // --
104 public function Pager ($get,$dir_pages,$def)
105 {
106 $anti_ref = array (
107 "server" => "5",
108 "events" => "2",
109 "aukce" => "2",
110 "gmlog" => "300",
111 "online" => "2",
112 );
113 $site_show = "./".$dir_pages."/".$get.".php";
114 if (isset($anti_ref[$get]))
115 {
116 if (!$this -> Antirefresh($anti_ref[$get],$get))
117 {
118
119 if ($site_show != "" AND is_readable($site_show))
120 {return $site_show;}
121 else
122 {return "./".$dir_pages."/".$def.".php";}
123 }
124 else
125 {
126 $this -> RefreshMsg($this -> Antirefresh($anti_ref[$get],$get),$get);
127 return "./".$dir_pages."/free.php";
128 }
129 }
130 else
131 {
132 if ($site_show != "" AND is_readable($site_show))
133 {return $site_show;}
134 else
135 {return "./".$dir_pages."/".$def.".php";}
136 }
137 }
138 public function Antirefresh ($value,$page)
139 {
140 $hash = md5($page);
141 if (isset($_SESSION["rf".$hash."rsh"]))
142 {
143 $refresh = $_SESSION["rf".$hash."rsh"] + $value;
144 if (time() < $refresh)
145 {
146 $dif = $refresh - time();
147 return $dif;
148 }
149 }
150 $_SESSION["rf".$hash."rsh"] = time();
151 }
152 // --
153 public function RefreshMsg ($dif,$get)
154 {
155 if ($dif != 0)
156 {
157 if ($dif > 60)
158 {
159 $dif = round( $dif / 60)." min";
160 $refresh = 30;
161 }
162 else
163 {
164 $dif = $dif." s";
165 $refresh = 2;
166 }
167 echo "
168 <center><h3>Refresh omezení</h3></center>
169 Stránka nepovoluje tak krátký čas pro refresh (znovunačtení).<br />
170 Další načtení stránky <b>?page=".$get."</b> bude možné za <b>".$dif."</b>.<br />
171 Pokud tento čas vyčkáte budete přesměrován automaticky !
172 <meta http-equiv=\"refresh\" content=\"".$refresh.";url=\">
173 ";
174 }
175
176 }
177 // --
178 public function PrgStart()
179 {
180 echo "
181 <table align=\"center\" width=\"346\" height=\"417\" border=\"0\" style=\"background-image: url(imgs/web/prg.gif);\">
182 <tr height=\"80\">
183 <td width=\"20\"></td>
184 <td align=\"center\">
185 <h3>Správa účtu</h3>
186 </td>
187 <td width=\"20\"></td>
188 </tr>
189 <tr>
190 <td width=\"20\"></td>
191 <td align=\"center\" valign=\"top\">";
192 }
193 // --
194 public function PrgStop ()
195 {
196 echo "
197 </td>
198 <td width=\"20\"></td>
199 </tr>
200 <tr height=\"30\">
201 <td width=\"20\"></td>
202 <td></td>
203 <td width=\"20\"></td>
204 </tr>
205 </table>";
206 }
207 // --
208 public function ShowNews ($kategorie)
209 {
210 include("inc/db.php");
211 global $db_webu;
212
213 if ($kategorie == "all")
214 {
215 $where = " ";
216 }
217 else
218 {
219 $where = "WHERE `category` = '".$kategorie."'";
220 }
221
222 mysql_connect("$db_server", "$db_user", "$db_pass");
223 mysql_select_db($db_webu);
224 $limit = 5;
225
226
227$pocet = mysql_num_rows(mysql_query("SELECT id FROM `articles`".$where."ORDER BY `date` DESC;"));
228$offset = ($_GET["offset"] ? $_GET["offset"] : $pocet);
229
230if ($pocet != 0)
231 {
232 mysql_query("SET NAMES 'utf8'");
233$result = mysql_query("SELECT * FROM articles $where ORDER BY date DESC, id DESC LIMIT $limit OFFSET " . ($pocet - $offset));
234while($row = mysql_fetch_array($result)){
235 switch ($row["category"])
236 {
237 case 1:
238 $cat = "Server novinky";
239 $link = "servernews";
240 break;
241 case 2:
242 $cat = "GM novinky";
243 $link = "gmnews";
244 break;
245 case 3:
246 $cat = "In-game novinky";
247 $link = "gamenews";
248 break;
249 case 4:
250 $cat = "Články";
251 $link = "articles";
252 break;
253 }
254 $date_arr = explode(" ",$row["date"]);
255 $date = explode("-",$date_arr[0]);
256 $time = mktime(0,0,0,$date[1],$date[2],$date[0]);
257 $human_date = date ("d.m.Y",$time);
258 echo "
259 <table align=\"center\" border=\"1\" width=\"500\">
260 <tr>
261 <td><b>".$row["title"]."</b></td>
262 <td width=\"100\">".$human_date."</td>
263 </tr>
264 <tr>
265 <td colspan=\"2\">
266 ".$row["text"]."
267 </td>
268 </tr>
269 <tr>
270 <td>Sekce : <a href=\"?page=".$link."\">".$cat."</a></td>
271 <td>".$row["autor"]."</td>
272 </tr>
273 </table>
274 <br />
275 ";
276}
277echo"<p align=center>";
278if ($offset < $pocet) {
279 echo "<a href='$_SERVER[PHP_SELF]" . ($offset + $limit < $pocet ? "?offset=" . ($offset + $limit) : "") . "'><-- novější</a>\n &nbsp;";
280}
281if ($offset > $limit) {
282 echo "&nbsp;<a href='$_SERVER[PHP_SELF]?offset=" . ($offset - $limit) . "'>starší --></a>\n";
283}
284
285
286
287
288
289
290 }
291 else
292 {
293 echo "<center><h3>Žádný článek v této kategorii !</h3></center>";
294 }
295 }
296
297}
298?>
Note: See TracBrowser for help on using the repository browser.