dede关于留言板插件添加

来源:互联网 发布:xbox360无线手柄 mac 编辑:程序博客网 时间:2024/06/04 19:09

一开始学织梦 就遇到留言板更新 后来用 织梦EIMS 的留言板发现得不到正确的路径 和返回值 就改了一下  

具体问题需要:

1.修改 留言板模板文件 路径为  织梦EIMS 根目录/templets/plus/guestbook.htm


首先 需要引入一个JS 文件 并且加载一个JS 判断用户登录

<script language="javascript" type="text/javascript" src="/include/dedeajax2.js"></script><script type="text/javascript">function CheckLogin(){  var taget_obj = document.getElementById('_userlogin');  myajax = new DedeAjax(taget_obj,false,false,'','','');  myajax.SendGet2("/member/ajax_loginsta.php");  DedeXHTTP = null;}</script>
然后将留言板 主要修改如下

<div class="content">      <div class="contact_message">                <a name="guestbok"></a>          <div class="east">      <dl class="e2e2e2 mT10">        <dt class="heading"><strong class="mL5"><?php echo GetLang('guestbook'); ?></strong></dt>        <dd class="body pB5">       {dede:datalist}          <table width='100%' border='0' align="center" cellpadding='3' cellspacing='1' bgcolor="#CCCCCC" style="border:1px solid #dcdcdc; background-color:#eeeeee;">            <tr>              <td height="20" style="padding:5px 15px;" ><?php echo GetLang('pubdate'); ?> <?php echo MyDate('Y-m-d H:i:s',$fields['dtime']); ?></td>            </tr>            <tr>              <td height="160" style="padding:5px 10px;" ><div class="pubBody" style="white-space:normal; word-break:break-all; overflow:auto; width:495px" ><?php echo $fields['msg']; ?></div></td>            </tr>            <tr>            <?php if($g_isadmin){?>              <td height="20"  style="padding:5px 15px;">                              <a href='guestbook.php?action=admin&id=<?php echo $fields['id']; ?>'>                [<?php echo GetLang('reply')?>/<?php echo GetLang('edit')?>]</a>                <a href='guestbook.php?action=admin&id=<?php echo $fields['id']; ?>&job=del'>                [<?php echo GetLang('del')?>]</a>                <?php                   if($fields['ischeck'] == 0){                    echo '<a class="submit" href="guestbook.php?action=admin&job=check&id='.$fields['id'].'" style="color:red;">[审核]</a>';                  }                                ?>                </td>              <?php }?>            </tr>          </table>          <br />    {/dede:datalist}          <table border='0' cellpadding='0' cellspacing='4' width='100%' align='center'>            <tr>              <td align="center"> {dede:pagelist listsize='5'/} </td>            </tr>            <tr>              <td></td>            </tr>          </table>          <table width="100%" border="0" cellspacing="1" cellpadding="4" align="center" bgcolor="#CCCCCC">            <form method="post" action="guestbook.php" name="form1">              <input type='hidden' name='action' value='save' />              <tr bgcolor="#ffffff">                <td width="20%" height="30" align="center" nowrap><?php echo GetLang('title')?>:</td>                <td width="80%"><input type="text" maxlength="10" name="title" size="60" class="text" id="title"/></td>              </tr>              <tr bgcolor="#ffffff">                <td align="center" nowrap><font color="#FF0000">*</font><?php echo GetLang('youname')?>:</td>                <td><input type="text" maxlength="10" name="uname" size="60" class="text"/></td>              </tr>              <tr bgcolor="#ffffff">                <td height="30" align="center" nowrap>联系方式:</td>                <td><input maxlength="20" type="text" name="qq" size="40" class="text" /></td>              </tr>              <tr bgcolor="#ffffff">                <td height="12" align="center"><font color="#FF0000">*</font><?php echo GetLang('validatecode')?>:</td>                <td height="12"><table width="400" border="0" cellspacing="0" cellpadding="0">                    <tr>                      <td width="84"><input name="validate" type="text" id="vdcode2" class="text" style="width:80px" /></td>                      <td width="116"><img src='../include/vdimgck.php' width='50' height='20' /></td>                    </tr>                </table></td>              </tr>              <tr bgcolor="#ffffff">                <td align="center" ><font color="#FF0000">*</font><?php echo GetLang('fbcontent')?>:<br />                  (1000字内) </td>                <td align="left" width="80%"><textarea name="msg" cols="60" rows="8" class="text"></textarea></td>              </tr>              <tr bgcolor="#ffffff">                <td height="30" colspan="4" align="center" nowrap><input maxlength="1000" type="submit" name="Submit" value="提 交" class="btn-2" />                                      <input type="reset" name="Submit2" value="取 消" class="btn-2" /></td>              </tr>            </form>          </table>        </dd>      </dl>      <div class="blank10"></div>    </div>      </div>

以上是留言薄的前端模板修改 ,完成后依然无法正常使用 需要找到根目录/plus/guestbook.php文件 将内容修改为

