<?php

if(!defined('OT_ROOT')) {
	exit('Access Denied');
}



class UsersNews{

	public static function Jud(){
		global $userSysArr;
		if ($userSysArr['US_isNews'] == 1){ return true; }else{ return false; }
	}

	// 用户菜单
	public static function UminiMenu($mode='pc'){
		if (! self::Jud()){ return ''; }
		if ($mode == 'home'){
			return '<div id="homeLogin_news"><a href="'. Users::SysUrl('addNews','','./') .'" class="font2_1" >[发表文章]</a></div>';
		}else{
			return '<div id="uebox_news" class="left" style="padding-left:8px;"><a href="'. Users::SysUrl('addNews','','./') .'" class="font2_1" >[投稿]</a></div>';
		}
	}

	// 会员中心信息统计栏
	public static function UcInfo($userID){
		if (! self::Jud()){ return ''; }

		global $DB;
		$whereTime = TimeDate::Add('d',-30,TimeDate::Get());
		$infoAddNum = $infoAuditNum = 0;
		$infoAddNum = $DB->GetOne('select count(IF_ID) from '. OT_dbPref .'info where IF_userID='. $userID .' and IF_time>='. $DB->ForTime($whereTime));
		if ($infoAddNum > 0){
			$infoAuditNum = $DB->GetOne('select count(IF_ID) from '. OT_dbPref .'info where IF_userID='. $userID .' and IF_isAudit=1 and IF_time>='. $DB->ForTime($whereTime));
		}

		return '
			<div class="item">
				<div class="serNum">0'. (++ UsersCenter::$infoNum) .'</div>
				<div class="cont">
					文章
					<p class="number">最近30天内发表了<span class="num1">'. $infoAddNum .'</span>篇，审核通过<span class="num2">'. $infoAuditNum .'</span>篇</p>
				</div>
				<div class="func"><a href="usersCenter.php?mudi=newsManage">管理</a></div>
			</div>
			<div class="clr"></div>
			';
	}

	public static function UcMenu(){
		if (! self::Jud()){ return ''; }

		return '
			<li><a href="usersCenter.php?mudi=addNews">发布文章</a></li>
			<li><a href="usersCenter.php?mudi=newsManage">文章管理</a></li>
			';
	}

