Exemple #1
0
 private function action($form)
 {
     //$session       = Application::session();
     $session = session_currentSession();
     $id = session_valueForKey('id');
     //$session->id;
     if (!empty($id)) {
         $u = new User();
         $u->initWithPrimaryKey($id);
         //$q             = phorm_query('User');
         //$q->filter('User->id = '.'"'.$id.'"');
         //$u             = $q->one();
         if (!empty($u->id)) {
             $email = array();
             $email['recipients'][] = $u->username;
             if ($this->shouldUpdateEmail) {
                 $u->username = strtolower($form->email);
                 $email['recipients'][] = strtolower($form->email);
             }
             if ($this->shouldUpdatePassword) {
                 $u->password = $form->password;
             }
             if ($this->shouldUpdatePhoto) {
                 $u->bitmap_normal = $form->photo;
                 $u->bitmap_bigger = $form->photo;
             }
             $u->save();
             $u->release();
             email_sendAccountModify($email);
             header('location:/account/settings/success');
         } else {
             header('location:/account/logout');
         }
     }
 }
 protected function page_load()
 {
     echo '<pre>', print_r($_SESSION, true), '</pre>';
     $session = session_currentSession();
     //$session = Application::session();
     echo $session->id, '<br>';
     echo $session->screenname;
     $user = user_currentUser();
     if ($user) {
         //twitter_setStatusForUser('Simultaneous post to twitter and facebook part 2 via #CouchDB #PHP', $user);
         //facebook_setStatusForUser('Simultaneous post to twitter and facebook part 2 via CouchDB and PHP', $user);
     }
 }
Exemple #3
0
 private function prepareErrors($form)
 {
     $messages = array();
     foreach ($form->validators as $validator) {
         if (!$validator->isValid) {
             $messages[$validator->key] = $validator->message;
         }
     }
     //$session = Application::session();
     $session = session_currentSession();
     $session->forms[__CLASS__]['messages'] = $messages;
     $session->forms[__CLASS__]['form'] = $form;
     header('location:/forgetful/');
 }
 private function action($user)
 {
     $session = session_currentSession();
     session_regenerateCurrentSession();
     session_setValueForKey($user->id, 'id');
     session_setValueForKey($user->screenname, 'screenname');
     session_setValueForKey($user->isValid, 'isValid');
     session_setValueForKey(true, 'isAuthenticated');
     //$session->id              = $user->id;
     //$session->screenname      = $user->screenname;
     //$session->isAuthenticated = true;
     $user->lastLogin = time();
     $user->save();
     header('location:/account/channels');
 }
Exemple #5
0
 private function action($form)
 {
     $session = session_currentSession();
     $p = new Channel();
     $p->user = $session->id;
     $p->label = $form->name;
     $p->short_label = $form->shortname;
     $p->key = $this->generateKey();
     $p->secret = $this->generateSecret();
     $p->domain = $form->domain;
     // ISO-8601 2005-08-14T16:13:03+0000;
     $time = time() + $value;
     $p->created = date('c', $time);
     $p->save();
     //header('location:/account/settings');
 }
 public function channels()
 {
     $session = session_currentSession();
     if ($session->isValid) {
         $dbh = Database::connection();
         //startkey=[%22f85638dfeff04bc1dec252ba2f8ed287%22,%20null]&endkey=[%22f85638dfeff04bc1dec252ba2f8ed287%22,%20{}]
         $session = session_currentSession();
         $startkey = array($session->id, null);
         $endkey = array($session->id, (object) null);
         //(object) null OR new stdClass do the same thing
         $options = array('startkey' => $startkey, 'endkey' => $endkey);
         $view = $dbh->view('applications/user', $options);
         foreach ($view as $document) {
             echo new ChannelView($document);
         }
     } else {
         echo 'Account Not Authorized to create Channels <a href="#">Resend Authorization E-mail</a>';
     }
 }
Exemple #7
0
 private function action($form)
 {
     $u = new User();
     $u->username = strtolower($form->email);
     $u->screenname = $form->screenname;
     $u->password = $form->password;
     $u->lastLogin = time();
     $u->isValid = false;
     $u->columns['bitmap_normal']->value = User::kProfileDefaultNormal;
     $u->columns['bitmap_bigger']->value = User::kProfileDefaultBigger;
     $u->save();
     //echo $u->bitmap_normal;
     //exit;
     //$session = Application::session();
     //$session->regenerate(true);
     //$session->id              = $u->id;
     //$session->screenname      = $u->screenname;
     //$session->isAuthenticated = true;
     $session = session_currentSession();
     session_regenerateCurrentSession();
     session_setValueForKey($u->id, 'id');
     session_setValueForKey($u->screenname, 'screenname');
     session_setValueForKey(true, 'isAuthenticated');
     // generate a random key for the user to authenticate against:
     $stream = fopen('/dev/random', 'r');
     $bytes = fread($stream, 512);
     fclose($stream);
     $key = hash('md5', base64_encode($bytes));
     $authorized = array('type' => 'authorization', 'user' => $u->id, 'key' => $key);
     $db = new CouchDB(array('database' => Configuration::kDatabaseName));
     $db->put(json_encode($authorized));
     $email = array();
     $email['recipients'][] = $u->username;
     $email['key'] = $key;
     email_sendAccountCreate($email);
     header('location:/');
 }
function session_deleteFormForKey($key)
{
    unset(session_currentSession()->forms[$key]);
}