Updates to SSL and other general items
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
* @copyright (c) 2009-2013 Deon George
|
||||
* @license http://dev.leenooks.net/license.html
|
||||
*/
|
||||
class Controller_User_SSL extends Controller_SSL {
|
||||
class Controller_User_Ssl extends Controller_Ssl {
|
||||
protected $auth_required = TRUE;
|
||||
|
||||
protected $secure_actions = array(
|
||||
@@ -19,31 +19,58 @@ class Controller_User_SSL extends Controller_SSL {
|
||||
);
|
||||
|
||||
public function action_add() {
|
||||
if ($this->request->post()) {
|
||||
$so = ORM::factory('SSL');
|
||||
if ($this->request->post() OR $_FILES) {
|
||||
if ($_FILES AND $this->request->post('csr'))
|
||||
SystemMessage::add(array(
|
||||
'title'=>_('Validation failed'),
|
||||
'type'=>'info',
|
||||
'body'=>_('Only supply a CSR file OR the CSR text, not both!'),
|
||||
));
|
||||
|
||||
$so->account_id = (string)Auth::instance()->get_user();
|
||||
else {
|
||||
|
||||
// Set our values, so that our filters have data
|
||||
$so->values($this->request->post());
|
||||
|
||||
$this->save($so);
|
||||
$so = ORM::factory('SSL');
|
||||
$so->account_id = (string)Auth::instance()->get_user();
|
||||
|
||||
if ($so->saved())
|
||||
HTTP::redirect(URL::link('user','ssl/view/'.$so->id));
|
||||
// Set our values, so that our filters have data
|
||||
$so->values($this->request->post());
|
||||
|
||||
if ($_FILES) {
|
||||
// Process upload
|
||||
$files = Validation::factory($_FILES)
|
||||
->rule('csr_file','Upload::valid')
|
||||
->rule('csr_file','Upload::not_empty')
|
||||
->rule('csr_file','Upload::type',array(':value',array('csr')))
|
||||
->rule('csr_file','Upload::size',array(':value','512K'));
|
||||
|
||||
if ($files->check())
|
||||
foreach ($files->data() as $file) {
|
||||
$so->csr = file_get_contents($file['tmp_name']);
|
||||
break;
|
||||
}
|
||||
|
||||
if (! $so->csr)
|
||||
throw HTTP_Exception::factory(501,'No CSR data :csr_file?',$files->errors('user/ssl/add'));
|
||||
}
|
||||
|
||||
$this->save($so);
|
||||
|
||||
if ($so->saved())
|
||||
HTTP::redirect(URL::link('user','ssl/view/'.$so->id));
|
||||
}
|
||||
}
|
||||
|
||||
Block::factory()
|
||||
->type('form-horizontal')
|
||||
->title('Add/Edit Record')
|
||||
->title_icon('fa-wrench')
|
||||
->title('SSL Certificate')
|
||||
->title_icon('fa-certificate')
|
||||
->body(View::factory('ssl/user/add')->set('o',$this->ao));
|
||||
}
|
||||
|
||||
public function action_download() {
|
||||
$passwd_len = Kohana::$config->load('ssl')->minpass_length;
|
||||
|
||||
$so = ORM::factory('SSL',$this->request->post('sid'));
|
||||
$so = ORM::factory('SSL',$this->request->param('id'));
|
||||
|
||||
if (! $so->loaded() OR ! Auth::instance()->authorised($so->account))
|
||||
throw HTTP_Exception::factory(403,'SSL either doesnt exist, or you are not authorised to see it');
|
||||
|
Reference in New Issue
Block a user