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 ***************************************************************/
00063 unset($MCONF);
00064 require ('conf.php');
00065 require ($BACK_PATH.'init.php');
00066 require ($BACK_PATH.'template.php');
00067 require_once (PATH_t3lib.'class.t3lib_admin.php');
00068 require_once (PATH_t3lib.'class.t3lib_loaddbgroup.php');
00069 require_once (PATH_t3lib.'class.t3lib_querygenerator.php');
00070 require_once (PATH_t3lib.'class.t3lib_xml.php');
00071 require_once (PATH_t3lib.'class.t3lib_fullsearch.php');
00072 require_once (PATH_t3lib.'class.t3lib_refindex.php');
00073 
00074 $LANG->includeLLFile('EXT:lowlevel/dbint/locallang.xml');
00075 $BE_USER->modAccess($MCONF,1);
00076 
00077 
00078 
00079 
00080 
00081 
00089 class SC_mod_tools_dbint_index {
00090 
00091         var $MCONF = array();
00092         var $MOD_MENU = array();
00093         var $MOD_SETTINGS = array();
00094         var $doc;
00095 
00096         var $content;
00097         var $menu;
00098 
00099 
00105         function init() {
00106                 global $LANG,$BACK_PATH;
00107                 $this->MCONF = $GLOBALS['MCONF'];
00108 
00109                 $this->menuConfig();
00110 
00111                 $this->doc = t3lib_div::makeInstance('mediumDoc');
00112                 $this->doc->form='<form action="" method="post">';
00113                 $this->doc->backPath = $BACK_PATH;
00114 
00115                                 // JavaScript
00116                 $this->doc->JScode = '
00117                 <script language="javascript" type="text/javascript">
00118                         script_ended = 0;
00119                         function jumpToUrl(URL) {
00120                                 window.location.href = URL;
00121                         }
00122                 </script>
00123                 ';
00124 
00125                 $this->doc->tableLayout = Array (
00126                         'defRow' => Array (
00127                                 '0' => Array('<td valign="top">','</td>'),
00128                                 '1' => Array('<td valign="top">','</td>'),
00129                                 'defCol' => Array('<td><img src="'.$this->doc->backPath.'clear.gif" width="15" height="1" alt="" /></td><td valign="top">','</td>')
00130                         )
00131                 );
00132         }
00133 
00139         function menuConfig()   {
00140                 global $LANG;
00141 
00142                 // MENU-ITEMS:
00143                         // If array, then it's a selector box menu
00144                         // If empty string it's just a variable, that'll be saved.
00145                         // Values NOT in this array will not be saved in the settings-array for the module.
00146                 $this->MOD_MENU = array(
00147                         'function' => array(
00148                                 0 => '[ MENU ]',
00149                                 'records' => 'Record Statistics',
00150                                 'tree' => 'Total Page Tree',
00151                                 'relations' => 'Database Relations',
00152                                 'search' => 'Full search',
00153                                 'filesearch' => 'Find filename',
00154                                 'refindex' => 'Manage Reference Index',
00155                         ),
00156                         'search' => array(
00157                                 'raw' => 'Raw search in all fields',
00158                                 'query' => 'Advanced query'
00159                         ),
00160 
00161                         'search_query_smallparts' => '',
00162                         'search_result_labels' => '',
00163                         'labels_noprefix' => '',
00164                         'options_sortlabel' => '',
00165                         'show_deleted' => '',
00166 
00167                         'queryConfig' => '',    // Current query
00168                         'queryTable' => '',     // Current table
00169                         'queryFields' => '',    // Current tableFields
00170                         'queryLimit' => '',     // Current limit
00171                         'queryOrder' => '',     // Current Order field
00172                         'queryOrderDesc' => '', // Current Order field descending flag
00173                         'queryOrder2' => '',    // Current Order2 field
00174                         'queryOrder2Desc' => '',        // Current Order2 field descending flag
00175                         'queryGroup' => '',     // Current Group field
00176 
00177                         'storeArray' => '',     // Used to store the available Query config memory banks
00178                         'storeQueryConfigs' => '',      // Used to store the available Query configs in memory
00179 
00180                         'search_query_makeQuery' => array(
00181                                 'all' => 'Select records',
00182                                 'count' => 'Count results',
00183                                 'explain' => 'Explain query',
00184                                 'csv' => 'CSV Export',
00185                                 'xml' => 'XML Export'
00186                         ),
00187 
00188                         'sword' => ''
00189                 );
00190                         // CLEAN SETTINGS
00191                 $OLD_MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU,'', $this->MCONF['name'], 'ses');
00192                 $this->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU, t3lib_div::_GP('SET'), $this->MCONF['name'], 'ses');
00193 
00194                 if (t3lib_div::_GP('queryConfig'))      {
00195                         $qA = t3lib_div::_GP('queryConfig');
00196                         $this->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU, array('queryConfig'=>serialize($qA)), $this->MCONF['name'], 'ses');
00197                 }
00198                 $addConditionCheck = t3lib_div::_GP('qG_ins');
00199                 foreach ($OLD_MOD_SETTINGS as $key=>$val)       {
00200                         if (substr($key, 0, 5)=='query' && $this->MOD_SETTINGS[$key]!=$val && $key!='queryLimit' && $key!='use_listview')       {
00201                                 $setLimitToStart = 1;
00202                                 if ($key == 'queryTable' && !$addConditionCheck) {
00203                                         $this->MOD_SETTINGS['queryConfig'] = '';
00204                                 }
00205                         }
00206                         if ($key=='queryTable' && $this->MOD_SETTINGS[$key]!=$val)      {
00207                                 $this->MOD_SETTINGS['queryFields'] = '';
00208                         }
00209                 }
00210                 if ($setLimitToStart)   {
00211                         $currentLimit = explode(',',$this->MOD_SETTINGS['queryLimit']);
00212                         if ($currentLimit[1])   {
00213                                 $this->MOD_SETTINGS['queryLimit']='0,'.$currentLimit[1];
00214                         } else {
00215                                 $this->MOD_SETTINGS['queryLimit']='0';
00216                         }
00217                         $this->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU, $this->MOD_SETTINGS, $this->MCONF['name'], 'ses');
00218                 }
00219         }
00220 
00226         function main() {
00227                 global $BE_USER,$LANG;
00228 
00229                         // Content creation
00230                 $this->content.= $this->doc->startPage($LANG->getLL('title'));
00231                 if (!$GLOBALS['BE_USER']->userTS['mod.']['dbint.']['disableTopMenu'])   {
00232                         $this->menu = t3lib_BEfunc::getFuncMenu(0,'SET[function]',$this->MOD_SETTINGS['function'],$this->MOD_MENU['function']);
00233                 }
00234 
00235                 switch($this->MOD_SETTINGS['function']) {
00236                         case 'search':
00237                                 $this->func_search();
00238                         break;
00239                         case 'tree':
00240                                 $this->func_tree();
00241                         break;
00242                         case 'records':
00243                                 $this->func_records();
00244                         break;
00245                         case 'relations':
00246                                 $this->func_relations();
00247                         break;
00248                         case 'filesearch':
00249                                 $this->func_filesearch();
00250                         break;
00251                         case 'refindex':
00252                                 $this->func_refindex();
00253                         break;
00254                         default:
00255                                 $this->func_default();
00256                         break;
00257                 }
00258 
00259                 if ($BE_USER->mayMakeShortcut())        {
00260                         $this->content.=$this->doc->spacer(20).
00261                                                 $this->doc->section('',$this->doc->makeShortcutIcon('','function,search,search_query_makeQuery',$this->MCONF['name']));
00262                 }
00263         }
00264 
00270         function printContent() {
00271 
00272                 $this->content.= $this->doc->endPage();
00273                 echo $this->content;
00274         }
00275 
00281         function func_default() {
00282                 global $LANG;
00283 
00284                 $this->content.=$this->doc->header($LANG->getLL('title'));
00285                 $this->content.=$this->doc->spacer(5);
00286                 $this->content.=$this->doc->section('',$this->menu);
00287                 $this->content.=$this->doc->section('<a href="index.php?SET[function]=records">'.$LANG->getLL('records').'</a>',$LANG->getLL('records_description'),1,1,0,1);
00288                 $this->content.=$this->doc->section('<a href="index.php?SET[function]=tree">'.$LANG->getLL('tree').'</a>',$LANG->getLL('tree_description'),1,1,0,1);
00289                 $this->content.=$this->doc->section('<a href="index.php?SET[function]=relations">'.$LANG->getLL('relations').'</a>',$LANG->getLL('relations_description'),1,1,0,1);
00290                 $this->content.=$this->doc->section('<a href="index.php?SET[function]=search">'.$LANG->getLL('search').'</a>',$LANG->getLL('search_description'),1,1,0,1);
00291                 $this->content.=$this->doc->section('<a href="index.php?SET[function]=filesearch">'.$LANG->getLL('filesearch').'</a>',$LANG->getLL('filesearch_description'),1,1,0,1);
00292                 $this->content.=$this->doc->section('<a href="index.php?SET[function]=refindex">'.$LANG->getLL('refindex').'</a>',$LANG->getLL('refindex_description'),1,1,0,1);
00293                 $this->content.=$this->doc->spacer(50);
00294         }
00295 
00296 
00297 
00298 
00299 
00300 
00301 
00302 
00303         /****************************
00304          *
00305          * Functionality implementation
00306          *
00307          ****************************/
00308 
00314         function func_refindex()        {
00315                 global $TYPO3_DB,$TCA;
00316 
00317                 $this->content.=$this->doc->section('',$this->menu);
00318                 $this->content.=$this->doc->section('',$menu2).$this->doc->spacer(10);
00319 
00320                 if (t3lib_div::_GP('_update') || t3lib_div::_GP('_check'))      {
00321                         $testOnly = t3lib_div::_GP('_check')?TRUE:FALSE;
00322 
00323                                 // Call the functionality
00324                         $refIndexObj = t3lib_div::makeInstance('t3lib_refindex');
00325                         list($headerContent,$bodyContent) = $refIndexObj->updateIndex($testOnly);
00326 
00327                                 // Output content:
00328                         $this->content.=$this->doc->section($headerContent,str_replace(chr(10),'<br/>',$bodyContent),0,1);
00329                 }
00330 
00331                         // Output content:
00332                 $content = 'Click here to update reference index: <input type="submit" name="_update" value="Update now!" /><br/>';
00333                 $content.= 'Click here to test reference index: <input type="submit" name="_check" value="Check now!" /><br/>';
00334                 $content.= 'You can also run the check as a shell script if the processing takes longer than the PHP max_execution_time allows:<br/>'.
00335                                         t3lib_extMgm::extPath('lowlevel').'dbint/cli/refindex_cli.phpsh';
00336                 $this->content.=$this->doc->section('Update reference index',$content,0,1);
00337         }
00338 
00344         function func_search()  {
00345                 global $LANG;
00346 
00347                 $fullsearch = t3lib_div::makeInstance('t3lib_fullsearch');
00348                 $this->content.= $this->doc->header($LANG->getLL('search'));
00349                 $this->content.= $this->doc->spacer(5);
00350 
00351                 $menu2='';
00352                 if (!$GLOBALS['BE_USER']->userTS['mod.']['dbint.']['disableTopMenu'])   {
00353                         $menu2 = t3lib_BEfunc::getFuncMenu(0, 'SET[search]', $this->MOD_SETTINGS['search'], $this->MOD_MENU['search']);
00354                 }
00355                 if ($this->MOD_SETTINGS['search']=='query' && !$GLOBALS['BE_USER']->userTS['mod.']['dbint.']['disableTopMenu']) {
00356                         $menu2 .= t3lib_BEfunc::getFuncMenu(0, 'SET[search_query_makeQuery]', $this->MOD_SETTINGS['search_query_makeQuery'], $this->MOD_MENU['search_query_makeQuery']). '<br />';
00357                 }
00358                 if (!$GLOBALS['BE_USER']->userTS['mod.']['dbint.']['disableTopCheckboxes'] && $this->MOD_SETTINGS['search']=='query')   {
00359                         $menu2 .= t3lib_BEfunc::getFuncCheck($GLOBALS['SOBE']->id, 'SET[search_query_smallparts]', $this->MOD_SETTINGS['search_query_smallparts']).'&nbsp;Show SQL parts<br />';
00360                         $menu2 .= t3lib_BEfunc::getFuncCheck($GLOBALS['SOBE']->id, 'SET[search_result_labels]', $this->MOD_SETTINGS['search_result_labels']).'&nbsp;Use formatted strings, labels and dates instead of original values for results<br />';
00361                         $menu2 .= t3lib_BEfunc::getFuncCheck($GLOBALS['SOBE']->id, 'SET[labels_noprefix]', $this->MOD_SETTINGS['labels_noprefix']).'&nbsp;Don\'t use original values in brackets as prefix for labelled results<br />';
00362                         $menu2 .= t3lib_BEfunc::getFuncCheck($GLOBALS['SOBE']->id, 'SET[options_sortlabel]', $this->MOD_SETTINGS['options_sortlabel']).'&nbsp;Sort selectbox options for relations by label and not by value<br />';
00363                         $menu2 .= t3lib_BEfunc::getFuncCheck($GLOBALS['SOBE']->id, 'SET[show_deleted]', $this->MOD_SETTINGS['show_deleted']).'&nbsp;Show even deleted entries (with undelete buttons)';
00364                 }
00365 
00366                 $this->content.= $this->doc->section('',$this->menu);//$this->doc->divider(5);
00367                 $this->content.= $this->doc->section('',$menu2).$this->doc->spacer(10);
00368 
00369                 switch($this->MOD_SETTINGS['search'])           {
00370                         case 'query':
00371                                 $this->content.=$fullsearch->queryMaker();
00372                         break;
00373                         case 'raw':
00374                         default:
00375                                 $this->content.=$this->doc->section('Search options:',$fullsearch->form(),0,1);
00376                                 $this->content.=$this->doc->section('Result:',$fullsearch->search(),0,1);
00377                         break;
00378                 }
00379         }
00380 
00386         function func_tree()    {
00387                 global $LANG,$BACK_PATH;
00388 
00389                 $startID = 0;
00390                 $admin = t3lib_div::makeInstance('t3lib_admin');
00391                 $admin->genTree_makeHTML=1;
00392                 $admin->backPath = $BACK_PATH;
00393                 $admin->genTree(intval($startID),'<img src="'.$BACK_PATH.'clear.gif" width="1" height="1" align="top" alt="" />');
00394 
00395                 $this->content.= $this->doc->header($LANG->getLL('tree'));
00396                 $this->content.= $this->doc->spacer(5);
00397                 $this->content.= $this->doc->section('',$this->menu).$this->doc->divider(5);
00398                 $this->content.= $this->doc->sectionEnd();
00399 
00400                 $this->content.= $admin->genTree_HTML;
00401                 $this->content.= $admin->lostRecords($admin->genTree_idlist.'0');
00402         }
00403 
00409         function func_records() {
00410                 global $LANG,$TCA,$BACK_PATH,$PAGES_TYPES;
00411 
00412                 $admin = t3lib_div::makeInstance('t3lib_admin');
00413                 $admin->genTree_makeHTML = 0;
00414                 $admin->backPath = $BACK_PATH;
00415                 $admin->genTree(0,'');
00416 
00417                 $this->content.= $this->doc->header($LANG->getLL('records'));
00418                 $this->content.= $this->doc->spacer(5);
00419                 $this->content.= $this->doc->section('',$this->menu);
00420 
00421                         // Pages stat
00422                 $codeArr=Array();
00423                 $i++;
00424                 $codeArr[$i][]='<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/i/pages.gif','width="18" height="16"').' hspace="4" align="top" alt="" />';
00425                 $codeArr[$i][]=$LANG->getLL('total_pages');
00426                 $codeArr[$i][]=count($admin->page_idArray);
00427                 $i++;
00428                 if (t3lib_extMgm::isLoaded('cms'))      {
00429                         $codeArr[$i][]='<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/hidden_page.gif','width="18" height="16"').' hspace="4" align="top">';
00430                         $codeArr[$i][]=$LANG->getLL('hidden_pages');
00431                         $codeArr[$i][]=$admin->recStat['hidden'];
00432                         $i++;
00433                 }
00434                 $codeArr[$i][]='<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/deleted_page.gif','width="18" height="16"').' hspace="4" align="top">';
00435                 $codeArr[$i][]=$LANG->getLL('deleted_pages');
00436                 $codeArr[$i][]=$admin->recStat['deleted'];
00437 
00438                 $this->content.=$this->doc->section($LANG->getLL('pages'),$this->doc->table($codeArr),0,1);
00439 
00440                         // Doktype
00441                 $codeArr=Array();
00442                 $doktype= $TCA['pages']['columns']['doktype']['config']['items'];
00443                 if (is_array($doktype)) {
00444                         reset($doktype);
00445                         while(list($n,$setup) = each($doktype)) {
00446                                 if ($setup[1]!='--div--')       {
00447                                         $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">';
00448                                         $codeArr[$n][] = $LANG->sL($setup[0]).' ('.$setup[1].')';
00449                                         $codeArr[$n][] = intval($admin->recStat[doktype][$setup[1]]);
00450                                 }
00451                         }
00452                         $this->content.=$this->doc->section($LANG->getLL('doktype'),$this->doc->table($codeArr),0,1);
00453                 }
00454 
00455                         // Tables and lost records
00456                 $id_list = '-1,0,'.implode(array_keys($admin->page_idArray),',');
00457                 $id_list = t3lib_div::rm_endcomma($id_list);
00458                 $admin->lostRecords($id_list);
00459 
00460                 if ($admin->fixLostRecord(t3lib_div::_GET('fixLostRecords_table'),t3lib_div::_GET('fixLostRecords_uid')))       {
00461                         $admin = t3lib_div::makeInstance('t3lib_admin');
00462                         $admin->backPath = $BACK_PATH;
00463                         $admin->genTree(0,'');
00464                         $id_list = '-1,0,'.implode(array_keys($admin->page_idArray),',');
00465                         $id_list = t3lib_div::rm_endcomma($id_list);
00466                         $admin->lostRecords($id_list);
00467                 }
00468 
00469                 $codeArr = Array();
00470                 $countArr = $admin->countRecords($id_list);
00471                 if (is_array($TCA))     {
00472                         reset($TCA);
00473                         while(list($t)=each($TCA))      {
00474                                 $codeArr[$t][]=t3lib_iconWorks::getIconImage($t,array(),$BACK_PATH,'hspace="4" align="top"');
00475                                 $codeArr[$t][]=$LANG->sL($TCA[$t]['ctrl']['title']);
00476                                 $codeArr[$t][]=$t;
00477 
00478                                 if ($countArr['all'][$t])       {
00479                                         $theNumberOfRe = intval($countArr['non_deleted'][$t]).'/'.(intval($countArr['all'][$t])-intval($countArr['non_deleted'][$t]));
00480                                 } else {
00481                                         $theNumberOfRe ='';
00482                                 }
00483                                 $codeArr[$t][]=$theNumberOfRe;
00484 
00485                                 $lr='';
00486                                 if (is_array($admin->lRecords[$t]))     {
00487                                         reset($admin->lRecords[$t]);
00488                                         while(list(,$data)=each($admin->lRecords[$t]))  {
00489                                                 if (!t3lib_div::inList($admin->lostPagesList,$data[pid]))       {
00490                                                         $lr.='<nobr><b><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="'.$LANG->getLL('fixLostRecord').'"></a>uid:'.$data[uid].', pid:'.$data[pid].', '.t3lib_div::fixed_lgd(strip_tags($data[title]),20).'</b></nobr><br>';
00491                                                 } else {
00492                                                         $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(strip_tags($data[title]),20).'</font></nobr><br>';
00493                                                 }
00494                                         }
00495                                 }
00496                                 $codeArr[$t][]=$lr;
00497                         }
00498                         $this->content.=$this->doc->section($LANG->getLL('tables'),$this->doc->table($codeArr),0,1);
00499                 }
00500         }
00501 
00507         function func_relations()       {
00508                 global $LANG,$BACK_PATH;
00509 
00510                 $this->content.= $this->doc->header($LANG->getLL('relations'));
00511                 $this->content.= $this->doc->spacer(5);
00512                 $this->content.= $this->doc->section('',$this->menu);
00513 
00514                 $admin = t3lib_div::makeInstance('t3lib_admin');
00515                 $admin->genTree_makeHTML=0;
00516                 $admin->backPath = $BACK_PATH;
00517 
00518                 $fkey_arrays = $admin->getGroupFields('');
00519                 $admin->selectNonEmptyRecordsWithFkeys($fkey_arrays);
00520 
00521 
00522                 $fileTest = $admin->testFileRefs();
00523 
00524                 $code='';
00525                 if (is_array($fileTest['noReferences']))        {
00526                         while(list(,$val)=each($fileTest['noReferences']))      {
00527                                 $code.='<nobr>'.$val[0].'/<b>'.$val[1].'</b></nobr><br>';
00528                         }
00529                 }
00530                 $this->content.=$this->doc->section($LANG->getLL('files_no_ref'),$code,1,1);
00531 
00532                 $code='';
00533                 if (is_array($fileTest['moreReferences']))      {
00534                         while(list(,$val)=each($fileTest['moreReferences']))    {
00535                                 $code.='<nobr>'.$val[0].'/<b>'.$val[1].'</b>: '.$val[2].' references:</nobr><br>'.$val[3].'<br><br>';
00536                         }
00537                 }
00538                 $this->content.=$this->doc->section($LANG->getLL('files_many_ref'),$code,1,1);
00539 
00540                 $code='';
00541                 if (is_array($fileTest['noFile']))      {
00542                         ksort($fileTest['noFile']);
00543                         reset($fileTest['noFile']);
00544                         while(list(,$val)=each($fileTest['noFile']))    {
00545                                 $code.='<nobr>'.$val[0].'/<b>'.$val[1].'</b> is missing! </nobr><br>Referenced from: '.$val[2].'<br><br>';
00546                         }
00547                 }
00548                 $this->content.=$this->doc->section($LANG->getLL('files_no_file'),$code,1,1);
00549                 $this->content.=$this->doc->section($LANG->getLL('select_db'),$admin->testDBRefs($admin->checkSelectDBRefs),1,1);
00550                 $this->content.=$this->doc->section($LANG->getLL('group_db'),$admin->testDBRefs($admin->checkGroupDBRefs),1,1);
00551         }
00552 
00558         function func_filesearch()      {
00559                 global $LANG;
00560 
00561                 $this->content.= $this->doc->header($LANG->getLL('relations'));
00562                 $this->content.= $this->doc->spacer(5);
00563                 $this->content.= $this->doc->section('',$this->menu);
00564 
00565 
00566                 $pattern = t3lib_div::_GP('pattern');
00567                 $pcontent = 'Enter regex pattern: <input type="text" name="pattern" value="'.htmlspecialchars($pattern?$pattern:$GLOBALS['TYPO3_CONF_VARS']['BE']['fileDenyPattern']).'"> <input type="submit" name="Search">';
00568                 $this->content.= $this->doc->section('Pattern',$pcontent,0,1);
00569 
00570                 if (strcmp($pattern,''))        {
00571                         $dirs = t3lib_div::get_dirs(PATH_site);
00572         #               debug($dirs);
00573                         $lines=array();
00574                         $depth=10;
00575 
00576                         foreach ($dirs as $key => $value) {
00577                                 $matching_files=array();
00578                                 $info='';
00579                                 if (!t3lib_div::inList('typo3,typo3conf,tslib,media,t3lib',$value))     {
00580                                         $info = $this->findFile(PATH_site.$value.'/',$pattern,$matching_files,$depth);
00581                                 }
00582                                 if (is_array($info))    {
00583                                         $lines[]='<hr><b>'.$value.'/</b> being checked...';
00584                                         $lines[]='Dirs: '.$info[0];
00585                                         if ($info[2])   $lines[]='<span class="typo3-red">ERROR: Directories deeper than '.$depth.' levels</span>';
00586                                         $lines[]='Files: '.$info[1];
00587                                         $lines[]='Matching files:<br><nobr><span class="typo3-red">'.implode('<br>',$matching_files).'</span></nobr>';
00588                                 } else {
00589                                         $lines[]=$GLOBALS['TBE_TEMPLATE']->dfw('<hr><b>'.$value.'/</b> not checked.');
00590                                 }
00591                         }
00592 
00593                         $this->content.=$this->doc->section('Searching for filenames:',implode('<br>',$lines),0,1);
00594                 }
00595         }
00596 
00607         function findFile($basedir,$pattern,&$matching_files,$depth)    {
00608                 $files_searched=0;
00609                 $dirs_searched=0;
00610                 $dirs_error=0;
00611 
00612                         // Traverse files:
00613                 $files = t3lib_div::getFilesInDir($basedir,'',1);
00614                 if (is_array($files))   {
00615                         $files_searched+=count($files);
00616                         foreach ($files as $value) {
00617                                 if (eregi($pattern,basename($value)))   $matching_files[]=substr($value,strlen(PATH_site));
00618                         }
00619                 }
00620 
00621 
00622                         // Traverse subdirs
00623                 if ($depth>0)   {
00624                         $dirs = t3lib_div::get_dirs($basedir);
00625                         if (is_array($dirs))    {
00626                                 $dirs_searched+=count($dirs);
00627 
00628                                 foreach ($dirs as $value) {
00629                                         $inf= $this->findFile($basedir.$value.'/',$pattern,$matching_files,$depth-1);
00630                                         $dirs_searched+=$inf[0];
00631                                         $files_searched+=$inf[1];
00632                                         $dirs_error=$inf[2];
00633                                 }
00634                         }
00635                 } else {
00636                         $dirs = t3lib_div::get_dirs($basedir);
00637                         if (is_array($dirs) && count($dirs))    {
00638                                 $dirs_error=1;  // Means error - there were further subdirs!
00639                         }
00640                 }
00641 
00642                 return array($dirs_searched,$files_searched,$dirs_error);
00643         }
00644 }
00645 
00646 // Include extension?
00647 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/lowlevel/dbint/index.php'])    {
00648         include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/lowlevel/dbint/index.php']);
00649 }
00650 
00651 
00652 
00653 
00654 
00655 
00656 
00657 
00658 
00659 // Make instance:
00660 $SOBE = t3lib_div::makeInstance('SC_mod_tools_dbint_index');
00661 $SOBE->init();
00662 $SOBE->main();
00663 $SOBE->printContent();
00664 ?>


Généré par Les spécialistes TYPO3 avec  doxygen 1.4.6