Changeset 566
- Timestamp:
- Aug 20, 2013, 11:37:30 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 4 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/Log/Log.php
r564 r566 1 1 <?php 2 2 3 include_once('includes/global.php'); 3 class ModuleLog extends AppModule 4 { 5 var $Excludes; 6 7 function __construct($System) 8 { 9 parent::__construct($System); 10 $this->Name = 'Log'; 11 $this->Version = '1.0'; 12 $this->Creator = 'Chronos'; 13 $this->License = 'GNU/GPL'; 14 $this->Description = 'Log various application events'; 15 $this->Dependencies = array(); 16 17 $this->Excludes = array(); 18 } 19 20 function Start() 21 { 22 $this->System->RegisterPage('log.php', 'PageLog'); 23 } 24 } 4 25 5 $Output = ''; 6 if(array_key_exists('rss', $_GET)) 26 function WriteLog($Text, $Type) 7 27 { 8 $Items = array(); 9 if(array_key_exists('type', $_GET)) $Where = ' WHERE `Type` = "'.($_GET['type'] * 1).'"'; 10 else $Where = ''; 11 $sql = 'SELECT *, UNIX_TIMESTAMP(`Date`) AS `TimeCreate`, (SELECT `User`.`Name` FROM `User` WHERE `User`.`ID` = `Log`.`User`) AS `UserName` FROM `Log`'.$Where.' ORDER BY `Date` DESC LIMIT 100'; 12 $DbResult = $System->Database->query($sql); 13 while($Line = $DbResult->fetch_assoc()) 28 global $System, $User; 29 30 if(!isset($_SERVER['REMOTE_ADDR'])) $IP = 'Konzole'; 31 else $IP = addslashes($_SERVER['REMOTE_ADDR']); 32 33 if(!is_null($User->Id)) $UserId = $User->Id; 34 else $UserId = 'NULL'; 35 $Query = 'INSERT INTO `Log` ( `User` , `Type` , `Text` , `Date` , `IP` ) 36 VALUES ('.$UserId.', '.$Type.', "'.addslashes($Text).'", NOW(), "'.$IP.'")'; 37 $System->Database->query($Query); 38 } 39 40 class PageLog extends Page 41 { 42 function ShowRSS() 14 43 { 15 $DbResult2 = $System->Database->query('SELECT * FROM `LogType` WHERE `Id`='.$Line['Type']); 16 $LogType = $DbResult2->fetch_assoc(); 44 $this->RawPage = true; 45 $Output = ''; 46 $Items = array(); 47 if(array_key_exists('type', $_GET)) $Where = ' WHERE `Type` = "'.($_GET['type'] * 1).'"'; 48 else $Where = ''; 49 $sql = 'SELECT *, UNIX_TIMESTAMP(`Date`) AS `TimeCreate`, (SELECT `User`.`Name` FROM `User` WHERE `User`.`ID` = `Log`.`User`) AS `UserName` FROM `Log`'.$Where.' ORDER BY `Date` DESC LIMIT 100'; 50 $DbResult = $this->System->Database->query($sql); 51 while($Line = $DbResult->fetch_assoc()) 52 { 53 $DbResult2 = $this->System->Database->query('SELECT * FROM `LogType` WHERE `Id`='.$Line['Type']); 54 $LogType = $DbResult2->fetch_assoc(); 55 56 if($Line['Type'] == LOG_TYPE_ERROR) $Line['Text'] = htmlspecialchars($Line['Text']); 57 $Line['Text'] = str_replace("\n", '<br>', $Line['Text']); 17 58 18 $Items[] = array 59 $Items[] = array 60 ( 61 'Title' => $LogType['Name'].' ('.$Line['UserName'].', '.$Line['IP'].')', 62 'Link' => 'http://'.$this->System->Config['Web']['Host'].$this->System->Link('/log.php'), 63 'Description' => $LogType['Name'].': '.$Line['Text'].' ('.$Line['UserName'].', '.$Line['IP'].')', 64 'Time' => $Line['TimeCreate'], 65 ); 66 } 67 68 $Output .= GenerateRSS(array 19 69 ( 20 'Title' => strip_tags($LogType['Name'].': '.$Line['Text'].' ('.$Line['UserName'].', '.$Line['IP'].')'), 21 'Link' => 'http://'.$Config['Web']['Host'].$System->Link('/log.php'), 22 'Description' => $LogType['Name'].': '.$Line['Text'].' ('.$Line['UserName'].', '.$Line['IP'].')', 23 'Time' => $Line['TimeCreate'], 70 'Title' => $this->System->Config['Web']['Title'], 71 'Link' => 'http://'.$this->System->Config['Web']['Host'].$this->System->Link('/'), 72 'Description' => $this->System->Config['Web']['Title'], 73 'WebmasterEmail' => $this->System->Config['Web']['AdminEmail'], 74 'Items' => $Items, 75 )); 76 return($Output); 77 } 78 79 function Show() 80 { 81 if(array_key_exists('a', $_POST)) $Action = $_POST['a']; 82 else if(array_key_exists('a', $_GET)) $Action = $_GET['a']; 83 else $Action = ''; 84 if($Action == 'rss') $Output = $this->ShowRSS(); 85 if($Action == 'delerrlog') $Output = $this->DeleteErrorLog(); 86 else $Output = $this->ShowList(); 87 return($Output); 88 } 89 90 function ShowList() 91 { 92 global $TranslationTree; 93 94 $Output = ''; 95 if(array_key_exists('type', $_GET)) $_SESSION['type'] = $_GET['type'] * 1; 96 else if(!array_key_exists('type', $_SESSION)) $_SESSION['type'] = ''; 97 98 if(array_key_exists('group', $_GET)) $_SESSION['group'] = $_GET['group']; 99 100 if($_SESSION['type'] != '') $WhereType = ' `Type`='.$_SESSION['type']; 101 else $WhereType = '1=1'; 102 103 $RSSChannels = array( 104 array('Title' => 'Záznamy změn', 'Channel' => 'log&type='.$_SESSION['type']) 24 105 ); 25 } 106 107 if($this->System->User->Licence(LICENCE_MODERATOR)) 108 { 109 $Output = '<strong>Filtr: </strong>'. 110 '<span style="color:black"><a href="log.php?type=" title="Bez filtrování">Všechny</a></span> '; 111 $DbResult = $this->System->Database->query('SELECT * FROM `LogType`'); 112 while($LogType = $DbResult->fetch_assoc()) 113 { 114 $Output .= '<a href="log.php?type='.$LogType['Id'].'" style="color:'.$LogType['Color'].'" title="'.$LogType['Name'].'">'.$LogType['Name'].'</a> '; 115 } 116 // echo ' Formát: datum: text zprávy (uživatel, IP)<br /><br />'; 117 $Output .= '<br /><br />'; 26 118 27 $Output .= GenerateRSS(array 28 ( 29 'Title' => $Config['Web']['Title'], 30 'Link' => 'http://'.$Config['Web']['Host'].$System->Link('/'), 31 'Description' => $Config['Web']['Title'], 32 'WebmasterEmail' => $Config['Web']['AdminEmail'], 33 'Items' => $Items, 34 )); 35 echo($Output); 36 } else 37 { 38 if(array_key_exists('type', $_GET)) $_SESSION['type'] = $_GET['type'] * 1; 39 else if(!array_key_exists('type', $_SESSION)) $_SESSION['type'] = ''; 119 if(array_key_exists('type', $_SESSION)) $Where = ' WHERE '.$WhereType; 120 else 121 { 122 if(array_key_exists('group', $_SESSION)) $Where = ' WHERE `Text` LIKE "%'.$TranslationTree[$_SESSION['group']]['Name'].'%"'; 123 else $Where = ''; 124 } 125 //if(($Where != '') and (array_key_exists('group', $_SESSION))) $Where .= ' AND text LIKE "%'.$TranslationTree[$_SESSION['group']]['Name'].'%"'; 40 126 41 if(array_key_exists('group', $_GET)) $_SESSION['group'] = $_GET['group']; 42 43 if($_SESSION['type'] != '') $WhereType = ' `Type`='.$_SESSION['type']; 44 else $WhereType = '1=1'; 45 46 $RSSChannels = array( 47 array('Title' => 'Záznamy změn', 'Channel' => 'log&type='.$_SESSION['type']) 48 ); 127 $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM `Log` '.$Where); 128 $DbRow = $DbResult->fetch_row(); 129 $PageList = GetPageList($DbRow[0]); 49 130 50 if($User->Licence(LICENCE_MODERATOR)) 131 $Output .= $PageList['Output']; 132 133 $TableColumns = array( 134 array('Name' => 'Date', 'Title' => 'Čas'), 135 array('Name' => 'LogName', 'Title' => 'Typ'), 136 array('Name' => 'Text', 'Title' => 'Text'), 137 array('Name' => 'UserName', 'Title' => 'Uživatel'), 138 array('Name' => 'IP', 'Title' => 'Adresa'), 139 ); 140 $Order = GetOrderTableHeader($TableColumns, 'date', 1); 141 $Output .= '<table width="98%" class="BaseTable">'. 142 $Order['Output']; 143 144 $sql = 'SELECT *, `LogType`.`Color` AS `LogColor`, `LogType`.`Name` AS `LogName`, '. 145 '(SELECT `User`.`Name` FROM `User` WHERE `User`.`ID` = `Log`.`User`) AS `UserName` FROM `Log` LEFT JOIN `LogType` ON `LogType`.`Id`=`Log`.`Type` '.$Where.$Order['SQL'].$PageList['SQLLimit']; 146 $DbResult = $this->System->Database->query($sql); 147 while($Line = $DbResult->fetch_assoc()) 148 { 149 if($Line['Type'] == LOG_TYPE_ERROR) $Line['Text'] = htmlspecialchars($Line['Text']); 150 $Line['Text'] = str_replace("\n", '<br>', $Line['Text']); 151 $Output .= '<tr><td>'.$Line['Date'].'</td>'. 152 '<td>'.$Line['LogName'].'</td>'. 153 '<td><span style="color: '.$Line['LogColor'].'">'.$Line['Text'].'</span></td>'. 154 '<td><a href="user.php?user='.$Line['User'].'">'.$Line['UserName'].'</a></td>'. 155 '<td>'.$Line['IP'].'</td></tr>'; 156 } 157 $Output .= '</table>'. 158 $PageList['Output']; 159 if($this->System->User->Licence(LICENCE_ADMIN)) 160 $Output .= '<div><a href="'.$this->System->Link('/log.php?a=delerrlog').'">Vymázání chybových záznamů</a></div>'; 161 } else $Output .= ShowMessage('Nemáte oprávnění.', MESSAGE_CRITICAL); 162 163 return($Output); 164 } 165 166 function DeleteErrorLog() 51 167 { 52 $Output = '<strong>Filtr: </strong>'. 53 '<span style="color:black"><a href="log.php?type=" title="Bez filtrování">Všechny</a></span> '; 54 $DbResult = $System->Database->query('SELECT * FROM `LogType`'); 55 while($LogType = $DbResult->fetch_assoc()) 56 { 57 $Output .= '<a href="log.php?type='.$LogType['Id'].'" style="color:'.$LogType['Color'].'" title="'.$LogType['Name'].'">'.$LogType['Name'].'</a> '; 58 } 59 // echo ' Formát: datum: text zprávy (uživatel, IP)<br /><br />'; 60 $Output .= '<br /><br />'; 61 62 if(array_key_exists('type', $_SESSION)) $Where = ' WHERE '.$WhereType; 63 else 64 { 65 if(array_key_exists('group', $_SESSION)) $Where = ' WHERE `Text` LIKE "%'.$TranslationTree[$_SESSION['group']]['Name'].'%"'; 66 else $Where = ''; 67 } 68 //if(($Where != '') and (array_key_exists('group', $_SESSION))) $Where .= ' AND text LIKE "%'.$TranslationTree[$_SESSION['group']]['Name'].'%"'; 69 70 $DbResult = $System->Database->query('SELECT COUNT(*) FROM `Log` '.$Where); 71 $DbRow = $DbResult->fetch_row(); 72 $PageList = GetPageList($DbRow[0]); 73 74 $Output .= $PageList['Output']; 75 76 $TableColumns = array( 77 array('Name' => 'Date', 'Title' => 'Čas'), 78 array('Name' => 'LogName', 'Title' => 'Typ'), 79 array('Name' => 'Text', 'Title' => 'Text'), 80 array('Name' => 'UserName', 'Title' => 'Uživatel'), 81 array('Name' => 'IP', 'Title' => 'Adresa'), 82 ); 83 $Order = GetOrderTableHeader($TableColumns, 'date', 1); 84 $Output .= '<table width="98%" class="BaseTable">'. 85 $Order['Output']; 86 87 $sql = 'SELECT *, `LogType`.`Color` AS `LogColor`, `LogType`.`Name` AS `LogName`, '. 88 '(SELECT `User`.`Name` FROM `User` WHERE `User`.`ID` = `Log`.`User`) AS `UserName` FROM `Log` LEFT JOIN `LogType` ON `LogType`.`Id`=`Log`.`Type` '.$Where.$Order['SQL'].$PageList['SQLLimit']; 89 $DbResult = $System->Database->query($sql); 90 while($Line = $DbResult->fetch_assoc()) 91 { 92 if($Line['Type'] == LOG_TYPE_ERROR) $Line['Text'] = htmlspecialchars($Line['Text']); 93 $Line['Text'] = str_replace("\n", '<br>', $Line['Text']); 94 $Output .= '<tr><td>'.$Line['Date'].'</td>'. 95 '<td>'.$Line['LogName'].'</td>'. 96 '<td><span style="color: '.$Line['LogColor'].'">'.$Line['Text'].'</span></td>'. 97 '<td><a href="user.php?user='.$Line['User'].'">'.$Line['UserName'].'</a></td>'. 98 '<td>'.$Line['IP'].'</td></tr>'; 168 if($this->System->User->Licence(LICENCE_ADMIN)) 169 { 170 $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM `Log` WHERE `Type`='.LOG_TYPE_ERROR); 171 $DbRow = $DbResult->fetch_row(); 172 $this->System->Database->query('DELETE FROM `Log` WHERE `Type`='.LOG_TYPE_ERROR); 173 WriteLog('Vymazány chybové záznamy', LOG_TYPE_ADMINISTRATION); 174 $Output = ShowMessage('Smazáno všech '.$DbRow[0].' chybových záznamů.'); 175 $Output .= $this->ShowList(); 176 return($Output); 177 } else $Output .= ShowMessage('Nemáte oprávnění.', MESSAGE_CRITICAL); 99 178 } 100 $Output .= '</table>'.101 $PageList['Output'];102 } else $Output .= ShowMessage('Nemáte oprávnění.', MESSAGE_CRITICAL);103 104 ShowPage($Output);105 179 } -
trunk/admin/index.php
r562 r566 19 19 '<a href="'.$System->Link('/admin/?action=img_level').'">Generování obrázků úrovní překladatelů</a><br/>'. 20 20 '<small>Ihned provede přegenerování všech obrázků úrovní překladatelů</small><br/><br/>'. 21 '<a href="'.$System->Link('/admin/?action=delerrlog').'">Vymázání chybových záznamů</a><br/>'.22 '<small>Provede vymazání všech chybových záznamů v logu</small><br/><br/>'.23 21 '<a href="'.$System->Link('/news/?a=add').'">Přidání aktuality</a><br/>'. 24 22 '<small>Přidá aktulitu na hlavní stranu projektu</small><br/><br/>'. … … 26 24 '<small>Testovací funkce</small><br/><br/>'; 27 25 return($Output); 28 }29 30 function DeleteErrorLog()31 {32 global $System;33 34 $DbResult = $System->Database->query('SELECT COUNT(*) FROM `Log` WHERE `Type`='.LOG_TYPE_ERROR);35 $DbRow = $DbResult->fetch_row();36 $System->Database->query('DELETE FROM `Log` WHERE `Type`='.LOG_TYPE_ERROR);37 WriteLog('Vymazány chybové záznamy', LOG_TYPE_ADMINISTRATION);38 $Output = ShowMessage('Smazáno všech '.$DbRow[0].' chybových záznamů.');39 return($Output);40 26 } 41 27 … … 83 69 { 84 70 if($_GET['action'] == 'img_level') $Output .= ImgLevelShow(); 85 else if($_GET['action'] == 'delerrlog') $Output .= DeleteErrorLog();86 71 else if($_GET['action'] == 'error') $Output .= TestError(12, 'test'); 87 72 else if($_GET['action'] == 'exception') $Output .= TestException(12, 'test'); -
trunk/includes/Page.php
r563 r566 236 236 var $System; 237 237 var $Database; 238 var $RawPage; 238 239 239 240 function __construct($System) 240 241 { 241 242 $this->System = &$System; 242 $this->Database = &$System->Database; 243 $this->Database = &$System->Database; 244 $this->RawPage = false; 243 245 } 244 246 … … 251 253 { 252 254 $Output = $this->Show(); 253 $Output = ShowPage($Output); 255 if($this->RawPage == false) $Output = ShowPage($Output); 256 else echo($Output); 254 257 return($Output); 255 258 } -
trunk/includes/Version.php
r565 r566 1 1 <?php 2 2 3 $Revision = 56 5; // Subversion revision3 $Revision = 566; // Subversion revision 4 4 $DatabaseRevision = 543; // Database structure revision 5 5 $ReleaseTime = '2013-08-20'; -
trunk/includes/global.php
r563 r566 14 14 // Include application modules 15 15 // TODO: Make modules configurable 16 include_once(dirname(__FILE__).'/../Modules/Log/Log.php'); 16 17 include_once(dirname(__FILE__).'/../Modules/Translation/Translation.php'); 17 18 include_once(dirname(__FILE__).'/../Modules/AoWoW/AoWoW.php'); … … 69 70 70 71 // Initialize application modules 72 $System->ModuleManager->RegisterModule(new ModuleLog($System)); 71 73 $System->ModuleManager->RegisterModule(new ModuleUser($System)); 72 74 $System->ModuleManager->RegisterModule(new ModuleAoWoW($System)); … … 331 333 332 334 $Moderators = array('Překladatel', 'Moderátor', 'Administrátor'); 333 334 function WriteLog($Text, $Type)335 {336 global $System, $User;337 338 if(!isset($_SERVER['REMOTE_ADDR'])) $IP = 'Konzole';339 else $IP = addslashes($_SERVER['REMOTE_ADDR']);340 341 if(!is_null($User->Id)) $UserId = $User->Id;342 else $UserId = 'NULL';343 $Query = 'INSERT INTO `Log` ( `User` , `Type` , `Text` , `Date` , `IP` )344 VALUES ('.$UserId.', '.$Type.', "'.addslashes($Text).'", NOW(), "'.$IP.'")';345 $System->Database->query($Query);346 }347 335 348 336 function HumanDate($SQLDateTime)
Note:
See TracChangeset
for help on using the changeset viewer.