Система за новини
Ето една добра система за новини. Скрипра който се използва е много елементарен, в което ще се убедите сами.

Изтегли Система за новини

Ето два скрийна от системата за новини:




За да смените паролата на вашия админ панел трябва да отворите файл admin.php и на този ред да
промените вашия потребителско име и вашата парола.
if ($potrebitel!='потребителско име' || $pas!='парола')


Структура:


db.php
index.php
save.php

admin
/admin/index.php
/admin/del.php
/admin/index.html
/admin/smilies/biggrin.gif
/admin/smilies/cool.gif
/admin/smilies/cry.gif
/admin/smilies/dead.gif
/admin/smilies/eek.gif
/admin/smilies/embarrassed.gif
/admin/smilies/laugh.gif
/admin/smilies/love.gif
/admin/smilies/mad.gif
/admin/smilies/no.gif
/admin/smilies/none.gif
/admin/smilies/rolleyes.gif
/admin/smilies/sad.gif
/admin/smilies/smile.gif
/admin/smilies/smilewinkgrin.gif
/admin/smilies/upset.gif
/admin/smilies/wink.gif
/admin/smilies/yes.gif

posts
/posts/1.html и т.н. .....

files
/files/font.css
/files/script.js

smilies
/smilies/biggrin.gif
/smilies/cool.gif
/smilies/cry.gif
/smilies/dead.gif
/smilies/eek.gif
/smilies/embarrassed.gif
/smilies/laugh.gif
/smilies/love.gif
/smilies/mad.gif
/smilies/no.gif
/smilies/none.gif
/smilies/rolleyes.gif
/smilies/sad.gif
/smilies/smile.gif
/smilies/smilewinkgrin.gif
/smilies/upset.gif
/smilies/wink.gif
/smilies/yes.gif


db.php
<?php $broi=1 ; ?>


index.php
<?php
include "db.php";
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<link rel="stylesheet" href="files/font.css" type="text/css">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
<title>Новини</title>
</head>
<body>
<center>
<table width="65%" align="center">
<tr>
<td>
<?php
for ($i=$broi; $i>$broi-11;$i--){
if (is_file("posts/".$i.".html")) {
include "posts/".$i.".html";
echo "<BR />";

}
}
?>
</td>
</tr>
</table>
</center>
</body>
</html>


