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
00066 var $doc;
00067
00068 var $content;
00069 var $lF;
00070 var $be_user_Array;
00071
00077 function init() {
00078 global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$CLIENT,$TYPO3_CONF_VARS;
00079 $this->MCONF = $GLOBALS['MCONF'];
00080
00081 $this->lF = t3lib_div::makeInstance('t3lib_BEDisplayLog');
00082 $this->menuConfig();
00083
00084 $this->doc = t3lib_div::makeInstance('noDoc');
00085 $this->doc->backPath = $BACK_PATH;
00086
00087
00088 $this->doc->JScode = '
00089 <script language="javascript" type="text/javascript">
00090 script_ended = 0;
00091 function jumpToUrl(URL) {
00092 window.location.href = URL;
00093 }
00094 </script>
00095 ';
00096
00097 $this->doc->tableLayout = Array (
00098 '0' => Array (
00099 '0' => Array('<td valign="top"><b>','</b></td>'),
00100 'defCol' => Array('<td><img src="'.$this->doc->backPath.'clear.gif" width="10" height="1"></td><td valign="top"><b>','</b></td>')
00101 ),
00102 'defRow' => Array (
00103 '0' => Array('<td valign="top">','</td>'),
00104 'defCol' => Array('<td><img src="'.$this->doc->backPath.'clear.gif" width="10" height="1"></td><td valign="top">','</td>')
00105 )
00106 );
00107 $this->doc->form = '<form action="" method="post">';
00108
00109 $this->be_user_Array = t3lib_BEfunc::getUserNames();
00110 $this->lF->be_user_Array = &$this->be_user_Array;
00111 }
00112
00118 function menuConfig() {
00119 global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$CLIENT,$TYPO3_CONF_VARS;
00120
00121
00122
00123
00124
00125 $this->MOD_MENU = array(
00126 'users' => array(
00127 0 => 'All users',
00128 '-1' => 'Self'
00129 ),
00130 'time' => array(
00131 0 => 'This week',
00132 1 => 'Last week',
00133 2 => 'Last 7 days',
00134 10 => 'This month',
00135 11 => 'Last month',
00136 12 => 'Last 31 days',
00137 20 => 'No limit'
00138 ),
00139 'max' => array(
00140 20 => '20',
00141 50 => '50',
00142 100 => '100',
00143 200 => '200',
00144 500 => '500'
00145 ),
00146 'action' => array(
00147 0 => 'All',
00148 1 => 'Database',
00149 2 => 'File',
00150 254 => 'Settings',
00151 255 => 'Login',
00152 '-1' => 'Errors'
00153 )
00154 );
00155
00156
00157 $groups = t3lib_BEfunc::getGroupNames();
00158 if (is_array($groups)) {
00159 while(list(,$grVals)=each($groups)) {
00160 $this->MOD_MENU['users'][$grVals['uid']] = 'Group: '.$grVals['title'];
00161 }
00162 }
00163
00164
00165 $this->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU, t3lib_div::_GP('SET'), $this->MCONF['name']);
00166 }
00167
00173 function main() {
00174 global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$CLIENT,$TYPO3_CONF_VARS;
00175
00176 $this->content.=$this->doc->startPage('Administration log');
00177 $this->content.=$this->doc->header('Administration log');
00178 $this->content.=$this->doc->spacer(5);
00179
00180
00181
00182 $menuU= t3lib_BEfunc::getFuncMenu(0,'SET[users]',$this->MOD_SETTINGS['users'],$this->MOD_MENU['users']);
00183 $menuM= t3lib_BEfunc::getFuncMenu(0,'SET[max]',$this->MOD_SETTINGS['max'],$this->MOD_MENU['max']);
00184 $menuT= t3lib_BEfunc::getFuncMenu(0,'SET[time]',$this->MOD_SETTINGS['time'],$this->MOD_MENU['time']);
00185 $menuA= t3lib_BEfunc::getFuncMenu(0,'SET[action]',$this->MOD_SETTINGS['action'],$this->MOD_MENU['action']);
00186
00187
00188 $this->content.=$this->doc->section('',$this->doc->menuTable(
00189 array(
00190 array('Users:',$menuU),
00191 array('Time:',$menuT)
00192 ),
00193 array(
00194 array('Max:',$menuM),
00195 array('Action:',$menuA)
00196 )
00197 ));
00198 $this->content.=$this->doc->divider(5);
00199
00200
00201 $codeArr = $this->lF->initArray();
00202 $oldHeader='';
00203 $c=0;
00204
00205
00206 $where_part='';
00207 if ($this->MOD_SETTINGS['action'] > 0) {
00208 $where_part.=' AND type='.intval($this->MOD_SETTINGS['action']);
00209 } elseif ($this->MOD_SETTINGS['action'] == -1) {
00210 $where_part.=' AND error';
00211 }
00212
00213
00214 $starttime=0;
00215 $endtime=time();
00216
00217
00218 switch($this->MOD_SETTINGS['time']) {
00219 case 0:
00220
00221 $week = (date('w') ? date('w') : 7)-1;
00222 $starttime = mktime (0,0,0)-$week*3600*24;
00223 break;
00224 case 1:
00225
00226 $week = (date('w') ? date('w') : 7)-1;
00227 $starttime = mktime (0,0,0)-($week+7)*3600*24;
00228 $endtime = mktime (0,0,0)-$week*3600*24;
00229 break;
00230 case 2:
00231
00232 $starttime = mktime (0,0,0)-7*3600*24;
00233 break;
00234 case 10:
00235
00236 $starttime = mktime (0,0,0, date('m'),1);
00237 break;
00238 case 11:
00239
00240 $starttime = mktime (0,0,0, date('m')-1,1);
00241 $endtime = mktime (0,0,0, date('m'),1);
00242 break;
00243 case 12:
00244
00245 $starttime = mktime (0,0,0)-31*3600*24;
00246 break;
00247 }
00248 if ($starttime) {
00249 $where_part.=' AND tstamp>='.$starttime.' AND tstamp<'.$endtime;
00250 }
00251
00252
00253
00254 if ($this->MOD_SETTINGS['users'] > 0) {
00255 $this->be_user_Array = t3lib_BEfunc::blindUserNames($this->be_user_Array,array($this->MOD_SETTINGS['users']),1);
00256 if (is_array($this->be_user_Array)) {
00257 while(list(,$val)=each($this->be_user_Array)) {
00258 if ($val['uid']!=$BE_USER->user['uid']) {
00259 $selectUsers[]=$val['uid'];
00260 }
00261 }
00262 }
00263 $selectUsers[] = 0;
00264 $where_part.=' AND userid in ('.implode($selectUsers,',').')';
00265 } elseif ($this->MOD_SETTINGS['users']==-1) {
00266 $where_part.=' AND userid='.$BE_USER->user['uid'];
00267 }
00268
00269 if ($GLOBALS['BE_USER']->workspace!==0) {
00270 $where_part.=' AND workspace='.intval($GLOBALS['BE_USER']->workspace);
00271 }
00272
00273
00274
00275
00276 $log = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'sys_log', '1=1'.$where_part, '', 'uid DESC', intval($this->MOD_SETTINGS['max']));
00277
00278 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($log)) {
00279 $header=$this->doc->formatTime($row['tstamp'],10);
00280 if (!$oldHeader) $oldHeader=$header;
00281
00282 if ($header!=$oldHeader) {
00283 $this->content.=$this->doc->spacer(10);
00284 $this->content.=$this->doc->section($oldHeader,$this->doc->table($codeArr));
00285 $codeArr=$this->lF->initArray();
00286 $oldHeader=$header;
00287 $this->lF->reset();
00288 }
00289
00290 $i++;
00291 $codeArr[$i][]=$this->lF->getTimeLabel($row['tstamp']);
00292 $codeArr[$i][]=$this->lF->getUserLabel($row['userid'],$row['workspace']);
00293 $codeArr[$i][]=$this->lF->getTypeLabel($row['type']);
00294 $codeArr[$i][]=$row['error'] ? $this->lF->getErrorFormatting($this->lF->errorSign[$row['error']],$row['error']) : '';
00295 $codeArr[$i][]=$this->lF->getActionLabel($row['type'].'_'.$row['action']);
00296 $codeArr[$i][]=$this->lF->formatDetailsForList($row);
00297 }
00298 $this->content.=$this->doc->spacer(10);
00299 $this->content.=$this->doc->section($header,$this->doc->table($codeArr));
00300
00301 $GLOBALS['TYPO3_DB']->sql_free_result($log);
00302
00303 if ($BE_USER->mayMakeShortcut()) {
00304 $this->content.=$this->doc->spacer(20).$this->doc->section('',$this->doc->makeShortcutIcon('','users,time,max,action',$this->MCONF['name']));
00305 }
00306 }
00307
00313 function printContent() {
00314
00315 $this->content.=$this->doc->spacer(20);
00316 $this->content.=$this->doc->endPage();
00317 echo $this->content;
00318 }
00319 }
00320
00321
00322 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/belog/mod/index.php']) {
00323 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/belog/mod/index.php']);
00324 }
00325
00326
00327
00328
00329
00330
00331
00332
00333
00334
00335
00336
00337
00338 $SOBE = t3lib_div::makeInstance('SC_mod_tools_log_index');
00339 $SOBE->init();
00340 $SOBE->main();
00341 $SOBE->printContent();
00342 ?>