示例#1
0
    protected function saveChildClick(Pap_Common_Banner $banner, Pap_Contexts_Tracking $context) {
		try {
    		$parentBanner = $banner->getParentBanner();
    		$parentBanner->saveChildClick($banner);	
    	} catch (Gpf_DbEngine_NoRowException $e) {
    		$this->setParentBannerNotExistsDebug($context);
    	}    	
    }
	/**
	 * @param String $channelValue
	 */
	private function setChannel($channelValue) {
		$channel = new Pap_Db_Channel();
		$channel->setValue($channelValue);
		$channel->setPapUserId(Gpf_Session::getAuthUser()->getPapUserId());
		try {
			$channel->loadFromData(array(Pap_Db_Table_Channels::VALUE, Pap_Db_Table_Channels::USER_ID));
			$this->banner->setChannel($channel);
		} catch (Gpf_Exception $e) {
		}
	}
 private function prepareCachedBanner(Pap_Common_Banner $banner, Pap_Db_CachedBanner $cachedBanner) {
     if ($banner->getWrapperId() !== null && $cachedBanner->getWrapper() !== '') {
         Pap_Merchants_Config_BannerWrapperService::fillCachedBanner($banner, $cachedBanner);
         return;
     }
     if ($banner->getBannerType() == Pap_Features_HoverBanner_Hover::TYPE_HOVER) {
         $cachedBanner->setCode($banner->getCode(Pap_Affiliates_User::loadFromId($cachedBanner->getUserId()), Pap_Common_Banner::FLAG_RAW_CODE));
     } else {
         $banner->fillCachedBanner($cachedBanner, Pap_Affiliates_User::loadFromId($cachedBanner->getUserId()));
     }
     self::addJavascriptCode($cachedBanner);
 }
示例#4
0
    /**
     * Performs any additional actions that are needed before row is saved
     */
    protected function beforeSaveAction() {
        parent::beforeSaveAction();
        if (($this->getData1() != $this->oldFileId) && ($this->oldFileId!='')) {
            $this->deleteTempDir(new Gpf_Io_File($this->getZipFolderUrl().$this->oldFileId));

        }
    }
示例#5
0
 private function setRecognizedParams(Pap_Contexts_Action $context) {
     $context->setUserObject($this->affiliate);
     $context->setBannerObject($this->banner);
     $context->setCampaignObject($this->campaign);
     $context->setAccountId($this->campaign->getAccountId(), Pap_Contexts_Tracking::ACCOUNT_RECOGNIZED_FROM_CAMPAIGN);
     $context->setTrackingMethod(Pap_Common_Transaction::TRACKING_METHOD_COUPON);
     $context->getTransaction()->setCouponId($this->coupon->getId());
     $context->getTransaction()->set(Pap_Db_Table_Transactions::BANNER_ID, $this->banner->getId());
 }
 public function getSrcCode(Pap_Common_Banner $banner, Pap_Common_User $user, Pap_Db_Channel $channel = null, $data1 = '', $data2 = ''){
     $code = $this->getScriptUrl("imp.php");
     $code .= "?".Pap_Tracking_Request::getAffiliateClickParamName()."=".$user->getRefId();
     $code .= "&".Pap_Tracking_Request::getBannerClickParamName()."=".$banner->getId();
     if ($banner->getParentBannerId() != null) {
         $code .= "&".Pap_Tracking_Request::getRotatorBannerParamName()."=".$banner->getParentBannerId();
     }
     if($channel != null && is_object($channel)) {
         $code .= "&".Pap_Tracking_Request::getChannelParamName()."=".$channel->getValue();
     }
     if($data1 != '') {
         $code .= "&".Pap_Tracking_Request::getExtraDataParamName(1)."=".$data1;
     }
     if($data2 != '') {
         $code .= "&".Pap_Tracking_Request::getExtraDataParamName(2)."=".$data2;
     }
     
     return $code;
 }
    private function replaceVariables($affiliate, Pap_Common_Banner $banner, $channelcode, $content) {
        $this->userFields->setUser($affiliate);
        $content = $this->userFields->replaceUserConstantsInText($content);
        if ($channelcode == null) {
           $channelcode = '';
        }
        $content = Pap_Common_UserFields::replaceCustomConstantInText(Pap_Features_ZipBanner_UserFields::CHANNELID,$channelcode,$content);
     
        $content = $banner->replaceBannerConstants($content, $affiliate);
        $content = $banner->replaceUserConstants($content, $affiliate);
        $content = $banner->replaceUrlConstants($content, $affiliate, null, $banner->getDestinationUrl());

        return $content;
    }
    private function checkBanner(Pap_Contexts_Tracking $context, Pap_Common_Banner $banner) {
        if ($this->isAccountRecognizedNotFromDefault($context) && $banner->getAccountId() != $context->getAccountId()) {
            $context->debug("Banner with Id: ".$banner->getId()." and name '".$banner->getName()."' cannot be used with accountId: '". $context->getAccountId() ."'!");
            throw new Gpf_Exception("Banner is from differen account");
        }

        if (!is_null($context->getCampaignObject()) && $context->getCampaignObject()->getId() != $banner->getCampaignId()) {
            $context->debug("Banner with Id: ".$banner->getId()." cannot be used (it is from different campaign as recognized campaign)!");
            throw new Gpf_Exception("Banner is from different campaign as recognized campaign!"); 
        }
    }
