function insert_get_ad($arr) { $position_name = $arr['cat_name'] . $arr['ad_name']; /* 替换广告 */ $obj_ad = class_ad::new_ad(); $new_ad = $obj_ad->replace_ad($position_name); /* end */ $time = gmtime(); if (empty($arr['num']) || $arr['num'] < 1) { $arr['num'] = 1; } if (!empty($arr['cat_name']) && !empty($arr['ad_name'])) { $sql = 'SELECT a.ad_id, a.position_id, a.media_type, a.ad_link, a.ad_code, a.ad_name, p.ad_width, ' . 'p.ad_height, p.position_style ' . 'FROM ' . $GLOBALS['ecs']->table('ad') . ' AS a ' . 'LEFT JOIN ' . $GLOBALS['ecs']->table('ad_position') . ' AS p ON a.position_id = p.position_id ' . "WHERE enabled = 1 AND start_time <= '" . $time . "' AND end_time >= '" . $time . "' " . "AND p.position_name = '" . $position_name . "' " . 'ORDER BY a.ad_id ASC LIMIT ' . $arr['num']; $res = $GLOBALS['db']->GetAll($sql); } else { echo "cat_goods.lbi缺少参数"; } foreach ($res as $idx => $row) { switch ($row['media_type']) { case 0: // 图片广告 $res[$idx]['link'] = urlencode($row["ad_link"]); $res[$idx]['src'] = strpos($row['ad_code'], 'http://') === false && strpos($row['ad_code'], 'https://') === false ? img_url() . DATA_DIR . "/afficheimg/{$row['ad_code']}" : $row['ad_code']; break; } } $need_cache = $GLOBALS['smarty']->caching; $GLOBALS['smarty']->caching = false; $GLOBALS['smarty']->assign('ad_res', $res); $GLOBALS['smarty']->assign('type', $arr['type']); $GLOBALS['smarty']->assign('media_type', $arr['media_type']); $val = $GLOBALS['smarty']->fetch('library/get_ad.lbi'); $GLOBALS['smarty']->caching = $need_cache; if ($position_name != $new_ad) { return $new_ad; } return $val; }
} admin_log('', 'remove', 'ads'); $url = 'new_ads.php?act=query&' . str_replace('act=remove', '', $_SERVER['QUERY_STRING']); ecs_header("Location: {$url}\n"); exit; } elseif ($_REQUEST['act'] == 'query') { $ads_list = get_newadslist(); $smarty->assign('ads_list', $ads_list['ads']); $smarty->assign('filter', $ads_list['filter']); $smarty->assign('record_count', $ads_list['record_count']); $smarty->assign('page_count', $ads_list['page_count']); $sort_flag = sort_flag($ads_list['filter']); $smarty->assign($sort_flag['tag'], $sort_flag['img']); make_json_result($smarty->fetch('new_ads_list.htm'), '', array('filter' => $ads_list['filter'], 'page_count' => $ads_list['page_count'])); } elseif ($_REQUEST['act'] == 'copy_ad') { $ad_obj = class_ad::new_ad(); $ad_obj->create_agency_ad(); $href[] = array('text' => '广告列表', 'href' => 'new_ads.php?act=list'); sys_msg('生成完毕', 0, $href); } /* 获取广告数据列表 */ function get_newadslist() { /* 过滤查询 */ $ad_name = !empty($_REQUEST['ad_name']) ? (string) $_REQUEST['ad_name'] : ''; $filter = array(); $filter['ad_name'] = $ad_name; $filter['admin_agency_id'] = !empty($_REQUEST['admin_agency_id']) ? (int) $_REQUEST['admin_agency_id'] : '0'; $filter['sort_by'] = empty($_REQUEST['sort_by']) ? 'ad_name' : trim($_REQUEST['sort_by']); $filter['sort_order'] = empty($_REQUEST['sort_order']) ? 'DESC' : trim($_REQUEST['sort_order']); $where = 'WHERE 1 ';
} if ((DEBUG_MODE & 4) == 4) { include ROOT_PATH . 'includes/lib.debug.php'; } /* 判断是否支持 Gzip 模式 */ if (!defined('INIT_NO_SMARTY') && gzip_enabled()) { ob_start('ob_gzhandler'); } else { ob_start(); } /*头部二维码 add by hg 2014-07-22*/ $code_url = $present_url; //goods_id其实是二维码图片名 $code_url = 'http://' . $code_url . '/codeImg.php?url=http://' . $code_url . '&goods_id=' . $code_url; if (isset($smarty)) { $smarty->assign('code_url', $code_url); } /* 广告赋值 */ if (isset($smarty)) { $obj_ad = class_ad::new_ad(); $show_ad = $obj_ad->get_res(); //dump($show_ad); $smarty->assign('show_ad', $show_ad); } /* 第三方登录显示 */ if (isset($smarty)) { $login_domain = array(); $login_domain = array('localhost', 'www.txd168.com', 'tg01.txd168.com', 'lc.txd168.com'); $oath_login = in_array($_SERVER['HTTP_HOST'], $login_domain) ? 1 : 0; $smarty->assign('oath_login', $oath_login); }