Exemplo n.º 1
0
 /**
  * Generate a password reset token and email a link to the user.
  *
  * @return string Standard JSON envelope
  */
 public function passwordRequest()
 {
     if (!isset($_POST['email'])) {
         return $this->error('No email address provided.', false);
     }
     $email = $_POST['email'];
     if ($email == $this->config->user->email) {
         $token = md5(rand(10000, 100000));
         $tokenUrl = sprintf('%s://%s/manage/password/reset/%s', $this->utility->getProtocol(false), $_SERVER['HTTP_HOST'], $token);
         $this->user->setAttribute('passwordToken', $token);
         $templateObj = getTemplate();
         $template = sprintf('%s/email/password-reset.php', $this->config->paths->templates);
         $body = $this->template->get($template, array('tokenUrl' => $tokenUrl));
         $emailer = new Emailer();
         $emailer->setRecipients(array($this->config->user->email));
         $emailer->setSubject('Trovebox password reset request');
         $emailer->setBody($body);
         $result = $emailer->send();
         if ($result > 0) {
             return $this->success('An email was sent to reset the password.', true);
         } else {
             $this->logger->info('Unable to send email. Confirm that your email settings are correct and the email addresses are valid.');
             return $this->error('We were unable to send a password reset email.', false);
         }
     }
     return $this->error('The email address provided does not match the registered email for this site.', false);
 }
Exemplo n.º 2
0
 public function send($type, $data)
 {
     getAuthentication()->requireAuthentication();
     getAuthentication()->requireCrumb();
     $email = $this->session->get('email');
     if (empty($email) || empty($_POST['message']) || empty($_POST['recipients'])) {
         return $this->error('Not all parameters were passed in', false);
     }
     $emailer = new Emailer($email);
     $emailer->setRecipients(array_merge(array($email), (array) explode(',', $_POST['recipients'])));
     if ($type === 'photo') {
         $status = $this->sendPhotoEmail($data, $emailer);
     } else {
         $status = $this->sendAlbumEmail($data, $emailer);
     }
     if (!$status) {
         return $this->error('Could not complete request', false);
     }
     return $this->success('yes', array('data' => $data, 'post' => $_POST));
 }
Exemplo n.º 3
0
 public function uploadNotify($token)
 {
     $shareTokenObj = new ShareToken();
     $tokenArr = $shareTokenObj->get($token);
     if (empty($tokenArr) || $tokenArr['type'] != 'upload') {
         return $this->forbidden('No permissions with the passed in token', false);
     }
     $albumId = $tokenArr['data'];
     $albumResp = $this->api->invoke(sprintf('/album/%s/view.json', $albumId), EpiRoute::httpGet, array('_GET' => array('token' => $token)));
     if ($albumResp['code'] !== 200) {
         return $this->error('Could not get album details', false);
     }
     $uploader = $count = null;
     if (isset($_POST['uploader'])) {
         $uploader = $_POST['uploader'];
     }
     if (isset($_POST['count'])) {
         $count = $_POST['count'];
     }
     $utilityObj = new Utility();
     $albumName = $albumResp['result']['name'];
     $albumUrl = sprintf('%s://%s/photos/album-%s/token-%s/list??sortBy=dateUploaded,desc', $utilityObj->getProtocol(false), $utilityObj->getHost(false), $albumId, $token);
     $tokenOwner = $tokenArr['actor'];
     $emailer = new Emailer();
     $emailer->setRecipients(array($tokenOwner));
     if (!empty($albumName)) {
         $emailer->setSubject(sprintf('Photos uploaded to %s', $albumName));
     } else {
         $emailer->setSubject('New photos were uploaded for you');
     }
     $markup = $this->theme->get('partials/upload-notify.php', array('albumId' => $albumId, 'albumName' => $albumName, 'albumUrl' => $albumUrl, 'uploader' => $uploader, 'count' => $count));
     $emailer->setBody($markup);
     $res = $emailer->send($markup);
     return $this->success('Email probably sent', true);
 }