"Fossies" - the Fresh Open Source Software Archive

Member "sqlgreywebinterface-1.1.8/sqlgreywebinterface-1.1.8/connect.php" (10 Aug 2015, 7789 Bytes) of package /linux/privat/old/sqlgreywebinterface-1.1.8.tgz:


The requested HTML page contains a <FORM> tag that is unusable on "Fossies" in "automatic" (rendered) mode so that page is shown as HTML 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 "connect.php" see the Fossies "Dox" file reference documentation.

    1 <?php
    2 
    3 /***********************************************
    4 SQLgrey Web Interface
    5 Filename:   connect.php
    6 Purpose:    Renders the email/domains pages
    7 Version:    1.1.8
    8 ************************************************/
    9 
   10     require "includes/functions.inc.php";
   11     require "includes/connect.inc.php";
   12     
   13     isset($_GET["action"]) ? $action = $_GET["action"] : $action = "";
   14     
   15     // For sort order.
   16     isset($_GET["csort"]) ? $csort = $_GET["csort"] : $csort = "";
   17     isset($_GET["sort"]) ? $sort = $_GET["sort"] : $sort = "";
   18     if ($sort==null || $sort=="") {
   19         $sort = "sender_name";
   20     }
   21     $dir = "asc";
   22     $ndir = "desc";
   23     if ($sort == $csort && $_GET["order"] == "desc") {
   24         $dir = "desc";
   25         $ndir = "asc";
   26     }
   27     
   28     //  Perform demanded action.
   29     $clearit = '<br /><br /><a class="navlike" href="connect.php">Clear this report</a>';
   30     $report2 = "";
   31     switch ($action) {
   32             case "act":
   33                 isset($_POST["acttype"]) ? $acttype = $_POST["acttype"] : $acttype = "";
   34                 isset($_POST["chk"]) ? $chk = $_POST["chk"] : $chk = "";
   35                 switch ($acttype) {
   36                         case "dodelete":
   37                     // For batch deleting.
   38                     if ($chk == '') {
   39                         $report = '<br />Nothing was selected - nothing has been deleted.'.$clearit;
   40                     } else {
   41                         foreach ($chk as $args) {
   42                             $parts = explode("@@", $args);
   43                             forget_entry($parts[0], $parts[1], $parts[2], $parts[3]);
   44                         }
   45                         $report = $deleted.$clearit;
   46                     }
   47                     break;
   48                 case "domove":
   49                     // For batch moving to whitelist.
   50                         if ($chk == '') {
   51                         $report = '<br />Nothing was selected - nothing has been moved.'.$clearit;
   52                     } else {
   53                         foreach ($chk as $args) {
   54                             $parts = explode("@@", $args);
   55                             move_entry($parts[0], $parts[1], $parts[2], $parts[3]);
   56                         }
   57                         $report = $moved.$clearit;
   58                     }
   59                     break;
   60                 case "":
   61                     $report = '<br />Please select Forget... or Move...';
   62                     break;
   63             }
   64                 break;
   65             case "del_old":
   66                 $year = $_POST["year"];
   67                 $month = $_POST["month"];
   68                 $day = $_POST["day"];
   69                 $hour = $_POST["hour"];
   70                 $minute = $_POST["minute"];
   71                 $seconds = $_POST["seconds"];
   72                 $err = 0;
   73             
   74             if ($year < 2000 || $year > 9999) $err = 1;
   75             else if ($month < 1 || $month > 12) $err = 1;
   76             else if ($day < 1 || $day > 31) $err = 1;
   77             else if ($hour < 0 || $hour > 23) $err = 1;
   78             else if ($minute < 0 || $minute > 59) $err = 1;
   79             else if ($seconds < 0 || $seconds > 60) $err = 1; # 60 indeed...
   80             
   81                 del_older_than($year, $month, $day, $hour, $minute, $seconds, $err);
   82             $report2 = $message.$warning; 
   83             $report = "";
   84                 break;
   85             case "":
   86                 $report = "";
   87                 break;
   88     }
   89     
   90     // For the header.
   91     $query = "SELECT COUNT(*) AS count FROM connect";
   92     $result = do_query($query);
   93     $n = fetch_row($result);
   94     
   95     /* mysql> describe connect;
   96       +---------------+---------------+------+-----+---------+-------+
   97       | Field         | Type          | Null | Key | Default | Extra |
   98       +---------------+---------------+------+-----+---------+-------+
   99       | sender_name   | varchar(64)   |      |     |         |       |
  100       | sender_domain | varchar(255)  |      |     |         |       |
  101       | src           | varchar(39)   |      | MUL |         |       |
  102       | rcpt          | varchar(255)  |      |     |         |       |
  103       | first_seen    | timestamp(14) | YES  | MUL | NULL    |       |
  104       +---------------+---------------+------+-----+---------+-------+
  105     */
  106 ?>
  107 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  108      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  109 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  110 
  111 <head>
  112     <title>Greylisted hosts/domains</title>
  113     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  114     <link rel="stylesheet" href="main.css" type="text/css" charset="utf-8" />
  115 </head>
  116 
  117 <body>
  118 
  119 <div id="page">
  120     <div class="navcontainer">
  121         <?php shownav('grey','','con','con'); ?>
  122     </div>
  123     
  124     <table width="100%" border="0" summary="header">
  125             <tr>
  126         <td>
  127             <h1>Greylisted hosts/domains (<?php echo $n["count"] . ")" ?></h1>
  128         </td>
  129         <td align="right">
  130             <a class="navlike" href="#end" title="End of List">EoL</a>
  131         </td>
  132         </tr>
  133     </table>
  134     
  135     <table border="0" summary="sortbar"><?php echo ('
  136         <tr>
  137         <td width="20">&nbsp;</td>
  138         <td width="210"><b><a href="connect.php?sort=sender_name&amp;csort='.$sort.'&amp;order='.$ndir.'">Sender name</a></b></td>
  139         <td width="190"><b><a href="connect.php?sort=sender_domain&amp;csort='.$sort.'&amp;order='.$ndir.'">Sender domain</a></b></td>
  140         <td width="100"><b><a href="connect.php?sort=src&amp;csort='.$sort.'&amp;order='.$ndir.'">IP address</a></b></td>
  141         <td width="260"><b><a href="connect.php?sort=rcpt&amp;csort='.$sort.'&amp;order='.$ndir.'">Recipient</a></b></td>
  142         <td width="120"><b><a href="connect.php?sort=first_seen&amp;csort='.$sort.'&amp;order='.$ndir.'">Seen at</a></b></td>
  143         </tr>
  144     ')?></table>
  145     
  146     <form method="post" action="connect.php?action=act">
  147         <div id="table_con">
  148             <table border="0" summary="data">
  149                 <tr><td><a name="top"></a></td></tr>
  150                 <?php
  151                 if ($sort == "sender_name")
  152                   $order = "sender_name ".$dir.", sender_domain ".$dir;
  153                 else if ($sort == "sender_domain")
  154                   $order = "sender_domain ".$dir.", sender_name ".$dir;
  155                 else
  156                   $order = $sort." ".$dir;
  157                 $query = "SELECT sender_name, sender_domain, src, rcpt, first_seen FROM connect ORDER BY ".$order;
  158                 $result = do_query($query);
  159                 while($line = fetch_row($result)) {
  160                     $sn = $line["sender_name"];
  161                     $sd = $line["sender_domain"];
  162                     $src = $line["src"];
  163                     $sr = $line["rcpt"];
  164                     $fs = $line["first_seen"];
  165                     echo ('
  166                 <tr>
  167                     <td width="20"><input type="checkbox" name="chk[]" value="'.$sn.'@@'.$sd.'@@'.$src.'@@'.$sr.'" /></td>
  168                         <td width="210"><span title="'.$sn.'">'.shorten_it($sn, 30).'</span></td>
  169                         <td width="190"><span title="'.$sd.'">'.shorten_it($sd, 30).'</span></td>
  170                         <td width="100">'.$src.'&nbsp;</td>
  171                     <td width="260"><span title="'.$sr.'">'.shorten_it($sr, 40).'</span></td>
  172                     <td width="120">'.strip_millisecs($fs).'</td>
  173                 </tr>
  174                     ');
  175                 }
  176                 ?>
  177                 <tr><td><a name="end"></a></td></tr>
  178             </table>
  179         </div>
  180         
  181         <br />
  182         
  183         <table width="100%" summary="options">
  184                 <tr>
  185             <td>
  186                 <input type="radio" name="acttype" value="dodelete" /> Forget (delete) selected entries<br />
  187                 <input type="radio" name="acttype" value="domove" /> Move selected entries to whitelist
  188             </td>
  189             <td align="right">
  190                 <a class="navlike" href="#top" title="Top of List">ToL</a>
  191             </td>
  192             </tr>
  193             <tr>
  194                 <td colspan="2"><input class="btn" type="submit" value="Submit" /></td>
  195             </tr>
  196         </table>
  197     </form>
  198     
  199     <?php if (! $report == '' ) echo '<span class="alert">'.$report.'</span>'; ?>
  200 
  201     <div id="form">
  202         <h2>Delete older than...</h2>
  203         <form method="post" action="connect.php?action=del_old&amp;sort=first_seen&amp;csort=first_seen&amp;order=asc">
  204         <table summary="date">
  205                 <tr>
  206             <td>y</td><td>m</td><td>d</td><td>h</td><td>m</td><td>s</td>
  207             </tr>
  208                 <tr class="datefld">
  209             <td><input type="text" value="0" name="year" />-</td>
  210             <td><input type="text" value="0" name="month" />-</td>
  211             <td><input type="text" value="0" name="day" /> </td>
  212             <td><input type="text" value="0" name="hour" />:</td>
  213             <td><input type="text" value="0" name="minute" />:</td>
  214             <td><input type="text" value="0" name="seconds" /></td>
  215             <td><input class="btn" type="submit" value="Delete" /></td>
  216             </tr>
  217         </table>
  218         </form>
  219     </div>
  220     
  221     <?php if (! $report2 == '' ) echo '<span class="alert">'.$report2.'</span>'; ?>
  222     
  223     <div id="footer">
  224         <?php include "includes/copyright.inc.php" ?>
  225     </div>
  226 
  227 </div>
  228 
  229 </body>
  230 
  231 </html>