<?phprequire_once(dirname(__FILE__).'/guestbook/guestbook.inc.php');require_once(DEDEINC.'/userlang.inc.php');require_once(DEDEINC.'/datalistcp.class.php');require_once(DEDEINC."/userlogin.class.php");$cuserLogin = new userLogin();if($cuserLogin->userType >= 10){$g_isadmin = true;}if(empty($action)) $action = '';//修改留言if($action=='admin'&&$g_isadmin){include_once(dirname(__FILE__).'/guestbook/edit.inc.php');exit();}else if($action=='admin' && $_GET['job']=='del' && $g_isadmin){$query = "DELETE FROM dede_guestbook WHERE id=".$_GET['id'];$dsql->ExecuteNoneQuery($query);if($g_isadmin) $sql = 'select * from `#@__guestbook` order by id desc';else $sql = 'select * from `#@__guestbook` where ischeck=1 order by id desc';$dlist = new DataListCP();$dlist->pageSize = 10;$dlist->SetParameter('lang',$userLang);$dlist->SetParameter('gotopagerank',$gotopagerank);$dlist->SetTemplate(DEDETEMPDIR.'/plus/guestbook.htm');$dlist->SetSource($sql);$dlist->Display();}else if($action=='admin' && $_GET['job']=='check' && $g_isadmin){$query = "UPDATE dede_guestbook SET ischeck=1 WHERE id=".$_GET['id'];$dsql->ExecuteNoneQuery($query);if($g_isadmin) $sql = 'select * from `#@__guestbook` order by id desc';else $sql = 'select * from `#@__guestbook` where ischeck=1 order by id desc';$dlist = new DataListCP();$dlist->pageSize = 10;$dlist->SetParameter('lang',$userLang);$dlist->SetParameter('gotopagerank',$gotopagerank);$dlist->SetTemplate(DEDETEMPDIR.'/plus/guestbook.htm');$dlist->SetSource($sql);$dlist->Display();}//保存留言else if($action=='save'){if(!empty($_COOKIE['GUEST_BOOK_POS'])) $GUEST_BOOK_POS = $_COOKIE['GUEST_BOOK_POS'];else $GUEST_BOOK_POS = 'guestbook.php';if(empty($validate)) $validate=='';else $validate = strtolower($validate);$svali = GetCkVdValue();if($validate=='' || $validate!=$svali){ ShowMsg("验证码不正确!","-1"); exit();}$ip = GetIP();$dtime = time();$uname = trimMsg($uname);$email = trimMsg($email);$homepage = trimMsg($homepage);$homepage = eregi_replace('http://','',$homepage);$qq = trimMsg($qq);$msg = trimMsg(cn_substrR($msg, 1024), 1);$tid = empty($tid) ? 0 : intval($tid);$reid = empty($reid) ? 0 : intval($reid);if($msg=='' || $uname=='') {showMsg('你的姓名和留言内容不能为空!','-1');exit();}$title = HtmlReplace( cn_substrR($title,60), 1 );if($title=='') $title = '无标题';if($reid != 0){$row = $dsql->GetOne("Select msg From `#@__guestbook` where id='$reid' ");$msg = "<div class=\\'rebox\\'>".addslashes($row['msg'])."</div>\n".$msg;}if(empty($tid)) $tid = 0;$query = "INSERT INTO `#@__guestbook`(title,tid,mid,uname,email,homepage,qq,face,msg,ip,dtime,ischeck)                  VALUES ('$title','$tid','{$g_mid}','$uname','$email','$homepage','$qq','$img','$msg','$ip','$dtime','$needCheck'); ";$dsql->ExecuteNoneQuery($query);$gid = $dsql->GetLastID();if($needCheck==1){require_once(DEDEINC."/oxwindow.class.php");$msg = "<b>成功发送你的留言!<br /><br /><a href='guestbook.php' style='font-size:14px;font-weight:bold'><u>点击此返回>></u></a>";  $wintitle = "发表留言成功提示";$wecome_info = "成功发表留言:";$win = new OxWindow();$win->Init("","js/blank.js","post");$win->AddTitle("系统提示:");$win->AddMsgItem("<div style='padding:20px;line-height:300%;font-size:14px'>$msg</div>");$winform = $win->GetWindow("hand");$win->Display();}else {ShowMsg('成功发送一则留言,但需审核后才能显示!','guestbook.php',0,3000);}exit();}//显示所有留言else{setcookie('GUEST_BOOK_POS',GetCurUrl(),time()+3600,'/');if($g_isadmin) $sql = 'select * from `#@__guestbook` order by id desc';else $sql = 'select * from `#@__guestbook` where ischeck=1 order by id desc';$dlist = new DataListCP();$dlist->pageSize = 10;$dlist->SetParameter('lang',$userLang);$dlist->SetParameter('gotopagerank',$gotopagerank);$dlist->SetTemplate(DEDETEMPDIR.'/plus/guestbook.htm');$dlist->SetSource($sql);  $dlist->Display();}?>

保存后就能正常使用了 还有管理员回复 和用户模板并没有修改,感兴趣可以自行修改CSS和DIV

0 0
原创粉丝点击