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