Esempio n. 1
0
 /**
  * A method to perform redirects. Only suitable for use once OpenX is installed,
  * as it requires the OpenX configuration file to be correctly set up.
  *
  * @param string  $adminPage           The administration interface page to redirect to
  *                                     (excluding a leading slash ("/")). Default is the
  *                                     index (i.e. login) page.
  * @param boolean $manualAccountSwitch Flag to know if the user has switched account.
  * @param boolean $redirectTopLevel    Flag to know if the redirection should be to the top
  *                                     level, even it not a manual account switch.
  */
 function redirect($adminPage = 'index.php', $manualAccountSwitch = false, $redirectTopLevel = false)
 {
     if ($manualAccountSwitch || $redirectTopLevel) {
         // Get the page where the user was in when switched account
         if (!empty($_SERVER['HTTP_REFERER'])) {
             $aUrlComponents = parse_url($_SERVER['HTTP_REFERER']);
         } elseif (!empty($_SERVER['REQUEST_URI'])) {
             $aUrlComponents = parse_url($_SERVER['REQUEST_URI']);
         }
         $aPathInformation = pathinfo($aUrlComponents['path']);
         $sectionID = $aPathInformation['filename'];
         // Get the top level page
         $adminPage = OA_Admin_UI::getTopLevelPage($sectionID);
         if (!empty($adminPage)) {
             header('Location: ' . MAX::constructURL(MAX_URL_ADMIN, $adminPage));
             exit;
         }
     }
     if (!$manualAccountSwitch || empty($return_url) && empty($GLOBALS['installing'])) {
         if (!preg_match('/[\\r\\n]/', $adminPage)) {
             header('Location: ' . MAX::constructURL(MAX_URL_ADMIN, $adminPage));
             exit;
         }
     }
     exit;
 }
 /**
  * A static method to display a login screen
  *
  * @static
  *
  * @param string $sMessage
  * @param string $sessionID
  * @param bool $inlineLogin
  */
 function displayLogin($sMessage = '', $sessionID = 0, $inLineLogin = false)
 {
     global $strUsername, $strPassword, $strLogin, $strWelcomeTo, $strEnterUsername, $strNoAdminInteface, $strForgotPassword;
     $aConf = $GLOBALS['_MAX']['CONF'];
     $aPref = $GLOBALS['_MAX']['PREF'];
     @header('Cache-Control: max-age=0, no-cache, proxy-revalidate, must-revalidate');
     if (!$inLineLogin) {
         phpAds_PageHeader(phpAds_Login);
     }
     // Check environment settings
     $oSystemMgr = new OA_Environment_Manager();
     $aSysInfo = $oSystemMgr->checkSystem();
     foreach ($aSysInfo as $env => $vals) {
         $errDetails = '';
         if (is_array($vals['error']) && !empty($vals['error'])) {
             if ($env == 'PERMS') {
                 // Just note that some file/folders are unwritable and that more information can be found in the debug.log
                 OA_Admin_UI::queueMessage('Error: File permission errors detected.<br />These <em>may</em> impact the accurate delivery of your ads,<br />See the debug.log file for the list of unwritable files', 'global', 'error', 0);
             } else {
                 foreach ($vals['error'] as $key => $val) {
                     $errDetails .= '<li>' . htmlspecialchars($key) . ' &nbsp; => &nbsp; ' . htmlspecialchars($val) . '</li>';
                 }
                 phpAds_Die(' Error: ' . $err, $errDetails);
             }
         }
     }
     $oTpl = new OA_Admin_Template('login.html');
     $appName = !empty($aConf['ui']['applicationName']) ? $aConf['ui']['applicationName'] : PRODUCT_NAME;
     $oTpl->assign('uiEnabled', $aConf['ui']['enabled']);
     $oTpl->assign('sessionID', $sessionID);
     $oTpl->assign('appName', $appName);
     $oTpl->assign('message', $sMessage);
     $oTpl->display();
     phpAds_PageFooter();
     exit;
 }
 /**
  * Process input from user and creates/upgrades DB etc....
  *
  * @param OA_Admin_UI_Component_Form $oForm
  * @param OX_Admin_UI_Install_Wizard $oWizard
  */
 protected function processDatabaseAction($oForm, $oWizard)
 {
     $oUpgrader = $this->getUpgrader();
     $upgraderSuccess = false;
     $aDbConfig = $oForm->populateDbConfig();
     if ($oUpgrader->canUpgradeOrInstall()) {
         $installStatus = $oUpgrader->existing_installation_status;
         define('DISABLE_ALL_EMAILS', 1);
         OA_Permission::switchToSystemProcessUser('Installer');
         if ($installStatus == OA_STATUS_NOT_INSTALLED) {
             if ($oUpgrader->install($aDbConfig)) {
                 $message = $GLOBALS['strDBInstallSuccess'];
                 $upgraderSuccess = true;
             }
         } else {
             if ($oUpgrader->upgrade($oUpgrader->package_file)) {
                 // Timezone support - hack
                 if ($oUpgrader->versionInitialSchema['tables_core'] < 538 && empty($aDbConfig['noTzAlert'])) {
                     OA_Dal_ApplicationVariables::set('utc_update', OA::getNowUTC());
                 }
                 // Clear the menu cache to built a new one with the new settings
                 OA_Admin_Menu::_clearCache(OA_ACCOUNT_ADMIN);
                 OA_Admin_Menu::_clearCache(OA_ACCOUNT_MANAGER);
                 OA_Admin_Menu::_clearCache(OA_ACCOUNT_ADVERTISER);
                 OA_Admin_Menu::_clearCache(OA_ACCOUNT_TRAFFICKER);
                 OA_Admin_Menu::singleton();
                 $message = $GLOBALS['strDBUpgradeSuccess'];
                 $upgraderSuccess = true;
             }
         }
         OA_Permission::switchToSystemProcessUser();
         //get back to normal user previously logged in
     } else {
         if ($oUpgrader->existing_installation_status == OA_STATUS_CURRENT_VERSION) {
             $upgraderSuccess = true;
             //rare but can occur if DB has been installed and user revisits the screen
         }
     }
     $dbSuccess = $upgraderSuccess && !$oUpgrader->oLogger->errorExists;
     if ($dbSuccess) {
         //show success status
         OA_Admin_UI::getInstance()->queueMessage($message, 'global', 'info');
     } else {
         //sth went wrong, display messages from upgrader
         $aMessages = OX_Admin_UI_Install_InstallUtils::getMessagesWithType($oUpgrader->getMessages());
         $this->setModelProperty('aMessages', $aMessages);
     }
     return $dbSuccess;
 }
Esempio n. 4
0
 /**
  * A method to switch the active account to a different one
  *
  * @static
  * @param int $accountId
  * @param boolean $hasAccess  Can be used for optimization - if we know that user
  *                            has access to the account he is switching to there is
  *                            no need to check it again
  */
 public static function switchAccount($accountId, $hasAccess = false)
 {
     if ($hasAccess || self::hasAccess($accountId)) {
         $oUser =& self::getCurrentUser();
         $oUser->loadAccountData($accountId);
     }
     // Force session save
     phpAds_SessionDataRegister('user', $oUser);
     // If exists previous message related to switchAccount remove it
     OA_Admin_UI::removeOneMessage('switchAccount');
     // Queue confirmation message
     $translation = new OX_Translation();
     $translated_message = $translation->translate($GLOBALS['strYouAreNowWorkingAsX'], array(htmlspecialchars($oUser->aAccount['account_name'])));
     OA_Admin_UI::queueMessage($translated_message, 'global', 'info', null, 'switchAccount');
 }
