Initial Commit of AgileBill Open Source

This commit is contained in:
unknown
2008-11-26 14:50:40 -08:00
parent ae5a0fc25e
commit 02306ccc47
2954 changed files with 410976 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
<?php
/**
* AgileBill - Open Billing Software
*
* This body of work is free software; you can redistribute it and/or
* modify it under the terms of the Open AgileBill License
* License as published at http://www.agileco.com/agilebill/license1-4.txt
*
* For questions, help, comments, discussion, etc., please join the
* Agileco community forums at http://forum.agileco.com/
*
* @link http://www.agileco.com/
* @copyright 2004-2008 Agileco, LLC.
* @license http://www.agileco.com/agilebill/license1-4.txt
* @author Tony Landis <tony@agileco.com>
* @package AgileBill
* @version 1.4.93
*/
$auth_methods = Array
(
Array ('module' => 'campaign', 'method' => 'display'),
Array ('module' => 'campaign', 'method' => 'click'),
Array ('module' => 'campaign', 'method' => 'affiliate')
);
?>

View File

@@ -0,0 +1,701 @@
<?php
/**
* AgileBill - Open Billing Software
*
* This body of work is free software; you can redistribute it and/or
* modify it under the terms of the Open AgileBill License
* License as published at http://www.agileco.com/agilebill/license1-4.txt
*
* For questions, help, comments, discussion, etc., please join the
* Agileco community forums at http://forum.agileco.com/
*
* @link http://www.agileco.com/
* @copyright 2004-2008 Agileco, LLC.
* @license http://www.agileco.com/agilebill/license1-4.txt
* @author Tony Landis <tony@agileco.com>
* @package AgileBill
* @version 1.4.93
*/
class campaign
{
# Open the constructor for this mod
function campaign()
{
# name of this module:
$this->module = "campaign";
# location of the construct XML file:
$this->xml_construct = PATH_MODULES . "" . $this->module . "/" . $this->module . "_construct.xml";
# open the construct file for parsing
$C_xml = new CORE_xml;
$construct = $C_xml->xml_to_array($this->xml_construct);
$this->method = $construct["construct"]["method"];
$this->trigger = $construct["construct"]["trigger"];
$this->field = $construct["construct"]["field"];
$this->table = $construct["construct"]["table"];
$this->module = $construct["construct"]["module"];
$this->cache = $construct["construct"]["cache"];
$this->order_by = $construct["construct"]["order_by"];
$this->limit = $construct["construct"]["limit"];
}
##############################
## CLICK ##
##############################
function click($VAR)
{
### Set the forward URL
if(!empty($VAR['caid']))
{
$db = &DB();
$sql = 'SELECT * FROM ' . AGILE_DB_PREFIX . 'campaign WHERE
site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND
id = ' . $db->qstr(@$VAR['caid']);
$result = $db->Execute($sql);
if (strlen($result->fields['url']) >= 1) $url = $result->fields['url'];
}
if(empty($url)) $url = URL;
echo '<script language="JavaScript"> <!-- START
document.location="'.$url.'";
// END -->
</SCRIPT>';
### LOG the click
if(!isset($VAR['_log']) && !empty($VAR['caid']))
{
if(isset($VAR['file']))
$file_no = $VAR['file'];
else
$file_no = '1';
$count_field= 'clicked'.$file_no;
$count = $result->fields[$count_field] + 1;
$sql = 'UPDATE ' . AGILE_DB_PREFIX . 'campaign SET
'.$count_field.' = ' . $db->qstr($count) . ' WHERE
site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND
id = ' . $db->qstr(@$VAR['caid']);
$result = $db->Execute($sql);
}
}
##############################
## DISPLAY ##
##############################
function display($VAR)
{
$db = &DB();
$sql = 'SELECT * FROM ' . AGILE_DB_PREFIX . 'campaign WHERE
site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND
id = ' . $db->qstr(@$VAR['id']);
$result = $db->Execute($sql);
if(isset($VAR['file']))
$file_no = $VAR['file'];
else
$file_no = '1';
$file = PATH_FILES . 'campaign_' . $VAR['id'] . '_' . $file_no .'.dat';
$type = 'type'.$file_no;
$name = 'file'.$file_no;
$count_field= 'served'.$file_no;
$count = $result->fields[$count_field] + 1;
if($result->RecordCount() > 0)
{
### Open the file
if (@$file=fopen($file, 'r'))
{
### Display the correct headers:
header ("Content-type: " . $result->fields[$type]);
header ("Content-Disposition: inline; filename=" . $result->fields[$name]);
header ("Content-Description: PHP/INTERBASE Generated Data" );
fpassthru($file);
### Increment the file
if(!isset($VAR['_log']))
{
$sql = 'UPDATE ' . AGILE_DB_PREFIX . 'campaign SET
'.$count_field.' = ' . $db->qstr($count) . ' WHERE
site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND
id = ' . $db->qstr(@$VAR['id']);
$result = $db->Execute($sql);
}
exit;
}
}
echo 'Sorry, the campaign or required file does not exist!';
}
##############################
## ADD ##
##############################
function add($VAR)
{
global $_FILES;
# Validate the files
for($i=1; $i<=12; $i++) {
if(isset($_FILES['upload_file'.$i]) && $_FILES['upload_file'.$i]['size'] > 0) {
$VAR['campaign_type'.$i] = $_FILES['upload_file'.$i]['type'];
$VAR['campaign_file'.$i] = $_FILES['upload_file'.$i]['name'];
}
}
## Attempt to add the record:
$type = "add";
$this->method["$type"] = split(",", $this->method["$type"]);
$db = new CORE_database;
$campaign_id = $db->add($VAR, $this, $type);
### Copy the files & delete temp files
if($campaign_id > 0) {
for($i=1; $i<=12; $i++) {
if(isset($_FILES['upload_file'.$i]) && $_FILES['upload_file'.$i]['size'] > 0)
{
if(!copy($_FILES['upload_file'.$i]['tmp_name'], PATH_FILES . 'campaign_'.$campaign_id.'_'.$i.'.dat'))
{
### ERROR:
}
#unlink any temp files
unlink($_FILES['upload_file'.$i]['tmp_name']);
}
}
}
}
##############################
## VIEW ##
##############################
function view($VAR)
{
$type = "view";
$this->method["$type"] = split(",", $this->method["$type"]);
$db = new CORE_database;
$smart = $db->view($VAR, $this, $type);
#print_r($smart);
for($i=0;$i<count($smart); $i++)
{
# Get the stats for each advertisement:
$budget = $smart[$i]['budget'];
# Total Impressions, Total Clicks, & Accounts referred
$smart[$i]['impressions_total'] = 0;
$smart[$i]['clicks_total'] = 0;
$smart[$i]['accounts_referred'] = $this->referred_accounts($smart[$i]['id']);
# Invoices referred
$inv = $this->referred_invoices($smart[$i]['id']);
$smart[$i]['invoices_referred'] = $inv[0];
$smart[$i]['invoices_revenue'] = round( $inv[1], 2);
# total impressions & clicks:
$impressions_total=0;
$clicks_total=0;
for($ii=1; $ii<=12; $ii++)
{
$impressions_total += $smart[$i]["served".$ii];
$clicks_total += $smart[$i]["clicked".$ii];
if(empty($smart[$i]["served".$ii]) && empty($smart[$i]["served".$ii]) && empty($smart[$i]["served".$ii]))
$smart[$i]["show".$ii] = false;
else
$smart[$i]["show".$ii] = true;
}
$smart[$i]['impressions_total'] = $impressions_total;
$smart[$i]['clicks_total'] = $clicks_total;
# Impr. percentage, Clicks percentage, CTR
$ctr_count = 0;
$ctr_amt = 0;
for($ii=1; $ii<=12; $ii++)
{
# Impr. percentage
if( $smart[$i]["show".$ii] )
{
$impressions_percentage = $smart[$i]["served".$ii] / $impressions_total;
$smart[$i]['impressions_percentage'.$ii] = "(".round($impressions_percentage*100)."%)";
} else {
$smart[$i]['impressions_percentage'.$ii] = '';
}
# Clicks percentage
if( $smart[$i]["show".$ii] ) {
@$clicks_percentage = ($smart[$i]["clicked".$ii] / $clicks_total);
$smart[$i]['clicks_percentage'.$ii] = "(".round($clicks_percentage*100)."%)";
} else {
$smart[$i]['clicks_percentage'.$ii] = '';
}
# Cost
if( $smart[$i]["show".$ii] ) {
$impressions_percentage = $smart[$i]["served".$ii] / $impressions_total;
$smart[$i]['cost'.$ii] = round($budget * $impressions_percentage, 2);
} else {
$smart[$i]['cost'.$ii] = "0";
}
# CTR
if( $smart[$i]["show".$ii] ) {
$ctr = ( $smart[$i]["clicked".$ii] / $smart[$i]["served".$ii] ) * 100;
if($ctr < 0)
$smart[$i]['ctr'.$ii] = round($ctr).'%';
else
$smart[$i]['ctr'.$ii] = round($ctr,1).'%';
$ctr_count++;
$ctr_amt += $ctr;
} else {
$smart[$i]['ctr'.$ii] = "0%";
$ctr_count++;
}
}
# CTR Avg:
if($ctr_count > 0)
$smart[$i]['ctr_avg'] = round( $ctr_amt / $ctr_count, 2) .'%';
else
$smart[$i]['ctr_avg'] = "0%";
# CPC Avg:
if($clicks_total > 0) {
$cpc_avg = $budget / $clicks_total;
if($cpc_avg < .1)
$smart[$i]['cpc_avg'] = round($cpc_avg,3);
else
$smart[$i]['cpc_avg'] = round($cpc_avg,2);
} else {
$smart[$i]['cpc_avg'] = 0;
}
# CPI Avg:
if($impressions_total > 0) {
$cpi_avg = $budget / $impressions_total;
if($cpi_avg < .1)
$smart[$i]['cpi_avg'] = round($cpi_avg,3);
else
$smart[$i]['cpi_avg'] = round($cpi_avg,2);
} else {
$smart[$i]['cpi_avg'] = 0;
}
# Cost per Conversion:
if($inv[0] > 0)
$smart[$i]['conversion_cost'] = round($budget / $inv[0], 2);
else
$smart[$i]['conversion_cost'] = 0;
# Avg sales amount:
if($inv[0] > 0 && $budget > 0)
$smart[$i]['invoice_avg'] = round($inv[1] / $inv[0], 2);
else
$smart[$i]['invoice_avg'] = 0;
# ROI
if($inv[0] > 0 && $budget > 0)
$smart[$i]['roi'] = round(($inv[1] / $budget) * 100).'%';
else
$smart[$i]['roi'] = '---';
# Impression to Buy Ratio
if($inv[0] > 0 && $impressions_total > 0) {
$ratio = round($impressions_total / $inv[0]);
$percent = round( ($inv[0] / $impressions_total) * 100, 3);
$smart[$i]['impr_to_buy'] = $ratio . ' / 1 &nbsp;&nbsp; ('.$percent.'%)';
} else {
$smart[$i]['impr_to_buy'] = '---';
}
# Click-thru to Buy ratio
if($inv[0] > 0 && $clicks_total > 0) {
$ratio = round($clicks_total / $inv[0]);
$percent = round( ($inv[0] / $clicks_total) * 100, 2);
$smart[$i]['click_to_buy'] = $ratio . ' / 1 &nbsp;&nbsp; ('.$percent.'%)';
} else {
$smart[$i]['click_to_buy'] = '---';
}
}
global $smarty;
$smarty->assign('campaign', $smart);
}
### Get the number of referred accounts:
function referred_accounts ($id) {
$dba = new CORE_database;
$db = &DB();
$sql = $dba->sql_select("account","id","campaign_id = $id", false, $db);
$rs = $db->Execute($sql);
return $rs->RecordCount();
}
### Get the number of referred invoices:
function referred_invoices ($id) {
$dba = new CORE_database;
$db = &DB();
$sql = $dba->sql_select("invoice","id,total_amt","campaign_id = $id", false, $db);
$rs = $db->Execute($sql);
if ($rs->RecordCount() == 0) {
return Array(0,0);
} else {
$total = 0;
while(!$rs->EOF) {
$total += $rs->fields['total_amt'];
$rs->MoveNext();
}
}
return Array($rs->RecordCount(), $total);
}
##############################
## AFFILIATE VIEW ##
##############################
function affiliate($VAR)
{
$type = "view";
$this->method["$type"] = split(",", $this->method["$type"]);
$db = new CORE_database;
$db->view($VAR, $this, $type);
}
##############################
## UPDATE ##
##############################
function update($VAR)
{
# Validate the files
for($i=1; $i<=12; $i++) {
if(isset($_FILES['upload_file'.$i]) && $_FILES['upload_file'.$i]['size'] > 0) {
$VAR['campaign_type'.$i] = $_FILES['upload_file'.$i]['type'];
$VAR['campaign_file'.$i] = $_FILES['upload_file'.$i]['name'];
}
}
# Store the record
$type = "update";
$this->method["$type"] = split(",", $this->method["$type"]);
$db = new CORE_database;
$rs = $db->update($VAR, $this, $type);
### Copy the files
if($rs) {
for($i=1; $i<=12; $i++) {
if(isset($_FILES['upload_file'.$i]) && $_FILES['upload_file'.$i]['size'] > 0)
{
if(!copy($_FILES['upload_file'.$i]['tmp_name'], PATH_FILES . 'campaign_'.$VAR['campaign_id'].'_'.$i.'.dat'))
{
### ERROR:
}
}
}
}
}
##############################
## DELETE ADDs ##
##############################
function delete_add($VAR)
{
$field = 'file'.$VAR['file'];
$db = &DB();
$sql = 'UPDATE ' . AGILE_DB_PREFIX . 'campaign
SET
'.$field.' = \'\'
WHERE
site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND
id = ' . $db->qstr($VAR["campaign_id"]);
$result = $db->Execute($sql);
error_reporting(0);
if(!unlink(PATH_FILES . 'campaign_'.$VAR["campaign_id"].'_' . $VAR['file'] . '.dat'))
{
global $C_debug;
$C_debug->error('file.inc.php','delete', PATH_FILES . 'file_'.$id[$i].
'.dat does not exist for deletion. File could not be deleted.');
}
# Restore the proper error level
$error_reporting_eval = 'error_reporting('.ERROR_REPORTING.');';
eval($error_reporting_eval);
}
##############################
## DELETE ##
##############################
function delete($VAR)
{
$db = &DB();
$id = $this->table . '_id';
# generate the list of ID's
$id_list = '';
$ii=0;
if(isset($VAR["delete_id"]))
{
$id = split(',',$VAR["delete_id"]);
}
elseif (isset($VAR["id"]))
{
$id = split(',',$VAR["id"]);
}
for($i=0; $i<count($id); $i++)
{
if($id[$i] != '')
{
if($i == 0)
{
$id_list .= " id = " . $db->qstr($id[$i]) . " ";
$ii++;
}
else
{
$id_list .= " OR id = " . $db->qstr($id[$i]) . " ";
$ii++;
}
}
}
if($ii>0)
{
# generate the full query
$q = "DELETE FROM
".AGILE_DB_PREFIX."$this->table
WHERE
$id_list
AND
site_id = '" . DEFAULT_SITE . "'";
# execute the query
$result = $db->Execute($q);
# error reporting
if ($result === false)
{
global $C_debug;
$C_debug->error('campaign.inc.php','delete', $db->ErrorMsg());
}
else
{
for($i=0; $i<count($id); $i++)
{
if($id[$i] != '')
{
error_reporting(0);
for($ii=1; $ii<=12; $ii++)
unlink(PATH_FILES . 'campaign_'.$id[$i].'_'.$ii.'.dat');
# Restore the proper error level
$error_reporting_eval = 'error_reporting('.ERROR_REPORTING.');';
eval($error_reporting_eval);
}
}
# Alert delete message
global $C_debug, $C_translate;
$C_translate->value["CORE"]["module_name"] = $C_translate->translate('name',$this->module,"");
$message = $C_translate->translate('alert_delete_ids',"CORE","");
$C_debug->alert($message);
}
}
}
##############################
## SEARCH FORM ##
##############################
function search_form($VAR)
{
$type = "search";
$this->method["$type"] = split(",", $this->method["$type"]);
$db = new CORE_database;
$db->search_form($VAR, $this, $type);
}
##############################
## SEARCH ##
##############################
function search($VAR)
{
$type = "search";
$this->method["$type"] = split(",", $this->method["$type"]);
$db = new CORE_database;
$db->search($VAR, $this, $type);
}
##############################
## SEARCH SHOW ##
##############################
function search_show($VAR)
{
$type = "search";
$this->method["$type"] = split(",", $this->method["$type"]);
$db = new CORE_database;
$smart = $db->search_show($VAR, $this, $type);
for($i=0; $i<count($smart); $i++)
{
# Get the stats for each advertisement:
$budget = $smart[$i]['budget'];
# Invoices referred
$inv = $this->referred_invoices($smart[$i]['id']);
$smart[$i]['invoices_referred'] = $inv[0];
$smart[$i]['invoices_revenue'] = $inv[1];
@$smart[$i]['invoice_avg'] = $inv[1] / $inv[0];
# total impressions & clicks:
$impressions_total=0;
$clicks_total=0;
for($ii=1; $ii<=12; $ii++)
{
$impressions_total += $smart[$i]["served".$ii];
$clicks_total += $smart[$i]["clicked".$ii];
if(empty($smart[$i]["served".$ii]) && empty($smart[$i]["served".$ii]) && empty($smart[$i]["served".$ii]))
$smart[$i]["show".$ii] = false;
else
$smart[$i]["show".$ii] = true;
}
$smart[$i]['impressions_total'] = $impressions_total;
$smart[$i]['clicks_total'] = $clicks_total;
# Impr. percentage, Clicks percentage, CTR
$ctr_count = 0;
$ctr_amt = 0;
for($ii=1; $ii<=12; $ii++)
{
# CTR
if( $smart[$i]["show".$ii] ) {
$ctr = ( $smart[$i]["clicked".$ii] / $smart[$i]["served".$ii] ) * 100;
if($ctr < 0)
$smart[$i]['ctr'.$ii] = round($ctr).'%';
else
$smart[$i]['ctr'.$ii] = round($ctr,1).'%';
$ctr_count++;
$ctr_amt += $ctr;
} else {
$smart[$i]['ctr'.$ii] = "0%";
$ctr_count++;
}
}
# CTR Avg:
if($ctr_count > 0)
$smart[$i]['ctr_avg'] = round( $ctr_amt / $ctr_count, 2) .'%';
else
$smart[$i]['ctr_avg'] = "0%";
# CPC Avg:
if($clicks_total > 0) {
$cpc_avg = $budget / $clicks_total;
if($cpc_avg < .1)
$smart[$i]['cpc_avg'] = round($cpc_avg,3);
else
$smart[$i]['cpc_avg'] = round($cpc_avg,2);
} else {
$smart[$i]['cpc_avg'] = 0;
}
# CPI Avg:
if($impressions_total > 0) {
$cpi_avg = $budget / $impressions_total;
if($cpi_avg < .1)
$smart[$i]['cpi_avg'] = round($cpi_avg,3);
else
$smart[$i]['cpi_avg'] = round($cpi_avg,2);
} else {
$smart[$i]['cpi_avg'] = 0;
}
# Cost per Conversion:
if($inv[0] > 0 && $budget > 0)
$smart[$i]['conversion_cost'] = round($budget / $inv[0], 2);
else
$smart[$i]['conversion_cost'] = 0;
# ROI
if($inv[0] > 0 && $budget > 0)
$smart[$i]['roi'] = round(($inv[1] / $budget) * 100).'%';
else
$smart[$i]['roi'] = '---';
}
global $smarty;
$smarty->assign('campaign', $smart);
}
##############################
## SEARCH EXPORT ##
##############################
function search_export($VAR)
{
# require the export class
require_once (PATH_CORE . "export.inc.php");
# Call the correct export function for inline browser display, download, email, or web save.
if($VAR["format"] == "excel")
{
$type = "export_excel";
$this->method["$type"] = split(",", $this->method["$type"]);
$export = new CORE_export;
$export->search_excel($VAR, $this, $type);
}
else if ($VAR["format"] == "pdf")
{
$type = "export_pdf";
$this->method["$type"] = split(",", $this->method["$type"]);
$export = new CORE_export;
$export->search_pdf($VAR, $this, $type);
}
else if ($VAR["format"] == "xml")
{
$type = "export_xml";
$this->method["$type"] = split(",", $this->method["$type"]);
$export = new CORE_export;
$export->search_xml($VAR, $this, $type);
}
else if ($VAR["format"] == "csv")
{
$type = "export_csv";
$this->method["$type"] = split(",", $this->method["$type"]);
$export = new CORE_export;
$export->search_csv($VAR, $this, $type);
}
else if ($VAR["format"] == "tab")
{
$type = "export_tab";
$this->method["$type"] = split(",", $this->method["$type"]);
$export = new CORE_export;
$export->search_tab($VAR, $this, $type);
}
}
}
?>

