<?php

/*
 * ----------------------------------------------------
 * 程序名称: 牛叉广告管理系统(NiuXams)
 * 程序功能: 实现专业的广告投放、管理和统计等管理系统！
 * 程序开发: 牛叉软件(NiuXSoft.com)
 * 版权所有: [NiuXams] (C)2013-2099 NiuXSoft.com
 * 官方网站: www.niuxsoft.com  Email: niuxsoft@163.com
 * ----------------------------------------------------
 * 使用条款:
 * 1.为构建创新型经济社会,请尊重保护知识产权！
 * 2.该软件个人非商业用途免费使用.
 * 3.免费使用禁止修改版权信息和官方推广链接.
 * 4.禁止任何衍生版本.禁止任何非法修改源代码贩卖.
 * ----------------------------------------------------
 */

defined('NIUX_INCLUDED') or exit('Access Denied.');

function getLeiSelectList($type, $adminID, $adminPowerLB, $adminLBID, $lei = '') {
    global $cfg_dbprefix, $nxsql;
    if ($adminPowerLB == 1) {
        $query = "SELECT id,name FROM `${cfg_dbprefix}lei` WHERE type=${type} AND lb_id=${adminLBID};";
    } elseif ($adminPowerLB == 0) {
        $query = "SELECT id,name FROM `${cfg_dbprefix}lei` WHERE type=${type} AND admin_id=${adminID};";
    } else {
        $query = "SELECT id,name FROM `${cfg_dbprefix}lei` WHERE type=${type};";
    }
    $tmp = '';
    $eq = $lei ? $lei : (isset($_COOKIE['lei' . $type]) ? $_COOKIE['lei' . $type] : '');
    if ($result = $nxsql->query($query)) {
        while ($row = $result->fetch_row()) {
            $tmp .= '<option value="' . htmlspecialchars($row[0]) . '"' . ($eq == $row[0] ? ' selected="selected"' : '') . '>' . htmlspecialchars($row[1]) . '</option>';
        }
        $result->close();
    }
    return $tmp;
}

function getZuSelectList($type, $adminID, $adminPowerLB, $adminLBID, $zu = '') {
    global $cfg_dbprefix, $nxsql;
    if ($adminPowerLB == 1) {
        $query = "SELECT id,name FROM `${cfg_dbprefix}zu` WHERE type=${type} AND lb_id=${adminLBID};";
    } elseif ($adminPowerLB == 0) {
        $query = "SELECT id,name FROM `${cfg_dbprefix}zu` WHERE type=${type} AND admin_id=${adminID};";
    } else {
        $query = "SELECT id,name FROM `${cfg_dbprefix}zu` WHERE type=${type};";
    }
    $tmp = '';
    $eq = $zu ? $zu : (isset($_COOKIE['zu' . $type]) ? $_COOKIE['zu' . $type] : '');
    if ($result = $nxsql->query($query)) {
        while ($row = $result->fetch_row()) {
            $tmp .= '<option value="' . htmlspecialchars($row[0]) . '"' . ($eq == $row[0] ? ' selected="selected"' : '') . '>' . htmlspecialchars($row[1]) . '</option>';
        }
        $result->close();
    }
    return $tmp;
}

function getLHcln($num) {
    if ($num == 5) {
        $cln = '幻灯片';
    } elseif ($num == 4) {
        $cln = '同时投放';
    } elseif ($num == 3) {
        $cln = '顺序循环';
    } elseif ($num == 2) {
        $cln = '手动比例';
    } else {
        $cln = '均匀随机';
    }
    return $cln;
}

function getGGdm($id, $ggType, $ggContent, $ggTj, $ggYb, $ggWidth, $ggHeight, $ggHref) {
    $ggDm = 'var gg={a:' . $ggType . ',b:unescape("' . $ggContent . '"),c:' . $ggTj . ',d:' . $ggYb . ',e:' . $ggWidth . ',f:' . $ggHeight . ',g:' . $id . ',h:"' . $ggHref . '"};';
    return $ggDm;
}

