Retrieve variable from PHP file on remote server.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
flapjack
Forum Newbie
Posts: 14
Joined: Fri May 29, 2009 8:09 pm

Retrieve variable from PHP file on remote server.

Post by flapjack »

Been writing a PHP software that I am almost done with.

I need to test the licence to ensure that they only use the software on one domain.

I have everything built on both ends, but am having problems with getting a variable from the remote script to do this. I have been racking my brain for hours.

So, here is the setup. On my main domain I have a php script that checks the Db to see if the receipt number and domain are already regstered. There are three conditions

1. Receipt or URL doesn't exsist = $status = added
2. Receipt Exsists but URL doesn't match = $status = confirmed
3. Any other condition = $status = used

It works great but now I need to pull that variable from another server. I have tried an include, file_get_contents but can't seem to echo $status.

Any thoughts?

I already realize the security risks here and will be protection with ION Cube
flapjack
Forum Newbie
Posts: 14
Joined: Fri May 29, 2009 8:09 pm

Re: Retrieve variable from PHP file on remote server.

Post by flapjack »

No takers?
User avatar
omniuni
Forum Regular
Posts: 738
Joined: Tue Jul 15, 2008 10:50 pm
Location: Carolina, USA

Re: Retrieve variable from PHP file on remote server.

Post by omniuni »

Try checking your php.ini. I bet you don't have PHP allowed to open remote URL's.

Then file_get_contents() should return the contents of the remote script.

Otherwise, try using CURL*.

Good Luck!

*I originally said WGET, I corrected this after seeing Flapjack's post.
Last edited by omniuni on Fri Jul 24, 2009 6:03 pm, edited 1 time in total.
flapjack
Forum Newbie
Posts: 14
Joined: Fri May 29, 2009 8:09 pm

Re: Retrieve variable from PHP file on remote server.

Post by flapjack »

It seems I will have to do a fsocket open or CURL. Any thoughts?
User avatar
andyhoneycutt
Forum Contributor
Posts: 468
Joined: Wed Aug 27, 2008 10:02 am
Location: Idaho Falls

Re: Retrieve variable from PHP file on remote server.

Post by andyhoneycutt »

I don't understand if you're just seeing if a file exists with the appropriate contents on their end, or what the actual setup is. I'm curious why you don't just create and issue a certificate? You could use AES encryption, or some other method of your choosing, to make sure the certificate document they have on their end has all the appropriate credentials that you could compare to your own local data set.

You could certainly just use an fopen or a file_get_contents (as previously suggested) if you were to move to a comparable scheme as the one I'm proposing.

Perhaps you could better explain your problem?

Thanks in advance,
Andy
User avatar
omniuni
Forum Regular
Posts: 738
Joined: Tue Jul 15, 2008 10:50 pm
Location: Carolina, USA

Re: Retrieve variable from PHP file on remote server.

Post by omniuni »

I'm an idiot. Thanks Flapjack, for the correction... I meant CURL, not WGET.
Post Reply