Avatar billede bandofbrothers Nybegynder
15. april 2005 - 13:08 Der er 7 kommentarer og
1 løsning

gameservers problem

hej jeg sidder her og bygger på en clansite i nuke v 7.6 jeg har hentet noget der skulle være kanon til gameservers men det kommer et problem se her:

Warning: main(): Unable to access class.aux.php in /home/sv_fox-cdk/modules/GameServers/gameq/class.gameq.php on line 30

Warning: main(class.aux.php): failed to open stream: No such file or directory in /home/sv_fox-cdk/modules/GameServers/gameq/class.gameq.php on line 30

Fatal error: main(): Failed opening required 'class.aux.php' (include_path='') in /home/sv_fox-cdk/modules/GameServers/gameq/class.gameq.php on line 30

denne fil findes og er sat til cmod 777 men den vil stadigvæk ikke hvad kan der være galt?
Avatar billede bandofbrothers Nybegynder
15. april 2005 - 13:27 #1
jeg kan heller ikke få blokken til at virke
Avatar billede splab Nybegynder
15. april 2005 - 13:46 #2
Den siger til dig at din include path er "" og det vil sige den ikke umiddelbart leder nogen specielt smarte steder efter filen.
Det er lidt svært at guestimere hvad problemet er uden at kunne se kode.
Avatar billede bandofbrothers Nybegynder
15. april 2005 - 14:03 #3
ok sender den her ind
Avatar billede bandofbrothers Nybegynder
15. april 2005 - 14:03 #4
<?PHP
/*
* GameQ - game server query class (http://gameq.sf.net)
* Copyright (C) 2003 Tom Buskens (tombuskens@users.sourceforge.net)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
*
*/



define('CFG_FILE',    'class.gameq.cfg.php'); /* path to config file */
define('INC_PATH',    'inc/');                /* path to inc. files */
define('INC_PREFIX',  'inc.');                /* prefix for .inc files */
define('INC_POSTFIX', '.php');                /* postfix for .inc files */
define('SOCK_TIMEOUT', '10');                /* socket timeout in ms */

require('class.aux.php');




class GameQ
{

    var $cfg_types;      /* contains $cfg_type array from class.gameq.cfg.php */
    var $cfg_strings;    /* containts $cfg_string array from class.gameq.cfg.php */

    var $type_id;        /* server type id (q3, ut etc.) */
    var $svr_id;        /* current server id */
    var $svr_name;      /* server type name (Quake 3 Arena, Unreal Tournament etc.) */
    var $svr_address;    /* server address */
    var $svr_port;      /* server QUERY port (NOT the gameport) */
    var $svr_type;      /* server QUERY type name */
    var $svr_strings;    /* string(s) to send to the server */
    var $svr_timeout;    /* time (ms) to listen to incoming data, the "ping" for the server */
    var $time;          /* average communication time with server */

    var $err_msg;        /* error messages */

    var $aux;            /* class with additional functions */



    /* Load the config file. */
    function GameQ()
    {
        require(CFG_FILE);
        $this->cfg_types  = $cfg_type;
        $this->cfg_strings = $cfg_string;
        $this->aux = new Aux;
    }



    /* Main function. */
    function getInfo($servers, $timeout = 200, $output_type = 'parsed')
    {
        $this->svr_timeout = $timeout;

        if (!is_array($servers)) $this->error('input data is not an array', 0);

        /* process servers */
        while (list($this->svr_id, $server) = each($servers))
        {
            /* get config */
            if (!$this->getConfig($server)) continue;

            /* communicate with server */
            if (($strings = $this->communicate()) !== FALSE)
            {
                /* check what to do with the returned strings */
                switch ($output_type)
                {
                    case 'parsed':
                        $svr_output = $this->parseData($strings);
                        break;

                    case 'raw':
                        $svr_output['strings'] = $strings;
                        break;

                    default:
                        $this->error('wrong output type specified', 0);
                }
            }
            else
            {
                $svr_output = '';
            }

            /* add some additional info */
            $svr_output = $this->customData($svr_output);

            /* put data into output array */
            $output[$this->svr_id] = $svr_output;
        }
        return $output;
    }




