예제 #1
0
         } catch (\Exception $e) {
             $this->assign('form_error', $e->getMessage());
             $api->delete();
         }
     }
     $this->assign('email_content', 'Hi ' . htmlspecialchars($req->getEmail()) . PHP_EOL . PHP_EOL . 'Your request of API credentials for ' . $_SERVER['SERVER_NAME'] . $this->URL() . ' has been rejected. So sorry!' . PHP_EOL . PHP_EOL . 'Thanks for sharing your mood :)');
     $this->page('manage/api/requests/reject');
     $this->getToken();
     $this->assign('request', array('email' => $req->getEmail()));
     break;
 case 'remove':
     if (!$this->request(4) || !$this->request(5)) {
         break;
     }
     $this->acceptExtendedToken($this->request(5));
     $req = new ApiRequest();
     $req->loadFromId(intval($this->request(4)));
     if (!$req->exists()) {
         break;
     }
     if (!empty($_POST)) {
         $this->acceptToken();
         try {
             $this->assign('form_data', array('delete_api' => !empty($_POST['delete_api']) && $_POST['delete_api'] == 'on'));
             if (empty($_POST['delete'])) {
                 throw new \Exception('Nothing will be removed until you check the box…');
             }
             if (empty($_POST['request_id']) || $_POST['request_id'] != intval($this->request(4))) {
                 $this->hackAttempt();
             }
             if (!$req->delete()) {
예제 #2
0
파일: api.php 프로젝트: Devenet/MoodPicker
 switch ($this->request(2)) {
     case 'sent':
         $this->page('api/request_sent');
         break;
     case NULL:
         if (!empty($_POST)) {
             $this->acceptToken();
             try {
                 $this->assign('form_data', array('email' => htmlspecialchars($_POST['email']), 'agree' => !empty($_POST['agree']) && $_POST['agree'] == 'on'));
                 if (empty($_POST['email']) || !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
                     throw new \Exception('Please enter a valid email address.');
                 }
                 if (empty($_POST['agree']) || $_POST['agree'] != 'on') {
                     throw new \Exception('You have to agree to a fair-use of the API.');
                 }
                 $req = new ApiRequest();
                 if (!$req->availableEmail($_POST['email'])) {
                     throw new \Exception('A user with this email address has already done a request. <br />The webmaster is probably on <abbr title="Maybe just in front of GoT&hellip;" class="tip" data-placement="bottom">vacation</abbr> and can not handle your request for now.');
                 }
                 $req->setEmail($_POST['email']);
                 if (!$req->save()) {
                     throw new Exception('Unable to create your request. Please contact the webmaster.');
                 }
                 header('Location: ' . $this->URL('api/request/sent'));
                 exit;
             } catch (\Exception $e) {
                 $this->assign('form_error', $e->getMessage());
             }
         }
         $this->getToken();
         $this->page('api/request');