<?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_detail')) {
  function get_m_detail($h_n_s, $class_title, $p, $class_n = 4, $class_more = '', $i, $tcolor_key) {
    global $web;
    $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]).""';
    }
    $p = preg_replace('/<style.+<\/style>/isU', '', trim($p));
    $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>
        '.($p != '' ? '<div class="priority">'.$p.'</div>' : $p).'';

    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).'&detail_title='.urlencode($_GET['detail_title']).'&p=', '', 10, 'addCFrame" 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>';

	  }
    }
    $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;
  }
}



@ $_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;');
}

$_GET['detail_title'] = @htmlspecialchars($_GET['detail_title']);
if (empty($_GET['detail_title'])) {
  die('&#19987;&#39064;&#21442;&#25968;&#38169;&#35823;&#25110;&#32570;&#22833;&#65281;&#35831;&#37325;<a href="./">&#39318;&#39029;</a>&#37325;&#26032;&#24320;&#22987;');
}


$text = $text_ = $text__ = $caiji_html = $text_dside = '';
$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 LIKE "'.$_GET['detail_title'].'|%"', $db);
  if (@mysql_num_rows($result) > 0) {
    while ($row = @mysql_fetch_assoc($result)) {
      if (!strstr($row['class_title'], '|') && $row['http_name_style'] == '') { // && trim($row['class_priority']) != ''这是头栏
        list(,$dpy, $ds) = @explode('|', $row['detail_title']);
        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($row['class_title']).'&detail_title='.$_GET['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">';
          //list(,$dpy, $ds) = @explode('|', $row['detail_title']);
          @ list($dside, $dside_, $dside__, $dside___) = @explode('-', $ds);

          $dside___ = abs($dside___) <= 120 ? 120 : (abs($dside___) >= 380 ? 380 : abs($dside___));
          $bodywidth = 960 - 22 - 8 - 10 - $dside___;
          if (is_numeric($dside__) && $dside__ >= 1  && $dside__ <= 4) {
            $imgwidth = (int)($dside___ / $dside__);
            $text_dside .= '
<style type="text/css">
<!--
#detail_obj { width:'.$dside___.'px; overflow:hidden; text-align:center; }
#detail_obj span { width:'.$imgwidth.'px; height:90px; margin:0; text-align:center; overflow:hidden; display:inline-block !important; display:inline; zoom:1; }
#detail_obj span img { max-width:64px; max-height:64px; margin:0; padding:0; clear:both; }

-->
</style>';
            $link_img = '"<img src=\"".(@file_exists($img_d.".gif") ? $img_d.".gif" : (@file_exists($img_d.".jpg") ? $img_d.".jpg" : (@file_exists($img_d.".png") ? $img_d.".png" : "readonly/images/i.gif")))."\" alt=\"".$detail_title."\" /><br />".$detail_title.""';
          } else {
            $link_img = '"".$detail_title.""';
          }

          if (empty($ds)) {
            $text .= '
  <div class="priority">'.$row['class_priority'].'</div>';
          } else {
            $text .= '
  <table width="100%" border="0" cellspacing="10" cellpadding="0" class="menu">
    <tr valign="top">';

            switch ($dside) {
              case 1 :
              $result_ = @mysql_query('SELECT detail_title FROM `'.$sql['pref'].''.$sql['data']['承载网址数据的表名'].'` WHERE column_id="'.$_GET['column_id'].'" AND class_id="'.$_GET['class_id'].'" AND class_title="'.$row['class_title'].'" AND detail_title<>"" AND (http_name_style="" AND class_priority<>"")', $db);
              if (@mysql_num_rows($result_) > 0) {
                if ($web['html'] == true) {
                  $link = '"".$dpy_.".html"';
                } else {
                  $link = '"detail.php?column_id=".$_GET["column_id"]."&class_id=".$_GET["class_id"]."&detail_title=".urlencode($detail_title).""';
                }
                //$text_dside .= '<div class="dside_title">同栏目下其它专题</div>';
                $text_dside .= '<div id="detail_out"><div id="detail_obj">';
                while ($row_ = @mysql_fetch_assoc($result_)) {
                  list($detail_title, $dpy_, ) = @explode('|', $row_['detail_title']);
                  $img_d = 'writable/__web__/images/'.$_GET['column_id'].'_'.$_GET['class_id'].'/'.$dpy_;
                  $text_dside .= '<span><a href='.($dpy == $dpy_ ? '"#" onclick="return false"' : '"'.eval('return '.$link.';').'"').'>'.eval('return '.$link_img.';').'</a></span>';
                  unset($row_, $detail_title, $dpy_, $img_d);
                }
                unset($link, $link_img);
                $text_dside .= '</div></div>';
              }
              @mysql_free_result($result_);

              break;
              case 2 :
              $result_ = @mysql_query('SELECT class_title FROM `'.$sql['pref'].''.$sql['data']['承载网址数据的表名'].'` WHERE column_id="'.$_GET['column_id'].'" AND class_id="'.$_GET['class_id'].'" AND class_title<>"" AND class_title<>"栏目头栏" AND class_title<>"栏目置顶" AND detail_title="" ORDER BY id', $db);
              if (@mysql_num_rows($result_) > 0) {
                //$text_dside .= '<div class="dside_title">上级全部栏目</div>';
                $tli = 0;
                $text_dside .= '<ul>';
                while ($row_ = @mysql_fetch_assoc($result_)) {
                  $tli++;
                  list($class_title, , ) = @explode('|', $row_['class_title']);
                  $text_dside .= '<li>
<a href="class.php?column_id='.$_GET['column_id'].'&class_id='.$_GET['class_id'].'#class_title_'.$tli.'">'.$class_title.'</a></li>';
                  unset($row_, $class_title);
                }
                unset($link);
                $text_dside .= '</ul>';
              }
              @mysql_free_result($result_);

              break;
              case 3 :
              $result_c = @mysql_query('SELECT class_title FROM `'.$sql['pref'].''.$sql['data']['承载网址数据的表名'].'` WHERE column_id="'.$_GET['column_id'].'" AND class_id="'.$_GET['class_id'].'" AND class_title NOT LIKE "%栏目头栏%" AND detail_title="" ORDER BY id', $db);
              if (@mysql_num_rows($result_c) > 0) {
                $sli = 0;
                if ($web['html'] == true) {
                  $link = '"".$dpy_.".html"';
                } else {
                  $link = '"detail.php?column_id=".$_GET["column_id"]."&class_id=".$_GET["class_id"]."&detail_title=".urlencode($detail_title).""';
                }
                if (isset($imgwidth)) {
                  $text_dside .= '<div id="detail_out"><div id="detail_obj">';                  
                }
                while ($row_c = @mysql_fetch_assoc($result_c)) {
                  $sli++;
                  list($class_title_c, ) = @explode('|', $row_c['class_title']);
                  if (!isset($imgwidth)) {
                    $text_dside .= '<div class="dside_title">
<a href="class.php?column_id='.$_GET['column_id'].'&class_id='.$_GET['class_id'].'#class_title_'.$sli.'">'.$class_title_c.'</a></div><div id="detail_out"><div id="detail_obj">';                 

                  }
                  if ($class_title_c) {
                    $result_ = @mysql_query('SELECT detail_title FROM `'.$sql['pref'].''.$sql['data']['承载网址数据的表名'].'` WHERE column_id="'.$_GET['column_id'].'" AND class_id="'.$_GET['class_id'].'" AND (detail_title<>"" AND http_name_style="" AND class_priority<>"") AND class_title="'.$class_title_c.'" ORDER BY detail_title', $db);
                    if (@mysql_num_rows($result_) > 0) {
                      while ($row_ = @mysql_fetch_assoc($result_)) {
                        list($class_title, , ) = @explode('|', $row_['class_title']);
                        list($detail_title, $dpy_, ) = @explode('|', $row_['detail_title']);
                        $img_d = 'writable/__web__/images/'.$_GET['column_id'].'_'.$_GET['class_id'].'/'.$dpy_;
                        $ct = urlencode($class_title);
                        $text_dside .= '<span><a href='.($dpy == $dpy_ ? '"#" onclick="return false"' : '"'.eval('return '.$link.';').'"').'>'.eval('return '.$link_img.';').'</a></span>';
                        unset($row_, $class_title, $ct, $detail_title, $dpy_);
                      }
                    }
                    @mysql_free_result($result_);
                  }
                  if (!isset($imgwidth)) {
                    $text_dside .= '</div></div>';                  
                  }
                }
                if (isset($imgwidth)) {
                  $text_dside .= '</div></div>';                  
                }
                unset($row_c, $class_title_c);
              }
              @mysql_free_result($result_c);
              break;
              default :
            }

            switch ($dside_) {
              case 'r' :
              $text .= '
<style type="text/css">
<!--
.dside_left { width:'.$bodywidth.'px; line-height:29px; text-align:center; }
#detail_body { width:'.$bodywidth.'px; overflow:hidden; }
.dside_right { padding-left:7px; border-left:1px #D4D4D4 solid; font-size:12px; text-align:left; }
.dside_right li a { color:#0033CC; font-family:宋体; white-space:nowrap; }
-->
</style>
      <td class="dside_left"><div id="detail_body">'.$row['class_priority'].'</div></td>
      <td class="dside_right">'.$text_dside.'</td>';
              break;
              case 'l' :
              $text .= '
<style type="text/css">
<!--
.dside_left { padding-right:7px; border-right:1px #D4D4D4 solid; font-size:12px; text-align:left; }
.dside_left li a { color:#0033CC; font-family:宋体; white-space:nowrap; }
.dside_right { width:'.$bodywidth.'px; line-height:29px; text-align:center; }
#detail_body { width:'.$bodywidth.'px; overflow:hidden; }
-->
</style>
      <td class="dside_left">'.$text_dside.'</td>
      <td class="dside_right"><div id="detail_body">'.$row['class_priority'].'</div></td>';

              break;
              default :
              $text .= '
      <td><div class="priority">'.$row['class_priority'].'</div></td>';
              break;
            }
            $text .= '
    </tr>
  </table>';
            unset($text_dside);
          }
          $text .= '
</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_detail($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,\''.$_GET['detail_title'].'\');return false;">'.$class_title.'</a>';


    $tcolor_key = $array_color[($tcolor + 4) % 4].'word';
    $tcolor ++;
          $cssmark++;
          $text__ .= get_m_detail($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 $_GET['detail_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">
<style type="text/css">
<!--
.dside_title, .dside_title a { font-weight:bold; color:#969696; }
#detail_obj span { display:block; margin-left:12px; }
-->
</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="./">首页</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']); ?>"><?php echo $web['area'][$_GET['column_id']][$_GET['class_id']][0]; ?></a><a id="top_title_is"><?php echo $_GET['detail_title']; ?></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
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'); ?>

<?php
if (isset($imgwidth)) {
?>
<script language="javascript" type="text/javascript">
<!--

function startDList(showHeight){function $(objId){return document.getElementById(objId);}
var dOut=$('detail_out');var dObj=$('detail_obj');dOut.style.overflow='hidden';var dObjMarginTop=0;var firstLi=dObj.firstChild;while(firstLi&&firstLi.nodeType!==1){firstLi=firstLi.nextSibling;}
childLiHeight=firstLi==null?90:firstLi.offsetHeight;showHeight=showHeight<childLiHeight?childLiHeight:showHeight;showHeight=parseInt(showHeight/childLiHeight)*childLiHeight;dOut.style.height=showHeight+'px';dObjH=dObj.offsetHeight;if(dObjH>showHeight){var newDiv=document.createElement('DIV');newDiv.style.width=dOut.offsetWidth+'px';newDiv.innerHTML+='<button type="button" id="detail_up">∧</button><button type="button" id="detail_down">∨</button>';dOut.parentNode.insertBefore(newDiv,null);}
$('detail_up').style.cssText=$('detail_down').style.cssText='width:50%; height:24px; line-height:18px; overflow:hidden; font-size:18px; font-weight:bold; font-family:"Microsoft YaHei"; text-align:center;';$('detail_down').onmousedown=function(){calcCountTimer=setInterval(function(){if(Math.abs(dObjMarginTop)>=dObjH-showHeight){window.clearInterval(calcCountTimer);return false;}
dObjMarginTop-=childLiHeight;dObj.style.marginTop=dObjMarginTop+'px';},100);}
$('detail_up').onmousedown=function(){calcCountTimer=setInterval(function(){if(dObjMarginTop>=0){window.clearInterval(calcCountTimer);return false;}
dObjMarginTop+=childLiHeight;dObj.style.marginTop=dObjMarginTop+'px';},100);}
$('detail_up').onmouseup=$('detail_down').onmouseup=function(){window.clearInterval(calcCountTimer);}}
function getDList_() {
  startDList($('detail_body').offsetHeight);
}
if (document.all) {
  window.attachEvent('onload', getDList_);//对于IE
} else {
  window.addEventListener('load', getDList_, false);//对于FireFox
}

-->
</script>
<?php
}
?>

</body>

</html>
