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

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


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

if($submit == "$admin_groups70") { $task = "newgroup"; }
elseif($submit == "$admin_groups71") { 
$default_group = $_POST['default_group'];
mysql_query("UPDATE bhost_groups SET default_group='0'");
mysql_query("UPDATE bhost_groups SET default_group='1' WHERE g_id='$default_group'");

$groups = mysql_query("SELECT * FROM bhost_groups ORDER BY group_name");
while($group_info = mysql_fetch_assoc($groups)) {
 $var = "show_group_".$group_info[g_id];
 if($_POST[$var] == "1") { mysql_query("UPDATE bhost_groups SET show_group='1' WHERE g_id='$group_info[g_id]'"); } else { mysql_query("UPDATE bhost_groups SET show_group='0' WHERE g_id='$group_info[g_id]'"); }
}

header("Location: admin_groups.php");
exit();
}}


if($task == "edit" OR $task == "newgroup") {
if(isset($_GET['g_id'])) { $g_id = $_GET['g_id']; } elseif(isset($_POST['g_id'])) { $g_id = $_POST['g_id']; } else { $g_id = ""; }
echo $head;

if($task == "edit") { 
if(mysql_num_rows(mysql_query("SELECT g_id FROM bhost_groups WHERE g_id='$g_id'")) != 1) { exit(); }
$group_info = mysql_fetch_assoc(mysql_query("SELECT * FROM bhost_groups WHERE g_id='$g_id'"));
$title = "$admin_groups54"; 
$description = "$admin_groups55";
$submit = "$admin_groups56";
}

elseif($task == "newgroup") {
$group_info[g_id] = "";
$group_info[group_name] = "";
$group_info[group_description] = "";
$group_info[default_group] = "0";
$group_info[allow_comments] = "1";
$group_info[allow_friends] = "1";
$group_info[allow_privacy] = "1";
$group_info[allow_profileprivacy] = "1";
$group_info[allow_mailinglist] = "1";
$group_info[allow_rss] = "1";
$group_info[allow_podcast] = "1";
$group_info[allow_moblogging] = "0";
$group_info[allow_album] = "1";
$group_info[album_extensions] = "jpeg,jpg,gif,bmp,png";
$group_info[allow_podcastfiles] = "1";
$group_info[podcast_extensions] = "mp3";
$group_info[allow_uploads] = "1";
$group_info[uploads_extensions] = "jpeg,jpg,gif,bmp,png";
$group_info[uploads_space] = "1024";
$group_info[allow_banning] = "1";
$group_info[allow_pinging] = "1";
$group_info[allow_trackback] = "1";
$group_info[allow_entry_cat] = "1";
$group_info[allow_pms] = "1";
$group_info[pms_max] = "50";
$group_info[allow_edittemplate] = "1";
$group_info[allow_language] = "0";
$group_info[allow_multiauthor] = "0";
$group_info[num_weblogs] = "1";
$group_info[show_ad] = "0";
$group_info[html_ad] = "";
$group_info[html_ad_bottom] = "";
$group_info[news] = "";
$group_info[templates] = "";
$count = 0;
$templates = mysql_query("SELECT t_id FROM bhost_templates");
$num_templates = mysql_num_rows($templates);
while($template_info = mysql_fetch_assoc($templates)) {
 $count = $count+1;
 $group_info[templates] .= "$template_info[t_id]";
 if($count != $num_templates) { $group_info[templates] .= ","; }
}

$title = "$admin_groups57";
$description = "$admin_groups58";
$submit = "$admin_groups59";
}

echo "
<h2>$title</h2>
$description 
<br><br>

<form action='admin_groups.php' method='POST' name='info'>

<table width='100%' cellpadding='0' cellspacing='0' style='margin-top: 3px;'>
<tr>
<td class='header'>$admin_groups120</td></tr>
<tr>
<td class='box'>
$admin_groups119
<br><br>
$admin_groups49<br>
<input type='text' class='text' size='30' maxlength='30' name='group_name' style='margin-top: 1px;' value='$group_info[group_name]'>
<br><br>
$admin_groups74<br>
<textarea name='group_description' rows='5' cols='60' style='width: 100%;'>$group_info[group_description]</textarea>
</td>
</tr>
</table>

<br>

<table width='100%' cellpadding='0' cellspacing='0' style='margin-top: 3px;'>
<tr>
<td class='header'>$admin_groups91</td></tr>
<tr>
<td class='box'>
$admin_groups92
<br><br>
<b>$admin_groups134</b>
<br>
<textarea rows='5' cols='60' name='news' style='width: 100%;'>$group_info[news]</textarea>
</td>
</tr>
</table>

<br>

<table width='100%' cellpadding='0' cellspacing='0' style='margin-top: 3px;'>
<tr>
<td class='header'>$admin_groups5</td></tr>
<tr>
<td class='box'>
$admin_groups6
<br><br>
<table cellpadding='0' cellspacing='0'>
<tr><td><input type='radio' name='allow_comments' id='allow_comments1' value='1'"; if($group_info[allow_comments] == 1) { echo " CHECKED"; } echo "></td><td><label for='allow_comments1'>$admin_groups7</label></td></tr>
<tr><td><input type='radio' name='allow_comments' id='allow_comments0' value='0'"; if($group_info[allow_comments] == 0) { echo " CHECKED"; } echo "></td><td><label for='allow_comments0'>$admin_groups8</label></td></tr>
</table>
</td>
</tr>
</table>

<br>

<table width='100%' cellpadding='0' cellspacing='0' style='margin-top: 3px;'>
<tr>
<td class='header'>$admin_groups9</td></tr>
<tr>
<td class='box'>
$admin_groups10
<br><br>
<table cellpadding='0' cellspacing='0'>
<tr><td><input type='radio' name='allow_friends' id='allow_friends1' value='1'"; if($group_info[allow_friends] == 1) { echo " CHECKED"; } echo "></td><td><label for='allow_friends1'>$admin_groups11</label></td></tr>
<tr><td><input type='radio' name='allow_friends' id='allow_friends0' value='0'"; if($group_info[allow_friends] == 0) { echo " CHECKED"; } echo "></td><td><label for='allow_friends0'>$admin_groups12</label></td></tr>
</table>
</td>
</tr>
</table>

<br>

<table width='100%' cellpadding='0' cellspacing='0' style='margin-top: 3px;'>
<tr>
<td class='header'>$admin_groups13</td></tr>
<tr>
<td class='box'>
$admin_groups14 
<br><br>
<table cellpadding='0' cellspacing='0'>
<tr><td><input type='radio' name='allow_privacy' id='allow_privacy1' value='1'"; if($group_info[allow_privacy] == 1) { echo " CHECKED"; } echo "></td><td><label for='allow_privacy1'>$admin_groups15</label></td></tr>
<tr><td><input type='radio' name='allow_privacy' id='allow_privacy0' value='0'"; if($group_info[allow_privacy] == 0) { echo " CHECKED"; } echo "></td><td><label for='allow_privacy0'>$admin_groups16</label></td></tr>
</table>
</td>
</tr>
</table>

<br>

<table width='100%' cellpadding='0' cellspacing='0' style='margin-top: 3px;'>
<tr>
<td class='header'>$admin_groups140</td></tr>
<tr>
<td class='box'>
$admin_groups141
<br><br>
<table cellpadding='0' cellspacing='0'>
<tr><td><input type='radio' name='allow_profileprivacy' id='allow_profileprivacy1' value='1'"; if($group_info[allow_profileprivacy] == 1) { echo " CHECKED"; } echo "></td><td><label for='allow_profileprivacy1'>$admin_groups138</label></td></tr>
<tr><td><input type='radio' name='allow_profileprivacy' id='allow_profileprivacy0' value='0'"; if($group_info[allow_profileprivacy] == 0) { echo " CHECKED"; } echo "></td><td><label for='allow_profileprivacy0'>$admin_groups139</label></td></tr>
</table>
</td>
</tr>
</table>

<br>

<table width='100%' cellpadding='0' cellspacing='0' style='margin-top: 3px;'>
<tr>
<td class='header'>$admin_groups17</td></tr>
<tr>
<td class='box'>
$admin_groups18
<br><br>
<table cellpadding='0' cellspacing='0'>
<tr><td><input type='radio' name='allow_mailinglist' id='allow_mailinglist1' value='1'"; if($group_info[allow_mailinglist] == 1) { echo " CHECKED"; } echo "></td><td><label for='allow_mailinglist1'>$admin_groups19</label></td></tr>
<tr><td><input type='radio' name='allow_mailinglist' id='allow_mailinglist0' value='0'"; if($group_info[allow_mailinglist] == 0) { echo " CHECKED"; } echo "></td><td><label for='allow_mailinglist0'>$admin_groups20</label></td></tr>
</table>
</td>
</tr>
</table>

<br>

<table width='100%' cellpadding='0' cellspacing='0' style='margin-top: 3px;'>
<tr>
<td class='header'>$admin_groups21</td></tr>
<tr>
<td class='box'>
$admin_groups22
<br><br>
<table cellpadding='0' cellspacing='0'>
<tr><td><input type='radio' name='allow_rss' id='allow_rss1' value='1'"; if($group_info[allow_rss] == 1) { echo " CHECKED"; } echo "></td><td><label for='allow_rss1'>$admin_groups23</label></td></tr>
<tr><td><input type='radio' name='allow_rss' id='allow_rss0' value='0'"; if($group_info[allow_rss] == 0) { echo " CHECKED"; } echo "></td><td><label for='allow_rss0'>$admin_groups24</label></td></tr>
</table>
</td>
</tr>
</table>

<br>

<table width='100%' cellpadding='0' cellspacing='0' style='margin-top: 3px;'>
<tr>
<td class='header'>$admin_groups128</td></tr>
<tr>
<td class='box'>
$admin_groups127
<br><br>
<table cellpadding='0' cellspacing='0'>
<tr><td><input type='radio' name='allow_podcast' id='allow_pod1' value='1'"; if($group_info[allow_podcast] == 1) { echo " CHECKED"; } echo "></td><td><label for='allow_pod1'>$admin_groups30</label></td></tr>
<tr><td><input type='radio' name='allow_podcast' id='allow_pod0' value='0'"; if($group_info[allow_podcast] == 0) { echo " CHECKED"; } echo "></td><td><label for='allow_pod0'>$admin_groups126</label></td></tr>
</table>
<br>
$admin_groups129
</td>
</tr>
</table>

<br>

<table width='100%' cellpadding='0' cellspacing='0' style='margin-top: 3px;'>
<tr>
<td class='header'>$admin_groups130</td></tr>
<tr>
<td class='box'>
$admin_groups131
<br><br>
<table cellpadding='0' cellspacing='0'>
<tr><td><input type='radio' name='allow_moblogging' id='allow_moblogging1' value='1'"; if($group_info[allow_moblogging] == 1) { echo " CHECKED"; } echo "></td><td><label for='allow_moblogging1'>$admin_groups132</label></td></tr>
<tr><td><input type='radio' name='allow_moblogging' id='allow_moblogging0' value='0'"; if($group_info[allow_moblogging] == 0) { echo " CHECKED"; } echo "></td><td><label for='allow_moblogging0'>$admin_groups133</label></td></tr>
</table>
</td>
</tr>
</table>

<br>

<table width='100%' cellpadding='0' cellspacing='0' style='margin-top: 3px;'>
<tr>
<td class='header'>$admin_groups26</td></tr>
<tr>
<td class='box'>
$admin_groups27
<br><br>
<table cellpadding='0' cellspacing='0'>
<tr>
  <td><input type='checkbox' name='allow_album' id='allow_album' value='1'"; if($group_info[allow_album] == 1) { echo " CHECKED"; } echo "></td><td><label for='allow_album'>$admin_groups28</label></td>
  <td style='padding-left: 40px;'>$admin_groups32&nbsp;<input type='text' class='text' name='album_extensions' size='30' value='$group_info[album_extensions]'></td>
</tr>
<tr>
  <td><input type='checkbox' name='allow_podcastfiles' id='allow_podcastfiles' value='1'"; if($group_info[allow_podcastfiles] == 1) { echo " CHECKED"; } echo "></td><td><label for='allow_podcastfiles'>$admin_groups29</label></td>
  <td style='padding-left: 40px;'>$admin_groups32&nbsp;<input type='text' class='text' name='podcast_extensions' size='30' value='$group_info[podcast_extensions]'></td>
</tr>
<tr>
  <td><input type='checkbox' name='allow_uploads' id='allow_uploads' value='1'"; if($group_info[allow_uploads] == 1) { echo " CHECKED"; } echo "></td><td><label for='allow_uploads'>$admin_groups73</label></td>
  <td style='padding-left: 40px;'>$admin_groups32&nbsp;<input type='text' class='text' name='uploads_extensions' size='30' value='$group_info[uploads_extensions]'></td>
</tr>
<tr>
  <td colspan='2'>&nbsp;</td>
  <td style='padding-left: 40px; padding-top: 10px;'>$admin_groups31
    <select name='uploads_space'>
    <option value='100'"; if($group_info[uploads_space] == "100") { echo " SELECTED"; } echo ">100 KB</option>
    <option value='250'"; if($group_info[uploads_space] == "250") { echo " SELECTED"; } echo ">250 KB</option>
    <option value='500'"; if($group_info[uploads_space] == "500") { echo " SELECTED"; } echo ">500 KB</option>
    <option value='1024'"; if($group_info[uploads_space] == "1024") { echo " SELECTED"; } echo ">1 MB</option>
    <option value='2048'"; if($group_info[uploads_space] == "2048") { echo " SELECTED"; } echo ">2 MB</option>
    <option value='3072'"; if($group_info[uploads_space] == "3072") { echo " SELECTED"; } echo ">3 MB</option>
    <option value='4096'"; if($group_info[uploads_space] == "4096") { echo " SELECTED"; } echo ">4 MB</option>
    <option value='5120'"; if($group_info[uploads_space] == "5120") { echo " SELECTED"; } echo ">5 MB</option>
    <option value='10240'"; if($group_info[uploads_space] == "10240") { echo " SELECTED"; } echo ">10 MB</option>
    <option value='15360'"; if($group_info[uploads_space] == "15360") { echo " SELECTED"; } echo ">15 MB</option>
    <option value='20480'"; if($group_info[uploads_space] == "20480") { echo " SELECTED"; } echo ">20 MB</option>
    <option value='25600'"; if($group_info[uploads_space] == "25600") { echo " SELECTED"; } echo ">25 MB</option>
    <option value='51200'"; if($group_info[uploads_space] == "51200") { echo " SELECTED"; } echo ">50 MB</option>
    <option value='102400'"; if($group_info[uploads_space] == "102400") { echo " SELECTED"; } echo ">100 MB</option>
    <option value='204800'"; if($group_info[uploads_space] == "204800") { echo " SELECTED"; } echo ">200 MB</option>
    <option value='307200'"; if($group_info[uploads_space] == "307200") { echo " SELECTED"; } echo ">300 MB</option>
    <option value='409600'"; if($group_info[uploads_space] == "409600") { echo " SELECTED"; } echo ">400 MB</option>
    <option value='512000'"; if($group_info[uploads_space] == "512000") { echo " SELECTED"; } echo ">500 MB</option>
    <option value='614400'"; if($group_info[uploads_space] == "614400") { echo " SELECTED"; } echo ">600 MB</option>
    <option value='716800'"; if($group_info[uploads_space] == "716800") { echo " SELECTED"; } echo ">700 MB</option>
    <option value='819200'"; if($group_info[uploads_space] == "819200") { echo " SELECTED"; } echo ">800 MB</option>
    <option value='921600'"; if($group_info[uploads_space] == "921600") { echo " SELECTED"; } echo ">900 MB</option>
    <option value='unlimited'"; if($group_info[uploads_space] == "unlimited") { echo " SELECTED"; } echo ">Unlimited</option>
    </select>
  </td>
</tr>
</table>
<br>
$admin_groups72
</td>
</tr>
</table>

<br>

<table width='100%' cellpadding='0' cellspacing='0' style='margin-top: 3px;'>
<tr>
<td class='header'>$admin_groups35</td></tr>
<tr>
<td class='box'>
$admin_groups36
<br><br>
<table cellpadding='0' cellspacing='0'>
<tr><td><input type='radio' name='allow_banning' id='allow_banning1' value='1'"; if($group_info[allow_banning] == 1) { echo " CHECKED"; } echo "></td><td><label for='allow_banning1'>$admin_groups37</label></td></tr>
<tr><td><input type='radio' name='allow_banning' id='allow_banning0' value='0'"; if($group_info[allow_banning] == 0) { echo " CHECKED"; } echo "></td><td><label for='allow_banning0'>$admin_groups38</label></td></tr>
</table>
</td>
</tr>
</table>

<br>

<table width='100%' cellpadding='0' cellspacing='0' style='margin-top: 3px;'>
<tr>
<td class='header'>$admin_groups39</td></tr>
<tr>
<td class='box'>
$admin_groups40
<br><br>
<table cellpadding='0' cellspacing='0'>
<tr><td><input type='radio' name='allow_pinging' id='allow_pinging1' value='1'"; if($group_info[allow_pinging] == 1) { echo " CHECKED"; } echo "></td><td><label for='allow_pinging1'>$admin_groups41</label></td></tr>
<tr><td><input type='radio' name='allow_pinging' id='allow_pinging0' value='0'"; if($group_info[allow_pinging] == 0) { echo " CHECKED"; } echo "></td><td><label for='allow_pinging0'>$admin_groups42</label></td></tr>
</table>
</td>
</tr>
</table>

<br>

<table width='100%' cellpadding='0' cellspacing='0' style='margin-top: 3px;'>
<tr>
<td class='header'>$admin_groups105</td></tr>
<tr>
<td class='box'>
$admin_groups106
<br><br>
<table cellpadding='0' cellspacing='0'>
<tr><td><input type='radio' name='allow_trackback' id='allow_trackback1' value='1'"; if($group_info[allow_trackback] == 1) { echo " CHECKED"; } echo "></td><td><label for='allow_trackback1'>$admin_groups107</label></td></tr>
<tr><td><input type='radio' name='allow_trackback' id='allow_trackback0' value='0'"; if($group_info[allow_trackback] == 0) { echo " CHECKED"; } echo "></td><td><label for='allow_trackback0'>$admin_groups108</label></td></tr>
</table>
</td>
</tr>
</table>

<br>

<table width='100%' cellpadding='0' cellspacing='0' style='margin-top: 3px;'>
<tr>
<td class='header'>$admin_groups87</td></tr>
<tr>
<td class='box'>
$admin_groups88
<br><br>
<table cellpadding='0' cellspacing='0'>
<tr><td><input type='radio' name='allow_entry_cat' id='allow_entry_cat1' value='1'"; if($group_info[allow_entry_cat] == 1) { echo " CHECKED"; } echo "></td><td><label for='allow_entry_cat1'>$admin_groups89</label></td></tr>
<tr><td><input type='radio' name='allow_entry_cat' id='allow_entry_cat0' value='0'"; if($group_info[allow_entry_cat] == 0) { echo " CHECKED"; } echo "></td><td><label for='allow_entry_cat0'>$admin_groups90</label></td></tr>
</table>
</td>
</tr>
</table>

<br>


<table width='100%' cellpadding='0' cellspacing='0' style='margin-top: 3px;'>
<tr>
<td class='header'>$admin_groups101</td></tr>
<tr>
<td class='box'>
$admin_groups121
<br><br>
<table cellpadding='0' cellspacing='0'>
<tr><td><input type='radio' name='allow_pms' id='allow_pms1' value='1'"; if($group_info[allow_pms] == 1) { echo " CHECKED"; } echo "></td><td><label for='allow_pms1'>$admin_groups122</label></td></tr>
<tr><td><input type='radio' name='allow_pms' id='allow_pms0' value='0'"; if($group_info[allow_pms] == 0) { echo " CHECKED"; } echo "></td><td><label for='allow_pms0'>$admin_groups123</label></td></tr>
</table>
<br>
$admin_groups124
<br><br>
<table cellpadding='0' cellspacing='0'>
<tr>
<td> 
<select name='pms_max'>
<option"; if($group_info[pms_max] == 1) { echo " SELECTED"; } echo ">1</option>
<option"; if($group_info[pms_max] == 5) { echo " SELECTED"; } echo ">5</option>
<option"; if($group_info[pms_max] == 10) { echo " SELECTED"; } echo ">10</option>
<option"; if($group_info[pms_max] == 20) { echo " SELECTED"; } echo ">20</option>
<option"; if($group_info[pms_max] == 50) { echo " SELECTED"; } echo ">50</option>
<option"; if($group_info[pms_max] == 100) { echo " SELECTED"; } echo ">100</option>
<option"; if($group_info[pms_max] == 150) { echo " SELECTED"; } echo ">150</option>
<option"; if($group_info[pms_max] == 200) { echo " SELECTED"; } echo ">200</option>
</select>
</td>
<td>&nbsp;$admin_groups125</td>
</tr>
</table>
</td>
</tr>
</table>
<br>

<table width='100%' cellpadding='0' cellspacing='0' style='margin-top: 3px;'>
<tr>
<td class='header'>$admin_groups93</td></tr>
<tr>
<td class='box'>
$admin_groups94
<br><br>
<table cellpadding='0' cellspacing='0'>
<tr><td><input type='radio' name='allow_edittemplate' id='allow_edittemplate1' value='1'"; if($group_info[allow_edittemplate] == 1) { echo " CHECKED"; } echo "></td><td><label for='allow_edittemplate1'>$admin_groups95</label></td></tr>
<tr><td><input type='radio' name='allow_edittemplate' id='allow_edittemplate0' value='0'"; if($group_info[allow_edittemplate] == 0) { echo " CHECKED"; } echo "></td><td><label for='allow_edittemplate0'>$admin_groups96</label></td></tr>
</table>
</td>
</tr>
</table>

<br>

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

$count = 0;
$template_array = explode(",", $group_info[templates]);
$templates = mysql_query("SELECT * FROM bhost_templates");
$num_templates = mysql_num_rows($templates);
while($template_info = mysql_fetch_assoc($templates)) {
 if($count%3 == 0) {
   echo "<tr><td><input type='checkbox' name='template_$template_info[t_id]' value='1'"; if(in_array($template_info[t_id], $template_array)) { echo " CHECKED"; } echo "></td><td style='padding-right: 20px;'><a href='../example.php?t_id=$template_info[t_id]' target='_blank'>$template_info[name]</a></td>";
 } elseif($count%3 == 1) {
   echo "<td><input type='checkbox' name='template_$template_info[t_id]' value='1'"; if(in_array($template_info[t_id], $template_array)) { echo " CHECKED"; } echo "></td><td style='padding-right: 20px;'><a href='../example.php?t_id=$template_info[t_id]' target='_blank'>$template_info[name]</a></td>";
 } else {
   echo "<td><input type='checkbox' name='template_$template_info[t_id]' value='1'"; if(in_array($template_info[t_id], $template_array)) { echo " CHECKED"; } echo "></td><td><a href='../example.php?t_id=$template_info[t_id]' target='_blank'>$template_info[name]</a></td></tr>";
 }
 $count = $count + 1;
}

if($num_templates%3 != 0) { echo "</tr>"; }

echo "
</table>
</td>
</tr>
</table>

<br>

<table width='100%' cellpadding='0' cellspacing='0' style='margin-top: 3px;'>
<tr>
<td class='header'>$admin_groups97</td></tr>
<tr>
<td class='box'>
$admin_groups98
<br><br>
<table cellpadding='0' cellspacing='0'>
<tr><td><input type='radio' name='allow_language' id='allow_language1' value='1'"; if($group_info[allow_language] == 1) { echo " CHECKED"; } echo "></td><td><label for='allow_language1'>$admin_groups99</label></td></tr>
<tr><td><input type='radio' name='allow_language' id='allow_language0' value='0'"; if($group_info[allow_language] == 0) { echo " CHECKED"; } echo "></td><td><label for='allow_language0'>$admin_groups100</label></td></tr>
</table>
</td>
</tr>
</table>

<br>

<table width='100%' cellpadding='0' cellspacing='0' style='margin-top: 3px;'>
<tr>
<td class='header'>$admin_groups111</td></tr>
<tr>
<td class='box'>
$admin_groups112
<br><br>
<table cellpadding='0' cellspacing='0'>
<tr><td><input type='radio' name='allow_multiauthor' id='allow_multiauthor1' value='1'"; if($group_info[allow_multiauthor] == 1) { echo " CHECKED"; } echo "></td><td><label for='allow_multiauthor1'>$admin_groups113</label></td></tr>
<tr><td><input type='radio' name='allow_multiauthor' id='allow_multiauthor0' value='0'"; if($group_info[allow_multiauthor] == 0) { echo " CHECKED"; } echo "></td><td><label for='allow_multiauthor0'>$admin_groups114</label></td></tr>
</table>
</td>
</tr>
</table>

<br>

<table width='100%' cellpadding='0' cellspacing='0' style='margin-top: 3px;'>
<tr>
<td class='header'>$admin_groups115</td></tr>
<tr>
<td class='box'>
$admin_groups116
<br><br>
<table cellpadding='0' cellspacing='0'>
<tr>
<td>$admin_groups117</td>
<td>&nbsp;
<select name='num_weblogs'>
";

for($c=0; $c<100; $c++) {
echo "
<option value='$c'"; if($group_info[num_weblogs] == $c) { echo " SELECTED"; } echo ">$c</option>";
}

echo "
</select>
</td>
</tr>
</table>
</td>
</tr>
</table>

<br>

<table width='100%' cellpadding='0' cellspacing='0' style='margin-top: 3px;'>
<tr><td class='header'>$admin_groups43</td></tr>
<tr>
<td class='box'>
$admin_groups44<br><br>
<table cellpadding='0' cellspacing='0'>
<tr><td><input type='radio' name='show_ad' id='show_ad0' value='0'"; if($group_info[show_ad] == 0) { echo " CHECKED"; } echo "></td><td><label for='show_ad0'>$admin_groups45</label></td></tr>
<tr><td><input type='radio' name='show_ad' id='show_ad1' value='1'"; if($group_info[show_ad] == 1) { echo " CHECKED"; } echo "></td><td><label for='show_ad1'>$admin_groups46</label></td></tr>
<tr><td><input type='radio' name='show_ad' id='show_ad2' value='2'"; if($group_info[show_ad] == 2) { echo " CHECKED"; } echo "></td><td><label for='show_ad2'>$admin_groups47</label></td></tr>
<tr><td><input type='radio' name='show_ad' id='show_ad3' value='3'"; if($group_info[show_ad] == 3) { echo " CHECKED"; } echo "></td><td><label for='show_ad3'>$admin_groups48</label></td></tr>
</table>
<br>
$admin_groups102
<br><br>
<b>$admin_groups103</b><br>
<textarea name='html_ad' rows='8' cols='40' style='width: 100%;'>".str_replace("<", "&lt;", $group_info[html_ad])."</textarea>
<br>
<b>$admin_groups104</b><br>
<textarea name='html_ad_bottom' rows='8' cols='40' style='width: 100%;'>".str_replace("<", "&lt;", $group_info[html_ad_bottom])."</textarea>
</td>
</tr>
</table>

<br>

<input type='submit' name='submit' class='button' value='$submit'>
<input type='submit' name='submit' class='button' value='$admin_groups63'>
<input type='hidden' name='task' value='doedit'>
<input type='hidden' name='g_id' value='$group_info[g_id]'>
</form>
";
echo $foot;
exit();
}











