本文整理汇总了PHP中addAlert函数的典型用法代码示例。如果您正苦于以下问题:PHP addAlert函数的具体用法?PHP addAlert怎么用?PHP addAlert使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了addAlert函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createAction
function createAction()
{
$config = getConfig();
$params = $config['memcache'];
$table = ['name' => 'item', 'dbname' => 'db_vktest', 'as' => 'i'];
$item = handleRequest($_POST);
$mysqli = db_mysqli_connect($table['dbname']);
$queryInsert = "INSERT INTO item (name,description,price,url) VALUES (" . "'" . mysqli_real_escape_string($mysqli, $item['name']) . "'," . "'" . mysqli_real_escape_string($mysqli, $item['description']) . "'," . $item['price'] . "," . "'" . mysqli_real_escape_string($mysqli, $item['url']) . "'" . ")";
$resultInsert = mysqli_query($mysqli, $queryInsert);
$resultError = mysqli_error($mysqli);
db_mysqli_close($mysqli);
if (!$resultInsert) {
addAlert('danger', 'Произошла ошибка записи:' . $resultError);
$url = 'http://' . $_SERVER['HTTP_HOST'] . "/";
header('Location: ' . $url);
exit;
}
//another proc
$pid = pcntl_fork();
if ($pid == 0) {
changeCountItemsById(1, 1);
exit(0);
}
addAlert('success', 'Продукт добавлен');
$url = 'http://' . $_SERVER['HTTP_HOST'] . "/";
header('Location: ' . $url);
}
示例2: db_mysqli_connect
function db_mysqli_connect($db_name)
{
$config = getConfig();
$dbParam = $config['databases'][$db_name];
$mysqli = mysqli_connect($dbParam['host'], $dbParam['user'], $dbParam['password'], $db_name, $dbParam['port']);
if (mysqli_connect_errno()) {
addAlert('danger', 'Нет подключения к базе данных:' . mysqli_connect_error());
$url = 'http://' . $_SERVER['HTTP_HOST'] . "/";
header('Location: ' . $url);
exit;
}
return $mysqli;
}
示例3: updateAction
function updateAction()
{
$config = getConfig();
$table = ['name' => 'item', 'dbname' => 'db_vktest', 'as' => 'i'];
$item = handleRequest($_POST);
$mysqli = db_mysqli_connect($table['dbname']);
$queryUpdate = "UPDATE item SET " . "name='" . mysqli_real_escape_string($mysqli, $item['name']) . "'," . "description='" . mysqli_real_escape_string($mysqli, $item['description']) . "'," . "price=" . $item['price'] . "," . "url='" . mysqli_real_escape_string($mysqli, $item['url']) . "'" . " WHERE iditem=" . $item['iditem'];
$resultUpdate = mysqli_query($mysqli, $queryUpdate);
$resultError = mysqli_error($mysqli);
db_mysqli_close($mysqli);
if (!$resultUpdate) {
addAlert('danger', 'Произошла ошибка записи:' . $resultError);
$url = 'http://' . $_SERVER['HTTP_HOST'] . "/";
header('Location: ' . $url);
exit;
}
addAlert('success', 'Продукт сохранен!');
$url = 'http://' . $_SERVER['HTTP_HOST'] . "/";
header('Location: ' . $url);
}
示例4: apiReturnError
} else {
if ($group_id) {
// Attempt to load action permits for the specified group.
if (!($results = loadGroupActionPermits($group_id))) {
apiReturnError($ajax, getReferralPage());
}
} else {
if ($all == "users") {
// Attempt to load action permits for all users
if (!($results = loadUserActionPermits("all"))) {
apiReturnError($ajax, getReferralPage());
}
} else {
if ($all == "groups") {
// Attempt to load action permits for all groups
if (!($results = loadGroupActionPermits("all"))) {
apiReturnError($ajax, getReferralPage());
}
} else {
addAlert("danger", "user_id, group_id, or all must be specified.");
apiReturnError($ajax, getReferralPage());
}
}
}
}
restore_error_handler();
if ($pretty) {
echo prettyPrint(json_encode($results, JSON_PRETTY_PRINT));
} else {
echo json_encode($results);
}
示例5: Validator
// Update an action_permit mapping for a user or group.
// POST: action_id, permit, [user_id, group_id]
$validator = new Validator();
$action_id = $validator->requiredPostVar('action_id');
$permit = $validator->requiredPostVar('permit');
$group_id = $validator->optionalPostVar('group_id');
$user_id = $validator->optionalPostVar('user_id');
// Add alerts for any failed input validation
foreach ($validator->errors as $error) {
addAlert("danger", $error);
}
if (count($validator->errors) > 0) {
apiReturnError($ajax, getReferralPage());
}
//Forms posted
if ($group_id) {
if (!updateGroupActionPermit($action_id, $group_id, $permit)) {
apiReturnError($ajax, getReferralPage());
}
} else {
if ($user_id) {
if (!updateUserActionPermit($action_id, $user_id, $permit)) {
apiReturnError($ajax, getReferralPage());
}
} else {
addAlert("danger", "You must specify a user or group id!");
apiReturnError($ajax, getReferralPage());
}
}
restore_error_handler();
apiReturnSuccess($ajax, getReferralPage());
示例6: fetchUserMin
function fetchUserMin($user_id)
{
try {
global $db_table_prefix;
$results = array();
$db = pdoConnect();
$sqlVars = array();
$query = "select {$db_table_prefix}users.id as user_id, user_name, display_name from {$db_table_prefix}users where {$db_table_prefix}users.id = :user_id";
$sqlVars[':user_id'] = $user_id;
$stmt = $db->prepare($query);
$stmt->execute($sqlVars);
if (!($results = $stmt->fetch(PDO::FETCH_ASSOC))) {
addAlert("danger", "Invalid user id specified");
return false;
}
$stmt = null;
return $results;
} catch (PDOException $e) {
addAlert("danger", "Oops, looks like our database encountered an error.");
error_log("Error in " . $e->getFile() . " on line " . $e->getLine() . ": " . $e->getMessage());
return false;
} catch (ErrorException $e) {
addAlert("danger", "Oops, looks like our server might have goofed. If you're an admin, please check the PHP error logs.");
return false;
}
}
示例7: lang
//Success, user details have been updated in the db now mail this information out.
$successes[] = lang("ACCOUNT_NEW_ACTIVATION_SENT");
}
}
}
}
}
}
}
} else {
$errors[] = lang("NO_DATA");
}
restore_error_handler();
foreach ($errors as $error) {
addAlert("danger", $error);
}
foreach ($successes as $success) {
addAlert("success", $success);
}
if (isset($_POST['ajaxMode']) and $_POST['ajaxMode'] == "true") {
echo json_encode(array("errors" => count($errors), "successes" => count($successes)));
} else {
// Send successes to the home page, while errors should return them to the activation page.
if (count($errors) == 0) {
header('Location: index.php');
exit;
} else {
header('Location: resend_activation.php');
exit;
}
}
示例8: addAlert
if ($self) {
//Confirm the hashes match before updating a users password
if ($passwordcheck == "") {
addAlert("danger", lang("ACCOUNT_SPECIFY_PASSWORD"));
apiReturnError($ajax, getReferralPage());
} else {
if (!passwordVerifyUF($passwordcheck, $loggedInUser->hash_pw)) {
//No match
addAlert("danger", lang("ACCOUNT_PASSWORD_INVALID"));
apiReturnError($ajax, getReferralPage());
}
}
}
// Prevent updating if someone attempts to update with the same password
if (passwordVerifyUF($password, $loggedInUser->hash_pw)) {
addAlert("danger", lang("ACCOUNT_PASSWORD_NOTHING_TO_UPDATE"));
apiReturnError($ajax, getReferralPage());
}
if (!($password_hash = updateUserPassword($user_id, $password, $passwordc))) {
$error_count++;
} else {
// If we're updating for the currently logged in user, update their hash_pw field
if ($self) {
$loggedInUser->hash_pw = $password_hash;
}
$success_count++;
}
}
//Remove groups
if (!empty($rm_groups)) {
// Convert string of comma-separated group_id's into array
示例9: addAlert
if (!isUserLoggedIn()) {
addAlert("danger", "You must be logged in to access this resource.");
echo json_encode(array("errors" => 1, "successes" => 0));
exit;
}
// GET Parameters: [user_id, group_id, limit]
// If a user_id is specified, attempt to load information for the specified user (self if set to 0).
// If a group_id is specified, attempt to load information for all users in the specified group.
// Otherwise, attempt to load all users.
$validator = new Validator();
$limit = $validator->optionalGetVar('limit');
$user_id = $validator->optionalGetVar('user_id');
$group_id = $validator->optionalGetVar('group_id');
// Add alerts for any failed input validation
foreach ($validator->errors as $error) {
addAlert("danger", $error);
}
if ($user_id) {
// Special case to load groups for the logged in user
if ($user_id == "0") {
$user_id = $loggedInUser->user_id;
}
if (!($results = loadUser($user_id))) {
echo json_encode(array("errors" => 1, "successes" => 0));
exit;
}
} else {
if ($group_id) {
if (!($results = loadUsersInGroup($group_id))) {
echo json_encode(array("errors" => 1, "successes" => 0));
exit;
示例10: Copyright
By Alex Weissman
Copyright (c) 2014
Based on the UserCake user management system, v2.0.2.
Copyright (c) 2009-2012
UserFrosting, like UserCake, is 100% free and open-source.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the 'Software'), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
require_once "../models/config.php";
// Always a publically accessible script
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
addAlert($_POST['type'], $_POST['message']);
}
if ($_SERVER['REQUEST_METHOD'] == 'GET') {
echo json_encode($_SESSION["userAlerts"]);
// Reset alerts after they have been delivered
$_SESSION["userAlerts"] = array();
}
示例11: setReferralPage
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
require_once "models/config.php";
setReferralPage(getAbsoluteDocumentPath(__FILE__));
//Prevent the user visiting the logged in page if he/she is already logged in
if (isUserLoggedIn()) {
addAlert("danger", "I'm sorry, you cannot request an activation email while logged in. Please log out first.");
apiReturnError(false, SITE_ROOT);
}
?>
<!DOCTYPE html>
<html lang="en">
<?php
echo renderTemplate("head.html", array("#SITE_ROOT#" => SITE_ROOT, "#SITE_TITLE#" => SITE_TITLE, "#PAGE_TITLE#" => "Resend Activation"));
?>
<body>
<div class="container">
<div class="header">
<ul class="nav nav-pills navbar pull-right">
</ul>
示例12: json_encode
// Try to create the new user
if (!($new_user_id = createUser($user_name, $display_name, $email, $title, $password, $passwordc, $require_activation, $admin))) {
echo json_encode(array("errors" => 1, "successes" => 0));
exit;
}
// If creation succeeds, add default groups for new users
/*if (dbAddUserToDefaultGroups($new_user_id)){
// Uncomment this if you want self-registered users to know about permission groups
//$successes[] = lang("ACCOUNT_PERMISSION_ADDED", array ($addition_count));
} else {
if (isset($_POST['ajaxMode']) and $_POST['ajaxMode'] == "true" ){
echo json_encode(array("errors" => 1, "successes" => 0));
} else {
header('Location: register_root.php');
}
exit();
}*/
// Set the primary group as the "Admin" group
updateUserField('1', 'primary_group_id', '2');
// Account creation was successful!
// On success, create the success message and delete the activation token
deleteConfigParameter('root_account_config_token');
addAlert("success", "You have successfully created the root account. Please delete this installation folder and log in via login.php.");
addAlert("success", "<a href='../login.php'>Click Here</a> to login");
} else {
echo json_encode(array("errors" => $error_count, "successes" => 0));
exit;
}
// Send successfully registered users to the completion page, while errors should return them to the registration page.
echo json_encode(array("errors" => 0, "successes" => 1));
exit;
示例13: addUserToGroup
$addition_count += addUserToGroup($new_user_id, $group_id);
}
// Set primary group
if (!empty($primary_group_id)) {
if (updateUserPrimaryGroup($new_user_id, $primary_group_id)) {
// Account creation was successful!
addAlert("success", lang("ACCOUNT_PRIMARY_GROUP_SET"));
addAlert("success", lang("ACCOUNT_CREATION_COMPLETE", array($user_name)));
} else {
$error_count++;
}
}
// Otherwise, add default groups and set primary group for new users
} else {
if (dbAddUserToDefaultGroups($new_user_id)) {
if ($require_activation) {
// Activation required
addAlert("success", lang("ACCOUNT_REGISTRATION_COMPLETE_TYPE2"));
} else {
// No activation required
addAlert("success", lang("ACCOUNT_REGISTRATION_COMPLETE_TYPE1"));
}
} else {
apiReturnError($ajax, $admin == "true" ? ACCOUNT_ROOT : SITE_ROOT);
}
}
} else {
apiReturnError($ajax, $admin == "true" ? ACCOUNT_ROOT : SITE_ROOT);
}
restore_error_handler();
apiReturnSuccess($ajax, $admin == "true" ? ACCOUNT_ROOT : SITE_ROOT);
示例14: setReferralPage
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
require_once "models/config.php";
// Public page
setReferralPage(getAbsoluteDocumentPath(__FILE__));
//Forward the user to their default page if he/she is already logged in
if (isUserLoggedIn()) {
addAlert("warning", "You're already logged in!");
header("Location: account");
exit;
}
?>
<!DOCTYPE html>
<html lang="en">
<?php
echo renderTemplate("head.html", array("#SITE_ROOT#" => SITE_ROOT, "#SITE_TITLE#" => SITE_TITLE, "#PAGE_TITLE#" => "Welcome to UserFrosting"));
?>
<body>
<div class="container">
<div class="header">
<ul class="nav nav-pills navbar pull-right">
示例15: loadPresetPermitOptions
function loadPresetPermitOptions($fields)
{
// This block automatically checks this action against the permissions database before running.
if (!checkActionPermissionSelf(__FUNCTION__, func_get_args())) {
addAlert("danger", "Sorry, you do not have permission to access this resource.");
return false;
}
return fetchPresetPermitOptions($fields);
}