dodgeitorelse3 Posted August 24, 2012 Share Posted August 24, 2012 I have been looking at some functions to try to learn how they work. In one of these I see \x79\x00\x00\x00\x00/\x79\x00\x00\x00\x01/\x79\x00\x00\x00\x02 what is the basic idea of what this does in general? Quote Link to comment https://forums.phpfreaks.com/topic/267520-what-does-this-stand-for-in-a-function/ Share on other sites More sharing options...
litebearer Posted August 24, 2012 Share Posted August 24, 2012 It would help if you displayed the function in which it is used. As you may have noticed, there is an incrementation of 1 for occurring; however, without seeing the actual function we cannot definitively describe what/why/how that incrementation is being used. Quote Link to comment https://forums.phpfreaks.com/topic/267520-what-does-this-stand-for-in-a-function/#findComment-1372068 Share on other sites More sharing options...
Barand Posted August 24, 2012 Share Posted August 24, 2012 \xnn = hex character code eg <?php echo "This should print a capital 'A': \x41"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/267520-what-does-this-stand-for-in-a-function/#findComment-1372074 Share on other sites More sharing options...
dodgeitorelse3 Posted August 24, 2012 Author Share Posted August 24, 2012 thank you Barand, I will read up on this. Quote Link to comment https://forums.phpfreaks.com/topic/267520-what-does-this-stand-for-in-a-function/#findComment-1372120 Share on other sites More sharing options...
MMDE Posted August 24, 2012 Share Posted August 24, 2012 thank you Barand, I will read up on this. It's the hex value of the character in the ASCII table. http://www.asciitable.com/ Quote Link to comment https://forums.phpfreaks.com/topic/267520-what-does-this-stand-for-in-a-function/#findComment-1372123 Share on other sites More sharing options...
Christian F. Posted August 24, 2012 Share Posted August 24, 2012 litebearer: That looks like the start of a connection string for a dedicated game server, or something like that. But, yeah. More context is needed to tell exactly what it is, and why it's used. Quote Link to comment https://forums.phpfreaks.com/topic/267520-what-does-this-stand-for-in-a-function/#findComment-1372164 Share on other sites More sharing options...
dodgeitorelse3 Posted August 24, 2012 Author Share Posted August 24, 2012 it is for a game server tracker . I am trying to learn what some parts of it are as I wopuld like to make a server query for our communications server. I am not afraid to learn and am somewaht capable within php but not to this extent. I have searched and searched and thanks to you guys I have been given keywords to search for and as usual, you guys know what you are looking at and talking about. below is the function I am trying to learn from. Any pointers to tutorials or whatever are greatly appreciated. function lgsl_query_09(&$server, &$lgsl_need, &$lgsl_fp) { //---------------------------------------------------------+ // SERIOUS SAM 2 RETURNS ALL PLAYER NAMES AS "Unknown Player" SO SKIP OR CONVERT ANY PLAYER REQUESTS if ($server['b']['type'] == "serioussam2") { $lgsl_need['p'] = FALSE; if (!$lgsl_need['s'] && !$lgsl_need['e']) { $lgsl_need['s'] = TRUE; } } //---------------------------------------------------------+ if ($lgsl_need['s'] || $lgsl_need['e']) { $lgsl_need['s'] = FALSE; $lgsl_need['e'] = FALSE; fwrite($lgsl_fp, "\xFE\xFD\x00\x21\x21\x21\x21\xFF\x00\x00\x00"); $buffer = fread($lgsl_fp, 4096); $buffer = substr($buffer, 5, -2); // REMOVE HEADER AND FOOTER if (!$buffer) { return FALSE; } $item = explode("\x00", $buffer); foreach ($item as $item_key => $data_key) { if ($item_key % 2) { continue; } // SKIP EVEN KEYS $data_key = strtolower($data_key); $server['e'][$data_key] = $item[$item_key+1]; } if (isset($server['e']['hostname'])) { $server['s']['name'] = $server['e']['hostname']; } if (isset($server['e']['mapname'])) { $server['s']['map'] = $server['e']['mapname']; } if (isset($server['e']['numplayers'])) { $server['s']['players'] = $server['e']['numplayers']; } if (isset($server['e']['maxplayers'])) { $server['s']['playersmax'] = $server['e']['maxplayers']; } if (isset($server['e']['password'])) { $server['s']['password'] = $server['e']['password']; } if (!empty($server['e']['gamename'])) { $server['s']['game'] = $server['e']['gamename']; } // AARMY if (!empty($server['e']['gsgamename'])) { $server['s']['game'] = $server['e']['gsgamename']; } // FEAR if (!empty($server['e']['game_id'])) { $server['s']['game'] = $server['e']['game_id']; } // BFVIETNAM if ($server['b']['type'] == "arma" || $server['b']['type'] == "arma2") { $server['s']['map'] = $server['e']['mission']; } elseif ($server['b']['type'] == "vietcong2") { $server['e']['extinfo_autobalance'] = ord($server['e']['extinfo'][18]) == 2 ? "off" : "on"; // [ 13 = Vietnam and RPG Mode 19 1b 99 9b ] [ 22 23 = Mounted MG Limit ] // [ 27 = Idle Limit ] [ 18 = Auto Balance ] [ 55 = Chat and Blind Spectator 5a 5c da dc ] } } //---------------------------------------------------------+ elseif ($lgsl_need['p']) { $lgsl_need['p'] = FALSE; fwrite($lgsl_fp, "\xFE\xFD\x00\x21\x21\x21\x21\x00\xFF\x00\x00"); $buffer = fread($lgsl_fp, 4096); $buffer = substr($buffer, 7, -1); // REMOVE HEADER / PLAYER TOTAL / FOOTER if (!$buffer) { return FALSE; } if (strpos($buffer, "\x00\x00") === FALSE) { return TRUE; } // NO PLAYERS $buffer = explode("\x00\x00",$buffer, 2); // SPLIT FIELDS FROM ITEMS $buffer[0] = str_replace("_", "", $buffer[0]); // REMOVE UNDERSCORES FROM FIELDS $buffer[0] = str_replace("player", "name", $buffer[0]); // LGSL STANDARD $field_list = explode("\x00",$buffer[0]); // SPLIT UP FIELDS $item = explode("\x00",$buffer[1]); // SPLIT UP ITEMS $item_position = 0; $item_total = count($item); $player_key = 0; do { foreach ($field_list as $field) { $server['p'][$player_key][$field] = $item[$item_position]; $item_position ++; } $player_key ++; } while ($item_position < $item_total); } //---------------------------------------------------------+ return TRUE; } //------------------------------------------------------------------------------------------------------------+ //------------------------------------------------------------------------------------------------------------+ Quote Link to comment https://forums.phpfreaks.com/topic/267520-what-does-this-stand-for-in-a-function/#findComment-1372189 Share on other sites More sharing options...
Christian F. Posted August 26, 2012 Share Posted August 26, 2012 The actual binary strings are specific to Serious Sam 2, and a description of them should be available in their official fora. That's not something we can help you with, as it requires specialized knowledge about the specific game engine. As for the rest of the code it's pretty standard socket communication, with the code sending a request to the server (fwrite ()), reading the response (fread ()), and then parsing the results to something humans can read (everything after if (!$buffer) {return false; }). The PHP manual will explain what each function does, and by stepping through the code with a debugger you can see the effects for yourself. Quote Link to comment https://forums.phpfreaks.com/topic/267520-what-does-this-stand-for-in-a-function/#findComment-1372406 Share on other sites More sharing options...
Solution dodgeitorelse3 Posted August 26, 2012 Author Solution Share Posted August 26, 2012 ty Quote Link to comment https://forums.phpfreaks.com/topic/267520-what-does-this-stand-for-in-a-function/#findComment-1372469 Share on other sites More sharing options...
Christian F. Posted August 26, 2012 Share Posted August 26, 2012 You're most welcome, glad I could help. Quote Link to comment https://forums.phpfreaks.com/topic/267520-what-does-this-stand-for-in-a-function/#findComment-1372470 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.