'a', 'attribute'=>'href'), // 2.0 array('element'=>'a', 'attribute'=>'urn'), // 2.0 array('element'=>'base', 'attribute'=>'href'), // 2.0 array('element'=>'form', 'attribute'=>'action'), // 2.0 array('element'=>'img', 'attribute'=>'src'), // 2.0 array('element'=>'link', 'attribute'=>'href'), // 2.0 array('element'=>'applet', 'attribute'=>'code'), // 3.2 array('element'=>'applet', 'attribute'=>'codebase'), // 3.2 array('element'=>'area', 'attribute'=>'href'), // 3.2 array('element'=>'body', 'attribute'=>'background'), // 3.2 array('element'=>'img', 'attribute'=>'usemap'), // 3.2 array('element'=>'input', 'attribute'=>'src'), // 3.2 array('element'=>'applet', 'attribute'=>'archive'), // 4.01 array('element'=>'applet', 'attribute'=>'object'), // 4.01 array('element'=>'blockquote','attribute'=>'cite'), // 4.01 array('element'=>'del', 'attribute'=>'cite'), // 4.01 array('element'=>'frame', 'attribute'=>'longdesc'), // 4.01 array('element'=>'frame', 'attribute'=>'src'), // 4.01 array('element'=>'head', 'attribute'=>'profile'), // 4.01 array('element'=>'iframe', 'attribute'=>'longdesc'), // 4.01 array('element'=>'iframe', 'attribute'=>'src'), // 4.01 array('element'=>'img', 'attribute'=>'longdesc'), // 4.01 array('element'=>'input', 'attribute'=>'usemap'), // 4.01 array('element'=>'ins', 'attribute'=>'cite'), // 4.01 array('element'=>'object', 'attribute'=>'archive'), // 4.01 array('element'=>'object', 'attribute'=>'classid'), // 4.01 array('element'=>'object', 'attribute'=>'codebase'), // 4.01 array('element'=>'object', 'attribute'=>'data'), // 4.01 array('element'=>'object', 'attribute'=>'usemap'), // 4.01 array('element'=>'q', 'attribute'=>'cite'), // 4.01 array('element'=>'script', 'attribute'=>'src'), // 4.01 array('element'=>'audio', 'attribute'=>'src'), // 5.0 array('element'=>'command', 'attribute'=>'icon'), // 5.0 array('element'=>'embed', 'attribute'=>'src'), // 5.0 array('element'=>'event-source','attribute'=>'src'), // 5.0 array('element'=>'html', 'attribute'=>'manifest'), // 5.0 array('element'=>'source', 'attribute'=>'src'), // 5.0 array('element'=>'video', 'attribute'=>'src'), // 5.0 array('element'=>'video', 'attribute'=>'poster'), // 5.0 array('element'=>'bgsound', 'attribute'=>'src'), // Extension array('element'=>'body', 'attribute'=>'credits'), // Extension array('element'=>'body', 'attribute'=>'instructions'),//Extension array('element'=>'body', 'attribute'=>'logo'), // Extension array('element'=>'div', 'attribute'=>'href'), // Extension array('element'=>'div', 'attribute'=>'src'), // Extension array('element'=>'embed', 'attribute'=>'code'), // Extension array('element'=>'embed', 'attribute'=>'pluginspage'),// Extension array('element'=>'html', 'attribute'=>'background'), // Extension array('element'=>'ilayer', 'attribute'=>'src'), // Extension array('element'=>'img', 'attribute'=>'dynsrc'), // Extension array('element'=>'img', 'attribute'=>'lowsrc'), // Extension array('element'=>'input', 'attribute'=>'dynsrc'), // Extension array('element'=>'input', 'attribute'=>'lowsrc'), // Extension array('element'=>'table', 'attribute'=>'background'), // Extension array('element'=>'td', 'attribute'=>'background'), // Extension array('element'=>'th', 'attribute'=>'background'), // Extension array('element'=>'layer', 'attribute'=>'src'), // Extension array('element'=>'xml', 'attribute'=>'src'), // Extension array('element'=>'button', 'attribute'=>'action'), // Forms 2.0 array('element'=>'datalist','attribute'=>'data'), // Forms 2.0 array('element'=>'form', 'attribute'=>'data'), // Forms 2.0 array('element'=>'input', 'attribute'=>'action'), // Forms 2.0 array('element'=>'select', 'attribute'=>'data'), // Forms 2.0 // XHTML array('element'=>'html', 'attribute'=>'xmlns'), // WML array('element'=>'access', 'attribute'=>'path'), // 1.3 array('element'=>'card', 'attribute'=>'onenterforward'),// 1.3 array('element'=>'card', 'attribute'=>'onenterbackward'),// 1.3 array('element'=>'card', 'attribute'=>'ontimer'), // 1.3 array('element'=>'go', 'attribute'=>'href'), // 1.3 array('element'=>'option', 'attribute'=>'onpick'), // 1.3 array('element'=>'template','attribute'=>'onenterforward'),// 1.3 array('element'=>'template','attribute'=>'onenterbackward'),// 1.3 array('element'=>'template','attribute'=>'ontimer'), // 1.3 array('element'=>'wml', 'attribute'=>'xmlns'), // 2.0 ); $match_metas = array( 'content-base', 'content-location', 'referer', 'location', 'refresh', ); // Extract all elements if ( !preg_match_all( '/<([a-z][^>]*)>/iu', $text, $matches ) ) return array( ); $elements = $matches[1]; $value_pattern = '=(("([^"]*)")|([^\s]*))'; // Match elements and attributes foreach ( $match_elements as $match_element ) { $name = $match_element['element']; $attr = $match_element['attribute']; $pattern = '/^' . $name . '\s.*' . $attr . $value_pattern . '/iu'; if ( $name == 'object' ) $split_pattern = '/\s*/u'; // Space-separated URL list else if ( $name == 'archive' ) $split_pattern = '/,\s*/u'; // Comma-separated URL list else unset( $split_pattern ); // Single URL foreach ( $elements as $element ) { if ( !preg_match( $pattern, $element, $match ) ) continue; $m = empty($match[3]) ? $match[4] : $match[3]; if ( !isset( $split_pattern ) ) $urls[$name][$attr][] = $m; else { $msplit = preg_split( $split_pattern, $m ); foreach ( $msplit as $ms ) $urls[$name][$attr][] = $ms; } } } // Match meta http-equiv elements foreach ( $match_metas as $match_meta ) { $attr_pattern = '/http-equiv="?' . $match_meta . '"?/iu'; $content_pattern = '/content' . $value_pattern . '/iu'; $refresh_pattern = '/\d*;\s*(url=)?(.*)$/iu'; foreach ( $elements as $element ) { if ( !preg_match( '/^meta/iu', $element ) || !preg_match( $attr_pattern, $element ) || !preg_match( $content_pattern, $element, $match ) ) continue; $m = empty($match[3]) ? $match[4] : $match[3]; if ( $match_meta != 'refresh' ) $urls['meta']['http-equiv'][] = $m; else if ( preg_match( $refresh_pattern, $m, $match ) ) $urls['meta']['http-equiv'][] = $match[2]; } } // Match style attributes $urls['style'] = array( ); $style_pattern = '/style' . $value_pattern . '/iu'; foreach ( $elements as $element ) { if ( !preg_match( $style_pattern, $element, $match ) ) continue; $m = empty($match[3]) ? $match[4] : $match[3]; $style_urls = extract_css_urls( $m ); if ( !empty( $style_urls ) ) $urls['style'] = array_merge_recursive( $urls['style'], $style_urls ); } // Match style bodies if ( preg_match_all( '/]*>(.*?)<\/style>/siu', $text, $style_bodies ) ) { foreach ( $style_bodies[1] as $style_body ) { $style_urls = extract_css_urls( $style_body ); if ( !empty( $style_urls ) ) $urls['style'] = array_merge_recursive( $urls['style'], $style_urls ); } } if ( empty($urls['style']) ) unset( $urls['style'] ); return $urls; } ?>$categoryName); $categoryCount = tep_db_getCount(TABLE_CATEGORY, $where_data_array); return $categoryCount; } function checkRegisteredAdvertiser($email) { $sql_data_array = array("email"); $where_data_array = array("email"=>$email); $advCount = tep_db_getCount(TABLE_ADVERTISERS, $where_data_array); return $advCount; } function checkRegisteredAffilateManager($email) { $sql_data_array = array("email"); $where_data_array = array("email"=>$email); $advCount = tep_db_getCount(TABLE_AFFILIATE_MANAGER, $where_data_array); return $advCount; } function checkRegisteredAdvertiserManager($email) { $sql_data_array = array("email"); $where_data_array = array("email"=>$email); $advCount = tep_db_getCount(TABLE_ADVERTISER_MANAGER, $where_data_array); return $advCount; } function checkAffManagerLogin($username, $password) { $sql_data_array = array("username"); $where_data_array = array("username"=>$username, "password"=>$password); $count = tep_db_data(TABLE_AFFILIATE_MANAGER, $where_data_array); return $count; } function checkAdvManagerLogin($username, $password) { $sql_data_array = array("username"); $where_data_array = array("username"=>$username, "password"=>$password); $count = tep_db_data(TABLE_ADVERTISER_MANAGER, $where_data_array); return $count; } function checkAccountLogin($username, $password) { $sql_data_array = array("username"); $where_data_array = array("username"=>$username, "password"=>$password); $count = tep_db_data(TABLE_ACCOUNT, $where_data_array); return $count; } function checkPublisherAdminLogin($pid) { $where_data_array = array("pid" => $pid); $count = tep_db_data(TABLE_PUBLISHERS, $where_data_array); return $count; } function checkRegisteredPublisher($email) { $where_data_array = array("email"=>$email); $advCount = tep_db_getCount(TABLE_PUBLISHERS, $where_data_array); return $advCount; } function checkAdminLogin($username, $password) { $sql_data_array = array("username"); $where_data_array = array("username"=>$username, "password"=>$password); $count = tep_db_data(TABLE_ADMIN, $where_data_array); return $count; } function checkAdvertiserLogin($username, $password) { $sql_data_array = array("username"); $where_data_array = array("username"=>$username, "password"=>$password); $count = tep_db_data(TABLE_ADVERTISERS, $where_data_array); return $count; } function checkPublisherLogin($username, $password) { $where_data_array = array("username" => $username, "password" => $password); $count = tep_db_data(TABLE_PUBLISHERS, $where_data_array); return $count; } function getLeadDetails($where_data_array) { $count = tep_db_data(TABLE_CAMPAIGN_IMPRESSION_DETAIL, $where_data_array); return $count; } function getClickDetails($where_data_array) { $count = tep_db_data(TABLE_CAMPAIGN_CLICKS_DETAIL, $where_data_array); return $count; } function getAllAdvertisers($where_data_array = '') { $orderQuery = " ORDER BY registeredDate"; $query = tep_db_select_query1(TABLE_ADVERTISERS, "*", $where_data_array, $orderQuery); return $query; } function getAllCampainPendingRequest($wherequery = '') { $orderQuery = " ORDER BY campaign_request.updatedate desc"; //$query = tep_db_select_query(TABLE_CAMPAIGN_REQUEST, "*", $where_data_array, $orderQuery); $query = "SELECT campaign_request.rId, campaign_request.status, campaign.offerStatus as offerStatus, campaign.campaignId as campaignId, campaign.campaignName as campaignName, concat(publishers.firstname,' ',publishers.lastname) as publisherName, campaign_request.publisherId as publisherId, concat(advertisers.firstname,' ',advertisers.lastname) as advertiserId FROM " .TABLE_CAMPAIGN_REQUEST." AS campaign_request join " .TABLE_CAMPAIGN." AS campaign ON campaign_request.campaignId = campaign.campaignId join " .TABLE_PUBLISHERS." AS publishers ON campaign_request.publisherId = publishers.pid join " .TABLE_ADVERTISERS." AS advertisers ON campaign.advertiserId = advertisers.aid" .$wherequery.$orderQuery; return $query; } //Function added for getting affiliate ids info which are assigned to particular status on 23 aug 2011 function getstatusAffiliateIds($wherequery = '') { $query = "SELECT status_assigned_affiliateids.id, status_assigned_affiliateids.status, campstatus.status_name as status_name, concat(publishers.firstname,' ',publishers.lastname) as publisherName, status_assigned_affiliateids.publisherId as publisherId FROM status_assigned_affiliateids AS status_assigned_affiliateids join ".TABLE_PUBLISHERS." AS publishers ON status_assigned_affiliateids.publisherId = publishers.pid join campaign_status AS campstatus ON campstatus.statusid = status_assigned_affiliateids.statusid".$wherequery; return $query; } //End of function function getAllPublishers($where_data_array = '') { $orderQuery = " ORDER BY firstname,pid"; $query = tep_db_select_query1(TABLE_PUBLISHERS, "*", $where_data_array, $orderQuery); return $query; } function getAlladminPublishers($where_data_array = '') { global $campaignData; $orderQuery = " ORDER BY registeredDate"; $query = tep_db_select_query1(TABLE_PUBLISHERS, "*", $where_data_array, $orderQuery); $result = tep_db_query($query); while($data = tep_db_fetch_array($result)) { $campaignData[$data['pid']] = $data; } return $campaignData; } //Added for the last day search of publisher on 24 may 11 function getAlladminlastsearchPublishers($where_data_array = '',$lastsearchquery = '') { global $campaignData; $orderQuery = " ORDER BY registeredDate"; $query = "Select * from ".TABLE_PUBLISHERS." where 1 ".$lastsearchquery." ".$orderQuery.""; //$query = "Select * from ".TABLE_PUBLISHERS." where 1 ".$where_data_array." ".$lastsearchquery." ".$orderQuery.""; //$query = tep_db_select_query1(TABLE_PUBLISHERS, "*", $where_data_array, $orderQuery); $result = tep_db_query($query); while($data = tep_db_fetch_array($result)) { $campaignData[$data['pid']] = $data; } return $campaignData; } //End of function //Added for special offers request publishers on 29 mar 11 function getAllspecialofferrequest($where_data_array = '') { global $campaignData; //$orderQuery = " ORDER BY registeredDate"; $query = "Select special.*,pub.firstname,pub.lastname,camp.campaignName from special_offer_request as special join publishers as pub on special.publisherId = pub.pid left join campaign as camp on special.campaignId = camp.campaignId where 1 ".$where_data_array." and camp.offerStatus='select'"; $result = tep_db_query($query); while($data = tep_db_fetch_array($result)) { $campaignData[$data['id']] = $data; } return $campaignData; } //End of function added for special offers request publishers on 29 mar 11 function getAllAffmanagerPublishers($where_data_array = '') { $orderQuery = " ORDER BY registeredDate"; $query = tep_db_select_query1(TABLE_PUBLISHERS, "*", $where_data_array, $orderQuery); return $query; } //FunctionAdded for getting affiliate manager publishers from the new table on 12 july 2011. function getAllAffmanagercatPublishers($where_data_array = '') { $orderQuery = " ORDER BY registeredDate"; $query = "select pub.*,pubaff.affMId as affMId from ".TABLE_PUBLISHERS." as pub join pubaffiliatemanagers as pubaff on pubaff.pid = pub.pid where 1 ".$where_data_array." and pub.status = 'Y' order by pub.firstname,pub.pid"; return $query; } //End of function function getAllAffiliateManager($where_data_array = '') { $orderQuery = " ORDER BY registeredDate"; $query = tep_db_select_query1(TABLE_AFFILIATE_MANAGER, "*", $where_data_array, $orderQuery); return $query; } function getAllAdvertiserManager($where_data_array = '') { $orderQuery = " ORDER BY registeredDate"; $query = tep_db_select_query1(TABLE_ADVERTISER_MANAGER, "*", $where_data_array, $orderQuery); return $query; } function getAllCampaignsw($wherequery = '') { $orderQuery = " ORDER BY addedDate"; $query = "SELECT cat.*, campaign.*, campaign.status AS status FROM ".TABLE_CAMPAIGN." AS campaign INNER JOIN ".TABLE_CATEGORY." AS cat ON cat.categoryId=campaign.categoryId ".$wherequery.$orderQuery; return $query; } //Function added for getting all the status of the campaigns on 23 aug 2011 function getAllStatus($wherequery = '') { $orderQuery = " ORDER BY addedDate"; $query = "SELECT * FROM campaign_status ".$wherequery; return $query; } //End of function //Added for campaign page advertiser based search field on 26 march 10 function getAllCampaignsaw($wherequery = '',$advertiserquery='') { global $campaignData; global $uniqueclicks; global $campaignIdArray; global $leads; global $campaignpayout; $orderQuery = " ORDER BY addedDate"; $query = "SELECT cat.*, campaign.*,advertiser.firstname,advertiser.lastname,campaign.status AS status FROM ".TABLE_CAMPAIGN." AS campaign INNER JOIN ".TABLE_CATEGORY." AS cat ON cat.categoryId=campaign.categoryId left join ".TABLE_ADVERTISERS." As advertiser ON advertiser.aid = campaign.advertiserId where 1 ".$wherequery. $advertiserquery.$orderQuery; $result = tep_db_query($query); $_SESSION['ses_campaign_report_query'] = $query; while($data = tep_db_fetch_array($result)) { $campaignData[$data['campaignId']] = $data; $campaignIdArray[$data['campaignId']]= $data['campaignId']; } $unique_clicksquery = "SELECT sum(uniqueclicks) As uniqueclickcount,campaign.campaignId,campaign.payout as campaignpayout FROM campaignclickdetailreport AS click RIGHT JOIN ".TABLE_CAMPAIGN." AS campaign ON campaign.campaignId=click.campaignId left JOIN ".TABLE_CATEGORY." AS cat ON cat.categoryId=campaign.categoryId WHERE 1 ".$wherequery." and click.affiliateId <> 0 AND campaign.status='Y' GROUP BY click.campaignId ".$orderQuery.""; $result_unique_clicksquery = tep_db_query($unique_clicksquery); while($data_uniqueclicks = tep_db_fetch_array($result_unique_clicksquery)) { $uniqueclicks[$data_uniqueclicks['campaignId']] = $data_uniqueclicks['uniqueclickcount']; $campaignpayout[$data_uniqueclicks['campaignId']] = $data_uniqueclicks['campaignpayout']; } $lead_query = "SELECT COUNT(*) AS leadCount,click.campaignId FROM ".TABLE_CAMPAIGN_LEAD_DETAIL." AS click RIGHT JOIN ".TABLE_CAMPAIGN." AS campaign ON campaign.campaignId=click.campaignId LEFT JOIN publishers AS affiliate ON affiliate.pid=click.affiliateId left JOIN ".TABLE_CATEGORY." AS cat ON cat.categoryId=campaign.categoryId WHERE 1 ".$wherequery." and click.affiliateId <> 0 AND affiliate.status = 'Y' GROUP BY click.campaignId ".$orderQuery.""; $result_lead_query = tep_db_query($lead_query); while($data_leads = tep_db_fetch_array($result_lead_query)) { $leads[$data_leads['campaignId']] = $data_leads['leadCount']; } return $campaignData; } //End of function for campaign page advertiser based search field on 26 march 10 function getAllCampaignsaffmanager($wherequery = '') { $orderQuery = " ORDER BY addedDate"; $query = "SELECT cat.*, campaign.*, campaign.status AS status FROM ".TABLE_CAMPAIGN." AS campaign INNER JOIN ".TABLE_CATEGORY." AS cat ON cat.categoryId=campaign.categoryId ".$wherequery." where campaign.offerStatus='automatic' OR campaign.offerStatus='private' ".$orderQuery.""; return $query; } function getAllCampaignsadvmanager($wherequery = '') { $orderQuery = " ORDER BY addedDate"; $query = "SELECT cat.*, campaign.*,advertiser.firstname,advertiser.lastname,campaign.status AS status FROM ".TABLE_CAMPAIGN." AS campaign INNER JOIN ".TABLE_CATEGORY." AS cat ON cat.categoryId=campaign.categoryId right join ".TABLE_ADVERTISERS." As advertiser ON advertiser.aid = campaign.advertiserId ".$wherequery." where advertiser.advMId='".$_SESSION['infinite_advmanagerID']."' AND (campaign.offerStatus='automatic' OR campaign.offerStatus='private' OR campaign.offerStatus='paused' OR campaign.offerStatus='test') ".$orderQuery.""; return $query; } function getadvmanagercampaign($wherequery = '') { global $campaignData; global $campaignIdArray; $orderQuery = " ORDER BY addedDate"; $query = "SELECT cat.*, campaign.*,advertiser.firstname,advertiser.lastname,campaign.status AS status FROM ".TABLE_CAMPAIGN." AS campaign INNER JOIN ".TABLE_CATEGORY." AS cat ON cat.categoryId=campaign.categoryId right join ".TABLE_ADVERTISERS." As advertiser ON advertiser.aid = campaign.advertiserId ".$wherequery." where advertiser.advMId='".$_SESSION['infinite_advmanagerID']."' AND (campaign.offerStatus='automatic' OR campaign.offerStatus='private' OR campaign.offerStatus='paused' OR campaign.offerStatus='test') ".$orderQuery.""; $result = tep_db_query($query); while($data = tep_db_fetch_array($result)) { $campaignData[$data['campaignId']] = $data; $campaignIdArray[$data['campaignId']]= $data['campaignId']; } /* echo"
";
	print_r($campaignData);
	echo"
