Fixed #11430: Performance improvement: use $GLOBALS['EXEC_TIME'] instead of time...
[Packages/TYPO3.CMS.git] / t3lib / class.t3lib_superadmin.php
old mode 100755 (executable)
new mode 100644 (file)
index cefb594..54e0dec
@@ -2,7 +2,7 @@
 /***************************************************************
 *  Copyright notice
 *
-*  (c) 1999-2004 Kasper Skaarhoj (kasper@typo3.com)
+*  (c) 1999-2009 Kasper Skaarhoj (kasperYYYY@typo3.com)
 *  All rights reserved
 *
 *  This script is part of the TYPO3 project. The TYPO3 project is
  * Revised for TYPO3 3.6 February/2004 by Kasper Skaarhoj
  * XHTML Compliant
  *
- * @author     Kasper Skaarhoj <kasper@typo3.com>
+ * @author     Kasper Skaarhoj <kasperYYYY@typo3.com>
  */
 /**
  * [CLASS/FUNCTION INDEX of SCRIPT]
  *
- *  119: function debug($p1,$p2='')
+ *  120: function debug($p1,$p2='')
  *
  *
- *  133: class t3lib_superadmin
+ *  134: class t3lib_superadmin
  *
  *              SECTION: Initialize stuff
- *  179:     function t3lib_superadmin()
- *  191:     function init($parentDirs)
+ *  180:     function t3lib_superadmin()
+ *  192:     function init($parentDirs)
  *
  *              SECTION: Main functions
- *  214:     function defaultSet()
- *  268:     function make()
+ *  215:     function defaultSet()
+ *  271:     function make()
  *
  *              SECTION: Output preparation
- *  370:     function setMenuItem($code,$label)
- *  384:     function error($str)
- *  395:     function headerParentDir($str)
- *  406:     function headerSiteDir($str)
+ *  376:     function setMenuItem($code,$label)
+ *  390:     function error($str)
+ *  401:     function headerParentDir($str)
+ *  412:     function headerSiteDir($str)
  *
  *              SECTION: Collection information
- *  438:     function initProcess()
- *  476:     function processSiteDir($path,$dir)
- *  518:     function includeLocalconf($localconf)
- *  542:     function connectToDatabase($siteInfo)
- *  564:     function getDBInfo($key)
+ *  444:     function initProcess()
+ *  482:     function processSiteDir($path,$dir)
+ *  524:     function includeLocalconf($localconf)
+ *  554:     function connectToDatabase($siteInfo)
+ *  576:     function getDBInfo($key)
  *
  *              SECTION: Content: Installation Overview
- *  614:     function makeTable()
+ *  626:     function makeTable()
  *
  *              SECTION: Content: Local extensions
- *  717:     function localExtensions()
- *  890:     function getExtensionInfo($path,$extKey,$k)
- *  943:     function getAllFilesAndFoldersInPath($fileArr,$extPath,$extList='',$regDirs=0)
- *  965:     function findMostRecent($fileArr,$extPath)
- *  983:     function removePrefixPathFromList($fileArr,$extPath)
+ *  729:     function localExtensions()
+ *  902:     function getExtensionInfo($path,$extKey,$k)
+ *  956:     function getAllFilesAndFoldersInPath($fileArr,$extPath,$extList='',$regDirs=0)
+ *  978:     function findMostRecent($fileArr,$extPath)
+ *  996:     function removePrefixPathFromList($fileArr,$extPath)
  *
  *              SECTION: Content: Other
- * 1020:     function singleSite($exp)
- * 1051:     function loginLog($DB)
- * 1089:     function log_getDetails($text,$data)
- * 1103:     function rmCachedFiles($exp)
- * 1136:     function menuContent($exp)
- * 1208:     function makeAdminLogin()
- * 1282:     function changeAdminPasswordsForm()
- * 1317:     function setNewPasswords()
+ * 1033:     function singleSite($exp)
+ * 1064:     function loginLog($DB)
+ * 1102:     function log_getDetails($text,$data)
+ * 1116:     function rmCachedFiles($exp)
+ * 1149:     function menuContent($exp)
+ * 1221:     function makeAdminLogin()
+ * 1295:     function changeAdminPasswordsForm()
+ * 1330:     function setNewPasswords()
  *
  * TOTAL FUNCTIONS: 28
  * (This index is automatically created/updated by the extension "extdeveval")
@@ -104,8 +104,9 @@ define('TYPO3_mainDir', 'typo3/');          // This is the directory of the backend admi
 
 
 // Dependency:
-include_once('./typo3_src/t3lib/class.t3lib_div.php');
-include_once('./typo3_src/t3lib/class.t3lib_db.php');
+$path_t3lib = './typo3_src/t3lib/';
+include_once($path_t3lib.'class.t3lib_div.php');
+include_once($path_t3lib.'class.t3lib_db.php');
 $TYPO3_DB = t3lib_div::makeInstance('t3lib_DB');
 
 
@@ -126,7 +127,7 @@ function debug($p1,$p2='')  {
  * Super Admin class has functions for the administration of multiple TYPO3 sites in folders
  * NOTICE: Only compliant with single MySQL database usage per installation!
  *
- * @author     Kasper Skaarhoj <kasper@typo3.com>
+ * @author     Kasper Skaarhoj <kasperYYYY@typo3.com>
  * @package TYPO3
  * @subpackage t3lib
  */
