<?php

/* 管理员后台首页 */
/* 162100源码 - 162100.com - download.162100.com */


@ require ('inc/set/set.php');
/*
if ($_SERVER['HTTP_REFERER'] && strpos($_SERVER['HTTP_REFERER'], $web['sitehttp']) !== 0) {
  err('跨域操作越权！');
}
*/
@ require ('inc/set/set_sql.php');
@ require ('inc/function/confirm_power.php');
//身份验证
$POWER = confirm_power();

//深层验证
if ($POWER) {
  if ($POWER >= 2 && $POWER <= 5) {
    $GLOBALS['session_key'] = get_session_key();
    if ($POWER == 5) {
      if (!$GLOBALS['session_key']) {
        $GLOBALS['session_key'] = substr(@file_get_contents('__temp__/temp/'.urlencode($session[0]).'.php'), 15);
      }
	}
    if (!(strlen($GLOBALS['session_key']) == 36 && $session[1].'|'.$session[2] == $GLOBALS['session_key'])) {
      $POWER = 1.5;
      $GLOBALS['session_err'] = ' <span class="redword">身份密钥已更改！请重新在此浏览器<a href="login.php" onclick="if(parent!=self)this.target=\'_blank\';">登陆</a>恢复。</span>';
    }
  } else {
    $POWER = 1.5;
  }
}

define('POWER', $POWER);
$userface = user_class(POWER, $session[3]);
function get_li_mode($area_index) {
  global $web;
  if (!isset($area_index) || empty($area_index)) {
    return $web['sitemode'];
  } elseif (strstr($area_index, $web['sitemode'])) {
    return $web['sitemode'];
  } else {
    $sitemode = false;
    foreach (@explode('|', $area_index) as $mode) {
      if (file_exists('inc/css/'.$mode.'/index.php') && file_exists('inc/css/'.$mode.'/list.php') && file_exists('inc/css/'.$mode.'/article.php')) {
        $sitemode = $mode == $web['sitemode'] ? $web['sitemode'] : $mode;
        break;
      }
    }
    return $sitemode ? $sitemode : $web['sitemode'];
  }
}

function get_mode($area_index) {
  global $web;
  if (!isset($area_index) || empty($area_index)) {
    return $web['sitemode'];
  } else {
    if (file_exists('inc/css/'.$area_index.'/index.php') && file_exists('inc/css/'.$area_index.'/list.php') && file_exists('inc/css/'.$area_index.'/article.php')) {
      return $area_index;
    } else {
      return $web['sitemode'];
    }
  }
}

@ $GLOBALS['this_mode'] = get_mode($_GET['mode']);