View File

@@ -0,0 +1,233 @@
<?xml version="1.0" encoding="ISO-8859-1" ?>
<construct>
<!-- define the module name -->
<module>campaign</module>
<!-- define the module table name -->
<table>campaign</table>
<!-- define the module dependancy(s) -->
<dependancy/>
<!-- define the DB cache in seconds -->
<cache>0</cache>
<!-- define the default order_by field for SQL queries -->
<order_by>name</order_by>
<!-- define the methods -->
<limit>25</limit>
<!-- define the fields -->
<field>
<id>
<type>I4</type>
<unique>1</unique>
<index>1</index>
</id>
<site_id>
<type>I4</type>
<index>1</index>
</site_id>
<date_orig>
<type>I8</type>
<convert>date-now</convert>
</date_orig>
<date_last>
<type>I8</type>
<convert>date-now</convert>
</date_last>
<date_start>
<type>C(16)</type>
<convert>date</convert>
</date_start>
<date_expire>
<type>C(16)</type>
<convert>date</convert>
</date_expire>
<status>
<type>L</type>
<pdf_width>30</pdf_width>
</status>
<name>
<type>C(128)</type>
<min_len>1</min_len>
<max_len>128</max_len>
<validate>any</validate>
<unique>1</unique>
<pdf_width>30</pdf_width>
</name>
<description>
<type>X2</type>
</description>
<budget>
<type>F</type>
<pdf_width>30</pdf_width>
</budget>
<target_conversion>
<type>F</type>
<pdf_width>30</pdf_width>
</target_conversion>
<file1>
<type>C(128)</type>
<min_len>1</min_len>
<max_len>128</max_len>
<validate>any</validate>
</file1>
<type1>
<type>C(128)</type>
</type1>
<served1>
<type>I4</type>
</served1>
<clicked1>
<type>I4</type>
</clicked1>
<file2>
<type>C(128)</type>
</file2>
<type2>
<type>C(128)</type>
</type2>
<served2>
<type>I4</type>
</served2>
<clicked2>
<type>I4</type>
</clicked2>
<file3>
<type>C(128)</type>
</file3>
<type3>
<type>C(128)</type>
</type3>
<served3>
<type>I4</type>
</served3>
<clicked3>
<type>I4</type>
</clicked3>
<file4>
<type>C(128)</type>
</file4>
<type4>
<type>C(128)</type>
</type4>
<served4>
<type>I4</type>
</served4>
<clicked4>
<type>I4</type>
</clicked4>
<file5>
<type>C(128)</type>
</file5>
<type5>
<type>C(128)</type>
</type5>
<served5>
<type>I4</type>
</served5>
<clicked5>
<type>I4</type>
</clicked5>
<file6>
<type>C(128)</type>
</file6>
<type6>
<type>C(128)</type>
</type6>
<served6>
<type>I4</type>
</served6>
<clicked6>
<type>I4</type>
</clicked6>
<file7>
<type>C(128)</type>
</file7>
<type7>
<type>C(128)</type>
</type7>
<served7>
<type>I4</type>
</served7>
<clicked7>
<type>I4</type>
</clicked7>
<file8>
<type>C(128)</type>
</file8>
<type8>
<type>C(128)</type>
</type8>
<served8>
<type>I4</type>
</served8>
<clicked8>
<type>I4</type>
</clicked8>
<file9>
<type>C(128)</type>
</file9>
<type9>
<type>C(128)</type>
</type9>
<served9>
<type>I4</type>
</served9>
<clicked9>
<type>I4</type>
</clicked9>
<file10>
<type>C(128)</type>
</file10>
<type10>
<type>C(128)</type>
</type10>
<served10>
<type>I4</type>
</served10>
<clicked10>
<type>I4</type>
</clicked10>
<file11>
<type>C(128)</type>
</file11>
<type11>
<type>C(128)</type>
</type11>
<served11>
<type>I4</type>
</served11>
<clicked11>
<type>I4</type>
</clicked11>
<file12>
<type>C(128)</type>
</file12>
<type12>
<type>C(128)</type>
</type12>
<served12>
<type>I4</type>
</served12>
<clicked12>
<type>I4</type>
</clicked12>
<last_served>
<type>I4</type>
</last_served>
<url>
<type>C(128)</type>
</url>
</field>
<!-- define all the methods for this class, and the fields they have access to, if applicable. -->
<method>
<add>id,site_id,date_orig,date_last,date_start,date_expire,status,name,description,budget,target_conversion,file1,type1,served1,clicked1,file2,type2,served2,clicked2,file3,type3,served3,clicked3,file4,type4,served4,clicked4,file5,type5,served5,clicked5,file6,type6,served6,clicked6,file7,type7,served7,clicked7,file8,type8,served8,clicked8,file9,type9,served9,clicked9,file10,type10,served10,clicked10,file11,type11,served11,clicked11,file12,type12,served12,clicked12,url</add>
<update>id,site_id,date_orig,date_last,date_start,date_expire,status,name,description,budget,target_conversion,file1,type1,served1,clicked1,file2,type2,served2,clicked2,file3,type3,served3,clicked3,file4,type4,served4,clicked4,file5,type5,served5,clicked5,file6,type6,served6,clicked6,file7,type7,served7,clicked7,file8,type8,served8,clicked8,file9,type9,served9,clicked9,file10,type10,served10,clicked10,file11,type11,served11,clicked11,file12,type12,served12,clicked12,url</update>
<delete>id,site_id,date_orig,date_last,date_start,date_expire,status,name,description,budget,target_conversion,file1,type1,served1,clicked1,file2,type2,served2,clicked2,file3,type3,served3,clicked3,file4,type4,served4,clicked4,file5,type5,served5,clicked5,file6,type6,served6,clicked6,file7,type7,served7,clicked7,file8,type8,served8,clicked8,file9,type9,served9,clicked9,file10,type10,served10,clicked10,file11,type11,served11,clicked11,file12,type12,served12,clicked12,url</delete>
<view>id,site_id,date_orig,date_last,date_start,date_expire,status,name,description,budget,target_conversion,file1,type1,served1,clicked1,file2,type2,served2,clicked2,file3,type3,served3,clicked3,file4,type4,served4,clicked4,file5,type5,served5,clicked5,file6,type6,served6,clicked6,file7,type7,served7,clicked7,file8,type8,served8,clicked8,file9,type9,served9,clicked9,file10,type10,served10,clicked10,file11,type11,served11,clicked11,file12,type12,served12,clicked12,url</view>
<search>id,site_id,date_orig,date_last,date_start,date_expire,status,name,description,budget,target_conversion,file1,type1,served1,clicked1,file2,type2,served2,clicked2,file3,type3,served3,clicked3,file4,type4,served4,clicked4,file5,type5,served5,clicked5,file6,type6,served6,clicked6,file7,type7,served7,clicked7,file8,type8,served8,clicked8,file9,type9,served9,clicked9,file10,type10,served10,clicked10,file11,type11,served11,clicked11,file12,type12,served12,clicked12,url</search>
<export_excel>status,name,description,budget,target_conversion,file1,type1,served1,clicked1,file2,type2,served2,clicked2,file3,type3,served3,clicked3,file4,type4,served4,clicked4,file5,type5,served5,clicked5,file6,type6,served6,clicked6,file7,type7,served7,clicked7,file8,type8,served8,clicked8,file9,type9,served9,clicked9,file10,type10,served10,clicked10,file11,type11,served11,clicked11,file12,type12,served12,clicked12</export_excel>
<export_xml>status,name,description,budget,target_conversion,file1,type1,served1,clicked1,file2,type2,served2,clicked2,file3,type3,served3,clicked3,file4,type4,served4,clicked4,file5,type5,served5,clicked5,file6,type6,served6,clicked6,file7,type7,served7,clicked7,file8,type8,served8,clicked8,file9,type9,served9,clicked9,file10,type10,served10,clicked10,file11,type11,served11,clicked11,file12,type12,served12,clicked12</export_xml>
<export_csv>status,name,description,budget,target_conversion,file1,type1,served1,clicked1,file2,type2,served2,clicked2,file3,type3,served3,clicked3,file4,type4,served4,clicked4,file5,type5,served5,clicked5,file6,type6,served6,clicked6,file7,type7,served7,clicked7,file8,type8,served8,clicked8,file9,type9,served9,clicked9,file10,type10,served10,clicked10,file11,type11,served11,clicked11,file12,type12,served12,clicked12</export_csv>
<export_tab>status,name,description,budget,target_conversion,file1,type1,served1,clicked1,file2,type2,served2,clicked2,file3,type3,served3,clicked3,file4,type4,served4,clicked4,file5,type5,served5,clicked5,file6,type6,served6,clicked6,file7,type7,served7,clicked7,file8,type8,served8,clicked8,file9,type9,served9,clicked9,file10,type10,served10,clicked10,file11,type11,served11,clicked11,file12,type12,served12,clicked12</export_tab>
</method>
<!-- define the method triggers -->
<trigger>0</trigger>
</construct>

