require_once() using a url, how do I enable it in the server
Moderator: General Moderators
-
PHPHelpNeeded
- Forum Commoner
- Posts: 83
- Joined: Mon Nov 17, 2014 8:03 pm
require_once() using a url, how do I enable it in the server
Hi,
NOTE: for the domain, in this help support forum I wrote 00.00.00.00 because I dont' want to give away my ip, I hope that's ok.
But I was hoping i can get help for these two errors I am getting:
---------------------------------
[24-Nov-2014 12:23:32 America/New_York] PHP Warning: require_once(): http:// wrapper is disabled in the server configuration by allow_url_include=0 in %WinDir%:\Eclipse_Projects\PHP_Project1\Client\Login\LoginAuth.php on line 7
[24-Nov-2014 12:23:32 America/New_York] PHP Warning: require_once(http://00.00.00.00/Server/Libraries/ServerPackage.php): failed to open stream: no suitable wrapper could be found in %WinDir%\Eclipse_Projects\PHP_Project1\Client\Login\LoginAuth.php on line 7
--------------------------------
I was trying to use a require_once with an URL but it says that I need to enable that at the server.
I am using IIS, is it referring to IIS as the server or what?
NOTE: for the domain, in this help support forum I wrote 00.00.00.00 because I dont' want to give away my ip, I hope that's ok.
But I was hoping i can get help for these two errors I am getting:
---------------------------------
[24-Nov-2014 12:23:32 America/New_York] PHP Warning: require_once(): http:// wrapper is disabled in the server configuration by allow_url_include=0 in %WinDir%:\Eclipse_Projects\PHP_Project1\Client\Login\LoginAuth.php on line 7
[24-Nov-2014 12:23:32 America/New_York] PHP Warning: require_once(http://00.00.00.00/Server/Libraries/ServerPackage.php): failed to open stream: no suitable wrapper could be found in %WinDir%\Eclipse_Projects\PHP_Project1\Client\Login\LoginAuth.php on line 7
--------------------------------
I was trying to use a require_once with an URL but it says that I need to enable that at the server.
I am using IIS, is it referring to IIS as the server or what?
Re: require_once() using a url, how do I enable it in the se
http://php.net/manual/en/function.include.php
As the error suggests, you can enable this behaviour by changing allow_url_fopen and allow_url_include. However, this is a bad, bad, bad idea. Why are you doing it this way? What is the goal here?I was trying to use a require_once with an URL
-
PHPHelpNeeded
- Forum Commoner
- Posts: 83
- Joined: Mon Nov 17, 2014 8:03 pm
Re: require_once() using a url, how do I enable it in the se
I am running iis, and therefore, the PHP server is not located at another computer that is not my server computer (which is my desktop), therefore, if I try to include or require the file from the root directory, it will not find it, for example, If I were to run the php file at another computer like laptop or from another computer not connect to the private network.Celauran wrote:http://php.net/manual/en/function.include.php
However, this is a bad, bad, bad idea. Why are you doing it this way? What is the goal here?
Any ideas as to how I can do this?
Re: require_once() using a url, how do I enable it in the se
You can't. The PHP file needs to be run on the same machine as the web server, and that needs to be accessible across the network.If I were to run the php file at another computer like laptop or from another computer not connect to the private network.
-
PHPHelpNeeded
- Forum Commoner
- Posts: 83
- Joined: Mon Nov 17, 2014 8:03 pm
Re: require_once() using a url, how do I enable it in the se
Ok you mean, the web server has to be accessed across the network?Celauran wrote:You can't. The PHP file needs to be run on the same machine as the web server, and that needs to be accessible across the network.
How do you do that with IIS?
Re: require_once() using a url, how do I enable it in the se
If it's working locally, it should already be listening on port 80. Just point your browser to the correct IP or set up a rule in your hosts file to resolve it by domain name.
-
PHPHelpNeeded
- Forum Commoner
- Posts: 83
- Joined: Mon Nov 17, 2014 8:03 pm
Re: require_once() using a url, how do I enable it in the se
I am using the correct IP...you might not be seeing the IP that I am using cause I omitted it out to post this forum question, but I personally know that I am using the correct PUBLIC ip address.Celauran wrote:If it's working locally, it should already be listening on port 80. Just point your browser to the correct IP or set up a rule in your hosts file to resolve it by domain name.
When you say "set up a rule in your hosts file to resolve it by domain name." Do you mean to add a BINDING on the IIS website to resolve the host to the PUBLIC IP?
Let me try that in the mean time....
UPDATE: in case you were referring to adding a binding to resolve to the public ip, it didn't work, now I get this error message:
Code: Select all
[24-Nov-2014 19:06:13 America/New_York] PHP Fatal error: Class 'Hello' not found in %WinDir%\Eclipse_Projects\PHP_Project1\Client\Login\LoginAuth.php on line 9
So what's wrong now
Re: require_once() using a url, how do I enable it in the se
I wasn't referring to public IPs at all. I assumed this was being accessed over a private network. Shouldn't matter much either way. That you're getting errors at all looks like progress. What's line 9 of LoginAuth.php? What's this serverpackage.php you mentioned?
-
PHPHelpNeeded
- Forum Commoner
- Posts: 83
- Joined: Mon Nov 17, 2014 8:03 pm
Re: require_once() using a url, how do I enable it in the se
LoginAuth.php => this file will be my login authentication page, for instance, that's where users will log in and for my current situation, since I am testing whether I can include() a library through a URL. The file looks like this:Celauran wrote:I wasn't referring to public IPs at all. I assumed this was being accessed over a private network. Shouldn't matter much either way. That you're getting errors at all looks like progress. What's line 9 of LoginAuth.php? What's this serverpackage.php you mentioned?
Code: Select all
<?php
require_once "http://my public IP/server/libraries/ServerPackage.php";
Echo Hello::HelloWorld("My Name");
?>
ServerPackage.php => this file will be a library of functions and classes I will want to include(), and it looks like this:
Code: Select all
<?php
class Hello {
public static function HelloWorld($name){
return "Hello World Mr. {$name}";
}
}
?>
Re: require_once() using a url, how do I enable it in the se
Since LoginAuth and ServerPackage are on the same machine, you should be able to require them via file path, but that's just an aside. require_once seems to be working as it throws a fatal error otherwise. Based on the code you've posted, I see no reason this wouldn't work. Is this the entirety of both files?
-
PHPHelpNeeded
- Forum Commoner
- Posts: 83
- Joined: Mon Nov 17, 2014 8:03 pm
Re: require_once() using a url, how do I enable it in the se
Celauran wrote:Since LoginAuth and ServerPackage are on the same machine, you should be able to require them via file path, but that's just an aside. require_once seems to be working as it throws a fatal error otherwise. Based on the code you've posted, I see no reason this wouldn't work. Is this the entirety of both files?
Yes, this is exactly what you see in each entire file...I got nothing else.
But even when I run the require_once("http://url") in the same machine of the web server, I still get that fatal error that says, CLASS NOT FOUND.
So I am puzzled, is like the allow_url_enable seems to be working, but the content of the file being included() is being restricted.
Re: require_once() using a url, how do I enable it in the se
Have you tried using require by file path instead?
-
PHPHelpNeeded
- Forum Commoner
- Posts: 83
- Joined: Mon Nov 17, 2014 8:03 pm
Re: require_once() using a url, how do I enable it in the se
I understand that the file can be acquired through file path.Celauran wrote:Have you tried using require by file path instead?
Anyway, my purpose is not to access the file through file path because as a website, it will be hosted from my desktop and be accessed from other computers outside the network.
Other outside computers cannot access the file through file path because it will not be found in those outside computers.
I think I have mentioned this.
Re: require_once() using a url, how do I enable it in the se
You have, and your understanding appears to be flawed. Other computers will not be accessing those files directly. Their access is restricted to what is exposed by the web server. PHP is all processed server side and only the results are sent to the client. Thus, it is not the client requesting those files directly, but PHP itself.
-
PHPHelpNeeded
- Forum Commoner
- Posts: 83
- Joined: Mon Nov 17, 2014 8:03 pm
Re: require_once() using a url, how do I enable it in the se
are you saying I have to enabled or UNrestrict something in IIS in order to fix this? Or are you saying this is completely impossible?Celauran wrote:You have, and your understanding appears to be flawed. Other computers will not be accessing those files directly. Their access is restricted to what is exposed by the web server. PHP is all processed server side and only the results are sent to the client. Thus, it is not the client requesting those files directly, but PHP itself.
If it is completely impossible, then I will have to ask a different question as to how I can perform what I want to do, with a different approach.
Let me know if you want me to explain what I want to perform, I need to get an answer from this...my personal problem with PHP is that I am not very familiar with how things work. Sometimes I find myself typing some concept that would work in Java but are not reliable or does not work with PHP. Though Java and PHP tend to be similar.