示例#9
0
 public function setId($id){
     if($id == 'null'){
         return;
     }
     parent::setId($id);
 }
 public static function isWrapperRequest(Pap_Common_Banner $banner, Pap_Tracking_Request $request){
     return $banner->getWrapperId() !== null &&
     $request->getRequestParameter(self::URL_PARAM_WRAPPER) !== '';
 }
示例#11
0
 function getDestURL(){
     return $this->convertUrlToNormal($this->banner->getClickUrl($this->user, '', 0));
 }
示例#12
0
 public function encodeSize(Gpf_Rpc_Form $form, $sizeFieldName) {
     parent::encodeSize($form, $sizeFieldName);
     if ($form->existsField(Pap_Db_Table_Banners::DATA4)) {
         parent::encodeSize($form, Pap_Db_Table_Banners::DATA4);
     }
 }
示例#13
0
    /**
     * removes style from rich text links, and convert the constants for {} to real {}
     *
     * @param Gpf_Rpc_Form $form
     */
    private function addRichTextLinks(Gpf_Rpc_Form $form, Pap_Common_Banner $banner) {
        if($banner->getBannerType() != Pap_Common_Banner_Factory::BannerTypePromoEmail
        && $banner->getBannerType() != Pap_Common_Banner_Factory::BannerTypePdf)
        {
            return;
        }
         
        $data2 = $form->getFieldValue('data2');
        $data2 = $this->addDefaultStyle($data2);
        $data2 = str_replace('"{', '"%7B', $data2);
        $data2 = str_replace('}"', '%7D"', $data2);

        $form->setField('data2', $data2);
    }
示例#14
0
 public function showBanner(Pap_Tracking_Request $request, Pap_Common_Banner $banner) {
     if($request->getAffiliateId() === 'preview'){
         echo $banner->getWindowPreview();
     }
 }
 private function getDestinationUrl(Pap_Common_Banner $banner = null, $specialDestinationUrl = '', Pap_Common_User $user = null) {
     if ($specialDestinationUrl != '') {
         return $specialDestinationUrl;
     }
     if ($banner != null) {
         return $banner->getDestinationUrl($user);
     }
     return Gpf_Settings::get(Pap_Settings::MAIN_SITE_URL);
 }
