function display_skill($id_nabz) { $skill_nabz = read_skill_nabz($id_nabz); $skill_angry = $skill_nabz['skill_angry']; $skill_thirst = $skill_nabz['skill_thirst']; $skill_health = $skill_nabz['skill_health']; echo '<div id="skill_bar" >'; echo display_bar($skill_angry, 'food'); echo '<br /><br />'; echo display_bar($skill_thirst, 'drink'); echo '<br /><br />'; echo display_bar($skill_health, 'health'); echo '</div>'; }
<?php // Initialisation include 'global/init.php'; require_once PATH_MODEL . 'cron.php'; require_once PATH_MODEL . 'nabz.php'; require_once PATH_LIB . "nabz_lib.php"; $tbx_rabbits_id = list_all_rabbits(); foreach ($tbx_rabbits_id as $rabbit) { $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 != "") {
<div id="nabz_summary"> <?php //require_once("menu_nabz.php"); ?> <?php require_once PATH_MODEL . 'nabz.php'; require_once "global/menu_nabz.php"; $infos_nabz = read_infos_nabz($_SESSION['id']); if ($infos_nabz !== false) { $id_nabz = $infos_nabz['rabbit_id']; $nabz_name = $infos_nabz['rabbit_name']; $_SESSION['nabzname'] = $nabz_name; //extract skills of the nabz $skill_nabz = read_skill_nabz($id_nabz); $skill_angry = $skill_nabz['skill_angry']; $skill_thirst = $skill_nabz['skill_thirst']; $skill_health = $skill_nabz['skill_health']; } display_avatar_name(); ?> <br /> <?php display_skill($id_nabz); /*call display skill function */ ?> </div>
<?php if (!user_admin()) { include PATH_GLOBAL_VIEW . 'error_not_admin.php'; } else { include PATH_LIB . 'form.php'; require_once PATH_MODEL . 'admin.php'; require_once PATH_MODEL . 'members.php'; //include the two models to not rewrite functions that already exist require_once PATH_MODEL . 'nabz.php'; $id_nabz = $_GET['nabz_id']; $id_user = $_GET['uid']; $user_balance = user_balance($id_user); $infos_nabz = read_infos_nabz($id_user); $infos_nabz_skill = read_skill_nabz($id_nabz); $form_edit_nabz = new Form('form_edit_nabz'); $form_edit_nabz->method('POST'); $form_edit_nabz->add('Text', 'serial')->label('Serial')->value($infos_nabz['rabbit_serial']); $form_edit_nabz->add('Text', 'token')->label('Token')->value($infos_nabz['rabbit_token']); $form_edit_nabz->add('Text', 'name')->label('Nom')->value($infos_nabz['rabbit_name']); $form_edit_nabz->add('Text', 'skill_angry')->label('Faim')->value($infos_nabz_skill['skill_angry']); $form_edit_nabz->add('Text', 'skill_thirst')->label('Soif')->value($infos_nabz_skill['skill_thirst']); $form_edit_nabz->add('Text', 'skill_health')->label('Santé')->value($infos_nabz_skill['skill_health']); $form_edit_nabz->add('Submit', 'submit')->value('Éditer'); if ($form_edit_nabz->is_valid($_POST)) { list($new_nabz_serial, $new_nabz_token, $new_nabz_name, $new_skill_angry, $new_skill_thirst, $new_skill_health) = $form_edit_nabz->get_cleaned_data('serial', 'token', 'rabbit_name', 'skill_angry', 'skill_thirst', 'skill_health'); if (nabz_exists($new_nabz_serial, $new_nabz_token) == true) { update_infos_nabz($id_user, $new_nabz_serial, $new_nabz_token); } else { $error_update[] = "Couple token/serial incorrect."; }