3 class_exists('DB_DataObject') ? '' : require_once 'DB/DataObject.php';
5 class Pman_Core_DataObjects_Core_setting extends DB_DataObject
7 public $__table = 'core_setting';
9 function initKeys($dir)
12 file_exists("{$dir}/pub.key") ||
13 file_exists("{$dir}/pri.key")
18 $ssl = openssl_pkey_new(array(
19 "digest_alg" => "sha512",
20 "private_key_bits" => 1024, //returns cipher in 128 char
21 "private_key_type" => OPENSSL_KEYTYPE_RSA
24 openssl_pkey_export($ssl, $pri_key);
25 $pub_key = openssl_pkey_get_details($ssl);
26 $pub_key = $pub_key["key"];
28 file_put_contents("{$dir}/pub.key",$pub_key);
29 file_put_contents("{$dir}/pri.key",$pri_key);
32 function getSetting($m,$n)
34 $s = DB_DataObject::factory('core_setting');
36 'module' => $q['module'],
45 function beforeInsert($q, $roo)
52 function initSetting($a, $dir)
54 if(empty($a) || empty($dir)) {
58 $c = $this->getSetting($a['module'], $a['name']);
63 //$ff->pman['storedir']/key generic for all projects?
64 $this->setStoreDir($dir);
69 if(!isset($a['is_encrypt']) || $a['is_encrypt'] == 1) {
73 $s = DB_DataObject::factory('core_setting');
75 'module' => $a['module'],
77 'description' => $a['description'],
79 'is_encrypt' => isset($a['is_encrypt']) ? $a['is_encrypt'] : 1
87 $pub_key = file_get_contents("{$this->storedir}/pub.key");
91 openssl_public_encrypt($v, $cipher, $pub_key);
95 function setStoreDir($dir)
97 if(!file_exists($dir)) {
100 $this->storedir = $dir;