Пример #1
0
        }
        return set_hotspot($data['xmlUrl'], $data['scene'], $data['id'], $data['ath'], $data['atv'], $data['iconUrl'], $data['options']);
    }
}
if ($_GET['req'] == 'delHotspot') {
    $data = $_GET['data'];
    return remove_hotspot($data['xmlUrl'], $data['id']);
}
if ($_GET['req'] == 'addScene') {
    $data = $_GET['data'];
    $image_data = null;
    if (isset($data['options']['pvrPath'])) {
        $new_id = str_replace("s", "", $data['id']);
        $image_data = extract_image_data($data['options']['pvrPath'] . '/pano.xml', "pvr/{$new_id}/");
    }
    add_scene($data['xmlUrl'], $data['id'], $image_data, $data['options']);
    return;
}
if ($_GET['req'] == 'setScene') {
    $data = $_GET['data'];
    if ($data['key'] == 'pvrPath') {
        $new_id = str_replace("s", "", $data['id']);
        $image_data = extract_image_data($data['val'] . '/pano.xml', "pvr/{$new_id}/");
        set_scene($data['xmlUrl'], $data['id'], $image_data);
    } else {
        set_scene($data['xmlUrl'], $data['id'], null, array($data['key'] => $data['val']));
    }
}
if ($_GET['req'] == 'delScene') {
    $data = $_GET['data'];
    return remove_scene($data['xmlUrl'], $data['id']);
Пример #2
0
function dbase_parse($cmd, $message)
{
    global $pisql, $dbhost, $dbuser, $dbpass, $dbname;
    global $log;
    // Used by daemon
    global $apperr, $appmsg;
    // For ajax usage
    if (!$pisql || !$pisql->ping()) {
        $log->lwrite("dbase_parse:: Ping failed, making new pisql connection to server", 1);
        $pisql = new mysqli($dbhost, $dbuser, $dbpass, $dbname);
    }
    // If there is an error
    if ($pisql->connect_errno) {
        $log->lwrite("dbase_parse:: Failed to connect to MySQL: (" . $pisql->connect_errno . ") " . $pisql->connect_error, 1);
        return -1;
    }
    // For logging only
    if (is_array($message)) {
        $str = "";
        foreach ($message as $key => $val) {
            $str .= " {" . $key . ":" . $val . "},";
        }
        $log->lwrite("dbase_parse:: " . $cmd . ": " . $str, 1);
    } else {
        $log->lwrite("dbase_parse:: message: " . $cmd . ": " . $message, 1);
    }
    //
    // Depending on $cmd execute database function
    switch ($cmd) {
        // Database
        case "load_database":
            $ret = load_database();
            break;
            // Device
        // Device
        case "load_devices":
            $ret = load_devices();
            break;
        case "add_device":
            $ret = add_device($message);
            break;
        case "delete_device":
            $ret = delete_device($message);
            break;
        case "store_device":
            $ret = store_device($message);
            break;
            // Room
        // Room
        case "add_room":
            $ret = add_room($message);
            break;
        case "delete_room":
            $ret = delete_room($message);
            break;
            // Scene
        // Scene
        case "read_scene":
            $ret = load_scene($message);
            break;
        case "load_scenes":
            $ret = load_scenes();
            break;
        case "add_scene":
            $ret = add_scene($message);
            break;
        case "delete_scene":
            $ret = delete_scene($message);
            break;
        case "upd_scene":
            $ret = upd_scene($message);
            break;
        case "store_scene":
            $ret = store_scene($message);
            break;
            // Timer
        // Timer
        case "add_timer":
            $ret = add_timer($message);
            break;
        case "delete_timer":
            $ret = delete_timer($message);
            break;
        case "store_timer":
            $ret = store_timer($message);
            break;
            // Handset
        // Handset
        case "add_handset":
            $ret = add_handset($message);
            break;
        case "delete_handset":
            $ret = delete_handset($message);
            break;
        case "store_handset":
            $ret = store_handset($message);
            break;
            // Weather
        // Weather
        case "add_weather":
            $ret = add_weather($message);
            break;
        case "delete_weather":
            $ret = delete_weather($message);
            break;
            // Setting
        // Setting
        case "store_setting":
            $ret = store_setting($message);
            break;
        default:
    }
    if ($ret >= 0) {
        // Prepare structure to send back to the calling ajax client (in stdout)
        $send = array('tcnt' => $ret, 'appmsg' => $appmsg, 'status' => 'OK', 'apperr' => $apperr);
        $output = json_encode($send);
    } else {
        //	Functions need to fill apperr themselves!
        $send = array('tcnt' => $ret, 'appmsg' => $appmsg, 'status' => 'ERR', 'apperr' => $apperr);
        $output = json_encode($send);
    }
    return $output;
}
Пример #3
0
     $apperr .= "Calling add_room:: icsmsg: " . $icsmsg . ", json: " . json_decode($icsmsg) . "\n";
     $tcnt = add_room($icsmsg);
     $apperr .= "\nAdd room ";
     $ret = $tcnt;
     break;
 case "delete_room":
     $apperr .= "Calling delete_room:: icsmsg: " . $icsmsg . ", json: " . json_decode($icsmsg) . "\n";
     $tcnt = delete_room($icsmsg);
     $apperr .= "\ndelete room ";
     $ret = $tcnt;
     break;
     // Scene commands
 // Scene commands
 case "add_scene":
     $apperr .= "Calling add_scene:: icsmsg: " . $icsmsg . ", json: " . json_decode($icsmsg) . "\n";
     $tcnt = add_scene($icsmsg);
     $apperr .= "\nScene added ";
     $ret = $tcnt;
     break;
 case "upd_scene":
     $apperr .= "Calling upd_scene:: icsmsg: " . $icsmsg . ", json: " . json_decode($icsmsg) . "\n";
     $tcnt = store_scene($icsmsg);
     $apperr .= "\nScene updated ";
     $ret = $tcnt;
     break;
 case "store_scene":
     $apperr .= "Calling store_scene:: jsonmsg: " . jason_decode($icsmsg) . "\n";
     $tcnt = store_scene($icsmsg);
     $apperr .= "\nScene stored ";
     $ret = $tcnt;
     break;