8e5abb6675d8511ef963b784ec6fb5946da448ed
[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->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
272 // Renders the module page
273 $this->content = $this->doc->render(
274 $GLOBALS['LANG']->getLL('title'),
275 $this->content
276 );
277 }
278
279 /**
280 * Print content
281 *
282 * @return void
283 */
284 function printContent() {
285 echo $this->content;
286 }
287
288 /**
289 * Create the panel of buttons for submitting the form or otherwise perform operations.
290 *
291 * @return array all available buttons as an assoc. array
292 */
293 protected function getButtons() {
294
295 $buttons = array(
296 'csh' => '',
297 'shortcut' => ''
298 );
299 // CSH
300 //$buttons['csh'] = t3lib_BEfunc::cshItem('_MOD_web_func', '', $GLOBALS['BACK_PATH']);
301
302 // Shortcut
303 if ($GLOBALS['BE_USER']->mayMakeShortcut()) {
304 $buttons['shortcut'] = $this->doc->makeShortcutIcon('','function,search,search_query_makeQuery',$this->MCONF['name']);
305 }
306 return $buttons;
307 }
308
309 /**
310 * Create the function menu
311 *
312 * @return string HTML of the function menu
313 */
314 protected function getFuncMenu() {
315 if (!$GLOBALS['BE_USER']->userTS['mod.']['dbint.']['disableTopMenu']) {
316 $funcMenu = t3lib_BEfunc::getFuncMenu(0, 'SET[function]', $this->MOD_SETTINGS['function'], $this->MOD_MENU['function']);
317 }
318 return $funcMenu;
319 }
320
321 /**
322 * Menu
323 *
324 * @return void
325 */
326 function func_default() {
327 $this->content .= $this->doc->header($GLOBALS['LANG']->getLL('title'));
328
329 $content = '<dl class="t3-overview-list">';
330
331 $availableModFuncs = array('records', 'relations', 'search', 'filesearch', 'refindex');
332 foreach ($availableModFuncs as $modFunc) {
333 $link = 'index.php?SET[function]=' . $modFunc;
334 $title = $GLOBALS['LANG']->getLL($modFunc);
335 $description = $GLOBALS['LANG']->getLL($modFunc . '_description');
336 $content .= '
337 <dt><a href="' . $link . '">' . $title . '</a></dt>
338 <dd>' . $description . '</dd>
339 ';
340 }
341
342 $content .= '</dl>';
343 $this->content .= $content;
344 }
345
346
347
348
349
350
351
352
353 /****************************
354 *
355 * Functionality implementation
356 *
357 ****************************/
358
359 /**
360 * Check and update reference index!
361 *
362 * @return void
363 */
364 function func_refindex() {
365 global $TYPO3_DB,$TCA;
366
367 if (t3lib_div::_GP('_update') || t3lib_div::_GP('_check')) {
368 $testOnly = t3lib_div::_GP('_check')?TRUE:FALSE;
369
370 // Call the functionality
371 $refIndexObj = t3lib_div::makeInstance('t3lib_refindex');
372 list($headerContent,$bodyContent) = $refIndexObj->updateIndex($testOnly);
373
374 // Output content:
375 $this->content.=$this->doc->section($headerContent,str_replace(LF,'<br/>',$bodyContent),0,1);
376 }
377
378 // Output content:
379 $content = '<p>' . $GLOBALS['LANG']->getLL('referenceIndex_description') . '</p><br />';
380 $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 />';
381 $content .= '<h3>' . $GLOBALS['LANG']->getLL('checkScript_headline') . '</h3>';
382 $content.= '<p>' . $GLOBALS['LANG']->getLL('checkScript') . '</p>';
383 $content.= '<h4>' . $GLOBALS['LANG']->getLL('checkScript_check_description') . '</h4>' .
384 '<code>php ' . PATH_typo3 . 'cli_dispatch.phpsh lowlevel_refindex -c</code><br />';
385 $content.= '<h4>' . $GLOBALS['LANG']->getLL('checkScript_update_description') . '</h4>' .
386 '<code>php ' . PATH_typo3 . 'cli_dispatch.phpsh lowlevel_refindex -e</code><br /><br />';
387 $content.= '<div class="typo3-message message-information"><div class="message-body">' . $GLOBALS['LANG']->getLL('checkScript_information') . '</div></div>';
388 $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>';
389
390 $this->content.= $this->doc->section($GLOBALS['LANG']->getLL('updateRefIndex'), $content, false, true);
391 }
392
393 /**
394 * Search (Full / Advanced)
395 *
396 * @return void
397 */
398 function func_search() {
399 global $LANG;
400
401 $fullsearch = t3lib_div::makeInstance('t3lib_fullsearch');
402 $fullsearch->setFormName($this->formName);
403 $this->content.= $this->doc->header($GLOBALS['LANG']->getLL('search'));
404 $this->content.= $this->doc->spacer(5);
405
406 $menu2='';
407 if (!$GLOBALS['BE_USER']->userTS['mod.']['dbint.']['disableTopMenu']) {
408 $menu2 = t3lib_BEfunc::getFuncMenu(0, 'SET[search]', $this->MOD_SETTINGS['search'], $this->MOD_MENU['search']);
409 }
410 if ($this->MOD_SETTINGS['search']=='query' && !$GLOBALS['BE_USER']->userTS['mod.']['dbint.']['disableTopMenu']) {
411 $menu2 .= t3lib_BEfunc::getFuncMenu(0, 'SET[search_query_makeQuery]', $this->MOD_SETTINGS['search_query_makeQuery'], $this->MOD_MENU['search_query_makeQuery']) . '<br />';
412 }
413 if (!$GLOBALS['BE_USER']->userTS['mod.']['dbint.']['disableTopCheckboxes'] && $this->MOD_SETTINGS['search']=='query') {
414 $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 />';
415 $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 />';
416 $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 />';
417 $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 />';
418 $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>';
419 }
420
421 $this->content.= $this->doc->section('',$menu2).$this->doc->spacer(10);
422
423 switch($this->MOD_SETTINGS['search']) {
424 case 'query':
425 $this->content.=$fullsearch->queryMaker();
426 break;
427 case 'raw':
428 default:
429 $this->content.=$this->doc->section($GLOBALS['LANG']->getLL('searchOptions'), $fullsearch->form(), false, true);
430 $this->content.=$this->doc->section($GLOBALS['LANG']->getLL('result'), $fullsearch->search(), false, true);
431 break;
432 }
433 }
434
435
436 /**
437 * Records overview
438 *
439 * @return void
440 */
441 function func_records() {
442 global $LANG,$TCA,$BACK_PATH,$PAGES_TYPES;
443
444 $admin = t3lib_div::makeInstance('t3lib_admin');
445 $admin->genTree_makeHTML = 0;
446 $admin->backPath = $BACK_PATH;
447 $admin->genTree(0,'');
448
449 $this->content.= $this->doc->header($GLOBALS['LANG']->getLL('records'));
450 $this->content.= $this->doc->spacer(5);
451
452 // Pages stat
453 $codeArr=array();
454 $codeArr['tableheader'] = array('', $GLOBALS['LANG']->getLL('count'));
455 $i++;
456 $codeArr[$i][]='<img' . t3lib_iconWorks::skinImg($BACK_PATH,'gfx/i/pages.gif','width="18" height="16"') . ' hspace="4" align="top" alt="" />';
457 $codeArr[$i][]=$GLOBALS['LANG']->getLL('total_pages');
458 $codeArr[$i][]=count($admin->page_idArray);
459 $i++;
460 if (t3lib_extMgm::isLoaded('cms')) {
461 $codeArr[$i][]='<img' . t3lib_iconWorks::skinImg($BACK_PATH,'gfx/hidden_page.gif','width="18" height="16"') . ' hspace="4" align="top">';
462 $codeArr[$i][]=$GLOBALS['LANG']->getLL('hidden_pages');
463 $codeArr[$i][]=$admin->recStat['hidden'];
464 $i++;
465 }
466 $codeArr[$i][]='<img' . t3lib_iconWorks::skinImg($BACK_PATH,'gfx/deleted_page.gif','width="18" height="16"') . ' hspace="4" align="top">';
467 $codeArr[$i][]=$GLOBALS['LANG']->getLL('deleted_pages');
468 $codeArr[$i][]=$admin->recStat['deleted'];
469
470 $this->content.=$this->doc->section($GLOBALS['LANG']->getLL('pages'), $this->doc->table($codeArr), false, true);
471
472 // Doktype
473 $codeArr=array();
474 $codeArr['tableheader'] = array($GLOBALS['LANG']->getLL('doktype_value'), $GLOBALS['LANG']->getLL('count'));
475 $doktype= $TCA['pages']['columns']['doktype']['config']['items'];
476 if (is_array($doktype)) {
477 foreach ($doktype as $n => $setup) {
478 if ($setup[1]!='--div--') {
479 $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">';
480 $codeArr[$n][] = $GLOBALS['LANG']->sL($setup[0]) . ' (' . $setup[1] . ')';
481 $codeArr[$n][] = intval($admin->recStat[doktype][$setup[1]]);
482 }
483 }
484 $this->content.=$this->doc->section($GLOBALS['LANG']->getLL('doktype'), $this->doc->table($codeArr), false, true);
485 }
486
487 // Tables and lost records
488 $id_list = '-1,0,' . implode(',', array_keys($admin->page_idArray));
489 $id_list = rtrim($id_list, ',');
490 $admin->lostRecords($id_list);
491
492 if ($admin->fixLostRecord(t3lib_div::_GET('fixLostRecords_table'), t3lib_div::_GET('fixLostRecords_uid'))) {
493 $admin = t3lib_div::makeInstance('t3lib_admin');
494 $admin->backPath = $BACK_PATH;
495 $admin->genTree(0,'');
496 $id_list = '-1,0,' . implode(',', array_keys($admin->page_idArray));
497 $id_list = rtrim($id_list, ',');
498 $admin->lostRecords($id_list);
499 }
500
501 $this->doc->table_TABLE = '<table border="0" cellspacing="0" cellpadding="0" class="typo3-dblist" style="width:700px!important;">';
502
503 $codeArr = array();
504 $codeArr['tableheader'] = array(
505 $GLOBALS['LANG']->getLL('label'),
506 $GLOBALS['LANG']->getLL('tablename'),
507 $GLOBALS['LANG']->getLL('total_lost'),
508 ''
509 );
510
511 $countArr = $admin->countRecords($id_list);
512 if (is_array($TCA)) {
513
514 foreach ($TCA as $t => $value) {
515 if ($TCA[$t]['ctrl']['hideTable']) {
516 continue;
517 }
518 $codeArr[$t][]=t3lib_iconWorks::getSpriteIconForRecord($t, array());
519 $codeArr[$t][]=$LANG->sL($TCA[$t]['ctrl']['title']);
520 $codeArr[$t][]=$t;
521
522 if ($countArr['all'][$t]) {
523 $theNumberOfRe = intval($countArr['non_deleted'][$t]).'/'.(intval($countArr['all'][$t])-intval($countArr['non_deleted'][$t]));
524 } else {
525 $theNumberOfRe ='';
526 }
527 $codeArr[$t][]=$theNumberOfRe;
528
529 $lr='';
530 if (is_array($admin->lRecords[$t])) {
531 foreach ($admin->lRecords[$t] as $data) {
532 if (!t3lib_div::inList($admin->lostPagesList,$data[pid])) {
533 $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>';
534 } else {
535 $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>';
536 }
537 }
538 }
539 $codeArr[$t][]=$lr;
540 }
541 $this->content.=$this->doc->section($GLOBALS['LANG']->getLL('tables'), $this->doc->table($codeArr), false, true);
542 }
543 }
544
545 /**
546 * Show list references
547 *
548 * @return void
549 */
550 function func_relations() {
551 global $LANG,$BACK_PATH;
552
553 $this->content.= $this->doc->header($GLOBALS['LANG']->getLL('relations'));
554 $this->content.= $this->doc->spacer(5);
555
556 $admin = t3lib_div::makeInstance('t3lib_admin');
557 $admin->genTree_makeHTML=0;
558 $admin->backPath = $BACK_PATH;
559
560 $fkey_arrays = $admin->getGroupFields('');
561 $admin->selectNonEmptyRecordsWithFkeys($fkey_arrays);
562
563
564 $fileTest = $admin->testFileRefs();
565
566 $code='';
567 if (is_array($fileTest['noReferences'])) {
568 foreach ($fileTest['noReferences'] as $val) {
569 $code.='<nobr>' . $val[0] . '/<strong>' . $val[1] . '</strong></nobr><br>';
570 }
571 }
572 $this->content.=$this->doc->section($GLOBALS['LANG']->getLL('files_no_ref'), $code, true, true);
573
574 $code='';
575 if (is_array($fileTest['moreReferences'])) {
576 foreach ($fileTest['moreReferences'] as $val) {
577 $code.='<nobr>' . $val[0] . '/<strong>' . $val[1] . '</strong>: ' . $val[2] . ' ' . $GLOBALS['LANG']->getLL('references') . '</nobr><br>' . $val[3] . '<br><br>';
578 }
579 }
580 $this->content.=$this->doc->section($GLOBALS['LANG']->getLL('files_many_ref'),$code, true, true);
581
582 $code='';
583 if (is_array($fileTest['noFile'])) {
584 ksort($fileTest['noFile']);
585 foreach ($fileTest['noFile'] as $val) {
586 $code.='<nobr>' . $val[0] . '/<strong>' . $val[1] . '</strong> ' . $GLOBALS['LANG']->getLL('isMissing') . ' </nobr><br>' . $GLOBALS['LANG']->getLL('referencedFrom') . $val[2] . '<br><br>';
587 }
588 }
589 $this->content.= $this->doc->section($GLOBALS['LANG']->getLL('files_no_file'), $code, true, true);
590 $this->content.= $this->doc->section($GLOBALS['LANG']->getLL('select_db'), $admin->testDBRefs($admin->checkSelectDBRefs), true, true);
591 $this->content.= $this->doc->section($GLOBALS['LANG']->getLL('group_db'), $admin->testDBRefs($admin->checkGroupDBRefs), true, true);
592 }
593
594 /**
595 * Searching for files with a specific pattern
596 *
597 * @return void
598 */
599 function func_filesearch() {
600 $pattern = t3lib_div::_GP('pattern');
601 $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') . '">';
602 $this->content.= $this->doc->section($GLOBALS['LANG']->getLL('pattern'), $pcontent, false, true);
603
604 if (strcmp($pattern,'')) {
605 $dirs = t3lib_div::get_dirs(PATH_site);
606 $lines=array();
607 $depth=10;
608
609 foreach ($dirs as $key => $value) {
610 $matching_files=array();
611 $info='';
612 if (!t3lib_div::inList('typo3,typo3conf,tslib,media,t3lib',$value)) {
613 $info = $this->findFile(PATH_site.$value.'/',$pattern,$matching_files,$depth);
614 }
615 if (is_array($info)) {
616 $lines[]='<hr><strong>' . $value . '/</strong> ' . $GLOBALS['LANG']->getLL('beingChecked');
617 $lines[]=$GLOBALS['LANG']->getLL('directories') . ' ' . $info[0];
618 if ($info[2]) $lines[]='<span class="typo3-red">' . $GLOBALS['LANG']->getLL('directoriesTooDeep') . ' ' . $depth . '</span>';
619 $lines[]=$GLOBALS['LANG']->getLL('files') . ' ' . $info[1];
620 $lines[]=$GLOBALS['LANG']->getLL('matchingFiles') . '<br><nobr><span class="typo3-red">' . implode('<br>', $matching_files) . '</span></nobr>';
621 } else {
622 $lines[]=$GLOBALS['TBE_TEMPLATE']->dfw('<hr><strong>' . $value . '/</strong> ' . $GLOBALS['LANG']->getLL('notChecked'));
623 }
624 }
625
626 $this->content.=$this->doc->section($GLOBALS['LANG']->getLL('searchingForFilenames'), implode('<br>', $lines), false, true);
627 }
628 }
629
630 /**
631 * Searching for filename pattern recursively in the specified dir.
632 *
633 * @param string Base directory
634 * @param string Match pattern
635 * @param array Array of matching files, passed by reference
636 * @param integer Depth to recurse
637 * @return array Array with various information about the search result
638 * @see func_filesearch()
639 */
640 function findFile($basedir,$pattern,&$matching_files,$depth) {
641 $files_searched=0;
642 $dirs_searched=0;
643 $dirs_error=0;
644
645 // Traverse files:
646 $files = t3lib_div::getFilesInDir($basedir,'',1);
647 if (is_array($files)) {
648 $files_searched+=count($files);
649 foreach ($files as $value) {
650 if (preg_match('/'.$pattern.'/i',basename($value))) $matching_files[]=substr($value,strlen(PATH_site));
651 }
652 }
653
654
655 // Traverse subdirs
656 if ($depth>0) {
657 $dirs = t3lib_div::get_dirs($basedir);
658 if (is_array($dirs)) {
659 $dirs_searched+=count($dirs);
660
661 foreach ($dirs as $value) {
662 $inf= $this->findFile($basedir.$value.'/',$pattern,$matching_files,$depth-1);
663 $dirs_searched+=$inf[0];
664 $files_searched+=$inf[1];
665 $dirs_error=$inf[2];
666 }
667 }
668 } else {
669 $dirs = t3lib_div::get_dirs($basedir);
670 if (is_array($dirs) && count($dirs)) {
671 $dirs_error=1; // Means error - there were further subdirs!
672 }
673 }
674
675 return array($dirs_searched,$files_searched,$dirs_error);
676 }
677 }
678
679
680 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/lowlevel/dbint/index.php'])) {
681 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/lowlevel/dbint/index.php']);
682 }
683
684
685
686 // Make instance:
687 $SOBE = t3lib_div::makeInstance('SC_mod_tools_dbint_index');
688 $SOBE->init();
689 $SOBE->main();
690 $SOBE->printContent();
691
692 ?>