Misc fixes from live

This commit is contained in:
Deon George 2015-09-29 11:54:45 +10:00
parent df74512105
commit 425ea9ff10
10 changed files with 80 additions and 35 deletions

View File

@ -26,6 +26,8 @@ abstract class ORM extends lnApp_ORM {
$this->where($this->_object_name.'.site_id','=',Company::instance()->site()); $this->where($this->_object_name.'.site_id','=',Company::instance()->site());
// Ensure we Cache our queries // Ensure we Cache our queries
// @todo: Disabled as it is not working as expected
/*
$caching = FALSE; $caching = FALSE;
foreach ($this->_db_pending as $method) foreach ($this->_db_pending as $method)
if ($method['name'] == 'cached') { if ($method['name'] == 'cached') {
@ -35,6 +37,7 @@ abstract class ORM extends lnApp_ORM {
if (! $caching) if (! $caching)
$this->cached(Kohana::$config->load('cache.orm.'.$this->_table_name)); $this->cached(Kohana::$config->load('cache.orm.'.$this->_table_name));
*/
return parent::_build($type); return parent::_build($type);
} }

View File

@ -128,7 +128,7 @@ class ADSL_Billing_Exetelvisp {
list($service,$description) = explode(':',(preg_replace('/([0-9]+)\s+-\s+(.*)$/',"$1:$2",$record[3]))); list($service,$description) = explode(':',(preg_replace('/([0-9]+)\s+-\s+(.*)$/',"$1:$2",$record[3])));
$result[$service]['credit'] = str_replace('$','',$record[6]); $result[$service]['credit'] = str_replace('$','',$record[6]);
} elseif (preg_match('/Excess usage charges for /',$record[3])) { } elseif (preg_match('/Excess usage charges/',$record[3])) {
list($service,$description) = explode(':',(preg_replace('/([0-9]+)\s+-\s+(.*)$/',"$1:$2",$record[3]))); list($service,$description) = explode(':',(preg_replace('/([0-9]+)\s+-\s+(.*)$/',"$1:$2",$record[3])));
$result[$service]['excess'] = str_replace('$','',$record[7]); $result[$service]['excess'] = str_replace('$','',$record[7]);

View File

@ -19,6 +19,10 @@ class Model_Charge extends ORM_OSB implements Invoicable {
'invoice_item'=>array('far_key'=>'id'), 'invoice_item'=>array('far_key'=>'id'),
); );
protected $_compress_column = array(
'attributes',
);
protected $_nullifempty = array( protected $_nullifempty = array(
'attributes', 'attributes',
); );

View File

@ -27,6 +27,8 @@
<dd><?php echo HTML::anchor($o->registrar->whitelabel_url,NULL); ?></dd> <dd><?php echo HTML::anchor($o->registrar->whitelabel_url,NULL); ?></dd>
<dt>Username</dt> <dt>Username</dt>
<dd><?php echo $o->registrar_username; ?></dd> <dd><?php echo $o->registrar_username; ?></dd>
<dt>Password</dt>
<dd><?php echo $o->registrar_password; ?></dd>
<?php endif ?> <?php endif ?>
</div> <!-- dl-horizontal --> </div> <!-- dl-horizontal -->
</fieldset> </fieldset>

View File

@ -19,6 +19,8 @@
<dd><?php echo HTML::anchor($o->host->whitelabel_url,NULL); ?></dd> <dd><?php echo HTML::anchor($o->host->whitelabel_url,NULL); ?></dd>
<dt>Username</dt> <dt>Username</dt>
<dd><?php echo $o->host_username; ?></dd> <dd><?php echo $o->host_username; ?></dd>
<dt>Password</dt>
<dd><?php echo $o->host_password; ?></dd>
<?php endif ?> <?php endif ?>
</div> <!-- dl-horizontal --> </div> <!-- dl-horizontal -->
</fieldset> </fieldset>

View File