View File

@@ -0,0 +1,60 @@
<install>
<module_properties>
<name>campaign</name>
<parent>affiliate</parent>
<notes><![CDATA[The campaign module enables you to setup campaings to serve up your advertisements.]]></notes>
<menu_display>1</menu_display>
</module_properties>
<sql_inserts>
<module_method>
<add>
<name>add</name>
<page><![CDATA[%%:add]]></page>
<menu_display>1</menu_display>
</add>
<update>
<name>update</name>
</update>
<delete>
<name>delete</name>
</delete>
<view>
<name>view</name>
<page><![CDATA[core:search&module=%%&_escape=1&_next_page_one=view]]></page>
<menu_display>1</menu_display>
</view>
<search>
<name>search</name>
<page><![CDATA[%%:search_form]]></page>
<menu_display>1</menu_display>
</search>
<search_form>
<name>search_form</name>
<notes><![CDATA[Allow users to view the search form]]></notes>
</search_form>
<search_show>
<name>search_show</name>
<notes><![CDATA[Allow users to view the search results]]></notes>
</search_show>
<delete_add>
<name>delete_add</name>
<notes><![CDATA[Delete a specific add in a campaign from rotation]]></notes>
</delete_add>
<search_export>
<name>search_export</name>
</search_export>
<export_excel>
<name>export_excel</name>
</export_excel>
<export_pdf>
<name>export_pdf</name>
</export_pdf>
<export_csv>
<name>export_csv</name>
</export_csv>
<export_tab>
<name>export_tab</name>
</export_tab>
</module_method>
</sql_inserts>
</install>

