<?
    $_name 
= isset($_POST['name']) ? trim(strval($_POST['name'])) : '';

    if (
language() == 'french')
    {
        
define('ACTION_COMMUNITY_CREATE_ROOTADMIN''Sorry, you can only be the root admin of five communities.');
    }
    else
    {
        
define('ACTION_COMMUNITY_CREATE_ROOTADMIN''Sorry, you can only be the root admin of five communities.');
    }
    
    
$community_permissions mysql_query("SELECT * FROM community_permissions WHERE user_id = '" $GLOBALS['auth']['id'] . "' AND permission = 'administrator'");
    if (
mysql_num_rows($community_permissions) >= 5)
    {
        
make_cookie('notice'ACTION_COMMUNITY_CREATE_ROOTADMIN);
        
header('Location: ./?s=community_create');
        die;
    }
    
    require_once(
'include/functions/community_name_valid.php');
    if (
$error community_name_valid($_name))    
    {
        
make_cookie('notice'$error);
        
header('Location: ./?s=community_create');
        die;
    }    

    
mysql_query("INSERT INTO community SET community_name = " sq($_name) . ", community_creator = '" $GLOBALS['auth']['id'] . "', community_created_on = NOW()");
    
$mysql_insert_id mysql_insert_id();
    
mysql_query("INSERT INTO community_permissions SET community_id = '" $mysql_insert_id "', user_id = '" $GLOBALS['auth']['id'] . "', permission = 'administrator'");

    
header('Location: ./?s=community_modify&i=' $mysql_insert_id);
?>