$post = !empty($_POST['post']) ? $_POST['post'] : (!empty($_GET['post']) ? $_GET['post'] : false);
$post = preg_replace('/[\.\/]+|eval|base64_/i', '', $post);
if (!empty($post)) {

  //输出信息
  function alert($text = '', $href) {
    global $web;
    echo '
    <div class="output"><p><img src="inc/images/ok.gif" /> '.$text.'</p>
        <p>或点击以下链接进入...<a href="'.$href.'">'.$href.'</a></p></div>
    </td>
  </tr>
</table>
<style type="text/css">
<!--
#transition { background:#FFFFFF; }
-->
</style>
<script language="javascript" type="text/javascript">
<!--
setTimeout("location.href=\''.$href.'\';", 5000);
-->
</script>
</body>
</html>';
    die;
  }

  //输出错误
  function err($text = '', $src = 'i') {
    global $web;
    echo '
    <div class="output"><p><img src="inc/images/'.$src.'.gif" /> '.$text.'</p>
    <p>点此可<a href="javascript:window.history.back();">返回</a></p></div>
    </td>
  </tr>
</table>
<style type="text/css">
<!--
#transition { background:#FFFFFF; }
-->
</style>
</body>
</html>';
    die;
  }

  echo '<!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>程序执行</title>
<link href="inc/css/'.$GLOBALS['this_mode'].'/style.css" rel="stylesheet" type="text/css" id="my_style">
<style type="text/css">
<!--
html { height:100%; text-align:center; background:none; border:none;  padding:0; }
body { width:auto; height:100%; margin:0 auto; padding:0; border-top:none; margin-top:0; background:url(inc/images/loading.gif) 50% 50% no-repeat; border:none; }
#transition { text-align:center; margin:auto; }
.wherego { margin:10px auto; background-color:#FFFFFF; }
.wherego td { width:50%; font-size:12px; word-wrap:break-word; word-break:break-all; }
.wherego td.whereyou { text-align:right; }
-->
</style>
<script type="text/javascript" language="javaScript" src="inc/js/main.js"></script>
</head>
<body>';

  //echo str_repeat(' ', 4096);
  //@ob_flush();
//@flush();
echo '
<table id="transition" width="100%" height="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td>';
  if ($post != false && file_exists('inc/run/post_manager_'.$post.'.php')) {
    @ require ('inc/run/post_manager_'.$post.'.php');
  } else {
    err('命令错误或功能尚未开通！');
  }
  echo '
<style type="text/css">
<!--
#transition { background:#FFFFFF; }
-->
</style>
    </td>
  </tr>
</table>
</body>
</html>';


  //echo str_repeat(' ', 4096);
  //@ob_flush();
//@flush();
die;
}

function get_en_url($d) {
  //$arr = @explode('/', $d);
  //$arr = array_map('urlencode', $arr);
  //return @implode('%2F', $arr);
  return urlencode(base64_encode($d));
}





$POWER_url = array(
  'set'                => array('POWER==5', ' &gt; 系统参数管理'),
  'sql'                => array('POWER==5', ' &gt; 数据库管理'),
  'area'               => array('POWER==5', ' &gt; 栏目分类管理'),
  'mail'               => array('POWER==5', ' &gt; 邮箱参数设定'),
  'logo'               => array('POWER==5', ' &gt; 上传图标'),
  'modify'             => array('POWER==5', ' &gt; 在线修改文件'),
  'banner'             => array('POWER==5', ' &gt; 编辑导航栏'),
  'foot'               => array('POWER==5', ' &gt; 编辑页脚'),
  'pay'                => array('POWER==5', ' &gt; 支付宝收银接口设置'),
  'upgrade'            => array('POWER==5', ' &gt; 在线升级'),
  'chadu'              => array('POWER==5', ' &gt; 查木马'),
  'friendlink'         => array('POWER>=4', ' &gt; 首页友情链接管理'),
  'tools'              => array('POWER>=4', ' &gt; 首页常用工具管理'),
  'ip'                 => array('POWER>=4', ' &gt; 屏蔽IP'),
  'upload'             => array('POWER>=4', ' &gt; 上载文件管理'),
  'member'             => array('POWER>=4', ' &gt; 成员管理'),
  'member_userface'    => array('POWER>=4', ' &gt; 成员头像管理'),
  'member_company'     => array('POWER>=4', ' &gt; 商号管理'),
  'check'              => array('POWER>=2', ' &gt; 审核待发文章'),
  'list'               => array('POWER>=2', ' &gt; 管理已发文章'),
  'check_reply'        => array('POWER>=2', ' &gt; 审核待发回帖'),
  'reply'              => array('POWER>=2', ' &gt; 管理已发回帖'),
  'reset_area_statistics'        => array('POWER>=4', ' &gt; 一键重置各栏目记录数'),
  'reset_area_mark'         => array('POWER>=4', ' &gt; 一键重置热门标签'),
  'member_check_reg'   => array('POWER>=4', ' &gt; 用户注册审批及黑名单'),
  'member_credit'      => array('POWER>=4', ' &gt; 用户信誉管理'),
  'member_funds'       => array('POWER>=4', ' &gt; 用户货币管理'),
  'member_badorder'    => array('POWER>=4', ' &gt; 查看过期订单'),
  'bulk_mail'          => array('POWER>=4', ' &gt; 群发邮件'),
  'ad'             => array('POWER>=4', ' &gt; 广告位管理'),
  'door'               => array('POWER>=2', ''),
);

if (!@$_GET['get'] || !isset($POWER_url[$_GET['get']])) {
  $_GET['get'] = 'door';
}
if (@ $_GET['get'] == 'sql') {
  header('Cache-Control:no-cache,must-revalidate');
  header('Pragma:no-cache');
}


?><!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 $POWER_url[$_GET['get']][1];

$index_url = $web['url_html_index'] == 1 ? 'index.html' : 'index.php';
echo $web['code_author'];

?></title>
<link id="my_style" rel="stylesheet" type="text/css" href="inc/css/<?php echo $GLOBALS['this_mode']; ?>/style.css">
<script language="javascript" type="text/javascript" src="inc/js/main.js"></script>
<script language="javascript" type="text/javascript">
<!--
function showE(o,id){
  var oe=$(id);
  oe.style.display='inline';
  o.onmouseout=function(){
    oe.style.display='none';
  }
}
-->
</script>
</head>
<body>
<script> loginReloadYeNo=true; </script>
<div id="session" class="session">
<button type="button" onclick="window.open('write.php','_blank');" title="发布文章"><b><div class="send_write"></div></b></button>
    <?php
echo @ $GLOBALS['session_err'];
@ include ('inc/require/head.txt');
?>
    &nbsp;
</div>
<div id="logo"><a href="<?php echo $web['path']; ?>"><img src="<?php echo $web['sitelogo']; ?>" /></a></div>
<div id="banner"> <a href="./">首页</a> <a class="column_is">管理员控制台</a> <a href="help.php">帮助</a> <?php @include ('inc/css/'.$web['sitemode'].'/banner.txt'); ?></div>
<div class="column"><h5><a href="./">首页</a> &gt; <a href="webmaster_central.php">管理员控制台</a><?php echo $POWER_url[$_GET['get']][1]; ?></h5></div>
<?php
if (eval('return '.$POWER_url[$_GET['get']][0].';')) {
?>
<table width="100%" height="400" border="0" cellspacing="0" cellpadding="0" id="menu">
  <tr>
    <td valign="top" id="leftmenu" class="leftmenu"><?php
if (POWER == 5) {
?>
        <strong>在线升级</strong>
        <ul>
          <li><a id="bar-upgrade" href="?get=upgrade">在线升级</a></li>
          <li><a id="bar-chadu" href="webmaster_central.php?post=chadu">查木马</a></li>
        </ul>
        <strong>系统设置</strong>
        <ul>
          <li><a id="bar-set" href="?get=set">系统参数</a></li>
          <li><a id="bar-sql" href="?get=sql">数据库参数</a></li>
          <li><a id="bar-area" href="?get=area">栏目分类</a></li>
          <li><a id="bar-mail" href="?get=mail">邮箱参数</a></li>
        </ul>
      <?php
}
?>
        <?php
if (POWER >= 2) {
?>
        <strong>信息管理</strong>
        <ul>
          <li><a id="bar-check" href="?get=check">审核待发文章</a></li>
          <li><a id="bar-list" href="?get=list">管理已发文章</a></li>
          <li><a id="bar-check_reply" href="?get=check_reply">审核待发回帖</a></li>
          <li><a id="bar-reply" href="?get=reply">管理已发回帖</a></li>
        </ul>
      <?php
  if (POWER >= 4) {
?>
        <strong>成员管理</strong>
        <ul>
          <li onmouseover="showE(this,'e7')"><a id="bar-member" href="?get=member">成员(头像、商号)管理</a></li>
          <li><a id="bar-member_check_reg" href="?get=member_check_reg">用户注册审批及黑名单</a></li>
          <li><a id="bar-bulk_mail" href="?get=bulk_mail">群发邮件</a></li>
          <li><a id="bar-ip" href="?get=ip">屏蔽IP</a></li>
        </ul>
      <strong>其它管理</strong>
        <ul>
          <li onmouseover="showE(this,'e6')"><a id="bar-inc/require/badword.txt" href="?get=modify&otherfile=<?php echo get_en_url('inc/require/badword.txt'); ?>">过滤词汇(一词一行)</a></li>
          <li><a id="bar-upload" href="?get=upload">上载文件管理</a></li>
          <li><a id="bar-reset_area_statistics" href="?get=reset_area_statistics">一键重置各栏目记录数</a></li>
          <li><a id="bar-reset_area_mark" href="webmaster_central.php?post=unity_run&dataname=reset_area_mark&id[]=1" onclick="return confirm('确定执行么？该命令可能需要较长时间')">一键重置热门标签</a></li>
        </ul>
      <?php
  }
?>
        <?php
}
?>
        <?php
if (POWER == 5) {
?>
        <strong>帐单管理</strong>
        <ul>
          <li><a id="bar-member_credit" href="?get=member_credit">用户信誉管理</a></li>
          <li><a id="bar-member_funds" href="?get=member_funds">用户货币管理</a></li>
          <li><a id="bar-member_badorder" href="?get=member_badorder">查看过期订单</a></li>
          <li><a id="bar-pay" href="?get=pay">支付宝收银接口设置</a></li>
        </ul>
      <strong>部件管理</strong>
        <ul>
          <li><a id="bar-banner" href="?get=banner">编辑导航栏</a></li>
          <li onmouseover="showE(this,'e5')"><a id="bar-foot" href="?get=foot">编辑页脚(含统计代码)</a> <span class="redword" id="e5" style="display:none">(若加统计代码，加于此项中)</span></li>
          <li><a id="bar-tools" href="?get=tools">首页常用工具</a></li>
          <li><a id="bar-friendlink" href="?get=friendlink">首页友情链接</a></li>
          <li><a id="bar-inc/require/icp.txt" href="?get=modify&otherfile=<?php echo get_en_url('inc/require/icp.txt'); ?>">ICP备案号</a></li>
        </ul>
      <strong>广告管理</strong>
        <ul>
          <li><a id="bar-ad" href="?get=ad">广告位管理</a></li>
          <!--li><a id="bar-inc/require/ad_list.txt" href="?get=modify&otherfile=<?php echo get_en_url('inc/require/ad_list.txt'); ?>">出售广告位</a></li-->
        </ul>
      <strong>在线修改</strong>
        <ul>
          <li onmouseover="showE(this,'e4')"><a id="bar-modify" href="?get=modify">修改文件(代码)</a> <span class="redword" id="e4" style="display:none">(此项要求熟悉代码语言)</span></li>
        </ul>
      <?php
}
?>
    </td>
    <td valign="top" class="rightmenu"><?php

  //<!-- require -->

  if (file_exists('inc/run/get_manager_'.$_GET['get'].'.php')) {
    require_once ('inc/run/get_manager_'.$_GET['get'].'.php');
    if ($_GET['get'] == 'modify') {
      $bar_id = !empty($_GET['otherfile']) ? base64_decode($_GET['otherfile']) : 'modify';
    } else {
      $bar_id = $_GET['get'];
    }
    echo '<script> try { if ($("bar_id_") != null) { $("bar_id_").id = ""; } $("bar-'.$bar_id.'").parentNode.id = "bar_id_"; } catch (err) {} </script>';
  } else {
    echo '<img src="inc/images/i.gif" /> 文件inc/run/get_manager_'.$_GET['get'].'.php不见了！请检查。';
  }

  //<!-- /require -->

?>
    </td>
  </tr>
</table>
<?php
} else {

  echo '<div class="body"><div class="siteannounce"><img src="inc/images/i.gif" /> 请以'.($POWER_url[$_GET['get']][0] == 'POWER>=2' ? '版主及管理员' : ($POWER_url[$_GET['get']][0] == 'POWER>=4' ? '管理员' : '基础管理员')).'身份<a href="login.php">登陆</a>！以获得此项管理权限。</div></div>';
}
?>
<div id="foot">
  <?php @include ('inc/css/'.$GLOBALS['this_mode'].'/foot.txt'); ?>
</div>
<?php
//检测数据库连接
if ($_GET['get'] != 'sql' && $_GET['get'] != 'upgrade') {
  if (isset($sql['db_err']) && $sql['db_err'] != '') {
    echo '<div id="submit_safe" class="filter"><table width="100%" height="100%"><tr><td><div id="submit_safe_in">'.$sql['db_err'].'</div></td></tr></table></div>';
  }
}
?>

</body>
</html>