function processForm($aAdvertiser, $form)
{
    $aFields = $form->exportValues();
    // Name
    if (OA_Permission::isAccount(OA_ACCOUNT_MANAGER)) {
        $aAdvertiser['clientname'] = $aFields['clientname'];
    }
    // Default fields
    $aAdvertiser['contact'] = $aFields['contact'];
    $aAdvertiser['email'] = $aFields['email'];
    $aAdvertiser['comments'] = $aFields['comments'];
    // Same advertiser limitation
    $aAdvertiser['advertiser_limitation'] = $aFields['advertiser_limitation'] == '1' ? 1 : 0;
    // Reports
    $aAdvertiser['report'] = $aFields['report'] == 't' ? 't' : 'f';
    $aAdvertiser['reportdeactivate'] = $aFields['reportdeactivate'] == 't' ? 't' : 'f';
    $aAdvertiser['reportinterval'] = (int) $aFields['reportinterval'];
    if ($aAdvertiser['reportinterval'] == 0) {
        $aAdvertiser['reportinterval'] = 1;
    }
    if ($aFields['reportlastdate'] == '' || $aFields['reportlastdate'] == '0000-00-00' || $aFields['reportprevious'] != $aAdvertiser['report']) {
        $aAdvertiser['reportlastdate'] = date("Y-m-d");
    }
    if (empty($aAdvertiser['clientid'])) {
        // Set agency ID
        $aAdvertiser['agencyid'] = OA_Permission::getAgencyId();
        $doClients = OA_Dal::factoryDO('clients');
        $doClients->setFrom($aAdvertiser);
        $doClients->updated = OA::getNow();
        // Insert
        $aAdvertiser['clientid'] = $doClients->insert();
        // Queue confirmation message
        $translation = new OX_Translation();
        $translated_message = $translation->translate($GLOBALS['strAdvertiserHasBeenAdded'], array(MAX::constructURL(MAX_URL_ADMIN, 'advertiser-edit.php?clientid=' . $aAdvertiser['clientid']), htmlspecialchars($aAdvertiser['clientname']), MAX::constructURL(MAX_URL_ADMIN, 'campaign-edit.php?clientid=' . $aAdvertiser['clientid'])));
        OA_Admin_UI::queueMessage($translated_message, 'local', 'confirm', 0);
        // Go to next page
        OX_Admin_Redirect::redirect("advertiser-index.php");
    } else {
        $doClients = OA_Dal::factoryDO('clients');
        $doClients->get($aAdvertiser['clientid']);
        $doClients->setFrom($aAdvertiser);
        $doClients->updated = OA::getNow();
        $doClients->update();
        // Queue confirmation message
        $translation = new OX_Translation();
        $translated_message = $translation->translate($GLOBALS['strAdvertiserHasBeenUpdated'], array(MAX::constructURL(MAX_URL_ADMIN, 'advertiser-edit.php?clientid=' . $aAdvertiser['clientid']), htmlspecialchars($aAdvertiser['clientname'])));
        OA_Admin_UI::queueMessage($translated_message, 'local', 'confirm', 0);
        OX_Admin_Redirect::redirect('advertiser-edit.php?clientid=' . $aAdvertiser['clientid']);
    }
    exit;
}
 /**
  * A static method to display a login screen
  *
  * @static
  *
  * @param string $sMessage
  * @param string $sessionID
  * @param bool $inlineLogin
  */
 function displayLogin($sMessage = '', $sessionID = 0, $inLineLogin = false)
 {
     global $strUsername, $strPassword, $strLogin, $strWelcomeTo, $strEnterUsername, $strNoAdminInteface, $strForgotPassword;
     $aConf = $GLOBALS['_MAX']['CONF'];
     $aPref = $GLOBALS['_MAX']['PREF'];
     @header('Cache-Control: max-age=0, no-cache, proxy-revalidate, must-revalidate');
     if (!$inLineLogin) {
         phpAds_PageHeader(phpAds_Login);
     }
     // Check environment settings
     $oSystemMgr = new OA_Environment_Manager();
     $aSysInfo = $oSystemMgr->checkSystem();
     foreach ($aSysInfo as $env => $vals) {
         $errDetails = '';
         if (is_array($vals['error']) && !empty($vals['error'])) {
             if ($env == 'PERMS') {
                 // Just note that some file/folders are unwritable and that more information can be found in the debug.log
                 OA_Admin_UI::queueMessage('Error: File permission errors detected.<br />These <em>may</em> impact the accurate delivery of your ads,<br />See the debug.log file for the list of unwritable files', 'global', 'error', 0);
             } else {
                 foreach ($vals['error'] as $key => $val) {
                     $errDetails .= '<li>' . htmlspecialchars($key) . ' &nbsp; => &nbsp; ' . htmlspecialchars($val) . '</li>';
                 }
                 phpAds_Die(' Error: ' . $err, $errDetails);
             }
         }
     }
     $oTpl = new OA_Admin_Template('login.html');
     // we build the URL of the current page to use a redirect URL after login
     // this code should work on all server configurations hence why it is a bit complicated
     // inspired by http://dev.piwik.org/svn/trunk/core/Url.php getCurrentUrl()
     $url = '';
     if (!empty($_SERVER['PATH_INFO'])) {
         $url = $_SERVER['PATH_INFO'];
     } else {
         if (!empty($_SERVER['REQUEST_URI'])) {
             if (($pos = strpos($_SERVER['REQUEST_URI'], "?")) !== false) {
                 $url = substr($_SERVER['REQUEST_URI'], 0, $pos);
             } else {
                 $url = $_SERVER['REQUEST_URI'];
             }
         }
     }
     if (empty($url)) {
         $url = $_SERVER['SCRIPT_NAME'];
     }
     if (!empty($_SERVER['QUERY_STRING'])) {
         $url .= '?' . $_SERVER['QUERY_STRING'];
     }
     if (!empty($url)) {
         // remove any extra slashes that would confuse the browser (see OX-5234)
         $url = '/' . ltrim($url, '/');
     }
     $appName = !empty($aConf['ui']['applicationName']) ? $aConf['ui']['applicationName'] : MAX_PRODUCT_NAME;
     $oTpl->assign('uiEnabled', $aConf['ui']['enabled']);
     $oTpl->assign('formAction', $url);
     $oTpl->assign('sessionID', $sessionID);
     $oTpl->assign('appName', $appName);
     $oTpl->assign('message', $sMessage);
     $oTpl->display();
     phpAds_PageFooter();
     exit;
 }
        }
    }
    if (!count($aErrormessage) && $changePassword) {
        $result = $oPlugin->changePassword($doUsers, $pw, $pwold);
        if (PEAR::isError($result)) {
            $aErrormessage[0][] = $result->getMessage();
        }
    }
    if (!count($aErrormessage)) {
        if ($doUsers->update() === false) {
            // Unable to update the preferences
            $aErrormessage[0][] = $strUnableToWritePrefs;
        } else {
            $translation = new OX_Translation();
            $translated_message = $translation->translate($GLOBALS['strPasswordChanged']);
            OA_Admin_UI::queueMessage($translated_message, 'local', 'confirm', 0);
            // The "preferences" were written correctly saved to the database,
            // go to the "next" preferences page from here
            OX_Admin_Redirect::redirect(basename($_SERVER['SCRIPT_NAME']));
        }
    }
}
// Set the correct section of the preference pages and display the drop-down menu
$prefSection = "password";
$setPref = $oOptions->getSettingsPreferences($prefSection);
$title = $setPref[$prefSection]['name'];
// Display the settings page's header and sections
$oHeaderModel = new OA_Admin_UI_Model_PageHeaderModel($title);
phpAds_PageHeader('account-user-index', $oHeaderModel);
// Get the current logged in user details
$oUser = OA_Permission::getCurrentUser();
Esempio n. 8
0
function processForm($form)
{
    $aFields = $form->exportValues();
    if (empty($aFields['affiliateid'])) {
        $aFields['affiliateid'] = 0;
    }
    if ($aFields['channelid']) {
        $doChannel = OA_Dal::factoryDO('channel');
        $doChannel->get($aFields['channelid']);
        $doChannel->name = $aFields['name'];
        $doChannel->description = $aFields['description'];
        $doChannel->comments = $aFields['comments'];
        $ret = $doChannel->update();
        // Queue confirmation message
        $translation = new OX_Translation();
        $channelURL = "channel-edit.php?" . (empty($aFields['affiliateid']) ? "agencyid=" . $aFields['agencyid'] . "&channelid=" . $aFields['channelid'] : "affiliateid=" . $aFields['affiliateid'] . "&channelid=" . $aFields['channelid']);
        $translated_message = $translation->translate($GLOBALS['strChannelHasBeenUpdated'], array(MAX::constructURL(MAX_URL_ADMIN, $channelURL), htmlspecialchars($aFields['name'])));
        OA_Admin_UI::queueMessage($translated_message, 'local', 'confirm', 0);
        if (!empty($aFields['affiliateid'])) {
            header("Location: channel-edit.php?affiliateid=" . $aFields['affiliateid'] . "&channelid=" . $aFields['channelid']);
        } else {
            header("Location: channel-edit.php?agencyid=" . $aFields['agencyid'] . "&channelid=" . $aFields['channelid']);
        }
        exit;
    } else {
        $doChannel = OA_Dal::factoryDO('channel');
        $doChannel->agencyid = $aFields['agencyid'];
        $doChannel->affiliateid = $aFields['affiliateid'];
        $doChannel->name = $aFields['name'];
        $doChannel->description = $aFields['description'];
        $doChannel->comments = $aFields['comments'];
        $doChannel->compiledlimitation = 'true';
        $doChannel->acl_plugins = 'true';
        $doChannel->active = 1;
        $aFields['channelid'] = $doChannel->insert();
        // Queue confirmation message
        $translation = new OX_Translation();
        $translated_message = $translation->translate($GLOBALS['strChannelHasBeenAdded'], array(MAX::constructURL(MAX_URL_ADMIN, 'channel-edit.php?affiliateid=' . $aFields['affiliateid'] . '&channelid=' . $aFields['channelid']), htmlspecialchars($aFields['name']), MAX::constructURL(MAX_URL_ADMIN, 'channel-acl.php?affiliateid=' . $aFields['affiliateid'] . '&channelid=' . $aFields['channelid'])));
        OA_Admin_UI::queueMessage($translated_message, 'local', 'confirm', 0);
        if (!empty($aFields['affiliateid'])) {
            OX_Admin_Redirect::redirect("affiliate-channels.php?affiliateid=" . $aFields['affiliateid']);
        } else {
            OX_Admin_Redirect::redirect("channel-index.php");
        }
    }
}
Esempio n. 9
0
/**
 * Processes submit values of zone form
 *
 * @param OA_Admin_UI_Component_Form $form form to process
 * @return An array of Pear::Error objects if any
 */
