/** * Toggle the approval given the supplied flag to toggle. * * @param integer $flag 0 = Pending | 1 = Approved * @return boolean TRUE if successful, FALSE if failure. */ private function adApprovalToggle($flag) { $DomainID = intval($this->params()->fromRoute('param1', 0)); $PublisherAdZoneID = intval($this->params()->fromRoute('id', 0)); if (($this->is_super_admin || $this->is_domain_admin) && $DomainID > 0 && $PublisherAdZoneID > 0 && ($flag === 0 || $flag === 1 || $flag === 2)) { $DomainObj = $this->get_domain_data($DomainID, $this->PublisherInfoID); if ($DomainObj === null) { $error_message = "An invalid publishing web domain was specified for the specified user."; } else { if ($this->is_domain_admin) { if (!\util\AuthHelper::domain_user_authorized_publisher($this->auth->getUserID(), $DomainObj->DomainOwnerID)) { die("Not Authorized"); } } $PublisherAdZoneFactory = \_factory\PublisherAdZone::get_instance(); $AdObject = new \model\PublisherAdZone(); $parameters = array("PublisherWebsiteID" => $DomainObj->PublisherWebsiteID, "PublisherAdZoneID" => $PublisherAdZoneID); $AdObject = $PublisherAdZoneFactory->get_row_object($parameters); if (intval($AdObject->PublisherAdZoneID) == $PublisherAdZoneID) { $AdObject->AutoApprove = 0; $AdObject->AdStatus = intval($flag); if ($PublisherAdZoneFactory->save_ads($AdObject)) { if (($flag == 1 || $flag == 2) && $this->config_handle['mail']['subscribe']['user_zones']) { $PublisherInfoFactory = \_factory\PublisherInfo::get_instance(); $params = array(); $params["PublisherInfoID"] = $DomainObj->DomainOwnerID; $PublisherInfo = $PublisherInfoFactory->get_row($params); if ($PublisherInfo !== null) { // approval, send out email $site_url = $this->config_handle['delivery']['site_url']; $exchange_name = $this->config_handle['delivery']['exchange_name']; if ($flag == 1) { $message = 'Your ' . $exchange_name . ' Publisher Ad Zone for : ' . $DomainObj->WebDomain . ' : ' . $AdObject->AdName . ' was approved.<br /><br />Please login <a href="' . $site_url . '/auth/login">here</a> with your email and password'; $subject = "Your " . $exchange_name . " Publisher Ad Zone for : " . $DomainObj->WebDomain . " was approved"; } else { $message = 'Your ' . $exchange_name . ' Publisher Ad Zone for : ' . $DomainObj->WebDomain . ' : ' . $AdObject->AdName . ' was rejected.<br /><br />Please login <a href="' . $site_url . '/auth/login">here</a> with your email and password'; $subject = "Your " . $exchange_name . " Publisher Ad Zone for : " . $DomainObj->WebDomain . " was rejected"; } $transport = $this->getServiceLocator()->get('mail.transport'); $text = new Mime\Part($message); $text->type = Mime\Mime::TYPE_HTML; $text->charset = 'utf-8'; $mimeMessage = new Mime\Message(); $mimeMessage->setParts(array($text)); $zf_message = new Message(); $zf_message->addTo($PublisherInfo->Email)->addFrom($this->config_handle['mail']['reply-to']['email'], $this->config_handle['mail']['reply-to']['name'])->setSubject($subject)->setBody($mimeMessage); $transport->send($zf_message); } } return TRUE; } } } } return FALSE; }
public function deletewebsiteAction() { $initialized = $this->initialize(); if ($initialized !== true) { return $initialized; } $auth = $this->getServiceLocator()->get('AuthService'); if (!$auth->hasIdentity()) { return $this->redirect()->toRoute('login'); } $success = false; $msg = null; $PublisherWebsiteFactory = \_factory\PublisherWebsite::get_instance(); $PublisherAdZoneFactory = \_factory\PublisherAdZone::get_instance(); $publisher_website_data = null; $request = $this->getRequest(); if ($request->isPost()) { $website_id = intval($request->getPost('website_id')); if ($this->auth->isDomainAdmin($this->config_handle)) { $authorized = \util\AuthHelper::domain_user_authorized_publisher_website($this->auth->getUserID(), $website_id); if ($authorized === true) { $params = array(); $params["PublisherWebsiteID"] = $website_id; $publisher_website_data = $PublisherWebsiteFactory->get_row($params); } } else { $params = array(); $params["PublisherWebsiteID"] = $website_id; $params["DomainOwnerID"] = $this->auth->getPublisherInfoID(); $publisher_website_data = $PublisherWebsiteFactory->get_row($params); } if ($publisher_website_data == null) { $msg = 'Authorization Error.'; } else { $success = true; $PublisherWebsiteFactory->delete_domain($website_id); $params = array(); $params['PublisherWebsiteID'] = $website_id; $PublisherAdZoneList = $PublisherAdZoneFactory->get($params); foreach ($PublisherAdZoneList as $PublisherAdZone) { $PublisherAdZoneFactory->delete_zone(intval($PublisherAdZone->PublisherAdZoneID)); } $msg = '"' . $publisher_website_data->WebDomain . '" removed successfully.'; } } $data = array('success' => $success, 'data' => array('msg' => $msg)); $this->setJsonHeader(); return $this->getResponse()->setContent(json_encode($data)); }
/** * * @return Ambigous <\Zend\View\Model\ViewModel, \Zend\View\Model\ViewModel> */ public function newinsertionorderAction() { $needed_input = array('campaignname', 'startdate', 'enddate', 'maximpressions', 'maxspend'); $initialized = $this->initialize(); if ($initialized !== true) { return $initialized; } $this->validateInput($needed_input); $campaignname = $this->getRequest()->getPost('campaignname'); $startdate = $this->getRequest()->getPost('startdate'); $enddate = $this->getRequest()->getPost('enddate'); $customername = $this->getRequest()->getPost('customername'); $customerid = $this->getRequest()->getPost('customerid'); if (!$customerid) { $customerid = "001"; } $maximpressions = intval($this->getRequest()->getPost('maximpressions')); $maxspend = $this->getRequest()->getPost('maxspend'); $campaignid = $this->getRequest()->getPost('campaignid'); $campaign_preview_id = $this->getRequest()->getPost('campaignpreviewid'); $ispreview = $this->getRequest()->getPost('ispreview'); $px_feeds = $this->getRequest()->getPost('px-feeds'); $pc_feeds = $this->getRequest()->getPost('pc-feeds'); $ssp_feeds = $this->getRequest()->getPost('ssp-feeds'); $pc_feeds = is_array($pc_feeds) ? $pc_feeds : array(); $px_feeds = is_array($px_feeds) ? $px_feeds : array(); $ssp_feeds = is_array($ssp_feeds) ? $ssp_feeds : array(); $exchange_feeds = array_merge($pc_feeds, $px_feeds); // 4 byte max int(11) check if ($maximpressions < 1 || $maximpressions > 2147483647) { $maximpressions = 2147483647; } $InsertionOrderPreview = new \model\InsertionOrderPreview(); if ($campaignid != null && $ispreview != true) { /* * THIS METHOD CHECKS IF THERE IS AN EXISTING PREVIEW MODE CAMPAIGN * IF NOT, IT CHECKS THE ACL PERMISSIONS ON THE PRODUCTION BANNER/CAMPAIGN REFERENCED * THEN IT CREATES A PREVIEW VERSION OF THE AD CAMPAIGN */ $update_data = array('type' => 'InsertionOrderID', 'id' => $campaignid); $return_val = \transformation\TransformPreview::previewCheckInsertionOrderID($campaignid, $this->auth, $this->config_handle, $this->getServiceLocator()->get('mail.transport'), $update_data); if ($return_val !== null) { $campaign_preview_id = $return_val["InsertionOrderPreviewID"]; } $InsertionOrderPreview->InsertionOrderID = $campaignid; } if ($campaign_preview_id != null) { // ACL PREVIEW PERMISSIONS CHECK transformation\CheckPermissions::checkEditPermissionInsertionOrderPreview($campaign_preview_id, $this->auth, $this->config_handle); $InsertionOrderPreview->InsertionOrderPreviewID = $campaign_preview_id; $params = array(); $params["InsertionOrderPreviewID"] = $campaign_preview_id; $InsertionOrderPreviewFactory = \_factory\InsertionOrderPreview::get_instance(); $_InsertionOrderPreview = $InsertionOrderPreviewFactory->get_row($params); $InsertionOrderPreview->InsertionOrderID = $_InsertionOrderPreview->InsertionOrderID; } // else new campaign, ispreview is always true $InsertionOrderPreview->UserID = $this->auth->getEffectiveUserID(); $InsertionOrderPreview->Name = $campaignname; $InsertionOrderPreview->StartDate = date("Y-m-d H:i:s", strtotime($startdate)); $InsertionOrderPreview->EndDate = date("Y-m-d H:i:s", strtotime($enddate)); $InsertionOrderPreview->Customer = $customername; $InsertionOrderPreview->CustomerID = $customerid; $InsertionOrderPreview->ImpressionsCounter = 0; $InsertionOrderPreview->MaxImpressions = $maximpressions; $InsertionOrderPreview->CurrentSpend = 0; $InsertionOrderPreview->MaxSpend = $maxspend; $InsertionOrderPreview->Active = 1; $InsertionOrderPreview->DateCreated = date("Y-m-d H:i:s"); $InsertionOrderPreview->DateUpdated = date("Y-m-d H:i:s"); $InsertionOrderPreview->ChangeWentLive = 0; $InsertionOrderPreview->WentLiveDate = '0000-00-00 00:00:00'; $InsertionOrderPreviewFactory = \_factory\InsertionOrderPreview::get_instance(); $new_campaign_preview_id = $InsertionOrderPreviewFactory->saveInsertionOrderPreview($InsertionOrderPreview); /* * Private Exchange Feeds * * wipe out existing preview data first */ $PmpDealPublisherWebsiteToInsertionOrderPreviewFactory = \_factory\PmpDealPublisherWebsiteToInsertionOrderPreview::get_instance(); $PmpDealPublisherWebsiteToInsertionOrderPreviewFactory->deletePmpDealPublisherWebsiteToInsertionOrderByInsertionOrderPreviewID($new_campaign_preview_id); foreach ($exchange_feeds as $raw_feed_data) { $raw_feed_data = rawurldecode($raw_feed_data); $exchange_feed_data = \util\AuthHelper::parse_feed_id($raw_feed_data); if ($exchange_feed_data === null) { continue; } $exchange_feed_id = intval($exchange_feed_data["id"]); $exchange_feed_description = $exchange_feed_data["description"]; $is_local = false; if (!$this->is_super_admin) { $authorized = \util\AuthHelper::domain_user_authorized_px_publisher_website_passthru($this->config_handle, $this->auth->getUserID(), $exchange_feed_id, $is_local); if (!$authorized) { $viewModel = new ViewModel(array('admin_email' => $this->config_handle['mail']['reply-to']['email'], 'refresh_url' => '/private-exchange/editinsertionorder/' . $new_campaign_preview_id . '?ispreview=true')); return $viewModel->setTemplate('dashboard-manager/demand/creditapp.phtml'); } } else { $ret_val = \util\AuthHelper::domain_user_authorized_publisher_passthru($this->auth->getEffectiveUserID(), $PublisherWebsite->DomainOwnerID); if ($ret_val === true) { $is_local = true; } } $params = array(); $params["PublisherWebsiteID"] = $exchange_feed_id; $_PmpDealPublisherWebsiteToInsertionOrderPreview = $PmpDealPublisherWebsiteToInsertionOrderPreviewFactory->get_row($params); $PmpDealPublisherWebsiteToInsertionOrderPreview = new \model\PmpDealPublisherWebsiteToInsertionOrderPreview(); if ($_PmpDealPublisherWebsiteToInsertionOrderPreview != null) { $PmpDealPublisherWebsiteToInsertionOrderPreview->PmpDealPublisherWebsiteToInsertionOrderPreviewID = $_PmpDealPublisherWebsiteToInsertionOrderPreview->PmpDealPublisherWebsiteToInsertionOrderPreviewID; } $PmpDealPublisherWebsiteToInsertionOrderPreview->PublisherWebsiteID = $exchange_feed_id; $PmpDealPublisherWebsiteToInsertionOrderPreview->PublisherWebsiteLocal = $is_local; $PmpDealPublisherWebsiteToInsertionOrderPreview->PublisherWebsiteDescription = $exchange_feed_description; $PmpDealPublisherWebsiteToInsertionOrderPreview->InsertionOrderPreviewID = $new_campaign_preview_id; $PmpDealPublisherWebsiteToInsertionOrderPreview->Enabled = 1; $PmpDealPublisherWebsiteToInsertionOrderPreviewFactory->savePmpDealPublisherWebsiteToInsertionOrderPreview($PmpDealPublisherWebsiteToInsertionOrderPreview); } /* * SSP RTB Feeds * * wipe out existing preview data first */ $SspRtbChannelToInsertionOrderPreviewFactory = \_factory\SspRtbChannelToInsertionOrderPreview::get_instance(); $SspRtbChannelToInsertionOrderPreviewFactory->deleteSspRtbChannelToInsertionOrderByInsertionOrderPreviewID($new_campaign_preview_id); /* * If they are adding inventory from SSP RTB Channels * make sure they are approved for that */ if (!$this->is_super_admin && count($ssp_feeds) >= 1) { if (!\util\CreditHelper::wasApprovedForSspRtbInventoryAuthUserID($this->auth->getUserID())) { $viewModel = new ViewModel(array('admin_email' => $this->config_handle['mail']['reply-to']['email'], 'refresh_url' => '/private-exchange/editinsertionorder/' . $new_campaign_preview_id . '?ispreview=true')); return $viewModel->setTemplate('dashboard-manager/demand/creditapp.phtml'); } } foreach ($ssp_feeds as $raw_feed_data) { $raw_feed_data = rawurldecode($raw_feed_data); $ssp_feed_data = \util\AuthHelper::parse_feed_id($raw_feed_data); if ($ssp_feed_data === null) { continue; } $ssp_feed_id = $ssp_feed_data["id"]; $ssp_exchange = $ssp_feed_data["exchange"]; $ssp_feed_id = str_replace('__COLON__', ':', $ssp_feed_id); $ssp_exchange = str_replace('__COLON__', ':', $ssp_exchange); $ssp_feed_description = $ssp_feed_data["description"]; if (!$this->is_super_admin) { $authorized = \util\AuthHelper::domain_user_authorized_ssp_passthru($this->auth->getUserID(), $ssp_feed_id); if (!$authorized) { die("You are not authorized to add inventory from SSP RTB Channel: " . $ssp_feed_id . ' - ' . $ssp_feed_description . " <br />Please contact an administrator for more information."); } } $params = array(); $params["SspPublisherChannelID"] = $ssp_feed_id; $_SspRtbChannelToInsertionOrderPreview = $SspRtbChannelToInsertionOrderPreviewFactory->get_row($params); $SspRtbChannelToInsertionOrderPreview = new \model\SspRtbChannelToInsertionOrderPreview(); if ($_SspRtbChannelToInsertionOrderPreview != null) { $SspRtbChannelToInsertionOrderPreview->SspRtbChannelToInsertionOrderPreviewID = $_SspRtbChannelToInsertionOrderPreview->SspRtbChannelToInsertionOrderPreviewID; } $SspRtbChannelToInsertionOrderPreview->SspPublisherChannelID = $ssp_feed_id; $SspRtbChannelToInsertionOrderPreview->SspPublisherChannelDescription = $ssp_feed_description; $SspRtbChannelToInsertionOrderPreview->SspExchange = $ssp_exchange; $SspRtbChannelToInsertionOrderPreview->InsertionOrderPreviewID = $new_campaign_preview_id; $SspRtbChannelToInsertionOrderPreview->Enabled = 1; $SspRtbChannelToInsertionOrderPreviewFactory->saveSspRtbChannelToInsertionOrderPreview($SspRtbChannelToInsertionOrderPreview); } if (!$this->is_super_admin && $this->config_handle['mail']['subscribe']['campaigns'] === true) { // if this ad campaign was not created/edited by the admin, then send out a notification email $message = '<b>NginAd Insertion Order Added/Updated by ' . $this->true_user_name . '.</b><br /><br />'; $message = $message . '<table border="0" width="10%">'; $message = $message . '<tr><td><b>InsertionOrderID: </b></td><td>' . $new_campaign_preview_id . '</td></tr>'; $message = $message . '<tr><td><b>UserID: </b></td><td>' . $InsertionOrderPreview->UserID . '</td></tr>'; $message = $message . '<tr><td><b>Name: </b></td><td>' . $InsertionOrderPreview->Name . '</td></tr>'; $message = $message . '<tr><td><b>StartDate: </b></td><td>' . $InsertionOrderPreview->StartDate . '</td></tr>'; $message = $message . '<tr><td><b>EndDate: </b></td><td>' . $InsertionOrderPreview->EndDate . '</td></tr>'; $message = $message . '<tr><td><b>Customer: </b></td><td>' . $InsertionOrderPreview->Customer . '</td></tr>'; $message = $message . '<tr><td><b>CustomerID: </b></td><td>' . $InsertionOrderPreview->CustomerID . '</td></tr>'; $message = $message . '<tr><td><b>MaxImpressions: </b></td><td>' . $InsertionOrderPreview->MaxImpressions . '</td></tr>'; $message = $message . '<tr><td><b>MaxSpend: </b></td><td>' . $InsertionOrderPreview->MaxSpend . '</td></tr>'; $message = $message . '</table>'; $subject = "NginAd Insertion Order Added/Updated by " . $this->true_user_name; $transport = $this->getServiceLocator()->get('mail.transport'); $text = new Mime\Part($message); $text->type = Mime\Mime::TYPE_HTML; $text->charset = 'utf-8'; $mimeMessage = new Mime\Message(); $mimeMessage->setParts(array($text)); $zf_message = new Message(); $zf_message->addTo($this->config_handle['mail']['admin-email']['email'], $this->config_handle['mail']['admin-email']['name'])->addFrom($this->config_handle['mail']['reply-to']['email'], $this->config_handle['mail']['reply-to']['name'])->setSubject($subject)->setBody($mimeMessage); $transport->send($zf_message); } $refresh_url = "/private-exchange/?ispreview=true"; $viewModel = new ViewModel(array('refresh_url' => $refresh_url)); return $viewModel->setTemplate('dashboard-manager/demand/interstitial.phtml'); }
public static function domain_user_authorized_publisher_website($parent_id, $publisher_website_id) { $PublisherWebsiteFactory = \_factory\PublisherWebsite::get_instance(); $params = array(); $params["PublisherWebsiteID"] = $publisher_website_id; $PublisherWebsite = $PublisherWebsiteFactory->get_row($params); if (!\util\AuthHelper::domain_user_authorized_publisher($parent_id, $PublisherWebsite->DomainOwnerID)) { die("You are not authorized to perform this action: CODE 101"); } return true; }
public function pxlistAction() { $initialized = $this->initialize(); if ($initialized !== true) { return $initialized; } if (!$this->auth->hasIdentity()) { return $this->redirect()->toRoute('login'); } elseif (!$this->is_domain_admin) { return $this->redirect()->toRoute('publisher'); } $publisher_id = intval($this->params()->fromRoute('param1', 0)); $PublisherInfoFactory = \_factory\PublisherInfo::get_instance(); $params = array(); $params["PublisherInfoID"] = $publisher_id; $PublisherInfo = $PublisherInfoFactory->get_row($params); if (!$PublisherInfo) { die("Publisher Not Found: CODE 103"); } $authUsersFactory = \_factory\authUsers::get_instance(); $params = array(); $params["PublisherInfoID"] = $PublisherInfo->PublisherInfoID; $authUserChild = $authUsersFactory->get_row($params); if (!$authUserChild) { die("Publisher Not Found: CODE 104"); } if (!\util\AuthHelper::domain_user_authorized($this->auth->getUserID(), $authUserChild->user_id)) { die("Not Authorized: CODE 105"); } $PublisherWebsiteFactory = \_factory\PublisherWebsite::get_instance(); $orders = 'DateCreated DESC'; $params = array(); $params["DomainOwnerID"] = $PublisherInfo->PublisherInfoID; $pending_list = $PublisherWebsiteFactory->get($params, $orders); $view = new ViewModel(array('dashboard_view' => 'account', 'pending_list' => $pending_list, 'PublisherInfoFactory' => $PublisherInfoFactory, 'vertical_map' => \util\DeliveryFilterOptions::$vertical_map, 'user_id_list' => $this->user_id_list, 'user_identity' => $this->identity(), 'true_user_name' => $this->auth->getUserName(), 'header_title' => 'Private Exchange Publisher Websites', 'is_domain_admin' => $this->is_domain_admin, 'effective_id' => $this->auth->getEffectiveIdentityID(), 'impersonate_id' => $this->ImpersonateID)); return $view; }
public function loginAction() { return \util\AuthHelper::login($this); }
/** * Get the user's (identity object) ID that is to be used, * impersonated or real, depending on mode specified prior * or during the session. NULL will be returned ONLY if no user * is logged in. * * @return integer|NULL Returns the current active/selected user ID. */ public function getEffectiveUserID() { if ($this->debug && $this->debug_verbose) { echo "\n<div style=\"font-size: 75%;\"><a style=\"font-weight: bold;\">Attempting Impersonation to User ID:</a> " . $this->ImpersonateIdentityID . "</div>\n"; } if ($this->AdminRoleSuperAdmin && $this->ImpersonateIdentityID != null && $this->ImpersonateIdentityID != 0) { if ($this->debug) { echo "\n<div style=\"font-weight: bold; font-size: 75%;\">Impersonated User ID: " . $this->ImpersonateIdentityID . "</div>\n"; } return $this->ImpersonateIdentityID; } elseif ($this->AdminRoleDomainAdmin && $this->ImpersonateIdentityID != null && $this->ImpersonateIdentityID != 0) { if ($this->debug) { echo "\n<div style=\"font-weight: bold; font-size: 75%;\">Impersonated User ID: " . $this->ImpersonateIdentityID . "</div>\n"; } if (\util\AuthHelper::domain_user_authorized($this->TrueIdentityID, $this->ImpersonateIdentityID)) { return $this->ImpersonateIdentityID; } } else { if ($this->debug && $this->debug_verbose) { echo "\n<div style=\"font-size: 75%;\"><a style=\"font-weight: bold;\">Impersonation FAILED!</a></div>\n"; } return $this->TrueIdentityID; } }
/** * * @return Ambigous <\Zend\Http\Response, \Zend\Stdlib\ResponseInterface> */ public function changeprivateexchangedomainmarkupAction() { $initialized = $this->initialize(); if ($initialized !== true) { return $initialized; } if ($this->is_super_admin == false && $this->is_domain_admin == false) { die("You do not have permission to access this page"); } $publisher_website_id = $this->getRequest()->getQuery('markupdomainid'); $publisher_website_markup = $this->getRequest()->getQuery('private-exchange-domain-markup'); if ($this->is_super_admin == false && !\util\AuthHelper::domain_user_authorized_publisher_website($this->auth->getUserID(), $publisher_website_id)) { die("You are not authorized to perform this action: CODE 101"); } $PrivateExchangePublisherWebsiteMarkupFactory = \_factory\PrivateExchangePublisherWebsiteMarkup::get_instance(); $params = array(); $params["PublisherWebsiteID"] = $publisher_website_id; $PrivateExchangePublisherWebsiteMarkup = $PrivateExchangePublisherWebsiteMarkupFactory->get_row($params); $publisher_website_markup = floatval($publisher_website_markup) / 100; if ($publisher_website_markup <= 0) { die("Domain Markup can not be less than or equal to zero percent"); } if ($publisher_website_markup >= 1) { die("Domain Markup can not be greater than or equal to one hundred percent"); } $publisher_website_markup = sprintf("%1.2f", $publisher_website_markup); $_PrivateExchangePublisherWebsiteMarkup = new \model\PrivateExchangePublisherWebsiteMarkup(); $_PrivateExchangePublisherWebsiteMarkup->PublisherWebsiteID = $publisher_website_id; $_PrivateExchangePublisherWebsiteMarkup->MarkupRate = $publisher_website_markup; if ($PrivateExchangePublisherWebsiteMarkup != null) { $PrivateExchangePublisherWebsiteMarkupFactory->updatePrivateExchangePublisherWebsiteMarkup($_PrivateExchangePublisherWebsiteMarkup); } else { $PrivateExchangePublisherWebsiteMarkupFactory->insertPrivateExchangePublisherWebsiteMarkup($_PrivateExchangePublisherWebsiteMarkup); } if ($this->is_domain_admin) { return $this->redirect()->toRoute('pxpublishers'); } else { return $this->redirect()->toRoute('publisher'); } }