Hey guys,
I've written this plugin called Player Validate Plugin, it is still a work in progress, but do you guys see any syntax errors?
PHP
<?php
$mod->registerEvent("playerJoined", "playervalidate");
function playervalidate($guid){global $mod, $players;$name = $players[$guid]->getName();$status = $mod->rconPlayerList();
foreach ($status as $line){if ($line["pid"] == $players[$guid]->getPid() || $line["guid"] == $guid){$ip = $line["ip"];break;}}
$check = "{$name}|i|{$ip}|x|{$guid}";$configdir = $mod->getConfigDir();$path = $configdir . "/plugins/accounts.lst";$timestamp = date("[d.m.y H:i:s]");$h = fopen(LOGDIR . "/accounts.log", "a");
if (!file_exists($path)){fwrite($h, $timestamp . $check . PHP_EOL);fclose($h);return;}
$file = file_get_contents($path);$array = explode('--', $file);$protected = explode(PHP_EOL, $array[2]);$banned = explode(PHP_EOL, $array[4]);$badd = array();$gadd = false;
foreach ($protected as $v){if ($check == $v){fwrite($h, $timestamp . $check . PHP_EOL);fclose($h);return;}elseif (strpos($v, $name)){if (strpos($v, $guid) || strpos($v, $guid)){$gadd = true;}elseif (!strpos($v, $ip) && !strpos($v, $guid)){$badd[] = "|i|{$ip}";$badd[] = "|x|{$guid}";}}elseif (strpos($v, $guid)){if (strpos($v, $ip)){$gadd = true;}else{$gadd = true;}}if ($gadd || sizeof($badd)){break;}}
if ($gadd){$file = str_replace('--BANNED--', $check . PHP_EOL . '--BANNED--', $file);file_put_contents($path, $file);fwrite($h, $timestamp . $check . PHP_EOL);fclose($h);return;}
foreach ($banned as $v){$default = ($v[1] == 'n') ? 'name' : ($v[1] == 'i') ? 'ip' : 'guid';$v2 = str_replace("|{$v[1]}|", '', $v);if ($$default == $v2){switch ($default){case 'name':if (strpos($array[4], $ip) === false){$badd[] = "|i|{$ip}";}if (strpos($array[4], $guid) === false){$badd[] = "|x|{$guid}";}break;
case 'ip':if (strpos($array[4], $name) === false){$badd[] = "|n|{$name}";}if (strpos($array[4], $guid) === false){$badd[] = "|x|{$guid}";}break;
case 'guid':if (strpos($array[4], $name) === false){$badd[] = "|n|{$name}";}if (strpos($array[4], $ip) === false){$badd[] = "|i|{$ip}";}break;}
if (sizeof($badd)){break;}}}
if (sizeof($badd)){$badd = implode(PHP_EOL, $badd);$list = fopen($path, 'a');fwrite($list, $badd . PHP_EOL);fclose($list);$players[$guid]->kick(false);return;}
fwrite($h, $timestamp . $check . PHP_EOL);fclose($h);return;}
?>
Alles anzeigen
Accounts.lst:
Code
--PROTECTED--Duck|i|125.238.143.85|x|01100001c258ed1aSomeguy|i|111.174.145.7|x|01100001abcc36d3--BANNED--|i|123.124.42.32|x|01100001a6e53a33|n|T3SX
Do you guys think it'll work as intended?
Thanks,
Comkid