function processForm($form)
{
    $aFields = $form->exportValues();
    switch ($aFields['delivery']) {
        case phpAds_ZoneText:
            $aFields['width'] = $aFields['height'] = 0;
            break;
        case OX_ZoneVideoOverlay:
            $aFields['width'] = $aFields['height'] = -2;
            break;
        case OX_ZoneVideoInstream:
            $aFields['width'] = $aFields['height'] = -3;
            break;
        default:
            if ($aFields['sizetype'] == 'custom') {
                if (isset($aFields['width']) && $aFields['width'] == '*') {
                    $aFields['width'] = -1;
                }
                if (isset($aFields['height']) && $aFields['height'] == '*') {
                    $aFields['height'] = -1;
                }
            } else {
                list($aFields['width'], $aFields['height']) = explode('x', $aFields['size']);
            }
            break;
    }
    if (!is_numeric($aFields['oac_category_id']) || $aFields['oac_category_id'] <= 0) {
        $aFields['oac_category_id'] = 'NULL';
    }
    if (empty($errors)) {
        // Edit
        if (!empty($aFields['zoneid'])) {
            // before we commit any changes to db, store whether the size has changed
            $aZone = Admin_DA::getZone($aFields['zoneid']);
            $size_changed = $aFields['width'] != $aZone['width'] || $aFields['height'] != $aZone['height'] ? true : false;
            $type_changed = $aFields['delivery'] != $aZone['delivery'] ? true : false;
            $doZones = OA_Dal::factoryDO('zones');
            $doZones->zonename = $aFields['zonename'];
            $doZones->description = $aFields['description'];
            $doZones->width = $aFields['width'];
            $doZones->height = $aFields['height'];
            $doZones->comments = $aFields['comments'];
            $doZones->delivery = $aFields['delivery'];
            if ($aFields['delivery'] != phpAds_ZoneText && $aFields['delivery'] != phpAds_ZoneBanner) {
                $doZones->append = '';
            }
            if ($aFields['delivery'] != phpAds_ZoneText) {
                $doZones->prepend = '';
            }
            $doZones->oac_category_id = $aFields['oac_category_id'];
            $doZones->zoneid = $aFields['zoneid'];
            $doZones->update();
            // Ad  Networks
            $doPublisher = OA_Dal::factoryDO('affiliates');
            $doPublisher->get($aFields['affiliateid']);
            $anWebsiteId = $doPublisher->as_website_id;
            if ($anWebsiteId) {
                $oAdNetworks = new OA_Central_AdNetworks();
                $doZones->get($aFields['zoneid']);
                $oAdNetworks->updateZone($doZones, $anWebsiteId);
            }
            // Reset append codes which called this zone
            $doZones = OA_Dal::factoryDO('zones');
            $doZones->appendtype = phpAds_ZoneAppendZone;
            if (OA_Permission::isAccount(OA_ACCOUNT_MANAGER)) {
                $doZones->addReferenceFilter('agency', OA_Permission::getEntityId());
            } elseif (OA_Permission::isAccount(OA_ACCOUNT_TRAFFICKER)) {
                $doZones->addReferenceFilter('affiliates', OA_Permission::getEntityId());
            }
            $doZones->find();
            while ($doZones->fetch() && ($row = $doZones->toArray())) {
                $append = phpAds_ZoneParseAppendCode($row['append']);
                if ($append[0]['zoneid'] == $aFields['zoneid']) {
                    $doZonesClone = clone $doZones;
                    $doZonesClone->appendtype = phpAds_ZoneAppendRaw;
                    $doZonesClone->append = '';
                    $doZonesClone->update();
                }
            }
            if ($type_changed && $aFields['delivery'] == MAX_ZoneEmail) {
                // Unlink all campaigns/banners linked to this zone
                $aPlacementZones = Admin_DA::getPlacementZones(array('zone_id' => $aFields['zoneid']), true, 'placement_id');
                if (!empty($aPlacementZones)) {
                    foreach ($aPlacementZones as $placementId => $aPlacementZone) {
                        Admin_DA::deletePlacementZones(array('zone_id' => $aFields['zoneid'], 'placement_id' => $placementId));
                    }
                }
                $aAdZones = Admin_DA::getAdZones(array('zone_id' => $aFields['zoneid']), false, 'ad_id');
                if (!empty($aAdZones)) {
                    foreach ($aAdZones as $adId => $aAdZone) {
                        Admin_DA::deleteAdZones(array('zone_id' => $aFields['zoneid'], 'ad_id' => $adId));
                    }
                }
            } else {
                if ($size_changed) {
                    $aZone = Admin_DA::getZone($aFields['zoneid']);
                    // Loop through all appended banners and make sure that they still fit...
                    $aAds = Admin_DA::getAdZones(array('zone_id' => $aFields['zoneid']), false, 'ad_id');
                    if (!empty($aAds)) {
                        foreach ($aAds as $adId => $aAd) {
                            $aAd = Admin_DA::getAd($adId);
                            if ($aZone['type'] == phpAds_ZoneText && $aAd['type'] != 'txt' || $aAd['width'] != $aZone['width'] && $aZone['width'] > -1 || $aAd['height'] != $aZone['height'] && $aZone['height'] > -1) {
                                Admin_DA::deleteAdZones(array('zone_id' => $aFields['zoneid'], 'ad_id' => $adId));
                            }
                        }
                    }
                    // Check if any campaigns linked to this zone have ads that now fit.
                    // If so, link them to the zone.
                    $aPlacementZones = Admin_DA::getPlacementZones(array('zone_id' => $aFields['zoneid']), true);
                    if (!empty($aPlacementZones)) {
                        foreach ($aPlacementZones as $aPlacementZone) {
                            // get ads in this campaign
                            $aAds = Admin_DA::getAds(array('placement_id' => $aPlacementZone['placement_id']), true);
                            foreach ($aAds as $adId => $aAd) {
                                Admin_DA::addAdZone(array('zone_id' => $aFields['zoneid'], 'ad_id' => $adId));
                            }
                        }
                    }
                }
            }
            // Queue confirmation message
            $translation = new OX_Translation();
            $translated_message = $translation->translate($GLOBALS['strZoneHasBeenUpdated'], array(MAX::constructURL(MAX_URL_ADMIN, "zone-edit.php?affiliateid=" . $aFields['affiliateid'] . "&zoneid=" . $aFields['zoneid']), htmlspecialchars($aFields['zonename'])));
            OA_Admin_UI::queueMessage($translated_message, 'local', 'confirm', 0);
            OX_Admin_Redirect::redirect("zone-edit.php?affiliateid=" . $aFields['affiliateid'] . "&zoneid=" . $aFields['zoneid']);
        } else {
            $doZones = OA_Dal::factoryDO('zones');
            $doZones->affiliateid = $aFields['affiliateid'];
            $doZones->zonename = $aFields['zonename'];
            $doZones->zonetype = phpAds_ZoneCampaign;
            $doZones->description = $aFields['description'];
            $doZones->comments = $aFields['comments'];
            $doZones->width = $aFields['width'];
            $doZones->height = $aFields['height'];
            $doZones->delivery = $aFields['delivery'];
            $doZones->oac_category_id = $aFields['oac_category_id'];
            // The following fields are NOT NULL but do not get values set in the form.
            // Should these fields be changed to NULL in the schema or should they have a default value?
            $doZones->category = '';
            $doZones->ad_selection = '';
            $doZones->chain = '';
            $doZones->prepend = '';
            $doZones->append = '';
            $aFields['zoneid'] = $doZones->insert();
            // Ad  Networks
            $doPublisher = OA_Dal::factoryDO('affiliates');
            $doPublisher->get($aFields['affiliateid']);
            $anWebsiteId = $doPublisher->as_website_id;
            if ($anWebsiteId) {
                $oAdNetworks = new OA_Central_AdNetworks();
                $oAdNetworks->updateZone($doZones, $anWebsiteId);
            }
            // Queue confirmation message
            $translation = new OX_Translation();
            $translated_message = $translation->translate($GLOBALS['strZoneHasBeenAdded'], array(MAX::constructURL(MAX_URL_ADMIN, 'zone-edit.php?affiliateid=' . $aFields['affiliateid'] . '&zoneid=' . $aFields['zoneid']), htmlspecialchars($aFields['zonename'])));
            OA_Admin_UI::queueMessage($translated_message, 'local', 'confirm', 0);
            OX_Admin_Redirect::redirect("affiliate-zones.php?affiliateid=" . $aFields['affiliateid']);
        }
    }
    return $errors;
}
Esempio n. 10
0
 /**
  * Method that returns the top level page of the page passed as parameter.
  *
  * @param string $sectionId The page that we want to know its parent page.
  * @return string A string with the parent page, it will be null if the page
  *                doesn't have a parent page.
  */
 function getTopLevelPage($sectionId = null)
 {
     $sectionId = OA_Admin_UI::getID($sectionId);
     $oMenu = OA_Admin_Menu::singleton();
     $parentSections = $oMenu->getParentSections($sectionId);
     return count($parentSections) ? $parentSections[0]->link : '';
 }