"; exit();*/ return $campaignData; } function getAllCampaignsw1($wherequery = '') { $orderQuery = " ORDER BY addedDate"; $query = "SELECT cat.*, campaign.*, campaign.status AS status FROM " .TABLE_CAMPAIGN." AS campaign INNER JOIN " .TABLE_CATEGORY." AS cat ON cat.categoryId=campaign.categoryId " .$wherequery.$orderQuery; return $query; } function getAllCampaignswPublisher($wherequery = '') { $orderQuery = " ORDER BY addedDate"; $query = "SELECT campaign_request.status as campaign_pending_status, campaign_request.publisherId as publisherId, cat.*, campaign.*, campaign.status AS status FROM " .TABLE_CAMPAIGN." AS campaign INNER JOIN " .TABLE_CATEGORY." AS cat ON cat.categoryId=campaign.categoryId " .$wherequery.$orderQuery; return $query; } //Added by tanvi on 12 jan 10 function getAllCampaignspubsort($wherequery = '',$ordquery='') { $orderQuery = $ordquery; $query = "SELECT campaign_request.status as campaign_pending_status, campaign_request.publisherId as publisherId, cat.*, campaign.*, campaign.status AS status FROM " .TABLE_CAMPAIGN." AS campaign INNER JOIN " .TABLE_CATEGORY." AS cat ON cat.categoryId=campaign.categoryId " .$wherequery.$orderQuery; return $query; } //End of the function added //Added for epc calculation for campaigns of publisher on 7 apr 10 function getAllCampaignspub($wherequery = '',$ordquery='') { global $campaignData; global $uniqueclicks; global $campaignIdArray; global $leads; global $campaignpayout; $orderQuery = $ordquery; $query = "SELECT campaign_request.status as campaign_pending_status, campaign_request.publisherId as publisherId, cat.*, campaign.*, campaign.status AS status FROM " .TABLE_CAMPAIGN." AS campaign INNER JOIN " .TABLE_CATEGORY." AS cat ON cat.categoryId=campaign.categoryId" .$wherequery.$orderQuery; $result = tep_db_query($query); while($data = tep_db_fetch_array($result)) { $campaignData[$data['campaignId']] = $data; $campaignIdArray[$data['campaignId']]= $data['campaignId']; } $unique_clicksquery = "SELECT sum(uniqueclicks) As uniqueclickcount,campaign.campaignId,campaign.payout as campaignpayout FROM campaignclickdetailreport AS click RIGHT JOIN ".TABLE_CAMPAIGN." AS campaign ON campaign.campaignId=click.campaignId left JOIN ".TABLE_CATEGORY." AS cat ON cat.categoryId=campaign.categoryId WHERE 1 and click.affiliateId <> 0 AND campaign.status='Y' GROUP BY click.campaignId "; $result_unique_clicksquery = tep_db_query($unique_clicksquery); while($data_uniqueclicks = tep_db_fetch_array($result_unique_clicksquery)) { $uniqueclicks[$data_uniqueclicks['campaignId']] = $data_uniqueclicks['uniqueclickcount']; $campaignpayout[$data_uniqueclicks['campaignId']] = $data_uniqueclicks['campaignpayout']; } $lead_query = "SELECT COUNT(*) AS leadCount,click.campaignId FROM ".TABLE_CAMPAIGN_LEAD_DETAIL." AS click RIGHT JOIN ".TABLE_CAMPAIGN." AS campaign ON campaign.campaignId=click.campaignId LEFT JOIN category AS cat ON cat.categoryId=campaign.categoryId LEFT JOIN publishers AS affiliate ON affiliate.pid=click.affiliateId WHERE 1 and click.affiliateId <> 0 AND affiliate.status = 'Y' GROUP BY click.campaignId"; $result_lead_query = tep_db_query($lead_query); while($data_leads = tep_db_fetch_array($result_lead_query)) { $leads[$data_leads['campaignId']] = $data_leads['leadCount']; } return $campaignData; } //End of function added. //Function added for blacklist feature of publisher section. function getAllCampaignspubblacklist($wherequery = '',$ordquery='') { global $campaignData; $orderQuery = $ordquery; $query = "SELECT campaign_request.status as campaign_pending_status, campaign_request.publisherId as publisherId,campaign.*,campaign.status AS status FROM " .TABLE_CAMPAIGN." AS campaign INNER JOIN " .TABLE_CATEGORY." AS cat ON cat.categoryId=campaign.categoryId" .$wherequery.$orderQuery; $result = tep_db_query($query); while($data = tep_db_fetch_array($result)) { $campaignData[$data['campaignId']] = $data; $campaignIdArray[$data['campaignId']]= $data['campaignId']; } return $campaignData; } //End of function added. function getAllPublishernotes($wherequery = '') { $orderQuery = " ORDER BY date"; $query = "SELECT notes.*, publisher.* FROM ".TABLE_PUBLISHERS." AS publisher INNER JOIN ".TABLE_PUBLISHERS_NOTES." AS notes ON notes.affiliateId=publisher.pid ".$wherequery.$orderQuery; return $query; } function getAllleads($wherequery = '',$ordquery='') { $orderQuery = $ordquery; $query = "SELECT lead.*, publisher.firstname ,publisher.lastname,publisher.pid,campaign.campaignName FROM (".TABLE_PUBLISHERS." AS publisher INNER JOIN ".TABLE_CAMPAIGN_LEAD_DETAIL." AS lead ON lead.affiliateId=publisher.pid ) INNER JOIN ".TABLE_CAMPAIGN." AS campaign ON lead.campaignId = campaign.campaignId and lead.affiliateId <> 0".$wherequery.$orderQuery; return $query; } //for testing of sorting in leads page function getAllleadstest($wherequery = '',$ordquery='') { $orderQuery = $ordquery; $query = "SELECT lead.*, publisher.firstname ,publisher.lastname,publisher.pid,campaign.campaignName FROM (".TABLE_PUBLISHERS." AS publisher INNER JOIN ".TABLE_CAMPAIGN_LEAD_DETAIL." AS lead ON lead.affiliateId=publisher.pid ) INNER JOIN ".TABLE_CAMPAIGN." AS campaign ON lead.campaignId = campaign.campaignId and lead.affiliateId <> 0".$wherequery.$orderQuery; return $query; } //end of testing of sorting in leads page function getAllCategory() { $orderQuery = " ORDER BY categoryName"; $query = tep_db_select_query(TABLE_CATEGORY, "*", $where_data_array, $orderQuery); return $query; } function getCategoryList() { $orderQuery = " ORDER BY categoryName"; $where_data_array = array("status"=>"Y"); $query = tep_db_select_query(TABLE_CATEGORY, "*", $where_data_array, $orderQuery); $result = tep_db_query($query); while($data = tep_db_fetch_array($result)) { $categoryList[$data['categoryId']] = $data['categoryName']; } return $categoryList; } function getAllCampaigns($parameters) { $orderQuery = " ORDER BY addedDate"; if(!empty($parameters)) { $wherequery = " where "; while (list($columns, $value) = each($parameters)) { switch ((string)$value) { case 'now()': $wherequery .= '`' . $columns . '` = now() and '; break; case 'null': $wherequery .= '`' . $columns .= '` = null and '; break; default: $wherequery .= '`' . $columns . '` = \'' . tep_db_input($value) . '\' and '; break; } } $wherequery = substr($wherequery, 0, -5) ; } $query = "SELECT *, campaign.status AS status FROM ".TABLE_CAMPAIGN." AS campaign left join ".TABLE_CATEGORY." AS cat ON cat.categoryId = campaign.categoryId ".$wherequery.$orderQuery; //$query = tep_db_select_query(TABLE_CAMPAIGN, "*", $where_data_array, $orderQuery); return $query; } function getCreativesTotal($campaignIdArray) { $orderQuery = " GROUP BY campaignId"; $query = tep_db_select_query(TABLE_CREATIVE, "count(*) AS count, campaignId", $where_data_array, $orderQuery); $result = tep_db_query($query); while($data = tep_db_fetch_array($result)) { $countData[$data['campaignId']] = $data['count']; } return $countData; } // for Campaign Click Data function getCampaignClickTotal($campaignIdArray) { $orderQuery = " GROUP BY campaignId"; $query = tep_db_select_query(TABLE_CAMPAIGN_CLICKS_DETAIL, "SUM(clicks) AS clicks, campaignId", $where_data_array, $orderQuery); $result = tep_db_query($query); while($data = tep_db_fetch_array($result)) { $clickCountData[$data['campaignId']] = $data['clicks']; } return $clickCountData; } function getCampaignImpressionTotal($campaignIdArray) { $orderQuery = " GROUP BY campaignId"; $query = tep_db_select_query(TABLE_CAMPAIGN_IMPRESSION_DETAIL, "SUM(impression) AS impression, campaignId", $where_data_array, $orderQuery); $result = tep_db_query($query); while($data = tep_db_fetch_array($result)) { $clickImpData[$data['campaignId']] = $data['impression']; } return $clickImpData; } function getAdvertiserDetails($field='*', $where_data_array, $orderQuery = '') { $query = tep_db_select_query(TABLE_ADVERTISERS, $field, $where_data_array, $orderQuery); $result = tep_db_query($query); $data = tep_db_fetch_array($result); return $data; } function getPublisherDetails($field='*', $where_data_array, $orderQuery = '') { $query = tep_db_select_query(TABLE_PUBLISHERS, $field, $where_data_array, $orderQuery); $result = tep_db_query($query); $data = tep_db_fetch_array($result); return $data; } //function added for getting special offer details on 29 mar11 function getSpecialOfferDetails($field='*', $where_data_array, $orderQuery = '') { $query = tep_db_select_query(TABLE_SPECIAL_OFFER_REQUEST, $field, $where_data_array, $orderQuery); $result = tep_db_query($query); $data = tep_db_fetch_array($result); return $data; } //End of function added for getting special offer details on 29 mar11 function getAffiliateManagerDetails($field='*', $where_data_array, $orderQuery = '') { $query = tep_db_select_query(TABLE_AFFILIATE_MANAGER, $field, $where_data_array, $orderQuery); $result = tep_db_query($query); $data = tep_db_fetch_array($result); return $data; } function getCategoryDetails($where_data_array) { $query = tep_db_select_query(TABLE_CATEGORY, "*", $where_data_array, $orderQuery); $result = tep_db_query($query); $data = tep_db_fetch_array($result); return $data; } function getAllCategories() { $orderQuery = " ORDER BY categoryName"; $query = tep_db_select_query(TABLE_CATEGORY, "*", $where_data_array, $orderQuery); $result = tep_db_query($query); while($data = tep_db_fetch_array($result)) { $categoryList[$data['categoryId']] = $data['categoryName']; } return $categoryList; } function getAllPubCategories() { $orderQuery = " ORDER BY categoryName"; $query = tep_db_select_query('publisher_category', "*", $where_data_array, $orderQuery); $result = tep_db_query($query); while($data = tep_db_fetch_array($result)) { $categoryList[$data['categoryId']] = $data['categoryName']; } return $categoryList; } function getCampaignDetails($where_data_array) { $query = tep_db_select_query(TABLE_CAMPAIGN, "*", $where_data_array, $orderQuery); $result = tep_db_query($query); $data = tep_db_fetch_array($result); return $data; } /*Added for edit advertiser blacklist page by tanvi on 16 feb 2010*/ function getPublisherAdvDetails($where_data_array) { $query = tep_db_select_query(TABLE_PUBLISHERS,"*", $where_data_array, $orderQuery); $result = tep_db_query($query); $data = tep_db_fetch_array($result); return $data; } /*Added for edit advertiser blacklist page by tanvi on 16 feb 2010*/ function deleteCampaign($where_data_array) { tep_db_delete(TABLE_CAMPAIGN, $where_data_array); return ; } function deleteCreative($where_data_array) { tep_db_delete(TABLE_CREATIVE, $where_data_array); return ; } function deleteSchedulemail($where_data_array) { tep_db_delete("email_schedule", $where_data_array); return ; } function deletePixel($where_data_array) { tep_db_delete(TABLE_PIXEL, $where_data_array); return ; } function deleteCustomPayout($where_data_array) { tep_db_delete(TABLE_CAMPAIGN_CUSTOM_PAYOUT, $where_data_array); return ; } function deleteBlacklist($where_data_array) { tep_db_delete(TABLE_CAMPAIGN_BLACKLIST, $where_data_array); return ; } function deleteAdvBlacklist($where_data_array) { tep_db_delete(TABLE_ADVERTISER_BLACKLIST, $where_data_array); return ; } function deletePubaffmanagers($where_data_array) { tep_db_delete('pubaffiliatemanagers', $where_data_array); return ; } function publishCampaign($sql_data_array, $where_data) { tep_db_perform(TABLE_CAMPAIGN, $sql_data_array, 'update', $where_data); return ; } function deleteCampainPendingRequest($where_data_array) { tep_db_delete(TABLE_CAMPAIGN_REQUEST, $where_data_array); return ; } //Function added to delete the affiliates assigned to particular status on 25 aug 2011 function deleteaffiliateassignstatus($where_data_array) { tep_db_delete('status_assigned_affiliateids', $where_data_array); return ; } //End of function. function getCreativeDetails($where_data_array) { $query = tep_db_select_query(TABLE_CREATIVE, "*", $where_data_array, $orderQuery); $result = tep_db_query($query); while($data = tep_db_fetch_array($result)) { $creativeData[$data['creativeId']] = $data; } return $creativeData; } //Added for mass email to publishers for sending new campaign info on 19apr10 function getEmailCreativeDetails($whereQuery) { $query = "select * from ".TABLE_CREATIVE." where 1 ".$whereQuery.""; $result = tep_db_query($query); while($data = tep_db_fetch_array($result)) { $creativeData = $data; } return $creativeData; } //Added for mass email to publishers for sending new campaign info on 19apr10 function getWebsiteCategory($where_data_array) { $query = tep_db_select_query(TABLE_WEBSITE_CATEGORY, "*", $where_data_array, $orderQuery); $result = tep_db_query($query); while($data = tep_db_fetch_array($result)) { $websiteCatData[$data['categoryId']] = $data; } return $websiteCatData; } function getCreativeDetailCount($campaignIdArray) { $orderQuery = " GROUP BY campaignId"; $query = tep_db_select_query(TABLE_CAMPAIGN_IMPRESSION_DETAIL, "SUM(impression) AS impression, campaignId", $where_data_array, $orderQuery); $result = tep_db_query($query); while($data = tep_db_fetch_array($result)) { $clickImpData[$data['campaignId']] = $data['impression']; } return $clickImpData; } function getPublisherList() { $orderQuery = " ORDER BY firstname,pid"; $where_data_array = array("status"=>"Y"); $query = tep_db_select_query(TABLE_PUBLISHERS, "pid,firstname,lastname,email,username,password,companyName,website", $where_data_array, $orderQuery); $result = tep_db_query($query); while($data = tep_db_fetch_array($result)) { $publisherList[$data['pid']] = $data['firstname'].' '.$data['lastname']; } return $publisherList; } function getaffmanagerPublisherList() { $orderQuery = " ORDER BY firstname,pid"; $where_data_array = array("status"=>"Y", "affMId"=>$_SESSION['infinite_affmanagerID']); //$query = tep_db_select_query(TABLE_PUBLISHERS, "pid,firstname,lastname,email,username,password,companyName,website", $where_data_array, $orderQuery); $query = "select pub.* from ".TABLE_PUBLISHERS." as pub join pubaffiliatemanagers as pubaff on pubaff.pid = pub.pid where pubaff.affMId ='".$_SESSION['infinite_affmanagerID']."' and pub.status = 'Y' order by pub.firstname,pub.pid"; $result = tep_db_query($query); while($data = tep_db_fetch_array($result)) { $publisherList[$data['pid']] = $data['firstname'].' '.$data['lastname']; } return $publisherList; } function getAffiliateManagerList() { $orderQuery = " ORDER BY amid"; $where_data_array = array("status"=>"Y"); $query = tep_db_select_query(TABLE_AFFILIATE_MANAGER, "amid,firstname,lastname,categoryId", $where_data_array, $orderQuery); $result = tep_db_query($query); while($data = tep_db_fetch_array($result)) { $affiliateManagerList[$data['amid']] = $data['firstname'].' '.$data['lastname']; } return $affiliateManagerList; } function getAffiliateManagercategoryList() { global $affmanagercategory; $orderQuery = " ORDER BY amid"; $where_data_array = array("status"=>"Y"); $query = tep_db_select_query(TABLE_AFFILIATE_MANAGER, "amid,firstname,lastname,categoryId", $where_data_array, $orderQuery); $result = tep_db_query($query); while($data = tep_db_fetch_array($result)) { $affiliateManagerList[$data['amid']] = $data; } return $affiliateManagerList; } function getAdvertiserManagerList() { $orderQuery = " ORDER BY amid"; $where_data_array = array("status"=>"Y"); $query = tep_db_select_query(TABLE_ADVERTISER_MANAGER, "amid,firstname,lastname", $where_data_array, $orderQuery); $result = tep_db_query($query); while($data = tep_db_fetch_array($result)) { $affiliateManagerList[$data['amid']] = $data['firstname'].' '.$data['lastname']; } return $affiliateManagerList; } function getPixelDetails($whereQuery) { //$query = tep_db_select_query(TABLE_PIXEL, "*", $where_data_array, $orderQuery); $query = "SELECT pixel.*,pub.firstname,pub.lastname,pub.pid,camp.campaignName FROM ".TABLE_PIXEL." AS pixel left join ".TABLE_PUBLISHERS." AS pub ON pub.pid = pixel.pid left join ".TABLE_CAMPAIGN." as camp on camp.campaignId=pixel.campaignId ".$whereQuery.$orderQuery; $result = tep_db_query($query); while($data = tep_db_fetch_array($result)) { $pixelData[$data['pixelId']] = $data; } return $pixelData; } function getCustomPayout($whereQuery) { //$query = tep_db_select_query(TABLE_PIXEL, "*", $where_data_array, $orderQuery); $query = "SELECT custom.*,pub.firstname,pub.lastname,pub.pid,camp.campaignName FROM ".TABLE_CAMPAIGN_CUSTOM_PAYOUT." AS custom left join ".TABLE_PUBLISHERS." AS pub ON pub.pid = custom.affiliateId left join ".TABLE_CAMPAIGN." as camp on camp.campaignId=custom.campaignId ".$whereQuery.$orderQuery; $result = tep_db_query($query); while($data = tep_db_fetch_array($result)) { $pixelData[$data['custId']] = $data; } return $pixelData; } function getPublisherCustomPayout($whereQuery) { //$query = tep_db_select_query(TABLE_PIXEL, "*", $where_data_array, $orderQuery); $query = "SELECT custom.*,pub.firstname,pub.lastname,camp.campaignName,camp.revenue,pubpayout.percentage,camp.campaignId,camp.percentrevenue FROM ".TABLE_CAMPAIGN_CUSTOM_PAYOUT." AS custom left join ".TABLE_PUBLISHERS." AS pub ON pub.pid = custom.affiliateId left join ".TABLE_CAMPAIGN." as camp on camp.campaignId=custom.campaignId left join ".TABLE_PUBLISHER_PAYOUT_PERCENTAGE." As pubpayout ON pubpayout.affiliateId = custom.affiliateId ".$whereQuery.$orderQuery; $result = tep_db_query($query); while($data = tep_db_fetch_array($result)) { $pixelData[$data['custId']] = $data; } return $pixelData; } //Added for view of scheduling emails list on 30 oct 2010. function getSchedulemails($whereQuery='') { $query = "SELECT * from email_schedule where 1 ".$whereQuery.""; $result = tep_db_query($query); while($data = tep_db_fetch_array($result)) { $maildata[$data['id']] = $data; } return $maildata; } //End of addition function getCustomBlacklist($whereQuery) { //$query = tep_db_select_query(TABLE_PIXEL, "*", $where_data_array, $orderQuery); $query = "SELECT custom.*,pub.firstname,pub.lastname,camp.campaignName FROM ".TABLE_CAMPAIGN_BLACKLIST." AS custom left join ".TABLE_PUBLISHERS." AS pub ON pub.pid = custom.affiliateId left join ".TABLE_CAMPAIGN." as camp on camp.campaignId=custom.campaignId ".$whereQuery.$orderQuery; $result = tep_db_query($query); while($data = tep_db_fetch_array($result)) { $pixelData[$data['custId']] = $data; } return $pixelData; } //Code Added for the advertiser blacklist publishers on 4 feb 10. function getAdvCustomBlacklist($whereQuery) { //$query = tep_db_select_query(TABLE_PIXEL, "*", $where_data_array, $orderQuery); $query = "SELECT custom.*,pub.firstname,pub.lastname,advertiser.firstname AS advertisername FROM ".TABLE_ADVERTISER_BLACKLIST." AS custom left join ".TABLE_PUBLISHERS." AS pub ON pub.pid = custom.affiliateId left join ".TABLE_ADVERTISERS." as advertiser on advertiser.aid=custom.aid ".$whereQuery.$orderQuery; $result = tep_db_query($query); while($data = tep_db_fetch_array($result)) { $pixelData[$data['custId']] = $data; } return $pixelData; } //End of code added for the advertiser blacklist publishers on 4 feb 10. function getCustomAffiliatePayout($whereQuery) { //$query = tep_db_select_query(TABLE_PIXEL, "*", $where_data_array, $orderQuery); $query = "SELECT * FROM ".TABLE_CAMPAIGN_CUSTOM_PAYOUT.$whereQuery.$orderQuery; $result = tep_db_query($query); while($data = tep_db_fetch_array($result)) { $pixelData[$data['campaignId']] = $data; } return $pixelData; } function getAllRecCampaign($wherequery = '') { $orderQuery = " ORDER BY leadCount"; $query = "SELECT COUNT(*) AS leadCount, click.campaignId,campaign.categoryId,campaign.campaignName,campaign.campaignDescription,campaign.payout FROM ".TABLE_CAMPAIGN_LEAD_DETAIL." AS click LEFT JOIN ".TABLE_CAMPAIGN." AS campaign ON campaign.campaignId=click.campaignId WHERE 1 ".$wherequery." GROUP BY click.campaignId".$orderQuery." limit 0,5"; $result = tep_db_query($query); while($data = mysql_fetch_assoc($result)) { $recCampaignData[$data['campaignId']] = $data; } return $recCampaignData; } function getSelectCategory($wherequery = '',$limit) { $orderQuery = " ORDER BY categoryName"; $query = "SELECT * FROM ".TABLE_CATEGORY." where 1 ".$wherequery; $result = tep_db_query($query); while($data = mysql_fetch_assoc($result)) { $category[$data['categoryId']] = $data['categoryName']; } return $category; } function getSupressionDetails($where_data_array) { $query = tep_db_select_query(TABLE_CAMPAIGN_SUPRESSION_FILES, "*", $where_data_array, $orderQuery); $result = tep_db_query($query); while($data = tep_db_fetch_array($result)) { $supressionData[$data['fileId']] = $data; } return $supressionData; } function deleteFile($where_data_array) { tep_db_delete(TABLE_CAMPAIGN_SUPRESSION_FILES, $where_data_array); return ; } function getPublishercategoryDetails($fields,$catid) { $query ="(select ".$fields." from ".TABLE_PUBLISHERS." where categoryId='' AND status='Y') union (select ".$fields." from ".TABLE_PUBLISHERS." where categoryId='".$catid."' AND status='Y')"; $result = tep_db_query($query); while($data = tep_db_fetch_array($result)) { $publisherList[$data['pid']] = $data; } return $publisherList; } function getActivePublisherDetails($fields) { $orderQuery = " ORDER BY pid"; $where_data_array = array("status"=>"Y"); $query = tep_db_select_query(TABLE_PUBLISHERS, $fields, $where_data_array, $orderQuery); $result = tep_db_query($query); while($data = tep_db_fetch_array($result)) { $publisherList[$data['pid']] = $data; } return $publisherList; } //Added on 1 feb 2011 for advertiser rep email function function getAdvertiserRepDetails($fields) { $orderQuery = " ORDER BY aid"; $where_data_array = array("status"=>"Y", "advMId"=>$_SESSION['infinite_advmanagerID']); $query = tep_db_select_query(TABLE_ADVERTISERS, $fields, $where_data_array, $orderQuery); $result = tep_db_query($query); while($data = tep_db_fetch_array($result)) { $publisherList[$data['aid']] = $data; } return $publisherList; } //End of Addition function get101PublisherDetails($fields) { $orderQuery = " ORDER BY pid"; $where_data_array = array("status"=>"Y", "pid"=>'101'); $query = tep_db_select_query(TABLE_PUBLISHERS, $fields, $where_data_array, $orderQuery); $result = tep_db_query($query); while($data = tep_db_fetch_array($result)) { $publisherList[$data['pid']] = $data; } return $publisherList; } function getAdvertiserList($where_data_array,$fields) { $orderQuery = " ORDER BY firstname,aid"; $query = tep_db_select_query(TABLE_ADVERTISERS, $fields, $where_data_array, $orderQuery); $result = tep_db_query($query); while($data = tep_db_fetch_array($result)) { $advertiserList[$data['aid']] = $data; } return $advertiserList; } /***************************************Added for download reports in publisher***************************************************************************/ function getnoclicks_download($wherequery = '') { $orderQuery = " ORDER BY leadDate"; global $campaignData_download; global $distinctCountpub; global $pub_subid; /*$query = "SELECT SUM(clicks) AS clickCount, click.subId, click.clickedDate, campaign.*, category.categoryName FROM ".TABLE_CAMPAIGN_CLICKS_DETAIL." AS click LEFT JOIN ".TABLE_CAMPAIGN." AS campaign ON campaign.campaignId=click.campaignId LEFT JOIN ".TABLE_CATEGORY ." AS category ON category.categoryId=campaign.categoryId WHERE 1 ".$wherequery." AND campaign.status='Y' GROUP BY click.campaignId,click.subId";*/ $query = "SELECT SUM(clickcount) AS clickCount,click.subId,sum(click.payout),click.clickedDate,sum(uniqueclicks) As uniqueclickcount,round(((sum(click.payout)/count(*))*sum(uniqueclicks)),2)as cpcearning,sum(impressioncount) AS impressioncount, campaign.*,click.campaignId,category.categoryName FROM campaignclickdetailreport AS click LEFT JOIN ".TABLE_CAMPAIGN." AS campaign ON campaign.campaignId=click.campaignId LEFT JOIN ".TABLE_CATEGORY ." AS category ON category.categoryId=campaign.categoryId WHERE 1 ".$wherequery." AND campaign.status='Y' AND click.campaignId <>'' GROUP BY click.campaignId,click.subId"; //$query = "SELECT lead.*, publisher.firstname ,publisher.lastname,publisher.pid,campaign.campaignName FROM (".TABLE_PUBLISHERS." AS publisher INNER JOIN ".TABLE_CAMPAIGN_LEAD_DETAIL." AS lead ON lead.affiliateId=publisher.pid ) INNER JOIN ".TABLE_CAMPAIGN." AS campaign ON lead.campaignId = campaign.campaignId and lead.affiliateId <> 0".$wherequery.$orderQuery; $result = tep_db_query($query); $_SESSION['ses_campaign_report_query'] = $query; while($data = tep_db_fetch_array($result)) { if($data['subId'] == '') $data['subId'] = 'None'; $pub_subid = trim($data['subId']); $data['subId'] = trim($data['subId']); $campaignData_download[$data['campaignId'].".".$data['subId']] = $data; $ClickSubId_array[$data['campaignId']][$data['subId']] = $data['subId']; $campaignIdArray[$data['campaignId']]= $data['campaignId']; }; $distinctpub_query = "select `campaignId`,count(*),`subId` from (select distinct `campaignId`,`userIpAddress`,`sessionId`,`subId` from ".TABLE_CAMPAIGN_CLICKS_DETAIL." AS click WHERE 1 ".$wherequery.") t GROUP BY campaignId,subId"; $result_distinctpub = tep_db_query($distinctpub_query); while($data_distinctpub = tep_db_fetch_array($result_distinctpub)) { if($data_distinctpub['subId'] == '') $data_distinctpub['subId'] = 'None'; $data_distinctpub['subId'] = trim($data_distinctpub['subId']); $distinctCountpub[$data_distinctpub['campaignId']][$data_distinctpub['subId']] = $data_distinctpub['count(*)']; } return $campaignData_download; } function getnoleads_download($wherequery = '') { //echo"2"; $orderQuery = " ORDER BY leadDate"; global $leadCount; global $leadPayout; global $leadDate; global $campaignData_download; $query = "SELECT COUNT(*) AS leadCount, click.campaignId,sum(click.payout) as payout, click.subId,click.leadDate,campaign.campaignName FROM ".TABLE_CAMPAIGN_LEAD_DETAIL." AS click LEFT JOIN ".TABLE_CAMPAIGN." AS campaign ON campaign.campaignId=click.campaignId WHERE 1 ".$wherequery." AND click.affiliateId='".$_SESSION['infinite_publisherID']."' GROUP BY click.campaignId,click.subId"; $result = tep_db_query($query); $_SESSION['ses_lead_report_query'] = $query; while($data = tep_db_fetch_array($result)) { if($data['subId'] == '') $data['subId'] = 'None'; $data['subId'] = trim($data['subId']); $campaignData_download[$data['campaignId'].".".$data['subId']] = $data; $leadCount[$data['campaignId']][$data['subId']] = $data['leadCount']; $leadPayout[$data['campaignId']][$data['subId']] = $data['payout']; $leadDate[$data['campaignId']][$data['subId']] = $data['leadDate']; } //$query = "SELECT lead.*, publisher.firstname ,publisher.lastname,publisher.pid,campaign.campaignName FROM (".TABLE_PUBLISHERS." AS publisher INNER JOIN ".TABLE_CAMPAIGN_LEAD_DETAIL." AS lead ON lead.affiliateId=publisher.pid ) INNER JOIN ".TABLE_CAMPAIGN." AS campaign ON lead.campaignId = campaign.campaignId and lead.affiliateId <> 0".$wherequery.$orderQuery; return $campaignData_download; } function getnoimpressions_download($wherequery = '') { //echo"1"; $orderQuery = " ORDER BY leadDate"; global $impressionCount; global $campaignData_download; $query = "SELECT COUNT(*) AS impressionCount, click.campaignId, click.subId FROM ".TABLE_CAMPAIGN_IMPRESSION_DETAIL." AS click LEFT JOIN ".TABLE_CAMPAIGN." AS campaign ON campaign.campaignId=click.campaignId WHERE 1 ".$wherequery." AND affiliateId='".$_SESSION['infinite_publisherID']."' GROUP BY click.campaignId,click.subId"; //$query = "SELECT COUNT(*) AS leadCount, click.campaignId,sum(click.payout) as payout, click.subId FROM ".TABLE_CAMPAIGN_LEAD_DETAIL." AS click LEFT JOIN ".TABLE_CAMPAIGN." AS campaign ON campaign.campaignId=click.campaignId WHERE 1 ".$wherequery." AND affiliateId='".$_SESSION['infinite_publisherID']."' GROUP BY click.campaignId,click.subId"; $result = tep_db_query($query); $_SESSION['ses_imp_report_query'] = $query; while($data = tep_db_fetch_array($result)) { if($data['subId'] == '') $data['subId'] = 'None'; $data['subId'] = trim($data['subId']); $campaignData_download[$data['campaignId'].".".$data['subId']] = $data; $impressionCount[$data['campaignId']][$data['subId']] = $data['impressionCount']; } //$query = "SELECT lead.*, publisher.firstname ,publisher.lastname,publisher.pid,campaign.campaignName FROM (".TABLE_PUBLISHERS." AS publisher INNER JOIN ".TABLE_CAMPAIGN_LEAD_DETAIL." AS lead ON lead.affiliateId=publisher.pid ) INNER JOIN ".TABLE_CAMPAIGN." AS campaign ON lead.campaignId = campaign.campaignId and lead.affiliateId <> 0".$wherequery.$orderQuery; return $campaignData_download; } /***************************************Added for download reports in publisher***************************************************************************/ function getadminclicks($wherequery = '',$ordquery='') { global $campaignData; global $distinctCount; global $clickPayout; global $distinctCountpub; $orderQuery = $ordquery; if(tep_session_is_registered('infinite_admin')) { $query = "SELECT SUM(clicks) AS clickCount,click.affiliateId,click.campaignId,sum(click.payout) as cpcpayout,click.subId, campaign.*,campaign.payout as totalpayout, category.categoryName FROM ".TABLE_CAMPAIGN_CLICKS_DETAIL." AS click RIGHT JOIN ".TABLE_CAMPAIGN." AS campaign ON campaign.campaignId=click.campaignId LEFT JOIN ".TABLE_CATEGORY ." AS category ON category.categoryId=campaign.categoryId WHERE 1 ".$wherequery." and click.affiliateId <> 0 AND campaign.status='Y' GROUP BY click.campaignId ".$orderQuery.""; $result = tep_db_query($query); $_SESSION['ses_campaign_report_query'] = $query; while($data = tep_db_fetch_array($result)) { $campaignData[$data['campaignId']] = $data; $clickPayout[$data['campaignId']] = $data['cpcpayout']; } $distinct_query = "select `campaignId`,count(*) from (select distinct `campaignId`, `affiliateId`, `userIpAddress`,`sessionId` from ".TABLE_CAMPAIGN_CLICKS_DETAIL." AS click WHERE 1 ".$wherequery." and affiliateId <> 0) t group by campaignId"; $result_distinct = tep_db_query($distinct_query); while($data_distinct = tep_db_fetch_array($result_distinct)) { $distinctCount[$data_distinct['campaignId']] = $data_distinct['count(*)']; } } else { $query = "SELECT SUM(clicks) AS clickCount, click.subId, campaign.*, category.categoryName FROM ".TABLE_CAMPAIGN_CLICKS_DETAIL." AS click LEFT JOIN ".TABLE_CAMPAIGN." AS campaign ON campaign.campaignId=click.campaignId LEFT JOIN ".TABLE_CATEGORY ." AS category ON category.categoryId=campaign.categoryId WHERE 1 ".$wherequery." AND campaign.status='Y' GROUP BY click.campaignId,click.subId"; //$query = "SELECT lead.*, publisher.firstname ,publisher.lastname,publisher.pid,campaign.campaignName FROM (".TABLE_PUBLISHERS." AS publisher INNER JOIN ".TABLE_CAMPAIGN_LEAD_DETAIL." AS lead ON lead.affiliateId=publisher.pid ) INNER JOIN ".TABLE_CAMPAIGN." AS campaign ON lead.campaignId = campaign.campaignId and lead.affiliateId <> 0".$wherequery.$orderQuery; $result = tep_db_query($query); $_SESSION['ses_campaign_report_query'] = $query; while($data = tep_db_fetch_array($result)) { if($data['subId'] == '') $data['subId'] = 'None'; $data['subId'] = trim($data['subId']); $campaignData[$data['campaignId'].".".$data['subId']] = $data; $ClickSubId_array[$data['campaignId']][$data['subId']] = $data['subId']; $campaignIdArray[$data['campaignId']]= $data['campaignId']; } $distinctpub_query = "select `campaignId`,count(*),`subId` from (select distinct `campaignId`,`userIpAddress`,`sessionId`,`subId` from ".TABLE_CAMPAIGN_CLICKS_DETAIL." AS click WHERE 1 ".$wherequery.") t GROUP BY campaignId,subId"; $result_distinctpub = tep_db_query($distinctpub_query); while($data_distinctpub = tep_db_fetch_array($result_distinctpub)) { if($data_distinctpub['subId'] == '') $data_distinctpub['subId'] = 'None'; $data_distinctpub['subId'] = trim($data_distinctpub['subId']); $distinctCountpub[$data_distinctpub['campaignId']][$data_distinctpub['subId']] = $data_distinctpub['count(*)']; } } //$query = "SELECT lead.*, publisher.firstname ,publisher.lastname,publisher.pid,campaign.campaignName FROM (".TABLE_PUBLISHERS." AS publisher INNER JOIN ".TABLE_CAMPAIGN_LEAD_DETAIL." AS lead ON lead.affiliateId=publisher.pid ) INNER JOIN ".TABLE_CAMPAIGN." AS campaign ON lead.campaignId = campaign.campaignId and lead.affiliateId <> 0".$wherequery.$orderQuery; return $campaignData; } function getadminleads($wherequery = '',$ordquery='') { //echo"2"; //$orderQuery = " ORDER BY leadDate"; global $leadCount; global $leadPayout; global $campaignData; $orderQuery = $ordquery; if(tep_session_is_registered('infinite_admin')) { $query = "SELECT COUNT(*) AS leadCount, click.campaignId,click.affiliateId ,sum(click.payout) as payout,campaign.campaignName,campaign.revenue,campaign.payout AS campaignpayout,affiliate.firstname,affiliate.lastname FROM ".TABLE_CAMPAIGN_LEAD_DETAIL." AS click RIGHT JOIN ".TABLE_CAMPAIGN." AS campaign ON campaign.campaignId=click.campaignId LEFT JOIN ".TABLE_PUBLISHERS." AS affiliate ON affiliate.pid=click.affiliateId WHERE 1 ".$wherequery." and click.affiliateId <> 0 GROUP BY click.campaignId ".$orderQuery.""; $result = tep_db_query($query); $_SESSION['ses_lead_report_query'] = $query; while($data = tep_db_fetch_array($result)) { $campaignData[$data['campaignId']] = $data; $leadCount[$data['campaignId']] = $data['leadCount']; $leadPayout[$data['campaignId']] = $data['payout']; } } else { $query = "SELECT COUNT(*) AS leadCount, click.campaignId,sum(click.payout) as payout, click.subId,campaign.campaignName FROM ".TABLE_CAMPAIGN_LEAD_DETAIL." AS click LEFT JOIN ".TABLE_CAMPAIGN." AS campaign ON campaign.campaignId=click.campaignId WHERE 1 ".$wherequery." AND affiliateId='".$_SESSION['infinite_publisherID']."' GROUP BY click.campaignId,click.subId"; $result = tep_db_query($query); $_SESSION['ses_lead_report_query'] = $query; while($data = tep_db_fetch_array($result)) { if($data['subId'] == '') $data['subId'] = 'None'; $data['subId'] = trim($data['subId']); $campaignData[$data['campaignId'].".".$data['subId']] = $data; $leadCount[$data['campaignId']][$data['subId']] = $data['leadCount']; $leadPayout[$data['campaignId']][$data['subId']] = $data['payout']; } } return $campaignData; } function getadminimpressions($wherequery = '',$ordquery='') { //echo"1"; //$orderQuery = " ORDER BY leadDate"; global $impressionCount; global $campaignData; global $affiliateArr_new; $orderQuery = $ordquery; if(tep_session_is_registered('infinite_admin')) { $query = "SELECT COUNT(*) AS impressionCount, click.campaignId ,sum(click.payout) as cpcpayout,sum(click.revenue) As cpcrevenue,click.affiliateId,campaign.campaignName,campaign.revenue FROM ".TABLE_CAMPAIGN_IMPRESSION_DETAIL." AS click RIGHT JOIN ".TABLE_CAMPAIGN." AS campaign ON campaign.campaignId=click.campaignId WHERE 1 ".$wherequery." and click.affiliateId <> 0 GROUP BY click.campaignId ".$orderQuery .""; $result = tep_db_query($query); $_SESSION['ses_imp_report_query'] = $query; while($data = tep_db_fetch_array($result)) { $campaignData[$data['campaignId']] = $data; $impressionCount[$data['campaignId']] += $data['impressionCount']; $affiliateArr_new[$data['affiliateId']]=$data['affiliateId']; } } else { $query = "SELECT COUNT(*) AS impressionCount, click.campaignId, click.subId FROM ".TABLE_CAMPAIGN_IMPRESSION_DETAIL." AS click LEFT JOIN ".TABLE_CAMPAIGN." AS campaign ON campaign.campaignId=click.campaignId WHERE 1 ".$wherequery." AND affiliateId='".$_SESSION['infinite_publisherID']."' GROUP BY click.campaignId,click.subId"; //$query = "SELECT COUNT(*) AS leadCount, click.campaignId,sum(click.payout) as payout, click.subId FROM ".TABLE_CAMPAIGN_LEAD_DETAIL." AS click LEFT JOIN ".TABLE_CAMPAIGN." AS campaign ON campaign.campaignId=click.campaignId WHERE 1 ".$wherequery." AND affiliateId='".$_SESSION['infinite_publisherID']."' GROUP BY click.campaignId,click.subId"; $result = tep_db_query($query); $_SESSION['ses_imp_report_query'] = $query; while($data = tep_db_fetch_array($result)) { if($data['subId'] == '') $data['subId'] = 'None'; $data['subId'] = trim($data['subId']); $campaignData[$data['campaignId'].".".$data['subId']] = $data; $impressionCount[$data['campaignId']][$data['subId']] = $data['impressionCount']; } } //$query = "SELECT lead.*, publisher.firstname ,publisher.lastname,publisher.pid,campaign.campaignName FROM (".TABLE_PUBLISHERS." AS publisher INNER JOIN ".TABLE_CAMPAIGN_LEAD_DETAIL." AS lead ON lead.affiliateId=publisher.pid ) INNER JOIN ".TABLE_CAMPAIGN." AS campaign ON lead.campaignId = campaign.campaignId and lead.affiliateId <> 0".$wherequery.$orderQuery; return $campaignData; } /******************************************For Affiliate Reports in the Admin section on 1 august 09********************************************/ function getaffiliateclicks($wherequery = '') { global $campaignData; global $affiliateIdArray; global $distinctCountaff; //$orderQuery = $ordquery; if(tep_session_is_registered('infinite_admin') || tep_session_is_registered('infinite_account')) { $query = "SELECT SUM(clicks) AS clickCount,sum(click.payout) as cpcpayout,sum(click.revenue) As cpcrevenue,affiliate.*,camp.* FROM ".TABLE_CAMPAIGN_CLICKS_DETAIL." AS click LEFT JOIN ".TABLE_PUBLISHERS." AS affiliate ON affiliate.pid=click.affiliateId LEFT JOIN ".TABLE_CAMPAIGN." AS camp ON camp.campaignId=click.campaignId WHERE 1 ".$wherequery." and click.affiliateId <> 0 GROUP BY click.affiliateId"; $query = "SELECT sum(clickcount) AS clickCount,click.affiliateId,click.campaignId,sum(click.payout) as cpcpayout,sum(click.revenue) As cpcrevenue,click.subId,sum(uniqueclicks) As uniqueclickcount,sum(impressioncount) AS impressioncount,affiliate.*,camp.*,camp.payout as camppayout FROM campaignclickdetailreport AS click LEFT JOIN ".TABLE_PUBLISHERS." AS affiliate ON affiliate.pid=click.affiliateId LEFT JOIN ".TABLE_CAMPAIGN." AS camp ON camp.campaignId=click.campaignId WHERE 1 ".$wherequery." and click.affiliateId <> 0 AND affiliate.status = 'Y' GROUP BY click.affiliateId"; $result = tep_db_query($query); $_SESSION['ses_campaign_report_query'] = $query; while($data = tep_db_fetch_array($result)) { $campaignData[$data['pid']] = $data; $affiliateIdArray[$data['pid']]= $data['pid']; } $distinctaff_query = "select `affiliateId`,count(*) from (select distinct `campaignId`, `affiliateId`, `userIpAddress`,`sessionId` from ".TABLE_CAMPAIGN_CLICKS_DETAIL." AS click WHERE 1 ".$wherequery." and affiliateId <> 0) t group by affiliateId"; $result_distinctaff = tep_db_query($distinctaff_query); while($data_distinctaff = tep_db_fetch_array($result_distinctaff)) { $distinctCountaff[$data_distinctaff['affiliateId']] = $data_distinctaff['count(*)']; } } //Added by Tanvi on 25 Nov for Advertiser Rep section Affiliate Reports elseif(tep_session_is_registered('infinite_advmanager')) { $query = "SELECT sum(clickcount) AS clickCount,click.affiliateId,click.campaignId,sum(click.payout) as cpcpayout,click.subId,sum(uniqueclicks) As uniqueclickcount,sum(impressioncount) AS impressioncount,affiliate.*,camp.* FROM campaignclickdetailreport AS click LEFT JOIN ".TABLE_PUBLISHERS." AS affiliate ON affiliate.pid=click.affiliateId LEFT JOIN ".TABLE_CAMPAIGN." AS camp ON camp.campaignId=click.campaignId right join ".TABLE_ADVERTISERS." As advertiser ON advertiser.aid = camp.advertiserId WHERE 1 ".$wherequery." and click.affiliateId <> 0 GROUP BY click.affiliateId"; $result = tep_db_query($query); $_SESSION['ses_campaign_report_query'] = $query; while($data = tep_db_fetch_array($result)) { $campaignData[$data['pid']] = $data; $affiliateIdArray[$data['pid']]= $data['pid']; } } //End of code added by Tanvi on 25 Nov for Advertiser Rep section Affiliate Reports else { $query = "SELECT sum(clickcount) AS clickCount,click.affiliateId,click.campaignId,sum(click.payout) as cpcpayout,click.subId,sum(uniqueclicks) As uniqueclickcount,sum(impressioncount) AS impressioncount,affiliate.*,camp.* FROM campaignclickdetailreport AS click LEFT JOIN ".TABLE_PUBLISHERS." AS affiliate ON affiliate.pid=click.affiliateId LEFT JOIN ".TABLE_CAMPAIGN." AS camp ON camp.campaignId=click.campaignId WHERE 1 ".$wherequery." and click.affiliateId <> 0 GROUP BY click.affiliateId"; $result = tep_db_query($query); $_SESSION['ses_campaign_report_query'] = $query; while($data = tep_db_fetch_array($result)) { $campaignData[$data['pid']] = $data; $affiliateIdArray[$data['pid']]= $data['pid']; } } return $campaignData; } function cpcaffiliateearning($wherequery = '',$ordquery='') { global $totalcpcvalue; global $totalcpcrevenue; $cpc_earningquery = "SELECT click.payout as cpcpayout,sum(uniqueclicks) As uniqueclickcount,click.revenue,affiliate.* FROM campaignclickdetailreport AS click LEFT JOIN ".TABLE_PUBLISHERS." AS affiliate ON affiliate.pid=click.affiliateId LEFT JOIN ".TABLE_CAMPAIGN." AS camp ON camp.campaignId=click.campaignId WHERE 1 ".$wherequery." and click.affiliateId <> 0 AND affiliate.status = 'Y' AND camp.offerType='CPC' GROUP BY click.affiliateId,click.clickedDate"; $result_cpcearning = tep_db_query($cpc_earningquery); unset($totalcpcvalue); $calculatedvalue = 0; while($data_cpc = tep_db_fetch_array($result_cpcearning)) { $revenue = $data_cpc['revenue']; $uniqueclicks = $data_cpc['uniqueclickcount']; $cpcpayout_required = $data_cpc['cpcpayout']; $calculatedvalue = ($uniqueclicks*$cpcpayout_required); $calculatedrevenue = ($uniqueclicks*$revenue); $totalcpcrevenue[$data_cpc['pid']] += $calculatedrevenue; $totalcpcvalue[$data_cpc['pid']] += $calculatedvalue; } return $totalcpcvalue; } function getaffiliateleads($wherequery = '') { //echo"2"; //$orderQuery = " ORDER BY leadDate"; global $leadCount; global $leadPayout; global $campaignData; global $leadRevenue; //$orderQuery = $ordquery; if(tep_session_is_registered('infinite_admin') || tep_session_is_registered('infinite_account')) { $query = "SELECT COUNT(*) AS leadCount, click.affiliateId as pid,sum(click.payout) as payout,campaign.campaignName,sum(click.revenue) As leadrevenue,campaign.payout AS campaignpayout,affiliate.firstname,affiliate.lastname FROM ".TABLE_CAMPAIGN_LEAD_DETAIL." AS click LEFT JOIN ".TABLE_CAMPAIGN." AS campaign ON campaign.campaignId=click.campaignId LEFT JOIN ".TABLE_PUBLISHERS." AS affiliate ON affiliate.pid=click.affiliateId WHERE 1 ".$wherequery." AND click.campaignId='".$_REQUEST['campaignId']."' and click.affiliateId <> 0 AND affiliate.status = 'Y' GROUP BY click.affiliateId"; $result = tep_db_query($query); // $_SESSION['ses_lead_report_query'] = $query; while($data = tep_db_fetch_array($result)) { $campaignData[$data['pid']] = $data; $leadCount[$data['pid']] = $data['leadCount']; $leadPayout[$data['pid']] = $data['payout']; $leadRevenue[$data['pid']] = $data['leadrevenue']; } } //Added by Tanvi on 25 Nov for Advertiser Rep section Affiliate Reports elseif(tep_session_is_registered('infinite_advmanager')) { $query = "SELECT COUNT(*) AS leadCount, click.affiliateId as pid,sum(click.payout) as payout,campaign.campaignName,campaign.revenue,campaign.payout AS campaignpayout,affiliate. firstname,affiliate.lastname FROM ".TABLE_CAMPAIGN_LEAD_DETAIL." AS click LEFT JOIN ".TABLE_CAMPAIGN." AS campaign ON campaign.campaignId=click.campaignId LEFT JOIN ".TABLE_PUBLISHERS." AS affiliate ON affiliate.pid=click.affiliateId right join ".TABLE_ADVERTISERS." As advertiser ON advertiser.aid = campaign.advertiserId WHERE 1 ".$wherequery." AND click.campaignId='".$_REQUEST['campaignId']."' and click.affiliateId <> 0 GROUP BY click.affiliateId"; $result = tep_db_query($query); // $_SESSION['ses_lead_report_query'] = $query; while($data = tep_db_fetch_array($result)) { $campaignData[$data['pid']] = $data; $leadCount[$data['pid']] = $data['leadCount']; $leadPayout[$data['pid']] = $data['payout']; } } //End of code added by Tanvi on 25 Nov for Advertiser Rep section Affiliate Reports else { $query = "SELECT COUNT(*) AS leadCount, click.affiliateId as pid,sum(click.payout) as payout,campaign.campaignName,campaign.revenue,campaign.payout AS campaignpayout,affiliate. firstname,affiliate.lastname FROM ".TABLE_CAMPAIGN_LEAD_DETAIL." AS click LEFT JOIN ".TABLE_CAMPAIGN." AS campaign ON campaign.campaignId=click.campaignId LEFT JOIN ".TABLE_PUBLISHERS." AS affiliate ON affiliate.pid=click.affiliateId WHERE 1 ".$wherequery." AND click.campaignId='".$_REQUEST['campaignId']."' and click.affiliateId <> 0 GROUP BY click.affiliateId"; $result = tep_db_query($query); // $_SESSION['ses_lead_report_query'] = $query; while($data = tep_db_fetch_array($result)) { $campaignData[$data['pid']] = $data; $leadCount[$data['pid']] = $data['leadCount']; $leadPayout[$data['pid']] = $data['payout']; } } return $campaignData; } function getaffiliateimpressions($wherequery = '') { //echo"1"; //$orderQuery = " ORDER BY leadDate"; global $impressionCount; global $campaignData; if(tep_session_is_registered('infinite_admin')) { $query = "SELECT COUNT(*) AS impressionCount, click.affiliateId as pid FROM ".TABLE_CAMPAIGN_IMPRESSION_DETAIL." AS click LEFT JOIN ".TABLE_PUBLISHERS." AS affiliate ON affiliate.pid=click.affiliateId WHERE 1 ".$wherequery." AND campaignId='".$_REQUEST['campaignId']."' and click.affiliateId <> 0 AND affiliate.status = 'Y' GROUP BY click.affiliateId"; $result = tep_db_query($query); // $_SESSION['ses_imp_report_query'] = $query; while($data = tep_db_fetch_array($result)) { $campaignData[$data['pid']] = $data; $impressionCount[$data['pid']] = $data['impressionCount']; //$affiliateArr_new[$data['affiliateId']]=$data['affiliateId']; } } return $campaignData; } /******************************************For Affiliate Reports in the Admin section on 1 august 09********************************************/ /********************************************For Testing reports without subid****************************************/ function gettestclicks($wherequery = '',$ordquery='') { global $campaignData; global $distinctCount; global $subidcampaignId; global $distinctCountpub; global $campaignIdArray; $orderQuery = $ordquery; $query = "SELECT SUM(clicks) AS clickCount,click.subId, campaign.*,click.campaignId,category.categoryName FROM ".TABLE_CAMPAIGN_CLICKS_DETAIL." AS click LEFT JOIN ".TABLE_CAMPAIGN." AS campaign ON campaign.campaignId=click.campaignId LEFT JOIN ".TABLE_CATEGORY." AS category ON category.categoryId=campaign.categoryId WHERE 1 ".$wherequery." AND campaign.status='Y' AND click.campaignId <>'' GROUP BY click.campaignId"; //$query = "SELECT lead.*, publisher.firstname ,publisher.lastname,publisher.pid,campaign.campaignName FROM (".TABLE_PUBLISHERS." AS publisher INNER JOIN ".TABLE_CAMPAIGN_LEAD_DETAIL." AS lead ON lead.affiliateId=publisher.pid ) INNER JOIN ".TABLE_CAMPAIGN." AS campaign ON lead.campaignId = campaign.campaignId and lead.affiliateId <> 0".$wherequery.$orderQuery; $result = tep_db_query($query); $_SESSION['ses_campaign_report_query'] = $query; while($data = tep_db_fetch_array($result)) { if($data['subId'] == '') $data['subId'] = 'None'; $data['subId'] = trim($data['subId']); $campaignData[$data['campaignId']] = $data; $ClickSubId_array[$data['campaignId']] = $data['subId']; $campaignIdArray[$data['campaignId']]= $data['campaignId']; } $distinctpub_query = "select `campaignId`,count(*),`subId` from (select distinct `campaignId`,`userIpAddress`,`sessionId`,`subId` from ".TABLE_CAMPAIGN_CLICKS_DETAIL." AS click WHERE 1 AND click.campaignId <>'' ".$wherequery.") t GROUP BY campaignId"; $result_distinctpub = tep_db_query($distinctpub_query); while($data_distinctpub = tep_db_fetch_array($result_distinctpub)) { if($data_distinctpub['subId'] == '') $data_distinctpub['subId'] = 'None'; $data_distinctpub['subId'] = trim($data_distinctpub['subId']); $distinctCountpub[$data_distinctpub['campaignId']] = $data_distinctpub['count(*)']; } $subid_query="SELECT click.campaignId, click.subId FROM campaignclicksdetail AS click WHERE 1 ".$wherequery." AND click.subId <> '' GROUP BY click.campaignId, click.subId"; $result_subid = tep_db_query($subid_query); while($data_subid = tep_db_fetch_array($result_subid)) { $subidcampaignId[$data_subid['campaignId']] = $data_subid['campaignId']; } return $campaignData; } function gettestleads($wherequery = '',$ordquery='') { global $leadCount; global $leadPayout; global $campaignData; $leadPayout = null; $orderQuery = $ordquery; $query = "SELECT COUNT(*) AS leadCount, click.campaignId,sum(click.payout) as payout, click.subId,campaign.campaignName FROM ".TABLE_CAMPAIGN_LEAD_DETAIL." AS click LEFT JOIN ".TABLE_CAMPAIGN." AS campaign ON campaign.campaignId=click.campaignId WHERE 1 ".$wherequery." AND affiliateId='".$_SESSION['infinite_publisherID']."' GROUP BY click.campaignId"; $result = tep_db_query($query); $_SESSION['ses_lead_report_query'] = $query; while($data = tep_db_fetch_array($result)) { if($data['subId'] == '') $data['subId'] = 'None'; $data['subId'] = trim($data['subId']); $campaignData[$data['campaignId']] = $data; $leadCount[$data['campaignId']] = $data['leadCount']; $leadPayout[$data['campaignId']]= $data['payout']; } return $campaignData; } function gettestimpressions($wherequery = '',$ordquery='') { global $impressionCount; global $campaignData; global $affiliateArr_new; $orderQuery = $ordquery; $query = "SELECT COUNT(*) AS impressionCount,click.campaignId,click.subId FROM ".TABLE_CAMPAIGN_IMPRESSION_DETAIL." AS click LEFT JOIN ".TABLE_CAMPAIGN." AS campaign ON campaign.campaignId=click.campaignId WHERE 1 ".$wherequery." AND affiliateId='".$_SESSION['infinite_publisherID']."' AND click.campaignId <>'' GROUP BY click.campaignId"; //$query = "SELECT COUNT(*) AS leadCount, click.campaignId,sum(click.payout) as payout, click.subId FROM ".TABLE_CAMPAIGN_LEAD_DETAIL." AS click LEFT JOIN ".TABLE_CAMPAIGN." AS campaign ON campaign.campaignId=click.campaignId WHERE 1 ".$wherequery." AND affiliateId='".$_SESSION['infinite_publisherID']."' GROUP BY click.campaignId,click.subId"; $result = tep_db_query($query); $_SESSION['ses_imp_report_query'] = $query; while($data = tep_db_fetch_array($result)) { if($data['subId'] == '') $data['subId'] = 'None'; $data['subId'] = trim($data['subId']); $campaignData[$data['campaignId']] = $data; $impressionCount[$data['campaignId']] = $data['impressionCount']; } return $campaignData; } /********************************************For Testing reports without subid****************************************/ function getajaxclicks($wherequery = '',$ordquery='') { global $campaignData; global $distinctCount; global $clickPayout; global $distinctCountpub; $orderQuery = $ordquery; $query = "SELECT SUM(clicks) AS clickCount, click.subId, campaign.*, category.categoryName FROM ".TABLE_CAMPAIGN_CLICKS_DETAIL." AS click LEFT JOIN ".TABLE_CAMPAIGN." AS campaign ON campaign.campaignId=click.campaignId LEFT JOIN ".TABLE_CATEGORY ." AS category ON category.categoryId=campaign.categoryId WHERE 1 ".$wherequery." AND campaign.status='Y' GROUP BY click.campaignId,click.subId"; //$query = "SELECT lead.*, publisher.firstname ,publisher.lastname,publisher.pid,campaign.campaignName FROM (".TABLE_PUBLISHERS." AS publisher INNER JOIN ".TABLE_CAMPAIGN_LEAD_DETAIL." AS lead ON lead.affiliateId=publisher.pid ) INNER JOIN ".TABLE_CAMPAIGN." AS campaign ON lead.campaignId = campaign.campaignId and lead.affiliateId <> 0".$wherequery.$orderQuery; $result = tep_db_query($query); $_SESSION['ses_campaign_report_query'] = $query; while($data = tep_db_fetch_array($result)) { if($data['subId'] == '') $data['subId'] = 'None'; $data['subId'] = trim($data['subId']); $campaignData[$data['campaignId'].".".$data['subId']] = $data; $ClickSubId_array[$data['campaignId']][$data['subId']] = $data['subId']; $campaignIdArray[$data['campaignId']]= $data['campaignId']; } $distinctpub_query = "select `campaignId`,count(*),`subId` from (select distinct `campaignId`,`userIpAddress`,`sessionId`,`subId` from ".TABLE_CAMPAIGN_CLICKS_DETAIL." AS click WHERE 1 ".$wherequery.") t GROUP BY campaignId,subId"; $result_distinctpub = tep_db_query($distinctpub_query); while($data_distinctpub = tep_db_fetch_array($result_distinctpub)) { if($data_distinctpub['subId'] == '') $data_distinctpub['subId'] = 'None'; $data_distinctpub['subId'] = trim($data_distinctpub['subId']); $distinctCountpub[$data_distinctpub['campaignId']][$data_distinctpub['subId']] = $data_distinctpub['count(*)']; } return $campaignData; } function getajaxleads($wherequery = '',$ordquery='') { global $leadCount; global $leadPayout; global $campaignData; $orderQuery = $ordquery; $query = "SELECT COUNT(*) AS leadCount, click.campaignId,sum(click.payout) as payout, click.subId,campaign.campaignName FROM ".TABLE_CAMPAIGN_LEAD_DETAIL." AS click LEFT JOIN ".TABLE_CAMPAIGN." AS campaign ON campaign.campaignId=click.campaignId WHERE 1 ".$wherequery." AND affiliateId='".$_SESSION['infinite_publisherID']."' GROUP BY click.campaignId,click.subId"; $result = tep_db_query($query); $_SESSION['ses_lead_report_query'] = $query; while($data = tep_db_fetch_array($result)) { if($data['subId'] == '') $data['subId'] = 'None'; $data['subId'] = trim($data['subId']); $campaignData[$data['campaignId'].".".$data['subId']] = $data; $leadCount[$data['campaignId']][$data['subId']] = $data['leadCount']; $leadPayout[$data['campaignId']][$data['subId']] = $data['payout']; } return $campaignData; } function getajaximpressions($wherequery = '',$ordquery='') { global $impressionCount; global $campaignData; global $affiliateArr_new; $orderQuery = $ordquery; $query = "SELECT COUNT(*) AS impressionCount, click.campaignId, click.subId FROM ".TABLE_CAMPAIGN_IMPRESSION_DETAIL." AS click LEFT JOIN ".TABLE_CAMPAIGN." AS campaign ON campaign.campaignId=click.campaignId WHERE 1 ".$wherequery." AND affiliateId='".$_SESSION['infinite_publisherID']."' GROUP BY click.campaignId,click.subId"; $result = tep_db_query($query); $_SESSION['ses_imp_report_query'] = $query; while($data = tep_db_fetch_array($result)) { if($data['subId'] == '') $data['subId'] = 'None'; $data['subId'] = trim($data['subId']); $campaignData[$data['campaignId'].".".$data['subId']] = $data; $impressionCount[$data['campaignId']][$data['subId']] = $data['impressionCount']; } return $campaignData; } /*******************************************************FOR NEWTABLE REPORTS*******************************************************************/ function getnewadminclicks($wherequery = '',$ordquery='') { global $campaignData; global $distinctCount; global $clickPayout; global $campaignIdarray; global $subidcampaignId; global $distinctCountpub; $orderQuery = $ordquery; $query = "SELECT sum(clickcount) AS clickCount,click.affiliateId,click.clickedDate,click.campaignId,sum(click.payout) as cpcpayout,sum(click.revenue) As cpcrevenue,click.subId,sum(uniqueclicks) As uniqueclickcount,sum(impressioncount) AS impressioncount,campaign.*,campaign.payout as totalpayout, category.categoryName,affiliate.firstname FROM campaignclickdetailreport AS click RIGHT JOIN ".TABLE_CAMPAIGN." AS campaign ON campaign.campaignId=click.campaignId LEFT JOIN ".TABLE_CATEGORY ." AS category ON category.categoryId=campaign.categoryId LEFT JOIN ".TABLE_PUBLISHERS." AS affiliate ON affiliate.pid=click.affiliateId WHERE 1 ".$wherequery." and click.affiliateId <> 0 AND campaign.status='Y' GROUP BY click.campaignId ".$orderQuery.""; $result = tep_db_query($query); $_SESSION['ses_campaign_report_query'] = $query; while($data = tep_db_fetch_array($result)) { $campaignData[$data['campaignId']] = $data; $clickPayout[$data['campaignId']] = $data['cpcpayout']; $campaignIdarray[$data['campaignId']] = $data['campaignId']; } return $campaignData; } function getnewadminleads($wherequery = '',$ordquery='') { //echo"2"; //$orderQuery = " ORDER BY leadDate"; global $leadCount; global $leadPayout; global $campaignIdarray; global $campaignData; global $leadRevenue; global $leadDate; global $saleAmount; $leadPayout = null; $orderQuery = $ordquery; // $orderQuery = $ordquery; $query = "SELECT COUNT(*) AS leadCount, click.campaignId,click.leadDate,sum(click.saleamount) as saleamount,click.affiliateId,sum(click.revenue) As leadrevenue,sum(click.payout) as payout,campaign.campaignName,campaign.revenue,campaign.payout AS campaignpayout,affiliate.firstname,affiliate.lastname FROM ".TABLE_CAMPAIGN_LEAD_DETAIL." AS click RIGHT JOIN ".TABLE_CAMPAIGN." AS campaign ON campaign.campaignId=click.campaignId LEFT JOIN ".TABLE_PUBLISHERS." AS affiliate ON affiliate.pid=click.affiliateId WHERE 1 ".$wherequery." and click.affiliateId <> 0 AND affiliate.status = 'Y' GROUP BY click.campaignId ".$orderQuery.""; $result = tep_db_query($query); $_SESSION['ses_lead_report_query'] = $query; while($data = tep_db_fetch_array($result)) { $campaignData[$data['campaignId']] = $data; $leadCount[$data['campaignId']] = $data['leadCount']; $leadPayout[$data['campaignId']] = $data['payout']; $leadRevenue[$data['campaignId']] = $data['leadrevenue']; $leadDate[$data['campaignId']] = $data['leadDate']; $saleAmount[$data['campaignId']] = $data['saleamount']; $campaignIdarray[$data['campaignId']] = $data['campaignId']; } return $campaignData; } function getnewadminimpressions($wherequery = '',$ordquery='') { //echo"1"; //$orderQuery = " ORDER BY leadDate"; global $impressionCount; global $campaignData; global $affiliateArr_new; $orderQuery = $ordquery; if(tep_session_is_registered('infinite_admin')) { $query = "SELECT COUNT(*) AS impressionCount, click.campaignId ,click.affiliateId,campaign.campaignName,campaign.revenue FROM ".TABLE_CAMPAIGN_IMPRESSION_DETAIL." AS click RIGHT JOIN ".TABLE_CAMPAIGN." AS campaign ON campaign.campaignId=click.campaignId WHERE 1 ".$wherequery." and click.affiliateId <> 0 GROUP BY click.campaignId ".$orderQuery .""; $result = tep_db_query($query); $_SESSION['ses_imp_report_query'] = $query; while($data = tep_db_fetch_array($result)) { $campaignData[$data['campaignId']] = $data; $impressionCount[$data['campaignId']] += $data['impressionCount']; $affiliateArr_new[$data['affiliateId']]=$data['affiliateId']; } } else { $query = "SELECT COUNT(*) AS impressionCount, click.campaignId, click.subId FROM ".TABLE_CAMPAIGN_IMPRESSION_DETAIL." AS click LEFT JOIN ".TABLE_CAMPAIGN." AS campaign ON campaign.campaignId=click.campaignId WHERE 1 ".$wherequery." AND affiliateId='".$_SESSION['infinite_publisherID']."' GROUP BY click.campaignId,click.subId"; //$query = "SELECT COUNT(*) AS leadCount, click.campaignId,sum(click.payout) as payout, click.subId FROM ".TABLE_CAMPAIGN_LEAD_DETAIL." AS click LEFT JOIN ".TABLE_CAMPAIGN." AS campaign ON campaign.campaignId=click.campaignId WHERE 1 ".$wherequery." AND affiliateId='".$_SESSION['infinite_publisherID']."' GROUP BY click.campaignId,click.subId"; $result = tep_db_query($query); $_SESSION['ses_imp_report_query'] = $query; while($data = tep_db_fetch_array($result)) { if($data['subId'] == '') $data['subId'] = 'None'; $data['subId'] = trim($data['subId']); $campaignData[$data['campaignId'].".".$data['subId']] = $data; $impressionCount[$data['campaignId']][$data['subId']] = $data['impressionCount']; } } //$query = "SELECT lead.*, publisher.firstname ,publisher.lastname,publisher.pid,campaign.campaignName FROM (".TABLE_PUBLISHERS." AS publisher INNER JOIN ".TABLE_CAMPAIGN_LEAD_DETAIL." AS lead ON lead.affiliateId=publisher.pid ) INNER JOIN ".TABLE_CAMPAIGN." AS campaign ON lead.campaignId = campaign.campaignId and lead.affiliateId <> 0".$wherequery.$orderQuery; return $campaignData; } /***********************************************************FOR NEWTABLE REPORTS******************************************************************/ /********************************************************FOR SUBID REPORTS IN NEWTABLE REPORTS*********************************************************************************/ function getajaxnewclicks($wherequery = '',$ordquery='') { global $campaignData; global $distinctCount; global $clickPayout; global $distinctCountpub; global $pub_subid; $orderQuery = $ordquery; $query = "SELECT SUM(clickcount) AS clickCount,click.subId,sum(uniqueclicks) As uniqueclickcount,sum(impressioncount) AS impressioncount, campaign.*,click.campaignId,category.categoryName FROM campaignclickdetailreport AS click LEFT JOIN ".TABLE_CAMPAIGN." AS campaign ON campaign.campaignId=click.campaignId LEFT JOIN ".TABLE_CATEGORY ." AS category ON category.categoryId=campaign.categoryId WHERE 1 ".$wherequery." AND campaign.status='Y' AND click.campaignId <>'' GROUP BY click.campaignId,click.subId"; //$query = "SELECT lead.*, publisher.firstname ,publisher.lastname,publisher.pid,campaign.campaignName FROM (".TABLE_PUBLISHERS." AS publisher INNER JOIN ".TABLE_CAMPAIGN_LEAD_DETAIL." AS lead ON lead.affiliateId=publisher.pid ) INNER JOIN ".TABLE_CAMPAIGN." AS campaign ON lead.campaignId = campaign.campaignId and lead.affiliateId <> 0".$wherequery.$orderQuery; $result = tep_db_query($query); $_SESSION['ses_campaign_report_query'] = $query; while($data = tep_db_fetch_array($result)) { if($data['subId'] == '') $data['subId'] = 'None'; $pub_subid = trim($data['subId']); $data['subId'] = trim($data['subId']); $campaignData[$data['campaignId'].".".$data['subId']] = $data; $ClickSubId_array[$data['campaignId']][$data['subId']] = $data['subId']; $campaignIdArray[$data['campaignId']]= $data['campaignId']; } return $campaignData; } function cpcajaxnewearning($wherequery = '') { global $totalcpcajaxvalue; $cpc_earningquery = "SELECT click.payout as cpcpayout,click.subId,sum(uniqueclicks) As uniqueclickcount,click.campaignId FROM campaignclickdetailreport AS click LEFT JOIN ".TABLE_CAMPAIGN." AS campaign ON campaign.campaignId=click.campaignId LEFT JOIN ".TABLE_CATEGORY ." AS category ON category.categoryId=campaign.categoryId WHERE 1 ".$wherequery." AND campaign.status='Y' AND click.campaignId <>'' AND campaign.offerType='CPC' GROUP BY click.subId,click.clickedDate"; $result_cpcearning = tep_db_query($cpc_earningquery); unset($totalcpcajaxvalue); $calculatedvalue = 0; while($data_cpc = tep_db_fetch_array($result_cpcearning)) { if($data_cpc['subId'] == '') $data_cpc['subId'] = 'None'; $data_cpc['subId'] = trim($data_cpc['subId']); $uniqueclicks = $data_cpc['uniqueclickcount']; $cpcpayout_required = $data_cpc['cpcpayout']; $calculatedvalue = ($uniqueclicks*$cpcpayout_required); //echo"the required values"."-----".$data_cpc['subId']."-----".$totalcpcajaxvalue[$data_cpc['campaignId']][$data_cpc['subId']] += $calculatedvalue; //; $totalcpcajaxvalue[$data_cpc['campaignId']][$data_cpc['subId']] += $data_cpc['uniqueclickcount']*$data_cpc['cpcpayout']; $total += $calculatedvalue; } /*echo"
";
	print_r($totalcpcajaxvalue);
	echo"
