[TASK] Update md5 checksums for system extensions
[Packages/TYPO3.CMS.git] / typo3 / sysext / adodb / checkconnectionwizard.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 2004-2011 Robert Lemke (robert@typo3.org)
6 * All rights reserved
7 *
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 *
17 * This script is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * This copyright notice MUST APPEAR in all copies of the script!
23 ***************************************************************/
24
25 /**
26 * Check connection wizard for ADO DB databases. For usage in a popup window.
27 *
28 * @author Robert Lemke <robert@typo3.org>
29 */
30
31 // Build TYPO3 enviroment:
32 $BACK_PATH='../../../typo3/';
33 define('TYPO3_MOD_PATH', 'sysext/adodb/');
34 require ($BACK_PATH.'init.php');
35 require ($BACK_PATH.'template.php');
36
37 // Include ADODB library:
38 require_once(t3lib_extMgm::extPath('adodb').'adodb/adodb.inc.php');
39
40 // Include language labels:
41 $LANG->includeLLFile('EXT:adodb/locallang_wizard.xml');
42
43 /**
44 * Script Class checking the connection to an ADODB handled database
45 *
46 * @author Robert Lemke <robert@typo3.org>
47 * @package TYPO3
48 * @subpackage adodb
49 */
50 class tx_adodb_checkconnectionwizard {
51
52 function main() {
53
54 $content = '<html><body>';
55 $conf = t3lib_div::_GP('P');
56
57 $conf['md5ID'];
58
59 if ($conf['table'] == 'tx_datasources_datasource') {
60 $dsRecord = t3lib_beFunc::getRecord($conf['table'], intval($conf['uid']));
61
62 if (is_array ($dsRecord)) {
63 $dsArr = t3lib_div::xml2array ($dsRecord['configuration']);
64 $dsConf = $dsArr['data']['sDEF']['lDEF'];
65
66 $content .= '<p>Trying to connect with Host / DSN <strong>'.htmlspecialchars($dsConf['field_host']['vDEF']).'</strong> with user <strong>'.htmlspecialchars($dsConf['field_username']['vDEF']).'</strong> ... ';
67 $dbConn = &ADONewConnection($dsConf['field_dbtype']['vDEF']);
68 $dbConn->PConnect($dsConf['field_host']['vDEF'], $dsConf['field_username']['vDEF'], $dsConf['field_password']['vDEF'], $dsConf['field_dbname']['vDEF']);
69 $dbConn->SetFetchMode(ADODB_FETCH_ASSOC);
70
71 $content .= $dbConn->ErrorMsg();
72 if ($dbConn->_connectionID) {
73 $content .= '</p>';
74
75 $query = 'SELECT * FROM '.$dsConf['field_table']['vDEF'];
76 $recordSet = &$dbConn->SelectLimit ($query, 150);
77 if (!$recordSet) {
78 $content .= '<p>Query failed ('.htmlspecialchars($query).'):<br />';
79 $content .= $dbConn->ErrorMsg().'</p>';
80 } else {
81 $content .= '<span style="color:green">successful!</span></p>';
82 $counter = 0;
83 $content .= '<p>Showing the first 150 entries from the result recordset:</p>';
84 $content .= '<table border="1">';
85 while (!$recordSet->EOF) {
86 $content .= '<tr>';
87 if ($counter == 0) {
88 foreach (array_keys($recordSet->fields) as $key) {
89 $content .= '<th>'.htmlspecialchars($key).'</th>';
90 }
91 $content .= '</tr><tr>';
92 }
93 foreach (array_values($recordSet->fields) as $value) {
94 $content .= '<td>'.htmlspecialchars($value).'&nbsp;</td>';
95 }
96 $recordSet->MoveNext();
97 $counter++;
98 $content .= '</tr>';
99 }
100 $content .= '<table>';
101 }
102 }
103 } else {
104 $content .= '<span style="color:red">failed!</span></p><p><strong>Error Message:</strong>'. $dbConn->ErrorMsg().'</p>';
105 }
106 }
107
108 $content .= '</body></html>';
109 echo ($content);
110 }
111
112 }
113
114 // Make instance:
115 $SOBE = t3lib_div::makeInstance('tx_adodb_checkconnectionwizard');
116
117 $SOBE->main();
118
119 ?>