Kod
<?php
function getThingData($file)
{
$i=0;
$file = file_get_contents($file);
$vars = explode("\n", $file);
while($vars[$i])
{
$var = explode("=", $vars[$i]);
$ret[$var[0]] = $var[1];
$i++;
}
return $ret;
}
function setThingValue($file_dir, $from, $to)
{
$file = file_get_contents($file_dir);
$content = explode("\n", $file);
$i=0;
while($content[$i])
{
$var = explode("=", $content[$i]);
if($var[0] == $from)
{
$var[1] = $to;
}
$ret_val .= $var[0]."=".$var[1]."\n";
$i++;
}
file_put_contents($file_dir, $ret_val);
}
if($_GET['logout'] == "me")
{
setcookie("session_id", false);
header("Location: index.php");
}
if($_POST['account_login'])
{
$acc_name = htmlspecialchars($_POST['account_name']);
$acc_pwd = htmlspecialchars($_POST['account_password']);
$acc_file = $server_dir.$acc_name.".txt";
if(!file_exists($acc_file)) { $error .= "Takie konto nie istnieje. <br />"; } else {
$account = getThingData($acc_file);
if(trim($account['Online']) != "1")
{
if( trim($acc_pwd) == trim($account['Haslo']) )
{
$NS = md5(rand(0,9999) + time()); // Losowy cig znakw zakodowany do md5, przez co ma unikaln forme 32 znakow (raczej nie do BruteForce'owania)
touch("data/".$acc_name.".sid");
if(!file_exists("data/".$acc_name.".cfg")) { touch("data/".$acc_name.".cfg"); }
// AccName|Time //
file_put_contents("data/".$acc_name.".sid", $NS.".".time());
file_put_contents("data/".$acc_name.".cfg", "Skype=Brak\nGG=Brak\nEMail=");
setcookie("session_id", $NS);
setcookie("acc_name", $acc_name);
header("Location: index.php");
} else { $error .= "Podane haslo jest nieprawidlowe. <br />"; }
} else { $error .= "Nie mozesz byc zalogowanym w grze, aby wejsc do panelu."; }
}
}
if($_POST['account_reg'])
{
$acc_name = htmlspecialchars($_POST['account_name']);
$acc_pwd = htmlspecialchars($_POST['account_password']);
$acc_pwd2 = htmlspecialchars($_POST['account_password2']);
$char_skin = htmlspecialchars($_POST['character_skin']);
$char_sex = htmlspecialchars($_POST['character_s']);
$char_orign = htmlspecialchars($_POST['character_o']);
if($acc_pwd == $acc_pwd2)
{
if(ereg("([a-zA-Z_]) ([a-zA-Z_])", $acc_name) && strlen($acc_name) < $reg_data["MaxNameLen"] && strlen($acc_name) > $reg_data["MinNameLen"])
{
if($char_skin == 23 || $char_skin == 7 || $char_skin == 101 || $char_skin == 28 || $char_skin == 60 || $char_skin == 56 || $char_skin == 190 || $char_skin == 191 || $char_skin == 192 || $char_skin == 193)
{
if($char_sex == 1 || $char_sex == 2)
{
if($orign_chosse[$char_orign])
{
$nF = $server_dir.$acc_name.".txt";
if(!file_exists($nF))
{
copy($server_dir."Example.txt", $nF);
// Ustawianie zmiennych:
setThingValue($nF, "Haslo", $acc_pwd);
setThingValue($nF, "Pochodzenie", $char_orign);
setThingValue($nF, "Skin", $char_skin);
setThingValue($nF, "Plec", $char_sex);
$reg_error = "Konto zostalo pomyslnie utworzone.";
} else { $reg_error = "Konto o podanej nazwie ju istnieje."; }
} else { $reg_error = "Podales zle pochodzenie."; }
} else { $reg_error = "Nie podales plci postaci."; }
} else { $reg_error = "Nie wybrales skina"; }
} else { $reg_error = "Nieprawidlowa nazwa konta."; }
} else { $reg_error = "Podane hasla si nie zgadzaj."; }
}
?>
Bo może ja źle do tego Parseru"parser.php" to wkładam, no nie wiem, sprawdz to jak możesz,