本文整理汇总了PHP中CakeText::uuid方法的典型用法代码示例。如果您正苦于以下问题:PHP CakeText::uuid方法的具体用法?PHP CakeText::uuid怎么用?PHP CakeText::uuid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CakeText
的用法示例。
在下文中一共展示了CakeText::uuid方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGenerate
public function testGenerate()
{
$data = ['url' => 'http://www.spiegel.de', 'start' => '2010-10-09 22:23:34', 'end' => '2010-10-09 23:23:34', 'summary' => 'xyz', 'description' => 'xyz hjdhfj dhfäöüp e', 'organizer' => 'CEO', 'class' => 'public', 'timestamp' => '2010-10-08 22:23:34', 'id' => CakeText::uuid(), 'location' => 'München'];
$this->Ical->add($data);
$this->Ical->add($data);
$res = $this->Ical->generate();
//pr($res);
}
示例2: testMultipleUuidGeneration
/**
* testMultipleUuidGeneration method
*
* @return void
*/
public function testMultipleUuidGeneration()
{
$check = array();
$count = mt_rand(10, 1000);
$pattern = "/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}\$/";
for ($i = 0; $i < $count; $i++) {
$result = CakeText::uuid();
$match = (bool) preg_match($pattern, $result);
$this->assertTrue($match);
$this->assertFalse(in_array($result, $check));
$check[] = $result;
}
}
示例3: testAddWithPreSpecifiedId
/**
* testAddWithPreSpecifiedId method
*
* @return void
*/
public function testAddWithPreSpecifiedId()
{
extract($this->settings);
$this->Tree = new $modelClass();
$this->Tree->order = null;
$this->Tree->initialize(2, 2);
$data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.1')));
$id = CakeText::uuid();
$this->Tree->create();
$result = $this->Tree->save(array($modelClass => array('id' => $id, 'name' => 'testAddMiddle', $parentField => $data[$modelClass]['id'])));
$expected = array_merge(array($modelClass => array('id' => $id, 'name' => 'testAddMiddle', $parentField => '2')), $result);
$this->assertSame($expected, $result);
$this->assertTrue($this->Tree->verify());
}
示例4: addEmbeddedBlobAttachment
/**
* Add an inline attachment as blob
*
* Options:
* - contentDisposition
*
* @param binary $content: blob data
* @param string $filename to attach it
* @param string $mimeType (leave it empty to get mimetype from $filename)
* @param string $contentId (optional)
* @param array $options Options
* @return mixed resource $EmailLib or string $contentId
*/
public function addEmbeddedBlobAttachment($content, $filename, $mimeType = null, $contentId = null, $options = [])
{
if ($mimeType === null) {
$ext = pathinfo($filename, PATHINFO_EXTENSION);
$mimeType = $this->_getMimeByExtension($ext);
}
$options['content'] = $content;
$options['mimetype'] = $mimeType;
$options['contentId'] = $contentId ? $contentId : str_replace('-', '', CakeText::uuid()) . '@' . $this->_domain;
$file = [$filename => $options];
$res = $this->addAttachments($file);
if ($contentId === null) {
return $options['contentId'];
}
return $res;
}
示例5: _saveMulti
/**
* Saves model hasAndBelongsToMany data to the database.
*
* @param array $joined Data to save
* @param int|string $id ID of record in this model
* @param DataSource $db Datasource instance.
* @return void
*/
protected function _saveMulti($joined, $id, $db)
{
foreach ($joined as $assoc => $data) {
if (!isset($this->hasAndBelongsToMany[$assoc])) {
continue;
}
$habtm = $this->hasAndBelongsToMany[$assoc];
list($join) = $this->joinModel($habtm['with']);
$Model = $this->{$join};
if (!empty($habtm['with'])) {
$withModel = is_array($habtm['with']) ? key($habtm['with']) : $habtm['with'];
list(, $withModel) = pluginSplit($withModel);
$dbMulti = $this->{$withModel}->getDataSource();
} else {
$dbMulti = $db;
}
$isUUID = !empty($Model->primaryKey) && $Model->_isUUIDField($Model->primaryKey);
$newData = $newValues = $newJoins = array();
$primaryAdded = false;
$fields = array($dbMulti->name($habtm['foreignKey']), $dbMulti->name($habtm['associationForeignKey']));
$idField = $db->name($Model->primaryKey);
if ($isUUID && !in_array($idField, $fields)) {
$fields[] = $idField;
$primaryAdded = true;
}
foreach ((array) $data as $row) {
if (is_string($row) && (strlen($row) === 36 || strlen($row) === 16) || is_numeric($row)) {
$newJoins[] = $row;
$values = array($id, $row);
if ($isUUID && $primaryAdded) {
$values[] = CakeText::uuid();
}
$newValues[$row] = $values;
unset($values);
} elseif (isset($row[$habtm['associationForeignKey']])) {
if (!empty($row[$Model->primaryKey])) {
$newJoins[] = $row[$habtm['associationForeignKey']];
}
$newData[] = $row;
} elseif (isset($row[$join]) && isset($row[$join][$habtm['associationForeignKey']])) {
if (!empty($row[$join][$Model->primaryKey])) {
$newJoins[] = $row[$join][$habtm['associationForeignKey']];
}
$newData[] = $row[$join];
}
}
$keepExisting = $habtm['unique'] === 'keepExisting';
if ($habtm['unique']) {
$conditions = array($join . '.' . $habtm['foreignKey'] => $id);
if (!empty($habtm['conditions'])) {
$conditions = array_merge($conditions, (array) $habtm['conditions']);
}
$associationForeignKey = $Model->alias . '.' . $habtm['associationForeignKey'];
$links = $Model->find('all', array('conditions' => $conditions, 'recursive' => empty($habtm['conditions']) ? -1 : 0, 'fields' => $associationForeignKey));
$oldLinks = Hash::extract($links, "{n}.{$associationForeignKey}");
if (!empty($oldLinks)) {
if ($keepExisting && !empty($newJoins)) {
$conditions[$associationForeignKey] = array_diff($oldLinks, $newJoins);
} else {
$conditions[$associationForeignKey] = $oldLinks;
}
$dbMulti->delete($Model, $conditions);
}
}
if (!empty($newData)) {
foreach ($newData as $data) {
$data[$habtm['foreignKey']] = $id;
if (empty($data[$Model->primaryKey])) {
$Model->create();
}
$Model->save($data, array('atomic' => false));
}
}
if (!empty($newValues)) {
if ($keepExisting && !empty($links)) {
foreach ($links as $link) {
$oldJoin = $link[$join][$habtm['associationForeignKey']];
if (!in_array($oldJoin, $newJoins)) {
$conditions[$associationForeignKey] = $oldJoin;
$db->delete($Model, $conditions);
} else {
unset($newValues[$oldJoin]);
}
}
$newValues = array_values($newValues);
}
if (!empty($newValues)) {
$dbMulti->insertMulti($Model, $fields, $newValues);
}
}
}
}
示例6: populateInfo
protected function populateInfo($userid)
{
// Fetch user info
$userinfo = $this->User->findById($userid);
if (empty($userinfo)) {
throw new InternalErrorException('Unknown UserID.');
}
// Save specific info from the current session (if exists)
$emulating = $this->Session->read('User.emulating');
$emulating_from = -1;
if ($emulating) {
$emulating_from = $this->Session->read('User.emulating_from');
}
// Destroy the current session (if any)
$this->Session->destroy();
// Verify the account is enabled/not expired
if ($userinfo['User']['active'] != 1) {
$this->redirect('/?account_disabled');
}
if ($userinfo['User']['expires'] != 0 && $userinfo['User']['expires'] <= time()) {
$this->redirect('/?account_expired');
}
// Generate logout token
$userinfo['User']['logout_token'] = Security::hash(CakeText::uuid());
// Generate refresh interval (5 minutes)
$userinfo['User']['refresh_info'] = time() + self::REFRESH_INTERVAL;
// Add the emulating information
$userinfo['User']['emulating'] = $emulating;
$userinfo['User']['emulating_from'] = $emulating_from;
// Fetch the team/group info
$teaminfo = $this->Team->findById($userinfo['User']['team_id']);
// Clean the password (remove it from the array)
unset($userinfo['User']['password']);
// Set the new information
$this->Session->write($userinfo);
$this->Session->write($teaminfo);
// Update our arrays
$this->userinfo = $userinfo['User'];
$this->teaminfo = $teaminfo['Team'];
$this->groupinfo = $teaminfo['Group'];
}
示例7: randomBytes
/**
* Get random bytes from a secure source.
*
* This method will fall back to an insecure source and trigger a warning,
* if it cannot find a secure source of random data.
*
* @param int $length The number of bytes you want.
* @return string Random bytes in binary.
*/
public static function randomBytes($length)
{
if (function_exists('random_bytes')) {
return random_bytes($length);
}
if (function_exists('openssl_random_pseudo_bytes')) {
return openssl_random_pseudo_bytes($length);
}
trigger_error('You do not have a safe source of random data available. ' . 'Install either the openssl extension, or paragonie/random_compat. ' . 'Falling back to an insecure random source.', E_USER_WARNING);
$bytes = '';
$byteLength = 0;
while ($byteLength < $length) {
$bytes .= static::hash(CakeText::uuid() . uniqid(mt_rand(), true), 'sha512', true);
$byteLength = strlen($bytes);
}
return substr($bytes, 0, $length);
}
示例8: view
public function view()
{
if (!empty($this->party->Party->finalized_date)) {
$this->party->Rewards->{'Half-Price Items'} = $this->party->Party->earned_coupons;
$this->party->Rewards->{'Free Product Credits'} = $this->party->Party->earned_free_product_credit;
if ($this->party->Party->earned_coupons > 0) {
$this->party->Rewards->{'Free Product'} = $this->party->Party->earned_coupons * 2 + 8 . '%';
} else {
$this->party->Rewards->{'Free Product'} = '0%';
}
}
$hostMarketCurrency = YouniqueAPI::call("market/getMarketData/{$this->party->Party->hostess_market_id}");
$this->set("hostMarketCurrency", $hostMarketCurrency->currencySymbol);
//this is set here for closed parties
//is video chat created if not show create dialogue;
// $party_videos = YouniqueAPI::call("/party/videos/{$this->party->Party->id}");
// $this->set('party_videos', $party_videos);
$this->set('token', CakeText::uuid());
$domain_name = $_SERVER['HTTP_HOST'];
$this->set('domain_name', $domain_name);
$presenter_data = YouniqueAPI::call("presenter/isPresenter/" . $this->userId);
$this->set("is_presenter", $presenter_data->isPresenter);
$chat_access = YouniqueAPI::call("presenter/chatAccess/" . $this->party->Presenter->id);
$has_chat_access = !empty($chat_access) ? 1 : 0;
//Temporary Code to show hotjar poll only to Presenters with early hangout access.
if ($has_chat_access == 1 && (!empty($presenter_data->isPresenter) && $presenter_data->isPresenter == $this->webSiteInfo->sequence_id) && empty($this->request->query["vh"])) {
if (!empty($this->request->query["success"])) {
$partyParams = array("success" => "1", "vh" => "1");
} else {
$partyParams = array("vh" => "1");
}
$this->redirect(array("controller" => "party", "action" => "view", "partyid" => $this->partyId, "?" => $partyParams));
}
//End temporary code for hotjar poll
$this->set('has_chat_access', $has_chat_access);
$this->set("party", $this->party);
//this is set here for closed parties
if ($this->party->Party->party_status_id == 0) {
if ($this->action == 'view' && (strstr($_SERVER['HTTP_USER_AGENT'], 'facebookexternalhit') || strstr($_SERVER['HTTP_USER_AGENT'], 'developers.google.com'))) {
//Allow access to open graph meta tags.
} else {
if (empty($this->userId)) {
$this->Session->setFlash(__("Log in and get your party started."), "default", array(), "heading");
$this->Session->setFlash(__("In order to start earning your party rewards, you need to log in or create an account."), "default", array(), "copy");
if (!empty($this->request->params['siteurl'])) {
$this->redirect(array("controller" => "account", "action" => "signin", '?' => array('auth_redirect' => $this->generateUrl(array("controller" => "party", "siteurl" => $this->request->params['siteurl'], "partyid" => $this->partyId, "action" => "view"), true))));
}
}
}
$presenter_id = $this->party->Presenter->id;
$chat_access = $this->party->Party->getDynamicData($presenter_id, 'chat_access');
$presenter_user_id = YouniqueAPI::call("/presenter/getPresenterFromId/{$presenter_id}");
if ($this->userId != $this->party->Party->hostess_id && $this->userId != $presenter_user_id) {
$this->redirect(array("controller" => "account", "action" => "newparty"));
}
$partyTheme = YouniqueAPI::call("/party/theme");
$this->set("partyTheme", $partyTheme);
if ($this->userId == $this->party->Party->hostess_id) {
$this->render('activation');
} else {
$this->render('pending');
}
} else {
if (array_key_exists('success', $this->request->query)) {
$this->set('showCongrats', true);
}
$this->set("partyid", $this->party->Party->id);
//this is set here for closed parties
$this->set("autoplay", isset($this->request->query['autoplay']));
}
$this->set("confirmed", isset($this->request->query['confirmed']));
}
示例9: _createPreviewTemplate
/**
* プレビュー用テンプレートを生成する
*
* @param mixed $id 固定ページID
* @return string uuid
*/
protected function _createPreviewTemplate($data)
{
// 一時ファイルとしてビューを保存
// タグ中にPHPタグが入る為、ファイルに保存する必要がある
$contents = $this->Page->addBaserPageTag(null, $data['Page']['contents_tmp'], $data['Content']['title'], $data['Content']['description'], $data['Page']['code']);
$uuid = CakeText::uuid();
$path = TMP . 'pages_preview_' . $uuid . $this->ext;
$file = new File($path);
$file->open('w');
$file->append($contents);
$file->close();
unset($file);
@chmod($path, 0666);
return $uuid;
}
示例10: createVideoChat
public function createVideoChat($data)
{
$start_date = new DateTime($data['start']['dateTime']);
$end_date = new DateTime($data['end']['dateTime']);
$this->PartyVideo->create();
$this->PartyVideo->set('party_id', $data['party_id']);
$this->PartyVideo->set('provider', 'Google');
$this->PartyVideo->set('uid', CakeText::uuid());
$this->PartyVideo->set('iCal', CakeText::uuid());
$this->PartyVideo->set('htmlLink', '');
$this->PartyVideo->set('summary', $data['summary']);
$this->PartyVideo->set('description', 'Demo Party');
$this->PartyVideo->set('start', $data['start']['dateTime']);
$this->PartyVideo->set('end', $data['end']['dateTime']);
$this->PartyVideo->set('created', date('Y-m-d'));
$this->PartyVideo->set('updated', date('Y-m-d'));
$this->PartyVideo->save();
}
示例11: __loginNewRegistration
private function __loginNewRegistration($incomingProfile, $accessToken)
{
// no-one logged in, must be a registration.
unset($incomingProfile['id']);
$this->User->validate['email']['isValid']['required'] = false;
$this->User->validate['email']['isValid']['allowEmpty'] = true;
$this->User->validate['email']['isUnique']['required'] = false;
$this->User->validate['email']['isUnique']['allowEmpty'] = true;
if (empty($incomingProfile['username'])) {
if (!empty($incomingProfile['email'])) {
$incomingProfile['username'] = $incomingProfile['email'];
} else {
if (!empty($incomingProfile['first_name']) || !empty($incomingProfile['last_name'])) {
$nom = !empty($incomingProfile['first_name']) ? $incomingProfile['first_name'] : "";
$ape = !empty($incomingProfile['last_name']) ? $incomingProfile['last_name'] : "";
$username = Inflector::slug($nom . $ape);
$incomingProfile['username'] = $username . "_" . substr(CakeText::uuid(), rand(0, 36), 4);
} else {
$incomingProfile['username'] = 'UsuarioOauth_' . substr(CakeText::uuid(), rand(0, 36), 4);
}
}
}
$user = $this->User->register(array('User' => $incomingProfile), array('emailVerification' => false));
if (!$user) {
throw new CakeException(__d('users', 'Error registering users'));
}
// create social profile linked to new user
$incomingProfile['user_id'] = $user['User']['id'];
$incomingProfile['last_login'] = date('Y-m-d h:i:s');
$incomingProfile['access_token'] = serialize($accessToken);
$this->User->SocialProfile->save($incomingProfile);
// log in
$this->__doAuthLogin($user);
}
示例12: sendUpdateMail
/**
* アップデートのURLを記載したメールを送信する
*/
function sendUpdateMail()
{
$bcSite = Configure::read('BcSite');
$bcSite['update_id'] = CakeText::uuid();
$SiteConfig = ClassRegistry::init('SiteConfig');
$SiteConfig->saveKeyValue(array('SiteConfig' => $bcSite));
ClassRegistry::removeObject('SiteConfig');
$BcEmail = new BcEmailComponent();
if (!empty($bcSite['mail_encode'])) {
$encode = $bcSite['mail_encode'];
} else {
$encode = 'ISO-2022-JP';
}
$BcEmail->charset = $encode;
$BcEmail->sendAs = 'text';
$BcEmail->lineLength = 105;
if (!empty($bcSite['smtp_host'])) {
$BcEmail->delivery = 'smtp';
$BcEmail->smtpOptions = array('host' => $bcSite['smtp_host'], 'port' => 25, 'timeout' => 30, 'username' => $bcSite['smtp_user'] ? $bcSite['smtp_user'] : null, 'password' => $bcSite['smtp_password'] ? $bcSite['smtp_password'] : null);
} else {
$BcEmail->delivery = "mail";
}
$BcEmail->to = $bcSite['email'];
$BcEmail->subject = 'baserCMSアップデート';
$BcEmail->from = $bcSite['name'] . ' <' . $bcSite['email'] . '>';
$message = array();
$message[] = '下記のURLよりbaserCMSのアップデートを完了してください。';
$message[] = topLevelUrl(false) . baseUrl() . 'updaters/index/' . $bcSite['update_id'];
$BcEmail->send($message);
}
示例13: doPostMultipartFormData
private function doPostMultipartFormData($url, $authorization, $paths, $data)
{
App::uses('String', 'Utility');
$boundary = CakeText::uuid();
$body = "--{$boundary}\r\n";
foreach ($data as $key => $value) {
$body .= "Content-Disposition: form-data; name=\"{$key}\"\r\n";
$body .= "\r\n";
$body .= "{$value}\r\n";
$body .= "--{$boundary}\r\n";
}
foreach ($paths as $key => $path) {
$body .= "Content-Disposition: form-data; name=\"{$key}\"; filename=\"{$path}\"\r\n";
$body .= "\r\n";
$body .= file_get_contents($path) . "\r\n";
$body .= "--{$boundary}--\r\n";
}
$socket = new HttpSocket();
$result = $socket->request(array('method' => 'POST', 'uri' => $url, 'header' => array('Authorization' => $authorization, 'Content-Type' => "multipart/form-data; boundary={$boundary}"), 'body' => $body));
$this->fullResponse = $result;
return $result;
}
示例14: populateInfo
protected function populateInfo($userid)
{
// Fetch user info
if (is_array($userid)) {
$userinfo = $userid;
} else {
$userinfo = $this->User->findById($userid);
}
if (empty($userinfo)) {
throw new InternalErrorException('Unknown UserID.');
}
// Destroy the current session (if any)
$this->Session->destroy();
// Verify the account is enabled/not expired
if ($userinfo['User']['active'] != 1) {
$this->redirect('/?account_disabled');
}
// Generate logout token
$userinfo['User']['logout_token'] = Security::hash(CakeText::uuid());
// Clean the password (remove it from the array)
unset($userinfo['User']['password']);
// Set the new information
$this->Session->write($userinfo);
// Update our arrays
$this->userinfo = $userinfo['User'];
$this->groupinfo = $userinfo['Group'];
}
示例15: generateUuid
public function generateUuid()
{
$version = Configure::version();
$version = explode('.', $version);
if (intval($version[0]) <= 2 && intval($version[1]) < 7) {
$uuid = String::uuid();
} else {
$uuid = CakeText::uuid();
}
return $uuid;
}