url(); $str = ""; /* 取得广告的信息 */ $sql = 'SELECT ad.ad_id, ad.ad_name, ad.ad_link, ad.ad_code '. 'FROM ' . $ecs->table('ad') . ' AS ad ' . 'LEFT JOIN ' . $ecs->table('ad_position') . ' AS p ON ad.position_id = p.position_id '. "WHERE ad.ad_id = '$ad_id' and " . gmtime() . " >= ad.start_time and " . gmtime() . "<= ad.end_time"; $ad_info = $db->getRow($sql); if (!empty($ad_info)) { /* 转换编码 */ if ($_GET['charset'] != 'UTF8') { $ad_info['ad_name'] = ecs_iconv('UTF8', $_GET['charset'], $ad_info['ad_name']); $ad_info['ad_code'] = ecs_iconv('UTF8', $_GET['charset'], $ad_info['ad_code']); } /* 初始化广告的类型和来源 */ $_GET['type'] = !empty($_GET['type']) ? intval($_GET['type']) : 0; $_GET['from'] = !empty($_GET['from']) ? urlencode($_GET['from']) : ''; $str = ''; switch ($_GET['type']) { case '0': /* 图片广告 */ $src = (strpos($ad_info['ad_code'], '//') === false && strpos($ad_info['ad_code'], 'https://') === false) ? $url . DATA_DIR . "/afficheimg/$ad_info[ad_code]" : $ad_info['ad_code']; $str = '湖北快三'; break; case '1': /* Falsh广告 */ $src = (strpos($ad_info['ad_code'], '//') === false && strpos($ad_info['ad_code'], 'https://') === false) ? $url . DATA_DIR . '/afficheimg/' . $ad_info['ad_code'] : $ad_info['ad_code']; $str = ' '; break; case '2': /* 代码广告 */ $str = $ad_info['ad_code']; break; case 3: /* 文字广告 */ $str = '' . nl2br(htmlspecialchars(addslashes($ad_info['ad_code']))). ''; break; } } echo "document.writeln('$str');"; } else { /* 获取投放站点的名称 */ $site_name = !empty($_GET['from']) ?htmlspecialchars($_GET['from']) : addslashes($_LANG['self_site']); /* 商品的ID */ $goods_id = !empty($_GET['goods_id']) ? intval($_GET['goods_id']) : 0; /* 存入SESSION中,购物后一起存到订单数据表里 */ $_SESSION['from_ad'] = $ad_id; $_SESSION['referer'] = stripslashes($site_name); /* 如果是商品的站外JS */ if ($ad_id == '-1') { $sql = "SELECT count(*) FROM " . $ecs->table('adsense') . " WHERE from_ad = '-1' AND referer = '" . $site_name . "'"; if($db->getOne($sql) > 0) { $sql = "UPDATE " . $ecs->table('adsense') . " SET clicks = clicks + 1 WHERE from_ad = '-1' AND referer = '" . $site_name . "'"; } else { $sql = "INSERT INTO " . $ecs->table('adsense') . "(from_ad, referer, clicks) VALUES ('-1', '" . $site_name . "', '1')"; } $db->query($sql); //$db->autoReplace($ecs->table('adsense'), array('from_ad' => -1, 'referer' => $site_name, 'clicks' => 1), array('clicks' => 1)); $sql = "SELECT goods_name FROM " .$ecs->table('goods'). " WHERE goods_id = $goods_id"; $res = $db->query($sql); $row = $db->fetchRow($res); $uri = build_uri('goods', array('gid' => $goods_id), $row['goods_name']); ecs_header("Location: $uri\n"); exit; } else { /* 更新站内广告的点击次数 */ $db->query('UPDATE ' . $ecs->table('ad') . " SET click_count = click_count + 1 WHERE ad_id = '$ad_id'"); $sql = "SELECT count(*) FROM " . $ecs->table('adsense') . " WHERE from_ad = '" . $ad_id . "' AND referer = '" . $site_name . "'"; if($db->getOne($sql) > 0) { $sql = "UPDATE " . $ecs->table('adsense') . " SET clicks = clicks + 1 WHERE from_ad = '" . $ad_id . "' AND referer = '" . $site_name . "'"; } else { $sql = "INSERT INTO " . $ecs->table('adsense') . "(from_ad, referer, clicks) VALUES ('" . $ad_id . "', '" . $site_name . "', '1')"; } $db->query($sql); $sql="SELECT * FROM ". $ecs->table('ad') ." WHERE ad_id = '$ad_id'"; $ad_info=$db->getRow($sql); /* 跳转到广告的链接页面 */ if (!empty($ad_info['ad_link'])) { $uri = (strpos($ad_info['ad_link'], '//') === false && strpos($ad_info['ad_link'], 'https://') === false ) ? $ecs->http() . urldecode($ad_info['ad_link']) : urldecode($ad_info['ad_link']); } else { $uri = $ecs->url(); } ecs_header("Location: $uri\n"); exit; } } ?>
  • 大力弘扬革命传统传承红色基因 持续深化作风建设造福老区人民 2018-09-18
  • 上海公办园占比超过六成 2018-07-25
  • 谢森的专栏作者中国国家地理网 2018-07-25
  • 习近平同哈萨克斯坦总统纳扎尔巴耶夫举行会谈 2018-07-24
  • 税费“红包”助推高质量发展 2018-07-23
  • 王小东任南宁市委委员、常委、书记 2018-07-22
  • 老师:讲课再累都不怕 就怕各级搞检查讲课再累都不怕-教育时讯 2018-07-22
  • 向着太阳出发:2018里昂——广州新丝绸之路太阳能自行车骑行赛揭幕 2018-07-21
  • 中生代女演员“不用焦虑” 2018-07-20
  • 【十九大·理论新视野】动漫:“美丽中国”如何绘就 2018-07-20
  • 中国,向大洋更深处挺进(评论员观察) 2018-07-19