function users_contact_post() { Pie_Session::start(); Pie_Valid::nonce(true); extract($_REQUEST); $user = Users::loggedInUser(); if (!$user) { throw new Users_Exception_NotLoggedIn(); } $app = Pie_Config::expect('pie', 'app'); $subject = "Welcome! Activate your email."; $view = "{$app}/email/setEmail.php"; $fields = array(); $p = array(); $p['subject'] =& $subject; $p['view'] =& $view; $p['fields'] =& $fields; Pie::event('users/setEmail', $p, 'before'); // may change the fields if (isset($first_name)) { $user->first_name = $first_name; } if (isset($last_name)) { $user->last_name = $last_name; } $user->addEmail($_REQUEST['email_address'], $subject, $view, true, $fields); // If no exceptions were throw, save this user row if (isset($first_name) or isset($last_name)) { $user->save(); } }
/** * This is a tool for selecting photos (to possibly add) * @param $facebook * Optional. You can provide instance of the Facebook class. * @param $upload * Defaults to false. If true, shows an option to upload, as well. * @param $action_uri * Defaults to 'items/addPhoto'. The URI to submit the form to. * @param $filter_visible * Optional string. Set to 'everyone' to only display albums visible to everyone. * @param $on_success * Optional string. The url to redirect to after a photo is added or uploaded. */ function items_addPhoto_tool($params) { if (isset(Users::$facebook)) { $facebook = Users::$facebook; } else { $app = Pie_Config::expect('pie', 'app'); if (!isset(Users::$facebooks[$app])) { throw new Pie_Exception_MissingObject(array('name' => 'Users::$facebooks[' . $app . ']')); } $facebook = Users::$facebooks[$app]; } $defaults = array('facebook' => $facebook, 'upload' => false, 'action_uri' => 'items/addPhoto', 'on_success' => Pie_Request::url()); extract(array_merge($defaults, $params)); if (!$facebook instanceof Facebook) { throw new Pie_Exception_WrongType(array('field' => '$facebook', 'type' => 'Facebook')); } if (isset($_REQUEST['_pie']['onSuccess'])) { $on_success = $_REQUEST['_pie']['onSuccess']; } $sn = Pie_Session::name(); $sid = Pie_Session::id(); $photos = array(); if (isset($aid)) { $photos = Items::facebookPhotos($facebook, $aid); return Pie::view('items/tool/addPhotoList.php', compact('photos')); } $facebook->require_login(); $album_rows = Items::facebookAlbums($facebook); $albums = array(); foreach ($album_rows as $ar) { if (isset($filter_visible) and $ar['visible'] != $filter_visible) { continue; } $albums[$ar['aid']] = $ar['name']; } $albums = $albums; if (count($album_rows)) { $row = reset($album_rows); $photos = Items::facebookPhotos($facebook, $row['aid']); } $throbber_url = Pie_Html::themedUrl('plugins/items/img/anim/throbber.gif'); $url_json = json_encode(Pie_Uri::url($action_uri)); Pie_Response::addStylesheet('plugins/items/css/Items.css'); if (Pie_Request::accepts('text/fbml')) { Pie_Response::addScript('plugins/items/fbjs/Items.fb.js'); } else { Pie_Response::addScript('plugins/items/js/Items.js'); } if (is_bool($upload)) { $upload = uniqid('up.', false); } $addPhoto_url_json = json_encode(Pie_Uri::url('items/addPhoto')); Pie_Response::addScriptLine("\tPie.Items.urls['items/addPhoto'] = {$addPhoto_url_json};"); return Pie::view('items/tool/addPhoto.php', compact('action_uri', 'on_success', 'on_added', 'albums', 'photos', 'throbber_url', 'upload')); }
function users_account_post() { Pie_Session::start(); Pie_Valid::nonce(true); extract($_REQUEST); // Implement the action $user = Users::loggedInUser(); if (!$user) { throw new Users_Exception_NotLoggedIn(); } /* if (!isset($gender) and isset($user->gender)) { $gender = $user->gender; } if (isset($orientation)) { if (isset($gender) and $orientation == 'straight') { $desired_gender = ($gender == 'male') ? 'female' : 'male'; } else if (isset($gender) and $orientation == 'gay') { $desired_gender = $gender; } else { $desired_gender = 'either'; } } if (isset($first_name)) $user->first_name = $first_name; if (isset($last_name)) $user->last_name = $last_name; if (isset($gender)) $user->gender = $gender; if (isset($desired_gender)) $user->desired_gender = $desired_gender; if (isset($username)) $user->username = $username; if (isset($relationship_status)) { $user->relationship_status = $relationship_status; } if (isset($birthday_year)) { $user->birthday = date("Y-m-d", mktime( 0, 0, 0, $birthday_month, $birthday_day, $birthday_year )); } if (isset($zipcode)) $user->zipcode = $zipcode; $user->save(true); */ // the $_SESSION['users']['user'] is now altered }
function users_account_response_content() { Pie_Session::start(); return Pie::tool('users/account'); }
/** * Use with caution! This bypasses authentication. * This functionality should not be exposed externally. * @param Users_User $user * The user object */ static function setLoggedInUser($user) { if (isset($_SESSION['users']['user']->id)) { if ($user->id == $_SESSION['users']['user']->id) { // This user is already the logged-in user. return; } } // Change the session id to prevent session fixation attacks Pie_Session::regenerate_id(); // Store the new information in the session $snf = Pie_Config::get('pie', 'session', 'nonceField', 'nonce'); $_SESSION['users']['user'] = $user; $_SESSION['pie'][$snf] = uniqid(); Pie::event('users/setLoggedInUser', compact('user'), 'after'); }
function users_contact_response_content() { Pie_Session::start(); return Pie::tool('users/contact'); }
function pie_before_pie_init($params, &$result) { Pie_Session::init(); }
static function write($id, $sess_data) { if (empty(self::$session_save_path)) { self::$session_save_path = self::savePath(); } if (!empty(self::$session_db_connection)) { $data_field = self::$session_db_data_field; $updated_field = self::$session_db_updated_field; self::$session_db_row->{$updated_field} = date('Y-m-d H:i:s'); self::$session_db_row->{$data_field} = $sess_data; self::$session_db_row->save(); } else { $sess_file = self::$session_save_path . "/sess_{$id}"; $fp = fopen($sess_file, "w"); if (!$fp) { return false; } $return = fwrite($fp, $sess_data); fclose($fp); return $return; } return true; }