Exemplo n.º 1
0
 /**
  * checkAlerts
  *
  * Check if we hit a alert and act on it here
  *
  * @param string $type type of logging default set to normal but it can be API too.
  * @return string $string if type is API returns data as string
  *
  */
 public function checkAlerts($timestamp, $data1, $data2, $settings)
 {
     //grab module name
     $module = __CLASS__;
     //for writing alert out
     $alert = null;
     //grab overloads
     $overload[1] = $settings['settings']['overload_transfer'];
     $overload[2] = $settings['settings']['overload_receive'];
     //echo 'memory: ' . $data1 . "\n";
     //echo 'totalmemory: ' . $data2 . "\n";
     $trackVal = 0;
     if ($data1 > $overload[1]) {
         $alert[$trackVal][0] = "transfer";
         $alert[$trackVal][1] = (double) $overload[1];
         $alert[$trackVal][2] = $data1;
         $trackVal++;
     }
     if ($data2 > $overload[2]) {
         $alert[$trackVal][0] = "receive";
         $alert[$trackVal][1] = (double) $overload[2];
         $alert[$trackVal][2] = $data2;
     }
     if ($alert != null) {
         //need to build this out
         $string = $timestamp . '|' . $module . "|" . json_encode($alert) . "\n";
         Alert::addAlert($string);
     }
 }
Exemplo n.º 2
0
 /**
  * checkAlerts
  *
  * Check if we hit a alert and act on it here
  *
  * @param string $type type of logging default set to normal but it can be API too.
  * @return string $string if type is API returns data as string
  *
  */
 public function checkAlerts($timestamp, $data1, $data2, $settings)
 {
     //grab module name
     $module = __CLASS__;
     //for writing alert out
     $alert = null;
     //grab overloads
     $overload[1] = $settings['settings']['overload_1'];
     //echo 'memory: ' . $data1 . "\n";
     //echo 'totalmemory: ' . $data2 . "\n";
     //check overloads against data using percentage for disk
     $percentage = $data1 / $data2 * 100;
     //echo 'perc: ' . $percentage . "\n";
     //echo 'overload: ' . $overload[1] . "\n";
     if ($percentage > $overload[1]) {
         $alert[0][0] = "memory";
         $alert[0][1] = (double) $overload[1];
         $alert[0][2] = $percentage;
     }
     if ($alert != null) {
         //need to build this out
         $string = $timestamp . '|' . $module . "|" . json_encode($alert) . "\n";
         Alert::addAlert($string);
     }
 }
Exemplo n.º 3
0
<?php

require_once './config.php';
require_once './lib/alert.class.php';
require_once './lib/user.class.php';
require_once './lib/category.class.php';
$db = new MySQLi($config['database']['host'], $config['database']['username'], $config['database']['password'], $config['database']['database']);
if ($db->connect_errno) {
    die('Ei tietokantayhteyttä.');
}
$alertClass = new Alert();
$userClass = new User($db);
if (!$userClass->isLoggedIn()) {
    $alertClass->addAlert('Sinun täytyy olla kirjautuneen sisään poistaaksesi kategorioita', 'error');
    $alertClass->redirect('/login.php');
}
if (!isset($_GET['id']) || !is_numeric($_GET['id'])) {
    $alertClass->addAlert('Kategorian ID oli tyhjä', 'error');
    $alertClass->redirect('/list_categories.php');
}
$user = $userClass->getCurrentUser();
$categoryClass = new Category($db);
$category = $categoryClass->getCategory($_GET['id']);
if ($category === null) {
    $alertClass->addAlert('Kategoriaa ei löytynyt');
    $alertClass->redirect('/list_categories.php');
}
if ($category['userID'] !== $user['id']) {
    $alertClass->addAlert('Sinulla ei ole oikeuksia tähän kategoriaan', 'error');
    $alertClass->redirect('/list_categories.php');
}
Exemplo n.º 4
0
 /**
  * checkAlerts
  *
  * Check if we hit a alert and act on it here
  *
  * @param string $type type of logging default set to normal but it can be API too.
  * @return string $string if type is API returns data as string
  *
  */
 public function checkAlerts($timestamp, $data, $settings)
 {
     //grab module name
     $module = __CLASS__;
     //for writing alert out
     $alert = null;
     //grab overloads
     $overload[1] = $settings['settings']['overload_1'];
     $overload[2] = $settings['settings']['overload_2'];
     //var_dump($overload);
     //var_dump($data);
     //check overloads against data
     //testing load 5 min only here from data
     if ($data[1] >= $overload[2]) {
         $alert[0][0] = "overload";
         $alert[0][1] = (double) $overload[2];
         $alert[0][2] = $data[1];
     } else {
         if ($data[1] >= $overload[1]) {
             $alert[0][0] = "overload";
             $alert[0][1] = (double) $overload[1];
             $alert[0][2] = $data[1];
         }
     }
     if ($alert != null) {
         //need to build this out
         $string = $timestamp . '|' . $module . "|" . json_encode($alert) . "\n";
         //Logger::addAlert($string);
         Alert::addAlert($string);
     }
 }