    /* Get configuration data for current server. */
    function getConfig($server)
    {
        /* clear data from previous servers */
        unset($this->svr_port);
        unset($this->svr_strings);

        /* read server data */
        if (!isset($server[0])) $this->error('server type not set', 0);
        if (!isset($server[1])) $this->error('server address not set', 0);

        $this->type_id    = $server[0];
        $this->svr_address = $server[1];

        /* check if type exists */
        if (!isset($this->cfg_types[$this->type_id]))
        {
            $this->error('server type '.$this->type_id.' does not exist in the config file.');
            return FALSE;
        }

        /* get data from config */
        $cfg_data = explode('/', $this->cfg_types[$this->type_id]);
        $this->svr_name = $cfg_data[0];
        $this->svr_type = $cfg_data[2];

        /* set port */
        if (!isset($server[2]))
        {
            $this->svr_port = $cfg_data[1];
        }
        else
        {
            $this->svr_port = $server[2];
        }

        /* get strings to query server */
        if (!isset($cfg_data[3]))
        {
            $this->svr_strings = explode('/', $this->cfg_strings[$this->svr_type]);
        }
        else
        {
            $this->svr_strings = explode('/', $this->cfg_strings[$cfg_data[3]]);
        }

        return TRUE;
    }



    /* Communicates with server, gets query information. */
    function communicate()
    {
        /* open connection to the server */
        if (!($sock = @fsockopen('udp://'.$this->svr_address, $this->svr_port)))
        {
            $this->error('could not connect to server');
            return FALSE;
        }
        socket_set_timeout($sock, 0, 1000*SOCK_TIMEOUT);

        /* send strings to server, receive data */
        $string_cnt = count($this->svr_strings);

        for($i=0; $i!=$string_cnt; $i++)
        {
            /* send string */
            fwrite($sock, $this->svr_strings[$i]);
           
            /* wait for answer */
            $wait = 0;
            while ($wait < $this->svr_timeout)
            {
                $string = fread($sock, 4096);
                if (!empty($string))
                {
                    $data[] = $string;
                    if (strlen($string) < 4096) break;
                }
                $wait += SOCK_TIMEOUT;
            }
        }
        @fclose($sock);
       
        /* rough ping time */
        $this->ping = $wait;
       
        /* check if any data was returned */
        if (empty($data[0]))
        {
            $this->error('the server didn\'t return any data');
            return FALSE;
        }

        return $data;
    }



    /* Parses data according to gametype. */
    function parseData($data)
    {
        /* include the parse file */
        $parse_file = INC_PATH.INC_PREFIX.$this->svr_type.INC_POSTFIX;
        if (!is_readable($parse_file))
        {
            $this->error('could not read file "'.$parse_file.'".', 0);
        }

        require($parse_file);
        return $output;
    }



    /* Adds some general server info to the output. */
    function customData(&$data)
    {
        $custom['address']    = $this->svr_address;
        $custom['query_port'] = $this->svr_port;
        $custom['id']        = $this->type_id;
        $custom['type']      = $this->svr_type;
        $custom['name']      = $this->svr_name;
        $custom['ping']      = $this->ping;

        $data['custom'] = $custom;
        return $data;
    }



    /* Error function. */
    function error($msg, $type = 1)
    {
        /* set message */
        $this->err_msg[$this->svr_id] = $msg;

        if ($type == 0)
        {
            /* fatal error */
            die('[fatal error]['.$this->svr_id.'] '.$msg);
        }
    }

}
?>
Avatar billede bandofbrothers Nybegynder
15. april 2005 - 14:04 #5
og her er aux filen
Avatar billede bandofbrothers Nybegynder
15. april 2005 - 14:04 #6
<?PHP
/*
* GameQ - misc functions (http://gameq.sf.net)
* Copyright (C) 2003 Tom Buskens (tombuskens@users.sourceforge.net)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
*/

class Aux
{
    function spyString($string, $del = '\\', $start = 2)
    {
        /* cut string into pieces according to delimiter */
        $pieces = explode($del, $string);
        $cnt = count($pieces, COUNT_RECURSIVE);
        for($i=$start; $i<$cnt; $i+=2)
        {
            $result[$pieces[$i-1]] = $pieces[$i];
        }
        return $result;
    }



    function savageString($string)
    {
        /* cut string into pieces */
        $pieces = explode('ÿ', $string);
        $cnt = count($pieces, COUNT_RECURSIVE);
        for($i=1; $i<$cnt; $i++)
        {
            $smpieces = explode('þ',$pieces[$i]);
            $result[$smpieces[0]] = $smpieces[1];
        }
        return $result;
    }



    function HLString($string, &$i)
    {
        $begin = $i;
        $strlen = strlen($string);
        for ($i; ($i < $strlen) && ($string{$i} != chr(0)); $i++);
        $result = substr($string, $begin, $i-$begin);
        $i++;
        return $result;
    }



