<?php


@ require ('writable/set/set.php');
@ require ('writable/set/set_sql.php');
@ require ('writable/set/set_area.php');
@ require ('readonly/function/get_page.php');

@ $_GET = array_map('htmlspecialchars', $_GET);

@ $_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['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'])) {
  $_GET['detail_title'] = filter(htmlspecialchars($_GET['detail_title']));
  $e1 = ' AND detail_title LIKE "'.$_GET['detail_title'].'|%"';
} else {
  $e1 = ' AND detail_title=""';
}

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

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]).""';
}

$text = $err = '';

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;

    if (empty($class_more) || !is_numeric($class_more) || $class_more <= 0) {
      die('&#x67E5;&#x65E0;&#x5206;&#x9875;&#x8BBE;&#x7F6E;&#xFF01;');
    }




    $total_arr = @explode("\n", trim($row['http_name_style']));
    $n = count($total_arr);

    if ($n > 0) {
      $p = get_page($n, $class_more); //页数
      $seek = $class_more * ($p-1);
      $total_arr = array_slice($total_arr, $seek, $class_more);

      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 .= get_page_foot($n, $class_more, $p, 'class_page.php?id='.$_GET['id'].'&current='.$_GET['current'].'&column_id='.$_GET['column_id'].'&class_id='.$_GET['class_id'].'&class_title='.urlencode($class_title).'&p=', '', 10, 'addPFrame" onclick="return addG(\''.$_GET['id'].'\', this);', '', '<div class="pagein"><a href="javascript:void(0);" onclick="showListClass(null, \'class_title_'.$_GET['id'].'\', \''.$class_title.'\', \''.$_GET['detail_title'].'\');try{if(typeof(eval(openMy))==\'function\'){openMy();}}catch(e){}return false;">[全部]</a></div>');


    } else {
      $text .= '没有数据！';
    }

    unset($row);
  } else {
    $err = '&#x6570;&#x636E;&#x4E3A;&#x7A7A;&#x6216;&#x8BFB;&#x53D6;&#x5931;&#x8D25;&#xFF01;';
  }

  @mysql_free_result($result);

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

@mysql_close();

echo $text, $err;

?>