phpMailStats.php3
上传用户:wl2659
上传日期:2007-01-04
资源大小:8k
文件大小:3k
源码类别:

WEB邮件程序

开发平台:

PHP

  1. <?php
  2.  require("dbase.inc");
  3.  $lnk = mysql_connect("$hostname", "$user", "$password");
  4.  $All = mysql_db_query ($db, "
  5.           SELECT         
  6.              DATE_FORMAT(t_stamp, 'm/d/Y h:i:s') as frmt_stamp, 
  7.              DATE_FORMAT(NOW(), 'm/d/Y') as frmmaxt_stamp,
  8.              DATE_FORMAT(min(t_stamp), 'm/d/Y') as frmmint_stamp,
  9.              TO_DAYS(NOW())+1-TO_DAYS(min(t_stamp)) as totaldays
  10.           FROM
  11.              $table
  12.           GROUP BY 
  13.              t_stamp
  14.           ORDER
  15.              BY t_stamp", $lnk);
  16.  $totalmails = mysql_num_rows($All);
  17.  $Entries = mysql_db_query($db, "
  18.           SELECT 
  19.              *,
  20.              DATE_FORMAT(t_stamp, 'm/d/Y h:i:s') as frmt_stamp
  21.           FROM 
  22.              maillog
  23.           ORDER BY
  24.              t_stamp
  25.              DESC
  26.           LIMIT 75", $lnk);
  27.  $Recipient = mysql_db_query($db, "
  28.           SELECT 
  29.              recipient,
  30.              count(recipient) as qnt 
  31.           FROM
  32.              maillog
  33.           GROUP BY
  34.              recipient 
  35.           ORDER BY
  36.              qnt", $lnk);
  37. ?>
  38. <head>
  39. <title>phpEasyMail Statistics</title>
  40. <link rel="stylesheet" href="styles.css"></head>
  41. <body bgcolor="#FFFFFF">
  42. <div align="center"> 
  43.   <h1>phpEasyMail</h1>
  44.   <?php $rowAll = mysql_fetch_array($All);?>
  45.   <p align="center"><b>Statistics for <?php echo $rowAll[frmmint_stamp];?> to <?php echo $rowAll[frmmaxt_stamp];?>:</b></p>
  46.   <table border="0" align="center">
  47.     <tr> 
  48.       <td>Total mails sent: </td>
  49.       <td><?php echo $totalmails;?></td>
  50.     </tr>
  51.     <tr> 
  52.       <td>Avg. mails per day:</td>
  53.       <td><?php 
  54.           $totaldays = $rowAll[totaldays];
  55.           echo number_format($totalmails/$totaldays, 2);
  56.           ?></td>
  57.     </tr>
  58.        <?php 
  59.         while ($rowRecipient = mysql_fetch_array($Recipient))
  60.               {
  61.               echo " <tr>n";
  62.               $percent = 100 * $rowRecipient[qnt] / $totalmails;
  63.               $percent = number_format($percent,2);
  64.               $percentoff = 100 - $percent;
  65.               echo "  <td>$rowRecipient[recipient]</td><td><img src="percent.gif" height="4" width="$percent"><img src="percentoff.gif" height="4" width="$percentoff"> $percent% ($rowRecipient[qnt])</td>n";
  66.               echo " </tr>n";
  67.               }
  68.        ?> 
  69.   </table>
  70.   <table border="1" align="center">
  71.   <tr>
  72.    <th>Time</th><th>Remote Host</th><th>Sender</th><th>Recipient</th><th>Subject</th>
  73.   </tr>
  74.   <?
  75.     while ($row = mysql_fetch_array($Entries))
  76.           {
  77.           print "   <tr>n";
  78.           print "    <td>$row[frmt_stamp]</td><td>$row[host]</td><td>$row[sender]</td><td>$row[recipient]</td><td>$row[subject]</td>n";
  79.           print "   </tr>n";
  80.           }
  81.   ?>
  82.   </table>
  83. </div>
  84. </body>
  85. </html>