Documentation TYPO3 par Ameos

index.php

00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 1999-2004 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 ***************************************************************/
00034 unset($MCONF);
00035 require ("conf.php");
00036 require ($BACK_PATH."init.php");
00037 require ($BACK_PATH."template.php");
00038 $BE_USER->modAccess($MCONF,1);
00039 
00040 t3lib_extMgm::isLoaded("indexed_search",1);
00041 
00042 
00043 
00044 // ***************************
00045 // Script Classes
00046 // ***************************
00047 class SC_mod_tools_isearch_index {
00048         var $MCONF=array();
00049         var $MOD_MENU=array();
00050         var $MOD_SETTINGS=array();
00051         var $doc;
00052 
00053         var $include_once=array();
00054         var $content;
00055 
00056         function init() {
00057                 global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$CLIENT,$TYPO3_CONF_VARS;
00058                 $this->MCONF = $GLOBALS["MCONF"];
00059 
00060                 $this->menuConfig();
00061 
00062                 $this->doc = t3lib_div::makeInstance("noDoc");
00063                 $this->doc->form='<form action="" method="POST">';
00064                 $this->doc->backPath = $BACK_PATH;
00065                                 // JavaScript
00066                 $this->doc->JScode = '
00067                 <script language="javascript" type="text/javascript">
00068                         script_ended = 0;
00069                         function jumpToUrl(URL) {
00070                                 document.location = URL;
00071                         }
00072                 </script>
00073                 ';
00074                 $this->doc->tableLayout = Array (
00075                         "defRow" => Array (
00076                                 "0" => Array('<td valign="top" nowrap>','</td>'),
00077                                 "defCol" => Array('<TD><img src="'.$this->doc->backPath.'clear.gif" width=10 height=1></td><td valign="top" nowrap>','</td>')
00078                         )
00079                 );
00080         }
00081         function menuConfig()   {
00082                 global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$CLIENT,$TYPO3_CONF_VARS;
00083 
00084                 // MENU-ITEMS:
00085                         // If array, then it's a selector box menu
00086                         // If empty string it's just a variable, that'll be saved.
00087                         // Values NOT in this array will not be saved in the settings-array for the module.
00088                 $this->MOD_MENU = array(
00089                         "function" => array(
00090                                 "stat" => "General statistics",
00091                                 "typo3pages" => "List: TYPO3 Pages",
00092                                 "externalDocs" => "List: External documents",
00093                         )
00094                 );
00095                         // CLEANSE SETTINGS
00096                 $this->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU, t3lib_div::_GP("SET"), $this->MCONF["name"], "ses");
00097         }
00098         function main() {
00099                 global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$CLIENT,$TYPO3_CONF_VARS;
00100 
00101                 $this->content="";
00102                 $this->content.=$this->doc->startPage("Indexing Engine Statistics");
00103 
00104                 $menu=t3lib_BEfunc::getFuncMenu(0,"SET[function]",$this->MOD_SETTINGS["function"],$this->MOD_MENU["function"]);
00105 
00106                 $this->content.=$this->doc->header("Indexing Engine Statistics");
00107                 $this->content.=$this->doc->spacer(5);
00108                 $this->content.=$this->doc->section('',$menu);
00109 
00110                 switch($this->MOD_SETTINGS["function"]) {
00111                         case "stat":
00112                                 $this->content.=$this->doc->section('Records',$this->doc->table($this->getRecordsNumbers()),0,1);
00113                                 $this->content.=$this->doc->spacer(15);
00114                 //              $this->content.=$this->doc->section('index_phash STATISTICS',$this->doc->table($this->getPhashStat()),1);
00115                 //              $this->content.=$this->doc->spacer(15);
00116                                 $this->content.=$this->doc->section('index_phash TYPES',$this->doc->table($this->getPhashTypes()),1);
00117                                 $this->content.=$this->doc->spacer(15);
00118                         break;
00119                         case "externalDocs":
00120                                 $this->content.=$this->doc->section('External documents',$this->doc->table($this->getPhashExternalDocs()),0,1);
00121                                 $this->content.=$this->doc->spacer(15);
00122                         break;
00123                         case "typo3pages":
00124                                 $this->content.=$this->doc->section('TYPO3 Pages',$this->doc->table($this->getPhashT3pages()),0,1);
00125                                 $this->content.=$this->doc->spacer(15);
00126                         break;
00127                 }
00128         }
00129         function printContent() {
00130 
00131                 $this->content.=$this->doc->endPage();
00132                 echo $this->content;
00133         }
00134 
00135 
00136         // ***************************
00137         // OTHER FUNCTIONS:
00138         // ***************************
00139         function getRecordsNumbers()    {
00140                 $tables=explode(",","index_phash,index_words,index_rel,index_grlist,index_section,index_fulltext");
00141                 $recList=array();
00142                 reset($tables);
00143                 while(list(,$t)=each($tables))  {
00144                         $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', $t, '');
00145                         $row = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
00146 
00147                         $recList[] = array($this->tableHead($t), $row[0]);
00148                 }
00149                 return $recList;
00150         }
00151         function tableHead($str)        {
00152                 return "<strong>".$str.":&nbsp;&nbsp;&nbsp;</strong>";
00153         }
00154         function getPhashStat() {
00155                 $recList = array();
00156 
00157                         // TYPO3 pages, unique
00158                 $items = array();
00159                 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*),phash', 'index_phash', 'data_page_id!=0', 'phash_grouping');
00160                 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_row($res)) {
00161                         $items[] = $row;
00162                 }
00163                 $recList[] = array($this->tableHead("TYPO3 pages"), count($items));
00164 
00165                         // TYPO3 pages:
00166                 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', 'index_phash', 'data_page_id!=0');
00167                 $row = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
00168                 $recList[] = array($this->tableHead("TYPO3 pages, raw"), $row[0]);
00169 
00170                         // External files, unique
00171                 $items = array();
00172                 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*),phash', 'index_phash', 'data_filename!=""', 'phash_grouping');
00173                 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_row($res)) {
00174                         $items[] = $row;
00175                 }
00176                 $recList[] = array($this->tableHead("External files"), count($items));
00177 
00178                         // External files
00179                 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', 'index_phash', 'data_filename!=""');
00180                 $row = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
00181                 $recList[] = array($this->tableHead("External files, raw"), $row[0]);
00182 
00183                 return $recList;
00184         }
00185         function getPhashT3pages()      {
00186                 $recList[]=array(
00187                         $this->tableHead("id/type"),
00188                         $this->tableHead("Title"),
00189                         $this->tableHead("Size"),
00190                         $this->tableHead("Words"),
00191                         $this->tableHead("mtime"),
00192                         $this->tableHead("Indexed"),
00193                         $this->tableHead("Updated"),
00194                         $this->tableHead("Parsetime"),
00195                         $this->tableHead("#sec/gr/full"),
00196                         $this->tableHead("#sub"),
00197                         $this->tableHead("Lang"),
00198                         $this->tableHead("cHash"),
00199                         $this->tableHead("phash")
00200                 );
00201 
00202                         // TYPO3 pages, unique
00203                 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*),index_phash.*', 'index_phash', 'data_page_id!=0', 'phash_grouping', 'data_page_id');
00204                 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))       {
00205 
00206                         $cHash = count(unserialize($row["cHashParams"])) ? $this->formatCHash(unserialize($row["cHashParams"])) : "";
00207                         $grListRec = $this->getGrlistRecord($row["phash"]);
00208                         $recList[] = array(
00209                                 $row["data_page_id"].($row["data_page_type"]?"/".$row["data_page_type"]:""),
00210                                 t3lib_div::fixed_lgd($row["item_title"],30),
00211                                 t3lib_div::formatSize($row["item_size"]),
00212                                 $this->getNumberOfWords($row["phash"]),
00213                                 t3lib_BEfunc::datetime($row["item_mtime"]),
00214                                 t3lib_BEfunc::datetime($row["crdate"]),
00215                                 ($row["tstamp"]!=$row["crdate"] ? t3lib_BEfunc::datetime($row["tstamp"]) : ""),
00216                                 $row["parsetime"],
00217                                 $this->getNumberOfSections($row["phash"])."/".$grListRec[0]["count(*)"]."/".$this->getNumberOfFulltext($row["phash"]),
00218                                 $row["count(*)"]."/".$this->formatFeGroup($grListRec),
00219                                 $row["sys_language_uid"],
00220                                 $cHash,
00221                                 $row["phash"]
00222                         );
00223 
00224                         if ($row["count(*)"]>1) {
00225                                 $res2 = $GLOBALS['TYPO3_DB']->exec_SELECTquery('index_phash.*', 'index_phash', 'phash_grouping='.intval($row['phash_grouping']).' AND phash!='.intval($row['phash']));
00226                                 while($row2 = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res2))     {
00227                                         $grListRec = $this->getGrlistRecord($row2["phash"]);
00228                                         $recList[] = array(
00229                                                 "",
00230                                                 "",
00231                                                 t3lib_div::formatSize($row2["item_size"]),
00232                                                 $this->getNumberOfWords($row2["phash"]),
00233                                                 t3lib_BEfunc::datetime($row2["item_mtime"]),
00234                                                 t3lib_BEfunc::datetime($row2["crdate"]),
00235                                                 ($row2["tstamp"]!=$row2["crdate"] ? t3lib_BEfunc::datetime($row2["tstamp"]) : ""),
00236                                                 $row2["parsetime"],
00237                                                 $this->getNumberOfSections($row2["phash"])."/".$grListRec[0]["count(*)"]."/".$this->getNumberOfFulltext($row2["phash"]),
00238                                                 "-/".$this->formatFeGroup($grListRec),
00239                                                 "",
00240                                                 "",
00241                                                 $row2["phash"]
00242                                         );
00243                                 }
00244                         }
00245                 }
00246                 return $recList;
00247         }
00248         function getPhashExternalDocs() {
00249                 $recList[]=array(
00250                         $this->tableHead("Filename"),
00251                         $this->tableHead("Size"),
00252                         $this->tableHead("Words"),
00253                         $this->tableHead("mtime"),
00254                         $this->tableHead("Indexed"),
00255                         $this->tableHead("Updated"),
00256                         $this->tableHead("Parsetime"),
00257                         $this->tableHead("#sec/gr/full"),
00258                         $this->tableHead("#sub"),
00259                         $this->tableHead("cHash"),
00260                         $this->tableHead("phash"),
00261                         $this->tableHead("Path")
00262                 );
00263 
00264                         // TYPO3 pages, unique
00265                 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*),index_phash.*', 'index_phash', 'item_type>0', 'phash_grouping', 'item_type');
00266                 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))       {
00267 
00268                         $cHash = count(unserialize($row["cHashParams"])) ? $this->formatCHash(unserialize($row["cHashParams"])) : "";
00269                         $grListRec = $this->getGrlistRecord($row["phash"]);
00270                         $recList[]=array(
00271                                 t3lib_div::fixed_lgd($row["item_title"],30),
00272                                 t3lib_div::formatSize($row["item_size"]),
00273                                 $this->getNumberOfWords($row["phash"]),
00274                                 t3lib_BEfunc::datetime($row["item_mtime"]),
00275                                 t3lib_BEfunc::datetime($row["crdate"]),
00276                                 ($row["tstamp"]!=$row["crdate"] ? t3lib_BEfunc::datetime($row["tstamp"]) : ""),
00277                                 $row["parsetime"],
00278                                 $this->getNumberOfSections($row["phash"])."/".$grListRec[0]["count(*)"]."/".$this->getNumberOfFulltext($row["phash"]),
00279                                 $row["count(*)"],
00280                                 $cHash,
00281                                 $row["phash"],
00282                                 t3lib_div::fixed_lgd($row["data_filename"],100)
00283                         );
00284 
00285                         if ($row["count(*)"]>1) {
00286                                 $res2 = $GLOBALS['TYPO3_DB']->exec_SELECTquery('index_phash.*', 'index_phash', 'phash_grouping='.intval($row['phash_grouping']).' AND phash!='.intval($row['phash']));
00287                                 while($row2 = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res2))     {
00288                                         $cHash = count(unserialize($row2["cHashParams"])) ? $this->formatCHash(unserialize($row2["cHashParams"])) : "";
00289                                         $grListRec = $this->getGrlistRecord($row2["phash"]);
00290                                         $recList[]=array(
00291                                                 "",
00292                                                 "",
00293                                                 $this->getNumberOfWords($row2["phash"]),
00294                                                 "",
00295                                                 t3lib_BEfunc::datetime($row2["crdate"]),
00296                                                 ($row2["tstamp"]!=$row2["crdate"] ? t3lib_BEfunc::datetime($row2["tstamp"]) : ""),
00297                                                 $row2["parsetime"],
00298                                                 $this->getNumberOfSections($row2["phash"])."/".$grListRec[0]["count(*)"]."/".$this->getNumberOfFulltext($row2["phash"]),
00299                                                 "",
00300                                                 $cHash,
00301                                                 $row2["phash"],
00302                                                 ""
00303                                         );
00304                                 }
00305                         }
00306         //              debug($row);
00307                 }
00308                 return $recList;
00309         }
00310         function formatFeGroup($fegroup_recs)   {
00311                 reset($fegroup_recs);
00312                 $str = array();
00313                 while(list(,$row)=each($fegroup_recs))  {
00314                         $str[] = $row["gr_list"]=="0,-1" ? "NL" : $row["gr_list"];
00315                 }
00316                 arsort($str);
00317                 return implode("|",$str);
00318         }
00319         function formatCHash($arr)      {
00320                 reset($arr);
00321                 $list=array();
00322                 while(list($k,$v)=each($arr))   {
00323                         $list[]=$k."=".$v;
00324                 }
00325                 return implode("<BR>",$list);
00326         }
00327         function getNumberOfSections($phash)    {
00328                 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', 'index_section', 'phash='.intval($phash));
00329                 $row = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
00330                 return $row[0];
00331         }
00332         function getNumberOfWords($phash)       {
00333                 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', 'index_rel', 'phash='.intval($phash));
00334                 $row = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
00335                 return $row[0];
00336         }
00337         function getGrlistRecord($phash)        {
00338                 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('index_grlist.*', 'index_grlist', 'phash='.intval($phash));
00339                 $allRows = array();
00340                 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))       {
00341                         $row["count(*)"] = $GLOBALS['TYPO3_DB']->sql_num_rows($res);
00342                         $allRows[] = $row;
00343                 }
00344                 return $allRows;
00345         }
00346         function getNumberOfFulltext($phash)    {
00347                 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', 'index_fulltext', 'phash='.intval($phash));
00348                 $row = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
00349                 return $row[0];
00350         }
00351         function getPhashTypes()        {
00352                 $recList=array();
00353 
00354                 // Types:
00355                 $Itypes = array(
00356                         "html" => 1,
00357                         "htm" => 1,
00358                         "pdf" => 2,
00359                         "doc" => 3,
00360                         "txt" => 4
00361                 );
00362 
00363                 $revTypes=array_flip($Itypes);
00364                 $revTypes[0]="TYPO3 page";
00365 
00366                 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*),item_type', 'index_phash', '', 'item_type', 'item_type');
00367                 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_row($res)) {
00368                         $iT = $row[1];
00369                         $recList[] = array($this->tableHead($revTypes[$iT]." ($iT)"), $this->countUniqueTypes($iT)."/".$row[0]);
00370                 }
00371 
00372                 return $recList;
00373         }
00374         function countUniqueTypes($item_type)   {
00375                         // TYPO3 pages, unique
00376                 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', 'index_phash', 'item_type='.intval($item_type), 'phash_grouping');
00377                 $items = array();
00378                 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_row($res)) {
00379                         $items[] = $row;
00380                 }
00381                 return count($items);
00382         }
00383 }
00384 
00385 // Include extension?
00386 if (defined("TYPO3_MODE") && $TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["ext/indexed_search/mod/index.php"])        {
00387         include_once($TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["ext/indexed_search/mod/index.php"]);
00388 }
00389 
00390 
00391 
00392 
00393 
00394 
00395 
00396 
00397 
00398 
00399 
00400 
00401 // Make instance:
00402 $SOBE = t3lib_div::makeInstance("SC_mod_tools_isearch_index");
00403 $SOBE->init();
00404 $SOBE->main();
00405 $SOBE->printContent();
00406 ?>


Généré par L'expert TYPO3 avec  doxygen 1.4.6