public function actionRegister() { $formModel = new Registration(); //$this->performAjaxValidation($formModel); if (isset($_POST['Registration'])) { $formModel->email = $_POST['Registration']['email']; $formModel->username = $_POST['Registration']['username']; $formModel->password = $_POST['Registration']['password']; $formModel->password_repeat = $_POST['Registration']['password_repeat']; $formModel->verification_code = $_POST['Registration']['verification_code']; if ($formModel->validate()) { $model = new User(); if ($model->insert(CassandraUtil::uuid1(), array('email' => $_POST['Registration']['email'], 'username' => $_POST['Registration']['username'], 'password' => User::encryptPassword($_POST['Registration']['password']), 'active' => false, 'blocked' => false)) === true) { echo 'Model email ' . $formModel->email . ' && username ' . $formModel->username; if (!User::sendRegisterVerification($formModel->email, $formModel->username)) { echo 'failed'; } else { echo 'done'; } die; //$this->redirect(array('user/profile')); } } } $this->render('register', array('model' => $formModel)); }
function __construct($uuid = null) { if (!isset($uuid)) { Loader::load("vendor", "phpcassa/columnfamily.php"); $this->uuid = CassandraUtil::uuid1(); //Loader::load("vendor","uuid/uuid"); // $this->uuid = UUID::TimeUUIDType(); // $this->uuid_binary = UUID::generate(UUID::UUID_TIME,UUID::FMT_BINARY); $this->data = new stdclass(); } else { $this->uuid = $uuid; } }
public function setUp() { $this->client = new Connection('Keyspace1'); $this->cf_long = new ColumnFamily($this->client, 'StdLong'); $this->cf_int = new ColumnFamily($this->client, 'StdInteger'); $this->cf_time = new ColumnFamily($this->client, 'StdTimeUUID'); $this->cf_lex = new ColumnFamily($this->client, 'StdLexicalUUID'); $this->cf_ascii = new ColumnFamily($this->client, 'StdAscii'); $this->cf_utf8 = new ColumnFamily($this->client, 'StdUTF8'); $this->cf_suplong = new ColumnFamily($this->client, 'SuperLong'); $this->cf_supint = new ColumnFamily($this->client, 'SuperInt'); $this->cf_suptime = new ColumnFamily($this->client, 'SuperTime'); $this->cf_suplex = new ColumnFamily($this->client, 'SuperLex'); $this->cf_supascii = new ColumnFamily($this->client, 'SuperAscii'); $this->cf_suputf8 = new ColumnFamily($this->client, 'SuperUTF8'); $this->cf_suplong_sublong = new ColumnFamily($this->client, 'SuperLongSubLong'); $this->cf_suplong_subint = new ColumnFamily($this->client, 'SuperLongSubInt'); $this->cf_suplong_subtime = new ColumnFamily($this->client, 'SuperLongSubTime'); $this->cf_suplong_sublex = new ColumnFamily($this->client, 'SuperLongSubLex'); $this->cf_suplong_subascii = new ColumnFamily($this->client, 'SuperLongSubAscii'); $this->cf_suplong_subutf8 = new ColumnFamily($this->client, 'SuperLongSubUTF8'); $this->cf_valid_long = new ColumnFamily($this->client, 'ValidatorLong'); $this->cf_valid_int = new ColumnFamily($this->client, 'ValidatorInt'); $this->cf_valid_time = new ColumnFamily($this->client, 'ValidatorTime'); $this->cf_valid_lex = new ColumnFamily($this->client, 'ValidatorLex'); $this->cf_valid_ascii = new ColumnFamily($this->client, 'ValidatorAscii'); $this->cf_valid_utf8 = new ColumnFamily($this->client, 'ValidatorUTF8'); $this->cf_valid_bytes = new ColumnFamily($this->client, 'ValidatorBytes'); $this->cf_def_valid = new ColumnFamily($this->client, 'DefaultValidator'); $this->cfs = array($this->cf_long, $this->cf_int, $this->cf_ascii, $this->cf_time, $this->cf_lex, $this->cf_utf8, $this->cf_suplong, $this->cf_supint, $this->cf_suptime, $this->cf_suplex, $this->cf_supascii, $this->cf_suputf8, $this->cf_suplong_sublong, $this->cf_suplong_subint, $this->cf_suplong_subtime, $this->cf_suplong_sublex, $this->cf_suplong_subascii, $this->cf_suplong_subutf8, $this->cf_valid_long, $this->cf_valid_int, $this->cf_valid_time, $this->cf_valid_lex, $this->cf_valid_ascii, $this->cf_valid_utf8, $this->cf_valid_bytes, $this->cf_def_valid); $this->TIME1 = CassandraUtil::uuid1(); $this->TIME2 = CassandraUtil::uuid1(); $this->TIME3 = CassandraUtil::uuid1(); $this->LEX1 = UUID::import('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')->bytes; $this->LEX2 = UUID::import('bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb')->bytes; $this->LEX3 = UUID::import('cccccccccccccccccccccccccccccccc')->bytes; }
/** * Processes the uploaded image. * @param CUploadedFile $uploadedImg The uploaded image * @param string $title The title (or caption) of this image (optional) * @param string $description The detailed description of this image (optional) * @param string $albumName The name of the album to put the image in (optional) * @return string The ID of new uploaded image | false */ private function saveImg($uploadedImg, $title = '', $description = '', $albumName = '') { // Key $userId = CassandraUtil::import(Yii::app()->user->getId())->__toString(); $key = $userId . '_' . CassandraUtil::uuid1(); // Path $path = realpath(Yii::app()->params['storagePath']) . DIRECTORY_SEPARATOR . 'images' . DIRECTORY_SEPARATOR . $userId; if (!is_dir($path)) { mkdir($path, 0775); } if (!empty($albumName)) { $path .= DIRECTORY_SEPARATOR . $albumName; } if (!is_dir($path)) { mkdir($path, 0775); } // Save the image information before processing the image $data = array('storage_path' => $uploadedImg->getTempName(), 'mime_type' => $uploadedImg->getType(), 'extension' => $uploadedImg->getExtensionName(), 'user_id' => Yii::app()->user->getId()); if (!empty($title)) { $data['title'] = $title; } if (!empty($description)) { $data['description'] = $description; } if ($this->insert($key, $data) === false) { $uploadedImg->clean(); return false; } // Render this image into different versions $photoTypes = Setting::model()->photo_types; // Get list of image types in JSON format. Decode it. $photoTypes = json_decode($photoTypes['value'], true); $img = Yii::app()->imagemod->load($data['storage_path']); $convertedImgs = array(); foreach ($photoTypes as $type => $config) { $img->image_convert = 'jpg'; $img->image_resize = true; $img->image_ratio = true; $img->image_x = $config['width']; $img->image_y = $config['height']; if (isset($config['suffix'])) { $img->file_safe_name = $key . $config['suffix'] . '.jpg'; } else { $img->file_safe_name = $key . '.jpg'; } $img->process($path); if (!$img->processed) { // Delete the original image $uploadedImg->clean(); // Delete the record in db $this->delete($key); // Log the error Yii::log('Cannot resize the image ' . $data['storage_path'] . ' to ' . $path . '/' . $img->file_safe_name, 'error', 'application.modules.storage.Storage'); // Delete all converted images foreach ($convertedImgs as $imgType => $imgPath) { unlink($imgPath); } // Return false return false; } else { // Remember the path of converted image $convertedImgs[$type] = $img->file_dst_path; } // Update the database $data = array('storage_path' => $convertedImgs['original'], 'mime_type' => 'image/jpeg', 'extension' => 'jpg'); unset($convertedImgs['original']); $data = array_merge($data, $convertedImgs); if ($this->insert($key, $data) === false) { // Delete the original image $uploadedImg->clean(); // Delete the record in db $this->delete($key); // Log the error Yii::log('Cannot resize the image ' . $data['storage_path'] . ' to ' . $path . '/' . $img->file_safe_name, 'error', 'application.modules.storage.Storage'); // Delete all converted images unlink($data['storage_path']); foreach ($convertedImgs as $imgType => $imgPath) { unlink($imgPath); } // Return false return false; } } // Delete the temporary image $uploadedImg->clean(); return $key; }
public function test_uuid1_generation() { $micros = 1293769171436849.0; $uuid = CassandraUtil::import(CassandraUtil::uuid1(null, $micros)); $t = (int) ($uuid->time * 1000000); self::assertWithinMargin($micros, $t, 100); }