Documentation TYPO3 par Ameos

checkconnectionwizard.php

00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 2004 Robert Lemke (robert@typo3.org)
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 *
00017 *  This script is distributed in the hope that it will be useful,
00018 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00019 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020 *  GNU General Public License for more details.
00021 *
00022 *  This copyright notice MUST APPEAR in all copies of the script!
00023 ***************************************************************/
00024 
00044         // Build TYPO3 enviroment:
00045 $BACK_PATH='../../../typo3/';
00046 define('TYPO3_MOD_PATH', '../typo3conf/ext/adodb/');
00047 require ($BACK_PATH.'init.php');
00048 require ($BACK_PATH.'template.php');
00049 
00050         // Include ADODB library:
00051 require_once(t3lib_extMgm::extPath('adodb').'adodb/adodb.inc.php');
00052 
00053         // Include language labels:
00054 $LANG->includeLLFile('EXT:adodb/locallang_wizard.xml');
00055 
00063 class tx_adodb_checkconnectionwizard {
00064 
00065         function main() {
00066 
00067                 $content = '<html><body>';
00068                 $conf = t3lib_div::_GP('P');
00069 
00070                 $conf['md5ID'];
00071 
00072                 if ($conf['table'] == 'tx_datasources_datasource') {
00073                         $dsRecord = t3lib_beFunc::getRecord($conf['table'], intval($conf['uid']));
00074 
00075                         if (is_array ($dsRecord)) {
00076                                 $dsArr = t3lib_div::xml2array ($dsRecord['configuration']);
00077                                 $dsConf = $dsArr['data']['sDEF']['lDEF'];
00078 
00079                                 $content .= '<p>Trying to connect with Host / DSN <strong>'.htmlspecialchars($dsConf['field_host']['vDEF']).'</strong> with user <strong>'.htmlspecialchars($dsConf['field_username']['vDEF']).'</strong> ... ';
00080                                 $dbConn = &ADONewConnection($dsConf['field_dbtype']['vDEF']);
00081                                 $dbConn->PConnect($dsConf['field_host']['vDEF'], $dsConf['field_username']['vDEF'], $dsConf['field_password']['vDEF'], $dsConf['field_dbname']['vDEF']);
00082                                 $dbConn->SetFetchMode(ADODB_FETCH_ASSOC);
00083 
00084                                 $content .= $dbConn->ErrorMsg();
00085                                 if ($dbConn->_connectionID) {
00086                                         $content .= '</p>';
00087 
00088                                         $query = 'SELECT * FROM '.$dsConf['field_table']['vDEF'];
00089                                         $recordSet = &$dbConn->SelectLimit ($query, 150);
00090                                         if (!$recordSet) {
00091                                                 $content .= '<p>Query failed ('.htmlspecialchars($query).'):<br />';
00092                                                 $content .= $dbConn->ErrorMsg().'</p>';
00093                                         } else {
00094                                                 $content .= '<span style="color:green">successful!</span></p>';
00095                                                 $counter = 0;
00096                                                 $content .= '<p>Showing the first 150 entries from the result recordset:</p>';
00097                                                 $content .= '<table border="1">';
00098                                                 while (!$recordSet->EOF) {
00099                                                         $content .= '<tr>';
00100                                                         if ($counter == 0) {
00101                                                                 foreach (array_keys($recordSet->fields) as $key) {
00102                                                                         $content .= '<th>'.htmlspecialchars($key).'</th>';
00103                                                                 }
00104                                                                 $content .= '</tr><tr>';
00105                                                         }
00106                                                         foreach (array_values($recordSet->fields) as $value) {
00107                                                                 $content .= '<td>'.htmlspecialchars($value).'&nbsp;</td>';
00108                                                         }
00109                                                         $recordSet->MoveNext();
00110                                                         $counter++;
00111                                                         $content .= '</tr>';
00112                                                 }
00113                                                 $content .= '<table>';
00114                                         }
00115                                 }
00116                         } else {
00117                                 $content .= '<span style="color:red">failed!</span></p><p><strong>Error Message:</strong>'. $dbConn->ErrorMsg().'</p>';
00118                         }
00119                 }
00120 
00121                 $content .= '</body></html>';
00122                 echo ($content);
00123         }
00124 
00125 }
00126 
00127         // Make instance:
00128 $SOBE = t3lib_div::makeInstance('tx_adodb_checkconnectionwizard');
00129 
00130 $SOBE->main();
00131 
00132 ?>


Généré par Le spécialiste TYPO3 avec  doxygen 1.4.6