"; echo "
".$total;*/ return $totalcpcajaxvalue; } function getajaxnewleads($wherequery = '',$ordquery='') { global $leadCount; global $leadPayout; global $campaignData; $orderQuery = $ordquery; $query = "SELECT COUNT(*) AS leadCount, click.campaignId,sum(click.payout) as payout, click.subId,campaign.campaignName FROM ".TABLE_CAMPAIGN_LEAD_DETAIL." AS click LEFT JOIN ".TABLE_CAMPAIGN." AS campaign ON campaign.campaignId=click.campaignId WHERE 1 ".$wherequery." AND affiliateId='".$_SESSION['infinite_publisherID']."' GROUP BY click.campaignId,click.subId"; $result = tep_db_query($query); $_SESSION['ses_lead_report_query'] = $query; while($data = tep_db_fetch_array($result)) { if($data['subId'] == '') $data['subId'] = 'None'; $data['subId'] = trim($data['subId']); $campaignData[$data['campaignId'].".".$data['subId']] = $data; $leadCount[$data['campaignId']][$data['subId']] = $data['leadCount']; $leadPayout[$data['campaignId']][$data['subId']] = $data['payout']; } return $campaignData; } function getajaxnewimpressions($wherequery = '',$ordquery='') { global $impressionCount; global $campaignData; global $affiliateArr_new; $orderQuery = $ordquery; $query = "SELECT COUNT(*) AS impressionCount, click.campaignId, click.subId FROM ".TABLE_CAMPAIGN_IMPRESSION_DETAIL." AS click LEFT JOIN ".TABLE_CAMPAIGN." AS campaign ON campaign.campaignId=click.campaignId WHERE 1 ".$wherequery." AND affiliateId='".$_SESSION['infinite_publisherID']."' GROUP BY click.campaignId,click.subId"; $result = tep_db_query($query); $_SESSION['ses_imp_report_query'] = $query; while($data = tep_db_fetch_array($result)) { if($data['subId'] == '') $data['subId'] = 'None'; $data['subId'] = trim($data['subId']); $campaignData[$data['campaignId'].".".$data['subId']] = $data; $impressionCount[$data['campaignId']][$data['subId']] = $data['impressionCount']; } return $campaignData; } /********************************************************FOR SUBID REPORTS IN NEWTABLE REPORTS*********************************************************************************/ function array_natsort($aryData, $strIndex, $strSortBy, $strSortType=false) { //if the parameters are invalid if(!is_array($aryData) || !$strIndex || !$strSortBy) { //return the array return $aryData; } //create our temporary arrays $arySort = $aryResult = array(); //loop through the array foreach ($aryData as $aryRow) { //set up the value in the array $arySort[$aryRow[$strIndex]] = $aryRow[$strSortBy]; } //apply the natural sort natsort($arySort); //if the sort type is descending if($strSortType=="desc") { //reverse the array arsort($arySort); } //loop through the sorted and original data foreach ($arySort as $arySortKey => $arySorted) { foreach ($aryData as $aryOriginal) { //if the key matches if ($aryOriginal[$strIndex]==$arySortKey) { //add it to the output array array_push($aryResult, $aryOriginal); } } } //return the return return $aryResult; } //added for the stats in publisher top menubar function getCpcCampaignValue($wherequery = '',$customPayoutstatus='') { $cpcvalue=0; $query = "SELECT SUM(clickcount) AS clickCount,click.subId,click.payout as cpcpayout,sum(uniqueclicks) As uniqueclickcount,round(((sum(click.payout)/count(*))*sum(uniqueclicks)),2)as cpcearning,campaign.*,campaign.payout as payout ,click.campaignId FROM campaignclickdetailreport AS click LEFT JOIN ".TABLE_CAMPAIGN." AS campaign ON campaign.campaignId=click.campaignId WHERE 1 ".$wherequery." AND campaign.status='Y' AND click.campaignId <>'' AND click.affiliateId='".$_SESSION['infinite_publisherID']."' AND campaign.offerType='cpc' GROUP BY click.campaignId,click.clickedDate"; $result = tep_db_query($query); while ($data = tep_db_fetch_array($result)) { if($data['offerType']=="CPC") { $uniqueclicks = $data['uniqueclickcount']; $cpcpayout_required = $data['cpcpayout']; $calculatedvalue = ($uniqueclicks*$cpcpayout_required); // $totalcpcvalue[$data_cpc['campaignId']] += $calculatedvalue; $cpcvalue += $calculatedvalue; } } return $cpcvalue; } //Added By Tanvi On 17 Nov 2009 for the Affiliate Manager Reports function getaffmanagerclicks($wherequery = '',$ordquery='') { global $campaignData; global $distinctCount; global $clickPayout; global $campaignIdarray; global $subidcampaignId; global $distinctCountpub; $orderQuery = $ordquery; $query = "SELECT sum(clickcount) AS clickCount,click.affiliateId,click.campaignId,sum(click.payout) as cpcpayout,sum(click.revenue) As cpcrevenue,click.subId,sum(uniqueclicks) As uniqueclickcount,sum(impressioncount) AS impressioncount,campaign.*,campaign.payout as totalpayout, category.categoryName FROM campaignclickdetailreport AS click RIGHT JOIN ".TABLE_CAMPAIGN." AS campaign ON campaign.campaignId=click.campaignId LEFT JOIN ".TABLE_PUBLISHERS." AS publishers ON publishers.pid=click.affiliateId LEFT JOIN publisher_category AS category ON category.categoryId=publishers.categoryId WHERE 1 ".$wherequery." and click.affiliateId <> 0 AND campaign.status='Y' GROUP BY click.campaignId ".$orderQuery.""; $result = tep_db_query($query); $_SESSION['ses_campaign_report_query'] = $query; while($data = tep_db_fetch_array($result)) { $campaignData[$data['campaignId']] = $data; $clickPayout[$data['campaignId']] = $data['cpcpayout']; $campaignIdarray[$data['campaignId']] = $data['campaignId']; } /*$subid_query="SELECT click.campaignId, click.subId FROM campaignclickdetailreport AS click WHERE 1 ".$wherequery." AND click.subId <> '' GROUP BY click.campaignId, click.subId"; $result_subid = tep_db_query($subid_query); while($data_subid = tep_db_fetch_array($result_subid)) { $subidcampaignId[$data_subid['campaignId']] = $data_subid['campaignId']; } */ return $campaignData; } function getaffmanagerleads($wherequery = '',$ordquery='') { global $leadCount; global $leadPayout; global $campaignIdarray; global $campaignData; global $leadRevenue; $leadPayout = null; $orderQuery = $ordquery; $query = "SELECT COUNT(*) AS leadCount, click.campaignId,click.affiliateId,sum(click.payout) as payout,sum(click.revenue) As leadrevenue,campaign.campaignName,campaign.revenue,campaign.payout AS campaignpayout,affiliate.firstname,affiliate.lastname,category.categoryName FROM ".TABLE_CAMPAIGN_LEAD_DETAIL." AS click RIGHT JOIN ".TABLE_CAMPAIGN." AS campaign ON campaign.campaignId=click.campaignId LEFT JOIN ".TABLE_PUBLISHERS." AS affiliate ON affiliate.pid=click.affiliateId LEFT JOIN publisher_category AS category ON category.categoryId=affiliate.categoryId WHERE 1 ".$wherequery." and click.affiliateId <> 0 GROUP BY click.campaignId ".$orderQuery.""; $result = tep_db_query($query); $_SESSION['ses_lead_report_query'] = $query; while($data = tep_db_fetch_array($result)) { $campaignData[$data['campaignId']] = $data; $leadCount[$data['campaignId']] = $data['leadCount']; $leadPayout[$data['campaignId']] = $data['payout']; $leadRevenue[$data['campaignId']] = $data['leadrevenue']; $campaignIdarray[$data['campaignId']] = $data['campaignId']; } return $campaignData; } //End of code Added By Tanvi On 17 Nov 2009 for the Affiliate Manager Reports //Added for cpc calculations of aff manager reports on 14 feb 2011. function cpcaffmanager($wherequery = '',$ordquery='') { global $totalcpcvalue; global $totalcpcrevenue; global $sumcpcpayout; $cpc_earningquery = "SELECT sum(clickcount) AS clickCount,click.payout as cpcpayout,click.campaignId,click.revenue,sum(uniqueclicks) As uniqueclickcount,round(((sum(click.payout)/count(*))*sum(uniqueclicks)),2)as cpcearning FROM campaignclickdetailreport AS click RIGHT JOIN ".TABLE_CAMPAIGN." AS campaign ON campaign.campaignId=click.campaignId LEFT JOIN ".TABLE_PUBLISHERS." AS publishers ON publishers.pid=click.affiliateId WHERE 1 ".$wherequery." and click.affiliateId <> 0 AND campaign.status='Y' AND campaign.offerType='CPC' GROUP BY click.affiliateId,click.campaignId,click.clickedDate ".$orderQuery.""; $result_cpcearning = tep_db_query($cpc_earningquery); unset($totalcpcvalue); $calculatedvalue = 0; while($data_cpc = tep_db_fetch_array($result_cpcearning)) { $revenue = $data_cpc['revenue']; $uniqueclicks = $data_cpc['uniqueclickcount']; $cpcpayout_required = $data_cpc['cpcpayout']; $calculatedvalue = ($uniqueclicks*$cpcpayout_required); $calculatedrevenue = ($uniqueclicks*$revenue); $totalcpcrevenue[$data_cpc['campaignId']] += $calculatedrevenue; $sumcpcpayout[$data_cpc['campaignId']] += $cpcpayout_required; $totalcpcvalue[$data_cpc['campaignId']] += $calculatedvalue; } return $totalcpcvalue; } //End of code on 14 feb 2011 //code Added By Tanvi On 24 Nov 2009 for the Advertiser Manager Reports function getadvmanagerclicks($wherequery = '',$ordquery='') { global $campaignData; global $distinctCount; global $clickPayout; global $campaignIdarray; global $subidcampaignId; global $distinctCountpub; $orderQuery = $ordquery; $query = "SELECT sum(clickcount) AS clickCount,click.affiliateId,click.campaignId,sum(click.payout) as cpcpayout,click.subId,sum(uniqueclicks) As uniqueclickcount,sum(impressioncount) AS impressioncount,campaign.*,campaign.payout as totalpayout,advertiser.firstname,advertiser.lastname,category.categoryName FROM campaignclickdetailreport AS click RIGHT JOIN ".TABLE_CAMPAIGN." AS campaign ON campaign.campaignId=click.campaignId LEFT JOIN ".TABLE_CATEGORY ." AS category ON category.categoryId=campaign.categoryId right join ".TABLE_ADVERTISERS." As advertiser ON advertiser.aid = campaign.advertiserId WHERE 1 ".$wherequery." and click.affiliateId <> 0 AND campaign.status='Y' GROUP BY click.campaignId ".$orderQuery.""; $result = tep_db_query($query); $_SESSION['ses_campaign_report_query'] = $query; while($data = tep_db_fetch_array($result)) { $campaignData[$data['campaignId']] = $data; $clickPayout[$data['campaignId']] = $data['cpcpayout']; $campaignIdarray[$data['campaignId']] = $data['campaignId']; } return $campaignData; } function getadvmanagerleads($wherequery = '',$ordquery='') { global $leadCount; global $leadPayout; global $campaignIdarray; global $campaignData; $leadPayout = null; $orderQuery = $ordquery; $query = "SELECT COUNT(*) AS leadCount, click.campaignId,click.affiliateId,sum(click.payout) as payout,campaign.campaignName,campaign.revenue,campaign.payout AS campaignpayout,affiliate.firstname,affiliate.pid FROM ".TABLE_CAMPAIGN_LEAD_DETAIL." AS click RIGHT JOIN ".TABLE_CAMPAIGN." AS campaign ON campaign.campaignId=click.campaignId LEFT JOIN ".TABLE_PUBLISHERS." AS affiliate ON affiliate.pid=click.affiliateId right join ".TABLE_ADVERTISERS." As advertiser ON advertiser.aid = campaign.advertiserId WHERE 1 ".$wherequery." and click.affiliateId <> 0 GROUP BY click.campaignId ".$orderQuery.""; $result = tep_db_query($query); $_SESSION['ses_lead_report_query'] = $query; while($data = tep_db_fetch_array($result)) { $campaignData[$data['campaignId']] = $data; $leadCount[$data['campaignId']] = $data['leadCount']; $leadPayout[$data['campaignId']] = $data['payout']; $campaignIdarray[$data['campaignId']] = $data['campaignId']; } return $campaignData; } function getadvmanagerimpressions($wherequery = '',$ordquery='') { global $impressionCount; global $campaignData; global $affiliateArr_new; $orderQuery = $ordquery; $query = "SELECT COUNT(*) AS impressionCount, click.campaignId ,click.affiliateId,campaign.campaignName,campaign.revenue FROM ".TABLE_CAMPAIGN_IMPRESSION_DETAIL." AS click RIGHT JOIN ".TABLE_CAMPAIGN." AS campaign ON campaign.campaignId=click.campaignId WHERE 1 ".$wherequery." and click.affiliateId <> 0 GROUP BY click.campaignId ".$orderQuery .""; $result = tep_db_query($query); $_SESSION['ses_imp_report_query'] = $query; while($data = tep_db_fetch_array($result)) { $campaignData[$data['campaignId']] = $data; $impressionCount[$data['campaignId']] += $data['impressionCount']; $affiliateArr_new[$data['affiliateId']]=$data['affiliateId']; } return $campaignData; } //End code Added By Tanvi On 24 Nov 2009 for the Advertiser Manager Reports //Code added for publisher earnings report By Tanvi on 23 Dec 09 function getpublisherleads($wherequery = '',$ordquery='') { global $leadCount; global $leadPayout; global $cpcuniqueclicks; global $cAffId; global $campId; global $cpcaffiliateId; global $clickPayout; global $clickCpcPayout; global $campaignData; global $cpccampaignIdarray; global $leadaffiliateId; $leadPayout = null; $orderQuery = $ordquery; $clickdataquery = str_replace("leadDate","clickedDate",$wherequery); // $orderQuery = $ordquery; $query = "SELECT COUNT(*) AS leadCount, click.campaignId,click.affiliateId,sum(click.payout) as payout,campaign.campaignName,campaign.revenue,campaign.payout AS campaignpayout,affiliate.firstname,affiliate.lastname FROM ".TABLE_CAMPAIGN_LEAD_DETAIL." AS click RIGHT JOIN ".TABLE_CAMPAIGN." AS campaign ON campaign.campaignId=click.campaignId LEFT JOIN ".TABLE_PUBLISHERS." AS affiliate ON affiliate.pid=click.affiliateId WHERE 1 ".$wherequery." AND affiliate.status = 'Y' and click.affiliateId <> 0 AND campaign.offerType<>'cpc' GROUP BY click.affiliateId ".$orderQuery.""; $result = tep_db_query($query); $_SESSION['ses_lead_report_query'] = $query; while($data = tep_db_fetch_array($result)) { $campaignData[$data['affiliateId']] = $data; $leadaffiliateId[$data['affiliateId']] = $data['affiliateId']; $leadCount[$data['affiliateId']] = $data['leadCount']; $leadPayout[$data['affiliateId']] = $data['payout']; } $cpcquery = "SELECT sum(clickcount) AS clickCount,click.affiliateId,publishers.firstname,publishers.lastname,click.campaignId,click.payout as cpcpayout,click.subId,sum(uniqueclicks) As uniqueclickcount,sum(impressioncount) AS impressioncount,campaign.payout as totalpayout FROM campaignclickdetailreport AS click RIGHT JOIN ".TABLE_CAMPAIGN." AS campaign ON campaign.campaignId=click.campaignId LEFT JOIN ".TABLE_PUBLISHERS." AS publishers ON publishers.pid=click.affiliateId WHERE 1 ".$clickdataquery." and click.affiliateId <> 0 AND campaign.status='Y' AND publishers.status = 'Y' AND campaign.offerType='CPC' GROUP BY click.campaignId,click.affiliateId,click.clickedDate ".$orderQuery.""; $cpcresult = tep_db_query($cpcquery); $_SESSION['ses_campaign_report_query'] = $cpcquery; while($cpcdata = tep_db_fetch_array($cpcresult)) { $cAffId[$cpcdata['affiliateId']] = $cpcdata['affiliateId']; $campId[$cpcdata['campaignId']] = $cpcdata['campaignId']; $cpckey = $cpcdata['affiliateId'].".".$cpcdata['campaignId']; $cpcaffiliateId[$cpckey] = $cpcdata['affiliateId'].".".$cpcdata['campaignId']; $payout[$cpckey] = $cpcdata['cpcpayout']; //$clickCpcPayout[$cpckey] = $cpcdata['cpcpayout']; $clickPayout[$cpckey] = $cpcdata['totalpayout']; //$clickEarning[$cpckey] = $cpcdata['cpcearning']; $cpcuniqueclicks[$cpckey] = $cpcdata['uniqueclickcount']; $clickCpcPayout[$cpckey] += (($cpcuniqueclicks[$cpckey])*($payout[$cpckey])); if(count($leadaffiliateId) != '') { if(!in_array($cpcdata['affiliateId'],$leadaffiliateId)) { $campaignData[$cpcdata['affiliateId']] = $cpcdata; } } } return $campaignData; } //End of Code added for publisher earnings report By Tanvi on 23 Dec 09 //Code Added for affiliate reports of the affiliate manager in the admin Section. function getaffmanageraffclicks($wherequery = '') { global $campaignData; global $affiliateIdArray; global $distinctCountaff; $query = "SELECT sum(clickcount) AS clickCount,click.affiliateId,click.campaignId,sum(click.payout) as cpcpayout,sum(click.revenue) As cpcrevenue,click.subId,sum(uniqueclicks) As uniqueclickcount,sum(impressioncount) AS impressioncount,affiliate.*,camp.* FROM campaignclickdetailreport AS click LEFT JOIN ".TABLE_PUBLISHERS." AS affiliate ON affiliate.pid=click.affiliateId LEFT JOIN ".TABLE_CAMPAIGN." AS camp ON camp.campaignId=click.campaignId WHERE 1 ".$wherequery." and click.affiliateId <> 0 GROUP BY click.affiliateId"; $result = tep_db_query($query); $_SESSION['ses_campaign_report_query'] = $query; while($data = tep_db_fetch_array($result)) { $campaignData[$data['pid']] = $data; $affiliateIdArray[$data['pid']]= $data['pid']; } return $campaignData; } function getaffmanageraffleads($wherequery = '') { global $leadCount; global $leadPayout; global $campaignData; global $leadRevenue; $query = "SELECT COUNT(*) AS leadCount, click.affiliateId as pid,sum(click.payout) as payout,sum(click.revenue) As leadrevenue,campaign.campaignName,campaign.revenue,campaign.payout AS campaignpayout,affiliate.firstname,affiliate.lastname FROM ".TABLE_CAMPAIGN_LEAD_DETAIL." AS click LEFT JOIN ".TABLE_CAMPAIGN." AS campaign ON campaign.campaignId=click.campaignId LEFT JOIN ".TABLE_PUBLISHERS." AS affiliate ON affiliate.pid=click.affiliateId WHERE 1 ".$wherequery." AND click.campaignId='".$_REQUEST['campaignId']."' and click.affiliateId <> 0 GROUP BY click.affiliateId"; $result = tep_db_query($query); while($data = tep_db_fetch_array($result)) { $campaignData[$data['pid']] = $data; $leadCount[$data['pid']] = $data['leadCount']; $leadRevenue[$data['pid']] = $data['leadrevenue']; $leadPayout[$data['pid']] = $data['payout']; } return $campaignData; } //End of Code Added for affiliate reports of the affiliate manager in the admin Section. //Added for daily reports of the campaigns in the admin section on 18 march 09. function getdailyreportclicks($wherequery = '',$ordquery='') { global $campaignData; global $distinctCount; global $clickPayout; global $campaignIdarray; global $subidcampaignId; global $distinctCountpub; $orderQuery = $ordquery; $query = "SELECT sum(clickcount) AS clickCount,FROM_UNIXTIME(clickedDate,'%m-%d-%Y') As date,click.campaignId,sum(click.payout) as cpcpayout,sum(click.revenue) As cpcrevenue,click.subId,sum(uniqueclicks) As uniqueclickcount,round(((sum(click.payout)/count(*))*sum(uniqueclicks)),2)as cpcearning,sum(impressioncount) AS impressioncount,campaign.*,campaign.payout as totalpayout, category.categoryName FROM campaignclickdetailreport AS click RIGHT JOIN ".TABLE_CAMPAIGN." AS campaign ON campaign.campaignId=click.campaignId LEFT JOIN ".TABLE_CATEGORY ." AS category ON category.categoryId=campaign.categoryId WHERE 1 ".$wherequery." and click.affiliateId <> 0 AND campaign.status='Y' GROUP BY FROM_UNIXTIME(`clickedDate`, '%m-%d-%Y') ".$orderQuery.""; $result = tep_db_query($query); $_SESSION['ses_campaign_report_query'] = $query; while($data = tep_db_fetch_array($result)) { $campaignData[$data['date']] = $data; $clickPayout[$data['date']][$data['affiliateId']] = $data['cpcpayout']; } } function cpcdailyearning($wherequery = '',$ordquery='') { global $totalcpcvalue; $cpc_earningquery = "SELECT sum(clickcount) AS clickCount,FROM_UNIXTIME(clickedDate,'%m-%d-%Y') As date,click.campaignId,sum(click.payout) as cpcpayout,sum(click.revenue) As cpcrevenue,click.subId,sum(uniqueclicks) As uniqueclickcount,round(((sum(click.payout)/count(*))*sum(uniqueclicks)),2)as cpcearning,sum(impressioncount) AS impressioncount,campaign.*,campaign.payout as totalpayout, category.categoryName FROM campaignclickdetailreport AS click RIGHT JOIN ".TABLE_CAMPAIGN." AS campaign ON campaign.campaignId=click.campaignId LEFT JOIN ".TABLE_CATEGORY ." AS category ON category.categoryId=campaign.categoryId WHERE 1 ".$wherequery." and click.affiliateId <> 0 AND campaign.status='Y' AND campaign.offerType='CPC' GROUP BY FROM_UNIXTIME(`clickedDate`, '%m-%d-%Y') ".$orderQuery.""; $result_cpcearning = tep_db_query($cpc_earningquery); unset($totalcpcvalue); while($data_cpc = tep_db_fetch_array($result_cpcearning)) { $totalcpcvalue[$data_cpc['date']] += $data_cpc['cpcearning']; } return $totalcpcvalue; } function getdailyreportleads($wherequery = '',$ordquery='') { global $leadCount; global $leadPayout; global $campaignIdarray; global $campaignData; global $leadRevenue; $leadPayout = null; $orderQuery = $ordquery; $query = "SELECT COUNT(*) AS leadCount, click.campaignId,FROM_UNIXTIME(`leadDate`,'%m-%d-%Y') as date,click.affiliateId,sum(click.revenue) As leadrevenue,sum(click.payout) as payout,campaign.campaignName,campaign.revenue,campaign.payout AS campaignpayout,affiliate.firstname,affiliate.lastname FROM ".TABLE_CAMPAIGN_LEAD_DETAIL." AS click RIGHT JOIN ".TABLE_CAMPAIGN." AS campaign ON campaign.campaignId=click.campaignId LEFT JOIN ".TABLE_PUBLISHERS." AS affiliate ON affiliate.pid=click.affiliateId WHERE 1 ".$wherequery." and click.affiliateId <> 0 AND affiliate.status = 'Y' GROUP BY FROM_UNIXTIME(`leadDate`,'%m-%d-%Y') ".$orderQuery.""; $result = tep_db_query($query); $_SESSION['ses_lead_report_query'] = $query; while($data = tep_db_fetch_array($result)) { $campaignData[$data['date']] = $data; $leadCount[$data['date']] = $data['leadCount']; $leadPayout[$data['date']] = $data['payout']; $leadRevenue[$data['date']] = $data['leadrevenue']; } } //End of functions added for daily reports of the campaigns in the admin section on 18 march 09. //Added for referral payout reports on 23 apr 10. function getnewreferralclicks($wherequery = '',$ordquery='') { global $campaignData; global $distinctCount; global $clickPayout; global $campaignIdarray; global $subidcampaignId; global $distinctCountpub; $orderQuery = $ordquery; /* echo"click query".*/$query = "SELECT sum(clickcount) AS clickCount,click.affiliateId,click.campaignId,sum(click.payout) as cpcpayout,sum(click.revenue) As cpcrevenue,click.subId,sum(uniqueclicks) As uniqueclickcount,sum(impressioncount) AS impressioncount,campaign.*,campaign.payout as totalpayout, affiliate.firstname,affiliate.lastname FROM campaignclickdetailreport AS click RIGHT JOIN ".TABLE_CAMPAIGN." AS campaign ON campaign.campaignId=click.campaignId LEFT JOIN ".TABLE_PUBLISHERS." AS affiliate ON affiliate.pid=click.affiliateId WHERE 1 ".$wherequery." and click.affiliateId <> 0 AND campaign.status='Y' GROUP BY click.campaignId ".$orderQuery.""; $result = tep_db_query($query); $_SESSION['ses_campaign_report_query'] = $query; while($data = tep_db_fetch_array($result)) { $campaignData[$data['campaignId']] = $data; $clickPayout[$data['campaignId']] = $data['cpcpayout']; $campaignIdarray[$data['campaignId']] = $data['campaignId']; } return $campaignData; } function cpcreferralearning($wherequery = '',$ordquery='') { global $totalcpcvalue; global $totalcpcrevenue; global $sumcpcpayout; $cpc_earningquery = "SELECT sum(clickcount) AS clickCount,click.payout as cpcpayout,click.campaignId,sum(click.revenue) As cpcrevenue,sum(uniqueclicks) As uniqueclickcount FROM campaignclickdetailreport AS click RIGHT JOIN ".TABLE_CAMPAIGN." AS campaign ON campaign.campaignId=click.campaignId LEFT JOIN ".TABLE_PUBLISHERS." AS affiliate ON affiliate.pid=click.affiliateId WHERE 1 ".$wherequery." and click.affiliateId <> 0 AND campaign.status='Y' GROUP BY click.affiliateId,click.campaignId,click.clickedDate ".$orderQuery.""; $result_cpcearning = tep_db_query($cpc_earningquery); unset($totalcpcvalue); $calculatedvalue = 0; while($data_cpc = tep_db_fetch_array($result_cpcearning)) { $revenue = $data_cpc['revenue']; $uniqueclicks = $data_cpc['uniqueclickcount']; $cpcpayout_required = $data_cpc['cpcpayout']; $calculatedvalue = ($uniqueclicks*$cpcpayout_required); $calculatedrevenue = ($uniqueclicks*$revenue); $totalcpcrevenue[$data_cpc['campaignId']] += $calculatedrevenue; $sumcpcpayout[$data_cpc['campaignId']] += $cpcpayout_required; $totalcpcvalue[$data_cpc['campaignId']] += $calculatedvalue; } return $totalcpcvalue; } function getnewreferralleads($wherequery = '',$ordquery='') { global $leadCount; global $leadPayout; global $campaignIdarray; global $campaignData; global $leadRevenue; $leadPayout = null; $orderQuery = $ordquery; /* echo"leads query".*/$query = "SELECT COUNT(*) AS leadCount, click.campaignId,click.leadDate,click.affiliateId,sum(click.revenue) As leadrevenue,sum(click.payout) as payout,campaign.campaignName,campaign.revenue,campaign.payout AS campaignpayout,affiliate.firstname,affiliate.lastname FROM ".TABLE_CAMPAIGN_LEAD_DETAIL." AS click RIGHT JOIN ".TABLE_CAMPAIGN." AS campaign ON campaign.campaignId=click.campaignId LEFT JOIN ".TABLE_PUBLISHERS." AS affiliate ON affiliate.pid=click.affiliateId WHERE 1 ".$wherequery." and click.affiliateId <> 0 AND affiliate.status = 'Y' GROUP BY click.campaignId ".$orderQuery.""; $result = tep_db_query($query); $_SESSION['ses_lead_report_query'] = $query; while($data = tep_db_fetch_array($result)) { $campaignData[$data['campaignId']] = $data; $leadCount[$data['campaignId']] = $data['leadCount']; $leadPayout[$data['campaignId']] = $data['payout']; $leadRevenue[$data['campaignId']] = $data['leadrevenue']; $campaignIdarray[$data['campaignId']] = $data['campaignId']; } return $campaignData; } //End of functions added for referral payout reports on 23 apr 10. //Added for getting the referral publisher name on 26 apr10 function getreferralpublisher($id) { $query = "Select firstname,lastname from ".TABLE_PUBLISHERS." where pid=".$id.""; $result = tep_db_query($query); $data = tep_db_fetch_array($result); $pub_name = $data['firstname']." ".$data['lastname']; return $pub_name; } //End of function for getting the referral publisher name on 26 apr10 //Added for stats of disapproved publishers on 11 may 10. function getdisapppubclicks($wherequery = '',$ordquery='') { global $campaignData; global $distinctCount; global $clickPayout; global $campaignIdarray; global $subidcampaignId; global $distinctCountpub; $orderQuery = $ordquery; $query = "SELECT sum(clickcount) AS clickCount,click.affiliateId,click.campaignId,sum(click.payout) as cpcpayout,sum(click.revenue) As cpcrevenue,click.subId,sum(uniqueclicks) As uniqueclickcount,sum(impressioncount) AS impressioncount,campaign.*,campaign.payout as totalpayout,affiliate.status FROM campaignclickdetailreport AS click RIGHT JOIN ".TABLE_CAMPAIGN." AS campaign ON campaign.campaignId=click.campaignId LEFT JOIN ".TABLE_PUBLISHERS." AS affiliate ON affiliate.pid=click.affiliateId WHERE 1 ".$wherequery." and click.affiliateId <> 0 AND affiliate.status = 'N' AND campaign.status='Y' GROUP BY click.campaignId ".$orderQuery.""; $result = tep_db_query($query); $_SESSION['ses_campaign_report_query'] = $query; while($data = tep_db_fetch_array($result)) { $campaignData[$data['campaignId']] = $data; $clickPayout[$data['campaignId']] = $data['cpcpayout']; $campaignIdarray[$data['campaignId']] = $data['campaignId']; } return $campaignData; } function getdisapppubleads($wherequery = '',$ordquery='') { global $leadCount; global $leadPayout; global $campaignIdarray; global $campaignData; global $leadRevenue; $leadPayout = null; $orderQuery = $ordquery; $query = "SELECT COUNT(*) AS leadCount, click.campaignId,click.leadDate,click.affiliateId,sum(click.revenue) As leadrevenue,sum(click.payout) as payout,campaign.campaignName,campaign.revenue,campaign.payout AS campaignpayout,affiliate.firstname,affiliate.lastname FROM ".TABLE_CAMPAIGN_LEAD_DETAIL." AS click RIGHT JOIN ".TABLE_CAMPAIGN." AS campaign ON campaign.campaignId=click.campaignId LEFT JOIN ".TABLE_PUBLISHERS." AS affiliate ON affiliate.pid=click.affiliateId WHERE 1 ".$wherequery." and click.affiliateId <> 0 AND affiliate.status = 'N' GROUP BY click.campaignId ".$orderQuery.""; $result = tep_db_query($query); $_SESSION['ses_lead_report_query'] = $query; while($data = tep_db_fetch_array($result)) { $campaignData[$data['campaignId']] = $data; $leadCount[$data['campaignId']] = $data['leadCount']; $leadPayout[$data['campaignId']] = $data['payout']; $leadRevenue[$data['campaignId']] = $data['leadrevenue']; $campaignIdarray[$data['campaignId']] = $data['campaignId']; } return $campaignData; } //End for stats of disapproved publishers on 11 may 10. /******************************************For disapproved Affiliate Reports in the Admin section on 12 may 10*******************************************/ function getdisappaffiliateclicks($wherequery = '') { global $campaignData; global $affiliateIdArray; global $distinctCountaff; $query = "SELECT sum(clickcount) AS clickCount,click.affiliateId,click.campaignId,sum(click.payout) as cpcpayout,sum(click.revenue) As cpcrevenue,click.subId,sum(uniqueclicks) As uniqueclickcount,sum(impressioncount) AS impressioncount,camp.*,affiliate.* FROM campaignclickdetailreport AS click LEFT JOIN ".TABLE_PUBLISHERS." AS affiliate ON affiliate.pid=click.affiliateId LEFT JOIN ".TABLE_CAMPAIGN." AS camp ON camp.campaignId=click.campaignId WHERE 1 ".$wherequery." and click.affiliateId <> 0 AND affiliate.status = 'N' GROUP BY click.affiliateId"; $result = tep_db_query($query); $_SESSION['ses_campaign_report_query'] = $query; while($data = tep_db_fetch_array($result)) { $campaignData[$data['pid']] = $data; $affiliateIdArray[$data['pid']]= $data['pid']; } $distinctaff_query = "select `affiliateId`,count(*) from (select distinct `campaignId`, `affiliateId`, `userIpAddress`,`sessionId` from ".TABLE_CAMPAIGN_CLICKS_DETAIL." AS click WHERE 1 ".$wherequery." and click.affiliateId <> 0) t group by affiliateId"; $result_distinctaff = tep_db_query($distinctaff_query); while($data_distinctaff = tep_db_fetch_array($result_distinctaff)) { $distinctCountaff[$data_distinctaff['affiliateId']] = $data_distinctaff['count(*)']; } return $campaignData; } function getdisappaffiliateleads($wherequery = '') { global $leadCount; global $leadPayout; global $campaignData; global $leadRevenue; $query = "SELECT COUNT(*) AS leadCount, click.affiliateId as pid,sum(click.payout) as payout,campaign.campaignName,sum(click.revenue) As leadrevenue,campaign.payout AS campaignpayout,affiliate.firstname,affiliate.lastname FROM ".TABLE_CAMPAIGN_LEAD_DETAIL." AS click LEFT JOIN ".TABLE_CAMPAIGN." AS campaign ON campaign.campaignId=click.campaignId LEFT JOIN ".TABLE_PUBLISHERS." AS affiliate ON affiliate.pid=click.affiliateId WHERE 1 ".$wherequery." AND click.campaignId='".$_REQUEST['campaignId']."' and click.affiliateId <> 0 AND affiliate.status = 'N' GROUP BY click.affiliateId"; $result = tep_db_query($query); while($data = tep_db_fetch_array($result)) { $campaignData[$data['pid']] = $data; $leadCount[$data['pid']] = $data['leadCount']; $leadPayout[$data['pid']] = $data['payout']; $leadRevenue[$data['pid']] = $data['leadrevenue']; } return $campaignData; } function getdisappaffiliateimpressions($wherequery = '') { global $impressionCount; global $campaignData; $query = "SELECT COUNT(*) AS impressionCount, affiliateId as pid FROM ".TABLE_CAMPAIGN_IMPRESSION_DETAIL." AS click WHERE 1 ".$wherequery." AND campaignId='".$_REQUEST['campaignId']."' and click.affiliateId <> 0 GROUP BY click.affiliateId"; $result = tep_db_query($query); // $_SESSION['ses_imp_report_query'] = $query; while($data = tep_db_fetch_array($result)) { $campaignData[$data['pid']] = $data; $impressionCount[$data['pid']] = $data['impressionCount']; //$affiliateArr_new[$data['affiliateId']]=$data['affiliateId']; } return $campaignData; } /******************************************End of code for disapproved Affiliate Reports in the Admin section on 12 may 10********************************************/ /******************************************function for sale offer details on 28 june 10********************************************/ function getsaleofferdetails($campaignId) { global $saleofferData; $query = "Select * from campaign_sale_percent where campaignId='".$campaignId."'"; $result = tep_db_query($query); while($data = tep_db_fetch_array($result)) { $saleofferData[$data['id']] = $data; } return $saleofferData; } /******************************************End of sale offer details********************************************/ /********Added for publisher reports for independent login and login through admin on 21 july10*******/ function getnewadminpubclicks($wherequery = '',$ordquery='') { global $campaignData; global $distinctCount; global $clickPayout; global $campaignIdarray; global $subidcampaignId; global $distinctCountpub; $orderQuery = $ordquery; $query = "SELECT SUM(clickcount) AS clickCount,click.subId,sum(click.payout),sum(uniqueclicks) As uniqueclickcount,round(((sum(click.payout)/count(*))*sum(uniqueclicks)),2)as cpcearning,sum(impressioncount) AS impressioncount, campaign.*,click.campaignId,category.categoryName FROM campaignclickdetailreport AS click LEFT JOIN ".TABLE_CAMPAIGN." AS campaign ON campaign.campaignId=click.campaignId LEFT JOIN ".TABLE_CATEGORY ." AS category ON category.categoryId=campaign.categoryId WHERE 1 ".$wherequery." AND campaign.status='Y' AND click.campaignId <>'' GROUP BY click.campaignId ".$orderQuery.""; //$query = "SELECT lead.*, publisher.firstname ,publisher.lastname,publisher.pid,campaign.campaignName FROM (".TABLE_PUBLISHERS." AS publisher INNER JOIN ".TABLE_CAMPAIGN_LEAD_DETAIL." AS lead ON lead.affiliateId=publisher.pid ) INNER JOIN ".TABLE_CAMPAIGN." AS campaign ON lead.campaignId = campaign.campaignId and lead.affiliateId <> 0".$wherequery.$orderQuery; $result = tep_db_query($query); $_SESSION['ses_campaign_report_query'] = $query; while($data = tep_db_fetch_array($result)) { if($data['subId'] == '') $data['subId'] = 'None'; $data['subId'] = trim($data['subId']); $campaignData[$data['campaignId']] = $data; $ClickSubId_array[$data['campaignId']] = $data['subId']; $campaignIdArray[$data['campaignId']]= $data['campaignId']; } $subid_query="SELECT click.campaignId, click.subId FROM campaignclickdetailreport AS click WHERE 1 ".$wherequery." AND click.subId <> '' GROUP BY click.campaignId, click.subId"; $result_subid = tep_db_query($subid_query); while($data_subid = tep_db_fetch_array($result_subid)) { $subidcampaignId[$data_subid['campaignId']] = $data_subid['campaignId']; } return $campaignData; } function getnewadminpubleads($wherequery = '',$ordquery='') { //echo"2"; //$orderQuery = " ORDER BY leadDate"; global $leadCount; global $leadPayout; global $campaignIdarray; global $campaignData; global $leadRevenue; global $saleAmount; $leadPayout = null; $orderQuery = $ordquery; // $orderQuery = $ordquery; $query = "SELECT COUNT(*) AS leadCount, click.campaignId,sum(click.payout) as payout,sum(click.saleamount) as saleamount, click.subId,campaign.campaignName FROM ".TABLE_CAMPAIGN_LEAD_DETAIL." AS click LEFT JOIN ".TABLE_CAMPAIGN." AS campaign ON campaign.campaignId=click.campaignId WHERE 1 ".$wherequery." AND affiliateId='".$_SESSION['infinite_publisherID']."' GROUP BY click.campaignId"; $result = tep_db_query($query); $_SESSION['ses_lead_report_query'] = $query; while($data = tep_db_fetch_array($result)) { if($data['subId'] == '') $data['subId'] = 'None'; $data['subId'] = trim($data['subId']); $campaignData[$data['campaignId']] = $data; $leadCount[$data['campaignId']] = $data['leadCount']; $leadPayout[$data['campaignId']]= $data['payout']; $saleAmount[$data['campaignId']] = $data['saleamount']; $campaignIdarray[$data['campaignId']] = $data['campaignId']; } return $campaignData; } /********End of function for publisher reports for independent login and login through admin on 21 july10 *******/ /*Function for Reports of account section on 4 aug 10*/ function getaccountclicks($wherequery = '',$ordquery='') { global $campaignData; global $distinctCount; global $clickPayout; global $campaignIdarray; global $subidcampaignId; global $distinctCountpub; $orderQuery = $ordquery; $query = "SELECT sum(clickcount) AS clickCount,click.affiliateId,click.campaignId,sum(click.payout) as cpcpayout,sum(click.revenue) As cpcrevenue,click.subId,sum(uniqueclicks) As uniqueclickcount,sum(impressioncount) AS impressioncount,campaign.*,campaign.payout as totalpayout, category.categoryName FROM campaignclickdetailreport AS click RIGHT JOIN ".TABLE_CAMPAIGN." AS campaign ON campaign.campaignId=click.campaignId LEFT JOIN ".TABLE_CATEGORY ." AS category ON category.categoryId=campaign.categoryId WHERE 1 ".$wherequery." and click.affiliateId <> 0 AND campaign.status='Y' GROUP BY click.campaignId ".$orderQuery.""; $result = tep_db_query($query); $_SESSION['ses_campaign_report_query'] = $query; while($data = tep_db_fetch_array($result)) { $campaignData[$data['campaignId']] = $data; $clickPayout[$data['campaignId']] = $data['cpcpayout']; $campaignIdarray[$data['campaignId']] = $data['campaignId']; } return $campaignData; } function getaccountleads($wherequery = '',$ordquery='') { global $leadCount; global $leadPayout; global $campaignIdarray; global $campaignData; global $leadRevenue; global $saleAmount; $leadPayout = null; $orderQuery = $ordquery; $query = "SELECT COUNT(*) AS leadCount, click.campaignId,click.leadDate,sum(click.saleamount) as saleamount,click.affiliateId,sum(click.revenue) As leadrevenue,sum(click.payout) as payout,campaign.campaignName,campaign.revenue,campaign.payout AS campaignpayout,affiliate.firstname,affiliate.lastname FROM ".TABLE_CAMPAIGN_LEAD_DETAIL." AS click RIGHT JOIN ".TABLE_CAMPAIGN." AS campaign ON campaign.campaignId=click.campaignId LEFT JOIN ".TABLE_PUBLISHERS." AS affiliate ON affiliate.pid=click.affiliateId WHERE 1 ".$wherequery." and click.affiliateId <> 0 AND affiliate.status = 'Y' GROUP BY click.campaignId ".$orderQuery.""; $result = tep_db_query($query); $_SESSION['ses_lead_report_query'] = $query; while($data = tep_db_fetch_array($result)) { $campaignData[$data['campaignId']] = $data; $leadCount[$data['campaignId']] = $data['leadCount']; $leadPayout[$data['campaignId']] = $data['payout']; $leadRevenue[$data['campaignId']] = $data['leadrevenue']; $saleAmount[$data['campaignId']] = $data['saleamount']; $campaignIdarray[$data['campaignId']] = $data['campaignId']; } return $campaignData; } /*End of function for Reports of account section on 4 aug 10*/ //Function for cpc payout calculation in the admin reports on 10 aug 10 function getcpcadminclicks($wherequery = '') { global $cpcaffiliatedata; global $affiliateIdArray; //echo $query = "SELECT sum(clickcount) AS clickCount,click.affiliateId,click.campaignId,sum(click.payout) as cpcpayout,sum(click.revenue) As cpcrevenue,click.subId,sum(uniqueclicks) As uniqueclickcount,sum(impressioncount) AS impressioncount,affiliate.*,camp.*,camp.payout as camppayout FROM campaignclickdetailreport AS click LEFT JOIN ".TABLE_PUBLISHERS." AS affiliate ON affiliate.pid=click.affiliateId LEFT JOIN ".TABLE_CAMPAIGN." AS camp ON camp.campaignId=click.campaignId WHERE 1 ".$wherequery." and affiliateId <> 0 AND affiliate.status = 'Y' GROUP BY click.affiliateId"; $query = "SELECT sum(clickcount) AS clickCount,click.affiliateId,click.campaignId,sum(click.payout) as cpcpayout,sum(click.revenue) As cpcrevenue,click.subId,sum(uniqueclicks) As uniqueclickcount,sum(impressioncount) AS impressioncount,campaign.*,campaign.payout as totalpayout, category.categoryName FROM campaignclickdetailreport AS click RIGHT JOIN ".TABLE_CAMPAIGN." AS campaign ON campaign.campaignId=click.campaignId LEFT JOIN ".TABLE_CATEGORY ." AS category ON category.categoryId=campaign.categoryId WHERE 1 ".$wherequery." and click.affiliateId <> 0 AND campaign.status='Y' GROUP BY click.campaignId,click.affiliateId"; $result = tep_db_query($query); $_SESSION['ses_campaign_report_query'] = $query; while($data = tep_db_fetch_array($result)) { $cpcaffiliatedata[$data['campaignId']][$data['affiliateId']] = $data; $affiliateIdArray[$data['affiliateId']]= $data['affiliateId']; } return $cpcaffiliatedata; } //End of Function for cpc payout calculation in the admin reports on 10 aug 10 //Function for getting the custompayout for cpc in admin reports on 10 aug 10 function getcpccustompayout($customsubquery,$value) { global $cpccustompayout; $queryCustom = "SELECT * FROM ".TABLE_CAMPAIGN_CUSTOM_PAYOUT." WHERE 1 ".$customsubquery." and campaignId = '".$value."'"; $resultCustom = tep_db_query($queryCustom); while($dataCustom = tep_db_fetch_array($resultCustom)) { $cpccustompayout[$dataCustom['affiliateId']][$dataCustom['campaignId']] = $dataCustom['payout']; } return $cpccustompayout; } //End of Function for getting the custompayout for cpc in admin reports on 10 aug 10 //For Testing of stats test function created for admin on 27 aug 10 function getstattestclicks($wherequery = '',$ordquery='') { global $campaignData; global $distinctCount; global $clickPayout; global $campaignIdarray; //global $totalcpcvalue; $orderQuery = $ordquery; $query = "SELECT sum(clickcount) AS clickCount,click.affiliateId,click.campaignId,sum(click.payout) as cpcpayout,sum(click.revenue) As cpcrevenue,click.subId,sum(uniqueclicks) As uniqueclickcount,round(((sum(click.payout)/count(*))*sum(uniqueclicks)),2)as cpcearning,sum(impressioncount) AS impressioncount,campaign.*,campaign.payout as totalpayout, category.categoryName FROM campaignclickdetailreport AS click RIGHT JOIN ".TABLE_CAMPAIGN." AS campaign ON campaign.campaignId=click.campaignId LEFT JOIN ".TABLE_CATEGORY ." AS category ON category.categoryId=campaign.categoryId WHERE 1 ".$wherequery." and click.affiliateId <> 0 AND campaign.status='Y' GROUP BY click.campaignId ".$orderQuery.""; $result = tep_db_query($query); $_SESSION['ses_campaign_report_query'] = $query; while($data = tep_db_fetch_array($result)) { $campaignData[$data['campaignId']] = $data; $clickPayout[$data['campaignId']] = $data['cpcpayout']; $campaignIdarray[$data['campaignId']] = $data['campaignId']; } return $campaignData; } function cpcadminearning($wherequery = '',$ordquery='') { global $totalcpcvalue; global $totalcpcrevenue; global $sumcpcpayout; $cpc_earningquery = "SELECT sum(clickcount) AS clickCount,click.payout as cpcpayout,click.campaignId,click.revenue,sum(uniqueclicks) As uniqueclickcount,round(((sum(click.payout)/count(*))*sum(uniqueclicks)),2)as cpcearning,affiliate.firstname FROM campaignclickdetailreport AS click RIGHT JOIN ".TABLE_CAMPAIGN." AS campaign ON campaign.campaignId=click.campaignId LEFT JOIN ".TABLE_PUBLISHERS." AS affiliate ON affiliate.pid=click.affiliateId WHERE 1 ".$wherequery." and click.affiliateId <> 0 AND campaign.status='Y' AND campaign.offerType='CPC' GROUP BY click.affiliateId,click.campaignId,click.clickedDate ".$orderQuery.""; $result_cpcearning = tep_db_query($cpc_earningquery); unset($totalcpcvalue); $calculatedvalue = 0; while($data_cpc = tep_db_fetch_array($result_cpcearning)) { $revenue = $data_cpc['revenue']; $uniqueclicks = $data_cpc['uniqueclickcount']; $cpcpayout_required = $data_cpc['cpcpayout']; $calculatedvalue = ($uniqueclicks*$cpcpayout_required); $calculatedrevenue = ($uniqueclicks*$revenue); $totalcpcrevenue[$data_cpc['campaignId']] += $calculatedrevenue; $sumcpcpayout[$data_cpc['campaignId']] += $cpcpayout_required; $totalcpcvalue[$data_cpc['campaignId']] += $calculatedvalue; } return $totalcpcvalue; } function cpcpublisherearning($wherequery = '') { global $totalcpcvalue; $cpc_earningquery = "SELECT click.payout as cpcpayout,sum(uniqueclicks) As uniqueclickcount,click.campaignId FROM campaignclickdetailreport AS click LEFT JOIN ".TABLE_CAMPAIGN." AS campaign ON campaign.campaignId=click.campaignId LEFT JOIN ".TABLE_CATEGORY ." AS category ON category.categoryId=campaign.categoryId WHERE 1 ".$wherequery." AND campaign.status='Y' AND click.campaignId <>'' AND campaign.offerType='CPC' GROUP BY click.campaignId,click.clickedDate"; $result_cpcearning = tep_db_query($cpc_earningquery); unset($totalcpcvalue); $calculatedvalue = 0; while($data_cpc = tep_db_fetch_array($result_cpcearning)) { $uniqueclicks = $data_cpc['uniqueclickcount']; $cpcpayout_required = $data_cpc['cpcpayout']; $calculatedvalue = ($uniqueclicks*$cpcpayout_required); $totalcpcvalue[$data_cpc['campaignId']] += $calculatedvalue; } return $totalcpcvalue; } //End of test function. //download publisher report for testingg. function getnoclicks_downloadtest($wherequery = '') { $orderQuery = " ORDER BY leadDate"; global $campaignData_download; global $distinctCountpub; $query = "SELECT SUM(clickcount) AS clickCount,click.subId,sum(click.payout),click.clickedDate,sum(uniqueclicks) As uniqueclickcount,round(((sum(click.payout)/count(*))*sum(uniqueclicks)),2)as cpcearning,sum(impressioncount) AS impressioncount, campaign.*,click.campaignId,category.categoryName FROM campaignclickdetailreport AS click LEFT JOIN ".TABLE_CAMPAIGN." AS campaign ON campaign.campaignId=click.campaignId LEFT JOIN ".TABLE_CATEGORY ." AS category ON category.categoryId=campaign.categoryId WHERE 1 ".$wherequery." AND campaign.status='Y' AND click.campaignId <>'' GROUP BY click.campaignId,click.subId"; //$query = "SELECT lead.*, publisher.firstname ,publisher.lastname,publisher.pid,campaign.campaignName FROM (".TABLE_PUBLISHERS." AS publisher INNER JOIN ".TABLE_CAMPAIGN_LEAD_DETAIL." AS lead ON lead.affiliateId=publisher.pid ) INNER JOIN ".TABLE_CAMPAIGN." AS campaign ON lead.campaignId = campaign.campaignId and lead.affiliateId <> 0".$wherequery.$orderQuery; $result = tep_db_query($query); $_SESSION['ses_campaign_report_query'] = $query; while($data = tep_db_fetch_array($result)) { if($data['subId'] == '') $data['subId'] = 'None'; $data['subId'] = trim($data['subId']); $campaignData_download[$data['campaignId'].".".$data['subId']] = $data; $ClickSubId_array[$data['campaignId']][$data['subId']] = $data['subId']; $campaignIdArray[$data['campaignId']]= $data['campaignId']; }; $distinctpub_query = "select `campaignId`,count(*),`subId` from (select distinct `campaignId`,`userIpAddress`,`sessionId`,`subId` from ".TABLE_CAMPAIGN_CLICKS_DETAIL." AS click WHERE 1 ".$wherequery.") t GROUP BY campaignId,subId"; $result_distinctpub = tep_db_query($distinctpub_query); while($data_distinctpub = tep_db_fetch_array($result_distinctpub)) { if($data_distinctpub['subId'] == '') $data_distinctpub['subId'] = 'None'; $data_distinctpub['subId'] = trim($data_distinctpub['subId']); $distinctCountpub[$data_distinctpub['campaignId']][$data_distinctpub['subId']] = $data_distinctpub['count(*)']; } return $campaignData_download; } //For testing of the disapproved affiliates stats in main reports function getdisappclicks($wherequery = '',$ordquery='') { global $campaignData; global $distinctCount; global $clickPayout; global $campaignIdarray; global $subidcampaignId; global $distinctCountpub; $orderQuery = $ordquery; $query = "SELECT sum(clickcount) AS clickCount,click.affiliateId,click.campaignId,sum(click.payout) as cpcpayout,sum(click.revenue) As cpcrevenue,click.subId,sum(uniqueclicks) As uniqueclickcount,sum(impressioncount) AS impressioncount,campaign.*,campaign.payout as totalpayout, category.categoryName FROM campaignclickdetailreport AS click RIGHT JOIN ".TABLE_CAMPAIGN." AS campaign ON campaign.campaignId=click.campaignId LEFT JOIN ".TABLE_CATEGORY ." AS category ON category.categoryId=campaign.categoryId WHERE 1 ".$wherequery." and click.affiliateId <> 0 AND campaign.status='Y' GROUP BY click.campaignId ".$orderQuery.""; $result = tep_db_query($query); $_SESSION['ses_campaign_report_query'] = $query; while($data = tep_db_fetch_array($result)) { $campaignData[$data['campaignId']] = $data; $clickPayout[$data['campaignId']] = $data['cpcpayout']; $campaignIdarray[$data['campaignId']] = $data['campaignId']; } return $campaignData; } //End //For testing of the disapproved affiliates stats in main reports function getdisappleads($wherequery = '',$ordquery='') { //echo"2"; //$orderQuery = " ORDER BY leadDate"; global $leadCount; global $leadPayout; global $campaignIdarray; global $campaignData; global $leadRevenue; global $saleAmount; $leadPayout = null; $orderQuery = $ordquery; // $orderQuery = $ordquery; $query = "SELECT COUNT(*) AS leadCount, click.campaignId,click.leadDate,affiliate.status,sum(click.saleamount) as saleamount,click.affiliateId,sum(click.revenue) As leadrevenue,sum(click.payout) as payout,campaign.campaignName,campaign.revenue,campaign.payout AS campaignpayout,affiliate.firstname,affiliate.lastname FROM ".TABLE_CAMPAIGN_LEAD_DETAIL." AS click RIGHT JOIN ".TABLE_CAMPAIGN." AS campaign ON campaign.campaignId=click.campaignId LEFT JOIN ".TABLE_PUBLISHERS." AS affiliate ON affiliate.pid=click.affiliateId WHERE 1 ".$wherequery." and click.affiliateId <> 0 and affiliate.firstname<>' ' GROUP BY click.campaignId ".$orderQuery.""; $result = tep_db_query($query); $_SESSION['ses_lead_report_query'] = $query; while($data = tep_db_fetch_array($result)) { $campaignData[$data['campaignId']] = $data; $leadCount[$data['campaignId']] = $data['leadCount']; $leadPayout[$data['campaignId']] = $data['payout']; $leadRevenue[$data['campaignId']] = $data['leadrevenue']; $saleAmount[$data['campaignId']] = $data['saleamount']; $campaignIdarray[$data['campaignId']] = $data['campaignId']; } return $campaignData; } //For Affiliate reports includin disapproved affiliate stats function getaffdisapprovedclicks($wherequery = '') { global $campaignData; global $affiliateIdArray; global $distinctCountaff; $query = "SELECT sum(clickcount) AS clickCount,click.affiliateId,click.campaignId,sum(click.payout) as cpcpayout,sum(click.revenue) As cpcrevenue,click.subId,sum(uniqueclicks) As uniqueclickcount,sum(impressioncount) AS impressioncount,affiliate.*,camp.*,camp.payout as camppayout FROM campaignclickdetailreport AS click LEFT JOIN ".TABLE_PUBLISHERS." AS affiliate ON affiliate.pid=click.affiliateId LEFT JOIN ".TABLE_CAMPAIGN." AS camp ON camp.campaignId=click.campaignId WHERE 1 ".$wherequery." and click.affiliateId <> 0 GROUP BY click.affiliateId"; $result = tep_db_query($query); $_SESSION['ses_campaign_report_query'] = $query; while($data = tep_db_fetch_array($result)) { $campaignData[$data['pid']] = $data; $affiliateIdArray[$data['pid']]= $data['pid']; } $distinctaff_query = "select `affiliateId`,count(*) from (select distinct `campaignId`, `affiliateId`, `userIpAddress`,`sessionId` from ".TABLE_CAMPAIGN_CLICKS_DETAIL." AS click WHERE 1 ".$wherequery." and click.affiliateId <> 0) t group by affiliateId"; $result_distinctaff = tep_db_query($distinctaff_query); while($data_distinctaff = tep_db_fetch_array($result_distinctaff)) { $distinctCountaff[$data_distinctaff['affiliateId']] = $data_distinctaff['count(*)']; } } function getaffdisapprovedleads($wherequery = '') { global $leadCount; global $leadPayout; global $campaignData; global $leadRevenue; $query = "SELECT COUNT(*) AS leadCount, click.affiliateId as pid,sum(click.payout) as payout,campaign.campaignName,sum(click.revenue) As leadrevenue,campaign.payout AS campaignpayout,affiliate.firstname,affiliate.lastname FROM ".TABLE_CAMPAIGN_LEAD_DETAIL." AS click LEFT JOIN ".TABLE_CAMPAIGN." AS campaign ON campaign.campaignId=click.campaignId LEFT JOIN ".TABLE_PUBLISHERS." AS affiliate ON affiliate.pid=click.affiliateId WHERE 1 ".$wherequery." AND click.campaignId='".$_REQUEST['campaignId']."' and click.affiliateId <> 0 and affiliate.firstname<>' ' GROUP BY click.affiliateId"; $result = tep_db_query($query); // $_SESSION['ses_lead_report_query'] = $query; while($data = tep_db_fetch_array($result)) { $campaignData[$data['pid']] = $data; $leadCount[$data['pid']] = $data['leadCount']; $leadPayout[$data['pid']] = $data['payout']; $leadRevenue[$data['pid']] = $data['leadrevenue']; } } //Added for the webservice for publisher stats on 28 sept 10 function getWebserviceClicks($wherequery = '',$id) { $orderQuery = " ORDER BY leadDate"; global $campaignData_download; global $distinctCountpub; $query = "SELECT SUM(clickcount) AS clickCount,click.subId,sum(click.payout),click.clickedDate,sum(uniqueclicks) As uniqueclickcount,round(((sum(click.payout)/count(*))*sum(uniqueclicks)),2)as cpcearning,sum(impressioncount) AS impressioncount, campaign.*,click.campaignId,category.categoryName FROM campaignclickdetailreport AS click LEFT JOIN ".TABLE_CAMPAIGN." AS campaign ON campaign.campaignId=click.campaignId LEFT JOIN ".TABLE_CATEGORY ." AS category ON category.categoryId=campaign.categoryId WHERE 1 ".$wherequery." AND campaign.status='Y' AND click.campaignId <>'' GROUP BY click.campaignId,click.subId"; $result = tep_db_query($query); $_SESSION['ses_campaign_report_query'] = $query; while($data = tep_db_fetch_array($result)) { if($data['subId'] == '') $data['subId'] = 'None'; $data['subId'] = trim($data['subId']); $campaignData_download[$data['campaignId'].".".$data['subId']] = $data; $ClickSubId_array[$data['campaignId']][$data['subId']] = $data['subId']; $campaignIdArray[$data['campaignId']]= $data['campaignId']; }; $distinctpub_query = "select `campaignId`,count(*),`subId` from (select distinct `campaignId`,`userIpAddress`,`sessionId`,`subId` from ".TABLE_CAMPAIGN_CLICKS_DETAIL." AS click WHERE 1 ".$wherequery.") t GROUP BY campaignId,subId"; $result_distinctpub = tep_db_query($distinctpub_query); while($data_distinctpub = tep_db_fetch_array($result_distinctpub)) { if($data_distinctpub['subId'] == '') $data_distinctpub['subId'] = 'None'; $data_distinctpub['subId'] = trim($data_distinctpub['subId']); $distinctCountpub[$data_distinctpub['campaignId']][$data_distinctpub['subId']] = $data_distinctpub['count(*)']; } return $campaignData_download; } function getWebserviceLeads($wherequery = '',$id) { $orderQuery = " ORDER BY leadDate"; global $leadCount; global $leadPayout; global $leadDate; global $campaignData_download; $query = "SELECT COUNT(*) AS leadCount, click.campaignId,sum(click.payout) as payout, click.subId,click.leadDate,campaign.campaignName FROM ".TABLE_CAMPAIGN_LEAD_DETAIL." AS click LEFT JOIN ".TABLE_CAMPAIGN." AS campaign ON campaign.campaignId=click.campaignId WHERE 1 ".$wherequery." AND affiliateId='".$id."' GROUP BY click.campaignId,click.subId"; $result = tep_db_query($query); $_SESSION['ses_lead_report_query'] = $query; while($data = tep_db_fetch_array($result)) { if($data['subId'] == '') $data['subId'] = 'None'; $data['subId'] = trim($data['subId']); $campaignData_download[$data['campaignId'].".".$data['subId']] = $data; $leadCount[$data['campaignId']][$data['subId']] = $data['leadCount']; $leadPayout[$data['campaignId']][$data['subId']] = $data['payout']; $leadDate[$data['campaignId']][$data['subId']] = $data['leadDate']; } return $campaignData_download; } function getWebserviceImpressions($wherequery = '',$id) { $orderQuery = " ORDER BY leadDate"; global $impressionCount; global $campaignData_download; $query = "SELECT COUNT(*) AS impressionCount, click.campaignId, click.subId FROM ".TABLE_CAMPAIGN_IMPRESSION_DETAIL." AS click LEFT JOIN ".TABLE_CAMPAIGN." AS campaign ON campaign.campaignId=click.campaignId WHERE 1 ".$wherequery." AND affiliateId='".$id."' GROUP BY click.campaignId,click.subId"; $result = tep_db_query($query); $_SESSION['ses_imp_report_query'] = $query; while($data = tep_db_fetch_array($result)) { if($data['subId'] == '') $data['subId'] = 'None'; $data['subId'] = trim($data['subId']); $campaignData_download[$data['campaignId'].".".$data['subId']] = $data; $impressionCount[$data['campaignId']][$data['subId']] = $data['impressionCount']; } return $campaignData_download; } /********************** End of Addition for the webservice for publisher stats on 28 sept 10*****************************/ //Code added for Advertiser earnings report By Tanvi on 26 oct 2010 function getadvertiserleads($wherequery = '') { global $leadCount; global $leadPayout; global $cpcuniqueclicks; global $cAffId; global $campId; global $cpcaffiliateId; global $clickPayout; global $clickCpcPayout; global $campaignData; global $cpccampaignIdarray; global $leadaffiliateId; $leadPayout = null; $clickdataquery = str_replace("leadDate","clickedDate",$wherequery); $query = "SELECT COUNT(*) AS leadCount,click.campaignId,click.affiliateId,advertiser.firstname,advertiser.lastname,campaign.advertiserId,sum(click.payout) as payout,campaign.campaignName,campaign.revenue,campaign.payout AS campaignpayout FROM ".TABLE_CAMPAIGN_LEAD_DETAIL." AS click RIGHT JOIN ".TABLE_CAMPAIGN." AS campaign ON campaign.campaignId=click.campaignId LEFT JOIN ".TABLE_ADVERTISERS." AS advertiser ON advertiser.aid=campaign.advertiserId WHERE 1 ".$wherequery." AND campaign.offerType<>'cpc' and click.affiliateId <> 0 GROUP BY campaign.advertiserId ".$orderQuery.""; $result = tep_db_query($query); $_SESSION['ses_lead_report_query'] = $query; while($data = tep_db_fetch_array($result)) { $campaignData[$data['advertiserId']] = $data; $leadaffiliateId[$data['advertiserId']] = $data['affiliateId']; $leadCount[$data['advertiserId']] = $data['leadCount']; $leadPayout[$data['advertiserId']] = $data['payout']; } $cpcquery = "SELECT sum(clickcount) AS clickCount,click.affiliateId,advertiser.firstname,advertiser.lastname,click.campaignId,campaign.advertiserId,click.payout as cpcpayout,click.subId,sum(uniqueclicks) As uniqueclickcount,sum(impressioncount) AS impressioncount,campaign.payout as totalpayout FROM campaignclickdetailreport AS click RIGHT JOIN ".TABLE_CAMPAIGN." AS campaign ON campaign.campaignId=click.campaignId LEFT JOIN ".TABLE_ADVERTISERS." AS advertiser ON advertiser.aid=campaign.advertiserId WHERE 1 ".$clickdataquery." AND campaign.status='Y' AND campaign.offerType='CPC' GROUP BY campaign.advertiserId,click.clickedDate ".$orderQuery.""; $cpcresult = tep_db_query($cpcquery); $_SESSION['ses_campaign_report_query'] = $cpcquery; while($cpcdata = tep_db_fetch_array($cpcresult)) { $cAffId[$cpcdata['advertiserId']] = $cpcdata['advertiserId']; $campId[$cpcdata['campaignId']] = $cpcdata['campaignId']; $cpckey = $cpcdata['advertiserId'].".".$cpcdata['campaignId']; $cpcaffiliateId[$cpckey] = $cpcdata['advertiserId'].".".$cpcdata['campaignId']; $payout[$cpckey] = $cpcdata['cpcpayout']; $clickPayout[$cpckey] = $cpcdata['totalpayout']; $cpcuniqueclicks[$cpckey] = $cpcdata['uniqueclickcount']; $clickCpcPayout[$cpckey] += (($cpcuniqueclicks[$cpckey])*($payout[$cpckey])); if(count($leadaffiliateId) != '') { if(!in_array($cpcdata['advertiserId'],$leadaffiliateId)) { $campaignData[$cpcdata['advertiserId']] = $cpcdata; } } } return $campaignData; } //End of Code added for Advertiser earnings report By Tanvi on 26 oct 2010 //Code added for Advertiser earnings report advertiserRep section By Tanvi on 17 feb 2011 function getadvertiserRepleads($wherequery = '') { global $leadCount; global $leadPayout; global $cpcuniqueclicks; global $cAffId; global $campId; global $cpcaffiliateId; global $clickPayout; global $clickCpcPayout; global $campaignData; global $cpccampaignIdarray; global $leadaffiliateId; $leadPayout = null; $clickdataquery = str_replace("leadDate","clickedDate",$wherequery); $query = "SELECT COUNT(*) AS leadCount,click.campaignId,click.affiliateId,advertiser.firstname,advertiser.lastname,campaign.advertiserId,sum(click.payout) as payout,campaign.campaignName,campaign.revenue,campaign.payout AS campaignpayout FROM ".TABLE_CAMPAIGN_LEAD_DETAIL." AS click RIGHT JOIN ".TABLE_CAMPAIGN." AS campaign ON campaign.campaignId=click.campaignId LEFT JOIN ".TABLE_ADVERTISERS." AS advertiser ON advertiser.aid=campaign.advertiserId WHERE 1 ".$wherequery." AND campaign.offerType<>'cpc' GROUP BY campaign.advertiserId ".$orderQuery.""; $result = tep_db_query($query); $_SESSION['ses_lead_report_query'] = $query; while($data = tep_db_fetch_array($result)) { $campaignData[$data['advertiserId']] = $data; $leadaffiliateId[$data['advertiserId']] = $data['affiliateId']; $leadCount[$data['advertiserId']] = $data['leadCount']; $leadPayout[$data['advertiserId']] = $data['payout']; } $cpcquery = "SELECT sum(clickcount) AS clickCount,click.affiliateId,advertiser.firstname,advertiser.lastname,click.campaignId,campaign.advertiserId,click.payout as cpcpayout,click.subId,sum(uniqueclicks) As uniqueclickcount,sum(impressioncount) AS impressioncount,campaign.payout as totalpayout FROM campaignclickdetailreport AS click RIGHT JOIN ".TABLE_CAMPAIGN." AS campaign ON campaign.campaignId=click.campaignId LEFT JOIN ".TABLE_ADVERTISERS." AS advertiser ON advertiser.aid=campaign.advertiserId WHERE 1 ".$clickdataquery." AND campaign.status='Y' AND campaign.offerType='CPC' GROUP BY campaign.advertiserId,click.clickedDate ".$orderQuery.""; $cpcresult = tep_db_query($cpcquery); $_SESSION['ses_campaign_report_query'] = $cpcquery; while($cpcdata = tep_db_fetch_array($cpcresult)) { $cAffId[$cpcdata['advertiserId']] = $cpcdata['advertiserId']; $campId[$cpcdata['campaignId']] = $cpcdata['campaignId']; $cpckey = $cpcdata['advertiserId'].".".$cpcdata['campaignId']; $cpcaffiliateId[$cpckey] = $cpcdata['advertiserId'].".".$cpcdata['campaignId']; $payout[$cpckey] = $cpcdata['cpcpayout']; $clickPayout[$cpckey] = $cpcdata['totalpayout']; $cpcuniqueclicks[$cpckey] = $cpcdata['uniqueclickcount']; $clickCpcPayout[$cpckey] += (($cpcuniqueclicks[$cpckey])*($payout[$cpckey])); if(count($leadaffiliateId) != '') { if(!in_array($cpcdata['advertiserId'],$leadaffiliateId)) { $campaignData[$cpcdata['advertiserId']] = $cpcdata; } } } return $campaignData; } //End of Code added for Advertiser earnings report of advertiserRep section By Tanvi on 17 feb 2011 //Added for the advertiser list in the advertiserRep section By Tanvi on 18 feb 2011 function getadvmanageradvertisers($wherequery = '') { global $campaignData; $query = "SELECT * FROM ".TABLE_ADVERTISERS." WHERE 1".$wherequery." ORDER BY registeredDate"; $result = tep_db_query($query); while($data = tep_db_fetch_array($result)) { $campaignData[$data['aid']] = $data; } return $campaignData; } //End of function //For download Csv report in the admin section where the timestamp value for the clicks is required added on 18 nov 10. function getcsvdownloadclicks($wherequery = '',$ordquery='') { global $campaignData; global $distinctCount; global $clickPayout; global $campaignIdarray; global $subidcampaignId; global $distinctCountpub; $orderQuery = $ordquery; /*echo"the click query is".*/$query = "SELECT sum(clickcount) AS clickCount,click.affiliateId,click.clickedDate,click.campaignId,sum(click.payout) as cpcpayout,sum(click.revenue) As cpcrevenue,click.subId,sum(uniqueclicks) As uniqueclickcount,sum(impressioncount) AS impressioncount,campaign.*,campaign.payout as totalpayout, category.categoryName FROM campaignclickdetailreport AS click RIGHT JOIN ".TABLE_CAMPAIGN." AS campaign ON campaign.campaignId=click.campaignId LEFT JOIN ".TABLE_CATEGORY ." AS category ON category.categoryId=campaign.categoryId WHERE 1 ".$wherequery." and click.affiliateId <> 0 AND campaign.status='Y' GROUP BY click.campaignId,click.clickedDate ".$orderQuery.""; $result = tep_db_query($query); $_SESSION['ses_campaign_report_query'] = $query; while($data = tep_db_fetch_array($result)) { $campaignData[$data['campaignId'].".".$data['clickedDate']] = $data; $clickPayout[$data['campaignId']][$data['clickedDate']] = $data['cpcpayout']; $campaignIdarray[$data['campaignId']] = $data['campaignId']; } return $campaignData; } function getcsvdownloadleads($wherequery = '',$ordquery='') { global $leadCount; global $leadPayout; global $campaignIdarray; global $campaignData; global $leadRevenue; global $leadDate; global $saleAmount; $leadPayout = null; $orderQuery = $ordquery; echo"the lead query is".$query = "SELECT COUNT(*) AS leadCount, click.campaignId,FROM_UNIXTIME(`leadDate`, '%m-%d-%Y') as leadDate,sum(click.saleamount) as saleamount,click.affiliateId,sum(click.revenue) As leadrevenue,sum(click.payout) as payout,campaign.campaignName,campaign.revenue,campaign.payout AS campaignpayout,affiliate.firstname,affiliate.lastname FROM ".TABLE_CAMPAIGN_LEAD_DETAIL." AS click RIGHT JOIN ".TABLE_CAMPAIGN." AS campaign ON campaign.campaignId=click.campaignId LEFT JOIN ".TABLE_PUBLISHERS." AS affiliate ON affiliate.pid=click.affiliateId WHERE 1 ".$wherequery." and click.affiliateId <> 0 AND affiliate.status = 'Y' GROUP BY click.campaignId,FROM_UNIXTIME(`leadDate`, '%m-%d-%Y') ".$orderQuery.""; $result = tep_db_query($query); $_SESSION['ses_lead_report_query'] = $query; while($data = tep_db_fetch_array($result)) { $campaignData[$data['campaignId'].".".$data['leadDate']] = $data; $leadCount[$data['campaignId']] = $data['leadCount']; $leadPayout[$data['campaignId']] = $data['payout']; $leadRevenue[$data['campaignId']] = $data['leadrevenue']; $leadDate[$data['campaignId']] = $data['leadDate']; $saleAmount[$data['campaignId']] = $data['saleamount']; $campaignIdarray[$data['campaignId']] = $data['campaignId']; } return $campaignData; } //End of adddition of the function. //For Cpc calculations for the download CSV reports of admin section in the time stamp on 23 nov 10 function cpccsvdownloadearning($wherequery = '',$ordquery='') { global $totalcpcvalue; global $totalcpcrevenue; global $sumcpcpayout; $cpc_earningquery = "SELECT sum(clickcount) AS clickCount,click.payout as cpcpayout,click.clickedDate,click.campaignId,click.revenue,sum(uniqueclicks) As uniqueclickcount,round(((sum(click.payout)/count(*))*sum(uniqueclicks)),2)as cpcearning FROM campaignclickdetailreport AS click RIGHT JOIN ".TABLE_CAMPAIGN." AS campaign ON campaign.campaignId=click.campaignId WHERE 1 ".$wherequery." and click.affiliateId <> 0 AND campaign.status='Y' AND campaign.offerType='CPC' GROUP BY click.affiliateId,click.campaignId,click.clickedDate ".$orderQuery.""; $result_cpcearning = tep_db_query($cpc_earningquery); unset($totalcpcvalue); $calculatedvalue = 0; while($data_cpc = tep_db_fetch_array($result_cpcearning)) { $revenue = $data_cpc['revenue']; $uniqueclicks = $data_cpc['uniqueclickcount']; $cpcpayout_required = $data_cpc['cpcpayout']; $calculatedvalue = ($uniqueclicks*$cpcpayout_required); $calculatedrevenue = ($uniqueclicks*$revenue); $totalcpcrevenue[$data_cpc['campaignId']][$data_cpc['clickedDate']] += $calculatedrevenue; $sumcpcpayout[$data_cpc['campaignId']][$data_cpc['clickedDate']] += $cpcpayout_required; $totalcpcvalue[$data_cpc['campaignId']][$data_cpc['clickedDate']] += $calculatedvalue; } return $totalcpcvalue; } //End of the function. //Added for daily reports listing affiliates on 7 mar function getaffiliatedailyclicks($wherequery = '') { global $affiliateIdArray; global $distinctCountaff; $query = "SELECT affiliate.pid,affiliate.firstname,affiliate.lastname FROM campaignclickdetailreport AS click LEFT JOIN ".TABLE_PUBLISHERS." AS affiliate ON affiliate.pid=click.affiliateId LEFT JOIN ".TABLE_CAMPAIGN." AS camp ON camp.campaignId=click.campaignId WHERE 1 ".$wherequery." and click.affiliateId <> 0 AND affiliate.status = 'Y' GROUP BY click.affiliateId"; $result = tep_db_query($query); $_SESSION['ses_campaign_report_query'] = $query; while($data = tep_db_fetch_array($result)) { //$campaignData[$data['pid']] = $data; $affiliateIdArray[$data['pid']]= $data['firstname']."-".$data['pid']; } return $affiliateIdArray; } //Added by Tanvi on 25 Nov for Advertiser Rep section Affiliate Reports //End of addition //Function added for affiliate subid reports on 5 apr 11 function getaffsubidclicks($wherequery = '',$ordquery='') { global $campaignData; global $distinctCount; global $clickPayout; global $campaignIdarray; global $ClickSubId_array; global $affiliateIdArray; $orderQuery = $ordquery; $query = "SELECT sum(clickcount) AS clickCount,click.affiliateId,click.clickedDate,click.campaignId,sum(click.payout) as cpcpayout,sum(click.revenue) As cpcrevenue,click.subId,sum(uniqueclicks) As uniqueclickcount,sum(impressioncount) AS impressioncount,camp.*,camp.payout as totalpayout,affiliate.* FROM campaignclickdetailreport AS click LEFT JOIN ".TABLE_PUBLISHERS." AS affiliate ON affiliate.pid=click.affiliateId LEFT JOIN ".TABLE_CAMPAIGN." AS camp ON camp.campaignId=click.campaignId WHERE 1 ".$wherequery." and click.affiliateId <> 0 GROUP BY click.affiliateId,click.subId"; $result = tep_db_query($query); $_SESSION['ses_campaign_report_query'] = $query; while($data = tep_db_fetch_array($result)) { if($data['subId'] == '') $data['subId'] = 'None'; $data['subId'] = trim($data['subId']); $campaignData[$data['pid'].".".$data['subId']] = $data; $ClickSubId_array[$data['pid']][$data['subId']] = $data['subId']; $affiliateIdArray[$data['pid']]= $data['pid']; } return $campaignData; } function getaffsubidleads($wherequery = '',$affiliateIdArray,$ClickSubId_array) { global $leadCount; global $leadPayout; global $campaignData; $orderQuery = $ordquery; $query = "SELECT COUNT(*) AS leadCount, click.affiliateId,sum(click.payout) as payout, click.subId FROM ".TABLE_CAMPAIGN_LEAD_DETAIL." AS click WHERE 1 ".$wherequery." AND affiliateId IN('".implode("','",$affiliateIdArray)."') GROUP BY click.affiliateId,click.subId"; $result = tep_db_query($query); $_SESSION['ses_lead_report_query'] = $query; while($data = tep_db_fetch_array($result)) { if($data['subId'] == '') $data['subId'] = 'None'; $data['subId'] = trim($data['subId']); $campaignData[$data['affiliateId'].".".$data['subId']] = $data; //$leadCount[$data['affiliateId']][$data['subId']] = $data['leadCount']; //$leadPayout[$data['affiliateId']][$data['subId']] = $data['payout']; if(@!in_array($data['subId'],$ClickSubId_array[$data['affiliateId']])) { $leadCount[$data['affiliateId']]['None'] += $data['leadCount']; $leadPayout[$data['affiliateId']]['None'] += $data['payout']; } else { $leadCount[$data['affiliateId']][$data['subId']] = $data['leadCount']; $leadPayout[$data['affiliateId']][$data['subId']] = $data['payout']; } } return $campaignData; } //End of Addition //Function added for advertiser Reports on 11 apr 2011 function getadvertiserreportclicks($wherequery = '',$ordquery='') { global $campaignData; global $distinctCount; global $clickPayout; global $campaignIdarray; global $subidcampaignId; global $distinctCountpub; $orderQuery = $ordquery; $query = "SELECT sum(clickcount) AS clickCount,click.affiliateId,click.clickedDate,click.campaignId,sum(click.payout) as cpcpayout,sum(click.revenue) As cpcrevenue,click.subId,sum(uniqueclicks) As uniqueclickcount,sum(impressioncount) AS impressioncount,campaign.*,campaign.payout as totalpayout,advertiser.firstname,advertiser.lastname FROM campaignclickdetailreport AS click RIGHT JOIN ".TABLE_CAMPAIGN." AS campaign ON campaign.campaignId=click.campaignId LEFT JOIN ".TABLE_ADVERTISERS." AS advertiser ON advertiser.aid=campaign.advertiserId LEFT JOIN category AS category ON category.categoryId=campaign.categoryId WHERE 1 ".$wherequery." and click.affiliateId <> 0 AND campaign.status='Y' GROUP BY campaign.advertiserId ".$orderQuery.""; $result = tep_db_query($query); $_SESSION['ses_campaign_report_query'] = $query; while($data = tep_db_fetch_array($result)) { $campaignData[$data['advertiserId']] = $data; $clickPayout[$data['advertiserId']] = $data['cpcpayout']; $campaignIdarray[$data['campaignId']] = $data['campaignId']; } return $campaignData; } function getadvertiserreportleads($wherequery = '',$ordquery='') { //echo"2"; //$orderQuery = " ORDER BY leadDate"; global $leadCount; global $leadPayout; global $campaignIdarray; global $campaignData; global $leadRevenue; global $leadDate; global $saleAmount; $leadPayout = null; $orderQuery = $ordquery; // $orderQuery = $ordquery; $query = "SELECT COUNT(*) AS leadCount, click.campaignId,click.leadDate,sum(click.saleamount) as saleamount,click.affiliateId,sum(click.revenue) As leadrevenue,sum(click.payout) as payout,campaign.campaignName,campaign.revenue,campaign.payout AS campaignpayout,advertiser.firstname,advertiser.lastname,campaign.advertiserId FROM ".TABLE_CAMPAIGN_LEAD_DETAIL." AS click RIGHT JOIN ".TABLE_CAMPAIGN." AS campaign ON campaign.campaignId=click.campaignId LEFT JOIN publishers AS affiliate ON affiliate.pid=click.affiliateId LEFT JOIN ".TABLE_ADVERTISERS." AS advertiser ON advertiser.aid=campaign.advertiserId WHERE 1 ".$wherequery." and click.affiliateId <> 0 AND affiliate.status = 'Y' GROUP BY campaign.advertiserId ".$orderQuery.""; $result = tep_db_query($query); $_SESSION['ses_lead_report_query'] = $query; while($data = tep_db_fetch_array($result)) { $campaignData[$data['advertiserId']] = $data; $leadCount[$data['advertiserId']] = $data['leadCount']; $leadPayout[$data['advertiserId']] = $data['payout']; $leadRevenue[$data['advertiserId']] = $data['leadrevenue']; $leadDate[$data['advertiserId']] = $data['leadDate']; $saleAmount[$data['advertiserId']] = $data['saleamount']; $campaignIdarray[$data['campaignId']] = $data['campaignId']; } return $campaignData; } function cpcadvertiserreportearning($wherequery = '',$ordquery='') { global $totalcpcvalue; global $totalcpcrevenue; global $sumcpcpayout; $cpc_earningquery = "SELECT sum(clickcount) AS clickCount,click.payout as cpcpayout,click.campaignId,click.revenue,sum(uniqueclicks) As uniqueclickcount,campaign.advertiserId,round(((sum(click.payout)/count(*))*sum(uniqueclicks)),2)as cpcearning FROM campaignclickdetailreport AS click RIGHT JOIN ".TABLE_CAMPAIGN." AS campaign ON campaign.campaignId=click.campaignId WHERE 1 ".$wherequery." and click.affiliateId <> 0 AND campaign.status='Y' AND campaign.offerType='CPC' GROUP BY click.affiliateId,campaign.advertiserId,click.campaignId,click.clickedDate ".$orderQuery.""; $result_cpcearning = tep_db_query($cpc_earningquery); unset($totalcpcvalue); $calculatedvalue = 0; while($data_cpc = tep_db_fetch_array($result_cpcearning)) { $revenue = $data_cpc['revenue']; $uniqueclicks = $data_cpc['uniqueclickcount']; $cpcpayout_required = $data_cpc['cpcpayout']; $calculatedvalue = ($uniqueclicks*$cpcpayout_required); $calculatedrevenue = ($uniqueclicks*$revenue); $totalcpcrevenue[$data_cpc['advertiserId']] += $calculatedrevenue; $sumcpcpayout[$data_cpc['advertiserId']] += $cpcpayout_required; $totalcpcvalue[$data_cpc['advertiserId']] += $calculatedvalue; } return $totalcpcvalue; } //End of function //Code Added for publisher login history data on 13 may 2011. function getpublisherloginhistory($wherequery = '',$ordquery='') { global $campaignData; global $affiliateIdArray; global $distinctCountaff; $query = "SELECT pubhistory.*,affiliate.firstname,affiliate.lastname FROM ".TABLE_PUBLISHERLOGIN_HISTORY." AS pubhistory LEFT JOIN ".TABLE_PUBLISHERS." AS affiliate ON pubhistory.pid=affiliate.pid WHERE 1 ".$wherequery.""; $result = tep_db_query($query); $_SESSION['ses_campaign_report_query'] = $query; while($data = tep_db_fetch_array($result)) { $campaignData[$data['id']] = $data; } return $campaignData; } //End of Code. //Function added for Publisher list Reports on 17 may 2011 function getpublisherreportclicks($wherequery = '',$ordquery='') { global $campaignData; global $distinctCount; global $clickPayout; global $campaignIdarray; global $subidcampaignId; global $cpcdata; global $distinctCountpub; $orderQuery = $ordquery; $query = "SELECT sum(clickcount) AS clickCount,click.affiliateId,click.clickedDate,click.campaignId,sum(click.payout) as cpcpayout,sum(click.revenue) As cpcrevenue,click.subId,sum(uniqueclicks) As uniqueclickcount,sum(impressioncount) AS impressioncount,campaign.*,campaign.payout as totalpayout,affiliate.firstname,affiliate.lastname FROM campaignclickdetailreport AS click RIGHT JOIN ".TABLE_CAMPAIGN." AS campaign ON campaign.campaignId=click.campaignId LEFT JOIN ".TABLE_PUBLISHERS." AS affiliate ON affiliate.pid=click.affiliateId LEFT JOIN category AS category ON category.categoryId=campaign.categoryId WHERE 1 ".$wherequery." and click.affiliateId <> 0 AND campaign.status='Y' GROUP BY click.affiliateId ".$orderQuery.""; $result = tep_db_query($query); $_SESSION['ses_campaign_report_query'] = $query; while($data = tep_db_fetch_array($result)) { $campaignData[$data['affiliateId']] = $data; $clickaffiliateId[$data['affiliateId']] = $data['affiliateId']; $clickPayout[$data['affiliateId']] = $data['cpcpayout']; $campaignIdarray[$data['campaignId']] = $data['campaignId']; } /*$allcamp_query = "SELECT campaign.*,click.affiliateId FROM campaignclickdetailreport AS click RIGHT JOIN ".TABLE_CAMPAIGN." AS campaign ON campaign.campaignId=click.campaignId LEFT JOIN ".TABLE_PUBLISHERS." AS affiliate ON affiliate.pid=click.affiliateId WHERE 1 ".$wherequery." and click.affiliateId <> 0 AND campaign.status='Y' GROUP BY click.campaignId,click.affiliateId ".$orderQuery.""; $result_allcamp_query = tep_db_query($allcamp_query); while($data_allcamp = tep_db_fetch_array($result_allcamp_query)) { $cpccampaignid[$data_allcamp['campaignId']] = $data_allcamp['campaignId']; $cpcaffiliateid[$data_allcamp['affiliateId']] = $data_allcamp['affiliateId']; $cpckey = $data_allcamp['affiliateId'].".".$data_allcamp['campaignId']; $cpcdata[$cpckey] = $data_allcamp['affiliateId'].".".$data_allcamp['campaignId']; }*/ return $campaignData; } function getpublisherreportleads($wherequery = '',$ordquery='') { //echo"2"; //$orderQuery = " ORDER BY leadDate"; global $leadCount; global $leadPayout; global $campaignIdarray; global $campaignData; global $leadRevenue; global $leadDate; global $saleAmount; $leadPayout = null; $orderQuery = $ordquery; // $orderQuery = $ordquery; $query = "SELECT COUNT(*) AS leadCount, click.campaignId,click.leadDate,sum(click.saleamount) as saleamount,click.affiliateId,sum(click.revenue) As leadrevenue,sum(click.payout) as payout,campaign.campaignName,campaign.revenue,campaign.payout AS campaignpayout,affiliate.firstname,affiliate.lastname,campaign.advertiserId FROM ".TABLE_CAMPAIGN_LEAD_DETAIL." AS click RIGHT JOIN ".TABLE_CAMPAIGN." AS campaign ON campaign.campaignId=click.campaignId LEFT JOIN publishers AS affiliate ON affiliate.pid=click.affiliateId WHERE 1 ".$wherequery." and click.affiliateId <> 0 AND affiliate.status = 'Y' GROUP BY click.affiliateId ".$orderQuery.""; $result = tep_db_query($query); $_SESSION['ses_lead_report_query'] = $query; while($data = tep_db_fetch_array($result)) { $campaignData[$data['affiliateId']] = $data; $leadCount[$data['affiliateId']] = $data['leadCount']; $leadPayout[$data['affiliateId']] = $data['payout']; $leadRevenue[$data['affiliateId']] = $data['leadrevenue']; $leadDate[$data['affiliateId']] = $data['leadDate']; $saleAmount[$data['affiliateId']] = $data['saleamount']; $campaignIdarray[$data['campaignId']] = $data['campaignId']; } return $campaignData; } function cpcpublisherreportearning($wherequery = '',$ordquery='') { global $totalcpcvalue; global $totalcpcrevenue; global $sumcpcpayout; global $cpcaffiliateid; $cpc_earningquery = "SELECT sum(clickcount) AS clickCount,click.affiliateId,click.payout as cpcpayout,click.campaignId,click.revenue,sum(uniqueclicks) As uniqueclickcount,round(((sum(click.payout)/count(*))*sum(uniqueclicks)),2)as cpcearning FROM campaignclickdetailreport AS click RIGHT JOIN ".TABLE_CAMPAIGN." AS campaign ON campaign.campaignId=click.campaignId LEFT JOIN publishers AS affiliate ON affiliate.pid=click.affiliateId WHERE 1 ".$wherequery." and click.affiliateId <> 0 AND campaign.status='Y' AND campaign.offerType='CPC' GROUP BY click.affiliateId,click.campaignId,click.clickedDate ".$orderQuery.""; $result_cpcearning = tep_db_query($cpc_earningquery); unset($totalcpcvalue); $calculatedvalue = 0; while($data_cpc = tep_db_fetch_array($result_cpcearning)) { $revenue = $data_cpc['revenue']; $uniqueclicks = $data_cpc['uniqueclickcount']; $cpcaffiliateid[$data_cpc['affiliateId']] = $data_cpc['affiliateId']; $cpcpayout_required = $data_cpc['cpcpayout']; $calculatedvalue = ($uniqueclicks*$cpcpayout_required); $calculatedrevenue = ($uniqueclicks*$revenue); $totalcpcrevenue[$data_cpc['affiliateId']] += $calculatedrevenue; $sumcpcpayout[$data_cpc['affiliateId']] += $cpcpayout_required; $totalcpcvalue[$data_cpc['affiliateId']] += $calculatedvalue; } return $totalcpcvalue; } //End of function //Function added for the campaigns page last day search criteria on 23 may 11 function getAllCampaignslastsearch($wherequery = '',$advertiserquery='',$lastsearchquery='') { global $campaignData; global $uniqueclicks; global $campaignIdArray; global $leads; global $campaignpayout; $orderQuery = " ORDER BY addedDate"; $query = "SELECT cat.*, campaign.*,advertiser.firstname,advertiser.lastname,campaign.status AS status FROM ".TABLE_CAMPAIGN." AS campaign INNER JOIN ".TABLE_CATEGORY." AS cat ON cat.categoryId=campaign.categoryId left join ".TABLE_ADVERTISERS." As advertiser ON advertiser.aid = campaign.advertiserId where 1 ".$wherequery. $advertiserquery.$lastsearchquery.$orderQuery; $result = tep_db_query($query); $_SESSION['ses_campaign_report_query'] = $query; while($data = tep_db_fetch_array($result)) { $campaignData[$data['campaignId']] = $data; $campaignIdArray[$data['campaignId']]= $data['campaignId']; } $unique_clicksquery = "SELECT sum(uniqueclicks) As uniqueclickcount,campaign.campaignId,campaign.payout as campaignpayout FROM campaignclickdetailreport AS click RIGHT JOIN ".TABLE_CAMPAIGN." AS campaign ON campaign.campaignId=click.campaignId left JOIN ".TABLE_CATEGORY." AS cat ON cat.categoryId=campaign.categoryId WHERE 1 ".$wherequery." ".$lastsearchquery." and click.affiliateId <> 0 AND campaign.status='Y' GROUP BY click.campaignId ".$orderQuery.""; $result_unique_clicksquery = tep_db_query($unique_clicksquery); while($data_uniqueclicks = tep_db_fetch_array($result_unique_clicksquery)) { $uniqueclicks[$data_uniqueclicks['campaignId']] = $data_uniqueclicks['uniqueclickcount']; $campaignpayout[$data_uniqueclicks['campaignId']] = $data_uniqueclicks['campaignpayout']; } $lead_query = "SELECT COUNT(*) AS leadCount,click.campaignId FROM ".TABLE_CAMPAIGN_LEAD_DETAIL." AS click RIGHT JOIN ".TABLE_CAMPAIGN." AS campaign ON campaign.campaignId=click.campaignId LEFT JOIN publishers AS affiliate ON affiliate.pid=click.affiliateId left JOIN ".TABLE_CATEGORY." AS cat ON cat.categoryId=campaign.categoryId WHERE 1 ".$wherequery." ".$lastsearchquery." and click.affiliateId <> 0 AND affiliate.status = 'Y' GROUP BY click.campaignId ".$orderQuery.""; $result_lead_query = tep_db_query($lead_query); while($data_leads = tep_db_fetch_array($result_lead_query)) { $leads[$data_leads['campaignId']] = $data_leads['leadCount']; } return $campaignData; } //End of function //Test subid reports in pub section on 9 june 2011 function getajaxtestclicks($wherequery = '',$ordquery='') { global $campaignData; global $distinctCount; global $clickPayout; global $distinctCountpub; global $pub_subid; $orderQuery = $ordquery; echo $query = "SELECT SUM(clickcount) AS clickCount,click.subId,sum(uniqueclicks) As uniqueclickcount,sum(impressioncount) AS impressioncount, campaign.*,click.campaignId,category.categoryName FROM campaignclickdetailreport AS click LEFT JOIN ".TABLE_CAMPAIGN." AS campaign ON campaign.campaignId=click.campaignId LEFT JOIN ".TABLE_CATEGORY ." AS category ON category.categoryId=campaign.categoryId WHERE 1 ".$wherequery." AND campaign.status='Y' AND click.campaignId <>'' GROUP BY click.campaignId,click.subId"; //$query = "SELECT lead.*, publisher.firstname ,publisher.lastname,publisher.pid,campaign.campaignName FROM (".TABLE_PUBLISHERS." AS publisher INNER JOIN ".TABLE_CAMPAIGN_LEAD_DETAIL." AS lead ON lead.affiliateId=publisher.pid ) INNER JOIN ".TABLE_CAMPAIGN." AS campaign ON lead.campaignId = campaign.campaignId and lead.affiliateId <> 0".$wherequery.$orderQuery; $result = tep_db_query($query); $_SESSION['ses_campaign_report_query'] = $query; while($data = tep_db_fetch_array($result)) { if($data['subId'] == '') $data['subId'] = 'None'; $pub_subid[$data['subId']] = ($data['subId']); $data['subId'] = trim($data['subId']); $campaignData[$data['campaignId'].".".$data['subId']] = $data; $ClickSubId_array[$data['campaignId']][$data['subId']] = $data['subId']; $campaignIdArray[$data['campaignId']]= $data['campaignId']; } return $campaignData; } function getajaxtestleads($wherequery = '',$ordquery='') { global $leadCount; global $leadPayout; global $campaignData; $orderQuery = $ordquery; echo $query = "SELECT COUNT(*) AS leadCount, click.campaignId,sum(click.payout) as payout, click.subId,campaign.campaignName FROM ".TABLE_CAMPAIGN_LEAD_DETAIL." AS click LEFT JOIN ".TABLE_CAMPAIGN." AS campaign ON campaign.campaignId=click.campaignId WHERE 1 ".$wherequery." AND affiliateId='".$_SESSION['infinite_publisherID']."' GROUP BY click.campaignId,click.subId"; $result = tep_db_query($query); $_SESSION['ses_lead_report_query'] = $query; while($data = tep_db_fetch_array($result)) { if($data['subId'] == '') $data['subId'] = 'None'; $data['subId'] = trim($data['subId']); $campaignData[$data['campaignId'].".".$data['subId']] = $data; $leadCount[$data['campaignId']][$data['subId']] = $data['leadCount']; $leadPayout[$data['campaignId']][$data['subId']] = $data['payout']; } return $campaignData; } //end //Function added for auto email sent of the top offers for cpc calculations. function cpctopofferearnings($datequery = '',$wherequery='') { global $totalcpcvalue; global $totalcpcrevenue; global $sumcpcpayout; $cpc_earningquery = "SELECT sum(clickcount) AS clickCount,click.payout as cpcpayout,click.campaignId,click.revenue,sum(uniqueclicks) As uniqueclickcount,round(((sum(click.payout)/count(*))*sum(uniqueclicks)),2)as cpcearning,affiliate.firstname FROM campaignclickdetailreport AS click RIGHT JOIN ".TABLE_CAMPAIGN." AS campaign ON campaign.campaignId=click.campaignId LEFT JOIN ".TABLE_PUBLISHERS." AS affiliate ON affiliate.pid=click.affiliateId LEFT JOIN ".TABLE_CATEGORY ." AS category ON category.categoryId=campaign.categoryId WHERE 1 ".$datequery." ".$wherequery." and click.affiliateId <> 0 AND campaign.status='Y' AND campaign.offerType='CPC' GROUP BY click.affiliateId,click.campaignId,click.clickedDate"; $result_cpcearning = tep_db_query($cpc_earningquery); unset($totalcpcvalue); $calculatedvalue = 0; while($data_cpc = tep_db_fetch_array($result_cpcearning)) { $revenue = $data_cpc['revenue']; $uniqueclicks = $data_cpc['uniqueclickcount']; $cpcpayout_required = $data_cpc['cpcpayout']; $calculatedvalue = ($uniqueclicks*$cpcpayout_required); $calculatedrevenue = ($uniqueclicks*$revenue); $totalcpcrevenue[$data_cpc['campaignId']] += $calculatedrevenue; $sumcpcpayout[$data_cpc['campaignId']] += $cpcpayout_required; $totalcpcvalue[$data_cpc['campaignId']] += $calculatedvalue; } return $totalcpcvalue; } //End of function //Function added for aff manager reports affiliatewise on 21 june 2011 function getaffmanagerpubclicks($wherequery = '',$ordquery='') { global $campaignData; global $distinctCount; global $clickPayout; global $campaignIdarray; global $subidcampaignId; global $distinctCountpub; $orderQuery = $ordquery; $query = "SELECT sum(clickcount) AS clickCount,click.affiliateId,click.campaignId,sum(click.payout) as cpcpayout,sum(click.revenue) As cpcrevenue,click.subId,sum(uniqueclicks) As uniqueclickcount,sum(impressioncount) AS impressioncount,campaign.*,publishers.firstname,publishers.lastname,campaign.payout as totalpayout,category.categoryName FROM campaignclickdetailreport AS click RIGHT JOIN ".TABLE_CAMPAIGN." AS campaign ON campaign.campaignId=click.campaignId LEFT JOIN ".TABLE_CATEGORY ." AS category ON category.categoryId=campaign.categoryId LEFT JOIN ".TABLE_PUBLISHERS." AS publishers ON publishers.pid=click.affiliateId WHERE 1 ".$wherequery." and click.affiliateId <> 0 AND campaign.status='Y' GROUP BY click.affiliateId ".$orderQuery.""; $result = tep_db_query($query); $_SESSION['ses_campaign_report_query'] = $query; while($data = tep_db_fetch_array($result)) { $campaignData[$data['affiliateId']] = $data; $clickPayout[$data['affiliateId']] = $data['cpcpayout']; $campaignIdarray[$data['campaignId']] = $data['campaignId']; } return $campaignData; } function getaffmanagerpubleads($wherequery = '',$ordquery='') { global $leadCount; global $leadPayout; global $campaignIdarray; global $campaignData; global $leadRevenue; $leadPayout = null; $orderQuery = $ordquery; $query = "SELECT COUNT(*) AS leadCount, click.campaignId,click.affiliateId,sum(click.payout) as payout,sum(click.revenue) As leadrevenue,campaign.campaignName,campaign.revenue,campaign.payout AS campaignpayout,affiliate.firstname,affiliate.lastname FROM ".TABLE_CAMPAIGN_LEAD_DETAIL." AS click RIGHT JOIN ".TABLE_CAMPAIGN." AS campaign ON campaign.campaignId=click.campaignId LEFT JOIN ".TABLE_PUBLISHERS." AS affiliate ON affiliate.pid=click.affiliateId WHERE 1 ".$wherequery." and click.affiliateId <> 0 GROUP BY click.affiliateId ".$orderQuery.""; $result = tep_db_query($query); $_SESSION['ses_lead_report_query'] = $query; while($data = tep_db_fetch_array($result)) { $campaignData[$data['affiliateId']] = $data; $leadCount[$data['affiliateId']] = $data['leadCount']; $leadPayout[$data['affiliateId']] = $data['payout']; $leadRevenue[$data['affiliateId']] = $data['leadrevenue']; $campaignIdarray[$data['campaignId']] = $data['campaignId']; } return $campaignData; } function cpcaffmanagerpub($wherequery = '',$ordquery='') { global $totalcpcvalue; global $totalcpcrevenue; global $sumcpcpayout; $cpc_earningquery = "SELECT sum(clickcount) AS clickCount,click.payout as cpcpayout,click.campaignId,click.revenue,sum(uniqueclicks) As uniqueclickcount,round(((sum(click.payout)/count(*))*sum(uniqueclicks)),2)as cpcearning,publishers.firstname,publishers.lastname, FROM campaignclickdetailreport AS click RIGHT JOIN ".TABLE_CAMPAIGN." AS campaign ON campaign.campaignId=click.campaignId LEFT JOIN ".TABLE_PUBLISHERS." AS publishers ON publishers.pid=click.affiliateId WHERE 1 ".$wherequery." and click.affiliateId <> 0 AND campaign.status='Y' AND campaign.offerType='CPC' GROUP BY click.affiliateId,click.campaignId,click.clickedDate ".$orderQuery.""; $result_cpcearning = tep_db_query($cpc_earningquery); unset($totalcpcvalue); $calculatedvalue = 0; while($data_cpc = tep_db_fetch_array($result_cpcearning)) { $revenue = $data_cpc['revenue']; $uniqueclicks = $data_cpc['uniqueclickcount']; $cpcpayout_required = $data_cpc['cpcpayout']; $calculatedvalue = ($uniqueclicks*$cpcpayout_required); $calculatedrevenue = ($uniqueclicks*$revenue); $totalcpcrevenue[$data_cpc['affiliateId']] += $calculatedrevenue; $sumcpcpayout[$data_cpc['affiliateId']] += $cpcpayout_required; $totalcpcvalue[$data_cpc['affiliateId']] += $calculatedvalue; } return $totalcpcvalue; } //End of function //Function Added for the random tracking url generation function trackingrandomurl() { $query = "SELECT sites.siteid, sites.sitename, sites.host, sites.username, sites.password FROM infinite_host.".TABLE_SITES." as sites WHERE infinitedomain='true'"; $result_query = tep_db_query($query); while($data = tep_db_fetch_array($result_query)) { $sitenames[] = $data['sitename']; } if(!empty($sitenames)) { if(count($sitenames)==1) { $rand_keys = array_rand($sitenames,1); $rand_url = $sitenames[$rand_keys]; } else { $rand_keys = array_rand($sitenames,2); $rand_url = $sitenames[$rand_keys[1]]; } } else { $rand_url = "infitrax.com"; } return $rand_url; } //Function added for new tracking domain for the campaign on 9 aug 2011 function newtrackingdomain($campaignid) { global $INFO; $query = "SELECT newtrackingdomain,trackingdomain FROM ".TABLE_CAMPAIGN." where campaignId='".$campaignid."'"; $result_query = tep_db_query($query); while($data = tep_db_fetch_array($result_query)) { $newdomain = $data['newtrackingdomain']; $rand_url = $data['trackingdomain']; } $INFO['PIXEL_TRACKING_URL'] = 'http://www.'.str_replace("www.", "", $rand_url).'/'; return $rand_url; } ?>
Advertiser Registration
Login Information
Email '.$email_data['email'].'
Password '.$email_data['password'].'
Contact Information
First Name '.$email_data['firstname'].'
Last Name '.$email_data['lastname'].'
Address '.$email_data['address'].'
Address1 '.$email_data['address1'].'
City '.$email_data['city'].'
State '.$USstate[$email_data['state']].'
Zip '.$email_data['zip'].'
Phone '.$email_data['phone'].'
Fax '.$email_data['fax'].'
Product Information
Company Name '.$email_data['companyName'].'
Website '.$email_data['website'].'
Product Information '.$email_data['productInfo'].'
'; return $email_text; } // Email Template for sending Email After registration of publisher function emailPublisherRegTemplate($email_data,$id) { global $INFO,$USstate; $web_desc = stripslashes($email_data['websiteDesc']); $web_description = str_replace("\\","",$web_desc); //Added for fetching the ip address of the new publisher application on 14 july 10 $ip=$_SERVER['REMOTE_ADDR']; if($email_data['imname'] !='') { $where_query .= " OR `instant_messenger_id`='".$email_data['imname']."'"; } if($email_data['bankAccount'] !='') { $where_query .= " OR `bankAccount`='".$email_data['bankAccount']."'"; } if($ip !='') { $where_query .= " OR `userIpAddress`='".$ip."'"; } if($email_data['altemail'] !='') { $where_query .= " OR `altemail`='".$email_data['altemail']."'"; } if($email_data['address1'] !='') { $where_query .= " OR `address1`='".$email_data['address1']."'"; } if($email_data['routingNumber'] !='') { $where_query .= " OR `routingNumber`='".$email_data['routingNumber']."'"; } if($email_data['routingNumberint'] !='') { $where_query .= " OR `routingNumberint`='".$email_data['routingNumberint']."'"; } $dup_query = "select * from ".TABLE_PUBLISHERS." where (`firstname`='".$email_data['firstname']."' OR `lastname`='".$email_data['lastname']."' OR `email`='".$email_data['email']."' OR `phone`='".$email_data['phone1']."' OR `password`='".$email_data['password']."' OR `birthDate`='".$email_data['birthDate']."' OR `companyName`='".$email_data['companyName']."' OR `address`='".$email_data['address']."' OR `zip`='".$email_data['zip']."' OR `website`='".$email_data['website']."' OR `ssn`='".$email_data['ssn']."' ".$where_query.") and pid<>'".$id."'"; $result_dup_query = tep_db_query($dup_query); //$referral_data = tep_db_fetch_array($result_dup_query); while($dupdata = mysql_fetch_array($result_dup_query)) { $pid[] = $dupdata['pid']; if($dupdata['firstname'] == $email_data['firstname']) { $dupfirstname[$dupdata['pid']] = $dupdata['firstname']; } if($dupdata['lastname'] == $email_data['lastname']) { $duplastname[$dupdata['pid']] = $dupdata['lastname']; } if($dupdata['phone'] == $email_data['phone1']) { $dupphone[$dupdata['pid']] = $dupdata['phone']; } if($dupdata['password'] == $email_data['password']) { $duppassword[$dupdata['pid']] = $dupdata['password']; } if($dupdata['birthDate'] == $email_data['birthDate']) { $dupbirthDate[$dupdata['pid']] = $dupdata['birthDate']; } if($dupdata['companyName'] == $email_data['companyName']) { $dupcompanyName[$dupdata['pid']] = $dupdata['companyName']; } if($dupdata['address'] == $email_data['address']) { $dupaddress[$dupdata['pid']] = $dupdata['address']; } if($dupdata['zip'] == $email_data['zip']) { $dupzip[$dupdata['pid']] = $dupdata['zip']; } if($dupdata['website'] == $email_data['website']."|") { $dupwebsite[$dupdata['pid']] = $dupdata['website']; } if($dupdata['ssn'] == $email_data['ssn']) { $dupssn[$dupdata['pid']] = $dupdata['ssn']; } if($dupdata['imname'] == $email_data['imname']) { $dupinstant_messenger_id[$dupdata['pid']] = $dupdata['imname']; } if($dupdata['bankAccount'] == $email_data['bankAccount']) { $dupbankAccount[$dupdata['pid']] = $dupdata['bankAccount']; } if($dupdata['userIpAddress'] == $ip) { $dupuserIpAddress[$dupdata['pid']] = $dupdata['userIpAddress']; } if($dupdata['altemail'] == $email_data['altemail']) { $dupaltemail[$dupdata['pid']] = $dupdata['altemail']; } if($dupdata['address1'] == $email_data['address1']) { $dupaddress1[$dupdata['pid']] = $dupdata['address1']; } if($dupdata['routingNumber'] == $email_data['routingNumber']) { $duproutingNumber[$dupdata['pid']] = $dupdata['routingNumber']; } if($dupdata['routingNumberint'] == $email_data['routingNumberint']) { $duproutingNumberint[$dupdata['pid']] = $dupdata['routingNumberint']; } } foreach($pid as $pubkey => $pubval) { if($dupfirstname[$pubval] != '') { $firstname_dupids .= "[".''. $pubval.''."]"." "; } if($duplastname[$pubval] != '') { $lastname_dupids .= "[".''.$pubval.''."]"." "; } if($dupphone[$pubval] != '') { $phone_dupids .= "[".''.$pubval.''."]"." "; } if($duppassword[$pubval] != '') { $password_dupids .= "[".''.$pubval.''."]"." "; } if($dupbirthDate[$pubval] != '') { $birthDate_dupids .= "[".''.$pubval.''."]"." "; } if($dupcompanyName[$pubval] != '') { $companyName_dupids .= "[".''.$pubval.''."]"." "; } if($dupaddress[$pubval] != '') { $address_dupids .= "[".''.$pubval.''."]"." "; } if($dupzip[$pubval] != '') { $zip_dupids .= "[".''.$pubval.''."]"." "; } if($dupzip[$pubval] != '') { $zip_dupids .= "[".''.$pubval.''."]"." "; } if($dupwebsite[$pubval] != '') { $website_dupids .= "[".''.$pubval.''."]"." "; } if($dupssn[$pubval] != '') { $ssn_dupids .= "[".''.$pubval.''."]"." "; } if($dupinstant_messenger_id[$pubval] != '') { $instant_messenger_id_dupids .= "[".''.$pubval.''."]"." "; } if($dupbankAccount[$pubval] != '') { $bankAccount_dupids .= "[".''.$pubval.''."]"." "; } if($dupuserIpAddress[$pubval] != '') { $userIpAddress_dupids .= "[".''.$pubval.''."]"." "; } if($dupaltemail[$pubval] != '') { $altemail_dupids .= "[".''.$pubval.''."]"." "; } if($dupaddress1[$pubval] != '') { $address1_dupids .= "[".''.$pubval.''."]"." "; } if($duproutingNumber[$pubval] != '') { $routingNumber_dupids .= "[".''.$pubval.''."]"." "; } if($duproutingNumberint[$pubval] != '') { $routingNumberint_dupids .= "[".''.$pubval.''."]"." "; } } $dup_affids = implode("','",$pid); $topMenubg= 'style="background-color:#eff4f8"'; $titleBg ='style="background-color:#ccd4e0; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:15px; font-weight:bold; color: #000080; letter-spacing: 2px;"'; $darkbluemedium ='style=" background-color:#54637e; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:11px; font-weight:normal; color:#FFFFFF;"'; $lightgrey='style=" background-color:#e4e6eb; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:11px; font-weight:normal; line-height:20px; color:#000000; "'; $lightMenubg='style=" background-color:#ccd4e0 ; font-family:Tahoma, Verdana, Arial; font-size:11px; color:#000000; line-height:20px; "'; foreach($INFO['taxClass'] as $key=>$val) { if($email_data['tax_classification'] == $key) $taxclassification = $val; } foreach($INFO['paymentMethod'] as $key=>$val) { if($email_data['payment_method'] == $key) $payment_method = $val; } if(!empty($_SESSION['referral_affId'])) { $query = "select firstname,lastname from ".TABLE_PUBLISHERS." where pid='".$_SESSION['referral_affId']."'"; $result = tep_db_query($query); $referral_data = tep_db_fetch_array($result); $referral_pub = $referral_data['firstname']." ".$referral_data['lastname']; $referralinfo = ' Referral Information Refferal Publisher '.$referral_pub.' '; } $email_text = '
Publisher Registration
'.$referralinfo.'
Login Information   Duplicate Affiliates Information
Affiliate Id '.$id.'  
Email '.$email_data['email'].'  
Password '.$email_data['password'].' '.$password_dupids.'
Contact Information
First Name '.$email_data['firstname'].' '.$firstname_dupids.'
Last Name '.$email_data['lastname'].' '.$lastname_dupids.'
Birth Date '.$email_data['birthDate'].' '.$birthDate_dupids.'
Alternate Email Address '.$email_data['altemail'].' '.$altemail_dupids.'
Aim Name '.$email_data['imname'].' '.$instant_messenger_id_dupids.'
Address '.$email_data['address'].' '.$address_dupids.'
Address1 '.$email_data['address1'].' '.$address1_dupids.'
City '.$email_data['city'].'  
State '.$USstate[$email_data['state']].'  
Country '.$INFO[$email_data['country']].'  
Zip '.$email_data['zip'].' '.$zip_dupids.'
Referral Name '.$email_data['referral_name'].'  
Referral Email '.$email_data['referral_email'].'  
Phone '.$email_data['phone1'].'-'.$email_data["phone2"].' '.$phone_dupids.'
Fax '.$email_data['fax1'].'-'.$email_data["fax2"].'  
IP Address '.$ip.' '.$userIpAddress_dupids.'
Payment Information
Tax Classification '.$taxclassification.'  
Tax ID or SSN: '.$email_data['ssn'].' '.$ssn_dupids.'
Payment Methods '.$payment_method.'  
Bank Address: '.$email_data['bankAddress'].'  
Bank Name: '.$email_data['bankName'].'  
Bank Account number: '.$email_data['bankAccount'].' '.$bankAccount_dupids.'
Routing Numbers: '.$email_data['routingNumber'].' '.$routingNumber_dupids.'
International Routing Numbers: '.$email_data['routingNumberint'].' '.$routingNumberint_dupids.'
Publishing Information
Company Name '.$email_data['companyName'].' '.$companyName_dupids.'
Website '.$email_data['website'].' '.$website_dupids.'
Website Description '.$web_description.'  
'; return $email_text; } //Email Template for sending email to network during clone publisher registration function emailclonePublisherTemplate($email_data) { global $INFO,$USstate; $topMenubg= 'style="background-color:#eff4f8"'; $titleBg ='style="background-color:#ccd4e0; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:15px; font-weight:bold; color: #000080; letter-spacing: 2px;"'; $darkbluemedium ='style=" background-color:#54637e; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:11px; font-weight:normal; color:#FFFFFF;"'; $lightgrey='style=" background-color:#e4e6eb; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:11px; font-weight:normal; line-height:20px; color:#000000; "'; $lightMenubg='style=" background-color:#ccd4e0 ; font-family:Tahoma, Verdana, Arial; font-size:11px; color:#000000; line-height:20px; "'; $email_text = '
Clone Publisher Info
Login Information
Email '.$email_data['email'].'
Username '.$email_data['username'].'
Password '.$email_data['password'].'
Contact Information
First Name '.$email_data['firstname'].'
Last Name '.$email_data['lastname'].'
Address '.$email_data['address'].'
Address1 '.$email_data['address1'].'
City '.$email_data['city'].'
State '.$USstate[$email_data['state']].'
Zip '.$email_data['zip'].'
Phone '.$email_data['phone1'].'-'.$email_data["phone2"].'
Fax '.$email_data['fax1'].'-'.$email_data["fax2"].'
Publishing Information
Company Name '.$email_data['companyName'].'
Website '.$email_data['website'].'
Website Description '.$email_data['websiteDesc'].'
'; return $email_text; } //end of the mail template for network during clone publisher registration /****************************For sending forgot password mail Added on 12 june 09****************************/ function emailForgotPasswordTemplate($email_data) { global $INFO,$USstate; $topMenubg= 'style="background-color:#eff4f8"'; $titleBg ='style="background-color:#ccd4e0; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:15px; font-weight:bold; color: #000080; letter-spacing: 2px;"'; $darkbluemedium ='style=" background-color:#54637e; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:11px; font-weight:normal; color:#FFFFFF;"'; $lightgrey='style=" background-color:#e4e6eb; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:11px; font-weight:normal; line-height:20px; color:#000000; "'; $lightMenubg='style=" background-color:#ccd4e0 ; font-family:Tahoma, Verdana, Arial; font-size:11px; color:#000000; line-height:20px; "'; $email_text = '
Forgot Password Details
Login Information
username '.$email_data['username'].'
Password '.$email_data['password'].'
'; return $email_text; } /****************************For sending forgot password mail Added on 12 june 09****************************/ /****************************For sending mass email of the new offers to publishers on 19apr 2010****************************/ function emailNewCampaignInfoTemplate($email_data) { global $INFO,$USstate; //$topMenubg= 'style="background-color:#eff4f8"'; $topMenubg= 'style="padding-left:10px"'; $titleBg ='style="background-color:#ccd4e0; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:15px; font-weight:bold; color: #000080; letter-spacing: 2px;"'; $darkbluemedium ='style=" background-color:#54637e; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:11px; font-weight:normal; color:#FFFFFF;"'; $lightgrey='style=" background-color:#e4e6eb; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:11px; font-weight:normal; line-height:20px; color:#000000; "'; $lightMenubg='style=" background-color:#ccd4e0 ; font-family:Tahoma, Verdana, Arial; font-size:11px; color:#000000; line-height:20px; "'; // for Campaign Details $where_data_array = array("campaignId" => $email_data['campaignId']); $data = getCampaignDetails($where_data_array); // for Creative Details $where_query = " and campaignId = ".$email_data['campaignId']." and creativeType='2' limit 1"; $creatives = getEmailCreativeDetails($where_query); // for Supression List $where_data_array = array("campaignId" => $email_data['campaignId']); $supressionData = getSupressionDetails($where_data_array); if(!empty($creatives)) { $campaign_tracking_url = $INFO['TRACKING_URL']."adClick.php?p=[AFF_ID]&c=".$creatives['campaignId']."&adId=".$creatives['creativeId']; $htmlCode = str_replace("[TRACKING_URL]", $campaign_tracking_url, $creatives['emailContent']); } /*if(!empty($supressionData)) { foreach($supressionData as $key=>$val) { $supressionlink = 'Get the suppression file here'; } } */ $supressionlink = 'Get the suppression file here'; $traffic_type = explode("|",$data['trafficMethods']); //unset($traffic_method); foreach($traffic_type as $traffickey=>$trafficval) { $traffic_method[] = $INFO['trafficMethod'][$trafficval]; } $email_text = '
[AFF_FIRSTNAME] [AFF_LASTNAME]
Affiliate ID: [AFF_ID]


