Need help with a couple things

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
andyh2
Forum Newbie
Posts: 1
Joined: Fri Dec 19, 2008 9:32 pm

Need help with a couple things

Post by andyh2 »

Hey all. I have a PHP script that is run on macintosh computers with a frontend GUI to it made using Platypus and CocoaDialog (google em'). It's a long story, but the script may break when a certain event happens, and I was wondering if it was possible to make a remote killswitch for the script to disable it (using the die() function) remotely, preferably by accessing a file on my server every time the script is run. My script is compiled into an executable with Platypus, so there's no way the user can remove the line of code. That's the first thing I want to know how to do. The second is- How can I make an update notifier, that checks for an update almost like the killswitch but instead, informs the user that there is an update available. I'd have a variable in each update I release that says like $Version = 2.2; and then it would see if there is a newer version available by querying a file on a server. Sadly, I am not very PHP-savvy and have really no idea how to do this. Can anyone give me an example or some kind of guidance as to how I can accomplish these two things?

Thanks,

Andy
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Need help with a couple things

Post by requinix »

andyh2 wrote:I was wondering if it was possible to make a remote killswitch for the script to disable it (using the die() function) remotely, preferably by accessing a file on my server every time the script is run.
Well yeah, that's how you'd do it. A simple

Code: Select all

if (file_get_contents("http://yoursite.com/disable.txt")) die("kill switch");
works: if disable.txt has anything inside it the script dies.

Of course it does mean that your server is queried every time the code runs.
andyh2 wrote:How can I make an update notifier, that checks for an update almost like the killswitch but instead, informs the user that there is an update available. I'd have a variable in each update I release that says like $Version = 2.2; and then it would see if there is a newer version available by querying a file on a server.
Same idea, same drawback.

Code: Select all

$version = 2.2;
$newest = file_get_contents("http://yoursite.com/version.txt");
 
if ($newest > $version) { /* there is a newer version available */ }
version.txt contains a number.
Post Reply