diff --git a/application/classes/lnapp/random.php b/application/classes/lnapp/random.php new file mode 100644 index 00000000..55403010 --- /dev/null +++ b/application/classes/lnapp/random.php @@ -0,0 +1,17 @@ + diff --git a/application/classes/random.php b/application/classes/random.php new file mode 100644 index 00000000..f4591d23 --- /dev/null +++ b/application/classes/random.php @@ -0,0 +1,4 @@ + diff --git a/modules/payment/classes/payment/bulk/ezypay.php b/modules/payment/classes/payment/bulk/ezypay.php index 474b8391..442611bd 100644 --- a/modules/payment/classes/payment/bulk/ezypay.php +++ b/modules/payment/classes/payment/bulk/ezypay.php @@ -28,7 +28,7 @@ class Payment_Bulk_Ezypay { // Process payment $file = file_get_contents($_FILES['payment']['tmp_name']); - $file = explode("\r\n",$file); + $file = preg_split("/[\r]?[\n]+/",$file); $i = 0; foreach ($file as $line) { @@ -55,7 +55,7 @@ class Payment_Bulk_Ezypay { } $file = file_get_contents($_FILES['transaction']['tmp_name']); - $file = explode("\r\n",$file); + $file = preg_split("/[\r]?[\n]+/",$file); $i = 0; foreach ($file as $line) { diff --git a/modules/ssl/classes/model/service/plugin/ssl.php b/modules/ssl/classes/model/service/plugin/ssl.php index 53faadf8..0f4e25bd 100644 --- a/modules/ssl/classes/model/service/plugin/ssl.php +++ b/modules/ssl/classes/model/service/plugin/ssl.php @@ -38,7 +38,26 @@ class Model_Service_Plugin_SSL extends Model_Service_Plugin { } public function name() { - return $this->display($this->cert ? 'cert' : 'csr'); + if ($this->cert) { + return sprintf('%s:%s',$this->ssl_ca->subject(),$this->display('cert')); + } else + return $this->display('csr'); + } + + public function algorithm() { + return SSL::algorithm($this->cert); + } + + public function dn() { + return SSL::dn($this->cert); + } + + public function dnissuer() { + return SSL::dnissuer($this->cert); + } + + public function issuer() { + return SSL::issuer($this->cert); } // @todo This needs to be validated for this model @@ -49,6 +68,10 @@ class Model_Service_Plugin_SSL extends Model_Service_Plugin { return $this->service->product->plugin(); } + public function details() { + return SSL::details($this->cert); + } + public function valid_from($format=FALSE) { return SSL::from($this->cert,$format); } @@ -132,6 +155,7 @@ class Model_Service_Plugin_SSL extends Model_Service_Plugin { $res = openssl_csr_sign($this->csr,$this->ssl_ca->sign_cert,$this->ssl_ca->sign_pk,$this->service->product->plugin()->days,array( 'config'=>$ssl_conf['config'], 'x509_extensions'=>$this->service->product->plugin()->extensions, + 'digest_alg'=>'sha1', ),time()); if ($res AND openssl_x509_export($res,$cert)) { diff --git a/modules/ssl/classes/ssl.php b/modules/ssl/classes/ssl.php index 55fa13ee..7a9345f9 100644 --- a/modules/ssl/classes/ssl.php +++ b/modules/ssl/classes/ssl.php @@ -15,43 +15,90 @@ class SSL { return new SSL; } - public static function details($key) { - return openssl_x509_parse($key); + public static function details($cert,$key=NULL) { + $k = openssl_x509_parse($cert); + + return is_null($key) ? $k : $k[$key]; } - public static function issuer($key) { - $k = static::details($key); - return $k['issuer']['CN']; + public static function algorithm($cert,$key=NULL) { + if (! $cert) + return ''; + + $r = openssl_x509_read($cert); + openssl_x509_export($r,$e,FALSE); + + // @todo There must be a nice way to get this? + if (preg_match('/^\s+Signature Algorithm:\s*(.*)\s*$/m',$e,$match)) + return $match[1]; + else + return _('Unknown'); } - public static function from($key,$format=FALSE) { - $k = static::details($key); - return $format ? Config::date($k['validFrom_time_t']) : $k['validFrom_time_t']; + public static function dn($cert) { + if (! $cert) + return ''; + + $s = ''; + + $c = 0; + foreach (static::details($cert,'subject') as $k=>$v) { + if ($c++) + $s .= ','; + + $s .= sprintf('%s=%s',$k,$v); + } + + return $s; + } + + public static function dnissuer($cert) { + if (! $cert) + return ''; + + $s = ''; + + $c = 0; + foreach (static::details($cert,'issuer') as $k=>$v) { + if ($c++) + $s .= ','; + + $s .= sprintf('%s=%s',$k,$v); + } + + return $s; + } + + public static function issuer($cert) { + $k = static::details($cert,'issuer'); + return $k['CN']; + } + + public static function from($cert,$format=FALSE) { + $k = static::details($cert,'validFrom_time_t'); + return $format ? Config::date($k) : $k; } public static function expire($key,$format=FALSE) { - $k = static::details($key); - return $format ? Config::date($k['validTo_time_t']) : $k['validTo_time_t']; + $k = static::details($key,'validTo_time_t'); + return $format ? Config::date($k) : $k; } public static function hash($key) { - $k = static::details($key); - return $k['hash']; + return static::details($key,'hash'); } public static function serial($key) { - $k = static::details($key); - return $k['serialNumber']; + return static::details($key,'serialNumber'); } public static function subject($key) { - $k = static::details($key); - return $k['subject']['CN']; + $k = static::details($key,'subject'); + return $k['CN']; } public static function version($key) { - $k = static::details($key); - return $k['version']; + return static::details($key,'version'); } public static function csrsubject($csr) { diff --git a/modules/ssl/views/service/user/plugin/ssl/view.php b/modules/ssl/views/service/user/plugin/ssl/view.php index 5912fef9..15e639d7 100644 --- a/modules/ssl/views/service/user/plugin/ssl/view.php +++ b/modules/ssl/views/service/user/plugin/ssl/view.php @@ -10,8 +10,16 @@ - - + + + + + + + + + + @@ -33,6 +41,10 @@ + + + + diff --git a/modules/ssl/views/ssl/admin/add_view.php b/modules/ssl/views/ssl/admin/add_view.php index 31c30468..a0591254 100644 --- a/modules/ssl/views/ssl/admin/add_view.php +++ b/modules/ssl/views/ssl/admin/add_view.php @@ -27,6 +27,10 @@ + + + +
Service Namedisplay('csr'); ?>Subjectdn(); ?>
Issuerdnissuer(); ?>
CAssl_ca->subject(); ?>
Valid FromHash hash(); ?>
Algorithmalgorithm(); ?>
Certificate
cert; ?>
Version sign_cert); ?>
Key Algorithmsign_cert); ?>
Private Key sign_pk,array('cols'=>64,'rows'=>13)); ?>