function initKeys()
{
- $d = HTML_FlexyFramework::get()->Pman['storedir'].'/key';
-
+ $dir = $this->keyDir();
if(
- file_exists("{$d}/pub.key") ||
- file_exists("{$d}/pri.key")
+ file_exists("{$dir}/pub.key") ||
+ file_exists("{$dir}/pri.key")
){
return;
}
$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');
return;
}
- function initSetting($a, $dir)
+ 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) || empty($dir)) {
+ if(empty($a)) {
return;
}
return;
}
- //$ff->pman['storedir']/key generic for all projects?
-
- $this->setStoreDir($dir);
-
$this->initKeys();
$val = $a['val'];
$s = DB_DataObject::factory('core_setting');
$s->setFrom(array(
- 'module' => $a['module'],
- 'name' => $a['name'],
- 'description' => $a['description'],
+ 'module' => $a['module'],
+ 'name' => $a['name'],
+ 'description' => $a['description'],
'val' =>$val,
'is_encrypt' => isset($a['is_encrypt']) ? $a['is_encrypt'] : 1
));
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;
}
openssl_public_encrypt($v, $cipher, $pub_key);
return $cipher;
}
-
- function setStoreDir($dir)
- {
- if(!file_exists($dir)) {
- $oldumask = umask(0);
- mkdir($dir, 0775, true);
- umask($oldumask);
- }
- $this->storedir = $dir;
- }
}