Esempio n. 1
1
 public function createParent()
 {
     $input = Input::all();
     if (Input::hasFile('profilepic')) {
         $input['profilepic'] = $this->filestore(Input::file('profilepic'));
     }
     $input['dob'] = date('Y-m-d H:i:s', strtotime(Input::get('dob')));
     $input['collegeid'] = Session::get('user')->collegeid;
     $input['collegename'] = Admin::where('collegeid', '=', Session::get('user')->collegeid)->first()->collegename;
     //$input['collegeid']="dummy";
     //$input['collegename']="dummy";
     $user = new User();
     $user->email = $input['email'];
     $user->password = Hash::make($input['password']);
     $user->collegeid = $input['collegeid'];
     $user->flag = 3;
     $user->save();
     $input['loginid'] = $user->id;
     $removed = array('_token', 'password', 'cpassword');
     foreach ($removed as $k) {
         unset($input[$k]);
     }
     Parent::saveFormData($input);
     return $input;
 }
Esempio n. 2
0
 /**
  * Add a label
  *
  * @return void
  * @author Justin Palmer
  **/
 public static function setLabel($key, $value)
 {
     if (!self::$Labels instanceof Hash) {
         self::$Labels = new Hash();
     }
     self::$Labels->set($key, $value);
 }
Esempio n. 3
0
 public function decodeHash()
 {
     $h = new Hash();
     $this->nextToken();
     $this->skipBlanks();
     if ($this->c === 125) {
         $this->nextToken();
         return $h;
     }
     while ($this->c !== 125) {
         $key = $this->decodeString();
         $this->skipBlanks();
         if ($this->c !== 58) {
             throw new HException("Expected ':'.");
         }
         $this->nextToken();
         $this->skipBlanks();
         $o = $this->localDecode();
         $h->set($key, $o);
         $this->skipBlanks();
         if ($this->c === 44) {
             $this->nextToken();
             $this->skipBlanks();
         } else {
             if ($this->c !== 125) {
                 throw new HException("Expected ',' or '}'. " . $this->getPositionRepresentation());
             }
         }
         unset($o, $key);
     }
     $this->nextToken();
     return $h;
 }
Esempio n. 4
0
 /**
  * Hashes a password.
  * 
  * @param String $password
  * @return Array
  * [
  *   password => <string>
  *   salt => <string>
  * ]
  */
 public function generatePassword($password)
 {
     $hashGenerator = new Hash();
     $salt = $hashGenerator->generateSalt(32);
     $hashedPassword = $this->generatePasswordWithSalt($password, $salt);
     return ['password' => $hashedPassword, 'salt' => $salt];
 }
Esempio n. 5
0
 public function testFilter()
 {
     $filter = new Hash();
     $this->assertEquals('0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33', $filter->apply('foo'));
     $filter = new Hash('sha256');
     $this->assertEquals('2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae', $filter->apply('foo'));
 }
Esempio n. 6
0
 function getAuthorizationHeader($verb, $url)
 {
     // UrlPath = <HTTP-Request-URI, from the port to the query string>
     $str = join("\n", array($verb, $date, $url));
     $h = new Hash('sha1');
     $sig = base64($h->hmac(str, $privkey));
     $header = 'BNET ' . $pubkey . ':' . $sig;
 }
Esempio n. 7
0
 /**
  * @param $string
  *
  * @return Hash
  */
 public function hash(string $string) : Hash
 {
     $hash = new Hash();
     $hash->setAlgorithm($this->getAlgorithm());
     $value = hash_hmac($this->getAlgorithm(), $string, $this->getSecret(), true);
     $hash->setValue($value);
     return $hash;
 }
 static function hashOfAssociativeArray($arr)
 {
     $h = new Hash();
     reset($arr);
     while (list($k, $v) = each($arr)) {
         $h->set($k, $v);
     }
     return $h;
 }
