Exemple #1
0
function displayEditPage($mac, $editIndex, &$s20Table, $myUrl)
{
    global $daysOfWeek;
    $timerName = $s20Table[$mac]['name'];
    $details = $_SESSION['details'];
    $nTimers = count($details);
    $thisTimer = $details[(int) $editIndex];
    ?>

<div style="text-align:center">
<h2> 
<?php 
    echo $timerName;
    echo '<img src="' . IMG_PATH . ($s20Table[$mac]['st'] ? "greenCircle100px.png" : "redCircle100px.png") . '" style="width:0.8em;position:relative;top:0.1em;left:0.3em;">';
    ?>
 
</h2>
<p>
<hr>

<?php 
    if ($editIndex < 0) {
        $h = $m = $s = 0;
        $code = "";
        $action = 0;
    } else {
        secToHour($thisTimer['time'], $h, $m, $s);
        $recCode = $thisTimer['recCode'];
        $action = $thisTimer['action'];
    }
    ?>

<div>
<form action="<?php 
    echo $myUrl;
    ?>
" method="post">
    <input type="submit" name="toDetailsPage" value="back<?php 
    echo $mac;
    ?>
" 
        id="backButton"> 
    <div>hh : mm : ss</div>
<div>
<select name="hours">
<?php 
    for ($i = 0; $i < 24; $i++) {
        if ($i == $h) {
            $selected = ' selected="selected"';
        } else {
            $selected = '';
        }
        echo '<option value="' . $i . '"' . $selected . '>' . $i . '</option>' . "\n";
    }
    ?>
</select>:
<select name="minutes">
<?php 
    for ($i = 0; $i < 60; $i++) {
        if ($i == $m) {
            $selected = ' selected="selected"';
        } else {
            $selected = '';
        }
        echo '<option value="' . $i . '"' . $selected . '>' . $i . '</option>' . "\n";
    }
    ?>
</select>:
<select name="seconds">
<?php 
    for ($i = 0; $i < 60; $i++) {
        if ($i == $s) {
            $selected = ' selected="selected"';
        } else {
            $selected = '';
        }
        echo '<option value="' . $i . '"' . $selected . '>' . $i . '</option>' . "\n";
    }
    ?>


</select>
</div>
<p>
<p>


<div>
Action<br>
<input id="action1" type="radio" name="detailAction" value="0" <?php 
    if ($action == 0) {
        echo "checked";
    }
    ?>
>
  <label for="action1"><span><span></span></span>OFF</label>
  <input id="action2" type="radio" name="detailAction" value="1" <?php 
    if ($action == 1) {
        echo "checked";
    }
    ?>
> 
  <label for="action2"><span><span></span></span>ON</label>
</div><p>
<p>
<hr>
<h2>Repeat every:</h2>
<div class="editDetail">

<?php 
    $bits = $thisTimer['r'];
    for ($k = 0; $k < 7; $k++) {
        $bit = (int) $bits % 2;
        $bits = (int) ($bits / 2);
        echo '<div class="rowDetail">';
        echo '<div class="weekDayCol">';
        echo $daysOfWeek[$k];
        echo '</div>';
        ?>
      <div class="checkBoxCol">
      <input type="checkbox" id="weekday<?php 
        echo $k;
        ?>
" 
        name="weekday<?php 
        echo $k;
        ?>
"  <?php 
        if ($bit == 1) {
            echo "checked";
        }
        ?>
 onclick="updateAllFunc()" > 
      <label for="weekday<?php 
        echo $k;
        ?>
" ><span></span></label>        
      </div>
      </div>
<?php 
    }
    ?>
 <p>
 <div class="rowDetail">
   <div class="weekDayCol"> Everyday </div>
   <div class="checkBoxCol">
      <input type="checkbox" id="setAll" onclick="setAllFunc()">       <label for="setAll"><span></span></label>        
   </div>
 </div>
 <div class="rowDetail">
   <div class="weekDayCol"> Once </div>
   <div class="checkBoxCol">
      <input type="checkbox" id="clearAll" onclick="clearAllFunc()">       <label for="clearAll"><span></span></label>        
   </div>
 </div>
</div>
<hr>
<button type="submit" name="toDetailsPage" value="updateOrAdd<?php 
    echo $mac;
    ?>
" id="doneButton">Done</button>
<input type="hidden" name="recCode" value="<?php 
    echo $recCode;
    ?>
">
</form>
<script>
updateAllFunc();
</script>
<?php 
}
Exemple #2
0
function secToHourString($seconds)
{
    secToHour($seconds, $h, $m, $s);
    return sprintf("%02d:%02d:%02d", $h, $m, $s);
}
Exemple #3
0
function checkTimer($mac, $s20Table, &$h, &$m, &$sec, &$action)
{
    //
    // Check if countdown timer of device with mac $mac is set.
    // Updates the arguments h,m, and s with hour, minutes and seconds
    // and updates value action with 0 (Off) or 1 (On).
    // If no countdown timer is programmed, returns 0, otherwise 1.
    //
    $cmdCode = "6364";
    $checkTimer = "01000000";
    $checkTimerHexMsg = MAGIC_KEY . "001A" . $cmdCode . $mac . TWENTIES . FOUR_ZEROS . $checkTimer;
    $recHex = createSocketSendHexMsgWaitReply($mac, $checkTimerHexMsg, $s20Table);
    if (DEBUG) {
        echo "Check timer\n";
        echo "Sent\n";
        printHex($checkTimerHexMsg);
        echo "Rec\n";
        printHex($recHex);
    }
    $relevant = substr($recHex, -6);
    $status = substr($relevant, 0, 2);
    $isSet = 0;
    if ($status != "FF") {
        $isSet = 1;
        $timeHex = substr($relevant, 4, 2) . substr($relevant, 2, 2);
        $seconds = hexdec($timeHex);
        secToHour($seconds, $h, $m, $sec);
        if ($status == "00") {
            $action = 0;
        } else {
            $action = 1;
        }
        // Set to turn on
    } else {
        $h = $m = $sec = $action = 0;
    }
    return $isSet;
}
Exemple #4
0
function checkTimer($mac, $s20Table, &$h, &$m, &$s, &$action)
{
    $ip = $s20Table[$mac]['ip'];
    $cmdCode = "6364";
    $checkTimer = "01000000";
    $checkTimerHexMsg = MAGIC_KEY . "001A" . $cmdCode . $mac . TWENTIES . FOUR_ZEROS . $checkTimer;
    $s = createSocketAndBind($ip);
    $recHex = sendHexMsgWaitReply($s, $checkTimerHexMsg, $ip);
    if (DEBUG) {
        echo "Check timer\n";
        echo "Sent\n";
        printHex($checkTimerHexMsg);
        echo "Rec\n";
        printHex($recHex);
    }
    socket_close($s);
    $relevant = substr($recHex, -6);
    $status = substr($relevant, 0, 2);
    $isSet = 0;
    if ($status != "FF") {
        $isSet = 1;
        $timeHex = substr($relevant, 4, 2) . substr($relevant, 2, 2);
        $sec = hexdec($timeHex);
        secToHour($sec, $h, $m, $s);
        if ($status == "00") {
            $action = 0;
        } else {
            $action = 1;
        }
        // Set to turn on
    }
    return $isSet;
}
Exemple #5
0
    $aVideo = $oPDO->query('SELECT * FROM youtube, cooldown WHERE timePlay>0 AND cooldown.name="YOUTUBE_MSG" AND cooldown.stepNext=youtube.ID')->fetch(PDO::FETCH_ASSOC);
    if ($aVideo && $iMSGStatus == 0) {
        // UNE ANNONCE EXISTE
        if ($aVideo['timerNext'] > microtrue()) {
            // ANNONCE TOUJOURS VALABLE
            $sMSG = $aVideo['titre'] . ' [' . secToHour($aVideo['duree']) . '] de ' . $aVideo['auteur'];
            $sTITRE = MSG_YOUTUBE_TITRE;
            $iMSGStatus = 1;
        }
    } else {
        if ($iMSGStatus == 0) {
            // AUCUNE ANNONCE EXISTE
            $aVideo = $oPDO->query('SELECT * FROM youtube WHERE timePlay>0')->fetch(PDO::FETCH_ASSOC);
            $oPDO->query('DELETE FROM cooldown WHERE name="YOUTUBE_MSG"');
            $oPDO->query('INSERT INTO cooldown SET name="YOUTUBE_MSG", stepNext=' . $aVideo['ID'] . ', timerNext=' . (microtrue() + COOLDOWN_MSG_YOUTUBE_LIFETIME));
            $sMSG = $aVideo['titre'] . ' [' . secToHour($aVideo['duree']) . '] de ' . $aVideo['auteur'];
            $sTITRE = MSG_YOUTUBE_TITRE;
            $iMSGStatus = 1;
        }
    }
}
// SINON CHOPE UNE PHRASE DANS LA TABLE
if ($iMSGStatus == 0) {
    include './php/messageStats.php';
    // VERIFIE LE TIMER
    $oPDO->query('DELETE FROM cooldown WHERE timerNext<' . microtrue() . ' AND name="MESSAGE"');
    $aCD = $oPDO->query('SELECT * FROM cooldown WHERE timerNext>' . microtrue() . ' AND name="MESSAGE"')->fetch(PDO::FETCH_ASSOC);
    if (!$aCD) {
        // AUCUN MESSAGE
        $oPDO->query('UPDATE message SET actual=0, used=1 WHERE actual=1');
        $aMSG = $oPDO->query('SELECT * FROM message WHERE actual=0 AND used=0 ORDER BY RAND() LIMIT 0,1')->fetch(PDO::FETCH_ASSOC);
Exemple #6
0
 }
 $sTitre = trim($sTitre[1]);
 if (!isset($sTitre)) {
     break;
 }
 // Vérifie la longueur
 if (!preg_match('#length_seconds":(.*?),#si', $sHTTP, $iDuree)) {
     echo ' toujours pas..';
     break;
 }
 $iDuree = intval($iDuree[1]);
 if (empty($iDuree) || $iDuree == 0) {
     break;
 }
 $sTitre = html_entity_decode($sTitre, ENT_QUOTES, 'UTF-8');
 $sDuree = secToHour($iDuree);
 // Vérifie les fond du viewer
 if ($sAuteur != 'Nestoyeur') {
     $aViewer = $oPDO->query('SELECT * FROM viewer WHERE name="' . $sAuteur . '"')->fetch(PDO::FETCH_ASSOC);
     if (!$aViewer['gils'] || intval($aViewer['gils']) < intval($iDuree)) {
         dire('dire [YOUTUBE] Vous n\'avez pas asse de gils ' . $aViewer['name'] . ' (' . $aViewer['gils'] . ' sur ' . $iDuree . ' gils nécessaire)');
         break;
     }
 }
 // Revérifie le doublon mais pas seulement pour playlist viewer cette fois
 $iCount = $oPDO->query('SELECT COUNT(*) FROM youtube WHERE youtubeID="' . $sLink . '"')->fetch(PDO::FETCH_COLUMN);
 if ($sPlaylist == 'viewer') {
     $iCount = '0';
 }
 // met a jour le fichier
 if ($iCount != '0') {