コード例 #1
0
ファイル: Swf.php プロジェクト: villos/tree_admin
 function getFileDetails()
 {
     $aDetails = parent::getFileDetails();
     $aDetails['pluginversion'] = $this->pluginVersion;
     $aDetails['editswf'] = $this->pluginVersion >= 3 && $this->hardcodedLinks;
     return $aDetails;
 }
コード例 #2
0
ファイル: Banner.php プロジェクト: Jaree/revive-adserver
 /**
  * This method modifies an existing banner. Undefined fields do not change
  * and defined fields with a NULL value also remain unchanged.
  *
  * @access public
  *
  * @param OA_Dll_BannerInfo &$oBanner <br />
  *          <b>For adding</b><br />
  *          <b>Required properties:</b> campaignId<br />
  *          <b>Optional properties:</b> bannerName, storageType, imageURL, htmlTemplate, width, height, weight, url, alt<br />
  *
  *          <b>For modify</b><br />
  *          <b>Required properties:</b> bannerId<br />
  *          <b>Optional properties:</b> campaignId, bannerName, storageType, imageURL, htmlTemplate, width, height, weight, url, altText<br />
  *
  * @return boolean  True if the operation was successful
  *
  */
 function modify(&$oBanner)
 {
     if (!isset($oBanner->bannerId)) {
         // Add
         $oBanner->setDefaultForAdd();
         if (!$this->checkPermissions($this->aAllowAdvertiserAndAbovePerm, 'campaigns', $oBanner->campaignId, OA_PERM_BANNER_EDIT)) {
             return false;
         }
     } else {
         // Edit
         if (!$this->checkPermissions($this->aAllowAdvertiserAndAbovePerm, 'banners', $oBanner->bannerId, OA_PERM_BANNER_EDIT)) {
             return false;
         }
     }
     $bannerData = (array) $oBanner;
     // Name
     $bannerData['bannerid'] = $oBanner->bannerId;
     $bannerData['campaignid'] = $oBanner->campaignId;
     $bannerData['description'] = $oBanner->bannerName;
     $bannerData['storagetype'] = $oBanner->storageType;
     $bannerData['imageurl'] = $oBanner->imageURL;
     $bannerData['htmltemplate'] = $oBanner->htmlTemplate;
     $bannerData['alt'] = $oBanner->alt;
     $bannerData['capping'] = $oBanner->capping > 0 ? $oBanner->capping : 0;
     $bannerData['session_capping'] = $oBanner->sessionCapping > 0 ? $oBanner->sessionCapping : 0;
     $bannerData['block'] = $oBanner->block > 0 ? $oBanner->block : 0;
     if ($this->_validate($oBanner)) {
         $bannerData['storagetype'] = $oBanner->storageType;
         switch ($bannerData['storagetype']) {
             case 'html':
                 $bannerData['contenttype'] = $bannerData['storagetype'];
                 $bannerData['bannertext'] = $oBanner->bannerText;
                 $bannerData['ext_bannertype'] = 'bannerTypeHtml:oxHtml:genericHtml';
                 break;
             case 'txt':
                 $bannerData['contenttype'] = $bannerData['storagetype'];
                 $bannerData['bannertext'] = $oBanner->bannerText;
                 $bannerData['ext_bannertype'] = 'bannerTypeText:oxText:genericText';
                 break;
             case 'sql':
             case 'web':
                 if (!empty($oBanner->aImage)) {
                     // Hardcoded link conversion
                     $bannerData['parameters'] = '';
                     if ($this->oImage->contentType == 'swf' && !empty($oBanner->aImage['editswf'])) {
                         $aLinks = array_keys($this->oImage->hardcodedLinks);
                         list($result, $params) = phpAds_SWFConvert($this->oImage->content, true, $aLinks);
                         if ($result != $this->oImage->content) {
                             $this->oImage->content = $result;
                             $bannerData['parameters'] = array('swf' => array());
                             foreach ($params as $key) {
                                 $bannerData['parameters']['swf'][$key] = array('link' => $this->oImage->hardcodedLinks[$key][0], 'tar' => $this->oImage->hardcodedLinks[$key][1]);
                             }
                             $bannerData['parameters'] = serialize($bannerData['parameters']);
                             $bannerData['url'] = $this->oImage->hardcodedLinks[1][0];
                             $bannerData['target'] = $this->oImage->hardcodedLinks[1][1];
                         }
                     }
                     $this->oImage->store($bannerData['storagetype']);
                     $bannerData['contenttype'] = $this->oImage->contentType;
                     $bannerData['filename'] = $this->oImage->fileName;
                     $bannerData['width'] = $this->oImage->width;
                     $bannerData['height'] = $this->oImage->height;
                 }
                 if (!empty($oBanner->aBackupImage)) {
                     if (isset($this->oBackupImage)) {
                         $this->oBackupImage->store($bannerData['storagetype']);
                         $bannerData['alt_contenttype'] = $this->oBackupImage->contentType;
                         $bannerData['alt_filename'] = $this->oBackupImage->fileName;
                     } elseif (!isset($oBanner->aBackupImage['filename'])) {
                         $bannerData['alt_contenttype'] = '';
                         $bannerData['alt_filename'] = '';
                     }
                 }
                 break;
             case 'url':
                 $bannerData['contenttype'] = OA_Creative_File::staticGetContentTypeByExtension($oBanner->imageURL);
                 break;
         }
         $doBanner = OA_Dal::factoryDO('banners');
         if (!isset($bannerData['bannerId'])) {
             $doBanner->setFrom($bannerData);
             $oBanner->bannerId = $doBanner->insert();
         } else {
             $doBanner->get($bannerData['bannerId']);
             $doBanner->setFrom($bannerData);
             $doBanner->update();
         }
         return true;
     } else {
         return false;
     }
 }