Esempio n. 9
0
 public function hasherize($key)
 {
     $value = $this->offsetGet($key);
     if (is_array($value)) {
         $hash = new Hash();
         return $hash->merge($value);
     }
     return $value;
 }
 static function fromProperties($prop)
 {
     $ht = new Hash();
     $key = "";
     $value = "";
     foreach ($prop as $key => $value) {
         $ht->set($key, $value);
     }
     return $ht;
 }
Esempio n. 11
0
 static function computeInverse($dict)
 {
     $keys = $dict->keys();
     $outDict = new Hash();
     while ($keys->hasNext()) {
         $key = $keys->next();
         $outDict->set($dict->get($key), $key);
         unset($key);
     }
     return $outDict;
 }
Esempio n. 12
0
 private function CreateChildren(array $array)
 {
     foreach ($array as $key => $value) {
         if (is_array($value)) {
             $tmp = new Hash();
             $tmp->Load($value);
             $this->offsetSet($key, $tmp);
         } else {
             $this->offsetSet($key, $value);
         }
     }
     return true;
 }
Esempio n. 13
0
 /**
  * 	Send email $to with using the $template file in the
  * 	/app/view/email/ directory otherwise you changed {@link $viewDir}
  * 	@param $to
  * 	@param string			$template	Filename of template to use
  * 	@param string			$subject		Optional alternate subject that should be used
  * 	@param array(string)	$data		optional additional associated array data to render in the view
  * 	@return boolean	true if mail was successfully send, otherwise false
  */
 public function send($to, $template, $subject = null, $data = array())
 {
     // use user logged in email for reply adress
     if ($this->controller->UserLogin->loggedin()) {
         $this->headers->set('Reply-To', $this->controller->UserLogin->User->get('email'));
         $this->headers->set('From', $this->controller->UserLogin->User->get('email'));
     }
     // render content
     $view = Library::create('ephFrame.lib.view.View', array($this->viewDir, $template, array_merge($this->controller->data->toArray(), $data)));
     $view->theme = $this->controller->theme;
     // send mail and return result
     return @mail($to, $subject == null ? $this->subject : $subject, $view->render(), $this->headers->implodef(RTLF, '%s: %s'));
 }
Esempio n. 14
0
 /**
  * Add a rule to a column
  *
  * @return void
  * @author Justin Palmer
  **/
 public function rule($column, Rule $rule)
 {
     //Make sure the property exists.
     $this->model->hasProperty($column);
     if ($rule instanceof RequiredRule) {
         $this->required[] = $column;
     }
     //Get the rules for this property.
     $rules = $this->rules->get($column);
     if ($rules === null) {
         $rules = array();
     }
     $rules[] = $rule;
     $this->rules->set($column, $rules);
 }
 /**
  *  Javascript strings Localization wrapper for Drupal
  * @param $locale
  */
 public function l10n($locale)
 {
     $strings = DruniqueAPIUtil::call('page_blocks.json', ['tag' => 'javascript'], $locale);
     $strings = Hash::combine($strings, '{s}.title', '{s}.content');
     $this->set(['result' => $strings, '_serialize' => 'result']);
     $this->response->cache('-1 minute', '+1 days');
 }
Esempio n. 16
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $faker = Faker::create();
     for ($i = 0; $i < 40; $i++) {
         \DB::table('usuarios')->insert(array('snombre' => $faker->firstname, 'sapellido' => $faker->lastname, 'scontrasena' => \Hash::make('12345'), 'scorreo' => $faker->unique()->email, 'badministra' => 0));
     }
 }
