Jump to content

CroNiX

Staff Alumni
  • Posts

    1,469
  • Joined

  • Last visited

  • Days Won

    12

Everything posted by CroNiX

  1. What doesn't work about it? Strange, it works here. Did you add the open/close php tags to the start/end of the script? Did you add the output that is from the very top of the 2nd code block to the very bottom of the script? When it does: $data = get_pb_data(); echo '<pre>'; print_r($data);
  2. Ah yes, apologies Psycho
  3. I was playing with a similar approach that didn't use regex except to extract the GUID status. Barands is a bit cleaner. function get_pb_data() { $pb_data = array(); $base_url = 'http://74.80.133.251/7778/'; // Retrieve main page $base_page = file_get_contents($base_url); // Exit and show error if couldn't be retrieved if ( ! $base_page) { exit('Could not retrieve main page: ' . $base_page); } // These are substring items that will be removed from each line of text of the HTML $items_to_remove = array( "\r", // hidden return chars (if present) '<p> ', // <p> tags with trailing space (note no closing </p>'s in src) '"', // Quotes around username '[', // Bracket around date/time ']', // Bracket around date/time '(W) GUID=' // (W), don't know if needed, and GUID= text ); // Remove the items from the raw page text $base_page = str_replace($items_to_remove, '', $base_page); // Create an array for each line $lines = explode("\n", $base_page); // Cycle through the lines, format the data and store it in a new array foreach($lines as $line) { // Remove the anchor tag from the line to isolate the punkbuster id ($pb_id) $line = strip_tags($line); if (substr_count($line, ' ') == 4) { // Grab the fields by exploding on spaces list($pb_id, $username, $guid, $date, $time) = explode(' ', $line); // Grab the "status" string from the GUID line within () preg_match('/\((.*?)\)/', $guid, $guid_status); // Remove the status string from the GUID line to isolate GUID $guid = str_replace($guid_status[0], '', $guid); // Replace dots with dashes in the date for a mysql valid format $date = str_replace('.', '-', $date); // Store the formatted user data. Normally would go in a db or something... $pb_data[] = array( 'id' => $pb_id, 'username' => $username, 'guid' => $guid, 'guid_status' => $guid_status[1], 'image_source' => $base_url . 'pb' . $pb_id . '.png', 'date' => $date, 'time' => $time, 'datetime' => $date . ' ' . $time ); } } return $pb_data; } output: $data = get_pb_data(); echo '<pre>'; print_r($data); -------------- Array ( [0] => Array ( [id] => 001646 [username] => -=D3G=-RotGM [guid] => 00000000000000076561198133386615 [guid_status] => VALID [image_source] => http://74.80.133.251/7778/pb001646.png [date] => 2015-06-25 [time] => 17:20:36 [datetime] => 2015-06-25 17:20:36 ) [1] => Array ( [id] => 001647 [username] => -=D3G=-Icey842 [guid] => 00000000000000076561198091035675 [guid_status] => VALID [image_source] => http://74.80.133.251/7778/pb001647.png [date] => 2015-06-25 [time] => 17:22:18 [datetime] => 2015-06-25 17:22:18 ) [2] => Array ( [id] => 001648 [username] => budsanonymous [guid] => 00000000000000076561198188792511 [guid_status] => VALID [image_source] => http://74.80.133.251/7778/pb001648.png [date] => 2015-06-25 [time] => 17:23:28 [datetime] => 2015-06-25 17:23:28 ) [3] => Array ( [id] => 001649 [username] => -=D3G=-Roosevelt [guid] => 00000000000000076561198161436214 [guid_status] => VALID [image_source] => http://74.80.133.251/7778/pb001649.png [date] => 2015-06-25 [time] => 17:23:48 [datetime] => 2015-06-25 17:23:48 ) [4] => Array ( [id] => 001650 [username] => -=D3G=-RotGM [guid] => 00000000000000076561198133386615 [guid_status] => VALID [image_source] => http://74.80.133.251/7778/pb001650.png [date] => 2015-06-25 [time] => 17:26:12 [datetime] => 2015-06-25 17:26:12 ) )
  4. It's a Microsoft IIS webserver config file. Not positive about it, but seems to prevent listing a directory when going to it in your web browser.
  5. Its not going to be easy due to all of the malformed/improper HTML of those pages. You'd start by using either CURL, or file_get_contents() and retrieve that remote page. The rest gets trickier. Normally you could use some libraries to traverse the DOM tree of the retrieved page, but this page has no document declaration, no html section, no head section, no body section, etc. It's just a straight list of <p> tags. So not sure if any of the dom traversing libraries, such as simple_html_dom, will be able to parse it. So you might be needing to use regex to get the bits you want out of each line (player name, guid, time and date) Then for each line, you'd need to also grab the href from each <a> tag, since that's where the image is located. Again, those pages are not using proper HTML markup: <p> <img src=pb001759.png> Once you can decipher the img src, you'd grab the image using, again, file_get_contents or CURL. I'd store all data in the database so it's easily sortable and you can look up things faster, like retrieving all data for a particular username.
  6. Are all of your fans turning? The 'crunch' sound could be a fan trying to start but failing.
  7. You send the request to the script that ajax would normally be submitting the login info to. It doesn't need to be an "ajax" request, unless they are specifically looking for the XMLHttpRequest header in which case you'd just need to add it to the CURL header to simulate an ajax request. Something like: curl_setopt($ch, CURLOPT_HTTPHEADER, array("X-Requested-With: XMLHttpRequest", "Content-Type: application/json; charset=utf-8"));
  8. Isn't what you are calling internal the same as private? Try calling a private method from outside the class.
×
×
  • 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.