NB : Cette page est appellée en parametre du programme C 'radioReception', vous voupvez tout à fait appeller une autre page en renseignant le parametre lors de l'execution du programme C. @author : Valentin CARRUESCO (idleman@idleman.fr) @licence : CC by sa (http://creativecommons.org/licenses/by-sa/3.0/fr/) RadioPi de Valentin CARRUESCO (Idleman) est mis à disposition selon les termes de la licence Creative Commons Attribution - Partage dans les Mêmes Conditions 3.0 France. Les autorisations au-delà du champ de cette licence peuvent être obtenues à idleman@idleman.fr. */ //Récuperation des parametres du signal sous forme de variables //list($file,$step,$cpt) = $_SERVER['argv']; //Affichages des valeurs dans la console a titre informatif //echo "\nemetteur : $sender,\n Groupe :$group,\n on/off :$state,\n boutton :$interruptor"; //echo $argv[1]; //$step //echo $argv[2]; //$cpt echo "step=" . $argv[1] . " et cpt=" . $argv[2] . "\n"; //echo "step=".$_GET['step']." et cpt=".$_GET['cpt']; include 'detect_porte.class.php'; $odetect_porte = new detect_porte(); $result = $odetect_porte->active_options(); echo $result; /*************************************************************************/ //Envoie de mail DEBUG $to = "*****@*****.**"; $subject = "Urgent"; $message = "<html><head></head><body>DEBUG DETECTION APPART : <\\br> step=" . $argv[1] . " et cpt=" . $argv[2] . "<\\br> </body></html>"; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n"; $flag = mail($to, $subject, $message, $headers); //echo 'Mail envoyé ='.$flag; /*************************************************************************/
<?php /* @name detectporte @author Nori @link http://pasdelien.com @licence Nori @version 1.0.0 @description Plugin pour la detection de porte sans fil */ include 'detect_porte.class.php'; $odetect_porte = new detect_porte(); if (isset($_GET['action'])) { switch ($_GET['action']) { case 'status': //statut de la detection $result = $odetect_porte->get_detect_status(); echo $result; break; case 'option': //sauvegarde des options if (isset($_GET['video'])) { $video = $_GET['video']; } else { $video = "0"; } if (isset($_GET['tv'])) { $tv = $_GET['tv']; } else { $tv = "0"; }
function detectporte_action() { global $_, $conf; $odetect_porte = new detect_porte(); switch ($_['action']) { case 'detectporte_sors': global $_; //activation de la détection $result = $odetect_porte->launch_detect(); if ($result == 1) { $possible_answers = array('OK. Jactive la sécurité.', 'Jactive la sécurité. Passe une bonne journée', 'OK. Jactive la sécurité. A plus', 'OK. Je moccupe du reste'); } else { $possible_answers = array('OK. La sécurité tourne déjà.', ' La sécurité tourne déjà. Passe une bonne journée', 'OK. La sécurité tourne déjà. A plus', 'OK. Je moccupe du reste'); } $affirmation = $possible_answers[rand(0, count($possible_answers) - 1)]; $response = array('responses' => array(array('type' => 'talk', 'sentence' => $affirmation))); $json = json_encode($response); echo $json == '[]' ? '{}' : $json; break; case 'detectporte_securite': global $_; //activation de la détection $result = $odetect_porte->launch_detect(); if ($result == 1) { $possible_answers = array('Sécurité activée.', "OK. C'est fait"); } else { $possible_answers = array('Il tourne déjà'); } $affirmation = $possible_answers[rand(0, count($possible_answers) - 1)]; $response = array('responses' => array(array('type' => 'talk', 'sentence' => $affirmation))); $json = json_encode($response); echo $json == '[]' ? '{}' : $json; break; case 'detectporte_desactive': global $_; //activation de la détection $result = $odetect_porte->stop_detect(); if ($result == 1) { $possible_answers = array('Sécurité désactivée.'); } else { $possible_answers = array('Il est déjà stopé', 'Il ne tournait pas'); } $affirmation = $possible_answers[rand(0, count($possible_answers) - 1)]; $response = array('responses' => array(array('type' => 'talk', 'sentence' => $affirmation))); $json = json_encode($response); echo $json == '[]' ? '{}' : $json; break; case 'detectporte_rentre': global $_; //activation de la détection $result = $odetect_porte->stop_detect(); if ($result == 1) { $possible_answers = array('Bienvenu. Je désactive la Sécurité.', "Coucou. j'ai coupé la sécurité"); } else { $possible_answers = array('Bienvenu. ', 'Coucou.'); } $affirmation = $possible_answers[rand(0, count($possible_answers) - 1)]; $response = array('responses' => array(array('type' => 'talk', 'sentence' => $affirmation))); $json = json_encode($response); echo $json == '[]' ? '{}' : $json; break; } }
<?php include 'detect_porte.class.php'; //echo 'début </br>'; $odetect_porte = new detect_porte(); $result = $odetect_porte->launch_detect(); echo $result; //fwrite($fp,"1\n"); //echo 'fwrite ok '; /* //création du fichier de flag disant au programme de continuer tant qu'il existe $fp=fopen("running_flag.txt","c+"); if (fwrite($fp,"1\n")) { echo "Le fichier à été créé avec succès</br>"; } else { // Erreur echo "Impossible de créer le fichier</br>"; } fclose($fp); //lancement du programme de détection //on vérifie que le fichier de flag du prog C n'existe pas sinon on va lancer 2 programmes en parallèle $fichier = 'running_C.txt'; if( file_exists ( $fichier)) echo "le programme est déjà en train de tourner</br>"; else exec("sudo /var/www/detect_porte/detect_porte /var/www/detect_porte/detect_porte.php 1"); */ /*
<?php include 'detect_porte.class.php'; //echo 'début </br>'; $odetect_porte = new detect_porte(); $odetect_porte->stop_detect(); /* //suppression fichier $fichier = 'running_flag.txt'; $fichier2 = 'running_C.txt'; if( file_exists ( $fichier)){ unlink( $fichier ) ; echo 'running_flag supprimé </br>'; } if( file_exists ( $fichier2)){ unlink( $fichier2 ) ; echo 'running_C supprimé </br>'; } */ echo 'stop </br>';