Example #1
0
            break;
        case "move":
            if ($_GET["dir"] == "up") {
                $heyusched->reorderElements($_GET['line'], $_GET['line'] - 1);
            }
            if ($_GET["dir"] == "down") {
                $heyusched->reorderElements($_GET['line'], $_GET['line'] + 1);
            }
            $mustSave = true;
            break;
    }
    if ($mustSave) {
        try {
            $heyusched->save();
        } catch (Exception $e) {
            if (count(preg_grep("/modified/", array($e->getMessage())))) {
                gen_error(null, array($e->getMessage(), $lang['exitbrowser']));
            } else {
                gen_error(null, $e->getMessage());
            }
            exit;
        }
    }
    if ($_GET["action"] != "edit") {
        header("Location: " . $_SERVER['PHP_SELF']);
        exit;
    }
}
## Display the page
$tpl->set('content', $tpl_body);
echo $tpl->fetch(TPL_FILE_LOCATION . 'layout.tpl');
Example #2
0
$tpl_body = new Template(TPL_FILE_LOCATION . 'upload.tpl');
$tpl_body->set('lang', $lang);
$tpl_body->set('config', $config);
if (isset($_GET["action"])) {
    switch ($_GET["action"]) {
        case "upload":
            try {
                $rs = heyu_upload();
                $tpl_body->set('type', 'upload');
            } catch (Exception $e) {
                gen_error("heyu upload", $e);
                exit;
            }
            break;
        case "erase":
            try {
                $rs = heyu_erase();
                $tpl_body->set('type', 'erase');
            } catch (Exception $e) {
                gen_error("heyu erase", $e);
                exit;
            }
            break;
    }
    $tpl_body->set('out', $rs);
} else {
    $tpl_body->set('type', 'none');
}
## Display the page
$tpl->set('content', $tpl_body);
echo $tpl->fetch(TPL_FILE_LOCATION . 'layout.tpl');
Example #3
0
    $config['heyu_subdir'] = $_POST["heyu_subdir"];
    $config['heyuconf'] = $_POST["heyuconf"];
    $config['heyuexec'] = $_POST["heyuexec"];
    $config['use_domus_security'] = $_POST["use_domus_security"];
    $config['hvac_house_code'] = $_POST["hvac_house_code"];
    $config['lang'] = $_POST["lang"];
    $config['url_path'] = $_POST["url_path"];
    $config['theme'] = $_POST["theme"];
    $config['themeview'] = $_POST["themeview"];
    $config['thememobile'] = $_POST["thememobile"];
    $config['mobileselect'] = $_POST["mobileselect"];
    $config['imgs'] = $_POST["imgs"];
    $config['codes'] = $_POST["codes"];
    $config['refresh'] = $_POST["refresh"];
    if (file_exists(CONFIG_FILE_LOCATION) && is_writable(CONFIG_FILE_LOCATION) || !file_exists(CONFIG_FILE_LOCATION)) {
        createHeyuSubdir($_POST["heyu_subdir"]);
        config_save($config);
        $_SESSION['frontObj']->getConfig(true);
        $_SESSION['frontObj']->getLanguageFile(true);
        $_SESSION['frontObj']->getHeyuConf(true);
        $_SESSION['frontObj']->getHeyuSched(true);
    } else {
        gen_error(null, CONFIG_FILE_LOCATION . " " . $lang['error_filerw']);
        exit;
    }
    header("Location: " . $_SERVER['PHP_SELF']);
    exit;
}
## Display the page
$tpl->set('content', $tpl_body);
echo $tpl->fetch(TPL_FILE_LOCATION . 'layout.tpl');
Example #4
0
 /**
  * Build Module Table
  * 
  * Description:
  * 
  * @param $alias
  */
 function buildModuleTable($anAliasable)
 {
     $lang = $_SESSION['frontObj']->getLanguageFile();
     $config = $_SESSION['frontObj']->getConfig();
     $modTypes = $_SESSION['frontObj']->getModuleTypes();
     $alias = $anAliasable;
     $scene = $anAliasable;
     $multi_alias = $alias->isMultiAlias();
     // check if A1,2 or just A1
     $hvac_alias = $alias->isHVACAlias();
     // check if HVAC module
     // check if is a multi alias, if true, use modules.tpl, if not use template acording to $type
     if ($multi_alias) {
         $tpl = "modules.tpl";
     } else {
         $tpl = $modTypes->getModuleType($anAliasable->getAliasMap()->getType())->getModuleImage() . ".tpl";
     }
     // create new template
     $mod = new Template(TPL_FILE_LOCATION . $tpl);
     $mod->set('config', $config);
     $mod->set('label', label_parse($anAliasable->getLabel(), false));
     $mod->set('lang', $lang);
     if ($anAliasable->isAlias()) {
         $mod->set('code', $alias->getHouseDevice());
     }
     if (!isset($_GET['page'])) {
         $_GET['page'] = 'domus_home_page';
     } else {
         $mod->set('page', $_GET['page']);
     }
     // if alias is a multi alias, scene or HVAC, module state & dimlevel are not checked
     if ($anAliasable->statusAbility()) {
         try {
             if (on_state($config, $alias->getHouseDevice())) {
                 $state = 'on';
                 $action = $config['cmd_off'];
             } else {
                 $state = 'off';
                 $action = $config['cmd_on'];
             }
         } catch (Exception $e) {
             gen_error("buildLocationTable - on_state ", $e->getMessage());
             exit;
         }
         $mod->set('action', $action);
         $mod->set('state', $state);
         if (strtolower(trim($modTypes->getModuleType($alias->getAliasMap()->getType())->getModuleType())) == DIMMABLE_D) {
             $mod->set('level', $this->level_calc(dim_level($config, $alias->getHouseDevice())));
         }
     } elseif ($hvac_alias) {
         $result_arr = heyu_action($config, "hvac_control", $alias->getHouseDevice(), null, null, "mode");
         //			error_log("error of heyu_action in hvac ".$result_arr[0]. " count of result array [".count($result_arr)."]");
         if ($result_arr[0] != "Error in HVAC result") {
             $mode = $result_arr[0];
         } else {
             $mode = "OFF";
         }
         if ($mode == "OFF") {
             $state = "off";
         } else {
             $state = "on";
         }
         $result_arr = heyu_action($config, "hvac_control", $alias->getHouseDevice(), null, null, "temp");
         if ($result_arr[0] != "Error in HVAC result") {
             $temp = $result_arr[0];
         } else {
             $temp = "?";
         }
         $result_arr = heyu_action($config, "hvac_control", $alias->getHouseDevice(), null, null, "setpoint");
         if ($result_arr[0] != "Error in HVAC result") {
             $setpoint = $result_arr[0];
         } else {
             $setpoint = "?";
         }
         $result_arr = heyu_action($config, "hvac_control", $alias->getHouseDevice(), null, null, "fan_mode");
         if ($result_arr[0] != "Error in HVAC result") {
             $fan_mode = $result_arr[0];
         } else {
             $fan_mode = "?";
         }
         $result_arr = heyu_action($config, "hvac_control", $alias->getHouseDevice(), null, null, "setback_mode");
         if ($result_arr[0] != "Error in HVAC result") {
             $setback_mode = $result_arr[0];
         } else {
             $setback_mode = "?";
         }
         $mod->set('state', $state);
         $mod->set('mode', $mode);
         $mod->set('temp', $temp);
         $mod->set('setpoint', $setpoint);
         $mod->set('fan_mode', $fan_mode);
         $mod->set('setback_mode', $setback_mode);
     }
     // return as html
     return $mod->fetch(TPL_FILE_LOCATION . $tpl);
 }
