Documentation TYPO3 par Ameos |
00001 <?php 00002 /*************************************************************** 00003 * Copyright notice 00004 * 00005 * (c) 1999-2005 Kasper Skaarhoj (kasperYYYY@typo3.com) 00006 * All rights reserved 00007 * 00008 * This script is part of the TYPO3 project. The TYPO3 project is 00009 * free software; you can redistribute it and/or modify 00010 * it under the terms of the GNU General Public License as published by 00011 * the Free Software Foundation; either version 2 of the License, or 00012 * (at your option) any later version. 00013 * 00014 * The GNU General Public License can be found at 00015 * http://www.gnu.org/copyleft/gpl.html. 00016 * A copy is found in the textfile GPL.txt and important notices to the license 00017 * from the author is found in LICENSE.txt distributed with these scripts. 00018 * 00019 * 00020 * This script is distributed in the hope that it will be useful, 00021 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00022 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00023 * GNU General Public License for more details. 00024 * 00025 * This copyright notice MUST APPEAR in all copies of the script! 00026 ***************************************************************/ 00060 require_once(PATH_t3lib.'class.t3lib_admin.php'); 00061 00062 00063 00071 class tx_lowlevel_cleaner_core { 00072 00073 var $label_infoString = 'The list of records is organized as [table]:[uid]:[field]:[flexpointer]:[softref_key]'; 00074 00075 00076 00077 00078 00079 00080 00081 00082 00083 /************************** 00084 * 00085 * Analyse functions 00086 * 00087 *************************/ 00088 00094 function missing_files_analyze() { 00095 global $TYPO3_DB; 00096 00097 $listExplain = ' Shows the relative filename of missing file as header and under a list of record fields in which the references are found. '.$this->label_infoString; 00098 00099 // Initialize result array: 00100 $resultArray = array( 00101 'message' => ' 00102 Objective: Find all file references from non-deleted records pointing to a missing (non-existing) file. 00103 00104 Assumptions: 00105 - a perfect integrity of the reference index table (always update the reference index table before using this tool!) 00106 - relevant soft reference parsers applied everywhere file references are used inline 00107 00108 Files may be missing for these reasons (except software bugs): 00109 - someone manually deleted the file inside fileadmin/ or another user maintained folder. If the reference was a soft reference (opposite to a TCEmain managed file relation from "group" type fields), technically it is not an error although it might be a mistake that someone did so. 00110 - someone manually deleted the file inside the uploads/ folder (typically containing managed files) which is an error since no user interaction should take place there. 00111 00112 NOTICE: Uses the Reference Index Table (sys_refindex) for analysis. Update it before use!', 00113 'headers' => array( 00114 'managedFilesMissing' => array('List of missing files managed by TCEmain', $listExplain, 3), 00115 'softrefFilesMissing' => array('List of missing files registered as a soft reference', $listExplain, 3), 00116 'warnings' => array('Warnings, if any','',2) 00117 ), 00118 'managedFilesMissing' => array(), 00119 'softrefFilesMissing' => array(), 00120 'warnings' => array() 00121 ); 00122 00123 // Select all files in the reference table 00124 $recs = $TYPO3_DB->exec_SELECTgetRows( 00125 '*', 00126 'sys_refindex', 00127 'ref_table='.$TYPO3_DB->fullQuoteStr('_FILE', 'sys_refindex'). 00128 ' AND deleted=0' // Check only for records which are not deleted (we don't care about missing files in deleted-flagged records) 00129 ); 00130 00131 // Traverse the files and put into a large table: 00132 if (is_array($recs)) { 00133 foreach($recs as $rec) { 00134 00135 // Compile info string for location of reference: 00136 $infoString = $rec['tablename'].':'.$rec['recuid'].':'.$rec['field'].':'.$rec['flexpointer'].':'.$rec['softref_key']; 00137 00138 // Handle missing file: 00139 if (!@is_file(PATH_site.$rec['ref_string'])) { 00140 00141 if ((string)$rec['softref_key']=='') { 00142 $resultArrayIndex = 'managedFilesMissing'; 00143 } else { 00144 $resultArrayIndex = 'softrefFilesMissing'; 00145 } 00146 00147 $resultArray[$resultArrayIndex][$rec['ref_string']][$rec['hash']] = $infoString; 00148 } 00149 } 00150 } 00151 00152 return $resultArray; 00153 } 00154 00161 function missing_relations_analyze($filter='') { 00162 global $TYPO3_DB; 00163 00164 $listExplain = ' Shows the missing record as header and underneath a list of record fields in which the references are found. '.$this->label_infoString; 00165 00166 // Initialize result array: 00167 $resultArray = array( 00168 'message' => ' 00169 Objective: Find all record references pointing to a missing (non-existing or deleted-flagged) record. 00170 Assumptions: 00171 - a perfect integrity of the reference index table (always update the reference index table before using this tool!) 00172 - all database references to check are integers greater than zero 00173 - does not check if a referenced record is inside an offline branch, another workspace etc. which could make the reference useless in reality or otherwise question integrity 00174 Records may be missing for these reasons (except software bugs): 00175 - someone deleted the record which is technically not an error although it might be a mistake that someone did so. 00176 - after flushing published versions and/or deleted-flagged records a number of new missing references might appear; those were pointing to records just flushed. 00177 NOTICE: Uses the Reference Index Table (sys_refindex) for analysis. Update it before use!', 00178 'headers' => array( 00179 'offlineVersionRecords' => array('Offline version records','These records are offline versions having a pid=-1 and references should never occur directly to their uids.'.$listExplain,3), 00180 'deletedRecords' => array('Deleted-flagged records','These records are deleted with a flag but references are still pointing at them. Keeping the references is useful if you undelete the referenced records later, otherwise the references are lost completely when the deleted records are flushed at some point.'.$listExplain,2), 00181 'nonExistingRecords' => array('Non-existing records to which there are references','These references can safely be removed since there is no record found in the database at all.'.$listExplain,3), // 3 = error 00182 'uniqueReferencesToTables' => array('Unique references to various tables','For each listed table, this shows how many different records had references pointing to them. More references to the same record counts only 1, hence it is the number of unique referenced records you see. The count includes both valid and invalid references.',1), // 1 = info 00183 'warnings' => array('Warnings picked up','',2) // 2 = warning 00184 ), 00185 'offlineVersionRecords' => array(), 00186 'deletedRecords' => array(), 00187 'nonExistingRecords' => array(), 00188 'uniqueReferencesToTables' => array(), 00189 'warnings' => array() 00190 ); 00191 00192 // Create clause to filter by: 00193 $filterClause = ''; 00194 if ($filter==='softref') { 00195 $filterClause = ' AND softref_key!='.$TYPO3_DB->fullQuoteStr('', 'sys_refindex'); 00196 } 00197 if ($filter==='managed') { 00198 $filterClause = ' AND softref_key='.$TYPO3_DB->fullQuoteStr('', 'sys_refindex'); 00199 } 00200 00201 // Select all files in the reference table not found by a soft reference parser (thus TCA configured) 00202 $recs = $TYPO3_DB->exec_SELECTgetRows( 00203 '*', 00204 'sys_refindex', 00205 'ref_table!='.$TYPO3_DB->fullQuoteStr('_FILE', 'sys_refindex'). // Assuming that any other key will be a table name! 00206 ' AND ref_uid>0'. 00207 $filterClause. 00208 ' AND deleted=0' // Check only for records which are not deleted (we don't care about missing relations in deleted-flagged records) 00209 ); 00210 00211 // Traverse the files and put into a large table: 00212 $tempExists = array(); 00213 if (is_array($recs)) { 00214 foreach($recs as $rec) { 00215 $idx = $rec['ref_table'].':'.$rec['ref_uid']; 00216 00217 if (!isset($tempExists[$idx])) { 00218 00219 // Select all files in the reference table not found by a soft reference parser (thus TCA configured) 00220 if (isset($GLOBALS['TCA'][$rec['ref_table']])) { 00221 $recs = $TYPO3_DB->exec_SELECTgetRows( 00222 'uid,pid'.($GLOBALS['TCA'][$rec['ref_table']]['ctrl']['delete'] ? ','.$GLOBALS['TCA'][$rec['ref_table']]['ctrl']['delete'] : ''), 00223 $rec['ref_table'], 00224 'uid='.intval($rec['ref_uid']) 00225 ); 00226 00227 $tempExists[$idx] = count($recs) ? TRUE : FALSE; 00228 } else { 00229 $tempExists[$idx] = FALSE; 00230 } 00231 $resultArray['uniqueReferencesToTables'][$rec['ref_table']]++; 00232 } 00233 00234 // Compile info string for location of reference: 00235 $infoString = $rec['tablename'].':'.$rec['recuid'].':'.$rec['field'].':'.$rec['flexpointer'].':'.$rec['softref_key']; 00236 00237 // Handle missing file: 00238 if ($tempExists[$idx]) { 00239 if ($recs[0]['pid']==-1) { 00240 $resultArray['offlineVersionRecords'][$idx][$rec['hash']] = $infoString; 00241 } elseif ($GLOBALS['TCA'][$rec['ref_table']]['ctrl']['delete'] && $recs[0][$GLOBALS['TCA'][$rec['ref_table']]['ctrl']['delete']]) { 00242 $resultArray['deletedRecords'][$idx][$rec['hash']] = $infoString; 00243 } 00244 } else { 00245 $resultArray['nonExistingRecords'][$idx][$rec['hash']] = $infoString; 00246 } 00247 } 00248 } 00249 00250 return $resultArray; 00251 } 00252 00258 function double_files_analyze() { 00259 global $TYPO3_DB; 00260 00261 // Initialize result array: 00262 $resultArray = array( 00263 'message' => ' 00264 Objective: Looking for files from TYPO3 managed records which are referenced more than one time (only one time allowed) 00265 Assumptions: 00266 - a perfect integrity of the reference index table (always update the reference index table before using this tool!) 00267 - files found in deleted records are included (otherwise you would see a false list of lost files) 00268 ' . 00269 'Files attached to records in TYPO3 using a "group" type configuration in TCA or FlexForm DataStructure are managed exclusively by the system and there must always exist a 1-1 reference between the file and the reference in the record.' . 00270 'This tool will expose when such files are referenced from multiple locations which is considered an integrity error. ' . 00271 'If a multi-reference is found it was typically created because the record was copied or modified outside of TCEmain which will otherwise maintain the relations correctly. ' . 00272 'Multi-references should be resolved to 1-1 references as soon as possible. The danger of keeping multi-references is that if the file is removed from one of the refering records it will actually be deleted in the file system, leaving missing files for the remaining referers! 00273 00274 NOTICE: Uses the Reference Index Table (sys_refindex) for analysis. Update it before use!', 00275 'headers' => array( 00276 'multipleReferencesList_count' => array('Number of multi-reference files','(See below)',1), 00277 'singleReferencesList_count' => array('Number of files correctly referenced','The amount of correct 1-1 references',1), 00278 'multipleReferencesList' => array('Entries with files having multiple references','These are serious problems that should be resolved ASAP to prevent data loss! '.$this->label_infoString,3), 00279 'dirname_registry' => array('Registry of directories in which files are found.','Registry includes which table/field pairs store files in them plus how many files their store.',1), 00280 'missingFiles' => array('Tracking missing files','(Extra feature, not related to tracking of double references. Further, the list may include more files than found in the missing_files()-test because this list includes missing files from deleted records.)',0), 00281 'warnings' => array('Warnings picked up','',2) 00282 ), 00283 'multipleReferencesList_count' => 0, 00284 'singleReferencesList_count' => 0, 00285 'multipleReferencesList' => array(), 00286 'dirname_registry' => array(), 00287 'missingFiles' => array(), 00288 'warnings' => array() 00289 ); 00290 00291 // Select all files in the reference table not found by a soft reference parser (thus TCA configured) 00292 $recs = $TYPO3_DB->exec_SELECTgetRows( 00293 '*', 00294 'sys_refindex', 00295 'ref_table='.$TYPO3_DB->fullQuoteStr('_FILE', 'sys_refindex'). 00296 ' AND softref_key='.$TYPO3_DB->fullQuoteStr('', 'sys_refindex') 00297 ); 00298 00299 // Traverse the files and put into a large table: 00300 $tempCount = array(); 00301 if (is_array($recs)) { 00302 foreach($recs as $rec) { 00303 00304 // Compile info string for location of reference: 00305 $infoString = $rec['tablename'].':'.$rec['recuid'].':'.$rec['field'].':'.$rec['flexpointer'].':'; 00306 00307 // Registering occurencies in directories: 00308 $resultArray['dirname_registry'][dirname($rec['ref_string'])][$rec['tablename'].':'.$rec['field']]++; 00309 00310 // Handle missing file: 00311 if (!@is_file(PATH_site.$rec['ref_string'])) { 00312 $resultArray['missingFiles'][$rec['ref_string']][$rec['hash']] = $infoString; 00313 } 00314 00315 // Add entry if file has multiple references pointing to it: 00316 if (isset($tempCount[$rec['ref_string']])) { 00317 if (!is_array($resultArray['multipleReferencesList'][$rec['ref_string']])) { 00318 $resultArray['multipleReferencesList'][$rec['ref_string']] = array(); 00319 $resultArray['multipleReferencesList'][$rec['ref_string']][$tempCount[$rec['ref_string']][1]] = $tempCount[$rec['ref_string']][0]; 00320 } 00321 $resultArray['multipleReferencesList'][$rec['ref_string']][$rec['hash']] = $infoString; 00322 } else { 00323 $tempCount[$rec['ref_string']] = array($infoString,$rec['hash']); 00324 } 00325 } 00326 } 00327 00328 // Add count for multi-references: 00329 $resultArray['multipleReferencesList_count'] = count($resultArray['multipleReferencesList']); 00330 $resultArray['singleReferencesList_count'] = count($tempCount) - $resultArray['multipleReferencesList_count']; 00331 00332 // Sort dirname registry and add warnings for directories outside uploads/ 00333 ksort($resultArray['dirname_registry']); 00334 foreach($resultArray['dirname_registry'] as $dir => $temp) { 00335 if (!t3lib_div::isFirstPartOfStr($dir,'uploads/')) { 00336 $resultArray['warnings'][] = 'Directory "'.$dir.'" was outside uploads/ which is unusual practice in TYPO3 although not forbidden. Directory used by the following table:field pairs: '.implode(',',array_keys($temp)); 00337 } 00338 } 00339 00340 return $resultArray; 00341 } 00342 00348 function RTEmagic_files_analyze() { 00349 global $TYPO3_DB; 00350 00351 // Initialize result array: 00352 $resultArray = array( 00353 'message' => ' 00354 Objective: Looking up all occurencies of RTEmagic images in the database and check existence of parent and copy files on the file system plus report possibly lost files of this type. 00355 Assumptions: 00356 - a perfect integrity of the reference index table (always update the reference index table before using this tool!) 00357 - that all RTEmagic image files in the database are registered with the soft reference parser "images" 00358 - images found in deleted records are included (means that you might find lost RTEmagic images after flushing deleted records) 00359 The assumptions are not requirements by the TYPO3 API but reflects the de facto implementation of most TYPO3 installations. ' . 00360 'However, many custom fields using an RTE will probably not have the "images" soft reference parser registered and so the index will be incomplete and not listing all RTEmagic image files. ' . 00361 'The consequence of this limitation is that you should be careful if you wish to delete lost RTEmagic images - they could be referenced from a field not parsed by the "images" soft reference parser!' . 00362 'Another limitation: In theory a RTEmagic image should be used from only one record, however TCEmain does not support this (unfortunately!) so when a record is copied or versionized no new version will be produced. This leads to a usage count of more than one for many RTEmagic images which is also shown in the overview. At this point in time its not considered a bug and there is no fix for it. 00363 00364 NOTICE: Uses the Reference Index Table (sys_refindex) for analysis. Update it before use!', 00365 'headers' => array( 00366 'completeFileList' => array('Complete list of used RTEmagic files','Both parent and copy are listed here including usage count (which should in theory all be "1")',1), 00367 'RTEmagicFilePairs' => array('Statistical info about RTEmagic files','(copy used as index)',0), 00368 'missingFiles' => array('Missing RTEmagic image files','Have either their parent or copy missing (look that up in RTEmagicFilePairs)',3), 00369 'lostFiles' => array('Lost RTEmagic files from uploads/','These files you might be able to deleted but only if _all_ RTEmagic images are found by the soft reference parser. If you are using the RTE in third-party extensions it is likely that the soft reference parser is not applied correctly to their RTE and thus these "lost" files actually represent valid RTEmagic images, just not registered.',2), 00370 'warnings' => array('Warnings picked up','',2) 00371 ), 00372 'RTEmagicFilePairs' => array(), 00373 'completeFileList' => array(), 00374 'missingFiles' => array(), 00375 'lostFiles' => array(), 00376 'warnings' => array() 00377 ); 00378 00379 // Select all RTEmagic files in the reference table (only from soft references of course) 00380 $recs = $TYPO3_DB->exec_SELECTgetRows( 00381 '*', 00382 'sys_refindex', 00383 'ref_table='.$TYPO3_DB->fullQuoteStr('_FILE', 'sys_refindex'). 00384 ' AND ref_string LIKE '.$TYPO3_DB->fullQuoteStr('%/RTEmagic%', 'sys_refindex'). 00385 ' AND softref_key='.$TYPO3_DB->fullQuoteStr('images', 'sys_refindex') 00386 ); 00387 00388 // Traverse the files and put into a large table: 00389 if (is_array($recs)) { 00390 foreach($recs as $rec) { 00391 $filename = basename($rec['ref_string']); 00392 if (t3lib_div::isFirstPartOfStr($filename,'RTEmagicC_')) { 00393 $original = 'RTEmagicP_'.ereg_replace('\.[[:alnum:]]+$','',substr($filename,10)); 00394 $infoString = $rec['tablename'].':'.$rec['recuid'].':'.$rec['field'].':'.$rec['flexpointer'].':'.$rec['softref_key']; 00395 00396 // Build index: 00397 $resultArray['RTEmagicFilePairs'][$rec['ref_string']]['exists'] = @is_file(PATH_site.$rec['ref_string']); 00398 $resultArray['RTEmagicFilePairs'][$rec['ref_string']]['original'] = substr($rec['ref_string'],0,-strlen($filename)).$original; 00399 $resultArray['RTEmagicFilePairs'][$rec['ref_string']]['original_exists'] = @is_file(PATH_site.$resultArray['RTEmagicFilePairs'][$rec['ref_string']]['original']); 00400 $resultArray['RTEmagicFilePairs'][$rec['ref_string']]['count']++; 00401 $resultArray['RTEmagicFilePairs'][$rec['ref_string']]['usedIn'][$rec['hash']] = $infoString; 00402 00403 $resultArray['completeFileList'][$resultArray['RTEmagicFilePairs'][$rec['ref_string']]['original']]++; 00404 $resultArray['completeFileList'][$rec['ref_string']]++; 00405 00406 // Missing files: 00407 if (!$resultArray['RTEmagicFilePairs'][$rec['ref_string']]['exists'] || !$resultArray['RTEmagicFilePairs'][$rec['ref_string']]['original_exists']) { 00408 $resultArray['missingFiles'][$rec['ref_string']] = $rec['ref_string']; 00409 } 00410 } 00411 } 00412 } 00413 00414 // Now, ask for RTEmagic files inside uploads/ folder: 00415 $resLostFiles = $this->clean_lost_files_analyze(); 00416 00417 if (is_array($resLostFiles['RTEmagicFiles'])) { 00418 foreach($resLostFiles['RTEmagicFiles'] as $fileName) { 00419 if (!isset($resultArray['completeFileList'][$fileName])) { 00420 $resultArray['lostFiles'][] = $fileName; 00421 } 00422 } 00423 } 00424 00425 return $resultArray; 00426 } 00427 00437 function clean_lost_files_analyze() { 00438 global $TYPO3_DB; 00439 00440 // Initialize result array: 00441 $resultArray = array( 00442 'message' => ' 00443 Objective: Looking for files in the uploads/ folder which does not have a reference in TYPO3 managed records. 00444 Assumptions: 00445 - a perfect integrity of the reference index table (always update the reference index table before using this tool!) 00446 - that all contents in the uploads folder are files attached to TCA records and exclusively managed by TCEmain through "group" type fields 00447 - exceptions are: index.html and .htaccess files (ignored) 00448 - exceptions are: RTEmagic* image files (ignored) 00449 - files found in deleted records are included (otherwise you would see a false list of lost files) 00450 The assumptions are not requirements by the TYPO3 API but reflects the de facto implementation of most TYPO3 installations and therefore a practical approach to cleaning up the uploads/ folder. ' . 00451 'Therefore, if all "group" type fields in TCA and flexforms are positioned inside the uploads/ folder and if no files inside are managed manually it should be safe to clean out files with no relations found in the system. ' . 00452 'Under such circumstances there should theoretically be no lost files in the uploads/ folder since TCEmain should have managed relations automatically including adding and deleting files. ' . 00453 'However, there is at least one reason known to why files might be found lost and that is when FlexForms are used. In such a case a change in the data structure used for the flexform could leave lost files behind. ' . 00454 'Another scenario could of course be de-installation of extensions which managed files in the uploads/ folders. 00455 00456 NOTICE: Uses the Reference Index Table (sys_refindex) for analysis. Update it before use!', 00457 'headers' => array( 00458 'managedFiles' => array('Files related to TYPO3 records and managed by TCEmain','These files you definitely want to keep.',0), 00459 'ignoredFiles' => array('Ignored files (index.html, .htaccess etc.)','These files are allowed in uploads/ folder',0), 00460 'RTEmagicFiles' => array('RTE magic images - those found (and ignored)','These files are also allowed in some uploads/ folders as RTEmagic images.',0), 00461 'lostFiles' => array('Lost files - those you can delete','You can delete these files!',3), 00462 'warnings' => array('Warnings picked up','',2) 00463 ), 00464 'managedFiles' => array(), 00465 'ignoredFiles' => array(), 00466 'RTEmagicFiles' => array(), 00467 'lostFiles' => array(), 00468 'warnings' => array() 00469 ); 00470 00471 // Get all files: 00472 $fileArr = array(); 00473 $fileArr = t3lib_div::getAllFilesAndFoldersInPath($fileArr,PATH_site.'uploads/'); 00474 $fileArr = t3lib_div::removePrefixPathFromList($fileArr,PATH_site); 00475 00476 // Traverse files and for each, look up if its found in the reference index. 00477 foreach($fileArr as $key => $value) { 00478 00479 // First, allow "index.html", ".htaccess" files since they are often used for good reasons 00480 if (substr($value,-11) == '/index.html' || substr($value,-10) == '/.htaccess') { 00481 unset($fileArr[$key]) ; 00482 $resultArray['ignoredFiles'][] = $value; 00483 } else { 00484 // Looking for a reference from a field which is NOT a soft reference (thus, only fields with a proper TCA/Flexform configuration) 00485 $recs = $TYPO3_DB->exec_SELECTgetRows( 00486 '*', 00487 'sys_refindex', 00488 'ref_table='.$TYPO3_DB->fullQuoteStr('_FILE', 'sys_refindex'). 00489 ' AND ref_string='.$TYPO3_DB->fullQuoteStr($value, 'sys_refindex'). 00490 ' AND softref_key='.$TYPO3_DB->fullQuoteStr('', 'sys_refindex') 00491 ); 00492 00493 // If found, unset entry: 00494 if (count($recs)) { 00495 unset($fileArr[$key]) ; 00496 $resultArray['managedFiles'][] = $value; 00497 if (count($recs)>1) { 00498 $resultArray['warnings'][]='Warning: File "'.$value.'" had '.count($recs).' references from group-fields, should have only one!'; 00499 } 00500 } else { 00501 // When here it means the file was not found. So we test if it has a RTEmagic-image name and if so, we allow it: 00502 if (ereg('^RTEmagic[P|C]_',basename($value))) { 00503 unset($fileArr[$key]) ; 00504 $resultArray['RTEmagicFiles'][] = $value; 00505 } else { 00506 // We conclude that the file is lost...: 00507 unset($fileArr[$key]) ; 00508 $resultArray['lostFiles'][] = $value; 00509 } 00510 } 00511 } 00512 } 00513 00514 // $fileArr variable should now be empty with all contents transferred to the result array keys. 00515 00516 return $resultArray; 00517 } 00518 00525 function orphan_records_analyze() { 00526 global $TYPO3_DB; 00527 00528 $adminObj = t3lib_div::makeInstance('t3lib_admin'); 00529 00530 $adminObj->genTree_includeDeleted = TRUE; // if set, genTree() includes deleted pages. This is default. 00531 $adminObj->genTree_includeVersions = TRUE; // if set, genTree() includes verisonized pages/records. This is default. 00532 $adminObj->genTree_includeRecords = TRUE; // if set, genTree() includes records from pages. 00533 $adminObj->perms_clause = ''; // extra where-clauses for the tree-selection 00534 $adminObj->genTree_makeHTML = 0; // if set, genTree() generates HTML, that visualizes the tree. 00535 00536 $pt = t3lib_div::milliseconds(); 00537 $adminObj->genTree(1,''); 00538 00539 print_r($adminObj->recStats); 00540 echo strlen(serialize($adminObj->recStats)).chr(10); 00541 echo (t3lib_div::milliseconds()-$pt).' milliseconds'; 00542 exit; 00543 00544 return $resultArray; 00545 } 00546 00547 00548 00549 00550 00551 00552 00553 00554 00555 00556 00557 /************************** 00558 * 00559 * Helper functions 00560 * 00561 *************************/ 00562 00572 function html_printInfo($header,$res,$silent=FALSE,$detailLevel=0) { 00573 00574 if (!$silent) { 00575 // Name: 00576 $output.= '<h3>'.htmlspecialchars($header).'</h3>'; 00577 00578 // Message: 00579 $output.= nl2br(htmlspecialchars(trim($res['message']))).'<hr/>'; 00580 } 00581 00582 // Traverse headers for output: 00583 if (is_array($res['headers'])) { 00584 foreach($res['headers'] as $key => $value) { 00585 00586 if ($detailLevel <= intval($value[2])) { 00587 if (!$silent || (is_array($res[$key]) && count($res[$key]))) { 00588 // Header and explanaion: 00589 $output.= '<b>'. 00590 ($silent ? '<i>'.htmlspecialchars($header).'</i><br/>' : ''). 00591 (is_array($res[$key]) && count($res[$key]) ? $GLOBALS['SOBE']->doc->icons($value[2]) : ''). 00592 htmlspecialchars($value[0]). 00593 '</b><br/>'; 00594 if (trim($value[1])) { 00595 $output.= '<em>'.htmlspecialchars(trim($value[1])).'</em><br/>'; 00596 } 00597 $output.='<br/>'; 00598 } 00599 00600 // Content: 00601 if (is_array($res[$key])) { 00602 if (count($res[$key])) { 00603 $output.= t3lib_div::view_array($res[$key]).'<br/><br/>'; 00604 } else { 00605 if (!$silent) $output.= '(None)'.'<br/><br/>'; 00606 } 00607 } else { 00608 if (!$silent) $output.= htmlspecialchars($res[$key]).'<br/><br/>'; 00609 } 00610 } 00611 } 00612 } 00613 00614 return $output; 00615 } 00616 00617 00618 00619 00620 00621 00622 00623 00624 00625 00626 00627 00628 00629 00630 /************************** 00631 * 00632 * CLI functionality 00633 * 00634 *************************/ 00635 00642 function cli_main($argv) { 00643 00644 if (in_array('-h',$argv)) { 00645 echo " 00646 Options: 00647 -h = This help screen. 00648 "; 00649 exit; 00650 } 00651 00652 00653 # $silentFlag = TRUE; 00654 $filter = 1; 00655 00656 // Missing files: 00657 # $res = $this->missing_files_analyze(); 00658 # $this->cli_printInfo('missing_files_analyze()', $res, $silentFlag, $filter); 00659 00660 // Missing relations: 00661 # $res = $this->missing_relations_analyze(); 00662 # $this->cli_printInfo('missing_relations_analyze()', $res, $silentFlag, $filter); 00663 00664 // Double references 00665 # $res = $this->double_files_analyze(); 00666 # $this->cli_printInfo('double_files_analyze()', $res, $silentFlag, $filter); 00667 00668 // RTE images 00669 # $res = $this->RTEmagic_files_analyze(); 00670 # $this->cli_printInfo('RTEmagic_files_analyze()', $res, $silentFlag, $filter); 00671 00672 // Lost files: 00673 # $res = $this->clean_lost_files_analyze(); 00674 # $this->cli_printInfo('clean_lost_files_analyze()', $res, $silentFlag, $filter); 00675 00676 $res = $this->orphan_records_analyze(); 00677 $this->cli_printInfo('orphan_records_analyze()', $res, $silentFlag, $filter); 00678 00679 # ob_start(); 00680 # $output.= ob_get_contents().chr(10); 00681 # ob_end_clean(); 00682 } 00683 00693 function cli_printInfo($header,$res,$silent=FALSE,$detailLevel=0) { 00694 00695 if (!$silent) { 00696 // Name: 00697 echo chr(10).'*********************************************'.chr(10).$header.chr(10).'*********************************************'.chr(10); 00698 00699 // Message: 00700 echo trim($res['message']).chr(10).chr(10); 00701 } 00702 00703 // Traverse headers for output: 00704 if (is_array($res['headers'])) { 00705 foreach($res['headers'] as $key => $value) { 00706 00707 if ($detailLevel <= intval($value[2])) { 00708 if (!$silent || (is_array($res[$key]) && count($res[$key]))) { 00709 // Header and explanaion: 00710 echo '---------------------------------------------'.chr(10). 00711 ($silent ? '['.$header.']'.chr(10) : ''). 00712 $value[0].' ['.$value[2].']'.chr(10). 00713 '---------------------------------------------'.chr(10); 00714 if (trim($value[1])) { 00715 echo '[Explanation: '.trim($value[1]).']'.chr(10); 00716 } 00717 } 00718 00719 // Content: 00720 if (is_array($res[$key])) { 00721 if (count($res[$key])) { 00722 print_r($res[$key]); 00723 } else { 00724 if (!$silent) echo '(None)'.chr(10).chr(10); 00725 } 00726 } else { 00727 if (!$silent) echo $res[$key].chr(10).chr(10); 00728 } 00729 } 00730 } 00731 } 00732 } 00733 } 00734 00735 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/lowlevel/class.tx_lowlevel_cleaner.php']) { 00736 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/lowlevel/class.tx_lowlevel_cleaner.php']); 00737 } 00738 ?>