TYPO3 API  SVNRelease
index.php
Go to the documentation of this file.
00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 1999-2011 Kasper Skårhøj (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 ***************************************************************/
00027 /**
00028  * Module: Database integrity check
00029  *
00030  * This module lets you check if all pages and the records relate properly to each other
00031  *
00032  * @author  Kasper Skårhøj <kasperYYYY@typo3.com>
00033  * @coauthor    Jo Hasenau <info@cybercraft.de>
00034  */
00035 /**
00036  * [CLASS/FUNCTION INDEX of SCRIPT]
00037  *
00038  *
00039  *
00040  *   89: class SC_mod_tools_dbint_index
00041  *  105:     function init()
00042  *  119:     function jumpToUrl(URL)
00043  *  139:     function menuConfig()
00044  *  226:     function main()
00045  *  270:     function printContent()
00046  *  281:     function func_default()
00047  *
00048  *              SECTION: Functionality implementation
00049  *  314:     function func_refindex()
00050  *  344:     function func_search()
00051  *  386:     function func_tree()
00052  *  409:     function func_records()
00053  *  507:     function func_relations()
00054  *  558:     function func_filesearch()
00055  *  607:     function findFile($basedir,$pattern,&$matching_files,$depth)
00056  *
00057  * TOTAL FUNCTIONS: 13
00058  * (This index is automatically created/updated by the extension "extdeveval")
00059  *
00060  */
00061 
00062 
00063 unset($MCONF);
00064 require ('conf.php');
00065 require ($BACK_PATH.'init.php');
00066 require ($BACK_PATH.'template.php');
00067 
00068 $GLOBALS['LANG']->includeLLFile('EXT:lowlevel/dbint/locallang.xml');
00069 $BE_USER->modAccess($MCONF,1);
00070 
00071 
00072 
00073 
00074 
00075 
00076 /**
00077  * Script class for the DB int module
00078  *
00079  * @author  Kasper Skårhøj <kasperYYYY@typo3.com>
00080  * @package TYPO3
00081  * @subpackage tx_lowlevel
00082  */
00083 class SC_mod_tools_dbint_index {
00084 
00085     var $MCONF = array();
00086     var $MOD_MENU = array();
00087     var $MOD_SETTINGS = array();
00088 
00089     /**
00090      * document template object
00091      *
00092      * @var mediumDoc
00093      */
00094     var $doc;
00095 
00096     var $content;
00097     var $menu;
00098 
00099     protected $formName = 'queryform';
00100 
00101 
00102     /**
00103      * Initialization
00104      *
00105      * @return  void
00106      */
00107     function init() {
00108         global $LANG,$BACK_PATH;
00109         $this->MCONF = $GLOBALS['MCONF'];
00110 
00111         $this->menuConfig();
00112 
00113         $this->doc = t3lib_div::makeInstance('template');
00114         $this->doc->backPath = $BACK_PATH;
00115         $this->doc->setModuleTemplate('templates/dbint.html');
00116         $this->doc->form='<form action="" method="post" name="'.$this->formName.'">';
00117 
00118                 // JavaScript
00119         $this->doc->JScode = '
00120         <script language="javascript" type="text/javascript">
00121             script_ended = 0;
00122             function jumpToUrl(URL) {
00123                 window.location.href = URL;
00124             }
00125         </script>
00126         ';
00127         $this->doc->table_TABLE = '<table border="0" cellspacing="0" cellpadding="0" class="typo3-dblist" style="width:400px!important;">
00128             <colgroup><col width="24"><col width="300"><col width="76"></colgroup>';
00129 
00130         $this->doc->tableLayout = array (
00131             '0' => array (
00132                 'defCol' => array('<td class="t3-row-header"><img src="' . $this->doc->backPath . 'clear.gif" width="10" height="1" alt="" /></td><td valign="top" class="t3-row-header"><strong>', '</strong></td>')
00133             ),
00134             'defRow' => array (
00135                 '0' => array('<td valign="top">','</td>'),
00136                 '1' => array('<td valign="top">','</td>'),
00137                 'defCol' => array('<td><img src="' . $this->doc->backPath . 'clear.gif" width="15" height="1" alt="" /></td><td valign="top">', '</td>')
00138             )
00139         );
00140     }
00141 
00142     /**
00143      * Configure menu
00144      *
00145      * @return  void
00146      */
00147     function menuConfig()   {
00148         global $LANG;
00149 
00150         // MENU-ITEMS:
00151             // If array, then it's a selector box menu
00152             // If empty string it's just a variable, that'll be saved.
00153             // Values NOT in this array will not be saved in the settings-array for the module.
00154         $this->MOD_MENU = array(
00155             'function' => array(
00156                 0 => $GLOBALS['LANG']->getLL('menu', true),
00157                 'records' => $GLOBALS['LANG']->getLL('recordStatistics', true),
00158                 'relations' => $GLOBALS['LANG']->getLL('databaseRelations', true),
00159                 'search' => $GLOBALS['LANG']->getLL('fullSearch', true),
00160                 'filesearch' => $GLOBALS['LANG']->getLL('findFilename', true),
00161                 'refindex' => $GLOBALS['LANG']->getLL('manageRefIndex', true),
00162             ),
00163             'search' => array(
00164                 'raw' => $GLOBALS['LANG']->getLL('rawSearch', true),
00165                 'query' => $GLOBALS['LANG']->getLL('advancedQuery', true)
00166             ),
00167 
00168             'search_query_smallparts' => '',
00169             'search_result_labels' => '',
00170             'labels_noprefix' => '',
00171             'options_sortlabel' => '',
00172             'show_deleted' => '',
00173 
00174             'queryConfig' => '',    // Current query
00175             'queryTable' => '', // Current table
00176             'queryFields' => '',    // Current tableFields
00177             'queryLimit' => '', // Current limit
00178             'queryOrder' => '', // Current Order field
00179             'queryOrderDesc' => '', // Current Order field descending flag
00180             'queryOrder2' => '',    // Current Order2 field
00181             'queryOrder2Desc' => '',    // Current Order2 field descending flag
00182             'queryGroup' => '', // Current Group field
00183 
00184             'storeArray' => '', // Used to store the available Query config memory banks
00185             'storeQueryConfigs' => '',  // Used to store the available Query configs in memory
00186 
00187             'search_query_makeQuery' => array(
00188                 'all' => $GLOBALS['LANG']->getLL('selectRecords', true),
00189                 'count' => $GLOBALS['LANG']->getLL('countResults', true),
00190                 'explain' => $GLOBALS['LANG']->getLL('explainQuery', true),
00191                 'csv' => $GLOBALS['LANG']->getLL('csvExport', true),
00192                 'xml' => $GLOBALS['LANG']->getLL('xmlExport', true)
00193             ),
00194 
00195             'sword' => ''
00196         );
00197             // CLEAN SETTINGS
00198         $OLD_MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU,'', $this->MCONF['name'], 'ses');
00199         $this->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU, t3lib_div::_GP('SET'), $this->MCONF['name'], 'ses');
00200 
00201         if (t3lib_div::_GP('queryConfig'))  {
00202             $qA = t3lib_div::_GP('queryConfig');
00203             $this->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU, array('queryConfig'=>serialize($qA)), $this->MCONF['name'], 'ses');
00204         }
00205         $addConditionCheck = t3lib_div::_GP('qG_ins');
00206         foreach ($OLD_MOD_SETTINGS as $key=>$val)   {
00207             if (substr($key, 0, 5)=='query' && $this->MOD_SETTINGS[$key]!=$val && $key!='queryLimit' && $key!='use_listview')   {
00208                 $setLimitToStart = 1;
00209                 if ($key == 'queryTable' && !$addConditionCheck) {
00210                     $this->MOD_SETTINGS['queryConfig'] = '';
00211                 }
00212             }
00213             if ($key=='queryTable' && $this->MOD_SETTINGS[$key]!=$val)  {
00214                 $this->MOD_SETTINGS['queryFields'] = '';
00215             }
00216         }
00217         if ($setLimitToStart)   {
00218             $currentLimit = explode(',',$this->MOD_SETTINGS['queryLimit']);
00219             if ($currentLimit[1])   {
00220                 $this->MOD_SETTINGS['queryLimit']='0,'.$currentLimit[1];
00221             } else {
00222                 $this->MOD_SETTINGS['queryLimit']='0';
00223             }
00224             $this->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU, $this->MOD_SETTINGS, $this->MCONF['name'], 'ses');
00225         }
00226     }
00227 
00228     /**
00229      * Main
00230      *
00231      * @return  void
00232      */
00233     function main() {
00234         global $BE_USER,$LANG;
00235 
00236             // Content creation
00237         if (!$GLOBALS['BE_USER']->userTS['mod.']['dbint.']['disableTopMenu'])   {
00238             $this->menu = t3lib_BEfunc::getFuncMenu(0,'SET[function]',$this->MOD_SETTINGS['function'],$this->MOD_MENU['function']);
00239         }
00240 
00241         switch($this->MOD_SETTINGS['function']) {
00242             case 'search':
00243                 $this->func_search();
00244             break;
00245             case 'records':
00246                 $this->func_records();
00247             break;
00248             case 'relations':
00249                 $this->func_relations();
00250             break;
00251             case 'filesearch':
00252                 $this->func_filesearch();
00253             break;
00254             case 'refindex':
00255                 $this->func_refindex();
00256             break;
00257             default:
00258                 $this->func_default();
00259             break;
00260         }
00261 
00262             // Setting up the buttons and markers for docheader
00263         $docHeaderButtons = $this->getButtons();
00264         $markers = array(
00265             'CSH' => $docHeaderButtons['csh'],
00266             'FUNC_MENU' => $this->getFuncMenu(),
00267             'CONTENT' => $this->content
00268         );
00269 
00270             // Build the <body> for the module
00271         $this->content = $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
00272             // Renders the module page
00273         $this->content = $this->doc->render(
00274             $GLOBALS['LANG']->getLL('title'),
00275             $this->content
00276         );
00277     }
00278 
00279     /**
00280      * Print content
00281      *
00282      * @return  void
00283      */
00284     function printContent() {
00285         echo $this->content;
00286     }
00287 
00288     /**
00289      * Create the panel of buttons for submitting the form or otherwise perform operations.
00290      *
00291      * @return  array   all available buttons as an assoc. array
00292      */
00293     protected function getButtons() {
00294 
00295         $buttons = array(
00296             'csh' => '',
00297             'shortcut' => ''
00298         );
00299             // CSH
00300         //$buttons['csh'] = t3lib_BEfunc::cshItem('_MOD_web_func', '', $GLOBALS['BACK_PATH']);
00301 
00302             // Shortcut
00303         if ($GLOBALS['BE_USER']->mayMakeShortcut()) {
00304             $buttons['shortcut'] = $this->doc->makeShortcutIcon('','function,search,search_query_makeQuery',$this->MCONF['name']);
00305         }
00306         return $buttons;
00307     }
00308 
00309     /**
00310      * Create the function menu
00311      *
00312      * @return  string  HTML of the function menu
00313      */
00314     protected function getFuncMenu() {
00315         if (!$GLOBALS['BE_USER']->userTS['mod.']['dbint.']['disableTopMenu']) {
00316             $funcMenu = t3lib_BEfunc::getFuncMenu(0, 'SET[function]', $this->MOD_SETTINGS['function'], $this->MOD_MENU['function']);
00317         }
00318         return $funcMenu;
00319     }
00320 
00321     /**
00322      * Creates the overview menu.
00323      *
00324      */
00325     protected function func_default() {
00326         $availableModFuncs = array('records', 'relations', 'search', 'filesearch', 'refindex');
00327 
00328         $moduleTitle = $GLOBALS['LANG']->getLL('title');
00329         $content     = '<dl class="t3-overview-list">';
00330 
00331         foreach ($availableModFuncs as $modFunc) {
00332             $link        = 'index.php?SET[function]=' . $modFunc;
00333             $title       = $GLOBALS['LANG']->getLL($modFunc);
00334             $description = $GLOBALS['LANG']->getLL($modFunc . '_description');
00335 
00336             $icon = '<img src="'
00337                 . t3lib_iconworks::skinImg($GLOBALS['BACK_PATH'], 'MOD:tools_dbint/db.gif', '', 1)
00338                 . '" width="16" height="16" title="' . $title . '" alt="' . $title
00339             . '" />';
00340 
00341             $content .= '
00342                 <dt><a href="' . $link . '">' . $icon . $title . '</a></dt>
00343                 <dd>' . $description . '</dd>
00344             ';
00345         }
00346 
00347         $content .= '</dl>';
00348 
00349         $this->content .= $this->doc->section($moduleTitle, $content, false, true);
00350     }
00351 
00352 
00353 
00354 
00355 
00356 
00357 
00358 
00359     /****************************
00360      *
00361      * Functionality implementation
00362      *
00363      ****************************/
00364 
00365     /**
00366      * Check and update reference index!
00367      *
00368      * @return  void
00369      */
00370     function func_refindex()    {
00371         global $TYPO3_DB,$TCA;
00372 
00373         if (t3lib_div::_GP('_update') || t3lib_div::_GP('_check'))  {
00374             $testOnly = t3lib_div::_GP('_check')?TRUE:FALSE;
00375 
00376                 // Call the functionality
00377             $refIndexObj = t3lib_div::makeInstance('t3lib_refindex');
00378             list($headerContent,$bodyContent) = $refIndexObj->updateIndex($testOnly);
00379 
00380                 // Output content:
00381             $this->content.=$this->doc->section($headerContent,str_replace(LF,'<br/>',$bodyContent),0,1);
00382         }
00383 
00384             // Output content:
00385         $content = '<p>' . $GLOBALS['LANG']->getLL('referenceIndex_description') . '</p><br />';
00386         $content .= '<input type="submit" name="_check" value="' . $GLOBALS['LANG']->getLL('referenceIndex_buttonCheck') . '" /> <input type="submit" name="_update" value="' . $GLOBALS['LANG']->getLL('referenceIndex_buttonUpdate') . '" /><br /><br />';
00387         $content .= '<h3>' . $GLOBALS['LANG']->getLL('checkScript_headline') . '</h3>';
00388         $content.= '<p>' . $GLOBALS['LANG']->getLL('checkScript') . '</p>';
00389         $content.= '<h4>' . $GLOBALS['LANG']->getLL('checkScript_check_description') . '</h4>' .
00390                     '<code>php ' . PATH_typo3 . 'cli_dispatch.phpsh lowlevel_refindex -c</code><br />';
00391         $content.= '<h4>' . $GLOBALS['LANG']->getLL('checkScript_update_description') . '</h4>' .
00392                     '<code>php ' . PATH_typo3 . 'cli_dispatch.phpsh lowlevel_refindex -e</code><br /><br />';
00393         $content.= '<div class="typo3-message message-information"><div class="message-body">' . $GLOBALS['LANG']->getLL('checkScript_information') . '</div></div>';
00394         $content.= '<p>' . $GLOBALS['LANG']->getLL('checkScript_moreDetails') . '<br /><a href="' . $GLOBALS['BACK_PATH'] . 'sysext/lowlevel/HOWTO_clean_up_TYPO3_installations.txt" target="_new">' . PATH_typo3 . 'sysext/lowlevel/HOWTO_clean_up_TYPO3_installations.txt</a></p>';
00395 
00396         $this->content.= $this->doc->section($GLOBALS['LANG']->getLL('updateRefIndex'), $content, false, true);
00397     }
00398 
00399     /**
00400      * Search (Full / Advanced)
00401      *
00402      * @return  void
00403      */
00404     function func_search()  {
00405         global $LANG;
00406 
00407         $fullsearch = t3lib_div::makeInstance('t3lib_fullsearch');
00408         $fullsearch->setFormName($this->formName);
00409         $this->content.= $this->doc->header($GLOBALS['LANG']->getLL('search'));
00410         $this->content.= $this->doc->spacer(5);
00411 
00412         $menu2='';
00413         if (!$GLOBALS['BE_USER']->userTS['mod.']['dbint.']['disableTopMenu'])   {
00414             $menu2 = t3lib_BEfunc::getFuncMenu(0, 'SET[search]', $this->MOD_SETTINGS['search'], $this->MOD_MENU['search']);
00415         }
00416         if ($this->MOD_SETTINGS['search']=='query' && !$GLOBALS['BE_USER']->userTS['mod.']['dbint.']['disableTopMenu']) {
00417             $menu2 .= t3lib_BEfunc::getFuncMenu(0, 'SET[search_query_makeQuery]', $this->MOD_SETTINGS['search_query_makeQuery'], $this->MOD_MENU['search_query_makeQuery']) . '<br />';
00418         }
00419         if (!$GLOBALS['BE_USER']->userTS['mod.']['dbint.']['disableTopCheckboxes'] && $this->MOD_SETTINGS['search']=='query')   {
00420             $menu2 .= t3lib_BEfunc::getFuncCheck($GLOBALS['SOBE']->id, 'SET[search_query_smallparts]', $this->MOD_SETTINGS['search_query_smallparts'], '', '', 'id="checkSearch_query_smallparts"') . '&nbsp;<label for="checkSearch_query_smallparts">' . $GLOBALS['LANG']->getLL('showSQL') . '</label><br />';
00421             $menu2 .= t3lib_BEfunc::getFuncCheck($GLOBALS['SOBE']->id, 'SET[search_result_labels]', $this->MOD_SETTINGS['search_result_labels'], '', '', 'id="checkSearch_result_labels"') . '&nbsp;<label for="checkSearch_result_labels">' . $GLOBALS['LANG']->getLL('useFormattedStrings') . '</label><br />';
00422             $menu2 .= t3lib_BEfunc::getFuncCheck($GLOBALS['SOBE']->id, 'SET[labels_noprefix]', $this->MOD_SETTINGS['labels_noprefix'], '', '', 'id="checkLabels_noprefix"') . '&nbsp;<label for="checkLabels_noprefix">' . $GLOBALS['LANG']->getLL('dontUseOrigValues') . '</label><br />';
00423             $menu2 .= t3lib_BEfunc::getFuncCheck($GLOBALS['SOBE']->id, 'SET[options_sortlabel]', $this->MOD_SETTINGS['options_sortlabel'], '', '', 'id="checkOptions_sortlabel"') . '&nbsp;<label for="checkOptions_sortlabel">' . $GLOBALS['LANG']->getLL('sortOptions') . '</label><br />';
00424             $menu2 .= t3lib_BEfunc::getFuncCheck($GLOBALS['SOBE']->id, 'SET[show_deleted]', $this->MOD_SETTINGS['show_deleted'], '', '', 'id="checkShow_deleted"') . '&nbsp;<label for="checkShow_deleted">' . $GLOBALS['LANG']->getLL('showDeleted') . '</label>';
00425         }
00426 
00427         $this->content.= $this->doc->section('',$menu2).$this->doc->spacer(10);
00428 
00429         switch($this->MOD_SETTINGS['search'])       {
00430             case 'query':
00431                 $this->content.=$fullsearch->queryMaker();
00432             break;
00433             case 'raw':
00434             default:
00435                 $this->content.=$this->doc->section($GLOBALS['LANG']->getLL('searchOptions'), $fullsearch->form(), false, true);
00436                 $this->content.=$this->doc->section($GLOBALS['LANG']->getLL('result'), $fullsearch->search(), false, true);
00437             break;
00438         }
00439     }
00440 
00441 
00442     /**
00443      * Records overview
00444      *
00445      * @return  void
00446      */
00447     function func_records() {
00448         global $LANG,$TCA,$BACK_PATH,$PAGES_TYPES;
00449 
00450         $admin = t3lib_div::makeInstance('t3lib_admin');
00451         $admin->genTree_makeHTML = 0;
00452         $admin->backPath = $BACK_PATH;
00453         $admin->genTree(0,'');
00454 
00455         $this->content.= $this->doc->header($GLOBALS['LANG']->getLL('records'));
00456         $this->content.= $this->doc->spacer(5);
00457 
00458             // Pages stat
00459         $codeArr=array();
00460         $codeArr['tableheader'] = array('', $GLOBALS['LANG']->getLL('count'));
00461         $i++;
00462         $codeArr[$i][]='<img' . t3lib_iconWorks::skinImg($BACK_PATH,'gfx/i/pages.gif','width="18" height="16"') . ' hspace="4" align="top" alt="" />';
00463         $codeArr[$i][]=$GLOBALS['LANG']->getLL('total_pages');
00464         $codeArr[$i][]=count($admin->page_idArray);
00465         $i++;
00466         if (t3lib_extMgm::isLoaded('cms'))  {
00467             $codeArr[$i][]='<img' . t3lib_iconWorks::skinImg($BACK_PATH,'gfx/hidden_page.gif','width="18" height="16"') . ' hspace="4" align="top">';
00468             $codeArr[$i][]=$GLOBALS['LANG']->getLL('hidden_pages');
00469             $codeArr[$i][] = $admin->recStats['hidden'];
00470             $i++;
00471         }
00472         $codeArr[$i][]='<img' . t3lib_iconWorks::skinImg($BACK_PATH,'gfx/deleted_page.gif','width="18" height="16"') . ' hspace="4" align="top">';
00473         $codeArr[$i][]=$GLOBALS['LANG']->getLL('deleted_pages');
00474         $codeArr[$i][] = count($admin->recStats['deleted']['pages']);
00475 
00476         $this->content.=$this->doc->section($GLOBALS['LANG']->getLL('pages'), $this->doc->table($codeArr), false, true);
00477 
00478             // Doktype
00479         $codeArr=array();
00480         $codeArr['tableheader'] = array($GLOBALS['LANG']->getLL('doktype_value'), $GLOBALS['LANG']->getLL('count'));
00481         $doktype= $TCA['pages']['columns']['doktype']['config']['items'];
00482         if (is_array($doktype)) {
00483             foreach ($doktype as $n => $setup) {
00484                 if ($setup[1]!='--div--')   {
00485                     $codeArr[$n][] = '<img' . t3lib_iconWorks::skinImg($BACK_PATH,'gfx/i/' . ($PAGES_TYPES[$setup[1]]['icon'] ? $PAGES_TYPES[$setup[1]]['icon'] : $PAGES_TYPES['default']['icon']), 'width="18" height="16"') . ' hspace="4" align="top">';
00486                     $codeArr[$n][] = $GLOBALS['LANG']->sL($setup[0]) . ' (' . $setup[1] . ')';
00487                     $codeArr[$n][] = intval($admin->recStats['doktype'][$setup[1]]);
00488                 }
00489             }
00490             $this->content.=$this->doc->section($GLOBALS['LANG']->getLL('doktype'), $this->doc->table($codeArr), false, true);
00491         }
00492 
00493             // Tables and lost records
00494         $id_list = '-1,0,' . implode(',', array_keys($admin->page_idArray));
00495         $id_list = rtrim($id_list, ',');
00496         $admin->lostRecords($id_list);
00497 
00498         if ($admin->fixLostRecord(t3lib_div::_GET('fixLostRecords_table'), t3lib_div::_GET('fixLostRecords_uid'))) {
00499             $admin = t3lib_div::makeInstance('t3lib_admin');
00500             $admin->backPath = $BACK_PATH;
00501             $admin->genTree(0,'');
00502             $id_list = '-1,0,' . implode(',', array_keys($admin->page_idArray));
00503             $id_list = rtrim($id_list, ',');
00504             $admin->lostRecords($id_list);
00505         }
00506 
00507         $this->doc->table_TABLE = '<table border="0" cellspacing="0" cellpadding="0" class="typo3-dblist" style="width:700px!important;">';
00508 
00509         $codeArr = array();
00510         $codeArr['tableheader'] = array(
00511             $GLOBALS['LANG']->getLL('label'),
00512             $GLOBALS['LANG']->getLL('tablename'),
00513             $GLOBALS['LANG']->getLL('total_lost'),
00514             ''
00515         );
00516 
00517         $countArr = $admin->countRecords($id_list);
00518         if (is_array($TCA)) {
00519 
00520             foreach ($TCA as $t => $value) {
00521                 if ($TCA[$t]['ctrl']['hideTable']) {
00522                     continue;
00523                 }
00524                 $codeArr[$t][]=t3lib_iconWorks::getSpriteIconForRecord($t, array());
00525                 $codeArr[$t][]=$LANG->sL($TCA[$t]['ctrl']['title']);
00526                 $codeArr[$t][]=$t;
00527 
00528                 if ($countArr['all'][$t])   {
00529                     $theNumberOfRe = intval($countArr['non_deleted'][$t]).'/'.(intval($countArr['all'][$t])-intval($countArr['non_deleted'][$t]));
00530                 } else {
00531                     $theNumberOfRe ='';
00532                 }
00533                 $codeArr[$t][]=$theNumberOfRe;
00534 
00535                 $lr='';
00536                 if (is_array($admin->lRecords[$t])) {
00537                     foreach ($admin->lRecords[$t] as $data) {
00538                         if (!t3lib_div::inList($admin->lostPagesList,$data[pid]))   {
00539                             $lr.= '<nobr><strong><a href="index.php?SET[function]=records&fixLostRecords_table=' . $t . '&fixLostRecords_uid=' . $data[uid] . '"><img src="' . $BACK_PATH . 'gfx/required_h.gif" width="10" hspace="3" height="10" border="0" align="top" title="' . $GLOBALS['LANG']->getLL('fixLostRecord') . '"></a>uid:' . $data[uid] . ', pid:' . $data[pid] . ', ' . t3lib_div::fixed_lgd_cs(strip_tags($data[title]), 20) . '</strong></nobr><br>';
00540                         } else {
00541                             $lr.= '<nobr><img src="' . $BACK_PATH . 'clear.gif" width="16" height="1" border="0"><font color="Gray">uid:' . $data[uid] . ', pid:' . $data[pid] . ', ' . t3lib_div::fixed_lgd_cs(strip_tags($data[title]), 20) . '</font></nobr><br>';
00542                         }
00543                     }
00544                 }
00545                 $codeArr[$t][]=$lr;
00546             }
00547             $this->content.=$this->doc->section($GLOBALS['LANG']->getLL('tables'), $this->doc->table($codeArr), false, true);
00548         }
00549     }
00550 
00551     /**
00552      * Show list references
00553      *
00554      * @return  void
00555      */
00556     function func_relations()   {
00557         global $LANG,$BACK_PATH;
00558 
00559         $this->content.= $this->doc->header($GLOBALS['LANG']->getLL('relations'));
00560         $this->content.= $this->doc->spacer(5);
00561 
00562         $admin = t3lib_div::makeInstance('t3lib_admin');
00563         $admin->genTree_makeHTML=0;
00564         $admin->backPath = $BACK_PATH;
00565 
00566         $fkey_arrays = $admin->getGroupFields('');
00567         $admin->selectNonEmptyRecordsWithFkeys($fkey_arrays);
00568 
00569 
00570         $fileTest = $admin->testFileRefs();
00571 
00572         $code='';
00573         if (is_array($fileTest['noReferences']))    {
00574             foreach ($fileTest['noReferences'] as $val) {
00575                 $code.='<nobr>' . $val[0] . '/<strong>' . $val[1] . '</strong></nobr><br>';
00576             }
00577         }
00578         $this->content.=$this->doc->section($GLOBALS['LANG']->getLL('files_no_ref'), $code, true, true);
00579 
00580         $code='';
00581         if (is_array($fileTest['moreReferences']))  {
00582             foreach ($fileTest['moreReferences'] as $val) {
00583                 $code.='<nobr>' . $val[0] . '/<strong>' . $val[1] . '</strong>: ' . $val[2] . ' ' . $GLOBALS['LANG']->getLL('references') . '</nobr><br>' . $val[3] . '<br><br>';
00584             }
00585         }
00586         $this->content.=$this->doc->section($GLOBALS['LANG']->getLL('files_many_ref'),$code, true, true);
00587 
00588         $code='';
00589         if (is_array($fileTest['noFile']))  {
00590             ksort($fileTest['noFile']);
00591             foreach ($fileTest['noFile'] as $val) {
00592                 $code.='<nobr>' . $val[0] . '/<strong>' . $val[1] . '</strong> ' . $GLOBALS['LANG']->getLL('isMissing') . ' </nobr><br>' . $GLOBALS['LANG']->getLL('referencedFrom') . $val[2] . '<br><br>';
00593             }
00594         }
00595         $this->content.= $this->doc->section($GLOBALS['LANG']->getLL('files_no_file'), $code, true, true);
00596         $this->content.= $this->doc->section($GLOBALS['LANG']->getLL('select_db'), $admin->testDBRefs($admin->checkSelectDBRefs), true, true);
00597         $this->content.= $this->doc->section($GLOBALS['LANG']->getLL('group_db'), $admin->testDBRefs($admin->checkGroupDBRefs), true, true);
00598     }
00599 
00600     /**
00601      * Searching for files with a specific pattern
00602      *
00603      * @return  void
00604      */
00605     function func_filesearch()  {
00606         $pattern = t3lib_div::_GP('pattern');
00607         $pcontent = $GLOBALS['LANG']->getLL('enterRegexPattern') . ' <input type="text" name="pattern" value="' . htmlspecialchars($pattern ? $pattern : $GLOBALS['TYPO3_CONF_VARS']['BE']['fileDenyPattern']) . '"> <input type="submit" name="' . $GLOBALS['LANG']->getLL('SearchButton') . '">';
00608         $this->content.= $this->doc->section($GLOBALS['LANG']->getLL('pattern'), $pcontent, false, true);
00609 
00610         if (strcmp($pattern,''))    {
00611             $dirs = t3lib_div::get_dirs(PATH_site);
00612             $lines=array();
00613             $depth=10;
00614 
00615             foreach ($dirs as $key => $value) {
00616                 $matching_files=array();
00617                 $info='';
00618                 if (!t3lib_div::inList('typo3,typo3conf,tslib,media,t3lib',$value)) {
00619                     $info = $this->findFile(PATH_site.$value.'/',$pattern,$matching_files,$depth);
00620                 }
00621                 if (is_array($info))    {
00622                     $lines[]='<hr><strong>' . $value . '/</strong> ' . $GLOBALS['LANG']->getLL('beingChecked');
00623                     $lines[]=$GLOBALS['LANG']->getLL('directories') . ' ' . $info[0];
00624                     if ($info[2])   $lines[]='<span class="typo3-red">' . $GLOBALS['LANG']->getLL('directoriesTooDeep') . ' ' . $depth . '</span>';
00625                     $lines[]=$GLOBALS['LANG']->getLL('files') . ' ' . $info[1];
00626                     $lines[]=$GLOBALS['LANG']->getLL('matchingFiles') . '<br><nobr><span class="typo3-red">' . implode('<br>', $matching_files) . '</span></nobr>';
00627                 } else {
00628                     $lines[]=$GLOBALS['TBE_TEMPLATE']->dfw('<hr><strong>' . $value . '/</strong> ' . $GLOBALS['LANG']->getLL('notChecked'));
00629                 }
00630             }
00631 
00632             $this->content.=$this->doc->section($GLOBALS['LANG']->getLL('searchingForFilenames'), implode('<br>', $lines), false, true);
00633         }
00634     }
00635 
00636     /**
00637      * Searching for filename pattern recursively in the specified dir.
00638      *
00639      * @param   string      Base directory
00640      * @param   string      Match pattern
00641      * @param   array       Array of matching files, passed by reference
00642      * @param   integer     Depth to recurse
00643      * @return  array       Array with various information about the search result
00644      * @see func_filesearch()
00645      */
00646     function findFile($basedir,$pattern,&$matching_files,$depth)    {
00647         $files_searched=0;
00648         $dirs_searched=0;
00649         $dirs_error=0;
00650 
00651             // Traverse files:
00652         $files = t3lib_div::getFilesInDir($basedir,'',1);
00653         if (is_array($files))   {
00654             $files_searched+=count($files);
00655             foreach ($files as $value) {
00656                 if (preg_match('/'.$pattern.'/i',basename($value))) $matching_files[]=substr($value,strlen(PATH_site));
00657             }
00658         }
00659 
00660 
00661             // Traverse subdirs
00662         if ($depth>0)   {
00663             $dirs = t3lib_div::get_dirs($basedir);
00664             if (is_array($dirs))    {
00665                 $dirs_searched+=count($dirs);
00666 
00667                 foreach ($dirs as $value) {
00668                     $inf= $this->findFile($basedir.$value.'/',$pattern,$matching_files,$depth-1);
00669                     $dirs_searched+=$inf[0];
00670                     $files_searched+=$inf[1];
00671                     $dirs_error=$inf[2];
00672                 }
00673             }
00674         } else {
00675             $dirs = t3lib_div::get_dirs($basedir);
00676             if (is_array($dirs) && count($dirs))    {
00677                 $dirs_error=1;  // Means error - there were further subdirs!
00678             }
00679         }
00680 
00681         return array($dirs_searched,$files_searched,$dirs_error);
00682     }
00683 }
00684 
00685 
00686 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/lowlevel/dbint/index.php'])) {
00687     include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/lowlevel/dbint/index.php']);
00688 }
00689 
00690 
00691 
00692 // Make instance:
00693 $SOBE = t3lib_div::makeInstance('SC_mod_tools_dbint_index');
00694 $SOBE->init();
00695 $SOBE->main();
00696 $SOBE->printContent();
00697 
00698 ?>