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(); $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>';