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