Пример #1
0
function get($lastmodified, $api)
{
    $sync = new Sync();
    $output = array();
    if ($lastmodified < $sync->get(Sync::USER)) {
        $output[Sync::USER] = getUser($api);
    }
    if ($lastmodified < $sync->get(Sync::SCENARIOS)) {
        $output[Sync::SCENARIOS] = getScenarios();
    }
    if ($lastmodified < $sync->get(Sync::LIGHTS)) {
        $output[Sync::LIGHTS] = getLights();
    }
    if ($lastmodified < $sync->get(Sync::ROOMS)) {
        $output[Sync::ROOMS] = getRooms();
    }
    if ($lastmodified < $sync->get(Sync::PLANTS)) {
        $output[Sync::PLANTS] = getPlants();
    }
    if ($lastmodified < $sync->get(Sync::DEVICES)) {
        $output[Sync::DEVICES] = getDevices();
    }
    if ($lastmodified < $sync->get(Sync::SENSORS)) {
        $output[Sync::SENSORS] = getSensors();
    }
    if ($lastmodified < $sync->get(Sync::EAN)) {
        $output[Sync::EAN] = getEan();
    }
    return $output;
}
Пример #2
0
function get()
{
    $hue = new Hue();
    $rooms = getRooms();
    $lights_hue = $hue->loadLights();
    $output = array('lights' => $lights_hue, 'rooms' => $rooms);
    http_response_code(202);
    return $output;
}
function getRooms($pointer)
{
    global $rooms;
    $room = getRoomAt($pointer);
    if (!isset($rooms[$room['id']])) {
        $rooms[$room['id']] = $room;
        foreach ($room['exits'] as $e) {
            getRooms($e['dest']);
        }
    }
}
 $sFiles = "";
 $res = getResult("SELECT * FROM `" . MODULE_DB_PREFIX . "Messages` WHERE `Type`='file' AND `Recipient`='" . $sId . "'");
 while ($aFile = mysql_fetch_assoc($res)) {
     $sFileName = $aFile['ID'] . ".file";
     if (!file_exists($sFilesPath . $sFileName)) {
         continue;
     }
     $sFiles .= parseXml($aXmlTemplates['file'], $aFile['Sender'], $sFileName, $aFile['Message']);
 }
 getResult("DELETE FROM `" . MODULE_DB_PREFIX . "Messages` WHERE `Type`='file' AND `Recipient`='" . $sId . "'");
 $sContents = makeGroup($sFiles, "files");
 //--- update user's info ---//
 $sContents .= refreshUsersInfo($sId, 'update');
 //--- check for new rooms ---//
 $sContents .= makeGroup(getRooms('update', $sId), "rooms");
 $sContents .= makeGroup(getRooms('updateUsers', $sId), "roomsUsers");
 //--- check for new messages ---//
 $iUpdateInterval = (int) getSettingValue($sModule, "updateInterval");
 $sMsgs = "";
 $sRooms = getValue("SELECT GROUP_CONCAT(DISTINCT `Room` SEPARATOR ',') FROM `" . MODULE_DB_PREFIX . "RoomsUsers` WHERE `User`='" . $sId . "' AND `Status`='" . ROOM_STATUS_NORMAL . "'");
 if (empty($sRooms)) {
     $sRooms = "''";
 }
 $sSql = "SELECT * FROM `" . MODULE_DB_PREFIX . "Messages` WHERE `Type`='text' AND `Sender`<>'" . $sId . "' AND ((`Room` IN (" . $sRooms . ") AND `Whisper`='" . FALSE_VAL . "') OR `Recipient`='" . $sId . "') AND `When`>='" . (time() - $iUpdateInterval) . "' ORDER BY `ID`";
 $res = getResult($sSql);
 while ($aMsg = mysql_fetch_assoc($res)) {
     $aStyle = unserialize($aMsg['Style']);
     $sMsgs .= parseXml($aXmlTemplates['message'], $aMsg['ID'], stripslashes($aMsg['Message']), $aMsg['Room'], $aMsg['Sender'], $aMsg['Recipient'], $aMsg['Whisper'], $aStyle['color'], $aStyle['bold'], $aStyle['underline'], $aStyle['italic'], $aStyle['size'], $aStyle['font'], $aStyle['smileset'], $aMsg['When']);
 }
 $sContents .= makeGroup($sMsgs, "messages");
 break;
