Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-07-2013, 01:35 PM   PM User | #1
jeddi
Senior Coder

 
Join Date: May 2006
Posts: 1,525
Thanks: 26
Thanked 4 Times in 4 Posts
jeddi has a little shameless behaviour in the past
Include code from other server ?

I am running 2 servers, one in the USA and one in the UK.

To make updates easier I want to ınclude php files from the USA server
in the php scripts of the UK server.

So I will have :

PHP Code:
<?php 
/*
*  index.php
*

*/
if(session_id() == ''){session_start();}

require_once(
"path-to-my-server/my_page.php");

then other stuff
?>
I did something similar between different virtual servers on the same
physical server by using a directory outside the local html directory.

EG using :
PHP Code:
require_once("/usr/local/mysites/head_cont.php"); 
But how would I do it between different servers ?

Javascript can pull code off any website and use it,
can php do a similar thing by using the url to get the php file
and then include it ?

Thanks.


.
__________________
If you want to attract and keep more clients, then offer great customer support.

Support-Focus.com. automates the process and gives you a trust seal to place on your website.
I recommend that you at least take the 30 day free trial.
jeddi is offline   Reply With Quote
Old 01-07-2013, 01:48 PM   PM User | #2
Redcoder
Regular Coder

 
Redcoder's Avatar
 
Join Date: May 2012
Location: /dev/couch
Posts: 309
Thanks: 2
Thanked 46 Times in 45 Posts
Redcoder has a little shameless behaviour in the past
Don't try it. Too big of a security risk.

But if you still want to push it on, take a look at:

http://httpd.apache.org/docs/2.0/mod/mod_access.html

Basically, you allow access using .htacess to a particular IP. (Never done it though)

Like:

Code:
<Directory *>
Order Deny,Allow
Deny from all
Allow from public_server.com 20.30.20.29 
</Directory>
__________________
For professional Hosting and Web design.....


NetEssentials.co.uk

Last edited by Redcoder; 01-07-2013 at 01:50 PM..
Redcoder is offline   Reply With Quote
Old 01-07-2013, 01:49 PM   PM User | #3
angst
Senior Coder

 
angst's Avatar
 
Join Date: Apr 2004
Location: Toronto, Ontario
Posts: 2,112
Thanks: 15
Thanked 122 Times in 122 Posts
angst is on a distinguished road
this can't be done, PHP is a server side language. have a look at PHP SOAP web services.
angst is offline   Reply With Quote
Old 01-07-2013, 01:57 PM   PM User | #4
Redcoder
Regular Coder

 
Redcoder's Avatar
 
Join Date: May 2012
Location: /dev/couch
Posts: 309
Thanks: 2
Thanked 46 Times in 45 Posts
Redcoder has a little shameless behaviour in the past
Of course it can be done - if he sets the proper permissions and has the proper login and acess credentials for servers and script at each end.

Hell, he can even use FTP to get the local file and save it to a local folder. Using PHP and FTP with ftp_get(). Actually, it's easier to use ftp_get() then just call the newly saved file instead of sever configurations that will leave a huge gaping security hole.
__________________
For professional Hosting and Web design.....


NetEssentials.co.uk
Redcoder is offline   Reply With Quote
Old 01-07-2013, 02:00 PM   PM User | #5
angst
Senior Coder

 
angst's Avatar
 
Join Date: Apr 2004
Location: Toronto, Ontario
Posts: 2,112
Thanks: 15
Thanked 122 Times in 122 Posts
angst is on a distinguished road
thats a terrible solution. SOAP is the proper way to share remote functionality.
angst is offline   Reply With Quote
Old 01-07-2013, 02:02 PM   PM User | #6
angst
Senior Coder

 
angst's Avatar
 
Join Date: Apr 2004
Location: Toronto, Ontario
Posts: 2,112
Thanks: 15
Thanked 122 Times in 122 Posts
angst is on a distinguished road
sure, lots of things are possible, he could even use Samba and create a long range share and mapping of the remote device, but again bad security, not the proper way to accomplish this and not what any experienced developer would call any elegant solution.
angst is offline   Reply With Quote
Old 01-07-2013, 02:08 PM   PM User | #7
Redcoder
Regular Coder

 
Redcoder's Avatar
 
Join Date: May 2012
Location: /dev/couch
Posts: 309
Thanks: 2
Thanked 46 Times in 45 Posts
Redcoder has a little shameless behaviour in the past
True, but the man doesn't want to interchange info, he wants to be able to include PHP code not available locally. SOAP won't do that for you mate. Elegant yes, but not the solution.

He wants a simple include('file_to_be_included.php').

And how is using PHP's FTP usage hacky and dirty? Its in the core of the PHP language and only needs 3 lines of code to implement such functionality.
__________________
For professional Hosting and Web design.....


NetEssentials.co.uk

Last edited by Redcoder; 01-07-2013 at 02:14 PM..
Redcoder is offline   Reply With Quote
Old 01-07-2013, 02:17 PM   PM User | #8
angst
Senior Coder

 
angst's Avatar
 
Join Date: Apr 2004
Location: Toronto, Ontario
Posts: 2,112
Thanks: 15
Thanked 122 Times in 122 Posts
angst is on a distinguished road
what makes you think that SOAP can't be used to simply include content?
angst is offline   Reply With Quote
Old 01-07-2013, 02:20 PM   PM User | #9
Redcoder
Regular Coder

 
Redcoder's Avatar
 
