Location: PHPKode > projects > Aratix > setup/mysql.inc.php
<?php
/*
** Aratix
** Version 0.2.2beta9 (Anubis)
**
** Autor: Manuel Burghammer
** E-Mail: hide@address.com
** Homepage: http://www.xitara.net
**
** File: mysql.inc.php - Version 0.2.2 build 9
** Position: /setup/
** Last Modified: 03.04.2006 - 23:11:34
*/
if($page == "mysql2"){
	$db = new Mysql;

	$content->assign("db_host", get('db_host'));
	$content->assign("db_port", get('db_port'));
	$content->assign("db_base", get('db_base'));
	$content->assign("db_pref", get('db_pref'));
	$content->assign("db_user", get('db_user'));
	$content->assign("db_pass", "********");

	$msg['connect'] = $db->connect(get('db_host'), get('db_user'), get('db_pass'));
	$msg['sel_db'] = $db->select_db(get('db_base'));
	$msg['create_table'] = $db->query("CREATE TABLE aratix_test (test VARCHAR(10) NOT NULL) TYPE = MYISAM");

	if($db->write("aratix_test", "test", "test") == 0)
		$msg['write'] = TRUE;
	else
		$msg['write'] = FALSE;

	$msg['read'] = $db->read("aratix_test", "test");
	$msg['update'] = $db->update("aratix_test", "test", "test2");
	$msg['delete'] = $db->delete("aratix_test", "test='test2'");
	$msg['delete_table'] = $db->query("DROP TABLE aratix_test");
	$msg['disconnect'] = $db->disconnect($db->connect_id);

	for($counter = 0; $counter < 9; $counter++){
		if($msg[key($msg)] == "" || $msg[key($msg)] == FALSE){
			$error_flag = TRUE;
			$error_text = "mysql_test";
		}
		next($msg);
	}
	if(!isset($error_flag)){
		$file = implode(file('mysql.conf'));

		$file = ereg_replace("{db_host}", get('db_host'), $file);
		$file = ereg_replace("{db_port}", get('db_port'), $file);
		$file = ereg_replace("{db_base}", get('db_base'), $file);
		$file = ereg_replace("{db_pref}", get('db_pref'), $file);
		$file = ereg_replace("{db_user}", get('db_user'), $file);
		$file = ereg_replace("{db_pass}", get('db_pass'), $file);

		$handle = fopen('../inc/mysql.conf.php', 'w');
		fwrite($handle, $file);
		fclose($handle);
		chmod('../inc/mysql.conf.php', 0644);

		if($handle)
			$content->assign("file_written_mysql", TRUE);
		else
			$error_flag = TRUE;
	}
	if(!isset($error_flag)){
		$file = implode(file('mysql.dump'));
		$file = ereg_replace("{prefix}", get('db_pref'), $file);

		$new_file = explode(";\n", $file);
		$lines = count($new_file);

		$db->connect(get('db_host'), get('db_user'), get('db_pass'));
		$db->select_db(get('db_base'));

		for($counter = 0; $counter < $lines; $counter++){
			if($new_file[$counter] != ""){
				$query = ereg_replace("{LANGUAGE}", get('language'), $new_file[$counter]);
				$mysql_error_msg[$counter]['rows'] = $db->query($query);

				if(!is_array($mysql_error_msg[$counter]))
					$error_flag = TRUE;
			}
		}
		if(isset($error_flag)){
			$content->assign("mysql_error", TRUE);
			$content->assign("mysql_errors", $mysql_error_msg);
		}
		else
			$content->assign("queries", count($mysql_error_msg));
	}
	$content->assign("msg", $msg);

	if(isset($error_flag)){
		$content->assign("error_flag", $error_flag);
	}
}
?>
Return current item: Aratix