コード例 #1
0
ファイル: user.php プロジェクト: Zandemmer/HackThisSite-Old
 protected function certificate_add($arguments)
 {
     // Create
     if (!Session::isLoggedIn()) {
         return Error::set('Please login to add keys.');
     }
     if (empty($_POST['csr'])) {
         return Error::set('No CSR found.');
     }
     $certs = new certs(ConnectionFactory::get('mongo'), ConnectionFactory::get('redis'));
     $output = $certs->create($_POST['csr']);
     if (!$output) {
         return Error::set('Invalid CSR.');
     }
     $users = new users(ConnectionFactory::get('mongo'));
     $check = $certs->preAdd($output);
     if (is_string($check)) {
         return Error::set($check);
     }
     $check = $users->preAdd(Session::getVar('_id'), $certs->getKey($output));
     if (is_string($check)) {
         return Error::set($check);
     }
     $certs->add($output);
     $users->addCert(Session::getVar('_id'), $certs->getKey($output));
     $this->view['valid'] = true;
     $this->view['certificate'] = $output;
 }