<?php

/* 栏目 - 即小类 */


@ require ('writable/set/set.php');
@ require ('writable/set/set_sql.php');
@ require ('writable/set/set_area.php');
@ require ('writable/set/set_html.php');

if (isset($GLOBALS['page_style'])) {
  unset($GLOBALS['page_style']);
}

if (!function_exists('get_page')) {
  @ require ('readonly/function/get_page.php');
}






if (!function_exists('get_m_class')) {
  function get_m_class($h_n_s, $class_title, $p, $class_n = 4, $class_more = '', $i, $tcolor_key) {
    global $web, $sql, $db, $link, $link_d;
    $text = '';

    if ($web['link_type'] == 1) {
      $link = '"".($h[3] == "js" ? $h[0] : "export.php?url=".urlencode($h[0])).""';
    } else {
      $link = '"".($h[3] == "js" ? "export.php?url=".urlencode($h[0]) : $h[0]).""';
    }

    if ($web['html'] == true) {
      $link_d = '"".$dpy.".html\" onclick=\"addM(this)\""';
    } else {
      $link_d = '"detail.php?column_id=".$_GET["column_id"]."&class_id=".$_GET["class_id"]."&detail_title=".urlencode($dt)."\" onclick=\"addM(this)\""';
    }

    $text .= '
  <div class="column" name="class_title_'.$i.'" id="class_title_'.$i.'" style="border:none;">
    <div class="column_title"><a class="tcolor '.$tcolor_key.'">'.$class_title.'</a></div>
        '.($p != '' ? '<div class="priority">'.$p.'</div>' : $p).'
    ';
    //导入专题链接
    $result__ = @mysql_query('SELECT class_title,detail_title FROM `'.$sql['pref'].''.$sql['data']['承载网址数据的表名'].'` WHERE column_id="'.$_GET['column_id'].'" AND class_id="'.$_GET['class_id'].'" AND class_title="'.$class_title.'" AND detail_title<>"" AND http_name_style="" AND class_priority<>"" ORDER BY detail_title', $db);
    $n2 = @mysql_num_rows($result__);
    if ($n2 > 0) {
      $text .= '<div class="yingyong" title="这里是站内专题应用区">';
      while ($row = @mysql_fetch_assoc($result__)) {
        list($dt, $dpy, ) = @explode('|', $row['detail_title']);
        $d_img_dir = 'writable/__web__/images/'.$_GET['column_id'].'_'.$_GET['class_id'].'/'.$dpy;
        if (@file_exists($d_img_dir.'.gif')) {
          $dimg = '<img src="'.$d_img_dir.'.gif" /><br />';
        } else {
          if (@file_exists($d_img_dir.'.jpg')) {
            $dimg = '<img src="'.$d_img_dir.'.jpg" /><br />';
          } else {
            if (@file_exists($d_img_dir.'.png')) {
              $dimg = '<img src="'.$d_img_dir.'.png" /><br />';
            } else {
              $dimg = '';
            }
          }
        }
        $text .= '<span><a onmouseover="addC(this)" href="'.eval('return '.$link_d.';').'">'.$dimg.''.$dt.'</a></span>';
        unset($row, $dt, $dpy, $dimg, $d_img_dir);
      }
      $text .= '</div>';
    }
    @mysql_free_result($result__);

    $n = NULL;
    if ($h_n_s = trim($h_n_s)) {
      $text_class_n = $text_class_more = '';
	  $total_arr = @explode("\n", trim($h_n_s));
      $n = count($total_arr);
      //导入网址链接
	  if ($n > 0) {
/*
        $text_class_n .= '<style type="text/css">
<!--
#class_'.$i.' span { width:';
        if ($class_n != 4 && $class_n != '') {
          switch ($class_n) { //878   -滚动条约18=860
          case 2 :
          $text_class_n .= '430';
          break;
          case 3 :
          $text_class_n .= '286';
          break;
          case 5 :
          $text_class_n .= '172';
          break;
          case 6 :
          $text_class_n .= '143';
          break;
          case 7 :
          $text_class_n .= '122';
          break;
          case 8 :
          $text_class_n .= '107';
          break;
          }
        }else{
          $text_class_n .= '215';
        }
        $text_class_n .= 'px; }
-->
</style>';
*/
        if (!empty($class_more) && is_numeric($class_more) && $class_more < $n) {
          $total_arr = array_slice($total_arr, 0, $class_more);
          $text_class_more .= get_page_foot($n, $class_more, 1, 'class_page.php?id='.$i.'&current=_s&column_id='.$_GET['column_id'].'&class_id='.$_GET['class_id'].'&class_title='.urlencode($class_title).'&p=', '', 10, 'addPFrame" onclick="return addG(\''.$i.'\', this);', '', '<div class="pagein"><a href="javascript:void(0);" onclick="showListClass(null, \'class_title_'.$i.'\', \''.$class_title.'\', \''.$_GET['detail_title'].'\');try{if(typeof(eval(openMy))==\'function\'){openMy();}}catch(e){}return false;">[全部]</a></div>');

        }

        //$text .= $text_class_n.'<div class="class" id="class_'.$i.'">';
        $text .= '<div class="class" id="class_'.$i.'">';
        foreach ($total_arr as $each) {
          $h = @explode("|", trim($each));
          $text .= '<span class="class_w_'.$class_n.'_s"><a onmouseover="addC(this)" onclick="addM(this)" href="'.eval('return '.$link.';').'"'.($h[2] != '' ? ' class="'.$h[2].'"':'').'>'.$h[1].'</a></span>';
        }
        $text .= ''.$text_class_more.'</div>';

	  }
    }
    if ($n + $n2 == 0) {
      //$text .= '没有网址数据！';
    }
    $text .= '
    </div>
';

    return $text;
  }
}
if (!function_exists('run_URLdecode')) {
  function run_URLdecode($e) {
    $text = "";
    if ($m = preg_split('/%3F/i', $e, 2)) {
      $text .= preg_match("/%[0-9A-Z]+/", $m[0]) ? urldecode($m[0]) : $m[0];
      if (count($m) == 2) {
        $text .= (!empty($m[1]) && preg_match("/(%[0-9A-Z]{4}){2,}/", $m[1])) ? '?'.urldecode($m[1]) : '?'.$m[1];
      }
    }
    return $text;
  }
}



