Documentation TYPO3 par Ameos

index.php

00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 1999-2005 Kasper Skaarhoj (kasperYYYY@typo3.com)
00006 *  All rights reserved
00007 *
00008 *  This script is part of the TYPO3 project. The TYPO3 project is
00009 *  free software; you can redistribute it and/or modify
00010 *  it under the terms of the GNU General Public License as published by
00011 *  the Free Software Foundation; either version 2 of the License, or
00012 *  (at your option) any later version.
00013 *
00014 *  The GNU General Public License can be found at
00015 *  http://www.gnu.org/copyleft/gpl.html.
00016 *  A copy is found in the textfile GPL.txt and important notices to the license
00017 *  from the author is found in LICENSE.txt distributed with these scripts.
00018 *
00019 *
00020 *  This script is distributed in the hope that it will be useful,
00021 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00022 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023 *  GNU General Public License for more details.
00024 *
00025 *  This copyright notice MUST APPEAR in all copies of the script!
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 
00049 // ***************************
00050 // Script Classes
00051 // ***************************
00052 class SC_mod_tools_log_index {
00053         var $MCONF=array();
00054         var $MOD_MENU=array();
00055         var $MOD_SETTINGS=array();
00056         var $doc;
00057 
00058         var $content;
00059         var $lF;
00060         var $be_user_Array;
00061 
00062         function init() {
00063                 global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$CLIENT,$TYPO3_CONF_VARS;
00064                 $this->MCONF = $GLOBALS["MCONF"];
00065 
00066                 $this->lF = t3lib_div::makeInstance("t3lib_BEDisplayLog");
00067                 $this->menuConfig();
00068 
00069                 $this->doc = t3lib_div::makeInstance("noDoc");
00070                 $this->doc->backPath = $BACK_PATH;
00071                                 // JavaScript
00072                 $this->doc->JScode = '
00073                 <script language="javascript" type="text/javascript">
00074                         script_ended = 0;
00075                         function jumpToUrl(URL) {
00076                                 document.location = URL;
00077                         }
00078                 </script>
00079                 ';
00080                 $this->doc->tableLayout = Array (
00081                         "0" => Array (
00082                                 "0" => Array('<TD valign="top"><b>','</b></td>'),
00083                                 "defCol" => Array('<TD><img src="'.$this->doc->backPath.'clear.gif" width=10 height=1></td><td valign="top"><b>','</b></td>')
00084                         ),
00085                         "defRow" => Array (
00086                                 "0" => Array('<TD valign="top">','</td>'),
00087                                 "defCol" => Array('<TD><img src="'.$this->doc->backPath.'clear.gif" width=10 height=1></td><td valign="top">','</td>')
00088                         )
00089                 );
00090                 $this->doc->form = '<form action="" method="post">';
00091 
00092                 $this->be_user_Array = t3lib_BEfunc::getUserNames();
00093                 $this->lF->be_user_Array = &$this->be_user_Array;
00094         }
00095         function menuConfig()   {
00096                 global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$CLIENT,$TYPO3_CONF_VARS;
00097 
00098                         // MENU-ITEMS:
00099                         // If array, then it's a selector box menu
00100                         // If empty string it's just a variable, that'll be saved.
00101                         // Values NOT in this array will not be saved in the settings-array for the module.
00102                 $this->MOD_MENU = array(
00103                         "users" => array(
00104                                 0 => "All users",
00105                                 "-1" => "Self"
00106                         ),
00107                         "time" => array(
00108                                 0 => "This week",
00109                                 1 => "Last week",
00110                                 2 => "Last 7 days",
00111                                 10 => "This month",
00112                                 11 => "Last month",
00113                                 12 => "Last 31 days",
00114                                 20 => "No limit"
00115                         ),
00116                         "max" => array(
00117                                 20 => "20",
00118                                 50 => "50",
00119                                 100 => "100",
00120                                 200 => "200",
00121                                 500 => "500"
00122                         ),
00123                         "action" => array(
00124                                 0 => "All",
00125                                 1 => "Database",
00126                                 2 => "File",
00127                                 254 => "Settings",
00128                                 255 => "Login",
00129                                 "-1" => "Errors"
00130                         )
00131                 );
00132 
00133                         // Adding groups to the users_array
00134                 $groups = t3lib_BEfunc::getGroupNames();
00135                 if (is_array($groups))  {
00136                         while(list(,$grVals)=each($groups))     {
00137                                 $this->MOD_MENU["users"][$grVals["uid"]] = "Group: ".$grVals["title"];
00138                         }
00139                 }
00140 
00141                         // CLEANSE SETTINGS
00142                 $this->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU, t3lib_div::_GP("SET"), $this->MCONF["name"]);
00143         }
00144         function main() {
00145                 global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$CLIENT,$TYPO3_CONF_VARS;
00146 
00147                 $this->content.=$this->doc->startPage("Administration log");
00148                 $this->content.=$this->doc->header("Administration log");
00149                 $this->content.=$this->doc->spacer(5);
00150 
00151 
00152                 // Example of a menu!
00153                         $menuU= t3lib_BEfunc::getFuncMenu(0,"SET[users]",$this->MOD_SETTINGS["users"],$this->MOD_MENU["users"]);
00154                         $menuM= t3lib_BEfunc::getFuncMenu(0,"SET[max]",$this->MOD_SETTINGS["max"],$this->MOD_MENU["max"]);
00155                         $menuT= t3lib_BEfunc::getFuncMenu(0,"SET[time]",$this->MOD_SETTINGS["time"],$this->MOD_MENU["time"]);
00156                         $menuA= t3lib_BEfunc::getFuncMenu(0,"SET[action]",$this->MOD_SETTINGS["action"],$this->MOD_MENU["action"]);
00157 
00158 
00159                         $this->content.=$this->doc->section("",$this->doc->menuTable(
00160                                 array(
00161                                         array(fw("Users:"),$menuU),
00162                                         array(fw("Time:"),$menuT)
00163                                 ),
00164                                 array(
00165                                         array(fw("Max:"),$menuM),
00166                                         array(fw("Action:"),$menuA)
00167                                 )
00168                         ));
00169                         $this->content.=$this->doc->divider(5);
00170 
00171 
00172                 $codeArr = $this->lF->initArray();
00173                 $oldHeader="";
00174                 $c=0;
00175 
00176                 // Action (type):
00177                 $where_part="";
00178                 if ($this->MOD_SETTINGS["action"] > 0)  {
00179                         $where_part.=" AND type=".intval($this->MOD_SETTINGS["action"]);
00180                 } elseif ($this->MOD_SETTINGS["action"] == -1)  {
00181                         $where_part.=" AND error";
00182                 }
00183 
00184 
00185                 $starttime=0;
00186                 $endtime=time();
00187 
00188                 // Time:
00189                 switch($this->MOD_SETTINGS["time"])             {
00190                         case 0:
00191                                 // This week
00192                                 $week = (date("w") ? date("w") : 7)-1;
00193                                 $starttime = mktime (0,0,0)-$week*3600*24;
00194                         break;
00195                         case 1:
00196                                 // Last week
00197                                 $week = (date("w") ? date("w") : 7)-1;
00198                                 $starttime = mktime (0,0,0)-($week+7)*3600*24;
00199                                 $endtime = mktime (0,0,0)-$week*3600*24;
00200                         break;
00201                         case 2:
00202                                 // Last 7 days
00203                                 $starttime = mktime (0,0,0)-7*3600*24;
00204                         break;
00205                         case 10:
00206                                 // This month
00207                                 $starttime = mktime (0,0,0, date("m"),1);
00208                         break;
00209                         case 11:
00210                                 // Last month
00211                                 $starttime = mktime (0,0,0, date("m")-1,1);
00212                                 $endtime = mktime (0,0,0, date("m"),1);
00213                         break;
00214                         case 12:
00215                                 // Last 31 days
00216                                 $starttime = mktime (0,0,0)-31*3600*24;
00217                         break;
00218                 }
00219                 if ($starttime) {
00220                         $where_part.=" AND tstamp>=".$starttime." AND tstamp<".$endtime;
00221                 }
00222 
00223 
00224                         // Users
00225                 if ($this->MOD_SETTINGS["users"] > 0)   {       // All users
00226                         $this->be_user_Array = t3lib_BEfunc::blindUserNames($this->be_user_Array,array($this->MOD_SETTINGS["users"]),1);
00227                         if (is_array($this->be_user_Array))     {
00228                                 while(list(,$val)=each($this->be_user_Array))   {
00229                                         if ($val[uid]!=$BE_USER->user[uid])     {
00230                                                 $selectUsers[]=$val[uid];
00231                                         }
00232                                 }
00233                         }
00234                         $selectUsers[] = 0;
00235                         $where_part.=" AND userid in (".implode($selectUsers,",").")";
00236                 } elseif ($this->MOD_SETTINGS["users"]==-1) {
00237                         $where_part.=" AND userid=".$BE_USER->user[uid];        // Self user
00238                 }
00239 
00240 
00241 
00242 
00243                 $log = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'sys_log', '1=1'.$where_part, '', 'uid DESC', intval($this->MOD_SETTINGS['max']));
00244 
00245                 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($log))       {
00246                         $header=$this->doc->formatTime($row[tstamp],10);
00247                         if (!$oldHeader)        $oldHeader=$header;
00248 
00249                         if ($header!=$oldHeader)        {
00250                                 $this->content.=$this->doc->spacer(10);
00251                                 $this->content.=$this->doc->section($oldHeader,$this->doc->table($codeArr));
00252                                 $codeArr=$this->lF->initArray();
00253                                 $oldHeader=$header;
00254                                 $this->lF->reset();
00255                         }
00256 
00257                         $i++;
00258                         $codeArr[$i][]=$this->lF->getTimeLabel($row[tstamp]);
00259                         $codeArr[$i][]=$this->lF->getUserLabel($row[userid]);
00260                         $codeArr[$i][]=$this->lF->getTypeLabel($row[type]);
00261                         $codeArr[$i][]=$row[error] ? $this->lF->getErrorFormatting($this->lF->errorSign[$row[error]]) : "";
00262                         $codeArr[$i][]=$this->lF->getActionLabel($row[type]."_".$row[action]);
00263                         $codeArr[$i][]=$this->lF->formatDetailsForList($row);
00264                 }
00265                 $this->content.=$this->doc->spacer(10);
00266                 $this->content.=$this->doc->section($header,$this->doc->table($codeArr));
00267 
00268                 $GLOBALS['TYPO3_DB']->sql_free_result($log);
00269 
00270                 if ($BE_USER->mayMakeShortcut())        {
00271                         $this->content.=$this->doc->spacer(20).$this->doc->section('',$this->doc->makeShortcutIcon("","users,time,max,action",$this->MCONF["name"]));
00272                 }
00273 
00274         }
00275         function printContent() {
00276 
00277                 $this->content.=$this->doc->spacer(20);
00278                 $this->content.=$this->doc->endPage();
00279                 echo $this->content;
00280         }
00281 }
00282 
00283 // Include extension?
00284 if (defined("TYPO3_MODE") && $TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["ext/belog/mod/index.php"]) {
00285         include_once($TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["ext/belog/mod/index.php"]);
00286 }
00287 
00288 
00289 
00290 
00291 
00292 
00293 
00294 
00295 
00296 
00297 
00298 
00299 // Make instance:
00300 $SOBE = t3lib_div::makeInstance("SC_mod_tools_log_index");
00301 $SOBE->init();
00302 $SOBE->main();
00303 $SOBE->printContent();
00304 ?>


Généré par Les experts TYPO3 avec  doxygen 1.4.6