diff options
| author | Christian Fowler <spider@viovio.com> | 2005-12-29 17:23:05 +0000 |
|---|---|---|
| committer | Christian Fowler <spider@viovio.com> | 2005-12-29 17:23:05 +0000 |
| commit | 4918af1a903bac5765cbf8709cfe2ce7f41ff082 (patch) | |
| tree | bf3e229faa3fb3e6209aac40e15f2804c9a527af | |
| parent | 4ef765eb33d8121228668bb4124a52c40ab5b980 (diff) | |
| download | newsletters-4918af1a903bac5765cbf8709cfe2ce7f41ff082.tar.gz newsletters-4918af1a903bac5765cbf8709cfe2ce7f41ff082.tar.bz2 newsletters-4918af1a903bac5765cbf8709cfe2ce7f41ff082.zip | |
add newsletter email read tracking
| -rw-r--r-- | BitMailer.php | 14 | ||||
| -rw-r--r-- | admin/schema_inc.php | 4 | ||||
| -rw-r--r-- | images/track.gif | bin | 0 -> 43 bytes | |||
| -rw-r--r-- | index.php | 15 | ||||
| -rw-r--r-- | track.php | 31 |
5 files changed, 47 insertions, 17 deletions
diff --git a/BitMailer.php b/BitMailer.php index 33219f6..298e1a0 100644 --- a/BitMailer.php +++ b/BitMailer.php @@ -1,12 +1,12 @@ <?php /** - * $Header: /cvsroot/bitweaver/_bit_newsletters/Attic/BitMailer.php,v 1.10 2005/12/29 15:31:29 spiderr Exp $ + * $Header: /cvsroot/bitweaver/_bit_newsletters/Attic/BitMailer.php,v 1.11 2005/12/29 17:22:47 spiderr Exp $ * * Copyright (c) 2004 bitweaver.org * All Rights Reserved. See copyright.txt for details and a complete list of authors. * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details * - * $Id: BitMailer.php,v 1.10 2005/12/29 15:31:29 spiderr Exp $ + * $Id: BitMailer.php,v 1.11 2005/12/29 17:22:47 spiderr Exp $ * * Class that handles editions of newsletters * @package newsletters @@ -15,7 +15,7 @@ * * @author spiderr <spider@steelsun.com> * - * @version $Revision: 1.10 $ $Date: 2005/12/29 15:31:29 $ $Author: spiderr $ + * @version $Revision: 1.11 $ $Date: 2005/12/29 17:22:47 $ $Author: spiderr $ */ /** @@ -101,7 +101,7 @@ class BitMailer extends phpmailer { $pick['url_code'] = md5( $pick['content_id'].$pick['email'].$pick['queue_date'] ); $gBitSmarty->assign( 'url_code', $pick['url_code'] ); $unsub = $gBitSmarty->fetch( 'bitpackage:newsletters/unsubscribe_inc.tpl' ); - $htmlBody = $unsub . $body[$pick['content_id']]['body'] . $unsub; + $htmlBody = $unsub . $body[$pick['content_id']]['body'] . $unsub . '<img src="'.NEWSLETTERS_PKG_URI.'track.php?sub='.$pick['url_code'].'" alt="" />'; if( !$this->sendMail( $pick, $body[$pick['content_id']]['subject'], $htmlBody ) ) { $this->logError( $pick ); @@ -136,6 +136,12 @@ class BitMailer extends phpmailer { return $ret; } + function trackMail( $pUrlCode ) { + global $gBitDb; + $query = "UPDATE `".BIT_DB_PREFIX."tiki_mail_queue` SET `reads`=`reads`+1, `last_read_date`=? WHERE `url_code`=? "; + $gBitDb->query( $query, array( time(), $pUrlCode ) ); + } + function logError( $pInfo ) { if( !empty( $pInfo['url_code'] ) && !$this->mDb->getOne( "SELECT `url_code` FROM `".BIT_DB_PREFIX."tiki_mail_errors` WHERE `url_code`=?", array( $pInfo['url_code'] ) ) ) { $store['url_code'] = $pInfo['url_code']; diff --git a/admin/schema_inc.php b/admin/schema_inc.php index 3f16b01..cf09edd 100644 --- a/admin/schema_inc.php +++ b/admin/schema_inc.php @@ -60,7 +60,9 @@ $tables = array( url_code C(32), queue_date I8 NOTNULL, begin_date I8, - sent_date I8 + sent_date I8, + last_read_date I8, + reads I2 NOTNULL DEFAULT '0' CONSTRAINTS ', CONSTRAINT `tiki_nl_mailq_ed_ref` FOREIGN KEY (`edition_id`) REFERENCES `".BIT_DB_PREFIX."tiki_newsletters_editions`( `edition_id` ), , CONSTRAINT `tiki_nl_mailq_user_ref` FOREIGN KEY (`users_id`) REFERENCES `".BIT_DB_PREFIX."users_users`( `users_id` )' " diff --git a/images/track.gif b/images/track.gif Binary files differnew file mode 100644 index 0000000..e7749f2 --- /dev/null +++ b/images/track.gif @@ -1,31 +1,22 @@ <?php +// $Header: /cvsroot/bitweaver/_bit_newsletters/index.php,v 1.15 2005/12/29 17:22:47 spiderr Exp $ -// $Header: /cvsroot/bitweaver/_bit_newsletters/index.php,v 1.14 2005/12/29 15:31:32 spiderr Exp $ - -// Copyright (c) 2002-2003, Luis Argerich, Garland Foster, Eduardo Polidor, et. al. +// Copyright (c) 2006 - bitweaver.org - Christian Fowler, Max Kremmel, et. al // All Rights Reserved. See copyright.txt for details and a complete list of authors. // Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details. // Initialization require_once( '../bit_setup_inc.php' ); - include_once( NEWSLETTERS_PKG_PATH.'BitMailer.php' ); $gBitSystem->verifyPackage( 'newsletters' ); -$gBitSmarty->assign('confirm', 'n'); -if( isset( $_REQUEST["confirm_subscription"] ) ) { - if( $conf = $gContent->confirmSubscription( $_REQUEST["confirm_subscription"] ) ) { - $gBitSmarty->assign( 'confirm', 'y' ); - $gBitSmarty->assign( 'nl_info', $conf ); - } -} - if( !$gBitUser->isRegistered() && !$gBitUser->hasPermission( 'bit_p_subscribe_newsletters' ) && empty( $_REQUEST["sub"] ) ) { $gBitSystem->fatalError( tra("You must be logged in to subscribe to newsletters")); } require_once( NEWSLETTERS_PKG_PATH.'lookup_newsletter_inc.php' ); + $feedback = array(); /* List newsletters */ diff --git a/track.php b/track.php new file mode 100644 index 0000000..ae213e1 --- /dev/null +++ b/track.php @@ -0,0 +1,31 @@ +<?php +// $Header: /cvsroot/bitweaver/_bit_newsletters/track.php,v 1.1 2005/12/29 17:22:47 spiderr Exp $ + +// Copyright (c) 2006 - bitweaver.org - Christian Fowler, Max Kremmel, et. al +// All Rights Reserved. See copyright.txt for details and a complete list of authors. +// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details. + +require_once( '../bit_setup_inc.php' ); +include_once( NEWSLETTERS_PKG_PATH.'BitMailer.php' ); + +if( isset( $_REQUEST["sub"] ) || $gBitUser->isRegistered() ) { + if( isset( $_REQUEST["sub"] ) && strlen( $_REQUEST["sub"] ) == 32 && ($subInfo = BitMailer::lookupSubscription( array( 'url_code' => $_REQUEST["sub"] ) )) ) { + BitMailer::trackMail( $subInfo['url_code'] ); + } +} + +// open the file in a binary mode +$trackImage = $gBitSystem->getPreference( 'newsletter_tracking_image', NEWSLETTERS_PKG_PATH.'images/track.gif' ); + +if( $fp = fopen( $trackImage, 'rb') ) { + // send the right headers + header( "Content-Type: image/png" ); + header( "Content-Length: " . filesize( $trackImage ) ); + + // dump the picture and stop the script + fpassthru( $fp ); +} + +exit; + +?>
\ No newline at end of file |
