[405] | 1 | <?php
|
---|
| 2 | class 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\" />
|
---|
[445] | 64 | <script type=\"text/javascript\" src=\"styles/global.js\"></script>
|
---|
[405] | 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 | {
|
---|
[445] | 210 | global $db_webu;
|
---|
| 211 |
|
---|
[405] | 212 | if ($kategorie == "all")
|
---|
| 213 | {
|
---|
| 214 | $where = " ";
|
---|
| 215 | }
|
---|
| 216 | else
|
---|
| 217 | {
|
---|
| 218 | $where = "WHERE `category` = '".$kategorie."'";
|
---|
| 219 | }
|
---|
[445] | 220 | $this -> db -> select_db($db_webu);
|
---|
[405] | 221 | $sql = $this -> db -> query("SELECT * FROM `articles`".$where."ORDER BY `date` DESC;");
|
---|
| 222 | if ($sql -> num_rows > 0)
|
---|
| 223 | {
|
---|
| 224 | // TODO !!
|
---|
[451] | 225 |
|
---|
| 226 | while ($row = $sql -> fetch_array())
|
---|
[405] | 227 | {
|
---|
| 228 | switch ($row["category"])
|
---|
| 229 | {
|
---|
| 230 | case 1:
|
---|
| 231 | $cat = "Server novinky";
|
---|
| 232 | $link = "servernews";
|
---|
| 233 | break;
|
---|
| 234 | case 2:
|
---|
| 235 | $cat = "GM novinky";
|
---|
| 236 | $link = "gmnews";
|
---|
| 237 | break;
|
---|
| 238 | case 3:
|
---|
| 239 | $cat = "In-game novinky";
|
---|
| 240 | $link = "gamenews";
|
---|
| 241 | break;
|
---|
| 242 | case 4:
|
---|
| 243 | $cat = "Články";
|
---|
| 244 | $link = "articles";
|
---|
| 245 | break;
|
---|
| 246 | }
|
---|
| 247 | $date_arr = explode(" ",$row["date"]);
|
---|
| 248 | $date = explode("-",$date_arr[0]);
|
---|
| 249 | $time = mktime(0,0,0,$date[1],$date[2],$date[0]);
|
---|
| 250 | $human_date = date ("d.m.Y",$time);
|
---|
| 251 | echo "
|
---|
| 252 | <table align=\"center\" border=\"1\" width=\"500\">
|
---|
| 253 | <tr>
|
---|
| 254 | <td><b>".$row["title"]."</b></td>
|
---|
| 255 | <td width=\"100\">".$human_date."</td>
|
---|
| 256 | </tr>
|
---|
| 257 | <tr>
|
---|
| 258 | <td colspan=\"2\">
|
---|
| 259 | ".$row["text"]."
|
---|
| 260 | </td>
|
---|
| 261 | </tr>
|
---|
| 262 | <tr>
|
---|
| 263 | <td>Sekce : <a href=\"?page=".$link."\">".$cat."</a></td>
|
---|
[445] | 264 | <td>".$row["autor"]."</td>
|
---|
[405] | 265 | </tr>
|
---|
| 266 | </table>
|
---|
| 267 | <br />
|
---|
| 268 | ";
|
---|
| 269 | }
|
---|
[451] | 270 |
|
---|
| 271 | mysql_connect($db_server, $db_user, $db_pass);
|
---|
| 272 | mysql_select_db($db_webu);
|
---|
| 273 | $limit = 5;
|
---|
| 274 | $pocet = mysql_result(mysql_query(" SELECT FOUND_ROWS()"), 0);
|
---|
| 275 | if ($_GET["offset"]) {
|
---|
| 276 | echo "<a href='$_SERVER[PHP_SELF]" . ($_GET["offset"] != $limit ? "?offset=" . ($_GET["offset"] - $limit) : "") . "'>zpět</a>\n";
|
---|
| 277 | }
|
---|
| 278 | if ($pocet > $_GET["offset"] + $limit) {
|
---|
| 279 | echo "<a href='$_SERVER[PHP_SELF]?offset=" . ($_GET["offset"] + $limit) . "'>vpřed</a>\n";
|
---|
| 280 | }
|
---|
| 281 |
|
---|
| 282 | $result = mysql_query("SELECT SQL_CALC_FOUND_ROWS * FROM tabulka ORDER BY datum DESC, id DESC LIMIT $limit OFFSET " . ($limit * $_GET["strana"]));
|
---|
| 283 | $pocet = mysql_result(mysql_query(" SELECT FOUND_ROWS()"), 0);
|
---|
| 284 | if ($_GET["strana"]) {
|
---|
| 285 | echo "<a href='$_SERVER[PHP_SELF]" . ($_GET["strana"] != 1 ? "?strana=" . ($_GET["strana"] - 1) : "") . "'>zpět</a>\n";
|
---|
| 286 | }
|
---|
| 287 | if ($pocet > $limit * ($_GET["strana"] + 1)) {
|
---|
| 288 | echo "<a href='$_SERVER[PHP_SELF]?strana=" . ($_GET["strana"] + 1) . "'>vpřed</a>\n";
|
---|
| 289 | }
|
---|
| 290 |
|
---|
[405] | 291 | }
|
---|
| 292 | else
|
---|
| 293 | {
|
---|
| 294 | echo "<center><h3>Žádný článek v této kategorii !</h3></center>";
|
---|
| 295 | }
|
---|
| 296 | }
|
---|
| 297 |
|
---|
| 298 | }
|
---|
| 299 | ?>
|
---|