本文整理汇总了PHP中Alert::addAlert方法的典型用法代码示例。如果您正苦于以下问题:PHP Alert::addAlert方法的具体用法?PHP Alert::addAlert怎么用?PHP Alert::addAlert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Alert
的用法示例。
在下文中一共展示了Alert::addAlert方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkAlerts
/**
* 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);
}
}
示例2: checkAlerts
/**
* 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);
}
}
示例3: MySQLi
<?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');
}
示例4: checkAlerts
/**
* 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);
}
}
示例5: MySQLi
<?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');
}
示例6: MySQLi
<?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>
示例7: MySQLi
<?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');
}
示例8: Alert
<?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');
示例9: MySQLi
<?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>
示例10: MySQLi
<?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';
?>
示例11: MySQLi
<?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');
}