<?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 (!function_exists('get_m_class')) {
  function get_m_class($h_n_s, $c, $class_n = 4, $i) {
    global $web, $sql, $db, $link, $link_d, $class_title;
    $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"';
    } else {
      $link_d = '"detail.php?column_id=".$_GET["column_id"]."&class_id=".$_GET["class_id"]."&detail_title=".urlencode($dt).""';
    }


    $text .= $_GET['show_o'] == 'body_' ? '
  <div class="column" name="class_title_'.$i.'" id="class_title_'.$i.'">' : '
';
    $text .= '
    <div class="column_title"><a class="tcolor">'.$class_title.'</a></div>
        '.(preg_replace('/<style.+<\/style>/isU', '', trim($c)) != '' ? '<div class="priority">'.$c.'</div>' : $c).'
  ';
    //导入专题链接
    $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="'.$_GET['class_title'].'" AND detail_title<>"" AND http_name_style="" AND class_priority<>""', $db); //'.(!empty($class_more) && is_numeric($class_more) ? ' LIMIT '.$class_more.'' : '').'
    $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)" onclick="addM(this)" href="'.eval('return '.$link_d.';').'">'.$dimg.''.$dt.'</a></span>';
        unset($row, $dt, $dpy, $dimg, $d_img_dir);
      }
      $text .= '</div>';
    }

    $n = NULL;
    if ($h_n_s = trim($h_n_s)) {
	  $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>';
        }
*/
        //$text .= $text_class_n.'<div class="class">';
        $text .= '<div class="class">';
        foreach ($total_arr as $each) {
          $h = @explode("|", trim($each));
          $text .= '<span class="class_w_'.$class_n.''.$_GET['current'].'"><a onmouseover="addC(this)" onclick="addM(this)" href="'.eval('return '.$link.';').'"'.($h[2] != '' ? ' class="'.$h[2].'"':'').'>'.$h[1].'</a></span>';
        }
        $text .= '</div>';

	  }
    }
    if ($n + $n2 == 0) {
      $text .= '没有数据！';
    }
    $text .= $_GET['show_o'] == 'body_' ? '
  </div>' : '';
    return $text;
  }
}

function filter($text) {
  $text = trim($text);
  $text = stripslashes($text);
  //$text = htmlspecialchars($text);
  $text = preg_replace('/[\r\n\'\"\s\<\>]+/', '', $text);
  $text = str_replace('|', '&#124;', $text);
  //$text = str_replace('/', '&#47;', $text);
  return $text;
}

@ $_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('&#20998;&#31867;&#73;&#68;'.$_GET['column_id'].'&#38169;&#35823;&#25110;&#32570;&#22833;&#65281;&#35831;&#37325;<a href="./">&#39318;&#39029;</a>&#37325;&#26032;&#24320;&#22987;');
}

if ($_GET['show_o'] == 'index') {
$text = '';
$tcolor = 0;
$array_color = array('red', 'orange', 'green', 'blue');

  $cssmark = $mark = 0;
  if (!isset($sql['db_err'])) {
    db_conn();
  }
  if ($sql['db_err'] == '') {
    //$column_py = $web['area'][$_GET['column_id']]['name'][1];
    //unset($web['area'][$_GET['column_id']]['name']);
    foreach ($web['area'][$_GET['column_id']] as $class_id => $class) {
      if ($class_id === 'name') continue;
	  $cssmark++;
    $tcolor_key = $array_color[($tcolor + 4) % 4].'word';
    $tcolor ++;
$column_title = get_class_html($_GET['column_id'], $class_id);



	  $text .= '
      <div class="column">
        <div class="column_title_"><a href="'.$column_title.'" class="tcolor '.$tcolor_key.'">'.$class[0].'</a></div>';
      $result = @mysql_query('SELECT * FROM `'.$sql['pref'].''.$sql['data']['承载网址数据的表名'].'` WHERE column_id="'.$_GET['column_id'].'" AND class_id="'.$class_id.'" AND class_title NOT LIKE "栏目置顶%" AND class_title NOT LIKE "栏目头栏%" AND detail_title="" ORDER BY id', $db);
      if (@mysql_num_rows($result) > 0) {
        $text .= '<div class="class" style="line-height:150%;">';
        while ($row = @mysql_fetch_assoc($result)) {
	      $mark++;
          list($class_title, , ) = @explode('|', $row['class_title']);
          $text .= '<a onmouseover="addC(this)" onclick="addM(this)" href="more.php?list_fr=index_hiddenmenu&column_id='.$_GET['column_id'].'&class_id='.$class_id.'&class_title='.urlencode($class_title).'#class_title_'.$mark.'">'.$class_title.'</a>';
          unset($row);
        }
	    $mark = 0;
        $text .= '</div>';
      } else {
        //$text .= $_GET['column_id'].' - '.$class_id.' 的数据为空或读取失败！';
      }
      @mysql_free_result($result);

        $text .= '
      </div>
';
    }
  } else {
    $err = $sql['db_err'];
  }
  @mysql_close();

  echo '
<style type="text/css">
<!--
#left_menu_'.$_GET['column_id'].' { background:#EEE; }
.column_title_ .tcolor { margin-top:-6px; padding-top:0; padding-bottom:0; height:28px; width:93%; display:block;}
.column_title_ a.tcolor { display:block; font-weight:bold; border-bottom:1px solid; }
-->
</style>
';
  echo $text.$err;

  die;
}





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;');
}
$_GET['class_title'] = filter(htmlspecialchars($_GET['class_title']));
if (empty($_GET['class_title'])) {
  die('&#20998;&#31867;&#21442;&#25968;&#38169;&#35823;&#25110;&#32570;&#22833;&#65281;&#35831;&#37325;<a href="./">&#39318;&#39029;</a>&#37325;&#26032;&#24320;&#22987;');
}


