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

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




if($task == "dosave") {
$field_title = $_POST['field_title'];
$field_description = $_POST['field_description'];
$categories_on = $_POST['categories_on'];
$recent_updates = $_POST['recent_updates'];

mysql_query("UPDATE bhost_admin SET field_title='$field_title', field_description='$field_description', categories_on='$categories_on', recent_updates='$recent_updates'");

echo $head;
echo "
<h2>$admin_weblogsettings1</h2>
$admin_weblogsettings2
<br><br>
<form action='admin_weblogsettings.php' method='POST'>
<input type='submit' class='button' value='$admin_weblogsettings3'>
<input type='hidden' name='task' value='main'>
</form>
";
echo $foot;
exit();
}





if($task == "addcat") {
echo $head;
echo "
<h2>$admin_weblogsettings4</h2>
<form action='admin_weblogsettings.php' method='POST'>
$admin_weblogsettings5<br><br>

$admin_weblogsettings6<br>
<input type='text' name='name' size='30' maxlength='30'><br><br>
<input class='button' type='submit' value='$admin_weblogsettings7'>
<input type='hidden' name='task' value='doaddcat'>
</form>
";
echo $foot;
exit();
}


if($task == "doaddcat") {
$name = str_replace("'", "&#39;", $_POST['name']);
  if(str_replace(" ", "", $name) == "") {
  echo $head;
  echo "<b>$admin_weblogsettings8</b><br>$admin_weblogsettings9";
  echo $foot;
  exit;
  }
mysql_query("INSERT INTO bhost_categories (name) VALUES ('$name')");
header("Location: admin_weblogsettings.php");
exit();
}


if($task == "editcat") {
if(isset($_GET['wc_id'])) { $wc_id = $_GET['wc_id']; } else { $wc_id = 0; }
$category = mysql_query("SELECT * FROM bhost_categories WHERE wc_id='$wc_id'");
if(mysql_num_rows($category) != 1) { header("Location: admin_weblogsettings.php"); exit(); }
$category_info = mysql_fetch_assoc($category);

echo $head;
echo "
<h2>$admin_weblogsettings10</h2>
<form action='admin_weblogsettings.php' method='POST'>
$admin_weblogsettings11<br><br>

$admin_weblogsettings6<br>
<input type='text' name='name' size='30' maxlength='30' value='$category_info[name]'><br><br>
<input class='button' type='submit' value='$admin_weblogsettings12'>
<input type='hidden' name='task' value='doeditcat'>
<input type='hidden' name='wc_id' value='$wc_id'>
</form>
";
echo $foot;
exit();
}


if($task == "doeditcat") {
$name = str_replace("'", "&#39;", $_POST['name']);
$wc_id = $_POST['wc_id'];
  if(str_replace(" ", "", $name) == "") {
  echo $head;
  echo "<b>$admin_weblogsettings8</b><br>$admin_weblogsettings9";
  echo $foot;
  exit;
  }
mysql_query("UPDATE bhost_categories SET name='$name' WHERE wc_id='$wc_id'");
header("Location: admin_weblogsettings.php");
exit();
}


if($task == "deletecat") {
if(isset($_GET['wc_id'])) { $wc_id = $_GET['wc_id']; } else { $wc_id = 0; }
$category = mysql_query("SELECT * FROM bhost_categories WHERE wc_id='$wc_id'");
if(mysql_num_rows($category) != 1) { header("Location: admin_weblogsettings.php"); exit(); }
$category_info = mysql_fetch_assoc($category);

echo $head;
echo "
<h2>$admin_weblogsettings13</h2>
$admin_weblogsettings14
<br><br>
<table cellpadding='0' cellspacing='0'>
<form action='admin_weblogsettings.php' method='POST'>
<tr>
<td>
<input class='button' type='submit' value='$admin_weblogsettings15'>&nbsp;
</td>
<input type='hidden' name='task' value='dodeletecat'>
<input type='hidden' name='wc_id' value='$wc_id'>
</form>
<form action='admin_weblogsettings.php' method='POST'>
<td>
<input class='button' type='submit' value='$admin_weblogsettings16'>
</td>
<input type='hidden' name='task' value='main'>
</form>
</tr></table>
";
echo $foot;
exit();
}



if($task == "dodeletecat") {
$wc_id = $_POST['wc_id'];
mysql_query("DELETE FROM bhost_categories WHERE wc_id='$wc_id'");
header("Location: admin_weblogsettings.php");
exit();
}






echo $head;

echo "
<h2>$admin_weblogsettings17</h2>
$admin_weblogsettings18
<br><br>

<form action='admin_weblogsettings.php' method='POST'>

<table width='100%' cellpadding='0' cellspacing='0' style='margin-top: 3px;'>
<tr><td class='header'>$admin_weblogsettings19</td></tr>
<tr>
<td class='box'>
$admin_weblogsettings20
<br><br>

<table cellpadding='5' cellspacing='0'>
<tr>
<td>&#149; $admin_weblogsettings36 &nbsp;</td>
<td>
<select style='width: 200px;' DISABLED>
<option>$admin_weblogsettings23</option>
</select>
</td>
</tr>

