source: global.php@ 323

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

Zobrazení počtu hráčů nad menu z tabulky characters namísto account.

File size: 7.4 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 ShowOnlinePlayerCount()
41{
42 global $Database;
43 //ini_set('allow_url_fopen', 'On');
44 // World of Warcraft user stat
45 //$Content = @file_get_contents('http://wow.zdechov.net:8080/stat.xml');
46 //$File = fopen('http://'.$WoWServer.'/mangos/inc/stat.xml', 'r');
47 //$Content = fgets($File, 1000000);
48 //fclose($File);
49 $Database->select_db('characters');
50 $Result = $Database->select('characters', 'COUNT(*)', 'online=1');
51 $Row = $Result->fetch_array();
52 $PlayerCount = $Row[0];
53
54 if($PlayerCount == 1) $P = 'hráè';
55 else if(($PlayerCount >= 2) and ($PlayerCount <= 4)) $P = 'hráèi';
56 else $P = 'hráèù';
57 echo($PlayerCount.' '.$P);
58}
59
60function FormatOutput($s)
61{
62 $out = '';
63 $nn = 0;
64 $n = 0;
65 while($s!='')
66 {
67 $start = strpos($s,'<');
68 $end = strpos($s,'>');
69 if($start != 0)
70 {
71 $end = $start-1;
72 $start = 0;
73 }
74 $line = trim(substr($s,$start,$end+1));
75 if(strlen($line)>0)
76 if($line[0] == '<')
77 {
78 if($s[$start+1] == '/')
79 {
80 $n = $n - 2;
81 $nn = $n;
82 } else
83 {
84 if(strpos($line,' ')) $cmd = substr($line,1,strpos($line,' ')-1);
85 else $cmd = substr($line,1,strlen($line)-2);
86 //echo('['.$cmd.']');
87 if(strpos($s,'</'.$cmd.'>')) $n = $n + 2;
88 }
89 }// else $line = '['.$line.']';
90 //if($line != '') echo(htmlspecialchars(str_repeat(' ',$nn).$line."\n"));
91 if($line != '') $out .= (str_repeat(' ',$nn).$line."\n");
92 $s = substr($s,$end+1,strlen($s));
93 $nn = $n;
94 }
95 return($out);
96}
97
98function CheckPortStatus($Ip, $Port)
99{
100 function ErrorHandler($errno,$errmsg,$filename,$linenum,$vars)
101 {
102 }
103 set_error_handler('ErrorHandler');
104 //error_reporting(0);
105 if($Fp1 = fsockopen($Ip, $Port, $ERROR_NO, $ERROR_STR,(float)0.5))
106 {
107 fclose($Fp1);
108 return true;
109 } else
110 {
111 //echo($ERROR_NO.','.$ERROR_STR);
112 //die();
113 return false;
114 }
115 restore_error_handler();
116}
117
118function GenerateMenu()
119{
120 global $Config, $Menu;
121 $Result = '';
122 foreach($Menu as $Index => $MenuItem)
123 {
124 $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";
125 }
126 return($Result);
127}
128
129function ShowHeader()
130{
131 global $Config;
132 echo('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
133<HTML>
134<HEAD>
135 <META http-equiv="Content-Language" content="cs">
136 <META http-equiv="Content-Type" content="text/html; charset='.$Config['Web']['Charset'].'">
137 <META HTTP-EQUIV="Expires" CONTENT="Mon, 06 Jan 1990 00:00:01 GMT">
138 <link rel="SHORTCUT ICON" href="images/favicon.ico">
139 <link rel="alternate" title="RSS aktuality" href="rss.php" type="application/rss+xml">
140 <TITLE>WoW server Heroes of Fantasy</TITLE>
141 <style type="text/css" media="screen">@import url('.$Config['Web']['BaseURL'].'css/style.css);</style>
142 <script language="JavaScript" type="text/javascript" src="'.$Config['Web']['BaseURL'].'css/global_js.php"></script>
143</HEAD>
144<BODY text="#cccccc">
145
146
147<TABLE cellspacing="0" cellpadding="0" align="center" class="TableHlavni" border="0">
148 <TR>
149 <TD id="BlankSpace">&nbsp;</td>
150 <TD rowspan="2" id="TdSloupec" valign="top">
151 <div class="Nadpis">Heroes of Fantasy</div>
152 <div class="DivText">');
153
154 ShowOnlinePlayerCount();
155
156
157echo('</div>');
158
159echo(GenerateMenu());
160
161echo('<A HREF="http://www.toplist.cz/" target="_blank"><IMG alt="pocitadlo"
162SRC="http://toplist.cz/count.asp?logo=mc&amp;ID=324802"
163border="0" width="0" height="0"></A>
164
165 </td>
166 </tr>
167 <tr><td id="LeftCell"><div class="pHlavni">');
168}
169
170function ShowFooter()
171{
172 global $Config;
173 echo('</div>
174 </td>
175 </tr>
176 <tr>
177 <td colspan="2">
178 <DIV class="DivPaticka">
179 <A href="'.$Config['Web']['BaseURL'].'administrace/" class="Paticka">#</A>
180 | Správce serveru: '.$Config['Web']['Admin'].' | Email: '.$Config['Web']['AdminEmail'].' | Poèet pøístupù: <A HREF="http://counter.cnw.cz/" TARGET=_parent>
181 <IMG SRC="http://counter.cnw.cz/monika.cgi?wowzdechov&amp;7&amp;000000&amp;FFFFFF&amp;on" BORDER=0 ALT="CNW:Counter"></A>
182 <SCRIPT type="text/javascript">
183 <!--
184 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>");
185 // -->
186 </SCRIPT>
187 | Provozováno na <a href="http://game.zdechov.net/">game.zdechov.net</a> |
188
189 </DIV>
190 </td>
191 </tr>
192 </TABLE>
193 </BODY>
194</HTML>
195');
196}
197
198// Zobrazení èíselný seznamu stránek
199function PagesList($URL,$Page,$TotalCount,$CountPerPage)
200{
201 $Count = ceil($TotalCount/$CountPerPage);
202 $Around = 10;
203 $Result = '';
204 if($Count>1)
205 {
206 if($Page>0)
207 {
208 $Result.= '<a href="'.$URL.'0">&lt;&lt;</a> ';
209 $Result.= '<a href="'.$URL.($Page-1).'">&lt;</a> ';
210 }
211 $PagesMax = $Count-1;
212 $PagesMin = 0;
213 if($PagesMax>($Page+$Around)) $PagesMax = $Page+$Around;
214 if($PagesMin<($Page-$Around))
215 {
216 $Result.= ' .. ';
217 $PagesMin = $Page-$Around;
218 }
219 for($i=$PagesMin;$i<=$PagesMax;$i++)
220 {
221 if($i==$Page) $Result.= '<strong>';
222 $Result.= '<a href="'.$URL.$i.'">'.($i+1).'</a> ';
223 if($i==$Page) $Result.= '</strong>';
224 }
225 if($PagesMax<($Count-1)) $Result .= ' .. ';
226 if($Page<($Count-1))
227 {
228 $Result.= '<a href="'.$URL.($Page+1).'">&gt;</a> ';
229 $Result.= '<a href="'.$URL.($Count-1).'">&gt;&gt;</a>';
230 }
231 }
232 return($Result);
233}
234
235?>
Note: See TracBrowser for help on using the repository browser.