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
00044
00045 $BACK_PATH='../../../typo3/';
00046 define('TYPO3_MOD_PATH', 'sysext/adodb/');
00047 require ($BACK_PATH.'init.php');
00048 require ($BACK_PATH.'template.php');
00049
00050
00051 require_once(t3lib_extMgm::extPath('adodb').'adodb/adodb.inc.php');
00052
00053
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).' </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
00128 $SOBE = t3lib_div::makeInstance('tx_adodb_checkconnectionwizard');
00129
00130 $SOBE->main();
00131
00132 ?>