unset($_GET['detail_title']);

@ $_GET['column_id'] = preg_replace('/[^\w]/', '', $_GET['column_id']);
@ $_GET['class_id'] = preg_replace('/[^\w]/', '', $_GET['class_id']);

if (!(isset($_GET['column_id']) && array_key_exists($_GET['column_id'], $web['area']))) {
  die('&#39057;&#36947;&#73;&#68;'.$_GET['column_id'].'&#38169;&#35823;&#25110;&#32570;&#22833;&#65281;&#35831;&#37325;&#39318;&#39029;&#37325;&#26032;&#24320;&#22987;');
}
if (!(isset($_GET['class_id']) && array_key_exists($_GET['class_id'], $web['area'][$_GET['column_id']]))) {
  die('&#26639;&#30446;&#73;&#68;'.$_GET['class_id'].'&#38169;&#35823;&#25110;&#32570;&#22833;&#65281;&#35831;&#37325;<a href="./">&#39318;&#39029;</a>&#37325;&#26032;&#24320;&#22987;');
}


$text = $text_ = $text__ = '';
$cssmark = 0;
$tcolor = 0;
$array_color = array('red', 'orange', 'green', 'blue');

if (!isset($sql['db_err'])) {
  db_conn();
}
if ($sql['db_err'] == '') {
  $result = @mysql_query('SELECT * FROM `'.$sql['pref'].''.$sql['data']['承载网址数据的表名'].'` WHERE column_id="'.$_GET['column_id'].'" AND class_id="'.$_GET['class_id'].'" AND detail_title="" ORDER BY id', $db);
  if (@mysql_num_rows($result) > 0) {
    while ($row = @mysql_fetch_assoc($result)) {
      if (strstr($row['class_title'], '栏目头栏') && $row['http_name_style'] == '') { //这是头栏$priority_pos_key
      //if (!strstr($row['class_title'], '|') && $row['http_name_style'] == '' && trim($row['class_priority']) != '') { //这是头栏

        if ($row['class_grab'] = trim($row['class_grab'])) {

          $text .= '
<div class="body">
  <iframe id="caijiFrame" name="caijiFrame" allowtransparency="true" frameborder="0" width="100%" scrolling="No" style=" background:url(readonly/images/loading2.gif) 50% 50% no-repeat; height:50px;"></iframe>
</div>
<script type="text/javascript" language="javaScript">
<!--

function caijiOnload(){
  $("caijiFrame").src="./caiji.php?column_id='.$_GET['column_id'].'&class_id='.$_GET['class_id'].'&class_title='.urlencode('栏目头栏').'&detail_title=";
}

if (document.all) {
	window.attachEvent("onload", caijiOnload);
} else {
	window.addEventListener("load", caijiOnload, false);
}

-->
</script>


';

        } else {
          if (preg_replace('/<style.+<\/style>/isU', '', trim($row['class_priority'])) != '') {
            $text .= '
  <div class="priority">'.$row['class_priority'].'</div>';
          } else {
            $text .= $row['class_priority'];
          }
        }
        continue;
      } else {

        list($class_title, $class_n, $class_more) = @explode("|", $row['class_title']);
        $class_n = $class_n ? $class_n : 4;

        if ($class_title == '栏目置顶') {
          $text_ .= get_m_class($row['http_name_style'], '栏目置顶', $row['class_priority'], $class_n, $class_more, 'top', '');
          continue;
        } else {
    $tcolor_key = $array_color[($tcolor + 4) % 4].'word';
    $tcolor ++;
          $cssmark++;
          $text__ .= get_m_class($row['http_name_style'], $class_title, $row['class_priority'], $class_n, $class_more, $cssmark, $tcolor_key);
	    }
      }
      unset($row);
    }
  } else {
    $err = '数据为空或读取失败！';
  }
  @mysql_free_result($result);

} else {
  $err = ''.$sql['db_err'].'';
}

