$banners['products'] = fn_get_aff_banners($_REQUEST['banner_type'], 'P', true); // [/Products banners] } if ($selected_section == 'url') { // [Products banners] $banners['url'] = fn_get_aff_banners($_REQUEST['banner_type'], 'U', true); // [/Products banners] } $js_banners = array(); foreach ($banners as $_key => $bans) { if (!empty($bans)) { foreach ($bans as $__key => $ban) { $js_banners[$ban['banner_id']]['example'] = fn_get_aff_banner_html('js', $ban); $js_banners[$ban['banner_id']]['code'] = fn_get_aff_banner_html('js', $ban, '', $auth['user_id']); if ($_REQUEST['banner_type'] == 'G') { $image_data = fn_get_aff_banner_image_data($ban['banner_id'], 'icon'); if (!empty($image_data)) { $banners[$_key][$__key] = fn_array_merge($ban, $image_data); } } if ($_REQUEST['banner_type'] != 'P') { $js_banners[$ban['banner_id']]['url'] = fn_get_aff_banner_url($ban, $auth['user_id']); } } } } $view->assign('banners', $banners); $view->assign('js_banners', $js_banners); if ($_REQUEST['banner_type'] == 'G') { $view->assign('mainbox_title', fn_get_lang_var('graphic_banners')); } elseif ($_REQUEST['banner_type'] == 'P') {
function fn_get_aff_banner_html($type, $banner_data, $mode = '', $partner_id = '', $lang_code = CART_LANGUAGE) { $banner_correct = true; $auth =& $_SESSION['auth']; if ((empty($banner_data['banner_id']) || empty($banner_data['type'])) && $mode != 'demo') { return false; } $banner_data['banner_url'] = fn_get_aff_banner_url($banner_data, $partner_id, $lang_code); $banner_data['flash_vars'] = "sl={$lang_code}" . (empty($partner_id) ? '' : "&aff_id={$partner_id}"); if ($banner_data['type'] == 'P') { $condition = ''; $join = ''; if (!empty($partner_id)) { $plan_data = fn_get_affiliate_plan_data_by_partner_id($partner_id); if (!empty($plan_data['product_ids'])) { $condition1 = db_quote("(?:products.product_id IN (?n))", array_keys($plan_data['product_ids'])); } if (!empty($plan_data['category_ids'])) { $condition2 = db_quote("(category_id IN (?n))", array_keys($plan_data['category_ids'])); $join .= " LEFT JOIN ?:products_categories ON ?:products.product_id = ?:products_categories.product_id "; } $condition .= !empty($condition1) && !empty($condition2) ? " AND ({$condition1} OR {$condition2}) " : (!empty($condition1) ? " AND {$condition1} " : (!empty($condition2) ? " AND {$condition2} " : '')); } if (!empty($banner_data['product_ids'])) { $condition .= db_quote(" AND ?:products.product_id IN (?n)", explode('-', $banner_data['product_ids'])); } $prod_cnt = db_get_field("SELECT COUNT(*) FROM ?:products {$join} WHERE status = 'A' {$condition}"); $product_id = db_get_field("SELECT ?:products.product_id FROM ?:products {$join} WHERE status = 'A' {$condition} LIMIT " . rand(0, $prod_cnt - 1) . ', 1'); if (!empty($product_id)) { $banner_data['product_id'] = $product_id; if ($mode != 'demo') { $banner_data['banner_url'] .= "&product_id={$banner_data['product_id']}"; } else { $banner_data['banner_url'] = ''; } $prod_data = fn_get_product_data($product_id, $auth, CART_LANGUAGE, "?:products.product_id, product, full_description as product_full_description, short_description as product_short_description", false, true, false); $banner_data = fn_array_merge($banner_data, $prod_data); if (!empty($banner_data['main_pair']['icon']['image_path'])) { $banner_data['main_pair']['icon']['image_path'] = 'http://' . Registry::get('config.http_host') . $banner_data['main_pair']['icon']['image_path']; } } else { $banner_correct = false; $banner_data['type'] = 'T'; $banner_data['link_to'] = 'U'; $banner_data['show_title'] = 'N'; $banner_data['content'] = '<div align="center" style="font-family: tahoma, arial; font-size: 12px;">' . fn_get_lang_var('warning') . '</div><hr size="0" style="border-top: #3b67d2 1px solid;" /><span style="font-family: tahoma, arial; font-size: 10px; color: #3b67d2;">' . fn_get_lang_var('text_no_products_found') . '</span>'; } } if (in_array($type, array('js_content', 'iframe'))) { $banner_data['border'] = empty($banner_data['border']) || $banner_data['border'] != 'Y' ? '' : 'style="border: #999999 1px solid;"'; } if (@$banner_data['type'] == 'G') { $image_data = fn_get_aff_banner_image_data($banner_data['banner_id'], 'icon', $lang_code); if (!empty($image_data)) { $banner_data = fn_array_merge($banner_data, $image_data); } } if (!empty($banner_data['width']) || !empty($banner_data['height'])) { $banner_data['wh_style'] = 'style="' . (!empty($banner_data['width']) ? "width:{$banner_data['width']}px;" : '') . (!empty($banner_data['height']) ? "height:{$banner_data['height']}px;" : '') . '"'; } else { $banner_data['wh_style'] = ''; } Registry::get('view')->assign('partner_id', $partner_id); Registry::get('view')->assign('banner_type', $type); Registry::get('view')->assign('mode', $mode); Registry::get('view')->assign('banner_data', $banner_data); Registry::get('view')->assign('no_image_path', 'http://' . Registry::get('config.http_host') . Registry::get('config.no_image_path')); Registry::get('view')->assign('affiliate_opts_settings', Registry::get('addons.affiliate')); $html_content = trim(Registry::get('view')->display('addons/affiliate/views/banners_manager/components/banner_content.tpl', false)); if ($type == 'js_content') { $html_content = fn_js_escape($html_content); } Registry::get('view')->assign('html_content', $html_content); $return_content = ''; if ($type == 'js' && $mode == 'demo' || $type == 'js_content') { $return_content .= fn_get_contents(DIR_ADDONS . 'affiliate/js/banner_script.js'); } $return_content .= trim(Registry::get('view')->display('addons/affiliate/views/banners_manager/components/banner.tpl', false)); if (in_array($type, array('iframe_content', 'js_content')) && !empty($partner_id) && $banner_correct) { fn_add_partner_action('show', $banner_data['banner_id'], $partner_id, '', array('R' => !empty($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '')); } return empty($return_content) ? false : $return_content; }