コード例 #3
0
ファイル: File.php プロジェクト: villos/tree_admin
 /**
  * A factory method to load a cretive from an uploaded file
  *
  * @todo: improve checks
  *
  * @param string $variableName
  * @return OA_Creative_File
  */
 function &factoryUploadedFile($variableName)
 {
     if (!empty($_FILES[$variableName]['error'])) {
         $aErrors = array(UPLOAD_ERR_INI_SIZE => "file size exceeds PHP max allowed size", UPLOAD_ERR_FORM_SIZE => "file size exceeds form max allowed size", UPLOAD_ERR_PARTIAL => "partial upload", UPLOAD_ERR_NO_FILE => "no file uploaded", UPLOAD_ERR_NO_TMP_DIR => "temp directory not available");
         if (isset($aErrors[$_FILES[$variableName]['error']])) {
             $message = $aErrors[$_FILES[$variableName]['error']];
         } else {
             $message = 'Error code: ' . $_FILES[$variableName]['error'];
         }
         return new PEAR_Error('An error occured dealing with the file upload: ' . $message);
     }
     if (!isset($_FILES[$variableName]['tmp_name']) || !is_uploaded_file($_FILES[$variableName]['tmp_name'])) {
         return new PEAR_Error('Could not find the uploaded file: ' . $variableName);
     }
     if (!isset($_FILES[$variableName]['name'])) {
         return new PEAR_Error('Could not find the uploaded file name: ' . $variableName);
     }
     $fileName = basename($_FILES[$variableName]['name']);
     $filePath = $_FILES[$variableName]['tmp_name'];
     if (!@is_readable($filePath)) {
         // The uploaded file is not directly readable, we should use a file from the var folder instead
         $tmpName = tempnam(MAX_PATH . '/var', 'oa_creative_');
         if ($tmpName === false) {
             return new PEAR_Error('Cannot create a temporary file: ' . $filePath);
         }
         // Move uploaded file to a temporary file
         if (!@move_uploaded_file($filePath, $tmpName)) {
             // Cleanup
             @unlink($tmpName);
             return new PEAR_Error('Could not move the uploaded file to: ' . $tmpName);
         }
         $filePath = $tmpName;
     }
     // Get new instance
     $oCreative =& OA_Creative_File::factory($filePath, $fileName);
     // Cleanup
     if (isset($tmpName)) {
         @unlink($tmpName);
     }
     return $oCreative;
 }