function processForm($bannerid, $form, &$oComponent, $formDisabled = false)
{
    $aFields = $form->exportValues();
    $doBanners = OA_Dal::factoryDO('banners');
    if (!empty($bannerid)) {
        if ($doBanners->get($bannerid)) {
            $aBanner = $doBanners->toArray();
        }
    }
    $aVariables = array();
    $aVariables['campaignid'] = $aFields['campaignid'];
    $aVariables['target'] = isset($aFields['target']) ? $aFields['target'] : '';
    $aVariables['height'] = isset($aFields['height']) ? $aFields['height'] : 0;
    $aVariables['width'] = isset($aFields['width']) ? $aFields['width'] : 0;
    $aVariables['weight'] = !empty($aFields['weight']) ? $aFields['weight'] : 0;
    $aVariables['adserver'] = !empty($aFields['adserver']) ? $aFields['adserver'] : '';
    $aVariables['alt'] = !empty($aFields['alt']) ? $aFields['alt'] : '';
    $aVariables['bannertext'] = !empty($aFields['bannertext']) ? $aFields['bannertext'] : '';
    $aVariables['htmltemplate'] = !empty($aFields['htmltemplate']) ? $aFields['htmltemplate'] : '';
    $aVariables['description'] = !empty($aFields['description']) ? $aFields['description'] : '';
    $aVariables['imageurl'] = !empty($aFields['imageurl']) && $aFields['imageurl'] != 'http://' ? $aFields['imageurl'] : '';
    $aVariables['url'] = !empty($aFields['url']) && $aFields['url'] != 'http://' ? $aFields['url'] : '';
    $aVariables['status'] = $aFields['status'] != '' ? $aFields['status'] : '';
    $aVariables['storagetype'] = $aFields['type'];
    $aVariables['ext_bannertype'] = 'bannerTypeText:oxMarkedText:oxMarkedTextComponent';
    $aVariables['comments'] = $aFields['comments'];
    $aVariables['contenttype'] = 'txt';
    if (isset($aFields['keyword']) && $aFields['keyword'] != '') {
        $keywordArray = split('[ ,]+', $aFields['keyword']);
        $aVariables['keyword'] = implode(' ', $keywordArray);
    } else {
        $aVariables['keyword'] = '';
    }
    $editSwf = false;
    $parameters = null;
    $aVariables['parameters'] = serialize($parameters);
    $insert = empty($bannerid) ? true : false;
    $doBanners->setFrom($aVariables);
    if ($insert) {
        $bannerid = $doBanners->insert();
        OA_Maintenance_Priority::scheduleRun();
    } else {
        $doBanners->update();
        if ($aVariables['width'] != $aBanner['width'] || $aVariables['height'] != $aBanner['height']) {
            MAX_adjustAdZones($bannerid);
            MAX_addDefaultPlacementZones($bannerid, $aVariables['campaignid']);
        }
    }
    $translation = new OX_Translation();
    if ($insert) {
        $translated_message = $translation->translate($GLOBALS['strBannerHasBeenAdded'], array(MAX::constructURL(MAX_URL_ADMIN, 'banner-edit.php?clientid=' . $aFields['clientid'] . '&campaignid=' . $aFields['campaignid'] . '&bannerid=' . $bannerid), htmlspecialchars($aFields['description'])));
        OA_Admin_UI::queueMessage($translated_message, 'local', 'confirm', 0);
        $nextPage = "oxMarkedTextAdvertiser-index.php?clientid=" . $aFields['clientid'] . "&campaignid=" . $aFields['campaignid'];
    } else {
        $translated_message = $translation->translate($GLOBALS['strBannerHasBeenUpdated'], array(MAX::constructURL(MAX_URL_ADMIN, 'banner-edit.php?clientid=' . $aFields['clientid'] . '&campaignid=' . $aFields['campaignid'] . '&bannerid=' . $aFields['bannerid']), htmlspecialchars($aFields['description'])));
        OA_Admin_UI::queueMessage($translated_message, 'local', 'confirm', 0);
        $nextPage = "banner-edit.php?clientid=" . $aFields['clientid'] . "&campaignid=" . $aFields['campaignid'] . "&bannerid={$bannerid}";
    }
    Header("Location: {$nextPage}");
    exit;
}
Esempio n. 12
0
/**
 * Show page header
 *
 * @todo Remove the "if stats, use numeric system" mechanism, should happen with the stats rewrite
 *       Also, this function seems to just be a wrapper to OA_Admin_UI::showHeader()... removing it would seem to make sense
 *
 * @param string ID If not passed in (or null) the page filename is used as the ID
 * @param string Extra
 * @param string imgPath: a relative path to Images, CSS files. Used if calling function from anything other than admin folder
 * @param bool $showSidebar Set to false if you do not wish to show the sidebar navigation
 * @param bool $showContentFrame Set to false if you do not wish to show the content frame
 * @param bool $showMainNavigation Set to false if you do not wish to show the main navigation
 */
