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