Amerika Posted May 16, 2012 Share Posted May 16, 2012 Hi i have a problem with an third party script. I dont know why but with the newer php version it is much slower then with an older php version. What could produce much slower results in the new php from this code: <?php $back = "#000000"; //background color $server_host="address"; $server_port="27015"; $img_width = "150px"; $img_height = "90px"; $img_addr = "http://images"; $img_n = ".jpg"; $qw=chr(32); $fp = fsockopen ("udp://".$server_host,$server_port); if (!$fp) { echo "Error\n"; } else { fwrite($fp,"\xFF\xFF\xFF\xFF\x54\x53\x6F\x75\x72\x63\x65\x20\x45\x6E\x67\x69\x6E\x65\x20\x51\x75\x65\x72\x79\x00".chr(10)); $start=time(); socket_set_timeout($fp,1); $st=fread($fp,1); $r=socket_get_status($fp); $r=$r["unread_bytes"]; if($r == 0) { echo "Serveris šobrīd nedarbojas vai maina karti!"; //teksts, kas uzraadiisies, ja serveris ir izsleegts vai maina mapi } else { $st=fread($fp,$r); fclose($fp); $st=substr($st,5); $adrese1=SubStr($st,0,StrPos($st,chr(0))); $adrese2=str_replace(chr(0),"|",$address); $st=SubStr($st,StrPos($st,chr(0))+1); $server_name=SubStr($st,0,StrPos($st,chr(0))); $st=SubStr($st,StrPos($st,chr(0))+1); $map=SubStr($st,0,StrPos($st,chr(0))); $st=SubStr($st,StrPos($st,chr(0))+1); $st=SubStr($st,StrPos($st,chr(0))+1); $st=SubStr($st,StrPos($st,chr(0))+1); $pl_online=ord(SubStr($st,0,1)); $pl_max=ord(SubStr($st,1,1)); $free = ($pl_max-$pl_online); if($pl_max == $pl_online) { $pl_col = "#ff0000"; } elseif($pl_online >= ($pl_max-0)) { $pl_col = "#4AA02C"; } else { $pl_col = "#4AA02C"; } if (@fclose(@fopen($img_addr." ".$map.$img_n, "r"))) { $current_map_img = "<img src='$img_addr$map$img_n class='image' float='top' alt='".$map."' style='width: ".$img_width."; height: ".$img_height."; border:2px solid ".$back.";'>"; } else { $current_map_img = "<img src='$img_addr$map$img_n' class='image' float='top' alt='".$map."' style='width: ".$img_width."; height: ".$img_height."; border:2px solid ".$back.";'>"; } echo " <div style=\"width: 165px; font-size: 12px; font-family: Arial, Helvetica, sans-serif; margin: auto;\"> <div style=\"float: left; color: #fff; padding: 3px; background-color: ".$back."; text-align: center;\" class=\"map_name\">".$map." ".$current_map_img." <br> <table> <tr> <td><font size='1pt' color='white'>Adrese:</font></td> <td><font size='1pt' color='white'>".$server_host.":".$server_port."</font></td> </tr> <tr> <td><font size='1pt' color='white'>Speletaji:</font></td> <td><font size='1pt' color='white'><span style=\"color: ".$pl_col."\">".$pl_online."</span>/<span style=\"color: #ff0000\">".$pl_max."</span></font></td> </tr> <tr> <td><font size='1pt' color='white'>Karte:</font></td> <td><font size='1pt' color='white'>".$map."</font></td> </tr> </table> </div></div>"; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/262611-script-working-slower-on-newer-php-version/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.