public function locationsAction() { $locationsModel = new Locations(); if ($this->getRequest()->isPost()) { $data = $this->getRequest()->getPost(); if (@$data['method'] == 'create') { //CREATE NEW Location unset($data['method']); if ($data['name'] == '') { $this->view->error = "Please Provide a Name for the New Location."; $this->view->data = $data; } else { $locationsModel->insert($data); $this->view->success = "New Location Created."; } } if (@$data['method'] == 'update') { //UPDATE Location unset($data['method']); $locationsModel->updateRecord($data['id'], $data); $this->view->success = "User Record Updated."; } if (@$data['method'] == 'delete') { //DELETE Location $where = "id=" . $data['id']; $locationsModel->delete($where); } } $locations = $locationsModel->getAll(); $page = $this->_getParam('page', 1); $paginator = Zend_Paginator::factory($locations); $paginator->setItemCountPerPage(20); $paginator->setCurrentPageNumber($page); $this->view->locations = $paginator; }
Util::response_bad_request(Token::create_error_message()); } } //Perform action if (is_array($validation_errors) && !empty($validation_errors)) { $error_msg = '<div style="padding-left:5px">' . _('The following errors occurred') . ":</div>\n <div style='padding: 5px 5px 5px 15px;'>" . implode('<br/>', $validation_errors) . '</div>'; Util::response_bad_request($error_msg); } $locations_id = POST('locations_id'); $name = POST('l_name'); $ctx = POST('ctx'); $desc = POST('desc'); $location = POST('search_location'); $longitude = POST('longitude'); $latitude = POST('latitude'); $cou = POST('country'); $sensor_list = POST('sensor_list'); try { $db = new ossim_db(); $conn = $db->connect(); if (empty($locations_id)) { $locations_id = Locations::insert($conn, $ctx, $name, $desc, $location, $latitude, $longitude, $cou); } else { Locations::update($conn, $locations_id, $name, $desc, $location, $latitude, $longitude, $cou); } Locations::save_location_sensors($conn, $locations_id, $sensor_list); Util::memcacheFlush(); $db->close(); } catch (Exception $e) { Util::response_bad_request($e->getMessage()); }
//Update admin info list($db, $conn) = Ossim_db::get_conn_db(); $local_tz = trim(Util::execute_command('head -1 /etc/timezone', FALSE, 'string')); Session::update_user_light($conn, AV_DEFAULT_ADMIN, 'pass', $fullname, $email, $company, '', 'en_GB', 0, 1, $local_tz); if ($company != '') { Session::update_default_entity_name($conn, $company); } Session::change_pass($conn, AV_DEFAULT_ADMIN, $pass); // Insert new location if ($location != '' && $lat != '' && $lng != '') { $default_ctx_id = str_replace('-', '', strtoupper($conf->get_conf('default_context_id'))); if (empty($default_ctx_id)) { $default_ctx = '00000000000000000000000000000000'; } $location_name = $company != '' ? $company . ' ' . _('Location') : $title . ' ' . _('Location'); $new_location_id = Locations::insert($conn, $default_ctx_id, $location_name, '', $location, $lat, $lng, $country); $sensors = Av_sensor::get_basic_list($conn); foreach ($sensors as $sensor) { Locations::insert_related_sensor($conn, $new_location_id, $sensor['id']); } } // Save Track Usage Information if ($track_usage_information == 1) { $tui_status = $track_usage_information > 0 ? 1 : 0; $config = new Config(); $config->update('track_usage_information', $tui_status); $client = new Alienvault_client(); $tui_status = $track_usage_information > 0 ? TRUE : FALSE; $client->system()->set_telemetry($tui_status); } $config->update('first_login', 'no');