本文整理汇总了PHP中Random::getGuid方法的典型用法代码示例。如果您正苦于以下问题:PHP Random::getGuid方法的具体用法?PHP Random::getGuid怎么用?PHP Random::getGuid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Random
的用法示例。
在下文中一共展示了Random::getGuid方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: post
public static function post()
{
if (isset($_POST['add_browser'])) {
$page = new Page();
$page->data['title'] = 'Browser toevoegen';
$errMsgs = AddEditBrowserTopViewValidator::validate($_POST);
if (empty($errMsgs)) {
try {
//Create new browser from entered data
$browser = new Browser(null, Random::getGuid(), $_POST['browser_name'], isset($_POST['can_add_renew_users']), isset($_POST['can_check_in']), isset($_POST['is_cash_register']));
BrowserDB::addBrowser($browser);
//Also set cookie
setcookie("stippersAuthorization", $browser->uuid, 2147483647);
$page->data['SuccessMessageNoDescriptionWithLinkView']['successTitle'] = 'Browser successvol toegevoegd';
$page->data['SuccessMessageNoDescriptionWithLinkView']['redirectUrl'] = 'managebrowser';
$page->addView('success/SuccessMessageNoDescriptionWithLinkView');
} catch (BrowserDBException $ex) {
if ($ex->getCode() == BrowserDBException::BROWSERNAMEEXISTS) {
AddBrowserController::buildAddEditBrowserTopView($page, true);
$page->data['AddEditBrowserTopView']['errMsgs']['global'] = '<h2 class="error_message" id="add_edit_browser_form_error_message">Deze naam is reeds in gebruik.</h2>';
} else {
AddBrowserController::buildAddEditBrowserTopView($page, true);
$page->data['AddEditBrowserTopView']['errMsgs']['global'] = '<h2 class="error_message" id="add_edit_browser_form_error_message">Kan browser niet toevoegen, probeer het opnieuw.</h2>';
}
} catch (Exception $ex) {
AddBrowserController::buildAddEditBrowserTopView($page, true);
$page->data['AddEditBrowserTopView']['errMsgs']['global'] = '<h2 class="error_message" id="add_edit_browser_form_error_message">Kan browser niet toevoegen, probeer het opnieuw.</h2>';
}
} else {
AddBrowserController::buildAddEditBrowserTopView($page, true);
$page->data['AddEditBrowserTopView']['errMsgs'] = array_merge($page->data['AddEditBrowserTopView']['errMsgs'], $errMsgs);
}
$page->showWithMenu();
} else {
header('Location: managebrowser', true, 303);
}
}
示例2: post
public static function post()
{
$page = new Page();
$page->data['title'] = 'Browser bewerken';
if (isset($_POST['save'])) {
$errMsgs = AddEditBrowserTopViewValidator::validate($_POST);
if (empty($errMsgs)) {
try {
//Create new browser of entered data and try to update
$newBrowser = new Browser($_SESSION['Stippers']['EditBrowser']['browser']->browserId, Random::getGuid(), $_POST['browser_name'], isset($_POST['can_add_renew_users']), isset($_POST['can_check_in']), isset($_POST['is_cash_register']));
BrowserDB::updateBrowser($_SESSION['Stippers']['EditBrowser']['browser'], $newBrowser);
$page->data['SuccessMessageNoDescriptionWithLinkView']['successTitle'] = 'Browser successvol gewijzigd';
$page->data['SuccessMessageNoDescriptionWithLinkView']['redirectUrl'] = 'managebrowser';
$page->addView('success/SuccessMessageNoDescriptionWithLinkView');
} catch (BrowserDBException $ex) {
if ($ex->getCode() == BrowserDBException::BROWSEROUTOFDATE) {
$page->data['ErrorMessageWithDescriptionWithLinkView']['errorTitle'] = 'Gebruiker niet hernieuwd';
$page->data['ErrorMessageWithDescriptionWithLinkView']['errorDescription'] = 'Iemand anders heeft de gebruiker in tussentijd al gewijzigd.';
$page->data['ErrorMessageWithDescriptionWithLinkView']['tryAgainUrl'] = $_SERVER['REQUEST_URI'];
$page->addView('error/ErrorMessageWithDescriptionWithLinkView');
} else {
EditBrowserController::buildAddEditBrowserTopView($page, true);
if ($ex->getCode() == BrowserDBException::BROWSERNAMEEXISTS) {
$page->data['AddEditBrowserTopView']['errMsgs']['global'] = '<h2 class="error_message" id="add_edit_browser_form_error_message">Deze naam is reeds in gebruik.</h2>';
} else {
$page->data['AddEditBrowserTopView']['errMsgs']['global'] = '<h2 class="error_message" id="add_edit_browser_form_error_message">Kan browser niet wijzigen, probeer het opnieuw.</h2>';
}
}
} catch (Exception $ex) {
EditBrowserController::buildAddEditBrowserTopView($page, true);
$page->data['AddEditBrowserTopView']['errMsgs']['global'] = '<h2 class="error_message" id="add_edit_browser_form_error_message">Kan browser niet wijzigen, probeer het opnieuw.</h2>';
}
} else {
EditBrowserController::buildAddEditBrowserTopView($page, true);
$page->data['AddEditBrowserTopView']['errMsgs'] = array_merge($page->data['AddEditBrowserTopView']['errMsgs'], $errMsgs);
}
$page->showWithMenu();
} elseif (isset($_POST['delete'])) {
try {
BrowserDB::removeBrowser($_SESSION['Stippers']['EditBrowser']['browser']);
$page->data['SuccessMessageNoDescriptionWithLinkView']['successTitle'] = 'Browser successvol gewijzigd';
$page->data['SuccessMessageNoDescriptionWithLinkView']['redirectUrl'] = 'managebrowser';
$page->addView('success/SuccessMessageNoDescriptionWithLinkView');
} catch (BrowserDBException $ex) {
if ($ex->getCode() == BrowserDBException::BROWSEROUTOFDATE) {
$page->data['ErrorMessageWithDescriptionWithLinkView']['errorTitle'] = 'Gebruiker niet hernieuwd';
$page->data['ErrorMessageWithDescriptionWithLinkView']['errorDescription'] = 'Iemand anders heeft de gebruiker in tussentijd al gewijzigd.';
$page->data['ErrorMessageWithDescriptionWithLinkView']['tryAgainUrl'] = $_SERVER['REQUEST_URI'];
$page->addView('error/ErrorMessageWithDescriptionWithLinkView');
} else {
EditBrowserController::buildAddEditBrowserTopView($page, true);
$page->data['AddEditBrowserTopView']['errMsgs']['global'] = '<h2 class="error_message" id="add_edit_browser_form_error_message">Kan browser niet wijzigen, probeer het opnieuw.</h2>';
}
} catch (Exception $ex) {
EditBrowserController::buildAddEditBrowserTopView($page, true);
$page->data['AddEditBrowserTopView']['errMsgs']['global'] = '<h2 class="error_message" id="add_edit_browser_form_error_message">Kan browser niet wijzigen, probeer het opnieuw.</h2>';
}
$page->showWithMenu();
} else {
header('Location: managebrowser', true, 303);
}
}
示例3: post
public static function post()
{
$page = new Page();
$page->data['title'] = 'Gebruiker toevoegen';
//Validate input
$formTopViewErrMsgs = UserDataFormTopViewValidator::validate($_POST);
$formPasswordViewErrMsgs = UserDataFormPasswordViewValidator::validate($_POST);
$formMiddleViewErrMsgs = UserDataFormMiddleViewValidator::validate($_POST);
//No error means we create a user and password salt
if (empty($formTopViewErrMsgs) && empty($formPasswordViewErrMsgs) && empty($formMiddleViewErrMsgs)) {
$passwordSalt = Random::getGuid();
$user = new User();
$user->email = $_POST['email'];
$user->firstName = ucwords($_POST['first_name']);
$user->lastName = ucwords($_POST['last_name']);
$user->passwordHash = hash_pbkdf2("sha256", $_POST['password'], $passwordSalt, SecurityConfig::N_PASSWORD_HASH_ITERATIONS);
$user->street = ucwords($_POST['street']);
$user->houseNumber = $_POST['house_number'];
$user->city = ucwords($_POST['city']);
$user->postalCode = $_POST['postal_code'];
$user->country = ucwords($_POST['country']);
$user->phone = $_POST['phone'];
$user->dateOfBirth = $_POST['date_of_birth'];
//Add the user
try {
$userId = UserDB::addUser($user, $passwordSalt, $_POST['card_number']);
$page->addView('addRenewUser/addUser/SuccessfullyAddedView');
//Send welcome mail
try {
$failedEmails = Email::sendEmails('WelcomeNewMember.html', 'JH DE Stip - Welkom', EmailConfig::FROM_ADDRESS, [$user], null);
//If failedEmails is not empty the mail was not sent
if (!empty($failedEmails)) {
$page->data['ErrorMessageNoDescriptionNoLinkView']['errorTitle'] = 'Kan welkomstmail niet verzenden.';
$page->addView('error/ErrorMessageNoDescriptionNoLinkView');
}
} catch (Exception $ex) {
$page->data['ErrorMessageNoDescriptionNoLinkView']['errorTitle'] = 'Kan welkomstmail niet verzenden.';
$page->addView('error/ErrorMessageNoDescriptionNoLinkView');
}
//Add money to user's card
try {
$addedUser = UserDB::getFullUserById($userId);
$executingBrowserName = BrowserDB::getBrowserById($_SESSION['Stippers']['browser']->browserId)->name;
$trans = new MoneyTransaction(null, $addedUser->userId, 0, AddOrRenewUserConfig::NEW_OR_RENEWED_USER_BONUS, 0, 0, true, null, $executingBrowserName, null);
MoneyTransactionDB::addTransaction($addedUser, $trans);
} catch (Exception $ex) {
if (isset($page->data['ErrorMessageNoDescriptionNoLinkView']['errorTitle'])) {
$page->data['ErrorMessageNoDescriptionNoLinkView']['errorTitle'] .= ' Kan het saldo van het account niet verhogen, probeer dit handmatig te doen.';
} else {
$page->data['ErrorMessageNoDescriptionNoLinkView']['errorTitle'] = 'Kan het saldo van het account niet verhogen, probeer dit handmatig te doen.';
}
$page->addView('error/ErrorMessageNoDescriptionNoLinkView');
}
} catch (UserDBException $ex) {
AddUserController::buildAddUserPage($page, true);
if ($ex->getCode() == UserDBException::EMAILALREADYEXISTS) {
$page->data['UserDataFormTopView']['errMsgs']['global'] = '<h2 class="error_message" id="user_data_form_error_message">Dit e-mailadres is al in gebruik.</h2>';
} elseif ($ex->getCode() == UserDBException::CARDALREADYUSED) {
$page->data['UserDataFormTopView']['errMsgs']['global'] = '<h2 class="error_message" id="user_data_form_error_message">Dit kaartnummer is al in gebruik.</h2>';
} else {
$page->data['UserDataFormTopView']['errMsgs']['global'] = '<h2 class="error_message" id="user_data_form_error_message">Kan gebruiker niet toevoegen, probeer het opnieuw.</h2>';
}
} catch (Exception $ex) {
AddUserController::buildAddUserPage($page, true);
$page->data['UserDataFormTopView']['errMsgs']['global'] = '<h2 class="error_message" id="user_data_form_error_message">Kan gebruiker niet toevoegen, probeer het opnieuw.</h2>';
}
} else {
AddUserController::buildAddUserPage($page, true);
$page->data['UserDataFormTopView']['errMsgs'] = array_merge($page->data['UserDataFormTopView']['errMsgs'], $formTopViewErrMsgs);
$page->data['UserDataFormPasswordView']['errMsgs'] = array_merge($page->data['UserDataFormPasswordView']['errMsgs'], $formPasswordViewErrMsgs);
$page->data['UserDataFormMiddleView']['errMsgs'] = array_merge($page->data['UserDataFormMiddleView']['errMsgs'], $formMiddleViewErrMsgs);
}
$page->showWithMenu();
}
示例4: User
/**
* This file is part of the Stippers project (available here: https://github.com/Stannieman/stippers/).
* The license and all terms en conditions that apply to Stippers also apply to this file.
*
* @author Stan Wijckmans
*
* Create admin page. This file can be used to create the admin account right after the data base is set up.
* This file should be removed once this is done.
*/
require_once 'app/config/SecurityConfig.php';
require_once 'app/helperClasses/database/DataBase.php';
require_once 'app/helperClasses/database/DataBaseException.php';
require_once 'app/models/user/User.php';
require_once 'app/helperClasses/random/Random.php';
// Generate password salt
$passwordSalt = Random::getGuid();
// Create new user
$user = new User();
$user->userId = 0;
$user->email = 'admin@stippers.be';
$user->firstName = 'admin';
$user->lastName = 'admin';
$user->street = 'Stippers street';
$user->houseNumber = '1';
$user->city = 'Stippers city';
$user->postalCode = '0000';
$user->country = 'Belgium';
$user->dateOfBirth = '23/03/1993';
$user->isAdmin = true;
$user->phone = '';
$user->passwordHash = hash_pbkdf2('sha256', 'Passw0rd', $passwordSalt, SecurityConfig::N_PASSWORD_HASH_ITERATIONS);