Caute, po pipojeni k databaze riesim presmerovanie banovanych uzivatelov ale netusim preco... nefunguje mi to.
Kód:
<?php
session_start();
// INCLUDE CONFIG AND HEADER FILE
define("ICONF", "config/iconf.php");
if(file_exists(ICONF)){
include(ICONF);
include(HEADER);
include(MFUNCTIONS);
}
// CONNECT TO THE DATABASE AND WRITE PAGE MENU
db_connect();
$ip=getRealIpAddr();
$sql = q("SELECT * FROM users WHERE ip='$ip' AND ban=1");
$rows = mysql_num_rows($sql);
if($rows != 0){
header("Location: banned.php");}
$result = q("SELECT * FROM pages");
while($write = mysql_fetch_array($result)){
$id = h($write['id']);
$name = h($write['name']);
echo "<a href=\"pages.php?id=$id\">$name</a>";
}
//WRITE PAGES CONDITIONS
if(isset($_GET['id'])){
(int)$id = $_GET['id'];
$result = q("SELECT * FROM pages WHERE id=$id");
$write = mysql_fetch_row($result);
$privacy = $write[2];
$articles = $write[3];
if($_SESSION['prihlaseny'] == 'nie'){
$logged = FALSE;
}
elseif($_SESSION['prihlaseny'] == 'ano'){
$logged = TRUE;
}
if($privacy == TRUE and $logged == FALSE ){
// ADVICE LOGIN IF PRIVATE
echo "This is a private page to view it you must be logged in.<br><a href=\"login.php\">Click here to login.</a>";
}
elseif($privacy == TRUE and $logged == TRUE and $articles == FALSE){
write_page();
echo "<br><a href='logout.php?logout=yes'>Logout</a>";
}
elseif($privacy == TRUE and $logged == TRUE and $articles == TRUE){
// WRITE ARTICLES
write_articles();
write_current_article();
echo "<br><a href='logout.php?logout=yes'>Logout</a>";
}
elseif($privacy == TRUE and $logged == FALSE and $articles == TRUE){
echo "This is a private page to view it you must be logged in.<br><a href=\"login.php\">Click here to login.</a>";
}
elseif($privacy == FALSE and $articles == FALSE){
// WRITE PAGE
write_page();
}
elseif($privacy == FALSE and $articles == TRUE){
// WRITE ARTICLES
write_articles();
write_current_article();
}
elseif($privacy == TRUE and $logged == FALSE and $articles == FALSE ){
echo "This is a private page to view it you must be logged in.<br><a href=\"login.php\">Click here to login.</a>";
}
elseif($privacy == TRUE and $logged == TRUE and $articles == FALSE){
// WRITE PAGE
write_page();
echo "<br><a href='logout.php?logout=yes'>Logout</a>";
}
}
// INCLUDE FOOTER FILE
include(FOOTER);
?>