Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class RemindMeMail{
- //ADMIN CONFIGURATION
- public $USERNAME="cytometric";
- public $PASSWORD="sistema";
- // SCRIPT CONFIGURATION
- public $DAYS_BEFORE =array(1,3,7,15,30,45,60); // days before the event to get the mail remi
- public $DATE=2; // date format: 1->timestamp --- 2->yyyy/mm/dd
- public $LOGFILE="log.txt"; // log file
- public $RECEIVE_MAIL=1; // 1 to receive mail when cron script runs. 0 to not receive mails
- public $YOUR_EMAIL="bromero@cytometricbioservices.com";
- // DATABASE CONFIGURATION
- public $DB_HOST="localhost";
- public $DB_USER="cytometr_mremind";
- public $DB_PASSWORD="201xcyto";
- public $DB_DATABASE="cytometr_mreminder";
- public $dbConn;
- public $dbConnection;
- // EVENT DB TABLE
- public $DB_TABLE_EVENT="event";
- public $DB_COL_EVENT_ID="id_event"; // the id column of the event
- public $DB_COL_DATE="date"; // the date event column
- public $DB_COL_EVENT="event"; // the event column
- public $DB_COL_RM="isrmensual"; // recordatorio mensual 0/1
- // USER DB TABLE
- public $DB_TABLE_USER="user"; // table where the user mail is
- public $DB_COL_USER_ID="id_user";
- public $DB_COL_USER_MAIL="email";
- // USUARIOS DEL SISTEMA
- public $DB_PANEL_USER="accounts";
- // USER-EVENT TABLE
- public $DB_TABLE_USER_EVENT="user_event"; // user_id - event-id correlation
- public $DB_TABLE_USER_EVENT_ID_USER="id_user";
- public $DB_TABLE_USER_EVENT_ID_EVENT="id_event";
- // EMAIL CONFIGURATION
- public $FROM="Recordatorio de Correo";
- public $FROM_EMAIL="informes@cytometricbioservices.com";
- public $TO;
- public $SUBJECT;
- public $MESSAGE_BODY;
- public function sendMail($to, $subject, $messageBody){
- $HEADERS = "From: $this->FROM <$this->FROM_EMAIL>\n";
- $HEADERS .= "Reply-To: $this->FROM <$this->FROM_EMAIL>\n";
- $HEADERS .= "Return-Path: $this->FROM <$this->FROM_EMAIL>\n";
- $HEADERS .= "Message-ID:<TheSystem@".$_SERVER['SERVER_NAME'].">\n";
- $HEADERS .= "X-Mailer: PHP v".phpversion()."\n";
- $this->TO=$to;
- $this->SUBJECT=$subject;
- $this->MESSAGE_BODY=$messageBody;
- if(mail($this->TO, $this->SUBJECT, $this->MESSAGE_BODY, $HEADERS))
- $this->writeLog($this->getDate(), "Mail sent to: ".$this->TO." #-# ".$this->MESSAGE_BODY);
- else
- $this->writeLog($this->getDate(), "Error sending mail to: ".$this->TO." #-# ".$this->MESSAGE_BODY);
- }
- // like 2011-12-07T12:48:05+01:00
- public function getDate(){
- return date('Y-m-d - G:i:s');
- }
- // write a logfile
- public function writeLog($date, $text){
- $toWrite=$date." #-# ".$text."\n"; // string to write in the logfile
- if (!file_exists($this->LOGFILE))
- touch($this->LOGFILE) or die("can't write file");
- $lines = file($this->LOGFILE); // all the old lines
- $fopen = fopen($this->LOGFILE, "w+");
- fwrite( $fopen, $toWrite); // write the new line
- foreach ($lines as $line) { fwrite( $fopen, "$line"); } // and all the old lines
- fclose($fopen);
- }
- // how many days between 2 dates
- public function differenceDateInDays($date_start, $date_end){
- $start_ts = strtotime($date_start);
- $end_ts = strtotime($date_end);
- $diff = $end_ts - $start_ts;
- return round($diff / 86400);
- }
- // connection to db and db selection
- public function setConnection(){
- $this->dbConn = mysql_connect($this->DB_HOST, $this->DB_USER, $this->DB_PASSWORD) or die ("Connection failed on Server");
- $this->dbConnection = mysql_select_db ($this->DB_DATABASE, $this->dbConn) or die ("Mysql Select failed on Database");
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement