How to run php script on localhost stored on another server - php

I want to run php script from another server on localhost I tried include "http://example.com/settings/aiacacc.php"; but I'm getting an error.
include(): http:// wrapper is disabled in the server configuration by allow_url_include=0
How can I enable include from another server using php.ini file. I know it is not a good practice but my application is going run on localhost only. i don't want this setting to be disabled.
I want to return a php script from another server and then execute this script on my localhost

Go to your php.ini file and edit it to switch on the allow_url_include setting:
; Whether to allow include/require to open URLs (like http:// or ftp://) as files.
; http://php.net/allow-url-include
allow_url_include = On
Alternatively use the code below in your php file
ini_set('allow_url_include', 'On');

In php.ini:
allow_url_include=1

As you mentioned above. you want to return some PHP code from another server and execute it on the localhost. For that the first step is to edit your php.ini file and add this line allow_url_include = On and secondly the php script that you want to return from another server should not have .php extension instead It should be saved as a simple text file with .txt extension

Related

How to fix PHP Deprecated Automatically populating $HTTP_RAW_POST_DATA is deprecated issue?

hello i'm getting this error in my error log:
"PHP Deprecated: Automatically populating $HTTP_RAW_POST_DATA is deprecated and will be removed in a future version. To avoid this warning set 'always_populate_raw_post_data' to '-1' in php.ini and use the php://input stream instead. in Unknown on line 0"
My wordpress version is 4.8.1 and the php version is 5.6.30.
I tried fixing the issue by creating a php ini file and setting always_populate_raw_post_data value to -1. But i still get the error.
If it cannot be fixed, how can i prevent it prints on the error log?
I'm using a shared hosting.
how can i prevent it prints on the error log?
Your problem here is not that you cannot access php.ini and it is not that error shows.
Your problem, in fact, is that you use deprecated variable
instead, you could try using
file_get_contents('php://input');
php.ini is located somewhere in the php files on the server, which I assume you have no access to on shared hosting.
The php.ini file you created needs to be located where PHP expects to find its config files. You can see the configs which PHP is already loading using the phpinfo() function:
Upload a file named info.php with the following contents to your web server root:
<?php
// delete this file or comment out the below function when not in use
phpinfo();
?>
Then use a browser to navigate to http://yourwebsite.com/info.php. A page should load which tells you all about your php configuration. Look for the part near the top which shows information about the loaded configuration files. In particular, look for these entries:
"Loaded Configuration File" and "Scan this dir for additional .ini files".
If you have access to the .ini file listed as the Loaded Configuration File simply modify the value for always_populate_raw_post_data there. Otherwise, upload the .ini file you already created to the directory that is scanned for additional configuration files. Of course, you'll need to reload or restart php in order to reparse the configuration files.
If you don't have access to any of the locations listed from the above steps, it's possible your hosting provider may give you access to your php.ini file through cPanel or a similar means. Otherwise, your best bet is to contact them directly.
Finally, if you don't care about the actual configuration value as much as just suppressing the warning message, you could use the ini_set() function to set your error reporting to a different value, eliminating any deprecation warnings. The variable you want to set is "error_reporting" and a list of possible values can be found here.
In addition, since you are running WordPress there are some debug and error reporting options you can set in the wp-config.php file.
If your Account (on the shared hosting) using (or Configured) PHP-FPM, you can't do it via php.ini (if you create php.ini in your root, it will have no effect)
you can try: add this code
<IfModule mod_php5.c>
php_value always_populate_raw_post_data -1
</IfModule>
in your .htaccess file in your root directory, if not helps then ask the server admin (support) to change that in core php.ini globally for the given host.
You cant create a PHP.ini just like that. This is a core config file that is part of the PHP install. http://php.net/manual/en/configuration.file.php Read over this documentation to get a better idea of what the ini does.
The ini file could be located in multiple places depending on the OS and who installed it. If you do not have access to it, talk to your hosting provider

PHP upload limit (Webmatrix)

I changed the php upload limit in the php.ini file, but it didn't take effect.
I'm using MS Webmatrix on a local machine, and restarted it if that matters.
I'm not sure what to do?
Could you double check the location of the php.ini file used?
Run the following code:
phpinfo();
This will give you the PHP settings.
On the 9th row the ini location should be printed (Loaded Configuration File)
If the file path is correct, please share the actual error you are getting.
I ran phpinfo(); then discovered that another version of php was actually being used.
So, I edited the right php.ini file, which was in a different location.
After restarting WebMatrix, everything worked as expected.

php include issue - works on one server... not another.. init file?

php "includes" are working fine on my current production server/site. (shared server)
I am moving this site to a new server and "includes" do not work. Error message:
Warning: include() [function.include]: URL file-access is disabled in the server configuration in /home/xxxxx/public_html/publications/abss/myfile.php on line 140
In control panel I can set php version from 5.2 to 5.6 and generate init file. When I look at init file I find no "include" option to enable.
Questions:
Why is there no enable option in php.ini file? (I tried both 5.2 and 5.6 versions) Can I manually enter?
Does the php.ini file run each time a page is rendered?
How do I know if php.ini is actually in effect?
Thank you very much.
First of all check
phpinfo()
to see allow_url_fopen" and "allow_url_include" are ON
If not, you need to set them on OR contact your webmaster or hosting provider to enable allow_url_fopen and allow_url_include in the PHP server configuration.
I had tryed "allow_url_include" on but didn't work.
However, when I copied my init file from the old server to the new it worked fine. Not sure why. Didn't do a file compare.

I am including a phar file (goutte.phar) in my php application. When I try to hit the url I get Connection to the server was reset error

Is there any specific settings in php.ini that I need to change to allow the server to include the file?
require_once dirname(dirname(__FILE__)).'/unleashapi/protected/extensions/goutte.phar';
You can set in php.ini auto_prepend_file:
auto_prepend_file="/custom/path/unleashapi/protected/extensions/goutte.phar"
make sure Apache has access to that file.
If you server is using suhosin (typically Debian and all Debian based distributions), you should add : suhosin.executor.include.whitelist="phar" to your php.ini

php.ini not working in IIS?

I've set magic_quotes_gpc = Off in php.ini,but I see it's still On in phpinfo();
First of all, you must be sure you modified the right php.ini file : there can be many files called php.ini -- and only one is "the right one".
You can see which php.ini file is used in the output of phpinfo() : there should be an entry called Configuration File (php.ini) Path that indicates the directory in which php.ini is looked for, and an entry called Loaded Configuration File that indicates the full path+name of the php.ini file that's used.
Then : don't forget to restart the webserver, so the modifications to php.ini are taken into account (Not sure that's necessary with IIS, but as it's required with Apache, I suppose it cannot hurt with IIS)
If that doesn't change a thing : what if you try to modify another directive : is the modification taken into account ?
As an alternative, you can disable it from your script too:
// disable magic_quotes_runtime
if (get_magic_quotes_runtime())
{
#set_magic_quotes_runtime(0);
}
You can check the php.ini file that was loaded via the php_ini_loaded_file function. Restart your web server.
On my installation the c:\php\php.ini file was named php ini. So phpmyinfo() was not loading it, despite the PATH environment variable including C:\php\. (Check this in a DOS prompt with SET PATH).
So rename it to php.ini.
It was difficult to spot in Windows Explorer.

Categories