require_once PATH_LIB . "nabz_lib.php"; require_once PATH_LIB . "form.php"; $form_mail_nabz = new Form('form_mail_nabz'); $form_mail_nabz->method('POST'); $form_mail_nabz->add('Textarea', 'mail_content')->label('Message')->cols(100)->rows(20); $form_mail_nabz->add('Select', 'lang_select')->label('Langue')->choices('Français', 'Anglais'); $form_mail_nabz->add('Submit', 'Envoyer'); if ($form_mail_nabz->is_valid($_POST)) { $message = $_POST['mail_content']; //dont use get_cleaned because it loose the aspect of the txt //Messages in different languages $lang = $form_mail_nabz->get_cleaned_data('lang_select'); if ($lang != 'Français') { $lang = "us"; } else { $lang = "fr"; } $tbx = list_all_rabbits(); foreach ($tbx as $key => $value) { $nabz_serial = $tbx[$key]['rabbit_serial']; $nabz_token = $tbx[$key]['rabbit_token']; //Send message with lib+API $nabaztag = new Nabaztag($nabz_serial, $nabz_token, $lang); $nabaztag->dire($message); $nabaztag->send(); } } //end of is_valid include PATH_VIEW . 'form_mail_all_nabz.php'; } //end of user_admin
$infos_rabbit = read_skill_nabz($rabbit); $sntoken_rabbit = get_serial_and_token($rabbit); print_r($sntoken_rabbit); $nabz_serial = $sntoken_rabbit['rabbit_serial']; $nabz_token = $sntoken_rabbit['rabbit_token']; if ($infos_rabbit['skill_angry'] < 50) { $message = "J'ai faim"; } if ($infos_rabbit['skill_thirst'] < 50) { $message .= "J'ai soif"; } if ($infos_rabbit['skill_health'] < 50) { $message .= "Je suis malade"; } //When lang will be implemented in ddb /*if($lang != 'Français') { $lang ="us"; }else { $lang = "fr"; }*/ if ($message != "") { //Send message with lib+API $nabaztag = new Nabaztag($nabz_serial, $nabz_token); $nabaztag->dire($message); $nabaztag->send(); $msg_confirm[] = $nabaztag->getAPImsg(); } //include PATH_LIB.'sendMess.php'; } //end foreach