function phpAds_PageHeader($ID = null, $headerModel = null, $imgPath = "", $showSidebar = true, $showContentFrame = true, $showMainNavigation = true)
{
    $GLOBALS['_MAX']['ADMIN_UI'] = OA_Admin_UI::getInstance();
    $GLOBALS['_MAX']['ADMIN_UI']->showHeader($ID, $headerModel, $imgPath, $showSidebar, $showContentFrame, $showMainNavigation);
    $GLOBALS['phpAds_GUIDone'] = true;
}
Esempio n. 13
0
function processForm($bannerid, $form, &$oComponent, $formDisabled = false)
{
    $aFields = $form->exportValues();
    $doBanners = OA_Dal::factoryDO('banners');
    // Get the existing banner details (if it is not a new banner)
    if (!empty($bannerid)) {
        if ($doBanners->get($bannerid)) {
            $aBanner = $doBanners->toArray();
        }
    }
    $aVariables = array();
    $aVariables['campaignid'] = $aFields['campaignid'];
    $aVariables['target'] = isset($aFields['target']) ? $aFields['target'] : '';
    $aVariables['height'] = isset($aFields['height']) ? $aFields['height'] : 0;
    $aVariables['width'] = isset($aFields['width']) ? $aFields['width'] : 0;
    $aVariables['weight'] = !empty($aFields['weight']) ? $aFields['weight'] : 0;
    $aVariables['adserver'] = !empty($aFields['adserver']) ? $aFields['adserver'] : '';
    $aVariables['alt'] = !empty($aFields['alt']) ? $aFields['alt'] : '';
    $aVariables['bannertext'] = !empty($aFields['bannertext']) ? $aFields['bannertext'] : '';
    $aVariables['htmltemplate'] = !empty($aFields['htmltemplate']) ? $aFields['htmltemplate'] : '';
    $aVariables['description'] = !empty($aFields['description']) ? $aFields['description'] : '';
    $aVariables['imageurl'] = !empty($aFields['imageurl']) && $aFields['imageurl'] != 'http://' ? $aFields['imageurl'] : '';
    $aVariables['url'] = !empty($aFields['url']) && $aFields['url'] != 'http://' ? $aFields['url'] : '';
    $aVariables['status'] = $aFields['status'] != '' ? $aFields['status'] : '';
    $aVariables['statustext'] = !empty($aFields['statustext']) ? $aFields['statustext'] : '';
    $aVariables['storagetype'] = $aFields['type'];
    $aVariables['ext_bannertype'] = $aFields['ext_bannertype'];
    $aVariables['comments'] = $aFields['comments'];
    $aVariables['filename'] = !empty($aBanner['filename']) ? $aBanner['filename'] : '';
    $aVariables['contenttype'] = !empty($aBanner['contenttype']) ? $aBanner['contenttype'] : '';
    if ($aFields['type'] == 'url') {
        $aVariables['contenttype'] = OA_Creative_File::staticGetContentTypeByExtension($aVariables['imageurl']);
        if (empty($aVariables['contenttype'])) {
            // Assume dynamic urls (i.e. http://www.example.com/foo?bar) are "gif"
            $aVariables['contenttype'] = 'gif';
        }
    } elseif ($aFields['type'] == 'txt') {
        // Text banners should always have a "txt" content type
        $aVariables['contenttype'] = 'txt';
    }
    $aVariables['alt_filename'] = !empty($aBanner['alt_filename']) ? $aBanner['alt_filename'] : '';
    $aVariables['alt_contenttype'] = !empty($aBanner['alt_contenttype']) ? $aBanner['alt_contenttype'] : '';
    $aVariables['alt_imageurl'] = !empty($aFields['alt_imageurl']) ? $aFields['alt_imageurl'] : '';
    if (isset($aFields['keyword']) && $aFields['keyword'] != '') {
        $keywordArray = split('[ ,]+', $aFields['keyword']);
        $aVariables['keyword'] = implode(' ', $keywordArray);
    } else {
        $aVariables['keyword'] = '';
    }
    $editSwf = false;
    // Deal with any files that are uploaded.
    if (!empty($_FILES['upload']) && $aFields['replaceimage'] == 't') {
        //TODO refactor upload to be a valid quickform elem
        $oFile = OA_Creative_File::factoryUploadedFile('upload');
        checkForErrorFileUploaded($oFile);
        $oFile->store($aFields['type']);
        $aFile = $oFile->getFileDetails();
        if (!empty($aFile)) {
            $aVariables['filename'] = $aFile['filename'];
            $aVariables['contenttype'] = $aFile['contenttype'];
            $aVariables['width'] = $aFile['width'];
            $aVariables['height'] = $aFile['height'];
            $aVariables['pluginversion'] = $aFile['pluginversion'];
            $editSwf = $aFile['editswf'];
        }
        // Delete the old file for this banner
        if (!empty($aBanner['filename']) && $aBanner['filename'] != $aFile['filename'] && ($aBanner['storagetype'] == 'web' || $aBanner['storagetype'] == 'sql')) {
            DataObjects_Banners::deleteBannerFile($aBanner['storagetype'], $aBanner['filename']);
        }
    }
    if (!empty($_FILES['uploadalt']) && $_FILES['uploadalt']['size'] > 0 && $aFields['replacealtimage'] == 't') {
        //TODO: Check image only? - Wasn't enforced before
        $oFile = OA_Creative_File::factoryUploadedFile('uploadalt');
        checkForErrorFileUploaded($oFile);
        $oFile->store($aFields['type']);
        $aFile = $oFile->getFileDetails();
        if (!empty($aFile)) {
            $aVariables['alt_filename'] = $aFile['filename'];
            $aVariables['alt_contenttype'] = $aFile['contenttype'];
        }
    }
    // Handle SWF transparency
    if ($aVariables['contenttype'] == 'swf') {
        $aVariables['transparent'] = isset($aFields['transparent']) && $aFields['transparent'] ? 1 : 0;
    }
    // Update existing hard-coded links if new file has not been uploaded
    if ($aVariables['contenttype'] == 'swf' && empty($_FILES['upload']['tmp_name']) && isset($aFields['alink']) && is_array($aFields['alink']) && count($aFields['alink'])) {
        // Prepare the parameters
        $parameters_complete = array();
        // Prepare targets
        if (!isset($aFields['atar']) || !is_array($aFields['atar'])) {
            $aFields['atar'] = array();
        }
        foreach ($aFields['alink'] as $key => $val) {
            if (substr($val, 0, 7) == 'http://' && strlen($val) > 7) {
                if (!isset($aFields['atar'][$key])) {
                    $aFields['atar'][$key] = '';
                }
                if (isset($aFields['alink_chosen']) && $aFields['alink_chosen'] == $key) {
                    $aVariables['url'] = $val;
                    $aVariables['target'] = $aFields['atar'][$key];
                }
                /*
                                if (isset($aFields['asource'][$key]) && $aFields['asource'][$key] != '') {
                                    $val .= '|source:'.$aFields['asource'][$key];
                                }
                */
                $parameters_complete[$key] = array('link' => $val, 'tar' => $aFields['atar'][$key]);
            }
        }
        $parameters = array('swf' => $parameters_complete);
    } else {
        $parameters = null;
    }
    $aVariables['parameters'] = serialize($parameters);
    //TODO: deleting images is not viable because they could still be in use in the delivery cache
    //    // Delete any old banners...
    //    if (!empty($aBanner['filename']) && $aBanner['filename'] != $aVariables['filename']) {
    //        phpAds_ImageDelete($aBanner['storagetype'], $aBanner['filename']);
    //    }
    //    if (!empty($aBanner['alt_filename']) && $aBanner['alt_filename'] != $aVariables['alt_filename']) {
    //        phpAds_ImageDelete($aBanner['storagetype'], $aBanner['alt_filename']);
    //    }
    // Clients are only allowed to modify certain fields, ensure that other fields are unchanged
    if (OA_Permission::isAccount(OA_ACCOUNT_ADVERTISER)) {
        $aVariables['weight'] = $aBanner['weight'];
        $aVariables['description'] = $aBanner['name'];
        $aVariables['comments'] = $aBanner['comments'];
    }
    $insert = empty($bannerid) ? true : false;
    if ($oComponent) {
        $result = $oComponent->preprocessForm($insert, $bannerid, $aFields, $aVariables);
        if ($result === false) {
            // handle error
            return false;
        }
    }
    // File the data
    $doBanners->setFrom($aVariables);
    if ($insert) {
        $bannerid = $doBanners->insert();
        // Run the Maintenance Priority Engine process
        OA_Maintenance_Priority::scheduleRun();
    } else {
        $doBanners->update();
        // check if size has changed
        if ($aVariables['width'] != $aBanner['width'] || $aVariables['height'] != $aBanner['height']) {
            MAX_adjustAdZones($bannerid);
            MAX_addDefaultPlacementZones($bannerid, $aVariables['campaignid']);
        }
    }
    if ($oComponent) {
        $result = $oComponent->processForm($insert, $bannerid, $aFields, $aVariables);
        if ($result === false) {
            // handle error
            // remove rec from banners table?
            return false;
        }
    }
    $translation = new OX_Translation();
    if ($insert) {
        // Queue confirmation message
        $translated_message = $translation->translate($GLOBALS['strBannerHasBeenAdded'], array(MAX::constructURL(MAX_URL_ADMIN, 'banner-edit.php?clientid=' . $aFields['clientid'] . '&campaignid=' . $aFields['campaignid'] . '&bannerid=' . $bannerid), htmlspecialchars($aFields['description'])));
        OA_Admin_UI::queueMessage($translated_message, 'local', 'confirm', 0);
        // Determine what the next page is
        if ($editSwf) {
            $nextPage = "banner-swf.php?clientid=" . $aFields['clientid'] . "&campaignid=" . $aFields['campaignid'] . "&bannerid={$bannerid}&insert=true";
        } else {
            $nextPage = "campaign-banners.php?clientid=" . $aFields['clientid'] . "&campaignid=" . $aFields['campaignid'];
        }
    } else {
        // Determine what the next page is
        if ($editSwf) {
            $nextPage = "banner-swf.php?clientid=" . $aFields['clientid'] . "&campaignid=" . $aFields['campaignid'] . "&bannerid={$bannerid}";
        } else {
            $translated_message = $translation->translate($GLOBALS['strBannerHasBeenUpdated'], array(MAX::constructURL(MAX_URL_ADMIN, 'banner-edit.php?clientid=' . $aFields['clientid'] . '&campaignid=' . $aFields['campaignid'] . '&bannerid=' . $aFields['bannerid']), htmlspecialchars($aFields['description'])));
            OA_Admin_UI::queueMessage($translated_message, 'local', 'confirm', 0);
            $nextPage = "banner-edit.php?clientid=" . $aFields['clientid'] . "&campaignid=" . $aFields['campaignid'] . "&bannerid={$bannerid}";
        }
    }
    // Go to the next page
    Header("Location: {$nextPage}");
    exit;
}
<?php