@mysql_close();


?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo $web['area'][$_GET['column_id']][$_GET['class_id']][0].' - '.$web['sitename2'], $web['code_author']; ?></title>
<base target="_blank" />
<!--link href="writable/css/<?php echo (isset($_COOKIE['myStyle']) && file_exists('writable/css/'.$_COOKIE['myStyle'].'/style.css') ? $_COOKIE['myStyle'] : ($web['cssfile'] ? $web['cssfile'] : 1)); ?>/style.css" rel="stylesheet" type="text/css" id="my_style"-->
<link href="writable/css/<?php echo $web['cssfile']; ?>/style.css" rel="stylesheet" type="text/css" id="my_style">
<script type="text/javascript" language="javaScript" src="readonly/js/main.js"></script>
<script type="text/javascript" language="javaScript" src="readonly/js/current.js"></script>
<script type="text/javascript" language="javaScript">
<!--
if(par==null || parent==self){
  location.href='<?php echo $link_current = get_class_html($_GET['column_id'], $_GET['class_id']); ?>';
}
function atParSize() {
  var bot=document.getElementById('body_tl');
  var bop=bop==null?bop=document.getElementById('body_p'):bop;
  var thisH=thisH==null?par.offsetHeight:thisH;
  if(bot!=null){
    var botH=bot.offsetHeight;
    var bopH=bop.offsetHeight-2;
    var diff=bopH-botH;
    if(diff>0){
      bop.style.height=botH+'px';
      par.style.height=(thisH-diff)+'px';
      par.style.top=(t+diff/2)+'px';

    }
  }
}
/*
function parNarrow(){
  if (par!=null){
    var parShowH=parent.document.documentElement.clientHeight;
    par.style.position='fixed';
    par.style.top=(parShowH-38)+'px';
    par.style.left=(parShowH-38)+'px';
    par.style.height='38px';
    parent.delSubmitSafe();
    parShowH=null;
    parent.window.onresize=window.onresize=function(){parNarrow();}
  }
}
*/
/*
if (document.all) {
  window.attachEvent('onload', atParSize);//对于IE
} else {
  window.addEventListener('load', atParSize, false);//对于FireFox
}
*/