Esempio n. 17
0
 public function login($username = null, $password = null, $remember = false)
 {
     if (!$username && !$password && $this->exists()) {
         Session::put($this->_sessionName, $this->data()->id);
     } else {
         $user = $this->find($username);
         if ($user) {
             if ($this->data()->password === Hash::make($password, $this->data()->salt)) {
                 Session::put($this->_sessionName, $this->data()->id);
                 if ($remember) {
                     $hash = Hash::unique();
                     $hashCheck = $this->_db->get('users_session', array('user_id', '=', $this->data()->id));
                     if (!$hashCheck->count()) {
                         $this->_db->insert('users_session', array('user_id' => $this->data()->id, 'hash' => $hash));
                     } else {
                         $hash = $hashCheck->first()->hash;
                     }
                     Cookie::put($this->_cookieName, $hash, Config::get('remember.cookie_expiry'));
                 }
                 return true;
             }
         }
     }
     return false;
 }
Esempio n. 18
0
 /**
  * Create a new event instance.
  *
  * @return void
  */
 public function __construct($EcNa, $typ, $eml, $pass, $nomresp, $fix, $port, $adres, $ville, $pays)
 {
     $this->ecoleNom = $EcNa;
     $this->type = $typ;
     $this->email = $eml;
     $this->password = $pass;
     $this->nomResponsable = $nomresp;
     $this->fix = $fix;
     $this->portab = $port;
     $this->adresse = $adres;
     $this->ville = $ville;
     $this->pays = $pays;
     $user = new User();
     $user->name = $this->ecoleNom;
     $user->type = $this->type;
     $user->email = $this->email;
     $user->password = \Hash::make($this->password);
     $user->nom_responsable = $this->nomResponsable;
     $user->tel_fixe = $this->fix;
     $user->tel_portable = $this->portab;
     $user->adresse = $this->adresse;
     $user->ville = $this->ville;
     $user->pays = $this->pays;
     $user->save();
     if ($user) {
         $info = ['nom_resp' => $this->nomResponsable, 'nom_ecole' => $this->ecoleNom, 'email' => $this->email, 'pass' => $this->password];
         Mail::queue('emails.school', $info, function ($message) {
             $message->to($this->email, 'ok')->from('*****@*****.**')->subject('Bienvenue  !');
         });
     }
 }
Esempio n. 19
0
 /**
  * Get the message from an array of member email data.
  * 
  * @param array $data The array of data to get the message from.
  * @return string The message, or null if it could not be found.
  */
 public function getMessage($data)
 {
     if (isset($data) && is_array($data)) {
         return Hash::get($data, 'MemberEmail.message');
     }
     return null;
 }
 /**
  * Take a comma seperated list of id's and save them in the matching order
  *
  * @param Controller $controller
  */
 public function startup(Controller $controller)
 {
     parent::startup($controller);
     $postedRanks = Hash::extract($controller->request->data, '{s}.updated-ranks');
     if ($controller->request->is('post') && !empty($postedRanks)) {
         $ranks = explode(',', $postedRanks[0]);
         $i = 0;
         foreach ($ranks as $order => $rowId) {
             $data[$i][$this->settings['model']][$this->settings['field']] = $rowId;
             $data[$i][$this->settings['model']][$this->settings['sortField']] = $order + 1;
             // As arrays count from 0, but our ranks count from 1
             $i++;
         }
         $element = 'default';
         if ($this->settings['useNiceAdmin']) {
             $element = 'NiceAdmin.alert-box';
         }
         $controller->loadModel($this->settings['model']);
         if ($controller->{$this->settings['model']}->saveAll($data, array('validate' => false))) {
             $controller->Session->setFlash($this->settings['model'] . ' order updated', $element, array('class' => 'alert-success'));
             $controller->redirect($controller->referer());
         } else {
             $controller->Session->setFlash($this->settings['model'] . ' order could not be updated, please try again', $element, array('class' => 'alert-error'));
         }
     }
 }
