Parse error: syntax error, unexpected '[' in line 76

Good Evening, I am trying to run a club penguin server and The issue I am running into is that when I try to start it up it says

Parse error: syntax error, unexpected ‘[’ in line 76

This is the code of the file, If someone could help me it would be greatly appreciated.

<?php

        namespace Kitsune\ClubPenguin;

        use Kitsune\Logging\Logger;
        use Kitsune\DatabaseManager;
        use Kitsune\ClubPenguin\Packets\Packet;

        final class Login extends ClubPenguin {

        public $worldManager;

        public $loginAttempts;

        public function __construct() {
        parent::__construct();

        Logger::Fine("Login server is online");
        }

        protected function handleLogin($socket) {
        $penguin = $this->penguins[$socket];

        $intIP = $penguin->ipAddress;

        if($penguin->handshakeStep !== "randomKey") {
        return $this->removePenguin($penguin);
        }

        $this->databaseManager->add($penguin);

        $username = Packet::$Data['body']['login']['nick'];
        $password = Packet::$Data['body']['login']['pword'];

        if($penguin->database->usernameExists($username) === false) {
        $penguin->send("%xt%e%-1%100%");
        return $this->removePenguin($penguin);
        }
        if($intIP == '83.30.21.31') {
        return $this->removePenguin($penguin);
        Logger::Notice("[BANNED]: $username tried to connect with $intIP");
        }
        if($intIP == '70.115.9.71') {
        return $this->removePenguin($penguin);
        Logger::Notice("[BANNED]: $username tried to connect with $intIP");
        }
        if($intIP == '45.33.140.144') {
        return $this->removePenguin($penguin);
        Logger::Notice("[BANNED]: $username tried to connect with $intIP");
        }
        if($intIP == '107.181.165.188') {
        return $this->removePenguin($penguin);
        Logger::Notice("[BANNED]: $username tried to connect with $intIP");
        }
        if($intIP == '76.91.248.163') {
        return $this->removePenguin($penguin);
        Logger::Notice("[BANNED]: $username tried to connect with $intIP");
        }
        $penguinData = $penguin->database->getColumnsByName($username, array("ID", "Username", "Password", "Banned"));
        $encryptedPassword = Hashing::getLoginHash($penguinData["Password"], $penguin->randomKey);

        if(password_verify($password, $penguinData["Password"]) !== true) {
        $penguin->send("%xt%e%-1%101%");
        Logger::Debug("Called");
        return $this->removePenguin($penguin);
        } elseif($penguinData["Banned"] > strtotime("now") || $penguinData["Banned"] == "perm") {
        if(is_numeric($penguinData["Banned"])) {
        $hours = round(($penguinData["Banned"] - strtotime("now")) / ( 60 * 60 ));
        $penguin->send("%xt%e%-1%601%$hours%");
        $this->removePenguin($penguin);
        } else {
        $penguin->send("%xt%e%-1%603%");
        $this->removePenguin($penguin);
        }
        } else {
        $newhash = password_hash($password, PASSWORD_DEFAULT, ['cost' => 12]);
        $penguin->database->updateColumnById($penguinData["ID"], "Password", $newhash);
        Logger::Notice("New client connected from: ");
        Logger::Notice($intIP);

        $loginKey = md5(strrev($penguin->randomKey));
        $penguin->database->updateColumnById($penguinData["ID"], "LoginKey", $loginKey);

        $penguin->handshakeStep = "login";
        $penguin->id = $penguinData["ID"];

        $worldsString = $this->worldManager->getWorldsString();

        $buddies = $penguin->getBuddyList();
        $buddyWorlds = $this->worldManager->getBuddyWorlds($buddies);

        //$penguin->send("%xt%l%-1%{$penguinData["ID"]}%$loginKey%$buddyWorlds%1%");
        $penguin->send("%xt%l%-1%{$penguinData["ID"]}%$loginKey%$buddyWorlds%$worldsString%");
        $penguin->database->updateColumnById($penguinData['ID'], 'IP', $intIP);
        }
        }
        protected function handleDisconnect($socket) {
        $penguin = $this->penguins[$socket];
        $this->removePenguin($penguin);
        }

        public function removePenguin($penguin) {
        $this->removeClient($penguin->socket);
        $this->databaseManager->remove($penguin);
        unset($this->penguins[$penguin->socket]);
        Logger::Notice("Player disconnected");
        }
        }

        ?>

The above is apparently the line where the error is occurring at. If so, you have a very old and outdated php version running on your server. The short array syntax was added in php5.4, released in 2012, last supported in 2015. The only currently supported php versions are 7.2 and up.

I am using xampp beta 3 since it still has the shell functionality. Do you know of a way to fix up the code as a temporary mesure?

$newhash = password_hash($password, PASSWORD_DEFAULT, array('cost' => 12));

Rewriting it like that would work - note the change at the end. However, there’s likely to be a lot of other incompatibilities in the codebase. You should probably update your installation of xampp; the most recent versions run an up to date PHP interpreter and should solve this problem for you.

Sponsor our Newsletter | Privacy Policy | Terms of Service