nsheldon wrote:One option I just thought of (but haven't tried myself yet) might be to create a web page served by the Mac's built-in Apache server where the images (or links) on the page execute CGIs or other shell command to tell Indigo to do things. Unfortunately, you're likely to encounter difficulties due to OS X's sandboxing and permissions security measures. It may require you to do some "creative" workarounds that involve "sodu" and the "expect" command.
matt (support) wrote:Correct, there is currently no user level access settings for Indigo Touch -- just a single user with all access. As mentioned above, if you know how to configure Apache then you might be able to hack together something. Adding more access control functionality is on our list of features we would like to eventually see in Indigo Touch (and the Indigo Web Server).
durosity wrote:Could this not be done by creating a separate control page with the modules you want them to control, opening it in safari then bookmarking it (then remove the indigo touch app)?
nsheldon wrote:Matt: Not being very familiar with the IWS plugin architecture, would it be possible for someone to create an IWS plugin that overrides the current authentication mechanism and presents a different one (or, rather, the same type of authentication mechanism with a different authentication source) to the web client?
<html><?PHP
/* =========================================================
Indigo Control Proxy
Version 1.0 b1
by Nathan Sheldon
nathan@nathansheldon.com
This script accepts HTTP GET requests containing a device
name, device state, and value for that state. It then
attempts to set the device's state to the specified
value. Currently, only the "brightness" and "on" states
are recognized. Also, this script does little more than
check to see if a device, state, and value were submitted
and does not check if the information makes sense.
Use at your own risk!
========================================================= */
// ==== EDIT THESE VARIABLES ====
// The username and password below should be set to the username
// and password of the local administrator account under which
// the Indigo server is launched, otherwise this proxy will
// fail. Note that you can't use quotes in your username or
// password. Other special characters may also cause errors.
$username = "myUsername";
$password = "myPassword";
// ==== DON'T EDIT ANYTHING AFTER THIS LINE ====
// Set error reporting level to avoid warning messages.
error_reporting (E_ERROR);
// ==== DEFINE VARIABLES ====
$device = $_GET['device']; // Indigo device name to control.
$state = $_GET['state']; // Device state to change. Currently,
// only "brightness" and "on"
// are controllable.
$value = $_GET['value']; // Value to change the device state to.
// ==== DEFINE FUNCTIONS ====
function fExecuteAppleScript ($AS) {
/* ----------
Expects:
$AS : string with AppleScript to execute.
Returns:
$Response : string with result of expect and su command.
---------- */
global $username, $password;
// Properly escape characters for use in shell + expect + shell command.
$AS = str_replace ('"', '\\"', $AS); // Escape quotes because we're in a shell
$AS = str_replace ("\\", "\\\\\\", $AS); // Escape escapes an additional 3 times.
$AS = str_replace ("\t", "", $AS); // Remove tabs.
$AS = str_replace ("\n", "\\\r ", $AS); // Convert newlines to tripple-escaped returns with a tailing space.
$Command = "expect -c \"spawn su - ".$username."; expect -re \\\".*assword.*\\\"; send \\\"" .$password."\\r\\\"; expect \\\"\\\\\\\\$\\\"; send \\\"osascript -e \'".$AS."\'\\r\\\"; expect \\\"\\\\\\\\$\\\"; send \\\"exit\\r\\\"; expect \\\"logout\\\";\"";
print "<!-- Command: ".$Command." -->\n";
$Response = shell_exec ($Command);
error_log ("IWS Control Proxy response: ".$Response);
return $Response;
} // End fExecuteAppleScript function.
// ==== START HTML CONTENT OUTPUT ====
?><head><title>Indigo Control Proxy</title>
<?
// ==== VALIDATE SUBMITTED DATA ====
// Limit access to 192.168.1.xxx address range based on REMOTE_ADDR value.
if (!preg_match ("/192\.168\.1\.[0-9]{3}/", $_SERVER['REMOTE_ADDR'])) {
print "</head>\n";
print "<body>\n";
print "Access denied for your IP address (".$_SERVER['REMOTE_ADDR'].").\n";
} elseif (($state == "brightness" or $state == "on") and
$device != "" and
$value != "") {
print "<!-- Setting ".$device." ".$state." to ".$value.". -->\n";
// ==== CREATE THE APPLESCRIPT ====
$AppleScript = "tell application \"IndigoServer\"\n";
if ($state == "brightness") {
$AppleScript = $AppleScript.' set brightness of device "'.$device.'" to '.$value."\n";
} elseif ($state == "on") {
if ($value == "true" or $value == "on") {
$AppleScript = $AppleScript.' turn on device "'.$device."\"\n";
} elseif ($value == "false" or $value == "off") {
$AppleScript = $AppleScript.' turn off device "'.$device."\"\n";
}
}
$AppleScript = $AppleScript.'end tell';
print "<!-- HTTP Referer: ".$_SERVER['HTTP_REFERER']." -->\n";
print "<!-- AppleScript to execute:\n".$AppleScript."\n-->\n";
// ==== EXECUTE THE APPLESCRIPT ====
$scriptResponse = fExecuteAppleScript ($AppleScript);
error_log ($scriptResponse);
print "<!-- Response:\n".$scriptResponse."\n-->\n\n";
// ==== REDIRECT THE USER TO THE PAGE THAT THEY CAME FROM ====
if ($_SERVER['HTTP_REFERER'] != "") {
print "<meta http-equiv=\"refresh\" content=\"0;URL='".$_SERVER['HTTP_REFERER']."'\">\n";
print "</head>\n";
} else {
?></head> <?
}
?><body>
<?
print "Command sent.\n";
} else {
print "</head>\n";
print "<body>\n";
print "Invalid input.\n";
}
// ==== END HTML OUTPUT AND SCRIPT ====
?>
</body>
</html>
if (!preg_match ("/192\.168\.1
#LoadModule php5_module libexec/apache2/libphp5.so
http://192.168.1.100/indigo-control.php?device=Family+Room+Lamp&state=brightness&value=80
http://192.168.1.100/indigo-control.php?device=Family+Room+Lamp&state=on&value=false
Users browsing this forum: No registered users and 10 guests