<tr>
<td>&#149; $admin_weblogsettings21 &nbsp;</td>
<td>
<select name='field_title' style='width: 200px;'>
<option value='3'"; if($admin_info[field_title] == "3") { echo " SELECTED"; } echo ">$admin_weblogsettings23</option>
<option value='2'"; if($admin_info[field_title] == "2") { echo " SELECTED"; } echo ">$admin_weblogsettings24</option>
<option value='1'"; if($admin_info[field_title] == "1") { echo " SELECTED"; } echo ">$admin_weblogsettings25</option>
<option value='0'"; if($admin_info[field_title] == "0") { echo " SELECTED"; } echo ">$admin_weblogsettings26</option>
</select>
</td>
</tr>

<tr>
<td>&#149; $admin_weblogsettings22 &nbsp;</td>
<td>
<select name='field_description' style='width: 200px;'>
<option value='3'"; if($admin_info[field_description] == "3") { echo " SELECTED"; } echo ">$admin_weblogsettings23</option>
<option value='2'"; if($admin_info[field_description] == "2") { echo " SELECTED"; } echo ">$admin_weblogsettings24</option>
<option value='1'"; if($admin_info[field_description] == "1") { echo " SELECTED"; } echo ">$admin_weblogsettings25</option>
<option value='0'"; if($admin_info[field_description] == "0") { echo " SELECTED"; } echo ">$admin_weblogsettings26</option>
</select>
</td>
</tr>

</table>

</td>
</tr>
</table>


<br>


<table width='100%' cellpadding='0' cellspacing='0' style='margin-top: 3px;'>
<tr><td class='header'>$admin_weblogsettings27</td></tr>
<tr>
<td class='box'>
$admin_weblogsettings28
<br><br>

<table cellpadding='0' cellspacing='0'>
<tr><td><input type='radio' name='categories_on' id='categories_on1' value='1'"; if($admin_info[categories_on] == "1") { echo " CHECKED"; } echo "></td><td><label for='categories_on1'>$admin_weblogsettings29</label></td></tr>
<tr><td><input type='radio' name='categories_on' id='categories_on0' value='0'"; if($admin_info[categories_on] == "0") { echo " CHECKED"; } echo "></td><td><label for='categories_on0'>$admin_weblogsettings30</label></td></tr>
</table>
<br>

$admin_weblogsettings31
<br><br>

<table cellpadding='0' cellspacing='0' style='margin-top: 5px; border-top: 1px solid #AAAAAA;'>
";

$categories = mysql_query("SELECT * FROM bhost_categories ORDER BY name");
if(mysql_num_rows($categories) == 0) {
  echo "
  <tr>
  <td class='list1' width='215' NOWRAP><b>$admin_weblogsettings32</b></td>
  </tr>
  ";
} else {
  while($category_info = mysql_fetch_assoc($categories)) {
    echo "
    <tr>
    <td class='list1' width='200' NOWRAP><b>$category_info[name]</b></td>
    <td class='stats2' NOWRAP><a href='admin_weblogsettings.php?task=editcat&wc_id=$category_info[wc_id]'>$admin_weblogsettings33</a> <font class='gray'>|</font> <a href='admin_weblogsettings.php?task=deletecat&wc_id=$category_info[wc_id]'>$admin_weblogsettings34</a></td>
    </tr>
    ";
  }
}

echo "
</table>

</td>
</tr>
</table>


<br>

<table width='100%' cellpadding='0' cellspacing='0' style='margin-top: 3px;'>
<tr><td class='header'>$admin_weblogsettings37</td></tr>
<tr>
<td class='box'>
$admin_weblogsettings38
<br><br>
<table cellpadding='0' cellspacing='0'>
<tr>
<td><b>$admin_weblogsettings39 &nbsp;</b></td>
<td>
<select name='recent_updates'>
<option value='0'"; if($admin_info[recent_updates] == 0) { echo " SELECTED"; } echo ">0</option>
<option value='1'"; if($admin_info[recent_updates] == 1) { echo " SELECTED"; } echo ">1</option>
<option value='2'"; if($admin_info[recent_updates] == 2) { echo " SELECTED"; } echo ">2</option>
<option value='3'"; if($admin_info[recent_updates] == 3) { echo " SELECTED"; } echo ">3</option>
<option value='4'"; if($admin_info[recent_updates] == 4) { echo " SELECTED"; } echo ">4</option>
<option value='5'"; if($admin_info[recent_updates] == 5) { echo " SELECTED"; } echo ">5</option>
<option value='10'"; if($admin_info[recent_updates] == 10) { echo " SELECTED"; } echo ">10</option>
<option value='20'"; if($admin_info[recent_updates] == 20) { echo " SELECTED"; } echo ">20</option>
</select>
</td>
<td><b>&nbsp; $admin_weblogsettings40</b></td>
</tr>
</table>

</td>
</tr>
</table>


<br>

<input type='submit' class='button' value='$admin_weblogsettings35'>
<input type='hidden' name='task' value='dosave'>
</form>
";


echo $foot;
?>