Към съдържанието

Добавяне на новини и коментари към тях

  • House
  • 17 820 прочитания

Урокът е от архива на сайта и е писан преди години. Някои бутони и менюта в програмите вече може да изглеждат различно.

Добавяне на новини и коментари към тях В този мой втори урок ще ви покажа как да направите система за добавяне на новини и коментари към тях. Към коментарите има и smileys.

Като за начало направете 1 обща папка,в моя случай се казва phpwebnews. В нея направете още 2 папки-admin и smileys.В папката smielys се знае какво да сложите(накрая на урока ще ви дам линк към всички файлове).В главната папка слагате файловете ;addcomment.php;showsmileys.php;
webnews.badwords.inc.php;webnews.config.inc.php;webnews.php и webnews.smileys.inc.php


addcomment.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 file 
require dirname(__FILE__)."/webnews.config.inc.php"; 
// include ("webnews.config.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); 


// If they have sent the comments form 
if ($save_comment==true) { 
// Stripping any bad stuff 
$name = htmlspecialchars($name); 
$email = htmlspecialchars($email); 
$comment = htmlspecialchars($comment); 

$name=trim($name); 
$email=trim($email); 
$comment=trim($comment); 

// Making sure the form is not blank 
if ($name==FALSE || $email==FALSE || $comment==FALSE || $id_for==FALSE) 
{ 
echo "<html><meta http-equiv='refresh' content='0;URL=javascript:history.back()'><body><script>alert('Please fill out the required fields')</script></body></html>"; 
exit; 
} 

// Making sure that details are the correct size 
if(strlen($name)<2 || strlen($name) >25) 
{ 
echo "<html><meta http-equiv='refresh' content='0;URL=javascript:history.back()'><body><script>alert('Please correct your name')</script></body></html>"; 
exit; 
} 

if(strlen($email)<2 || strlen($email) >80) 
{ 
echo "<html><meta http-equiv='refresh' content='0;URL=javascript:history.back()'><body><script>alert('Please correct your email address')</script></body></html>"; 
exit; 
} 

if(strlen($comment)<2 || strlen($comment) >1000) 
{ 
echo "<html><meta http-equiv='refresh' content='0;URL=javascript:history.back()'><body><script>alert('Please correct your comment (1000 char max)')</script></body></html>"; 
exit; 
} 

// Checking if they have a cookie to stop spaming! 
if ($phpwebnews[spam]==true) 
{ 
echo "<html><meta http-equiv='refresh' content='0;URL=javascript:history.back()'><body><script>alert('You can only send 1 comment every $spam_time_english')</script></body></html>"; 
exit; 
} 

// Error checking ok 
// Setting cookie to stop users spaming 
setcookie("phpwebnews[spam]",spam,time()+$spam_time_out); 

// Get date and time 
$timeadjust = ($hourdiff * 60 * 60); // Changing the $hourdiff into sec's for UNIX time stamp 
$melbdate = (mktime() + $timeadjust);; 

// Save to database 
mysql_select_db("$database",$db); 
$sql = "INSERT $mysql_pre$mysql_comments SET id_for='$id_for',name='$name',date='$melbdate',email='$email',comments='$comment'"; 


$result = mysql_query($sql) or die(mysql_error()); ; 


// Echoing sent 
echo "<html><meta http-equiv='refresh' content='0;URL=$mainurl'><body><script>alert('Thank you, your comment has been saved')</script></body></html>"; 
exit; 
} 
?>

showsmileys.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 file 
require dirname(__FILE__)."/webnews.config.inc.php"; 
?> 
<html> 
<head> 
<title>Smileys!</title> 
<script language="JavaScript"> 
<!-- 
function MM_findObj(n, d) { //v4.0 
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { 
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} 
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n]; 
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); 
if(!x && document.getElementById) x=document.getElementById(n); return x; 
} 

function MM_setTextOfTextfield(objName,x,newText) { //v3.0 
var obj = MM_findObj(objName); if (obj) obj.value = newText; 
} 

function x() { return; } 

