<?
$page = "admin_html.php";
include "admin_header.php"; 

if(isset($_POST['task'])) { $task = $_POST['task']; } else { $task = "main"; }




if($task == "dosave") {
$message = "";
$insert_tag = 0;

// GET EXTERNAL HTML AND SPLIT INTO HEADER AND FOOTER
$html_external = $_POST['html_external'];
if(!stristr($html_external, "<%PageContent%>")) { 
	$message = "$admin_html12"; 
} else {
	$html_external = spliti("<%PageContent%>", $html_external, 2);
	$html_external = str_replace("&lt;", "<", $html_external);
	$html_external_header = $html_external[0];
	$html_external_footer = $html_external[1];
}


// GET INTERNAL HTML AND SPLIT INTO HEADER AND FOOTER
$html_internal = $_POST['html_internal'];
if(!stristr($html_internal, "<%PageContent%>")) { 
	$message = "$admin_html15"; 
} else {
	$html_internal = spliti("<%PageContent%>", $html_internal, 2);
	$html_internal = str_replace("&lt;", "<", $html_internal);
	$html_internal_header = $html_internal[0];
	$html_internal_footer = $html_internal[1];
}


// SHOW SUCCESS MESSAGE AND SAVE CHANGES IF NO ERROR
if($message == "") {
mysql_query("UPDATE bhost_admin SET html_external_header='$html_external_header', html_external_footer='$html_external_footer', html_internal_header='$html_internal_header', html_internal_footer='$html_internal_footer'");
$insert_tag = 1;
$message = "<h2>$admin_html1</h2>$admin_html2";
}

echo $head;
echo "
$message
<br><br>
<form action='admin_html.php' method='POST'>
<input type='submit' class='button' value='$admin_html3'>
<input type='hidden' name='insert_tag' value='$insert_tag'>
</form>
";
echo $foot;
exit();
}









if($task == "restore") {
echo $head;
echo "
<h2>$admin_html4</h2>
$admin_html5
<br><br>
<form action='admin_html.php' method='POST'>
<input type='submit' name='submit' class='button' value='$admin_html6'>
<input type='submit' name='submit' class='button' value='$admin_html7'>
<input type='hidden' name='task' value='dorestore'>
</form>
";
echo $foot;
exit();
}








