Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ //set the include path $conf = glob("{/usr/local/etc,/etc}/fusionpbx/config.conf", GLOB_BRACE); set_include_path(parse_ini_file($conf[0])['document.root']); //includes files require_once "resources/require.php"; require_once "resources/check_auth.php"; //check permissions if (permission_exists('event_guard_log_add') || permission_exists('event_guard_log_edit')) { //access granted } else { echo "access denied"; exit; } //add multi-lingual support $language = new text; $text = $language->get(); //action add or update if (is_uuid($_REQUEST["id"])) { $action = "update"; $event_guard_log_uuid = $_REQUEST["id"]; $id = $_REQUEST["id"]; } else { $action = "add"; } //get http post variables and set them to php variables if (is_array($_POST)) { $hostname = $_POST["hostname"]; $log_date = $_POST["log_date"]; $filter = $_POST["filter"]; $ip_address = $_POST["ip_address"]; $extension = $_POST["extension"]; $user_agent = $_POST["user_agent"]; $log_status = $_POST["log_status"]; } //process the user data and save it to the database if (count($_POST) > 0 && empty($_POST["persistformvar"])) { //validate the token $token = new token; if (!$token->validate($_SERVER['PHP_SELF'])) { message::add($text['message-invalid_token'],'negative'); header('Location: event_guard_logs.php'); exit; } //process the http post data by submitted action if ($_POST['action'] != '' && !empty($_POST['action'])) { //prepare the array(s) //send the array to the database class switch ($_POST['action']) { case 'copy': if (permission_exists('event_guard_log_add')) { $obj = new database; $obj->copy($array); } break; case 'delete': if (permission_exists('event_guard_log_delete')) { $obj = new database; $obj->delete($array); } break; case 'toggle': if (permission_exists('event_guard_log_update')) { $obj = new database; $obj->toggle($array); } break; } //redirect the user if (in_array($_POST['action'], array('copy', 'delete', 'toggle'))) { header('Location: event_guard_log_edit.php?id='.$id); exit; } } //check for all required data $msg = ''; if (empty($hostname)) { $msg .= $text['message-required']." ".$text['label-hostname']."
\n"; } if (empty($log_date)) { $msg .= $text['message-required']." ".$text['label-log_date']."
\n"; } if (empty($filter)) { $msg .= $text['message-required']." ".$text['label-filter']."
\n"; } if (empty($ip_address)) { $msg .= $text['message-required']." ".$text['label-ip_address']."
\n"; } if (empty($extension)) { $msg .= $text['message-required']." ".$text['label-extension']."
\n"; } //if (empty($user_agent)) { $msg .= $text['message-required']." ".$text['label-user_agent']."
\n"; } if (empty($log_status)) { $msg .= $text['message-required']." ".$text['label-log_status']."
\n"; } if (!empty($msg) && empty($_POST["persistformvar"])) { require_once "resources/header.php"; require_once "resources/persist_form_var.php"; echo "
\n"; echo "
\n"; echo $msg."
"; echo "
\n"; persistformvar($_POST); echo "
\n"; require_once "resources/footer.php"; return; } //add the event_guard_log_uuid if (!is_uuid($_POST["event_guard_log_uuid"])) { $event_guard_log_uuid = uuid(); } //prepare the array $array['event_guard_logs'][0]['event_guard_log_uuid'] = $event_guard_log_uuid; $array['event_guard_logs'][0]['hostname'] = $hostname; $array['event_guard_logs'][0]['log_date'] = $log_date; $array['event_guard_logs'][0]['filter'] = $filter; $array['event_guard_logs'][0]['ip_address'] = $ip_address; $array['event_guard_logs'][0]['extension'] = $extension; $array['event_guard_logs'][0]['user_agent'] = $user_agent; $array['event_guard_logs'][0]['log_status'] = $log_status; //save the data $database = new database; $database->app_name = 'event guard'; $database->app_uuid = 'c5b86612-1514-40cb-8e2c-3f01a8f6f637'; $database->save($array); //redirect the user if (isset($action)) { if ($action == "add") { $_SESSION["message"] = $text['message-add']; } if ($action == "update") { $_SESSION["message"] = $text['message-update']; } //header('Location: event_guard_logs.php'); header('Location: event_guard_log_edit.php?id='.urlencode($event_guard_log_uuid)); return; } } //pre-populate the form if (is_array($_GET) && $_POST["persistformvar"] != "true") { $sql = "select "; $sql .= " event_guard_log_uuid, "; $sql .= " hostname, "; $sql .= " log_date, "; $sql .= " filter, "; $sql .= " ip_address, "; $sql .= " extension, "; $sql .= " user_agent, "; $sql .= " log_status "; $sql .= "from v_event_guard_logs "; $sql .= "where event_guard_log_uuid = :event_guard_log_uuid "; $parameters['event_guard_log_uuid'] = $event_guard_log_uuid; $database = new database; $row = $database->select($sql, $parameters, 'row'); if (is_array($row) && @sizeof($row) != 0) { $hostname = $row["hostname"]; $log_date = $row["log_date"]; $filter = $row["filter"]; $ip_address = $row["ip_address"]; $extension = $row["extension"]; $user_agent = $row["user_agent"]; $log_status = $row["log_status"]; } unset($sql, $parameters, $row); } //create token $object = new token; $token = $object->create($_SERVER['PHP_SELF']); //show the header $document['title'] = $text['title-event_guard_log']; require_once "resources/header.php"; //show the content echo "
\n"; echo "\n"; echo "
\n"; echo "
".$text['title-event_guard_log']."
\n"; echo "
\n"; echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'id'=>'btn_back','collapse'=>'hide-xs','style'=>'margin-right: 15px;','link'=>'event_guard_logs.php']); if ($action == 'update') { if (permission_exists('_add')) { echo button::create(['type'=>'button','label'=>$text['button-copy'],'icon'=>$_SESSION['theme']['button_icon_copy'],'id'=>'btn_copy','name'=>'btn_copy','style'=>'display: none;','onclick'=>"modal_open('modal-copy','btn_copy');"]); } if (permission_exists('_delete')) { echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$_SESSION['theme']['button_icon_delete'],'id'=>'btn_delete','name'=>'btn_delete','style'=>'display: none; margin-right: 15px;','onclick'=>"modal_open('modal-delete','btn_delete');"]); } } echo button::create(['type'=>'submit','label'=>$text['button-save'],'icon'=>$_SESSION['theme']['button_icon_save'],'id'=>'btn_save','collapse'=>'hide-xs']); echo "
\n"; echo "
\n"; echo "
\n"; echo $text['title_description-event_guard_logs']."\n"; echo "