if (!empty($_GET['detail_title'])) {
  $title = $_GET['detail_title'] = filter(htmlspecialchars($_GET['detail_title']));
  $nav = '"<a href=\"detail.php?column_id='.$_GET['column_id'].'&class_id='.$_GET['class_id'].'&detail_title='.urlencode($_GET['detail_title']).'\">'.$_GET['detail_title'].'</a>"';
  $e1 = ' AND detail_title LIKE "'.$_GET['detail_title'].'|%"';
  $ee1 = ' AND class_title<>"栏目置顶" AND NOT (class_title NOT LIKE "%|%" AND http_name_style="")';
} else {
  $title = $web['area'][$_GET['column_id']][$_GET['class_id']][0];
  $nav = '';
  $e1 = ' AND detail_title=""';
  $ee1 = ' AND class_title<>"栏目置顶" AND NOT (class_title LIKE "%栏目头栏%" AND http_name_style="")';
}

$text = $text__ = $err = '';
$cssmark = 0;

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 class_title LIKE "'.$_GET['class_title'].'|%"'.$e1.' LIMIT 1', $db);
  if ($row = @mysql_fetch_assoc($result)) {
    list($class_title, $class_n, $class_more) = @explode("|", $row['class_title']);
        $class_n = $class_n ? $class_n : 4;

    list(, $dpy) = @explode("|", $row['detail_title']);
    $cssmark++;
    $text__ .= get_m_class($row['http_name_style'], $row['class_priority'], $class_n, $cssmark);
    unset($row);
  } else {
    $err = '数据为空或读取失败！';
  }
  @mysql_free_result($result);
  if (!empty($_GET['list_fr']) && $_GET['list_fr'] == 'index_hiddenmenu') {
    $list_class_title = '
<script>
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='.$_GET['column_id'].'&class_id='.$_GET['class_id'].'&class_title="+encodeURIComponent(class_title)+"&detail_title="+encodeURIComponent(detail_title)+"");
}
</script>
<div class="body"><div id="list_class">';
    $list_class_title .= '<a href="'.get_class_html($_GET['column_id'], $_GET['class_id']).'" target="_self"><b>全部</b></a>';
    $result = @mysql_query('SELECT * FROM `'.$sql['pref'].''.$sql['data']['承载网址数据的表名'].'` WHERE column_id="'.$_GET['column_id'].'" AND class_id="'.$_GET['class_id'].'"'.$e1.$ee1.'', $db);
    if (@mysql_num_rows($result) > 0) {
      while ($row = @mysql_fetch_assoc($result)) {
        list($class_title, $class_n, $class_more) = @explode("|", $row['class_title']);
        $list_class_title .= '<a href="javascript:void(0);" onclick="showListClass(this,\'body_\',this.innerHTML,\''.$_GET['detail_title'].'\');return false;"'.($class_title==$_GET['class_title']?' id="class_is"':'').'>'.$class_title.'</a>';
      }
	}
    @mysql_free_result($result);
    $list_class_title .= '</div></div><div class="body" id="body_"></div>';
  
  
  }

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

@mysql_close();


?>
<?php

if (!empty($_GET['list_fr']) && $_GET['list_fr'] == 'index_hiddenmenu') :







?>
<!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 $title.' - '.$class_title.' - '.$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>
</head>
<body>
<?php @ include ('readonly/require/head.php'); ?>
<div id="top_title"><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 href="<?php echo get_class_html($_GET['column_id'], $_GET['class_id']); ?>" target="_self"><?php echo $web['area'][$_GET['column_id']][$_GET['class_id']][0]; ?></a><?php echo eval('return '.$nav.';'); ?><a id="top_title_is"><?php echo $class_title; ?></a></div>

<img src="readonly/images/star.gif" id="star" style="display:none" title="加入收藏" />
<?php echo $list_class_title; ?>
<div class="body" id="body">
  <div class="column">
<?php
endif;

?>
<?php
echo $text__.$err;
?>
<?php

if (!empty($_GET['list_fr']) && $_GET['list_fr'] == 'index_hiddenmenu') :

?>
  </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>
<?php
endif;

?>