示例#16
0
    protected function migrateBanners() {
    	Pap3Compatibility_Migration_OutputWriter::log("  Migrating banners.....");
    	
    	$selectBuilder = new Gpf_SqlBuilder_SelectBuilder();
        $selectBuilder->select->add('*');
        $selectBuilder->from->add('wd_pa_banners', 'b');
        $selectBuilder->where->add('b.deleted', '=', '0' );

        $result = $selectBuilder->getAllRows();

        $count = 0;
        foreach($result as $record) {
        	$obj = new Pap_Common_Banner();
        	$obj->setId($record->get('bannerid'));
        	$obj->setCampaignId($record->get('campaignid'));
        	$obj->setAccountId(Pap3Compatibility_Migration_Pap3Constants::DEFAULT_ACCOUNT_ID);
        	if($record->get('destinationurl') != '') {
        		$obj->setDestinationUrl($record->get('destinationurl'));
        	} else {
        		$obj->setDestinationUrl(' ');
        	}
        	$obj->setName($record->get('name'));
        	if($record->get('dateinserted') != '') {
        		$obj->set('dateinserted', $record->get('dateinserted'));
        	} else {
        		$obj->set('dateinserted', Gpf_Common_DateUtils::now());
        	}
        	$obj->setStatus(($record->get('hidden') == 1 ? 'H' : 'A'));
        	
        	$bannerType = Pap3Compatibility_Migration_Pap3Constants::translateBannerType($record->get('bannertype'));
        	switch($bannerType) {
        		case Pap_Common_Banner_Factory::BannerTypeText:
        			$obj->setData1($record->get('sourceurl'));
        			$obj->setData2($this->replaceVariables($record->get('description')));
        			break;
        		case Pap_Common_Banner_Factory::BannerTypeImage:
        			$obj->setData1($record->get('sourceurl'));
        			break;
        		case Pap_Common_Banner_Factory::BannerTypeHtml:
        			$obj->setData1('N');
        			$obj->setData2($this->replaceVariables($record->get('description')));
        			break;
        		case Pap_Common_Banner_Factory::BannerTypePopup:
        		case Pap_Common_Banner_Factory::BannerTypePopunder:
        			// these banners are not yet supported in PAP4
        			continue;
        		case Pap_Common_Banner_Factory::BannerTypePromoEmail:
        			$obj->setData1($record->get('sourceurl'));
        			$obj->setData2($this->replaceVariables($record->get('description')));
       			break;
        	}
        	$obj->setBannerType($bannerType);
        	
        	try {
        	   $obj->save();
        	} catch (Gpf_Exception $e) {
        	    Pap3Compatibility_Migration_OutputWriter::log(
        	       sprintf(' Warning: banner %s not migrated. Reason: %s', $obj->getId(), $e->getMessage()));
        	}
        	$count++;
        }
    	Pap3Compatibility_Migration_OutputWriter::log(" ($count) ..... DONE<br/>");
    }
