コード例 #1
0
 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
0
 /**
  * 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
0
 /**
  * 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
0
ファイル: EmailLib.php プロジェクト: ByMyHandsOnly/BMHO_Web
 /**
  * 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
0
ファイル: Model.php プロジェクト: nocif/cake
 /**
  * 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
0
 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
0
 /**
  * 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
0
 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
0
 /**
  * プレビュー用テンプレートを生成する
  *
  * @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
0
ファイル: Party.php プロジェクト: kameshwariv/testexample
 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
0
 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'] = '******' . 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
0
ファイル: basics.php プロジェクト: baserproject/basercms
/**
 * アップデートの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
0
ファイル: OAuthClient.php プロジェクト: baserproject/basercms
 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
0
 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
0
ファイル: AppModel.php プロジェクト: humbertcostas/MISP
 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;
 }
コード例 #16
0
 /**
  * Generate authorization hash.
  *
  * @return string Hash
  */
 public static function generateAuthKey()
 {
     return Security::hash(CakeText::uuid());
 }
コード例 #17
0
ファイル: User.php プロジェクト: ristorantino/users
 /**
  * Registers a new user
  *
  * Options:
  * - bool emailVerification : Default is true, generates the token for email verification
  * - bool removeExpiredRegistrations : Default is true, removes expired registrations to do cleanup when no cron is configured for that
  * - bool returnData : Default is true, if false the method returns true/false the data is always available through $this->User->data
  *
  * @param array $postData Post data from controller
  * @param mixed should be array now but can be boolean for emailVerification because of backward compatibility
  * @return mixed
  */
 public function register($postData = array(), $options = array())
 {
     $Event = new CakeEvent('Users.Model.User.beforeRegister', $this, array('data' => $postData, 'options' => $options));
     $this->getEventManager()->dispatch($Event);
     if ($Event->isStopped()) {
         return $Event->result;
     }
     if (is_bool($options)) {
         $options = array('emailVerification' => $options);
     }
     $defaults = array('emailVerification' => true, 'removeExpiredRegistrations' => true, 'returnData' => true);
     extract(array_merge($defaults, $options));
     $postData = $this->_beforeRegistration($postData, $emailVerification);
     if ($removeExpiredRegistrations) {
         $this->_removeExpiredRegistrations();
     }
     $this->set($postData);
     if ($this->validates()) {
         if (empty($postData[$this->alias]['password'])) {
             // Oauth registering
             $postData[$this->alias]['password'] = CakeText::uuid();
         }
         $postData[$this->alias]['password'] = $this->hash($postData[$this->alias]['password'], 'sha1', true);
         $this->create();
         $this->data = $this->save($postData, false);
         $this->data[$this->alias]['id'] = $this->id;
         $Event = new CakeEvent('Users.Model.User.afterRegister', $this, array('data' => $this->data, 'options' => $options));
         $this->getEventManager()->dispatch($Event);
         if ($Event->isStopped()) {
             return $Event->result;
         }
         if ($returnData) {
             return $this->data;
         }
         return true;
     }
     return false;
 }
コード例 #18
0
ファイル: FixtureTask.php プロジェクト: galabyca/nostalgames
 /**
  * Generate String representation of Records
  *
  * @param array $tableInfo Table schema array
  * @param int $recordCount The number of records to generate.
  * @return array Array of records to use in the fixture.
  */
 protected function _generateRecords($tableInfo, $recordCount = 1)
 {
     $records = array();
     for ($i = 0; $i < $recordCount; $i++) {
         $record = array();
         foreach ($tableInfo as $field => $fieldInfo) {
             if (empty($fieldInfo['type'])) {
                 continue;
             }
             $insert = '';
             switch ($fieldInfo['type']) {
                 case 'integer':
                 case 'float':
                     $insert = $i + 1;
                     break;
                 case 'string':
                 case 'binary':
                     $isPrimaryUuid = isset($fieldInfo['key']) && strtolower($fieldInfo['key']) === 'primary' && isset($fieldInfo['length']) && $fieldInfo['length'] == 36;
                     if ($isPrimaryUuid) {
                         $insert = CakeText::uuid();
                     } else {
                         $insert = "Lorem ipsum dolor sit amet";
                         if (!empty($fieldInfo['length'])) {
                             $insert = substr($insert, 0, (int) $fieldInfo['length'] - 2);
                         }
                     }
                     break;
                 case 'timestamp':
                     $insert = time();
                     break;
                 case 'datetime':
                     $insert = date('Y-m-d H:i:s');
                     break;
                 case 'date':
                     $insert = date('Y-m-d');
                     break;
                 case 'time':
                     $insert = date('H:i:s');
                     break;
                 case 'boolean':
                     $insert = 1;
                     break;
                 case 'text':
                     $insert = "Lorem ipsum dolor sit amet, aliquet feugiat.";
                     $insert .= " Convallis morbi fringilla gravida,";
                     $insert .= " phasellus feugiat dapibus velit nunc, pulvinar eget sollicitudin";
                     $insert .= " venenatis cum nullam, vivamus ut a sed, mollitia lectus. Nulla";
                     $insert .= " vestibulum massa neque ut et, id hendrerit sit,";
                     $insert .= " feugiat in taciti enim proin nibh, tempor dignissim, rhoncus";
                     $insert .= " duis vestibulum nunc mattis convallis.";
                     break;
             }
             $record[$field] = $insert;
         }
         $records[] = $record;
     }
     return $records;
 }
コード例 #19
0
ファイル: User.php プロジェクト: kameshwariv/testexample
 /**
  * public setResetToken
  *
  * @param email , user_id
  * @return
  *
  * @author CharlesKing
  */
 public function setResetToken($user_id, $email)
 {
     $token = CakeText::uuid();
     $data = ['token' => $token, 'email' => $email, 'user_id' => $user_id];
     $password_reset_data = $this->UserPasswordReset->find("first", array("conditions" => array("user_id" => $user_id)));
     if (!empty($password_reset_data)) {
         $data['id'] = $password_reset_data['UserPasswordReset']['id'];
     }
     if ($this->UserPasswordReset->save($data)) {
         return $token;
     } else {
         return false;
     }
 }