function insertEmoticon(addSmilie) { 
var addSmilie; var revisedMessage; 
var currentMessage = window.opener.document.sbx.shout.value; 
revisedMessage = currentMessage+addSmilie; 
window.opener.document.sbx.shout.value=revisedMessage; 
window.opener.document.sbx.shout.focus(); 
} 
//--> 
</script> 
</head> 
<body> 
<table width="100%" border="0" cellspacing="0" cellpadding="2"> 
<tr align="center" valign="bottom"> 
<td width="12%"><a href="javascript:x();" onClick="insertEmoticon(':)');" onMouseOver="MM_setTextOfTextfield('tip','',':)')"><img src='smileys/smile.gif' alt=':)' border="0"></a></td> 
<td width="12%"><a href="javascript:x();" onClick="insertEmoticon(':(');" onMouseOver="MM_setTextOfTextfield('tip','',':(')"><img src='smileys/sad.gif' alt=':(' border="0"></a></td> 
<td width="12%"><a href="javascript:x();" onClick="insertEmoticon(';)');" onMouseOver="MM_setTextOfTextfield('tip','',';)')"><img src='smileys/smilewinkgrin.gif' alt=';)' border="0"></a></td> 
<td width="12%"><a href="javascript:x();" onClick="insertEmoticon('B)');" onMouseOver="MM_setTextOfTextfield('tip','','B)')"><img src='smileys/cool.gif' alt='B)' border="0"></a></td> 
<td width="12%"><a href="javascript:x();" onClick="insertEmoticon(':D');" onMouseOver="MM_setTextOfTextfield('tip','',':D')"><img src='smileys/biggrin.gif' alt=':D' border="0"></a></td> 
<td width="12%"><a href="javascript:x();" onClick="insertEmoticon(':P');" onMouseOver="MM_setTextOfTextfield('tip','',':P')"><img src='smileys/bigrazz.gif' alt=':P' border="0"></a></td> 
<td width="12%"><a href="javascript:x();" onClick="insertEmoticon(':cry:');" onMouseOver="MM_setTextOfTextfield('tip','',':cry:')"><img src='smileys/cry.gif' alt=':cry:' border="0"></a></td> 
<td width="12%"><a href="javascript:x();" onClick="insertEmoticon(':dead:');" onMouseOver="MM_setTextOfTextfield('tip','',':dead:')"><img src='smileys/dead.gif' alt=':dead:' border="0"></a></td> 
</tr> 
<tr align="center" valign="bottom"> 
<td width="12%"><a href="javascript:x();" onClick="insertEmoticon(':laugh:');" onMouseOver="MM_setTextOfTextfield('tip','',':laugh:')"><img src='smileys/laugh.gif' alt=':laugh:' border="0"></a></td> 
<td width="12%"><a href="javascript:x();" onClick="insertEmoticon(':eek:');" onMouseOver="MM_setTextOfTextfield('tip','',':eek:')"><img src='smileys/bigeek.gif' alt=':eek:' border="0"></a></td> 
<td width="12%"><a href="javascript:x();" onClick="insertEmoticon(':rolleyes:');" onMouseOver="MM_setTextOfTextfield('tip','',':rolleyes:')"><img src='smileys/rolleyes.gif' alt=':rolleyes:' border="0"></a></td> 
<td width="12%"><a href="javascript:x();" onClick="insertEmoticon(':mad:');" onMouseOver="MM_setTextOfTextfield('tip','',':mad:')"><img src='smileys/mad.gif' alt=':mad:' border="0"></a></td> 
<td width="12%"><a href="javascript:x();" onClick="insertEmoticon(':confused:');" onMouseOver="MM_setTextOfTextfield('tip','',':confused:')"><img src='smileys/confusedw.gif' alt=':confused:' border="0"></a></td> 
<td width="12%"><a href="javascript:x();" onClick="insertEmoticon(':sigh:');" onMouseOver="MM_setTextOfTextfield('tip','',':sigh:')"><img src='smileys/sighw.gif' alt=':sigh:' border="0"></a></td> 
<td width="12%"><a href="javascript:x();" onClick="insertEmoticon(':yes:');" onMouseOver="MM_setTextOfTextfield('tip','',':yes:')"><img src='smileys/yes.gif' alt=':yes:' border="0"></a></td> 
<td width="12%"><a href="javascript:x();" onClick="insertEmoticon(':no:');" onMouseOver="MM_setTextOfTextfield('tip','',':no:')"><img src='smileys/no.gif' alt=':no:' border="0"></a></td> 
</tr> 
<tr align="center" valign="bottom"> 
<td width="12%"><a href="javascript:x();" onClick="insertEmoticon(':sleep:');" onMouseOver="MM_setTextOfTextfield('tip','',':sleep:')"><img src='smileys/sleepw.gif' alt=':sleep:' border="0"></a></td> 
<td width="12%"><a href="javascript:x();" onClick="insertEmoticon(':upset:');" onMouseOver="MM_setTextOfTextfield('tip','',':upset:')"><img src='smileys/upsetw.gif' alt=':upset:' border="0"></a></td> 
<td width="12%"><a href="javascript:x();" onClick="insertEmoticon(':shy:');" onMouseOver="MM_setTextOfTextfield('tip','',':shy:')"><img src='smileys/shy.gif' alt=':shy:' border="0"></a></td> 
<td width="12%"><a href="javascript:x();" onClick="insertEmoticon(':|');" onMouseOver="MM_setTextOfTextfield('tip','',':|')"><img src='smileys/none.gif' alt=':|' border="0"></a></td> 
<td colspan="4" align="center"> 
<input type="text" name="tip" size="15" class="editbox" READONLY value="choose a pic"> 
</td> 
</tr> 
</table> 
<?php 
// Print version - Please keep the line(s) below - NOTISE: REMOVING THE LINE(S) BELOW BRECHES THE LICENCE AGREEMENT 
echo("n<br><center><font face='Verdana, Verdana, arial, sans-serif, sans-serif' size='1'>News powered by <a href='http://www.sebflipper.com' target='_blank'>PHPWebNews</a> $webnews_ver</font></center><br>n"); 
?> 
</body> 
</html>

