"Fossies" - the Fresh Open Source Software Archive

Member "openmailadmin-1.0.1/inc/panel_filter.php" (6 Nov 2007, 4166 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 "panel_filter.php" see the Fossies "Dox" file reference documentation.

    1 <?php
    2 // calculate LIMIT and OFFSET for SQL
    3 if(!isset($_SESSION['limit'])) {
    4     $_SESSION['limit'] = $cfg['max_elements_per_page'];
    5 }
    6 if(!isset($_SESSION['offset']) || isset($_POST['limit'])) {
    7     $_SESSION['offset']
    8         = array('address' => -1, 'regexp' => -1, 'domain' => -1, 'mbox' => -1,
    9             'addr_page' => 0, 'regx_page' => 0, 'dom_page' => 0, 'mbox_page' => 0);
   10 }
   11 if(isset($_POST['limit'])) {
   12     if(is_numeric($_POST['limit'])) {
   13         $_SESSION['limit']  = intval($_POST['limit']);
   14     } else {
   15         $_SESSION['limit']  = -1;
   16     }
   17 }
   18 if(isset($_GET['addr_page']) && is_numeric($_GET['addr_page'])) {
   19     $_SESSION['offset']['address'] = max(-1, (intval($_GET['addr_page']) - 1) * $_SESSION['limit']);
   20     $_SESSION['offset']['addr_page'] = intval($_GET['addr_page']);
   21     unset($_GET['addr_page']);
   22 }
   23 if(isset($_GET['regx_page']) && is_numeric($_GET['regx_page'])) {
   24     $_SESSION['offset']['regexp'] = max(-1, (intval($_GET['regx_page']) - 1) * $_SESSION['limit']);
   25     $_SESSION['offset']['regx_page'] = intval($_GET['regx_page']);
   26     unset($_GET['regx_page']);
   27 }
   28 if(isset($_GET['dom_page']) && is_numeric($_GET['dom_page'])) {
   29     $_SESSION['offset']['domain'] = max(-1, (intval($_GET['dom_page']) - 1) * $_SESSION['limit']);
   30     $_SESSION['offset']['dom_page'] = intval($_GET['dom_page']);
   31     unset($_GET['dom_page']);
   32 }
   33 if(isset($_GET['mbox_page']) && is_numeric($_GET['mbox_page'])) {
   34     $_SESSION['offset']['mbox'] = max(-1, (intval($_GET['mbox_page']) - 1) * $_SESSION['limit']);
   35     $_SESSION['offset']['mbox_page'] = intval($_GET['mbox_page']);
   36     unset($_GET['mbox_page']);
   37 }
   38 if(isset($_SESSION['limit']) && $_SESSION['limit']) {
   39     $_POST['limit'] = $_SESSION['limit'];
   40 }
   41 // now on creating additional WHERE
   42 if(isset($_POST['filtr']) && !isset($_POST['filtr_addr'])) {
   43     $_SESSION['filter']['active'] = false;
   44     $_SESSION['filter']['str'] = array('address' => '', 'regexp' => '', 'domain' => '', 'mbox' => '');
   45 } else if((isset($_SESSION['filter']['active']) && $_SESSION['filter']['active']) || (isset($_POST['filtr_addr']) && $_POST['filtr_addr'] == 1)) {
   46     $_SESSION['filter']['active'] = true; $_POST['filtr_addr'] = 1;
   47 }
   48 if(isset($_POST['filtr']) && isset($_POST['filtr_addr']) && $_POST['filtr'] == 'set' && trim($_POST['cont']) != '') {
   49     $filtr_post = '';
   50     $_SESSION['filter']['str'] = array('address' => '', 'regexp' => '', 'domain' => '', 'mbox' => '');
   51     switch($_POST['cond']) {
   52         case 'has':
   53             $filtr_post = $db->qstr('%'.str_replace(txt('5'), $oma->current_user->mbox, $_POST['cont']).'%');
   54             break;
   55         case 'begins':
   56             $filtr_post = $db->qstr(str_replace(txt('5'), $oma->current_user->mbox, $_POST['cont']).'%');
   57             break;
   58         case 'ends':
   59             $filtr_post = $db->qstr('%'.str_replace(txt('5'), $oma->current_user->mbox, $_POST['cont']));
   60             break;
   61     }
   62     switch($_POST['what']) {
   63         case 'addr':
   64             $_SESSION['filter']['str']['address'] = ' AND address LIKE '.$filtr_post;
   65             break;
   66         case 'target':
   67             $_SESSION['filter']['str']['address'] = ' AND dest LIKE '.$filtr_post;
   68             $_SESSION['filter']['str']['regexp'] = ' AND dest LIKE '.$filtr_post;
   69             break;
   70         case 'domain':
   71             $_SESSION['filter']['str']['address'] = ' AND SUBSTRING_INDEX(address, "@", -1) LIKE '.$filtr_post;
   72             $_SESSION['filter']['str']['domain'] = ' AND domain LIKE '.$filtr_post;
   73             break;
   74         case 'mbox':
   75             $_SESSION['filter']['str']['mbox'] = ' AND mbox LIKE '.$filtr_post;
   76             $_SESSION['filter']['str']['domain'] = ' AND owner LIKE '.$filtr_post;
   77             break;
   78     }
   79 
   80     $_SESSION['filter']['active'] = true;
   81     $_SESSION['filter']['what'] = $_POST['what'];
   82     $_SESSION['filter']['cond'] = $_POST['cond'];
   83     $_SESSION['filter']['cont'] = $_POST['cont'];
   84 }
   85 if(isset($_SESSION['filter']['active'])) {
   86     if($_SESSION['filter']['active']) $_POST['filtr_addr'] = 1;
   87     $_POST['what'] = isset($_SESSION['filter']['what']) ? $_SESSION['filter']['what'] : '';
   88     $_POST['cond'] = isset($_SESSION['filter']['cond']) ? $_SESSION['filter']['cond'] : '';
   89     $_POST['cont'] = isset($_SESSION['filter']['cont']) ? $_SESSION['filter']['cont'] : '';
   90 }
   91 if(!isset($_SESSION['filter'])) {
   92     $_SESSION['filter']['str'] = array('address' => '', 'regexp' => '', 'domain' => '', 'mbox' => '');
   93 }
   94 // DISPLAY
   95 include('./templates/'.$cfg['theme'].'/filter_panel.tpl');
   96 
   97 ?>