Пример #5
0
function show_metabox_new_room()
{
    global $post;
    $html = '<label for="nombre_cuarto" class="label-paquetes-desc">Nombre: </label>';
    $html .= '<input type="text" name="nombre_cuarto" class="widefat-medium" value="" id="name-cuarto"/>';
    $html .= '<br><br><label for="descripcion_cuarto" class="label-paquetes-desc">Descripción: </label>';
    $html .= '<textarea type="text" name="descripcion_cuarto" class="widefat-medium" id="description-cuarto"/></textarea>';
    $html .= '<input type="hidden" id="post_id" class="widefat"	 value="' . $post->ID . '">';
    $html .= '<br><br><a href="#" class="button button-upload-select button-upload" data-editor="content"><span class="wp-media-buttons-icon" ></span> Agregar Imagen </a>';
    $html .= '<div class="imagen-a-agregar"></div>';
    $html .= '<span class="button-primary guardar-cuarto">Guardar</span><br><br><hr>';
    $html .= '<h3 id="box-cuartos">Cuartos</h3>';
    $html .= '<div class="rooms-container">';
    $rooms = getRooms($post->ID);
    if (!empty($rooms)) {
        foreach ($rooms as $key => $room) {
            $html .= '<div class="container-expu">';
            $html .= '<span class="eliminar-cuarto"
					data-id="' . $room->id . '"
					data-name="' . $room->name . '"
					 >
					Eliminar
				</span>';
            $html .= wp_get_attachment_image($room->id_attachmend, 'thumbnail');
            $html .= '<p>' . $room->name . '</p>';
            $html .= '<p>' . $room->description . '</p>';
            $html .= '</div>';
        }
    }
    $html .= '</div>';
    echo $html;
}
Пример #6
0
		<?php 
        }
        ?>

	</select>
	<br><br>
	Device Name:<br>
	<input type="text" name="wdevice_name" value="<?php 
        echo utf8_encode($workdata['device']);
        ?>
">
	<br><br>
	Room:<br>
	<select name="wroom_id">
		<?php 
        $ro = getRooms();
        for ($x = 0; $x < count($ro); $x++) {
            if ($ro[$x]["id"] == $workdata['room_id']) {
                echo '<option value="' . $ro[$x]["id"] . '" selected>' . utf8_encode($ro[$x]["room"]) . '</option>';
            } else {
                echo '<option value="' . $ro[$x]["id"] . '">' . utf8_encode($ro[$x]["room"]) . '</option>';
            }
        }
        ?>
	</select>
	<br><br>
	Letter:<br>
	<?php 
        $letters = array("A", "B", "C", "D");
        ?>
	<select name="wletter">		
Пример #7
0
echo wp_get_attachment_image($id_attachment, 'full', false, ['class' => '[ img-responsive ][ hidden-md hidden-lg ]']);
?>
						<!-- Diagrama desktop -->
						<?php 
echo wp_get_attachment_image($id_attachment, 'full', false, ['class' => '[ img-responsive ][ hidden-xs hidden-sm ]']);
?>
					</section>
				</div>
			</div>

			<section>
				<!-- Cuartos -->
				<h3 class="[ text-center ][ color-primary ][ margin-bottom ]">Cabinas</h3>
				<div class="[ row ]">
					<?php 
