file-get-contents

PHP file_get_contents / CURL not returning full page

╄→尐↘猪︶ㄣ 提交于 2019-12-10 17:22:11
问题 I'm geting some strange behaviour trying to pull 3rd party file contents using CURL or file_get_contents, pasrt of the page is read, but it stops at a random position... no error though (timeout etc). Probably easiest to see if I give the full example!: Using the following very bsic script to read a full URL and return the contents works just fine, with the full content of the page (less some external css etc) in a mater of a second or two: <?php set_time_limit(180); $page = file_get_contents

Is it possible to break CSRF token validation using file_get_contents in PHP

℡╲_俬逩灬. 提交于 2019-12-10 15:56:55
问题 The CSRF prevention method of using a token on the form for each session is a popular way. However, I don't get how this token way can protect if the file_get_contents of PHP can get contents of cross domain file form --> it can get the token on the form and use it also. So how does this token way work? 回答1: If I understand your question well, you are imagining a possible exploit like this : Attacker creates a PHP page that will present a fake form to a target user Attacker's PHP script will

How to read a text file and search for a certain string before a colon and then show the content after the colon?

独自空忆成欢 提交于 2019-12-10 14:05:50
问题 I have a file that contains something like this: test:fOwimWPu0eSaNR8 test2:vogAqsfXpKzCfGr I would like to be able to search the file for say test and it set the string after the : to a variable so it can be displayed, used etc. Here is the code I have so far for finding 'test' in the file. $file = 'file.txt'; $string = 'test'; $searchFile = file_get_contents($file); if (preg_match('/\\b'.$string.'\\b/', $searchFile)) { echo 'true'; // Find String } else { echo 'false'; } How would I go

Read and parse contents of very large file [duplicate]

ぃ、小莉子 提交于 2019-12-10 12:53:10
问题 This question already has answers here : Least memory intensive way to read a file in PHP (5 answers) Closed 6 years ago . I am trying to parse a tab delimited file that is ~1GB in size. Where I run the script i get: Fatal error: Allowed memory size of 1895825408 bytes exhausted (tried to allocate 1029206974 bytes) ... My script at the moment is just: $file = file_get_contents('allCountries.txt') ; $file = str_replace(array("\r\n", "\t"), array("[NEW*LINE]", "[tAbul*Ator]"), $file) ; I have

Unable to file_get_contents or cURL via HTTPS

别来无恙 提交于 2019-12-10 12:39:22
问题 I have been using file_get_contents to grab the contents of a site for years. Recently, they updated their URL to HTTPS and file_get_contents stopped working. I've read previous questions and tried marked solutions, but nothing has worked. For example, I tried this, and it returned the following: openssl: yes http wrapper: yes https wrapper: yes wrappers: array ( 0 => 'https', 1 => 'ftps', 2 => 'compress.zlib', 3 => 'compress.bzip2', 4 => 'php', 5 => 'file', 6 => 'data', 7 => 'http', 8 =>

Get specific html content from other site with PHP

こ雲淡風輕ζ 提交于 2019-12-10 12:25:36
问题 I want to try and get the latest movie I checked on the IcheckMovies site and display it on my website. I don't know how, I've read about php_get_contents() and then getting an element but the specific element I want is rather deep in the DOM-structure. Its in a div in a div in a list in a ... So, this is the link I want to get my content from: http://www.icheckmovies.com/profiles/robinwatchesmovies and I want to get the first title of the movie in the list. Thanks so much in advance! EDIT:

create php cache with file_get_contents

可紊 提交于 2019-12-10 12:04:37
问题 I am trying to create a cache file from a menu that takes random data called 'includes/menu.php' the random data is created when I run that file manually, it works. Now I want to cache this data into a file for a certain amount of time and then recache it. I am running into 2 problems, from my code cache is created, but it caches the full php page, it does not cache the result, only the code without executing it. What am I doing wrong ? Here is what I have until now : <?php $cache_file =

Why does php's file_get_contents incorrectly retrieve json files from xkcd?

依然范特西╮ 提交于 2019-12-10 11:49:46
问题 In writing a PHP script to download xkcd comics, i incurred errors when trying to get specific comics (as opposed to the latest one). Specifically, pointing file_get_contents at the following url: xkcd.com/$COMIC_NUM/info.0.json inexplicably retrieved the xhtml version of the comic's page on xkcd.com, and not a JSON file. However, if i request the exact same url in my browser, the correct JSON file is downloaded. I'm not sure why this is happening, but i suspect it has something to do with

File_get_contents() not working when the get url redirects

被刻印的时光 ゝ 提交于 2019-12-10 11:42:32
问题 The function I am using is: function http_post ($url, $data) { $data_url = http_build_query ($data); $data_len = strlen ($data_url); date_default_timezone_set('America/New_York'); return array ('content'=>file_get_contents ($url, false , stream_context_create (array ('http'=>array ( 'method'=>'GET', 'header'=>"Connection: close\r\nContent-Length: $data_len\r\nContent-type: application/x-www-form-urlencoded\r\n", 'content'=>$data_url )))), 'headers'=>$http_response_header ); } And the call is:

reCaptcha file_get_contents(): SSL operation failed

偶尔善良 提交于 2019-12-10 07:14:19
问题 I'm using Google reCaptcha for my webpage. In testing mode everything works fine. No SSL. When I test my webpage in production environment the following errors occures: Warning : file_get_contents(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed in /vendor/google/recaptcha/src/ReCaptcha/RequestMethod/Post.php on line 68 Warning : file_get_contents(): Failed to enable crypto in /vendor/google