'.$data['campaignName'].'


CampaignID: '.$data['campaignId'].'

Campaign Payout:
$[AFF_PAYOUT]

Campaign Description:
'.$data['campaignDescription'].'

Traffic Methods:
'.@implode(", ",$traffic_method).'

Your tracking link:
http://www.infitrax.com/adClick.php?p=[AFF_ID]&c='.$data['campaignId'].'

Get your campaign creatives here    Get the suppression file here


'.$htmlCode.'


Please contact Sean or Auggie if you have any questions.

Thank you,
HopeTon Media
'; return $email_text; } /****************************For sending mass email of the new offers to publishers on 19apr 2010****************************/ /****************************function sending email campaign pixel to the advertiser of respective campaign on 1 sept 2010****************************/ function emailcampaignpixelTemplate($id,$name) { global $INFO,$USstate; //$topMenubg= 'style="background-color:#eff4f8"'; $topMenubg= 'style="padding-left:10px"'; $titleBg ='style="background-color:#ccd4e0; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:15px; font-weight:bold; color: #000080; letter-spacing: 2px;"'; $darkbluemedium ='style=" background-color:#54637e; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:11px; font-weight:normal; color:#FFFFFF;"'; $lightgrey='style=" background-color:#e4e6eb; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:11px; font-weight:normal; line-height:20px; color:#000000; "'; $lightMenubg='style=" background-color:#ccd4e0 ; font-family:Tahoma, Verdana, Arial; font-size:11px; color:#000000; line-height:20px; "'; $script_pixel = ''; $campaign_tracking_url = $INFO['TRACKING_URL']."adClick.php?p=102&c=".$id; $email_text = '
Hello,