	// 添加/修改文章
	public static function AddOrRev(){
		global $DB,$mudi,$userSysArr,$userRow,$systemArr,$webPathPart;

		$infoSysArr = Cache::PhpFile('infoSys');

		$UE_ID			= $userRow['UE_ID'];
		$UE_username	= $userRow['UE_username'];

		$dataID = OT::GetInt2( OT::ParaArr('id') );
		$beforeURL = GetUrl::CurrDir();

		if (! self::Jud()){
			return '<br /><br /><center>文章功能已关闭，有问题请联系管理员</center>';
		}

		$retStr = '';
		$writerAddiStr = '';
		if ($mudi == 'revNews'){
			if ($userSysArr['US_isNewsRev'] == 0){
				return '<br /><br /><center>不允许修改文章，有问题请联系管理员</center>';
			}
			
			$revexe = $DB->query('select IF_ID,IF_theme,IF_isOri,IF_source,IF_writer,IF_typeStr,IF_tabID,IF_content,IF_upImgStr,IF_pageNum,IF_themeKey,IF_contentKey,IF_mediaFile,IF_file,IF_fileName,IF_fileStr,IF_isRenameFile,IF_isUserFile,IF_isNew,IF_isHomeThumb,IF_isThumb,IF_isFlash,IF_isImg,IF_isMarquee,IF_isRecom,IF_isTop,IF_img,IF_voteMode,IF_isReply,IF_isCheckUser,IF_score1,IF_score2,IF_score3,IF_cutScore1,IF_cutScore2,IF_cutScore3,IF_isEnc,IF_encContent,IF_addition,IF_topicList,IF_topAddiID,IF_addiID,IF_freeGroupList,IF_userGroupList,IF_cutQuickMoney,IF_mediaFile,IF_videoID from '. OT_dbPref .'info where IF_ID='. $dataID);
				if (! $row = $revexe->fetch()){
					return '<br /><br /><center style="font-size:14px;">获取不到指定的记录.</center>';
				}
				$IF_ID			= $row['IF_ID'];
				$IF_theme		= $row['IF_theme'];
				$IF_isOri		= $row['IF_isOri'];
				$IF_source		= $row['IF_source'];
				$IF_writer		= $row['IF_writer'];
				$IF_typeStr		= $row['IF_typeStr'];
				if ($row['IF_tabID'] > 0){
					$IF_content	= Info::GetTabContent($row['IF_tabID'], $dataID);
				}else{
					$IF_content	= $row['IF_content'];
				}
					$imgUrl = $beforeURL . InfoImgDir;
					$IF_content	= str_replace(InfoImgAdminDir,$imgUrl,$IF_content);
				$IF_upImgStr	= $row['IF_upImgStr'];
				$IF_pageNum		= $row['IF_pageNum'];
				$IF_themeKey	= $row['IF_themeKey'];
				$IF_contentKey	= $row['IF_contentKey'];
				$IF_mediaFile	= $row['IF_mediaFile'];
				$IF_file		= $row['IF_file'];
				$IF_fileName	= $row['IF_fileName'];
				$IF_fileStr		= $row['IF_fileStr'];
					if (strlen($IF_fileStr) == 0 && strlen($IF_file) > 0){
						$IF_fileStr = $IF_file .'|'. $IF_fileName .'|';
						$IF_fileName = '';
						$IF_file = '';
					}
				$IF_isRenameFile= $row['IF_isRenameFile'];
				$IF_isUserFile	= $row['IF_isUserFile'];
				$IF_isNew		= $row['IF_isNew'];
				$IF_isHomeThumb	= $row['IF_isHomeThumb'];
				$IF_isThumb		= $row['IF_isThumb'];
				$IF_isFlash		= $row['IF_isFlash'];
				$IF_isImg		= $row['IF_isImg'];
				$IF_isMarquee	= $row['IF_isMarquee'];
				$IF_isRecom		= $row['IF_isRecom'];
				$IF_isTop		= $row['IF_isTop'];
				$IF_img			= $row['IF_img'];
				$IF_voteMode	= $row['IF_voteMode'];
				$IF_isReply		= $row['IF_isReply'];
				$IF_topicList	= $row['IF_topicList'];
				$IF_topAddiID	= $row['IF_topAddiID'];
				$IF_addiID		= $row['IF_addiID'];
				$IF_isCheckUser	= $row['IF_isCheckUser'];
				$IF_freeGroupList = $row['IF_freeGroupList'];
				$IF_userGroupList = $row['IF_userGroupList'];
				$IF_score1		= $row['IF_score1'];
				$IF_score2		= $row['IF_score2'];
				$IF_score3		= $row['IF_score3'];
				$IF_cutScore1	= $row['IF_cutScore1'];
				$IF_cutScore2	= $row['IF_cutScore2'];
				$IF_cutScore3	= $row['IF_cutScore3'];
				$IF_isEnc		= $row['IF_isEnc'];
				$IF_encContent	= $row['IF_encContent'];
				$IF_addition	= $row['IF_addition'];
				$IF_cutQuickMoney = $row['IF_cutQuickMoney'];
				$IF_mediaFile	= $row['IF_mediaFile'];
				$IF_videoID		= $row['IF_videoID'];
			unset($revexe);

			$ug = new UserGroup($UE_ID);
			$infoScore1	= $ug->row['UG_infoScore1'];
			$infoScore2	= $ug->row['UG_infoScore2'];
			$infoScore3	= $ug->row['UG_infoScore3'];
			if (strpos(''. $ug->row['UG_event'],'|禁止投稿|') !== false){
				return '<br /><br /><center>您所在用户组禁止投稿，如有问题请联系管理员</center>';
			}

			$mudiCN = '修 改';
		}else{
			if ($userSysArr['US_isNewsAdd'] == 0){
				return '<br /><br /><center>文章发表已关闭，如有问题请联系管理员</center>';
			}

			$ug = new UserGroup($UE_ID);
			$infoScore1	= $ug->row['UG_infoScore1'];
			$infoScore2	= $ug->row['UG_infoScore2'];
			$infoScore3	= $ug->row['UG_infoScore3'];
			if (strpos(''. $ug->row['UG_event'],'|禁止投稿|') !== false){
				return '<br /><br /><center>您所在用户组禁止投稿，如有问题请联系管理员</center>';
			}

			// 总投稿数限制
			$retArr = $ug->InfoTotalNumArr();
				if ($retArr['res']){
					if (strlen($retArr['note']) > 0){
						$retStr .= '<div style="color:blue;font-size:16px;padding-bottom:6px;">'. $retArr['note'] .'</div>';
					}
				}else{
					return '<center style="padding-top:25px;font-size:16px;">'. $retArr['note'] .'</center>';
				}
			
			// 每日投稿限制
			$retArr = $ug->InfoDayNumArr();
				if ($retArr['res']){
					if (strlen($retArr['note']) > 0){
						$retStr .= '<div style="color:blue;font-size:16px;padding-bottom:6px;">'. $retArr['note'] .'</div>';
					}
				}else{
					return '<center style="padding-top:25px;font-size:16px;">'. $retArr['note'] .'</center>';
				}

			$nasStr = $nas2Str = '';
			$newsAddScoreArr = Users::ScoreArr('newsAdd');
			if ($newsAddScoreArr['US_score1'] < 0){
				$nasStr .= $userSysArr['US_score1Name'] .'：'. $newsAddScoreArr['US_score1'] .'&ensp;&ensp;';
			}
			if ($userSysArr['US_isScore2'] == 1 && $newsAddScoreArr['US_score2'] < 0){
				$nasStr .= $userSysArr['US_score2Name'] .'：'. $newsAddScoreArr['US_score2'] .'&ensp;&ensp;';
			}
			if ($userSysArr['US_isScore3'] == 1 && $newsAddScoreArr['US_score3'] < 0){
				$nasStr .= $userSysArr['US_score3Name'] .'：'. $newsAddScoreArr['US_score3'] .'&ensp;&ensp;';
			}
			if (strlen($nasStr) > 0){
				$state0Num = $DB->GetOne('select count(IF_ID) from '. OT_dbPref .'info where IF_userID='. $UE_ID .' and IF_isAudit<>1 and IF_isGetScore=0');
				$state0Score1	= $newsAddScoreArr['US_score1'] * $state0Num;
				$state0Score2	= $newsAddScoreArr['US_score2'] * $state0Num;
				$state0Score3	= $newsAddScoreArr['US_score3'] * $state0Num;
				
				$urs = $DB->GetRow('select UE_realname,UE_score1,UE_score2,UE_score3 from '. OT_dbPref .'users where UE_ID='. $UE_ID);
				if ($urs['UE_score1'] + $newsAddScoreArr['US_score1'] + $state0Score1 < 0){
					$nas2Str .= '<div>您当前 '. $userSysArr['US_score1Name'] .'：'. $urs['UE_score1'] .'，不足以扣除 '. abs($newsAddScoreArr['US_score1']) . ($state0Score1 < 0 ? ' + <span style="color:blue;">'. abs($state0Score1) .'(未审核文章'. $state0Num .'篇)</span>' : '') .'</div>';
				}
				if ($userSysArr['US_isScore2'] == 1 && $urs['UE_score2'] + $newsAddScoreArr['US_score2'] + $state0Score2 < 0){
					$nas2Str .= '<div>您当前 '. $userSysArr['US_score2Name'] .'：'. $urs['UE_score2'] .'，不足以扣除 '. abs($newsAddScoreArr['US_score2']) . ($state0Score2 < 0 ? ' + <span style="color:blue;">'. abs($state0Score2) .'(未审核文章'. $state0Num .'篇)</span>' : '') .'</div>';
				}
				if ($userSysArr['US_isScore3'] == 1 && $urs['UE_score3'] + $newsAddScoreArr['US_score3'] + $state0Score3 < 0){
					$nas2Str .= '<div>您当前 '. $userSysArr['US_score3Name'] .'：'. $urs['UE_score3'] .'，不足以扣除 '. abs($newsAddScoreArr['US_score3']) . ($state0Score3 < 0 ? ' + <span style="color:blue;">'. abs($state0Score3) .'(未审核文章'. $state0Num .'篇)</span>' : '') .'</div>';
				}
				if (strlen($nas2Str) > 0){
					$alertStr = ' ';
					if (AppMoneyAlipay::Jud() || AppMoneyWeixin::Jud()){
						$alertStr .= '，您可以先 <a href="'. $webPathPart .'usersCenter.php?mudi=onlinePay&isBack=1" target="_blank" style="font-weight:bold;text-decoration:underline;color:red;">在线充值</a> 然后再投稿 ';
					}
					return '<div style="padding-bottom:10px;">发布文章需要 '. $nasStr . $alertStr .'</div>'. $nas2Str;
				}
			}

			$IF_ID			= 0;
			$IF_theme		= '';
			$IF_isOri		= 0;
			$IF_source		= $userSysArr['US_newsSource'];
			$IF_writer		= $userSysArr['US_newsWriter'];
				if (strpos($IF_writer,'{username}') !== false){
					$IF_writer		= str_replace('{username}', $UE_username, $IF_writer);
				}elseif (strpos($IF_writer,'{会员用户名}') !== false){
					$IF_writer		= str_replace('{会员用户名}', $UE_username, $IF_writer);
				}elseif (strpos($IF_writer,'{会员用户名部分隐藏}') !== false){
					$IF_writer		= str_replace('{会员用户名部分隐藏}', Str::PartHide($UE_username), $IF_writer);
				}
				if (strpos($IF_writer,'{会员昵称}') !== false){
					if (isset($urs['UE_realname'])){
						$realname = $urs['UE_realname'];
					}else{
						$realname = $DB->GetOne('select UE_realname from '. OT_dbPref .'users where UE_ID='. $UE_ID);;
					}
					if ($IF_writer == '{会员昵称}' && strlen($realname) == 0){
						$writerAddiStr = '<span style="color:red;">（昵称为空，可以到 个人资料修改 - 姓名/昵称 填写下）</span>';
					}
					$IF_writer		= str_replace('{会员昵称}', $realname, $IF_writer);
				}
			$IF_typeStr		= $userSysArr['US_newsTypeStr'];
			$IF_content		= '';
			$IF_upImgStr	= '';
			$IF_pageNum		= '';
			$IF_themeKey	= '';
			$IF_contentKey	= '';
			$IF_mediaFile	= '';
			$IF_file		= '';
			$IF_fileName	= '';
			$IF_fileStr		= '';
			$IF_isRenameFile= 0;
			$IF_isUserFile	= 0;
			$IF_isNew		= 1;
			$IF_isHomeThumb	= 0;
			$IF_isThumb		= 0;
			$IF_isFlash		= 0;
			$IF_isImg		= 0;
			$IF_isMarquee	= 0;
			$IF_isRecom		= 0;
			$IF_isTop		= 0;
			$IF_img			= '';
			$IF_voteMode	= 1;
			$IF_isReply		= 1;
			$IF_topicList	= '';
			$IF_topAddiID	= 0;
			$IF_addiID		= 0;
			$IF_isCheckUser	= 0;
			$IF_freeGroupList = '';
			$IF_userGroupList = '';
			$IF_score1		= '';
			$IF_score2		= '';
			$IF_score3		= '';
			$IF_cutScore1	= '';
			$IF_cutScore2	= '';
			$IF_cutScore3	= '';
			$IF_isEnc		= 0;
			$IF_encContent	= '';
			$IF_addition	= '';
			$IF_cutQuickMoney = '';
			$IF_videoID		= 0;

			$mudiCN = '发 表';
		}

		if ($userSysArr['US_isRevSource'] == 1){
			$sourceStr = '<input type="text" id="source" name="source" class="text" value="'. Str::MoreReplace($IF_source,'input') .'" style="width:500px;" />';
		}else{
			$sourceStr = $IF_source .'<input type="hidden" id="source" name="source" value="'. Str::MoreReplace($IF_source,'input') .'" />';
		}
		if ($userSysArr['US_isRevWriter'] == 1){
			$writerStr = '<input type="text" id="writer" name="writer" class="text" value="'. Str::MoreReplace($IF_writer,'input') .'" style="width:500px;" />';
		}else{
			$writerStr = $IF_writer . $writerAddiStr .'<input type="hidden" id="writer" name="writer" value="'. Str::MoreReplace($IF_writer,'input') .'" />';
		}

		if (strlen(trim(''. Str::RegExp($userSysArr['US_addNewsAnnoun'],'html'))) >= 3){
			$retStr .= '<div class="announ">'. $userSysArr['US_addNewsAnnoun'] .'</div>';
		}

		$retStr .= '
		<script language="javascript" type="text/javascript" src="js/usersNews.js?v='. OT_VERSION .'"></script>
		<script language="javascript" type="text/javascript" src="js/inc/editor.js?v='. OT_VERSION .'"></script>

		<div style="color:red;padding-top:10px;">带 * 号为必填项，其他项可选。</div>
		<form id="dealForm" name="dealForm" method="post" action="usersNews_deal.php?mudi=deal" onsubmit="return CheckNewsForm();" class="form">
		<script language="javascript" type="text/javascript">document.write(\'<input type="hidden" name="backURL" value="\'+ document.location.href +\'" />\')</script>
		<input type="hidden" id="dataID" name="dataID" value="'. $IF_ID .'" />
		<input type="hidden" id="beforeURL" name="beforeURL" value="'. $beforeURL .'" />
		<input type="hidden" id="userID" name="userID" value="'. $UE_ID .'" />
		<input type="hidden" id="isScore1" name="isScore1" value="'. $userSysArr['US_isScore1'] .'" />
		<input type="hidden" id="isScore2" name="isScore2" value="'. $userSysArr['US_isScore2'] .'" />
		<input type="hidden" id="isScore3" name="isScore3" value="'. $userSysArr['US_isScore3'] .'" />
		<input type="hidden" id="score1Name" name="score1Name" value="'. $userSysArr['US_score1Name'] .'" />
		<input type="hidden" id="score2Name" name="score2Name" value="'. $userSysArr['US_score2Name'] .'" />
		<input type="hidden" id="score3Name" name="score3Name" value="'. $userSysArr['US_score3Name'] .'" />
		<input type="hidden" id="infoScore1" name="infoScore1" value="'. $infoScore1 .'" />
		<input type="hidden" id="infoScore2" name="infoScore2" value="'. $infoScore2 .'" />
		<input type="hidden" id="infoScore3" name="infoScore3" value="'. $infoScore3 .'" />
		<table cellpadding="0" cellspacing="0" class="revInfoBox">
		<tr><td style="width:100px;"></td><td></td></tr>
		<tr>
			<td align="right"><span class="font2_2">*</span>&ensp;标题：</td>
			<td>
				<input type="text" id="theme" name="theme" class="text" value="'. Str::MoreReplace($IF_theme,'input') .'" style="width:500px;" />
				<span style="'. self::CssDisplay($userSysArr['US_newsCloseArea'], 'isOri') .'">&ensp;<label title="原创打钩，会根据百度原创保护 星火计划2.0 在页头增加原创标签"><input type="checkbox" name="isOri" value="1" '. Is::Checked($IF_isOri,1) .' />原创</label></span>
				&ensp;&ensp;<a href="javascript:void(0);" onclick="CheckRepeatTheme();return false;" style="text-decoration:underline;">检测重复标题</a>
			</td>
		</tr>
		<tr>
			<td align="right">来源：</td>
			<td>'. $sourceStr .'</td>
		</tr>
		<tr>
			<td align="right">作者：</td>
			<td>'. $writerStr .'</td>
		</tr>
		<tr>
			<td align="right"><span class="font2_2">*</span>&ensp;栏目：</td>
			<td>
				<select id="typeStr" name="typeStr">
				<option value=""></option>
				';
				$typeNum = 0;
				$typeexe = $DB->query('select * from '. OT_dbPref .'infoType where IT_state=1 and IT_level=1 and IT_isUser=1 order by IT_rank ASC');
				if (! $row = $typeexe->fetch()){
					$retStr .= '
					<option value="">无栏目，需到后台 常规设置-栏目管理 开启[用户投稿]</option>
					';
				}else{
					do {
						$typeNum ++;
						$type2exe = $DB->query('select * from '. OT_dbPref .'infoType where IT_state=1 and IT_level=2 and IT_fatID='. $row['IT_ID'] .' and IT_isUser=1 order by IT_rank ASC');
						if (! $row2 = $type2exe->fetch()){
							$retStr .= '<option value=",'. $row['IT_ID'] .'," '. Is::InstrSelected($IF_typeStr,','. $row['IT_ID'] .',') .'>'. $typeNum .'、'. $row['IT_theme'] .'</option>';
						}else{
							$retStr .= '<optgroup label="'. $typeNum .'、'. $row['IT_theme'] .'" style="font-weight:normal;"></optgroup>';
							do{
								$retStr .= '<option value=",'. $row['IT_ID'] .','. $row2['IT_ID'] .'," '. Is::InstrSelected($IF_typeStr,','. $row2['IT_ID'] .',') .'>&ensp;&ensp;&ensp;┣&ensp;'. $row2['IT_theme'] .'</option>';
							}while ($row2 = $type2exe->fetch());
						}
						$type2exe=null;
					}while ($row = $typeexe->fetch());
				}
				unset($typeexe);

				$retStr .= '
				</select>&ensp;
				<span class="font2_2">如果有二级栏目,一级栏目不能选择</span><span onclick=\'if($id("bugBox").style.display==""){$id("bugBox").style.display="none";}else{$id("bugBox").style.display="";}\'>&ensp;</span><label id="bugBox" style="display:none;"><input type="checkbox" id="bugMode" name="bugMode" value="1" />调试模式</label>
			</td>
		</tr>
		<tr>
			<td align="right" valign="top" style="padding-top:6px;"><span class="font2_2">*</span>&ensp;内容：</td>
			<td>
				<textarea id="content" name="content" cols="40" rows="4" style="width:680px;height:500px;" class="text" onclick=\'LoadEditor("content",0,800,"");\' title="点击开启编辑器模式">'. $IF_content .'</textarea>
				<div>
					<input type="button" onclick=\'InsertStrToEditor("content", "[OT_page]");\' value="插入分页符" />
					'. AppBase::UsersNewsBox1($userSysArr['US_isNewsUpImg'], 'content', $dataID) .'
					<input type="hidden" id="infoFileDir" name="infoFileDir" value="'. InfoImgDir .'" />
					<input type="hidden" id="upImgStr" name="upImgStr" value="'. $IF_upImgStr .'" />
				</div>
			</td>
		</tr>
		<tr style="'. self::CssDisplay($userSysArr['US_newsCloseArea'], 'pageNum') .'">
			<td align="right">自动分页字数：</td>
			<td>
				<input type="text" id="pageNum" name="pageNum" size="50" style="width:50px;" value="'. $IF_pageNum .'" />
				&ensp;<span class="font2_2">页数=内容总字数÷自动分页字数；如果在内容中加入了手动分页符或不想分页,请填写0或留空</span>
			</td>
		</tr>
		<tr style="'. self::CssDisplay($userSysArr['US_newsCloseArea'], 'themeKey') .'">
			<td align="right" valign="top" style="padding-top:8px;">关键词(标签)：</td>
			<td>
				<input type="text" id="themeKey" name="themeKey" class="text" value="'. Str::MoreReplace($IF_themeKey,'input') .'" style="width:500px;" />
				&ensp;<a href="javascript:void(0);" onclick=\'GetKeyWord("fc");return false;\' style="text-decoration:underline;">分词获取</a>
				<!-- &ensp;&ensp;<a href="javascript:void(0);" onclick=\'GetKeyWord("dz");return false;\' style="text-decoration:underline;">网络获取</a> -->
				&ensp;&ensp;<a href="javascript:void(0);" onclick=\'GetKeyWord("");return false;\' style="text-decoration:underline;">本地获取</a>
				<br /><span class="font2_2">多个关键词用空格、竖杆“|”或逗号“,”隔开</span>
				&ensp;<span id="onloadThemeKey" class="font3_2"></span>
			</td>
		</tr>
		<tr style="'. self::CssDisplay($userSysArr['US_newsCloseArea'],'contentKey') .'">
			<td align="right" valign="top" style="padding-top:8px;">内容摘要：</td>
			<td>
				<textarea id="contentKey" name="contentKey" cols="40" rows="4" style="width:500px;height:60px;" class="text">'. Str::MoreReplace($IF_contentKey,'textarea') .'</textarea>
				&ensp;<a href="javascript:void(0);" onclick="ToContentKey();return false;" style="text-decoration:underline;">自动获取</a>
				<br /><span class="font2_2">内容摘要为空则自动获取</span>
			</td>
		</tr>
		'. AppBase::UsersNewsBox2($userSysArr['US_isNewsUpFile'], $IF_isRenameFile, $IF_isUserFile, $IF_file, $IF_fileName, $IF_fileStr, $dataID) .'
		';
		$addiStr = '';
		if (strpos($userSysArr['US_newsAddiStr'],'|new|') !== false){
			$addiStr .= '<label title="出现在前台最新消息处"><input type="checkbox" id="isNew" name="isNew" onclick="CheckAddition()" value="1" '. Is::Checked($IF_isNew,1) .' />最新消息</label>&ensp;&ensp;';
		}
		if (strpos($userSysArr['US_newsAddiStr'],'|homeThumb|') !== false){
			$addiStr .= '<label title="首页栏目显示图片文章需要此属性，同时所属栏目【在首页显示图片文章】需要开启"><input type="checkbox" id="isHomeThumb" name="isHomeThumb" onclick="CheckAddition()" value="1" '. Is::Checked($IF_isHomeThumb,1) .' />首页缩略图</label>&ensp;&ensp;';
		}
		if (strpos($userSysArr['US_newsAddiStr'],'|thumb|') !== false){
			$addiStr .= '<label title="列表页中显示"><input type="checkbox" id="isThumb" name="isThumb" onclick="CheckAddition()" value="1" '. Is::Checked($IF_isThumb,1) .' />缩略图</label>&ensp;&ensp;';
		}
		if (strpos($userSysArr['US_newsAddiStr'],'|flash|') !== false){
			$addiStr .= '<label title="首页左上角幻灯片"><input type="checkbox" id="isFlash" name="isFlash" onclick="CheckAddition()" value="1" '. Is::Checked($IF_isFlash,1) .' />幻灯片</label>&ensp;&ensp;';
		}
		if (strpos($userSysArr['US_newsAddiStr'],'|img|') !== false){
			$addiStr .= '<label title="首页中部滚动图片"><input type="checkbox" id="isImg" name="isImg" onclick="CheckAddition()" value="1" '. Is::Checked($IF_isImg,1) .' />滚动图片</label>&ensp;&ensp;';
		}
		if (strpos($userSysArr['US_newsAddiStr'],'|marquee|') !== false){
			$addiStr .= '<label title="页头滚动信息"><input type="checkbox" id="isMarquee" name="isMarquee" onclick="CheckAddition()" value="1" '. Is::Checked($IF_isMarquee,1) .' />滚动信息</label>&ensp;&ensp;';
		}
		if (strpos($userSysArr['US_newsAddiStr'],'|recom|') !== false){
			$addiStr .= '<label title="出现在精彩推荐/本类推荐里"><input type="checkbox" id="isRecom" name="isRecom" onclick="CheckAddition()" value="1" '. Is::Checked($IF_isRecom,1) .' />推荐</label>&ensp;&ensp;';
		}
		if (strpos($userSysArr['US_newsAddiStr'],'|top|') !== false){
			$addiStr .= '<label title="出现在最新消息第一条及列表页前几条"><input type="checkbox" id="isTop" name="isTop" onclick="CheckAddition()" value="1" '. Is::Checked($IF_isTop,1) .' />置顶</label>&ensp;&ensp;';
		}
		if (strlen($addiStr) > 0){
			$addiStr = '
				<tr style="'. self::CssDisplay($userSysArr['US_newsCloseArea'],'isAttr') .'">
					<td align="right">文章属性：</td>
					<td>'. $addiStr .'</td>
				</tr>
				';
		}

		$retStr .= $addiStr .'
		<tr id="imgBox" style="display:none;">
			<td align="right">缩略图/图片：</td>
			<td>
				<input type="text" id="img" name="img" size="50" style="width:320px;" value="'. $IF_img .'" />
				<span style="position:relative;"><span style="position:absolute; left:-200px; top:22px;"><img id="imgView" src="" width="100" style="display:none;" onerror=\'CheckNoPicErr(this, "'. $webPathPart .'", "def");\' /></span></span>
				<input type="button" onclick=\'OT_OpenUpImg("input","img","info","&proType=info&proID='. $dataID .'")\' value="上传图片" />
				&ensp;<a href="javascript:void(0);" onclick="GetEditorImg();return false;" class="font1_2" style="text-decoration:underline;">从编辑器中获取</a>
				<div id="editorImgBox"></div>
			</td>
		</tr>
		'. AppAudioVideo::UsersNewsBox1($IF_videoID, 'pc');
		if ($userSysArr['US_isNewsVote'] == 99){
			$retStr .= '
			<tr>
				<td align="right">投票方式：</td>
				<td>
					<label><input type="radio" name="voteMode" value="0" '. Is::Checked($IF_voteMode,0) .' />关闭</label>&ensp;&ensp;
					<label><input type="radio" name="voteMode" value="1" '. Is::Checked($IF_voteMode,1) .' />心情</label>&ensp;&ensp;
					<label><input type="radio" name="voteMode" value="2" '. Is::Checked($IF_voteMode,2) .' />顶踩</label>&ensp;&ensp;
					<label><input type="radio" name="voteMode" value="11" '. Is::Checked($IF_voteMode,11) .' />百度喜欢按钮</label>&ensp;&ensp;
				</td>
			</tr>
			';
		}
		if ($userSysArr['US_isReply'] == 99){
			$retStr .= '
			<tr>
				<td align="right">评论区：</td>
				<td>
					<label><input type="radio" name="isReply" value="1" '. Is::Checked($IF_isReply,1) .' />显示</label>&ensp;&ensp;
					<label><input type="radio" name="isReply" value="0" '. Is::Checked($IF_isReply,0) .' />隐藏</label>&ensp;&ensp;
				</td>
			</tr>
			';
		}
		if ($userSysArr['US_topicID'] == -1){
			$retStr .= AppTopic::UcNewsTrBox1($IF_topicList, 'pc');
		}
		if ($userSysArr['US_topAddiID'] == -1 || $userSysArr['US_addiID'] == -1){
			$topAddiOptionStr = $addiOptionStr = '';
			$addiexe=$DB->query("select IW_ID,IW_theme from ". OT_dbPref ."infoWeb where IW_type='news' order by IW_rank ASC");
			while ($row = $addiexe->fetch()){
				$topAddiOptionStr .= '<option value="'. $row['IW_ID'] .'" '. Is::Selected($IF_topAddiID,$row['IW_ID']) .'>'. $row['IW_theme'] .'</option>';
				$addiOptionStr .= '<option value="'. $row['IW_ID'] .'" '. Is::Selected($IF_addiID,$row['IW_ID']) .'>'. $row['IW_theme'] .'</option>';
			}
			unset($addiexe);

			if ($userSysArr['US_topAddiID'] == -1){
				$retStr .= '
				<tr>
					<td align="right">头附加内容：</td>
					<td>
						<select id="topAddiID" name="topAddiID">
						<option value="0">无</option>
						'. $topAddiOptionStr .'
						</select>
					</td>
				</tr>
				';
			}
			if ($userSysArr['US_addiID'] == -1){
				$retStr .= '
				<tr>
					<td align="right">尾附加内容：</td>
					<td>
						<select id="addiID" name="addiID">
						<option value="0">无</option>
						'. $addiOptionStr .'
						</select>
					</td>
				</tr>
				';
			}
		}
		if ($userSysArr['US_isCheckUser'] == 1){
			$scoreNum = 0;
			if ($userSysArr['US_isScore1'] == 1 && $infoScore1 > 0){ $score1Style = ''; $scoreNum ++; }else{ $score1Style = 'display:none;'; }
			if ($userSysArr['US_isScore2'] == 1 && $infoScore2 > 0){ $score2Style = ''; $scoreNum ++; }else{ $score2Style = 'display:none;'; }
			if ($userSysArr['US_isScore3'] == 1 && $infoScore3 > 0){ $score3Style = ''; $scoreNum ++; }else{ $score3Style = 'display:none;'; }
			if ($scoreNum == 0){ $noScoreStr = '<span style="color:blue;">[无法设置，您会员组尚未设置最大积分]</span>'; }else{ $noScoreStr = ''; }

			$freeGroupStr = $limitGroupStr = '';
			$groupexe = $DB->query('select UG_ID,UG_theme from '. OT_dbPref .'userGroup where UG_state=1 order by UG_rank ASC');
			while ($row = $groupexe->fetch()){
				$freeGroupStr .= '<label><input type="checkbox" name="freeGroupList[]" value="['. $row['UG_ID'] .']" '. Is::InstrChecked($IF_freeGroupList,'['. $row['UG_ID'] .']') .'>'. $row['UG_theme'] .'</label>&ensp;&ensp;';
				$limitGroupStr .= '<label><input type="checkbox" name="userGroupList[]" value="['. $row['UG_ID'] .']" '. Is::InstrChecked($IF_userGroupList,'['. $row['UG_ID'] .']') .'>'. $row['UG_theme'] .'</label>&ensp;&ensp;';
			}
			unset($groupexe);

			$retStr .= '
			<tr>
				<td align="right">限制阅读：</td>
				<td align="left">
					<label><input type="checkbox" id="addition_user" name="addition[]" value="|checkUser|" '. Is::InstrChecked($IF_addition,'|checkUser|') .' onclick="CheckCheckUser()" />仅限会员阅读</label>&ensp;&ensp;
					<label><input type="checkbox" id="addition_reply" name="addition[]" value="|checkReply|" '. Is::InstrChecked($IF_addition,'|checkReply|') .' onclick="CheckCheckUser()" />会员回复可见</label>&ensp;&ensp;
					'. AppMoneyQuick::InfoCheckItem($IF_addition, 'qiantai') .'
					'. AppNewsPwd::InfoCheckItem($IF_addition, 'qiantai') .'
					'. AppXcxAd::InfoCheckItem($IF_addition, 'qiantai') .'
				</td>
			</tr>
			<tbody id="checkUserBox" style="display:none;">
			<tr><td align="left" colspan="2">
				<table align="left" cellpadding="0" cellspacing="0" summary="" class="padd3" style="width:100%;">
				<tr>
					<td class="tabLeftWidth"></td>
					<td align="left" colspan="4"><b>【仅限会员阅读】设置区</b></td>
				</tr>
				<tr>
					<td align="right" style="width:120px;"></td>
					<td align="center" style="width:55px;'. $score1Style .'">'. $userSysArr['US_score1Name'] .'</td>
					<td align="center" style="width:55px;'. $score2Style .'">'. $userSysArr['US_score2Name'] .'</td>
					<td align="center" style="width:55px;'. $score3Style .'">'. $userSysArr['US_score3Name'] .'</td>
					<td></td>
				</tr>
				<tr>
					<td align="right"></td>
					<td align="center" style="'. $score1Style .'">≤'. $infoScore1 .'</td>
					<td align="center" style="'. $score2Style .'">≤'. $infoScore2 .'</td>
					<td align="center" style="'. $score3Style .'">≤'. $infoScore3 .'</td>
					<td></td>
				</tr>
				<tr>
					<td align="right">限制阅读积分：</td>
					<td align="center" style="'. $score1Style .'"><input type="text" id="score1" name="score1" value="'. $IF_score1 .'" size="3" style="width:65px;" onkeyUp="this.value=FiltInt(this.value)" /></td>
					<td align="center" style="'. $score2Style .'"><input type="text" id="score2" name="score2" value="'. $IF_score2 .'" size="3" style="width:65px;" onkeyUp="this.value=FiltInt(this.value)" /></td>
					<td align="center" style="'. $score3Style .'"><input type="text" id="score3" name="score3" value="'. $IF_score3 .'" size="3" style="width:65px;" onkeyUp="this.value=FiltInt(this.value)" /></td>
					<td class="font2_2">'. $noScoreStr .'（用户积分达到才能阅读，不要求直接填0）</td>
				</tr>
				<tr>
					<td align="right">付费阅读积分：</td>
					<td align="center" style="'. $score1Style .'"><input type="text" id="cutScore1" name="cutScore1" value="'. $IF_cutScore1 .'" size="3" style="width:65px;" onkeyUp="this.value=FiltInt(this.value)" /></td>
					<td align="center" style="'. $score2Style .'"><input type="text" id="cutScore2" name="cutScore2" value="'. $IF_cutScore2 .'" size="3" style="width:65px;" onkeyUp="this.value=FiltInt(this.value)" /></td>
					<td align="center" style="'. $score3Style .'"><input type="text" id="cutScore3" name="cutScore3" value="'. $IF_cutScore3 .'" size="3" style="width:65px;" onkeyUp="this.value=FiltInt(this.value)" /></td>
					<td class="font2_2">'. $noScoreStr .'（用户扣积分才能阅读）</td>
				</tr>
				<tr>
					<td align="right">免费阅读组：</td>
					<td align="left" colspan="4">
						'. $freeGroupStr .'
						<span class="font2_2">(【免费阅读组】优先于【限制/付费阅读组】)</span>
					</td>
				</tr>
				<tr>
					<td align="right">限制/付费阅读组：</td>
					<td align="left" colspan="4">
						'. $limitGroupStr .'
						<span class="font2_2">(都不选，等于允许所有用户组)</span>
					</td>
				</tr>
				</table>
			</td></tr>
			<tbody>
			<tbody id="checkQuickBox" style="display:none;">
				'. AppMoneyQuick::InfoTrBox($IF_cutQuickMoney, 'qiantai') .'
			</tbody>
			<tbody id="checkPwdBox" style="display:none;">
			</tbody>
			<tbody id="newsEncBox" style="display:none;">
				'. AppNewsEnc::UcInfoTrBox1($IF_isEnc, $IF_encContent, $IF_addition, $IF_ID) .'
			</tbody>
			';
		}
		if (OT_OpenVerCode && strpos($systemArr['SYS_verCodeStr'],'|news|')!==false){
			$retStr .= '
			<tr>
				<td align="right">验证码：</td>
				<td>'. Area::VerCode('dealForm') .'</td>
			</tr>
			';
		}
		$retStr .= '
		</table>
		<center style="padding-right:100px;">
			<input type="submit" value=" '. $mudiCN .' " class="btn subBtn" />
			<span id="loadingStr"></span>
		</center>
		</form>

		<script language="javascript" type="text/javascript">
		LoadEditor("content",0,800,"");
		try {
			CheckFile();
		}catch (e) {}
		try {
			CheckAddition();
		}catch (e) {}
		try {
			CheckCheckUser();
		}catch (e) {}
		try {
			$("#img").on("mouseover", function() {

				}).on("mouseenter", function() { 
					$("#imgView").css({"display":""});
					$id("imgView").src=$id("infoFileDir").value + $id("img").value;
				}).on("mouseleave", function(){
					$("#imgView").css({"display":"none"});
			});
		}catch (e) {}
		</script>
		';

		return $retStr;
	}



	// 文章管理
	public static function Manage(){
		global $DB,$mudi,$userRow,$userSysArr,$webPathPart;

		if (! self::Jud()){
			return '<br /><br /><center>文章功能已关闭，有问题请联系管理员</center>';
		}

		$UE_ID		= $userRow['UE_ID'];

		$refTypeStr	= OT::GetRegExpStr('refTypeStr','sql+,');
	//	$refState	= OT::GetInt('refState',-1);
		$refTheme	= OT::GetRegExpStr('refTheme','sql');
		$refSource	= OT::GetRegExpStr('refSource','sql');
		$refWriter	= OT::GetRegExpStr('refWriter','sql');

		$SQLstr='select IF_ID,IF_theme,IF_time,IF_infoTypeDir,IF_datetimeDir,IF_readNum,IF_replyNum,IF_isAudit,IF_isGetScore,IF_auditNote from '. OT_dbPref .'info where IF_userID='. $UE_ID .'';

		if ($refTypeStr != ''){ $SQLstr .= " and IF_typeStr like '%". $DB->ForStr($refTypeStr,false) ."%'"; }
	//	if ($refState > -1){ $SQLstr .= " and IF_state=". $refState; }
		if ($refTheme != ''){ $SQLstr .= " and IF_theme like '%". $DB->ForStr($refTheme,false) ."%'"; }
		if ($refSource != ''){ $SQLstr .= " and IF_source like '%". $DB->ForStr($refSource,false) ."%'"; }
		if ($refWriter != ''){ $SQLstr .= " and IF_writer like '%". $DB->ForStr($refWriter,false) ."%'"; }

		$newsDelScoreArr = Users::ScoreArr('newsDel');

		$announ = '';
		if (strlen(trim(''. Str::RegExp($userSysArr['US_newsMngAnnoun'],'html'))) >= 3){
			$announ = '<div class="announ">'. $userSysArr['US_newsMngAnnoun'] .'</div>';
		}

		$retStr = '
		<script language="javascript" type="text/javascript" src="js/usersNews.js?v='. OT_VERSION .'"></script>

		<input type="hidden" id="isScore1" name="isScore1" value="'. $userSysArr['US_isScore1'] .'" />
		<input type="hidden" id="isScore2" name="isScore2" value="'. $userSysArr['US_isScore2'] .'" />
		<input type="hidden" id="isScore3" name="isScore3" value="'. $userSysArr['US_isScore3'] .'" />
		<input type="hidden" id="score1Name" name="score1Name" value="'. $userSysArr['US_score1Name'] .'" />
		<input type="hidden" id="score2Name" name="score2Name" value="'. $userSysArr['US_score2Name'] .'" />
		<input type="hidden" id="score3Name" name="score3Name" value="'. $userSysArr['US_score3Name'] .'" />
		<input type="hidden" id="delScore1" name="delScore1" value="'. $newsDelScoreArr['US_score1'] .'" />
		<input type="hidden" id="delScore2" name="delScore2" value="'. $newsDelScoreArr['US_score2'] .'" />
		<input type="hidden" id="delScore3" name="delScore3" value="'. $newsDelScoreArr['US_score3'] .'" />

		'. $announ .'
		<div style="padding:5px 5px 15px 5px;">
			<form id="refForm" name="refForm" method="get" action="" onsubmit="return CheckRefNewsForm()">
			<input type="hidden" name="mudi" value="'. $mudi .'" />
			栏目：<select id="refTypeStr" name="refTypeStr" style="width:150px;">
				<option value=""></option>
				';
				$typeNum = 0;
				$typeexe = $DB->query('select * from '. OT_dbPref .'infoType where IT_state=1 and IT_level=1 and IT_isUser=1 order by IT_rank ASC');
					while ($row = $typeexe->fetch()){
						$retStr .= '<option value=",'. $row['IT_ID'] .'," '. Is::InstrSelected($refTypeStr,','. $row['IT_ID'] .',') .'>'. $typeNum .'、'. $row['IT_theme'] .'</option>';

						$typeNum ++;
						$type2exe = $DB->query('select * from '. OT_dbPref .'infoType where IT_state=1 and IT_level=2 and IT_fatID='. $row['IT_ID'] .' and IT_isUser=1 order by IT_rank ASC');
							while ($row2 = $type2exe->fetch()){
								$retStr .= '<option value=",'. $row['IT_ID'] .','. $row2['IT_ID'] .'," '. Is::InstrSelected($refTypeStr,','. $row2['IT_ID'] .',') .'>&ensp;&ensp;&ensp;┣&ensp;'. $row2['IT_theme'] .'</option>';
							}
						$type2exe = null;
					}
				unset($typeexe);

				$retStr .= '
				</select>&ensp;&ensp;&ensp;
			标题：<input type="text" id="refTheme" name="refTheme" style="width:120px;" value="'. $refTheme .'" />&ensp;&ensp;&ensp;
			来源：<input type="text" id="refSource" name="refSource" style="width:70px;" value="'. $refSource .'" />&ensp;&ensp;&ensp;
			作者：<input type="text" id="refWriter" name="refWriter" style="width:70px;" value="'. $refWriter .'" />&ensp;&ensp;&ensp;
			<input type="submit" value="查 询" class="btn subBtn2 btn-info" />&ensp;&ensp;
			<input type="button" value="重 置" onclick=\'document.location.href="?mudi=newsManage";\' class="btn defBtn2" />
			</form>
		</div>

		<table cellpadding="0" cellspacing="0" border="0" class="tabList1">
		<thead>
		<tr>
			<td width="6%" align="center">编号</td>
			<td width="44%" align="center">标题</td>
			<td width="7%" align="center">阅读量</td>
			<td width="7%" align="center">评论数</td>
			<td width="8%" align="center">状态</td>
			<td width="14%" align="center">发布时间</td>
			<td width="14%" align="center">操作</td>
		</tr>
		</thead>
		';
		$pageSize	= $userRow['UE_pageNum'];	// 每页条数
		$page		= OT::GetInt('page');
		$showRow=$DB->GetLimit($SQLstr .' order by IF_time DESC',$pageSize,$page);
		if (! $showRow){
			$retStr .= '</table><center class="font1_1 padd8">暂无内容</center>';
			return $retStr;
		}else{
			$recordCount=$DB->GetRowCount();
			$pageCount=ceil($recordCount/$pageSize);
			if ($page < 1 || $page > $pageCount){$page=1;}

			$retStr .= '<tbody class="tabBody">';
			$number=1+($page-1)*$pageSize;
			$rowCount = count($showRow);
			for ($i=0; $i<$rowCount; $i++){
				if ($i % 2 == 1){ $bgcolor='class="tabColorTr"'; }else{ $bgcolor=''; }
				$newsBtn = $auditNote = '';
				if ($showRow[$i]['IF_isAudit'] == 1){
					$auditCN = '<span style="color:green;">已审核</span>';
					$newsBtn = '<a style="margin-right:8px;" href="'. Url::NewsID($showRow[$i]['IF_infoTypeDir'],$showRow[$i]['IF_datetimeDir'],$showRow[$i]['IF_ID']) .'" target="_blank">预览</a>';
				}elseif ($showRow[$i]['IF_isAudit'] == 2){
					$auditCN = '<span style="color:red;">被拒绝</span>';
					$auditNote = '<div style="padding-top:3px;color:red;">被拒绝原因：'. $showRow[$i]['IF_auditNote'] .'</div>';
				}else{
					$auditCN = '<span style="color:#000;">待审核</span>';
				}
				if ($userSysArr['US_isNewsAuditLook'] == 1 && strlen($newsBtn) == 0){
					$newsBtn = '<a style="margin-right:8px;" href="'. $webPathPart .'news/?'. $showRow[$i]['IF_ID'] .'.html&rnd=user'. $UE_ID .'" target="_blank">预览</a>';
				}
				$retStr .= '
				<tr id="data'. $showRow[$i]['IF_ID'] .'" '. $bgcolor .'>
					<td align="center">'. $number .'</td>
					<td align="left" style="word-break:break-all;padding:5px;">'. $showRow[$i]['IF_theme'] . $auditNote .'</td>
					<td align="center" >'. $showRow[$i]['IF_readNum'] .'</td>
					<td align="center" >'. $showRow[$i]['IF_replyNum'] .'</td>
					<td align="center">'. $auditCN .'</td>
					<td align="center">'. TimeDate::Get('datetime3',$showRow[$i]['IF_time']) .'</td>
					<td align="center">
						'. $newsBtn .
						'<a href="usersCenter.php?mudi=revNews&dataID='. $showRow[$i]['IF_ID'] .'">修改</a>'.
						'<a style="margin-left:8px;" href="javascript:void(0);" onclick="DelNews('. $showRow[$i]['IF_ID'] .','. $showRow[$i]['IF_isGetScore'] .');return false;" class="font2_1">删除</a>
					</td>
				</tr>
				';
				$number ++;
			}
		}
		unset($showRow);

		$retStr .= '
		</tbody>
		</table>

		<table cellpadding="0" cellspacing="0" align="center" class="listNavBox"><tr><td>
		'. Nav::Show('',$pageCount,$pageSize,$recordCount,'img','pageNum','get') .'
		</td></tr></table>
		';

		return $retStr;
	}


	// css display:none
	public static function CssDisplay($event, $str){
		if (strpos($event, '|'. $str .'|') !== false){
			return 'display:none;';
		}else{
			return '';
		}
	}

}
?>