Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Index: class-admin.php
- ===================================================================
- --- class-admin.php (revision 670456)
- +++ class-admin.php (working copy)
- @@ -191,7 +191,8 @@
- <tr valign="top"><th scope="row"><label for="language">Language</label></th>
- <td><?php
- $dom_object = new DOMDocument();
- - $dom_object->load("http://www.facebook.com/translations/FacebookLocales.xml");
- + $content = fbcomments_remote_http_get("http://www.facebook.com/translations/FacebookLocales.xml");
- + $dom_object->loadXML( str_replace("<?xml version='1.0'?>", '', $content) );
- $langfeed = $dom_object->getElementsByTagName("locale");
- echo '<select name="fbcomments[language]">';
- @@ -353,4 +354,65 @@
- <?php
- }
- +
- +function fbcomments_remote_http_get($url) {
- + $url_stuff = parse_url($url);
- + $port = isset($url_stuff['port']) ? $url_stuff['port'] : 80;
- + $fp = fsockopen($url_stuff['host'], $port);
- +
- + if (!$fp) {
- + return false;
- + }
- + $query = 'GET '.$url_stuff['path'].'?'.$url_stuff['query']." HTTP/1.1\r\n";
- + $query .= 'Host: '.$url_stuff['host']."\r\n";
- + $query .= 'Connection: close'."\r\n";
- + $query .= 'Cache-Control: no'."\r\n";
- + $query .= 'Accept-Ranges: bytes'."\r\n";
- + //$query .= 'Referer: http:/...'."\r\n";
- + //$query .= 'User-Agent: myphp'."\r\n";
- + $query .= "\r\n";
- +
- + fwrite($fp, $query);
- +
- + $chunksize = 1*(1024*1024);
- + $headersfound = false;
- + $buffer = '';
- +
- + while (!feof($fp) && !$headersfound) {
- + $buffer .= fread($fp, 1);
- + if (preg_match('/HTTP\/[0-9]\.[0-9][ ]+([0-9]{3}).*\r\n/', $buffer, $matches)) {
- + $headers['HTTP'] = $matches[1];
- + $buffer = '';
- + }
- + elseif (preg_match('/([^:][A-Za-z_-]+):[ ]+(.*)\r\n/', $buffer, $matches)) {
- + $headers[$matches[1]] = $matches[2];
- + $buffer = '';
- + }
- + elseif (preg_match('/^\r\n/', $buffer)) {
- + $headersfound = true;
- + $buffer = '';
- + }
- +
- + if (strlen($buffer) >= $chunksize) {
- + return false;
- + }
- + }
- +
- + if (preg_match('/4[0-9]{2}/', $headers['HTTP'])) {
- + return false;
- + }
- + elseif (preg_match('/3[0-9]{2}/', $headers['HTTP']) && !empty($headers['Location'])) {
- + $url = $headers['Location'];
- + return _fifingerprint_remote_http_get($url, $range);
- + }
- + $_content = array();
- + while (!feof($fp) && $headersfound) {
- + $buffer = fread($fp, $chunksize);
- + $_content[] = $buffer;
- + }
- + $status = fclose($fp);
- +
- + return join("\n", $_content);
- +}
- +
- ?>
- \ No newline at end of file
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement