codepal Posted November 4, 2018 Share Posted November 4, 2018 So yea i'm having issues how to use PHP inside IPS theme ? i need to use this code somehow isindise IPS theme? function query_source($address) { $array = explode(":", $address); $server['status'] = išjungtas; $server['ip'] = $array[0]; $server['port'] = $array[1]; if (!$server['ip'] || !$server['port']) { exit("EMPTY OR INVALID ADDRESS"); } $socket = @fsockopen("udp://{$server['ip']}", $server['port'], $errno, $errstr, 1); if (!$socket) { return $server; } stream_set_timeout($socket, 1); stream_set_blocking($socket, TRUE); fwrite($socket, "\xFF\xFF\xFF\xFF\x54Source Engine Query\x00"); $packet = fread($socket, 4096); @fclose($socket); if (!$packet) { return $server; } $header = substr($packet, 0, 4); $response_type = substr($packet, 4, 1); $network_version = ord(substr($packet, 5, 1)); $packet_array = explode("\x00", substr($packet, 6), 5); $server['name'] = $packet_array[0]; $server['map'] = $packet_array[1]; $server['game'] = $packet_array[2]; $server['description'] = $packet_array[3]; $packet = $packet_array[4]; $app_id = array_pop(unpack("S", substr($packet, 0, 2))); $server['players'] = ord(substr($packet, 2, 1)); $server['playersmax'] = ord(substr($packet, 3, 1)); $server['status'] = įjungtas; return $server; } $query = query_source("91.211.244.117:27015"); tryed with <?php ?> and <php></php> tags doesnt works im getting this:http://prntscr.com/le7mec Link to comment Share on other sites More sharing options...
0 Dusan Posted November 4, 2018 Share Posted November 4, 2018 <?php include( './script-folder/script-name.php' ); // Path to script main file ?> Not sure if you can use something like that direct, but maybe you can include it as external script to your template. Link to comment Share on other sites More sharing options...
0 codepal Posted November 4, 2018 Author Share Posted November 4, 2018 i dont need to direct Link to comment Share on other sites More sharing options...
0 codepal Posted November 4, 2018 Author Share Posted November 4, 2018 (edited) @Dusan, im trying to use this in theme: <div class="nameServer"><?php echo $query['players'];?> / <?php echo $query['playersmax']; ?></div> but im getting the same error Edited November 4, 2018 by codepal Link to comment Share on other sites More sharing options...
0 Dusan Posted November 4, 2018 Share Posted November 4, 2018 I am not sure that you can use raw php in templates. What are you trying to achieve with this anyways? Display status of a server? Link to comment Share on other sites More sharing options...
0 codepal Posted November 4, 2018 Author Share Posted November 4, 2018 (edited) im trying to display only 2 things from the server $query['players']; and $query['maxplayers']; @Dusan Edited November 4, 2018 by codepal Link to comment Share on other sites More sharing options...
0 Dusan Posted November 4, 2018 Share Posted November 4, 2018 Well maybe you can check this out then. Link to comment Share on other sites More sharing options...
0 codepal Posted November 4, 2018 Author Share Posted November 4, 2018 yeah i know this one but i want to make a custom server list Link to comment Share on other sites More sharing options...
0 codepal Posted November 4, 2018 Author Share Posted November 4, 2018 nevermind i foud the suliution how to make it just use iframe with file from server thanks for trying to help @Dusan. Link to comment Share on other sites More sharing options...
0 Dusan Posted November 4, 2018 Share Posted November 4, 2018 Glad to hear that. No problem, that's why we are here. Link to comment Share on other sites More sharing options...
0 Administrator James Posted November 5, 2018 Administrator Share Posted November 5, 2018 The question(s) in this support topic have been answered and the topic author has resolved their issue. This topic is now closed. If you have other questions, please open a new topic. Link to comment Share on other sites More sharing options...
Question
codepal
So yea i'm having issues how to use PHP inside IPS theme ?
i need to use this code somehow isindise IPS theme?
function query_source($address) { $array = explode(":", $address); $server['status'] = išjungtas; $server['ip'] = $array[0]; $server['port'] = $array[1]; if (!$server['ip'] || !$server['port']) { exit("EMPTY OR INVALID ADDRESS"); } $socket = @fsockopen("udp://{$server['ip']}", $server['port'], $errno, $errstr, 1); if (!$socket) { return $server; } stream_set_timeout($socket, 1); stream_set_blocking($socket, TRUE); fwrite($socket, "\xFF\xFF\xFF\xFF\x54Source Engine Query\x00"); $packet = fread($socket, 4096); @fclose($socket); if (!$packet) { return $server; } $header = substr($packet, 0, 4); $response_type = substr($packet, 4, 1); $network_version = ord(substr($packet, 5, 1)); $packet_array = explode("\x00", substr($packet, 6), 5); $server['name'] = $packet_array[0]; $server['map'] = $packet_array[1]; $server['game'] = $packet_array[2]; $server['description'] = $packet_array[3]; $packet = $packet_array[4]; $app_id = array_pop(unpack("S", substr($packet, 0, 2))); $server['players'] = ord(substr($packet, 2, 1)); $server['playersmax'] = ord(substr($packet, 3, 1)); $server['status'] = įjungtas; return $server; } $query = query_source("91.211.244.117:27015");tryed with <?php ?> and <php></php> tags doesnt works im getting this:
http://prntscr.com/le7mec
Link to comment
Share on other sites
10 answers to this question
Recommended Posts