Join Date: May 2012
Location: /dev/couch
Posts: 309
Thanks: 2
Thanked 46 Times in 45 Posts
Redcoder has a little shameless behaviour in the past
Hmm...it actually can. Call another page that will read the.php files contents and then send it to the calling php file. Yeah. I must have just zoned out when you said:

Code:
"this can't be done, PHP is a server side language. have a look at PHP SOAP web services. "
Maybe there's a SOAP functionality thats more native than the one I mentioned. I don't use SOAP much....or at all in my line of work.

Hmpff. Haha.
__________________
For professional Hosting and Web design.....


NetEssentials.co.uk

Last edited by Redcoder; 01-07-2013 at 02:23 PM..
Redcoder is offline   Reply With Quote
Old 01-07-2013, 02:56 PM   PM User | #10
jeddi
Senior Coder

 
Join Date: May 2006
Posts: 1,525
Thanks: 26
Thanked 4 Times in 4 Posts
jeddi has a little shameless behaviour in the past
Is accessing a database on a different
physical server less of a problem ?

I usually just have something like:

PHP Code:
$host "localhost";
$user "boss"
$password "h8&k5sTmK9(s"
$database "mydb"
But if the MySQL db is on a different server,
I guess I need something other than "localhost".

What should I put in there in order to ensure access ?

Thanks


.
__________________
If you want to attract and keep more clients, then offer great customer support.

Support-Focus.com. automates the process and gives you a trust seal to place on your website.
I recommend that you at least take the 30 day free trial.
jeddi is offline   Reply With Quote
Old 01-07-2013, 03:01 PM   PM User | #11
Redcoder
Regular Coder

 
Redcoder's Avatar
 
Join Date: May 2012
Location: /dev/couch
Posts: 309
Thanks: 2
Thanked 46 Times in 45 Posts
Redcoder has a little shameless behaviour in the past
Yes, Remote MySQL is just like normal except no localhost for hostname. You use something like...

PHP Code:
$host "http://mysql.remotedomain.com"//its not always mysql.balhblah.com can be 2.remotedomain.com or http://remotedomain.com/mysql depends on hostname configured 
First, you need to make sure that your host provides remote MySQL acess. Most free hosts don't provide this.

You ussually have a hostname where you login fo phpmyadmin and such. Most hosts give this for use in scripts. e.g mysql.yourdomain.com . Just check with your host the subdomain or path for MySQL access.
__________________
For professional Hosting and Web design.....


NetEssentials.co.uk
Redcoder is offline   Reply With Quote
Old 01-07-2013, 03:02 PM   PM User | #12
angst
Senior Coder

 
angst's Avatar
 
Join Date: Apr 2004
Location: Toronto, Ontario
Posts: 2,112
Thanks: 15
Thanked 122 Times in 122 Posts
angst is on a distinguished road
yes, if the ports are open on your firewall/router and your MySQL server is configured correctly to bind to any local address then yes, you can connect to the MySQL server from anywhere.
angst is offline   Reply With Quote
Old 01-07-2013, 04:29 PM   PM User | #13
tangoforce
Senior Coder

 
tangoforce's Avatar
 
Join Date: Feb 2011
Location: Your Monitor
Posts: 3,515
Thanks: 45
Thanked 439 Times in 428 Posts
tangoforce will become famous soon enoughtangoforce will become famous soon enough
Quote:
Originally Posted by Redcoder View Post
Yes, Remote MySQL is just like normal except no localhost for hostname. You use something like...

PHP Code:
$host "http://mysql.remotedomain.com"


Since when was http used for all TCP based connections?

I've never known http be used for anything but webservers.

@Jeddi: What redcoder is saying is almost correct except that you don't use http:// on the address. You only use the actual hostname.
__________________
Please wrap your code in [php] tags. It is a sticky topic and it HELPS us to HELP YOU!
TIP: Coding styles and $end errors :::::::::: TIP: Warning: Cannot modify header information - headers already sent :::::::::: TIP: Quotes / Parse error: syntax error, unexpected T_..
PHP Code:
//Please don't use this for your form processing:
if (isset($_POST['submit']))
//Internet explorer has a bug and does not always send the submit value. 
Explanation: The IE if(isset($_POST['submit'])) bug explained.
tangoforce is offline   Reply With Quote
Old 01-07-2013, 04:34 PM   PM User | #14
angst
Senior Coder

 
angst's Avatar
 
Join Date: Apr 2004
Location: Toronto, Ontario
Posts: 2,112
Thanks: 15
Thanked 122 Times in 122 Posts
angst is on a distinguished road
or IP address.
angst is offline   Reply With Quote
Old 01-07-2013, 04:39 PM   PM User | #15
Redcoder
Regular Coder

 
Redcoder's Avatar
 
Join Date: May 2012
Location: /dev/couch
Posts: 309
Thanks: 2
Thanked 46 Times in 45 Posts
Redcoder has a little shameless behaviour in the past
Hahaha. Tangoforce. My bad. Must be the lack of sleep...no, not me. Haha
__________________
For professional Hosting and Web design.....


NetEssentials.co.uk
Redcoder is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:16 PM.


Advertisement
Log in to turn off these ads.