423b7ea8a5c84947357f9fe624d47823ccdbd12f
[Packages/TYPO3.CMS.git] / typo3 / sysext / integrity / Classes / SyslogCommand.php
1 <?php
2 namespace TYPO3\CMS\Integrity;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 2007-2011 Kasper Skårhøj (kasperYYYY@typo3.com)
8 * All rights reserved
9 *
10 * This script is part of the TYPO3 project. The TYPO3 project is
11 * free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * The GNU General Public License can be found at
17 * http://www.gnu.org/copyleft/gpl.html.
18 * A copy is found in the textfile GPL.txt and important notices to the license
19 * from the author is found in LICENSE.txt distributed with these scripts.
20 *
21 *
22 * This script is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
26 *
27 * This copyright notice MUST APPEAR in all copies of the script!
28 ***************************************************************/
29 /**
30 * Cleaner module: syslog
31 * User function called from tx_lowlevel_cleaner_core configured in ext_localconf.php
32 *
33 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
34 */
35 /**
36 * syslog
37 *
38 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
39 * @package TYPO3
40 * @subpackage tx_lowlevel
41 */
42 class SyslogCommand extends \TYPO3\CMS\Integrity\CleanerCommand {
43
44 /**
45 * Constructor
46 *
47 * @todo Define visibility
48 */
49 public function __construct() {
50 parent::__construct();
51 $this->cli_help['name'] = 'syslog -- Show entries from syslog';
52 $this->cli_help['description'] = trim('
53 Showing last 25 hour entries from the syslog. More features pending. This is the most basic and can be useful for nightly check test reports.
54 ');
55 $this->cli_help['examples'] = '';
56 }
57
58 /**
59 * Find syslog
60 *
61 * @return array
62 * @todo Define visibility
63 */
64 public function main() {
65 global $TYPO3_DB;
66 // Initialize result array:
67 $resultArray = array(
68 'message' => $this->cli_help['name'] . LF . LF . $this->cli_help['description'],
69 'headers' => array(
70 'listing' => array('', '', 1),
71 'allDetails' => array('', '', 0)
72 ),
73 'listing' => array(),
74 'allDetails' => array()
75 );
76 $rows = $TYPO3_DB->exec_SELECTgetRows('*', 'sys_log', 'tstamp>' . ($GLOBALS['EXEC_TIME'] - 25 * 3600));
77 foreach ($rows as $r) {
78 $l = unserialize($r['log_data']);
79 $explained = '#' . $r['uid'] . ' ' . \TYPO3\CMS\Backend\Utility\BackendUtility::datetime($r['tstamp']) . ' USER[' . $r['userid'] . ']: ' . sprintf($r['details'], $l[0], $l[1], $l[2], $l[3], $l[4], $l[5]);
80 $resultArray['listing'][$r['uid']] = $explained;
81 $resultArray['allDetails'][$r['uid']] = array($explained, \TYPO3\CMS\Core\Utility\GeneralUtility::arrayToLogString($r, 'uid,userid,action,recuid,tablename,recpid,error,tstamp,type,details_nr,IP,event_pid,NEWid,workspace'));
82 }
83 return $resultArray;
84 }
85
86 /**
87 * Mandatory autofix function
88 * Will run auto-fix on the result array. Echos status during processing.
89 *
90 * @param array Result array from main() function
91 * @return void
92 * @todo Define visibility
93 */
94 public function main_autoFix($resultArray) {
95
96 }
97
98 }
99
100
101 ?>