1. GSManager
    1. Funktionen
    2. Unterstützte Spiele
    3. Neuigkeiten
    4. Statistiken
    5. Serverliste
  2. Lexikon
  3. Filebase
  4. Entwicklung
  5. Forum
    1. Dashboard
    2. Unerledigte Themen
  6. Mitglieder
    1. Letzte Aktivitäten
    2. Benutzer online
    3. Team
    4. Mitgliedersuche
  • Anmelden
  • Registrieren
  • Suche
Dieses Thema
  • Alles
  • Dieses Thema
  • Dieses Forum
  • Artikel
  • Seiten
  • Dateien
  • Forum
  • Lexikon
  • Erweiterte Suche
  1. GSManager
  2. Forum
  3. Unterstützung
  4. Benutzung

Player Validate Plugin [WIP]

  • Comkid
  • 28. Januar 2011 um 02:38
Das Projekt GSManager (vormals ManuAdminMod) wurde am 01.01.2020 eingestellt - diese Internetpräsenz bleibt verfügbar, die Software wird aber nicht länger gepflegt. Vielen Dank für eure Unterstützung in den mehr als zehn vergangenen Jahren!
  • Comkid
    Anfänger
    Punkte
    15
    Beiträge
    2
    • 28. Januar 2011 um 02:38
    • #1

    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

  • manu
    Meister
    Punkte
    10.835
    Trophäen
    3
    Beiträge
    2.113
    • 28. Januar 2011 um 07:56
    • #2
    Zitat

    but do you guys see any syntax errors?


    Hahaha, thats a joke, isn't it?
    Your code looks horrible. No linebreaks, tabs, no structure...
    I won't even read any line of your code as long as it this unreadable...

  • Comkid
    Anfänger
    Punkte
    15
    Beiträge
    2
    • 28. Januar 2011 um 13:36
    • #3

    Not my fault, when I copied over the source code, it was all structured ;)

    Check this pastebin ;)

    http://pastebin.com/vupR66tk

    If I coded like that, I wouldn't even be able to know what I'm coding... :? XD

    Trying to copy again :S Tried and tested with preview couldn't do it :? Check the pastebin ;)

    Einmal editiert, zuletzt von Comkid (28. Januar 2011 um 14:02)

Benutzer online in diesem Thema

  • 1 Besucher
  1. Mitarbeiter
  2. Datenschutzerklärung
  3. Nutzungsbedingungen
  4. Impressum
  5. Kontakt
Community-Software: WoltLab Suite™