save.php
<?php
umask(0);
//variables
if ( isset($_POST['ime']) AND isset($_POST['poqsnenie']) AND isset($_POST['kartinka']) AND isset($_POST['text']) ) {
$user = $_POST['ime'];

$http = $_POST['poqsnenie'];
$town = $_POST['kartinka'];
$msg = $_POST['text'];



if (( $user != "" ) AND ( $msg != "" )) {
include "db.php";
$ip = $_SERVER['REMOTE_ADDR'];
$vreme=date("d F Y, H:i");
$vremeto=date("d F Y");
$http=str_replace("<",'<',$http);
$http=str_replace(">",'>',$http);
$town=str_replace("<",'<',$town);
$town=str_replace(">",'>',$town);
$user=str_replace("<",'<',$user);
$user=str_replace(">",'>',$user);
$mail=str_replace("<",'<',$mail);
$mail=str_replace(">",'>',$mail);
$msg=str_replace("<",'<',$msg);
$msg=str_replace(">",'>',$msg);
$msg=preg_replace("/(\[b\])(.+?)(\[\/b\])/i", "<b>\\2</b>", $msg);
$msg=preg_replace("/(\[i\])(.+?)(\[\/i\])/i", "<i>\\2</i>", $msg);
$msg=preg_replace("/(\[u\])(.+?)(\[\/u\])/i", "<u>\\2</u>", $msg);
$msg=preg_replace("/(\[email=(.+?)\])(.+?)(\[\/email\])/i", '<a href="mailto:\\2" target="_blank">\\3</a>',$msg);
$msg=preg_replace("/(\[email\])(.+?)(\[\/email\])/i", '<a href="mailto:\\2">\\2</a>', $msg);
$msg=preg_replace("/(\[url\])(.+?)(\[\/url\])/i", '<a href="\\2" target="_blank">\\2</a>', $msg);
$msg=preg_replace("/(\[url=\])(.+?)(\[\/url\])/i", '<a href="\\2" target="_blank">\\2</a>', $msg);
$msg=preg_replace("/(\[url=(.+?)\])(.+?)(\[\/url\])/i", '<a href="\\2" target="_blank">\\3</a>', $msg);
$msg=str_replace(":biggrin:",'<img src="smilies/biggrin.gif" alt="img">',$msg);
$msg=str_replace(":cool:",'<img src="smilies/cool.gif" alt="img">',$msg);
$msg=str_replace(":cry:",'<img src="smilies/cry.gif" alt="img">',$msg);
$msg=str_replace(":dead:",'<img src="smilies/dead.gif" alt="img">',$msg);
$msg=str_replace(":eek:",'<img src="smilies/eek.gif" alt="img">',$msg);
$msg=str_replace(":embarrassed:",'<img src="smilies/embarrassed.gif" alt="img">',$msg);
$msg=str_replace(":laugh:",'<img src="smilies/laugh.gif" alt="img">',$msg);
$msg=str_replace(":love:",'<img src="smilies/love.gif" alt="img">',$msg);
$msg=str_replace(":mad:",'<img src="smilies/mad.gif" alt="img">',$msg);
$msg=str_replace(":no:",'<img src="smilies/no.gif" alt="img">',$msg);
$msg=str_replace(":none:",'<img src="smilies/none.gif" alt="img">',$msg);
$msg=str_replace(":rolleyes:",'<img src="smilies/rolleyes.gif" alt="img">',$msg);
$msg=str_replace(":sad:",'<img src="smilies/sad.gif" alt="img">',$msg);
$msg=str_replace(":smile:",'<img src="smilies/smile.gif">',$msg);
$msg=str_replace(":smilewinkgrin:",'<img src="smilies/smilewinkgrin.gif" alt="img">',$msg);
$msg=str_replace(":upset:",'<img src="smilies/upset.gif" alt="img">',$msg);
$msg=str_replace(":wink:",'<img src="smilies/wink.gif" alt="img">',$msg);
$msg=str_replace(":yes:",'<img src="smilies/yes.gif" alt="img">',$msg);




$write1 = "<!--Дата:$vreme IP-адрес:$ip -->
<table class=\"border\" cellpadding=\"1\" cellspacing=\"1\" width=\"100%\">
<tr>
<td class=\"a\" align=\"left\">
<table>
<tr>
<td width=\"71%\" class=\"b\">
<b>";
//ime = name
$write2 = "
</b>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table>
<tr>
<td>
<img src=\"";
//ime = http
$write4 = "\" alt=\"img\">
</td>
<td class=\"b\">
<b>";
//ime = town
$write5 = "</b>
<br />
<br />
<i>Публикувано на | $vremeto</i>
</td>
</tr>
</table>";
//ime = comment
$write6 ="
</td>
</tr>
<tr>
<td class=\"a\" height=\"6\" width=\"100%\">
</td>
</tr>
</table>";


$ip = $_SERVER['REMOTE_ADDR'];
umask(0);

$fp = fopen("posts/".$broi.".html", "w");

fwrite($fp, "$write1");
fwrite($fp, "$user");
fwrite($fp, "$write2");
fwrite($fp, "$town");

fwrite($fp, "$write4");
fwrite($fp, "$http");
fwrite($fp, "$write5");
fwrite($fp, "$msg");
fwrite($fp, "$write6");
fclose($fp);

umask(0);
$broi++;
$fp2 = fopen("db.php", "w");
$writedb = '<?php $broi='.$broi." ; ?>";
fwrite($fp2, "$writedb");
fclose($fp2);
$message = "Благодарим Ви за мнението!";
} else {
$message = "Не сте въвели информация!";
}
} else {
$message = "Грешен линк!";
}
?>


