"Fossies" - the Fresh Open Source Software Archive

Member "openmailadmin-1.0.1/folders.php" (31 May 2007, 2861 Bytes) of package /linux/privat/old/openmailadmin-1.0.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) PHP source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "folders.php" see the Fossies "Dox" file reference documentation.

    1 <?php
    2 include('./inc/_prepend.php');
    3 
    4 if($oma->current_user->mbox != $oma->authenticated_user->mbox) {
    5     error(txt('104'));
    6     include('./inc/_append.php');
    7     exit();
    8 }
    9 
   10 // we shall log in as the current user
   11 $IMAP       = $cfg['Servers']['IMAP'][$_SESSION['server']];
   12 $IMAP['ADMIN']  = $oma->authenticated_user->mbox.$IMAP['VDOM'];
   13 $IMAP['PASS']   = $oma->authenticated_user->password->get_plaintext();
   14 if($cfg['Servers']['IMAP'][$_SESSION['server']]['TYPE'] != 'fake-imap') {
   15     $imap = IMAP_get_instance($IMAP, $cfg['Servers']['IMAP'][$_SESSION['server']]['TYPE']);
   16     $oma->imap  = $imap;
   17 }
   18 
   19 // ACTION
   20 if(isset($_POST['frm']) && $_POST['frm'] == 'ACL') {
   21     if(!isset($_POST['action'])) {
   22         error(txt('112'));
   23     } else
   24     switch($_POST['action']) {
   25         case 'new':
   26             if(isset($_GET['folder'])) {
   27                 $_GET['folder'] = trim($_GET['folder']);
   28                 $_POST['subname']   = trim($_POST['subname']);
   29                 if(preg_match('/[\w\s\d\+\-\_\.\:\~\=]{'.mb_strlen($_POST['subname'], 'UTF-8').'}/u', $_POST['subname'])) {
   30                     $to_be_created = addslashes($_GET['folder'].$imap->gethierarchyseparator().mb_convert_encoding($_POST['subname'], 'UTF7-IMAP', 'UTF-8'));
   31                     if(!$imap->createmb($to_be_created)) {
   32                         error($imap->error_msg);
   33                     }
   34                 } else {
   35                     error(txt('109'));
   36                 }
   37             }
   38             break;
   39         case 'delete':
   40             if(isset($_GET['folder'])) {
   41                 $imap->deletemb(addslashes(trim($_GET['folder'])));
   42                 $_GET['folder'] = 'INBOX';
   43             }
   44             break;
   45         case 'rights':
   46             if(!isset($_POST['moduser']) || trim($_POST['moduser']) == '') {
   47                 error(txt('111'));
   48             } else if(isset($_GET['folder'])) {
   49                 if($_POST['modaclsel'] == 'above') {
   50                     if(isset($_POST['modacl']) && count($_POST['modacl']) > 0)
   51                         $imap->setacl(addslashes(trim($_GET['folder'])), $_POST['moduser'], implode('', $_POST['modacl']));
   52                     if($imap->error_msg != '')
   53                         error($imap->error_msg);
   54                 } else {
   55                     $imap->setacl(addslashes(trim($_GET['folder'])), $_POST['moduser'], addslashes($_POST['modaclsel']));
   56                 }
   57             }
   58             break;
   59     }
   60 }
   61 
   62 // DATA
   63 $raw_folder_list = $imap->getmailboxes();
   64 
   65 // merge all steps
   66 $mbox_arr = array();
   67 for($i = 0; $i < count($raw_folder_list); $i++) {
   68     $mailbox_list[] = $raw_folder_list[$i]['name'];
   69     $mbox_arr = array_merge_recursive($mbox_arr, array_stepper($raw_folder_list[$i]['delimiter'], $raw_folder_list[$i]['name']));
   70 }
   71 
   72 // DISPLAY
   73 include('./templates/'.$cfg['theme'].'/folders/list.tpl');
   74 
   75 // ADMIN PANEL (not hidden by default)
   76 if(isset($_GET['folder']) && in_array($_GET['folder'], $mailbox_list)) {
   77     $ACLs = $imap->getacl($_GET['folder']);
   78     ksort($ACLs);
   79     reset($ACLs);
   80     $has_acl_a = isset($ACLs[$oma->authenticated_user->mbox.$IMAP['VDOM']]) && stristr($ACLs[$oma->authenticated_user->mbox.$IMAP['VDOM']], 'a')
   81             || isset($ACLs['anyone']) && stristr($ACLs['anyone'], 'a');
   82 
   83     include('./templates/'.$cfg['theme'].'/folders/admin.tpl');
   84 }
   85 
   86 include('./inc/_append.php');
   87 ?>