OSDN Git Service

modified code to prevent DB inflation
[opengatem/opengatem.git] / phpsrc / sendreportmail.php
index fb62ae2..785935d 100755 (executable)
@@ -38,12 +38,6 @@ if(!(list($device, $mailAddress)=getDataFromMysql($macAddress))){
        return;
 }
 
-// if reported recently, skip reporting
-if(skipReporting($link, $macAddress, $gatewayName, $reportInterval)){
-       mysqli_close($link);
-       return;
-}
-
 // close database
 mysqli_close($link);
 
@@ -131,37 +125,6 @@ function getDataFromMysql($macAddress){
 }
 
 /***
-To avoid to send too many mails, 
- skip if there are recent logs having same macaddress and same gateway. 
-If you want to change the report period, $reportPeriod is defined at the top of this file.
-***/
-function skipReporting($link, $macAddress, $gatewayName, $reportInterval){
-       
-       // query
-       $result = mysqli_query($link, 'SELECT count(*) FROM sessionmd '
-               .'WHERE EXISTS (SELECT * FROM sessionmd '
-               .'WHERE macAddress="'.$macAddress.'" '
-               .'AND gatewayName LIKE "'.$gatewayName.'.%" '
-               .'AND openTime > NOW() - INTERVAL '.$reportInterval.' '
-               .'AND openTime < NOW() - INTERVAL 1 MINUTE '
-               .')'
-               );
-
-       if (!$result){
-               syslog(LOG_INFO, 'ERR: Fail query '.mysqli_error());
-               return TRUE;
-       }
-
-       // get data
-       if($row = mysqli_fetch_row($result)) $count = $row[0];
-       else    $count = 0;
-
-       // if recent logs exist, skip is true
-       if($count>0)return TRUE;
-       else return FALSE;
-}
-
-/***
 send mail to the user mail address
 ***/
 function sendMailToUser($mailSender, $mailAddress, $device, $gatewayName,