示例#17
0
    function createUpdateIncrementBuild(Pap_Common_Banner $childBanner, $column){
        $updateBuild = new Gpf_SqlBuilder_UpdateBuilder();
        $updateBuild->from->add(Pap_Db_Table_BannersInRotators::getName());
        $updateBuild->set->add($column, "$column+1", false);
        $updateBuild->where->add(Pap_Db_Table_BannersInRotators::PARENT_BANNER_ID,'=',$this->getId());
        $updateBuild->where->add(Pap_Db_Table_BannersInRotators::ROTATED_BANNER_ID,'=',$childBanner->getId());

        $c1 = new Gpf_SqlBuilder_CompoundWhereCondition();
        $c1->add(Pap_Db_Table_BannersInRotators::VALID_FROM,'=',null);
        $c1->add(Pap_Db_Table_BannersInRotators::VALID_UNTIL,'=',null);

        $c2 = new Gpf_SqlBuilder_CompoundWhereCondition();
        $c2->add(Pap_Db_Table_BannersInRotators::VALID_FROM,'<',date("Y-m-d H:i:s"));
        $c2->add(Pap_Db_Table_BannersInRotators::VALID_UNTIL,'>',date("Y-m-d H:i:s"));

        $c3 = new Gpf_SqlBuilder_CompoundWhereCondition();
        $c3->add(Pap_Db_Table_BannersInRotators::VALID_FROM,'=',null);
        $c3->add(Pap_Db_Table_BannersInRotators::VALID_UNTIL,'>',date("Y-m-d H:i:s"));

        $c4 = new Gpf_SqlBuilder_CompoundWhereCondition();
        $c4->add(Pap_Db_Table_BannersInRotators::VALID_FROM,'<',date("Y-m-d H:i:s"));
        $c4->add(Pap_Db_Table_BannersInRotators::VALID_UNTIL,'=',null);

        $c = new Gpf_SqlBuilder_CompoundWhereCondition();
        $c->addCondition($c1,'OR');
        $c->addCondition($c2,'OR');
        $c->addCondition($c3,'OR');
        $c->addCondition($c4,'OR');

        $updateBuild->where->addCondition($c,'AND');

        return $updateBuild;
    }
    public function createSampleBanners($campaignId) {
        $banner = new Pap_Common_Banner();
        $banner->setId('11110001');
        $banner->setName('Sample image banner 1');
        $banner->setBannerType(Pap_Common_Banner_Factory::BannerTypeImage);
        $banner->setCampaignId($campaignId);
        $banner->setStatus('A');
        $banner->setDestinationUrl("http://www.qualityunit.com");
        $banner->setSize("P468x60");
        $banner->setData1($this->copyToBannerUploads('sample_image_banner.gif'));
        $banner->setAccountId($this->account->getId());
        $banner->set("dateinserted", Gpf_Common_DateUtils::now());
        $banner->setWrapperId('plain');
        $banner->save();

        $banner = new Pap_Common_Banner();
        $banner->setId('11110002');
        $banner->setName('Sample text link 1');
        $banner->setBannerType(Pap_Common_Banner_Factory::BannerTypeText);
        $banner->setCampaignId($campaignId);
        $banner->setStatus('A');
        $banner->setDestinationUrl("http://www.qualityunit.com");
        $banner->setSize("U");
        $banner->setData1("Click here");
        $banner->setData2("to find out more about this link");
        $banner->set("dateinserted", Gpf_Common_DateUtils::now());
        $banner->setAccountId($this->account->getId());
        $banner->setWrapperId('plain');
        $banner->save();

        $banner = new Pap_Common_Banner();
        $banner->setId('11110003');
        $banner->setName('Sample Flash banner');
        $banner->setBannerType(Pap_Common_Banner_Factory::BannerTypeFlash);
        $banner->setCampaignId($campaignId);
        $banner->setStatus('A');
        $banner->setDestinationUrl("http://www.qualityunit.com");
        $banner->setSize("P468x60");
        $banner->setData1($this->copyToBannerUploads("sample_flash_banner.swf"));
        $banner->setData2("Opaque");
        $banner->set("dateinserted", Gpf_Common_DateUtils::now());
        $banner->setAccountId($this->account->getId());
        $banner->setWrapperId('plain');
        $banner->save();

        $banner = new Pap_Common_Banner();
        $banner->setId('11110004');
        $banner->setName('Sample HTML banner 1');
        $banner->setBannerType(Pap_Common_Banner_Factory::BannerTypeHtml);
        $banner->setCampaignId($campaignId);
        $banner->setStatus('A');
        $banner->setDestinationUrl("http://www.qualityunit.com");
        $banner->setSize("U");
        $banner->setData1('N');
        $banner->setData2('<table width="100%" border="0" cellpadding="3">
            <tr>
              <td align="left" valign="top"><img src="' . $this->copyToBannerUploads('sample_html_banner_image.gif') . '" alt=""/></td>
              <td></td>
              <td align="left" valign="top">
                <b>Post Affiliate Pro</b><br/>

                - a powerful affiliate management system that allows you to:<br/>
                - easy set up and maintain your own affiliate program  <br/>
                - pay your affiliates per lead per click per sale or %commission.<br/>
                - multi-tier commissions: up to 10 tiers<br/>
                - get more traffic for you website without additional costs<br/>
                - increase sales<br/>
                - already used by more than thousand merchants worldwide
                <br/>
              </td>
              </tr>
            <tr>
              <td colspan="3" align="left">
              Post Affiliate Pro offers you a vast spectrum of features and PRICE / FEATURES RATIO IS THE BEST you can find.
              <br/>You also get FREE INSTALLATION, lifetime upgrades and fast and helpful support.<br/><br/>
              <b>Post Affiliate Pro</b> is compatible with nearly all merchant accounts, payment gateways, shopping carts and
              membership systems.
              <br/>
              <a style="color:red;" href="{$targeturl}">Click here to learn more</a>
              </td>
            </tr>
           </table>');
        $banner->set("dateinserted", Gpf_Common_DateUtils::now());
        $banner->setAccountId($this->account->getId());
        $banner->setWrapperId('plain');
        $banner->save();

        $banner = new Pap_Common_Banner();
        $banner->setId('11110005');
        $banner->setName('Sample promotional email');
        $banner->setBannerType(Pap_Common_Banner_Factory::BannerTypePromoEmail);
        $banner->setCampaignId($campaignId);
        $banner->setStatus('A');
        $banner->setDestinationUrl("http://www.qualityunit.com");
        $banner->setSize("U");
        $banner->setData1("New generation affiliate software");
        $banner->setData2('Dear friend,<br><br>I would like to let you know about an affiliate software I recently found.<br>It is called Post Affiliate Pro.<br><br>Go to the link below learn more:<br><a href=\"{$targeturl}\">Post Affiliate Pro</a><br><br>best regards,<br><br>{$firstname} {$lastname}');
        $banner->set("dateinserted", Gpf_Common_DateUtils::now());
        $banner->setAccountId($this->account->getId());
        $banner->setWrapperId('plain');
        $banner->save();

        $banner = new Pap_Common_Banner();
        $banner->setId('11110006');
        $banner->setName('Sample Simple PDF book 1');
        $banner->setBannerType(Pap_Common_Banner_Factory::BannerTypePdf);
        $banner->setCampaignId($campaignId);
        $banner->setStatus('A');
        $banner->setDestinationUrl("http://www.qualityunit.com");
        $banner->setSize("U");
        $banner->setData1("book1.pdf");
        $banner->setData2('<span style="font-weight: bold;">Example Simple PDF book</span><br><br><img src="http://www.qualityunit.com/themes/site_themes/qu/pap/post_affiliate_pro_logo.gif"><br><br>Dear {$firstname} {$lastname},<br><br>let me present you this book.<br><br><ol><li>list 1</li><li>list 2</li><li>list 3</li></ol>To find out more, click <a href="{$targeturl}">here</a>.<br>');
        $banner->setData3('Sample SimplePDF book');
        $banner->set("dateinserted", Gpf_Common_DateUtils::now());
        $banner->setAccountId($this->account->getId());
        $banner->setWrapperId('plain');
        $banner->save();
    }
示例#19
0
	private function getClickParamsArray(Pap_Db_ClickImpression $click, Pap_Contexts_Click $context, Pap_Common_Banner $banner=null) {
	    $columns = array();
	    $columns[Pap_Db_Table_ClicksImpressions::ACCOUNTID] = $context->getAccountId();
        $columns[Pap_Db_Table_ClicksImpressions::USERID] = $context->getUserObject()->getId();
        $columns[Pap_Db_Table_ClicksImpressions::BANNERID] = $banner == null ? '' : $banner->getId();
        $columns[Pap_Db_Table_ClicksImpressions::PARENTBANNERID] = $banner == null ? '' : $banner->getParentBannerId();
        $columns[Pap_Db_Table_ClicksImpressions::CAMPAIGNID] = $context->getCampaignObject() == null ? '' : $context->getCampaignObject()->getId();
        $columns[Pap_Db_Table_ClicksImpressions::COUNTRYCODE] = $context->getCountryCode();
        $columns[Pap_Db_Table_ClicksImpressions::CDATA1] = $context->getExtraDataFromRequest(1);
        $columns[Pap_Db_Table_ClicksImpressions::CDATA2] = $context->getExtraDataFromRequest(2);
        $columns[Pap_Db_Table_ClicksImpressions::CHANNEL] = $this->getChannel($context);
        $timeNow = new Gpf_DateTime($context->getVisitDateTime());
        $columns[Pap_Db_Table_ClicksImpressions::DATEINSERTED] = $timeNow->format("Y-m-d H:00:00");
        return $columns;
	}
示例#20
0
 public function insert() {
     parent::insert();
     $file = new Gpf_Io_File(Gpf_Paths::getInstance()->getAccountDirectoryPath() . Pap_Features_SiteReplication_Replicator::SITES_DIR . $this->getId());
     $file->mkdir();
 }
示例#21
0
}
if ($destUrl == '') {
    $result = $db->query('SELECT value FROM qu_g_settings WHERE name="mainSiteUrl"');
    if ($result) {
        if ($row = mysql_fetch_assoc($result)) {
            $destUrl = $row['value'];
        }
    }
}

require_once 'bootstrap.php';
@include_once('../include/Compiled/Core.php');

Gpf_Session::create(new Pap_Tracking_ModuleBase(), null, false);

$banner = new Pap_Common_Banner();
$user = new Pap_Affiliates_User();
$userId = @$_GET[$settings->get('param_name_user_id')];

try {
    $user = $user->loadFromId($userId);
    $destUrl = $banner->replaceUserConstants($destUrl, $user, 'Y');
} catch (Gpf_Exception $e) {
    $destUrl = $banner->removeUserConstants($destUrl, 'Y');
}
$clickFieldsValues = array();
$clickFieldsValues['chan'] = @$_GET['chan'];
$clickFieldsValues['extra_data1'] = @$_GET[$settings->get('param_name_extra_data1')];
$clickFieldsValues['extra_data2'] = @$_GET[$settings->get('param_name_extra_data2')];

$destUrl = $banner->replaceClickConstants($destUrl, $clickFieldsValues);