Here is our Tracking Pixel. Please do not alter it in any way other than adding an \'s\' if you need to make it secure.

'.$name.'


Script Pixel:
'.htmlentities ($script_pixel).'

Test URL:
'.$campaign_tracking_url.'

Please reply to this email once you have placed the pixel and ran a test using the test URL above.

Thank you,
HopeTon Media
'; return $email_text; } /****************************End of function sending email campaign pixel to the advertiser of respective campaign****************************/ /****************************Function Added for automatic emails sent to publisher when the campaign is set to paused on 29 apr 2011******************/ function autoemailcampaignpaused($campname,$campid,$redirectcampid) { global $INFO,$USstate; //$topMenubg= 'style="background-color:#eff4f8"'; $topMenubg= 'style="padding-left:10px"'; $titleBg ='style="background-color:#ccd4e0; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:15px; font-weight:bold; color: #000080; letter-spacing: 2px;"'; $darkbluemedium ='style=" background-color:#54637e; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:11px; font-weight:normal; color:#FFFFFF;"'; $lightgrey='style=" background-color:#e4e6eb; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:11px; font-weight:normal; line-height:20px; color:#000000; "'; $lightMenubg='style=" background-color:#ccd4e0 ; font-family:Tahoma, Verdana, Arial; font-size:11px; color:#000000; line-height:20px; "'; // for Campaign Details $where_data_array = array("campaignId" => $redirectcampid); $data = getCampaignDetails($where_data_array); $email_text = '
Campaign Name:
'.$campname.'

