X-Git-Url: http://git.roojs.org/?a=blobdiff_plain;f=DataObjects%2FCore_setting.php;h=b0b0c6d6f31a443fab4249f8096549463b9fa21f;hb=fcbcbde31635a0e7bb9e9aa7f0750de8cec7503f;hp=cab7b95c6561890416a38ed3c48f468e57be0ceb;hpb=80ea68e91a22fbeb74d95b568e0511aac12686e5;p=Pman.Core diff --git a/DataObjects/Core_setting.php b/DataObjects/Core_setting.php index cab7b95c..b0b0c6d6 100644 --- a/DataObjects/Core_setting.php +++ b/DataObjects/Core_setting.php @@ -8,11 +8,10 @@ class Pman_Core_DataObjects_Core_setting extends DB_DataObject function initKeys() { - $d = HTML_FlexyFramework::get()->Pman['storedir'].'/key'; - + $dir = $this->getkeyDirectory(); if( - file_exists("{$d}/pub.key") || - file_exists("{$d}/pri.key") + file_exists("{$dir}/pub.key") || + file_exists("{$dir}/pri.key") ){ return; } @@ -27,10 +26,12 @@ class Pman_Core_DataObjects_Core_setting extends DB_DataObject $pub_key = openssl_pkey_get_details($ssl); $pub_key = $pub_key["key"]; - file_put_contents("{$d}/pub.key",$pub_key); - file_put_contents("{$d}/pri.key",$pri_key); + file_put_contents("{$dir}/pub.key",$pub_key); + file_put_contents("{$dir}/pri.key",$pri_key); } + //FIXME - rename to lookup + function getSetting($m,$n) { $s = DB_DataObject::factory('core_setting'); @@ -46,11 +47,25 @@ class Pman_Core_DataObjects_Core_setting extends DB_DataObject function beforeInsert($q, $roo) { + print_r($q); exit; return; } + function getkeyDirectory() + { + $d = HTML_FlexyFramework::get()->Pman['storedir'].'/key'; + if(!file_exists($d)) { + $oldumask = umask(0); + mkdir($d, 0775, true); + umask($oldumask); + } + return $d; + } + + // FIXME - this needs to go in beforeInsert/beforeUpdate + // should not be sending this the values.. function initSetting($a) { if(empty($a)) { @@ -62,32 +77,26 @@ class Pman_Core_DataObjects_Core_setting extends DB_DataObject return; } - $d = HTML_FlexyFramework::get()->Pman['storedir'].'/key'; - - $this->setStoreDir($dir); - $this->initKeys(); - $val = $a['val']; - if(!isset($a['is_encrypt']) || $a['is_encrypt'] == 1) { - $val = $this->encrypt($val); - } - $s = DB_DataObject::factory('core_setting'); $s->setFrom(array( - 'module' => $a['module'], - 'name' => $a['name'], - 'description' => $a['description'], - 'val' =>$val, + 'module' => $a['module'], + 'name' => $a['name'], + 'description' => $a['description'], + 'val' => (!isset($a['is_encrypt']) || $a['is_encrypt'] == 1) ? + $this->encrypt($val) : $val, 'is_encrypt' => isset($a['is_encrypt']) ? $a['is_encrypt'] : 1 )); + $s->beforeInsert(); + $s->insert(); } function encrypt($v) { - $pub_key = file_get_contents("{$this->storedir}/pub.key"); + $pub_key = file_get_contents("{$this->getkeyDirectory()}/pub.key"); if(!$pub_key) { return; }