function _duplicateAd($aAd, $checkUniqueNames = false) { require_once MAX_PATH . '/www/admin/lib-storage.inc.php'; // Copy the linked creative $newFile = phpAds_ImageDuplicate($aAd['type'], $aAd['filename']); if ($newFile !== false) { $aAd['filename'] = $newFile; } // Remove the existing advert id $adId = $aAd['ad_id']; unset($aAd['ad_id']); // Check for unique names if ($checkUniqueNames) { $aAds = Admin_DA::getAds(array('placement_id' => $aAd['placement_id'])); Admin_DA::_getUniqueName($aAd, $aAds, $GLOBALS['strCopy']); } // Add the new ad $newAdId = Admin_DA::addAd($aAd); // Copy the limitations $aLimitations = Admin_DA::getDeliveryLimitations(array('ad_id' => $adId)); foreach ($aLimitations as $aLimitation) { $aLimitation['ad_id'] = $newAdId; Admin_DA::addLimitation($aLimitation); } // Copy the zone ad associations $aAdZones = Admin_DA::getAdZones(array('ad_id' => $adId)); foreach ($aAdZones as $aAdZone) { $aAdZone['ad_id'] = $newAdId; Admin_DA::duplicateAdZone($aAdZone); } return $newAdId; }
/** * Wrapper for phpAds_ImageDuplicate * * @access private */ function _imageDuplicate($storagetype, $filename) { return phpAds_ImageDuplicate($storagetype, $filename); }
} phpAds_cacheDelete(); // Prevent HTTP response splitting if (!preg_match('/[\\r\\n]/', $returnurl)) { $url = stripslashes($returnurl); header("Location: " . $returnurl . "?clientid=" . $clientid . "&campaignid=" . $campaignid . "&bannerid=" . $applyto); } } elseif (isset($duplicate) && $duplicate == 'true') { // Duplicate the banner $res = phpAds_dbQuery("\n\t\t\tSELECT\n\t\t \t\t*\n\t\t\tFROM\n\t\t\t\t" . $phpAds_config['tbl_banners'] . "\n\t\t\tWHERE\n\t\t\t\tbannerid = '" . $bannerid . "'\n\t\t") or phpAds_sqlDie(); if ($row = phpAds_dbFetchArray($res)) { // Remove bannerid unset($row['bannerid']); // Duplicate stored banner if ($row['storagetype'] == 'web' || $row['storagetype'] == 'sql') { $row['filename'] = phpAds_ImageDuplicate($row['storagetype'], $row['filename']); if ($row['storagetype'] == 'sql') { // SQL-stored banner $row['imageurl'] = '{url_prefix}/adimage.php?filename=' . $row['filename'] . '&contenttype=' . $row['contenttype']; } else { // Web-stored banner $row['imageurl'] = $phpAds_config['type_web_url'] . '/' . $row['filename']; } $row['htmlcache'] = phpAds_getBannerCache($row); } // Clone banner $values_fields = ''; $values = ''; while (list($name, $value) = each($row)) { $values_fields .= "{$name}, "; $values .= "'" . addslashes($value) . "', ";