@ -222,9 +222,10 @@ class Model_Invoice extends ORM_OSB implements Cartable {
* Check the reminder value * Check the reminder value
*/ */
public function remind($key) { public function remind($key) {
if (isset($this->reminders[$key])) if (isset($this->reminders[$key])) {
return (is_array($this->reminders[$key])) ? end($this->reminders[$key]) : $this->reminders[$key]; $x = $this->reminders[$key];
else return is_array($x) ? end($x) : $x;
} else
return FALSE; return FALSE;
} }

View File

@ -20,12 +20,16 @@ class Controller_Reseller_SSL extends Controller_SSL {
); );
public function action_list() { public function action_list() {
$o = ORM::factory('SSL_CA')->where_authorised($this->ao);
if ($this->request->param('id') != 'Y')
$o->where_active();
Block::factory() Block::factory()
->title('SSL CA Certificates') ->title('SSL CA Certificates')
->title_icon('icon-th-list') ->title_icon('icon-th-list')
->body(Table::factory() ->body(Table::factory()
->jssort('ca') ->jssort('ca')
->data(ORM::factory('SSL_CA')->where_authorised($this->ao)->where_active()->find_all()) ->data($o->find_all())
->columns(array( ->columns(array(
'id'=>'ID', 'id'=>'ID',
'sign_cert'=>'Cert', 'sign_cert'=>'Cert',

View File

@ -56,8 +56,12 @@ class Model_Service_Plugin_Ssl extends Model_Service_Plugin {
public function __call($name,$args) { public function __call($name,$args) {
$m = 'get_'.$name; $m = 'get_'.$name;
if (method_exists($this->_so,$m)) if ($this->isCSR() AND method_exists($this,$m))
return $this->{$m}($args);
elseif (method_exists($this->_so,$m))
return $this->_so->{$m}($args); return $this->_so->{$m}($args);
else else
throw new Kohana_Exception('Unknown method :method',array(':method'=>$name)); throw new Kohana_Exception('Unknown method :method',array(':method'=>$name));
} }
@ -72,6 +76,13 @@ class Model_Service_Plugin_Ssl extends Model_Service_Plugin {
return $this; return $this;
} }
/**
* Is this just a CSR?
*/
public function isCSR() {
return ! $this->cert AND $this->csr;
}
/** /**
* Return all our CA Certs for this certificate * Return all our CA Certs for this certificate
*/ */
@ -103,16 +114,32 @@ class Model_Service_Plugin_Ssl extends Model_Service_Plugin {
return $output; return $output;
} }
public function get_dn() {
return SSL::csrsubject($this->csr);
}
public function get_valid_to() {
// @todo
return 'Unknown';
}
/** /**
* Renew an SSL Certificate * Renew an SSL Certificate
*/ */
// @todo: Renew renews the expiry date as 1 day too early.
public function renew($force=FALSE) { public function renew($force=FALSE) {
$sslo = SSL::instance($this->cert);
$ssl_conf = Kohana::$config->load('ssl'); $ssl_conf = Kohana::$config->load('ssl');
// If our certificate is not old enough skip if ($this->cert) {
if ($sslo->get_valid_to() > time()+$ssl_conf['min_renew_days']*86400 AND ! $force) $sslo = SSL::instance($this->cert);
return FALSE;
// If our certificate is not old enough skip
if ($sslo->get_valid_to() > time()+$ssl_conf['min_renew_days']*86400 AND ! $force)
return FALSE;
} elseif (! $this->csr) {
throw new Kohana_Exception('Unable to renew, no CERT or CSR');
}
$today = mktime(0,0,0,date('n'),date('j'),date('Y')); $today = mktime(0,0,0,date('n'),date('j'),date('Y'));
$days = (int)(($this->service->invoiced_to()-$today)/86400); $days = (int)(($this->service->invoiced_to()-$today)/86400);

View File

@ -28,7 +28,7 @@ class SSL {
private static function _dec_to_hex($number) { private static function _dec_to_hex($number) {
$hex = array(); $hex = array();
if ($number == 0) if ($number == 0 OR ! $number)
return '00'; return '00';
while ($number > 0) { while ($number > 0) {

View File

@ -6,38 +6,40 @@
<dt>DN</dt> <dt>DN</dt>
<dd><?php echo $o->dn(); ?></dd> <dd><?php echo $o->dn(); ?></dd>
<dt>Serial Number</dt> <?php if (! $o->isCSR()) : ?>
<dd><?php echo $o->serial(); ?></dd> <dt>Serial Number</dt>
<dd><?php echo $o->serial(); ?></dd>
<dt>Subject Key Id</dt> <dt>Subject Key Id</dt>
<dd><?php echo $o->ski(); ?></dd> <dd><?php echo $o->ski(); ?></dd>
<dt>Issuer</dt> <dt>Issuer</dt>
<dd> <dd>
<?php if ($o->validCA() AND $o->authorised($o->ca)) : ?> <?php if ($o->validCA() AND $o->authorised($o->ca)) : ?>
<?php echo HTML::anchor(URL::link('reseller','ssl/edit/').$o->ca->id,$o->issuer()); ?> <?php echo HTML::anchor(URL::link('reseller','ssl/edit/').$o->ca->id,$o->issuer()); ?>
<?php else : ?> <?php else : ?>
<?php echo $o->issuer(); ?> <?php echo $o->issuer(); ?>
<?php endif ?> <?php endif ?>
</dd> </dd>
<dt>Issuer Serial</dt> <dt>Issuer Serial</dt>
<dd><?php printf('%s (%s)',$o->aki_keyid(), $o->aki_serial()); ?></dd> <dd><?php printf('%s (%s)',$o->aki_keyid(), $o->aki_serial()); ?></dd>
<dt>Valid From</dt> <dt>Valid From</dt>
<dd><?php echo $o->valid_from(TRUE); ?></dd> <dd><?php echo $o->valid_from(TRUE); ?></dd>
<dt>Valid To</dt> <dt>Valid To</dt>
<dd><?php echo $o->valid_to(TRUE); ?></dd> <dd><?php echo $o->valid_to(TRUE); ?></dd>
<dt>Hash</dt> <dt>Hash</dt>
<dd><?php echo $o->hash(); ?></dd> <dd><?php echo $o->hash(); ?></dd>
<dt>Version</dt> <dt>Version</dt>
<dd><?php echo $o->version(); ?></dd> <dd><?php echo $o->version(); ?></dd>
<dt>Algorithm</dt> <dt>Algorithm</dt>
<dd><?php echo $o->algorithm(); ?></dd> <dd><?php echo $o->algorithm(); ?></dd>
<?php endif ?>
</div> <!-- dl-horizontal --> </div> <!-- dl-horizontal -->
</fieldset> </fieldset>