    function tribesString($string, &$i, $count_index = TRUE)
    {
        $strlen = ord($string{$i});
        if ($count_index) $result = substr($string, ++$i, $strlen-1);
        else $result = substr($string, ++$i, $strlen);
        $i+=$strlen;
        return $result;
    }
   

    /* Unreal 2 XMP strings sometimes have color coding.
    * See http://unreal.student.utwente.nl/UT2003-queryspec.html for more details.
    */
    function unreal2String($string, &$i, $count_index = TRUE)
    {
        if (substr($string, $i+1, 4) == "\x5e\x00\x23\x00")
        {
           
            /* color coded string */
            $strlen = ord($string{$i})-128;
            $strlen*=2;
        }
        else
        {
            /* normal (Tribes)string */
            $strlen = ord($string{$i});
        }
        if ($count_index) $result = substr($string, ++$i, $strlen-1);
        else $result = substr($string, ++$i, $strlen);
        $i+=$strlen;
        return $result;

    }


    function ghostReconString($string, &$i)
    {
        $substr = substr($string, $i, 4);
        if (strlen($substr) < 4) return 0;
        $length = current(unpack("V", $substr));
        $i+=4;
        $j=0;
        while ($j < $length && $string{$i+$j} != chr(0)) $j++; // check for first "\x00" in the string
        $result = substr($string, $i, min($j, $length-1));
        $i+=$length;
        return $result;
    }



    function unsignedLong($string, &$i)
    {
        $substr = substr($string, $i, 4);
        if (strlen($substr) < 4) return 0;
        $result = current(unpack("V", $substr));
        $i+=4;
        return $result;
    }



    function parseBitFlag($flag, $data)
    {
        $bit = 1;
        foreach($data AS $elt)
        {
            if ($flag & $bit) $output[$elt] = 1;
            else $output[$elt] = 0;
            $bit *= 2;
        }
        return $output;
    }
   
   
    /* Sorts players by score, puts player data for ALL gametypes
    * into $data['players'][$i], clears any other
    * player data.
    * This breaks compatibility with versions < 0.2.5
    */
    function sortPlayers(&$data, $type = 'spy')
    {
        /* possible variables to sort players by */
        $sortvars = array('score', 'frags', 'kills', 'honor');
        $cnt = count($sortvars);

        switch($type){
               
            /* gamespy style players */
            case 'spy':
               
                /* put all data with key <name>_<postfix> into an array
                * $player[<postfix>][<name>]
                */
                foreach($data AS $key => $val)
                {
                    if (preg_match("/^(.+)_(\d\d?)$/", $key, $match) && $match[1] != 'teamname') // fix for bf1942
                    {
                        $players_u[$match[2]][$match[1]] = $data[$key];
                        unset($data[$key]);
                    }
                }
               
                /* check if a sortvar can be found */
                for($i=0; $i!=$cnt; $i++)
                {
                    if (isset($players_u[0][$sortvars[$i]]))
                    {
                        $sortvar = $sortvars[$i];
                        break;
                    }
                }
               
                /* if no sortvar is found, return players unsorted */
                if (!isset($sortvar))
                {
                    if (isset($players_u)) $data['players'] = $players_u;
                    return TRUE;
                }
   
                /* re-index players so they can be sorted more easily */
                foreach($players_u AS $key => $val)
                {
                    $players[] = $players_u[$key];
                }
                break;
           
           
            /* quake style players */
            case 'quake':
                /* check if a sortvar can be found */
                for($i=0; $i!=$cnt; $i++)
                {
                    if (isset($data['players'][0][$sortvars[$i]]))
                    {
                        $sortvar = $sortvars[$i];
                        break;
                    }
                }
               
                /* if no sortvar is found, return players unsorted */
                if (!isset($sortvar)) return TRUE;
                $players = $data['players'];
                break;
        }
       
        /* sort */
        $cnt = count($players);
        for($i=0; $i != $cnt; $i++){
            $a = $i;
            $b = $cnt-1;
            while ($a != $b){
                if ($players[$a][$sortvar] > $players[$b][$sortvar]) $b--;
                else $a++;
            }
            $h = $players[$i];
            $players[$i] = $players[$a];
            $players[$a] = $h;
        }
               
        /* put playerdata back into the array */
        $data['players'] = $players;
    }


}
?>
Avatar billede bandofbrothers Nybegynder
15. april 2005 - 14:05 #7
Avatar billede bandofbrothers Nybegynder
16. april 2005 - 14:57 #8
123456 har selv fundet udaf det
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Vi tilbyder markedets bedste kurser inden for webudvikling

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester