Skocz do zawartości
"Idzie nowe..." - o zmianach i nie tylko ×
Przeniesienie zakupów z IPS Marketplace / Moving bought items from IPS Marketplace ×

Warning: Cannot modify header information


Adam22
Przejdź do rozwiązania Rozwiązane przez Macsch15,

Rekomendowane odpowiedzi

Po wgraniu customowego skryptu do globalTemplate pokazuje mi błąd:


Warning: Cannot modify header information - headers already sent by (output started at /home/chimchil/public_html/forum/cache/skin_cache/cacheid_5/skin_global.php:108) in /home/chimchil/public_html/forum/admin/sources/classes/output/formats/html/htmlOutput.php on line 114

Warning: Cannot modify header information - headers already sent by (output started at /home/chimchil/public_html/forum/cache/skin_cache/cacheid_5/skin_global.php:108) in /home/chimchil/public_html/forum/admin/sources/classes/output/formats/html/htmlOutput.php on line 114

Warning: Cannot modify header information - headers already sent by (output started at /home/chimchil/public_html/forum/cache/skin_cache/cacheid_5/skin_global.php:108) in /home/chimchil/public_html/forum/admin/sources/classes/output/formats/html/htmlOutput.php on line 127

Warning: Cannot modify header information - headers already sent by (output started at /home/chimchil/public_html/forum/cache/skin_cache/cacheid_5/skin_global.php:108) in /home/chimchil/public_html/forum/admin/sources/classes/output/formats/html/htmlOutput.php on line 136

Warning: Cannot modify header information - headers already sent by (output started at /home/chimchil/public_html/forum/cache/skin_cache/cacheid_5/skin_global.php:108) in /home/chimchil/public_html/forum/admin/sources/classes/output/formats/html/htmlOutput.php on line 137

Warning: Cannot modify header information - headers already sent by (output started at /home/chimchil/public_html/forum/cache/skin_cache/cacheid_5/skin_global.php:108) in /home/chimchil/public_html/forum/admin/sources/classes/output/formats/html/htmlOutput.php on line 141

Skrypt działa, lecz z takim błędem.

Czy może to być spowodowane użyciem "echo" ?

Edytowane przez Adam22

ipbaddons.com

Odnośnik do komentarza
Udostępnij na innych stronach

Może jak by ktoś był taki dobry i naprowadził mnie co i jak:

Skrypt wyświetla wersję,ilość użytkowników, motd, host, i ping


    class MinecraftServerStatus {
        private $timeout;


        public function __construct($timeout = 3) {
            $this->timeout = $timeout;
        }

        public function getStatus($host = '127.0.0.1', $port = 25565) {

            //Transform domain to ip address.
            if (substr_count($host , '.') != 4) $host = gethostbyname($host);

            //Get timestamp for the ping
            $start = microtime(true);

            //Connect to the server
            if(!$socket = @stream_socket_client('tcp://'.$host.':'.$port, $errno, $errstr, $this->timeout)) {

                //Server is offline
                return false;


            } else {

                stream_set_timeout($socket, $this->timeout);

                //Write and read data
                fwrite($socket, "\xFE\x01");
                $data = fread($socket, 2048);
                fclose($socket);
                if($data == null) return false;

                //Calculate the ping
                $ping = round((microtime(true)-$start)*1000);

                //Evaluate the received data
                if (substr((String)$data, 3, 5) == "\x00\xa7\x00\x31\x00"){

                    $result = explode("\x00", mb_convert_encoding(substr((String)$data, 15), 'UTF-8', 'UCS-2'));
                    $motd = preg_replace("/(§.)/", "",$result[1]);

                }else{

                    $result = explode('§', mb_convert_encoding(substr((String)$data, 3), 'UTF-8', 'UCS-2'));

                    $motd = "";
                    foreach ($result as $key => $string) {
                        if($key != sizeof($result)-1 && $key != sizeof($result)-2 && $key != 0) {
                            $motd .= '§'.$string;
                        }
                    }

                    $motd = preg_replace("/(§.)/", "", $motd);

                }
                //Remove all special characters from a string
                $motd = preg_replace("/[^[:alnum:][:punct:] ]/", "", $motd);

                //Set variables
                $res = array();
                $res['hostname'] = $host;
                $res['version'] = $result[0];
                $res['motd'] = $motd;
                $res['players'] = $result[sizeof($result)-2];
                $res['maxplayers'] = $result[sizeof($result)-1];
                $res['ping'] = $ping;

                //return obj
                return $res;
            }

        }
    }

Wywołuje go w ten sposób:

 

 


include_once './status.php'; //include the class
$status = new MinecraftServerStatus(); // call the class
$response = $status->getStatus('127.0.0.1'); // call the function

if(!$response) {
return "<div class='offilne_status'>The Server is offline!</div>";
} else {
return "<div class='offilne_status'>The Server ".$response['hostname']." is running on ".$response['version']." and is online,
currently are ".$response['players']." players</div>";
}

</php>





 

Edytowane przez Adam22

ipbaddons.com

Odnośnik do komentarza
Udostępnij na innych stronach

  • Rozwiązanie


<php>

include_once './status.php'; //include the class

$status = new MinecraftServerStatus(); // call the class

$response = $status->getStatus('127.0.0.1'); // call the function

</php>

<if test="!$response">

<div class='offilne_status'>The Server is offline!</div>

<else />

<div class='offilne_status'>The Server {$response['hostname']} is running on {$response['version']} and is online, currently are {$response['players']} players</div>

</if>

  • Lubię to 1
Odnośnik do komentarza
Udostępnij na innych stronach

Gość
Ten temat został zamknięty. Brak możliwości dodania odpowiedzi.
  • Ostatnio przeglądający   0 użytkowników

    • Brak zarejestrowanych użytkowników przeglądających tę stronę.
×
×
  • Dodaj nową pozycję...

Powiadomienie o plikach cookie

Umieściliśmy na Twoim urządzeniu pliki cookie, aby pomóc Ci usprawnić przeglądanie strony. Możesz dostosować ustawienia plików cookie, w przeciwnym wypadku zakładamy, że wyrażasz na to zgodę.