当前位置: 首页>>代码示例>>PHP>>正文


PHP Alert::addAlert方法代码示例

本文整理汇总了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);
     }
 }
开发者ID:javinc,项目名称:loadavg,代码行数:38,代码来源:log.Network.php

示例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);
     }
 }
开发者ID:javinc,项目名称:loadavg,代码行数:34,代码来源:log.Memory.php

示例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');
}
开发者ID:AntiPaste,项目名称:kuitinseuranta,代码行数:31,代码来源:remove_category.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);
     }
 }
开发者ID:javinc,项目名称:loadavg,代码行数:40,代码来源:log.Cpu.php

示例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');
}
开发者ID:AntiPaste,项目名称:kuitinseuranta,代码行数:31,代码来源:view_receipt.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>
开发者ID:AntiPaste,项目名称:kuitinseuranta,代码行数:31,代码来源:list_categories.php

示例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');
    }
开发者ID:AntiPaste,项目名称:kuitinseuranta,代码行数:31,代码来源:edit_receipt.php

示例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');
开发者ID:AntiPaste,项目名称:kuitinseuranta,代码行数:13,代码来源:logout.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>
开发者ID:AntiPaste,项目名称:kuitinseuranta,代码行数:31,代码来源:list_receipts.php

示例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';
?>
开发者ID:AntiPaste,项目名称:kuitinseuranta,代码行数:30,代码来源:login.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');
    }
开发者ID:AntiPaste,项目名称:kuitinseuranta,代码行数:31,代码来源:edit_category.php


注:本文中的Alert::addAlert方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。