Campaign ID:
'.$campid.'

'.@implode(", ",$traffic_method).'

CID'.$campid.' '.$campname.' is now paused. Any residual traffic will be redirected to CID '.$redirectcampid.' '.$data['campaignName'].'([REDIRECTURL]).

We apologize for any inconvenience this may cause you, although we wanted to ensure you were aware so you can take any action necessary to maximize your earnings.



Thank you,
HopeTon Media
'; return $email_text; } /***************************End of the function for emails sent to publisher when the campaign is set to paused on 29 apr 2011******************/ /****************************Function Added for automatic emails sent to publisher when the campaign is set to paused on 29 apr 2011******************/ function autoemailpayoutchange($campname,$campid) { global $INFO,$USstate; //$topMenubg= 'style="background-color:#eff4f8"'; $topMenubg= 'style="padding-left:10px"'; $titleBg ='style="background-color:#ccd4e0; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:15px; font-weight:bold; color: #000080; letter-spacing: 2px;"'; $darkbluemedium ='style=" background-color:#54637e; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:11px; font-weight:normal; color:#FFFFFF;"'; $lightgrey='style=" background-color:#e4e6eb; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:11px; font-weight:normal; line-height:20px; color:#000000; "'; $lightMenubg='style=" background-color:#ccd4e0 ; font-family:Tahoma, Verdana, Arial; font-size:11px; color:#000000; line-height:20px; "'; // for Campaign Details $where_data_array = array("campaignId" => $redirectcampid); $data = getCampaignDetails($where_data_array); $email_text = '
Campaign Name:
'.$campname.'

