<?php

define("CONST_FILE_PATH", "../includes/constants.php");
include '../classes/WebPage.php';
//Set up page as a web page
$thisPage = new WebPage();
//Create new instance of webPage class
$dbObj = new Database();
//Instantiate database
$eventObj = new Event($dbObj);
// Create an object of Event class
$totalNo = filter_input(INPUT_GET, "totalNo", FILTER_VALIDATE_INT) ? mysqli_real_escape_string($dbObj->connection, filter_input(INPUT_GET, "totalNo", FILTER_VALIDATE_INT)) : 100;
$offset = filter_input(INPUT_GET, "offset", FILTER_VALIDATE_INT) ? mysqli_real_escape_string($dbObj->connection, filter_input(INPUT_GET, "offset", FILTER_VALIDATE_INT)) : 0;
echo $eventObj->fetch("*", " status = 1 AND date_time >= NOW() ", " id ASC LIMIT {$totalNo} OFFSET {$offset} ");
Example #2
0
<?php

require 'core/init.php';
if (!isset($_POST['type'])) {
    redirect("index.php");
}
//create an Event object
$event = new Event();
$type = $_POST['type'];
if ($type == 'fetch') {
    echo $event->fetch();
}
if ($type == 'getDetails') {
    $data = array();
    $data['id'] = $_POST['eventid'];
    echo $event->getDetails($data);
}
Example #3
0
 private function event()
 {
     if ($this->get_request_method() == "GET" && isset($this->_request['id'])) {
         $event = new Event((int) $this->_request['id']);
         if ($event->fetch()) {
             $domxmldata = $event->getDomXMLElement($this->domxml);
             $this->response($this->finishxml($domxmldata), 200);
         } else {
             $this->error_code = 1;
             $this->error_message = "Event not found";
             $this->response($this->finishxml(), 404);
         }
     } elseif ($this->get_request_method() == "POST" or $this->get_request_method() == "GET" && !isset($this->_request['id']) && count($_GET) > 1) {
         if ($this->isApiKeyValid($this->api_key)) {
             $data = !empty($_POST) ? $_POST : $_GET;
             $event = new Event(false, false, $this->_request['object'], (int) $this->_request['object_id'], $this->_request['action'], $this->_request['data']);
             $event_id = $event->store();
             if ($event_id != false) {
                 header('Location: ' . ConfigLine::configByName('url_to_netmon') . '/api/rest/event/' . $event_id);
             } else {
                 $this->authentication = false;
                 $this->error_code = 2;
                 $this->error_message = "The Event could not be created. Your request seems to miss some data.";
                 $this->response($this->finishxml(), 400);
             }
         } else {
             $this->error_code = 2;
             $this->error_message = "The api_key is not valid.";
             $this->response($this->finishxml(), 401);
         }
     } else {
         $this->response('', 406);
     }
 }
Example #4
0
<?php

require_once 'runtime.php';
require_once 'lib/core/Event.class.php';
//get messages of the message system
$smarty->assign('message', Message::getMessage());
//get data
$event = new Event((int) $_GET['event_id'], 0);
$event->fetch();
$smarty->assign('event', $event);
//load the template
$smarty->display("header.tpl.html");
$smarty->display("event.tpl.html");
$smarty->display("footer.tpl.html");