/** * Add monitoring of the propel object by the user * * @return void * @param BaseObject $object * @param int $user_id User primary key **/ public function addMonitoringUser(BaseObject $object, $user_id) { if (is_null($user_id) or trim((string) $user_id) === '') { throw new deppPropelActAsMonitorableException('Impossible to allow a user monitoring with no user primary key provided'); } // add the record $monitoring_object = new Monitoring(); $monitoring_object->setMonitorableModel(get_class($object)); $monitoring_object->setMonitorableId($this->getReferenceKey($object)); $monitoring_object->setUserId($user_id); $ret = $monitoring_object->save(); // update the caches $user = call_user_func_array(array($this->getMonitorerModel($object) . "Peer", 'retrieveByPK'), array($user_id)); $user->countMonitoredObjects(get_class($object), null, true); $this->countMonitoringUsers($object, true); }
function dash_monitoring_plugin_actions() { global $myUser, $_, $conf; switch ($_['action']) { case 'dash_monitoring_plugin_load': if ($myUser == false) { exit('Vous devez vous connecter pour cette action.'); } header('Content-type: application/json'); $response = array(); switch ($_['bloc']) { case 'ram': $response['title'] = 'RAM'; $hdds = Monitoring::ram(); $response['content'] = ' <div style="width: 100%"> <canvas id="RAM_PIE"></canvas> <br/><br/> <ul class="graphic_pane"> <li class="pane_orange"> <h1>RAM UTILISEE</h1> <h2>' . $hdds['percentage'] . '%</h2> </li><li class="pane_cyan"> <h1>RAM LIBRE</h1> <h2>' . $hdds['free'] . ' Mo</h2> </li><li class="pane_red"> <h1>RAM TOTALE</h1> <h2>' . $hdds['total'] . ' Mo</h2> </li> </ul> </div> <script> $("#RAM_PIE:visible").chart({ type : "doughnut", label : ["RAM UTILISEE","RAM LIBRE"], backgroundColor : ["' . ($hdds['percentage'] > 80 ? '#E64C65' : '#FCB150') . '","#4FC4F6"], segmentShowStroke:false, data : [' . $hdds['percentage'] . ',' . (100 - $hdds['percentage']) . '] }); </script>'; break; case 'system': $response['title'] = 'Système'; if (PHP_OS != 'WINNT') { $heat = Monitoring::heat(); $cpu = Monitoring::cpu(); } $response['content'] = '<ul class="yana-list"> <li><strong>Distribution :</strong> ' . Monitoring::distribution() . '</li> <li><strong>Kernel :</strong> ' . Monitoring::kernel() . '</li> <li><strong>HostName :</strong> ' . Monitoring::hostname() . '</li> <li><strong>Température :</strong> <span class="label ' . $heat["label"] . '">' . $heat["degrees"] . '°C</span></li> <li><strong>Temps de marche :</strong> ' . Monitoring::uptime() . '</li> <li><strong>CPU :</strong> <span class="label label-info">' . $cpu['current_frequency'] . ' Mhz</span> (Max ' . $cpu['maximum_frequency'] . ' Mhz/ Min ' . $cpu['minimum_frequency'] . ' Mhz)</li> <li><strong>Charge :</strong> <span class="label label-info">' . $cpu['loads'] . ' </span> | ' . $cpu['loads5'] . ' 5min | ' . $cpu['loads15'] . ' 15min</li> </ul>'; break; case 'vocal': if ($myUser->getId() == '') { exit('{"error":"invalid or missing token"}'); } if (!$myUser->can('vocal', 'r')) { exit('{"error":"insufficient permissions for this account"}'); } list($host, $port) = explode(':', $_SERVER['HTTP_HOST']); $actionUrl = 'http://' . $host . ':' . $_SERVER['SERVER_PORT'] . $_SERVER['REQUEST_URI']; $actionUrl = substr($actionUrl, 0, strpos($actionUrl, '?')); Plugin::callHook("vocal_command", array(&$response, $actionUrl)); $response['title'] = count($response['commands']) . ' Commandes vocales'; $response['content'] = '<ul class="yana-list">'; foreach ($response['commands'] as $command) { $response['content'] .= '<li title="Sensibilité : ' . $command['confidence'] . '">' . $command['command'] . '</li>'; } $response['content'] .= '</ul>'; break; case 'logs': if ($myUser->getId() == '') { exit('{"error":"invalid or missing token"}'); } $response['title'] = 'Logs'; $logs = dirname(__FILE__) . '/../../' . LOG_FILE; $response['content'] = '<div style="overflow:auto;max-height:200px;"><ul class="yana-list" style="margin:0px;">'; if (file_exists($logs)) { $lines = file($logs); foreach ($lines as $i => $line) { $response['content'] .= '<li style="font-size:8px;' . ($i % 2 == 0 ? 'background-color:#F4F4F4;' : '') . '">' . $line . '</li>'; } } else { $response['content'] .= '<li>Aucun logs</li>'; } $response['content'] .= '</ul></div>'; break; case 'network': $response['title'] = 'Réseau'; $ethernet = array(); $lan = ''; $wan = ''; $http = ''; $connections = ''; if (PHP_OS != 'WINNT') { $ethernet = Monitoring::ethernet(); $lan = Monitoring::internalIp(); $wan = Monitoring::externalIp(); $http = Monitoring::webServer(); $connections = Monitoring::connections(); } $response['content'] = '<ul class="yana-list"> <li><strong>IP LAN :</strong> <code>' . $lan . '</code></li> <li><strong>IP WAN :</strong> <code>' . $wan . '</code></li> <li><strong>Serveur HTTP :</strong> ' . $http . '</li> <li><strong>Ethernet :</strong> ' . $ethernet['up'] . ' Montant / ' . $ethernet['down'] . ' Descendant</li> <li><strong>Connexions :</strong> <span class="label label-info">' . $connections . '</span></li> </ul>'; break; case 'gpio': $response['title'] = 'GPIO'; $gpios = array(); $gpios = Monitoring::gpio(); $model = System::getModel(); $pinLabelsRange = System::getPinForModel($model['type'], $model['version']); $response['title'] = 'RPI Type ' . $model['type'] . ' V' . $model['version'] . ' (' . count($gpios) . ' pins)'; $response['content'] .= '<table class="gpio_container">'; $response['content'] .= '<tr>'; foreach ($pinLabelsRange as $range => $pinLabels) { $response['content'] .= '<td valign="top"><table>'; foreach ($pinLabels as $pin) { $roleColor = 'transparent'; $class = 'gpio_state_' . ($gpios[$pin->wiringPiNumber] ? 'on' : 'off'); if ($pin->name == '5V' || $pin->name == '3.3V') { $class = 'gpio_power'; } if ($pin->name == '0V' || $pin->name == 'DNC') { $class = 'gpio_ground'; } $response['content'] .= '<div class="' . $class . '" title="Role : ' . ($pin->role == '' ? 'GPIO' : $pin->role) . ', Position physique : ' . $pin->physicalNumber . ', Numero BMC : ' . $pin->bcmNumber . '" onclick="change_gpio_state(' . $pin->wiringPiNumber . ',this);">'; $response['content'] .= '<span style="' . ($range == 0 ? 'float:right;' : '') . '"></span> ' . $pin->name . ' <small>(' . ($pin->role == '' ? 'GPIO' : $pin->role) . ')</small>'; $response['content'] .= '</div>'; } $response['content'] .= '</table></td>'; } $response['content'] .= '</tr>'; $response['content'] .= '</table>'; break; case 'users': $users = array(); if (PHP_OS != 'WINNT') { $users = Monitoring::users(); } $response['title'] = count($users) . ' utilisateurs connectés'; $response['content'] = '<ul class="yana-list">'; foreach ($users as $value) { $response['content'] .= '<li>Utilisateur <strong class="badge">' . $value['user'] . '</strong> IP : <code>' . $value['ip'] . '</code>, Connexion : ' . $value['hour'] . ' </li>'; } $response['content'] .= '</ul>'; break; case 'services': $response['title'] = 'Services'; $services = array(); if (PHP_OS != 'WINNT') { $services = Monitoring::services(); $response['content'] = '<ul class="yana-list">'; foreach ($services as $value) { $response['content'] .= '<li ' . ($value['status'] ? 'class="service-active"' : '') . '>- ' . $value['name'] . '</li>'; } $response['content'] .= '</ul>'; } else { $response['content'] .= 'Information indisponible sur cet OS :' . PHP_OS; } break; case 'hdd': $response['title'] = 'HDD'; $hdds = array(); if (PHP_OS != 'WINNT') { $hdds = Monitoring::hdd(); $response['content'] = '<ul class="yana-list">'; foreach ($hdds as $value) { $response['content'] .= '<li><strong class="badge">' . $value['name'] . '</strong><br><strong> Espace :</strong> ' . $value['used'] . '/' . $value['total'] . '<strong> Format :</strong> ' . $value['format'] . ' </li>'; } $response['content'] .= '</ul>'; } else { $response['content'] .= 'Information indisponible sur cet OS :' . PHP_OS; } break; case 'disk': $response['title'] = 'Disques'; $disks = array(); if (PHP_OS != 'WINNT') { $disks = Monitoring::disks(); $response['content'] = '<ul class="yana-list">'; foreach ($disks as $value) { $response['content'] .= '<li><strong class="badge">' . $value['name'] . '</strong> Statut : ' . $value['size'] . ' Type : ' . $value['type'] . ' Chemin : ' . $value['mountpoint'] . ' </li>'; } $response['content'] .= '</ul>'; } else { $response['content'] .= 'Information indisponible sur cet OS :' . PHP_OS; } break; } echo json_encode($response); exit(0); break; case 'dash_monitoring_plugin_edit': echo '<label>Time Zone</label><input id="zone" type="text">'; break; case 'dash_monitoring_plugin_save': break; case 'dash_monitoring_plugin_delete': break; case 'dash_monitoring_plugin_move': break; } }
public function reserve_post($id) { // GET THE LAST RESERVATION $last_user_reservation = Reservation::where('user_id', Sentry::getUser()->id)->orderBy('created_at', 'desc')->first(); if (!is_null($last_user_reservation)) { $current_time = time(); $last_user_reservation_time = strtotime($last_user_reservation->created_at); $interval = abs($current_time - $last_user_reservation_time) / 3600; if ($interval < 15) { return Redirect::to('clients')->with('info', 'You must wait 15 hours before you can reserve again.'); } } if (is_null(Property::find($id))) { return Redirect::to('properties'); } $monitoring = Monitoring::where('block', Input::get('block'))->where('lot', Input::get('lot')) - first(); if (!is_null($monitoring) && $monitoring->status == false) { return Redirect::to('clients')->with('info', 'This s**t is not available sorry.'); } $rules = array('total_contract_price' => 'required', 'reservation_fee' => 'required', 'downpayment' => 'required', 'equity' => 'required', 'total_months' => 'required', 'monthly_fee' => 'required', 'agent_id' => 'required', 'terms' => 'required', 'block' => 'required|numeric', 'lot' => 'required|numeric'); $validator = Validator::make(Input::all(), $rules); if ($validator->fails()) { return Redirect::to('clients/reserve/' . $id)->withInput()->withErrors($validator); } else { $property = Property::find($id); $user = $this->user; // 0. CHANGE PROPERTY STATUS TO 0 $downpayment = intval(Input::get('downpayment')) / 100 * $property->price; $equity = $property->price - $downpayment - $property->reservation_fee; $total_months = intval(Input::get('total_months')); // 1. SAVE TO THE DATABASE $reservation = new Reservation(); $reservation->property_id = $id; $reservation->user_id = $this->user->id; $reservation->agent_id = Input::get('agent_id'); $reservation->total_contract_price = intval(Input::get('total_contract_price')); $reservation->downpayment = $downpayment; $reservation->reservation_fee = $property->reservation_fee; $reservation->block = Input::get('block'); $reservation->lot = Input::get('lot'); // LOANABLE AMOUNT $reservation->equity = $equity; $reservation->total_months = $total_months; $reservation->monthly_fee = $equity / $total_months; $reservation->terms = Input::get('terms'); //$reservation->unit_type = Input::get('unit_type'); $reservation->save(); // 2. NEW TRANSACTION $transaction = new Transaction(); $transaction->reference_number = date('Ymd') . '-' . strtoupper(str_random(5)); $transaction->property_id = $id; $transaction->user_id = $this->user->id; $transaction->reservation_id = $reservation->id; $transaction->status = 'Pending'; $transaction->amount = $property->reservation_fee; $transaction->remarks = "Property Reservation"; $transaction->save(); // UPDATE MONITORING DB::table('monitorings')->where('block', Input::get('block'))->where('lot', Input::get('lot'))->update(array('status' => false)); // 3.GENERATE INVOICE $x = View::make('admin.transactions.show', compact('transaction', 'user', 'property')); $pdf = storage_path() . '/invoices/' . $transaction->reference_number . '.pdf'; $dompdf = new DOMPDF(); $dompdf->load_html($x); $dompdf->render(); $output = $dompdf->output(); @file_put_contents($pdf, $output); // 3.1 GENERATE RESERVATION INFORMATION PDF $y = View::make('admin.reservations.pdf', compact('transaction', 'user', 'reservation', 'property')); $res = storage_path() . '/reservations/reservation-' . $transaction->reference_number . '.pdf'; $dompdf = new DOMPDF(); $dompdf->load_html($y); $dompdf->render(); $output = $dompdf->output(); @file_put_contents($res, $output); // 4. EMAIL DEVELOPER,ADMIN AND BUYER $admin = User::find(1); $developer = $property->developer; $data['transaction'] = $transaction; Mail::send('mails.default', $data, function ($message) use($transaction, $pdf, $developer, $admin, $res) { $user = Sentry::getUser(); $message->to($user->email)->subject("Property Reservation Notification"); $message->to($developer->email)->subject("Property Reservation Notification"); $message->to($admin->email)->subject("Property Reservation Notification"); $message->attach($pdf); $message->attach($res); }); return Redirect::to('clients')->with('success', 'Your reservation has been sent to administrator for approval.'); } }
function dash_monitoring_plugin_actions() { global $myUser, $_, $conf; switch ($_['action']) { case 'dash_monitoring_plugin_load': if ($myUser == false) { exit('Vous devez vous connecter pour cette action.'); } header('Content-type: application/json'); $response = array(); switch ($_['bloc']) { case 'ram': $response['title'] = 'RAM'; $hdds = Monitoring::ram(); $response['content'] = ' <div style="width: 100%"> <canvas id="RAM_PIE"></canvas> <br/><br/> <ul class="graphic_pane"> <li class="pane_orange"> <h1>RAM UTILISEE</h1> <h2>' . $hdds['percentage'] . '%</h2> </li><li class="pane_cyan"> <h1>RAM LIBRE</h1> <h2>' . $hdds['free'] . ' Mo</h2> </li><li class="pane_red"> <h1>RAM TOTALE</h1> <h2>' . $hdds['total'] . ' Mo</h2> </li> </ul> </div> <script> $("#RAM_PIE:visible").chart({ type : "doughnut", label : ["RAM UTILISEE","RAM LIBRE"], backgroundColor : ["' . ($hdds['percentage'] > 80 ? '#E64C65' : '#FCB150') . '","#4FC4F6"], segmentShowStroke:false, data : [' . $hdds['percentage'] . ',' . (100 - $hdds['percentage']) . '] }); </script>'; break; case 'system': $response['title'] = 'Système'; if (PHP_OS != 'WINNT') { $heat = Monitoring::heat(); $cpu = Monitoring::cpu(); } $response['content'] = '<ul> <li><strong>Distribution :</strong> ' . Monitoring::distribution() . '</li> <li><strong>Kernel :</strong> ' . Monitoring::kernel() . '</li> <li><strong>HostName :</strong> ' . Monitoring::hostname() . '</li> <li><strong>Température :</strong> <span class="label ' . $heat["label"] . '">' . $heat["degrees"] . '°C</span></li> <li><strong>Temps de marche :</strong> ' . Monitoring::uptime() . '</li> <li><strong>CPU :</strong> <span class="label label-info">' . $cpu['current_frequency'] . ' Mhz</span> (Max ' . $cpu['maximum_frequency'] . ' Mhz/ Min ' . $cpu['minimum_frequency'] . ' Mhz)</li> <li><strong>Charge :</strong> <span class="label label-info">' . $cpu['loads'] . ' </span> | ' . $cpu['loads5'] . ' 5min | ' . $cpu['loads15'] . ' 15min</li> <li><strong>Version WiringPi : </strong> ' . exec("gpio -v | grep 'gpio version' | cut -c15-") . '</li> <li><strong>Raspberry Pi Details : </strong> ' . exec("gpio -v") . '</li> </ul>'; break; case 'vocal': if ($myUser->getId() == '') { exit('{"error":"invalid or missing token"}'); } if (!$myUser->can('vocal', 'r')) { exit('{"error":"insufficient permissions for this account"}'); } list($host, $port) = explode(':', $_SERVER['HTTP_HOST']); $actionUrl = 'http://' . $host . ':' . $_SERVER['SERVER_PORT'] . $_SERVER['REQUEST_URI']; $actionUrl = substr($actionUrl, 0, strpos($actionUrl, '?')); Plugin::callHook("vocal_command", array(&$response, $actionUrl)); $response['title'] = count($response['commands']) . ' Commandes vocales'; $response['content'] = '<ul>'; foreach ($response['commands'] as $command) { $response['content'] .= '<li title="Sensibilité : ' . $command['confidence'] . '">' . $command['command'] . '</li>'; } $response['content'] .= '</ul>'; break; case 'network': $response['title'] = 'Réseau'; $ethernet = array(); $lan = ''; $wan = ''; $http = ''; $connections = ''; if (PHP_OS != 'WINNT') { $ethernet = Monitoring::ethernet(); $lan = Monitoring::internalIp(); $wan = Monitoring::externalIp(); $http = Monitoring::webServer(); $connections = Monitoring::connections(); } $response['content'] = '<ul> <li><strong>IP LAN :</strong> <code>' . $lan . '</code></li> <li><strong>IP WAN :</strong> <code>' . $wan . '</code></li> <li><strong>Serveur HTTP :</strong> ' . $http . '</li> <li><strong>Ethernet :</strong> ' . $ethernet['up'] . ' Montant / ' . $ethernet['down'] . ' Descendant</li> <li><strong>Connexions :</strong> <span class="label label-info">' . $connections . '</span></li> </ul>'; break; case 'gpio': $response['title'] = 'GPIO'; if (PHP_OS != 'WINNT') { $version = Functions::getRaspVersion(); $response['content'] .= '<pre><table style="width:100%;text-align:center;"><tbody>'; // getListOptionalWiringPin // // Liste des GPIO $i = 0; // var_dump(Gpio::getListWiringPin($version)); foreach (Gpio::getListWiringPin($version) as $key => $GPIO) { $class = 'info'; $value = 'off'; if (Gpio::read_($key, false)) { $class = 'warning'; $value = 'on'; } if ($i % 2 == 0) { $response['content'] .= '<tr><td><strong>' . $GPIO . '</strong></td><td>-></td><td> <span onclick="change_gpio_state(' . $key . ',this);" style="width:20px;text-align:center;" class="label label-' . $class . ' pointer">' . $value . '</span> </td>'; } else { $response['content'] .= '<td> <span onclick="change_gpio_state(' . $key . ',this);" style="width:20px;text-align:center;" class="pointer label label-' . $class . '">' . $value . '</span> </td><td><-</td><td><strong>' . $GPIO . '</strong></td></tr>'; } $i++; } $listeOfOptionnalGpios = Gpio::getListOptionalWiringPin($version); if (!empty($listeOfOptionnalGpios)) { $response['content'] .= '<tr><td colspan="6">Liste des Gpio optionnels</td></tr>'; //liste des GPIO optionnels $i = 0; foreach (Gpio::getListOptionalWiringPin($version) as $GPIO) { $class = 'info'; $value = 'off'; if (Gpio::read_($key, false)) { $class = 'warning'; $value = 'on'; } if ($i % 2 == 0) { $response['content'] .= '<tr><td><strong>' . Gpio::getNameOfWiringPins($i) . '</strong></td><td>-></td><td> <span onclick="change_gpio_state(' . $i . ',this);" style="width:20px;text-align:center;" class="label label-' . $class . ' pointer">' . $value . '</span> </td>'; } else { $response['content'] .= '<td> <span onclick="change_gpio_state(' . $i . ',this);" style="width:20px;text-align:center;" class="pointer label label-' . $class . '">' . $value . '</span> </td><td><-</td><td><strong>' . Gpio::getNameOfWiringPins($i + 1) . '</strong></td></tr>'; } $i++; } } $response['content'] .= '</tbody></table></pre>'; } else { $response['content'] .= 'Information indisponible sur cet OS :' . PHP_OS; } break; case 'pins': $response['title'] = 'PINS'; if (PHP_OS != 'WINNT') { $version = Functions::getRaspVersion(); //un peu de style $response["content"] .= '<style>.label_pin{padding:5px;border: 1px solid #FFF;}.pin_gpio{background: #FCBF21}.pin_power{background: #FB0C1A}.pin_ground{background: #000}.pin_UART{background: #00AF08}.pin_SPI{background: #9B04EF}.pin_I2C{background: #0044AB}.legende_pins a{color:#FFF}.legende_pins{margin:5px; border: 1px solid #FFF;display:inline;padding: 5px}</style>'; $response["content"] .= '<pre><table style="width:100%;text-align:center;margin:5px;"><tbody>'; //on met les titres $response["content"] .= '<tr><th>WiringPi</th><th>Nom</th><th></th><th></th><th>Nom</th><th>WiringPi</th></tr>'; $i = 0; foreach (Gpio::getListPins($version) as $numero => $infos) { $wiringPi = is_null($infos[0]) ? "N/A" : $infos[0]; $nom = $infos[1]; $class = ""; //on détermine les class switch ($nom) { case preg_match("~GPIO~Uis", $nom) ? true : false: $class = "gpio"; break; case "0V": $class = "ground"; break; case "3,3V": case "5V": $class = "power"; break; case "MOSI": case "MISO": case "SCLK": case "CE0": case "CE1": $class = "SPI"; break; case "RxD": case "TxD": $class = "UART"; break; case preg_match("~SDA~Uis", $nom) ? true : false: case preg_match("~SCL~Uis", $nom) ? true : false: $class = "I2C"; break; default: $class = ""; break; } $class = !empty($class) ? 'pin_' . $class : ""; if ($i % 2 == 0) { $response['content'] .= '<tr><td>' . $wiringPi . '</td><td>' . $nom . '</td><td class="label_pin ' . $class . '" ><i class="fa fa-dot-circle-o"></i></td>'; } else { $response['content'] .= '<td class="label_pin ' . $class . '" ><i class="fa fa-dot-circle-o"></i></td><td>' . $nom . '</td><td>' . $wiringPi . '</td></tr>'; } $i++; } $temp_list = Gpio::getListOptionalPins($version); if (!empty($temp_list)) { $response['content'] .= '<tr><td colspan="6">Pins optionnels</td></tr>'; $i = 0; foreach (Gpio::getListOptionalPins($version) as $numero => $infos) { $wiringPi = is_null($infos[0]) ? "N/A" : $infos[0]; $nom = $infos[1]; $class = ""; //on détermine les class switch ($nom) { case preg_match("~GPIO~Uis", $nom) ? true : false: $class = "gpio"; break; case "0V": $class = "ground"; break; case "3,3V": case "5V": $class = "power"; break; case "MOSI": case "MISO": case "SCLK": case "CE0": case "CE1": $class = "SPI"; break; case "RxD": case "TxD": $class = "UART"; break; case preg_match("~SDA~Uis", $nom) ? true : false: case preg_match("~SCL~Uis", $nom) ? true : false: $class = "I2C"; break; default: $class = ""; break; } $class = !empty($class) ? 'pin_' . $class : ""; if ($i % 2 == 0) { $response['content'] .= '<tr><td>' . $wiringPi . '</td><td>' . $nom . '</td><td class="label_pin ' . $class . '" ><i class="fa fa-dot-circle-o"></i></td>'; } else { $response['content'] .= '<td class="label_pin ' . $class . '" ><i class="fa fa-dot-circle-o"></i></td><td>' . $nom . '</td><td>' . $wiringPi . '</td></tr>'; } $i++; } } $response['content'] .= '</tbody></table>'; $response['content'] .= '<div class="legende_pins pin_ground"><a href="http://fr.wikipedia.org/wiki/Terre_(%C3%A9lectricit%C3%A9)">ground</a></div><div class="legende_pins pin_power"><a href="http://fr.wikipedia.org/wiki/Alimentation_%C3%A9lectrique">power</a></div><div class="legende_pins pin_gpio"><a href="http://fr.wikipedia.org/wiki/General_Purpose_Input/Output">gpio</a></div><div class="legende_pins pin_SPI"><a href="http://fr.wikipedia.org/wiki/Serial_Peripheral_Interface">SPI</a></div><div class="legende_pins pin_UART"><a href="http://fr.wikipedia.org/wiki/UART">UART</a></div><div class="legende_pins pin_I2C"><a href="http://fr.wikipedia.org/wiki/I2C">I2C</a></div></tr>'; $response['content'] .= '</pre>'; } else { $response['content'] .= 'Information indisponible sur cet OS :' . PHP_OS; } break; case 'users': $users = array(); if (PHP_OS != 'WINNT') { $users = Monitoring::users(); } $response['title'] = count($users) . ' utilisateurs connectés'; $response['content'] = '<ul>'; foreach ($users as $value) { $response['content'] .= '<li>Utilisateur <strong class="badge">' . $value['user'] . '</strong> IP : <code>' . $value['ip'] . '</code>, Connexion : ' . $value['hour'] . ' </li>'; } $response['content'] .= '</ul>'; break; case 'services': $response['title'] = 'Services'; $services = array(); if (PHP_OS != 'WINNT') { $services = Monitoring::services(); $response['content'] = '<ul>'; foreach ($services as $value) { $response['content'] .= '<li ' . ($value['status'] ? 'class="service-active"' : '') . '>- ' . $value['name'] . '</li>'; } $response['content'] .= '</ul>'; } else { $response['content'] .= 'Information indisponible sur cet OS :' . PHP_OS; } break; case 'hdd': $response['title'] = 'HDD'; $hdds = array(); if (PHP_OS != 'WINNT') { $hdds = Monitoring::hdd(); $response['content'] = '<ul>'; foreach ($hdds as $value) { $response['content'] .= '<li><strong class="badge">' . $value['name'] . '</strong><br><strong> Espace :</strong> ' . $value['used'] . '/' . $value['total'] . '<strong> Format :</strong> ' . $value['format'] . ' </li>'; } $response['content'] .= '</ul>'; } else { $response['content'] .= 'Information indisponible sur cet OS :' . PHP_OS; } break; case 'disk': $response['title'] = 'Disques'; $disks = array(); if (PHP_OS != 'WINNT') { $disks = Monitoring::disks(); $response['content'] = '<ul>'; foreach ($disks as $value) { $response['content'] .= '<li><strong class="badge">' . $value['name'] . '</strong> Statut : ' . $value['size'] . ' Type : ' . $value['type'] . ' Chemin : ' . $value['mountpoint'] . ' </li>'; } $response['content'] .= '</ul>'; } else { $response['content'] .= 'Information indisponible sur cet OS :' . PHP_OS; } break; } echo json_encode($response); exit(0); break; case 'dash_monitoring_plugin_edit': echo '<label>Time Zone</label><input id="zone" type="text">'; break; case 'dash_monitoring_plugin_save': break; case 'dash_monitoring_plugin_delete': break; case 'dash_monitoring_plugin_move': break; } }
* @param exitCode int Exit code to pass on to exit function and monitor report * @param fatal boolean Should we exit out entirely * @return none **/ public function endCronjob($cron_name, $msgCode, $exitCode = 0, $fatal = false, $mail = true) { $this->setStatus($cron_name . "_active", "yesno", 0); $this->setStatus($cron_name . "_message", "message", $this->getErrorMsg($msgCode)); $this->setStatus($cron_name . "_status", "okerror", $exitCode); $this->setStatus($cron_name . "_endtime", "date", time()); if ($mail) { $aMailData = array('email' => $this->setting->getValue('system_error_email'), 'subject' => 'Cronjob Failure', 'Error Code' => $msgCode, 'Error Message' => $this->getErrorMsg($msgCode)); if (!$this->mail->sendMail('notifications/error', $aMailData)) { $this->setErrorMessage('Failed to send mail notification'); } } if ($fatal) { if ($exitCode != 0) { $this->setStatus($cron_name . "_disabled", "yesno", 1); } exit($exitCode); } } } $monitoring = new Monitoring(); $monitoring->setErrorCodes($aErrorCodes); $monitoring->setConfig($config); $monitoring->setDebug($debug); $monitoring->setMail($mail); $monitoring->setMysql($mysqli); $monitoring->setSetting($setting);
Route::get('search', 'PropertyController@search'); }); // Administration Routes Route::group(array('before' => 'client', 'prefix' => 'clients'), function () { // RESERVATIONS Route::get('/', 'PublicClientsController@main'); Route::get('reserve/{id}', 'PublicClientsController@reserve'); Route::post('reserve/{id}', 'PublicClientsController@reserve_post'); Route::get('profile', 'PublicClientsController@profile'); Route::post('profile', 'PublicClientsController@profile_post'); Route::get('reservation/{id}', 'PublicClientsController@reservation'); Route::get('invoice/{id}', 'PublicClientsController@invoice'); Route::get('all', 'PublicClientsController@all'); Route::post('request/lots', function () { $block = Input::get('block'); $monitoring = Monitoring::where('block', $block[0])->where('status', 1)->get(); $array = array(); foreach ($monitoring as $m) { array_push($array, $m->lot); } header("content-type:text/json"); echo json_encode($array); }); }); // Administration Routes Route::group(array('before' => 'client_not_logged_in', 'prefix' => 'clients'), function () { Route::get('login', 'PublicClientsController@login'); Route::post('login', 'PublicClientsController@login_post'); Route::get('register', 'PublicClientsController@register'); Route::post('register', 'PublicClientsController@register_post'); Route::get('forgot-password', 'PublicClientsController@forgot');
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer $id the ID of the model to be loaded * @return Monitoring the loaded model * @throws CHttpException */ public function loadModel($id) { $model = Monitoring::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
function isPointOnline($ip) { $monitoringModel = new Monitoring(); return $monitoringModel->checkIpOnline($ip); }
public function delete($id) { $monitoring = Monitoring::find($id); $monitoring->delete(); return Redirect::to(Session::get('redirect_url'))->with('success', 'Block has deleted.'); }