Campaign ID:
'.$campid.'

Please log in and check your payout for CID'.$campid.' '.$campname.' as the payout has been changed.


Thank you,
Team HopeTon Media
'; return $email_text; } /***************************End of the function for emails sent to publisher when the campaign is set to paused on 29 apr 2011******************/ //Test function for pub reg info alongwith dup aff id info on 10 june 2011 function emailDupPublisherRegTemplate($email_data,$id) { global $INFO,$USstate; $web_desc = stripslashes($email_data['websiteDesc']); $web_description = str_replace("\\","",$web_desc); if($email_data['imname'] !='') { $where_query .= " OR `instant_messenger_id`='".$email_data['imname']."'"; } if($email_data['bankAccount'] !='') { $where_query .= " OR `bankAccount`='".$email_data['bankAccount']."'"; } if($email_data['bankAccount'] !='') { $where_query .= " OR `userIpAddress`='".$_SERVER['REMOTE_ADDR']."'"; } if($email_data['altemail'] !='') { $where_query .= " OR `altemail`='".$email_data['altemail']."'"; } if($email_data['address1'] !='') { $where_query .= " OR `address1`='".$email_data['address1']."'"; } echo $dup_query = "select * from ".TABLE_PUBLISHERS." where (`firstname`='".$email_data['firstname']."' OR `lastname`='".$email_data['lastname']."' OR `email`='".$email_data['email']."' OR `phone`='".$email_data['phone1']."' OR `password`='".$email_data['password']."' OR `birthDate`='".$email_data['birthDate']."' OR `companyName`='".$email_data['companyName']."' OR `address`='".$email_data['address']."' OR `zip`='".$email_data['zip']."' OR `website`='".$email_data['website']."' OR `ssn`='".$email_data['ssn']."' ".$where_query.") and pid<>'".$id."'"; $result_dup_query = tep_db_query($dup_query); //$referral_data = tep_db_fetch_array($result_dup_query); while($dupdata = mysql_fetch_array($result_dup_query)) { $pid[] = $dupdata['pid']; if($dupdata['firstname'] == $email_data['firstname']) { $dupfirstname[$dupdata['pid']] = $dupdata['firstname']; } if($dupdata['lastname'] == $email_data['lastname']) { $duplastname[$dupdata['pid']] = $dupdata['lastname']; } if($dupdata['phone'] == $email_data['phone1']) { $dupphone[$dupdata['pid']] = $dupdata['phone']; } if($dupdata['password'] == $email_data['password']) { $duppassword[$dupdata['pid']] = $dupdata['password']; } if($dupdata['birthDate'] == $email_data['birthDate']) { $dupbirthDate[$dupdata['pid']] = $dupdata['birthDate']; } if($dupdata['companyName'] == $email_data['companyName']) { $dupcompanyName[$dupdata['pid']] = $dupdata['companyName']; } if($dupdata['address'] == $email_data['address']) { $dupaddress[$dupdata['pid']] = $dupdata['address']; } if($dupdata['zip'] == $email_data['zip']) { $dupzip[$dupdata['pid']] = $dupdata['zip']; } if($dupdata['website'] == $email_data['website']."|") { $dupwebsite[$dupdata['pid']] = $dupdata['website']; } if($dupdata['ssn'] == $email_data['ssn']) { $dupssn[$dupdata['pid']] = $dupdata['ssn']; } if($dupdata['imname'] == $email_data['imname']) { $dupinstant_messenger_id[$dupdata['pid']] = $dupdata['imname']; } if($dupdata['bankAccount'] == $email_data['bankAccount']) { $dupbankAccount[$dupdata['pid']] = $dupdata['bankAccount']; } if($dupdata['userIpAddress'] == $email_data['userIpAddress']) { $dupuserIpAddress[$dupdata['pid']] = $dupdata['userIpAddress']; } if($dupdata['altemail'] == $email_data['altemail']) { $dupaltemail[$dupdata['pid']] = $dupdata['altemail']; } if($dupdata['address1'] == $email_data['address1']) { $dupaddress1[$dupdata['pid']] = $dupdata['address1']; } } /*echo"
";
		print_r($dupfirstname);
		echo"
