Location: PHPKode > scripts > GRA4 Social Network (Micro) > micro/settings.php
<?php
require_once('common.php');

if(!userIsAdmin())
{
	header('Location: gra4/index.php');
	exit;//we done. Admins only!
}
$strResult = '';
$aUsers = getUsers(); //id:email:password:status

//print_r($_POST);
$strSubject = $_POST['subject'];
$strBody = $_POST['body'];

if(isset($_POST['SaveSiteSettings']))
{
	if(isset($_POST['members_only']))
	{
		setConfig('members_only','yes');
	}
	else
	{
		setConfig('members_only','no');
	}
	setConfig('site_description',$_POST['description']);
	setConfig('site_title',$_POST['title']);	
	$strResult = $language['saved_ok'];
}


$strTitle = getSiteTitle();
$strDescription = getSiteDescription();
$strMembersOnly = getConfig('members_only');

$strMembersOnlyChecked = '';
if($strMembersOnly == 'yes')
{
	$strMembersOnlyChecked = 'CHECKED';
}

$strUserTableTRs = "\n<tr><td nowrap><button title='Invert Selection' onClick='InvertUserSelection();return false;'>&bull;</button></td><td nowrap>".$language['users_settings_caption']."</td><td nowrap></td></tr>\n";
$iEmailSent = 0;
for($i = 0; $i < count($aUsers); $i++) 		
{
	$tmp = explode(':', $aUsers[$i]);//id:email:password:status
	if(isset($_POST['ucd_'.$tmp[0]]))
	{
		mail($tmp[1],$strSubject,$strBody);
		$iEmailSent++;
	}	
	if(isset($_POST['ban_user_'.$tmp[0]]))
	{
		$tmp[3] = 'banned';
		$strResult = $language['ban_caption'] . " : " .$tmp[1];
	}	
	if(isset($_POST['unban_user_'.$tmp[0]]))
	{
		$tmp[3] = 'ok';
		$strResult = $language['unban_caption'] . " : " .$tmp[1];
	}	
	if(isset($_POST['confirm_user_'.$tmp[0]]))
	{
		$tmp[3] = 'ok';
		unset($tmp[4]);
		$strResult = $language['confirm_caption'] . " : " .$tmp[1];
	}
	$aUsers[$i] = implode(':',$tmp);	
		
	$id = $tmp[0];	
	$email = $tmp[1];
	$status = $tmp[3];
	$banreason = '';
	if(isset($tmp[4]))
	{
		$banreason = $tmp[4]; 
	}
	
	$button = '';
	if($status == 'admin' || $id == '0')
	{
		$button = 'Admin';
	}
	if($status == 'unconfirmed')
	{
		$button = "<input class='text' type='submit' name='confirm_user_$id' value='".$language['confirm_caption']."'/>";
	}
	if($status == 'ok')
	{
		$button = "<input class='text' type='submit' name='ban_user_$id' value='".$language['ban_caption']."'/>";
	}	
	if($status == 'banned')
	{
		$button = "<input class='text' type='submit' name='unban_user_$id' value='".$language['unban_caption']."'/>";			
	}		
	$check= "<input id='utd_$id' class='text' name='ucd_$id' type='checkbox' />";
	$strUserTableTRs .= "<tr title='$email , id: $id, status: $status'><td nowrap>$check</td><td nowrap>$email</td><td nowrap id='utd_$id'>$button</td></tr>\n";
}//user loop
if($iEmailSent > 0)
{
	$strResult = sprintf($language['email_sent'],$iEmailSent);
}
putUsers($aUsers);	
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
<html>
<head>
   <title><?php echo(getSiteTitle()); ?></title>
   <META name=DESCRIPTION content="<?php echo(getSiteDescription()); ?>">   
   
   <link href="style/style.css" rel="stylesheet" type="text/css" />
</head>
<script language="javascript">
var iMaxUserId = <?php echo($id)?>;
function InvertUserSelection()
{
	for(var i=0; i <= iMaxUserId; i++)
	{
		oUserCheck = document.getElementById('utd_'+i);
		if(oUserCheck)
		{
			oUserCheck.checked = !oUserCheck.checked;
		}
	}
}
</script>
<body>
    <div id="main">
      <div class="caption"><?php echo($language['site_settings_caption']); ?></div>
      <div id="icon2">&nbsp;</div>
      <form id="site_form" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="siteform">
        <table width="100%">
          <tr><td><?php echo($language['title_caption']); ?></td><td> <input class="text" name="title" type="text" value="<?php echo($strTitle);?>" /></td></tr>
          <tr><td><?php echo($language['description_caption']); ?></td><td> <input class="text" name="description" type="text" value="<?php echo($strDescription);?>" /></td></tr>
          <tr><td><?php echo($language['members_only_caption']); ?></td><td> <input class="text" name="members_only" type="checkbox" <?php echo($strMembersOnlyChecked);?> /></td></tr>
          <tr><td colspan="2" align="center"><input class="text" type="submit" name="SaveSiteSettings" value="<?php echo($language['save_action']); ?>" /></td></tr>
        </table>  
      </form>

<?php
if($strResult !== '')
{
	echo("
      <div id='result'>
        <table width='100%'><tr><td>
$strResult
	<br/></td></tr></table>
	</div>
			");
}
?>
      
      <div class="caption"><?php echo($language['users_settings_caption']); ?></div>
      <div id="icon">&nbsp;</div>
      <form id="user_form" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="userform">
        <table width="100%" style="border: dashed lightgray 1px;"><?php echo($strUserTableTRs); ?></table>  
        <table width="100%">
          <tr><td><?php echo($language['subject_caption']); ?></td><td> <input class="text" name="subject" type="text" value="<?php echo($strSubject); ?>" /></td></tr>
          <tr><td><?php echo($language['text_caption']); ?></td><td> <textarea class="text" name="body" ><?php echo($strBody); ?></textarea></td></tr>
          <tr><td colspan="2" align="center"><input class="text" type="submit" name="EmailToSelected" value="<?php echo($language['email_selected_caption']); ?>" /></td></tr>
        </table>  
      </form>

      &nbsp;<a href="gra4"><?php echo($language['back_to'] . $strTitle); ?></a>
      
      
</div>
</body>   
Return current item: GRA4 Social Network (Micro)