Esempio n. 21
0
 public function run()
 {
     $now = date('Y-m-d H:i:s');
     //DB::table('users')->delete();
     $users = [['group_id' => 5, 'username' => 'nick', 'fullname' => 'Nicholas Law', 'active' => 1, 'email' => '*****@*****.**', 'email_verified' => 1, 'password' => Hash::make('nl511988'), 'ip_address' => Request::getClientIp(), 'gender' => 'male', 'country' => 'Australia', 'created_at' => $now, 'updated_at' => $now], ['group_id' => 5, 'username' => 'demo', 'fullname' => 'Demo Account', 'active' => 1, 'email' => '*****@*****.**', 'email_verified' => 1, 'password' => Hash::make('demo'), 'ip_address' => Request::getClientIp(), 'gender' => 'male', 'country' => 'United States', 'created_at' => $now, 'updated_at' => $now], ['group_id' => 5, 'username' => 'test', 'fullname' => 'John Doe', 'active' => 1, 'email' => '*****@*****.**', 'email_verified' => 1, 'password' => Hash::make('test'), 'ip_address' => Request::getClientIp(), 'gender' => 'male', 'country' => 'United States', 'created_at' => $now, 'updated_at' => $now]];
     DB::table('users')->insert($users);
 }
Esempio n. 22
0
 /**
  * Adds new task
  *
  * @param string $command
  * @param string $path
  * @param array $arguments
  * @param array $options
  * - `unique` - if true and found active duplicates wont add new task
  * - `dependsOn` - an array of task ids that must be done before this task starts
  * @return bool
  */
 public function add($command, $path, array $arguments = array(), array $options = array())
 {
     $dependsOn = (array) Hash::get($options, 'dependsOn');
     $unique = (bool) Hash::get($options, 'unique');
     unset($options['dependsOn'], $options['unique']);
     $task = compact('command', 'path', 'arguments') + $options;
     $task += array('timeout' => 60 * 60, 'status' => TaskType::UNSTARTED, 'code' => 0, 'stdout' => '', 'stderr' => '', 'details' => array(), 'server_id' => 0, 'scheduled' => null, 'hash' => $this->_hash($command, $path, $arguments));
     $dependsOnIds = $this->find('list', array('fields' => array('id', 'id'), 'conditions' => array('hash' => $task['hash'], 'status' => array(TaskType::UNSTARTED, TaskType::DEFFERED, TaskType::RUNNING))));
     if ($unique && $dependsOnIds) {
         return false;
     } elseif ($dependsOnIds) {
         $dependsOn = array_merge($dependsOn, $dependsOnIds);
     }
     $this->create();
     if ($dependsOn) {
         $data = array($this->alias => $task, $this->DependsOnTask->alias => $dependsOn);
         $success = $this->saveAssociated($data);
     } else {
         $success = $this->save($task);
     }
     if (!$success) {
         return false;
     } else {
         return $this->read()[$this->alias];
     }
 }
 /**
  * Constructor
  *
  * @param ComponentCollection $collection The controller for this request.
  * @param string $settings An array of settings. This class does not use any settings.
  */
 public function __construct(ComponentCollection $collection, $settings = array())
 {
     $this->_Collection = $collection;
     $controller = $collection->getController();
     $this->controller($controller);
     $this->settings = Hash::merge($this->settings, $settings);
 }
Esempio n. 24
0
 public function postNew()
 {
     $validation = new Validators\SeatUserRegisterValidator();
     if ($validation->passes()) {
         // Let's register a user.
         $user = new \User();
         $user->email = Input::get('email');
         $user->username = Input::get('username');
         $user->password = Hash::make(Input::get('password'));
         $user->tsid = Input::get('tsid');
         $user->activation_code = str_random(24);
         $user->activated = 1;
         $user->save();
         // Prepare data to be sent along with the email. These
         // are accessed by their keys in the email template
         $data = array('activation_code' => $user->activation_code);
         // Send the email with the activation link
         Mail::send('emails.auth.register', $data, function ($message) {
             $message->to(Input::get('email'), 'New SeAT User')->subject('SeAT Account Confirmation');
         });
         // And were done. Redirect to the login again
         return Redirect::action('SessionController@getSignIn')->with('success', 'Successfully registered a new account. Please check your email for the activation link.');
     } else {
         return Redirect::back()->withInput()->withErrors($validation->errors);
     }
 }
 public function run()
 {
     DB::table('users')->truncate();
     factory('CodeCommerce\\User')->create(['name' => "Houston", 'email' => '*****@*****.**', 'password' => Hash::make('123456'), 'is_admin' => true, 'endereco' => 'R. Canadá', 'numero' => 73, 'bairro' => 'Jardim Naltilus', 'cidade' => 'Cabo Frio', 'uf' => 'RJ', 'cep' => '28909-170']);
     //usuario  padrao
     factory('CodeCommerce\\User', 9)->create();
 }