webnews.badwords.inc.php

Код
<?php 
////////////////////////////////////////////////////////////////////// 
// PHPWebNews - sebflipper Copyright 2002 // 
// http://www.sebflipper.com // 
// Config File // 
// // 
// Please edit this file with your information the best way to do // 
// this is to read my comments on each section // 
// // 
// By using this script you agree to the Licence // 
// // 
////////////////////////////////////////////////////////////////////// 


// Changing text like fuck into **** 
// You can add and delete as you like ;) 
// 
// Adding more words to the censor: 
// 
// $badword[] = array('badword', 'goodword'); 
// 
// duplicate these lines as needed, changing the good 
// and bad words as necessary. 
// 
// Putting a space either side of both badword and goodword will only change 
// a whole word... ie 'ass' will be changed and not 'assessment' 
// 
// NB: Unlike webnews.smileys.inc.php, this file is not case sensitive: 
// Case == CASE == case == cAsE 
// But for ease of reading, use lower case. 
// 
// If you get a REG_EPAREN error, try replacing symbols such as ( and ) with 
// ( and ) ... 

function parseBadwords ($text) { 

$badword = array(); 
$badword[] = array('arse', '****'); 
$badword[] = array('arsehole', '********'); 
$badword[] = array('asshole', '*******'); 
$badword[] = array('bitch', '*****'); 
$badword[] = array('cock', '****'); 
$badword[] = array('cocksucker', '**********'); 
$badword[] = array('cunt', '****'); 
$badword[] = array('dickhead', '********'); 
$badword[] = array('fuck', '****'); 
$badword[] = array('fuckwit', '*******'); 
$badword[] = array('fuk', '***'); 
$badword[] = array('fuking', '******'); 
$badword[] = array('motherfucker', '************'); 
$badword[] = array('nigger', '******'); 
$badword[] = array('pussy', '*****'); 
$badword[] = array('shit', '****'); 
$badword[] = array('wanker', '******'); 
$badword[] = array('wankers', '*******'); 
$badword[] = array('whore', '*****'); 
$badword[] = array('slag', '****'); 
$badword[] = array('bitch', '*****'); 

foreach ($badword as $badwords) { 
$text = eregi_replace(($badwords[0]),($badwords[1]),($text)); 
} 
return trim($text); 
} 
?>

webnews.config.inc.php

Код
<?php 
////////////////////////////////////////////////////////////////////// 
// PHPWebNews - sebflipper Copyright 2002 // 
// http://www.sebflipper.com // 
// Config File // 
// // 
// Please edit this file with your information the best way to do // 
// this is to read my comments on each section // 
// // 
// By using this script you agree to the Licence // 
// // 
////////////////////////////////////////////////////////////////////// 


////////////////////////////////////// 
// MySQL info 
$server = "localhost"; 
$db_user = ""; 
$db_pass = ""; 
$database = "phpwebnews"; 
////////////////////////////////////// 
// 
////////////////////////////////////// 
// Prefects in Database 
$mysql_pre = "wn_"; 
$mysql_news = "news"; 
$mysql_comments = "comments"; 
$mysql_admin = "admin"; 
////////////////////////////////////// 
// 
////////////////////////////////////// 
// The full url of the page that has the script on it e.g. http://www.site.com/index.php 
$mainurl = "http://localhost/website.php"; 
// Dir thats the scripts in 
$dirin = "phpwebnews"; 
// Please use text or HTML for the link Add/View Comments on the main news script 
$add_view_comments = "Add/View Comments"; 
// How many news posts to show per page 
$news_limit = "10"; 
// Spam stopper, set this to a cookie time to stop people spaming, the setting is the time is in seconds 
// eg 3600 is one hour | 1800 is 30 mins | 900 is 15 mins etc 
$spam_time_out = "900"; 
// Spam stopper english time eg 15 mins 
$spam_time_english = "15 mins"; 
// Hours in difference between server time and local time 
$hourdiff = "0"; 
////////////////////////////////////// 
// 
////////////////////////////////////// 
// DO NOT EDIT Program Version 
$webnews_ver = "v1.1"; 
$webnews_ver_date = "17/10/2002"; 
////////////////////////////////////// 
// 


