/**
  * Get the file component from the request
  *
  * @param \SS_HTTPRequest $request
  * @return string
  */
 protected function parseFilename(\SS_HTTPRequest $request)
 {
     $filename = '';
     $next = $request->param('Filename');
     while ($next) {
         $filename = $filename ? \File::join_paths($filename, $next) : $next;
         $next = $request->shift();
     }
     if ($extension = $request->getExtension()) {
         $filename = $filename . "." . $extension;
     }
     return $filename;
 }
 /**
  * Show the "password sent" page, after a user has requested
  * to reset their password.
  *
  * @param SS_HTTPRequest $request The SS_HTTPRequest for this action.
  * @return string Returns the "password sent" page as HTML code.
  */
 public function emailsent($request)
 {
     Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/behaviour/behaviour.js');
     Requirements::javascript(SAPPHIRE_DIR . '/javascript/loader.js');
     Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/prototype/prototype.js');
     Requirements::javascript(SAPPHIRE_DIR . '/javascript/prototype_improvements.js');
     Requirements::javascript(THIRDPARTY_DIR . '/scriptaculous/effects.js');
     $tmpPage = new Page();
     $tmpPage->Title = _t('Security.LOSTPASSWORDHEADER');
     $tmpPage->URLSegment = 'Security';
     $tmpPage->ID = -1;
     // Set the page ID to -1 so we dont get the top level pages as its children
     $controller = new Page_Controller($tmpPage);
     $controller->init();
     $email = Convert::raw2xml($request->param('ID') . '.' . $request->getExtension());
     $customisedController = $controller->customise(array('Title' => sprintf(_t('EmailVerifiedMember.EMAILSENTHEADER', "Verify Email link sent to '%s'"), $email), 'Content' => "<p>" . sprintf(_t('EmailVerifiedMember.EMAILSENTTEXT', "Thank you! A verify email link has been sent to  '%s', provided an account exists for this email address."), $email) . "</p>", 'Email' => $email));
     return $customisedController->renderWith(array('Security_emailsent', 'Security', $this->owner->stat('template_main'), 'ContentController'));
 }
 /**
  * Show the "password sent" page, after a user has requested
  * to reset their password.
  *
  * @param SS_HTTPRequest $request The SS_HTTPRequest for this action.
  * @return string Returns the "password sent" page as HTML code.
  */
 public function passwordsent($request)
 {
     if (class_exists('SiteTree')) {
         $tmpPage = new Page();
         $tmpPage->Title = _t('Security.LOSTPASSWORDHEADER', 'Lost Password');
         $tmpPage->URLSegment = 'Security';
         // Disable ID-based caching  of the log-in page by making it a random number
         $tmpPage->ID = -1 * rand(1, 10000000);
         $controller = Page_Controller::create($tmpPage);
         $controller->init();
     } else {
         $controller = $this;
     }
     // if the controller calls Director::redirect(), this will break early
     if (($response = $controller->getResponse()) && $response->isFinished()) {
         return $response;
     }
     $email = Convert::raw2xml(rawurldecode($request->param('ID')) . '.' . $request->getExtension());
     $customisedController = $controller->customise(array('Title' => _t('Security.PASSWORDSENTHEADER', "Password reset link sent to '{email}'", array('email' => $email)), 'Content' => "<p>" . _t('Security.PASSWORDSENTTEXT', "Thank you! A reset link has been sent to '{email}', provided an account exists for this email" . " address.", array('email' => $email)) . "</p>", 'Email' => $email));
     //Controller::$currentController = $controller;
     return $customisedController->renderWith($this->getTemplate('passwordsent'));
 }
Example #4
0
 /**
  * Show the "password sent" page, after a user has requested
  * to reset their password.
  *
  * @param SS_HTTPRequest $request The SS_HTTPRequest for this action.
  * @return string Returns the "password sent" page as HTML code.
  */
 public function passwordsent($request)
 {
     $controller = $this->getResponseController(_t('Security.LOSTPASSWORDHEADER', 'Lost Password'));
     // if the controller calls Director::redirect(), this will break early
     if (($response = $controller->getResponse()) && $response->isFinished()) {
         return $response;
     }
     $email = Convert::raw2xml(rawurldecode($request->param('ID')) . '.' . $request->getExtension());
     $customisedController = $controller->customise(array('Title' => _t('Security.PASSWORDSENTHEADER', "Password reset link sent to '{email}'", array('email' => $email)), 'Content' => "<p>" . _t('Security.PASSWORDSENTTEXT', "Thank you! A reset link has been sent to '{email}', provided an account exists for this email" . " address.", array('email' => $email)) . "</p>", 'Email' => $email));
     //Controller::$currentController = $controller;
     return $customisedController->renderWith($this->getTemplatesFor('passwordsent'));
 }
