Yea, I'm running a lil' game server, and I want to make it easier for players to signup. My friend sent me some files in php, but I don't know what to do with them, they bring up some errors here or there...
<?
define ('LF', "\n");
define ('TAB', chr(9));
$file = 'C:\YARE\data\accounts.txt'; // Set the path to your accounts.txt
$online = 'C:\YARE\data\online.txt'; // Online users
/
$user = 'sysgm'; // For debug only!
$pass = 'somepass'; // For debug only!
$action = 'list'; // For debug only! (list, register, login)
$gender = 'M'; // For debug only (M/F)
/
$bu_index = 0;
$gu_index = 0;
$ma_index = 0;
$online_usr = 0;
if ($user != "" AND $pass != "" AND $action != ""){
$handle = fopen($file, "r");
while (!feof($handle)) {
$data = fgets($handle, 1024);
if(strlen($data) != 0) {
list ($xid, $xuser, $xpass, $xlogin) = explode(chr(9), $data);
$ma_index = $ma_index + 1;
if($action == "list"){
echo "<hr>";
echo "ID: ".$xid."<br>";
echo "Username: ".$xuser."<br>";
//echo "Passwort: ".$xpass."<br>"; // Not so good Al!
echo "Last login: ".$xlogin."<br>";
}elseif($action == 'register'){
if(strtolower($xuser) == strtolower($user)){
//echo "User $xuser already exist!<br>";
$bu_index = $bu_index + 1;
}
if (strtolower($xuser) != strtolower($user)){
//echo "User $user doesn't exist yet!<br>";
$gu_index = $gu_index + 1;
}
}elseif($action == 'login'){
if(strtolower($xuser) == strtolower($user) AND $xpass == $pass){
echo "(User <b>$xuser</b>) >> <u>Access granted</u><br>";
// Maybe add a link to another site (member area or something...)
}else{
echo "(User <b>$xuser</b>) >> <u>No access!</u><br>";
// No access :p
}
}
}
}
fclose ($handle);
if ($action == 'register' AND $gu_index != 0){
if($bu_index >= 1){
echo "User $user already existing, choose another name!";
}else{
$xid = $xid + 1;
echo "User $user is not yet created! :-)<br>";
echo "Writing user...<br>";
$writehnd = fopen($file, "a+");
fputs($writehnd, $xid . TAB . $user . TAB . $pass . TAB . date("Y-m-d G:i:s") . TAB . $gender . TAB . '1' . LF);
fclose($writehnd);
echo "Done! You can now log on and play next time the server is online.";
}
}
}
?>
That is the signup form...
<?php
$ip = gethostbyname("infectedanime.myserver.org");
echo("<table>");
echo(" <tr>");
echo(" <th>IP</th>");
if($LOGGEDIN == 2) echo(" <td bgcolor=\"#EFEFF7\" colspan=\"2\">$ip</td>");
else echo(" <td bgcolor=\"#EFEFF7\">$ip</td>");
echo(" </tr>");
echo(" <tr>");
if($fp = @fsockopen($ip, 5121,$un,$sinn,2)) {
echo("<th>Map:</th><td bgcolor=\"#EFEFF7\"><font color=\"#00DD00\">online</font></td>");
fclose($fp);
} else {
echo("<th>Map:</th><td bgcolor=\"#EFEFF7\"><font color=\"#DD0000\">offline</font></td>");
}
echo(" </tr>");
echo(" <tr>");
if($fp = @fsockopen($ip, 6121,$un,$sinn,2)) {
echo("<th>Char:</h><td bgcolor=\"#EFEFF7\"><font color=\"#00DD00\">online</font></td>");
fclose($fp);
} else {
echo("<th>Char:</th><td bgcolor=\"#EFEFF7\"><font color=\"#DD0000\">offline</font></td>");
}
echo(" </tr>");
echo(" <tr>");
if($fp = @fsockopen($ip, 6900,$un,$sinn,2)) {
echo("<th>Login:</th><td bgcolor=\"#EFEFF7\"><font color=\"#00DD00\">online</font></td>");
fclose($fp);
} else {
echo("<th>Login:</th><td bgcolor=\"#EFEFF7\"><font color=\"#DD0000\">offline</font></td>");
}
echo(" </tr>");
echo("</table>");
?>
This shows if/when servers are down, offline, and current ip address, since I don't have a static IP...
Well, with the signup form, none of it works... and the server ststus checker, I get a variable error, can I get some help please? 😕