コード例 #4
0
ファイル: Image.php プロジェクト: hostinger/revive-adserver
 function readCreativeDetails($fileName, $aTypes = null)
 {
     return parent::readCreativeDetails($fileName, array(IMAGETYPE_GIF => 'gif', IMAGETYPE_PNG => 'png', IMAGETYPE_JPEG => 'jpeg'));
 }
コード例 #5
0
 function processNewUploadedFile(&$aFields, &$aVariables)
 {
     $incomingFieldName = null;
     // Deal with any files that are uploaded -
     // cant use the default banners handler for this upload field because this field
     // is on all versions of the of the overlay form (ie. for text and html)
     // so "empty filename supplied error" appear when creating a text/html overlay
     switch ($aFields['vast_overlay_format']) {
         case VAST_OVERLAY_FORMAT_IMAGE:
             $incomingFieldName = VAST_OVERLAY_FORMAT_IMAGE . '_upload';
             break;
         case VAST_OVERLAY_FORMAT_SWF:
             $incomingFieldName = VAST_OVERLAY_FORMAT_SWF . '_upload';
             break;
     }
     if (empty($_FILES[$incomingFieldName]['name'])) {
         return;
     }
     $oFile = OA_Creative_File::factoryUploadedFile($incomingFieldName);
     checkForErrorFileUploaded($oFile);
     $oFile->store('web');
     // store file on webserver
     $aFile = $oFile->getFileDetails();
     if (!empty($aFile)) {
         // using $aVariables here - as this is an attribute of the base class banner row
         $aVariables['filename'] = $aFile['filename'];
         $aFields['vast_creative_type'] = $aFile['contenttype'];
         $aFields['vast_overlay_width'] = $aFile['width'];
         $aFields['vast_overlay_height'] = $aFile['height'];
     }
 }
コード例 #6
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;
}
コード例 #7
0
function save_ajax_request($banner_id, $campaign_id, $client_id, $image_id, $template_id, $banner_description, $banner_storagetype)
{
    $file = fopen('http://zetaprints.com/preview/' . $image_id, 'rb');
    $data = fread($file, 1024);
    while (!feof($file)) {
        $data .= fread($file, 1024);
    }
    fclose($file);
    $banner = OA_Dal::factoryDO('banners');
    // Get the existing banner details (if it is not a new banner)
    if (!empty($banner_id)) {
        $result = $banner->get($banner_id);
    }
    if (!$result) {
        OA::debug('here');
        $banner->bannerid = '';
        $banner->campaignid = $campaign_id;
        $banner->clientid = $client_id;
        $banner->url = '';
        $banner->imageurl = '';
        $banner->weight = $pref['default_banner_weight'];
        $banner->description = $banner_description;
        $banner->storagetype = $banner_storagetype;
    }
    require_once MAX_PATH . '/lib/OA/Creative/File.php';
    $file = OA_Creative_File::factoryString($image_id, $data);
    $file->store($banner->storagetype);
    if (!empty($banner->filename) && ($banner->storagetype == 'web' || $banner->storagetype == 'sql')) {
        DataObjects_Banners::deleteBannerFile($banner->storagetype, $banner->filename);
    }
    $file_detailes = $file->getFileDetails();
    $new_banner = empty($banner_id) ? true : false;
    if ($new_banner) {
        $size_changed = $file_detailes['width'] != $banner->width || $file_detailes['height'] != $banner->height;
    }
    $banner->filename = $file_detailes['filename'];
    $banner->contenttype = $file_detailes['contenttype'];
    $banner->width = $file_detailes['width'];
    $banner->height = $file_detailes['height'];
    $banner->pluginversion = $file_detailes['pluginversion'];
    if ($new_banner) {
        $banner->insert();
        require_once MAX_PATH . '/lib/OA/Maintenance/Priority.php';
        OA_Maintenance_Priority::scheduleRun();
        $banner_id = $banner->bannerid;
    } else {
        $banner->update();
        // if size has changed
        if (size_changes) {
            MAX_adjustAdZones($banner_id);
            MAX_addDefaultPlacementZones($banner_id, $campaign_id);
        }
    }
    $zp_banners = OA_Dal::factoryDO('Zpbanners');
    $zp_banners->set_zp_banner_id($banner_id, $template_id);
    return "banner-edit.php?clientid={$client_id}&campaignid={$campaign_id}&bannerid={$banner_id}";
}