if($task == "dorestore") {
$submit = $_POST['submit'];

if($submit == "$admin_html7") {
header("Location: admin_html.php");
exit();
} else {

$default_external_head = "
<html>
<head>
<title>Blog Host</title>
<style type='text/css'>

/* GLOBAL */
body { background: #FFFFFF; margin: 0px; font-size: 8pt; font-family: verdana, arial, tahoma; color: #333333; }
div.content_top { padding: 10px; line-height: 13pt; }
div.content_bottom { padding: 10px; padding-top: 0px; line-height: 13pt; }
td { font-size: 8pt; font-family: verdana, arial, tahoma; color: #333333; }
td.list { background: #FFFFFF; padding: 7px; border: 1px solid #AAAAAA; border-top: none; }
td.header { border: 1px solid #AAAAAA; padding: 7px; padding-bottom: 7px; background-color: #DDDDDD; background-image: url(../images/header_bg2.gif); background-repeat: repeat-x; font-weight: bold; }
td.header2 { border: 1px solid #AAAAAA; border-right: none; padding: 7px; padding-bottom: 7px; background-color: #DDDDDD; background-image: url(../images/header_bg2.gif); background-repeat: repeat-x; font-weight: bold; }
td.empty { background: #F5F5F5; padding: 7px; border: 1px solid #AAAAAA; }
td.advanced { padding: 5px; background: #EEEEEE; border-bottom: 1px solid #AAAAAA; }
table.box { width: 130px; border: 1px solid #666666; border-bottom: 2px solid #666666; background: #F5F5F5; }
img.icon { vertical-align: middle; }
img.avatar { border: 1px solid #666666; }
img.thumb { border: 1px solid #CCCCCC; }
blockquote { margin-left: 20px; }
ul { margin-bottom: 0px; margin-top: 0px; margin-left: 25px; }

/* FORMS */
form { margin: 0px; }
td.form { border: 1px solid #DDDDDD; padding: 15px; vertical-align: top; line-height: 13pt; }
table.form { border: 1px solid #DDDDDD; border-left: none; border-bottom: none; }
td.form1 { border-bottom: 1px solid #DDDDDD; border-left: 4px solid #DDDDDD; padding: 13px; padding-top: 16px; font-weight: bold; vertical-align: top; }
td.form1error { border-bottom: 1px solid #DDDDDD; border-left: 4px solid #FF0000; padding: 13px; padding-top: 16px; font-weight: bold; vertical-align: top; }
td.form2 { border-bottom: 1px solid #DDDDDD; padding: 13px; vertical-align: top; }
div.help { color: #666666; padding-top: 3px; font-weight: normal; }
font.code { font-family: arial, tahoma, sans-serif; font-size: 8pt; font-weight: bold; }
font.error { color: #FF0000; }
font.success { color: #5B8C29; font-weight: bold; }
img.error { vertical-align: middle; }
img.success { vertical-align: middle; }

/* ALTERNATING LISTS */
td.list1a { background: #FFFFFF; padding: 7px; border: 1px solid #CCCCCC; border-top: none; border-right: none; }
td.list1b { background: #FFFFFF; padding: 7px; border: 1px solid #CCCCCC; border-top: none; }
td.list2a { background: #F5F5F5; padding: 7px; border: 1px solid #CCCCCC; border-top: none; border-right: none; }
td.list2b { background: #F5F5F5; padding: 7px; border: 1px solid #CCCCCC; border-top: none; }

/* FONTS */
h1 { margin-left: 3px; font-family: Georgia, \"Trebuchet MS\", verdana, arial, tahoma; margin-bottom: 2px; font-size: 18pt; }
h2 { font-family: Georgia, \"Trebuchet MS\", verdana, arial, tahoma; margin-bottom: 2px; margin-top: 0px; font-size: 12pt; }
font.disabled { color: #666666; }
font.gray { color: #666666; }
font.bold { font-weight: bold; font-size: 8pt; \"Trebuchet MS\", verdana, sans-serif; }
font.stats { font-size: 7pt; font-family: arial, verdana, tahoma; }
font.url { font-size: 9pt; font-weight: normal; }

/* INPUT FIELDS */
input.button { background: #DDDDDD; color: #444444; font-size: 8pt; padding: 3px; font-weight: bold; font-family: verdana, arial, tahoma; }
input.sbutton { background-color: #DDDDDD; font-size: 8pt; font-weight: bold; font-family: verdana, arial, tahoma; }
input.text { font-family: arial, verdana, tahoma, sans-serif; padding-left: 2px; }
textarea, select { font-family: arial, verdana, tahoma; margin-top: 1px; font-size: 10pt; }
select.small { font-size: 8pt; margin-left: 4px; }
input.status { border: none; background: clear; padding-left: 8px; font-size: 8pt; font-weight: bold; font-family: verdana, arial, tahoma; }

/* NORMAL LINKS */
a:link { color: #000066; }
a:visited { color: #000066; }
a:hover { color: #000066; }

/* VIEW PROFILE PAGE */
img.profile_avatar { border: 1px solid #666666; margin-top: 1px; margin-bottom: 10px; }
table.profile { width: 600px; border: 1px solid #AAAAAA; margin-top: 5px; }
td.profile { padding: 7px; line-height: 17px; color: #333333; background-color: #F5F5F5; background-image: url(../images/bg_bar.gif); background-repeat: repeat-x; }
td.profile2 { padding: 7px; background-color: #F5F5F5; background-image: url(../images/bg_bar.gif); background-repeat: repeat-x; }
td.profile3 { padding: 7px; border-top: 1px solid #CCCCCC; background-color: #F5F5F5; }
td.profile_description { padding: 7px; line-height: 17px; padding-top: 0px; background: #F5F5F5; }
td.profile_category { padding: 7px; padding-top: 0px; background: #F5F5F5; font-style: italic; }
td.profile_members { padding: 7px; padding-top: 0px; background: #F5F5F5; }
div.profile_avatar { width: 150px; padding: 7px; border: 1px solid #AAAAAA; background: #FFFFFF; float: right; text-align: center; }
font.profile_blogstat { font-weight: bold; }

/* CHOOSE TEMPLATE PAGE */
img.template { border: 1px solid #AAAAAA; margin-top: 3px; }
div.templatebox { float: left; padding: 5px; padding-top: 2px; margin-top: 3px; background: #FFFFFF; border: 1px solid #666666; }
div.float { float: left; margin-top: 15px; margin-right: 15px; }
td.templatename { padding-top: 5px; }

/* PHOTO ALBUM */
div.album_viewpic1 { text-align: center; padding-top: 20px; }
div.albumpic { float: left; border: 1px solid #AAAAAA; padding: 5px; margin-right: 10px; margin-bottom: 10px; width: 200px; height: 200px; background-image: url(./images/album_bg.gif); background-repeat: no-repeat; vertical-align: middle; text-align: center; }
td.album_viewpic2 { border: 1px solid #AAAAAA; padding: 20px; }

/* BROWSE AND SEARCH */
td.result1 { padding: 6px; line-height: 12pt; }
td.result2 { padding: 6px; line-height: 12pt;}

</style>
</head>
<body>
<br>
";

$default_external_foot = "
</body>
</html>
";

$default_internal_head = "
<html>
<head>
<title>Blog Host</title>
<style type='text/css'>

/* MENUS */
td.title { background-color: #B2D7FE; background-image: url(../images/menu_title_bg.gif); background-repeat: no-repeat; color: #1C6192; font-size: 30pt; font-family: \"Trebuchet MS\", verdana, arial, sans-serif; padding: 10px; padding-top: 20px; padding-bottom: 0px; }
td.tab, td.menu_rightside { background-color: #245688; background-image: url(../images/menu_topbar_bg.gif); background-repeat: repeat-x; border-top: 1px solid #FFFFFF; font-size: 8pt; font-family: verdana, arial, sans-serif; padding: 7px; padding-left: 13px; padding-right: 13px; }
td.tab1, td.menu_rightside1 { background-color: #245688; background-image: url(../images/menu_topbar_bg.gif); background-repeat: repeat-x; border-top: 1px solid #FFFFFF; font-size: 8pt; font-family: verdana, arial, sans-serif; border-bottom: 1px solid #EEEEEE; padding: 7px; padding-left: 13px; padding-right: 13px; }
td.tab2 { background-color: #487EB3; background-image: url(../images/menu_tab_bg.gif); background-repeat: repeat-x; padding-left: 13px; padding-right: 13px; border-left: 1px solid #7CA1C4; border-right: 1px solid #7CA1C4; }
td.submenu { background-color: #487EB3; background-image: url(../images/menu_bottombar_bg.gif); background-repeat: repeat-x; font-size: 8pt; font-family: verdana, arial, sans-serif; padding: 7px; padding-left: 13px; }
td.menu_rightside, td.menu_rightside1 { text-align: right; color: #FFFFFF; }
div.shadow { background-image: url(../images/shadow.gif); background-repeat: repeat-x; }
a.menu:link { color: #FFFFFF; font-weight: bold; text-decoration: none; }
a.menu:visited { color: #FFFFFF; font-weight: bold; text-decoration: none; }
a.menu:hover { color: #FFFFFF; font-weight: bold; text-decoration: underline; }
a.sidemenu:link { color: #EEEEEE; text-decoration: none; }
a.sidemenu:visited { color: #EEEEEE; text-decoration: none; }
a.sidemenu:hover { color: #FFFFFF; text-decoration: underline; }
a.title:link { color: #1C6192; text-decoration: none; }
a.title:visited { color: #1C6192; text-decoration: none; }
a.title:hover { color: #3D81B2; text-decoration: none; }
font.title_editing { font-size: 14pt; }

/* GLOBAL */
body { background: #FFFFFF; margin: 0px; font-size: 8pt; font-family: verdana, arial, tahoma; color: #333333; }
div.content_top { padding: 10px; line-height: 13pt; }
div.content_bottom { padding: 10px; padding-top: 0px; line-height: 13pt; }
td { font-size: 8pt; font-family: verdana, arial, tahoma; color: #333333; }
td.list { background: #FFFFFF; padding: 7px; border: 1px solid #AAAAAA; border-top: none; }
td.header { border: 1px solid #AAAAAA; padding: 7px; padding-bottom: 7px; background-color: #DDDDDD; background-image: url(../images/header_bg2.gif); background-repeat: repeat-x; font-weight: bold; }
td.header2 { border: 1px solid #AAAAAA; border-right: none; padding: 7px; padding-bottom: 7px; background-color: #DDDDDD; background-image: url(../images/header_bg2.gif); background-repeat: repeat-x; font-weight: bold; }
td.empty { background: #F5F5F5; padding: 7px; border: 1px solid #AAAAAA; }
td.advanced { padding: 5px; background: #EEEEEE; border-bottom: 1px solid #AAAAAA; }
table.box { width: 130px; border: 1px solid #666666; border-bottom: 2px solid #666666; background: #F5F5F5; }
img.icon { vertical-align: middle; }
img.avatar { border: 1px solid #666666; }
img.thumb { border: 1px solid #CCCCCC; }
blockquote { margin-left: 20px; }
ul { margin-bottom: 0px; margin-top: 0px; margin-left: 25px; }

/* FORMS */
form { margin: 0px; }
td.form { border: 1px solid #DDDDDD; padding: 15px; vertical-align: top; line-height: 13pt; }
table.form { border: 1px solid #DDDDDD; border-left: none; border-bottom: none; }
td.form1 { border-bottom: 1px solid #DDDDDD; border-left: 4px solid #DDDDDD; padding: 13px; padding-top: 16px; font-weight: bold; vertical-align: top; }
td.form1error { border-bottom: 1px solid #DDDDDD; border-left: 4px solid #FF0000; padding: 13px; padding-top: 16px; font-weight: bold; vertical-align: top; }
td.form2 { border-bottom: 1px solid #DDDDDD; padding: 13px; vertical-align: top; }
div.help { color: #666666; padding-top: 3px; font-weight: normal; }
font.code { font-family: arial, tahoma, sans-serif; font-size: 8pt; font-weight: bold; }
font.error { color: #FF0000; }
font.success { color: #5B8C29; font-weight: bold; }
img.error { vertical-align: middle; }
img.success { vertical-align: middle; }

/* ALTERNATING LISTS */
td.list1a { background: #FFFFFF; padding: 7px; border: 1px solid #CCCCCC; border-top: none; border-right: none; }
td.list1b { background: #FFFFFF; padding: 7px; border: 1px solid #CCCCCC; border-top: none; }
td.list2a { background: #F5F5F5; padding: 7px; border: 1px solid #CCCCCC; border-top: none; border-right: none; }
td.list2b { background: #F5F5F5; padding: 7px; border: 1px solid #CCCCCC; border-top: none; }

/* FONTS */
h1 { margin-left: 3px; font-family: Georgia, \"Trebuchet MS\", verdana, arial, tahoma; margin-bottom: 2px; font-size: 18pt; }
h2 { font-family: Georgia, \"Trebuchet MS\", verdana, arial, tahoma; margin-bottom: 2px; margin-top: 0px; font-size: 12pt; }
font.disabled { color: #666666; }
font.gray { color: #666666; }
font.bold { font-weight: bold; font-size: 8pt; \"Trebuchet MS\", verdana, sans-serif; }
font.stats { font-size: 7pt; font-family: arial, verdana, tahoma; }
font.url { font-size: 9pt; font-weight: normal; }

/* INPUT FIELDS */
input.button { background: #DDDDDD; color: #444444; font-size: 8pt; padding: 3px; font-weight: bold; font-family: verdana, arial, tahoma; }
input.sbutton { background-color: #DDDDDD; font-size: 8pt; font-weight: bold; font-family: verdana, arial, tahoma; }
input.text { font-family: arial, verdana, tahoma, sans-serif; padding-left: 2px; }
textarea, select { font-family: arial, verdana, tahoma; margin-top: 1px; font-size: 10pt; }
select.small { font-size: 8pt; margin-left: 4px; }
input.status { border: none; background: clear; padding-left: 8px; font-size: 8pt; font-weight: bold; font-family: verdana, arial, tahoma; }

/* NORMAL LINKS */
a:link { color: #000066; }
a:visited { color: #000066; }
a:hover { color: #000066; }

/* MY WEBLOGS PAGE */
table.webloglist { border: 1px solid #CCCCCC; margin-top: 6px; }
td.webloglist1 { padding: 7px; background-color: #F5F5F5; background-image: url(../images/bg_bar.gif); background-repeat: repeat-x; }
td.webloglist2 { border-top: 1px solid #DDDDDD; padding: 7px; background-color: #F5F5F5; }
div.myweblogs_box { padding: 7px; margin-top: 6px; border: 1px solid #CCCCCC; background-color: #F5F5F5; background-image: url(../images/bg_bar.gif); background-repeat: repeat-x; }

/* SEND PINGS PAGE */
table.pingslist { border: 1px solid #CCCCCC; margin-top: 6px; }
td.pingslist1 { padding: 7px; background: #F5F5F5; }
td.pingslist2 { border-top: 1px solid #DDDDDD; padding: 7px; background: #F5F5F5; }

/* SEARCH RESULTS PAGE */
td.result1 { padding: 5px; padding-left: 0px; width: 100px; height: 100px; }
td.result2 { padding: 5px; line-height: 12pt; }

/* CHOOSE TEMPLATE PAGE */
img.template { border: 1px solid #AAAAAA; margin-top: 3px; }
div.templatebox { float: left; padding: 5px; padding-top: 2px; margin-top: 3px; background: #FFFFFF; border: 1px solid #666666; }
div.float { float: left; margin-top: 15px; margin-right: 15px; }
td.templatename { padding-top: 5px; }

/* EDIT TEMPLATE PAGE */
textarea.edit_template { margin-top: 10px; width: 100%; font-family: \"Courier New\", courier, arial, tahoma; }

/* GENERAL SETTINGS PAGE */
textarea.settings { width: 413px; font-size: 9pt; font-family: \"Courier New\"; }

/* ADD/EDIT ENTRY PAGES */
table.entryform { border: 1px solid #CCCCCC; border-bottom: none; width: 100%; }
td.entryform1 { border-bottom: 1px solid #CCCCCC; padding: 8px; font-weight: bold; }
td.entryform2 { border-bottom: 1px solid #CCCCCC; padding: 8px; }
table.advancedoptions { width: 100%; border: 1px solid #CCCCCC; border-top: 4px solid #CCCCCC; }
td.advancedoptions { padding: 6px; padding-left: 8px; background: #F5F5F5; }
div.advancedoptions { display: none; margin-top: 3px; border-top: 3px solid #CCCCCC; }
table.composer { width: 600px; }

/* FILE UPLOADS */
table.files { width: 450px; border: 1px solid #CCCCCC; border-bottom: none; background-image: url(../images/files_bg.gif); background-repeat: repeat-y; }
td.file { padding: 5px; border-bottom: 1px solid #CCCCCC; }
td.file1 { padding: 5px; padding-left: none; line-height: 13pt; }
div.fileoptions { margin-top: 8px; }
input.upload_status { background: clear; border: none; font-size: 8pt; font-weight: bold; font-family: verdana, serif; }

/* PM INBOX */
table.message { border: 1px solid #CCCCCC; }
td.message_top1 { padding: 10px; line-height: 13pt; }
td.message_top2 { padding: 10px; width: 300px; line-height: 13pt; }
td.message { border-top: 1px solid #CCCCCC; padding: 10px; line-height: 13pt; }
td.messages_none { padding: 7px; border: 1px solid #AAAAAA; }

/* HELP PAGES */
ul.variablelist { line-height: 15pt; }

</style>
</head>
<body>
";

$default_internal_foot = "
</body>
</html>
";

$default_external_head = str_replace("'", "\\'", $default_external_head);
$default_external_foot = str_replace("'", "\\'", $default_external_foot);

$default_internal_head = str_replace("'", "\\'", $default_internal_head);
$default_internal_foot = str_replace("'", "\\'", $default_internal_foot);

mysql_query("UPDATE bhost_admin SET html_external_header='$default_external_head', html_external_footer='$default_external_foot', html_internal_header='$default_internal_head', html_internal_footer='$default_internal_foot'");

echo $head;
echo "
<h2>$admin_html9</h2>
$admin_html10
<br><br>
<form action='admin_html.php' method='POST'>
<input type='submit' class='button' value='$admin_html3'>
</form>
";
echo $foot;
}
}






if($task == "main") {

if(isset($_POST['insert_tag'])) { $insert_tag = $_POST['insert_tag']; } else { $insert_tag = 1; }

$settings = mysql_fetch_assoc(mysql_query("SELECT html_external_header, html_external_footer, html_internal_header, html_internal_footer FROM bhost_admin"));

$html_external_header = str_replace("<", "&lt;", $settings[html_external_header]);
$html_external_footer = str_replace("<", "&lt;", $settings[html_external_footer]);
$html_internal_header = str_replace("<", "&lt;", $settings[html_internal_header]);
$html_internal_footer = str_replace("<", "&lt;", $settings[html_internal_footer]);

if($insert_tag != 0) { 
	$html_external = "$html_external_header<%PageContent%>$html_external_footer";
	$html_internal = "$html_internal_header<%PageContent%>$html_internal_footer";
} else {
	$html_external = "$html_external_header"."$html_external_footer";
	$html_internal = "$html_internal_header"."$html_internal_footer";
}

echo $head;
echo "
<h2>$admin_html1</h2>
$admin_html11

<br><br>

<form action='admin_html.php' method='POST'>
$admin_html13<br>
<textarea wrap='off' rows='25' cols='60' name='html_external' style='font-family: \"Courier New\", verdana, arial; font-size: 8pt; width: 100%; margin-top: 3px;'>$html_external</textarea>
<br>

$admin_html14<br>
<textarea wrap='off' rows='25' cols='60' name='html_internal' style='font-family: \"Courier New\", verdana, arial; font-size: 8pt; width: 100%; margin-top: 3px;'>$html_internal</textarea>
<br>

<table cellpadding='0' cellspacing='0'>
<tr>
<td><input type='submit' class='button' value='$admin_html17'>&nbsp;</td>
<input type='hidden' name='task' value='dosave'>
</form>
<form action='admin_html.php' method='POST'>
<td><input type='submit' class='button' value='$admin_html6'></td>
<input type='hidden' name='task' value='restore'>
</form>
</tr>
</table>
</form>
";
echo $foot;
}
?>