<?php
////////////////////////////////////////////////////////////////////////
// Breeze Website Builder
// Copyright EB Dynamics, Inc., Edward Lemmers, P.E.
// For licensing, see license.txt.
// 
// Revised: 2/10/2012	ELL
// Added table prefix handling.
//
	
	include ("check_session.php");
		
	$doc_root = getenv('DOCUMENT_ROOT');
	$doc_root_arr = explode("/", $doc_root);
	$cpanel_user_id = $doc_root_arr[2];
	$_SESSION['cpanel_user_id'] = $cpanel_user_id;
	
//	include "/home/" . $cpanel_user_id . "/public_html/connect/db_connection.php";
	
	//First check to see if file is already in database.
	$query = "SELECT `page_name` FROM `" . BWB_TABLE_PREFIX . "page_data`";
	$result = $bwb_dbh->query($query);
	$row_cnt = $result->rowCount();
	if ($row_cnt > 0)
	{
		echo <<<END
<html>
<head>
<title>Breeze Website Builder</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="css/wizard.css" type="text/css">
<link rel="stylesheet" href="../manage/theme/classic/manager.css" type="text/css">
<link rel="shortcut icon" href="images/favicon.ico" type="image/x-icon">
</head>
<body>
	<table align="center" width="80%">
		<tr>
			<td colspan="2">Warning! Your site already has content.  Running this wizard will apply changes to your site that will be very difficult to undo if you decide you do not want these changes.<br/><br/>What do you want to do?</td>
		</tr>
		<tr>
			<td width="10%">&nbsp;</td>
			<td style="padding-top:50px;">
            	<form name="frmSelectAction" method="post" action="wizard_step_1.php" enctype="multipart/form-data" >
            	<table width="100%" border="0">
                <tr><td rowspan="2" valign="top" style="vertical-align:top;">
				<div class='button_console_cancel' onClick="window.close();" style="width:150px;"><span class='button_console_text_w_icon'>Cancel</span></div>
                </td><td>
				<div class='button_console_save' onClick="document.forms['frmSelectAction'].submit();" style="width:200px;"><span class='button_console_text_w_icon'>Continue to Wizard</span></div>
                </td>
				</tr>
				<tr>
				<td>
				CPanel User ID:
                <input type="text" name="cuic" id="cuic" />
                </td></tr>
               </table>
               </form>
			</td>
		</tr>
	</table>
</body>
</html>

END;
		exit;
	}
	else
//		header("Location: wizard_step_1.php?cpanel_user_id_confirm=$cpanel_user_id");
		header("Location: wizard_step_1.php?cuic=$cpanel_user_id");
?>