+ $this->initKeys();
+
+ $c = $this->lookup($a['module'], $a['name']);
+
+ $o = $c ? clone($c) : false;
+
+ $c = $c ? $c : DB_DataObject::factory('core_setting');
+
+ $c->setFrom(array(
+ 'module' => $a['module'],
+ 'name' => $a['name'],
+ 'description' => $a['description'],
+ 'val' => (!isset($a['is_encrypt']) || $a['is_encrypt'] == 1) ?
+ $this->encrypt($a['val']) : $a['val'],
+ 'is_encrypt' => isset($a['is_encrypt']) ? $a['is_encrypt'] : 1,
+ 'is_valid' => 1
+ ));
+
+ $o ? $c->update($o) : $c->insert();
+ }
+
+ //one key for encrypting all the settings
+ function encrypt($v)
+ {
+ $key_dir = "{$this->getKeyDirectory()}/pub.key";
+
+ if(!file_exists($key_dir)) {
+ return false;