Mid-development commit so I can continue at home

8.0.x
Greg Dunlap 2011-09-14 16:32:07 +02:00
parent 8e78061b44
commit 2b0a6d778a
2 changed files with 18 additions and 11 deletions

View File

@ -6,6 +6,13 @@ $_SERVER['REMOTE_ADDR'] = '127.0.0.1';
include_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
$config = config('foo.bar');
$config->foo = 'bar';
$config->save();
echo config('foo.bar')->foo;
echo '<br>That should be bar';
die();
config_write_signed_file_storage_key();
//echo config_sign_data('onetwothree');
$sfs = new SignedFileStorage('one.two');
@ -22,15 +29,9 @@ $sfs->resign();
echo $sfs->read() . PHP_EOL;
// Fail
////file_put_contents($sfs->getFilePath(), $existing_content . 'extra');
//echo $sfs->read() . PHP_EOL;
print_r(get_signed_file_storage_names_with_prefix());
file_put_contents($sfs->getFilePath(), $existing_content . 'extra');
echo $sfs->read() . PHP_EOL;
print_r(config_get_signed_file_storage_names_with_prefix());
print '<hr>';
$config = config('foo.bar');
$config->foo = 'bar';
$config->save();
echo config('foo.bar')->foo;
echo '<br>That should be bar';

View File

@ -141,6 +141,7 @@ class SignedFileStorage {
public function verify($contentOnSuccess = FALSE) {
if ($this->exists()) {
$split = $this->readWithSignature();
print_r($split);
$expected_signature = config_sign_data($split['data']);
if ($expected_signature === $split['signature']) {
if ($contentOnSuccess) {
@ -307,6 +308,11 @@ function config($name, $class = 'DrupalConfig') {
* An associative array representation of the data.
*/
function config_decode($data) {
if (empty($data)) {
return array();
}
print_r(debug_backtrace());
print $data;
$xml = new SimpleXMLElement($data);
$json = json_encode($xml);
return json_decode($json);
@ -337,6 +343,7 @@ function config_encode($data) {
* format.
*/
function config_array_to_xml($arr, $tab_count = 0) {
$xml = '<?xml version="1.0" encoding="UTF8"?>' . PHP_EOL . '<data>';
foreach ($arr as $tag => $val) {
if (!is_array($val)) {
$xml .= PHP_EOL . '<' . $tag . '>' . htmlentities($val) . '</' . $tag . '>';
@ -346,7 +353,7 @@ function config_array_to_xml($arr, $tab_count = 0) {
$xml .= PHP_EOL . '</' . $tag . '>';
}
}
$xml .= PHP_EOL . '</data>';
return $xml;
}
@ -382,7 +389,6 @@ class DrupalConfig {
$obj->$key = $val;
}
}
$this->_verifiedStorage->write(config_encode($obj));
}
}