Esempio n. 26
0
 /**
  * Return roles_rooms_users
  *
  * @param array $conditions Conditions by Model::find
  * @return array
  */
 public function getRolesRoomsUsers($conditions = array())
 {
     $this->Room = ClassRegistry::init('Rooms.Room');
     $conditions = Hash::merge(array('Room.page_id_top NOT' => null), $conditions);
     $rolesRoomsUsers = $this->find('all', array('recursive' => -1, 'fields' => array($this->alias . '.*', $this->RolesRoom->alias . '.*', $this->Room->alias . '.*'), 'joins' => array(array('table' => $this->RolesRoom->table, 'alias' => $this->RolesRoom->alias, 'type' => 'INNER', 'conditions' => array($this->alias . '.roles_room_id' . ' = ' . $this->RolesRoom->alias . ' .id')), array('table' => $this->Room->table, 'alias' => $this->Room->alias, 'type' => 'INNER', 'conditions' => array($this->RolesRoom->alias . '.room_id' . ' = ' . $this->Room->alias . ' .id'))), 'conditions' => $conditions));
     return $rolesRoomsUsers;
 }
 /**
  * edit
  *
  * @return void
  */
 public function edit()
 {
     //事前準備
     $this->__prepare();
     //リクエストセット
     if ($this->request->is('post')) {
         $this->set('membershipTab', Hash::get($this->request->data['SiteSetting'], 'membershipTab', 'automatic-registration'));
         $this->request->data['SiteSetting'] = Hash::remove($this->request->data['SiteSetting'], 'membershipTab');
         $automaticInputItems = Hash::get($this->request->data, '_siteManager.automaticInputItems', 'false');
         $this->Session->write('automaticInputItems', $automaticInputItems);
         $this->__parseRequestData();
         $this->SiteSetting->autoRegistRoles = $this->viewVars['userRoles'];
         //登録処理
         $redirect = Router::parse($this->referer());
         $redirect['?'] = array('membershipTab' => $this->viewVars['membershipTab']);
         $this->SiteManager->saveData($redirect);
     } else {
         $this->set('membershipTab', Hash::get($this->request->query, 'membershipTab', 'automatic-registration'));
         if ($this->Session->read('automaticInputItems')) {
             $automaticInputItems = $this->Session->read('automaticInputItems');
             $this->Session->delete('automaticInputItems');
         } else {
             $automaticInputItems = 'false';
         }
         $this->request->data['SiteSetting'] = $this->SiteSetting->getSiteSettingForEdit(array('SiteSetting.key' => array('AutoRegist.use_automatic_register', 'AutoRegist.confirmation', 'AutoRegist.use_secret_key', 'AutoRegist.secret_key', 'AutoRegist.role_key', 'AutoRegist.prarticipate_default_room', 'AutoRegist.disclaimer', 'AutoRegist.approval_mail_subject', 'AutoRegist.approval_mail_body', 'AutoRegist.acceptance_mail_subject', 'AutoRegist.acceptance_mail_body', 'UserRegist.mail_subject', 'UserRegist.mail_body', 'UserCancel.use_cancel_feature', 'UserCancel.disclaimer', 'UserCancel.notify_administrators', 'UserCancel.mail_subject', 'UserCancel.mail_body')));
     }
     $this->set('automaticInputItems', $automaticInputItems);
 }