Exemplo n.º 5
0
<?php

require_once './config.php';
require_once './lib/alert.class.php';
require_once './lib/user.class.php';
require_once './lib/receipt.class.php';
$db = new MySQLi($config['database']['host'], $config['database']['username'], $config['database']['password'], $config['database']['database']);
if ($db->connect_errno) {
    die('Ei tietokantayhteyttä.');
}
$alertClass = new Alert();
$userClass = new User($db);
if (!$userClass->isLoggedIn()) {
    $alertClass->addAlert('Sinun täytyy olla kirjautuneen sisään katsellaksesi kuitteja', 'error');
    $alertClass->redirect('/login.php');
}
if (!isset($_GET['id']) || !is_numeric($_GET['id'])) {
    $alertClass->addAlert('Kuitin ID oli tyhjä');
    $alertClass->redirect('/list_receipts.php');
}
$user = $userClass->getCurrentUser();
$receiptClass = new Receipt($db);
$receipt = $receiptClass->getReceipt($_GET['id']);
if ($receipt === null) {
    $alertClass->addAlert('Kuittia ei löytynyt');
    $alertClass->redirect('/list_receipts.php');
}
if ($receipt['userID'] !== $user['id']) {
    $alertClass->addAlert('Sinulla ei ole oikeuksia tähän kuittiin');
    $alertClass->redirect('/list_receipts.php');
}
Exemplo n.º 6
0
<?php

require_once './config.php';
require_once './lib/alert.class.php';
require_once './lib/user.class.php';
require_once './lib/category.class.php';
$db = new MySQLi($config['database']['host'], $config['database']['username'], $config['database']['password'], $config['database']['database']);
if ($db->connect_errno) {
    die('Ei tietokantayhteyttä.');
}
$alertClass = new Alert();
$userClass = new User($db);
if (!$userClass->isLoggedIn()) {
    $alertClass->addAlert('Sinun täytyy olla kirjautuneen sisään katsellaksesi kategorioita', 'error');
    $alertClass->redirect('/login.php');
}
$user = $userClass->getCurrentUser();
$categoryClass = new Category($db);
$categories = $categoryClass->getAllCategories($user['id']);
$active = 'categories';
require_once 'header.php';
?>

		<table class="table">
			<thead>
				<tr>
					<th>ID</th>
					<th>Nimi</th>
					<th>Kokonaissumma</th>
					<th></th>
				</tr>
Exemplo n.º 7
0
<?php

