login.php
<?php
session_start("c:\winnt\temp");
if ($sure) {
mysql_connect("***" , "***" , "***") or die ("Spojenie sa
nepodarilo.");
mysql_select_db("***");
$sql = "select heslo from admin where meno = '$name'";
$res = mysql_query($sql);
if ($res && mysql_num_rows($res) && $pass==mysql_result($res,0)) {
$_SESSION["name"] = $name;
Header("Location:admin.php");
exit;
}
else
$chyba = true;
}
?>
<center><h1>Prihlasenie</h1>
<?php
if ($chyba)
echo "<p style=\"color: red\">Chyba. Uzivatelske meno neexistuje, alebo ste
zadali zle heslo. </p>";
?>
<form action="<?php echo $PHP_SELF ?>" method="post">
<input type="hidden" name="back" value="<?php echo $back ?>">
<table border=1 align="center">
<tr><td>
<table>
<tr><td>Uzivatelske meno:</td>
<td><input type="text" name="name" value="<?php echo $name ?>"></td>
</tr>
<tr><td>Heslo:</td>
<td><input type="password" name="pass"></td>
</tr>
<tr><td colspan="2"><input type="submit" name="sure" value="Prihlasit sa"></td></tr>
</table>
</td></tr>
</table>
</form>
admin.php
<?php
session_start("x");
if (!$_SESSION["name"]) {
Header("Location:login.php");
exit;
}
?>
<html>
<head>
<title>Admin centrum Multiherného klanu XenologY.eu</title>
</head>
<body bgcolor="#C0C0C0">
<center>
<table bgcolor="#000000" width="800">
<tr><td bgcolor=#FF0000>
<!--Menu-->
<?php
echo "<center>
<font color=#FFFFFF><h1>Zoznam noviniek:</h1></font>
<hr color=#000000 size=2 width=500>";
$link = mysql_connect("***" , "***" , "***") or die ("Spojenie sa nepodarilo.");
$db = mysql_select_db("***");
$query = "SELECT * FROM novinky ORDER BY cas desc limit 10";
$result = mysql_query($query , $link) or die ("Prikaz neslo splnit");
$num = mysql_num_rows($result);
while ($row=mysql_fetch_array($result))
echo "
<table border=1 RULES=GROUPS FRAME=BOX width=400 cellpadding=3 align=center>
<tr><td align=left><font size=3 font color=#000000><b>" .$row["nadpis"]."</td>
<td align=right><a href=\"$PHP_SELF?akcia=clanky&&id={$row["cas"]}\">detaily</a></td></tr>";
echo "<tr align=center><td><a href=\"$PHP_SELF?akcia=novinka\"><b>Pridaj novinku</a></td></tr></table><p>";
mysql_free_result($result);
mysql_close();
?>
<font size="5" color="#FFFFFF"><b>Toto je iba skusobna prevadzka diskusie!</b></font>
</td></tr>
<tr><td bgcolor="#EEE8AA">
<!--Funkcna cast-->
<?php
switch ($akcia) {
case "clanky" :
//Vypis novinky + administracia
echo "<center>";
$link = mysql_connect("***" , "***" , "***") or die ("Spojenie sa nepodarilo.");
$db = mysql_select_db("***");
$query = "SELECT * FROM novinky where cas = '$id'";
$result = mysql_query($query , $link) or die ("Prikaz neslo splnit");
if ($row=mysql_fetch_array($result)) {
echo "
<table border=1 RULES=GROUPS FRAME=BOX width=400 cellpadding=3 align=center>
<thead bgcolor=#FFFFFF>
<tr><th align=center><font size=4 font color=#000000><b>" .$row["nadpis"].
"</th></tr>
<tr><th align=left><font size=3 font color=#000000>" .$row["meno"].
", " .date("j.n.Y, H:i" , $row["cas"]).
"</th></tr>
</thead>
<tbody bgcolor=#000000>
<tr><td><font size=5 color=#FFFFFF><b>" .$row["obsah"]."</b></td></tr>
</tbody>
<tfoot bgcolor=#FFFFFF>
<tr align=center><td><a href=\"$PHP_SELF?akcia=prispevky&&id={$row["cas"]}\">Pridaj komentar/Zmaz komentar</a>
</td></tr>
<tr align=center><td>
<form method=post>
<input type=submit name=zmaz value=Vymazat>
</form>
</tfoot>
</table>\n";
}
if ($zmaz) {
$dotaz = " delete from novinky where cas = '$id'";
echo "Pre dokoncenie reloadni stranku!";
if (!mysql_query($dotaz))
echo "Nepodarilo sa vymazat zaznam <i>$dotaz</i><p>";
}
mysql_free_result($result);
mysql_close();
break;
//Diskusna cast
case "prispevky" :
//zobrazenie prispevkov
mysql_connect("***" , "***" , "***") or die ("Spojenie sa
nepodarilo.");
mysql_select_db("***");
$query = "SELECT nadpis from novinky where cas = '$id'";
$result = mysql_query($query , $link) or die ("Prikaz neslo splnit");
if ($row=mysql_fetch_array($result)) {
echo "<center><font color=#FF0000><h1>" . $row[nadpis] . "</h1></font>"; }
mysql_free_result($result);
$query = "SELECT * FROM diskusia where forid = '$id' ORDER BY datum desc";
$result = mysql_query($query , $link) or die ("Prikaz neslo splnit");
$num = mysql_num_rows($result);
echo "<table align=center>\n";
while ($row=mysql_fetch_array($result))
echo "
<tr><td>
<table border=1 RULES=GROUPS FRAME=BOX width=400 cellpadding=3>
<thead bgcolor=#87CEFA>
<tr><th align=center><font size=3 font color=#000000>Predmet - <b>" .$row["titulok"].
"</b></th></tr>
<tr><th align=left><font size=2 font color=#000000>Pridal - <b>" .$row["meno"].
", " .date("j.n.Y, H:i" , $row["datum"])."</b></th></tr>
</thead>
<tbody bgcolor=#E0FFFF>
<tr><td><font size=3 color=#FF0000>" .$row["obsah"]."</b></td></tr>
</tbody>
<tfoot>
<tr align=center><td>
<a href=\"$PHP_SELF?akcia=deldis&&id={$row["datum"]}\">Zmazat</a>
</td></tr>
</table>
</td></tr>
<tr><td><hr width=90% size=2 color=#000000></td></tr>\n";
echo "</td></tr>";
echo "</table><p>";
//odosielanie + formular + zobrazenie noveho prispevku
if ($ok) {
$dotaz = "insert into diskusia values ( '" . htmlspecialchars($name) . "' ,
" . time() . " , '" . htmlspecialchars($titulok) . "' , '" . htmlspecialchars(nl2br($mojtext)) . "' ,
'" .($id). "' )";
if (!mysql_query($dotaz))
echo "Nepodarilo sa vlozit zaznam <i>$dotaz</i><p>";
mysql_free_result($result);
echo "<h2>Vas posledny prispevok:</h2>";
$query = "SELECT * FROM diskusia ORDER by datum desc limit 1";
$result = mysql_query($query , $link) or die ("Prikaz neslo splnit");
$num = mysql_num_rows($result);
echo "<table align=center>\n";
if ($row=mysql_fetch_array($result)) {
echo "
<tr><td>
<table border=1 RULES=GROUPS FRAME=BOX width=400 cellpadding=3>
<thead bgcolor=#87CEFA>
<tr><th align=center><font size=3 font color=#000000><b>Predmet - " .$row["titulok"].
"</th></tr>
<tr><th align=left><font size=2 font color=#000000>Pridal - " .$row["meno"].
", " .date("j.n.Y, H:i" , $row["datum"])."</th></tr>
</thead>
<tbody bgcolor=#E0FFFF>
<tr><td><font size=3 color=#FF0000>" .$row["obsah"]."</b></td></tr>
</tbody>
</table>
</td></tr>
<tr><td><hr width=90% size=2 color=#000000></td></tr>\n";
echo "</td></tr>";
echo "</table><p>"; }
mysql_close();
}
echo "<form method=post>";
echo "<table align=center>
<tr><td><b>Predmet:</b></td><td><input type=text name=titulok size=30></td></tr>
<tr><td><b>Obsah novinky</b></td><td><textarea name=mojtext cols=30 rows=6></textarea></td></tr>";
echo "<tr align=center><td><input type=submit name=ok value=Potvrdit></td></tr>";
echo "</form>";
echo "</table>";
break;
case "novinka":
//pridavanie noviniek
mysql_connect("***" , "***" , "***") or die ("Spojenie sa
nepodarilo.");
mysql_select_db("***");
if ($ok) {
$dotaz = "insert into novinky values ( '" . ($nadpis) . "' ,
'" . ($name) . "' , " . time() . " , '" . nl2br($mojtext) . "' )";
if (!mysql_query($dotaz))
echo "Nepodarilo sa vlozit zaznam <i>$dotaz</i><p>";
mysql_close();
}
echo "<center><h2>Administracia noviniek</h2>";
echo "<form method=post>";
echo "<table align=center>
<tr><td><b>Nadpis:</b><ttd></tr>
<tr><td><input type=text name=nadpis size=60></td></tr>
<tr><td><b>Obsah novinky</b></td></tr>
<tr><td><textarea name=mojtext cols=45 rows=6></textarea></td></tr>
<tr><td><input type=submit name=ok value=Potvrdit></td></tr>
</table>";
echo "</form>";
break;
case "deldis" :
mysql_connect("***" , "***" , "***") or die ("Spojenie sa
nepodarilo.");
mysql_select_db("***");
$dotaz = " delete from diskusia where datum = '$id' ";
echo "<center>Vymazane, prosim, vyber si polozku z menu!";
if (!mysql_query($dotaz))
echo "Nepodarilo sa vymazat zaznam <i>$dotaz</i><p>";
mysql_close();
}
?>
</td></tr>
</table>
</body>
</html>
|