"; echo"
";
		print_r($duplastname);
		echo"
"; echo"
";
		print_r($dupphone);
		echo"
"; echo"
";
		print_r($duppassword);
		echo"
"; echo"
";
		print_r($dupbirthDate);
		echo"
"; echo"
";
		print_r($dupcompanyName);
		echo"
"; echo"
";
		print_r($dupaddress);
		echo"
"; echo"
";
		print_r($dupuserIpAddress);
		echo"
"; echo"
";
		print_r($dupzip);
		echo"
"; echo"
";
		print_r($dupwebsite);
		echo"
"; echo"
";
		print_r($dupssn);
		echo"
"; echo"
";
		print_r($dupinstant_messenger_id);
		echo"
"; echo"
";
		print_r($dupbankAccount);
		echo"
"; echo"
";
		print_r($dupaltemail);
		echo"
"; echo"
";
		print_r($dupaddress1);
		echo"
"; exit();*/ foreach($pid as $pubkey => $pubval) { if($dupfirstname[$pubval] != '') { $firstname_dupids .= "[".$pubval."]"." "; } if($duplastname[$pubval] != '') { $lastname_dupids .= "[".$pubval."]"." "; } if($dupphone[$pubval] != '') { $phone_dupids .= "[".$pubval."]"." "; } if($duppassword[$pubval] != '') { $password_dupids .= "[".$pubval."]"." "; } if($dupbirthDate[$pubval] != '') { $birthDate_dupids .= "[".$pubval."]"." "; } if($dupcompanyName[$pubval] != '') { $companyName_dupids .= "[".$pubval."]"." "; } if($dupaddress[$pubval] != '') { $address_dupids .= "[".$pubval."]"." "; } if($dupzip[$pubval] != '') { $zip_dupids .= "[".$pubval."]"." "; } if($dupzip[$pubval] != '') { $zip_dupids .= "[".$pubval."]"." "; } if($dupwebsite[$pubval] != '') { $website_dupids .= "[".$pubval."]"." "; } if($dupssn[$pubval] != '') { $ssn_dupids .= "[".$pubval."]"." "; } if($dupinstant_messenger_id[$pubval] != '') { $instant_messenger_id_dupids .= "[".$pubval."]"." "; } if($dupbankAccount[$pubval] != '') { $bankAccount_dupids .= "[".$pubval."]"." "; } if($dupuserIpAddress[$pubval] != '') { $userIpAddress_dupids .= "[".$pubval."]"." "; } if($dupaltemail[$pubval] != '') { $altemail_dupids .= "[".$pubval."]"." "; } if($dupaddress1[$pubval] != '') { $address1_dupids .= "[".$pubval."]"." "; } } /* echo"
";
		print_r($firstname_dupids);
		echo"
"; echo"
";
		print_r($lastname_dupids);
		echo"
"; echo"
";
		print_r($phone_dupids);
		echo"
"; echo"
";
		print_r($password_dupids);
		echo"
"; echo"
";
		print_r($birthDate_dupids);
		echo"
"; echo"
";
		print_r($companyName_dupids);
		echo"
"; echo"
";
		print_r($address_dupids);
		echo"
"; echo"
";
		print_r($zip_dupids);
		echo"
"; echo"
";
		print_r($website_dupids);
		echo"
"; echo"
";
		print_r($ssn_dupids);
		echo"
"; echo"
";
		print_r($instant_messenger_id_dupids);
		echo"
"; echo"
";
		print_r($dupinstant_messenger_id);
		echo"
"; echo"
";
		print_r($bankAccount_dupids);
		echo"
"; echo"
";
		print_r($userIpAddress_dupids);
		echo"
"; echo"
";
		print_r($altemail_dupids);
		echo"
"; echo"
";
		print_r($address1_dupids);
		echo"
"; exit(); */ $dup_affids = implode("','",$pid); $topMenubg= 'style="background-color:#eff4f8"'; $titleBg ='style="background-color:#ccd4e0; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:15px; font-weight:bold; color: #000080; letter-spacing: 2px;"'; $darkbluemedium ='style=" background-color:#54637e; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:11px; font-weight:normal; color:#FFFFFF;"'; $lightgrey='style=" background-color:#e4e6eb; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:11px; font-weight:normal; line-height:20px; color:#000000; "'; $lightMenubg='style=" background-color:#ccd4e0 ; font-family:Tahoma, Verdana, Arial; font-size:11px; color:#000000; line-height:20px; "'; //Added for fetching the ip address of the new publisher application on 14 july 10 $ip=$_SERVER['REMOTE_ADDR']; foreach($INFO['taxClass'] as $key=>$val) { if($email_data['tax_classification'] == $key) $taxclassification = $val; } foreach($INFO['paymentMethod'] as $key=>$val) { if($email_data['payment_method'] == $key) $payment_method = $val; } if(!empty($_SESSION['referral_affId'])) { $query = "select firstname,lastname from ".TABLE_PUBLISHERS." where pid='".$_SESSION['referral_affId']."'"; $result = tep_db_query($query); $referral_data = tep_db_fetch_array($result); $referral_pub = $referral_data['firstname']." ".$referral_data['lastname']; $referralinfo = ' Referral Information Refferal Publisher '.$referral_pub.' '; } $email_text = '
Publisher Registration
'.$referralinfo.'
Login Information   Duplicate Affiliates Information
Affiliate Id '.$id.' '.$dup_affids.'
Email '.$email_data['email'].'  
Password '.$email_data['password'].' '.$password_dupids.'
Contact Information
First Name '.$email_data['firstname'].' '.$firstname_dupids.'
Last Name '.$email_data['lastname'].' '.$lastname_dupids.'
Birth Date '.$email_data['birthDate'].' '.$birthDate_dupids.'
Alternate Email Address '.$email_data['altemail'].' '.$altemail_dupids.'
Aim Name '.$email_data['imname'].' '.$instant_messenger_id_dupids.'
Address '.$email_data['address'].' '.$address_dupids.'
Address1 '.$email_data['address1'].' '.$address1_dupids.'
City '.$email_data['city'].'  
State '.$USstate[$email_data['state']].'  
Country '.$INFO[$email_data['country']].'  
Zip '.$email_data['zip'].' '.$zip_dupids.'
Referral Name '.$email_data['referral_name'].'  
Referral Email '.$email_data['referral_email'].'  
Phone '.$email_data['phone1'].'-'.$email_data["phone2"].' '.$phone_dupids.'
Fax '.$email_data['fax1'].'-'.$email_data["fax2"].'  
IP Address '.$ip.' '.$userIpAddress_dupids.'
Payment Information
Tax Classification '.$taxclassification.'  
Tax ID or SSN: '.$email_data['ssn'].' '.$ssn_dupids.'
Payment Methods '.$payment_method.'  
Bank Address: '.$email_data['bankAddress'].'  
Bank Name: '.$email_data['bankName'].'  
Bank Account number: '.$email_data['bankAccount'].' '.$bankAccount_dupids.'
Routing Numbers: '.$email_data['routingNumber'].'  
Publishing Information
Company Name '.$email_data['companyName'].' '.$companyName_dupids.'
Website '.$email_data['website'].' '.$website_dupids.'
Website Description '.$web_description.'  
'; return $email_text; } //End of function ?> Hopeton Media
HopeTon Media for Publishers

HopeTon Media - A Network HopeTon Medialy Different than the rest! HopeTon Media is an Invite Only network where Publishers are treated with unparalleled levels of appreciation that far exceed even the most publisher-centric affiliate networks within the industry today. Steeped in the practical lessons learned from long-term, high volume, Internet marketing veterans; HopeTon Media is dynamic, flexible, exclusive, and comprised solely of top tier publishers. We strive to bring you only the most exclusive, direct, top converting offers found anywhere on the market.

HopeTon Media for Advertisers

HopeTon Media is an unequalled network specifically designed to deliver the results our Clients demand by way of cost-for-performance campaigns. It is our goal to make sure we deliver our clientele exactly what they demand with our unique marketing and campaign management services. With years of online marketing experience under our belt, we have developed a complete system for the promotion of nearly any business on the market.

Our Featured Advertisers
Need assistance now? We're here to help you day or night!
        By Direct: 604.474.2484        By E-Mail: support@hopetonmedia.com        On AIM: HopeTon Media

DMCA | Privacy Policy | Terms & Conditions
© Copyright HopeTon Media, LLC. 2017 All Rights Reserved