Esempio n. 28
0
 public static function password_update($password, $user = NULL)
 {
     if ($user or $user = self::find(Auth::user()->id)) {
         $user->pass = Hash::make($password);
         return $user->save();
     }
 }
 /**
  * UserAttributesRoleのデフォルト値
  *
  * * パスワード=自分/他人とも読み取り不可
  * * ラベル項目=自分/他人とも書き込み不可
  * * 会員管理が使用可=上記以外、自分・他人とも自分/他人の読み・書き可
  * * 会員管理が使用不可
  * ** 管理者以外、読み取り不可項目とする=自分/他人の読み・書き不可。※読めないのに書けるはあり得ないため。
  * ** 管理者以外、書き込み不可項目とする=自分/他人の書き込み不可。
  * ** 上記以外
  * *** ハンドル・アバター=自分は、読み・書き可。他人は、読み取り可/書き込み不可。
  * *** それ以外=自分は、読み・書き可。他人は、読み・書き不可。
  *
  * @param Model $model Model using this behavior
  * @param array|string $userAttrSetting 配列:ユーザ属性設定データ、文字列:ユーザ属性キー
  * @param bool $enableUserManager 有効かどうか
  * @return array ユーザ属性ロールデータ
  */
 public function defaultUserAttributeRole(Model $model, $userAttrSetting, $enableUserManager)
 {
     $model->loadModels(['UserAttributeSetting' => 'UserAttributes.UserAttributeSetting']);
     $userAttrSetting = $model->UserAttributeSetting->create($userAttrSetting);
     $userAttributeRole = array();
     $userAttributeRole['UserAttributesRole']['self_readable'] = true;
     $userAttributeRole['UserAttributesRole']['self_editable'] = true;
     $userAttributeKey = $userAttrSetting['UserAttributeSetting']['user_attribute_key'];
     if ($userAttributeKey === UserAttribute::PASSWORD_FIELD) {
         $userAttributeRole['UserAttributesRole']['self_readable'] = false;
         $userAttributeRole['UserAttributesRole']['other_readable'] = false;
     } elseif ($enableUserManager) {
         $userAttributeRole['UserAttributesRole']['other_readable'] = true;
     } elseif (Hash::get($userAttrSetting, 'UserAttributeSetting.only_administrator_readable')) {
         $userAttributeRole['UserAttributesRole']['self_readable'] = false;
         $userAttributeRole['UserAttributesRole']['other_readable'] = false;
         $userAttrSetting['UserAttributeSetting']['only_administrator_editable'] = true;
     } else {
         $userAttributeRole['UserAttributesRole']['self_readable'] = true;
         $userAttributeRole['UserAttributesRole']['other_readable'] = in_array($userAttributeKey, $this->readableDefault, true);
     }
     $userAttributeRole['UserAttributesRole']['other_editable'] = false;
     if ($userAttrSetting['UserAttributeSetting']['data_type_key'] === DataType::DATA_TYPE_LABEL) {
         $userAttributeRole['UserAttributesRole']['self_editable'] = false;
     } elseif ($enableUserManager) {
         $userAttributeRole['UserAttributesRole']['other_editable'] = true;
     } elseif (Hash::get($userAttrSetting, 'UserAttributeSetting.only_administrator_editable')) {
         $userAttributeRole['UserAttributesRole']['self_editable'] = false;
     }
     return $userAttributeRole;
 }
Esempio n. 30
-2
function render($template, $locals = array())
{
    $context = new Hash(array('response' => response(), 'request' => request(), 'route' => route()));
    $context->params = $context->request->params;
    $context->merge($locals);
    $views = options()->get('views', __DIR__ . '/views');
    $filename = realpath("{$views}/{$template}");
    ob_start();
    $included = php($filename, $context);
    $output = ob_get_clean();
    return $included ? $output : false;
}