Example #5
0
 /**
  * Show the "password sent" page, after a user has requested
  * to reset their password.
  *
  * @param SS_HTTPRequest $request The SS_HTTPRequest for this action. 
  * @return string Returns the "password sent" page as HTML code.
  */
 public function passwordsent($request)
 {
     if (class_exists('SiteTree')) {
         $tmpPage = new Page();
         $tmpPage->Title = _t('Security.LOSTPASSWORDHEADER');
         $tmpPage->URLSegment = 'Security';
         $tmpPage->ID = -1;
         // Set the page ID to -1 so we dont get the top level pages as its children
         $controller = new Page_Controller($tmpPage);
         $controller->init();
     } else {
         $controller = $this;
     }
     $email = Convert::raw2xml(rawurldecode($request->param('ID')) . '.' . $request->getExtension());
     $customisedController = $controller->customise(array('Title' => sprintf(_t('Security.PASSWORDSENTHEADER', "Password reset link sent to '%s'"), $email), 'Content' => "<p>" . sprintf(_t('Security.PASSWORDSENTTEXT', "Thank you! A reset link has been sent to  '%s', provided an account exists for this email address."), $email) . "</p>", 'Email' => $email));
     //Controller::$currentController = $controller;
     return $customisedController->renderWith(array('Security_passwordsent', 'Security', $this->stat('template_main'), 'BlankPage'));
 }
Example #6
0
 /**
  * Show the "password sent" page, after a user has requested
  * to reset their password.
  *
  * @param SS_HTTPRequest $request The SS_HTTPRequest for this action. 
  * @return string Returns the "password sent" page as HTML code.
  */
 public function passwordsent($request)
 {
     if (class_exists('SiteTree')) {
         $tmpPage = new Page();
         $tmpPage->Title = _t('Security.LOSTPASSWORDHEADER');
         $tmpPage->URLSegment = 'Security';
         $tmpPage->ID = -1;
         // Set the page ID to -1 so we dont get the top level pages as its children
         $controller = Page_Controller::create($tmpPage);
         $controller->init();
     } else {
         $controller = $this;
     }
     // if the controller calls Director::redirect(), this will break early
     if (($response = $controller->getResponse()) && $response->isFinished()) {
         return $response;
     }
     $email = Convert::raw2xml(rawurldecode($request->param('ID')) . '.' . $request->getExtension());
     $customisedController = $controller->customise(array('Title' => _t('Security.PASSWORDSENTHEADER', "Password reset link sent to '{email}'", array('email' => $email)), 'Content' => "<p>" . _t('Security.PASSWORDSENTTEXT', "Thank you! A reset link has been sent to '{email}', provided an account exists for this email" . " address.", array('email' => $email)) . "</p>", 'Email' => $email));
     //Controller::$currentController = $controller;
     return $customisedController->renderWith(array('Security_passwordsent', 'Security', $this->stat('template_main'), 'BlankPage'));
 }
Example #7
0
 /**
  * Action - Get the latest deploy log
  *
  * @return string
  */
 public function transferlog(SS_HTTPRequest $request)
 {
     $params = $request->params();
     $transfer = DNDataTransfer::get()->byId($params['Identifier']);
     if (!$transfer || !$transfer->ID) {
         throw new SS_HTTPResponse_Exception('Transfer not found', 404);
     }
     if (!$transfer->canView()) {
         return Security::permissionFailure();
     }
     $environment = $transfer->Environment();
     $project = $environment->Project();
     if ($project->Name != $params['Project']) {
         throw new LogicException("Project in URL doesn't match this deploy");
     }
     $log = $transfer->log();
     if ($log->exists()) {
         $content = $log->content();
     } else {
         $content = 'Waiting for action to start';
     }
     $sendJSON = strpos($request->getHeader('Accept'), 'application/json') !== false || $request->getExtension() == 'json';
     $content = preg_replace('/(?:(?:\\r\\n|\\r|\\n)\\s*){2}/s', "\n", $content);
     if ($sendJSON) {
         $this->response->addHeader("Content-type", "application/json");
         return json_encode(array('status' => $transfer->ResqueStatus(), 'content' => $content));
     } else {
         $this->response->addHeader("Content-type", "text/plain");
         return $content;
     }
 }
 /**
  * Read a file and output its contents.
  *
  * SideEffects:
  *  Sets Content-Type: text/plain header.
  *  Outputs file contents to output buffer via readfile, so can't echo ReplicantProgressLogEntry here.
  *
  * @param SS_HTTPRequest $request
  * @internal param $id
  * @return bool|int false if fails, otherwise number of bytes read
  */
 protected function readFile(SS_HTTPRequest $request)
 {
     $options = array('FileName' => $request->param('ID') . ($request->getExtension() ? '.' . $request->getExtension() : ''));
     return ReplicantActionReadFile::create()->checkPerm()->update($options)->execute();
 }
Example #9
0
 /**
  * Show the "password sent" page, after a user has requested
  * to reset their password.
  *
  * @param SS_HTTPRequest $request The SS_HTTPRequest for this action.
  * @return string Returns the "password sent" page as HTML code.
  */
 public function passwordsent($request)
 {
     $controller = $this;
     // if the controller calls Director::redirect(), this will break early
     if (($response = $controller->getResponse()) && $response->isFinished()) {
         return $response;
     }
     $email = Convert::raw2xml(rawurldecode($request->param('ID')) . '.' . $request->getExtension());
     return $this->customiseSummitPage(array('Title' => 'Password Reset Link Sent', 'Email' => $email, 'ClassName' => 'SummitLostPassword'))->renderWith(array('SummitSecurity_passwordsent', 'SummitPage'), $this);
 }