示例#1
0
 /**
  * Updates the user profile from a form
  */
 public function actionProfile()
 {
     if (Pii::guest()) {
         $this->_redirectError('You must be logged in to change your profile.');
     }
     $_model = new ProfileForm();
     if (isset($_POST, $_POST['ProfileForm'])) {
         $_model->attributes = $_POST['ProfileForm'];
         if ($_model->validate()) {
             try {
                 $_userId = Session::getCurrentUserId();
                 $_result = Profile::changeProfile($_userId, $_model->attributes);
                 if (Option::getBool($_result, 'success')) {
                     Yii::app()->user->setFlash('profile-form', 'Your profile has been successfully updated.');
                 }
             } catch (\Exception $_ex) {
                 $_model->addError(null, $_ex->getMessage());
             }
         }
     } else {
         $_userId = Session::getCurrentUserId();
         $_model->attributes = Profile::getProfile($_userId);
     }
     $this->render('profile', array('model' => $_model, 'backUrl' => $this->_getRedirectUrl(), 'session' => Session::generateSessionDataFromUser(Session::getCurrentUserId())));
 }
示例#2
0
文件: Curl.php 项目: kisma/kisma
 /**
  * Returns the validated URL that has been called to get here
  *
  * @param bool $includeQuery If true, query string is included
  * @param bool $includePath  If true, the uri path is included
  *
  * @return string
  */
 public static function currentUrl($includeQuery = true, $includePath = true)
 {
     //	Are we SSL? Check for load balancer protocol as well...
     $_port = intval(Option::get($_SERVER, 'HTTP_X_FORWARDED_PORT', Option::get($_SERVER, 'SERVER_PORT', 80)));
     $_protocol = Option::get($_SERVER, 'HTTP_X_FORWARDED_PROTO', 'http' . (Option::getBool($_SERVER, 'HTTPS') ? 's' : null)) . '://';
     $_host = Option::get($_SERVER, 'HTTP_X_FORWARDED_HOST', Option::get($_SERVER, 'HTTP_HOST', gethostname()));
     $_parts = parse_url($_protocol . $_host . Option::get($_SERVER, 'REQUEST_URI'));
     if ((empty($_port) || !is_numeric($_port)) && null !== ($_parsePort = Option::get($_parts, 'port'))) {
         $_port = @intval($_parsePort);
     }
     if (null !== ($_query = Option::get($_parts, 'query'))) {
         $_query = static::urlSeparator($_query) . http_build_query(explode('&', $_query));
     }
     if (false !== strpos($_host, ':') || $_protocol == 'https://' && $_port == 443 || $_protocol == 'http://' && $_port == 80) {
         $_port = null;
     } else {
         $_port = ':' . $_port;
     }
     if (false !== strpos($_host, ':')) {
         $_port = null;
     }
     $_currentUrl = $_protocol . $_host . $_port . (true === $includePath ? Option::get($_parts, 'path') : null) . (true === $includeQuery ? $_query : null);
     if (\Kisma::get('debug.curl.current_url')) {
         Log::debug('Parsed current URL to be: ' . $_currentUrl, $_parts);
     }
     return $_currentUrl;
 }