function getGGCLdm($id, $wllx, $ggclWeight, $xzggs, $rotate_cl, $slide_interval, $time_cl, $time_content, $limit_gg, $limit_gg_num, $limit_visitor, $visitor_num, $os_cl, $os_content, $screen_cl, $screen_content, $browser_cl, $browser_content, $lang_cl, $lang_content, $referer_cl, $referer_content, $url_cl, $url_content, $local_cl, $local_content, $ua_cl, $ua_content) {
    global $cfg_amsUrl, $cfg_output, $cfg_thread, $cfg_book, $cfg_forum;
    $clDm = '(function(){var a=' . $wllx . ',b=' . $ggclWeight . ',e=[];if(!a&&b<=p)return;';
    if ($time_content) {
        $clDm .= 'var r=new Date(),s=r.getFullYear(),t=r.getMonth()+1,u=r.getDate(),v=r.getDay()||7,w=r.getHours();if(';
        $time_cl || $clDm .= '!(';
        $time_array = explode('. ', $time_content);
        $size = count($time_array) - 1;
        for ($i = 0; $i < $size; $i++) {
            if ($time_array[$i]) {
                $time_content_array = explode(', ', $time_array[$i]);
                list($time_begin, $time_end) = explode('-', $time_content_array[1]);
                if ((int) $time_begin > (int) $time_end) {
                    $ls = $time_begin;
                    $time_begin = $time_end;
                    $time_end = $ls;
                }
                switch ($time_content_array[0]) {
                    case 'nianfen':
                        $i && $clDm .= '&&';
                        $clDm .= 's>=' . $time_begin . '&&s<=' . $time_end;
                        break;
                    case 'yuefen':
                        $i && $clDm .= '&&';
                        $clDm .= 't>=' . $time_begin . '&&t<=' . $time_end;
                        break;
                    case 'riqi':
                        $i && $clDm .= '&&';
                        $clDm .= 'u>=' . $time_begin . '&&u<=' . $time_end;
                        break;
                    case 'xingqi':
                        $i && $clDm .= '&&';
                        $clDm .= 'v>=' . $time_begin . '&&v<=' . $time_end;
                        break;
                    case 'xiaoshi':
                        $i && $clDm .= '&&';
                        $clDm .= 'w>=' . $time_begin . '&&w<=' . $time_end;
                        break;
                }
            }
        }
        $time_cl || $clDm .= ')';
        $clDm .= ')return;';
    }
    if ($limit_gg && $limit_gg_num && count(explode('. ', $xzggs)) == 2) {
        $ggData = explode(', ', $xzggs);
        $ggGidId = explode(' / ', $ggData[0]);
        $clDm .= 'var r=null;try{r=new XMLHttpRequest()}catch(e){try{r=new ActiveXObject("Microsoft.XMLHTTP")}catch(e){return}}r.open("GET",l+"counter.php?ac=3&id=' . $ggGidId[1] . '&class=' . $limit_gg . '",!1);r.send();if(r.responseText>=' . $limit_gg_num . ')return;';
    }
    if ($limit_visitor && $visitor_num && count(explode('. ', $xzggs)) == 2) {
        switch ($limit_visitor) {
            case 1:
                $xztime = 24 * 60 * 60;
                break;
            case 2:
                $xztime = 60 * 60;
                break;
            case 3:
                $xztime = 30 * 60;
                break;
            case 4:
                $xztime = 10 * 60;
                break;
            case 5:
                $xztime = 60;
                break;
        }
        $ggData = explode(', ', $xzggs);
        $ggGidId = explode(' / ', $ggData[0]);
        $clDm .= 'var r="' . $cfg_thread . '-' . $ggGidId[1] . '",s=' . $xztime . ',t=0,u=g.cookie,v=u.indexOf(r+"="),w=-1,x=new Date;-1!=v&&(v+=r.length+1,w=u.indexOf(";",v),-1==w&&(w=u.length),t=parseInt(u.substring(v,w)));if(t>=' . $visitor_num . '){return}else{x.setSeconds(x.getSeconds()+s);g.cookie=r+"="+escape(t+1)+";expires="+x.toGMTString()+";path=/"}';
    }
    if ($os_content) {
        $clDm .= 'var r=f.navigator.userAgent.toLowerCase();if(';
        $os_cl || $clDm .= '!(';
        $os_array = explode(', ', $os_content);
        $size = count($os_array);
        for ($i = 0; $i < $size; $i++) {
            if ($os_array[$i]) {
                switch ($os_array[$i]) {
                    case 'Windows':
                        $i && $clDm .= '||';
                        $clDm .= 'r.indexOf("win")>-1';
                        break;
                    case 'Windows Phone':
                        $i && $clDm .= '||';
                        $clDm .= 'r.indexOf("windows phone")>-1';
                        break;
                    case 'Mac':
                        $i && $clDm .= '||';
                        $clDm .= 'r.indexOf("mac")>-1';
                        break;
                    case 'iOS':
                        $i && $clDm .= '||';
                        $clDm .= 'r.indexOf("ios")>-1';
                        break;
                    case 'iPhone':
                        $i && $clDm .= '||';
                        $clDm .= 'r.indexOf("iphone")>-1';
                        break;
                    case 'iPad':
                        $i && $clDm .= '||';
                        $clDm .= 'r.indexOf("ipad")>-1';
                        break;
                    case 'iPod':
                        $i && $clDm .= '||';
                        $clDm .= 'r.indexOf("ipod")>-1';
                        break;
                    case 'Android':
                        $i && $clDm .= '||';
                        $clDm .= 'r.indexOf("android")>-1';
                        break;
                    case 'BlackBerry':
                        $i && $clDm .= '||';
                        $clDm .= 'r.indexOf("blackberry")>-1';
                        break;
                    case 'Linux':
                        $i && $clDm .= '||';
                        $clDm .= 'r.indexOf("linux")>-1';
                        break;
                    case 'Unix':
                        $i && $clDm .= '||';
                        $clDm .= 'r.indexOf("unix")>-1';
                        break;
                }
            }
        }
        $os_cl || $clDm .= ')';
        $clDm .= ')return;';
    }
    if ($screen_content) {
        $clDm .= 'var r=f.screen,s=(r.width||r.availWidth)+"*"+(r.height||r.availHeight);if(';
        $screen_cl || $clDm .= '!(';
        $screen_array = explode(', ', $screen_content);
        $size = count($screen_array);
        for ($i = 0; $i < $size; $i++) {
            $i && $clDm .= '||';
            $clDm .= 's=="' . $screen_array[$i] . '"';
        }
        $screen_cl || $clDm .= ')';
        $clDm .= ')return;';
    }
    if ($browser_content) {
        $clDm .= 'var r=f.navigator.userAgent.toLowerCase();if(';
        $browser_cl || $clDm .= '!(';
        $browser_array = explode(', ', $browser_content);
        $size = count($browser_array);
        for ($i = 0; $i < $size; $i++) {
            if ($browser_array[$i]) {
                switch ($browser_array[$i]) {
                    case 'Internet Explorer 6':
                        $i && $clDm .= '||';
                        $clDm .= 'r.indexOf("msie 6")>-1';
                        break;
                    case 'Internet Explorer 7':
                        $i && $clDm .= '||';
                        $clDm .= 'r.indexOf("msie 7")>-1';
                        break;
                    case 'Internet Explorer 8':
                        $i && $clDm .= '||';
                        $clDm .= 'r.indexOf("msie 8")>-1';
                        break;
                    case 'Internet Explorer 9':
                        $i && $clDm .= '||';
                        $clDm .= 'r.indexOf("msie 9")>-1';
                        break;
                    case 'Internet Explorer 10':
                        $i && $clDm .= '||';
                        $clDm .= 'r.indexOf("msie 10")>-1';
                        break;
                    case 'Internet Explorer 11':
                        $i && $clDm .= '||';
                        $clDm .= 'r.indexOf("msie 11")>-1';
                        break;
                    case 'Edge':
                        $i && $clDm .= '||';
                        $clDm .= 'r.indexOf("edge")>-1';
                        break;
                    case 'IEMobile':
                        $i && $clDm .= '||';
                        $clDm .= 'r.indexOf("mobile")>-1';
                        break;
                    case 'Chrome':
                        $i && $clDm .= '||';
                        $clDm .= 'r.indexOf("chrome")>-1';
                        break;
                    case 'Safari':
                        $i && $clDm .= '||';
                        $clDm .= 'r.indexOf("safari")>-1';
                        break;
                    case 'Firefox':
                        $i && $clDm .= '||';
                        $clDm .= 'r.indexOf("firefox")>-1';
                        break;
                    case 'Mozilla':
                        $i && $clDm .= '||';
                        $clDm .= 'r.indexOf("mozilla")>-1';
                        break;
                    case 'Opera':
                        $i && $clDm .= '||';
                        $clDm .= 'r.indexOf("opera")>-1';
                        break;
                }
            }
        }
        $browser_cl || $clDm .= ')';
        $clDm .= ')return;';
    }
    if ($lang_content) {
        $clDm .= 'var r=f.navigator.language.toLowerCase();if(';
        $lang_cl || $clDm .= '!(';
        $lang_array = explode(', ', $lang_content);
        $size = count($lang_array);
        for ($i = 0; $i < $size; $i++) {
            if ($lang_array[$i]) {
                $i && $clDm .= '||';
                $clDm .= 'r.indexOf("' . $lang_array[$i] . '")>-1';
            }
        }
        $lang_cl || $clDm .= ')';
        $clDm .= ')return;';
    }
    if ($referer_content) {
        $clDm .= 'var r=g.referrer||"direct";if(';
        $referer_cl || $clDm .= '!(';
        $referer_array = explode("\n", $referer_content);
        $size = count($referer_array);
        for ($i = 0; $i < $size; $i++) {
            if ($referer_array[$i]) {
                $referer_array[$i] = strtr($referer_array[$i], "\r", '');
                $i && $clDm .= '||';
                $clDm .= 'r.indexOf("' . htmlspecialchars($referer_array[$i]) . '")>-1';
            }
        }
        $referer_cl || $clDm .= ')';
        $clDm .= ')return;';
    }
    if ($url_content) {
        $clDm .= 'var r=g.URL||f.location.href;if(';
        $url_cl || $clDm .= '!(';
        $url_array = explode("\n", $url_content);
        $size = count($url_array);
        for ($i = 0; $i < $size; $i++) {
            if ($url_array[$i]) {
                $url_array[$i] = strtr($url_array[$i], "\r", '');
                $i && $clDm .= '||';
                $clDm .= 'r.indexOf("' . htmlspecialchars($url_array[$i]) . '")>-1';
            }
        }
        $url_cl || $clDm .= ')';
        $clDm .= ')return;';
    }
    if ($local_content) {
        $clDm .= 'var r=null,s;try{r=new XMLHttpRequest()}catch(e){try{r=new ActiveXObject("Microsoft.XMLHTTP")}catch(e){return}}r.open("GET",l+"agent.php",!1);r.send();s=r.responseText;if(';
        $local_cl || $clDm .= '!(';
        $local_array = explode("\n", $local_content);
        $size = count($local_array);
        for ($i = 0; $i < $size; $i++) {
            if ($local_array[$i]) {
                $local_array[$i] = strtr($local_array[$i], "\r", '');
                $i && $clDm .= '||';
                $clDm .= 's.indexOf("' . htmlspecialchars($local_array[$i]) . '")>-1';
            }
        }
        $local_cl || $clDm .= ')';
        $clDm .= ')return;';
    }
    if ($ua_content) {
        $clDm .= 'var r=f.navigator.userAgent.toLowerCase();if(';
        $ua_cl || $clDm .= '!(';
        $ua_array = explode("\n", $ua_content);
        $size = count($ua_array);
        for ($i = 0; $i < $size; $i++) {
            if ($ua_array[$i]) {
                $ua_array[$i] = strtr($ua_array[$i], "\r", '');
                $i && $clDm .= '||';
                $clDm .= 'r.indexOf("' . htmlspecialchars($ua_array[$i]) . '")>-1';
            }
        }
        $ua_cl || $clDm .= ')';
        $clDm .= ')return;';
    }
    if ($xzggs) {
        $gg_array = explode('. ', $xzggs);
        $size = count($gg_array) - 1;
        $ggbl = 0;
        $ggcl = '';
        for ($i = 0; $i < $size; $i++) {
            if ($gg_array[$i]) {
                list($gg_gid_id, $gg_bl) = explode(', ', $gg_array[$i]);
                list($gg_gid, $gg_id) = explode(' / ', $gg_gid_id);
                $ggDm = substr(insou(@file_get_contents(ROOT_DIR . $cfg_output . '/' . $cfg_thread . '-' . $gg_id . '.js')), 7, -1);
                if ($size == 1) {
                    $clDm .= 'e=[' . $ggDm . '];';
                } else {
                    switch ($rotate_cl) {
                        case 1:
                            if ($i == 0) {
                                $clDm .= 'var r=Math.floor(Math.random()*' . $size . ');if(r==' . $i . ')e=[' . $ggDm . '];';
                            } else {
                                $clDm .= 'else if(r==' . $i . ')e=[' . $ggDm . '];';
                            }
                            break;
                        case 2:
                            $ggbl += $gg_bl;
                            if ($i == 0) {
                                $ggcl = 'if(r<=' . $ggbl . ')e=[' . $ggDm . '];';
                            } else {
                                $ggcl = $ggcl . 'else if(r<=' . $ggbl . ')e=[' . $ggDm . '];';
                            }
                            if ($i == $size - 1) {
                                $clDm .= 'var r=Math.ceil(Math.random()*' . $ggbl . ');' . $ggcl;
                            }
                            break;
                        case 3:
                            $ggcl = $ggcl . 'case ' . ($i + 1) % $size . ':e=[' . $ggDm . '];break;';
                            if ($i == $size - 1) {
                                $clDm .= 'var r="' . $cfg_forum . '-"+j.e,s=1,t=g.cookie,u=t.indexOf(r+"="),v=-1;-1!=u&&(u+=r.length+1,v=t.indexOf(";",u),-1==v&&(v=t.length),s=parseInt(t.substring(u,v)));g.cookie=r+"="+(s+1)+";path=/";switch(s%' . $size . '){' . rtrim($ggcl) . '}';
                            }
                            break;
                        case 4:
                            $ggcl = $ggcl . $ggDm . ',';
                            if ($i == $size - 1) {
                                $clDm .= 'e=[' . rtrim($ggcl, ',') . '];';
                            }
                            break;
                        case 5:
                            $ggcl = $ggcl . '"' . $cfg_thread . '-' . $gg_id . '",';
                            if ($i == $size - 1) {
                                $clDm .= 'e=[{b:\'<iframe frameborder="0" scrolling="no" allowtransparency="true"></iframe><script>(function(){var c=[' . rtrim($ggcl, ',') . '],e=c.length,a=0,f="' . $cfg_amsUrl . '/' . $cfg_output . '/thread.html?ggwId=\'+j.e+\'&W=\'+j.c+\'&H=\'+j.d+\'&gg=",d=document.getElementsByTagName("script"),b=d[d.length-1].previousElementSibling||d[d.length-1].previousSibling;b.width=\'+j.c+\'||"100%";b.height=\'+j.d+\'||"100%";b.src=f+c[a];setInterval(function(){a<e-1?a++:a=0;b.src=f+c[a]+"&sid="+Math.random()},' . $slide_interval . 'E3)})();</script>\'}];';
                            }
                            break;
                    }
                }
            }
        }
    }
    return $clDm . 'e.length&&(a?h=h.concat(e):(c=e,p=b))})();';
}

