projects
/
Pman.Core
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fix #8131 - chinese translations
[Pman.Core]
/
DataObjects
/
Core_setting.php
diff --git
a/DataObjects/Core_setting.php
b/DataObjects/Core_setting.php
index
34936e5
..
e1eea76
100644
(file)
--- a/
DataObjects/Core_setting.php
+++ b/
DataObjects/Core_setting.php
@@
-55,7
+55,11
@@
class Pman_Core_DataObjects_Core_setting extends DB_DataObject
function beforeInsert($q, $roo)
{
function beforeInsert($q, $roo)
{
- exit;
+ if (isset($q['is_encrypt'])) {
+ $roo->jerr("no direct access for setting encrypted data at present?");
+ }
+ // we store column data in here now - so it has to be insertable.
+ //exit;
}
function getKeyDirectory()
}
function getKeyDirectory()
@@
-85,16
+89,15
@@
class Pman_Core_DataObjects_Core_setting extends DB_DataObject
return;
}
return;
}
+ $this->initKeys();
+
$c = $this->lookup($a['module'], $a['name']);
$c = $this->lookup($a['module'], $a['name']);
- if($c) {
- return;
- }
- $
this->initKeys()
;
+ $
o = $c ? clone($c) : false
;
- $
s =
DB_DataObject::factory('core_setting');
+ $
c = $c ? $c :
DB_DataObject::factory('core_setting');
- $
s
->setFrom(array(
+ $
c
->setFrom(array(
'module' => $a['module'],
'name' => $a['name'],
'description' => $a['description'],
'module' => $a['module'],
'name' => $a['name'],
'description' => $a['description'],
@@
-104,7
+107,7
@@
class Pman_Core_DataObjects_Core_setting extends DB_DataObject
'is_valid' => 1
));
'is_valid' => 1
));
- $
s
->insert();
+ $
o ? $c->update($o) : $c
->insert();
}
//one key for encrypting all the settings
}
//one key for encrypting all the settings
@@
-113,49
+116,48
@@
class Pman_Core_DataObjects_Core_setting extends DB_DataObject
$key_dir = "{$this->getKeyDirectory()}/pub.key";
if(!file_exists($key_dir)) {
$key_dir = "{$this->getKeyDirectory()}/pub.key";
if(!file_exists($key_dir)) {
- print_r("Cannot find {$key_dir}");
- exit;
+ return false;
}
$pub_key = file_get_contents($key_dir);
if(!$pub_key) {
}
$pub_key = file_get_contents($key_dir);
if(!$pub_key) {
- return;
+ return
false
;
}
openssl_public_encrypt($v, $ciphertext, $pub_key);
return $ciphertext;
}
}
openssl_public_encrypt($v, $ciphertext, $pub_key);
return $ciphertext;
}
- function
getDecryptVal(
)
+ function
decrypt($v
)
{
{
- $
dir = $this->getKeyDirectory()
;
+ $
key_dir = "{$this->getKeyDirectory()}/pri.key"
;
- if(!
$dir
) {
+ if(!
file_exists($key_dir)
) {
return false;
}
return false;
}
- if(empty($this->val)) {
+ $pri_key = file_get_contents($key_dir);
+
+ if(!$pri_key) {
return false;
}
return false;
}
- if(empty($this->is_encrypt)) {
- return $this->val;
- }
+ openssl_private_decrypt($v, $plaintext, $pri_key);
- $key_dir = "{$dir}/pri.key";
+ return $plaintext;
+ }
+
+ function getDecryptVal()
+ {
- if(
!file_exists($key_dir
)) {
+ if(
empty($this->val
)) {
return false;
}
return false;
}
- $pri_key = file_get_contents($key_dir);
-
- if(!$pri_key) {
- return false;
+ if(empty($this->is_encrypt)) {
+ return $this->val;
}
}
- openssl_private_decrypt($this->val, $plaintext, $pri_key);
-
- return $plaintext;
+ return $this->decrypt($this->val);
}
}
}
}