Esempio n. 1
0
File: ad.php Progetto: h3len/Project
 function outputPlayerAds()
 {
     $para = array();
     $fileds = array_flip(array('pubid', 'mtype', 'brief', 'link', 'title', 'url', 'param', 'name', 'material', 'id', 'ad_id', 'pos_id', 'm3u8'));
     $para['offset'] = $this->input['offset'] ? intval(urldecode($this->input['offset'])) : 0;
     $para['count'] = $this->input['count'] ? intval(urldecode($this->input['count'])) : 100;
     if ($this->input['is_one']) {
         $para['count'] = 1;
     }
     $para['where'] = urldecode($this->get_condition());
     $para['arcinfo'] = json_decode(urldecode(html_entity_decode($this->input['vinfo'])), true);
     $para['colid'] = $this->input['colid'];
     $ad = new adv();
     $dostatistic = true;
     if ($this->input['preview']) {
         $dostatistic = false;
     }
     $ads = $ad->getAdDatas($para, $dostatistic);
     $this->setXmlNode('ads', 'ad');
     if ($ads) {
         foreach ($ads as $k => $r) {
             $r = array_intersect_key($r, $fileds);
             //链接不存在输出id=0
             if (!$r['link']) {
                 $r['pubid'] = 0;
             }
             if ($r['mtype'] == 'javascript') {
                 continue;
             }
             $this->addItem($r);
         }
     }
     $this->output();
 }
Esempio n. 2
0
 function show()
 {
     $hg_ad_js = ADV_DATA_DIR . 'script/hg_ad.js';
     if (!file_exists($hg_ad_js) || $this->input['forcejs']) {
         if (!is_dir(ADV_DATA_DIR . 'script/')) {
             hg_mkdir(ADV_DATA_DIR . 'script/');
         }
         $adjs = file_get_contents('./core/ad.js');
         hg_file_write($hg_ad_js, str_replace('{$addomain}', AD_DOMAIN, $adjs));
     }
     $para = array();
     $para['offset'] = $this->input['offset'] ? intval($this->input['offset']) : 0;
     $para['count'] = $this->input['count'] ? intval($this->input['count']) : 100;
     $para['where'] = urldecode($this->get_condition());
     $para['arcinfo'] = json_decode(urldecode($this->input['vinfo']), true);
     $para['colid'] = hg_filter_ids($this->input['colid']);
     $para['colid'] = $para['colid'] == -1 ? 0 : $para['colid'];
     $dostatistic = true;
     if ($this->input['preview']) {
         $dostatistic = false;
     }
     $ad = new adv();
     $ads = $ad->getAdDatas($para, $dostatistic);
     if ($ads) {
         $outputjs = '';
         foreach ($ads as $k => $r) {
             $_ad = $r;
             if (!is_array($r[0])) {
                 //不存在广告位多个广告
                 $_ad = array(0 => $r);
                 unset($r);
             }
             $_ad_tpl = '';
             foreach ($_ad as $r) {
                 if ($r['mtype'] != 'javascript') {
                     $is_js = 0;
                 } else {
                     $is_js = 1;
                 }
                 $r['param'] = array_merge((array) $r['param']['pos'], (array) $r['param']['ani']);
                 $r['param']['title'] = $r['title'];
                 $r['param']['content'] = build_ad_tpl($r['url'], $r['mtype'], $r['param']);
                 foreach ($r as $k => $v) {
                     if (is_array($v)) {
                         foreach ($v as $kk => $vv) {
                             ${$kk} = $vv;
                         }
                     } else {
                         ${$k} = $v;
                     }
                 }
                 if (!$tpl) {
                     $tpl = '{$content}';
                 }
                 $ad_tpl = stripslashes(preg_replace("/{(\\\$[a-zA-Z0-9_\\[\\]\\-\\'\"\$\\>\\.]+)}/ies", '${1}', $tpl));
                 $ad_tpl = preg_replace("/[\n]+/is", '', $ad_tpl);
                 //通过API进行统计
                 if ($link) {
                     if ($r['mtype'] != 'javascript') {
                         $_ad_tpl .= '<a href="' . AD_DOMAIN . 'click.php?a=doclick&url=' . urlencode($link) . '&pubid=' . $pubid . '" target="_blank">' . $ad_tpl . '</a>';
                     }
                 } else {
                     $_ad_tpl .= $ad_tpl;
                 }
                 if (!$ad_js_para) {
                     $ad_js_para = stripslashes(preg_replace("/{\\\$([a-zA-Z0-9_\\[\\]\\-\\'\"\$\\>\\.]+)}/ies", '${1} . ":\\"" . $${1} . "\\""', str_replace("\r\n", '', $js_para)));
                 }
             }
             $outputjs .= 'hg_AD_AddHtml({para:{' . $ad_js_para . '}, html:"' . addslashes($_ad_tpl) . '",box:"ad_' . $id . '",loadjs:"' . $include_js . '",loadurl:"' . ADV_DATA_URL . 'script/",isjs:' . $is_js . '});';
         }
         header('Content-Type:application/x-javascript');
         echo $outputjs;
     }
 }