Example #5
0
## Setup the userdb if it does not exist.
require_once $dirname . DIRECTORY_SEPARATOR . 'utility/setupuserdb.php';
setUpUserDB();
$authCheck = new Login(USERDB_FILE_LOCATION, $config['use_domus_security']);
if (!$authCheck->login()) {
    header("Location: login.php?from=index");
    exit;
}
$tpl->set('sec_level', $authCheck->getUser()->getSecurityLevel());
$tpl->set('sec_level_type', $authCheck->getUser()->getSecurityLevelType());
// start/stop controls for heyu
if (isset($_GET["daemon"]) && $authCheck->getUser()->getSecurityLevel() <= 2) {
    try {
        heyu_ctrl($config, $_GET["daemon"]);
    } catch (Exception $e) {
        gen_error("heyu " . $_GET["daemon"], $e->getMessage());
        exit;
    }
}
// get which page is open
$page = isset($_GET['page']) ? $_GET['page'] : "domus_home_page";
// set page title
$tpl->set('title', ucwords($page));
$tpl->set('page', $page);
// check if heyu is running, if true display modules
if (heyu_running()) {
    $dirname = dirname(__FILE__);
    require_once $dirname . DIRECTORY_SEPARATOR . 'include_globals.php';
    ## Load mod group types
    if ($config['themeview'] == 'typed') {
        $modgrouptypes =& $_SESSION['frontObj']->getTypedGroups()->getVisibleGroups();
Example #6
0
 * This program is distributed in the hope's that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details. You should have 
 * received a copy of the GNU General Public License along with
 * this program; if not, write to the Free Software Foundation, 
 * Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
# error_log("Entered globals");
## instantiate cached lists
try {
    $directives =& $_SESSION['frontObj']->getDirectives();
    $modlist =& $_SESSION['frontObj']->getModList();
    $heyuconf =& $_SESSION['frontObj']->getHeyuConf();
    $modtypes =& $_SESSION['frontObj']->getModuleTypes();
    $groups =& $_SESSION['frontObj']->getGroups();
} catch (Exception $e) {
    gen_error("Load Cache", $e->getMessage());
    exit;
}
try {
    $heyusched =& $_SESSION['frontObj']->getHeyuSched();
} catch (Exception $e) {
    $theTrace = $e->getTrace();
    if ($theTrace[0]["function"] == "load") {
        gen_error("Load Cache Sched File", $e->getMessage());
        exit;
    }
    // else noop
}
# error_log("Exited globals");