Thread: [Openfirst-cvscommit] news comments.php,NONE,1.1 newcomment.php,NONE,1.1 index.php,1.9,1.10 viewnews
Brought to you by:
xtimg
From: <i-...@us...> - 2003-10-24 07:29:51
|
Update of /cvsroot/openfirst/news In directory sc8-pr-cvs1:/tmp/cvs-serv30173/news Modified Files: index.php viewnews.php Added Files: comments.php newcomment.php Log Message: Added news comment system with Forum integration. Works without the forum as well. --- NEW FILE: comments.php --- <?php /* * openFIRST.news - comments.php * * Copyright (C) 2003, * openFIRST Project * Original Author: Greg Inozemtsev <gr...@si...> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ //what subforum to use for news discussions define("newsforum","news"); include_once("../config/globals.php"); $id=0; if(isset($_GET["ID"])){ $id=$_GET["ID"]; } $admin=false; if (isset($user->membertype)){ $admin=($user->membertype == "administrator"); } if(function_exists("latest_posts")){ //forum integration $q=ofirst_dbquery("SELECT Website FROM ofirst_news_comments WHERE StoryID='$id'"); if(ofirst_dbnum_rows($q)!=0){ $redirect=ofirst_dbfetch_object($q); header("Location: ".$redirect->Website); } else{ $q=ofirst_dbquery("SELECT * FROM ofirst_news WHERE ID='$id'"); $newspost=ofirst_dbfetch_object($q); ofirst_dbquery("INSERT INTO ofirst_forumposts (forum,ReplyTo,Title,Author,Message,DatePosted) values ('".newsforum."','0','".$newspost->title."','".$newspost->poster."','".$newspost->news."','".date("Y-m-d H:i:s")."');"); $query=ofirst_dbquery("SELECT ID FROM ofirst_forumposts WHERE forum='".newsforum."' AND ReplyTo=0 AND Title='".$newspost->title."' AND Author='".$newspost->poster."' AND Message='".$newspost->news."'"); $news=ofirst_dbfetch_object($query); ofirst_dbquery("INSERT INTO ofirst_news_comments (StoryID,Author,Website,Comment,Date) values ('$id','".$newspost->poster."','".$basepath."/forum/thread.php?id=".$news->ID."','Discussion moved to forum','".date("Y-m-d H:i:s")."');"); header("Location: ".$basepath."/forum/thread.php?id=".$news->ID); } } else{ include_once($header); ?> <h2>Comments</h2> <table width=500> <tr><th colspan=2> <?php $q=ofirst_dbquery("SELECT title FROM ofirst_news WHERE ID='$id'"); if(ofirst_dbnum_rows($q)!=0){ $post=ofirst_dbfetch_object($q); echo("Discussion: ".$post->title); echo("</th></tr>"); $q=ofirst_dbquery("SELECT * FROM ofirst_news_comments WHERE StoryID='$id'"); if(ofirst_dbnum_rows($q)!=0){ while($post=ofirst_dbfetch_object($q)){ echo("<tr valign=top><td class=sub width=200>"); if($post->EMail!=""){ echo("<a href=\"=$post->EMail\">$post->Author</a>"); } else{ echo("<b>$post->Author</b>"); } if($post->Website!=""){ echo("<br />Website: <a href=\"$post->Website\">$post->Website</a>"); } echo("<div><i>".$post->Date."</i></div>"); echo("</td><td width=300>".$post->Comment); if($admin){ echo("<br /><div align=right><a href=\"admin/delcomment.php?id=$post->ID\">Delete</a></div></td>"); } echo("</td></tr>"); } } else{ echo("<tr><td colspan=2 align=center>No comments have been posted</td></tr>"); } ?> </table><br /> <form action="newcomment.php" method=POST> <input type="hidden" name=id value="<?php echo($id); ?>" /> <table> <tr><th colspan=2>Post Comment</th></tr> <tr><td class=sub><label for=uname><b>Name</b></label></td> <td><input name=uname id=uname /></td></tr> <tr><td class=sub><label for=email><b>E-Mail</b><br />(optional)</label></td> <td><input name=email id=email /></td></tr> <tr><td class=sub><label for=web><b>Web site</b><br />(optional)</label></td> <td><input name=web id=web /></td></tr> <tr><td class=sub><label for=comment><b>Comment</b></label></td> <td><textarea name=comment id=comment rows=5 cols=25></textarea></td></tr> <tr><td colspan=2 align=center><input type=submit value="Post" /></td></tr> </table> </form><br /> <?php } else{ echo("This news item does not exist</th></tr></table><br />"); } ?> [ <a href="index.php">News Main</a> ] <?php include_once($footer); } ?> --- NEW FILE: newcomment.php --- <?php /* * openFIRST.news - newcomment.php * * Copyright (C) 2003, * openFIRST Project * Original Author: Greg Inozemtsev <gr...@si...> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ include_once("../config/globals.php"); include_once($header); if(isset($_POST["comment"])&&$_POST["comment"]!=""&&isset($_POST["uname"])&&$_POST["uname"]!=""){ $mail=""; if(isset($_POST["email"])&&ereg("^[^@ ]+@[^@ ]+\.[^@ \.]+$",$_POST["email"])){ $mail="mailto:".strip_tags($_POST["email"]); } $web=""; if(isset($_POST["web"])&&$_POST["web"]!=""){ $web=strip_tags($_POST["web"]); if(substr($web,7)!="http://"){ $web="http://".$web; } } ofirst_dbquery("INSERT INTO ofirst_news_comments (StoryID,Author,EMail,Website,Comment,Date) values ('".$_POST["id"]."','".$_POST["uname"]."','".$mail."','".$web."','".strip_tags($_POST["comment"],"<b><i><em><strong>")."','".date("Y-m-d H:i:s")."');"); echo("<h4>Comment Added</h4>"); } else{ echo("<h4>Could not add comment</h4>"); } if(isset($_SERVER["HTTP_REFERER"])){ echo('[ <a href="'.$_SERVER["HTTP_REFERER"].'">Back</a> ] '); } echo('[ <a href="index.php">News Main</a> ]'); include_once($footer); ?> Index: index.php =================================================================== RCS file: /cvsroot/openfirst/news/index.php,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** index.php 13 Oct 2003 17:59:42 -0000 1.9 --- index.php 23 Oct 2003 22:31:12 -0000 1.10 *************** *** 30,34 **** ?> <h2>Top Headlines</h2> ! Here are the top 5 most important news outbreaks.<br><br> <?php $admin=false; --- 30,34 ---- ?> <h2>Top Headlines</h2> ! Here are the most recent news outbreaks.<br><br> <?php $admin=false; Index: viewnews.php =================================================================== RCS file: /cvsroot/openfirst/news/viewnews.php,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** viewnews.php 23 Oct 2003 21:49:00 -0000 1.9 --- viewnews.php 23 Oct 2003 22:31:12 -0000 1.10 *************** *** 52,55 **** --- 52,58 ---- echo("There is not yet any news.<br><br>"); } + if($admin){ + echo("<div align=center>[ <b><a href=\"".$GLOBALS["basepath"]."/news/admin\">Post News</a></b> ]</div>"); + } return(0); } |