00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00036 unset($MCONF);
00037 require ('conf.php');
00038 require ($BACK_PATH.'init.php');
00039 require ($BACK_PATH.'template.php');
00040 $LANG->includeLLFile('EXT:belog/mod/locallang.php');
00041 require_once (PATH_t3lib.'class.t3lib_bedisplaylog.php');
00042 require_once (PATH_t3lib.'class.t3lib_pagetree.php');
00043
00044 $BE_USER->modAccess($MCONF,1);
00045
00046
00047
00048
00056 class SC_mod_tools_log_index {
00057 var $MCONF=array();
00058 var $MOD_MENU=array();
00059 var $MOD_SETTINGS=array();
00060 var $doc;
00061
00062 var $content;
00063 var $lF;
00064 var $be_user_Array;
00065
00071 function init() {
00072 global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$CLIENT,$TYPO3_CONF_VARS;
00073 $this->MCONF = $GLOBALS['MCONF'];
00074
00075 $this->lF = t3lib_div::makeInstance('t3lib_BEDisplayLog');
00076 $this->menuConfig();
00077
00078 $this->doc = t3lib_div::makeInstance('noDoc');
00079 $this->doc->backPath = $BACK_PATH;
00080
00081
00082 $this->doc->JScode = '
00083 <script language="javascript" type="text/javascript">
00084 script_ended = 0;
00085 function jumpToUrl(URL) {
00086 window.location.href = URL;
00087 }
00088 </script>
00089 ';
00090
00091 $this->doc->tableLayout = Array (
00092 '0' => Array (
00093 '0' => Array('<td valign="top"><b>','</b></td>'),
00094 'defCol' => Array('<td><img src="'.$this->doc->backPath.'clear.gif" width="10" height="1"></td><td valign="top"><b>','</b></td>')
00095 ),
00096 'defRow' => Array (
00097 '0' => Array('<td valign="top">','</td>'),
00098 'defCol' => Array('<td><img src="'.$this->doc->backPath.'clear.gif" width="10" height="1"></td><td valign="top">','</td>')
00099 )
00100 );
00101 $this->doc->form = '<form action="" method="post">';
00102
00103 $this->be_user_Array = t3lib_BEfunc::getUserNames();
00104 $this->lF->be_user_Array = &$this->be_user_Array;
00105 }
00106
00112 function menuConfig() {
00113 global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$CLIENT,$TYPO3_CONF_VARS;
00114
00115
00116
00117
00118
00119 $this->MOD_MENU = array(
00120 'users' => array(
00121 0 => 'All users',
00122 '-1' => 'Self'
00123 ),
00124 'time' => array(
00125 0 => 'This week',
00126 1 => 'Last week',
00127 2 => 'Last 7 days',
00128 10 => 'This month',
00129 11 => 'Last month',
00130 12 => 'Last 31 days',
00131 20 => 'No limit'
00132 ),
00133 'max' => array(
00134 20 => '20',
00135 50 => '50',
00136 100 => '100',
00137 200 => '200',
00138 500 => '500'
00139 ),
00140 'action' => array(
00141 0 => 'All',
00142 1 => 'Database',
00143 2 => 'File',
00144 254 => 'Settings',
00145 255 => 'Login',
00146 '-1' => 'Errors'
00147 )
00148 );
00149
00150
00151 $groups = t3lib_BEfunc::getGroupNames();
00152 if (is_array($groups)) {
00153 while(list(,$grVals)=each($groups)) {
00154 $this->MOD_MENU['users'][$grVals['uid']] = 'Group: '.$grVals['title'];
00155 }
00156 }
00157
00158
00159 $this->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU, t3lib_div::_GP('SET'), $this->MCONF['name']);
00160 }
00161
00167 function main() {
00168 global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$CLIENT,$TYPO3_CONF_VARS;
00169
00170 $this->content.=$this->doc->startPage('Administration log');
00171 $this->content.=$this->doc->header('Administration log');
00172 $this->content.=$this->doc->spacer(5);
00173
00174
00175
00176 $menuU= t3lib_BEfunc::getFuncMenu(0,'SET[users]',$this->MOD_SETTINGS['users'],$this->MOD_MENU['users']);
00177 $menuM= t3lib_BEfunc::getFuncMenu(0,'SET[max]',$this->MOD_SETTINGS['max'],$this->MOD_MENU['max']);
00178 $menuT= t3lib_BEfunc::getFuncMenu(0,'SET[time]',$this->MOD_SETTINGS['time'],$this->MOD_MENU['time']);
00179 $menuA= t3lib_BEfunc::getFuncMenu(0,'SET[action]',$this->MOD_SETTINGS['action'],$this->MOD_MENU['action']);
00180
00181
00182 $this->content.=$this->doc->section('',$this->doc->menuTable(
00183 array(
00184 array('Users:',$menuU),
00185 array('Time:',$menuT)
00186 ),
00187 array(
00188 array('Max:',$menuM),
00189 array('Action:',$menuA)
00190 )
00191 ));
00192 $this->content.=$this->doc->divider(5);
00193
00194
00195 $codeArr = $this->lF->initArray();
00196 $oldHeader='';
00197 $c=0;
00198
00199
00200 $where_part='';
00201 if ($this->MOD_SETTINGS['action'] > 0) {
00202 $where_part.=' AND type='.intval($this->MOD_SETTINGS['action']);
00203 } elseif ($this->MOD_SETTINGS['action'] == -1) {
00204 $where_part.=' AND error';
00205 }
00206
00207
00208 $starttime=0;
00209 $endtime=time();
00210
00211
00212 switch($this->MOD_SETTINGS['time']) {
00213 case 0:
00214
00215 $week = (date('w') ? date('w') : 7)-1;
00216 $starttime = mktime (0,0,0)-$week*3600*24;
00217 break;
00218 case 1:
00219
00220 $week = (date('w') ? date('w') : 7)-1;
00221 $starttime = mktime (0,0,0)-($week+7)*3600*24;
00222 $endtime = mktime (0,0,0)-$week*3600*24;
00223 break;
00224 case 2:
00225
00226 $starttime = mktime (0,0,0)-7*3600*24;
00227 break;
00228 case 10:
00229
00230 $starttime = mktime (0,0,0, date('m'),1);
00231 break;
00232 case 11:
00233
00234 $starttime = mktime (0,0,0, date('m')-1,1);
00235 $endtime = mktime (0,0,0, date('m'),1);
00236 break;
00237 case 12:
00238
00239 $starttime = mktime (0,0,0)-31*3600*24;
00240 break;
00241 }
00242 if ($starttime) {
00243 $where_part.=' AND tstamp>='.$starttime.' AND tstamp<'.$endtime;
00244 }
00245
00246
00247
00248 if ($this->MOD_SETTINGS['users'] > 0) {
00249 $this->be_user_Array = t3lib_BEfunc::blindUserNames($this->be_user_Array,array($this->MOD_SETTINGS['users']),1);
00250 if (is_array($this->be_user_Array)) {
00251 while(list(,$val)=each($this->be_user_Array)) {
00252 if ($val['uid']!=$BE_USER->user['uid']) {
00253 $selectUsers[]=$val['uid'];
00254 }
00255 }
00256 }
00257 $selectUsers[] = 0;
00258 $where_part.=' AND userid in ('.implode($selectUsers,',').')';
00259 } elseif ($this->MOD_SETTINGS['users']==-1) {
00260 $where_part.=' AND userid='.$BE_USER->user['uid'];
00261 }
00262
00263 if ($GLOBALS['BE_USER']->workspace!==0) {
00264 $where_part.=' AND workspace='.intval($GLOBALS['BE_USER']->workspace);
00265 }
00266
00267
00268
00269
00270 $log = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'sys_log', '1=1'.$where_part, '', 'uid DESC', intval($this->MOD_SETTINGS['max']));
00271
00272 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($log)) {
00273 $header=$this->doc->formatTime($row['tstamp'],10);
00274 if (!$oldHeader) $oldHeader=$header;
00275
00276 if ($header!=$oldHeader) {
00277 $this->content.=$this->doc->spacer(10);
00278 $this->content.=$this->doc->section($oldHeader,$this->doc->table($codeArr));
00279 $codeArr=$this->lF->initArray();
00280 $oldHeader=$header;
00281 $this->lF->reset();
00282 }
00283
00284 $i++;
00285 $codeArr[$i][]=$this->lF->getTimeLabel($row['tstamp']);
00286 $codeArr[$i][]=$this->lF->getUserLabel($row['userid'],$row['workspace']);
00287 $codeArr[$i][]=$this->lF->getTypeLabel($row['type']);
00288 $codeArr[$i][]=$row['error'] ? $this->lF->getErrorFormatting($this->lF->errorSign[$row['error']],$row['error']) : '';
00289 $codeArr[$i][]=$this->lF->getActionLabel($row['type'].'_'.$row['action']);
00290 $codeArr[$i][]=$this->lF->formatDetailsForList($row);
00291 }
00292 $this->content.=$this->doc->spacer(10);
00293 $this->content.=$this->doc->section($header,$this->doc->table($codeArr));
00294
00295 $GLOBALS['TYPO3_DB']->sql_free_result($log);
00296
00297 if ($BE_USER->mayMakeShortcut()) {
00298 $this->content.=$this->doc->spacer(20).$this->doc->section('',$this->doc->makeShortcutIcon('','users,time,max,action',$this->MCONF['name']));
00299 }
00300 }
00301
00307 function printContent() {
00308
00309 $this->content.=$this->doc->spacer(20);
00310 $this->content.=$this->doc->endPage();
00311 echo $this->content;
00312 }
00313 }
00314
00315
00316 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/belog/mod/index.php']) {
00317 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/belog/mod/index.php']);
00318 }
00319
00320
00321
00322
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332 $SOBE = t3lib_div::makeInstance('SC_mod_tools_log_index');
00333 $SOBE->init();
00334 $SOBE->main();
00335 $SOBE->printContent();
00336 ?>