$rooms = getRooms($post->ID);
if (!empty($rooms)) {
    foreach ($rooms as $room) {
        ?>
							<div class="[ col-xs-6 col-md-3 ][ margin-bottom ]">
								<?php 
        echo wp_get_attachment_image($room->id_attachmend, 'medium', false, ['class' => '[ img-responsive ][ margin-bottom--small ]']);
        ?>

								<p class="[ color-primary ][ normal ][ line-height-small ][ margin-bottom--small ]"><?php 
        echo $room->name;
        ?>
</p>
								<p><?php 
        echo $room->description;
        ?>
         getResult("REPLACE `" . MODULE_DB_PREFIX . "CurrentUsers` SET `ID`='" . $sId . "', `Nick`='" . $aUserInfo['nick'] . "', `RoomID`='" . $iRoomId . "', `Sex`='" . $aUserInfo['sex'] . "', `Age`='" . $aUserInfo['age'] . "', `Desc`='" . addslashes($aUserInfo['desc']) . "', `Photo`='" . $aUserInfo['photo'] . "', `Profile`='" . $aUserInfo['profile'] . "', `When` = UNIX_TIMESTAMP(), `Status` = '" . USER_STATUS_NEW . "'");
     }
     //--- Update user's info and return info about all online users. ---//
     $sContents = refreshUsersInfo($sId);
     break;
     /**
      * Check for chat changes: new users, rooms, messages.
      * Note. This action is used in XML mode and by ADMIN.
      */
 /**
  * Check for chat changes: new users, rooms, messages.
  * Note. This action is used in XML mode and by ADMIN.
  */
 case 'update':
     //--- check for new rooms ---//
     $sContents .= makeGroup(getRooms('upd', $sId), "rooms");
     //--- update user's info ---//
     $sContents .= refreshUsersInfo($sId, 'upd');
     //--- check for new messages ---//
     $iUpdateInterval = (int) getSettingValue($sModule, "updateInterval");
     $sMsgs = "";
     $res = getResult("SELECT cm.`ID` AS `ID`, cm.`Msg` AS `Msg`, cm.`Style` AS `Style`, ccu.`ID` AS `userID` FROM `" . MODULE_DB_PREFIX . "Messages` AS cm, `" . MODULE_DB_PREFIX . "CurrentUsers` AS ccu WHERE cm.`UserID`=ccu.`ID` AND cm.`UserID`<>'" . $sId . "' AND cm.`When`>=(UNIX_TIMESTAMP()-" . $iUpdateInterval . ") ORDER BY cm.`ID`");
     while ($aMsg = mysql_fetch_assoc($res)) {
         $aStyle = unserialize($aMsg['Style']);
         $sMsgs .= parseXml($aXmlTemplates['message'], $aMsg['ID'], stripslashes($aMsg['Msg']), $aMsg['userID'], $aStyle['color'], $aStyle['bold'], $aStyle['underline'], $aStyle['italic'], $aStyle['smileset']);
     }
     $sContents .= makeGroup($sMsgs, "msgs");
     break;
     /**
      * Add message to database.
      */
Пример #9
0
require_once __DIR__ . '/classes/connexion.php';
require_once __DIR__ . '/classes/checkAPI.php';
require_once __DIR__ . '/classes/Settings.php';
require_once __DIR__ . '/classes/Alarm.php';
require_once __DIR__ . '/classes/Mode.php';
require_once __DIR__ . '/classes/VigilanceMeteo.php';
require_once __DIR__ . '/classes/Weather.php';
$page_level = 1;
$settings = new Settings();
$vigilance = new VigilanceMeteo();
if (isset($_REQUEST['api']) && checkAPI($_REQUEST['api'], $page_level)) {
    switch ($_SERVER['REQUEST_METHOD']) {
        case 'GET':
            $alarm = $settings->getSettings('Alarm', 'status');
            http_response_code(202);
            echo json_encode(array('alarm' => $alarm, 'weather' => getWeather(), 'rooms' => getRooms(), 'mode' => (new Mode())->getMode()));
            break;
        case 'PUT':
            echo json_encode(update($_REQUEST));
            break;
    }
} else {
    if ($argc > 1) {
        switch ($argv[1]) {
            case 'weather':
                setWeather();
                break;
        }
    } else {
        http_response_code(403);
    }
Пример #10
0
function add2Room($clientID, $user_id, $room)
{
    global $Server;
    $mes = 'Приглашен в комнату пользователем ' . $Server->wsClients[$clientID][13];
    // sendMess($id, $data);
    addHistory($user_id, $mes, '000', $room);
    if (getRoom($room, $user_id)) {
        updateRoom($room, false, $user_id);
    } else {
        updateRoom($room);
    }
    foreach ($Server->wsClients as $id => $data) {
        if ($data[15] != $room) {
            if ($data[12] == $user_id) {
                sendMess($id, array('System', $Server->wsClients[$clientID][13] . ' пригласил Вас в чат <a href="index.php?module=kChat&room=' . $room . '">"' . getRoomName($room, $data[12]) . '"</a>', '000;font-weight:bolder'));
                getRooms($id);
            }
        } else {
            getUsers($id, $room);
        }
    }
}
Пример #11
0
 *
 * PiHome Copyright (c) 2012, Sebastian Harke
 * Lizenz Informationen.
 * 
 * This work is licensed under the Creative Commons Namensnennung - Nicht-kommerziell - Weitergabe unter gleichen Bedingungen 3.0 Unported License. To view a copy of this license,
 * visit: http://creativecommons.org/licenses/by-nc-sa/3.0/.
 *
*/
require '../configs/dbconfig.inc.php';
require 'configs/functions.inc.php';
?>


<ul>
	<?php 
$rp = getRooms();
for ($x = 0; $x < count($rp); $x++) {
    ?>
	
		<li>
			<div class="light">			
				<div class="name_room"><div class="device"><?php 
    echo utf8_encode($rp[$x]["room"]);
    ?>
</div></div>
				<div class="btn_room">
					<span><a href="javascript:update_room('<?php 
    echo $rp[$x]["id"];
    ?>
');"><img src="images/work.png" border="0"></a></span><span><a href="javascript:del_room('<?php 
    echo $rp[$x]["id"];
Пример #12
0
function get($arr)
{
    $zwave = new Zwave();
    if (isset($arr['id'])) {
        $result = getDeviceDetails($arr['id']);
        $rooms = getRooms();
        $output = array('devices' => $result, 'rooms' => $rooms);
        return $result;
    } else {
        if (isset($arr['scenario'])) {
            $bdd = getBDD();
            $sensor = $arr['scenario'];
            $req = $bdd->query("SELECT * FROM at_sensors_scenarios WHERE sensor = {$sensor}");
            $result = array();
            while ($data = $req->fetch()) {
                $result[] = array('id' => $data['id'], 'sensor' => $data['sensor'], 'scenario' => $data['scenario']);
            }
            return $result;
        } else {
            if (isset($arr['type'])) {
                $type = $arr['type'];
                $bdd = getBDD();
                $req = $bdd->query("SELECT at_sensors.*, at_sensors_devices.alias, at_sensors_devices.room FROM at_sensors INNER JOIN at_sensors_devices ON at_sensors.device = at_sensors_devices.device WHERE `type` = '{$type}' AND `ignore` = 0");
                $result = array();
                while ($data = $req->fetch()) {
                    $result[] = array('id' => $data['id'], 'sensor' => $data['sensor'], 'protocol' => $data['protocol'], 'type' => $data['type'], 'unit' => $data['unit'], 'history' => $data['history'], 'date' => $data['date'], 'time' => $data['time']);
                }
                return $result;
            } else {
                $devices_zwave = $zwave->loadDevices();
                $result = array_merge($devices_zwave);
                $rooms = getRooms();
                $output = array('devices' => $result, 'rooms' => $rooms);
                return $output;
            }
        }
    }
}