View File

@@ -0,0 +1,97 @@
<?php
/**
* AgileBill - Open Billing Software
*
* This body of work is free software; you can redistribute it and/or
* modify it under the terms of the Open AgileBill License
* License as published at http://www.agileco.com/agilebill/license1-4.txt
*
* For questions, help, comments, discussion, etc., please join the
* Agileco community forums at http://forum.agileco.com/
*
* @link http://www.agileco.com/
* @copyright 2004-2008 Agileco, LLC.
* @license http://www.agileco.com/agilebill/license1-4.txt
* @author Tony Landis <tony@agileco.com>
* @package AgileBill
* @version 1.4.93
*/
ob_start();
# Required includes:
require_once('../../config.inc.php');
require_once(PATH_ADODB . 'adodb.inc.php');
require_once(PATH_CORE . 'database.inc.php');
require_once(PATH_CORE . 'vars.inc.php');
$C_debug = new CORE_debugger;
$C_vars = new CORE_vars;
$VAR = $C_vars->f;
$db = &DB();
$sql = 'SELECT * FROM ' . AGILE_DB_PREFIX . 'campaign WHERE
site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND
id = ' . $db->qstr(@$VAR['id']);
$result = $db->Execute($sql);
if( !empty($VAR['file']) ) {
$file_no = $VAR['file'];
}
else
{
# random file:
$last = $result->fields['last_served'];
if(empty($last)) $last = 1;
$next = false;
for($i=1; $i<=12; $i++) {
if(!empty($result->fields["file".$i]) && !$next) {
if($i == $last)
$next = true;
} else if(!empty($result->fields["file".$i]) && $next) {
$file_no = $i;
$i = 20;
}
}
}
if(empty($file_no))
$file_no = '1';
$file = PATH_FILES . 'campaign_' . $VAR['id'] . '_' . $file_no .'.dat';
$type = 'type'.$file_no;
$name = 'file'.$file_no;
$count_field= 'served'.$file_no;
$count = $result->fields[$count_field] + 1;
if($result->RecordCount() > 0)
{
### Open the file
if (@$file=fopen($file, 'r'))
{
### Display the correct headers:
header ("Content-type: " . $result->fields[$type]);
header ("Content-Disposition: inline; filename=" . $result->fields[$name]);
header ("Content-Description: PHP/INTERBASE Generated Data" );
fpassthru($file);
### Increment the file
if(!isset($VAR['_log']))
{
$sql = 'UPDATE ' . AGILE_DB_PREFIX . 'campaign SET
'.$count_field.' = ' . $db->qstr($count) . ',
last_served = ' . $db->qstr($file_no) . '
WHERE
site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND
id = ' . $db->qstr(@$VAR['id']);
$result = $db->Execute($sql);
}
exit;
}
}
echo 'Sorry, the campaign or required file does not exist!';
ob_end_flush();
?>