if($task == "doedit") {
$g_id = $_POST['g_id'];
$group_name = $_POST['group_name'];
$group_description = htmlspecialchars($group_description);
$allow_comments = $_POST['allow_comments'];
$allow_friends = $_POST['allow_friends'];
$allow_privacy = $_POST['allow_privacy'];
$allow_profileprivacy = $_POST['allow_profileprivacy'];
$allow_mailinglist = $_POST['allow_mailinglist'];
$allow_rss = $_POST['allow_rss'];
$allow_podcast = $_POST['allow_podcast'];
$allow_moblogging = $_POST['allow_moblogging'];
$uploads_space = $_POST['uploads_space'];
$allow_album = $_POST['allow_album'];
$album_extensions = preg_replace("/\,+/", ",", preg_replace("/[^a-z,A-Z,0-9,\,]/", "", $_POST['album_extensions']));
$allow_podcastfiles = $_POST['allow_podcastfiles'];
$podcast_extensions = preg_replace("/\,+/", ",", preg_replace("/[^a-z,A-Z,0-9,\,]/", "", $_POST['podcast_extensions']));
$allow_uploads = $_POST['allow_uploads'];
$uploads_extensions = preg_replace("/\,+/", ",", preg_replace("/[^a-z,A-Z,0-9,\,]/", "", $_POST['uploads_extensions']));
$allow_banning = $_POST['allow_banning'];
$allow_pinging = $_POST['allow_pinging'];
$allow_trackback = $_POST['allow_trackback'];
$allow_entry_cat = $_POST['allow_entry_cat'];
$allow_pms = $_POST['allow_pms'];
$pms_max = $_POST['pms_max'];
$allow_edittemplate = $_POST['allow_edittemplate'];
$allow_language = $_POST['allow_language'];
$allow_multiauthor = $_POST['allow_multiauthor'];
$num_weblogs = $_POST['num_weblogs'];
$show_ad = $_POST['show_ad'];
$html_ad = str_replace("&lt;", "<", $_POST['html_ad']);
$html_ad_bottom = str_replace("&lt;", "<", $_POST['html_ad_bottom']);
$news = $_POST['news'];
$submit = $_POST['submit'];

// CHECK FOR EMPTY FILE UPLOADS BOXES
if($allow_album != 1) { $allow_album = 0; }
if($allow_podcastfiles != 1) { $allow_podcastfiles = 0; }
if($allow_uploads != 1) { $allow_uploads = 0; }

$count = 0;
$templates = "";
$bhost_templates = mysql_query("SELECT * FROM bhost_templates");
while($template_info = mysql_fetch_assoc($bhost_templates)) {
  $var = "template_$template_info[t_id]";
  $included = $_POST[$var];
  if($included == "1") {
    if($count != 0) { $templates .= ","; }
    $templates .= "$template_info[t_id]";
    $count = $count + 1;
  }
}


if($submit == "$admin_groups63") { header("Location: admin_groups.php"); exit(); }

if(str_replace(" ", "", $group_name) == "") {
echo $head;
echo "
<h2>$admin_groups51</h2>
$admin_groups53
<br><br>
<form action='admin_groups.php' method='POST'>
<input type='submit' class='button' value='$admin_groups3'>
";
if($g_id == "") { echo "<input type='hidden' name='task' value='newgroup'>"; } else { echo "<input type='hidden' name='task' value='edit'><input type='hidden' name='g_id' value='$g_id'>"; }
echo "
</form>
";
echo $foot;
exit();
}


if($num_weblogs != (int) $num_weblogs | !is_numeric($num_weblogs)) { $num_weblogs = (int) $num_weblogs; }
if($num_weblogs > 99) { $num_weblogs = 99; }
if($num_weblogs == "") { $num_weblogs = 1; }

if($g_id == "") {
mysql_query("INSERT INTO bhost_groups (group_name, group_description, allow_comments, allow_friends, allow_privacy, allow_profileprivacy, allow_mailinglist, allow_rss, allow_podcast, allow_moblogging, uploads_space, allow_album, album_extensions, allow_podcastfiles, podcast_extensions, allow_uploads, uploads_extensions, allow_banning, allow_pinging, allow_trackback, allow_entry_cat, allow_pms, allow_edittemplate, templates, allow_language, allow_multiauthor, num_weblogs, show_ad, html_ad, html_ad_bottom, pms_max, news) VALUES ('$group_name', '$group_description', '$allow_comments', '$allow_friends', '$allow_privacy', '$allow_profileprivacy', '$allow_mailinglist', '$allow_rss', '$allow_podcast', '$allow_moblogging', '$uploads_space', '$allow_album', '$album_extensions', '$allow_podcastfiles', '$podcast_extensions', '$allow_uploads', '$uploads_extensions', '$allow_banning', '$allow_pinging', '$allow_trackback', '$allow_entry_cat', '$allow_pms', '$allow_edittemplate', '$templates', '$allow_language', '$allow_multiauthor', '$num_weblogs', '$show_ad', '$html_ad', '$html_ad_bottom', '$pms_max', '$news')");
} else {
mysql_query("UPDATE bhost_groups SET group_name='$group_name', group_description='$group_description', allow_comments='$allow_comments', allow_friends='$allow_friends', allow_privacy='$allow_privacy', allow_profileprivacy='$allow_profileprivacy', allow_mailinglist='$allow_mailinglist', allow_rss='$allow_rss', allow_podcast='$allow_podcast', allow_moblogging='$allow_moblogging', uploads_space='$uploads_space', allow_album='$allow_album', album_extensions='$album_extensions', allow_podcastfiles='$allow_podcastfiles', podcast_extensions='$podcast_extensions', allow_uploads='$allow_uploads', uploads_extensions='$uploads_extensions', allow_banning='$allow_banning', allow_pinging='$allow_pinging', allow_trackback='$allow_trackback', allow_entry_cat='$allow_entry_cat', allow_pms='$allow_pms', allow_edittemplate='$allow_edittemplate', templates='$templates', allow_language='$allow_language', allow_multiauthor='$allow_multiauthor', num_weblogs='$num_weblogs', show_ad='$show_ad', html_ad='$html_ad', html_ad_bottom='$html_ad_bottom', pms_max='$pms_max', news='$news' WHERE g_id='$g_id'") or die(mysql_error());
}
header("Location: admin_groups.php");
exit();
}











