Jump to content

script works but ..


salvador2001

Recommended Posts

Hello,

I have a problem wich i cant solve because my knowledge of PHP is to little at this moment. So i hope someone can help me out with a problem and give me a clear solution.

This script is working fine when the hosting pc is turned on. The script will clearly show if the game is running or not. But when the hosting pc is turned of i get a error on line 11 wich says:

Fatal error: maximum execution time of 30 seconds.... on line 11.

Can somebody help me with this ?

Here is the script:

[code]<?php

$s_port = 12203;          // Serverport
$s_ip  = "82.217.212.106";    // Server-IP
$s_con = fsockopen("udp://".$s_ip, $s_port);
fwrite($s_con, "ÿÿÿÿ". chr (0x02). "getstatus". chr (0x00));

// testen verbindings opbouw

fread($s_con, 4);
$status = socket_get_status($s_con);

// SERVER DOWN

if($status["unread_bytes"] == 0)
{
echo "<div align='left'>
  <table width='20%' border='1' cellpadding='0' cellspacing='0' bordercolor='#465461'>
    <tr>
      <td colspan='3'> <div align='center'><strong>Hier Plaatje</strong></div></td>
    </tr>
  <tr>
      <td colspan='3'> <div align='center'><strong>server
          status</strong></div></td>
    </tr> 
    <tr bordercolor='#2D3740'>
      <td align='center'><strong>Server down</strong></td>";
die();
}

$beginnen = "";

do
{
$beginnen .= fread($s_con, 1);
$status = socket_get_status($s_con);
}
while($status["unread_bytes"] != 0);

fclose($s_con);

$data = explode("\n", $beginnen);


// Serverinformatie

$s_con = fsockopen("udp://".$s_ip, $s_port);
fwrite($s_con, "ÿÿÿÿ". chr (0x02). "getstatus". chr (0x00));

// bytes lezen en verbindingsopbouw

fread($s_con, 4);
$status = socket_get_status($s_con);

if($status["unread_bytes"] == 0)
{
echo "no info. sorry";
die();
}

$beginnen = "";

do
{
$beginnen .= fread($s_con, 1);
$status = socket_get_status($s_con);
}
while($status["unread_bytes"] != 0);

fclose($s_con);


echo"
<div align='left'>
  <table width='20%' border='1' cellpadding='0' cellspacing='0' bordercolor='#465461'>
    <tr>
      <td colspan='3'> <div align='center'><strong>hier plaatje</strong></div></td>
    </tr>
  <tr>
      <td colspan='3'> <div align='center'><strong>server
          status</strong></div></td>
    </tr> 
    <tr bordercolor='#2D3740'>
      <td align='center'><strong>Playing Mohaa or Spearhead</strong></td>";

;
?>
[/code]
Link to comment
Share on other sites

I dont understand //insert normal code from above, i tried a few things but like i said, my knowledge is poor.

if ($status = socket_get_status($s_con)) {
fread($s_con, 4);
$status = socket_get_status($s_con);
} else {
  echo "Server is down.";
}

I am sure its wrong because the script doesnt work like it should. Can you be more specific please sir ?
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.