function getGGWdm($id, $xzggcls, $bjgg, $ggwType, $ggwWidth, $ggwHeight) {
    global $cfg_amsUrl, $cfg_output, $cfg_thread, $cfg_book, $cfg_nameSpace;
    $ggwDm = '(function(f){var g=f.document,d=f.' . $cfg_nameSpace . '||{},c=g.getElementsByTagName("script"),k=c[c.length-1],j={a:k,b:' . $ggwType . ',c:' . $ggwWidth . ',d:' . $ggwHeight . ',e:' . $id . '},c=[],h=[],p=0,l="' . $cfg_amsUrl . '/' . $cfg_output . '/";';
    if ($xzggcls) {
        $ggcl_array = explode('. ', $xzggcls);
        $size = count($ggcl_array) - 1;
        for ($i = 0; $i < $size; $i++) {
            if ($ggcl_array[$i]) {
                list($ggcl_gid, $ggcl_id) = explode(' / ', $ggcl_array[$i]);
                $ggwDm .= insou(@file_get_contents(ROOT_DIR . $cfg_output . '/' . $cfg_book . '-' . $ggcl_id . '.js'));
            }
        }
    }
    if ($bjgg) {
        list($gg_gid, $gg_id) = explode(' / ', $bjgg);
        $ggDm = substr(insou(@file_get_contents(ROOT_DIR . $cfg_output . '/' . $cfg_thread . '-' . $gg_id . '.js')), 7, -1);
        if ($ggwType) {
            $ggwDm .= 'h.length||(h=[' . $ggDm . ']);';
        } else {
            $ggwDm .= 'c.length||(c=[' . $ggDm . ']);';
        }
    }
    return $ggwDm . '(function(c){for(var b="",h,e,a=0,m=c.length;a<m;a++)b+=c[a].b,!c[a].d&&/<\/script>/gi.test(c[a].b)&&(e=1),c[a].c&&(h=1);if(b){if(e)g.write("<div>"+b+"</div>");else{e=g.createElement("div");e.innerHTML=b;b=e.getElementsByTagName("script");a=0;for(m=b.length;a<m;a++)if(b[a].src){var n=g.createElement("script");n.src=b[a].src;b[a].charset&&(n.charset=b[a].charset);e.replaceChild(n,b[a])}else(f.execScript||function(a){f.eval.call(f,a)})(b[a].text||b[a].textContent||b[a].innerHTML||"");k.parentNode.insertBefore(e,k.nextSibling)}h&&(d.a=d.a||[],d.a.push({a:j,b:c}),d.b||(d.b=l,g.write(\'<script src="\'+l+\'counter.js"><\/script>\')))}})(c.concat(h));f.' . $cfg_nameSpace . '=d})(window);';
}

function updateGgw($ggclId) {
    global $cfg_dbprefix, $nxsql, $cfg_output, $cfg_forum;
    $query = "SELECT id,ggcl,recycle,bjgg,type,width,height FROM ${cfg_dbprefix}ggw WHERE ggcl LIKE '%{$ggclId}%';";
    if ($result = $nxsql->query($query)) {
        while ($row = $result->fetch_row()) {
            $id_array = explode(' ', rtrim(preg_replace('|(.+?)( \/ )(.+?)(\. )|is', "$3 ", $row[1])));
            if (in_array($ggclId, $id_array)) {
                $path = ROOT_DIR . $cfg_output . '/' . $cfg_forum . '-' . $row[0] . '.js' . ($row[2] ? 'recycle' : '');
                $ggwDm = getGGWdm($row[0], $row[1], $row[3], $row[4], $row[5], $row[6]);
                file_put_contents($path, $ggwDm) or die('出错啦！无法修改广告位文件！请检查输出目录名称、权限设置是否正确。');
            }
        }
    }
}

function updateGgcl($ggId) {
    global $cfg_dbprefix, $nxsql, $cfg_output, $cfg_forum, $cfg_book;
    $query = "SELECT id,gg,recycle,type,weight,rotate_cl,slide_interval,time_cl,time_content,limit_gg,limit_gg_num"
            . ",limit_visitor,visitor_num,os_cl,os_content,screen_cl,screen_content,browser_cl,browser_content,lang_cl,lang_content,"
            . "referer_cl,referer_content,url_cl,url_content,local_cl,local_content,ua_cl,ua_content FROM ${cfg_dbprefix}ggcl WHERE gg LIKE '%{$ggId}%';";
    if ($result = $nxsql->query($query)) {
        while ($row = $result->fetch_row()) {
            $id_array = explode(' ', rtrim(preg_replace('|(.+?)( \/ )(.+?)(, )(.+?)(\. )|is', "$3 ", $row[1])));
            if (in_array($ggId, $id_array)) {
                $path = ROOT_DIR . $cfg_output . '/' . $cfg_book . '-' . $row[0] . '.js' . ($row[2] ? 'recycle' : '');
                $ggclDm = getGGCLdm($row[0], $row[3], $row[4], $row[1], $row[5], $row[6], $row[7], $row[8], $row[9], $row[10], $row[11], $row[12], $row[13], $row[14], $row[15], $row[16], $row[17], $row[18], $row[19], $row[20], $row[21], $row[22], $row[23], $row[24], $row[25], $row[26], $row[27], $row[28]);
                file_put_contents($path, $ggclDm) or die('出错啦！无法修改广告策略文件！请检查输出目录名称、权限设置是否正确。');
                $row[2] || updateGgw($row[0]);
            }
        }
    }
    $query = "SELECT id,ggcl,recycle,bjgg,type,width,height FROM ${cfg_dbprefix}ggw WHERE bjgg LIKE '%{$ggId}%';";
    if ($result = $nxsql->query($query)) {
        while ($row = $result->fetch_row()) {
            list($gg_gid, $gg_id) = explode(' / ', $row[3]);
            if ($gg_id == $ggId) {
                $path = ROOT_DIR . $cfg_output . '/' . $cfg_forum . '-' . $row[0] . '.js' . ($row[2] ? 'recycle' : '');
                $ggwDm = getGGWdm($row[0], $row[1], $row[3], $row[4], $row[5], $row[6]);
                file_put_contents($path, $ggwDm) or die('出错啦！无法修改广告位文件！请检查输出目录名称、权限设置是否正确。');
                $row[2] || updateGgws($row[0]);
            }
        }
    }
}
