static function register($table, $key, $value = "") { // create the global config object if not available if (!array_key_exists('config', $GLOBALS)) { $GLOBALS['config'] = array(); } // exit now if variable already available $key_exists = array_key_exists($table, $GLOBALS['config']) && array_key_exists($key, $GLOBALS['config'][$table]) && !(empty($GLOBALS['config'][$table][$key]) && is_null($GLOBALS['config'][$table][$key])); if ($key_exists) { return; } // then check if the table exists if (empty($GLOBALS['config'][$table])) { $config = new Config(0, $table); // FIX: The id needs to be setup as autoincrement //$config->create_table($table, "id INTEGER PRIMARY KEY ASC," . implode(",", array_keys( $config->rs )) ); $config->create_table($table, "id INTEGER PRIMARY KEY ASC, key, value"); $GLOBALS['config'][$table] = array(); } // we already know the key doesn't exist - just create it $config = new Config(0, $table); $config->set('key', "{$key}"); // FIX: special case for admin password (use cipher if available) $cipher = is_null(CIPHER) ? $value : CIPHER; $value = $key == "admin_password" ? crypt($value, $cipher) : $value; $config->set('value', "{$value}"); $config->create(); // save in the global object $GLOBALS['config'][$table][$key] = $value; }