function create_labs($data, $pre_data) { // HACK: to zip loop $labs = array(); foreach ($data as $lab_name => $n) { $lab = new Lab($lab_name, $n, $pre_data->{$lab_name}); if ($lab->is_include() and $lab->is_main()) { $labs[] = $lab; } } return $labs; }
static function map(Lab $lab, array $propriedades) { if (array_key_exists('id_laboratorio', $propriedades)) { $lab->setIdLaboratorio($propriedades['id_laboratorio']); } if (array_key_exists('nome_laboratorio', $propriedades)) { $lab->setNomeLaboratorio($propriedades['nome_laboratorio']); } if (array_key_exists('numero_laboratorio', $propriedades)) { $lab->setNumeroLaboratorio($propriedades['numero_laboratorio']); } if (array_key_exists('chave_laboratorio', $propriedades)) { $lab->setChaveLaboratorio($propriedades['chave_laboratorio']); } }
public function index() { $lab = Lab::all(); $kdlab = Input::get('kdlab'); $lapkeglab = DB::table('v_pemeriksaandetail')->where('KdLab', array($kdlab))->groupBy('KdKategori')->get(); return View::make('laporan.laptest', compact('lab', 'lapkeglab')); }
public function edit($KdTarif) { $tarif = Tarif::find($KdTarif); $jnskategori = Jnskategori::all(); $lab = Lab::all(); return View::make('tarif.edit_tarif')->with('jnskategori', $jnskategori)->with('lab', $lab)->with('tarif', $tarif); }
public function edit($noreglab) { $reglab = RegLab::where('NoReglab', '=', $noreglab)->first(); $riwdiag = RiwayatDiagnosa::where('NoRegLab', '=', $noreglab)->paginate(10); $pemeriksaan = Pemeriksaan2::where('NoRegLab', '=', $noreglab)->paginate(10); $lab = Lab::all(); return View::make('registrasi.index2_registrasi')->with('reglab', $reglab)->with('pemeriksaan', $pemeriksaan)->with('riwdiag', $riwdiag)->with('lab', $lab); }
public function hapus($id, $noreglab) { $this->riwdiag->hapus($id); $reglab = RegLab::where('NoRegLab', '=', $noreglab)->first(); $idriw = RiwayatDiagnosa::orderBy('id', 'desc')->pluck('id'); $riwdiag = RiwayatDiagnosa::where('NoRegLab', '=', $noreglab)->paginate(); $lab = Lab::all(); $pemeriksaan = Pemeriksaan2::where('NoRegLab', '=', $noreglab)->paginate(); return View::make('registrasi.index2_registrasi')->with('reglab', $reglab)->with('riwdiag', $riwdiag)->with('pemeriksaan', $pemeriksaan)->with('lab', $lab); }
/** * @param int $address - IP address of a machine in the required lab * @return Lab - Lab object for specified IP address or false if not found */ public function get_lab_based_on_client($address) { $sql = 'SELECT lab, name FROM client_identifiers, labs WHERE client_identifiers.lab = labs.id AND address = ?'; $lab_results = $this->db->prepare($sql); $lab_results->bind_param('s', $address); $lab_results->execute(); $lab_results->store_result(); $lab_results->bind_result($lab_id, $room_name); if ($lab_results->num_rows < 1) { $lab_results->close(); return false; } $lab_results->fetch(); $lab_object = new Lab(); $lab_object->set_id($lab_id); $lab_object->set_name($room_name); $lab_results->close(); return $lab_object; }
public function edit($NmrSpesimen) { $rujukan = Rujukan::find($NmrSpesimen); $lab = Lab::get(); $pasien = Pasien::get(); $jnskategori = Jnskategori::get(); //$reglab = Reglab::all(); return View::make('rujukan.edit_rujukan')->with('rujukan', $rujukan)->with('lab', $lab)->with('pasien', $pasien)->with('jnskategori', $jnskategori); //->with('reglab',$reglab); }
/** * Function to add a node to a lab. * * @param Lab $lab Lab * @return Array Return code (JSend data) */ function apiGetLabTopology($lab) { // Printing topology $output['code'] = '200'; $output['status'] = 'success'; $output['message'] = 'Topology loaded'; $output['data'] = array(); foreach ($lab->getNodes() as $node_id => $node) { foreach ($node->getEthernets() as $interface) { if ($interface->getNetworkId() != '' && isset($lab->getNetworks()[$interface->getNetworkId()])) { // Interface is connected switch ($lab->getNetworks()[$interface->getNetworkId()]->getCount()) { default: // More than two connected nodes $output['data'][] = array('type' => 'ethernet', 'source' => 'node' . $node_id, 'source_type' => 'node', 'source_label' => $interface->getName(), 'destination' => 'network' . $interface->getNetworkId(), 'destination_type' => 'network', 'destination_label' => ''); break; case 0: // Network not used break; case 1: // Only one connected node $output['data'][] = array('type' => 'ethernet', 'source' => 'node' . $node_id, 'source_type' => 'node', 'source_label' => $interface->getName(), 'destination' => 'network' . $interface->getNetworkId(), 'destination_type' => 'network', 'destination_label' => ''); break; case 2: // P2P Link if ($lab->getNetworks()[$interface->getNetworkId()]->isCloud()) { // Cloud are never printed as P2P link $output['data'][] = array('type' => 'ethernet', 'source' => 'node' . $node_id, 'source_type' => 'node', 'source_label' => $interface->getName(), 'destination' => 'network' . $interface->getNetworkId(), 'destination_type' => 'network', 'destination_label' => ''); } else { foreach ($lab->getNodes() as $remote_node_id => $remote_node) { foreach ($remote_node->getEthernets() as $remote_interface) { if ($interface->getNetworkId() == $remote_interface->getNetworkId()) { // To avoid duplicates, only print if source node_id > destination node_id if ($node_id > $remote_node_id) { $output['data'][] = array('type' => 'ethernet', 'source' => 'node' . $node_id, 'source_type' => 'node', 'source_label' => $interface->getName(), 'destination' => 'node' . $remote_node_id, 'destination_type' => 'node', 'destination_label' => $remote_interface->getName()); } break; } } } } break; } } } foreach ($node->getSerials() as $interface) { if ($interface->getRemoteID() != '' && $node_id > $interface->getRemoteId()) { $output['data'][] = array('type' => 'serial', 'source' => 'node' . $node_id, 'source_type' => 'node', 'source_label' => $interface->getName(), 'destination' => 'node' . $interface->getRemoteID(), 'destination_type' => 'node', 'destination_label' => $lab->getNodes()[$interface->getRemoteID()]->getSerials()[$interface->getRemoteIf()]->getName()); } } } return $output; }
// Drop after lab file (ending with .unl) $replacements[1] = '$1'; $lab_file = preg_replace($patterns[0], $replacements[0], $s); $id = preg_replace($patterns[1], $replacements[1], $s); // Interfere after lab_file.unl if (!is_file(BASE_LAB . $lab_file)) { // Lab file does not exists $output['code'] = 404; $output['status'] = 'fail'; $output['message'] = $GLOBALS['messages'][60000]; $app->response->setStatus($output['code']); $app->response->setBody(json_encode($output)); return; } try { $lab = new Lab(BASE_LAB . $lab_file, $tenant); } catch (Exception $e) { // Lab file is invalid $output['code'] = 400; $output['status'] = 'fail'; $output['message'] = $GLOBALS['messages'][60056]; $output['message'] = $e->getMessage(); $app->response->setStatus($output['code']); $app->response->setBody(json_encode($output)); return; } if (preg_match('/^\\/[A-Za-z0-9_+\\/\\s-]+\\.unl\\/html$/', $s)) { $Parsedown = new Parsedown(); $output['code'] = 200; $output['status'] = 'success'; $output['message'] = $GLOBALS['messages']['60054'];
public function jadwal() { $jadwals = Jadwal::where('jadwal_status', '=', 1)->get(); $labs = Lab::where('lab_status', '=', 1)->get(); $ruangs = Ruang::where('ruang_status', '=', 1)->get(); $praktikums = Praktikum::all(); return View::make('dashboard.kordas.DataMaster.jadwal')->with('jadwals', $jadwals)->with('labs', $labs)->with('ruangs', $ruangs)->with('praktikums', $praktikums); }
/** * Function to get all lab networks. * * @param Lab $lab Lab * @return Array Lab networks (JSend data) */ function apiGetLabNetworks($lab) { // Getting network(s) $networks = $lab->getNetworks(); // Printing networks $output['code'] = 200; $output['status'] = 'success'; $output['message'] = $GLOBALS['messages'][60004]; $output['data'] = array(); foreach ($networks as $network_id => $network) { $output['data'][$network_id] = array('id' => $network_id, 'count' => $network->getCount(), 'left' => $network->getLeft(), 'name' => $network->getName(), 'top' => $network->getTop(), 'type' => $network->getNType()); } return $output; }
/** * CARE2X Integrated Hospital Information System Deployment 2.2 - 2006-07-10 * GNU General Public License * Copyright 2002,2003,2004,2005,2006 Elpidio Latorilla * elpidio@care2x.org, * * See the file "copy_notice.txt" for the licence notice */ define('LANG_FILE', 'lab.php'); $local_user = '******'; require_once $root_path . 'include/inc_front_chain_lang.php'; $thisfile = basename($_SERVER['PHP_SELF']); //$db->debug=true; # Create lab object require_once $root_path . 'include/care_api_classes/class_lab.php'; $lab_obj = new Lab(); # Create presc object require_once $root_path . 'include/care_api_classes/class_prescription.php'; $pres_obj = new Prescription(); //create a new drugs and services object require_once $root_path . 'include/care_api_classes/class_tz_drugsandservices.php'; $das_obj = new DrugsAndServices(); # Load the date formatter */ function cleanString($wild) { return preg_replace("/[^[:alnum:]+]/", "_", $wild); } if (isset($mode) && !empty($mode)) { if ($mode == 'save') { # Save the nr if (empty($_POST['status'])) {
* CARE2X Integrated Hospital Information System Deployment 2.2 - 2006-07-10 * GNU General Public License * Copyright 2002,2003,2004,2005,2006 Elpidio Latorilla * elpidio@care2x.org, * * See the file "copy_notice.txt" for the licence notice */ $lang_tables = array('chemlab_groups.php', 'chemlab_params.php'); define('LANG_FILE', 'lab.php'); $local_user = '******'; require_once $root_path . 'include/inc_front_chain_lang.php'; $thisfile = basename($_SERVER['PHP_SELF']); ///$db->debug=true; # Create lab object require_once $root_path . 'include/care_api_classes/class_lab.php'; $lab_obj = new Lab(); # Load the date formatter */ include_once $root_path . 'include/inc_date_format_functions.php'; if (isset($mode) && !empty($mode)) { $lab_obj->moveUp($_GET['nrFirst'], $_GET['sortnrFirst']); $lab_obj->moveDown($_GET['nrSecond'], $_GET['sortnrSecond']); } # Get the test test groups $tgroups =& $lab_obj->TestGroups(); $breakfile = "labor.php" . URL_APPEND; // echo "from table ".$linecount; # Start Smarty templating here /** * LOAD Smarty */ # Note: it is advisable to load this after the inc_front_chain_lang.php so
/** * Function to export a node running-config. * * @param int $node_id Node ID * @param Node $n Node * @param Lab $lab Lab * @return int 0 means ok */ function export($node_id, $n, $lab) { $tmp = tempnam(sys_get_temp_dir(), 'unl_cfg_' . $node_id . '_'); if (is_file($tmp) && !unlink($tmp)) { // Cannot delete tmp file error_log('ERROR: ' . $GLOBALS['messages'][80059]); return 80059; } switch ($n->getNType()) { default: // Unsupported error_log('ERROR: ' . $GLOBALS['messages'][80061]); return 80061; break; case 'dynamips': foreach (scandir($n->getRunningPath()) as $filename) { if (preg_match('/_nvram$/', $filename)) { $nvram = $n->getRunningPath() . '/' . $filename; break; } else { if (preg_match('/_rom$/', $filename)) { $nvram = $n->getRunningPath() . '/' . $filename; break; } } } if (!isset($nvram) || !is_file($nvram)) { // NVRAM file not found error_log('ERROR: ' . $GLOBALS['messages'][80066]); return 80066; } $cmd = '/usr/bin/nvram_export ' . $nvram . ' ' . $tmp; exec($cmd, $o, $rc); error_log('INFO: exporting ' . $cmd); if ($rc != 0) { error_log('ERROR: ' . $GLOBALS['messages'][80060]); error_log((string) $o); return 80060; } break; case 'iol': $nvram = $n->getRunningPath() . '/nvram_' . sprintf('%05u', $node_id); if (!is_file($nvram)) { // NVRAM file not found error_log('ERROR: ' . $GLOBALS['messages'][80066]); return 80066; } $cmd = '/opt/unetlab/scripts/iou_export ' . $nvram . ' ' . $tmp; exec($cmd, $o, $rc); usleep(1); error_log('INFO: exporting ' . $cmd); if ($rc != 0) { error_log('ERROR: ' . $GLOBALS['messages'][80060]); error_log((string) $o); return 80060; } break; case 'qemu': if (is_file('/opt/unetlab/scripts/config_' . $n->getTemplate() . '.py')) { $cmd = '/opt/unetlab/scripts/config_' . $n->getTemplate() . '.py -a get -p ' . $n->getPort() . ' -f ' . $tmp . ' -t 15'; exec($cmd, $o, $rc); error_log('INFO: exporting ' . $cmd); if ($rc != 0) { error_log('ERROR: ' . $GLOBALS['messages'][80060]); error_log((string) $o); return 80060; } } } if (!is_file($tmp)) { // File not found error_log('ERROR: ' . $GLOBALS['messages'][80062]); return 80062; } // Now save the config file within the lab $fp = fopen($tmp, 'r'); if (!isset($fp)) { // Cannot open file error_log('ERROR: ' . $GLOBALS['messages'][80064]); return 80064; } $config_data = fread($fp, filesize($tmp)); if ($config_data === False || $config_data === '') { // Cannot read file error_log('ERROR: ' . $GLOBALS['messages'][80065]); return 80065; } if ($lab->setNodeConfigData($node_id, $config_data) !== 0) { // Failed to save startup-config error_log('ERROR: ' . $GLOBALS['messages'][80063]); return 80063; } if (!unlink($tmp)) { // Failed to remove tmp file error_log('WARNING: ' . $GLOBALS['messages'][80070]); } return 0; }
// Must be executed from CLI exit(1); } require_once '/opt/unetlab/html/includes/init.php'; if (!isset($argv[1])) { // File does not exists or not set error_log('ERROR: Must need a lab file as argument.'); exit(1); } if (!is_file($argv[1])) { // File does not exists error_log('ERROR: File does not exist.'); exit(2); } try { $lab = new Lab($argv[1], 0); if (is_dir(BASE_TMP . '/0/' . $lab->getId()) && is_dir(BASE_TMP . '/0/' . $lab->getName())) { // Source dir and destinaion dir both exists error_log('ERROR: Destination folder already exists.'); error_log('Cannot migrate "' . $argv[1] . '", manually delete directory and loose data to migrate the old configs:'); error_log('rm -rf "' . BASE_TMP . '/0/' . $lab->getId() . '"'); error_log($argv[0] . ' ' . $argv[1]); error_log('Or remove the old directory if not needed anymore:'); error_log('rm -rf "' . BASE_TMP . '/0/' . $lab->getName() . '"'); exit(3); } else { if (!is_dir(BASE_TMP . '/0/' . $lab->getId()) && is_dir(BASE_TMP . '/0/' . $lab->getName())) { if (rename(BASE_TMP . '/0/' . $lab->getName(), BASE_TMP . '/0/' . $lab->getId())) { // Mark as configured all nodes $cmd = 'find /opt/unetlab/tmp/0/' . $lab->getId() . '/[0-9]* -type d -exec touch {}/.configured \\;'; exec($cmd, $o, $rc);
* CARE2X Integrated Hospital Information System Deployment 2.1 - 2004-10-02 * GNU General Public License * Copyright 2002,2003,2004,2005 Elpidio Latorilla * elpidio@care2x.org, * * See the file "copy_notice.txt" for the licence notice */ $lang_tables = array('chemlab_groups.php'); define('LANG_FILE', 'lab.php'); $local_user = '******'; require_once $root_path . 'include/inc_front_chain_lang.php'; require_once $root_path . 'include/care_api_classes/class_lab.php'; $thisfile = 'labor_data_check_arch.php'; $breakfile = 'labor_data_patient_such.php' . URL_APPEND . '&mode=edit'; $toggle = 0; $lab_obj = new Lab(); # Load the date formatter require_once $root_path . 'include/inc_date_format_functions.php'; $lab_results =& $lab_obj->createResultsList($encounter_nr); $linecount = $lab_obj->LastRecordCount(); if (!$linecount) { switch ($mode) { case 'list': header("location:pflege-station-patientdaten.php" . URL_REDIRECT_APPEND . "&station={$station}&pn={$encounter_nr}&nodoc=labor"); break; default: header("location:labor_datainput.php" . URL_REDIRECT_APPEND . "&encounter_nr={$encounter_nr}&newid=1&mode={$mode}"); } } ?> <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 3.0//EN" "html.dtd">
$encounter_nr = $pn; } if (!$_COOKIE[$local_user . $sid]) { header("Location:" . $root_path . "language/" . $lang . "/lang_" . $lang . "_invalid-access-warning.php"); exit; } if (!$encounter_nr) { header("location:" . $root_path . "modules/laboratory/labor_data_patient_such.php?sid={$sid}&lang={$lang}"); } $thisfile = basename(__FILE__); //$db->debug=1; $_enx = $multi->get_5_visits($pid); /* Create encounter object */ require_once $root_path . 'include/care_api_classes/class_lab.php'; $enc_obj = new Encounter($encounter_nr); $lab_obj = new Lab($encounter_nr); $jobs = $lab_obj->GetJobsByEncounter_summary($_enx); $count_job = 0; $count_subjob = 1; if ($jobs) { while ($j = $jobs->FetchRow()) { if ($last_job != $j['job_id']) { $count_job++; } $arr_tasks = unserialize($j['serial_value']); while (list($x, $v) = each($arr_tasks)) { $parameters[$count_job]['tasks'][$x] = $v; $taskstodo[$x] = $v; if ($x > $old_x) { $old_x = $x; }
/** * Function to get all startup-configs. * * @param Lab $lab Lab * @return Array startup-configs (JSend data) */ function apiGetLabConfigs($lab) { // Getting startup-configs $nodes = $lab->getNodes(); // Printing startup-configs $output['code'] = 200; $output['status'] = 'success'; $output['message'] = $GLOBALS['messages'][60055]; $output['data'] = array(); foreach ($nodes as $node_id => $node) { if (isset($GLOBALS['node_config'][$node->getTemplate()])) { $output['data'][$node_id] = array('config' => $node->getConfig(), 'name' => $node->getName()); } } return $output; }
public function store() { $nomedrec = Input::get('no_medrec'); $tgl_reg = Input::get('tgl_reg'); $sasaran = Input::get('sasaran'); //$idpegawai = Input::get('id_pegawai'); $idpegawai = Auth::user()->IdPegawai; $pasien = Pasien2::where('id_pasien', '=', $nomedrec)->first(); $nomorreglab = Input::get('noreglab'); $pivotData = array($idpegawai => array('tgl_reg' => $tgl_reg, 'Keterangan' => $sasaran)); //$idpegawai = User::with('') /*$input = Pegawai::where('IdPegawai', '=', $idpegawai)->first(); $input->pasien()->attach($pasien->NoMedrec);*/ //$pasien->pegawai()->getRelatedIds(); $pasien->pegawai()->attach($pivotData); $noreglab = RegLab::orderBy('created_at', 'desc')->pluck('NoRegLab'); $this->billing->NoRegLab = $noreglab; $this->billing->save(); //$input = Input::all(); //$this->billing->simpan($input); //$pasien->pegawai()->getRelatedIds(); //$pasien->push(); //Session::flash('message', 'Pasien Berhasil Terdaftar'); $noreglab = RegLab::orderBy('created_at', 'desc')->pluck('NoRegLab'); $reglab = Reglab::where('NoRegLab', '=', $noreglab)->first(); $riwdiag = RiwayatDiagnosa::where('NoRegLab', '=', $noreglab)->get(); $pemeriksaan = Pemeriksaan2::where('NoRegLab', '=', $noreglab)->get(); $lab = Lab::all(); //$reglab = DB::connection('mysql')->reglab->lastInsertId(); //return Redirect::to('registrasi/search'); return View::make('registrasi.index2_registrasi')->with('reglab', $reglab)->with('riwdiag', $riwdiag)->with('noreglab', $noreglab)->with('pemeriksaan', $pemeriksaan)->with('lab', $lab); //->with('reglab', $reglab); }
/** * Function to get a single lab picture binary data. Picture can be resized * if width/height is less than real ones. Aspect ratio is always guaranteed. * * @param Lab $lab Lab * @param int $id Picture ID * @param int $height Height of the resized picture * @param int $width Width of the resized picture * @return Array Lab picture (JSend data) */ function apiGetLabPictureData($lab, $id, $width, $height) { $output['code'] = 200; $output['encoding'] = 'image/png'; if (isset($lab->getPictures()[$id])) { $output['data'] = resizeImage($lab->getPictures()[$id]->getData(), $width, $height); } else { // Generate an error image $draw = new ImagickDraw(); $draw->setFillColor('black'); $draw->setFontSize(30); $pixel = new ImagickPixel('white'); $img = new Imagick(); $img->newImage(800, 75, $pixel); $img->setImageFormat('png'); $img->annotateImage($draw, 10, 45, 0, 'ERROR: ' . $GLOBALS['messages'][60029]); $output['data'] = resizeImage($img->getImageBlob(), $width, $height); } return $output; }
<?php ini_set("display_errors", 1); require_once "../classes/db_connection.php"; require_once "../classes/lab.php"; header("Content-Type: application/json"); $occupancities = array(); try { DBConnection::Connect(); $occupancities = Lab::GetLabsOccupancy(); DBConnection::Close(); } catch (Exception $ex) { } echo "{"; $json = ""; foreach ($occupancities as $o) { $json .= "\"Lab_" . $o["LabID"] . "\": { \"Used\": " . $o["TotalUsed"] . ", \"Capacity\": " . $o["Capacity"] . "},"; } $json = substr($json, 0, -1); $json .= "}"; echo $json;
/** * Function to export a node running-config. * * @param int $node_id Node ID * @param Node $n Node * @param Lab $lab Lab * @return int 0 means ok */ function export($node_id, $n, $lab) { $tmp = tempnam(sys_get_temp_dir(), 'unl_cfg_' . $node_id . '_'); if (is_file($tmp) && !unlink($tmp)) { // Cannot delete tmp file error_log(date('M d H:i:s ') . 'ERROR: ' . $GLOBALS['messages'][80059]); return 80059; } switch ($n->getNType()) { default: // Unsupported error_log(date('M d H:i:s ') . 'ERROR: ' . $GLOBALS['messages'][80061]); return 80061; break; case 'dynamips': foreach (scandir($n->getRunningPath()) as $filename) { if (preg_match('/_nvram$/', $filename)) { $nvram = $n->getRunningPath() . '/' . $filename; break; } else { if (preg_match('/_rom$/', $filename)) { $nvram = $n->getRunningPath() . '/' . $filename; break; } } } if (!isset($nvram) || !is_file($nvram)) { // NVRAM file not found error_log(date('M d H:i:s ') . 'ERROR: ' . $GLOBALS['messages'][80066]); return 80066; } $cmd = '/opt/unetlab/scripts/wrconf_dyn.py -p ' . $n->getPort() . ' -t 15'; exec($cmd, $o, $rc); error_log(date('M d H:i:s ') . 'INFO: force write configuration ' . $cmd); if ($rc != 0) { error_log(date('M d H:i:s ') . 'ERROR: ' . $GLOBALS['messages'][80060]); error_log(date('M d H:i:s ') . (string) $o); return 80060; } $cmd = '/usr/bin/nvram_export ' . $nvram . ' ' . $tmp; exec($cmd, $o, $rc); error_log(date('M d H:i:s ') . 'INFO: exporting ' . $cmd); if ($rc != 0) { error_log(date('M d H:i:s ') . 'ERROR: ' . $GLOBALS['messages'][80060]); error_log(date('M d H:i:s ') . (string) $o); return 80060; } break; case 'vpcs': if (!is_file($n->getRunningPath() . '/startup.vpc')) { error_log(date('M d H:i:s ') . 'ERROR: ' . $GLOBALS['messages'][80062]); } else { copy($n->getRunningPath() . '/startup.vpc', $tmp); } break; case 'iol': $nvram = $n->getRunningPath() . '/nvram_' . sprintf('%05u', $node_id); if (!is_file($nvram)) { // NVRAM file not found error_log(date('M d H:i:s ') . 'ERROR: ' . $GLOBALS['messages'][80066]); return 80066; } $cmd = '/opt/unetlab/scripts/wrconf_iol.py -p ' . $n->getPort() . ' -t 15'; exec($cmd, $o, $rc); error_log(date('M d H:i:s ') . 'INFO: force write configuration ' . $cmd); if ($rc != 0) { error_log(date('M d H:i:s ') . 'ERROR: ' . $GLOBALS['messages'][80060]); error_log(date('M d H:i:s ') . (string) $o); return 80060; } $cmd = '/opt/unetlab/scripts/iou_export ' . $nvram . ' ' . $tmp; exec($cmd, $o, $rc); usleep(1); error_log(date('M d H:i:s ') . 'INFO: exporting ' . $cmd); if ($rc != 0) { error_log(date('M d H:i:s ') . 'ERROR: ' . $GLOBALS['messages'][80060]); error_log(date('M d H:i:s ') . implode("\n", $o)); return 80060; } // Add no shut if (is_file($tmp)) { file_put_contents($tmp, preg_replace('/(\\ninterface.*)/', '$1' . chr(10) . ' no shutdown', file_get_contents($tmp))); } break; case 'qemu': if ($n->getStatus() < 2 || !isset($GLOBALS['node_config'][$n->getTemplate()])) { // Skipping powered off nodes or unsupported nodes error_log(date('M d H:i:s ') . 'WARNING: ' . $GLOBALS['messages'][80084]); return 80084; } else { $cmd = '/opt/unetlab/scripts/' . $GLOBALS['node_config'][$n->getTemplate()] . ' -a get -p ' . $n->getPort() . ' -f ' . $tmp . ' -t 15'; exec($cmd, $o, $rc); error_log(date('M d H:i:s ') . 'INFO: exporting ' . $cmd); if ($rc != 0) { error_log(date('M d H:i:s ') . 'ERROR: ' . $GLOBALS['messages'][80060]); error_log(date('M d H:i:s ') . implode("\n", $o)); return 80060; } // Add no shut if (($n->getTemplate() == "crv" || $n->getTemplate() == "vios" || $n->getTemplate() == "viosl2" || $n->getTemplate() == "xrv") && is_file($tmp)) { file_put_contents($tmp, preg_replace('/(\\ninterface.*)/', '$1' . chr(10) . ' no shutdown', file_get_contents($tmp))); } } } if (!is_file($tmp)) { // File not found error_log(date('M d H:i:s ') . 'ERROR: ' . $GLOBALS['messages'][80062]); return 80062; } // Now save the config file within the lab clearstatcache(); $fp = fopen($tmp, 'r'); if (!isset($fp)) { // Cannot open file error_log(date('M d H:i:s ') . 'ERROR: ' . $GLOBALS['messages'][80064]); return 80064; } $config_data = fread($fp, filesize($tmp)); if ($config_data === False || $config_data === '') { // Cannot read file error_log(date('M d H:i:s ') . 'ERROR: ' . $GLOBALS['messages'][80065]); return 80065; } if ($lab->setNodeConfigData($node_id, $config_data) !== 0) { // Failed to save startup-config error_log(date('M d H:i:s ') . 'ERROR: ' . $GLOBALS['messages'][80063]); return 80063; } if (!unlink($tmp)) { // Failed to remove tmp file error_log(date('M d H:i:s ') . 'WARNING: ' . $GLOBALS['messages'][80070]); } return 0; }
function apiImportLabs($p) { ini_set('max_execution_time', '300'); ini_set('memory_limit', '64M'); if (!isset($p['file']) || empty($p['file'])) { // Upload failed $output['code'] = 400; $output['status'] = 'fail'; $output['message'] = $GLOBALS['messages'][80081]; return $output; } if (!isset($p['path'])) { // Path is not set $output['code'] = 400; $output['status'] = 'fail'; $output['message'] = $GLOBALS['messages'][80076]; return $output; } if (checkFolder(BASE_LAB . $p['path']) !== 0) { // Path is not valid $output['code'] = 400; $output['status'] = 'fail'; $output['message'] = $GLOBALS['messages'][80077]; return $output; } $finfo = new finfo(FILEINFO_MIME); if (strpos($finfo->file($p['file']), 'application/zip') !== False) { // UNetLab export $cmd = 'unzip -o -d "' . BASE_LAB . $p['path'] . '" ' . $p['file'] . ' *.unl'; exec($cmd, $o, $rc); if ($rc != 0) { $output['code'] = 400; $output['status'] = 'fail'; $output['message'] = $GLOBALS['messages'][80079]; return $output; } $output['code'] = 200; $output['status'] = 'success'; $output['message'] = $GLOBALS['messages'][80080]; return $output; } else { if (strpos($finfo->file($p['file']), 'application/x-gzip') !== False) { // iou-web export $tmp = tempnam(sys_get_temp_dir(), 'iouweb_'); $dst = '/opt/unetlab/labs/Imported'; $cmd = 'gunzip -c ' . $p['file'] . ' > ' . $tmp; $default_image = 'L3-TPGEN+ADVENTERPRISEK9-M-12.4-20090714.bin'; exec($cmd, $o, $rc); if ($rc != 0) { unlink($tmp); $output['code'] = 400; $output['status'] = 'fail'; $output['message'] = $GLOBALS['messages'][80086]; return $output; } // Open the iou-web database try { $db = new PDO('sqlite:' . $tmp); $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } catch (Exception $e) { unlink($tmp); $output['code'] = 400; $output['status'] = 'fail'; $output['message'] = $GLOBALS['messages'][80086]; error_log(date('M d H:i:s ') . 'ERROR: ' . $GLOBALS['messages'][80086]); error_log(date('M d H:i:s ') . (string) $e); return $output; } // Creating import dir if it does not exist if (!is_dir($dst) && !mkdir($dst)) { unlink($tmp); $output['code'] = 400; $output['status'] = 'fail'; $output['message'] = $GLOBALS['messages'][80086]; error_log(date('M d H:i:s ') . 'ERROR: ' . $GLOBALS['messages'][80086]); error_log(date('M d H:i:s ') . (string) $e); return $output; } // List all iou-web labs try { $query_labs = 'SELECT lab_id, lab_name, lab_description, lab_info, lab_netmap FROM labs;'; $statement_labs = $db->prepare($query_labs); $statement_labs->execute(); } catch (Exception $e) { unlink($tmp); $output['code'] = 400; $output['status'] = 'fail'; $output['message'] = $GLOBALS['messages'][80086]; error_log(date('M d H:i:s ') . 'ERROR: ' . $GLOBALS['messages'][80086]); error_log(date('M d H:i:s ') . (string) $e); return $output; } // Import each lab while ($result_labs = $statement_labs->fetch(PDO::FETCH_ASSOC)) { //error_log('INFO: found iou-web lab "'.$result_labs['lab_name'].'" with lab_id = '.$result_labs['lab_id'].'.'); $lab_file = $dst . '/' . $result_labs['lab_name'] . '.unl'; if (is_file($lab_file)) { error_log('ERROR: skipping lab lab_id = ' . $result_labs['lab_id'] . ', file "' . $lab_file . '" already exists.'); //continue; unlink($lab_file); } // Adding new file try { $lab = new Lab($lab_file, 0); } catch (Exception $e) { unlink($tmp); $output['code'] = 400; $output['status'] = 'fail'; $output['message'] = $GLOBALS['messages'][80086]; error_log(date('M d H:i:s ') . 'ERROR: ' . $GLOBALS['messages'][80086]); error_log(date('M d H:i:s ') . (string) $e); return $output; } //error_log('INFO: importing lab "'.$result_labs['lab_name'].'.'); // Setting author, description, version $p_lab = array('author' => 'Imported from iou-web', 'version' => date('Ymd')); if (!empty($result['lab_description']) || !empty($result_labs['lab_info'])) { $p_lab['description'] = trim($result_labs['lab_description'] . ' ' . $result_labs['lab_info']); } $rc = $lab->edit($p_lab); if ($rc !== 0) { error_log('ERROR: failed to set author/description/version while importing lab "' . $result_labs['lab_name'] . '.'); error_log($GLOBALS['messages'][$rc]); } // Adding pictures try { $query_pictures = 'SELECT images.img_id, img_name, img_content, img_map FROM images LEFT JOIN rel_img_lab ON images.img_id = rel_img_lab.img_id WHERE rel_img_lab.lab_id = :lab_id'; $statement_pictures = $db->prepare($query_pictures); $statement_pictures->bindParam(':lab_id', $result_labs['lab_id'], PDO::PARAM_INT); $statement_pictures->execute(); $statement_pictures->execute(); while ($result_pictures = $statement_pictures->fetch(PDO::FETCH_ASSOC)) { //error_log('INFO: found iou-web picture img_name = '.$result_pictures['img_name'].' with img_id = '.$result_pictures['img_id'].'.'); $p_picture = array('type' => 'image/png', 'data' => $result_pictures['img_content']); if (!empty($result_pictures['img_name'])) { $p_picture['name'] = $result_pictures['img_name']; } if (!empty($result_pictures['img_map'])) { $p_picture['map'] = $result_pictures['img_map']; $p_picture['map'] = preg_replace_callback('/:2*([0-9]+)/', function ($m) { return ':{{NODE$' . (int) $m[1] . '}}'; }, $p_picture['map']); //$p_picture['map'] = preg_replace_callback('/coords=\'([0-9]+),([0-9]+),/', function($m) { return 'coords=\''.((int) ($m[1] / 1.78)).','.((int) ($m[2] / 1.78).','); }, $p_picture['map']); } $rc = $lab->addPicture($p_picture); if ($rc !== 0) { error_log('ERROR: skipping picture img_id = ' . $result_pictures['img_id'] . ', error while creating picture.'); error_log($GLOBALS['messages'][$rc]); } } } catch (Exception $e) { error_log('ERROR: cannot list pictures for iou-web lab "' . $result_labs['lab_name'] . '.'); error_log((string) $e); } // Parsing NETMAP $netmap = preg_replace('/(#.*)/', '', $result_labs['lab_netmap']); // Remove comments $netmap = preg_replace("/(^[\r\n]*|[\r\n]+)[\\s\t]*[\r\n\\']+/", "\n", $netmap); // Remove empty lines $netmap = preg_replace("/[\\s]+\n/", "\n", $netmap); // Remove trailing spaces (trim lines) $netmap = trim($netmap); // Remove trailing spaces (trim all) $network_id = 1; $node_id = 1; $all_nodes = array(); // Key is iou-web node_id, value is UNetLab node_id $all_ethernets = array(); // Key is iou-web node_id, value is configured ethernet interfaces foreach (explode("\n", $netmap) as $line) { $line = preg_replace('/\\s+/', ' ', $line); // Remove duplicated spaces $elements = explode(' ', $line); $network_added = False; $remote_node = False; foreach ($elements as $element) { $id = (int) substr($element, 0, strpos($element, ':')); $portgroup = (int) substr($element, strpos($element, ':') + 1, strpos($element, '/')); $interface = (int) substr($element, strpos($element, '/') + 1); $interface_id = $portgroup + $interface * 16; //error_log('INFO: found iou-web node '.$id.':'.$portgroup.'/'.$interface.'.'); if ($id < 1) { error_log('ERROR: skipping node, invalid iou-web ID.'); continue; } if (!isset($all_nodes[$id])) { // New node, need to create // Getting a single node try { $query_nodes = 'SELECT dev_name, bin_name, dev_ram, dev_nvram, dev_ethernet, dev_serial, dev_picture, dev_delay, dev_top, dev_left, cfg_config FROM devices LEFT JOIN configs ON devices.cfg_id = configs.cfg_id WHERE dev_id = :dev_id AND lab_id = :lab_id AND dev_picture != "cloud";'; $statement_nodes = $db->prepare($query_nodes); $statement_nodes->bindParam(':dev_id', $id, PDO::PARAM_INT); $statement_nodes->bindParam(':lab_id', $result_labs['lab_id'], PDO::PARAM_INT); $statement_nodes->execute(); $result_nodes = $statement_nodes->fetch(PDO::FETCH_ASSOC); $p_node = array('iou-web' => $id, 'id' => $node_id, 'type' => 'iol', 'template' => 'iol', 'name' => $result_nodes['dev_name'], 'image' => $result_nodes['bin_name'], 'nvram' => (int) $result_nodes['dev_nvram'], 'ram' => (int) $result_nodes['dev_ram'], 'ethernet' => (int) $result_nodes['dev_ethernet'], 'serial' => (int) $result_nodes['dev_serial'], 'picture' => $result_nodes['dev_picture'], 'delay' => (int) $result_nodes['dev_delay'], 'top' => 768 * $result_nodes['dev_top'] / 100, 'left' => 1024 * $result_nodes['dev_left'] / 100); if ($p_node['top'] == 0) { unset($p_node['top']); } if ($p_node['left'] == 0) { unset($p_node['left']); } // Fixing images if (!is_file('/opt/unetlab/addons/iol/bin/' . $p_node['image'])) { $p_node['image'] = $default_image; } // Fixing pictures if ($p_node['picture'] == 'desktop') { $p_node['picture'] = 'Desktop.png'; } if ($p_node['picture'] == 'hub') { $p_node['picture'] = 'HUB.png'; } if ($p_node['picture'] == 'mpls') { $p_node['picture'] = 'MPLS.png'; } if ($p_node['picture'] == 'router') { $p_node['picture'] = 'Router.png'; } if ($p_node['picture'] == 'framerelay') { $p_node['picture'] = 'Frame Relay.png'; } if ($p_node['picture'] == 'l3switch') { $p_node['picture'] = 'Switch L3.png'; } if ($p_node['picture'] == 'switch') { $p_node['picture'] = 'Switch.png'; } if ($p_node['picture'] == 'nam') { $p_node['picture'] = 'Network Analyzer.png'; } //error_log('INFO: adding node node_id = '.$node_id.' (name = '.$p_node['name'].', image = '.$p_node['image'].', nvram = '.$p_node['nvram'].', ram = '.$p_node['ram'].', eth = '.$p_node['ethernet'].', ser = '.$p_node['serial'].', picture = '.$p_node['picture'].', delay = '.$p_node['delay'].', top = '.$p_node['top'].', left = '.$p_node['left'].').'); //print_r('INFO: adding node node_id = '.$node_id.' (name = '.$p_node['name'].', image = '.$p_node['image'].', nvram = '.$p_node['nvram'].', ram = '.$p_node['ram'].', eth = '.$p_node['ethernet'].', ser = '.$p_node['serial'].', picture = '.$p_node['picture'].', delay = '.$p_node['delay'].', top = '.$p_node['top'].', left = '.$p_node['left'].').'); $rc = $lab->addNode($p_node); if ($rc !== 0) { error_log('ERROR: skipping node node_id = ' . $node_id . ', error while importing.'); error_log($GLOBALS['messages'][$rc]); continue; } // Adding startup-config if (!empty($result_nodes['cfg_config'])) { //error_log('INFO: adding config for node_id = '.$node_id.').'); } $rc = $lab->setNodeConfigData($node_id, $result_nodes['cfg_config']); if ($rc !== 0) { error_log('ERROR: skipping config for for node_id = ' . $node_id . ', error while importing.'); error_log($GLOBALS['messages'][$rc]); } $all_nodes[$id] = $node_id; $all_ethernets[$id] = $p_node['ethernet']; $node_id = $node_id + 1; } catch (Exception $e) { error_log('ERROR: skipping node dev_id = ' . $id . ', error while creating node.'); error_log((string) $e); continue; } } else { //error_log('INFO: skipping iou-web node '.$id.':'.$portgroup.'/'.$interface.' ('.$interface_id.'), already created.'); } // Node is added, need to connect interfaces if ($portgroup <= $all_ethernets[$id] - 1) { // Got an ethernet inteface if ($network_added === False) { // Need to create the network //error_log('INFO: adding network network_id = '.$network_id.').'); $p_network = array('type' => 'bridge', 'name' => 'Net' . $network_id); $rc = $lab->addNetwork($p_network); if ($rc != 0) { error_log('ERROR: skipping network network_id = ' . $network_id . ', error while creating.'); error_log($GLOBALS['messages'][$rc]); continue; } else { $network_added = True; } } // Connect the node $p_interface = array($interface_id => $network_id); //error_log('INFO: connecting (ethernet) node '.$id.':'.$portgroup.'/'.$interface.' ('.$all_nodes[$id].':'.$interface_id.') to network '.$network_id.'.'); $rc = $lab->connectNode($all_nodes[$id], $p_interface); if ($rc != 0) { error_log('ERROR: skipping interface ' . $portgroup . '/' . $interface . ' (' . $all_nodes[$id] . ':' . $interface_id . ') for node_id = ' . $all_nodes[$id] . ', error while connecting.'); error_log($GLOBALS['messages'][$rc]); } } else { // Got a serial interface if ($remote_node === False) { // Fisrt node on this link $remote_node = $all_nodes[$id] . ':' . $interface_id; } else { // Second node on this link, connect and reset the parameter $p_interface = array($interface_id => $remote_node); //error_log('INFO: connecting (serial) node '.$all_nodes[$id].':'.$portgroup.'/'.$interface.' ('.$all_nodes[$id].':'.$interface_id.') to node '.$remote_node.'.'); $rc = $lab->connectNode($all_nodes[$id], $p_interface); if ($rc != 0) { error_log('ERROR: skipping interface ' . $portgroup . '/' . $interface . ' (' . $all_nodes[$id] . ':' . $interface_id . ') for node_id = ' . $all_nodes[$id] . ', error while connecting.'); error_log($GLOBALS['messages'][$rc]); } $remote_node = False; } } } if ($network_added === True) { $network_id = $network_id + 1; $network_added = False; } } error_log('INFO: lab "' . $result_labs['lab_name'] . '" imported into "' . $lab_file . '".'); } $output['code'] = 200; $output['status'] = 'success'; $output['message'] = $GLOBALS['messages'][80087]; unlink($tmp); return $output; } else { // File is not a Zip $output['code'] = 400; $output['status'] = 'fail'; $output['message'] = $GLOBALS['messages'][80078]; return $output; } } }
function apiCloneLab($p, $tenant) { $rc = checkFolder(BASE_LAB . dirname($p['source'])); if ($rc === 2) { // Folder is not valid $output['code'] = 400; $output['status'] = 'fail'; $output['message'] = $GLOBALS['messages'][60009]; return $output; } else { if ($rc === 1) { // Folder does not exist $output['code'] = 404; $output['status'] = 'fail'; $output['message'] = $GLOBALS['messages'][60008]; return $output; } } if (!is_file(BASE_LAB . $p['source'])) { $output['code'] = 400; $output['status'] = 'fail'; $output['message'] = $GLOBALS['messages'][60000]; return $output; } if (!copy(BASE_LAB . $p['source'], BASE_LAB . dirname($p['source']) . '/' . $p['name'] . '.unl')) { // Failed to copy $output['code'] = 400; $output['status'] = 'fail'; $output['message'] = $GLOBALS['messages'][60037]; error_log('ERROR: ' . $GLOBALS['messages'][60037]); return $output; } try { $lab = new Lab(BASE_LAB . dirname($p['source']) . '/' . $p['name'] . '.unl', $tenant); } catch (Exception $e) { // Lab file is invalid $output['code'] = 400; $output['status'] = 'fail'; $output['message'] = $GLOBALS['messages'][$e->getMessage()]; $app->response->setStatus($output['code']); $app->response->setBody(json_encode($output)); return; } $rc = $lab->edit($p); if ($rc !== 0) { $output['code'] = 400; $output['status'] = 'fail'; $output['message'] = $GLOBALS['messages'][$rc]; } else { $output['code'] = 200; $output['status'] = 'success'; $output['message'] = $GLOBALS['messages'][60036]; } return $output; }
$lab = Utils::getById($_GET['labkeyedit'], 'laboratorios', 'id_laboratorio', 'Lab'); } if (array_key_exists('saveLab', $_POST)) { $dados = array('nome_laboratorio' => array('Laboratório'), 'numero_laboratorio' => array('Número', 'tipo' => 'inteiro')); $validacao = ValidaFormulario($dados); if ($validacao === true) { $data = array('nome_laboratorio' => $_POST['nome_laboratorio'], 'numero_laboratorio' => $_POST['numero_laboratorio']); $lab = new Lab(); LabMapper::map($lab, $data); LabMapper::addLabs($lab); header('location:index.php?modulo=chaves&page=visualizar'); } } if (array_key_exists('updateLab', $_POST)) { $dados = array('nome_laboratorio' => array('Laboratório'), 'numero_laboratorio' => array('Número', 'tipo' => 'inteiro')); $validacao = ValidaFormulario($dados); if ($validacao === true) { $data = array('id_laboratorio' => $_POST['id_laboratorio'], 'nome_laboratorio' => $_POST['nome_laboratorio'], 'numero_laboratorio' => $_POST['numero_laboratorio']); $lab = new Lab(); LabMapper::map($lab, $data); LabMapper::updateLab($lab); header('location:index.php?modulo=chaves&page=visualizar'); } } if (array_key_exists('labkeydelete', $_GET)) { $lab = new Lab(); $lab->setIdLaboratorio($_GET['labkeydelete']); LabMapper::deleteLab($lab); header('location:index.php?modulo=chaves&page=visualizar'); } }
exit(5); } else { $tenant = (int) $options['T']; } } } // Checking -F (Lab file) if (in_array($action, array('delete', 'export', 'start', 'stop', 'wipe'))) { if (!is_file($options['F'])) { // File not found usage(); error_log(date('M d H:i:s ') . date('M d H:i:s ') . 'ERROR: ' . $GLOBALS['messages'][6]); exit(6); } try { $lab = new Lab($options['F'], $tenant); } catch (Exception $e) { // Lab file is invalid error_log(date('M d H:i:s ') . date('M d H:i:s ') . 'ERROR: ' . $GLOBALS['messages'][$e->getMessage()]); error_log(date('M d H:i:s ') . date('M d H:i:s ') . 'ERROR: ' . $GLOBALS['messages'][7]); exit(7); } } // Checking -D (Node ID) if (isset($options['D'])) { if ((int) $options['D'] > 0 && isset($lab->getNodes()[$options['D']])) { $node_id = (int) $options['D']; } else { // Node ID must be numeric, greater than 0 and exists on lab usage(); error_log(date('M d H:i:s ') . date('M d H:i:s ') . 'ERROR: ' . $GLOBALS['messages'][8]);
# Workaround: Resolve the search key variables if (empty($keyword) && !empty($searchkey)) { $keyword = $searchkey; } if (is_numeric($keyword)) { $keyword = (int) $keyword; } else { # Convert other wildcards $keyword = strtr($keyword, '*&', '%_'); } } if ($search && !empty($keyword)) { # Load the date formatter include_once $root_path . 'include/inc_date_format_functions.php'; include_once $root_path . 'include/care_api_classes/class_lab.php'; $lab_obj = new Lab(); #Load and create paginator object include_once $root_path . 'include/care_api_classes/class_paginator.php'; $pagen =& new Paginator($pgx, $thisfile, $_SESSION['sess_searchkey'], $root_path); $GLOBAL_CONFIG = array(); include_once $root_path . 'include/care_api_classes/class_globalconfig.php'; $glob_obj = new GlobalConfig($GLOBAL_CONFIG); # Get the max nr of rows from global config $glob_obj->getConfig('pagin_patient_search_max_block_rows'); if (empty($GLOBAL_CONFIG['pagin_patient_search_max_block_rows'])) { $pagen->setMaxCount(MAX_BLOCK_ROWS); } else { $pagen->setMaxCount($GLOBAL_CONFIG['pagin_patient_search_max_block_rows']); } $encounter =& $lab_obj->searchPatientWithPendingLabResults($keyword, $pagen->MaxCount(), $pgx, $oitem, $odir); //echo $lab_obj->getLastQuery()."<p>";
$local_user = '******'; $breakfile = $root_path . 'modules/laboratory/labor_datalist_noedit.php' . URL_APPEND . '&pn=' . $encounter_nr . '&user_origin=' . $user_origin . '&edit=' . $edit; } if (!$_COOKIE[$local_user . $sid]) { header("location:" . $root_path . "language/" . $lang . "/lang_" . $lang . "_invalid-access-warning.php"); exit; } if (!$encounter_nr) { header("location:" . $root_path . "modules/laboratory/labor_data_patient_such.php?sid={$sid}&lang={$lang}"); } require_once $root_path . 'include/inc_config_color.php'; $thisfile = basename($_SERVER['PHP_SELF']); /* Create encounter object */ require_once $root_path . 'include/care_api_classes/class_lab.php'; $enc_obj = new Encounter($encounter_nr); $lab_obj = new Lab($encounter_nr); //gjergji : //diff for the date of birth function dateDiff($dformat, $endDate, $beginDate) { $date_parts1 = explode($dformat, $beginDate); $date_parts2 = explode($dformat, $endDate); $start_date = gregoriantojd($date_parts1[1], $date_parts1[2], $date_parts1[0]); $end_date = gregoriantojd($date_parts2[1], $date_parts2[2], $date_parts2[0]); return $end_date - $start_date; } //gjergji //display the median values function medianValue($paramValue, $pName) { global $patient;
/** * Function to wipe all nodes. * * @param Lab $lab Lab * @param int $tenant Tenant ID * @return Array Return code (JSend data) */ function apiWipeLabNodes($lab, $tenant) { $cmd = 'sudo /opt/unetlab/wrappers/unl_wrapper'; $cmd .= ' -a wipe'; $cmd .= ' -T ' . $tenant; $cmd .= ' -F "' . $lab->getPath() . '/' . $lab->getFilename() . '"'; $cmd .= ' 2>> /opt/unetlab/data/Logs/unl_wrapper.txt'; exec($cmd, $o, $rc); if ($rc == 0) { // Nodes started $output['code'] = 200; $output['status'] = 'success'; $output['message'] = $GLOBALS['messages'][80052]; } else { // Failed to start $output['code'] = 400; $output['status'] = 'fail'; $output['message'] = $GLOBALS['messages'][$rc]; } return $output; }