@@ -221,8 +222,8 @@ class t3lib_superadmin {
                        case 'page':
 ?>
 <!DOCTYPE html
-     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
-     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+        PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 <html>
 <head>
        <style type="text/css">
@@ -253,8 +254,8 @@ class t3lib_superadmin {
        <title>TYPO3 Super Admin</title>
 </head>
 <frameset  cols="250,*">
-    <frame name="TSAmenu" src="superadmin.php?type=page&show=menu" marginwidth="10" marginheight="10" scrolling="auto" frameborder="0">
-    <frame name="TSApage" src="superadmin.php?type=page" marginwidth="10" marginheight="10" scrolling="auto" frameborder="0">
+       <frame name="TSAmenu" src="superadmin.php?type=page&show=menu" marginwidth="10" marginheight="10" scrolling="auto" frameborder="0">
+       <frame name="TSApage" src="superadmin.php?type=page" marginwidth="10" marginheight="10" scrolling="auto" frameborder="0">
 </frameset>
 </html>
 <?php
@@ -269,6 +270,8 @@ class t3lib_superadmin {
         */
        function make() {
 
+               $retVal = '';
+
                        // Creating information about the sites found:
                $content = $this->initProcess();
 
@@ -288,10 +291,10 @@ class t3lib_superadmin {
                                $content = implode('<br />',$lines);
                                $content.= '<hr />';
                                $content.=$this->menuContent($this->exp);
-                               return '<h2 align="center">TYPO3<br />Super Admin</h2>'.$content;
+                               $retVal = '<h2 align="center">TYPO3<br />Super Admin</h2>'.$content;
                        break;
                        case 'all':
-                               return '
+                               $retVal = '
                                        <h1>All details:</h1>
                                        <h2>Overview:</h2>
                                        '.$this->makeTable().'
@@ -302,7 +305,7 @@ class t3lib_superadmin {
                        case 'admin':
                                $content = $this->setNewPasswords();
                                $this->makeTable();
-                               return $content.'
+                               $retVal = $content.'
                                        <h1>Admin options:</h1>
 
                                        <h2>Admin logins:</h2>
@@ -322,29 +325,30 @@ class t3lib_superadmin {
                                        <br /><hr /><br />';
                        break;
                        case 'info':
-                               return '
+                               $retVal = '
                                        <h1>Single site details</h1>
                                        '.$this->singleSite($this->exp).
                                        '<br />';
                        break;
                        case 'rmTempCached':
-                               return '
+                               $retVal = '
                                        <h1>Removing temp_CACHED_*.php files</h1>
                                        '.$this->rmCachedFiles($this->exp).
                                        '<br />';
                        break;
                        case 'localext':
-                               return '
+                               $retVal = '
                                        <h1>Local Extensions Found:</h1>
                                        '.$this->localExtensions().
                                        '<br />';
                        break;
                        default:
-                               return '
+                               $retVal = '
                                        <h1>Default info:</h1>'.
                                        $content;
                        break;
                }
+               return $retVal;
        }
 
 
@@ -441,8 +445,8 @@ class t3lib_superadmin {
                $content = '';
 
                foreach($this->parentDirs as $k => $v)  {
-                       $dir = ereg_replace('/$','',$v['dir']);
-                       $baseUrl=ereg_replace('/$','',$v['url']);
+                       $dir = rtrim($v['dir'], '/');
+                       $baseUrl=rtrim($v['url'], '/');
                        $content.='<br /><br /><br />';
                        $content.=$this->headerParentDir($dir);
                        if (@is_dir($dir))      {
@@ -518,6 +522,12 @@ class t3lib_superadmin {
         * @see processSiteDir()
         */
        function includeLocalconf($localconf)   {
+               $TYPO3_CONF_VARS = array();
+               $typo_db = '';
+               $typo_db_username = '';
+               $typo_db_password = '';
+               $typo_db_host = '';
+
                include($localconf);
 
                $siteInfo=array();
@@ -567,19 +577,19 @@ class t3lib_superadmin {
                $DB = $this->globalSiteInfo[$key]['siteInfo']['TYPO3_db'];
 
                        // Non-admin users
-               $query = $GLOBALS['TYPO3_DB']->SELECTquery('count(*)', 'be_users', 'admin=0 AND NOT deleted');
+               $query = $GLOBALS['TYPO3_DB']->SELECTquery('count(*)', 'be_users', 'admin=0 AND deleted=0');
                $res = mysql($DB, $query);
                $row = mysql_fetch_row($res);
                $this->globalSiteInfo[$key]['siteInfo']['BE_USERS_NONADMIN'] = $row[0];
 
                        // Admin users
-               $query = $GLOBALS['TYPO3_DB']->SELECTquery('count(*)', 'be_users', 'admin!=0 AND NOT deleted');
+               $query = $GLOBALS['TYPO3_DB']->SELECTquery('count(*)', 'be_users', 'admin!=0 AND deleted=0');
                $res = mysql($DB, $query);
                $row = mysql_fetch_row($res);
                $this->globalSiteInfo[$key]['siteInfo']['BE_USERS_ADMIN'] = $row[0];
 
                        // Select Admin users
-               $query = $GLOBALS['TYPO3_DB']->SELECTquery('uid,username,password,email,realName,disable', 'be_users', 'admin!=0 AND NOT deleted');
+               $query = $GLOBALS['TYPO3_DB']->SELECTquery('uid,username,password,email,realName,disable', 'be_users', 'admin!=0 AND deleted=0');
                $res = mysql($DB, $query);
                while($row = mysql_fetch_assoc($res))   {
                        $this->globalSiteInfo[$key]['siteInfo']['ADMINS'][] = $row;
@@ -893,6 +903,7 @@ class t3lib_superadmin {
                $file = $path.$extKey.'/ext_emconf.php';
                if (@is_file($file))    {
                        $_EXTKEY = $extKey;
+                       $EM_CONF = array();
                        include($file);
 
                        $eInfo = array();
@@ -1056,7 +1067,7 @@ class t3lib_superadmin {
                $query = $GLOBALS['TYPO3_DB']->SELECTquery(
                                                'sys_log.*, be_users.username  AS username, be_users.admin AS admin',
                                                'sys_log,be_users',
-                                               'be_users.uid=sys_log.userid AND sys_log.type=255 AND sys_log.tstamp > '.(time()-(60*60*24*30)),
+                                               'be_users.uid=sys_log.userid AND sys_log.type=255 AND sys_log.tstamp > ' . ($GLOBALS['EXEC_TIME'] - (60 * 60 * 24 * 30)),
                                                '',
                                                'sys_log.tstamp DESC'
                                        );
@@ -1147,7 +1158,7 @@ class t3lib_superadmin {
                                        // Setting section header, if needed.
                                if ($head!=$all['siteInfo']['MAIN_DIR'])        {
                                        $lines[] = '
-                                               <h4 style="white-space: nowrap;">'.htmlspecialchars(t3lib_div::fixed_lgd_pre($all['siteInfo']['MAIN_DIR'],18)).'</h4>';
+                                               <h4 style="white-space: nowrap;">'.htmlspecialchars(t3lib_div::fixed_lgd_cs($all['siteInfo']['MAIN_DIR'],-18)).'</h4>';
                                        $head = $all['siteInfo']['MAIN_DIR'];   // Set new head...
                                }
 
@@ -1162,7 +1173,7 @@ class t3lib_superadmin {
                                                        <b>'.htmlspecialchars($label).'</b> ('.htmlspecialchars(substr($all['siteInfo']['SA_PATH'],strlen($all['siteInfo']['MAIN_DIR'])+1)).')<br />';
 
                                                                // To avoid "visited links" display on next hit:
-                                                       $tempVal='&_someUniqueValue='.time();
+                                                       $tempVal='&_someUniqueValue=' . $GLOBALS['EXEC_TIME'];
 
                                                                // Add links for update:
                                                        $url = $this->scriptName.'?type=page&show=rmTempCached&exp='.$k.$tempVal;
@@ -1358,4 +1369,5 @@ class t3lib_superadmin {
 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_superadmin.php'])       {
        include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_superadmin.php']);
 }
+
 ?>