webnews.php
<?php
//////////////////////////////////////////////////////////////////////
// PHPWebNews - sebflipper Copyright 2002 //
// http://www.sebflipper.com //
// Main Script File //
// //
// Please DO NOT edit this file unless you know what you are doing //
// //
// By using this script you agree to the Licence //
// //
//////////////////////////////////////////////////////////////////////
// Beginning php
// Loading Config files
require dirname(__FILE__)."/webnews.config.inc.php";
require dirname(__FILE__)."/webnews.smileys.inc.php";
require dirname(__FILE__)."/webnews.badwords.inc.php";
// Turns off error messages
error_reporting (E_ERROR | E_PARSE);
// Connecting to server database
$db = mysql_connect("$server", "$db_user", "$db_pass");
mysql_select_db("$database",$db);
// Checking action
if ($news_action==false) {
$news_action = "viewnews";
}
// If they want to add/view comments
if ($news_action=="viewcomments") {
mysql_select_db("$database",$db);
$resultlink = mysql_query("SELECT * FROM `$mysql_pre$mysql_news` WHERE id='$id' ORDER BY `id` DESC LIMIT 0,1",$db);
if ($myrow = mysql_fetch_array($resultlink)) {
$get_id_for = $myrow["id"]; ?>
<font size=4><b>News</b></font><br><br>
<?php
// Echoing news for the comment
do {
?>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr valign="top">
<td><b><?php echo $myrow[subject]; ?></b> posted by <b><a href="mailto:<?php echo $myrow[email]; ?>"><?php echo $myrow[name]; ?></a></b> (<b><?php $sql_total_user_posts = mysql_query("SELECT * FROM $mysql_pre$mysql_news WHERE name='$myrow[name]'",$db) or die(mysql_error());
$total_user_posts = mysql_num_rows($sql_total_user_posts); echo $total_user_posts; ?></b> posts made)<br>
Posted on <?php $con_date = date("l, d<sup>S</sup> F Y h:i a", $myrow[date]);; echo $con_date; ?></td>
<td valign="top"> <div align="right"></div></td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><br><?php $myrow[news] = parseEmoticons($myrow[news], $dirin); $myrow[news] = parseBadwords($myrow[news]); $myrow[news]=nl2br($myrow[news]); echo $myrow[news]; ?></td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="medtext">
<tr>
<td>
<DIV ALIGN=right>
<?php $sql_total_comments = mysql_query("SELECT * FROM $mysql_pre$mysql_comments WHERE id_for='$get_id_for'",$db) or die(mysql_error());
$total_comments = mysql_num_rows($sql_total_comments); echo $total_comments; ?>
comments made</DIV>
</td>
</tr>
</td>
</tr>
</table>
<hr>
<?php
} while ($myrow = mysql_fetch_array($resultlink));
// Start of comments
mysql_select_db("$database",$db);
$resultlink = mysql_query("SELECT * FROM `$mysql_pre$mysql_comments` WHERE id_for='$id' ORDER BY `id` DESC",$db);
if ($myrow = mysql_fetch_array($resultlink)) {
?>
<font size=4><b>Comments</b></font><br><br>
<?php
// Echoing comments
do {
$comment_count = $myrow[id];
?>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr valign="top">
<td>Comment posted by <b><a href="mailto:<?php $myrow[email] = parseBadwords($myrow[email]); echo $myrow[email]; ?>"><?php $myrow[name] = parseBadwords($myrow[name]); echo $myrow[name]; ?></a></b> (<b><?php $sql_total_user_comments = mysql_query("SELECT * FROM $mysql_pre$mysql_comments WHERE email='$myrow[email]'",$db) or die(mysql_error());
$total_user_comments = mysql_num_rows($sql_total_user_comments); echo $total_user_comments; ?></b> comments made)<br>Posted on <?php $con_date = date("l, d<sup>S</sup> F Y h:i a", $myrow[date]);; echo $con_date; ?></td>
<td valign="top"> <div align="right"></div></td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><br><?php $myrow[comments] = parseEmoticons($myrow[comments], $dirin); $myrow[comments] = parseBadwords($myrow[comments]); $myrow[comments]=nl2br($myrow[comments]); echo $myrow[comments]; ?></td>
</tr>
</table>
<hr>
<?php
} while ($myrow = mysql_fetch_array($resultlink));
} else {
echo "No Comments Found<br>";
}
?>
<br>
<form action="<?php echo $dirin; ?>/addcomment.php" method="post">
<div align="center">
<table border=1 bordercolor=#000000>
<tr>
<td>Name:</td>
<td><input name="name" type="text" id="name"></td>
</tr>
<tr>
<td>Email:</td>
<td><input name="email" type="text" id="email"></td>
</tr>
<tr>
<td>Comments:<br>[
<script>
<!--
function MM_openBrWindow(theURL,winName,features) { //v2.0
window.open(theURL,winName,features);
}
//-->
</script>
<a href="javascript:void(0);" onClick="MM_openBrWindow('<?php echo $dirin; ?>/showsmileys.php','showsmileys','scrollbars=no,width=250,height=150')">Smileys</a> ]</td>
<td><textarea name="comment" cols="15" rows="5" wrap="VIRTUAL" id="comment"></textarea></td>
</tr>
</table>
</div>
<p align="center">
<input name="id_for" id="id_for" type="hidden" value="<?php echo $get_id_for; ?>">
<input name="save_comment" type="submit" id="comment" value="Ok">
</p>
</form>
<?php
// Print version - Please keep the line(s) below - NOTISE: REMOVING THE LINE(S) BELOW BRECHES THE LICENCE AGREEMENT
echo("n<center><font face='Verdana, Verdana, arial, sans-serif, sans-serif' size='1'>[<a href='$dirin/admin'><font face='Verdana, Verdana, arial, sans-serif, sans-serif' size='1'>Admin Centre</font></a>]<br>News powered by <a href='http://www.sebflipper.com' target='_blank'><font face='Verdana, Verdana, arial, sans-serif, sans-serif' size='1'>PHPWebNews</font></a> $webnews_ver</font></center><br>n");} else {
echo "No News Found<br>";
}
}
// End of viewing comments
// If they want to view the news
if ($news_action=="viewnews") {
if ($news_from==false)
{
$news_from = 0;
}
mysql_select_db("$database",$db);
$resultlink = mysql_query("SELECT * FROM `$mysql_pre$mysql_news` ORDER BY `id` DESC LIMIT $news_from, $news_limit",$db);
if ($myrow = mysql_fetch_array($resultlink)) {
?>
<font size=4><b>News</b></font><br><br>
<?php
// For debuging
echo "n<!-Debug: PHPWebNews $webnews_ver | Build Date: $webnews_ver_date | http://www.sebflipper.com-!>n";
// Echoing news
do {
$comment_count = $myrow[id];
?>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr valign="top">
<td><b><?php echo $myrow[subject]; ?></b> posted by <b><a href="mailto:<?php echo $myrow[email]; ?>"><?php echo $myrow[name]; ?></a></b> (<b><?php $sql_total_user_posts = mysql_query("SELECT * FROM $mysql_pre$mysql_news WHERE name='$myrow[name]'",$db) or die(mysql_error());
$total_user_posts = mysql_num_rows($sql_total_user_posts); echo $total_user_posts; ?></b> posts made)<br>
Posted on <?php $con_date = date("l, d<sup>S</sup> F Y h:i a", $myrow[date]);; echo $con_date; ?></td>
<td valign="top"> <div align="right"><a href="<?php echo $PHP_SELF; ?>?news_action=viewcomments&id=<?php echo $myrow[id]; ?>"><?php echo "$add_view_comments"; ?></a></div></td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><br><?php $myrow[news] = parseEmoticons($myrow[news], $dirin); $myrow[news] = parseBadwords($myrow[news]); $myrow[news]=nl2br($myrow[news]); echo $myrow[news]; ?></td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="medtext">
<tr>
<td>
<DIV ALIGN=right>
<?php $sql_total_comments = mysql_query("SELECT * FROM $mysql_pre$mysql_comments WHERE id_for='$comment_count'",$db) or die(mysql_error());
$total_comments = mysql_num_rows($sql_total_comments); echo $total_comments; ?>
comments made</DIV>
</td>
</tr>
</td>
</tr>
</table>
<hr>
<?php
} while ($myrow = mysql_fetch_array($resultlink)); ?>
<br>
<?php
// Setting from stuff
$news_pfrom = $news_from;
$news_nfrom = $news_from;
$news_pfrom=$news_pfrom-$news_limit;
$news_nfrom=$news_nfrom+$news_limit;
echo "<table width=100% border=0><tr><td>";
if ($news_from > 0)
{
echo "<a href='$PHP_SELF?news_from=$news_pfrom'><Previous</a>";
}
echo "</td><td><div align=right><a href='$PHP_SELF?news_from=$news_nfrom'>Next></a></div></td></tr></table><br>";
?>
<DIV ALIGN=RIGHT>Total amount of news made =
<B>
<?php $sql_total_news = mysql_query("SELECT * FROM $mysql_pre$mysql_news",$db) or die(mysql_error());
$total_news = mysql_num_rows($sql_total_news); echo $total_news; ?>
</B>
<BR>Total amount of comments made =
<B>
<?php $sql_total_comments = mysql_query("SELECT * FROM $mysql_pre$mysql_comments",$db) or die(mysql_error());
$total_comments = mysql_num_rows($sql_total_comments); echo $total_comments; ?>
</B>
<BR>Total amount of posts made =
<B>
<?php $total_posts = $total_news+$total_comments;
echo $total_posts; ?>
</B></DIV><br><br>
<?php
// Print version - Please keep the line(s) below - NOTISE: REMOVING THE LINE(S) BELOW BRECHES THE LICENCE AGREEMENT
echo("n<center><font face='Verdana, Verdana, arial, sans-serif, sans-serif' size='1'>[<a href='$dirin/admin'><font face='Verdana, Verdana, arial, sans-serif, sans-serif' size='1'>Admin Centre</font></a>]<br>News powered by <a href='http://www.sebflipper.com' target='_blank'><font face='Verdana, Verdana, arial, sans-serif, sans-serif' size='1'>PHPWebNews</font></a> $webnews_ver</font></center><br>n");
} else {
echo "<a href=javascript:history.back()>Back</a><br><br>No more news found or there has been an error!<br>";
}
}
// End of PHP!
?>