00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065 unset($MCONF);
00066 require('conf.php');
00067 require($BACK_PATH . 'init.php');
00068 require($BACK_PATH . 'template.php');
00069 $BE_USER->modAccess($MCONF, 1);
00070
00071 t3lib_extMgm::isLoaded('indexed_search', 1);
00072 require_once(t3lib_extMgm::extPath('indexed_search') . 'class.indexer.php');
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083 class SC_mod_tools_isearch_index {
00084 var $MCONF = array();
00085 var $MOD_MENU = array();
00086 var $MOD_SETTINGS = array();
00087
00088
00089
00090
00091
00092
00093 var $doc;
00094
00095 var $include_once = array();
00096 var $content;
00097
00098
00099
00100
00101
00102
00103
00104 function init() {
00105 $this->MCONF = $GLOBALS['MCONF'];
00106
00107 $this->menuConfig();
00108 $this->doc = t3lib_div::makeInstance('template');
00109 $this->doc->form = '<form action="" method="post">';
00110 $this->doc->backPath = $GLOBALS['BACK_PATH'];
00111 $this->doc->setModuleTemplate(t3lib_extMgm::extRelPath('indexed_search') . '/mod/mod_template.html');
00112
00113
00114 $this->doc->JScodeArray['indexed_search'] = '
00115 script_ended = 0;
00116 function jumpToUrl(URL) {
00117 window.location.href = URL;
00118 }';
00119
00120 $this->doc->tableLayout = array(
00121 'defRow' => array(
00122 '0' => array('<td valign="top" nowrap>','</td>'),
00123 'defCol' => array('<td><img src="' . $this->doc->backPath . 'clear.gif" width=10 height=1></td><td valign="top" nowrap>','</td>')
00124 )
00125 );
00126
00127 $indexer = t3lib_div::makeInstance('tx_indexedsearch_indexer');
00128 $indexer->initializeExternalParsers();
00129 }
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139 function menuConfig() {
00140 $this->MOD_MENU = array(
00141 'function' => array(
00142 'stat' => 'General statistics',
00143 'typo3pages' => 'List: TYPO3 Pages',
00144 'externalDocs' => 'List: External documents',
00145 )
00146 );
00147
00148
00149 $this->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU, t3lib_div::_GP('SET'), $this->MCONF['name'], 'ses');
00150 }
00151
00152
00153
00154
00155
00156
00157 function main() {
00158 $this->content = $this->doc->header('Indexing Engine Statistics');
00159 $this->content .= $this->doc->spacer(5);
00160
00161 switch($this->MOD_SETTINGS['function']) {
00162 case 'stat':
00163 $this->content .= $this->doc->section('Records', $this->doc->table($this->getRecordsNumbers()), 0, 1);
00164 $this->content .= $this->doc->spacer(15);
00165 $this->content .= $this->doc->section('index_phash TYPES', $this->doc->table($this->getPhashTypes()), 1);
00166 $this->content .= $this->doc->spacer(15);
00167 break;
00168 case 'externalDocs':
00169 $this->content .= $this->doc->section('External documents', $this->doc->table($this->getPhashExternalDocs()), 0, 1);
00170 $this->content .= $this->doc->spacer(15);
00171 break;
00172 case 'typo3pages':
00173 $this->content .= $this->doc->section('TYPO3 Pages', $this->doc->table($this->getPhashT3pages()), 0, 1);
00174 $this->content .= $this->doc->spacer(15);
00175 break;
00176 }
00177
00178 $docHeaderButtons = $this->getButtons();
00179 $markers = array(
00180 'CSH' => $docHeaderButtons['csh'],
00181 'FUNC_MENU' => t3lib_BEfunc::getFuncMenu(0, 'SET[function]', $this->MOD_SETTINGS['function'], $this->MOD_MENU['function']),
00182 'CONTENT' => $this->content
00183 );
00184
00185 $this->content = $this->doc->startPage('Indexing Engine Statistics');
00186 $this->content .= $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
00187 $this->content .= $this->doc->endPage();
00188 $this->content = $this->doc->insertStylesAndJS($this->content);
00189 }
00190
00191
00192
00193
00194
00195
00196 function printContent() {
00197 echo $this->content;
00198 }
00199
00200
00201
00202
00203
00204
00205 protected function getButtons() {
00206 $buttons = array(
00207 'csh' => '',
00208 'shortcut' => ''
00209 );
00210
00211
00212 if ($GLOBALS['BE_USER']->mayMakeShortcut()) {
00213 $buttons['shortcut'] = $this->doc->makeShortcutIcon('','function',$this->MCONF['name']);
00214 }
00215 return $buttons;
00216 }
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234 function getRecordsNumbers() {
00235 $tables=explode(",","index_phash,index_words,index_rel,index_grlist,index_section,index_fulltext");
00236 $recList=array();
00237 reset($tables);
00238 while(list(,$t)=each($tables)) {
00239 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', $t, '');
00240 $row = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
00241 $recList[] = array($this->tableHead($t), $row[0]);
00242 }
00243 return $recList;
00244 }
00245
00246
00247
00248
00249
00250
00251
00252 function tableHead($str) {
00253 return "<strong>".$str.": </strong>";
00254 }
00255
00256
00257
00258
00259
00260
00261 function getPhashStat() {
00262 $recList = array();
00263
00264
00265 $items = array();
00266 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*),phash', 'index_phash', 'data_page_id!=0', 'phash_grouping,pcount,phash');
00267 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_row($res)) {
00268 $items[] = $row;
00269 }
00270 $recList[] = array($this->tableHead("TYPO3 pages"), count($items));
00271
00272
00273 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', 'index_phash', 'data_page_id!=0');
00274 $row = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
00275 $recList[] = array($this->tableHead("TYPO3 pages, raw"), $row[0]);
00276
00277
00278 $items = array();
00279 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*),phash', 'index_phash', 'data_filename!=\'\'', 'phash_grouping');
00280 $row = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
00281 $recList[] = array($this->tableHead("External files"), $row[0]);
00282
00283
00284 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', 'index_phash', 'data_filename!=\'\'');
00285 $row = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
00286 $recList[] = array($this->tableHead("External files, raw"), $row[0]);
00287
00288 return $recList;
00289 }
00290
00291
00292
00293
00294
00295
00296 function getPhashT3pages() {
00297 $recList[]=array(
00298 $this->tableHead("id/type"),
00299 $this->tableHead("Title"),
00300 $this->tableHead("Size"),
00301 $this->tableHead("Words"),
00302 $this->tableHead("mtime"),
00303 $this->tableHead("Indexed"),
00304 $this->tableHead("Updated"),
00305 $this->tableHead("Parsetime"),
00306 $this->tableHead("#sec/gr/full"),
00307 $this->tableHead("#sub"),
00308 $this->tableHead("Lang"),
00309 $this->tableHead("cHash"),
00310 $this->tableHead("phash")
00311 );
00312
00313
00314 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*) AS pcount,index_phash.*', 'index_phash', 'data_page_id!=0', 'phash_grouping,phash,cHashParams,data_filename,data_page_id,data_page_reg1,data_page_type,data_page_mp,gr_list,item_type,item_title,item_description,item_mtime,tstamp,item_size,contentHash,crdate,parsetime,sys_language_uid,item_crdate,externalUrl,recordUid,freeIndexUid,freeIndexSetId', 'data_page_id');
00315 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
00316
00317 $cHash = count(unserialize($row["cHashParams"])) ? $this->formatCHash(unserialize($row["cHashParams"])) : "";
00318 $grListRec = $this->getGrlistRecord($row["phash"]);
00319 $recList[] = array(
00320 $row["data_page_id"].($row["data_page_type"]?"/".$row["data_page_type"]:""),
00321 t3lib_div::fixed_lgd($row["item_title"],30),
00322 t3lib_div::formatSize($row["item_size"]),
00323 $this->getNumberOfWords($row["phash"]),
00324 t3lib_BEfunc::datetime($row["item_mtime"]),
00325 t3lib_BEfunc::datetime($row["crdate"]),
00326 ($row["tstamp"]!=$row["crdate"] ? t3lib_BEfunc::datetime($row["tstamp"]) : ""),
00327 $row["parsetime"],
00328 $this->getNumberOfSections($row["phash"])."/".$grListRec[0]["pcount"]."/".$this->getNumberOfFulltext($row["phash"]),
00329 $row["pcount"]."/".$this->formatFeGroup($grListRec),
00330 $row["sys_language_uid"],
00331 $cHash,
00332 $row["phash"]
00333 );
00334
00335 if ($row["pcount"]>1) {
00336 $res2 = $GLOBALS['TYPO3_DB']->exec_SELECTquery('index_phash.*', 'index_phash', 'phash_grouping='.intval($row['phash_grouping']).' AND phash!='.intval($row['phash']));
00337 while($row2 = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res2)) {
00338 $grListRec = $this->getGrlistRecord($row2["phash"]);
00339 $recList[] = array(
00340 "",
00341 "",
00342 t3lib_div::formatSize($row2["item_size"]),
00343 $this->getNumberOfWords($row2["phash"]),
00344 t3lib_BEfunc::datetime($row2["item_mtime"]),
00345 t3lib_BEfunc::datetime($row2["crdate"]),
00346 ($row2["tstamp"]!=$row2["crdate"] ? t3lib_BEfunc::datetime($row2["tstamp"]) : ""),
00347 $row2["parsetime"],
00348 $this->getNumberOfSections($row2["phash"])."/".$grListRec[0]["pcount"]."/".$this->getNumberOfFulltext($row2["phash"]),
00349 "-/".$this->formatFeGroup($grListRec),
00350 "",
00351 "",
00352 $row2["phash"]
00353 );
00354 }
00355 }
00356 }
00357 return $recList;
00358 }
00359
00360
00361
00362
00363
00364
00365 function getPhashExternalDocs() {
00366 $recList[]=array(
00367 $this->tableHead("Filename"),
00368 $this->tableHead("Size"),
00369 $this->tableHead("Words"),
00370 $this->tableHead("mtime"),
00371 $this->tableHead("Indexed"),
00372 $this->tableHead("Updated"),
00373 $this->tableHead("Parsetime"),
00374 $this->tableHead("#sec/gr/full"),
00375 $this->tableHead("#sub"),
00376 $this->tableHead("cHash"),
00377 $this->tableHead("phash"),
00378 $this->tableHead("Path")
00379 );
00380
00381
00382 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*) AS pcount,index_phash.*', 'index_phash', 'item_type!=\'0\'', 'phash_grouping,phash,cHashParams,data_filename,data_page_id,data_page_reg1,data_page_type,data_page_mp,gr_list,item_type,item_title,item_description,item_mtime,tstamp,item_size,contentHash,crdate,parsetime,sys_language_uid,item_crdate,externalUrl,recordUid,freeIndexUid,freeIndexSetId', 'item_type');
00383 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
00384
00385 $cHash = count(unserialize($row["cHashParams"])) ? $this->formatCHash(unserialize($row["cHashParams"])) : "";
00386 $grListRec = $this->getGrlistRecord($row["phash"]);
00387 $recList[]=array(
00388 t3lib_div::fixed_lgd($row["item_title"],30),
00389 t3lib_div::formatSize($row["item_size"]),
00390 $this->getNumberOfWords($row["phash"]),
00391 t3lib_BEfunc::datetime($row["item_mtime"]),
00392 t3lib_BEfunc::datetime($row["crdate"]),
00393 ($row["tstamp"]!=$row["crdate"] ? t3lib_BEfunc::datetime($row["tstamp"]) : ""),
00394 $row["parsetime"],
00395 $this->getNumberOfSections($row["phash"])."/".$grListRec[0]["pcount"]."/".$this->getNumberOfFulltext($row["phash"]),
00396 $row["pcount"],
00397 $cHash,
00398 $row["phash"],
00399 t3lib_div::fixed_lgd($row["data_filename"],100)
00400 );
00401
00402 if ($row["pcount"]>1) {
00403 $res2 = $GLOBALS['TYPO3_DB']->exec_SELECTquery('index_phash.*', 'index_phash', 'phash_grouping='.intval($row['phash_grouping']).' AND phash!='.intval($row['phash']));
00404 while($row2 = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res2)) {
00405 $cHash = count(unserialize($row2["cHashParams"])) ? $this->formatCHash(unserialize($row2["cHashParams"])) : "";
00406 $grListRec = $this->getGrlistRecord($row2["phash"]);
00407 $recList[]=array(
00408 "",
00409 "",
00410 $this->getNumberOfWords($row2["phash"]),
00411 "",
00412 t3lib_BEfunc::datetime($row2["crdate"]),
00413 ($row2["tstamp"]!=$row2["crdate"] ? t3lib_BEfunc::datetime($row2["tstamp"]) : ""),
00414 $row2["parsetime"],
00415 $this->getNumberOfSections($row2["phash"])."/".$grListRec[0]["pcount"]."/".$this->getNumberOfFulltext($row2["phash"]),
00416 "",
00417 $cHash,
00418 $row2["phash"],
00419 ""
00420 );
00421 }
00422 }
00423
00424 }
00425 return $recList;
00426 }
00427
00428
00429
00430
00431
00432
00433
00434 function formatFeGroup($fegroup_recs) {
00435 reset($fegroup_recs);
00436 $str = array();
00437 while(list(,$row)=each($fegroup_recs)) {
00438 $str[] = $row["gr_list"]=="0,-1" ? "NL" : $row["gr_list"];
00439 }
00440 arsort($str);
00441 return implode("|",$str);
00442 }
00443
00444
00445
00446
00447
00448
00449
00450 function formatCHash($arr) {
00451 reset($arr);
00452 $list=array();
00453 while(list($k,$v)=each($arr)) {
00454 $list[]=$k."=".$v;
00455 }
00456 return implode("<BR>",$list);
00457 }
00458
00459
00460
00461
00462
00463
00464
00465 function getNumberOfSections($phash) {
00466 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', 'index_section', 'phash='.intval($phash));
00467 $row = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
00468 return $row[0];
00469 }
00470
00471
00472
00473
00474
00475
00476
00477 function getNumberOfWords($phash) {
00478 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', 'index_rel', 'phash='.intval($phash));
00479 $row = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
00480 return $row[0];
00481 }
00482
00483
00484
00485
00486
00487
00488
00489 function getGrlistRecord($phash) {
00490 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('index_grlist.*', 'index_grlist', 'phash='.intval($phash));
00491 $allRows = array();
00492 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
00493 $row["pcount"] = $GLOBALS['TYPO3_DB']->sql_num_rows($res);
00494 $allRows[] = $row;
00495 }
00496 return $allRows;
00497 }
00498
00499
00500
00501
00502
00503
00504
00505 function getNumberOfFulltext($phash) {
00506 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', 'index_fulltext', 'phash='.intval($phash));
00507 $row = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
00508 return $row[0];
00509 }
00510
00511
00512
00513
00514
00515
00516 function getPhashTypes() {
00517 $recList=array();
00518
00519
00520 $Itypes = array(
00521 "html" => 1,
00522 "htm" => 1,
00523 "pdf" => 2,
00524 "doc" => 3,
00525 "txt" => 4
00526 );
00527
00528 $revTypes=array_flip($Itypes);
00529 $revTypes[0]="TYPO3 page";
00530
00531 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*),item_type', 'index_phash', '', 'item_type', 'item_type');
00532 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_row($res)) {
00533 $iT = $row[1];
00534 $recList[] = array($this->tableHead($revTypes[$iT]." ($iT)"), $this->countUniqueTypes($iT)."/".$row[0]);
00535 }
00536
00537 return $recList;
00538 }
00539
00540
00541
00542
00543
00544
00545
00546 function countUniqueTypes($item_type) {
00547
00548 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', 'index_phash', 'item_type='.$GLOBALS['TYPO3_DB']->fullQuoteStr($item_type, 'index_phash'), 'phash_grouping');
00549 $items = array();
00550 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_row($res)) {
00551 $items[] = $row;
00552 }
00553 return count($items);
00554 }
00555 }
00556
00557
00558 if (defined("TYPO3_MODE") && $TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["ext/indexed_search/mod/index.php"]) {
00559 include_once($TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["ext/indexed_search/mod/index.php"]);
00560 }
00561
00562
00563
00564 $SOBE = t3lib_div::makeInstance("SC_mod_tools_isearch_index");
00565 $SOBE->init();
00566 $SOBE->main();
00567 $SOBE->printContent();
00568
00569 ?>