if($task == "delete") {
if(isset($_GET['g_id'])) { $g_id = $_GET['g_id']; } else { $g_id = 0; }
if(mysql_num_rows(mysql_query("SELECT g_id FROM bhost_groups WHERE g_id='$g_id'")) != 1) { exit(); }
$group_info = mysql_fetch_assoc(mysql_query("SELECT g_id, default_group FROM bhost_groups WHERE g_id='$g_id'"));

if($group_info[default_group] == 1) {
echo $head;
echo "
<h2>$admin_groups51</h2>
$admin_groups52
<br><br>
<form action='admin_groups.php' method='POST'>
<input type='submit' class='button' value='$admin_groups3'>
</form>
";
echo $foot;
exit();
}

echo $head;
echo "
<h2>$admin_groups60</h2>
$admin_groups61
<br><br>
<table cellpadding='0' cellspacing='0'>
<tr>
<form action='admin_groups.php' method='POST'>
<td>
<input type='submit' class='button' value='$admin_groups62'>&nbsp;
</td>
<input type='hidden' name='task' value='dodelete'>
<input type='hidden' name='g_id' value='$g_id'>
</form>
<form action='admin_groups.php' method='POST'>
<td>
<input type='submit' class='button' value='$admin_groups63'>
</td>
</tr>
</form>
</table>
";
echo $foot;
exit();
}











