Errore mio: avevo incluso 2 volte uno stesso file!
Ecco il codice (questo è il codice login_.php):
Codice PHP:
<?php include "antet.php"; include "func.php";
if (isset($_POST["name"], $_POST["pass"]))
{
$_POST["name"]=clean($_POST["name"]); $_POST["pass"]=clean($_POST["pass"]);
$_SESSION["user"]=login($_POST["name"], md5($_POST["pass"]));
$config=config();
if ((!$config[2][1])&&($_SESSION["user"][4]<4))
{
$_SESSION = array();
session_destroy();
msg($lang['loginClosed']);
}
else if ($_SESSION["user"][0])
{
if (check_d($_SESSION["user"][0]))
{
if (isset($_SESSION["user"][0]))
{
$land=get_land();
$xy=$land[rand(0, count($land)-1)];
$towns=towns($_SESSION["user"][0]);
if (count($towns))
{
$query = "SELECT id, email FROM users WHERE name = '".$_SESSION["user"]."'";
$result = mysql_query($query);
$row = mysql_fetch_array($result);
$query3 = "SELECT id FROM towns WHERE owner = '".$row[id]."' AND isCapital = '1'";
$result3 = mysql_query($query3);
$capitale = mysql_fetch_array($result3);
header("Location: town.php?town=".$capitale);
}
else
{
?>
<html>
<?php echo "<link rel='stylesheet' type='text/css' href='".$imgs.$fimgs."default.css'>"; ?>
<script src="func.js" type="text/javascript"></script>
<head>
<title><?php echo $title; ?> - <?php echo $lang['createTown']; ?></title>
</head>
<body class="q_body">
<div align="center">
<?php echo $top_ad; ?>
<table class="q_table">
<tr>
<td class="td_logo">
<?php logo($title); ?></td>
</tr>
<tr>
<td class="td_top_menu"><?php menu_up(); ?></td>
</tr>
<tr>
<td class="td_content"><form name="form1" method="post" action="create_.php?is_cap=<?php echo $is_cap; ?>">
<center><b>Non hai ancora fondato nessuna citta, fallo adesso!</b>
</br><img height='95' src='construction.gif'></br></center>
<p><?php echo $lang['desCoord']; ?>:
<input class="textbox" name="x" id="x" type="text" size="5" value="<?php echo $xy[0]; ?>">
<input class="textbox" name="y" id="y" type="text" size="5" value="<?php echo $xy[1]; ?>">
[<a class='q_link' href="javascript: go('create.php');"><?php echo $lang['random']; ?></a>]
</p>
<p><?php echo "Nome della città:";?>
<input class="textbox" name="name" type="text" size="25" value="villaggio di <?php echo $_SESSION["user"][1]; ?>">
</p>
<p>
<input class="button" type="submit" name="go" value="<?php echo $lang['create']; ?>">
</p>
</form>
</td>
</tr>
<tr>
<td class="td_bottom_menu">
<?php menu_down(); ?></td>
</tr>
</table>
<?php echo $bottom_ad; ?>
<p><?php about(); ?></div>
</body>
</html>
<?
}
}
else {header('Location: login.php'); die();}
}
else header('Location: logout.php');
}
else msg($lang['noUserWrong']);
}
else msg($lang['noInput']);
?>
E ti passo anche il login.php:
Codice PHP:
<?php include "antet.php"; include "func.php";
$_SESSION = array();
session_destroy();
?>
<html>
<?php echo "<link rel='stylesheet' type='text/css' href='".$imgs.$fimgs."default.css'>"; ?>
<script src="func.js" type="text/javascript"></script>
<head>
<title><?php echo $title; ?> - <?php echo $lang['login'] ?></title>
</head>
<body class="q_body">
<div align="center">
<?php echo $top_ad; ?>
<table class="q_table">
<tr>
<td class="td_logo">
<?php logo($title); ?></td>
</tr>
<tr>
<td class="td_top_menu"><?php menu_up(); ?></td>
</tr>
<tr>
<td class="td_content">
<table class="q_table" style="border-collapse: collapse" width="624" height="266" border="1">
<tr>
<td height="24" align="center" class='head_table'><?php echo $lang['userLogin'] ?></td>
<td align="center" class='head_table'><?php echo $lang['sitterLogin'] ?></td>
</tr>
<tr>
<td height="234" align="right"><center>
<img src='account.png' height='39'></center></br><center><a>Accesso al proprio account</a></center></br><form action="login_.php" method="post" name="form" target="_self">
<label><?php echo $lang['username'] ?>
<input class='textbox' type="text" name="name" id="name"><a> </a>
</label>
<p>
<label><?php echo $lang['password'] ?>
<input class='textbox' type="password" name="pass"><a> </a>
</label>
</p>
<p>
<label>
<input class='button' type="submit" name="login" value="<?php echo $lang['login'] ?>"><a> </a>
</label>
</p>
<p><a title='<?php echo $lang['emailPass'] ?>' class='q_link' href='javascript: forgot();'><?php echo $lang['emailPass'] ?></a><a> </a></p>
</form></td>
<td align="right"><center>
<img src='sitter.png' height='39'></center></br><center><a>Accesso account da sitterare</a></center></br><form action="sit.php" method="post" name="form" target="_self">
<label><?php echo $lang['accToSit'] ?>
<input class='textbox' type="text" name="account"><a> </a>
</label>
<p>
<label><?php echo $lang['yourUsername'] ?>
<input class='textbox' type="text" name="name"><a> </a>
</label>
</p>
<p>
<label><?php echo $lang['yourPass'] ?>
<input class='textbox' type="password" name="pass"><a> </a>
</label>
</p>
<p>
<label>
<input class='button' type="submit" name="login" value="<?php echo $lang['login'] ?>"><a> </a>
</label>
</p>
</form></td>
</tr>
</table>
</td>
</tr>
<tr>
<td class="td_bottom_menu">
<?php menu_down(); ?></td>
</tr>
</table>
<?php echo $bottom_ad; ?>
<p><?php about(); ?></div>
</body>
</html>
L'antet.php
Codice PHP:
<?php
session_start();
//if (isset($_SESSION["user"][0])) include "./language/".$_SESSION["user"][16];
//else if (isset($_SESSION["lang"])) include "./language/".$_SESSION["lang"];
include "./language/it.php"; //configure language it.php is default
$title="Enkantar"; $m=49; $n=49;
$db_host="localhost"; $db_user="enkantar2"; $db_pass=""; $db_name="my_enkantar2"; //configure this database
$top_ad="<table><tr><td> <font class='q_label'></font> </td><td>";
$bottom_ad="</td><td> <font class='q_label'></font> </td></tr></table>";
$bottom_text="";
if (isset($_SESSION["user"][0])&&($_SESSION["user"][4]>1)) {$top_ad=""; $bottom_ad=""; $bottom_text="";}
function logo($title)
{
//echo "<embed type='application/x-shockwave-flash' width='640' height='136' src='default/logo.swf' quality='high'></embed>";
}
function menu_up()
{
//global $lang;
//if (isset($_SESSION["user"][1], $_GET["town"]))
//{
// $_GET["town"]=clean($_GET["town"]);
// $loc=town_xy($_GET["town"]);
// $map_lnk="<a class='q_link' href='map.php?x=".$loc[0]."&y=".$loc[1]."'>".$lang['map']."</a>";
}
//else $map_lnk="<a class='q_link' href='map.php?x=10&y=13'>".$lang['map']."</a>";
//echo "<a class='q_link' href='index.php'>".$lang['home']."</a> | ";
//if (!isset($_SESSION["user"][1])) echo "<a class='q_link' href='login.php'>".$lang['login']."</a> |
//<a class='q_link' href='register.php'>".$lang['register']."</a> | ";
//else echo "<a class='q_link' href='logout.php'>".$lang['logout']."</a> | ";
//echo $map_lnk." | <a class='q_link' href='/forum' target='blank'>".$lang['forum']."</a> |
//<a class='q_link' href='help.php'>".$lang['about']."</a> | ";
//if (isset($_SESSION["user"][1])) echo "<a class='q_link' href='profile_view.php?id=".$_SESSION["user"][0]."'>".$lang['profile']."</a> | <a class='q_link' href='league.php'>Top 10</a> | <a class='q_link' href='towns.php'>".$lang['towns']."</a> | ";
//if(isset($_SESSION["user"][1], $_GET["town"]))echo " <a class='q_yellow_link' href='grotta.php?town=".$_GET["town"]."'> Plus </a> |";
//}
//
function menu_down()
{
// global $lang;
// if (isset($_SESSION["user"][0], $_GET["town"]))
// {
// $_GET["town"]=clean($_GET["town"]);
// echo "<a class='q_link' href='town.php?town=".$_GET["town"]."'>".$lang['townCenter']."</a> | <a class='q_link' href='stats.php?town=".$_GET["town"]."'>".$lang['statistics']."</a> | ";
}
// if (isset($_SESSION["user"][0])) $alert=msg_rep_alert($_SESSION["user"][0]);
// if ($alert[0][0]) $alert[0]="<font color='red'>".$alert[0][0]."</font> "; else $alert[0]="";
// if ($alert[1][0]) $alert[1]="<font color='red'>".$alert[1][0]."</font> "; else $alert[1]="";
// if (isset($_SESSION["user"][1])) echo "<a class='q_link' href='reports.php?page=0'>".$alert[0].$lang['reports']."</a> | <a class='q_link' href='messages.php?page=0'>".$alert[1].$lang['messages']."</a> || <a class='q_link' href='chat.php'>".$lang['chat']."</a> | ";
// if (((isset($_SESSION["user"][4]))&&($_SESSION["user"][4]>2)&&($_SESSION["user"][4]<4))) echo "<a class='q_link' href='apanel.php'>Pannello Natar</a> | ";
// if (((isset($_SESSION["user"][4]))&&($_SESSION["user"][4]>3)&&($_SESSION["user"][4]<5))) echo "<a class='q_link' href='apanel.php'>Pannello MH</a> | ";
// if ((isset($_SESSION["user"][4]))&&($_SESSION["user"][4]>4)) echo "<a class='q_link' href='apanel.php'>".$lang['adminPanel']."</a> | ";
// }
//function about()
//{global $bottom_text; echo $bottom_text;}
$system=array();
$system[0]=5;//chat message life, in minutes
$system[1]=5;//chat refresh time, in seconds
?>