Fixed bug #10259: Link to CLI Script in Check DP->ReferenceIndex Script is wrong...
[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/><br/>';
377 $content.= '<p>' . $GLOBALS['LANG']->getLL('checkScript') . '</p><br />';
378 $content.= '<p>' . $GLOBALS['LANG']->getLL('checkScript_check_description') . '<br />' .
379 $GLOBALS['LANG']->getLL('checkScript_check_example') . '</p><br />';
380 $content.= '<p>' . $GLOBALS['LANG']->getLL('checkScript_update_description') . '<br />' .
381 $GLOBALS['LANG']->getLL('checkScript_update_example') . '</p><br />';
382 $content.= '<p>' . $GLOBALS['LANG']->getLL('checkScript_more') . '</p>';
383 $this->content.= $this->doc->section($GLOBALS['LANG']->getLL('updateRefIndex'), $content, false, true);
384 }
385
386 /**
387 * Search (Full / Advanced)
388 *
389 * @return void
390 */
391 function func_search() {
392 global $LANG;
393
394 $fullsearch = t3lib_div::makeInstance('t3lib_fullsearch');
395 $fullsearch->setFormName($this->formName);
396 $this->content.= $this->doc->header($GLOBALS['LANG']->getLL('search'));
397 $this->content.= $this->doc->spacer(5);
398
399 $menu2='';
400 if (!$GLOBALS['BE_USER']->userTS['mod.']['dbint.']['disableTopMenu']) {
401 $menu2 = t3lib_BEfunc::getFuncMenu(0, 'SET[search]', $this->MOD_SETTINGS['search'], $this->MOD_MENU['search']);
402 }
403 if ($this->MOD_SETTINGS['search']=='query' && !$GLOBALS['BE_USER']->userTS['mod.']['dbint.']['disableTopMenu']) {
404 $menu2 .= t3lib_BEfunc::getFuncMenu(0, 'SET[search_query_makeQuery]', $this->MOD_SETTINGS['search_query_makeQuery'], $this->MOD_MENU['search_query_makeQuery']) . '<br />';
405 }
406 if (!$GLOBALS['BE_USER']->userTS['mod.']['dbint.']['disableTopCheckboxes'] && $this->MOD_SETTINGS['search']=='query') {
407 $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 />';
408 $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 />';
409 $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 />';
410 $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 />';
411 $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>';
412 }
413
414 $this->content.= $this->doc->section('',$menu2).$this->doc->spacer(10);
415
416 switch($this->MOD_SETTINGS['search']) {
417 case 'query':
418 $this->content.=$fullsearch->queryMaker();
419 break;
420 case 'raw':
421 default:
422 $this->content.=$this->doc->section($GLOBALS['LANG']->getLL('searchOptions'), $fullsearch->form(), false, true);
423 $this->content.=$this->doc->section($GLOBALS['LANG']->getLL('result'), $fullsearch->search(), false, true);
424 break;
425 }
426 }
427
428 /**
429 * Display page tree
430 *
431 * @return void
432 */
433 function func_tree() {
434 global $LANG,$BACK_PATH;
435
436 $startID = 0;
437 $admin = t3lib_div::makeInstance('t3lib_admin');
438 $admin->genTree_makeHTML=1;
439 $admin->backPath = $BACK_PATH;
440 $admin->genTree(intval($startID),'<img src="' . $BACK_PATH . 'clear.gif" width="1" height="1" align="top" alt="" />');
441
442 $this->content.= $this->doc->header($GLOBALS['LANG']->getLL('tree'));
443 $this->content.= $this->doc->spacer(5);
444 $this->content.= $this->doc->sectionEnd();
445
446 $this->content.= $admin->genTree_HTML;
447 $this->content.= $admin->lostRecords($admin->genTree_idlist.'0');
448 }
449
450 /**
451 * Records overview
452 *
453 * @return void
454 */
455 function func_records() {
456 global $LANG,$TCA,$BACK_PATH,$PAGES_TYPES;
457
458 $admin = t3lib_div::makeInstance('t3lib_admin');
459 $admin->genTree_makeHTML = 0;
460 $admin->backPath = $BACK_PATH;
461 $admin->genTree(0,'');
462
463 $this->content.= $this->doc->header($GLOBALS['LANG']->getLL('records'));
464 $this->content.= $this->doc->spacer(5);
465
466 // Pages stat
467 $codeArr=Array();
468 $i++;
469 $codeArr[$i][]='<img' . t3lib_iconWorks::skinImg($BACK_PATH,'gfx/i/pages.gif','width="18" height="16"') . ' hspace="4" align="top" alt="" />';
470 $codeArr[$i][]=$GLOBALS['LANG']->getLL('total_pages');
471 $codeArr[$i][]=count($admin->page_idArray);
472 $i++;
473 if (t3lib_extMgm::isLoaded('cms')) {
474 $codeArr[$i][]='<img' . t3lib_iconWorks::skinImg($BACK_PATH,'gfx/hidden_page.gif','width="18" height="16"') . ' hspace="4" align="top">';
475 $codeArr[$i][]=$GLOBALS['LANG']->getLL('hidden_pages');
476 $codeArr[$i][]=$admin->recStat['hidden'];
477 $i++;
478 }
479 $codeArr[$i][]='<img' . t3lib_iconWorks::skinImg($BACK_PATH,'gfx/deleted_page.gif','width="18" height="16"') . ' hspace="4" align="top">';
480 $codeArr[$i][]=$GLOBALS['LANG']->getLL('deleted_pages');
481 $codeArr[$i][]=$admin->recStat['deleted'];
482
483 $this->content.=$this->doc->section($GLOBALS['LANG']->getLL('pages'), $this->doc->table($codeArr), false, true);
484
485 // Doktype
486 $codeArr=Array();
487 $doktype= $TCA['pages']['columns']['doktype']['config']['items'];
488 if (is_array($doktype)) {
489 reset($doktype);
490 while(list($n,$setup) = each($doktype)) {
491 if ($setup[1]!='--div--') {
492 $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">';
493 $codeArr[$n][] = $GLOBALS['LANG']->sL($setup[0]) . ' (' . $setup[1] . ')';
494 $codeArr[$n][] = intval($admin->recStat[doktype][$setup[1]]);
495 }
496 }
497 $this->content.=$this->doc->section($GLOBALS['LANG']->getLL('doktype'), $this->doc->table($codeArr), false, true);
498 }
499
500 // Tables and lost records
501 $id_list = '-1,0,'.implode(array_keys($admin->page_idArray),',');
502 $id_list = t3lib_div::rm_endcomma($id_list);
503 $admin->lostRecords($id_list);
504
505 if ($admin->fixLostRecord(t3lib_div::_GET('fixLostRecords_table'),t3lib_div::_GET('fixLostRecords_uid'))) {
506 $admin = t3lib_div::makeInstance('t3lib_admin');
507 $admin->backPath = $BACK_PATH;
508 $admin->genTree(0,'');
509 $id_list = '-1,0,'.implode(array_keys($admin->page_idArray),',');
510 $id_list = t3lib_div::rm_endcomma($id_list);
511 $admin->lostRecords($id_list);
512 }
513
514 $codeArr = Array();
515 $countArr = $admin->countRecords($id_list);
516 if (is_array($TCA)) {
517 reset($TCA);
518 while(list($t)=each($TCA)) {
519 $codeArr[$t][]=t3lib_iconWorks::getIconImage($t,array(),$BACK_PATH,'hspace="4" align="top"');
520 $codeArr[$t][]=$LANG->sL($TCA[$t]['ctrl']['title']);
521 $codeArr[$t][]=$t;
522
523 if ($countArr['all'][$t]) {
524 $theNumberOfRe = intval($countArr['non_deleted'][$t]).'/'.(intval($countArr['all'][$t])-intval($countArr['non_deleted'][$t]));
525 } else {
526 $theNumberOfRe ='';
527 }
528 $codeArr[$t][]=$theNumberOfRe;
529
530 $lr='';
531 if (is_array($admin->lRecords[$t])) {
532 reset($admin->lRecords[$t]);
533 while(list(,$data)=each($admin->lRecords[$t])) {
534 if (!t3lib_div::inList($admin->lostPagesList,$data[pid])) {
535 $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_cs(strip_tags($data[title]), 20) . '</b></nobr><br>';
536 } else {
537 $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_cs(strip_tags($data[title]), 20) . '</font></nobr><br>';
538 }
539 }
540 }
541 $codeArr[$t][]=$lr;
542 }
543 $this->content.=$this->doc->section($GLOBALS['LANG']->getLL('tables'), $this->doc->table($codeArr), false, true);
544 }
545 }
546
547 /**
548 * Show list references
549 *
550 * @return void
551 */
552 function func_relations() {
553 global $LANG,$BACK_PATH;
554
555 $this->content.= $this->doc->header($GLOBALS['LANG']->getLL('relations'));
556 $this->content.= $this->doc->spacer(5);
557
558 $admin = t3lib_div::makeInstance('t3lib_admin');
559 $admin->genTree_makeHTML=0;
560 $admin->backPath = $BACK_PATH;
561
562 $fkey_arrays = $admin->getGroupFields('');
563 $admin->selectNonEmptyRecordsWithFkeys($fkey_arrays);
564
565
566 $fileTest = $admin->testFileRefs();
567
568 $code='';
569 if (is_array($fileTest['noReferences'])) {
570 while(list(,$val)=each($fileTest['noReferences'])) {
571 $code.='<nobr>' . $val[0] . '/<b>' . $val[1] . '</b></nobr><br>';
572 }
573 }
574 $this->content.=$this->doc->section($GLOBALS['LANG']->getLL('files_no_ref'), $code, true, true);
575
576 $code='';
577 if (is_array($fileTest['moreReferences'])) {
578 while(list(,$val)=each($fileTest['moreReferences'])) {
579 $code.='<nobr>' . $val[0] . '/<b>' . $val[1] . '</b>: ' . $val[2] . ' ' . $GLOBALS['LANG']->getLL('references') . '</nobr><br>' . $val[3] . '<br><br>';
580 }
581 }
582 $this->content.=$this->doc->section($GLOBALS['LANG']->getLL('files_many_ref'),$code, true, true);
583
584 $code='';
585 if (is_array($fileTest['noFile'])) {
586 ksort($fileTest['noFile']);
587 reset($fileTest['noFile']);
588 while(list(,$val)=each($fileTest['noFile'])) {
589 $code.='<nobr>' . $val[0] . '/<b>' . $val[1] . '</b> ' . $GLOBALS['LANG']->getLL('isMissing') . ' </nobr><br>' . $GLOBALS['LANG']->getLL('referencedFrom') . $val[2] . '<br><br>';
590 }
591 }
592 $this->content.= $this->doc->section($GLOBALS['LANG']->getLL('files_no_file'), $code, true, true);
593 $this->content.= $this->doc->section($GLOBALS['LANG']->getLL('select_db'), $admin->testDBRefs($admin->checkSelectDBRefs), true, true);
594 $this->content.= $this->doc->section($GLOBALS['LANG']->getLL('group_db'), $admin->testDBRefs($admin->checkGroupDBRefs), true, true);
595 }
596
597 /**
598 * Searching for files with a specific pattern
599 *
600 * @return void
601 */
602 function func_filesearch() {
603 $pattern = t3lib_div::_GP('pattern');
604 $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') . '">';
605 $this->content.= $this->doc->section($GLOBALS['LANG']->getLL('pattern'), $pcontent, false, true);
606
607 if (strcmp($pattern,'')) {
608 $dirs = t3lib_div::get_dirs(PATH_site);
609 $lines=array();
610 $depth=10;
611
612 foreach ($dirs as $key => $value) {
613 $matching_files=array();
614 $info='';
615 if (!t3lib_div::inList('typo3,typo3conf,tslib,media,t3lib',$value)) {
616 $info = $this->findFile(PATH_site.$value.'/',$pattern,$matching_files,$depth);
617 }
618 if (is_array($info)) {
619 $lines[]='<hr><b>' . $value . '/</b> ' . $GLOBALS['LANG']->getLL('beingChecked');
620 $lines[]=$GLOBALS['LANG']->getLL('directories') . ' ' . $info[0];
621 if ($info[2]) $lines[]='<span class="typo3-red">' . $GLOBALS['LANG']->getLL('directoriesTooDeep') . ' ' . $depth . '</span>';
622 $lines[]=$GLOBALS['LANG']->getLL('files') . ' ' . $info[1];
623 $lines[]=$GLOBALS['LANG']->getLL('matchingFiles') . '<br><nobr><span class="typo3-red">' . implode('<br>', $matching_files) . '</span></nobr>';
624 } else {
625 $lines[]=$GLOBALS['TBE_TEMPLATE']->dfw('<hr><b>' . $value . '/</b> ' . $GLOBALS['LANG']->getLL('notChecked'));
626 }
627 }
628
629 $this->content.=$this->doc->section($GLOBALS['LANG']->getLL('searchingForFilenames'), implode('<br>', $lines), false, true);
630 }
631 }
632
633 /**
634 * Searching for filename pattern recursively in the specified dir.
635 *
636 * @param string Base directory
637 * @param string Match pattern
638 * @param array Array of matching files, passed by reference
639 * @param integer Depth to recurse
640 * @return array Array with various information about the search result
641 * @see func_filesearch()
642 */
643 function findFile($basedir,$pattern,&$matching_files,$depth) {
644 $files_searched=0;
645 $dirs_searched=0;
646 $dirs_error=0;
647
648 // Traverse files:
649 $files = t3lib_div::getFilesInDir($basedir,'',1);
650 if (is_array($files)) {
651 $files_searched+=count($files);
652 foreach ($files as $value) {
653 if (eregi($pattern,basename($value))) $matching_files[]=substr($value,strlen(PATH_site));
654 }
655 }
656
657
658 // Traverse subdirs
659 if ($depth>0) {
660 $dirs = t3lib_div::get_dirs($basedir);
661 if (is_array($dirs)) {
662 $dirs_searched+=count($dirs);
663
664 foreach ($dirs as $value) {
665 $inf= $this->findFile($basedir.$value.'/',$pattern,$matching_files,$depth-1);
666 $dirs_searched+=$inf[0];
667 $files_searched+=$inf[1];
668 $dirs_error=$inf[2];
669 }
670 }
671 } else {
672 $dirs = t3lib_div::get_dirs($basedir);
673 if (is_array($dirs) && count($dirs)) {
674 $dirs_error=1; // Means error - there were further subdirs!
675 }
676 }
677
678 return array($dirs_searched,$files_searched,$dirs_error);
679 }
680 }
681
682
683 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/lowlevel/dbint/index.php']) {
684 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/lowlevel/dbint/index.php']);
685 }
686
687
688
689 // Make instance:
690 $SOBE = t3lib_div::makeInstance('SC_mod_tools_dbint_index');
691 $SOBE->init();
692 $SOBE->main();
693 $SOBE->printContent();
694
695 ?>