<?php
   

require '../Connections/telmanik_press.php';
require 'template/header.php';

$tables = array();

$q = mysql_query('SHOW TABLES');

while ($r = @mysql_fetch_array($q)) 
{
	$tables[] = $r[0];
}

@mysql_free_result($q);

if(in_array('settings', $tables)) 
{
	echo "<p class=\"table-already-exists\">";$translate->__('If you are doing fresh install, make sure the database is empty.');echo "</p>";
	
	echo "<form name='yesgo' method='POST' action=''>
	<input type='submit' class='button' name='submit' value='Retry Installing' />
	<input type='hidden' name='step' value='2' />
	<input type=\"hidden\" name=\"db_host\" value=\"$hostname_telmanik_press\" />
	<input type=\"hidden\" name=\"db_name\" value=\"$database_telmanik_press\" />
	<input type=\"hidden\" name=\"db_user\" value=\"$username_telmanik_press\" />
	<input type=\"hidden\" name=\"db_pass\" value=\"$password_telmanik_press\" />
	<input type=\"hidden\" name=\"action\" value=\"create_tables\" />
	</form>";

} 
else 
{
	require './library/sql_import.php';
	$sql_import = new Sql2Db('sql/telmanik_cms_press.sql');
	$sql_import->debug_filename = 'install';
	$sql_import->import();


	echo "<p class=\"tables-created\">"; $translate->__('Database has been loaded.'); echo "</p>
		<form action=\" completed.php?lang";echo $output; echo "\" METHOD=\"POST\">
		<input type=\"submit\" name=\"submit\" value=\""; $translate->__('Continue Installation >>'); echo "\" class=\"install_it\" />
		</form>";
}

require './template/footer.php';
