Blame Scripts/CentOS-Web/admin/p_users.php

1f953a
1f953a
/***
1f953a
 * Useradmin page.
1f953a
 *
1f953a
 * This page sumarize the actions needed to administer users into LDAP
1f953a
 * directory server's database.
1f953a
 *
1f953a
 * --
1f953a
 * 2009 (c) Alain Reguera Delgado <al@ciget.cienfuegos.cu>
1f953a
 * Released under GPL lisence (http://www.fsf.org/licensing/licenses/gpl.txt)
1f953a
 */
1f953a
1f953a
1f953a
//-------------/* Show error if this page is called directly.
1f953a
1f953a
    if ( basename($_SERVER['PHP_SELF']) <> 'index.php')
1f953a
    {
1f953a
        echo '

Sorry, this page can\'t be served directly. ';

1f953a
        echo 'Try this instead.';
1f953a
        exit;
1f953a
    }
1f953a
1f953a
//------------|* Define filter.
1f953a
1f953a
    $filter = $ldap->build_filter_string(); 
1f953a
1f953a
/*------------|* Initialize entry values. */
1f953a
1f953a
    $entries = $ldap->get_entries( $filter );
1f953a
1f953a
/*------------|* Do Action if POST 
1f953a
               *
1f953a
               * Description : Actions take place entry by entry. Just one
1f953a
               * entry at the same time. Actually two actions are supported
1f953a
               * (update,delete). */
1f953a
1f953a
    if ( isset( $_POST['useradmin'] ) )
1f953a
    {
1f953a
        // Define useradmin attributes.
1f953a
        $fields = array('cn', 'userpassword', 'displayname', 'preferredlanguage', 'employeetype');
1f953a
1f953a
        // Recover action to do.
1f953a
        $action = $_POST['action'];
1f953a
1f953a
        // Reinitialize entries values based on input and do action if present
1f953a
        $message = $ldap->init_useradmin_values( $entries, $fields, $action );
1f953a
1f953a
1f953a
        // Reload entry value to reflect changes immediately
1f953a
        $entries = $ldap->get_entries( $filter );
1f953a
    }
1f953a
1f953a
//------------/* Display useradmin action results
1f953a
1f953a
    if ( isset( $message ) )
1f953a
    {
1f953a
        echo $message;
1f953a
    }
1f953a
1f953a
//------------/* Display useradmin title 
1f953a
1f953a
    echo '

' . ucfirst(translate(strtolower('admin'))) . ' ' . translate(strtolower('users')) . '

';
1f953a
1f953a
//------------/* Display useradmin form
1f953a
1f953a
?>
1f953a
1f953a
<form name="ldapusers" action="" method="post">
1f953a
1f953a
    

show_useradmin_info( $entries ) ?>

1f953a
1f953a
    
1f953a
1f953a
    
1f953a
1f953a
        
1f953a
1f953a
        <input type="submit" name="useradmin" value="<?php echo ucfirst(translate('accept'))?>" />
1f953a
1f953a
    
1f953a
1f953a
    
1f953a
1f953a
    
1f953a
1f953a
         
1f953a
1f953a
        
1f953a
1f953a
        
1f953a
1f953a
        
1f953a
1f953a
        
1f953a
1f953a
        
1f953a
1f953a
        
1f953a
1f953a
1f953a
    
1f953a
1f953a
1f953a
    
1f953a
        <input type="checkbox" name="uid[<?php echo $i ?>]" value="<?php echo $entries[$i]['uid'][0]; ?>" />
1f953a
        
1f953a
1f953a
1f953a
        <input type="password" name="userpassword[<?php echo $i ?>]" value="<?php echo $entries[$i]['userpassword'][0]; ?>" size="20" />
1f953a
1f953a
        <input type="text" name="cn[<?php echo $i ?>]" value="<?php echo $entries[$i]['cn'][0]; ?>" size="20" />
1f953a
1f953a
        <input type="text" name="displayname[<?php echo $i ?>]" value="<?php echo $entries[$i]['displayname'][0]; ?>" size="10" />
1f953a
1f953a
        
1f953a
        
1f953a
        
1f953a
1f953a
        
1f953a
        
1f953a
        
1f953a
1f953a
    
1f953a
    
1f953a
1f953a
    
1f953a
1f953a
    
1f953a
1f953a
        <input type="submit" name="useradmin" value="<?php echo ucfirst(translate('accept'))?>" />
1f953a
1f953a
    
1f953a
    
1f953a
</form>