f6b83f6cbf17719f11f22202306b8c5dcebcb3fe
[Packages/TYPO3.CMS.git] / typo3 / sysext / lowlevel / dbint / index.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2010 Kasper Skårhøj (kasperYYYY@typo3.com)
6 * All rights reserved
7 *
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 * A copy is found in the textfile GPL.txt and important notices to the license
17 * from the author is found in LICENSE.txt distributed with these scripts.
18 *
19 *
20 * This script is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
27 /**
28 * Module: Database integrity check
29 *
30 * This module lets you check if all pages and the records relate properly to each other
31 *
32 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
33 * @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
68 $GLOBALS['LANG']->includeLLFile('EXT:lowlevel/dbint/locallang.xml');
69 $BE_USER->modAccess($MCONF,1);
70
71
72
73
74
75
76 /**
77 * Script class for the DB int module
78 *
79 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
80 * @package TYPO3
81 * @subpackage tx_lowlevel
82 */
83 class SC_mod_tools_dbint_index {
84
85 var $MCONF = array();
86 var $MOD_MENU = array();
87 var $MOD_SETTINGS = array();
88
89 /**
90 * document template object
91 *
92 * @var mediumDoc
93 */
94 var $doc;
95
96 var $content;
97 var $menu;
98
99 protected $formName = 'queryform';
100
101
102 /**
103 * Initialization
104 *
105 * @return void
106 */
107 function init() {
108 global $LANG,$BACK_PATH;
109 $this->MCONF = $GLOBALS['MCONF'];
110
111 $this->menuConfig();
112
113 $this->doc = t3lib_div::makeInstance('template');
114 $this->doc->backPath = $BACK_PATH;
115 $this->doc->setModuleTemplate('templates/dbint.html');
116 $this->doc->form='<form action="" method="post" name="'.$this->formName.'">';
117
118 // JavaScript
119 $this->doc->JScode = '
120 <script language="javascript" type="text/javascript">
121 script_ended = 0;
122 function jumpToUrl(URL) {
123 window.location.href = URL;
124 }
125 </script>
126 ';
127 $this->doc->table_TABLE = '<table border="0" cellspacing="0" cellpadding="0" class="typo3-dblist" style="width:400px!important;">
128 <colgroup><col width="24"><col width="300"><col width="76"></colgroup>';
129
130 $this->doc->tableLayout = array (
131 '0' => array (
132 'defCol' => array('<td class="t3-row-header"><img src="' . $this->doc->backPath . 'clear.gif" width="10" height="1" alt="" /></td><td valign="top" class="t3-row-header"><strong>', '</strong></td>')
133 ),
134 'defRow' => array (
135 '0' => array('<td valign="top">','</td>'),
136 '1' => array('<td valign="top">','</td>'),
137 'defCol' => array('<td><img src="' . $this->doc->backPath . 'clear.gif" width="15" height="1" alt="" /></td><td valign="top">', '</td>')
138 )
139 );
140 }
141
142 /**
143 * Configure menu
144 *
145 * @return void
146 */
147 function menuConfig() {
148 global $LANG;
149
150 // MENU-ITEMS:
151 // If array, then it's a selector box menu
152 // If empty string it's just a variable, that'll be saved.
153 // Values NOT in this array will not be saved in the settings-array for the module.
154 $this->MOD_MENU = array(
155 'function' => array(
156 0 => $GLOBALS['LANG']->getLL('menu', true),
157 'records' => $GLOBALS['LANG']->getLL('recordStatistics', true),
158 'relations' => $GLOBALS['LANG']->getLL('databaseRelations', true),
159 'search' => $GLOBALS['LANG']->getLL('fullSearch', true),
160 'filesearch' => $GLOBALS['LANG']->getLL('findFilename', true),
161 'refindex' => $GLOBALS['LANG']->getLL('manageRefIndex', true),
162 ),
163 'search' => array(
164 'raw' => $GLOBALS['LANG']->getLL('rawSearch', true),
165 'query' => $GLOBALS['LANG']->getLL('advancedQuery', true)
166 ),
167
168 'search_query_smallparts' => '',
169 'search_result_labels' => '',
170 'labels_noprefix' => '',
171 'options_sortlabel' => '',
172 'show_deleted' => '',
173
174 'queryConfig' => '', // Current query
175 'queryTable' => '', // Current table
176 'queryFields' => '', // Current tableFields
177 'queryLimit' => '', // Current limit
178 'queryOrder' => '', // Current Order field
179 'queryOrderDesc' => '', // Current Order field descending flag
180 'queryOrder2' => '', // Current Order2 field
181 'queryOrder2Desc' => '', // Current Order2 field descending flag
182 'queryGroup' => '', // Current Group field
183
184 'storeArray' => '', // Used to store the available Query config memory banks
185 'storeQueryConfigs' => '', // Used to store the available Query configs in memory
186
187 'search_query_makeQuery' => array(
188 'all' => $GLOBALS['LANG']->getLL('selectRecords', true),
189 'count' => $GLOBALS['LANG']->getLL('countResults', true),
190 'explain' => $GLOBALS['LANG']->getLL('explainQuery', true),
191 'csv' => $GLOBALS['LANG']->getLL('csvExport', true),
192 'xml' => $GLOBALS['LANG']->getLL('xmlExport', true)
193 ),
194
195 'sword' => ''
196 );
197 // CLEAN SETTINGS
198 $OLD_MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU,'', $this->MCONF['name'], 'ses');
199 $this->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU, t3lib_div::_GP('SET'), $this->MCONF['name'], 'ses');
200
201 if (t3lib_div::_GP('queryConfig')) {
202 $qA = t3lib_div::_GP('queryConfig');
203 $this->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU, array('queryConfig'=>serialize($qA)), $this->MCONF['name'], 'ses');
204 }
205 $addConditionCheck = t3lib_div::_GP('qG_ins');
206 foreach ($OLD_MOD_SETTINGS as $key=>$val) {
207 if (substr($key, 0, 5)=='query' && $this->MOD_SETTINGS[$key]!=$val && $key!='queryLimit' && $key!='use_listview') {
208 $setLimitToStart = 1;
209 if ($key == 'queryTable' && !$addConditionCheck) {
210 $this->MOD_SETTINGS['queryConfig'] = '';
211 }
212 }
213 if ($key=='queryTable' && $this->MOD_SETTINGS[$key]!=$val) {
214 $this->MOD_SETTINGS['queryFields'] = '';
215 }
216 }
217 if ($setLimitToStart) {
218 $currentLimit = explode(',',$this->MOD_SETTINGS['queryLimit']);
219 if ($currentLimit[1]) {
220 $this->MOD_SETTINGS['queryLimit']='0,'.$currentLimit[1];
221 } else {
222 $this->MOD_SETTINGS['queryLimit']='0';
223 }
224 $this->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU, $this->MOD_SETTINGS, $this->MCONF['name'], 'ses');
225 }
226 }
227
228 /**
229 * Main
230 *
231 * @return void
232 */
233 function main() {
234 global $BE_USER,$LANG;
235
236 // Content creation
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 'records':
246 $this->func_records();
247 break;
248 case 'relations':
249 $this->func_relations();
250 break;
251 case 'filesearch':
252 $this->func_filesearch();
253 break;
254 case 'refindex':
255 $this->func_refindex();
256 break;
257 default:
258 $this->func_default();
259 break;
260 }
261
262 // Setting up the buttons and markers for docheader
263 $docHeaderButtons = $this->getButtons();
264 $markers = array(
265 'CSH' => $docHeaderButtons['csh'],
266 'FUNC_MENU' => $this->getFuncMenu(),
267 'CONTENT' => $this->content
268 );
269
270 // Build the <body> for the module
271 $this->content = $this->doc->startPage($GLOBALS['LANG']->getLL('title'));
272 $this->content.= $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
273 $this->content.= $this->doc->endPage();
274 $this->content = $this->doc->insertStylesAndJS($this->content);
275 }
276
277 /**
278 * Print content
279 *
280 * @return void
281 */
282 function printContent() {
283 echo $this->content;
284 }
285
286 /**
287 * Create the panel of buttons for submitting the form or otherwise perform operations.
288 *
289 * @return array all available buttons as an assoc. array
290 */
291 protected function getButtons() {
292
293 $buttons = array(
294 'csh' => '',
295 'shortcut' => ''
296 );
297 // CSH
298 //$buttons['csh'] = t3lib_BEfunc::cshItem('_MOD_web_func', '', $GLOBALS['BACK_PATH']);
299
300 // Shortcut
301 if ($GLOBALS['BE_USER']->mayMakeShortcut()) {
302 $buttons['shortcut'] = $this->doc->makeShortcutIcon('','function,search,search_query_makeQuery',$this->MCONF['name']);
303 }
304 return $buttons;
305 }
306
307 /**
308 * Create the function menu
309 *
310 * @return string HTML of the function menu
311 */
312 protected function getFuncMenu() {
313 if (!$GLOBALS['BE_USER']->userTS['mod.']['dbint.']['disableTopMenu']) {
314 $funcMenu = t3lib_BEfunc::getFuncMenu(0, 'SET[function]', $this->MOD_SETTINGS['function'], $this->MOD_MENU['function']);
315 }
316 return $funcMenu;
317 }
318
319 /**
320 * Menu
321 *
322 * @return void
323 */
324 function func_default() {
325 $this->content .= $this->doc->header($GLOBALS['LANG']->getLL('title'));
326
327 $content = '<dl class="t3-overview-list">';
328
329 $availableModFuncs = array('records', 'relations', 'search', 'filesearch', 'refindex');
330 foreach ($availableModFuncs as $modFunc) {
331 $link = 'index.php?SET[function]=' . $modFunc;
332 $title = $GLOBALS['LANG']->getLL($modFunc);
333 $description = $GLOBALS['LANG']->getLL($modFunc . '_description');
334 $content .= '
335 <dt><a href="' . $link . '">' . $title . '</a></dt>
336 <dd>' . $description . '</dd>
337 ';
338 }
339
340 $content .= '</dl>';
341 $this->content .= $content;
342 }
343
344
345
346
347
348
349
350
351 /****************************
352 *
353 * Functionality implementation
354 *
355 ****************************/
356
357 /**
358 * Check and update reference index!
359 *
360 * @return void
361 */
362 function func_refindex() {
363 global $TYPO3_DB,$TCA;
364
365 if (t3lib_div::_GP('_update') || t3lib_div::_GP('_check')) {
366 $testOnly = t3lib_div::_GP('_check')?TRUE:FALSE;
367
368 // Call the functionality
369 $refIndexObj = t3lib_div::makeInstance('t3lib_refindex');
370 list($headerContent,$bodyContent) = $refIndexObj->updateIndex($testOnly);
371
372 // Output content:
373 $this->content.=$this->doc->section($headerContent,str_replace(LF,'<br/>',$bodyContent),0,1);
374 }
375
376 // Output content:
377 $content = '<p>' . $GLOBALS['LANG']->getLL('referenceIndex_description') . '</p><br />';
378 $content .= '<input type="submit" name="_check" value="' . $GLOBALS['LANG']->getLL('referenceIndex_buttonCheck') . '" /> <input type="submit" name="_update" value="' . $GLOBALS['LANG']->getLL('referenceIndex_buttonUpdate') . '" /><br /><br />';
379 $content .= '<h3>' . $GLOBALS['LANG']->getLL('checkScript_headline') . '</h3>';
380 $content.= '<p>' . $GLOBALS['LANG']->getLL('checkScript') . '</p>';
381 $content.= '<h4>' . $GLOBALS['LANG']->getLL('checkScript_check_description') . '</h4>' .
382 '<code>php ' . PATH_typo3 . 'cli_dispatch.phpsh lowlevel_refindex -c</code><br />';
383 $content.= '<h4>' . $GLOBALS['LANG']->getLL('checkScript_update_description') . '</h4>' .
384 '<code>php ' . PATH_typo3 . 'cli_dispatch.phpsh lowlevel_refindex -e</code><br /><br />';
385 $content.= '<div class="typo3-message message-information"><div class="message-body">' . $GLOBALS['LANG']->getLL('checkScript_information') . '</div></div>';
386 $content.= '<p>' . $GLOBALS['LANG']->getLL('checkScript_moreDetails') . '<br /><a href="' . $GLOBALS['BACK_PATH'] . 'sysext/lowlevel/HOWTO_clean_up_TYPO3_installations.txt" target="_new">' . PATH_typo3 . 'sysext/lowlevel/HOWTO_clean_up_TYPO3_installations.txt</a></p>';
387
388 $this->content.= $this->doc->section($GLOBALS['LANG']->getLL('updateRefIndex'), $content, false, true);
389 }
390
391 /**
392 * Search (Full / Advanced)
393 *
394 * @return void
395 */
396 function func_search() {
397 global $LANG;
398
399 $fullsearch = t3lib_div::makeInstance('t3lib_fullsearch');
400 $fullsearch->setFormName($this->formName);
401 $this->content.= $this->doc->header($GLOBALS['LANG']->getLL('search'));
402 $this->content.= $this->doc->spacer(5);
403
404 $menu2='';
405 if (!$GLOBALS['BE_USER']->userTS['mod.']['dbint.']['disableTopMenu']) {
406 $menu2 = t3lib_BEfunc::getFuncMenu(0, 'SET[search]', $this->MOD_SETTINGS['search'], $this->MOD_MENU['search']);
407 }
408 if ($this->MOD_SETTINGS['search']=='query' && !$GLOBALS['BE_USER']->userTS['mod.']['dbint.']['disableTopMenu']) {
409 $menu2 .= t3lib_BEfunc::getFuncMenu(0, 'SET[search_query_makeQuery]', $this->MOD_SETTINGS['search_query_makeQuery'], $this->MOD_MENU['search_query_makeQuery']) . '<br />';
410 }
411 if (!$GLOBALS['BE_USER']->userTS['mod.']['dbint.']['disableTopCheckboxes'] && $this->MOD_SETTINGS['search']=='query') {
412 $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 />';
413 $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 />';
414 $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 />';
415 $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 />';
416 $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>';
417 }
418
419 $this->content.= $this->doc->section('',$menu2).$this->doc->spacer(10);
420
421 switch($this->MOD_SETTINGS['search']) {
422 case 'query':
423 $this->content.=$fullsearch->queryMaker();
424 break;
425 case 'raw':
426 default:
427 $this->content.=$this->doc->section($GLOBALS['LANG']->getLL('searchOptions'), $fullsearch->form(), false, true);
428 $this->content.=$this->doc->section($GLOBALS['LANG']->getLL('result'), $fullsearch->search(), false, true);
429 break;
430 }
431 }
432
433
434 /**
435 * Records overview
436 *
437 * @return void
438 */
439 function func_records() {
440 global $LANG,$TCA,$BACK_PATH,$PAGES_TYPES;
441
442 $admin = t3lib_div::makeInstance('t3lib_admin');
443 $admin->genTree_makeHTML = 0;
444 $admin->backPath = $BACK_PATH;
445 $admin->genTree(0,'');
446
447 $this->content.= $this->doc->header($GLOBALS['LANG']->getLL('records'));
448 $this->content.= $this->doc->spacer(5);
449
450 // Pages stat
451 $codeArr=array();
452 $codeArr['tableheader'] = array('', $GLOBALS['LANG']->getLL('count'));
453 $i++;
454 $codeArr[$i][]='<img' . t3lib_iconWorks::skinImg($BACK_PATH,'gfx/i/pages.gif','width="18" height="16"') . ' hspace="4" align="top" alt="" />';
455 $codeArr[$i][]=$GLOBALS['LANG']->getLL('total_pages');
456 $codeArr[$i][]=count($admin->page_idArray);
457 $i++;
458 if (t3lib_extMgm::isLoaded('cms')) {
459 $codeArr[$i][]='<img' . t3lib_iconWorks::skinImg($BACK_PATH,'gfx/hidden_page.gif','width="18" height="16"') . ' hspace="4" align="top">';
460 $codeArr[$i][]=$GLOBALS['LANG']->getLL('hidden_pages');
461 $codeArr[$i][]=$admin->recStat['hidden'];
462 $i++;
463 }
464 $codeArr[$i][]='<img' . t3lib_iconWorks::skinImg($BACK_PATH,'gfx/deleted_page.gif','width="18" height="16"') . ' hspace="4" align="top">';
465 $codeArr[$i][]=$GLOBALS['LANG']->getLL('deleted_pages');
466 $codeArr[$i][]=$admin->recStat['deleted'];
467
468 $this->content.=$this->doc->section($GLOBALS['LANG']->getLL('pages'), $this->doc->table($codeArr), false, true);
469
470 // Doktype
471 $codeArr=array();
472 $codeArr['tableheader'] = array($GLOBALS['LANG']->getLL('doktype_value'), $GLOBALS['LANG']->getLL('count'));
473 $doktype= $TCA['pages']['columns']['doktype']['config']['items'];
474 if (is_array($doktype)) {
475 foreach ($doktype as $n => $setup) {
476 if ($setup[1]!='--div--') {
477 $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">';
478 $codeArr[$n][] = $GLOBALS['LANG']->sL($setup[0]) . ' (' . $setup[1] . ')';
479 $codeArr[$n][] = intval($admin->recStat[doktype][$setup[1]]);
480 }
481 }
482 $this->content.=$this->doc->section($GLOBALS['LANG']->getLL('doktype'), $this->doc->table($codeArr), false, true);
483 }
484
485 // Tables and lost records
486 $id_list = '-1,0,'.implode(array_keys($admin->page_idArray),',');
487 $id_list = t3lib_div::rm_endcomma($id_list);
488 $admin->lostRecords($id_list);
489
490 if ($admin->fixLostRecord(t3lib_div::_GET('fixLostRecords_table'),t3lib_div::_GET('fixLostRecords_uid'))) {
491 $admin = t3lib_div::makeInstance('t3lib_admin');
492 $admin->backPath = $BACK_PATH;
493 $admin->genTree(0,'');
494 $id_list = '-1,0,'.implode(array_keys($admin->page_idArray),',');
495 $id_list = t3lib_div::rm_endcomma($id_list);
496 $admin->lostRecords($id_list);
497 }
498
499 $this->doc->table_TABLE = '<table border="0" cellspacing="0" cellpadding="0" class="typo3-dblist" style="width:700px!important;">';
500
501 $codeArr = array();
502 $codeArr['tableheader'] = array(
503 $GLOBALS['LANG']->getLL('label'),
504 $GLOBALS['LANG']->getLL('tablename'),
505 $GLOBALS['LANG']->getLL('total_lost'),
506 ''
507 );
508
509 $countArr = $admin->countRecords($id_list);
510 if (is_array($TCA)) {
511
512 foreach ($TCA as $t => $value) {
513 if ($TCA[$t]['ctrl']['hideTable']) {
514 continue;
515 }
516 $codeArr[$t][]=t3lib_iconWorks::getSpriteIconForRecord($t, array());
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 foreach ($admin->lRecords[$t] as $data) {
530 if (!t3lib_div::inList($admin->lostPagesList,$data[pid])) {
531 $lr.= '<nobr><strong><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) . '</strong></nobr><br>';
532 } else {
533 $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>';
534 }
535 }
536 }
537 $codeArr[$t][]=$lr;
538 }
539 $this->content.=$this->doc->section($GLOBALS['LANG']->getLL('tables'), $this->doc->table($codeArr), false, true);
540 }
541 }
542
543 /**
544 * Show list references
545 *
546 * @return void
547 */
548 function func_relations() {
549 global $LANG,$BACK_PATH;
550
551 $this->content.= $this->doc->header($GLOBALS['LANG']->getLL('relations'));
552 $this->content.= $this->doc->spacer(5);
553
554 $admin = t3lib_div::makeInstance('t3lib_admin');
555 $admin->genTree_makeHTML=0;
556 $admin->backPath = $BACK_PATH;
557
558 $fkey_arrays = $admin->getGroupFields('');
559 $admin->selectNonEmptyRecordsWithFkeys($fkey_arrays);
560
561
562 $fileTest = $admin->testFileRefs();
563
564 $code='';
565 if (is_array($fileTest['noReferences'])) {
566 foreach ($fileTest['noReferences'] as $val) {
567 $code.='<nobr>' . $val[0] . '/<strong>' . $val[1] . '</strong></nobr><br>';
568 }
569 }
570 $this->content.=$this->doc->section($GLOBALS['LANG']->getLL('files_no_ref'), $code, true, true);
571
572 $code='';
573 if (is_array($fileTest['moreReferences'])) {
574 foreach ($fileTest['moreReferences'] as $val) {
575 $code.='<nobr>' . $val[0] . '/<strong>' . $val[1] . '</strong>: ' . $val[2] . ' ' . $GLOBALS['LANG']->getLL('references') . '</nobr><br>' . $val[3] . '<br><br>';
576 }
577 }
578 $this->content.=$this->doc->section($GLOBALS['LANG']->getLL('files_many_ref'),$code, true, true);
579
580 $code='';
581 if (is_array($fileTest['noFile'])) {
582 ksort($fileTest['noFile']);
583 foreach ($fileTest['noFile'] as $val) {
584 $code.='<nobr>' . $val[0] . '/<strong>' . $val[1] . '</strong> ' . $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><strong>' . $value . '/</strong> ' . $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><strong>' . $value . '/</strong> ' . $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 (preg_match('/'.$pattern.'/i',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
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 // Make instance:
685 $SOBE = t3lib_div::makeInstance('SC_mod_tools_dbint_index');
686 $SOBE->init();
687 $SOBE->main();
688 $SOBE->printContent();
689
690 ?>