file-get-contents

Broken image with readfile and file_get_contents

ε祈祈猫儿з 提交于 2019-12-29 07:47:13
问题 I'm trying to use a function in order to get this working: <img src='login.php?image=ind_legend.jpg'> But I can't pass through the function to place the image. I went back a couple of steps and tried only this part of the code: <?php $file = "http://localhost/sales/test.jpg"; header('Content-type: image/jpeg'); readfile($file); ?> or using this function: echo file_get_contents($source); but the fact is that the only thing I get is a broken image cross (IE) or nothing in Firefox. I would

PHP file_get_contents Maximum execution time exceeded (Cause of emotes?)

这一生的挚爱 提交于 2019-12-25 04:22:55
问题 I started messing around with the Steam API a bit ago, and I made a simple site showing profile information using the GetPlayerSummaries method. It's been working great, right until some of my friends started adding iOS emotes in their name, which causes the following: Fatal error : Maximum execution time of 300 seconds exceeded in file on line 137 This is what's on that line in the file: public function getPlayerSummary($steamid) { $contents = file_get_contents( "http://api.steampowered.com

Checking a string against a pattern

人盡茶涼 提交于 2019-12-25 02:42:50
问题 I want to check posted content against a pattern. I am having trouble setting up this preg_match (or array?). The pattern being... TEXTHERE:TEXTHERE TEST:TEST FILE:FILE AND TEXTHERE:TEXTHERE TEST:TEST FILE:FILE I want to check for either pattern, the one with the whitespace and the one with the line break. If the posted content is this... (with extra line breaks and/or whitespace) TEXTHERE:TEXTHERE TEST:TEST FILE:FILE I want it to somehow display as... TEXTHERE:TEXTHERE TEST:TEST FILE:FILE

PHP file_get_contents returns other web page than I see in my browser

匆匆过客 提交于 2019-12-24 17:13:18
问题 I'm trying to load a website into a variable. But if I run my code, it returns an other page than I see in my browser. Here's my code: $query = $_GET['q']; $url = 'https://www.google.com/search?q='.str_replace(' ','+',$query); $doc = file_get_contents($url, false, $context); echo $doc; I see a (I guess older and) other version of Google in my website then when I go to Google's website itsself. Can anyone help me? Edit Here are some screenshots: This is my websiteThis is Google To be more

How to block curl or file_get_contents

心不动则不痛 提交于 2019-12-24 13:08:13
问题 How can I disallow someone from using curl or file_get_contents to get my page HTML? For example, my domain is www.example.com . If someone has PHP code like this: <?php $info = file_get_contents('http://www.example.com/theinfo.php'); ?> how can I block them? I can try to check by the user agent, but that’s not the right way. What is the best way to check when someone is trying to get the page content? What I built contains information that many will try to copy to their own websites, and it

file_get_contents jpg corrupt download

心已入冬 提交于 2019-12-24 07:31:06
问题 I am downloading this photo using function: file_get_contents(), and it seems to be corrupted. But original photo looks fine. Original photo: original photo Downloaded photo: Download photo Code: $current = file_get_contents($image); $name = '/tmp/img/' . uniqid().".jpg"; file_put_contents($name, $current); $tmpImages[] = $name; 回答1: Try this. function savephoto($urlpath,$savepath) { //Download images from url $in = fopen($urlpath, "rb"); $out = fopen($savepath, "wb"); while ($chunk = fread(

file_get_contents fails with “getaddrinfo failed: no address associated with hostname”

こ雲淡風輕ζ 提交于 2019-12-24 03:28:02
问题 I'm trying to get the page from another host. I do as hph manual says: $page = file_get_contents('http://www.example.com/'); echo $page; But it fails and in apache log i get the following: [Mon Oct 12 18:58:47.676454 2015] [:error] [pid 2971] [client 127.0.0.1:49434] PHP Warning: file_get_contents(): php_network_getaddresses: getaddrinfo failed: No address associated with hostname in /var/www/html/digest/ftry.php on line 2 [Mon Oct 12 18:58:47.704659 2015] [:error] [pid 2971] [client 127.0.0

PHP - Download file and preserve timestamp?

帅比萌擦擦* 提交于 2019-12-24 01:19:48
问题 As the name suggests, is there a quick way to download a file, but bring the timestamp along? I'm writing a basic cache that, among other checks, determines (via get_headers ) if a given local file is the same as it's remote counterpart. I know I can file_get_contents / file_put_contents and then touch() the file with the results of get_headers , but the calling that is making another HTTP call (even if it is a HEAD call) and I'd only like to test Last-Modified as a last resort. So is there a

char limit with php file_get_contents() and Google Chart API?

孤街醉人 提交于 2019-12-24 00:24:15
问题 the specific issue I am working on is enabling https with Google charts API, and a possible character limit when using php file_get_contents on a url string. Let me take you through what is going on. I have made good progress using some tutorials on the net, specifically to enable the https. I am using their 'basic method' from this tutorial: http://webguru.org/2009/11/09/php/how-to-use-google-charts-api-in-your-secure-https-webpage/ I have a chart.php file with this code in it: <?php $url =

file_get_contents returns 404 when URL is opened with the Browser and URL is valid

五迷三道 提交于 2019-12-23 17:08:21
问题 I get the following Error: Warning: file_get_contents(https://www.readability.com/api/content/v1/parser?url=http://www.redmondpie.com/ps1-and-ps2-games-will-be-playable-on-playstation-4-very-soon/?utm_source=dlvr.it&utm_medium=twitter&token=MYAPIKEY) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.1 404 NOT FOUND in /home/DIR/htdocs/readability.php on line 23 With some Echoes I got the URL parsed by the function and it is fine and valid, I do the request from