</font>
<html>
<head>
<title></title>
<META HTTP-EQUIV="Refresh" CONTENT="0; URL=index.php">
</head>
<body>

</body>
</html>


font.css
Body {
font-family: verdana, tahoma, arial, helvetica;
font-weight: normal;
font-size: 11px;
background-color: #E8EFF7;
scrollbar-face-color: #E8F0F7;
scrollbar-highlight-color: #E8F0F7;
scrollbar-shadow-color: #99BCD7;
scrollbar-3dlight-color: #DCE8F1;
scrollbar-arrow-color: #99BCD7;
scrollbar-track-color: #E0EBF3;
scrollbar-darkshadow-color:#;
}
Table.border {
width: 100%;
color: #00395B;
background: #F5F9FD;
border-style: solid;
border: solid 1px;
border-color: #6699CC;
}
Table.fon {
width: 100%;
background: #E0EBF3;
border: 1px solid #99BCD7;
}
Table.b {
width: 100%;
background: #C6D9EC;
border: 1px solid #99BCD7;
font: normal 11px Verdana, Arial, Helvetica, sans-serif;
}
Table.c {
width: 100%;
border: 1px solid #D1E1ED;
font: normal 11px Verdana, Arial, Helvetica, sans-serif;
}
Table.d {
border: 1px solid #6699CC;
color: #00395B;
background: #F5F9FD;
font: normal 11px Verdana, Arial, Helvetica, sans-serif;
}
Table.e {
color: #00395B;
font: normal 11px Verdana, Arial, Helvetica, sans-serif;
}
Td {
font-family: verdana, tahoma, helvetica;
font-size: 11px;
}

Td.a {
background: #C6D9EC;
}

Td.b {
font-family: verdana, tahoma, helvetica;
font-size: 11px;
color: #005080;
}

Td.c {
background: #000000;
font: normal 11px Verdana, Arial, Helvetica, sans-serif;
}

A:link {
background: none;
color: #6699CC;
text-decoration: none;
}
A:active {
background: none;
color: #6699CC;
text-decoration: none;
}
A:visited {
background: none;
color: #6699CC;
text-decoration: none;
}
A:hover {
background: none;
color: #005080;
text-decoration: underline;
}
Textarea {
border-color: #B3CDE1;
color: #2B4157;
font: normal 11px Verdana, Arial, Helvetica, sans-serif;
border-width: 1px 1px 1px 1px;
border: 1px solid #94BAD6;
background-color: #EDF3F8;
}
Input {
border-color: #D1E1ED;
color: #2B4157;
font: normal 11px Verdana, Arial, Helvetica, sans-serif;
border-width: 1px 1px 1px 1px;
border: 1px solid #94BAD6;
background-color: #EDF3F8;
}
Input.button {
border-color: #94BAD6;
background: #D1E1ED;
font: 10px Verdana, Arial, Helvetica, sans-serif;
border-width: 1px 1px 1px 1px;
}


script.js
function textCounter(field, countfield, maxlimit) {
if (field.value.length > maxlimit) // if too long...trim it!
field.value = field.value.substring(0, maxlimit);

else
countfield.value = maxlimit - field.value.length;
}
function b()
{
document.form1.text.value += ("")
}
function i()
{
document.form1.text.value += ("[i][/i]")
}
function u()
{
document.form1.text.value += ("[u][/u]")
}function url()
{
document.form1.text.value += ("[url][/url]")
}function email()
{
document.form1.text.value += ("[email][/email]")
}
function emoticon(text) {
var txtarea = document.form1.text;
text = ' ' + text;
if (txtarea.createTextRange && txtarea.caretPos) {
var caretPos = txtarea.caretPos;
caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? caretPos.text + text + ' ' : caretPos.text + text;
txtarea.focus();
} else {
txtarea.value += text;
txtarea.focus();
}
}


admin.php
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
<title>Администраторски панел</title>
<link rel="stylesheet" href="../files/font.css" type="text/css">
<script LANGUAGE="JavaScript" src="../files/script.js" type="text/JavaScript"></script>
</head>
<body>
<?php
include "../db.php";
session_start();
$potrebitel= $HTTP_POST_VARS['potrebitel'];
$pas= $HTTP_POST_VARS['pas'];
if ($potrebitel!='admin' || $pas!='admin')
{echo "

";
exit;}
else
{
$HTTP_SESSION_VARS['potrebitel']= $potrebitel;

}
?>
<table align="center" class="d" cellspacing="0" cellpadding="10">
<tr>
<td>
<br />
<form action="../save.php" method="post" name="form1">
<table border="0" cellspacing="2" cellpadding="0" class="e">
<tr>
<td align="right">
<b>Име на новината:</b>
</td>
<td>
<input name="ime" size="68">
</td>
</tr>
<tr>
<td align="right">
<b>Картинка:</b>
</td>
<td>
<input name="kartinka" size="68">
</td>
</tr>
<tr>
<td align="right">
<b>Пояснение:</b>
</td>
<td>
<textarea name="poqsnenie" cols="65" rows="5"></textarea>
</td>
</tr>
<tr>
<td width="100"><br>
<table align="center" class="e">
<tr>
<td colspan="4">
<b>Emoticons</b>
</td>
</tr>
<tr>
<td>
<a href="javascript:emoticon(':biggrin:');"><img src="smilies/biggrin.gif" border="0" alt="img" ></a>
</td>
<td>
<a href="javascript:emoticon(':cool:');"><img src="smilies/cool.gif" border="0" alt="img"></a>
</td>
<td>
<a href="javascript:emoticon(':cry:');"><img src="smilies/cry.gif" border="0" alt="img"></a>
</td>
<td>
<a href="javascript:emoticon(':dead:');"><img src="smilies/dead.gif" border="0" alt="img"></a>
</td>
</tr>
<tr>
<td>
<a href="javascript:emoticon(':eek:');"><img src="smilies/eek.gif" border="0" alt="img"></a>
</td>
<td>
<a href="javascript:emoticon(':embarrassed:');"><img src="smilies/embarrassed.gif" border="0" alt="img"></a>
</td>
<td>
<a href="javascript:emoticon(':laugh:');"><img src="smilies/laugh.gif" border="0" alt="img"></a>
</td>
<td>
<a href="javascript:emoticon(':love:');"><img src="smilies/love.gif" border="0" alt="img"></a>
</td>
</tr>
<tr>
<td>
<a href="javascript:emoticon(':mad:');"><img src="smilies/mad.gif" border="0" alt="img"></a>
</td>
<td>
<a href="javascript:emoticon(':no:');"><img src="smilies/no.gif" border="0" alt="img"></a>
</td>
<td>
<a href="javascript:emoticon(':none:');"><img src="smilies/none.gif" border="0" alt="img"></a>
</td>
<td>
<a href="javascript:emoticon(':rolleyes:');"><img src="smilies/rolleyes.gif" border="0" alt="img"></a>
</td>
</tr>
<tr>
<td>
<a href="javascript:emoticon(':sad:');"><img src="smilies/sad.gif" border="0" alt="img"></a>
</td>
<td>
<a href="javascript:emoticon(':smile:');"><img src="smilies/smile.gif" border="0" alt="img"></a>
</td>
<td>
<a href="javascript:emoticon(':smilewinkgrin:');"><img src="smilies/smilewinkgrin.gif" border="0" alt="img"></a>
</td>
<td>
<a href="javascript:emoticon(':wink:');"><img src="smilies/wink.gif" border="0" alt="img"></a>
</td>
</tr>
</table>
</td>
<td>
<br />
<INPUT onclick="b()" type="button" value="B" class="button">
<INPUT onclick="i()" type="button" value="I" class="button">
<INPUT onclick="u()" type="button" value="U" class="button">
<INPUT onclick="url()" type="button" value="Url" class="button">
<INPUT onclick="email()" type="button" value="Email" class="button">
<br />
<textarea name="text" cols="65" rows="9"></textarea>
</td>
</tr>
<tr>
<td>
</td>
<td>
<center>
<input name="Submit" type="submit" class="button" value="Изпрати">
</center>
</td>
</tr>
</table>
</form>
</td>
</tr>
</table>
<br />
<table width="65%" align="center">
<tr>
<td><?

