<?php
require ('authentication_manager.php');
?>
<style type="text/css">
<!--
.column__ { margin-bottom:10px; line-height:39px; text-align:left; clear:both; background-color:#ECECEC; }
-->
</style>
<?php

/* 导航Banner */
/* 162100源码 - 162100.com */




$text = $err = '';
if (isset($_GET['mode']) && $_GET['mode'] && file_exists('inc/css/'.$_GET['mode'])) { 
  echo '<div class="list_title"><a href="?get=banner">&lt;&lt;返回</a><a class="list_title_in">导航栏编辑</a></div>
<ul class="manager_menu">所属模板：'.substr($_GET['mode'], 0, 1).''.str_pad('', strlen($_GET['mode'])-1, '*').' ['.file_get_contents('inc/css/'.$_GET['mode'].'/title.txt').'] </ul>
';
$editstr = @file_get_contents('inc/css/'.$_GET['mode'].'/banner.txt');
$editstr = str_replace("'", "\'", $editstr);
$editstr = preg_replace('/<\?(php)?.*\?>/iU', '', $editstr);
$editstr = preg_replace('/[\r\n]+/', '', $editstr);
$editstr = preg_replace('/<script/i', '<sc\'+\'ri\'+\'pt', $editstr);
$editstr = preg_replace('/<\/script/i', '</sc\'+\'ri\'+\'pt', $editstr);
//$editstr = str_replace('&', '&amp;', $editstr);
//$editstr = str_replace('<', '&lt;', $editstr);
//$editstr = str_replace('>', '&gt;', $editstr);
?>
<iframe id="lastFrame" name="lastFrame" frameborder="0" style="display:none"></iframe>
<script language="JavaScript" type="text/javascript">
<!--
var eXSize = 588;       //编辑器宽度，最小宽度限588px
var formU = '?post=banner&mode=<?php echo $_GET['mode']; ?>';
var formT = '<div class="column">在下面编辑器中填写导航代码吧。<br /><br /><input type="radio" class="radio" name="filter" value="yes" checked />请系统自动过滤代码<span class="grayword">（点选此项可能会过滤掉不希望过滤的代码，否则请点选下面的。）</span><br /><input type="radio" class="radio" name="filter" value="no" />不用过滤，我相信自己所写的代码规范（填写JS等代码如统计代码时）。<b>注意此项每次提交前要仔细校对代码</b><br /><b class="redword">提交前请确定inc/css/<?php echo $_GET['mode']; ?>目录具备写权限</b><div align="right"><button type="button" class="botton" onclick="toDefault()"><b>恢复默认值</b></button></div></div>';
var contT = '<?php echo addslashes($editstr); ?>';
document.write('<'+'sc'+'ript language="javascript" src="inc/js/editor.js?'+new Date().getTime()+'?'+new Date().getTime()+'" type="text/javascript"></'+'sc'+'ript>');


function toDefault() {
  try {
    e162100T.value = e162100I.document.body.innerHTML = '<a href="member.php?get=mess&username=admin">给管理员写信</a> <a href="http://www.162100.com/"><b>网址导航</b></a>';
  } catch (err) {
  }
}

function addAreaBanner(areaMode, areaName, areaId) {
  if ($('html_php_area') != null && $('html_php_area').checked == true) {
    var url = 'list.'+areaMode+'.'+areaId+'..1.html';
  } else {
    var url = 'list.php?mode='+areaMode+'&area_id='+areaId+'';
  }
  var reg = new RegExp('<a [^>]*href[\\\s\\\n\\\r]*=[\\\s\\\n\\\r]*(\\\"|\\\')?'+url.replace(/([\.\/\?])/g, '\\\$1')+'[^>]*>'+areaName+'<\\\/a> *', 'ig');
  var text = '<a href="'+url+'">'+areaName+'</a> '+e162100T.value.replace(reg, '');
  e162100T.value = e162100I.document.body.innerHTML = text;
  location.href='#editor162100_';
}

function addModeBanner(areaMode, areaName) {
  if ($('html_php_mode') != null && $('html_php_mode').checked == true) {
    var url = 'index.html?mode='+areaMode+'';
  } else {
    var url = 'index.php?mode='+areaMode+'';
  }
  var reg = new RegExp('<a [^>]*href[\\\s\\\n\\\r]*=[\\\s\\\n\\\r]*(\\\"|\\\')?'+url.replace(/([\.\/\?])/g, '\\\$1')+'[^>]*>'+areaName+'<\\\/a> *', 'ig');
  var text = '<a href="'+url+'">'+areaName+'</a> '+e162100T.value.replace(reg, '');
  e162100T.value = e162100I.document.body.innerHTML = text;
  location.href='#editor162100_';
  
}

-->
</script>
<br />
<div class="column"><a href="?get=area">栏目设置</a>中，如果有多个模板，可将其它未用的模板做成独立频道置于此导航栏中，进而增加网站的丰富性。</div>
<div class="list_title"><a class="list_title_in">以模板形式<?php echo ''.($web['url_html_list'] == 1 ? '<input type="checkbox" class="checkbox" id="html_php_mode" /> 伪静态' : '').''; ?></a></div>
<ul class="manager_menu">
<div class="list_title_">
  <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <th>模板名</th>
      <th style="width:150px;">操作</th>
    </tr>
  </table>
</div>
<?php
  $text = $err = '';
  if ($m_arr = @glob('./inc/css/*', GLOB_ONLYDIR)) {
    foreach ($m_arr as $m_f) {
      $base_index_mode = basename($m_f);
	  $title = @file_get_contents($m_f.'/title.txt');
			if ($_GET['mode'] == $base_index_mode) {
				$chk = ' checked="checked" disabled="disabled"';
				$lik = '——';
			} else {
				$chk = '';
				$lik = '<button type="button" onclick="addModeBanner(\''.$base_index_mode.'\', \''.@file_get_contents('./inc/css/'.$base_index_mode.'/title2.txt').'\', \'list\');"><b>插入</b></button>';
			}
        $text .= '<div class="li">
  <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td style="text-align:left;"><input type="radio" class="radio" name="sitemode" value="'.$base_index_mode.'"'.$chk.' /> '.substr($base_index_mode, 0, 1).'*** '.$title.' [<a href="index.php?mode='.$base_index_mode.'" target="_blank">预览</a> ]</td>
      <td style="width:150px;">'.$lik.'</td>
    </tr>
  </table>
</div>';
      unset($base_index_mode, $chk, $lik);
    }
  } else {
        $err .= '没有模板！';
  }
  echo $text;
$text = $text__ = $err = '';
  




?>
</ul>






<div class="list_title"><a class="list_title_in">以栏目形式<?php echo ''.($web['url_html_list'] == 1 ? '<input type="checkbox" class="checkbox" id="html_php_area" /> 伪静态' : '').''; ?></a></div>
<ul class="manager_menu">
<div class="list_title_">
  <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <th>栏目名</th>
      <th style="width:150px;">操作</th>
    </tr>
  </table>
</div>
  <?php
$list_url = $web['url_html_list'] == 1 ? '"list.".$mode.".".$row["area_id"]."..1.html"' : '"list.php?mode=".$mode."&area_id=".$row["area_id"].""';


$n = $mess = 0;
if (!isset($sql['db_err'])) {
  db_conn();
}

if ($sql['db_err'] == '') {

  $result = @mysql_query('SELECT area_id,area_name,area_index FROM '.$sql['pref'].''.$sql['data']['承载版区分类的表名'].' WHERE area_id REGEXP "^[0-9]+\-[0-9]+$"', $db);
  if (@mysql_num_rows($result) > 0) {
    $text .= '
';
    while ($row = @mysql_fetch_assoc($result)) {
      $mode = get_li_mode($row['area_index']);
      $text .= '
<div class="li">
  <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td style="text-align:left;"><a href="'.eval('return '.$list_url.';').'">'.$row['area_name'].'</a></td>
      <td style="width:150px;"><button type="button" onclick="addAreaBanner(\''.$mode.'\', \''.$row['area_name'].'\', \''.$row['area_id'].'\');"><b>插入</b></button></td>
    </tr>
  </table>
</div>';
      unset($row, $mode);
    }
  } else {
    $err .= '暂无隐藏栏目！';
  }
  @mysql_free_result($result);


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

@mysql_close();
echo $text, $err;
$text = $err = '';
?>
</ul>


<?php

} else {
  $_GET['mode'] = $web['sitemode'];
  if ($m_arr = @glob('./inc/css/*', GLOB_ONLYDIR)) {
    foreach ($m_arr as $m_f) {
      $base_index_mode = basename($m_f);
	  $title = @file_get_contents($m_f.'/title.txt');
      if (file_exists('./inc/css/'.$base_index_mode.'/index.php') && file_exists('./inc/css/'.$base_index_mode.'/list.php') && file_exists('./inc/css/'.$base_index_mode.'/article.php')) {
       $text .= '<div class="column__"><a href="?mode='.$base_index_mode.'&get=banner">'.substr($base_index_mode, 0, 1).'*** ['.$title.'] 的导航栏编辑</a></div>';
      } else {
        $text__ .= '<div class="column__">'.substr($base_index_mode, 0, 1).'*** ['.$title.'] 该风格尚未安装，请<a href="http://wpa.qq.com/msgrd?v=3&uin=184830962&site=qq&menu=yes" target="_blank">QQ联系程序作者</a>定制</div>';
      }
      unset($base_index_mode, $title);
    }
  } else {
    $err .= '没有任何模板，也无法进行栏目分类管理！';
  }
}


echo $text,$text__, $err;


?>
