POST TIME:2018-03-19 22:20
找了很久的修改問答系統(tǒng)的方法,就是站長在網(wǎng)站后臺就可以修改問題和答案的方法,現(xiàn)在分享給大家,用的到的好評一下。
1.把a(bǔ)sk/include/asktype.inc.php復(fù)制到dede/inc/里面去
2.修改/dede/ask_type第91行
把$sql = "update `dede_asktype` set name='$name', reid='$reid', disorder='$disorder' where id='$id' ";
改成$sql = "update `dede_asktype` set name='$name', reid='$reid', disorder='$disorder',keywords='$keywords',description='$description',title='$title' where id='$id' ";
現(xiàn)在在asktype表里面新增 keywords, description , title三個字段
3.在dede/新建modify_ask.php文件,代碼如下:
<?php
require_once(dirname(__FILE__)."/config.php");
require_once(DEDEINC.'/datalistcp.class.php');
//問題分類
require_once DEDEADMIN.'/inc/asktype.inc.php';
$dlist = new DataListCP();
$sql = "select * from `dede_ask` where id='".intval($askid)."'";
$row = $dsql->GetOne($sql);
if($item == 'mod_ask'){
include(DEDEADMIN."/templets/modify_ask.htm");
}else if($item == 'revert'){
$sql = "select * from `dede_askanswer` where askid='".intval($askid)."'";
$answerArr = $dsql->GetOne($sql);
include(DEDEADMIN."/templets/ask_revert.htm");
}
exit;
?>
4.在dede/ templets/新建modify_ask.htm文件
<!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=gb2312" />
<link href="http://viscms.blog.163.com/blog/img/base.css" rel="stylesheet" type="text/css" />
<title>修改問題</title>
<script language="javascript" src="http://viscms.blog.163.com/blog/js/jquery.js"></script>
<script language="javascript">
function showSub(reid){
$.getJSON("subTypes.php?reid="+reid, function(data){
$('#sctTid2').empty();
$.each(data,function(i,row){
$('#sctTid2').append("<option value='"+row.id+"'>"+ row.name + "</option>");
});
});
}
</script>
</head>
<body>
<div>
<form action="ask_admin.php" method="post" name="form1">
<input type="hidden" value="modify" name="action" />
<input type="hidden" value="<?php echo $row['id'];?>" name="askid" />
<table width="420" height="125" border="0" cellpadding="0" cellspacing="0" style="margin-top:15px;">
<tr height="35">
<td width="103" align="right">提問者ID:</td>
<td width="133"><?php echo $row['id'];?></td>
</tr>
<tr height="35">
<td align="right">所屬欄目:</td>
<td><label>
<select name="ClassLevel1" onchange="showSub($(this).val())">
<?php
foreach($asktypes as $t1){
if($t1['reid'] == '0'){
if($row['tid'] == $t1['id']){
$selected = "selected='selected'";
echo "<option value='".$t1['id']."' ".$selected.">".$t1['name']."</option>";
}else{
echo "<option value='".$t1['id']."'>".$t1['name']."</option>";
}
}
}
?>
</select>
</label>
<label>
<select name="ClassLevel2" id="sctTid2">
<?php
foreach($asktypes as $t2){
if($t2['reid'] == $row['tid']){
if($row['tid2'] == $t2['id']){
$selected = "selected='selected'";
echo "<option value='".$t2['id']."' ".$selected.">".$t2['name']."</option>";
}else{
echo "<option value='".$t2['id']."'>".$t2['name']."</option>";
}
}
}
?>
</select>
</label></td>
</tr>
<tr height="35">
<td align="right">提問標(biāo)題:</td>
<td><input name="title" type="text" size="52" height="25" value="<?php echo $row['title'];?>" /></td>
</tr>
<tr height="35">
<td align="right">補(bǔ)充說明:</td>
<td><textarea name="content" cols="50" rows="6"><?php echo $row['content'];?></textarea></td>
</tr>
<tr height="35">
<td align="right"> </td>
<td><label>
<input type="submit" name="Submit" value="修改" /></label>
<label>
<input name="cancel" type="reset" id="cancel" value="重置" />
</label></td>
</tr>
<tr height="35">
<td align="right"> </td>
<td> </td>
</tr>
</table>
</form>
</div>
</body>
</html>
5.在dede/templets/新建ask_revert文件
<!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=gb2312" />
<link href="http://viscms.blog.163.com/blog/img/base.css" rel="stylesheet" type="text/css" />
<title>回復(fù)問題</title>
</head>
<body>
<div>
<form action="ask_admin.php" method="post" name="form1">
<input type="hidden" name="action" value="revert" />
<input type="hidden" name="askid" value="<?php echo $row['id']; ?>" />
<table width="80%" border="1" cellpadding="10" cellspacing="10">
<tr>
<td width="86" align="right">回復(fù)ID:</td>
<td width="370">
<input type="hidden" name="answerid" value="<?php if($answerArr['id'] != ''){ echo $answerArr['id'];}else{ echo 0;}?>" />
<?php if($answerArr['id'] != ''){ echo $answerArr['id'];}else{ echo 0;}?></td>
</tr>
<tr>
<td align="right">問題:</td>
<td><strong><font color="#CC00FF"><?php echo $row['title'];?></font></strong></td>
</tr>
<tr>
<td align="right">補(bǔ)充說明:</td>
<td><font color="#0066CC"><?php echo nl2br($row['content']);?></font></td>
</tr>
<tr>
<td align="right">關(guān)鍵詞(多個請用,號分隔):</td>
<td>
<input type="text" value="<?php echo $row['keywords'];?>" name='keywords'/>
</td>
</tr>
<tr>
<td align="right">回復(fù)內(nèi)容:</td>
<td>
<?php GetEditor("content",$answerArr['content']); ?>
</td>
</tr>
<tr>
<td align="right"> </td>
<td><label>
<input type="submit" name="Submit" value="提交" />
<input name="cancel" type="reset" id="cancel" value="重填" />
</label></td>
</tr>
</table>
</form>
</div>
</body>
</html>
6.在dede/ask_admin.php第143行加入以下代碼
else if($action == 'modify'){ //修改問題
$ClassLevel1 = intval($ClassLevel1);
$ClassLevel2 = intval($ClassLevel2);
if($ClassLevel2 != 0)
{
$where = "id in ($ClassLevel1,$ClassLevel2)";
}else
{
$where = "id='$ClassLevel1'";
}
$query = "select id, name, reid from `dede_asktype` where $where";
$dsql->Execute('me',$query);
while($row = $dsql->getarray())
{
if($row['id'] == $ClassLevel1)
{
$tidname = $row['name'];
$tid = $row['id'];
}elseif($row['id'] == $ClassLevel2 && $row['reid'] == $ClassLevel1)
{
$tid2name = $row['name'];
$tid2 = $row['id'];
}
}
$sql = "update `dede_ask` set title='{$title}',tid='{$tid}',tidname='{$tidname}',tid2='{$tid2}',tid2name='{$tid2name}',content='{$content}' where id='{$askid}'";
$dsql->ExecuteNoneQuery($sql);
//header('location:ask_admin.php');
ShowMsg("問題修改成功!",'ask_admin.php');
exit;
}else if($action == 'revert'){ //回復(fù)問題
if($answerid){
$sql = "update `dede_askanswer` set content='{$content}' where id='{$answerid}'";
$dsql->ExecuteNoneQuery($sql);
}else{
$dateline = time();
$sql = "insert into `dede_askanswer`(askid,ifanswer,username,content,dateline,ifcheck) values('{$askid}',1,'一六一醫(yī)院專家','{$content}','{$dateline}',1)";
$dsql->ExecuteNoneQuery($sql);
}
$keywords = $_POST['keywords'];
$description = $_POST['description'];
//修改問題狀態(tài)
$sql = "UPDATE `dede_ask` set status='1',replies='1',keywords='{$keywords}',description='$description' where id='{$askid}'";
$dsql->ExecuteNoneQuery($sql);
ShowMsg("問題回復(fù)成功!",'ask_admin.php');
exit;
}
7.在ask表中加入以下字段keywords,description,username
8.修改browser.php第35來始的整個if條件包括elseif
if($tid)
{
$dsql->Execute('me',"select * from `dede_asktype` where id='$tid' ");
if(!$typeinfo = $dsql->getarray())
{
showmsgs('browser_notexists','index.php');
exit;
}
$wheresql .= " tid='$tid' ";
$multistr .="tid=$tid";
$tidstr = "tid=$tid";
if($typeinfo['title'] == ''){
$navtitle = $typeinfo['name'];
}else{
$navtitle = $typeinfo['title'];
}
$nav = " $symbols <a href=&;browser.php?tid=$tid&;>".$typeinfo['name'].'</a>';
$toptypeinfo = $typeinfo;
}
elseif($tid2)
{
$dsql->Execute('me',"select * from `dede_asktype` where id='$tid2' ");
if(!$typeinfo = $dsql->getarray())
{
showmsgs('browser_notexists','index.php');
exit;
}
$wheresql .= "tid2='$tid2'";
$multistr .="tid2=$tid2";
$tidstr = "tid2=$tid2";
$toptypeinfo = $dsql->getone("select id, name, asknum from `dede_asktype` where id='".$typeinfo['reid']."' limit 1");
if($typeinfo['title'] == ''){
$navtitlestr = $typeinfo['name'];
}else{
$navtitlestr = $typeinfo['title'];
}
$navtitle = $navtitlestr.' '.$toptypeinfo['name'];
$nav = ' '.$symbols.' <a href="browser.php?tid='.$toptypeinfo['id'].'">'.$toptypeinfo['name'].'</a> '.$symbols.' <a href="browser.php?tid2='.$tid2.'">'.$typeinfo['name'].'</a>';
}
9.在所有的browser.htm里面加入