for ($i=$broi; $i>0; $i--) {
if (is_file("../posts/".$i.".html")) {
include "../posts/".$i.".html";

echo"<font size=1>Файл $i.html</font> ";
echo "<a href='del.php?file=".$i."' class='BlockTextSmall'>Изтриване</a>";
echo "<br /><hr />";
}
}
?>
</td>
</tr>
</table>
</body>
</html>


del.php
<?
session_start();
if (isset($HTTP_SESSION_VARS['potrebitel']))
{
$potrebitel=$HTTP_SESSION_VARS['potrebitel'];
}
else
{
echo "Нямате достъп до тази страница";
exit;
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
<META HTTP-EQUIV="Refresh" CONTENT="0; URL=../index.php">
</head>
<body>
<?php
umask(0);
$i = $_GET['file'];


umask(0);
unlink ("../posts/".$i.".html");
?>
</body>
</html>


index.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Вход</title>
<link rel="stylesheet" href="../files/font.css" type="text/css">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
</head>
<body>
<FORM ACTION="admin.php" METHOD="POST">
<table align="center" class="e">
<caption><b>Контрол Панел</b></caption>
<tr>
<td><b>Потребител:</b></td>
<td><INPUT TYPE="text" NAME="potrebitel"></td>
</tr>
<tr>
<td><b>Парола:</b></td>
<td><INPUT TYPE="password" NAME="pas"></td>
</tr>
<tr>
<td></td>
<td><INPUT TYPE="submit" VALUE="ВХОД" class="button"></td>
</tr>
</table>
</FORM>
</body>
</html>














/ Трябва да сте регистриран за да напишете коментар /
От: dELux_nike
23:02 12-09-2009
Какво да кажа освен Браво !
От: JcaL
16:48 10-10-2009
А как мога да променя дизайна ?
От: FelickizeR
17:58 29-10-2009
е съм я пробвал но мисля че от фонт.цсс до системата е супер
От: csk1drock
14:38 01-11-2009
Сега ще я пробвам и ако всичко бачка ще я сложа! урокът е прекрасен по добър не бях срещъл!
От: JcaL
1:14 06-11-2009
Как да сложа странициране например на всеки 4 новини ?
От: MaLa_NocHe
21:39 10-12-2009
Какво му е хубаво на УРОКА, след като няма обяснение за всяко нещо, за какво служи и за какво въобще е написано ? :) Въпроса ми е за @csk1drock
От: Anrth
10:40 03-03-2010
Урока е добър, да..Но не забравяйте, че трябва да сложите права на някои файлове..
От: Pupe64etoo_92
23:20 28-05-2010
А как мога да променя дизайна ?


Трябва да отвориш тези два файла /files/font.css /files/script.js
ако разбираш от CSS и JS и да си промениш стилъ на системата
От: IvanAdamov
14:15 20-06-2010
А как да свържем базата данни...Че нещо не намирам такава опция...
От: dkkZ
17:03 02-10-2010
защо няма файл от където да се едитват новините :@:@:@
От: MaG1cS7aR
18:25 24-01-2011
$potrebitel= $HTTP_POST_VARS['potrebitel'];
$pas= $HTTP_POST_VARS['pas'];

Тук ми изкарва грешка ;(
От: botevis2
19:14 03-06-2012
Таблици няма ли тази система ?
1