"TYPO3 4.0.1: typo3_src-4.0.1/typo3/sysext/dbal/mod1/index.php Source File", "datetime" => "Sat Dec 2 19:22:16 2006", "date" => "2 Dec 2006", "doxygenversion" => "1.4.6", "projectname" => "TYPO3 4.0.1", "projectnumber" => "4.0.1" ); get_header($doxygen_vars); ?>

index.php

00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 2004, 2005 Kasper Skaarhoj (kasperYYYY@typo3.com)
00006 *  (c) 2004, 2005 Karsten Dambekalns (karsten@typo3.org)
00007 *  All rights reserved
00008 *
00009 *  This script is part of the TYPO3 project. The TYPO3 project is
00010 *  free software; you can redistribute it and/or modify
00011 *  it under the terms of the GNU General Public License as published by
00012 *  the Free Software Foundation; either version 2 of the License, or
00013 *  (at your option) any later version.
00014 *
00015 *  The GNU General Public License can be found at
00016 *  http://www.gnu.org/copyleft/gpl.html.
00017 *
00018 *  This script is distributed in the hope that it will be useful,
00019 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00020 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00021 *  GNU General Public License for more details.
00022 *
00023 *  This copyright notice MUST APPEAR in all copies of the script!
00024 ***************************************************************/
00032 unset($MCONF);
00033 require ('conf.php');
00034 require ($BACK_PATH.'init.php');
00035 require ($BACK_PATH.'template.php');
00036 $LANG->includeLLFile('EXT:dbal/mod1/locallang.xml');
00037 require_once (PATH_t3lib.'class.t3lib_scbase.php');
00038 $BE_USER->modAccess($MCONF,1);
00039 
00040 
00049 class tx_dbal_module1 extends t3lib_SCbase {
00050 
00056         function menuConfig()   {
00057                 $this->MOD_MENU = Array (
00058                         'function' => Array (
00059                                 0 => $GLOBALS['LANG']->getLL('Debug_log'),
00060                                 'info' => $GLOBALS['LANG']->getLL('Cached_info'),
00061                                 'sqlcheck' => $GLOBALS['LANG']->getLL('SQL_check'),
00062                         )
00063                 );
00064                 parent::menuConfig();
00065         }
00066 
00072         function main() {
00073                 global $BACK_PATH,$BE_USER;
00074 
00075                         // Clean up settings:
00076                 $this->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU, t3lib_div::_GP('SET'), $this->MCONF['name']);
00077 
00078                         // Draw the header.
00079                 $this->doc = t3lib_div::makeInstance('noDoc');
00080                 $this->doc->backPath = $BACK_PATH;
00081                 $this->doc->form='<form action="" method="post">';
00082                 $this->doc->docType = 'xhtml_trans';
00083 
00084                         // JavaScript
00085                 $this->doc->JScode = $this->doc->wrapScriptTags('
00086                                 script_ended = 0;
00087                                 function jumpToUrl(URL) {       //
00088                                         window.location.href = URL;
00089                                 }
00090                         ');
00091 
00092                         // DBAL page title:
00093                 $this->content.=$this->doc->startPage($GLOBALS['LANG']->getLL('title'));
00094                 $this->content.=$this->doc->header($GLOBALS['LANG']->getLL('title'));
00095                 $this->content.=$this->doc->spacer(5);
00096                 $this->content.=$this->doc->section('',$this->doc->funcMenu('',t3lib_BEfunc::getFuncMenu(0,'SET[function]',$this->MOD_SETTINGS['function'],$this->MOD_MENU['function'])));
00097 
00098                         // Debug log:
00099                 switch($this->MOD_SETTINGS['function']) {
00100                         case 'info':
00101                                 $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('Cached_info'), $this->printCachedInfo());
00102                                 break;
00103                         case 'sqlcheck':
00104                                 $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('SQL_check'), $this->printSqlCheck());
00105                                 break;
00106                         case 0:
00107                                 $this->content.= $this->doc->section($GLOBALS['LANG']->getLL('Debug_log'), $this->printLogMgm());
00108                                 break;
00109                 }
00110 
00111                         // ShortCut
00112                 if ($BE_USER->mayMakeShortcut())        {
00113                         $this->content.=$this->doc->spacer(20).$this->doc->section('',$this->doc->makeShortcutIcon('id',implode(',',array_keys($this->MOD_MENU)),$this->MCONF['name']));
00114                 }
00115 
00116                 $this->content.=$this->doc->spacer(10);
00117         }
00118 
00124         function printContent() {
00125                 global $SOBE;
00126 
00127                 $this->content.=$this->doc->middle();
00128                 $this->content.=$this->doc->endPage();
00129                 echo $this->content;
00130         }
00131 
00137         function printSqlCheck()        {
00138                 $input = t3lib_div::_GP('tx_dbal');
00139 
00140                 $out = '
00141                         <form name="sql_check" action="index.php" method="post" enctype="'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['form_enctype'].'">
00142                         <script type="text/javascript">
00143 /*<![CDATA[*/
00144 function updateQryForm(s) {
00145         document.getElementById(\'tx-dbal-result\').style.display = \'none\';
00146         switch(s) {
00147         case \'SELECT\':
00148                 document.getElementById(\'tx-dbal-qryupdate\').style.display = \'none\';
00149                 document.getElementById(\'tx-dbal-qryfields\').style.display = \'table-row\';
00150                 document.getElementById(\'tx-dbal-qryinsertvalues\').style.display = \'none\';
00151                 document.getElementById(\'tx-dbal-qryupdatevalues\').style.display = \'none\';
00152                 document.getElementById(\'tx-dbal-qryfrom\').style.display = \'table-row\';
00153                 document.getElementById(\'tx-dbal-qryinto\').style.display = \'none\';
00154                 document.getElementById(\'tx-dbal-qrywhere\').style.display = \'table-row\';
00155                 document.getElementById(\'tx-dbal-qrygroup\').style.display = \'table-row\';
00156                 document.getElementById(\'tx-dbal-qryorder\').style.display = \'table-row\';
00157                 document.getElementById(\'tx-dbal-qrylimit\').style.display = \'table-row\';
00158         break;
00159         case \'INSERT\':
00160                 document.getElementById(\'tx-dbal-qryupdate\').style.display = \'none\';
00161                 document.getElementById(\'tx-dbal-qryfields\').style.display = \'none\';
00162                 document.getElementById(\'tx-dbal-qryinsertvalues\').style.display = \'table-row\';
00163                 document.getElementById(\'tx-dbal-qryupdatevalues\').style.display = \'none\';
00164                 document.getElementById(\'tx-dbal-qryfrom\').style.display = \'none\';
00165                 document.getElementById(\'tx-dbal-qryinto\').style.display = \'table-row\';
00166                 document.getElementById(\'tx-dbal-qrywhere\').style.display = \'table-row\';
00167                 document.getElementById(\'tx-dbal-qrygroup\').style.display = \'table-row\';
00168                 document.getElementById(\'tx-dbal-qryorder\').style.display = \'table-row\';
00169                 document.getElementById(\'tx-dbal-qrylimit\').style.display = \'table-row\';
00170         break;
00171         case \'UPDATE\':
00172                 document.getElementById(\'tx-dbal-qryupdate\').style.display = \'table-row\';
00173                 document.getElementById(\'tx-dbal-qryfields\').style.display = \'none\';
00174                 document.getElementById(\'tx-dbal-qryinsertvalues\').style.display = \'none\';
00175                 document.getElementById(\'tx-dbal-qryupdatevalues\').style.display = \'table-row\';
00176                 document.getElementById(\'tx-dbal-qryfrom\').style.display = \'none\';
00177                 document.getElementById(\'tx-dbal-qryinto\').style.display = \'none\';
00178                 document.getElementById(\'tx-dbal-qryupdate\').style.display = \'table-row\';
00179                 document.getElementById(\'tx-dbal-qrywhere\').style.display = \'table-row\';
00180                 document.getElementById(\'tx-dbal-qrygroup\').style.display = \'none\';
00181                 document.getElementById(\'tx-dbal-qryorder\').style.display = \'none\';
00182                 document.getElementById(\'tx-dbal-qrylimit\').style.display = \'none\';
00183         break;
00184         case \'DELETE\':
00185                 document.getElementById(\'tx-dbal-qryupdate\').style.display = \'none\';
00186                 document.getElementById(\'tx-dbal-qryfields\').style.display = \'none\';
00187                 document.getElementById(\'tx-dbal-qryinsertvalues\').style.display = \'none\';
00188                 document.getElementById(\'tx-dbal-qryupdatevalues\').style.display = \'none\';
00189                 document.getElementById(\'tx-dbal-qryfrom\').style.display = \'table-row\';
00190                 document.getElementById(\'tx-dbal-qryinto\').style.display = \'none\';
00191                 document.getElementById(\'tx-dbal-qrywhere\').style.display = \'table-row\';
00192                 document.getElementById(\'tx-dbal-qrygroup\').style.display = \'none\';
00193                 document.getElementById(\'tx-dbal-qryorder\').style.display = \'none\';
00194                 document.getElementById(\'tx-dbal-qrylimit\').style.display = \'none\';
00195         break;
00196         }
00197 }
00198 /*]]>*/
00199                                 </script>
00200             <table>
00201             <tr class="tableheader bgColor5"><th colspan="2">Easy SQL check</th></tr>
00202             <tr><td colspan="2">
00203             <select name="tx_dbal[QUERY]"size="1" onchange="updateQryForm(this.options[this.selectedIndex].value)">
00204              <option value="SELECT" '.($input['QUERY']=='SELECT'? 'selected="selected"' : '').'>SELECT</option>
00205              <option value="INSERT" '.($input['QUERY']=='INSERT'? 'selected="selected"' : '').'>INSERT</option>
00206              <option value="UPDATE" '.($input['QUERY']=='UPDATE'? 'selected="selected"' : '').'>UPDATE</option>
00207              <option value="DELETE" '.($input['QUERY']=='DELETE' ? 'selected="selected"' : '').'>DELETE</option>
00208             </select>
00209             </td></tr>
00210             <tr id="tx-dbal-qryupdate" style="display:none;"><td></td><td><input name="tx_dbal[UPDATE]" value="'.$input['UPDATE'].'" type="text" size="30" maxsize="100" /></td></tr>
00211             <tr id="tx-dbal-qryfields"><td></td><td><input name="tx_dbal[FIELDS]" value="'.$input['FIELDS'].'" type="text" size="30" maxsize="100" /></td></tr>
00212             <tr id="tx-dbal-qryinsertvalues" style="display:none;"><td></td><td><textarea name="tx_dbal[INSERTVALUES]" cols="30" rows="4">'.$input['INSERTVALUES'].'</textarea></td></tr>
00213             <tr id="tx-dbal-qryupdatevalues" style="display:none;"><th>SET</th><td><textarea name="tx_dbal[UPDATEVALUES]" cols="30" rows="4">'.$input['UPDATEVALUES'].'</textarea></td></tr>
00214             <tr id="tx-dbal-qryfrom"><th>FROM</th><td><input name="tx_dbal[FROM]" value="'.$input['FROM'].'" type="text" size="30" maxsize="100" /></td></tr>
00215             <tr id="tx-dbal-qryinto" style="display:none;"><th>INTO</th><td><input name="tx_dbal[INTO]" value="'.$input['INTO'].'" type="text" size="30" maxsize="100" /></td></tr>
00216             <tr id="tx-dbal-qrywhere"><th>WHERE</th><td><input name="tx_dbal[WHERE]" value="'.$input['WHERE'].'" type="text" size="30" maxsize="100" /></td></tr>
00217             <tr id="tx-dbal-qrygroup"><th>GROUP BY</th><td><input name="tx_dbal[GROUP]" value="'.$input['GROUP'].'" type="text" size="30" maxsize="100" /></td></tr>
00218             <tr id="tx-dbal-qryorder"><th>ORDER BY</th><td><input name="tx_dbal[ORDER]" value="'.$input['ORDER'].'" type="text" size="30" maxsize="100" /></td></tr>
00219             <tr id="tx-dbal-qrylimit"><th>LIMIT</th><td><input name="tx_dbal[LIMIT]" value="'.$input['LIMIT'].'" type="text" size="30" maxsize="100" /></td></tr>
00220                         <tr><td></td><td style="text-align:right;"><input type="submit" value="CHECK" /></td></tr>
00221                         <script type="text/javascript">
00222 /*<![CDATA[*/
00223 updateQryForm(\''.$input['QUERY'].'\');
00224 /*]]>*/
00225                                 </script>
00226                         ';
00227 
00228                 $out .= '<tr id="tx-dbal-result" class="bgColor4"><th>Result:</th><td>';
00229                 switch($input['QUERY']) {
00230                         case 'SELECT':
00231                                 $qry = $GLOBALS['TYPO3_DB']->SELECTquery($input['FIELDS'],$input['FROM'],$input['WHERE'],$input['GROUP'],$input['ORDER'],$input['LIMIT']);
00232                                 break;
00233                         case 'INSERT':
00234                                 $qry = $GLOBALS['TYPO3_DB']->INSERTquery($input['INTO'],$this->createFieldsValuesArray($input['INSERTVALUES']));
00235                                 break;
00236                         case 'UPDATE':
00237                                 $qry = $GLOBALS['TYPO3_DB']->UPDATEquery($input['UPDATE'],$input['WHERE'],$this->createFieldsValuesArray($input['UPDATEVALUES']));
00238                                 break;
00239                         case 'DELETE':
00240                                 $qry = $GLOBALS['TYPO3_DB']->DELETEquery($input['FROM'],$input['WHERE']);
00241                                 break;
00242                 }
00243                 $out .= '<pre>'.htmlspecialchars($qry).'</pre></td></tr>';
00244 
00245                 $out .= '
00246                         <tr class="tableheader bgColor5"><th colspan="2">RAW SQL check</th></tr>
00247                         <tr><td colspan="2" style="text-align:right;"><textarea name="tx_dbal[RAWSQL]" cols="60" rows="5">'.$input['RAWSQL'].'</textarea><br /><input type="submit" value="CHECK" /></td></tr>';
00248                 if(!empty($input['RAWSQL'])) {
00249                         $out .= '<tr class="bgColor4">';
00250                         $parseResult = $GLOBALS['TYPO3_DB']->SQLparser->parseSQL($input['RAWSQL']);
00251                         if (is_array($parseResult))     {
00252                                 $newQuery = $GLOBALS['TYPO3_DB']->SQLparser->compileSQL($parseResult);
00253                                 $testResult = $GLOBALS['TYPO3_DB']->SQLparser->debug_parseSQLpartCompare($input['RAWSQL'], $newQuery);
00254                                 if (!is_array($testResult))     {
00255                                         $out .= '<td colspan="2">'.$newQuery;
00256                                 } else {
00257                                         $out .= '<td colspan="2">'.htmlspecialchars($testResult[0]).'</td></tr>
00258                                         <tr><th>Error:</th><td style="border:2px solid #f00;">Input query did not match the parsed and recompiled query exactly (not observing whitespace):<br />'.htmlspecialchars($testResult[1]);
00259                                 }
00260                         } else {
00261                                 $out .= '<th>Result:</th><td style="border:2px solid #f00;">'.$parseResult;
00262                         }
00263                         $out .='</td></tr>';
00264                 }
00265 
00266                 $out .='</table></form>';
00267                 return $out;
00268         }
00269 
00279         function createFieldsValuesArray($in) {
00280                 $ret = array();
00281                 $in = explode(chr(10),$in);
00282                 foreach ($in as $v) {
00283                         $fv = explode('=',$v);
00284                         $ret[$fv[0]] = $fv[1];
00285                 }
00286 
00287                 return $ret;
00288         }
00289 
00299         function printCachedInfo()      {
00300                         // Get cmd:
00301                 if((string)t3lib_div::_GP('cmd') == 'clear') {
00302                         $GLOBALS['TYPO3_DB']->clearCachedFieldInfo();
00303                         $GLOBALS['TYPO3_DB']->cacheFieldInfo();
00304                 }
00305 
00306                 $out = '<table border="1" cellspacing="0"><caption>auto_increment</caption><tbody><tr><th>Table</th><th>Field</th></tr>';
00307                 ksort($GLOBALS['TYPO3_DB']->cache_autoIncFields);
00308                 foreach($GLOBALS['TYPO3_DB']->cache_autoIncFields as $table => $field) {
00309                         $out .= '<tr>';
00310                         $out .= '<td>'.$table.'</td>';
00311                         $out .= '<td>'.$field.'</td>';
00312                         $out .= '</tr>';
00313                 }
00314                 $out .= '</tbody></table>';
00315                 $out .= $this->doc->spacer(5);
00316                 $out .= '<table border="1" cellspacing="0"><caption>Primary keys</caption><tbody><tr><th>Table</th><th>Field(s)</th></tr>';
00317                 ksort($GLOBALS['TYPO3_DB']->cache_primaryKeys);
00318                 foreach($GLOBALS['TYPO3_DB']->cache_primaryKeys as $table => $field) {
00319                         $out .= '<tr>';
00320                         $out .= '<td>'.$table.'</td>';
00321                         $out .= '<td>'.$field.'</td>';
00322                         $out .= '</tr>';
00323                 }
00324                 $out .= '</tbody></table>';
00325                 $out .= $this->doc->spacer(5);
00326                 $out .= '<table border="1" cellspacing="0"><caption>Field types</caption><tbody><tr><th colspan="4">Table</th></tr><tr><th>Field</th><th>Type</th><th>Metatype</th><th>NOT NULL</th></th></tr>';
00327                 ksort($GLOBALS['TYPO3_DB']->cache_fieldType);
00328                 foreach($GLOBALS['TYPO3_DB']->cache_fieldType as $table => $fields) {
00329                         $out .= '<th colspan="4">'.$table.'</th>';
00330                         foreach($fields as $field => $data) {
00331                                 $out .= '<tr>';
00332                                 $out .= '<td>'.$field.'</td>';
00333                                 $out .= '<td>'.$data['type'].'</td>';
00334                                 $out .= '<td>'.$data['metaType'].'</td>';
00335                                 $out .= '<td>'.$data['notnull'].'</td>';
00336                                 $out .= '</tr>';
00337                         }
00338                 }
00339                 $out .= '</tbody></table>';
00340 
00341                 $menu = '<a href="index.php?cmd=clear">CLEAR DATA</a><hr />';
00342 
00343                 return $menu.$out;
00344         }
00345 
00353         function printLogMgm()  {
00354 
00355                         // Disable debugging in any case...
00356                 $GLOBALS['TYPO3_DB']->debug = FALSE;
00357 
00358                         // Get cmd:
00359                 $cmd = (string)t3lib_div::_GP('cmd');
00360                 switch($cmd)    {
00361                         case 'flush':
00362                                 $res = $GLOBALS['TYPO3_DB']->exec_DELETEquery('tx_dbal_debuglog','');
00363                                 $res = $GLOBALS['TYPO3_DB']->exec_DELETEquery('tx_dbal_debuglog_where','');
00364                                 $outStr = 'Log FLUSHED!';
00365                                 break;
00366                         case 'joins':
00367                                 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('table_join,exec_time,query,script','tx_dbal_debuglog','table_join!=\'\'', 'table_join,script,exec_time,query');
00368 
00369                                         // Init vars in which to pick up the query result:
00370                                 $tableIndex = array();
00371                                 $tRows = array();
00372                                 $tRows[] = '
00373                                         <tr>
00374                                                 <td>Execution time</td>
00375                                                 <td>Table joins</td>
00376                                                 <td>Script</td>
00377                                                 <td>Query</td>
00378                                         </tr>';
00379 
00380                                 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))       {
00381                                         $tableArray = $GLOBALS['TYPO3_DB']->SQLparser->parseFromTables($row['table_join']);
00382 
00383                                                 // Create table name index:
00384                                         foreach($tableArray as $a)      {
00385                                                 foreach($tableArray as $b)      {
00386                                                         if ($b['table']!=$a['table'])   {
00387                                                                 $tableIndex[$a['table']][$b['table']]=1;
00388                                                         }
00389                                                 }
00390                                         }
00391 
00392                                                 // Create output row
00393                                         $tRows[] = '
00394                                                 <tr>
00395                                                         <td>'.htmlspecialchars($row['exec_time']).'</td>
00396                                                         <td>'.htmlspecialchars($row['table_join']).'</td>
00397                                                         <td>'.htmlspecialchars($row['script']).'</td>
00398                                                         <td>'.htmlspecialchars($row['query']).'</td>
00399                                                 </tr>';
00400                                 }
00401 
00402                                         // Printing direct joins:
00403                                 $outStr.= '<h4>Direct joins:</h4>'.t3lib_div::view_array($tableIndex);
00404 
00405 
00406                                         // Printing total dependencies:
00407                                 foreach($tableIndex as $priTable => $a) {
00408                                         foreach($tableIndex as $tableN => $v)   {
00409                                                 foreach($v as $tableP => $vv)   {
00410                                                         if ($tableP == $priTable)       {
00411                                                                 $tableIndex[$priTable] = array_merge($v, $a);
00412                                                         }
00413                                                 }
00414                                         }
00415                                 }
00416                                 $outStr.= '<h4>Total dependencies:</h4>'.t3lib_div::view_array($tableIndex);
00417 
00418                                         // Printing data rows:
00419                                 $outStr.= '
00420                                         <table border="1" cellspacing="0">'.implode('',$tRows).'
00421                                         </table>';
00422                                 break;
00423                         case 'errors':
00424 
00425                                 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('serdata,exec_time,query,script','tx_dbal_debuglog','errorFlag>0','','tstamp DESC');
00426 
00427                                 // Init vars in which to pick up the query result:
00428                                 $tRows = array();
00429                                 $tRows[] = '
00430                                         <tr>
00431                                                 <td>Execution time</td>
00432                                                 <td>Error data</td>
00433                                                 <td>Script</td>
00434                                                 <td>Query</td>
00435                                         </tr>';
00436 
00437                                 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))       {
00438                                         // Create output row
00439                                         $tRows[] = '
00440                                                 <tr>
00441                                                         <td>'.htmlspecialchars($row['exec_time']).'</td>
00442                                                         <td>'.t3lib_div::view_array(unserialize($row['serdata'])).'</td>
00443                                                         <td>'.htmlspecialchars($row['script']).'</td>
00444                                                         <td>'.htmlspecialchars($row['query']).'</td>
00445                                                 </tr>';
00446                                 }
00447 
00448                                 // Printing data rows:
00449                                 $outStr.= '
00450                                         <table border="1" cellspacing="0">'.implode('',$tRows).'
00451                                         </table>';
00452                                 break;
00453                         case 'parsing':
00454                                 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('query,serdata','tx_dbal_debuglog','errorFlag&2=2');
00455                                 $tRows = array();
00456                                 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))       {
00457                                         // Create output row
00458                                         $tRows[] = '
00459                                                 <tr>
00460                                                         <td>'.htmlspecialchars($row['query']).'</td>
00461                                                 </tr>';
00462                                 }
00463 
00464                                 // Printing data rows:
00465                                 $outStr.= '
00466                                         <table border="1" cellspacing="0">'.implode('',$tRows).'
00467                                         </table>';
00468                                 break;
00469                         case 'where':
00470                                 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('tstamp,script,tablename,whereclause','tx_dbal_debuglog_where','','','tstamp DESC');
00471                                 $tRows = array();
00472                                 $tRows[] = '
00473                                         <tr>
00474                                                 <td>Time</td>
00475                                                 <td>Script</td>
00476                                                 <td>Table</td>
00477                                                 <td>WHERE clause</td>
00478                                         </tr>';
00479                                 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))       {
00480                                         $tRows[] = '
00481                                                 <tr>
00482                                                         <td>'.t3lib_BEfunc::datetime($row['tstamp']).'</td>
00483                                                         <td>'.htmlspecialchars($row['script']).'</td>
00484                                                         <td>'.htmlspecialchars($row['tablename']).'</td>
00485                                                                 <td>'.str_replace(array('\'\'','""','IS NULL','IS NOT NULL'), array('<span style="background-color:#ff0000;color:#ffffff;padding:2px;font-weight:bold;">\'\'</span>','<span style="background-color:#ff0000;color:#ffffff;padding:2px;font-weight:bold;">""</span>','<span style="background-color:#00ff00;color:#ffffff;padding:2px;font-weight:bold;">IS NULL</span>','<span style="background-color:#00ff00;color:#ffffff;padding:2px;font-weight:bold;">IS NOT NULL</span>'), htmlspecialchars($row['whereclause'])).'</td>
00486                                                 </tr>';
00487                                 }
00488 
00489                                 $outStr = '
00490                                         <table border="1" cellspacing="0">'.implode('',$tRows).'
00491                                         </table>';
00492                                 break;
00493                         default:
00494 
00495                                 // Look for request to view specific script exec:
00496                                 $specTime = t3lib_div::_GP('specTime');
00497 
00498                                 if ($specTime)  {
00499                                         $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*','tx_dbal_debuglog','tstamp='.intval($specTime));
00500                                         $tRows = array();
00501                                         $tRows[] = '
00502                                                 <tr>
00503                                                         <td>Execution time</td>
00504                                                         <td>Error</td>
00505                                                         <td>Table joins</td>
00506                                                         <td>Data</td>
00507                                                         <td>Query</td>
00508                                                 </tr>';
00509                                         while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))       {
00510                                                 $tRows[] = '
00511                                                         <tr>
00512                                                                 <td>'.htmlspecialchars($row['exec_time']).'</td>
00513                                                                 <td>'.($row['errorFlag'] ? 1 : 0).'</td>
00514                                                                 <td>'.htmlspecialchars($row['table_join']).'</td>
00515                                                                 <td>'.t3lib_div::view_array(unserialize($row['serdata'])).'</td>
00516                                                                 <td>'.str_replace(array('\'\'','""','IS NULL','IS NOT NULL'), array('<span style="background-color:#ff0000;color:#ffffff;padding:2px;font-weight:bold;">\'\'</span>','<span style="background-color:#ff0000;color:#ffffff;padding:2px;font-weight:bold;">""</span>','<span style="background-color:#00ff00;color:#ffffff;padding:2px;font-weight:bold;">IS NULL</span>','<span style="background-color:#00ff00;color:#ffffff;padding:2px;font-weight:bold;">IS NOT NULL</span>'), htmlspecialchars($row['query'])).'</td>
00517                                                         </tr>';
00518                                         }
00519                                 } else {
00520                                         $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('tstamp,script, SUM(exec_time) as calc_sum, count(*) AS qrycount, MAX(errorFlag) as error','tx_dbal_debuglog','','tstamp,script','tstamp DESC');
00521                                         $tRows = array();
00522                                         $tRows[] = '
00523                                                 <tr>
00524                                                         <td>Time</td>
00525                                                         <td># of queries</td>
00526                                                         <td>Error</td>
00527                                                         <td>Time (ms)</td>
00528                                                         <td>Script</td>
00529                                                 </tr>';
00530                                         while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))       {
00531                                                 $tRows[] = '
00532                                                         <tr>
00533                                                                 <td>'.t3lib_BEfunc::datetime($row['tstamp']).'</td>
00534                                                                 <td>'.htmlspecialchars($row['qrycount']).'</td>
00535                                                                 <td>'.($row['error'] ? '<strong style="color:#f00">ERR</strong>' : '').'</td>
00536                                                                 <td>'.htmlspecialchars($row['calc_sum']).'</td>
00537                                                                 <td><a href="index.php?specTime='.intval($row['tstamp']).'">'.htmlspecialchars($row['script']).'</a></td>
00538                                                         </tr>';
00539                                         }
00540                                 }
00541                                 $outStr = '
00542                                         <table border="1" cellspacing="0">'.implode('',$tRows).'
00543                                         </table>';
00544 
00545                                 break;
00546                 }
00547 
00548                 $menu = '
00549                                         <a href="index.php?cmd=flush">FLUSH LOG</a> -
00550                                         <a href="index.php?cmd=joins">JOINS</a> -
00551                                         <a href="index.php?cmd=errors">ERRORS</a> -
00552                                         <a href="index.php?cmd=parsing">PARSING</a> -
00553                                         <a href="index.php">LOG</a> -
00554                                         <a href="index.php?cmd=where">WHERE</a> -
00555 
00556                                         <a href="'.htmlspecialchars(t3lib_div::linkThisScript()).'" target="tx_debuglog">[New window]</a>
00557                                         <hr />
00558                 ';
00559                 return $menu.$outStr;
00560         }
00561 }
00562 
00563 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/dbal/mod1/index.php']) {
00564         include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/dbal/mod1/index.php']);
00565 }
00566 
00567 
00568 
00569 
00570         // Make instance:
00571 $SOBE = t3lib_div::makeInstance('tx_dbal_module1');
00572 $SOBE->init();
00573 $SOBE->main();
00574 $SOBE->printContent();
00575 ?>