source: global.php@ 47

Last change on this file since 47 was 47, checked in by george, 18 years ago

Listování stránek u aktualit.
Zjednodušení generování hlavního menu do funkcí.
Doplnění položek konfigurace.

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