if($task == "dodelete") {
if(isset($_POST['g_id'])) { $g_id = $_POST['g_id']; } else { exit(); }
$group_info = mysql_fetch_assoc(mysql_query("SELECT g_id, default_group FROM bhost_groups WHERE g_id='$g_id'"));
if($group_info[default_group] == 1) { exit(); }
$default_group = mysql_fetch_assoc(mysql_query("SELECT g_id, default_group FROM bhost_groups WHERE default_group='1' LIMIT 1"));

mysql_query("DELETE FROM bhost_groups WHERE g_id='$g_id'");
mysql_query("UPDATE bhost_users SET g_id='$default_group[g_id]' WHERE g_id='$g_id'");
header("Location: admin_groups.php");
exit();
}






if($task == "move") {
$g_id = $_GET['g_id'];
if($g_id == "") { exit(); }

$totalusers = mysql_num_rows(mysql_query("SELECT g_id, u_id FROM bhost_users WHERE g_id='$g_id'"));

// IF ZERO USERS IN GROUP, SHOW ERROR
if($totalusers == 0) {
echo $head;
echo "
<h2>$admin_groups33</h2>
$admin_groups76
<br><br>
<form action='admin_groups.php' method='POST'>
<input type='submit' class='button' value='$admin_groups3'>
</form>
";
echo $foot;
exit();
}

// IF ONLY ONE GROUP EXISTS, SHOW ERROR
$totalgroups = mysql_num_rows(mysql_query("SELECT g_id FROM bhost_groups"));
if($totalgroups == 1) {
echo $head;
echo "
<h2>$admin_groups33</h2>
$admin_groups86
<br><br>
<form action='admin_groups.php' method='POST'>
<input type='submit' class='button' value='$admin_groups3'>
</form>
";
echo $foot;
exit();
}

$group_info = mysql_fetch_assoc(mysql_query("SELECT * FROM bhost_groups WHERE g_id='$g_id'"));
echo $head;
echo "
<h2>$admin_groups77</h2>
$admin_groups78 $totalusers $admin_groups79 <b>$group_info[group_name]</b>
<br><br>
<table cellpadding='7' cellspacing='0' class='box' style='background: #FFFFFF;'>
<form action='admin_groups.php' method='POST'>
<tr><td>$admin_groups80 <b>$group_info[group_name]</b> $admin_groups81</td><td>
<select name='newgroup'>
";

$groups = mysql_query("SELECT * FROM bhost_groups ORDER BY group_name");
while($group = mysql_fetch_assoc($groups)) {
if($group[g_id] != $g_id) {
echo "<option value='$group[g_id]'>$group[group_name]</option>
";
}}

echo "
</select>
</td></tr></table>

<br>

<input type='submit' class='button' name='submit' value='$admin_groups82'>
<input type='submit' class='button' name='submit' value='$admin_groups63'>
<input type='hidden' name='task' value='domove'>
<input type='hidden' name='g_id' value='$g_id'>
</form>
";
echo $foot;
exit();
}