?>

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! 
?>


webnews.smileys.inc.php

Код
<?php 
////////////////////////////////////////////////////////////////////// 
// PHPWebNews - sebflipper Copyright 2002 // 
// http://www.sebflipper.com // 
// Config File // 
// // 
// Please edit this file with your information the best way to do // 
// this is to read my comments on each section // 
// // 
// By using this script you agree to the Licence // 
// // 
////////////////////////////////////////////////////////////////////// 


// Changing text like :) into smileys! 
// You can add and delete as you like ;) 
function parseEmoticons ($text, $dirin) { 

$emoticons = array(); 
$emoticons[] = array(":EEK:", "<img src='".$dirin."/smileys/bigeek.gif' alt='' align='absmiddle'>"); 
$emoticons[] = array(":ROLLEYES:", "<img src='".$dirin."/smileys/rolleyes.gif' alt='' align='absmiddle'>"); 
$emoticons[] = array(":MAD:", "<img src='".$dirin."/smileys/mad.gif' alt='' align='absmiddle'>"); 
$emoticons[] = array(":CONFUSED:", "<img src='".$dirin."/smileysconfused.gif' alt='' align='absmiddle'>"); 
$emoticons[] = array(":SIGH:", "<img src='".$dirin."/smileys/sigh.gif' alt='' align='absmiddle'>"); 
$emoticons[] = array(":YES:", "<img src='".$dirin."/smileys/yes.gif' alt='' align='absmiddle'>"); 
$emoticons[] = array(":NO:", "<img src='".$dirin."/smileys/no.gif' alt='' align='absmiddle'>"); 
$emoticons[] = array(":SLEEP:", "<img src='".$dirin."/smileys/sleep.gif' alt='' align='absmiddle'>"); 
$emoticons[] = array(":UPSET:", "<img src='".$dirin."/smileys/upset.gif' alt='' align='absmiddle'>"); 
$emoticons[] = array(":SHY:", "<img src='".$dirin."/smileys/shy.gif' alt='' align='absmiddle'>"); 
$emoticons[] = array(":NONE:", "<img src='".$dirin."/smileys/none.gif' alt='' align='absmiddle'>"); 
$emoticons[] = array(":LAUGH:", "<img src='".$dirin."/smileys/laugh.gif' alt='' align='absmiddle'>"); 
$emoticons[] = array(":DEAD:", "<img src='".$dirin."/smileys/dead.gif' alt='' align='absmiddle'>"); 
$emoticons[] = array(":CRY:", "<img src='".$dirin."/smileys/cry.gif' alt='' align='absmiddle'>"); 
$emoticons[] = array(":eek:", "<img src='".$dirin."/smileys/bigeek.gif' alt='' align='absmiddle'>"); 
$emoticons[] = array(":rolleyes:", "<img src='".$dirin."/smileys/rolleyes.gif' alt='' align='absmiddle'>"); 
$emoticons[] = array(":mad:", "<img src='".$dirin."/smileys/mad.gif' alt='' align='absmiddle'>"); 
$emoticons[] = array(":confused:", "<img src='".$dirin."/smileys/confused.gif' alt='' align='absmiddle'>"); 
$emoticons[] = array(":sigh:", "<img src='".$dirin."/smileys/sigh.gif' alt='' align='absmiddle'>"); 
$emoticons[] = array(":yes:", "<img src='".$dirin."/smileys/yes.gif' alt='' align='absmiddle'>"); 
$emoticons[] = array(":no:", "<img src='".$dirin."/smileys/no.gif' alt='' align='absmiddle'>"); 
$emoticons[] = array(":sleep:", "<img src='".$dirin."/smileys/sleep.gif' alt='' align='absmiddle'>"); 
$emoticons[] = array(":upset:", "<img src='".$dirin."/smileys/upset.gif' alt='' align='absmiddle'>"); 
$emoticons[] = array(":shy:", "<img src='".$dirin."/smileys/shy.gif' alt='' align='absmiddle'>"); 
$emoticons[] = array(":laugh:", "<img src='".$dirin."/smileys/laugh.gif' alt='' align='absmiddle'>"); 
$emoticons[] = array(":dead:", "<img src='".$dirin."/smileys/dead.gif' alt='' align='absmiddle'>"); 
$emoticons[] = array(":cry:", "<img src='".$dirin."/smileys/cry.gif' alt='' align='absmiddle'>"); 
$emoticons[] = array(":)", "<img src='".$dirin."/smileys/smile.gif' alt='' align='absmiddle'>"); 
$emoticons[] = array(":(", "<img src='".$dirin."/smileys/sad.gif' alt='' align='absmiddle'>"); 
$emoticons[] = array(";)", "<img src='".$dirin."/smileys/smilewinkgrin.gif' alt='' align='absmiddle'>"); 
$emoticons[] = array(":|", "<img src='".$dirin."/smileys/none.gif' alt='' align='absmiddle'>"); 
$emoticons[] = array(":-)", "<img src='".$dirin."/smileys/smile.gif' alt='' align='absmiddle'>"); 
$emoticons[] = array(":-(", "<img src='".$dirin."/smileys/sad.gif' alt='' align='absmiddle'>"); 
$emoticons[] = array(";-)", "<img src='".$dirin."/smileys/smilewinkgrin.gif' alt='' align='absmiddle'>"); 
$emoticons[] = array(":-|", "<img src='".$dirin."/smileys/none.gif' alt='' align='absmiddle'>"); 
$emoticons[] = array(":0", "<img src='".$dirin."/smileys/bigeek.gif' alt='' align='absmiddle'>"); 
$emoticons[] = array("B)", "<img src='".$dirin."/smileys/cool.gif' alt='' align='absmiddle'>"); 
$emoticons[] = array(":D", "<img src='".$dirin."/smileys/biggrin.gif' alt='' align='absmiddle'>"); 
$emoticons[] = array(":P", "<img src='".$dirin."/smileys/bigrazz.gif' alt='' align='absmiddle'>"); 
$emoticons[] = array(":B", "<img src='".$dirin."/smileys/bigrazz.gif' alt='' align='absmiddle'>"); 
$emoticons[] = array("B-)", "<img src='".$dirin."/smileys/cool.gif' alt='' align='absmiddle'>"); 
$emoticons[] = array(":-D", "<img src='".$dirin."/smileys/biggrin.gif' alt='' align='absmiddle'>"); 
$emoticons[] = array(":-P", "<img src='".$dirin."/smileys/bigrazz.gif' alt='' align='absmiddle'>"); 
$emoticons[] = array(":O", "<img src='".$dirin."/smileys/bigeek.gif' alt='' align='absmiddle'>"); 
$emoticons[] = array("b)", "<img src='".$dirin."/smileys/cool.gif' alt='' align='absmiddle'>"); 
$emoticons[] = array(":d", "<img src='".$dirin."/smileys/biggrin.gif' alt='' align='absmiddle'>"); 
$emoticons[] = array(":p", "<img src='".$dirin."/smileys/bigrazz.gif' alt='' align='absmiddle'>"); 
$emoticons[] = array(":b", "<img src='".$dirin."/smileys/bigrazz.gif' alt='' align='absmiddle'>"); 
$emoticons[] = array("b-)", "<img src='".$dirin."/smileys/cool.gif' alt='' align='absmiddle'>"); 
$emoticons[] = array(":-d", "<img src='".$dirin."/smileys/biggrin.gif' alt='' align='absmiddle'>"); 
$emoticons[] = array(":-p", "<img src='".$dirin."/smileys/bigrazz.gif' alt='' align='absmiddle'>"); 
$emoticons[] = array(":-b", "<img src='".$dirin."/smileys/bigrazz.gif' alt='' align='absmiddle'>"); 
$emoticons[] = array(":o", "<img src='".$dirin."/smileys/bigeek.gif' alt='' align='absmiddle'>"); 
$emoticons[] = array("o_O", "<img src='".$dirin."/smileys/bigeek.gif' alt='' align='absmiddle'>"); 
$emoticons[] = array("O_o", "<img src='".$dirin."/smileys/bigeek.gif' alt='' align='absmiddle'>"); 
$emoticons[] = array("o_o", "<img src='".$dirin."/smileys/bigeek.gif' alt='' align='absmiddle'>"); 
$emoticons[] = array("O_O", "<img src='".$dirin."/smileys/bigeek.gif' alt='' align='absmiddle'>"); 

foreach ($emoticons as $emoticon) { 
$text = str_replace($emoticon[0],$emoticon[1],$text); 
} 
return $text; 
} 
?>

Готово. Смятам, че не бъркам някъде.

Ето от къде може да си изтеглите нужните файлове: phpwebnews
Споделете: