<?php
require ('authentication_member.php');
?>
<?php

/* 编辑我的文章 */
/* 162100源码 - 162100.com */

if (!isset($_GET['area_id'])) {
  $_GET['area_id'] = @$_POST['area_id'];
}
$_REQUEST['id'] = array_unique((array)$_REQUEST['id']);
$_REQUEST['id'] = $_REQUEST['id'][0];

$arr_area_title = $arr_area_child = $arr_area_power = array();
$mess = $point = 0;
if ($_REQUEST['id'] && is_numeric($_REQUEST['id'])) {
  if (!isset($sql['db_err'])) {
    db_conn();
  }

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

    $result = @mysql_query('SELECT mess_num,check_reg,point FROM '.$sql['pref'].''.$sql['data']['承载成员档案的表名'].' WHERE username="'.$session[0].'" LIMIT 1', $db);
    if ($row = @mysql_fetch_assoc($result)) {
      if ($row['check_reg'] == '1') {
        $err = '帐号注册审核中！';
      } elseif ($row['check_reg'] == '2') {
        $err = '帐号已被移除至<a href="list_member.php?act=punished" target="_blank">黑名单</a>！';
      } else {
        $mess = '<span class="grayword">'.preg_replace('/^\d+/', '<span>$0</span>', $row['mess_num']).'</span>';
        //求和货币值
        $result__ = @mysql_query('SELECT SUM(money) AS total FROM '.$sql['pref'].''.$sql['data']['承载财务数据的表名'].' WHERE (username="'.$session[0].'" AND type="0")', $db);
        $row__ = @mysql_fetch_assoc($result__);
        $total_funds = floatval($row__['total']);
        unset($row__);
        @mysql_free_result($result__);
      }
      $point = $row['point'];
      unset($row);
    } else {
      $err = '帐号不存在！';
    }
    @mysql_free_result($result);

    if (empty($err)) {
      if (preg_match('/^(\d+\-\d+)(\_\d+)*$/', $_GET['area_id'], $area_m)) {
        $area_id_root = $area_m[1];
        //栏目属性
        $result = @mysql_query('SELECT * FROM '.$sql['pref'].''.$sql['data']['承载版区分类的表名'].' WHERE area_id="'.$area_id_root.'" LIMIT 1', $db);
        $row = @mysql_fetch_assoc($result);
        @mysql_free_result($result);
        $sitemode = $area_mode[$area_id_root] = get_li_mode($row['area_index']);

        //栏目
        $base_title = $_GET['area_id'];
        $eval_title = 'area_id="'.$_GET['area_id'].'"';
        $area_title = 'strip_tags($arr_area_title[\''.$_GET['area_id'].'\'])';
    while (strpos($base_title, '_') !== false) {
      $base_title = preg_replace('/\_\d+$/', '', $base_title);
      $eval_title .= ' OR area_id="'.$base_title.'"';
      $area_title = '$arr_area_title[\''.$base_title.'\'].\' &gt; \'.'.$area_title.'';
    }

        $result = @mysql_query('SELECT * FROM `'.$sql['pref'].''.$sql['data']['承载版区分类的表名'].'` WHERE '.$eval_title.' OR area_id REGEXP "^'.$_GET['area_id'].'_[0-9]+$"', $db);
        if (mysql_num_rows($result) > 0) {
          while ($row = @mysql_fetch_assoc($result)) {
            if (strstr('area'.$_GET['area_id'], 'area'.$row['area_id'])) {
              $arr_area_title[$row['area_id']] = '<a href="?get=list_edit2&mode='.$area_mode[$area_id_root].'&area_id='.$row['area_id'].'&id='.$_REQUEST['id'].'"'.$row['area_style'].'>'.$row['area_name'].'</a> ';
            } else {
              $arr_area_child[$row['area_id']] = '<a href="?get=list_edit2&mode='.$area_mode[$area_id_root].'&area_id='.$row['area_id'].'&id='.$_REQUEST['id'].'" style="white-space:nowrap;"'.$row['area_style'].'>'.$row['area_name'].'</a> ';
            }
            unset($row);
          }
        }
        @mysql_free_result($result);
        @uksort($arr_area_child, 'strnatcmp');
        eval('$title1 = '.$area_title.';');

        if (empty($arr_area_title[$_GET['area_id']])) {
          $n = '（栏目分类不存在！）';
        } else {
          if (count($arr_area_child) > 0) {
            $mark_child = '<span class="redword">该标签仍可细分：</span>';
          } else {
            $yes = '现在可以发表了';
          }
          $childs = $row['area_mark'].'<br />'.@$mark_child.''.@implode('', $arr_area_child);
        }

      } else {
        $title1 = '分类';
        $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) {
          while ($row = @mysql_fetch_assoc($result)) {
            $area_mode[$row['area_id']] = get_li_mode($row['area_index']);
            $arr_area_child[$row['area_id']] = '<a href="?get=list_edit2&mode='.$area_mode[$row['area_id']].'&area_id='.$row['area_id'].'&id='.$_REQUEST['id'].'">'.$row['area_name'].'</a><br />';
          }
          unset($row);
        }
        @mysql_free_result($result);
        @uksort($arr_area_child, 'strnatcmp');

        $childs = '<br />'.@implode('', $arr_area_child);

      }

      $result=mysql_query('SELECT A.author_ip,A.area_id,A.title,A.text,A.reward,B.title AS t FROM '.$sql['pref'].''.$sql['data']['承载主题文章的表名'].' AS A LEFT JOIN '.$sql['pref'].''.$sql['data']['承载关键词的表名'].' AS B ON B.id=A.id WHERE A.id="'.$_REQUEST['id'].'"', $db);
      if ($row = @mysql_fetch_assoc($result)) {
        if ($row['author_ip'] != $session[0]) {
          if (!(POWER >= 4 || (POWER >= 2 && strstr($session[4], '('.get_arearoot($row['area_id']).')')))) {
            $err .= '经查你与该文作者不符！且不是管理员或版主。';
          }
        }
        if (strstr($row['reward'], '（已兑现）')) {
          $err .= '该文已经兑现悬赏，不允再编辑。';
        }

      } else {
        $err = '数据库查无此文章记录！';
      }
      @mysql_free_result($result);

    }

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

  require ('inc/function/add_online.php'); //在线
  @mysql_close();

} else {
  $err = '文章参数出错！问题分析：1、您可能未选择文章；2、参数传递出错';
}

