Location: PHPKode > projects > Cancerbero - The watchdog of the ports > cancerbero-0.6/site/include/dbconnect.php
<?php

# Declaring vars

$host_db = "";
$user_db = "";
$pass_db = "";
$name_db = "";

# Reading config from file.

if ($file = fopen( "/etc/cancerbero/cancerbero.cfg",  "r")) { 
	while (!feof($file)) {
		$linea = fgets($file, 255);
		if (!(stristr($linea,'<') || stristr($linea,'>'))) {
			eval ($linea);
		}
	}
	fclose($file); // hemos terminado, cerramos el apuntador
} 

if ($user_db == "") {  //first time

	echo "
	<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN' 'http://www.w3.org/TR/html4/loose.dtd'>
	
	<html>
	<head>
	<TITLE>Cancerbero, the watchdog of the ports</TITLE>
	<LINK REL='SHORTCUT ICON' HREF='icons/cancerbero.ico'>
	<link href='include/smenustyles.css' type='text/css' rel='stylesheet'>
	</head>
	<body>
	<!-- http://www.wpdfd.com/editorial/simplemenus.htm-->
	<div id='page'>
	<div align='center'>
	<div class='row'>
		<a href='http://cancerbero.sf.net'><img title='Go to Cancerbero site!' src='icons/titulo-cancerbero.png' border='0' alt='Cancerbero'></a>
	</div>
	<hr>
	<table class='cancerbero' width = 600 border = 10>
	<tbody>
	<tr><h1>Wellcome to Canberbero initial configuration</h1><h2>Before use cancerbero, a database must be created. Please introduce the appropriate info.</h2></tr>";

	echo "<th><div align='center'><h1>Cancerbero Database Install</h1>";
	echo "
	<form action='first_install.php' method='post' onsubmit='return checkform(this);'>
	<p><b>Mysql administrator user:  </b>
	<input class='input' type='text' name='admin' value='root'> <a href='' onmouseover=\"return escape('Admin username of the Database Server. Default admin username is root.')\"><img src='icons/help.png' border='0'></a>
	<p><b>Mysql administrator password:  </b>
	<input class='input' type='password' name='pass_admin' value=''> <a href='' onmouseover=\"return escape('Admin password of the Database Server.')\"><img src='icons/help.png' border='0'></a>
	<p><b>Host of the GUI:  </b>
	<input class='input' type='text' name='source_host' value='localhost' maxlength=255> <a href='' onmouseover=\"return escape('Hostname of the GUI interface. Default hostname is localhost')\"><img src='icons/help.png' border='0'></a>
	<hr>

	<hr>
	<p><b>Database Name:  </b>
	<input class='input' type='text' name='name_db' value='$name_db' maxlength=255> <a href='' onmouseover=\"return escape('Name of the database. It will store all the information. Default name is cancerberodb.')\"><img src='icons/help.png' border='0'></a>
	<p><b>User of the database:  </b>
	<input class='input' type='text' name='user_db' value='cancerbero' maxlength=255> <a href='' onmouseover=\"return escape('User for access to cancerbero database. Default username is cancerbero.')\"><img src='icons/help.png' border='0'></a>
	<p><b>Password of the database:  </b>
	<input class='input' type='password' name='pass_db' value='' maxlength=255> <a href='' onmouseover=\"return escape('Password of the cancerbero user. Empty password is not allowed.')\"><img src='icons/help.png' border='0'></a>
	<p><b>Retype password of the database: </b>
	<input class='input' type='password' name='retype_pass_db' value='' maxlength=255>
	<p><b>Host of the database:  </b>
	<input class='input' type='text' name='host_db' value='$host_db' maxlength=255> <a href='' onmouseover=\"return escape('Hostname of the Database Server. Default hostname is localhost')\"><img src='icons/help.png' border='0'></a>
	<p><div align='center'><input class='lowred' type='submit' name='save' value='save_database'></div>
	</form>
	<p>
	";
	echo "</div>";
	echo "</th></tbody></table>";

	echo "<p>&nbsp;</div>
	<script language='JavaScript' type='text/javascript' src='include/wz_tooltip.js'></script>
	</body>
	</html>";



	exit;
}
$status_connect = mysql_connect($host_db, $user_db, $pass_db);
$status_select = mysql_select_db($name_db);



?>

Return current item: Cancerbero - The watchdog of the ports