added @var phpDoc comments to various variables
[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 Skaarhoj <kasperYYYY@typo3.com>
33 * @coauthor Jo Hasenau <info@cybercraft.de>
34 */
35 /**
36 * [CLASS/FUNCTION INDEX of SCRIPT]
37 *
38 *
39 *
40 * 89: class SC_mod_tools_dbint_index
41 * 105: function init()
42 * 119: function jumpToUrl(URL)
43 * 139: function menuConfig()
44 * 226: function main()
45 * 270: function printContent()
46 * 281: function func_default()
47 *
48 * SECTION: Functionality implementation
49 * 314: function func_refindex()
50 * 344: function func_search()
51 * 386: function func_tree()
52 * 409: function func_records()
53 * 507: function func_relations()
54 * 558: function func_filesearch()
55 * 607: function findFile($basedir,$pattern,&$matching_files,$depth)
56 *
57 * TOTAL FUNCTIONS: 13
58 * (This index is automatically created/updated by the extension "extdeveval")
59 *
60 */
61
62
63 unset($MCONF);
64 require ('conf.php');
65 require ($BACK_PATH.'init.php');
66 require ($BACK_PATH.'template.php');
67 require_once (PATH_t3lib.'class.t3lib_admin.php');
68 require_once (PATH_t3lib.'class.t3lib_loaddbgroup.php');
69 require_once (PATH_t3lib.'class.t3lib_querygenerator.php');
70 require_once (PATH_t3lib.'class.t3lib_xml.php');
71 require_once (PATH_t3lib.'class.t3lib_fullsearch.php');
72 require_once (PATH_t3lib.'class.t3lib_refindex.php');
73
74 $LANG->includeLLFile('EXT:lowlevel/dbint/locallang.xml');
75 $BE_USER->modAccess($MCONF,1);
76
77
78
79
80
81
82 /**
83 * Script class for the DB int module
84 *
85 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
86 * @package TYPO3
87 * @subpackage tx_lowlevel
88 */
89 class SC_mod_tools_dbint_index {
90
91 var $MCONF = array();
92 var $MOD_MENU = array();
93 var $MOD_SETTINGS = array();
94
95 /**
96 * document template object
97 *
98 * @var mediumDoc
99 */
100 var $doc;
101
102 var $content;
103 var $menu;
104
105
106 /**
107 * Initialization
108 *
109 * @return void
110 */
111 function init() {
112 global $LANG,$BACK_PATH;
113 $this->MCONF = $GLOBALS['MCONF'];
114
115 $this->menuConfig();
116
117 $this->doc = t3lib_div::makeInstance('mediumDoc');
118 $this->doc->form='<form action="" method="post">';
119 $this->doc->backPath = $BACK_PATH;
120
121 // JavaScript
122 $this->doc->JScode = '
123 <script language="javascript" type="text/javascript">
124 script_ended = 0;
125 function jumpToUrl(URL) {
126 window.location.href = URL;
127 }
128 </script>
129 ';
130
131 $this->doc->tableLayout = Array (
132 'defRow' => Array (
133 '0' => Array('<td valign="top">','</td>'),
134 '1' => Array('<td valign="top">','</td>'),
135 'defCol' => Array('<td><img src="'.$this->doc->backPath.'clear.gif" width="15" height="1" alt="" /></td><td valign="top">','</td>')
136 )
137 );
138 }
139
140 /**
141 * Configure menu
142 *
143 * @return void
144 */
145 function menuConfig() {
146 global $LANG;
147
148 // MENU-ITEMS:
149 // If array, then it's a selector box menu
150 // If empty string it's just a variable, that'll be saved.
151 // Values NOT in this array will not be saved in the settings-array for the module.
152 $this->MOD_MENU = array(
153 'function' => array(
154 0 => '[ MENU ]',
155 'records' => 'Record Statistics',
156 'tree' => 'Total Page Tree',
157 'relations' => 'Database Relations',
158 'search' => 'Full search',
159 'filesearch' => 'Find filename',
160 'refindex' => 'Manage Reference Index',
161 ),
162 'search' => array(
163 'raw' => 'Raw search in all fields',
164 'query' => 'Advanced query'
165 ),
166
167 'search_query_smallparts' => '',
168 'search_result_labels' => '',
169 'labels_noprefix' => '',
170 'options_sortlabel' => '',
171 'show_deleted' => '',
172
173 'queryConfig' => '', // Current query
174 'queryTable' => '', // Current table
175 'queryFields' => '', // Current tableFields
176 'queryLimit' => '', // Current limit
177 'queryOrder' => '', // Current Order field
178 'queryOrderDesc' => '', // Current Order field descending flag
179 'queryOrder2' => '', // Current Order2 field
180 'queryOrder2Desc' => '', // Current Order2 field descending flag
181 'queryGroup' => '', // Current Group field
182
183 'storeArray' => '', // Used to store the available Query config memory banks
184 'storeQueryConfigs' => '', // Used to store the available Query configs in memory
185
186 'search_query_makeQuery' => array(
187 'all' => 'Select records',
188 'count' => 'Count results',
189 'explain' => 'Explain query',
190 'csv' => 'CSV Export',
191 'xml' => 'XML Export'
192 ),
193
194 'sword' => ''
195 );
196 // CLEAN SETTINGS
197 $OLD_MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU,'', $this->MCONF['name'], 'ses');
198 $this->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU, t3lib_div::_GP('SET'), $this->MCONF['name'], 'ses');
199
200 if (t3lib_div::_GP('queryConfig')) {
201 $qA = t3lib_div::_GP('queryConfig');
202 $this->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU, array('queryConfig'=>serialize($qA)), $this->MCONF['name'], 'ses');
203 }
204 $addConditionCheck = t3lib_div::_GP('qG_ins');
205 foreach ($OLD_MOD_SETTINGS as $key=>$val) {
206 if (substr($key, 0, 5)=='query' && $this->MOD_SETTINGS[$key]!=$val && $key!='queryLimit' && $key!='use_listview') {
207 $setLimitToStart = 1;
208 if ($key == 'queryTable' && !$addConditionCheck) {
209 $this->MOD_SETTINGS['queryConfig'] = '';
210 }
211 }
212 if ($key=='queryTable' && $this->MOD_SETTINGS[$key]!=$val) {
213 $this->MOD_SETTINGS['queryFields'] = '';
214 }
215 }
216 if ($setLimitToStart) {
217 $currentLimit = explode(',',$this->MOD_SETTINGS['queryLimit']);
218 if ($currentLimit[1]) {
219 $this->MOD_SETTINGS['queryLimit']='0,'.$currentLimit[1];
220 } else {
221 $this->MOD_SETTINGS['queryLimit']='0';
222 }
223 $this->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU, $this->MOD_SETTINGS, $this->MCONF['name'], 'ses');
224 }
225 }
226
227 /**
228 * Main
229 *
230 * @return void
231 */
232 function main() {
233 global $BE_USER,$LANG;
234
235 // Content creation
236 $this->content.= $this->doc->startPage($LANG->getLL('title'));
237 if (!$GLOBALS['BE_USER']->userTS['mod.']['dbint.']['disableTopMenu']) {
238 $this->menu = t3lib_BEfunc::getFuncMenu(0,'SET[function]',$this->MOD_SETTINGS['function'],$this->MOD_MENU['function']);
239 }
240
241 switch($this->MOD_SETTINGS['function']) {
242 case 'search':
243 $this->func_search();
244 break;
245 case 'tree':
246 $this->func_tree();
247 break;
248 case 'records':
249 $this->func_records();
250 break;
251 case 'relations':
252 $this->func_relations();
253 break;
254 case 'filesearch':
255 $this->func_filesearch();
256 break;
257 case 'refindex':
258 $this->func_refindex();
259 break;
260 default:
261 $this->func_default();
262 break;
263 }
264
265 if ($BE_USER->mayMakeShortcut()) {
266 $this->content.=$this->doc->spacer(20).
267 $this->doc->section('',$this->doc->makeShortcutIcon('','function,search,search_query_makeQuery',$this->MCONF['name']));
268 }
269 }
270
271 /**
272 * Print content
273 *
274 * @return void
275 */
276 function printContent() {
277
278 $this->content.= $this->doc->endPage();
279 echo $this->content;
280 }
281
282 /**
283 * Menu
284 *
285 * @return void
286 */
287 function func_default() {
288 global $LANG;
289
290 $this->content.=$this->doc->header($LANG->getLL('title'));
291 $this->content.=$this->doc->spacer(5);
292 $this->content.=$this->doc->section('',$this->menu);
293 $this->content.=$this->doc->section('<a href="index.php?SET[function]=records">'.$LANG->getLL('records').'</a>',$LANG->getLL('records_description'),1,1,0,1);
294 $this->content.=$this->doc->section('<a href="index.php?SET[function]=tree">'.$LANG->getLL('tree').'</a>',$LANG->getLL('tree_description'),1,1,0,1);
295 $this->content.=$this->doc->section('<a href="index.php?SET[function]=relations">'.$LANG->getLL('relations').'</a>',$LANG->getLL('relations_description'),1,1,0,1);
296 $this->content.=$this->doc->section('<a href="index.php?SET[function]=search">'.$LANG->getLL('search').'</a>',$LANG->getLL('search_description'),1,1,0,1);
297 $this->content.=$this->doc->section('<a href="index.php?SET[function]=filesearch">'.$LANG->getLL('filesearch').'</a>',$LANG->getLL('filesearch_description'),1,1,0,1);
298 $this->content.=$this->doc->section('<a href="index.php?SET[function]=refindex">'.$LANG->getLL('refindex').'</a>',$LANG->getLL('refindex_description'),1,1,0,1);
299 $this->content.=$this->doc->spacer(50);
300 }
301
302
303
304
305
306
307
308
309 /****************************
310 *
311 * Functionality implementation
312 *
313 ****************************/
314
315 /**
316 * Check and update reference index!
317 *
318 * @return void
319 */
320 function func_refindex() {
321 global $TYPO3_DB,$TCA;
322
323 $this->content.=$this->doc->section('',$this->menu);
324 $this->content.=$this->doc->section('',$menu2).$this->doc->spacer(10);
325
326 if (t3lib_div::_GP('_update') || t3lib_div::_GP('_check')) {
327 $testOnly = t3lib_div::_GP('_check')?TRUE:FALSE;
328
329 // Call the functionality
330 $refIndexObj = t3lib_div::makeInstance('t3lib_refindex');
331 list($headerContent,$bodyContent) = $refIndexObj->updateIndex($testOnly);
332
333 // Output content:
334 $this->content.=$this->doc->section($headerContent,str_replace(chr(10),'<br/>',$bodyContent),0,1);
335 }
336
337 // Output content:
338 $content = 'Click here to update reference index: <input type="submit" name="_update" value="Update now!" /><br/>';
339 $content.= 'Click here to test reference index: <input type="submit" name="_check" value="Check now!" /><br/>';
340 $content.= 'You can also run the check as a shell script if the processing takes longer than the PHP max_execution_time allows:<br/>'.
341 t3lib_extMgm::extPath('lowlevel').'dbint/cli/refindex_cli.phpsh';
342 $this->content.=$this->doc->section('Update reference index',$content,0,1);
343 }
344
345 /**
346 * Search (Full / Advanced)
347 *
348 * @return void
349 */
350 function func_search() {
351 global $LANG;
352
353 $fullsearch = t3lib_div::makeInstance('t3lib_fullsearch');
354 $this->content.= $this->doc->header($LANG->getLL('search'));
355 $this->content.= $this->doc->spacer(5);
356
357 $menu2='';
358 if (!$GLOBALS['BE_USER']->userTS['mod.']['dbint.']['disableTopMenu']) {
359 $menu2 = t3lib_BEfunc::getFuncMenu(0, 'SET[search]', $this->MOD_SETTINGS['search'], $this->MOD_MENU['search']);
360 }
361 if ($this->MOD_SETTINGS['search']=='query' && !$GLOBALS['BE_USER']->userTS['mod.']['dbint.']['disableTopMenu']) {
362 $menu2 .= t3lib_BEfunc::getFuncMenu(0, 'SET[search_query_makeQuery]', $this->MOD_SETTINGS['search_query_makeQuery'], $this->MOD_MENU['search_query_makeQuery']). '<br />';
363 }
364 if (!$GLOBALS['BE_USER']->userTS['mod.']['dbint.']['disableTopCheckboxes'] && $this->MOD_SETTINGS['search']=='query') {
365 $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">Show SQL parts</label><br />';
366 $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">Use formatted strings, labels and dates instead of original values for results</label><br />';
367 $menu2 .= t3lib_BEfunc::getFuncCheck($GLOBALS['SOBE']->id, 'SET[labels_noprefix]', $this->MOD_SETTINGS['labels_noprefix'],'','','id="checkLabels_noprefix"').'&nbsp;<label for="checkLabels_noprefix">Don\'t use original values in brackets as prefix for labelled results</label><br />';
368 $menu2 .= t3lib_BEfunc::getFuncCheck($GLOBALS['SOBE']->id, 'SET[options_sortlabel]', $this->MOD_SETTINGS['options_sortlabel'],'','','id="checkOptions_sortlabel"').'&nbsp;<label for="checkOptions_sortlabel">Sort selectbox options for relations by label and not by value</label><br />';
369 $menu2 .= t3lib_BEfunc::getFuncCheck($GLOBALS['SOBE']->id, 'SET[show_deleted]', $this->MOD_SETTINGS['show_deleted'],'','','id="checkShow_deleted"').'&nbsp;<label for="checkShow_deleted">Show even deleted entries (with undelete buttons)</label>';
370 }
371
372 $this->content.= $this->doc->section('',$this->menu);//$this->doc->divider(5);
373 $this->content.= $this->doc->section('',$menu2).$this->doc->spacer(10);
374
375 switch($this->MOD_SETTINGS['search']) {
376 case 'query':
377 $this->content.=$fullsearch->queryMaker();
378 break;
379 case 'raw':
380 default:
381 $this->content.=$this->doc->section('Search options:',$fullsearch->form(),0,1);
382 $this->content.=$this->doc->section('Result:',$fullsearch->search(),0,1);
383 break;
384 }
385 }
386
387 /**
388 * Display page tree
389 *
390 * @return void
391 */
392 function func_tree() {
393 global $LANG,$BACK_PATH;
394
395 $startID = 0;
396 $admin = t3lib_div::makeInstance('t3lib_admin');
397 $admin->genTree_makeHTML=1;
398 $admin->backPath = $BACK_PATH;
399 $admin->genTree(intval($startID),'<img src="'.$BACK_PATH.'clear.gif" width="1" height="1" align="top" alt="" />');
400
401 $this->content.= $this->doc->header($LANG->getLL('tree'));
402 $this->content.= $this->doc->spacer(5);
403 $this->content.= $this->doc->section('',$this->menu).$this->doc->divider(5);
404 $this->content.= $this->doc->sectionEnd();
405
406 $this->content.= $admin->genTree_HTML;
407 $this->content.= $admin->lostRecords($admin->genTree_idlist.'0');
408 }
409
410 /**
411 * Records overview
412 *
413 * @return void
414 */
415 function func_records() {
416 global $LANG,$TCA,$BACK_PATH,$PAGES_TYPES;
417
418 $admin = t3lib_div::makeInstance('t3lib_admin');
419 $admin->genTree_makeHTML = 0;
420 $admin->backPath = $BACK_PATH;
421 $admin->genTree(0,'');
422
423 $this->content.= $this->doc->header($LANG->getLL('records'));
424 $this->content.= $this->doc->spacer(5);
425 $this->content.= $this->doc->section('',$this->menu);
426
427 // Pages stat
428 $codeArr=Array();
429 $i++;
430 $codeArr[$i][]='<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/i/pages.gif','width="18" height="16"').' hspace="4" align="top" alt="" />';
431 $codeArr[$i][]=$LANG->getLL('total_pages');
432 $codeArr[$i][]=count($admin->page_idArray);
433 $i++;
434 if (t3lib_extMgm::isLoaded('cms')) {
435 $codeArr[$i][]='<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/hidden_page.gif','width="18" height="16"').' hspace="4" align="top">';
436 $codeArr[$i][]=$LANG->getLL('hidden_pages');
437 $codeArr[$i][]=$admin->recStat['hidden'];
438 $i++;
439 }
440 $codeArr[$i][]='<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/deleted_page.gif','width="18" height="16"').' hspace="4" align="top">';
441 $codeArr[$i][]=$LANG->getLL('deleted_pages');
442 $codeArr[$i][]=$admin->recStat['deleted'];
443
444 $this->content.=$this->doc->section($LANG->getLL('pages'),$this->doc->table($codeArr),0,1);
445
446 // Doktype
447 $codeArr=Array();
448 $doktype= $TCA['pages']['columns']['doktype']['config']['items'];
449 if (is_array($doktype)) {
450 reset($doktype);
451 while(list($n,$setup) = each($doktype)) {
452 if ($setup[1]!='--div--') {
453 $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">';
454 $codeArr[$n][] = $LANG->sL($setup[0]).' ('.$setup[1].')';
455 $codeArr[$n][] = intval($admin->recStat[doktype][$setup[1]]);
456 }
457 }
458 $this->content.=$this->doc->section($LANG->getLL('doktype'),$this->doc->table($codeArr),0,1);
459 }
460
461 // Tables and lost records
462 $id_list = '-1,0,'.implode(array_keys($admin->page_idArray),',');
463 $id_list = t3lib_div::rm_endcomma($id_list);
464 $admin->lostRecords($id_list);
465
466 if ($admin->fixLostRecord(t3lib_div::_GET('fixLostRecords_table'),t3lib_div::_GET('fixLostRecords_uid'))) {
467 $admin = t3lib_div::makeInstance('t3lib_admin');
468 $admin->backPath = $BACK_PATH;
469 $admin->genTree(0,'');
470 $id_list = '-1,0,'.implode(array_keys($admin->page_idArray),',');
471 $id_list = t3lib_div::rm_endcomma($id_list);
472 $admin->lostRecords($id_list);
473 }
474
475 $codeArr = Array();
476 $countArr = $admin->countRecords($id_list);
477 if (is_array($TCA)) {
478 reset($TCA);
479 while(list($t)=each($TCA)) {
480 $codeArr[$t][]=t3lib_iconWorks::getIconImage($t,array(),$BACK_PATH,'hspace="4" align="top"');
481 $codeArr[$t][]=$LANG->sL($TCA[$t]['ctrl']['title']);
482 $codeArr[$t][]=$t;
483
484 if ($countArr['all'][$t]) {
485 $theNumberOfRe = intval($countArr['non_deleted'][$t]).'/'.(intval($countArr['all'][$t])-intval($countArr['non_deleted'][$t]));
486 } else {
487 $theNumberOfRe ='';
488 }
489 $codeArr[$t][]=$theNumberOfRe;
490
491 $lr='';
492 if (is_array($admin->lRecords[$t])) {
493 reset($admin->lRecords[$t]);
494 while(list(,$data)=each($admin->lRecords[$t])) {
495 if (!t3lib_div::inList($admin->lostPagesList,$data[pid])) {
496 $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>';
497 } else {
498 $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>';
499 }
500 }
501 }
502 $codeArr[$t][]=$lr;
503 }
504 $this->content.=$this->doc->section($LANG->getLL('tables'),$this->doc->table($codeArr),0,1);
505 }
506 }
507
508 /**
509 * Show list references
510 *
511 * @return void
512 */
513 function func_relations() {
514 global $LANG,$BACK_PATH;
515
516 $this->content.= $this->doc->header($LANG->getLL('relations'));
517 $this->content.= $this->doc->spacer(5);
518 $this->content.= $this->doc->section('',$this->menu);
519
520 $admin = t3lib_div::makeInstance('t3lib_admin');
521 $admin->genTree_makeHTML=0;
522 $admin->backPath = $BACK_PATH;
523
524 $fkey_arrays = $admin->getGroupFields('');
525 $admin->selectNonEmptyRecordsWithFkeys($fkey_arrays);
526
527
528 $fileTest = $admin->testFileRefs();
529
530 $code='';
531 if (is_array($fileTest['noReferences'])) {
532 while(list(,$val)=each($fileTest['noReferences'])) {
533 $code.='<nobr>'.$val[0].'/<b>'.$val[1].'</b></nobr><br>';
534 }
535 }
536 $this->content.=$this->doc->section($LANG->getLL('files_no_ref'),$code,1,1);
537
538 $code='';
539 if (is_array($fileTest['moreReferences'])) {
540 while(list(,$val)=each($fileTest['moreReferences'])) {
541 $code.='<nobr>'.$val[0].'/<b>'.$val[1].'</b>: '.$val[2].' references:</nobr><br>'.$val[3].'<br><br>';
542 }
543 }
544 $this->content.=$this->doc->section($LANG->getLL('files_many_ref'),$code,1,1);
545
546 $code='';
547 if (is_array($fileTest['noFile'])) {
548 ksort($fileTest['noFile']);
549 reset($fileTest['noFile']);
550 while(list(,$val)=each($fileTest['noFile'])) {
551 $code.='<nobr>'.$val[0].'/<b>'.$val[1].'</b> is missing! </nobr><br>Referenced from: '.$val[2].'<br><br>';
552 }
553 }
554 $this->content.=$this->doc->section($LANG->getLL('files_no_file'),$code,1,1);
555 $this->content.=$this->doc->section($LANG->getLL('select_db'),$admin->testDBRefs($admin->checkSelectDBRefs),1,1);
556 $this->content.=$this->doc->section($LANG->getLL('group_db'),$admin->testDBRefs($admin->checkGroupDBRefs),1,1);
557 }
558
559 /**
560 * Searching for files with a specific pattern
561 *
562 * @return Searching for files
563 */
564 function func_filesearch() {
565 global $LANG;
566
567 $this->content.= $this->doc->header($LANG->getLL('relations'));
568 $this->content.= $this->doc->spacer(5);
569 $this->content.= $this->doc->section('',$this->menu);
570
571
572 $pattern = t3lib_div::_GP('pattern');
573 $pcontent = 'Enter regex pattern: <input type="text" name="pattern" value="'.htmlspecialchars($pattern?$pattern:$GLOBALS['TYPO3_CONF_VARS']['BE']['fileDenyPattern']).'"> <input type="submit" name="Search">';
574 $this->content.= $this->doc->section('Pattern',$pcontent,0,1);
575
576 if (strcmp($pattern,'')) {
577 $dirs = t3lib_div::get_dirs(PATH_site);
578 # debug($dirs);
579 $lines=array();
580 $depth=10;
581
582 foreach ($dirs as $key => $value) {
583 $matching_files=array();
584 $info='';
585 if (!t3lib_div::inList('typo3,typo3conf,tslib,media,t3lib',$value)) {
586 $info = $this->findFile(PATH_site.$value.'/',$pattern,$matching_files,$depth);
587 }
588 if (is_array($info)) {
589 $lines[]='<hr><b>'.$value.'/</b> being checked...';
590 $lines[]='Dirs: '.$info[0];
591 if ($info[2]) $lines[]='<span class="typo3-red">ERROR: Directories deeper than '.$depth.' levels</span>';
592 $lines[]='Files: '.$info[1];
593 $lines[]='Matching files:<br><nobr><span class="typo3-red">'.implode('<br>',$matching_files).'</span></nobr>';
594 } else {
595 $lines[]=$GLOBALS['TBE_TEMPLATE']->dfw('<hr><b>'.$value.'/</b> not checked.');
596 }
597 }
598
599 $this->content.=$this->doc->section('Searching for filenames:',implode('<br>',$lines),0,1);
600 }
601 }
602
603 /**
604 * Searching for filename pattern recursively in the specified dir.
605 *
606 * @param string Base directory
607 * @param string Match pattern
608 * @param array Array of matching files, passed by reference
609 * @param integer Depth to recurse
610 * @return array Array with various information about the search result
611 * @see func_filesearch()
612 */
613 function findFile($basedir,$pattern,&$matching_files,$depth) {
614 $files_searched=0;
615 $dirs_searched=0;
616 $dirs_error=0;
617
618 // Traverse files:
619 $files = t3lib_div::getFilesInDir($basedir,'',1);
620 if (is_array($files)) {
621 $files_searched+=count($files);
622 foreach ($files as $value) {
623 if (eregi($pattern,basename($value))) $matching_files[]=substr($value,strlen(PATH_site));
624 }
625 }
626
627
628 // Traverse subdirs
629 if ($depth>0) {
630 $dirs = t3lib_div::get_dirs($basedir);
631 if (is_array($dirs)) {
632 $dirs_searched+=count($dirs);
633
634 foreach ($dirs as $value) {
635 $inf= $this->findFile($basedir.$value.'/',$pattern,$matching_files,$depth-1);
636 $dirs_searched+=$inf[0];
637 $files_searched+=$inf[1];
638 $dirs_error=$inf[2];
639 }
640 }
641 } else {
642 $dirs = t3lib_div::get_dirs($basedir);
643 if (is_array($dirs) && count($dirs)) {
644 $dirs_error=1; // Means error - there were further subdirs!
645 }
646 }
647
648 return array($dirs_searched,$files_searched,$dirs_error);
649 }
650 }
651
652 // Include extension?
653 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/lowlevel/dbint/index.php']) {
654 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/lowlevel/dbint/index.php']);
655 }
656
657
658
659
660
661
662
663
664
665 // Make instance:
666 $SOBE = t3lib_div::makeInstance('SC_mod_tools_dbint_index');
667 $SOBE->init();
668 $SOBE->main();
669 $SOBE->printContent();
670 ?>