Jul 22 2008

Using PHP and a Shell Script to Restart an AppleTV remotely — via the web

Published by Jonathan Wise under Hacks

As a follow up to my previous post, here’s how to do the same thing, but from a web browser (say, on your iPhone) — it assumes you’ve already written a shell script, as discussed earlier.

  • Configure Apache to run PHP on your Mac (these instructions are for Leopard, but similar ones are out there for Tiger)
  • Configure Apache to run as your own user, instead of the WWW user — a serious security risk. Only do this on an internal network! The WWW user won’t have adequate permissions to do what we need to.
  • Put this .php page in your /Library/WebServer/Documents/ folder as RestartMedia.php — you’ll need to supply your own image file in the same path as well.
  • Visit http://yourcomputer.local/RestartMedia.php from a browser. Clicking on the text or image will execute a shell script located at: /Applications/Automation/RebootMediaServers.sh

Obviously you can customize this at will, including file locations. This was just a quick hack that does the job for me — and the webpage is optimized for Mobile Safari.

No responses yet

Oct 15 2007

iPhone Theme for WordPress

Published by Jonathan Wise under Code Snippets, Hacks

Here’s a hack for ContentRobot’s excellent iPhone Plugin + Theme additions for WordPress that allows the user to decide which version to view. When deploying this theme, I had originally chosen two different roll-out strategies — both modifications of what’s provided by the original code.

For jonandnic.com I made two versions of the website. This seemed like a worthwhile idea at the time, but now that I’ve further hacked the plug-in, I think the approach I used on this site is better.

In short, what I wanted to do was allow the user to choose which version of the site they want to view. The iPhone theme obviously has less features than a full widget/side-bar ready theme, and despite the small screen size, there are times that I want that functionality on my iPhone.
Initially I had a hack in that would ask the users with each page visit. This got annoying, so I improved my hack to include a cookie that saves the preference for an hour. This way they can decide on each visit which version they want to see.

This is a derivative work from the original plug-in, which is provided here, under the GPL.

Update: Here’s another note. Once the user’s made their selection, you can allow them to change their preference by adding the following code somewhere in your iPhone theme code. I added it to the Footer…

  • <p>View <a href="<?php bloginfo('siteurl'); ?>?iphone=no">Full Version</a> of this site</p>

2 responses so far