PHP error reading remote file - file

When I try to do a file('http://somewebsite.com') i get an error
"URL file-access is disabled in the server configuration"
I tried using ini_set('allow_url_fopen', 'On'); but that didn't work.
I'm using shared hosting. Any suggestions?
All I want to do is read the html source code of a website.

On php version>4.3.4 and <6, you can't set allow_url_fopen in your script. Try using curl instead.

If your hosting allows and reads custom .htaccess files, try putting the following line to a .htaccess at the root of your project:
php_flag allow_url_fopen on
and see if it has an effect...

Related

save pdf on server fpdf

I am generating a pdf with fpdf in cakephp and I try to save it on the server.
I do it like this :
$fpdf->Output("D:/Files/mypdf.pdf",'F');
but it doesn't save.
I think it doesn't find the folder, but I don't know how specified it?
I have put the all the right on the folder.
I don't know if it is a cakephp restriction or just my directory?
Try this
$fpdf->Output(WWW_ROOT."files\mypdf.pdf", 'F');
As this code works fine locally, it's probably server-problem.
(1) Are you sure you can create files? Most free servers disallow creating files.
(2) Have you tried it with different location e.g. the current root location $fpdf->Output("mypdf.pdf",'F')
Anyway, you should enable error reporting in your index.php. If it was matter of directory not found you would get this result:
Warning (2): fopen(D:/Files/mypdf.pdf): failed to open stream: No such file or directory [ROOT\vendor\fpdf\fpdf.php, line 1025]
FPDF error: Unable to create output file: D:/Files/mypdf.pdf
Just a wild guess but change the slashes to windows style.
$fpdf->Output("D:\Files\mypdf.pdf",'F');
or even
$fpdf->Output("D:\\Files\\mypdf.pdf",'F');

Apache2 configuration issue - Avoid file accessing without extension

I'm developing a website and having development environment as Ubuntu 14.04, PHP 5.5.9, Apache 2.4.7. My issue is if some want accessing a file like http://domain.com/robots(without extension) then I should avoid but I've to allow if some tries to access http://domain.com/robots.txt(with extension).
Now in both ways I'm able to access files, I want to avoid this when user haven't given extension of the file using .htaccess or apache configuration file.
My previous environment was Apache 2.2 and PHP 5.3.10 at the time with default Apache configuration it was working as expected but after upgrade its not working as expected and due lack of knowledge on Apache configuration I'm unable to pick those lines of code.
Add following line in .htaccess
Options -Multiviews

Code to be executed before every page on server

I have an apache2 server, it has a vast and growing folder structure.
There is a set of instructions I would like to be executed at the beginning of every page in that website.
How do I implement that without pasting those very lines at the beginning of every file in the website?
I don't want to have the code at the beginning of every file.
I have tried changing the auto_prepend_file in php.ini to:
auto_prepend_file = ~/website_preview/say_hello.php
'say_hello' is a hello-world php script, but the script does still not get executed at all.
Wrong php.ini file, correct location is /etc/php5/apache2/php.ini
If all of your pages are in PHP, then I think you were on the right path with setting up auto_prepend_file in php.ini.
Try this:
Check your include_path in php.ini and if needed append a new path to it for your instructions file.
Copy your instructions.php file to the location from the include path.
Edit your auto_prepend_file in php.ini to be just the filename from step 2.
I tested this out and was able to get it working that way but had trouble specifying the path directly in the auto_prepend_file setting.
Also, when I had the auto_prepend_file setting configured improperly I received the following php error:
PHP Fatal error: Unknown: Failed opening required ...
Hope that helps.

Ushahidi No Input File Specified

I have been trying to install Ushahidi platform for weeks but without any luck. I recently started over using Ushahidi latest release ushahidi-Ushahidi_Web-2.0.1-140-g0991172.zip and extracted it to folder ushahidi under my root.
I am using godaddy Linux server. I have tried both the manual and wizard to setup Ushahidi. In all cases, after installation, I get the same error when I try to access admin page. The error reads:
No input file specified.
I have tried tried installing using the wizard and the manual process. My PHP version is as required.
Any help will be appreciated. I need it to work so I can move on and customize it. Very disappointing such a good open source tool has poor installation guides!
Thanks.
Sting
there are a few things that can trip up following the installation.
Make sure that:
mod_rewrite is turned on in apache "a2enmod rewrite"
AllowOverride All is set in your apache config for your site (/etc/apache2/sites-available/default)
your .htaccess file points to the correct webroot

apache2 .htm extension

Since I've installed LAMP stack on ubuntu server with apache2, I've been having a weird issue. Whenever I create a file called filename.html, it renders and displays on browser fine. But whenever I create file with extension .htm, it will prompt the browser (firefox) to save the file.
I've already looked into /etc/mime.types and /etc/apache2/mod-enabled/mime.load
And what's in these files for .htm extension?
Can you check what mime-type returned by the Apache? (via browser plugins/sniffer)
After that you will see the issue...

Resources