***/ class DB_MYSQL { public $db_conn; public $db_host; public $db_user; public $db_pass; public $db_xoops_db; public $db_xoops_tbl; public $db_phpbb_db; public $db_phpbb_tbl; /*** * Class Construct ***/ function __construct() { // Initialize configuration values $this->db_host = 'localhost'; $this->db_user = 'root'; $this->db_pass = ''; $this->db_xoops_db = 'xoops'; $this->db_xoops_tbl = 'xoops_'; $this->db_phpbb_db = 'phpBB'; $this->db_phpbb_tbl = 'phpbb_'; // Reinitialize configuration values $config = array('db_host', 'db_user', 'db_pass', 'db_xoops_db', 'db_xoops_tbl', 'db_phpbb_db', 'db_phpbb_tbl'); foreach ( $config as $param ) { if ( ! isset( $_SESSION[$param] ) ) { $_SESSION[$param] = $this->$param; } $_SESSION[$param] = isset($_POST[$param])?$_POST[$param]:$_SESSION[$param]; $this->$param = $_SESSION[$param]; } } /*** * Connect */ function connect() { // Connect to MySQL database $this->db_conn = mysql_connect( $this->db_host, $this->db_user, $this->db_pass ); if ( $this->db_conn ) { return true; } else { return false; } } /*** * DB Configuration */ function get_configForm( $disabled = '' ) { $htmlblock = array(); array_push( $htmlblock, // Common DB Configuration '

Common DB configuration:

', '
', '
Server:
', '
', '
Username:
', '
', '
Password:
', '
', '
', // Xoops Configuration '

Xoops configuration:

', '
', '
Xoops database name:
', '
', '
Xoops table prefix:
', '
', '
', // phpBB Configuration '

phpBB configuration:

', '
', '
Phpbb database name:
', '
', '
Phpbb table prefix:
', '
', '
'); return $htmlblock; } /*** * Query */ function query( $sql ) { $this->connect(); $result = mysql_query( $sql, $this->db_conn ); if ( $result ) { return $result; } else { return false; } } /*** * Check existance */ function check_existance( $name ) { switch ( $name ) { case 'phpbb': $check_dbname = $this->db_phpbb_db; $check_suffix = $this->db_phpbb_tbl; $check_tables = array('users', 'forums', 'topics', 'posts'); break; case 'xoops': $check_dbname = $this->db_xoops_db; $check_suffix = $this->db_xoops_tbl; $check_tables = array('users', 'bb_forums', 'bb_topics', 'bb_posts', 'bb_posts_text'); break; } $error = 0; $table_list = array(); // Check database existance if ( ! mysql_select_db( $check_dbname ) ) { $error++; } // Check tables existance else { $sql = 'SHOW TABLES FROM ' . $check_dbname . ';'; $result = $this->query( $sql ); while ( $row = mysql_fetch_row ($result) ) { array_push($table_list, $row[0]); } foreach ($check_tables as $tablename) { $tablename = $check_suffix . $tablename; if (in_array($tablename, $table_list) === false ) { $error++; } } } if ( $error == 0 ) { return true; } else { return false; } } /*** * Class Destruct ***/ function disconnect() { mysql_close( $this->db_conn ); } } $db = new DB_MYSQL; ?>