Reverting a change because it was made in the wrong branch.
[Packages/TYPO3.CMS.git] / typo3 / sysext / lowlevel / dbint / index.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2005 Kasper Skaarhoj (kasperYYYY@typo3.com)
6 * All rights reserved
7 *
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 * A copy is found in the textfile GPL.txt and important notices to the license
17 * from the author is found in LICENSE.txt distributed with these scripts.
18 *
19 *
20 * This script is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
27 /**
28 * Module: Database integrity check
29 *
30 * This module lets you check if all pages and the records relate properly to each other
31 *
32 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
33 */
34
35
36 unset($MCONF);
37 require ('conf.php');
38 require ($BACK_PATH.'init.php');
39 require ($BACK_PATH.'template.php');
40 require_once (PATH_t3lib.'class.t3lib_admin.php');
41 require_once (PATH_t3lib.'class.t3lib_loaddbgroup.php');
42 require_once (PATH_t3lib.'class.t3lib_querygenerator.php');
43 require_once (PATH_t3lib.'class.t3lib_xml.php');
44 require_once (PATH_t3lib.'class.t3lib_fullsearch.php');
45 require_once (PATH_t3lib.'class.t3lib_refindex.php');
46
47 $BE_USER->modAccess($MCONF,1);
48
49
50
51 // **************************
52 // Setting english (ONLY!) LOCAL_LANG
53 // **************************
54 $LOCAL_LANG = Array (
55 'default' => Array (
56 'tables' => 'Tables:',
57 'fixLostRecord' => 'Click to move this lost record to rootlevel (pid=0)',
58
59 'doktype' => 'Document types:',
60 'pages' => 'Pages:',
61 'total_pages' => 'Total number of pages:',
62 'deleted_pages' => 'Marked-deleted pages:',
63 'hidden_pages' => 'Hidden pages:',
64 'relations' => 'Relations:',
65 'relations_description' => 'This will analyse the content of the tables and check if there are \'empty\' relations between records or if files are missing from their expected position.',
66
67 'files_many_ref' => 'Files referenced from more than one record:',
68 'files_no_ref' => 'Files with no references at all (delete them!):',
69 'files_no_file' => 'Missing files:',
70 'select_db' => 'Select fields:',
71 'group_db' => 'Group fields:',
72
73 'tree' => 'The Page Tree:',
74 'tree_description' => 'This shows all pages in the system in one large tree. Beware that this will probably result in a very long document which will also take some time for the server to compute!',
75 'records' => 'Records Statistics:',
76 'records_description' => 'This shows some statistics for the records in the database. This runs through the entire page-tree and therefore it will also load the server heavily!',
77 'search' => 'Search Whole Database',
78 'search_description' => 'This searches through all database tables and records for a text string.',
79 'filesearch' => 'Search all filenames for pattern',
80 'filesearch_description' => 'Will search recursively for filenames in the PATH_site (subdirs to the website path) matching a certain regex pattern.',
81 'title' => 'Database integrity check'
82 )
83 );
84
85
86
87
88
89 // ***************************
90 // Script Classes
91 // ***************************
92 class SC_mod_tools_dbint_index {
93 var $MCONF=array();
94 var $MOD_MENU=array();
95 var $MOD_SETTINGS=array();
96 var $doc;
97
98 var $content;
99 var $menu;
100
101 /**
102 * @return [type] ...
103 */
104 function init() {
105 global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$CLIENT,$TYPO3_CONF_VARS;
106 $this->MCONF = $GLOBALS['MCONF'];
107
108 $this->menuConfig();
109
110 $this->doc = t3lib_div::makeInstance('mediumDoc');
111 $this->doc->form='<form action="" method="POST">';
112 $this->doc->backPath = $BACK_PATH;
113 // JavaScript
114 $this->doc->JScode = '
115 <script language="javascript" type="text/javascript">
116 script_ended = 0;
117 function jumpToUrl(URL) {
118 document.location = URL;
119 }
120 </script>
121 ';
122 $this->doc->tableLayout = Array (
123 'defRow' => Array (
124 '0' => Array('<td valign="top">','</td>'),
125 '1' => Array('<td valign="top">','</td>'),
126 'defCol' => Array('<TD><img src="'.$this->doc->backPath.'clear.gif" width="15" height="1"></td><td valign="top">','</td>')
127 )
128 );
129 }
130
131 /**
132 * @return [type] ...
133 */
134 function menuConfig() {
135 global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$CLIENT,$TYPO3_CONF_VARS;
136
137 // MENU-ITEMS:
138 // If array, then it's a selector box menu
139 // If empty string it's just a variable, that'll be saved.
140 // Values NOT in this array will not be saved in the settings-array for the module.
141 $this->MOD_MENU = array(
142 'function' => array(
143 0 => '[ MENU ]',
144 'records' => 'Record Statistics',
145 'tree' => 'Total Page Tree',
146 'relations' => 'Database Relations',
147 'search' => 'Full search',
148 'filesearch' => 'Find filename',
149 'refindex' => 'Manage Reference Index',
150 ),
151 'search' => array(
152 'raw' => 'Raw search in all fields',
153 'query' => 'Advanced query'
154 ),
155
156 'search_query_smallparts' => '',
157
158 'queryConfig' => '', // Current query
159 'queryTable' => '', // Current table
160 'queryFields' => '', // Current tableFields
161 'queryLimit' => '', // Current limit
162 'queryOrder' => '', // Current Order field
163 'queryOrderDesc' => '', // Current Order field descending flag
164 'queryOrder2' => '', // Current Order2 field
165 'queryOrder2Desc' => '', // Current Order2 field descending flag
166 'queryGroup' => '', // Current Group field
167
168 'storeArray' => '', // Used to store the available Query config memory banks
169 'storeQueryConfigs' => '', // Used to store the available Query configs in memory
170
171 'search_query_makeQuery' => array(
172 'all' => 'Select records',
173 'count' => 'Count results',
174 'explain' => 'Explain query',
175 'csv' => 'CSV Export',
176 'xml' => 'XML Export'
177 ),
178
179 'sword' => ''
180 );
181 // CLEANSE SETTINGS
182 $this->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU, t3lib_div::_GP('SET'), $this->MCONF['name'], 'ses');
183
184 if (t3lib_div::_GP('queryConfig')) {
185 $qA = t3lib_div::_GP('queryConfig');
186 $this->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU, array('queryConfig'=>serialize($qA)), $this->MCONF['name'], 'ses');
187 }
188 }
189
190 /**
191 * @return [type] ...
192 */
193 function main() {
194 global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$CLIENT,$TYPO3_CONF_VARS;
195
196 // **************************
197 // Content creation
198 // **************************
199 $this->content.=$this->doc->startPage($LANG->getLL('title'));
200 $this->menu=t3lib_BEfunc::getFuncMenu(0,'SET[function]',$this->MOD_SETTINGS['function'],$this->MOD_MENU['function']);
201
202 switch($this->MOD_SETTINGS['function']) {
203 case 'search':
204 $this->func_search();
205 break;
206 case 'tree':
207 $this->func_tree();
208 break;
209 case 'records':
210 $this->func_records();
211 break;
212 case 'relations':
213 $this->func_relations();
214 break;
215 case 'filesearch':
216 $this->func_filesearch();
217 break;
218 case 'refindex':
219 $this->func_refindex();
220 break;
221 default:
222 $this->func_default();
223 break;
224 }
225
226 if ($BE_USER->mayMakeShortcut()) {
227 $this->content.=$this->doc->spacer(20).
228 $this->doc->section('',$this->doc->makeShortcutIcon('','function,search,search_query_makeQuery',$this->MCONF['name']));
229 }
230 }
231
232 /**
233 * @return [type] ...
234 */
235 function printContent() {
236
237 $this->content.=$this->doc->endPage();
238 echo $this->content;
239 }
240
241 function func_refindex() {
242 global $TCA,$TYPO3_DB;
243
244 $this->content.=$this->doc->section('',$this->menu);//$this->doc->divider(5);
245 $this->content.=$this->doc->section('',$menu2).$this->doc->spacer(10);
246
247 if (t3lib_div::_GP('_update') || t3lib_div::_GP('_check')) {
248 $testOnly = t3lib_div::_GP('_check')?TRUE:FALSE;
249 $errors = array();
250 $tableNames = array();
251 $recCount=0;
252 $tableCount=0;
253
254 // Traverse all tables:
255 foreach($TCA as $tableName => $cfg) {
256 $tableNames[] = $tableName;
257 $tableCount++;
258
259 // Traverse all non-deleted records in tables:
260 $allRecs = $TYPO3_DB->exec_SELECTgetRows('uid',$tableName,'1'.t3lib_BEfunc::deleteClause($tableName));
261 $uidList = array(0);
262 foreach($allRecs as $recdat) {
263 $refIndexObj = t3lib_div::makeInstance('t3lib_refindex');
264 $result = $refIndexObj->updateRefIndexTable($tableName,$recdat['uid'],$testOnly);
265 $uidList[]= $recdat['uid'];
266 $recCount++;
267
268 if ($result['addedNodes'] || $result['deletedNodes']) {
269 $errors[] = 'Record '.$tableName.':'.$recdat['uid'].' had '.$result['addedNodes'].' added indexes and '.$result['deletedNodes'].' deleted indexes';
270 #$errors[] = t3lib_div::view_array($result);
271 }
272 }
273
274 // Searching lost indexes for this table:
275 $where = 'tablename='.$TYPO3_DB->fullQuoteStr($tableName,'sys_refindex').' AND recuid NOT IN ('.implode(',',$uidList).')';
276 $lostIndexes = $TYPO3_DB->exec_SELECTgetRows('hash','sys_refindex',$where);
277 if (count($lostIndexes)) {
278 $errors[] = 'Table '.$tableName.' has '.count($lostIndexes).' lost indexes which are now deleted';
279 if (!$testOnly) $TYPO3_DB->exec_DELETEquery('sys_refindex',$where);
280 }
281 }
282
283 // Searching lost indexes for non-existing tables:
284 $where = 'tablename NOT IN ('.implode(',',$TYPO3_DB->fullQuoteArray($tableNames,'sys_refindex')).')';
285 $lostTables = $TYPO3_DB->exec_SELECTgetRows('hash','sys_refindex',$where);
286 if (count($lostTables)) {
287 $errors[] = 'Index table hosted '.count($lostTables).' indexes for non-existing tables, now removed';
288 if (!$testOnly) $TYPO3_DB->exec_DELETEquery('sys_refindex',$where);
289 }
290
291 $testedHowMuch = $recCount.' records from '.$tableCount.' tables were checked/updated.<br/>';
292 // Output content:
293 $this->content.=$this->doc->section($testOnly ? 'Reference Index TESTED (nothing written)' : 'Reference Index Updated',$testedHowMuch.(count($errors)?implode('<br/>',$errors):'Index Integrity was perfect!'),0,1);
294 }
295
296 // Output content:
297 $content = 'Click here to update reference index: <input type="submit" name="_update" value="Update now!" /><br/>';
298 $content.= 'Click here to test reference index: <input type="submit" name="_check" value="Check now!" />';
299 $this->content.=$this->doc->section('Update reference index',$content,0,1);
300 }
301
302 /**
303 * @return [type] ...
304 */
305 function func_search() {
306 global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$CLIENT,$TYPO3_CONF_VARS;
307
308 $fullsearch = t3lib_div::makeInstance('t3lib_fullsearch');
309 $this->content.=$this->doc->header($LANG->getLL('search'));
310 $this->content.=$this->doc->spacer(5);
311
312 $menu2=t3lib_BEfunc::getFuncMenu(0,'SET[search]',$this->MOD_SETTINGS['search'],$this->MOD_MENU['search']);
313 if ($this->MOD_SETTINGS['search']=='query') {
314 $menu2.=t3lib_BEfunc::getFuncMenu(0,'SET[search_query_makeQuery]',$this->MOD_SETTINGS['search_query_makeQuery'],$this->MOD_MENU['search_query_makeQuery']).
315 '&nbsp;'.t3lib_BEfunc::getFuncCheck($GLOBALS['SOBE']->id,'SET[search_query_smallparts]',$this->MOD_SETTINGS['search_query_smallparts']).'&nbsp;Show SQL parts';
316 }
317 $this->content.=$this->doc->section('',$this->menu);//$this->doc->divider(5);
318 $this->content.=$this->doc->section('',$menu2).$this->doc->spacer(10);
319
320 switch($this->MOD_SETTINGS['search']) {
321 case 'query':
322 $this->content.=$fullsearch->queryMaker();
323 break;
324 case 'raw':
325 default:
326 $this->content.=$this->doc->section('Search options:',$fullsearch->form(),0,1);
327 $this->content.=$this->doc->section('Result:',$fullsearch->search(),0,1);
328 break;
329 }
330 }
331
332 /**
333 * @return [type] ...
334 */
335 function func_tree() {
336 global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$CLIENT,$TYPO3_CONF_VARS;
337
338 $startID=0;
339 $admin = t3lib_div::makeInstance('t3lib_admin');
340 $admin->genTree_makeHTML=1;
341 $admin->backPath = $BACK_PATH;
342 $admin->genTree(intval($startID),'<img src="'.$BACK_PATH.'clear.gif" width="1" height="1" align="top">');
343
344 $this->content.=$this->doc->header($LANG->getLL('tree'));
345 $this->content.=$this->doc->spacer(5);
346 $this->content.=$this->doc->section('',$this->menu).$this->doc->divider(5);
347 $this->content.=$this->doc->sectionEnd();
348
349 $this->content.=$admin->genTree_HTML;
350 $this->content.=$admin->lostRecords($admin->genTree_idlist.'0');
351 }
352
353 /**
354 * @return [type] ...
355 */
356 function func_records() {
357 global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$CLIENT,$TYPO3_CONF_VARS;
358 global $PAGES_TYPES;
359
360 $admin = t3lib_div::makeInstance('t3lib_admin');
361 $admin->genTree_makeHTML=0;
362 $admin->backPath = $BACK_PATH;
363 $admin->genTree(0,'');
364
365 $this->content.=$this->doc->header($LANG->getLL('records'));
366 $this->content.=$this->doc->spacer(5);
367 $this->content.=$this->doc->section('',$this->menu);
368
369 // Pages stat
370 $codeArr=Array();
371 $i++;
372 $codeArr[$i][]='<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/i/pages.gif','width="18" height="16"').' hspace="4" align="top">';
373 $codeArr[$i][]=$LANG->getLL('total_pages');
374 $codeArr[$i][]=count($admin->page_idArray);
375 $i++;
376 if (t3lib_extMgm::isLoaded('cms')) {
377 $codeArr[$i][]='<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/hidden_page.gif','width="18" height="16"').' hspace="4" align="top">';
378 $codeArr[$i][]=$LANG->getLL('hidden_pages');
379 $codeArr[$i][]=$admin->recStat['hidden'];
380 $i++;
381 }
382 $codeArr[$i][]='<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/deleted_page.gif','width="18" height="16"').' hspace="4" align="top">';
383 $codeArr[$i][]=$LANG->getLL('deleted_pages');
384 $codeArr[$i][]=$admin->recStat['deleted'];
385
386 $this->content.=$this->doc->section($LANG->getLL('pages'),$this->doc->table($codeArr),0,1);
387
388 // Doktype
389 $codeArr=Array();
390 $doktype=$TCA['pages']['columns']['doktype']['config']['items'];
391 if (is_array($doktype)) {
392 reset($doktype);
393 while(list($n,$setup)=each($doktype)) {
394 if ($setup[1]!='--div--') {
395 $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">';
396 $codeArr[$n][]=$LANG->sL($setup[0]).' ('.$setup[1].')';
397 $codeArr[$n][]=intval($admin->recStat[doktype][$setup[1]]);
398 }
399 }
400 $this->content.=$this->doc->section($LANG->getLL('doktype'),$this->doc->table($codeArr),0,1);
401 }
402
403 // Tables and lost records
404 $id_list='0,'.implode($admin->page_idArray,',');
405 $id_list = t3lib_div::rm_endcomma($id_list);
406 $admin->lostRecords($id_list);
407 if ($admin->fixLostRecord(t3lib_div::_GET('fixLostRecords_table'),t3lib_div::_GET('fixLostRecords_uid'))) {
408 $admin = t3lib_div::makeInstance('admin_int');
409 $admin->backPath = $BACK_PATH;
410 $admin->genTree(0,'');
411 $id_list='0,'.implode($admin->page_idArray,',');
412 $id_list = t3lib_div::rm_endcomma($id_list);
413 $admin->lostRecords($id_list);
414 }
415
416 $codeArr=Array();
417 $countArr=$admin->countRecords($id_list);
418 if (is_array($TCA)) {
419 reset($TCA);
420 while(list($t)=each($TCA)) {
421 $codeArr[$t][]=t3lib_iconWorks::getIconImage($t,array(),$BACK_PATH,'hspace="4" align="top"');
422 $codeArr[$t][]=$LANG->sL($TCA[$t]['ctrl']['title']);
423 $codeArr[$t][]=$t;
424
425 if ($countArr['all'][$t]) {
426 $theNumberOfRe = intval($countArr['non_deleted'][$t]).'/'.(intval($countArr['all'][$t])-intval($countArr['non_deleted'][$t]));
427 } else {
428 $theNumberOfRe ='';
429 }
430 $codeArr[$t][]=$theNumberOfRe;
431
432 $lr='';
433 if (is_array($admin->lRecords[$t])) {
434 reset($admin->lRecords[$t]);
435 while(list(,$data)=each($admin->lRecords[$t])) {
436 if (!t3lib_div::inList($admin->lostPagesList,$data[pid])) {
437 $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>';
438 } else {
439 $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>';
440 }
441 }
442 }
443 $codeArr[$t][]=$lr;
444 }
445 $this->content.=$this->doc->section($LANG->getLL('tables'),$this->doc->table($codeArr),0,1);
446 }
447 }
448
449 /**
450 * @return [type] ...
451 */
452 function func_relations() {
453 global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$CLIENT,$TYPO3_CONF_VARS;
454
455 $this->content.=$this->doc->header($LANG->getLL('relations'));
456 $this->content.=$this->doc->spacer(5);
457 $this->content.=$this->doc->section('',$this->menu);
458
459 $admin = t3lib_div::makeInstance('t3lib_admin');
460 $admin->genTree_makeHTML=0;
461 $admin->backPath = $BACK_PATH;
462
463 $fkey_arrays = $admin->getGroupFields('');
464 $admin->selectNonEmptyRecordsWithFkeys($fkey_arrays);
465
466
467 $fileTest=$admin->testFileRefs();
468
469 $code='';
470 if (is_array($fileTest['noReferences'])) {
471 while(list(,$val)=each($fileTest['noReferences'])) {
472 $code.='<nobr>'.$val[0].'/<b>'.$val[1].'</b></nobr><br>';
473 }
474 }
475 $this->content.=$this->doc->section($LANG->getLL('files_no_ref'),$code,1,1);
476
477 $code='';
478 if (is_array($fileTest[moreReferences])) {
479 while(list(,$val)=each($fileTest['moreReferences'])) {
480 $code.='<nobr>'.$val[0].'/<b>'.$val[1].'</b>: '.$val[2].' references:</nobr><br>'.$val[3].'<br><br>';
481 }
482 }
483 $this->content.=$this->doc->section($LANG->getLL('files_many_ref'),$code,1,1);
484
485 $code='';
486 if (is_array($fileTest['noFile'])) {
487 ksort($fileTest['noFile']);
488 reset($fileTest['noFile']);
489 while(list(,$val)=each($fileTest['noFile'])) {
490 $code.='<nobr>'.$val[0].'/<b>'.$val[1].'</b> is missing! </nobr><br>Referenced from: '.$val[2].'<br><br>';
491 }
492 }
493 $this->content.=$this->doc->section($LANG->getLL('files_no_file'),$code,1,1);
494 $this->content.=$this->doc->section($LANG->getLL('select_db'),$admin->testDBRefs($admin->checkSelectDBRefs),1,1);
495 $this->content.=$this->doc->section($LANG->getLL('group_db'),$admin->testDBRefs($admin->checkGroupDBRefs),1,1);
496 }
497
498 /**
499 * Searching for files with a specific pattern
500 *
501 * @return [type] ...
502 */
503 function func_filesearch() {
504 global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$CLIENT,$TYPO3_CONF_VARS;
505
506 $this->content.=$this->doc->header($LANG->getLL('relations'));
507 $this->content.=$this->doc->spacer(5);
508 $this->content.=$this->doc->section('',$this->menu);
509
510
511 $pattern = t3lib_div::_GP('pattern');
512 $pcontent='Enter regex pattern: <input type="text" name="pattern" value="'.htmlspecialchars($pattern?$pattern:$GLOBALS['TYPO3_CONF_VARS']['BE']['fileDenyPattern']).'"> <input type="submit" name="Search">';
513 $this->content.=$this->doc->section('Pattern',$pcontent,0,1);
514
515 if (strcmp($pattern,'')) {
516 $dirs = t3lib_div::get_dirs(PATH_site);
517 # debug($dirs);
518 $lines=array();
519 $depth=10;
520
521 foreach ($dirs as $key => $value) {
522 $matching_files=array();
523 $info='';
524 if (!t3lib_div::inList('typo3,typo3conf,tslib,media,t3lib',$value)) {
525 $info = $this->findFile(PATH_site.$value.'/',$pattern,$matching_files,$depth);
526 }
527 if (is_array($info)) {
528 $lines[]='<hr><b>'.$value.'/</b> being checked...';
529 $lines[]='Dirs: '.$info[0];
530 if ($info[2]) $lines[]='<span class="typo3-red">ERROR: Directories deeper than '.$depth.' levels</span>';
531 $lines[]='Files: '.$info[1];
532 $lines[]='Matching files:<br><nobr><span class="typo3-red">'.implode('<br>',$matching_files).'</span></nobr>';
533 } else {
534 $lines[]=$GLOBALS['TBE_TEMPLATE']->dfw('<hr><b>'.$value.'/</b> not checked.');
535 }
536 }
537
538 $this->content.=$this->doc->section('Searching for filenames:',implode('<br>',$lines),0,1);
539 }
540 }
541
542 /**
543 * Searching for filename pattern recursively in the specified dir.
544 *
545 * @param [type] $basedir: ...
546 * @param [type] $pattern: ...
547 * @param [type] $matching_files: ...
548 * @param [type] $depth: ...
549 * @return [type] ...
550 */
551 function findFile($basedir,$pattern,&$matching_files,$depth) {
552 $files_searched=0;
553 $dirs_searched=0;
554 $dirs_error=0;
555
556 // Traverse files:
557 $files = t3lib_div::getFilesInDir($basedir,'',1);
558 if (is_array($files)) {
559 $files_searched+=count($files);
560 foreach ($files as $value) {
561 if (eregi($pattern,basename($value))) $matching_files[]=substr($value,strlen(PATH_site));
562 }
563 }
564
565
566 // Traverse subdirs
567 if ($depth>0) {
568 $dirs = t3lib_div::get_dirs($basedir);
569 if (is_array($dirs)) {
570 $dirs_searched+=count($dirs);
571
572 foreach ($dirs as $value) {
573 $inf= $this->findFile($basedir.$value.'/',$pattern,$matching_files,$depth-1);
574 $dirs_searched+=$inf[0];
575 $files_searched+=$inf[1];
576 $dirs_error=$inf[2];
577 }
578 }
579 } else {
580 $dirs = t3lib_div::get_dirs($basedir);
581 if (is_array($dirs) && count($dirs)) {
582 $dirs_error=1; // Means error - there were further subdirs!
583 }
584 }
585
586 return array($dirs_searched,$files_searched,$dirs_error);
587 }
588
589 /**
590 * Menu
591 *
592 * @return [type] ...
593 */
594 function func_default() {
595 global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$CLIENT,$TYPO3_CONF_VARS;
596
597 $this->content.=$this->doc->header($LANG->getLL('title'));
598 $this->content.=$this->doc->spacer(5);
599 $this->content.=$this->doc->section('',$this->menu);
600 $this->content.=$this->doc->section('<a href="index.php?SET[function]=records">'.$LANG->getLL('records').'</a>',$LANG->getLL('records_description'),1,1,0,1);
601 $this->content.=$this->doc->section('<a href="index.php?SET[function]=tree">'.$LANG->getLL('tree').'</a>',$LANG->getLL('tree_description'),1,1,0,1);
602 $this->content.=$this->doc->section('<a href="index.php?SET[function]=relations">'.$LANG->getLL('relations').'</a>',$LANG->getLL('relations_description'),1,1,0,1);
603 $this->content.=$this->doc->section('<a href="index.php?SET[function]=search">'.$LANG->getLL('search').'</a>',$LANG->getLL('search_description'),1,1,0,1);
604 $this->content.=$this->doc->section('<a href="index.php?SET[function]=filesearch">'.$LANG->getLL('filesearch').'</a>',$LANG->getLL('filesearch_description'),1,1,0,1);
605 $this->content.=$this->doc->spacer(50);
606 }
607 }
608
609 // Include extension?
610 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/lowlevel/dbint/index.php']) {
611 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/lowlevel/dbint/index.php']);
612 }
613
614
615
616
617
618
619
620
621
622 // Make instance:
623 $SOBE = t3lib_div::makeInstance('SC_mod_tools_dbint_index');
624 $SOBE->init();
625 $SOBE->main();
626 $SOBE->printContent();
627 ?>