This repository has been archived on 2020-01-20. You can view files and clone it, but cannot push or open issues or pull requests.
bounces-parser/lib/storage.php
Gregory Colpart 2ce7ad8f68 push old code
2015-11-26 16:30:00 +01:00

54 lines
1.3 KiB
PHP

<?php
/**
* database object
*
* Copyright (c) 2009 Evolix - Tous droits reserves
*
* $Id: storage.php 26 2010-01-11 10:01:45Z spalma $
* vim: expandtab softtabstop=4 tabstop=4 shiftwidth=4 showtabline=2
*
* @author Thomas Martin <tmartin@evolix.fr>
* @author Sebastien Palma <spalma@evolix.fr>
* @version 0.1
*/
require_once('../lib/Mysql.php');
class databaseStorage {
private $mysql=NULL;
private $connexion=NULL;
public function __construct() {
$this->mysql = new Mysql();
$this->connexion = $this->mysql->MyConnect();
}
public function store_in_db($bounce, $mailbox='') {
$sql = "INSERT INTO `bounces";
if ($mailbox!='') $sql .= "_$mailbox";
$sql.= "` VALUES(NULL,";
$sql.= "'".$bounce->getStatus()."',";
$sql.= "'".$bounce->getMessageID()."',";
$sql.= "'".$bounce->getErrorCode()."',";
$sql.= "'".$bounce->getBounceReason()."',";
$sql.= "'".$bounce->getServerAnswer()."',";
$sql.= "'".date('Y-m-d H:i:s')."',";
$sql.= "'".$bounce->getBouncedEmail()."',";
$domain='';
$email_parts = explode('@', $bounce->getBouncedEmail());
if (is_array($email_parts) && array_key_exists(1, $email_parts)) $domain=$email_parts[1];
$sql.= "'".$domain."'";
$sql.= ")";
//echo "$sql\n";
$this->mysql->MyReq($this->connexion, $sql);
}
}