function showListClass(o,showO,class_title,detail_title){
  if(!showO) return false;
  if(o!=null){
    try{$('class_is').id='';}catch(e){}
    o.id='class_is';
    $('body_').style.display='block';
    $('body').style.display='none';
  }else{
    $('page_img').innerHTML='&nbsp;'+$('page_style').innerHTML;
  }
  doXMLHTTP(showO, 'more.php?show_o='+showO+'&current=_s&column_id=<?php echo $_GET['column_id']; ?>&class_id=<?php echo $_GET['class_id']; ?>&class_title='+encodeURIComponent(class_title)+'&detail_title='+encodeURIComponent(detail_title)+'');
}

if(navigator.userAgent.indexOf("MSIE")>0){
  var location='';
}

-->
</script>
<script type="text/javascript" language="javaScript">
<!--
function addG(objId,linkObj){var bjImg=document.getElementById('page_img');var obj=document.getElementById('class_'+objId);var hf=linkObj.href;if(obj!=null&&bjImg!=null){var w,h,l,t;h=obj.offsetHeight;t=obj.offsetTop;while(obj=obj.offsetParent){t+=obj.offsetTop}bjImg.style.display="block";bjImg.style.height=h+"px";bjImg.style.top=t+"px"}doXMLHTTP('class_'+objId,hf);bjImg.style.display="none";try{}catch(err){}return true}
-->
</script>
</head>
<body style="background-color:transparent; background-image:none;">
<img src="readonly/images/star.gif" id="star" style="display:none" title="加入收藏" />
<div id="page_img"></div>
<div class="i1">&nbsp;</div>
<div class="i2">&nbsp;</div>
<div class="i3">&nbsp;</div>

<div id="nav">
  <div id="nav_mingz"><a href="./">首页</a> / <a href="<?php echo get_column_html($_GET['column_id']); ?>"><?php echo $web['area'][$_GET['column_id']]['name'][0]; ?></a> / <?php echo $web['area'][$_GET['column_id']][$_GET['class_id']][0]; ?></div>
  <div id="nav_session"><a href="<?php echo $link_current; ?>" title="展开" target="_parent"><img src="readonly/images/y.gif" class="close" /></a> <!--a href="javascript:void(0)" title="缩小" onclick="parNarrow()" target="_self"><img src="readonly/images/z.gif" class="close" /></a--> <a href="about:blank" title="关闭" onclick="parClose()" target="_self"><img src="readonly/images/x.gif" class="close" /></a></div>
</div>
<iframe id="addPFrame" name="addPFrame" style="display:none"></iframe>
<div class="body" id="body"><div id="body_p"><div id="body_p_in">
<?php
if (!isset($err)) {
  $text____ = (!empty($text_) || !empty($text__)) ? $text_.$text__ : '';
  echo (isset($priority_pos_key) && abs($priority_pos_key) == 1) ? $text____.$text : $text.$text____;
} else {
  echo '
    <div class="output">'.$err.'</div>';
}
?>
</div></div></div>
<div class="i3">&nbsp;</div>
<div class="i2">&nbsp;</div>
<div class="i1">&nbsp;</div>
</body>
</html>