- Timestamp:
- Mar 29, 2009, 11:57:40 AM (16 years ago)
- Location:
- trunk/inc
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/inc/html.php
r470 r550 1 1 <?php 2 class Html { 2 3 class Html 4 { 3 5 private $values; 4 6 private $db; 5 // -- 6 7 8 $this ->db = &$db;9 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 else26 {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 else40 {41 return "Undefined";42 43 } 44 45 46 $code = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">7 8 public function __construct($values,$db) 9 { 10 $this->db = &$db; 11 // default config 12 $this->html_cfg = array 13 ( 14 "charset" => "utf-8", 15 "author" => "Zork", 16 "copyright" => "(C) 2008 Heroes of Fantasy, All rights reserved.", 17 "favicon" => "imgs/fav", 18 "title" => "Heroes of Fantasy", 19 "description" => "Heroes of Fantasy free WoW server běžící na programu MaNGOS", 20 "keywords" => "wowserver, world of warcraft, free, wow, server, hof, heroes of fantasy, zdechov, mangos" 21 ); 22 23 if((count($values) > 1) or ($values[0] != 0) and ($values[0] != 0)) 24 { 25 $result_cfg = array_merge ($this->html_cfg, $values); 26 foreach($result_cfg as $name => $value) 27 $this->{$name} = $value; 28 } else 29 { 30 foreach($this->html_cfg as $name => $value) 31 $this->{$name} = $value; 32 } 33 } 34 35 private function CfgChck($value) 36 { 37 if(isset($this->{$value})) 38 { 39 return($this->{$value}); 40 } else 41 { 42 return('Undefined'); 43 } 44 } 45 46 public function Start() 47 { 48 $code = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"> 47 49 <html> 48 50 <head> … … 65 67 <!--[if IE]><link rel=\"stylesheet\" type=\"text/css\" href=\"styles/ie.css\" /><![endif]--> 66 68 </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> 69 <body>"; 70 $this->TimerStart(); 71 echo($code); 72 } 73 74 private function TimerStart() 75 { 76 $time_start = microtime(); 77 $time_start = explode(' ', $time_start); 78 $time_start = $time_start[1] + $time_start[0]; 79 $this->time_start = $time_start; 80 } 81 82 private function TimerStop() 83 { 84 $round = 100000; 85 $time_start = $this->time_start; 86 $time_stop = microtime(); 87 $time_stop = explode(' ', $time_stop); 88 $time_stop = $time_stop[1] + $time_stop[0]; 89 $deltatime = $time_stop - $time_start; 90 $deltatime = (round(($deltatime * $round))) / $round; 91 return($deltatime); 92 } 93 94 public function Stop() 95 { 96 $time = $this->TimerStop(); 97 $code = '<!-- Vygenerováno za : ".$time." s -->'. 98 '</body></html>'; 99 echo($code); 100 } 101 102 public function Pager($get, $dir_pages, $def) 103 { 104 $anti_ref = array 105 ( 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 if(($site_show != '') and is_readable($site_show)) return($site_show); 118 else return('./'.$dir_pages.'/'.$def.'.php'); 119 } else 120 { 121 $this->RefreshMsg($this -> Antirefresh($anti_ref[$get], $get), $get); 122 return("./".$dir_pages."/free.php"); 123 } 124 } else 125 { 126 if($site_show != "" AND is_readable($site_show)) return($site_show); 127 else return("./".$dir_pages."/".$def.".php"); 128 } 129 } 130 131 public function Antirefresh($value, $page) 132 { 133 $hash = md5($page); 134 if(isset($_SESSION["rf".$hash."rsh"])) 135 { 136 $refresh = $_SESSION["rf".$hash."rsh"] + $value; 137 if(time() < $refresh) 138 { 139 $dif = $refresh - time(); 140 return($dif); 141 } 142 } 143 $_SESSION["rf".$hash."rsh"] = time(); 144 } 145 146 public function RefreshMsg($dif, $get) 147 { 148 if($dif != 0) 149 { 150 if($dif > 60) 151 { 152 $dif = round($dif / 60)." min"; 153 $refresh = 30; 154 } else 155 { 156 $dif = $dif." s"; 157 $refresh = 2; 158 } 159 echo("<center><h3>Refresh omezení</h3></center> 169 160 Stránka nepovoluje tak krátký čas pro refresh (znovunačtení).<br /> 170 161 Další načtení stránky <b>?page=".$get."</b> bude možné za <b>".$dif."</b>.<br /> 171 162 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);\"> 163 <meta http-equiv=\"refresh\" content=\"".$refresh.";url=\">"); 164 } 165 } 166 167 public function PrgStart() 168 { 169 echo("<table align=\"center\" width=\"346\" height=\"417\" border=\"0\" style=\"background-image: url(imgs/web/prg.gif);\"> 182 170 <tr height=\"80\"> 183 171 <td width=\"20\"></td> … … 189 177 <tr> 190 178 <td width=\"20\"></td> 191 <td align=\"center\" valign=\"top\">"; 192 } 193 // -- 194 public function PrgStop () 195 { 196 echo " 197 </td> 179 <td align=\"center\" valign=\"top\">"); 180 } 181 182 public function PrgStop() 183 { 184 echo("</td> 198 185 <td width=\"20\"></td> 199 186 </tr> … … 203 190 <td width=\"20\"></td> 204 191 </tr> 205 </table>" ;206 207 // -- 208 public function ShowNews($kategorie)209 210 192 </table>"); 193 } 194 195 public function ShowNews($kategorie) 196 { 197 include("inc/db.php"); 211 198 global $db_webu; 212 199 213 if ($kategorie == "all") 200 if($kategorie == "all") 201 { 202 $where = " "; 203 } else 204 { 205 $where = "WHERE `category` = '".$kategorie."'"; 206 } 207 208 mysql_connect($db_server, $db_user, $db_pass); 209 mysql_select_db($db_webu); 210 $limit = 5; 211 212 $pocet = mysql_num_rows(mysql_query("SELECT id FROM `articles`".$where."ORDER BY `date` DESC;")); 213 $offset = ($_GET["offset"] ? $_GET["offset"] : $pocet); 214 215 if($pocet != 0) 216 { 217 mysql_query('SET NAMES utf8'); 218 $result = mysql_query("SELECT * FROM articles $where ORDER BY date DESC, id DESC LIMIT $limit OFFSET " . ($pocet - $offset)); 219 while($row = mysql_fetch_array($result)) 220 { 221 switch ($row["category"]) 214 222 { 215 $where = " "; 223 case 1: 224 $cat = "Server novinky"; 225 $link = "servernews"; 226 break; 227 case 2: 228 $cat = "GM novinky"; 229 $link = "gmnews"; 230 break; 231 case 3: 232 $cat = "In-game novinky"; 233 $link = "gamenews"; 234 break; 235 case 4: 236 $cat = "Články"; 237 $link = "articles"; 238 break; 216 239 } 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 230 if ($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)); 234 while($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\"> 240 $date_arr = explode(' ', $row['date']); 241 $date = explode('-', $date_arr[0]); 242 $time = mktime(0, 0, 0, $date[1], $date[2], $date[0]); 243 $human_date = date ("d.m.Y", $time); 244 echo("<table align=\"center\" border=\"1\" width=\"500\"> 260 245 <tr> 261 246 <td><b>".$row["title"]."</b></td> … … 272 257 </tr> 273 258 </table> 274 <br /> 275 "; 259 <br />"); 260 } 261 echo("<p align=center>"); 262 if($offset < $pocet) 263 { 264 echo("<a href='$_SERVER[PHP_SELF]" . ($offset + $limit < $pocet ? "?offset=" . ($offset + $limit) : "") . "'><-- novější</a>\n "); 265 } 266 if($offset > $limit) 267 { 268 echo(" <a href='$_SERVER[PHP_SELF]?offset=" . ($offset - $limit) . "'>starší --></a>\n"); 269 } 270 } else 271 { 272 echo("<center><h3>Žádný článek v této kategorii !</h3></center>"); 273 } 274 } 275 276 function QuickNew() 277 { 278 global $server; 279 280 if(isset($_COOKIE["hof-quick"]) AND $_COOKIE["hof-quick"] == "no") 281 { 282 } else 283 { 284 echo('<table align="center" border="1" width="500">'. 285 '<tr>'. 286 '<td><b>Rychlý přehled</b></td>'. 287 '<td width="100">'.date('d.m.Y', time()).'</td>'. 288 '</tr>'. 289 '<tr>'. 290 '<td colspan="2">'. 291 '<b>Server : </b>'.$server->ServerImg($server->ServerOnline('wow.zdechov.net', 8085)).'<b> (<a href="?page=online">'.$server->MangosOnline().' hráčů</a>) | Patch 3.0.9 | <a href="http://wow.zdechov.net/pages/realmlist.wtf">Realmlist</a> | Více info <a href="?page=server">zde</a></b>'. 292 '</td></tr></table><br />'); 293 } 294 } 276 295 } 277 echo"<p align=center>"; 278 if ($offset < $pocet) { 279 echo "<a href='$_SERVER[PHP_SELF]" . ($offset + $limit < $pocet ? "?offset=" . ($offset + $limit) : "") . "'><-- novější</a>\n "; 280 } 281 if ($offset > $limit) { 282 echo " <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 } 296 298 297 ?> -
trunk/inc/server.php
r548 r550 1 1 <?php 2 class Server { 2 3 class Server 4 { 3 5 private $db; 4 6 public function __construct ($db) … … 361 363 } 362 364 } 365 } 363 366 364 365 366 367 }368 367 ?>
Note:
See TracChangeset
for help on using the changeset viewer.