Changeset 376 for trunk/includes/global.php
- Timestamp:
- Mar 11, 2010, 8:40:32 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/includes/global.php
r365 r376 14 14 foreach($_GET as $Index => $Item) $_GET[$Index] = addslashes($_GET[$Index]); 15 15 16 include_once('config.php'); 17 include_once('error.php'); 18 include_once('databaseconection.php'); 19 include_once('global_function.php'); 20 include_once('rss.php'); 21 include_once('system.php'); 16 include_once(dirname(__FILE__).'/config.php'); 17 include_once(dirname(__FILE__).'/error.php'); 18 include_once(dirname(__FILE__).'/databaseconection.php'); 19 include_once(dirname(__FILE__).'/global_function.php'); 20 include_once(dirname(__FILE__).'/rss.php'); 21 include_once(dirname(__FILE__).'/system.php'); 22 include_once(dirname(__FILE__).'/user.php'); 22 23 23 24 $Database = new Database($Config['Database']['Host'], $Config['Database']['User'], $Config['Database']['Password']); … … 30 31 $System = new System(); 31 32 $System->Init(); 33 $User = new User(); 34 $User->Restore(); 32 35 33 36 function GetMicrotime() … … 39 42 function ShowShoutbox() 40 43 { 41 global $Database, $Config ;44 global $Database, $Config, $User; 42 45 43 46 echo('<strong><a href="'.$Config['Web']['BaseURL'].'action.php?action=ShoutBoxView">Kecátko:</a></strong>'); 44 if(Licence(LICENCE_USER)) echo(' <a href="'.$Config['Web']['BaseURL'].'action.php?action=shoutbox">Vložit</a>'); 47 if($User->Licence(LICENCE_USER)) 48 echo(' <a href="'.$Config['Web']['BaseURL'].'action.php?action=shoutbox">Vložit</a>'); 45 49 echo('<div class="box"><table>'); 46 50 $ID = $Database->SQLCommand('SELECT * FROM `ShoutBox` ORDER BY `ID` DESC LIMIT 20'); … … 52 56 function ShowTopBar() 53 57 { 54 global $Config, $Database ;58 global $Config, $Database, $User; 55 59 56 60 echo('<div class="Menu">'); 57 echo('<span class="MenuItem"></span>'); 58 if(Licence(LICENCE_USER)) 59 { 60 $DbResult = $Database->SQLCommand('SELECT `Team`, `Name` FROM `User` WHERE ID='.$_SESSION['UserID']); 61 $User = mysql_fetch_assoc($DbResult); 62 $DbResult = $Database->SQLCommand('SELECT `Id`, `Name` FROM `Team` WHERE Id='.$User['Team']); 61 echo('<span class="MenuItem"></span>'); 62 if($User->Licence(LICENCE_USER)) 63 { 64 $DbResult = $Database->SQLCommand('SELECT `Id`, `Name` FROM `Team` WHERE `Id`='.$User->Team); 63 65 $Team = mysql_fetch_assoc($DbResult); 64 66 65 67 //echo('<span class="MenuItem">Moje překlady: <a href="">Dokončené</a> <a href="">Rozpracované</a> <a href="">Exporty</a> Tým: <a href="">'.$Team['name'].'</a></span>'); 66 echo('<span class="MenuItem2">'.$User ['Name'].' <a href="'.$Config['Web']['BaseURL'].'?Logout">Odhlášení</a> <a href="'.$Config['Web']['BaseURL'].'Options.php">Nastavení</a></span>');68 echo('<span class="MenuItem2">'.$User->Name.' <a href="'.$Config['Web']['BaseURL'].'?action=logout">Odhlášení</a> <a href="'.$Config['Web']['BaseURL'].'Options.php">Nastavení</a></span>'); 67 69 } else 68 70 { 69 echo('<span class="MenuItem2"><form action="? " method="post"> Jméno: <input type="text" name="LoginUser" size="8 " /> Heslo: <td><input type="password" name="LoginPass" size="8" /> <input type="submit" value="Přihlásit" /></form> <a href="'.$Config['Web']['BaseURL'].'registrace.php">Registrace</a></span>');71 echo('<span class="MenuItem2"><form action="?action=login" method="post"> Jméno: <input type="text" name="LoginUser" size="8 " /> Heslo: <td><input type="password" name="LoginPass" size="8" /> <input type="submit" value="Přihlásit" /></form> <a href="'.$Config['Web']['BaseURL'].'registrace.php">Registrace</a></span>'); 70 72 } 71 73 echo('</div>'); … … 74 76 function ShowLoginBox() 75 77 { 76 if(Licence(LICENCE_USER)) 77 { 78 // echo 'Jste přihlášen jako: <b>'.$_SESSION['User'].'</b> <a href="index.php?Logout">Odhlásit</a>'; 78 global $User; 79 80 if($User->Licence(LICENCE_USER)) 81 { 82 // echo 'Jste přihlášen jako: <b>'.$User->Id.'</b> <a href="index.php?Logout">Odhlásit</a>'; 79 83 } else 80 84 { … … 116 120 function ShowMainMenu() 117 121 { 118 global $TranslationTree, $Config ;122 global $TranslationTree, $Config, $User; 119 123 120 124 $Menu = array … … 140 144 141 145 echo('<strong>Hlavní menu:</strong>'. 142 '<div class="verticalmenu"><ul>'); 143 146 '<div class="verticalmenu"><ul>'); 144 147 foreach($Menu as $MenuTarget => $MenuItem) 145 148 { 146 if(isset($MenuItem[3])) $OnClick = ' onclick="'.$MenuItem[3].'"'; else $OnClick = ''; 147 if(Licence($MenuItem[0])) echo('<li><a class="verticalmenua" title="'.$MenuItem[1].'" href="'.$MenuTarget.'"'.$OnClick.'>'.$MenuItem[2].'</a></li>'); 149 if(isset($MenuItem[3])) $OnClick = ' onclick="'.$MenuItem[3].'"'; 150 else $OnClick = ''; 151 if($User->Licence($MenuItem[0])) echo('<li><a class="verticalmenua" title="'.$MenuItem[1].'" href="'.$MenuTarget.'"'.$OnClick.'>'.$MenuItem[2].'</a></li>'); 148 152 } 149 153 echo('</ul></div>'); … … 152 156 function ShowTranslatedMenu() 153 157 { 154 global $TranslationTree, $Config, $Database ;158 global $TranslationTree, $Config, $Database, $User; 155 159 156 160 echo('<strong>Překladové skupiny:</strong><br /><div id="TranslationMenu">'); 157 if( Licence(LICENCE_USER))158 { 159 echo ('<a title="Všechny překlady, které jste přeložil" href="'.$Config['Web']['BaseURL'].'TranslationList.php?user='.$_SESSION['UserID'].'&action=userall">Všechny moje texty</a><br />');160 echo ('<a title="Všechny překlady, které jste rozepsal a nedokončil" href="'.$Config['Web']['BaseURL'].'TranslationList.php?user='.$_SESSION['UserID'].'&not&action=userall">Rozpracované texty</a>');161 if($User->Licence(LICENCE_USER)) 162 { 163 echo('<a title="Všechny překlady, které jste přeložil" href="'.$Config['Web']['BaseURL'].'TranslationList.php?user='.$User->Id.'&action=userall">Všechny moje texty</a><br />'); 164 echo('<a title="Všechny překlady, které jste rozepsal a nedokončil" href="'.$Config['Web']['BaseURL'].'TranslationList.php?user='.$User->Id.'&not&action=userall">Rozpracované texty</a>'); 161 165 //TODO: počet nedokončených 162 echo 166 echo('<br /><br />'); 163 167 } 164 168 foreach($TranslationTree as $Group) … … 169 173 echo(' <a title="Zde můžete začít překládat" href="'.$Config['Web']['BaseURL'].'TranslationList.php?group='.$Group['Id'].'&action=notran">Nepřeložené</a><br /> 170 174 <a title="Přeložené texty, můžete zde hlasovat, nebo opravovat překlady" href="'.$Config['Web']['BaseURL'].'TranslationList.php?group='.$Group['Id'].'&action=Translate">Přeložené</a><br />'); 171 $ID = $Database->SQLCommand('SELECT * FROM connexion WHERE `Group` = '.$Group['Id']);175 $ID = $Database->SQLCommand('SELECT * FROM connexion WHERE `Group` = '.$Group['Id']); 172 176 if (mysql_num_rows($ID) > 0) 173 177 echo(' <a title="Vypsání souvislostí" href="'.$Config['Web']['BaseURL'].'TranslationList.php?group='.$Group['Id'].'&action=connexion_list">Souvislosti</a><br />'); 174 178 175 if(Licence(LICENCE_USER))179 if($User->Licence(LICENCE_USER)) 176 180 { 177 181 echo(' <a title="Nedokončené překlady" href="'.$Config['Web']['BaseURL'].'TranslationList.php?group='.$Group['Id'].'&action=mydevelop">Rozepsané</a><br /> … … 186 190 function ShowOnlineUserList() 187 191 { 188 global $Database, $Moderators ;192 global $Database, $Moderators, $User; 189 193 190 194 echo('Online překladatelé:<br />'); 191 195 $ID = $Database->SQLCommand('SELECT `Name`, `GM`, `ID` FROM `User` WHERE `LastLogin` >= NOW() - 300 AND ((`LastLogout` < `LastLogin`) OR (ISNULL(`LastLogout`)))'); 192 while($ User = mysql_fetch_assoc($ID))193 { 194 if( Licence(LICENCE_MODERATOR)) $Name = '<a href="user.php?user='.$User['ID'].'">'.$User['Name'].'</a>';195 else $Name = $ User['Name'];196 while($DbUser = mysql_fetch_assoc($ID)) 197 { 198 if($User->Licence(LICENCE_MODERATOR)) $Name = '<a href="user.php?user='.$DbUser['ID'].'">'.$DbUser['Name'].'</a>'; 199 else $Name = $DbUser['Name']; 196 200 $TextGM = ''; 197 201 echo('<strong>'.$Name.'</strong>'.$TextGM.'<br />'); … … 199 203 } 200 204 201 function CheckLogin()202 {203 global $Database;204 205 if(!array_key_exists('UserID', $_SESSION)) $_SESSION['UserID'] = '';206 if(!array_key_exists('User', $_SESSION)) $_SESSION['User'] = 'NotRegistred';207 if(!array_key_exists('Pass', $_SESSION)) $_SESSION['Pass'] = '';208 209 // Přihlášení210 if(array_key_exists('LoginUser', $_POST))211 {212 $_SESSION['User'] = $_POST['LoginUser'];213 $_SESSION['Pass'] = $_POST['LoginPass'];214 215 $DbResult = $Database->SQLCommand('SELECT * FROM `User` WHERE LOWER(`Name`) = LOWER("'.$_SESSION['User'].'") AND `Pass` = sha1(CONCAT(sha1("'.$_SESSION['Pass'].'"), `Salt`))');216 if(mysql_num_rows($DbResult) == 0)217 {218 echo('<script> alert("Jméno nebo heslo bylo zadáno špatně!"); </script>');219 $_SESSION['UserID'] = '';220 $_SESSION['User'] = '';221 $_SESSION['Pass'] = '';222 } else223 {224 $User = mysql_fetch_assoc($DbResult);225 $_SESSION['UserID'] = $User['ID'];226 $_SESSION['User'] = $User['Name'];227 WriteLog('Login: '.$_SESSION['User'], LOG_TYPE_USER);228 }229 }230 231 // Odhlášení232 if(array_key_exists('Logout', $_GET) and ($_SESSION['User'] != ''))233 {234 WriteLog('Odhlášení', LOG_TYPE_USER);235 if(is_numeric($_SESSION['UserID']))236 $Database->SQLCommand('UPDATE `User` SET `LastLogout` = NOW() WHERE `ID` = '.$_SESSION['UserID']);237 $_SESSION['User'] = '';238 $_SESSION['Pass'] = '';239 $_SESSION['UserID'] = '';240 }241 242 // Záznam o aktivitě243 if(Licence(LICENCE_USER) and array_key_exists('REMOTE_ADDR', $_SERVER))244 $Database->SQLCommand('UPDATE `User` SET `LastIP` = "'.$_SERVER['REMOTE_ADDR'].'", `LastLogin` = NOW() WHERE `ID` = '.$_SESSION['UserID']);245 }246 247 205 function ShowPage() 248 206 { 249 global $ Config, $Database, $RSSChannels, $PageFooterRequested;207 global $User, $Config, $Database, $RSSChannels, $PageFooterRequested; 250 208 251 209 echo('<?xml version="1.0" encoding="'.$Config['Web']['Charset'].'"?> … … 263 221 foreach($RSSChannels as $Channel) 264 222 echo(' <link rel="alternate" title="'.$Channel['Title'].'" href="'.$Channel['URL'].'" type="application/rss+xml" />'); 265 echo('<title> Projekt překládání textů WoW</title>223 echo('<title>'.$Config['Web']['Title'].'</title> 266 224 </head> 267 225 <body> 268 226 <table id="bannertable"><tr> 269 227 <td id="banner1"></td> 270 <td id="banner"><div id="bannertitle"> Projekt překládání textů WoW</div></td>228 <td id="banner"><div id="bannertitle">'.$Config['Web']['Title'].'</div></td> 271 229 <td id="banner2"></td></tr> 272 230 </table>'); 273 231 274 CheckLogin(); 232 if(array_key_exists('action', $_GET)) 233 { 234 if($_GET['action'] == 'login') 235 { 236 $User->Login($_POST['LoginUser'], $_POST['LoginPass']); 237 if($User->Role == LICENCE_ANONYMOUS) echo('<script> alert("Jméno nebo heslo bylo zadáno špatně!"); </script>'); 238 } else 239 if($_GET['action'] == 'logout') 240 { 241 if($User->Role != LICENCE_ANONYMOUS) 242 { 243 $User->Logout(); 244 WriteLog('Odhlášení', LOG_TYPE_USER); 245 } 246 } 247 } 275 248 ShowTopBar(); 276 249 277 250 echo('<table class="page"><tr><td class="menu">'); 278 251 ShowMainMenu(); 279 280 // echo('<br />');281 //ShowLoginBox();282 //echo('<br />');283 252 ShowOnlineUserList(); 284 253 echo('<br />'); … … 305 274 function ShowFooter() 306 275 { 307 global $Database, $Config, $ScriptStartTime, $PageFooterRequested ;276 global $Database, $Config, $ScriptStartTime, $PageFooterRequested, $User; 308 277 309 278 if(isset($PageFooterRequested)) … … 333 302 '</html>'); 334 303 $Database->Disconnect(); 304 $User->Store(); 335 305 } 336 306 }
Note:
See TracChangeset
for help on using the changeset viewer.