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
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
00083 class SC_mod_tools_isearch_index {
00084 var $MCONF=array();
00085 var $MOD_MENU=array();
00086 var $MOD_SETTINGS=array();
00087
00093 var $doc;
00094
00095 var $include_once=array();
00096 var $content;
00097
00103 function init() {
00104 global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$CLIENT,$TYPO3_CONF_VARS;
00105 $this->MCONF = $GLOBALS["MCONF"];
00106
00107 $this->menuConfig();
00108
00109 $this->doc = t3lib_div::makeInstance("noDoc");
00110 $this->doc->form='<form action="" method="POST">';
00111 $this->doc->backPath = $BACK_PATH;
00112
00113 $this->doc->JScode = '
00114 <script language="javascript" type="text/javascript">
00115 script_ended = 0;
00116 function jumpToUrl(URL) {
00117 window.location.href = URL;
00118 }
00119 </script>
00120 ';
00121 $this->doc->tableLayout = Array (
00122 "defRow" => Array (
00123 "0" => Array('<td valign="top" nowrap>','</td>'),
00124 "defCol" => Array('<TD><img src="'.$this->doc->backPath.'clear.gif" width=10 height=1></td><td valign="top" nowrap>','</td>')
00125 )
00126 );
00127
00128 $indexer = t3lib_div::makeInstance('tx_indexedsearch_indexer');
00129 $indexer->initializeExternalParsers();
00130 #debug(array_keys($indexer->external_parsers));
00131 #debug($indexer->internal_log);
00132 }
00133
00139 function menuConfig() {
00140 global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$CLIENT,$TYPO3_CONF_VARS;
00141
00142
00143
00144
00145
00146 $this->MOD_MENU = array(
00147 "function" => array(
00148 "stat" => "General statistics",
00149 "typo3pages" => "List: TYPO3 Pages",
00150 "externalDocs" => "List: External documents",
00151 )
00152 );
00153
00154 $this->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU, t3lib_div::_GP("SET"), $this->MCONF["name"], "ses");
00155 }
00156
00162 function main() {
00163 global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$CLIENT,$TYPO3_CONF_VARS;
00164
00165 $this->content="";
00166 $this->content.=$this->doc->startPage("Indexing Engine Statistics");
00167
00168 $menu=t3lib_BEfunc::getFuncMenu(0,"SET[function]",$this->MOD_SETTINGS["function"],$this->MOD_MENU["function"]);
00169
00170 $this->content.=$this->doc->header("Indexing Engine Statistics");
00171 $this->content.=$this->doc->spacer(5);
00172 $this->content.=$this->doc->section('',$menu);
00173
00174 switch($this->MOD_SETTINGS["function"]) {
00175 case "stat":
00176 $this->content.=$this->doc->section('Records',$this->doc->table($this->getRecordsNumbers()),0,1);
00177 $this->content.=$this->doc->spacer(15);
00178
00179
00180 $this->content.=$this->doc->section('index_phash TYPES',$this->doc->table($this->getPhashTypes()),1);
00181 $this->content.=$this->doc->spacer(15);
00182 break;
00183 case "externalDocs":
00184 $this->content.=$this->doc->section('External documents',$this->doc->table($this->getPhashExternalDocs()),0,1);
00185 $this->content.=$this->doc->spacer(15);
00186 break;
00187 case "typo3pages":
00188 $this->content.=$this->doc->section('TYPO3 Pages',$this->doc->table($this->getPhashT3pages()),0,1);
00189 $this->content.=$this->doc->spacer(15);
00190 break;
00191 }
00192 }
00193
00199 function printContent() {
00200 $this->content.=$this->doc->endPage();
00201 echo $this->content;
00202 }
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00222 function getRecordsNumbers() {
00223 $tables=explode(",","index_phash,index_words,index_rel,index_grlist,index_section,index_fulltext");
00224 $recList=array();
00225 reset($tables);
00226 while(list(,$t)=each($tables)) {
00227 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', $t, '');
00228 $row = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
00229 $recList[] = array($this->tableHead($t), $row[0]);
00230 }
00231 return $recList;
00232 }
00233
00240 function tableHead($str) {
00241 return "<strong>".$str.": </strong>";
00242 }
00243
00249 function getPhashStat() {
00250 $recList = array();
00251
00252
00253 $items = array();
00254 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*),phash', 'index_phash', 'data_page_id!=0', 'phash_grouping,pcount,phash');
00255 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_row($res)) {
00256 $items[] = $row;
00257 }
00258 $recList[] = array($this->tableHead("TYPO3 pages"), count($items));
00259
00260
00261 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', 'index_phash', 'data_page_id!=0');
00262 $row = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
00263 $recList[] = array($this->tableHead("TYPO3 pages, raw"), $row[0]);
00264
00265
00266 $items = array();
00267 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*),phash', 'index_phash', 'data_filename!=\'\'', 'phash_grouping');
00268 $row = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
00269 $recList[] = array($this->tableHead("External files"), $row[0]);
00270
00271
00272 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', 'index_phash', 'data_filename!=\'\'');
00273 $row = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
00274 $recList[] = array($this->tableHead("External files, raw"), $row[0]);
00275
00276 return $recList;
00277 }
00278
00284 function getPhashT3pages() {
00285 $recList[]=array(
00286 $this->tableHead("id/type"),
00287 $this->tableHead("Title"),
00288 $this->tableHead("Size"),
00289 $this->tableHead("Words"),
00290 $this->tableHead("mtime"),
00291 $this->tableHead("Indexed"),
00292 $this->tableHead("Updated"),
00293 $this->tableHead("Parsetime"),
00294 $this->tableHead("#sec/gr/full"),
00295 $this->tableHead("#sub"),
00296 $this->tableHead("Lang"),
00297 $this->tableHead("cHash"),
00298 $this->tableHead("phash")
00299 );
00300
00301
00302 $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', 'data_page_id');
00303 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
00304
00305 $cHash = count(unserialize($row["cHashParams"])) ? $this->formatCHash(unserialize($row["cHashParams"])) : "";
00306 $grListRec = $this->getGrlistRecord($row["phash"]);
00307 $recList[] = array(
00308 $row["data_page_id"].($row["data_page_type"]?"/".$row["data_page_type"]:""),
00309 t3lib_div::fixed_lgd($row["item_title"],30),
00310 t3lib_div::formatSize($row["item_size"]),
00311 $this->getNumberOfWords($row["phash"]),
00312 t3lib_BEfunc::datetime($row["item_mtime"]),
00313 t3lib_BEfunc::datetime($row["crdate"]),
00314 ($row["tstamp"]!=$row["crdate"] ? t3lib_BEfunc::datetime($row["tstamp"]) : ""),
00315 $row["parsetime"],
00316 $this->getNumberOfSections($row["phash"])."/".$grListRec[0]["pcount"]."/".$this->getNumberOfFulltext($row["phash"]),
00317 $row["pcount"]."/".$this->formatFeGroup($grListRec),
00318 $row["sys_language_uid"],
00319 $cHash,
00320 $row["phash"]
00321 );
00322
00323 if ($row["pcount"]>1) {
00324 $res2 = $GLOBALS['TYPO3_DB']->exec_SELECTquery('index_phash.*', 'index_phash', 'phash_grouping='.intval($row['phash_grouping']).' AND phash!='.intval($row['phash']));
00325 while($row2 = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res2)) {
00326 $grListRec = $this->getGrlistRecord($row2["phash"]);
00327 $recList[] = array(
00328 "",
00329 "",
00330 t3lib_div::formatSize($row2["item_size"]),
00331 $this->getNumberOfWords($row2["phash"]),
00332 t3lib_BEfunc::datetime($row2["item_mtime"]),
00333 t3lib_BEfunc::datetime($row2["crdate"]),
00334 ($row2["tstamp"]!=$row2["crdate"] ? t3lib_BEfunc::datetime($row2["tstamp"]) : ""),
00335 $row2["parsetime"],
00336 $this->getNumberOfSections($row2["phash"])."/".$grListRec[0]["pcount"]."/".$this->getNumberOfFulltext($row2["phash"]),
00337 "-/".$this->formatFeGroup($grListRec),
00338 "",
00339 "",
00340 $row2["phash"]
00341 );
00342 }
00343 }
00344 }
00345 return $recList;
00346 }
00347
00353 function getPhashExternalDocs() {
00354 $recList[]=array(
00355 $this->tableHead("Filename"),
00356 $this->tableHead("Size"),
00357 $this->tableHead("Words"),
00358 $this->tableHead("mtime"),
00359 $this->tableHead("Indexed"),
00360 $this->tableHead("Updated"),
00361 $this->tableHead("Parsetime"),
00362 $this->tableHead("#sec/gr/full"),
00363 $this->tableHead("#sub"),
00364 $this->tableHead("cHash"),
00365 $this->tableHead("phash"),
00366 $this->tableHead("Path")
00367 );
00368
00369
00370 $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', 'item_type');
00371 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
00372
00373 $cHash = count(unserialize($row["cHashParams"])) ? $this->formatCHash(unserialize($row["cHashParams"])) : "";
00374 $grListRec = $this->getGrlistRecord($row["phash"]);
00375 $recList[]=array(
00376 t3lib_div::fixed_lgd($row["item_title"],30),
00377 t3lib_div::formatSize($row["item_size"]),
00378 $this->getNumberOfWords($row["phash"]),
00379 t3lib_BEfunc::datetime($row["item_mtime"]),
00380 t3lib_BEfunc::datetime($row["crdate"]),
00381 ($row["tstamp"]!=$row["crdate"] ? t3lib_BEfunc::datetime($row["tstamp"]) : ""),
00382 $row["parsetime"],
00383 $this->getNumberOfSections($row["phash"])."/".$grListRec[0]["pcount"]."/".$this->getNumberOfFulltext($row["phash"]),
00384 $row["pcount"],
00385 $cHash,
00386 $row["phash"],
00387 t3lib_div::fixed_lgd($row["data_filename"],100)
00388 );
00389
00390 if ($row["pcount"]>1) {
00391 $res2 = $GLOBALS['TYPO3_DB']->exec_SELECTquery('index_phash.*', 'index_phash', 'phash_grouping='.intval($row['phash_grouping']).' AND phash!='.intval($row['phash']));
00392 while($row2 = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res2)) {
00393 $cHash = count(unserialize($row2["cHashParams"])) ? $this->formatCHash(unserialize($row2["cHashParams"])) : "";
00394 $grListRec = $this->getGrlistRecord($row2["phash"]);
00395 $recList[]=array(
00396 "",
00397 "",
00398 $this->getNumberOfWords($row2["phash"]),
00399 "",
00400 t3lib_BEfunc::datetime($row2["crdate"]),
00401 ($row2["tstamp"]!=$row2["crdate"] ? t3lib_BEfunc::datetime($row2["tstamp"]) : ""),
00402 $row2["parsetime"],
00403 $this->getNumberOfSections($row2["phash"])."/".$grListRec[0]["pcount"]."/".$this->getNumberOfFulltext($row2["phash"]),
00404 "",
00405 $cHash,
00406 $row2["phash"],
00407 ""
00408 );
00409 }
00410 }
00411
00412 }
00413 return $recList;
00414 }
00415
00422 function formatFeGroup($fegroup_recs) {
00423 reset($fegroup_recs);
00424 $str = array();
00425 while(list(,$row)=each($fegroup_recs)) {
00426 $str[] = $row["gr_list"]=="0,-1" ? "NL" : $row["gr_list"];
00427 }
00428 arsort($str);
00429 return implode("|",$str);
00430 }
00431
00438 function formatCHash($arr) {
00439 reset($arr);
00440 $list=array();
00441 while(list($k,$v)=each($arr)) {
00442 $list[]=$k."=".$v;
00443 }
00444 return implode("<BR>",$list);
00445 }
00446
00453 function getNumberOfSections($phash) {
00454 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', 'index_section', 'phash='.intval($phash));
00455 $row = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
00456 return $row[0];
00457 }
00458
00465 function getNumberOfWords($phash) {
00466 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', 'index_rel', 'phash='.intval($phash));
00467 $row = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
00468 return $row[0];
00469 }
00470
00477 function getGrlistRecord($phash) {
00478 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('index_grlist.*', 'index_grlist', 'phash='.intval($phash));
00479 $allRows = array();
00480 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
00481 $row["pcount"] = $GLOBALS['TYPO3_DB']->sql_num_rows($res);
00482 $allRows[] = $row;
00483 }
00484 return $allRows;
00485 }
00486
00493 function getNumberOfFulltext($phash) {
00494 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', 'index_fulltext', 'phash='.intval($phash));
00495 $row = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
00496 return $row[0];
00497 }
00498
00504 function getPhashTypes() {
00505 $recList=array();
00506
00507
00508 $Itypes = array(
00509 "html" => 1,
00510 "htm" => 1,
00511 "pdf" => 2,
00512 "doc" => 3,
00513 "txt" => 4
00514 );
00515
00516 $revTypes=array_flip($Itypes);
00517 $revTypes[0]="TYPO3 page";
00518
00519 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*),item_type', 'index_phash', '', 'item_type', 'item_type');
00520 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_row($res)) {
00521 $iT = $row[1];
00522 $recList[] = array($this->tableHead($revTypes[$iT]." ($iT)"), $this->countUniqueTypes($iT)."/".$row[0]);
00523 }
00524
00525 return $recList;
00526 }
00527
00534 function countUniqueTypes($item_type) {
00535
00536 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', 'index_phash', 'item_type='.intval($item_type), 'phash_grouping');
00537 $items = array();
00538 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_row($res)) {
00539 $items[] = $row;
00540 }
00541 return count($items);
00542 }
00543 }
00544
00545
00546 if (defined("TYPO3_MODE") && $TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["ext/indexed_search/mod/index.php"]) {
00547 include_once($TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["ext/indexed_search/mod/index.php"]);
00548 }
00549
00550
00551
00552
00553
00554
00555
00556
00557
00558
00559
00560
00561
00562 $SOBE = t3lib_div::makeInstance("SC_mod_tools_isearch_index");
00563 $SOBE->init();
00564 $SOBE->main();
00565 $SOBE->printContent();
00566 ?>