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 var $doc;
00088
00089 var $include_once=array();
00090 var $content;
00091
00097 function init() {
00098 global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$CLIENT,$TYPO3_CONF_VARS;
00099 $this->MCONF = $GLOBALS["MCONF"];
00100
00101 $this->menuConfig();
00102
00103 $this->doc = t3lib_div::makeInstance("noDoc");
00104 $this->doc->form='<form action="" method="POST">';
00105 $this->doc->backPath = $BACK_PATH;
00106
00107 $this->doc->JScode = '
00108 <script language="javascript" type="text/javascript">
00109 script_ended = 0;
00110 function jumpToUrl(URL) {
00111 document.location = URL;
00112 }
00113 </script>
00114 ';
00115 $this->doc->tableLayout = Array (
00116 "defRow" => Array (
00117 "0" => Array('<td valign="top" nowrap>','</td>'),
00118 "defCol" => Array('<TD><img src="'.$this->doc->backPath.'clear.gif" width=10 height=1></td><td valign="top" nowrap>','</td>')
00119 )
00120 );
00121
00122 $indexer = t3lib_div::makeInstance('tx_indexedsearch_indexer');
00123 $indexer->initializeExternalParsers();
00124 #debug(array_keys($indexer->external_parsers));
00125 #debug($indexer->internal_log);
00126 }
00127
00133 function menuConfig() {
00134 global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$CLIENT,$TYPO3_CONF_VARS;
00135
00136
00137
00138
00139
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 $this->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU, t3lib_div::_GP("SET"), $this->MCONF["name"], "ses");
00149 }
00150
00156 function main() {
00157 global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$CLIENT,$TYPO3_CONF_VARS;
00158
00159 $this->content="";
00160 $this->content.=$this->doc->startPage("Indexing Engine Statistics");
00161
00162 $menu=t3lib_BEfunc::getFuncMenu(0,"SET[function]",$this->MOD_SETTINGS["function"],$this->MOD_MENU["function"]);
00163
00164 $this->content.=$this->doc->header("Indexing Engine Statistics");
00165 $this->content.=$this->doc->spacer(5);
00166 $this->content.=$this->doc->section('',$menu);
00167
00168 switch($this->MOD_SETTINGS["function"]) {
00169 case "stat":
00170 $this->content.=$this->doc->section('Records',$this->doc->table($this->getRecordsNumbers()),0,1);
00171 $this->content.=$this->doc->spacer(15);
00172
00173
00174 $this->content.=$this->doc->section('index_phash TYPES',$this->doc->table($this->getPhashTypes()),1);
00175 $this->content.=$this->doc->spacer(15);
00176 break;
00177 case "externalDocs":
00178 $this->content.=$this->doc->section('External documents',$this->doc->table($this->getPhashExternalDocs()),0,1);
00179 $this->content.=$this->doc->spacer(15);
00180 break;
00181 case "typo3pages":
00182 $this->content.=$this->doc->section('TYPO3 Pages',$this->doc->table($this->getPhashT3pages()),0,1);
00183 $this->content.=$this->doc->spacer(15);
00184 break;
00185 }
00186 }
00187
00193 function printContent() {
00194
00195 $this->content.=$this->doc->endPage();
00196 echo $this->content;
00197 }
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00217 function getRecordsNumbers() {
00218 $tables=explode(",","index_phash,index_words,index_rel,index_grlist,index_section,index_fulltext");
00219 $recList=array();
00220 reset($tables);
00221 while(list(,$t)=each($tables)) {
00222 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', $t, '');
00223 $row = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
00224 $recList[] = array($this->tableHead($t), $row[0]);
00225 }
00226 return $recList;
00227 }
00228
00235 function tableHead($str) {
00236 return "<strong>".$str.": </strong>";
00237 }
00238
00244 function getPhashStat() {
00245 $recList = array();
00246
00247
00248 $items = array();
00249 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*),phash', 'index_phash', 'data_page_id!=0', 'phash_grouping,pcount,phash');
00250 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_row($res)) {
00251 $items[] = $row;
00252 }
00253 $recList[] = array($this->tableHead("TYPO3 pages"), count($items));
00254
00255
00256 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', 'index_phash', 'data_page_id!=0');
00257 $row = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
00258 $recList[] = array($this->tableHead("TYPO3 pages, raw"), $row[0]);
00259
00260
00261 $items = array();
00262 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*),phash', 'index_phash', 'data_filename!=\'\'', 'phash_grouping');
00263 $row = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
00264 $recList[] = array($this->tableHead("External files"), $row[0]);
00265
00266
00267 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', 'index_phash', 'data_filename!=\'\'');
00268 $row = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
00269 $recList[] = array($this->tableHead("External files, raw"), $row[0]);
00270
00271 return $recList;
00272 }
00273
00279 function getPhashT3pages() {
00280 $recList[]=array(
00281 $this->tableHead("id/type"),
00282 $this->tableHead("Title"),
00283 $this->tableHead("Size"),
00284 $this->tableHead("Words"),
00285 $this->tableHead("mtime"),
00286 $this->tableHead("Indexed"),
00287 $this->tableHead("Updated"),
00288 $this->tableHead("Parsetime"),
00289 $this->tableHead("#sec/gr/full"),
00290 $this->tableHead("#sub"),
00291 $this->tableHead("Lang"),
00292 $this->tableHead("cHash"),
00293 $this->tableHead("phash")
00294 );
00295
00296
00297 $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');
00298 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
00299
00300 $cHash = count(unserialize($row["cHashParams"])) ? $this->formatCHash(unserialize($row["cHashParams"])) : "";
00301 $grListRec = $this->getGrlistRecord($row["phash"]);
00302 $recList[] = array(
00303 $row["data_page_id"].($row["data_page_type"]?"/".$row["data_page_type"]:""),
00304 t3lib_div::fixed_lgd($row["item_title"],30),
00305 t3lib_div::formatSize($row["item_size"]),
00306 $this->getNumberOfWords($row["phash"]),
00307 t3lib_BEfunc::datetime($row["item_mtime"]),
00308 t3lib_BEfunc::datetime($row["crdate"]),
00309 ($row["tstamp"]!=$row["crdate"] ? t3lib_BEfunc::datetime($row["tstamp"]) : ""),
00310 $row["parsetime"],
00311 $this->getNumberOfSections($row["phash"])."/".$grListRec[0]["pcount"]."/".$this->getNumberOfFulltext($row["phash"]),
00312 $row["pcount"]."/".$this->formatFeGroup($grListRec),
00313 $row["sys_language_uid"],
00314 $cHash,
00315 $row["phash"]
00316 );
00317
00318 if ($row["pcount"]>1) {
00319 $res2 = $GLOBALS['TYPO3_DB']->exec_SELECTquery('index_phash.*', 'index_phash', 'phash_grouping='.intval($row['phash_grouping']).' AND phash!='.intval($row['phash']));
00320 while($row2 = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res2)) {
00321 $grListRec = $this->getGrlistRecord($row2["phash"]);
00322 $recList[] = array(
00323 "",
00324 "",
00325 t3lib_div::formatSize($row2["item_size"]),
00326 $this->getNumberOfWords($row2["phash"]),
00327 t3lib_BEfunc::datetime($row2["item_mtime"]),
00328 t3lib_BEfunc::datetime($row2["crdate"]),
00329 ($row2["tstamp"]!=$row2["crdate"] ? t3lib_BEfunc::datetime($row2["tstamp"]) : ""),
00330 $row2["parsetime"],
00331 $this->getNumberOfSections($row2["phash"])."/".$grListRec[0]["pcount"]."/".$this->getNumberOfFulltext($row2["phash"]),
00332 "-/".$this->formatFeGroup($grListRec),
00333 "",
00334 "",
00335 $row2["phash"]
00336 );
00337 }
00338 }
00339 }
00340 return $recList;
00341 }
00342
00348 function getPhashExternalDocs() {
00349 $recList[]=array(
00350 $this->tableHead("Filename"),
00351 $this->tableHead("Size"),
00352 $this->tableHead("Words"),
00353 $this->tableHead("mtime"),
00354 $this->tableHead("Indexed"),
00355 $this->tableHead("Updated"),
00356 $this->tableHead("Parsetime"),
00357 $this->tableHead("#sec/gr/full"),
00358 $this->tableHead("#sub"),
00359 $this->tableHead("cHash"),
00360 $this->tableHead("phash"),
00361 $this->tableHead("Path")
00362 );
00363
00364
00365 $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');
00366 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
00367
00368 $cHash = count(unserialize($row["cHashParams"])) ? $this->formatCHash(unserialize($row["cHashParams"])) : "";
00369 $grListRec = $this->getGrlistRecord($row["phash"]);
00370 $recList[]=array(
00371 t3lib_div::fixed_lgd($row["item_title"],30),
00372 t3lib_div::formatSize($row["item_size"]),
00373 $this->getNumberOfWords($row["phash"]),
00374 t3lib_BEfunc::datetime($row["item_mtime"]),
00375 t3lib_BEfunc::datetime($row["crdate"]),
00376 ($row["tstamp"]!=$row["crdate"] ? t3lib_BEfunc::datetime($row["tstamp"]) : ""),
00377 $row["parsetime"],
00378 $this->getNumberOfSections($row["phash"])."/".$grListRec[0]["pcount"]."/".$this->getNumberOfFulltext($row["phash"]),
00379 $row["pcount"],
00380 $cHash,
00381 $row["phash"],
00382 t3lib_div::fixed_lgd($row["data_filename"],100)
00383 );
00384
00385 if ($row["pcount"]>1) {
00386 $res2 = $GLOBALS['TYPO3_DB']->exec_SELECTquery('index_phash.*', 'index_phash', 'phash_grouping='.intval($row['phash_grouping']).' AND phash!='.intval($row['phash']));
00387 while($row2 = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res2)) {
00388 $cHash = count(unserialize($row2["cHashParams"])) ? $this->formatCHash(unserialize($row2["cHashParams"])) : "";
00389 $grListRec = $this->getGrlistRecord($row2["phash"]);
00390 $recList[]=array(
00391 "",
00392 "",
00393 $this->getNumberOfWords($row2["phash"]),
00394 "",
00395 t3lib_BEfunc::datetime($row2["crdate"]),
00396 ($row2["tstamp"]!=$row2["crdate"] ? t3lib_BEfunc::datetime($row2["tstamp"]) : ""),
00397 $row2["parsetime"],
00398 $this->getNumberOfSections($row2["phash"])."/".$grListRec[0]["pcount"]."/".$this->getNumberOfFulltext($row2["phash"]),
00399 "",
00400 $cHash,
00401 $row2["phash"],
00402 ""
00403 );
00404 }
00405 }
00406
00407 }
00408 return $recList;
00409 }
00410
00417 function formatFeGroup($fegroup_recs) {
00418 reset($fegroup_recs);
00419 $str = array();
00420 while(list(,$row)=each($fegroup_recs)) {
00421 $str[] = $row["gr_list"]=="0,-1" ? "NL" : $row["gr_list"];
00422 }
00423 arsort($str);
00424 return implode("|",$str);
00425 }
00426
00433 function formatCHash($arr) {
00434 reset($arr);
00435 $list=array();
00436 while(list($k,$v)=each($arr)) {
00437 $list[]=$k."=".$v;
00438 }
00439 return implode("<BR>",$list);
00440 }
00441
00448 function getNumberOfSections($phash) {
00449 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', 'index_section', 'phash='.intval($phash));
00450 $row = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
00451 return $row[0];
00452 }
00453
00460 function getNumberOfWords($phash) {
00461 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', 'index_rel', 'phash='.intval($phash));
00462 $row = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
00463 return $row[0];
00464 }
00465
00472 function getGrlistRecord($phash) {
00473 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('index_grlist.*', 'index_grlist', 'phash='.intval($phash));
00474 $allRows = array();
00475 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
00476 $row["pcount"] = $GLOBALS['TYPO3_DB']->sql_num_rows($res);
00477 $allRows[] = $row;
00478 }
00479 return $allRows;
00480 }
00481
00488 function getNumberOfFulltext($phash) {
00489 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', 'index_fulltext', 'phash='.intval($phash));
00490 $row = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
00491 return $row[0];
00492 }
00493
00499 function getPhashTypes() {
00500 $recList=array();
00501
00502
00503 $Itypes = array(
00504 "html" => 1,
00505 "htm" => 1,
00506 "pdf" => 2,
00507 "doc" => 3,
00508 "txt" => 4
00509 );
00510
00511 $revTypes=array_flip($Itypes);
00512 $revTypes[0]="TYPO3 page";
00513
00514 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*),item_type', 'index_phash', '', 'item_type', 'item_type');
00515 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_row($res)) {
00516 $iT = $row[1];
00517 $recList[] = array($this->tableHead($revTypes[$iT]." ($iT)"), $this->countUniqueTypes($iT)."/".$row[0]);
00518 }
00519
00520 return $recList;
00521 }
00522
00529 function countUniqueTypes($item_type) {
00530
00531 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', 'index_phash', 'item_type='.intval($item_type), 'phash_grouping');
00532 $items = array();
00533 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_row($res)) {
00534 $items[] = $row;
00535 }
00536 return count($items);
00537 }
00538 }
00539
00540
00541 if (defined("TYPO3_MODE") && $TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["ext/indexed_search/mod/index.php"]) {
00542 include_once($TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["ext/indexed_search/mod/index.php"]);
00543 }
00544
00545
00546
00547
00548
00549
00550
00551
00552
00553
00554
00555
00556
00557 $SOBE = t3lib_div::makeInstance("SC_mod_tools_isearch_index");
00558 $SOBE->init();
00559 $SOBE->main();
00560 $SOBE->printContent();
00561 ?>