if (empty($err)) {

  echo '<u><b><span class="redword">*</span> 类目：</b></u><br />
<a href="?get=list_edit2&id='.$_REQUEST['id'].'">全部栏目</a> &gt; '.$title1.''; // <a href="member.php?get=list_edit2&id='.$_REQUEST['id'].'"> [ 改变类目 ]</a>';
  echo '<br />'.$childs, @$n.'<br />';

  if (@$yes == '现在可以发表了') {
    echo '<div style="position:relative;z-index:99;">';
    if (POWER == 1 && is_numeric($row['area_power_write']) && abs($session[3]) < $row['area_power_write']) {
      echo '<div class="ok filter">系统设置该分类发表需要成员积分达到'.$row['area_power_write'].'</div>';
    }
    echo '</div>';

$sub = @explode('|TMD|', $row['t']);

?>
<iframe id="lastFrame" name="lastFrame" frameborder="0" style="display:none"></iframe>
<script type="text/javascript">
<!--

function runReward(obj) {
  var power = <?php echo POWER; ?>;
  var funds = <?php echo $total_funds; ?>;
  var text = '';
  if (power < 4) {
    if (funds > 0) {
      text = '对此文悬赏 <input name="reward" id="reward" type="text" size="5" onkeyup="isDigit(this,1,1,\'.\')" onblur="chkReward(this)" /> 货币值<span class="grayword">（你货币值余额为'+funds+'）</span>';
    } else {
      text = '你货币值余额为0，无法悬赏<span class="grayword">（<a href="member.php?get=myfunds" target="_blank">充值</a>）</span>';
    }
  } else {
    text = '对此文悬赏 <input name="reward" id="reward" type="text" size="5" onkeyup="isDigit(this,1,1,\'.\')" onblur="chkReward(this)" /> 货币值';
  }
  obj.parentNode.innerHTML = '&nbsp;'+text+'&nbsp;<a href="javascript:void(0)" onclick="runRewardClose(this)" style=" text-decoration:none;">╳</a>&nbsp;';
}
function runRewardClose(obj) {
  obj.parentNode.innerHTML='<img src="inc/images/coin.gif" onclick="runReward(this);" style="cursor:pointer;margin:5px;" title="设置悬赏分，进行悬赏" />';
}
function chkReward(obj) {
  var power = <?php echo POWER; ?>;
  var funds = <?php echo $total_funds; ?>;
  var reward = <?php echo floatval($row['reward']); ?>;
  if (parseFloat(obj.value) < reward) {
    alert('悬赏值只能增加不能减少！');
    obj.value = reward;
    return;
  }
  if (power < 4) {
    if (parseFloat(obj.value) > reward) {
      if (parseFloat(obj.value) - reward > funds) {
        alert('余额（'+funds+'）不足！你最多只能悬赏'+(reward + funds)+'货币值');
        obj.value = reward + funds;
        return;
      }
    }
  }
}

var uploadPower = <?php echo $point >= $web['up_start'] || POWER >= 4 ? '"yes"' : $web['up_start']; ?>;
var liMaxCount = <?php echo $web['list_wordcount']; ?>;
var eXSize = 588;       //编辑器宽度，最小宽度限588px
var formU = '?post=edit&id=<?php echo $_REQUEST['id']; ?>&mode=<?php echo @$sitemode; ?>';
var formT='<input type="hidden" name="m" id="m" value="1" /><u><b id="a_subject"><span class="redword">*</span> 题　目：</b></u><br /><table border="0" cellspacing="0" cellpadding="0"><tr><td width="348"><input class="large" name="subject" id="subject" type="text" value="<?php echo $row['title']; ?>" style="width:330px" maxlength="180" /></td><td><div style="float:left;font-size:13px;background-color:#F2F2F2;height:26px;line-height:24px;border:#DDDDDD 1px solid;overflow:hidden;"><?php echo (is_numeric($row['reward']) && $row['reward'] > 0) ? '&nbsp;对此文悬赏 <input name="reward" id="reward" type="text" size="5" value="'.$row['reward'].'" onkeyup="isDigit(this,1,1,\\\'.\\\')" onblur="chkReward(this)" /> 货币值&nbsp;' : '<img src="inc/images/coin.gif" onclick="runReward(this);" style="cursor:pointer;margin:5px;" title="设置悬赏分，进行悬赏" />'; ?></div></td></tr></table><br /><u><b><span class="redword">*</span> 关键词：</b></u><br /><input name="keyword" id="keyword" type="text" onfocus="if(this.value!=\'\'){this.className=\'large\';}else{this.className=\'large subject_keyword\';}" onblur="if(this.value==\'\'){this.className=\'large subject_keyword\';}else{this.className=\'large\';}"<?php echo trim($sub[1]) != '' ? '" class="large" value="'.trim($sub[1]).'"' : ' class="large subject_keyword"'; ?> size="50" maxlength="180" /><br /><br /><input type="hidden" name="area_id" value="<?php echo $_GET['area_id']; ?>" /><u><b id="a_content"><span class="redword">*</span> 内　容：</b></u><br />';
var contT = '<?php echo addslashes($row['text']); ?>';
document.write('<'+'sc'+'ript language="javascript" src="inc/js/editor.js?'+new Date().getTime()+'" type="text/javascript"></'+'sc'+'ript>');
-->
</script>
<br />
<script language="javascript" type="text/javascript">
<!--
function previewContents(){
  try{
    document.mainform162100.action='inc/require/z_other_getpreview.php';
    document.mainform162100.target='lastFrame';
    runSubmit();
  }catch(err){
    alert('预览失败！请稍候再试或放弃。');
  }
}
-->
</script>
[ <a href="#" onclick="previewContents();return false;">点此预览——看看文章提交后的实际效果。保证没有禁用词，以便审核顺利通过。</a> ]<br />
提示：禁用词表现为：<SPAN title=此处词汇被过滤 style="BACKGROUND-COLOR: #cc9999"> !!!!! </SPAN>
<?php
  }
} else {
  echo $err;
}
?>
