source: global.php@ 358

Last change on this file since 358 was 358, checked in by george, 17 years ago

Oprava zobrazení času běhu serveru na hlavní stránce

File size: 8.7 KB
Line 
1<?php
2
3session_start();
4include('config.php');
5include('database.php');
6include('error.php');
7$Database = new Database($Config['Database']['Host'], $Config['Database']['User'], $Config['Database']['Password'], $Config['Database']['Database']);
8$Database->Prefix = $Config['Database']['Prefix'];
9$Database->charset($Config['Database']['Charset']);
10
11$Menu = array(
12 array('index.php', 'Home', 'home'),
13 array('jak_zacit.php', 'Jak zaèít', 'how'),
14 array('registrace/', 'Registrace', 'registrace'),
15 array('minimanager/', 'Správa úètu', 'account'),
16 array('forum/', 'Diskusní fórum', 'forum'),
17 array('server.php', 'Server', 'server'),
18 array('finance/', 'Finance', 'donate'),
19 //array('db/', 'Online databáze', 'database'),
20 array('download_soubory/', 'Soubory', 'download'),
21 array('link.php', 'Odkazy', 'link'),
22 array('mapa.php', 'Mapa', 'mapa'),
23 array('guildy.php', 'Seznam guild', 'guilds'),
24 array('online_player.php', 'Online hráèi', 'online_player'),
25 array('honor.php', 'Tabulka cti', 'honor'),
26 array('events.php', 'Události', 'udalosti'),
27 //array('Death%20Dealers%20Hratelne%20Rasy.php', 'Rasy', 'rasy'),
28 //array('Death%20Dealers%20Povolani.php', 'Povolání', 'povolani'),
29 //array('Death%20Dealers%20Profese.php', 'Profese', 'profese'),
30);
31
32function HumanDate($DateTime)
33{
34 $DateTimeParts = explode(' ', $DateTime);
35 $Parts = explode('-', $DateTimeParts[0]);
36 if($DateTimeParts[0] != '0000-00-00') return(($Parts[2]*1).'.'.($Parts[1]*1).'.'.$Parts[0]);
37 else return('&nbsp;');
38}
39
40function OnlinePlayerCount()
41{
42 global $Database;
43 $Database->select_db('characters');
44 $Result = $Database->select('characters', 'COUNT(*)', 'online=1');
45 $Row = $Result->fetch_array();
46 return($Row[0]);
47}
48
49function CharacterCount()
50{
51 global $Database;
52 $Database->select_db('characters');
53 $Result = $Database->select('characters', 'COUNT(*)');
54 $Row = $Result->fetch_array();
55 return($Row[0]);
56}
57
58function AccountCount()
59{
60 global $Database;
61 $Database->select_db('realmd');
62 $DbResult = $Database->query('SELECT COUNT(*) FROM account');
63 $Row = $DbResult->fetch_array();
64 return($Row[0]);
65}
66
67function MangosUptime()
68{
69 global $Database;
70 $Database->select_db('mangos');
71 $DbResult = $Database->query('SELECT `starttime`, `uptime` FROM `uptime` ORDER BY `starttime` DESC LIMIT 1');
72 $Row = $DbResult->fetch_array();
73 $Uptime = $Row['uptime'];
74 //$Uptime = 0;
75 $Days = floor($Uptime / 3600 / 24);
76 if($Days == 0) $DaysText = '';
77 else if($Days == 1) $DaysText = $Days.' den';
78 else if(($Days > 1) and ($Days < 5)) $DaysText = $Days.' dny';
79 else if(($Days > 5)) $DaysText = $Days.' dnù';
80 $Seconds = $Uptime - 3600;
81 return($DaysText.' '.date('G:i', $Seconds));
82}
83
84function RunningEventCount()
85{
86 global $Database;
87 $Count = 0;
88 $Database->select_db('mangos');
89 $DbResult = $Database->select('game_event', '*, UNIX_TIMESTAMP(start_time) as start', 'end_time > NOW() AND start_time < NOW()');
90 while($Row = $DbResult->fetch_array())
91 {
92 $Start = (floor((time() - $Row['start']) / ($Row['occurence'] * 60))) * $Row['occurence'] * 60 + $Row['start'];
93 $End = $Start + $Row['length'] * 60;
94 if((time() > $Start) and (time() < $End)) $Count++;
95 }
96 return($Count);
97}
98
99function ShowOnlinePlayerCount()
100{
101 $PlayerCount = OnlinePlayerCount();
102 if($PlayerCount == 1) $P = 'hráè';
103 else if(($PlayerCount >= 2) and ($PlayerCount <= 4)) $P = 'hráèi';
104 else $P = 'hráèù';
105 echo($PlayerCount.' '.$P);
106}
107
108function FormatOutput($s)
109{
110 $out = '';
111 $nn = 0;
112 $n = 0;
113 while($s!='')
114 {
115 $start = strpos($s,'<');
116 $end = strpos($s,'>');
117 if($start != 0)
118 {
119 $end = $start-1;
120 $start = 0;
121 }
122 $line = trim(substr($s,$start,$end+1));
123 if(strlen($line)>0)
124 if($line[0] == '<')
125 {
126 if($s[$start+1] == '/')
127 {
128 $n = $n - 2;
129 $nn = $n;
130 } else
131 {
132 if(strpos($line,' ')) $cmd = substr($line,1,strpos($line,' ')-1);
133 else $cmd = substr($line,1,strlen($line)-2);
134 //echo('['.$cmd.']');
135 if(strpos($s,'</'.$cmd.'>')) $n = $n + 2;
136 }
137 }// else $line = '['.$line.']';
138 //if($line != '') echo(htmlspecialchars(str_repeat(' ',$nn).$line."\n"));
139 if($line != '') $out .= (str_repeat(' ',$nn).$line."\n");
140 $s = substr($s,$end+1,strlen($s));
141 $nn = $n;
142 }
143 return($out);
144}
145
146function CheckPortStatus($Ip, $Port)
147{
148 function ErrorHandler($errno,$errmsg,$filename,$linenum,$vars)
149 {
150 }
151 set_error_handler('ErrorHandler');
152 //error_reporting(0);
153 if($Fp1 = fsockopen($Ip, $Port, $ERROR_NO, $ERROR_STR,(float)0.5))
154 {
155 fclose($Fp1);
156 return true;
157 } else
158 {
159 //echo($ERROR_NO.','.$ERROR_STR);
160 //die();
161 return false;
162 }
163 restore_error_handler();
164}
165
166function GenerateMenu()
167{
168 global $Config, $Menu;
169 $Result = '';
170 foreach($Menu as $Index => $MenuItem)
171 {
172 $Result .= "<a href=\"".$Config['Web']['BaseURL'].$MenuItem[0]."\" onMouseOver=\"swtch(&quot;".($Index*2+2)."&quot;,&quot;".$MenuItem[2]."&quot;)\" onMouseOut=\"swtch(&quot;".($Index*2+1)."&quot;,&quot;".$MenuItem[2]."&quot;)\"><IMG SRC=\"".$Config['Web']['BaseURL']."images/".$MenuItem[2].".jpg\" name=\"".$MenuItem[2]."\" alt=\"".$MenuItem[1]."\" border=\"0\"></A><br>\n";
173 }
174 return($Result);
175}
176
177function ShowHeader()
178{
179 global $Config;
180 echo('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
181<HTML>
182<HEAD>
183 <META http-equiv="Content-Language" content="cs">
184 <META http-equiv="Content-Type" content="text/html; charset='.$Config['Web']['Charset'].'">
185 <META HTTP-EQUIV="Expires" CONTENT="Mon, 06 Jan 1990 00:00:01 GMT">
186 <link rel="SHORTCUT ICON" href="images/favicon.ico">
187 <link rel="alternate" title="RSS aktuality" href="rss.php" type="application/rss+xml">
188 <TITLE>WoW server Heroes of Fantasy</TITLE>
189 <style type="text/css" media="screen">@import url('.$Config['Web']['BaseURL'].'css/style.css);</style>
190 <script language="JavaScript" type="text/javascript" src="'.$Config['Web']['BaseURL'].'css/global_js.php"></script>
191</HEAD>
192<BODY text="#cccccc">
193
194
195<TABLE cellspacing="0" cellpadding="0" align="center" class="TableHlavni" border="0">
196 <TR>
197 <TD id="BlankSpace">&nbsp;</td>
198 <TD rowspan="2" id="TdSloupec" valign="top">
199 <div class="Nadpis">Heroes of Fantasy</div>
200 <div class="DivText">');
201
202 ShowOnlinePlayerCount();
203
204
205echo('</div>');
206
207echo(GenerateMenu());
208
209echo('<A HREF="http://www.toplist.cz/" target="_blank"><IMG alt="pocitadlo"
210SRC="http://toplist.cz/count.asp?logo=mc&amp;ID=324802"
211border="0" width="0" height="0"></A>
212
213 </td>
214 </tr>
215 <tr><td id="LeftCell"><div class="pHlavni">');
216}
217
218function ShowFooter()
219{
220 global $Config;
221 echo('</div>
222 </td>
223 </tr>
224 <tr>
225 <td colspan="2">
226 <DIV class="DivPaticka">
227 <A href="'.$Config['Web']['BaseURL'].'administrace/" class="Paticka">#</A>
228 | Správce serveru: '.$Config['Web']['Admin'].' | Email: '.$Config['Web']['AdminEmail'].' | Poèet pøístupù: <A HREF="http://counter.cnw.cz/" TARGET=_parent>
229 <IMG SRC="http://counter.cnw.cz/monika.cgi?wowzdechov&amp;7&amp;000000&amp;FFFFFF&amp;on" BORDER=0 ALT="CNW:Counter"></A>
230 <SCRIPT type="text/javascript">
231 <!--
232 document.write("<A href=\"http://counter.cnw.cz\" target=\"_parent\"><IMG src=\"http://counter.cnw.cz/trackit.cgi?wowzdechov&t5&" + escape(top.document.referrer) + "\" alt=\"CNW:Tracker\" border=\"0\" width=\"1\" height=\"1\"></A>");
233 // -->
234 </SCRIPT>
235 | Provozováno na <a href="http://game.zdechov.net/">game.zdechov.net</a> |
236
237 </DIV>
238 </td>
239 </tr>
240 </TABLE>
241 </BODY>
242</HTML>
243');
244}
245
246// Zobrazení èíselný seznamu stránek
247function PagesList($URL,$Page,$TotalCount,$CountPerPage)
248{
249 $Count = ceil($TotalCount/$CountPerPage);
250 $Around = 10;
251 $Result = '';
252 if($Count>1)
253 {
254 if($Page>0)
255 {
256 $Result.= '<a href="'.$URL.'0">&lt;&lt;</a> ';
257 $Result.= '<a href="'.$URL.($Page-1).'">&lt;</a> ';
258 }
259 $PagesMax = $Count-1;
260 $PagesMin = 0;
261 if($PagesMax>($Page+$Around)) $PagesMax = $Page+$Around;
262 if($PagesMin<($Page-$Around))
263 {
264 $Result.= ' .. ';
265 $PagesMin = $Page-$Around;
266 }
267 for($i=$PagesMin;$i<=$PagesMax;$i++)
268 {
269 if($i==$Page) $Result.= '<strong>';
270 $Result.= '<a href="'.$URL.$i.'">'.($i+1).'</a> ';
271 if($i==$Page) $Result.= '</strong>';
272 }
273 if($PagesMax<($Count-1)) $Result .= ' .. ';
274 if($Page<($Count-1))
275 {
276 $Result.= '<a href="'.$URL.($Page+1).'">&gt;</a> ';
277 $Result.= '<a href="'.$URL.($Count-1).'">&gt;&gt;</a>';
278 }
279 }
280 return($Result);
281}
282
283?>
Note: See TracBrowser for help on using the repository browser.