if($task == "domove") {
$submit = $_POST['submit'];
$g_id = $_POST['g_id'];
$newgroup = $_POST['newgroup'];

if($submit == "$admin_groups63") { header("Location: admin_groups.php"); exit(); }
if($g_id == "" OR $newgroup == "") { exit(); }

// MOVE USERS TO NEW GROUP
mysql_query("UPDATE bhost_users SET g_id='$newgroup' WHERE g_id='$g_id'");
$totalusers = mysql_affected_rows();

$oldgroup = mysql_fetch_assoc(mysql_query("SELECT * FROM bhost_groups WHERE g_id='$g_id'"));
$newgroup = mysql_fetch_assoc(mysql_query("SELECT * FROM bhost_groups WHERE g_id='$newgroup'"));

echo $head;
echo "
<h2>$admin_groups83</h2>
$admin_groups84 $totalusers $admin_groups85 <b>$oldgroup[group_name]</b> $admin_groups81 <b>$newgroup[group_name]</b>.
<br><br>
<form action='admin_groups.php' method='POST'>
<input type='submit' class='button' value='$admin_groups3'>
</form>
";
echo $foot;
exit();
}




if($task == "main") {
echo $head;
echo "
<h2>$admin_groups1</h2>
$admin_groups4
<br><br>

<table cellpadding='0' cellspacing='0' width='100%'>
<tr><form action='admin_groups.php' method='POST'>
<td class='header' width='1%' NOWRAP>$admin_groups64</td>
<td class='header' width='70%' style='border-left: none;' NOWRAP>$admin_groups65</td>
<td class='header' width='5%' style='border-left: none;' NOWRAP>$admin_groups66</td>
<td class='header' width='5%' style='border-left: none;' NOWRAP>$admin_groups50</td>
<td class='header' width='5%' style='border-left: none;' NOWRAP>$admin_groups118</td>
<td class='header' width='19%' style='border-left: none;' NOWRAP>$admin_groups67</td>
</tr>
";

$groups = mysql_query("SELECT * FROM bhost_groups ORDER BY group_name");
while($group_info = mysql_fetch_assoc($groups)) {
$users_in_group = mysql_num_rows(mysql_query("SELECT u_id, g_id FROM bhost_users WHERE g_id='$group_info[g_id]'"));
  echo "
  <tr>
  <td class='list2' align='center' style='border-left: 1px solid #AAAAAA;' NOWRAP>$group_info[g_id]</td>
  <td class='list2' style='border-left: none;'>$group_info[group_name]</td>
  <td class='list2' style='border-left: none;' align='center' NOWRAP>$users_in_group</td>
  <td class='list2' style='border-left: none; padding: 3px;' align='center' NOWRAP><input type='radio' name='default_group' value='$group_info[g_id]'"; if($group_info[default_group] == 1) { echo " CHECKED"; } echo ">
  <td class='list2' style='border-left: none; padding: 3px;' align='center' NOWRAP><input type='checkbox' name='show_group_$group_info[g_id]' value='1'"; if($group_info[show_group] == 1) { echo " CHECKED"; } echo ">
  <td class='list2' style='border-left: none;' NOWRAP><a href='admin_groups.php?task=edit&g_id=$group_info[g_id]'>$admin_groups68</a> <font class='gray'>|</font> <a href='admin_groups.php?task=move&g_id=$group_info[g_id]'>$admin_groups75</a> <font class='gray'>|</font> <a href='admin_groups.php?task=delete&g_id=$group_info[g_id]'>$admin_groups69</a></td>
  </tr>
  ";
}

echo "
</table>

<br>
<input type='submit' name='submit' class='button' value='$admin_groups71'>
<input type='submit' name='submit' class='button' value='$admin_groups70'>
<input type='hidden' name='task' value='newgroup_or_setdefault'>
</form>

";

echo $foot;
exit();
}

?>