Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function endswith( $str, $sub ) {
- // Lets me quickly check if something ends with something else.
- return ( substr( $str, strlen( $str ) - strlen( $sub ) ) == $sub );
- }
- function ParseMember($keyname) {
- // This is a dumbed-down rewrite of the hub data loader written by the Tibbius team. - Nadrew
- // Member data isn't near as complicated as hub data so we don't need all the extra parsing.
- // The full version we use handles member pages too, but it's a bit clunky if you're not going for game data too.
- $url = "http://byond.com/members/" . $keyname . "?format=text&long=1"; // Get the long (sans medals) of the user's data.
- // You can add medals too it as well, of course.
- // TODO: Add error checking in case an invalid key is passed.
- $return_data = array();
- $page_data = file_get_contents($url);
- $main_array = explode("\n",$page_data); // Split the website data up by newlines first.
- $header = null;
- foreach($main_array as $data) {
- $data = trim($data);
- if(!$data) continue;
- if(!strpos($data,"=")) {
- // If the data doesn't have an equals sign it's a header.
- $header = $data;
- $return_data[$header] = array();
- }
- else {
- // Otherwise, it's a sub-item.
- $data_array = explode("=",$data); // An array that splits the variable name from the variable value.
- $subheader = trim($data_array[0]);
- $value = str_replace("\"","",trim($data_array[1]));
- $is_list = strpos($value,"list("); // Handles if the value is a list()
- if($is_list !== false) {
- // By turning it into an array()
- $list_start = $is_list + 5;
- $list_end = strpos($value,")");
- $list_text = substr($value,$list_start,$list_end-$list_start);
- $value = explode(",",$list_text);
- }
- $return_data[$header][$subheader] = $value;
- }
- }
- return $return_data;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement