Changeset 880 for trunk/Modules/Log/Log.php
- Timestamp:
- Apr 7, 2020, 10:15:48 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/Log/Log.php
r861 r880 33 33 function WriteLog($Text, $Type) 34 34 { 35 if (isset($this->System->User) and !is_null($this->System->User->Id))35 if (isset($this->System->User) and !is_null($this->System->User->Id)) 36 36 $UserId = $this->System->User->Id; 37 37 else $UserId = 'NULL'; … … 60 60 global $System, $User; 61 61 62 if (isset($User) and !is_null($User->Id)) $UserId = $User->Id;62 if (isset($User) and !is_null($User->Id)) $UserId = $User->Id; 63 63 else $UserId = 'NULL'; 64 64 $Query = 'INSERT INTO `Log` ( `User` , `Type` , `Text` , `Date` , `IP`, `URL` ) '. … … 75 75 $Output = ''; 76 76 $Items = array(); 77 if (array_key_exists('type', $_GET)) $Where = ' WHERE `Type` = "'.($_GET['type'] * 1).'"';77 if (array_key_exists('type', $_GET)) $Where = ' WHERE `Type` = "'.($_GET['type'] * 1).'"'; 78 78 else $Where = ''; 79 79 $sql = 'SELECT *, UNIX_TIMESTAMP(`Date`) AS `TimeCreate`, (SELECT `User`.`Name` FROM `User` WHERE `User`.`ID` = `Log`.`User`) AS `UserName`, `Date` FROM `Log`'. 80 80 $Where.' ORDER BY `Date` DESC LIMIT 100'; 81 81 $DbResult = $this->System->Database->query($sql); 82 while ($Line = $DbResult->fetch_assoc())82 while ($Line = $DbResult->fetch_assoc()) 83 83 { 84 84 $DbResult2 = $this->System->Database->query('SELECT * FROM `LogType` WHERE `Id`='.$Line['Type']); 85 85 $LogType = $DbResult2->fetch_assoc(); 86 86 87 if ($Line['Type'] == LOG_TYPE_ERROR) $Line['Text'] = htmlspecialchars($Line['Text']);87 if ($Line['Type'] == LOG_TYPE_ERROR) $Line['Text'] = htmlspecialchars($Line['Text']); 88 88 $Line['Text'] = str_replace("\n", '<br>', $Line['Text']); 89 89 … … 106 106 'Items' => $Items, 107 107 )); 108 return ($Output);108 return $Output; 109 109 } 110 110 111 111 function Show() 112 112 { 113 if (array_key_exists('a', $_POST)) $Action = $_POST['a'];114 else if (array_key_exists('a', $_GET)) $Action = $_GET['a'];113 if (array_key_exists('a', $_POST)) $Action = $_POST['a']; 114 else if (array_key_exists('a', $_GET)) $Action = $_GET['a']; 115 115 else $Action = ''; 116 if ($Action == 'delerrlog') $Output = $this->DeleteErrorLog();116 if ($Action == 'delerrlog') $Output = $this->DeleteErrorLog(); 117 117 else $Output = $this->ShowList(); 118 return ($Output);118 return $Output; 119 119 } 120 120 … … 125 125 $this->Title = T('System log'); 126 126 $Output = ''; 127 if (array_key_exists('type', $_GET)) $_SESSION['type'] = $_GET['type'] * 1;128 else if (!array_key_exists('type', $_SESSION)) $_SESSION['type'] = '';129 130 if (array_key_exists('group', $_GET)) $_SESSION['group'] = $_GET['group'];131 132 if ($_SESSION['type'] != '') $WhereType = ' (`Type`='.$_SESSION['type'].')';127 if (array_key_exists('type', $_GET)) $_SESSION['type'] = $_GET['type'] * 1; 128 else if (!array_key_exists('type', $_SESSION)) $_SESSION['type'] = ''; 129 130 if (array_key_exists('group', $_GET)) $_SESSION['group'] = $_GET['group']; 131 132 if ($_SESSION['type'] != '') $WhereType = ' (`Type`='.$_SESSION['type'].')'; 133 133 else $WhereType = '1=1'; 134 134 … … 138 138 139 139 // Show category filter 140 if ($this->System->User->Licence(LICENCE_MODERATOR))140 if ($this->System->User->Licence(LICENCE_MODERATOR)) 141 141 { 142 142 $Output = '<strong>'.T('Filter').':</strong>'; 143 143 $Item = '<a href="'.$this->System->Link('/log/?type=').'" title="Bez filtrování">'.T('All').'</a>'; 144 if ($_SESSION['type'] == '') $Item = '<strong>'.$Item.'</strong>';144 if ($_SESSION['type'] == '') $Item = '<strong>'.$Item.'</strong>'; 145 145 $Output .= ' '.$Item; 146 146 $DbResult = $this->System->Database->query('SELECT * FROM `LogType`'); 147 while ($LogType = $DbResult->fetch_assoc())147 while ($LogType = $DbResult->fetch_assoc()) 148 148 { 149 149 $Item = '<a href="'.$this->System->Link('/log/?type='.$LogType['Id']).'" style="color:'. 150 150 $LogType['Color'].'" title="'.$LogType['Name'].'">'.T($LogType['Name']).'</a>'; 151 if ($_SESSION['type'] == $LogType['Id']) $Item = '<strong>'.$Item.'</strong>';151 if ($_SESSION['type'] == $LogType['Id']) $Item = '<strong>'.$Item.'</strong>'; 152 152 $Output .= ' '.$Item; 153 153 } … … 155 155 $Output .= '<br /><br />'; 156 156 157 if (array_key_exists('type', $_SESSION)) $Where = ' WHERE '.$WhereType;157 if (array_key_exists('type', $_SESSION)) $Where = ' WHERE '.$WhereType; 158 158 else 159 159 { 160 if (array_key_exists('group', $_SESSION)) $Where = ' WHERE `Text` LIKE "%'.$TranslationTree[$_SESSION['group']]['Name'].'%"';160 if (array_key_exists('group', $_SESSION)) $Where = ' WHERE `Text` LIKE "%'.$TranslationTree[$_SESSION['group']]['Name'].'%"'; 161 161 else $Where = ''; 162 162 } 163 //if (($Where != '') and (array_key_exists('group', $_SESSION))) $Where .= ' AND text LIKE "%'.$TranslationTree[$_SESSION['group']]['Name'].'%"';163 //if (($Where != '') and (array_key_exists('group', $_SESSION))) $Where .= ' AND text LIKE "%'.$TranslationTree[$_SESSION['group']]['Name'].'%"'; 164 164 165 165 $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM `Log` '.$Where); … … 172 172 array('Name' => 'Date', 'Title' => T('Time')), 173 173 ); 174 if ($_SESSION['type'] == '') $TableColumns[] =174 if ($_SESSION['type'] == '') $TableColumns[] = 175 175 array('Name' => 'LogName', 'Title' => T('Type')); 176 176 $TableColumns = array_merge($TableColumns, array( … … 187 187 '(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']; 188 188 $DbResult = $this->System->Database->query($sql); 189 while ($Line = $DbResult->fetch_assoc())190 { 191 if ($Line['Type'] == LOG_TYPE_ERROR) $Line['Text'] = htmlspecialchars($Line['Text']);189 while ($Line = $DbResult->fetch_assoc()) 190 { 191 if ($Line['Type'] == LOG_TYPE_ERROR) $Line['Text'] = htmlspecialchars($Line['Text']); 192 192 $Line['Text'] = str_replace("\n", '<br/>', $Line['Text']); 193 193 $Output .= '<tr><td>'.$Line['Date'].'</td>'; 194 if ($_SESSION['type'] == '') $Output .= '<td>'.T($Line['LogName']).'</td>';194 if ($_SESSION['type'] == '') $Output .= '<td>'.T($Line['LogName']).'</td>'; 195 195 $Output .= '<td><span style="color: '.$Line['LogColor'].'">'.$Line['Text'].'</span></td>'. 196 196 '<td><a href="'.$this->System->Link('/user/?user='.$Line['User']).'">'.$Line['UserName'].'</a></td>'. … … 200 200 $Output .= '</table>'. 201 201 $PageList['Output']; 202 if ($this->System->User->Licence(LICENCE_ADMIN))202 if ($this->System->User->Licence(LICENCE_ADMIN)) 203 203 { 204 204 $Output .= '<div>'.T('Remove').': <a href="'.$this->System->Link('/log/?a=delerrlog&type='.LOG_TYPE_ERROR).'">'.T('Error logs').'</a> '. … … 207 207 } else $Output .= ShowMessage(T('Access denied'), MESSAGE_CRITICAL); 208 208 209 return ($Output);209 return $Output; 210 210 } 211 211 212 212 function DeleteErrorLog() 213 213 { 214 if ($this->System->User->Licence(LICENCE_ADMIN) and214 if ($this->System->User->Licence(LICENCE_ADMIN) and 215 215 (($_GET['type'] == LOG_TYPE_ERROR) or ($_GET['type'] == LOG_TYPE_PAGE_NOT_FOUND))) 216 216 { … … 223 223 $Output = ShowMessage('Smazáno všech '.$DbRow[0].' záznamů z '.$LogType['Description'].'.'); 224 224 $Output .= $this->ShowList(); 225 return ($Output);225 return $Output; 226 226 } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL); 227 227 }
Note:
See TracChangeset
for help on using the changeset viewer.