CREATE TABLE 'shoutbox' (
'id' int(9) NOT NULL auto_increment,
'nick' varchar(30) NOT NULL default '',
'tekst' varchar(255) default NULL)
style.css
a {
text-decoration:none;
}
a:link {
color:#505050;
}
a:hover {
color:#787878;
}
a:active {
color:#787878;
}
a:visited {
color:#505050;
}
.logo {
background-color: #BFC9BF;
background-image: url("gfx/logo_sb.gif");
background-repeat: no-repeat;
background-position: left top;
height:30px;
}
.form1 {
background-color:#EEF2EE;
border-style:solid;
border-width:1px;
border-color:#CDD6CD;
font-family:Verdana;
font-size:10px;
color:#666666;
width:80px;
height:20px;
}
.form2 {
background-color:#EEF2EE;
border-style:solid;
border-width:1px;
border-color:#CDD6CD;
font-family:Verdana;
font-size:10px;
color:#666666;
width:60px;
height:16px;
}
.form_txt {
font-family:Verdana;
font-size:10px;
color:#666666;
}
.tabela {
height=100%;
width:100%;
border=0px;
padding-left:2px;
padding-bottom:5px;
}
.nick {
font-family:Verdana;
font-size:10px;
font-weight:bold;
color:#000000;
}
.tresc {
font-family:Verdana;
font-size:10px;
color:#484848;
}
.linia {
font-family:Verdana;
font-size:10px;
color:#C5CFC5;
}
include.php
<?
/* nazwa bazy danych */
$dbname = "_____";
/* nazwa hosta */
$hostname="_____";
/* login */
$dbuser="_____";
/* haslo */
$dbpass="_____";
/* funkcja polaczenie z serwerem i baza danych */
function ConFunc()
{
global $dbpass;
global $dbuser;
global $hostname;
global $dbname;
/* polaczenie z hostem */
$link = @mysql_connect($hostname, $dbuser, $dbpass);
if (!$link)
{
echo("error : laczenie z serwerem");
exit;
}
/* polaczenie z baza danych */
if(!@mysql_select_db($dbname))
{
echo("error : laczenie z baza");
exit;
}
}
?>
shoutbox.php
<?php
//ilosc wpisow pokazywanych
$ile = 20;
//szerokosc i wysokosc ramki
$szerokosc = 150;
$wysokosc = 200;
//wyswietlanie ramki
if(!$shout)
{
print "<iframe ";
print "width='".$szerokosc."'";
print " height='".$wysokosc."'";
print " style='";
print "border:1px solid #C5CFC5";
print "margin:0px;";
print "padding:0px;'";
print "src='shoutbox.php?shout=1'";
print "name='shoutbox'>";
print "</iframe>";
}
//zapisywanie danych
elseif($HTTP_GET_VARS['add']==1)
{
include("include.php");
ConFunc();
if(!$HTTP_POST_VARS['nick'])
{
$autor = "Gosc";
}
elseif($HTTP_POST_VARS['nick'])
{
$autor = $HTTP_POST_VARS['nick'];
}
$tresc = $HTTP_POST_VARS['tekst'];
$zapytanie = "INSERT INTO shoutbox VALUES ('', '".$autor."' ,'".$tresc."');";
$wynik = mysql_query($zapytanie);
print "<html>";
print "<head>";
print "<meta http-equiv='Content-Type'";
print " content='text/html;";
print " charset=iso-8859-2'>";
print "<link href='style.css'";
print " rel='stylesheet'";
print " type='text/css'>";
print "</head>";
print "<body>";
//komunikat
if($wynik)
{
print "<br><br>";
print "<center>";
print "<span class='form_txt'>";
print "Wpis dodany.";
print "<br><br>";
print "<b>";
print "<a href='shoutbox.php?shout=1'";
print "target='shoutbox'>";
print "Powrot";
print "</b>";
print "</center>";
}
else
{
print "<br><br>";
print "<center>";
print "<span class='form_txt'>";
print "Blad!";
print "<br><br>";
print "<b>";
print "<a href='shoutbox.php?shout=1'";
print "target='shoutbox'>";
print "Powrot";
print "</b>";
print "</center>";
}
print "</td></tr></table>";
print "</body></html>";
}
//wyswietlanie zawartosci
elseif($HTTP_GET_VARS['shout'] == 1)
{
include("include.php");
ConFunc();
print "<html>";
print "<head>";
print "<meta http-equiv='Content-Type'";
print " content='text/html;";
print " charset=iso-8859-2'>";
print "<link href='style.css'";
print " rel='stylesheet'";
print " type='text/css'>";
print "</head>";
print "<body>";
print "<table class='tabela' cellpadding='0'";
print "cellspacing='0'";
print "<tr>";
print "<td>";
$query = "SELECT * FROM shoutbox ORDER BY id DESC";
$result = mysql_query($query);
while ($wpis = mysql_fetch_array($result))
{
$wyrazy = array("<",">","</>");
$cenzura="";
$nick = str_replace($wyrazy, $cenzura, $wpis["nick"]);
$tekst= str_replace($wyrazy, $cenzura, $wpis["tekst"]);
print "<span class='nick'>";
print $nick;
print "</span><br>";
print "<span class='tresc'>";
print $tekst;
print "</span>";
print "<span class='linia'>";
print "<br>- - - - - -<br>";
print "</span>";
}
print "<center>";
print "<form target='shoutbox' action='shoutbox.php?add=1&shout=1' method='POST'>";
print "<input type='text' class='form1'";
print "maxlength='30' name='nick'>";
print "<span class='form_txt'> nick";
print "<br><br></span>";
print "<input type='text' class='form1'";
print "maxlength='255' name='tekst'>";
print "<span class='form_txt'> txt";
print "<br><br></span>";
print "<input type='submit'";
print " class='form2' value='dodaj'>";
print "</center></form> ";
print "</td></tr></table>";
print "</body></html>";
}
?>
Offline