PHP Copy, failed to open stream: Connection refused - php

i am trying to copy a image, it is hosted here, this is just an example:
http://111.74.239.161:8898/uploads/allimg/130821/2-130R1100341.jpg
I want to copy the image, but i keep getting connection refused. What could be the root of this error ?
What strikes me as odd is that its using port 8898 ?

If you can view the image in a browser that is on the same machine as your program, then it might be that the server won't send the picture unless you look like a user rather than a program. In that case, modifying the browser identification string might fix your problem.
If you cannot view the image from a browser running on the program's PC, you will need to look elsewhere for the source of your problem.

Related

How to allow my PHP app to write to a file on my AWS?

I have a codeigniter app that grabes and then pushes data from one database to another. This process takes a large amount of time, and I want to update my user of what files are being queried and pushed. I decided that the best solution was to write the progress messages to a txt file and have my front-end page (index.php) use ajax to send a request for the message by fetching it. I use a session to create a unique session token and use that to create the name of the txt file. This way, no two users will get each other's messages.
I managed to get this working on localhost, but the problem now is how I get it to work on my live server with the proper permissions. I uploaded the code to my server and received this error when trying to run:
Severity: Warning Message:
file_put_contents(application/tmp/d9jf9d9f9jdd9jfd09u09dj0sjf9s0.txt): failed to open stream:
Permission denied
On localhost, I chmodded the application/tmp directory, so this wasn't a problem, but I can't seem to do this on the AWS live server, at least, not permanently (also a bad practice, I hear). Is there an alternative solution to this problem?

phpsdk_deps returns fatal error on windows

To compile PHP 7.1.X on Windows I use steps written here:
https://wiki.php.net/internals/windows/stepbystepbuild_sdk_2
When I try to update dependencies with following command:
phpsdk_deps -u
I get following error:
D:\php-sdk2\php-sdk-binary-tools\phpdev\vc14\x64_71_2\php-7.1.15-src
$ phpsdk_deps -u
Fatal error: Uncaught SDK\Exception: Failed to fetch supported
branches
This is happening for almost two weeks now.
You're having network trouble.
If you open up the Config.php file at this line, you'll see that the Config tries to load the URI https://windows.php.net/downloads/php-sdk/deps/series/, and pick the correct txt file from there, in order to download the right dependencies. The exception you get means that this cannot be properly fetched.
The solution in my case was to use the company proxy (command line wasn't using it, so it cannot properly resolve & reach the above URL, and so the Config.php gets an empty response). How to do so might change depending on the network settings you use. In my case, I simply visited the URL above in Firefox (which is properly configured by the company), opened up the network pannel, get the IP of the website from there (which is actually the IP of the proxy Firefox was told to use by the company settings), and add the IP hostname entry in my host file (C:\Windows\System32\Drivers\etc\host) so it looks like 10.1.2.3 windows.php.net
Then I rerun the Config script, and boom, it managed to retrieve the txt files and the dependencies.
Another solution can be to retrieve all the dependencies listed in the txt file that corresponds to your setup, but it's a bit tedious...

why I have file_get_content warning

I used file_get_content() to read from the uploaded image temp file and store in database.
Everything is work fine except this warning. It show every page of my site. And there is no such page "footer.php". Is it the server problem or I need to change that function.
Warning:
file_get_contents(http://admanager.nethosting.com/getads/www.mogoke.5gbfree.com/):
failed to open stream: Connection timed out in
/usr/share/php/footer.php on line 11
The problem is another invocation of file_get_contents, which downloads advertisements from a remote server, but that download fails due to network problems or a firewall.
This looks very much like your code or server had a security vulnerability and someone uploaded code that includes ad banners on your website (but the money for the clicks of course goes to the crooks instead of you). Removing the malware (i.e. the added advertisement lines, probably heavily obfuscated) should suffice. See this security.stackexchange.com question for more details.

FTP fopen() error 550—not a plain file

Well, this is a problem I have never seen before.
I am trying to stream an FTP file using PHP's fopen() and feof() in order to copy it from one server to my own. This works fine when using normal http:// URLs. However, when using the ftp:// protocol, I'm receiving the following error:
fopen(ftp://.../streaming/planted2.mp4) [0function.fopen0]: failed to open stream: FTP server reports 550 /streaming/planted2.mp4: not a plain file.
Bear in mind that I have confirmed the URL is correct.
If I pop it into my browser's search bar, it always loads correctly.
Following this error, any attempt to use feof() or fread() on the wrapper results in an error complaining that the respective function expects a resource, but that instead a boolean is being provided. This would not be the case if fopen() was not failing.
As the files are quite large (several gigabytes at times) streaming is mandatory. Also, due to the configuration of the server, I need a way to loop through each chunk in order to buffer some output. If I don't, the server holds up. It's a weird configuration on Rackspace's behalf. That's why I'm using feof().
So, without further ado, my question is this: What does the 550 error mean, and what is a "plain file"? If it is a problem with the configuration of the server I am attempting to download from, what are my options, given my limitations?
EDIT
I have determined this is a server issue. However, the problem is still unresolved.
I contacted my boss and our server administrator, and the server guy told me to test this out on a different Windows-based server instead of the Linux-based one I was playing with. My script works with the Windows server, so I have confirmed my script is not in error.
Unfortunately, my boss still wants me to figure out the problem, and find out why it's not working on the Linux box. I have absolutely no idea why, and don't know where to look. Any hints would be greatly appreciated!
I've just come across this issue when trying to get a file from a sco unix server.
Server File Location: /home/user/data/myfile.csv
I can put the below into any browser and it gets the file.
ftp://user:password#host/data/myfile.csv
However if I run the below, I get the same error as you
$f = fopen("ftp://user:password#host/data/myfile.csv", "r");
However, if I put the full path into fopen - it works fine.
$f = fopen("ftp://user:password#host/home/user/data/myfile.csv", "r");
I'm not sure if this will fix it for you, but works for me.

Using FPDF - not working on XP laptop

I'm trying to use FPDF on my server and part of that is downloading an image file that is placed in the PDF. The code is working perfectly on one machine and a server, however when using another XP laptop I'm getting these error messages.
Warning: imagecreatefromgif(): php_network_getaddresses: getaddrinfo failed: NO such host is known in C:\wamp\www\fpdf.php
FPDF Error: Missing or incorrect image file:http://www.personal.psu.edu/rdl5038/dino.gif
I have tried changing the image to an image that is stored locally on the machine and this works fine. As soon as I try an external link it fails. I have checked the php ini for the allow_url and this is turned on. REally stuck as there seems to be a security problem somewhere. Could it be something to do with access rights / read/write as the laptop is pretty locked down (work one - financial services)
You could try using cURL or another system to download to a temp file and uses it with FPDF.

Categories