require_once '../../../../init.php';
require_once '../../config.php';
require_once MAX_PATH . '/lib/OA/Admin/TemplatePlugin.php';
require_once MAX_PATH . '/lib/OA/Admin/UI/component/Form.php';
require_once 'lib/common.php';
$admin_ui = OA_Admin_UI::getInstance();
$admin_ui->registerStylesheetFile(MAX::constructURL(MAX_URL_ADMIN, 'plugins/zpBannerDesigner/css/colorpicker.css'));
$admin_ui->registerStylesheetFile(MAX::constructURL(MAX_URL_ADMIN, 'plugins/zpBannerDesigner/css/zp-style.css'));
phpAds_registerGlobalUnslashed('bannerid', 'campaignid', 'clientid', 'ajax', 'size', 'keywords', 'qty', 'template_id', 'image_url', 'description', 'type');
OA_Permission::enforceAccount(OA_ACCOUNT_MANAGER, OA_ACCOUNT_ADVERTISER);
if (isset($ajax)) {
    if ($ajax === 'search') {
        echo search_ajax_request($keywords, $size, $qty);
    } elseif ($ajax === 'form') {
        echo form_ajax_request($template_id);
    } elseif ($ajax === 'preview') {
        echo preview_ajax_request($template_id);
    } elseif ($ajax === 'save-image') {
        echo save_ajax_request($bannerid, $campaignid, $clientid, $image_url, $template_id, $description, $type);
    }
    return;
}
//get advertisers and set the current one
$aAdvertisers = getAdvertiserMap();
if (empty($clientid)) {
    //if it's empty
    $campaignid = null;
    //reset campaign id, we could derive it after we have clientid
    if ($session['prefs']['inventory_entities'][OA_Permission::getEntityId()]['clientid']) {
Esempio n. 15
0
function processForm($aZone, $form, $oComponent = null)
{
    $aFields = $form->exportValues();
    if (empty($aFields['zoneid'])) {
        return;
    }
    $doZones = OA_Dal::factoryDO('zones');
    $doZones->get($aFields['zoneid']);
    // Determine chain
    if ($aFields['chaintype'] == '1' && $aFields['chainzone'] != '') {
        $chain = 'zone:' . $aFields['chainzone'];
    } else {
        $chain = '';
    }
    $doZones->chain = $chain;
    if (!isset($aFields['prepend'])) {
        $aFields['prepend'] = '';
    }
    $aFields['prepend'] = MAX_commonGetValueUnslashed('prepend');
    $doZones->prepend = $aFields['prepend'];
    // Do not save append until not finished with zone appending, if present
    if (!empty($aFields['appendsave'])) {
        if (!isset($aFields['append'])) {
            $aFields['append'] = '';
        }
        if (!isset($aFields['appendtype'])) {
            $aFields['appendtype'] = phpAds_ZoneAppendZone;
        }
        $aFields['append'] = MAX_commonGetValueUnslashed('append');
        $doZones->append = $aFields['append'];
        $doZones->appendtype = $aFields['appendtype'];
    }
    if (isset($aFields['forceappend'])) {
        $doZones->forceappend = $aFields['forceappend'];
    }
    $block = _initCappingVariables($aFields['time'], $aFields['capping'], $aFields['session_capping']);
    // Set adselection PCI if required
    if (isset($aFields['ext_adselection'])) {
        $doZones->ext_adselection = $aFields['ext_adselection'] == 'none' ? OX_DATAOBJECT_NULL : $aFields['ext_adselection'];
    }
    $doZones->block = $block;
    $doZones->capping = $aFields['capping'];
    $doZones->session_capping = $aFields['session_capping'];
    if ($aFields['show_capped_no_cookie'] != 1) {
        $aFields['show_capped_no_cookie'] = 0;
    }
    $doZones->show_capped_no_cookie = $aFields['show_capped_no_cookie'];
    $doZones->update();
    // Queue confirmation message
    $translation = new OX_Translation();
    $translated_message = $translation->translate($GLOBALS['strZoneAdvancedHasBeenUpdated'], array(MAX::constructURL(MAX_URL_ADMIN, 'zone-edit.php?affiliateid=' . $aFields['affiliateid'] . '&zoneid=' . $aFields['zoneid']), htmlspecialchars($doZones->zonename)));
    OA_Admin_UI::queueMessage($translated_message, 'local', 'confirm', 0);
    // Rebuild Cache
    // require_once MAX_PATH . '/lib/max/deliverycache/cache-'.$conf['delivery']['cache'].'.inc.php';
    // phpAds_cacheDelete('what=zone:'.$zoneid);
    $oUI = OA_Admin_UI::getInstance();
    OX_Admin_Redirect::redirect("zone-advanced.php?affiliateid=" . $aFields['affiliateid'] . "&zoneid=" . $aFields['zoneid']);
}
function processForm($form)
{
    $aFields = $form->exportValues();
    // If ID is not set, it should be a null-value for the auto_increment
    if (empty($aFields['trackerid'])) {
        $aFields['trackerid'] = "null";
    }
    $doTrackers = OA_Dal::factoryDO('trackers');
    $doTrackers->trackername = $aFields['trackername'];
    $doTrackers->description = $aFields['description'];
    $doTrackers->status = $aFields['status'];
    $doTrackers->type = $aFields['type'];
    $doTrackers->linkcampaigns = $aFields['linkcampaigns'] == "t" ? "t" : "f";
    $doTrackers->clientid = $aFields['clientid'];
    if (empty($aFields['trackerid']) || $aFields['trackerid'] == "null") {
        $aFields['trackerid'] = $doTrackers->insert();
        // Queue confirmation message
        $translation = new OX_Translation();
        $translated_message = $translation->translate($GLOBALS['strTrackerHasBeenAdded'], array(MAX::constructURL(MAX_URL_ADMIN, "tracker-edit.php?clientid=" . $aFields['clientid'] . "&trackerid=" . $aFields['trackerid']), htmlspecialchars($aFields['trackername'])));
        OA_Admin_UI::queueMessage($translated_message, 'local', 'confirm', 0);
        OX_Admin_Redirect::redirect('advertiser-trackers.php?clientid=' . $aFields['clientid']);
    } else {
        $doTrackers->trackerid = $aFields['trackerid'];
        $doTrackers->update();
        // Queue confirmation message
        $translation = new OX_Translation();
        $translated_message = $translation->translate($GLOBALS['strTrackerHasBeenUpdated'], array(MAX::constructURL(MAX_URL_ADMIN, "tracker-edit.php?clientid=" . $aFields['clientid'] . "&trackerid=" . $aFields['trackerid']), htmlspecialchars($aFields['trackername'])));
        OA_Admin_UI::queueMessage($translated_message, 'local', 'confirm', 0);
        OX_Admin_Redirect::redirect("tracker-edit.php?clientid=" . $aFields['clientid'] . "&trackerid=" . $aFields['trackerid']);
    }
    exit;
}
Esempio n. 17
0
function processForm($affiliateid, $form, $oComponent)
{
    $aFields = $form->exportValues();
    $newWebsite = empty($aFields['affiliateid']);
    // Setup a new publisher object and set the fields passed in from the form:
    $oPublisher = new OA_Dll_PublisherInfo();
    $oPublisher->agencyId = $aFields['agencyid'];
    $oPublisher->contactName = $aFields['contact'];
    $oPublisher->emailAddress = $aFields['email'];
    $oPublisher->publisherId = $aFields['affiliateid'];
    $oPublisher->publisherName = $aFields['name'];
    $oPublisher->website = $aFields['website'];
    // process form data for oxThorium if this is edit existing website
    if (!$newWebsite && $oComponent) {
        $aFields['affiliateid'] = $oPublisher->publisherId;
        $oComponent->processAffiliateForm($aFields);
    }
    $oPublisherDll = new OA_Dll_Publisher();
    if ($oPublisherDll->modify($oPublisher) && !$oPublisherDll->_noticeMessage) {
        // Queue confirmation message
        $translation = new OX_Translation();
        if ($newWebsite) {
            //process form data for oxThorium for new website
            if ($oComponent) {
                $aFields['affiliateid'] = $oPublisher->publisherId;
                $oComponent->processAffiliateForm($aFields);
            }
            $translated_message = $translation->translate($GLOBALS['strWebsiteHasBeenAdded'], array(MAX::constructURL(MAX_URL_ADMIN, 'affiliate-edit.php?affiliateid=' . $oPublisher->publisherId), htmlspecialchars($oPublisher->publisherName), MAX::constructURL(MAX_URL_ADMIN, 'zone-edit.php?affiliateid=' . $oPublisher->publisherId)));
            OA_Admin_UI::queueMessage($translated_message, 'local', 'confirm', 0);
            $redirectURL = "website-index.php";
        } else {
            $translated_message = $translation->translate($GLOBALS['strWebsiteHasBeenUpdated'], array(MAX::constructURL(MAX_URL_ADMIN, 'affiliate-edit.php?affiliateid=' . $oPublisher->publisherId), htmlspecialchars($oPublisher->publisherName)));
            $redirectURL = "affiliate-edit.php?affiliateid={$oPublisher->publisherId}";
        }
        OA_Admin_UI::queueMessage($translated_message, 'local', 'confirm', 0);
        OX_Admin_Redirect::redirect($redirectURL);
    }
    return $oPublisherDll;
}
<?php

/*
+---------------------------------------------------------------------------+
| Revive Adserver                                                           |
| http://www.revive-adserver.com                                            |
|                                                                           |
| Copyright: See the COPYRIGHT.txt file.                                    |
| License: GPLv2 or later, see the LICENSE.txt file.                        |
+---------------------------------------------------------------------------+
*/
/**
 * OpenX jQuery ajax functions
 */
require_once '../../../../init.php';
require_once MAX_PATH . '/lib/OA/Admin/UI.php';
/**
 since we are loading a page inside of a frame we do not have access to
 scripts defined in top frame. Thus we need to load them on our own if we want to
 use jQuery.
 Please note that scripts.html is an admin template not a plugin template
 **/
$oUI = OA_Admin_UI::getInstance();
$aScripts = $oUI->genericJavascript();
$oTpl = new OA_Admin_Template('layout/scripts.html');
$oTpl->assign('aGenericJavascript', $aScripts);
$oTpl->display();
//now display the page content
include "templates/content.html";
Esempio n. 19
0
 function handlePost($vars)
 {
     $codes = array();
     if (isset($vars['tag']) && is_array($vars['tag'])) {
         foreach ($vars['tag'] as $k => $v) {
             $codes[$k] = array('tagcode' => stripslashes($v), 'paused' => false);
             $codes[$k]['autotrack'] = isset($vars['autotrack'][$k]);
         }
     }
     if (isset($vars['t_paused'])) {
         foreach (explode(',', $vars['t_paused']) as $k) {
             if (isset($codes[$k])) {
                 $codes[$k]['paused'] = true;
             }
         }
     }
     if (isset($vars['t_action'])) {
         switch ($vars['t_action']) {
             case 'new':
                 $codes[] = array('tagcode' => '', 'paused' => false);
                 break;
             case 'del':
                 if (isset($vars['t_id']) && isset($codes[$vars['t_id']])) {
                     unset($codes[$vars['t_id']]);
                 }
                 break;
             case 'up':
                 if (isset($vars['t_id']) && isset($codes[$vars['t_id']]) && isset($codes[$vars['t_id'] - 1])) {
                     $tmp = $codes[$vars['t_id']];
                     $codes[$vars['t_id']] = $codes[$vars['t_id'] - 1];
                     $codes[$vars['t_id'] - 1] = $tmp;
                 }
                 break;
             case 'down':
                 if (isset($vars['t_id']) && isset($codes[$vars['t_id']]) && isset($codes[$vars['t_id'] + 1])) {
                     $tmp = $codes[$vars['t_id']];
                     $codes[$vars['t_id']] = $codes[$vars['t_id'] + 1];
                     $codes[$vars['t_id'] + 1] = $tmp;
                 }
                 break;
             case 'pause':
             case 'restart':
                 if (isset($vars['t_id']) && isset($codes[$vars['t_id']])) {
                     $codes[$vars['t_id']]['paused'] = $vars['t_action'] == 'pause';
                 }
                 break;
         }
     }
     if (isset($vars['save'])) {
         $this->_dal->setAppendCodes($this->tracker_id, $codes);
         // Queue confirmation message
         $doTrackers = OA_Dal::factoryDO('trackers');
         $doTrackers->get($this->tracker_id);
         $translation = new OX_Translation();
         $translated_message = $translation->translate($GLOBALS['strTrackerAppendHasBeenUpdated'], array(MAX::constructURL(MAX_URL_ADMIN, "tracker-edit.php?clientid=" . $this->advertiser_id . "&trackerid=" . $this->tracker_id), htmlspecialchars($doTrackers->trackername)));
         OA_Admin_UI::queueMessage($translated_message, 'local', 'confirm', 0);
         OX_Admin_Redirect::redirect("tracker-append.php?clientid={$this->advertiser_id}&trackerid={$this->tracker_id}");
     } else {
         $this->codes = $codes;
         $this->showReminder = true;
     }
 }
/**
 * Processes submit values of campaign form
 *
 * @param OA_Admin_UI_Component_Form $form form to process
 * @return An array of Pear::Error objects if any
 */
function processCampaignForm($form, &$oComponent = null)
{
    $aFields = $form->exportValues();
    if (!empty($aFields['start'])) {
        $oDate = new Date(date('Y-m-d 00:00:00', strtotime($aFields['start'])));
        $oDate->toUTC();
        $activate = $oDate->getDate();
    } else {
        $oDate = new Date(date('Y-m-d 00:00:00'));
        $oDate->toUTC();
        $activate = $oDate->getDate();
    }
    if (!empty($aFields['end'])) {
        $oDate = new Date(date('Y-m-d 23:59:59', strtotime($aFields['end'])));
        $oDate->toUTC();
        $expire = $oDate->getDate();
    } else {
        $expire = null;
    }
    if (empty($aFields['campaignid'])) {
        // The form is submitting a new campaign, so, the ID is not set;
        // set the ID to the string "null" so that the table auto_increment
        // or sequence will be used when the campaign is created
        $aFields['campaignid'] = "null";
    } else {
        // The form is submitting a campaign modification; need to test
        // if any of the banners in the campaign are linked to an email zone,
        // and if so, if the link(s) would still be valid if the change(s)
        // to the campaign were made...
        $dalCampaigns = OA_Dal::factoryDAL('campaigns');
        $aCurrentLinkedEmalZoneIds = $dalCampaigns->getLinkedEmailZoneIds($aFields['campaignid']);
        if (PEAR::isError($aCurrentLinkedEmalZoneIds)) {
            OX::disableErrorHandling();
            $errors[] = PEAR::raiseError($GLOBALS['strErrorDBPlain']);
            OX::enableErrorHandling();
        }
        $errors = array();
        foreach ($aCurrentLinkedEmalZoneIds as $zoneId) {
            $thisLink = Admin_DA::_checkEmailZoneAdAssoc($zoneId, $aFields['campaignid'], $activate, $expire);
            if (PEAR::isError($thisLink)) {
                $errors[] = $thisLink;
                break;
            }
        }
    }
    //correct and check revenue and ecpm
    correctAdnCheckNumericFormField($aFields, $errors, 'revenue', $GLOBALS['strErrorEditingCampaignRevenue']);
    correctAdnCheckNumericFormField($aFields, $errors, 'ecpm', $GLOBALS['strErrorEditingCampaignECPM']);
    if (empty($errors)) {
        //check booked limits values
        // If this is a remnant, ecpm or exclusive campaign with an expiry date, set the target's to unlimited
        if (!empty($expire) && ($aFields['campaign_type'] == OX_CAMPAIGN_TYPE_REMNANT || $aFields['campaign_type'] == OX_CAMPAIGN_TYPE_ECPM || $aFields['campaign_type'] == OX_CAMPAIGN_TYPE_CONTRACT_EXCLUSIVE)) {
            $aFields['impressions'] = $aFields['clicks'] = $aFields['conversions'] = -1;
        } else {
            if (!empty($aFields['impr_unlimited']) && $aFields['impr_unlimited'] == 't') {
                $aFields['impressions'] = -1;
            } else {
                if (empty($aFields['impressions']) || $aFields['impressions'] == '-') {
                    $aFields['impressions'] = 0;
                }
            }
            if (!empty($aFields['click_unlimited']) && $aFields['click_unlimited'] == 't') {
                $aFields['clicks'] = -1;
            } else {
                if (empty($aFields['clicks']) || $aFields['clicks'] == '-') {
                    $aFields['clicks'] = 0;
                }
            }
            if (!empty($aFields['conv_unlimited']) && $aFields['conv_unlimited'] == 't') {
                $aFields['conversions'] = -1;
            } else {
                if (empty($aFields['conversions']) || $aFields['conversions'] == '-') {
                    $aFields['conversions'] = 0;
                }
            }
        }
        //pricing model - reset fields not applicable to model to 0,
        //note that in new flow MAX_FINANCE_CPA allows all limits to be set
        if ($aFields['revenue_type'] == MAX_FINANCE_CPM) {
            $aFields['clicks'] = -1;
            $aFields['conversions'] = -1;
        } else {
            if ($aFields['revenue_type'] == MAX_FINANCE_CPC) {
                $aFields['conversions'] = -1;
            } else {
                if ($aFields['revenue_type'] == MAX_FINANCE_MT) {
                    $aFields['impressions'] = -1;
                    $aFields['clicks'] = -1;
                    $aFields['conversions'] = -1;
                }
            }
        }
        //check type and set priority
        if ($aFields['campaign_type'] == OX_CAMPAIGN_TYPE_REMNANT) {
            $aFields['priority'] = 0;
            //low
        } else {
            if ($aFields['campaign_type'] == OX_CAMPAIGN_TYPE_CONTRACT_NORMAL) {
                $aFields['priority'] = isset($aFields['high_priority_value']) ? $aFields['high_priority_value'] : 5;
                //high
            } else {
                if ($aFields['campaign_type'] == OX_CAMPAIGN_TYPE_CONTRACT_EXCLUSIVE) {
                    $aFields['priority'] = -1;
                    //exclusive
                } else {
                    if ($aFields['campaign_type'] == OX_CAMPAIGN_TYPE_ECPM) {
                        $aFields['priority'] = -2;
                        //ecpm
                    }
                }
            }
        }
        // Set target
        $target_impression = 0;
        $target_click = 0;
        $target_conversion = 0;
        if ($aFields['priority'] > 0) {
            // Daily targets need to be set only if the campaign doesn't have both expiration and lifetime targets
            $hasExpiration = !empty($expire);
            $hasLifetimeTargets = $aFields['impressions'] != -1 || $aFields['clicks'] != -1 || $aFields['conversions'] != -1;
            if (!($hasExpiration && $hasLifetimeTargets) && isset($aFields['target_value']) && $aFields['target_value'] != '-') {
                switch ($aFields['target_type']) {
                    case 'target_impression':
                        $target_impression = $aFields['target_value'];
                        break;
                    case 'target_click':
                        $target_click = $aFields['target_value'];
                        break;
                    case 'target_conversion':
                        $target_conversion = $aFields['target_value'];
                        break;
                }
            }
            $aFields['weight'] = 0;
        } else {
            // Set weight
            if (!isset($aFields['weight']) || $aFields['weight'] == '-' || $aFields['weight'] == '') {
                $aFields['weight'] = 0;
            }
        }
        if ($aFields['anonymous'] != 't') {
            $aFields['anonymous'] = 'f';
        }
        if ($aFields['companion'] != 1) {
            $aFields['companion'] = 0;
        }
        if ($aFields['show_capped_no_cookie'] != 1) {
            $aFields['show_capped_no_cookie'] = 0;
        }
        $new_campaign = $aFields['campaignid'] == 'null';
        if (empty($aFields['revenue']) || $aFields['revenue'] <= 0) {
            // No revenue information, set to null
            $aFields['revenue'] = OX_DATAOBJECT_NULL;
        }
        if (empty($aFields['ecpm']) || $aFields['ecpm'] <= 0) {
            // No ecpm information, set to null
            $aFields['ecpm'] = OX_DATAOBJECT_NULL;
        }
        // Get the capping variables
        $block = _initCappingVariables($aFields['time'], $aFields['capping'], $aFields['session_capping']);
        $doCampaigns = OA_Dal::factoryDO('campaigns');
        $doCampaigns->campaignname = $aFields['campaignname'];
        $doCampaigns->clientid = $aFields['clientid'];
        $doCampaigns->views = $aFields['impressions'];
        $doCampaigns->clicks = $aFields['clicks'];
        $doCampaigns->conversions = $aFields['conversions'];
        $doCampaigns->priority = $aFields['priority'];
        $doCampaigns->weight = $aFields['weight'];
        $doCampaigns->target_impression = $target_impression;
        $doCampaigns->target_click = $target_click;
        $doCampaigns->target_conversion = $target_conversion;
        $doCampaigns->min_impressions = $aFields['min_impressions'];
        $doCampaigns->ecpm = $aFields['ecpm'];
        $doCampaigns->anonymous = $aFields['anonymous'];
        $doCampaigns->companion = $aFields['companion'];
        $doCampaigns->show_capped_no_cookie = $aFields['show_capped_no_cookie'];
        $doCampaigns->comments = $aFields['comments'];
        $doCampaigns->revenue = $aFields['revenue'];
        $doCampaigns->revenue_type = $aFields['revenue_type'];
        $doCampaigns->block = $block;
        $doCampaigns->capping = $aFields['capping'];
        $doCampaigns->session_capping = $aFields['session_capping'];
        // Activation and expiration
        $doCampaigns->activate_time = isset($activate) ? $activate : OX_DATAOBJECT_NULL;
        $doCampaigns->expire_time = isset($expire) ? $expire : OX_DATAOBJECT_NULL;
        if (!empty($aFields['campaignid']) && $aFields['campaignid'] != "null") {
            $doCampaigns->campaignid = $aFields['campaignid'];
            $doCampaigns->setEcpmEnabled();
            $doCampaigns->update();
        } else {
            $doCampaigns->setEcpmEnabled();
            $aFields['campaignid'] = $doCampaigns->insert();
        }
        if ($oComponent) {
            $oComponent->processCampaignForm($aFields);
        }
        // Recalculate priority only when editing a campaign
        // or moving banners into a newly created, and when:
        //
        // - campaign changes status (activated or deactivated) or
        // - the campaign is active and target/weight are changed
        //
        if (!$new_campaign) {
            $doCampaigns = OA_Dal::staticGetDO('campaigns', $aFields['campaignid']);
            $status = $doCampaigns->status;
            switch (true) {
                case (bool) $status != (bool) $aFields['status_old']:
                    // Run the Maintenance Priority Engine process
                    OA_Maintenance_Priority::scheduleRun();
                    break;
                case $status == OA_ENTITY_STATUS_RUNNING:
                    if (!empty($aFields['target_type']) && ${$aFields['target_type']} != $aFields['target_old'] || !empty($aFields['target_type']) && $aFields['target_type_old'] != $aFields['target_type'] || $aFields['weight'] != $aFields['weight_old'] || $aFields['clicks'] != $aFields['previousclicks'] || $aFields['conversions'] != $aFields['previousconversions'] || $aFields['impressions'] != $aFields['previousimpressions']) {
                        // Run the Maintenance Priority Engine process
                        OA_Maintenance_Priority::scheduleRun();
                    }
                    break;
            }
        }
        // Rebuild cache
        // include_once MAX_PATH . '/lib/max/deliverycache/cache-'.$conf['delivery']['cache'].'.inc.php';
        // phpAds_cacheDelete();
        // Delete channel forecasting cache
        include_once 'Cache/Lite.php';
        $options = array('cacheDir' => MAX_CACHE);
        $cache = new Cache_Lite($options);
        $group = 'campaign_' . $aFields['campaignid'];
        $cache->clean($group);
        $translation = new OX_Translation();
        if ($new_campaign) {
            // Queue confirmation message
            $translated_message = $translation->translate($GLOBALS['strCampaignHasBeenAdded'], array(MAX::constructURL(MAX_URL_ADMIN, 'campaign-edit.php?clientid=' . $aFields['clientid'] . '&campaignid=' . $aFields['campaignid']), htmlspecialchars($aFields['campaignname']), MAX::constructURL(MAX_URL_ADMIN, 'banner-edit.php?clientid=' . $aFields['clientid'] . '&campaignid=' . $aFields['campaignid'])));
            OA_Admin_UI::queueMessage($translated_message, 'local', 'confirm', 0);
            OX_Admin_Redirect::redirect("advertiser-campaigns.php?clientid=" . $aFields['clientid']);
        } else {
            $translated_message = $translation->translate($GLOBALS['strCampaignHasBeenUpdated'], array(MAX::constructURL(MAX_URL_ADMIN, 'campaign-edit.php?clientid=' . $aFields['clientid'] . '&campaignid=' . $aFields['campaignid']), htmlspecialchars($aFields['campaignname'])));
            OA_Admin_UI::queueMessage($translated_message, 'local', 'confirm', 0);
            OX_Admin_Redirect::redirect("campaign-edit.php?clientid=" . $aFields['clientid'] . "&campaignid=" . $aFields['campaignid']);
        }
    }
    //return processing errors
    return $errors;
}
Esempio n. 21
0
 function showHeader($keyword)
 {
     $this->oTpl->assign('keyword', $keyword);
     parent::showHeader(0);
 }
    $aElements = array();
    $aCheckboxes = array();
    // Timezone
    $aElements[] = 'timezone';
    // Save the preferences
    $result = OA_Preferences::processPreferencesFromForm($aElements, $aCheckboxes);
    if ($result) {
        // Queue confirmation message
        $setPref = $oOptions->getSettingsPreferences($prefSection);
        $title = $setPref[$prefSection]['name'];
        $translation = new OX_Translation();
        $translatedMessage = $translation->translate($GLOBALS['strXPreferencesHaveBeenUpdated'], array(htmlspecialchars($title)));
        OA_Admin_UI::queueMessage($translatedMessage, 'local', 'confirm', 2000);
        // Also display warning after 2 seconds
        $translatedMessage = $translation->translate($GLOBALS['strTZPreferencesWarning']);
        OA_Admin_UI::queueMessage($translatedMessage, 'local', 'warning', 0);
        OX_Admin_Redirect::redirect(basename($_SERVER['SCRIPT_NAME']));
    }
    // Could not write the preferences to the database, store this
    // error message and continue
    $aErrormessage[0][] = $strUnableToWritePrefs;
}
// Set the correct section of the preference pages and display the drop-down menu
$setPref = $oOptions->getSettingsPreferences($prefSection);
$title = $setPref[$prefSection]['name'];
// Display the settings page's header and sections
$oHeaderModel = new OA_Admin_UI_Model_PageHeaderModel($title);
phpAds_PageHeader('account-preferences-index', $oHeaderModel);
// Get timezone dropdown information
$aTimezones = OX_Admin_Timezones::availableTimezones(true);
$oConfigTimezone = trim($GLOBALS['_MAX']['PREF']['timezone']);