\n"; if ($action == 'update') { if (permission_exists('event_guard_log_add')) { echo modal::create(['id'=>'modal-copy','type'=>'copy','actions'=>button::create(['type'=>'submit','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_copy','style'=>'float: right; margin-left: 15px;','collapse'=>'never','name'=>'action','value'=>'copy','onclick'=>"modal_close();"])]); } if (permission_exists('event_guard_log_delete')) { echo modal::create(['id'=>'modal-delete','type'=>'delete','actions'=>button::create(['type'=>'submit','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_delete','style'=>'float: right; margin-left: 15px;','collapse'=>'never','name'=>'action','value'=>'delete','onclick'=>"modal_close();"])]); } } echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "
\n"; echo " ".$text['label-hostname']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-hostname']."\n"; echo "
\n"; echo " ".$text['label-log_date']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-log_date']."\n"; echo "
\n"; echo " ".$text['label-filter']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-filter']."\n"; echo "
\n"; echo " ".$text['label-ip_address']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-ip_address']."\n"; echo "
\n"; echo " ".$text['label-extension']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-extension']."\n"; echo "
\n"; echo " ".$text['label-user_agent']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-user_agent']."\n"; echo "
\n"; echo " ".$text['label-log_status']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-log_status']."\n"; echo "
"; echo "

"; echo "\n"; echo "
"; //include the footer require_once "resources/footer.php"; ?>