Zdalne logowanie do forum phpbb nie działa

Do forum phpbb powinienem się logowac tym skryptem, lecz jak go użyje to wywala mi błąd w 7 linijce. Co jest nie tak??

<?php

function login($username, $password)

        {

        global $_SERVER;


        // Generate post string

        $post_fields = $this->array_to_http(array(

            'username' => $username,

            'password' => $password,

            'autologin' => 1,

            'redirect' => 'index.php',

            'login' => 'Zaloguj'

        ));

        // Definiowanie cURL'a

        $this->curl = curl_init();

        // Set options

        curl_setopt ( $this->curl, CURLOPT_URL, $this->phpbb_url . 'login.php?redirect=index.php' );

        curl_setopt ( $this->curl, CURLOPT_POST, true );

        curl_setopt ($ch, CURLOPT_REFERER, "http://www.przykładowastrona.pl/forum/index.php"); 

	curl_setopt ( $this->curl, CURLOPT_POSTFIELDS, $post_fields );

        curl_setopt ( $this->curl, CURLOPT_RETURNTRANSFER, true );

        curl_setopt ( $this->curl, CURLOPT_HEADER, false );

        curl_setopt ( $this->curl, CURLOPT_COOKIE, $this->cookie_name );

        curl_setopt ( $this->curl, CURLOPT_COOKIEJAR, $this->cookie_name );

        curl_setopt ( $this->curl, CURLOPT_COOKIEFILE, $this->cookie_name );

        curl_setopt ( $this->curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; pl; rv:1.8.1.4) Gecko/20070515 Firefox/2.0.0.4');

        // Logowanie

        $result = curl_exec ( $this->curl );

        // Diagnoza błędu

        if ( curl_errno ( $this->curl ) )

        {

            $this->error = array(

                curl_errno($this->curl),

                curl_error($this->curl),

            );

            curl_close ( $this->curl );

            return false;

        }

        // Rozłączanie

        curl_close ( $this->curl );

        // Prawidłowy wynik

        return true;

    }


?>

A ‘$this’ co tam robi jeśli to funkcja a nie metoda klasy? Najprościej będzie jak wywalisz wszystkie ‘this->’ oraz skopiujesz brakującą funkcję array_to_http