This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
khosb/modules/ssl/classes/Controller/User/Ssl.php

52 lines
1.5 KiB
PHP
Raw Normal View History

2011-12-16 23:31:35 +00:00
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class provides User SSL functions
*
* @package OSB
* @subpackage SSL
* @category Controllers/Admin
* @author Deon George
* @copyright (c) 2010 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
class Controller_User_SSL extends Controller_TemplateDefault_User {
protected $secure_actions = array(
'download'=>FALSE,
);
public function action_download() {
$id = $_POST['sid'];
2012-11-09 23:13:57 +00:00
$so = ORM::factory('Service',$id);
2011-12-16 23:31:35 +00:00
if (! $so->loaded())
2012-11-09 23:13:57 +00:00
HTTP::redirect('welcome/index');
2011-12-16 23:31:35 +00:00
$passwd = $_POST['passwd'];
2012-11-09 23:13:57 +00:00
if (strlen($passwd) < Kohana::$config->load('ssl')->minpass_length) {
2011-12-16 23:31:35 +00:00
SystemMessage::add(array(
2012-08-01 12:43:33 +00:00
'title'=>_('Validation failed'),
2011-12-16 23:31:35 +00:00
'type'=>'error',
'body'=>_('Your requested password is too short.'),
));
2012-11-09 23:13:57 +00:00
HTTP::redirect('user/service/view/'.$so->id);
2011-12-16 23:31:35 +00:00
}
if (! $so->loaded() OR ! Auth::instance()->authorised($so->account_id,$so->affiliate_id)) {
$this->template->content = 'Unauthorised or doesnt exist?';
return FALSE;
}
2012-11-09 23:13:57 +00:00
$file = sprintf('%s/%s.pkcs12',Kohana::$config->load('config')->tmpdir,$so->name());
2011-12-16 23:31:35 +00:00
openssl_pkcs12_export_to_file($so->plugin()->cert,$file,$so->plugin()->pk,$passwd,array('extracerts'=>$so->plugin()->cacerts()));
$x = file_get_contents($file);
unlink($file);
$this->response->headers('Content-Type','application/pks12');
$this->response->headers('Content-Disposition','attachment; filename="'.basename($file).'"');
$this->response->body($x);
$this->auto_render = FALSE;
}
}
?>