require_once './config.php';
require_once './lib/alert.class.php';
require_once './lib/user.class.php';
require_once './lib/receipt.class.php';
$db = new MySQLi($config['database']['host'], $config['database']['username'], $config['database']['password'], $config['database']['database']);
if ($db->connect_errno) {
    die('Ei tietokantayhteyttä.');
}
$alertClass = new Alert();
$userClass = new User($db);
$receiptClass = new Receipt($db);
if (!$userClass->isLoggedIn()) {
    $alertClass->addAlert('Sinun täytyy olla kirjautuneen sisään muokataksesi kuitteja', 'error');
    $alertClass->redirect('/login.php');
}
$user = $userClass->getCurrentUser();
if (!empty($_POST)) {
    if (empty($_POST['id'])) {
        $alertClass->addAlert('Kuitin tunnus oli tyhjä', 'error');
    }
    if (empty($_POST['location'])) {
        $alertClass->addAlert('Kuitin sijainti oli tyhjä', 'error');
    }
    if (empty($_POST['date'])) {
        $alertClass->addAlert('Kuitin päivämäärä oli tyhjä', 'error');
    }
    if (empty($_POST['sum'])) {
        $alertClass->addAlert('Kuitin summa oli tyhjä', 'error');
    }
Exemplo n.º 8
0
<?php

require_once './config.php';
require_once './lib/alert.class.php';
$alertClass = new Alert();
$alerts = $alertClass->getAlerts();
$_SESSION = array();
session_destroy();
session_start();
session_regenerate_id(true);
$alertClass->setAlerts($alerts);
$alertClass->addAlert('Uloskirjautuminen onnistui!', 'success');
$alertClass->redirect('/index.php');
Exemplo n.º 9
0
<?php

require_once './config.php';
require_once './lib/alert.class.php';
require_once './lib/user.class.php';
require_once './lib/receipt.class.php';
$db = new MySQLi($config['database']['host'], $config['database']['username'], $config['database']['password'], $config['database']['database']);
if ($db->connect_errno) {
    die('Ei tietokantayhteyttä.');
}
$alertClass = new Alert();
$userClass = new User($db);
if (!$userClass->isLoggedIn()) {
    $alertClass->addAlert('Sinun täytyy olla kirjautuneen sisään katsellaksesi kuitteja', 'error');
    $alertClass->redirect('/login.php');
}
$user = $userClass->getCurrentUser();
$receiptClass = new Receipt($db);
$receipts = $receiptClass->getAllReceipts($user['id']);
$active = 'receipts';
require_once 'header.php';
?>

		<table class="table">
			<thead>
				<tr>
					<th>ID</th>
					<th>Sijainti</th>
					<th>Päivämäärä</th>
					<th>Summa</th>
				</tr>
Exemplo n.º 10
0
<?php

require_once './config.php';
require_once './lib/alert.class.php';
require_once './lib/user.class.php';
$db = new MySQLi($config['database']['host'], $config['database']['username'], $config['database']['password'], $config['database']['database']);
if ($db->connect_errno) {
    die('Ei tietokantayhteyttä.');
}
$alertClass = new Alert();
$userClass = new User($db);
if (!empty($_POST)) {
    if (empty($_POST['username'])) {
        $alertClass->addAlert('Käyttäjätunnus oli tyhjä', 'error');
    }
    if (empty($_POST['password'])) {
        $alertClass->addAlert('Salasana oli tyhjä', 'error');
    }
    if ($alertClass->hasErrors()) {
        $alertClass->redirect('/login.php');
    }
    $result = $userClass->authenticate($_POST['username'], $_POST['password']);
    if ($result === null) {
        $alertClass->addAlert('Väärä käyttäjätunnus tai salasana', 'error');
    }
    $alertClass->addAlert('Kirjautuminen onnistui!', 'success');
    $alertClass->redirect('/index.php');
}
require_once 'header.php';
?>
Exemplo n.º 11
0
<?php

require_once './config.php';
require_once './lib/alert.class.php';
require_once './lib/user.class.php';
require_once './lib/category.class.php';
$db = new MySQLi($config['database']['host'], $config['database']['username'], $config['database']['password'], $config['database']['database']);
if ($db->connect_errno) {
    die('Ei tietokantayhteyttä.');
}
$alertClass = new Alert();
$userClass = new User($db);
$categoryClass = new Category($db);
if (!$userClass->isLoggedIn()) {
    $alertClass->addAlert('Sinun täytyy olla kirjautuneen sisään muokataksesi kategorioita', 'error');
    $alertClass->redirect('/login.php');
}
$user = $userClass->getCurrentUser();
if (!empty($_POST)) {
    if (empty($_POST['id'])) {
        $alertClass->addAlert('Kategorian tunnus oli tyhjä', 'error');
    }
    if (empty($_POST['name'])) {
        $alertClass->addAlert('Kategorian nimi oli tyhjä', 'error');
    }
    if (!is_numeric($_POST['id'])) {
        $alertClass->addAlert('Virheellinen kategorian tunnus', 'error');
    }
    if ($alertClass->hasErrors()) {
        $alertClass->redirect('/list_categories.php');
    }