3e70af2e7559522de9d4a251c3308059a804c04a
[Packages/TYPO3.CMS.git] / typo3 / sysext / lowlevel / dbint / index.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2005 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 Skårhøj <kasperYYYY@typo3.com>
33 */
34
35
36 unset($MCONF);
37 require ("conf.php");
38 require ($BACK_PATH."init.php");
39 require ($BACK_PATH."template.php");
40 require_once (PATH_t3lib."class.t3lib_admin.php");
41 require_once (PATH_t3lib."class.t3lib_loaddbgroup.php");
42 require_once (PATH_t3lib."class.t3lib_querygenerator.php");
43 require_once (PATH_t3lib."class.t3lib_xml.php");
44 require_once (PATH_t3lib."class.t3lib_fullsearch.php");
45 require_once (PATH_t3lib."class.t3lib_refindex.php");
46
47 $BE_USER->modAccess($MCONF,1);
48
49
50
51 // **************************
52 // Setting english (ONLY!) LOCAL_LANG
53 // **************************
54 $LOCAL_LANG = Array (
55 "default" => Array (
56 "tables" => "Tables:",
57 "fixLostRecord" => "Click to move this lost record to rootlevel (pid=0)",
58
59 "doktype" => "Document types:",
60 "pages" => "Pages:",
61 "total_pages" => "Total number of pages:",
62 "deleted_pages" => "Marked-deleted pages:",
63 "hidden_pages" => "Hidden pages:",
64 "relations" => "Relations:",
65 "relations_description" => "This will analyse the content of the tables and check if there are 'empty' relations between records or if files are missing from their expected position.",
66
67 "files_many_ref" => "Files referenced from more than one record:",
68 "files_no_ref" => "Files with no references at all (delete them!):",
69 "files_no_file" => "Missing files:",
70 "select_db" => "Select fields:",
71 "group_db" => "Group fields:",
72
73 "tree" => "The Page Tree:",
74 "tree_description" => "This shows all pages in the system in one large tree. Beware that this will probably result in a very long document which will also take some time for the server to compute!",
75 "records" => "Records Statistics:",
76 "records_description" => "This shows some statistics for the records in the database. This runs through the entire page-tree and therefore it will also load the server heavily!",
77 "search" => "Search Whole Database",
78 "search_description" => "This searches through all database tables and records for a text string.",
79 "filesearch" => "Search all filenames for pattern",
80 "filesearch_description" => "Will search recursively for filenames in the PATH_site (subdirs to the website path) matching a certain regex pattern.",
81 "title" => "Database integrity check"
82 )
83 );
84
85
86
87
88
89 // ***************************
90 // Script Classes
91 // ***************************
92 class SC_mod_tools_dbint_index {
93 var $MCONF=array();
94 var $MOD_MENU=array();
95 var $MOD_SETTINGS=array();
96 var $doc;
97
98 var $content;
99 var $menu;
100
101 /**
102 * @return [type] ...
103 */
104 function init() {
105 global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$CLIENT,$TYPO3_CONF_VARS;
106 $this->MCONF = $GLOBALS["MCONF"];
107
108 $this->menuConfig();
109
110 $this->doc = t3lib_div::makeInstance("mediumDoc");
111 $this->doc->form='<form action="" method="POST">';
112 $this->doc->backPath = $BACK_PATH;
113 // JavaScript
114 $this->doc->JScode = '
115 <script language="javascript" type="text/javascript">
116 script_ended = 0;
117 function jumpToUrl(URL) {
118 document.location = URL;
119 }
120 </script>
121 ';
122 $this->doc->tableLayout = Array (
123 "defRow" => Array (
124 "0" => Array('<TD valign="top">','</td>'),
125 "1" => Array('<TD valign="top">','</td>'),
126 "defCol" => Array('<TD><img src="'.$this->doc->backPath.'clear.gif" width=15 height=1></td><td valign="top">','</td>')
127 )
128 );
129 }
130
131 /**
132 * @return [type] ...
133 */
134 function menuConfig() {
135 global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$CLIENT,$TYPO3_CONF_VARS;
136
137 // MENU-ITEMS:
138 // If array, then it's a selector box menu
139 // If empty string it's just a variable, that'll be saved.
140 // Values NOT in this array will not be saved in the settings-array for the module.
141 $this->MOD_MENU = array(
142 "function" => array(
143 0 => "[ MENU ]",
144 "records" => "Record Statistics",
145 "tree" => "Total Page Tree",
146 "relations" => "Database Relations",
147 "search" => "Full search",
148 "filesearch" => "Find filename",
149 'refindex' => 'Manage Reference Index',
150 ),
151 "search" => array(
152 "raw" => "Raw search in all fields",
153 "query" => "Advanced query"
154 ),
155
156 "search_query_smallparts" => "",
157
158 "queryConfig" => "", // Current query
159 "queryTable" => "", // Current table
160 "queryFields" => "", // Current tableFields
161 "queryLimit" => "", // Current limit
162 "queryOrder" => "", // Current Order field
163 "queryOrderDesc" => "", // Current Order field descending flag
164 "queryOrder2" => "", // Current Order2 field
165 "queryOrder2Desc" => "", // Current Order2 field descending flag
166 "queryGroup" => "", // Current Group field
167
168 "storeArray" => "", // Used to store the available Query config memory banks
169 "storeQueryConfigs" => "", // Used to store the available Query configs in memory
170
171 "search_query_makeQuery" => array(
172 "all" => "Select records",
173 "count" => "Count results",
174 "explain" => "Explain query",
175 "csv" => "CSV Export",
176 "xml" => "XML Export"
177 ),
178
179
180 "sword" => ""
181 );
182 // CLEANSE SETTINGS
183 $this->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU, t3lib_div::_GP("SET"), $this->MCONF["name"], "ses");
184
185 if (t3lib_div::_GP("queryConfig")) {
186 $qA = t3lib_div::_GP("queryConfig");
187 $this->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU, array("queryConfig"=>serialize($qA)), $this->MCONF["name"], "ses");
188 }
189 }
190
191 /**
192 * @return [type] ...
193 */
194 function main() {
195 global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$CLIENT,$TYPO3_CONF_VARS;
196
197 // **************************
198 // Content creation
199 // **************************
200 $this->content.=$this->doc->startPage($LANG->getLL("title"));
201 $this->menu=t3lib_BEfunc::getFuncMenu(0,"SET[function]",$this->MOD_SETTINGS["function"],$this->MOD_MENU["function"]);
202
203 switch($this->MOD_SETTINGS["function"]) {
204 case "search":
205 $this->func_search();
206 break;
207 case "tree":
208 $this->func_tree();
209 break;
210 case "records":
211 $this->func_records();
212 break;
213 case "relations":
214 $this->func_relations();
215 break;
216 case "filesearch":
217 $this->func_filesearch();
218 break;
219 case 'refindex':
220 $this->func_refindex();
221 break;
222 default:
223 $this->func_default();
224 break;
225 }
226
227 if ($BE_USER->mayMakeShortcut()) {
228 $this->content.=$this->doc->spacer(20).
229 $this->doc->section('',$this->doc->makeShortcutIcon("","function,search,search_query_makeQuery",$this->MCONF["name"]));
230 }
231 }
232
233 /**
234 * @return [type] ...
235 */
236 function printContent() {
237
238 $this->content.=$this->doc->endPage();
239 echo $this->content;
240 }
241
242 function func_refindex() {
243 global $TCA,$TYPO3_DB;
244
245 $this->content.=$this->doc->section('',$this->menu);//$this->doc->divider(5);
246 $this->content.=$this->doc->section('',$menu2).$this->doc->spacer(10);
247
248 if (t3lib_div::_GP('_update') || t3lib_div::_GP('_check')) {
249 $testOnly = t3lib_div::_GP('_check')?TRUE:FALSE;
250 $errors = array();
251 $tableNames = array();
252 $recCount=0;
253 $tableCount=0;
254
255 // Traverse all tables:
256 foreach($TCA as $tableName => $cfg) {
257 $tableNames[] = $tableName;
258 $tableCount++;
259
260 // Traverse all non-deleted records in tables:
261 $allRecs = $TYPO3_DB->exec_SELECTgetRows('uid',$tableName,'1'.t3lib_BEfunc::deleteClause($tableName));
262 $uidList = array(0);
263 foreach($allRecs as $recdat) {
264 $refIndexObj = t3lib_div::makeInstance('t3lib_refindex');
265 $result = $refIndexObj->updateRefIndexTable($tableName,$recdat['uid'],$testOnly);
266 $uidList[]= $recdat['uid'];
267 $recCount++;
268
269 if ($result['addedNodes'] || $result['deletedNodes']) {
270 $errors[] = 'Record '.$tableName.':'.$recdat['uid'].' had '.$result['addedNodes'].' added indexes and '.$result['deletedNodes'].' deleted indexes';
271 #$errors[] = t3lib_div::view_array($result);
272 }
273 }
274
275 // Searching lost indexes for this table:
276 $where = 'tablename='.$TYPO3_DB->fullQuoteStr($tableName,'sys_refindex').' AND recuid NOT IN ('.implode(',',$uidList).')';
277 $lostIndexes = $TYPO3_DB->exec_SELECTgetRows('hash','sys_refindex',$where);
278 if (count($lostIndexes)) {
279 $errors[] = 'Table '.$tableName.' has '.count($lostIndexes).' lost indexes which are now deleted';
280 if (!$testOnly) $TYPO3_DB->exec_DELETEquery('sys_refindex',$where);
281 }
282 }
283
284 // Searching lost indexes for non-existing tables:
285 $where = 'tablename NOT IN ('.implode(',',$TYPO3_DB->fullQuoteArray($tableNames,'sys_refindex')).')';
286 $lostTables = $TYPO3_DB->exec_SELECTgetRows('hash','sys_refindex',$where);
287 if (count($lostTables)) {
288 $errors[] = 'Index table hosted '.count($lostTables).' indexes for non-existing tables, now removed';
289 if (!$testOnly) $TYPO3_DB->exec_DELETEquery('sys_refindex',$where);
290 }
291
292 $testedHowMuch = $recCount.' records from '.$tableCount.' tables were checked/updated.<br/>';
293 // Output content:
294 $this->content.=$this->doc->section($testOnly ? 'Reference Index TESTED (nothing written)' : 'Reference Index Updated',$testedHowMuch.(count($errors)?implode('<br/>',$errors):'Index Integrity was perfect!'),0,1);
295 }
296
297 // Output content:
298 $content = 'Click here to update reference index: <input type="submit" name="_update" value="Update now!" /><br/>';
299 $content.= 'Click here to test reference index: <input type="submit" name="_check" value="Check now!" />';
300 $this->content.=$this->doc->section('Update reference index',$content,0,1);
301 }
302
303 /**
304 * @return [type] ...
305 */
306 function func_search() {
307 global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$CLIENT,$TYPO3_CONF_VARS;
308
309 $fullsearch = t3lib_div::makeInstance("t3lib_fullsearch");
310 $this->content.=$this->doc->header($LANG->getLL("search"));
311 $this->content.=$this->doc->spacer(5);
312
313 $menu2=t3lib_BEfunc::getFuncMenu(0,"SET[search]",$this->MOD_SETTINGS["search"],$this->MOD_MENU["search"]);
314 if ($this->MOD_SETTINGS["search"]=="query") {
315 $menu2.=t3lib_BEfunc::getFuncMenu(0,"SET[search_query_makeQuery]",$this->MOD_SETTINGS["search_query_makeQuery"],$this->MOD_MENU["search_query_makeQuery"]).
316 "&nbsp;".t3lib_BEfunc::getFuncCheck($GLOBALS["SOBE"]->id,"SET[search_query_smallparts]",$this->MOD_SETTINGS["search_query_smallparts"])."&nbsp;Show SQL parts";
317 }
318 $this->content.=$this->doc->section('',$this->menu);//$this->doc->divider(5);
319 $this->content.=$this->doc->section('',$menu2).$this->doc->spacer(10);
320
321 switch($this->MOD_SETTINGS["search"]) {
322 case "query":
323 $this->content.=$fullsearch->queryMaker();
324 break;
325 case "raw":
326 default:
327 $this->content.=$this->doc->section('Search options:',$fullsearch->form(),0,1);
328 $this->content.=$this->doc->section('Result:',$fullsearch->search(),0,1);
329 break;
330 }
331 }
332
333 /**
334 * @return [type] ...
335 */
336 function func_tree() {
337 global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$CLIENT,$TYPO3_CONF_VARS;
338
339 $startID=0;
340 $admin = t3lib_div::makeInstance("t3lib_admin");
341 $admin->genTree_makeHTML=1;
342 $admin->backPath = $BACK_PATH;
343 $admin->genTree(intval($startID),'<img src="'.$BACK_PATH.'clear.gif" width=1 height=1 align=top>');
344
345 $this->content.=$this->doc->header($LANG->getLL("tree"));
346 $this->content.=$this->doc->spacer(5);
347 $this->content.=$this->doc->section('',$this->menu).$this->doc->divider(5);
348 $this->content.=$this->doc->sectionEnd();
349
350 $this->content.=$admin->genTree_HTML;
351 $this->content.=$admin->lostRecords($admin->genTree_idlist."0");
352 }
353
354 /**
355 * @return [type] ...
356 */
357 function func_records() {
358 global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$CLIENT,$TYPO3_CONF_VARS;
359 global $PAGES_TYPES;
360
361 $admin = t3lib_div::makeInstance("t3lib_admin");
362 $admin->genTree_makeHTML=0;
363 $admin->backPath = $BACK_PATH;
364 $admin->genTree(0,'');
365
366 $this->content.=$this->doc->header($LANG->getLL("records"));
367 $this->content.=$this->doc->spacer(5);
368 $this->content.=$this->doc->section('',$this->menu);
369
370 // Pages stat
371 $codeArr=Array();
372 $i++;
373 $codeArr[$i][]='<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/i/pages.gif','width="18" height="16"').' hspace=4 align="top">';
374 $codeArr[$i][]=$LANG->getLL("total_pages");
375 $codeArr[$i][]=count($admin->page_idArray);
376 $i++;
377 if (t3lib_extMgm::isLoaded("cms")) {
378 $codeArr[$i][]='<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/hidden_page.gif','width="18" height="16"').' hspace=4 align="top">';
379 $codeArr[$i][]=$LANG->getLL("hidden_pages");
380 $codeArr[$i][]=$admin->recStat["hidden"];
381 $i++;
382 }
383 $codeArr[$i][]='<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/deleted_page.gif','width="18" height="16"').' hspace=4 align="top">';
384 $codeArr[$i][]=$LANG->getLL("deleted_pages");
385 $codeArr[$i][]=$admin->recStat["deleted"];
386
387 $this->content.=$this->doc->section($LANG->getLL("pages"),$this->doc->table($codeArr),0,1);
388
389 // Doktype
390 $codeArr=Array();
391 $doktype=$TCA["pages"]["columns"]["doktype"]["config"]["items"];
392 if (is_array($doktype)) {
393 reset($doktype);
394 while(list($n,$setup)=each($doktype)) {
395 if ($setup[1]!="--div--") {
396 $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">';
397 $codeArr[$n][]=$LANG->sL($setup[0]).' ('.$setup[1].')';
398 $codeArr[$n][]=intval($admin->recStat[doktype][$setup[1]]);
399 }
400 }
401 $this->content.=$this->doc->section($LANG->getLL("doktype"),$this->doc->table($codeArr),0,1);
402 }
403
404 // Tables and lost records
405 $id_list="0,".implode($admin->page_idArray,",");
406 $id_list = t3lib_div::rm_endcomma($id_list);
407 $admin->lostRecords($id_list);
408 if ($admin->fixLostRecord(t3lib_div::_GET('fixLostRecords_table'),t3lib_div::_GET('fixLostRecords_uid'))) {
409 $admin = t3lib_div::makeInstance("admin_int");
410 $admin->backPath = $BACK_PATH;
411 $admin->genTree(0,'');
412 $id_list="0,".implode($admin->page_idArray,",");
413 $id_list = t3lib_div::rm_endcomma($id_list);
414 $admin->lostRecords($id_list);
415 }
416
417 $codeArr=Array();
418 $countArr=$admin->countRecords($id_list);
419 if (is_array($TCA)) {
420 reset($TCA);
421 while(list($t)=each($TCA)) {
422 $codeArr[$t][]=t3lib_iconWorks::getIconImage($t,array(),$BACK_PATH,'hspace="4" align="top"');
423 $codeArr[$t][]=$LANG->sL($TCA[$t]["ctrl"]["title"]);
424 $codeArr[$t][]=$t;
425
426 if ($countArr["all"][$t]) {
427 $theNumberOfRe = intval($countArr["non_deleted"][$t])."/".(intval($countArr["all"][$t])-intval($countArr["non_deleted"][$t]));
428 } else {
429 $theNumberOfRe ="";
430 }
431 $codeArr[$t][]=$theNumberOfRe;
432
433 $lr="";
434 if (is_array($admin->lRecords[$t])) {
435 reset($admin->lRecords[$t]);
436 while(list(,$data)=each($admin->lRecords[$t])) {
437 if (!t3lib_div::inList($admin->lostPagesList,$data[pid])) {
438 $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="'.$LANG->getLL("fixLostRecord").'"></a>uid:'.$data[uid].', pid:'.$data[pid].', '.t3lib_div::fixed_lgd(strip_tags($data[title]),20).'</b></NOBR><BR>';
439 } else {
440 $lr.='<NOBR><img src="'.$BACK_PATH.'clear.gif" width=16 height=1 border=0><font color="Gray">uid:'.$data[uid].', pid:'.$data[pid].', '.t3lib_div::fixed_lgd(strip_tags($data[title]),20).'</font></NOBR><BR>';
441 }
442 }
443 }
444 $codeArr[$t][]=$lr;
445 }
446 $this->content.=$this->doc->section($LANG->getLL("tables"),$this->doc->table($codeArr),0,1);
447 }
448 }
449
450 /**
451 * @return [type] ...
452 */
453 function func_relations() {
454 global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$CLIENT,$TYPO3_CONF_VARS;
455
456 $this->content.=$this->doc->header($LANG->getLL("relations"));
457 $this->content.=$this->doc->spacer(5);
458 $this->content.=$this->doc->section('',$this->menu);
459
460 $admin = t3lib_div::makeInstance("t3lib_admin");
461 $admin->genTree_makeHTML=0;
462 $admin->backPath = $BACK_PATH;
463
464 $fkey_arrays = $admin->getGroupFields("");
465 $admin->selectNonEmptyRecordsWithFkeys($fkey_arrays);
466
467
468 $fileTest=$admin->testFileRefs();
469
470 $code="";
471 if (is_array($fileTest["noReferences"])) {
472 while(list(,$val)=each($fileTest["noReferences"])) {
473 $code.="<NOBR>".$val[0]."/<b>".$val[1]."</b></NOBR><BR>";
474 }
475 }
476 $this->content.=$this->doc->section($LANG->getLL("files_no_ref"),$code,1,1);
477
478 $code="";
479 if (is_array($fileTest[moreReferences])) {
480 while(list(,$val)=each($fileTest["moreReferences"])) {
481 $code.="<NOBR>".$val[0]."/<b>".$val[1]."</b>: ".$val[2]." references:</NOBR><BR>".$val[3]."<BR><BR>";
482 }
483 }
484 $this->content.=$this->doc->section($LANG->getLL("files_many_ref"),$code,1,1);
485
486 $code="";
487 if (is_array($fileTest["noFile"])) {
488 ksort($fileTest["noFile"]);
489 reset($fileTest["noFile"]);
490 while(list(,$val)=each($fileTest["noFile"])) {
491 $code.="<NOBR>".$val[0]."/<b>".$val[1]."</b> is missing! </NOBR><BR>Referenced from: ".$val[2]."<BR><BR>";
492 }
493 }
494 $this->content.=$this->doc->section($LANG->getLL("files_no_file"),$code,1,1);
495 $this->content.=$this->doc->section($LANG->getLL("select_db"),$admin->testDBRefs($admin->checkSelectDBRefs),1,1);
496 $this->content.=$this->doc->section($LANG->getLL("group_db"),$admin->testDBRefs($admin->checkGroupDBRefs),1,1);
497 }
498
499 /**
500 * Searching for files with a specific pattern
501 *
502 * @return [type] ...
503 */
504 function func_filesearch() {
505 global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$CLIENT,$TYPO3_CONF_VARS;
506
507 $this->content.=$this->doc->header($LANG->getLL("relations"));
508 $this->content.=$this->doc->spacer(5);
509 $this->content.=$this->doc->section('',$this->menu);
510
511
512 $pattern = t3lib_div::_GP("pattern");
513 $pcontent='Enter regex pattern: <input type="text" name="pattern" value="'.htmlspecialchars($pattern?$pattern:$GLOBALS["TYPO3_CONF_VARS"]["BE"]["fileDenyPattern"]).'"> <input type="submit" name="Search">';
514 $this->content.=$this->doc->section('Pattern',$pcontent,0,1);
515
516 if (strcmp($pattern,"")) {
517 $dirs = t3lib_div::get_dirs(PATH_site);
518 # debug($dirs);
519 $lines=array();
520 $depth=10;
521
522 foreach ($dirs as $key => $value) {
523 $matching_files=array();
524 $info="";
525 if (!t3lib_div::inList("typo3,typo3conf,tslib,media,t3lib",$value)) {
526 $info = $this->findFile(PATH_site.$value."/",$pattern,$matching_files,$depth);
527 }
528 if (is_array($info)) {
529 $lines[]='<hr><b>'.$value.'/</b> being checked...';
530 $lines[]='Dirs: '.$info[0];
531 if ($info[2]) $lines[]='<span class="typo3-red">ERROR: Directories deeper than '.$depth.' levels</span>';
532 $lines[]='Files: '.$info[1];
533 $lines[]='Matching files:<br><nobr><span class="typo3-red">'.implode("<br>",$matching_files).'</span></nobr>';
534 } else {
535 $lines[]=$GLOBALS["TBE_TEMPLATE"]->dfw('<hr><b>'.$value.'/</b> not checked.');
536 }
537 }
538
539 $this->content.=$this->doc->section('Searching for filenames:',implode("<BR>",$lines),0,1);
540 }
541 }
542
543 /**
544 * Searching for filename pattern recursively in the specified dir.
545 *
546 * @param [type] $basedir: ...
547 * @param [type] $pattern: ...
548 * @param [type] $matching_files: ...
549 * @param [type] $depth: ...
550 * @return [type] ...
551 */
552 function findFile($basedir,$pattern,&$matching_files,$depth) {
553 $files_searched=0;
554 $dirs_searched=0;
555 $dirs_error=0;
556
557 // Traverse files:
558 $files = t3lib_div::getFilesInDir($basedir,"",1);
559 if (is_array($files)) {
560 $files_searched+=count($files);
561 foreach ($files as $value) {
562 if (eregi($pattern,basename($value))) $matching_files[]=substr($value,strlen(PATH_site));
563 }
564 }
565
566
567 // Traverse subdirs
568 if ($depth>0) {
569 $dirs = t3lib_div::get_dirs($basedir);
570 if (is_array($dirs)) {
571 $dirs_searched+=count($dirs);
572
573 foreach ($dirs as $value) {
574 $inf= $this->findFile($basedir.$value."/",$pattern,$matching_files,$depth-1);
575 $dirs_searched+=$inf[0];
576 $files_searched+=$inf[1];
577 $dirs_error=$inf[2];
578 }
579 }
580 } else {
581 $dirs = t3lib_div::get_dirs($basedir);
582 if (is_array($dirs) && count($dirs)) {
583 $dirs_error=1; // Means error - there were further subdirs!
584 }
585 }
586
587 return array($dirs_searched,$files_searched,$dirs_error);
588 }
589
590 /**
591 * Menu
592 *
593 * @return [type] ...
594 */
595 function func_default() {
596 global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$CLIENT,$TYPO3_CONF_VARS;
597
598 $this->content.=$this->doc->header($LANG->getLL("title"));
599 $this->content.=$this->doc->spacer(5);
600 $this->content.=$this->doc->section('',$this->menu);
601 $this->content.=$this->doc->section('<A HREF="index.php?SET[function]=records">'.$LANG->getLL("records").'</a>',$LANG->getLL("records_description"),1,1,0,1);
602 $this->content.=$this->doc->section('<A HREF="index.php?SET[function]=tree">'.$LANG->getLL("tree").'</a>',$LANG->getLL("tree_description"),1,1,0,1);
603 $this->content.=$this->doc->section('<A HREF="index.php?SET[function]=relations">'.$LANG->getLL("relations").'</a>',$LANG->getLL("relations_description"),1,1,0,1);
604 $this->content.=$this->doc->section('<A HREF="index.php?SET[function]=search">'.$LANG->getLL("search").'</a>',$LANG->getLL("search_description"),1,1,0,1);
605 $this->content.=$this->doc->section('<A HREF="index.php?SET[function]=filesearch">'.$LANG->getLL("filesearch").'</a>',$LANG->getLL("filesearch_description"),1,1,0,1);
606 $this->content.=$this->doc->spacer(50);
607 }
608 }
609
610 // Include extension?
611 if (defined("TYPO3_MODE") && $TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["ext/lowlevel/dbint/index.php"]) {
612 include_once($TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["ext/lowlevel/dbint/index.php"]);
613 }
614
615
616
617
618
619
620
621
622
623 // Make instance:
624 $SOBE = t3lib_div::makeInstance("SC_mod_tools_dbint_index");
625 $SOBE->init();
626 $SOBE->main();
627 $SOBE->printContent();
628 ?>