<?php

/* 栏目 - 即小类 */


@ require ('writable/set/set.php');
if (!isset($sql)) {
  @ require ('writable/set/set_sql.php');
}
if (!isset($web['area'])) {
  @ require ('writable/set/set_area.php');
}
if (!isset($web['html'])) {
  @ 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)\""';
    }
*/
      $link_d = '"detail_current.php?column_id=".$_GET["column_id"]."&class_id=".$_GET["class_id"]."&detail_title=".urlencode($dt)."\" onclick=\"addSubmitSafe(1);addM(this);\" target=\"addCFrame\""';


    $text .= '
  <div class="column" name="class_title_'.$i.'" id="class_title_'.$i.'">
    <div class="column_title"><a class="tcolor '.$tcolor_key.'">'.$class_title.'</a></div>
        '.(preg_replace('/<style.+<\/style>/isU', '', trim($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) {
/*
        if ($class_n != 4 && $class_n != '') {
        $text_class_n .= '<style type="text/css">
<!--
#class_'.$i.' span { width:';
        switch ($class_n) {
          case 2 :
          $text_class_n .= '468';
          break;
          case 3 :
          $text_class_n .= '312';
          break;
          case 5 :
          $text_class_n .= '187';
          break;
          case 6 :
          $text_class_n .= '156';
          break;
          case 7 :
          $text_class_n .= '133';
          break;
          case 8 :
          $text_class_n .= '117';
          break;
          }
          $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=&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'].'\');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.'"><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__ = $caiji_html = '';
$cssmark = 0;
$tcolor = 0;
$array_color = array('red', 'orange', 'green', 'blue');
$list_class_title = '<a id="class_is" href="javascript:void(0);" onclick="try{$(\'class_is\').id=\'\';}catch(e){}this.id=\'class_is\';$(\'body_\').style.display=\'none\';$(\'body\').style.display=\'block\';return false;"><b>全部</b></a>';

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="body">
  <div class="priority">'.$row['class_priority'].'</div>
</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 {

          $list_class_title .= '<a href="javascript:void(0);" onclick="showListClass(this,\'body_\',this.innerHTML,\'\');return false;">'.$class_title.'</a>';











    $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 $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">
<!--
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}
<?php
echo $caiji_html;
unset($caiji_html);
?>




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=&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>
</head>
<body>
<?php @ include ('readonly/require/head.php'); ?>
<div id="top_title"><a href="./write_newsite.php" class="top_title_other">网站加入</a><a href="./member.php?get=collection" class="top_title_other">自定义网址</a><a href="./">首页</a><a href="<?php echo get_column_html($_GET['column_id']); ?>" target="_self"><?php echo $web['area'][$_GET['column_id']]['name'][0]; ?></a><a id="top_title_is"><?php echo $web['area'][$_GET['column_id']][$_GET['class_id']][0]; ?></a></div>

<img src="readonly/images/star.gif" id="star" style="display:none" title="加入收藏" />
<div id="page_img"></div>
<iframe id="addPFrame" name="addPFrame" style="display:none"></iframe>

<?php




unset($array_color, $tcolor_key, $tcolor);




if (!isset($err)) {
  $text____ = (!empty($text_) || !empty($text__)) ? '<div class="body"><div id="list_class">'.$list_class_title.'</div></div><div class="body" id="body_"></div><div class="body" id="body">'.$text_.$text__.'</div>' : '';
  echo (isset($priority_pos_key) && abs($priority_pos_key) == 1) ? $text____.$text : $text.$text____;
} else {
  echo '
  <div class="body">
    <div class="output">'.$err.'</div>
  </div>';
}
?>
<script type="text/javascript" language="JavaScript" src="writable/ad/ad_bottom.js"></script>
<?php @ include ('writable/require/foot.php'); ?>
<?php @ include ('writable/require/statistics.txt'); ?>


</body>
</html>
