Example #1
0
    return $encodedStr;
}
date_default_timezone_set('America/Los_Angeles');
$db = new mysqldb();
// First lets check for any jobs which are a) Schedule for any time NOW or before AND b) Status is PENDING (0)
// Now we need member id of campaign...  later we'll need list id... we can probably do this as part of the same query with a join
// while we're at it, let's get the message details?
$now = date('Y-m-d G:i:s', strtotime("now"));
$sql = "SELECT \r\nXJ.XE_JOB_ID AS JID,\r\nXJ.XE_JOB_CAMPAIGN_ID AS CID,\r\nXC.XE_CAMPAIGN_MID AS MID,\r\nXC.XE_CAMPAIGN_LIST_ID AS GID,\r\nXM.XE_MSG_FROM_LABEL AS FROM_LABEL,\r\nXM.XE_MSG_FROM_EMAIL AS FROM_EMAIL,\r\nXM.XE_MSG_SUBJECT AS SUBJECT,\r\nXM.XE_MSG_REPLY_TO AS REPLYTO,\r\nXM.XE_MSG_UNSUBSCRIBE AS UNSUBSCRIBE,\r\nXM.XE_MSG_POSTAL_ADDRESS AS ADDRESS,\r\nXM.XE_MSG_TEMPLATE_TEXT AS MSG_TXT,\r\nXM.XE_MSG_TEMPLATE_HTML AS MSG_HTML\r\nFROM XEBURA_JOBS AS XJ\r\nJOIN XEBURA_CAMPAIGN AS XC ON XJ.XE_JOB_CAMPAIGN_ID = XC.XE_CAMPAIGN_ID\r\nJOIN XEBURA_MESSAGE  AS XM ON XJ.XE_JOB_CAMPAIGN_ID = XM.XE_MSG_CAMPAIGN_ID\r\nWHERE XE_JOB_LAUNCH <= '" . $now . "'\r\nAND XE_JOB_STATUS = '0'";
//job status 0 = pending
// now that we've got the campaigns, we need to loop over them..
$db->query($sql);
$result = $db->query($sql);
$total_items = $db->getNumRows($result);
if ($db->getNumRows($result) > 0) {
    while (list($jid, $cid, $mid, $gid, $from_label, $from_email, $subject, $replyto, $unsubscribe, $address, $msg_txt, $msg_html) = $db->fetchQueryRow($result)) {
        // get the amazon credentials for the campaign creator
        $res = $db->query("SELECT\r\nXE_AMZ_ACCESS_KEY AS ACCESS_KEY,\r\nXE_AMZ_SECRET_KEY AS SECRET_KEY\r\nFROM XEBURA_AMAZON_CREDENTIALS\r\nWHERE XE_AMZ_MID = '" . $mid . "'");
        $row = $db->fetchQueryArray($res);
        $amz_akey = $row['ACCESS_KEY'];
        $amz_skey = $row['SECRET_KEY'];
        // intialize ses class
        $ses = new SimpleEmailService($amz_akey, $amz_skey);
        // now for our inner loop, let's find out who we're supposed to send this campaign out to, and loop over them.
        // need to add check for sending allowed status on email record to this query later
        // remove LIMIT
        // update campaign as launched
        $values = array(XE_CAMPAIGN_STATUS => '2');
        // status 2 = launched
        $db->update("XEBURA_CAMPAIGN", $values, "WHERE XE_CAMPAIGN_ID = '" . $cid . "'");
        ////update job as running
Example #2
0
//               256 South Robertson Blvd
//               Beverly Hills, CA 90211
//               USA
//               www.xebura.com
//               hello@xebura.com
//============================================================+
// this script tracks link clicks and redirects the user to the link
require 'class/dbclass.php';
include_once 'include/config.php';
date_default_timezone_set('America/Los_Angeles');
$db = new mysqldb();
$now = date('Y-m-d G:i:s', strtotime("now"));
$ip = $_SERVER['REMOTE_ADDR'];
$eid = $_REQUEST['i'];
$lid = $_REQUEST['l'];
$sql = "SELECT XE_LINK_CAMPAIGN_ID, XE_LINK_MID, XE_LINK_URL FROM XEBURA_LINK WHERE XE_LINK_ID = '" . $lid . "'";
$result = $db->query($sql);
if ($db->getNumRows($result) > 0) {
    while (list($cid, $mid, $url, $amount) = $db->fetchQueryRow($result)) {
        // count every click
        // log the event to the statistics table
        $values = array(XE_STAT_CAMPAIGN_ID => $cid, XE_STAT_MID => $mid, XE_STAT_EMAIL_ID => $eid, XE_STAT_LINK_ID => $lid, XE_STAT_TYPE => '2', XE_STAT_IP => $ip, XE_STAT_TIMESTAMP => $now);
        $stat = $db->insert("XEBURA_STATISTICS", $values);
        //echo 'update - open';
        header("Location:" . $url);
        exit;
    }
} else {
    echo 'invalid url';
    exit;
}