Permalink
Browse files

git-svn-id: svn://cherokee-project.com/cherokee/trunk@313 5dc97367-97…

…f1-0310-9951-d761b3857238
  • Loading branch information...
1 parent 0d0f76b commit b7f7d10b7c0a2ac9400e9cd089c8010157425728 @alobbs alobbs committed Jun 25, 2006
View
@@ -1,18 +1,19 @@
## Cherokee: cherokee/Makefile.am -*- makefile -*-
cherokeeadmindir = "$(prefix)/share/cherokee/admin/"
-cherokeeadmin_DATA = \
-index.php \
-common.php \
-config_node.php \
-server.php \
-page.php \
-page_index.php \
-page_debug.php \
-widget.php \
-widget_debug.php \
-widget_prop_table.php \
-theme.php \
+cherokeeadmin_DATA = \
+index.php \
+common.php \
+config_node.php \
+server.php \
+page.php \
+page_index.php \
+page_debug.php \
+widget.php \
+widget_debug.php \
+widget_prop_table.php \
+widget_vsrvs_table.php \
+theme.php \
check.php
EXTRA_DIST = \
View
@@ -25,7 +25,8 @@
require_once ('common.php');
-function check_is_int ($i) {
+function check_is_int ($i)
+{
if (!is_numeric ($i))
return 'Non numeric';
@@ -39,7 +40,8 @@ function check_is_int ($i) {
return NULL;
}
-function fix_bool ($b) {
+function fix_bool ($b)
+{
$lb = strtolower($b);
if (($lb == 'on') || ($lb == 'true'))
@@ -51,7 +53,8 @@ function fix_bool ($b) {
return (int)$b;
}
-function check_is_bool ($b) {
+function check_is_bool ($b)
+{
$lb = strtolower($b);
if (($lb == 'on') or ($lb == 'true') or
@@ -64,7 +67,8 @@ function check_is_bool ($b) {
return "Wrong value";
}
-function check_is_ipv4 ($ip) {
+function check_is_ipv4 ($ip)
+{
$oct = explode('.', $ip);
if (count($oct) != 4) {
return "Bad formated";
@@ -83,19 +87,22 @@ function check_is_ipv4 ($ip) {
return NULL;
}
-function check_is_ipv6 ($ip) {
+function check_is_ipv6 ($ip)
+{
return NULL;
}
-function check_is_ip ($ip) {
+function check_is_ip ($ip)
+{
$colon = strchr ($ip, ':');
if ($colon != FALSE)
return check_is_ipv6($ip);
return check_is_ipv4($ip);
}
-function check_is_path ($path) {
+function check_is_path ($path)
+{
if (is_windows()) {
// TODO
return "Windows: unsupported";
@@ -107,4 +114,25 @@ function check_is_path ($path) {
return NULL;
}
+function check_nil ($param)
+{
+ return NULL;
+}
+
+function check_file_list ($l)
+{
+ if (empty($l))
+ return NULL;
+
+ $parts = preg_split ('/ *\, */', $l);
+
+ foreach ($parts as $part) {
+ $re = preg_match ('/[a-zA-Z0-9\.\_\-]+/', $part);
+ if (!$re)
+ return "Invalid: ".$part;
+ }
+
+ return NULL;
+}
+
?>
View
@@ -31,40 +31,53 @@ function ConfigNode() {
$this->value = NULL;
}
- function ParseLine ($line) {
- /* Split left and right sides
- */
- list($left, $right) = explode(' = ', $line);
+ function &_CreatePath ($path) {
+ $subconf =& $this;
- /* Get the first element
- */
- $sep = strchr ($left, '!');
+ for (;;) {
+ /* Get the first element
+ */
+ $sep = strchr ($path, '!');
- /* Intermediate node
- */
- if (empty($sep)) {
- $first = $left;
- $rest = '';
- } else {
- $first = substr ($left, 0, strlen($left) - strlen($sep));
- $rest = substr ($line, strlen($first) + 1, strlen($line)-(strlen($first)+1));
+ /* Intermediate node
+ */
+ if (empty($sep)) {
+ $first = $path;
+ $rest = '';
+ } else {
+ $first = substr ($path, 0, strlen($path) - strlen($sep));
+ $rest = substr ($path, strlen($first) + 1, strlen($path)-(strlen($first)+1));
+ }
+
+ /* Create a new node
+ */
+ if (! array_key_exists ($first, $subconf->child)) {
+ $subconf->child[$first] =& new ConfigNode;
+ }
+
+ $child =& $subconf->child;
+ $subconf =& $child[$first];
+
+ if (empty($rest))
+ return $subconf;
+
+ $path = $rest;
}
+ }
- /* Create a new node
+ function ParseLine ($line) {
+ /* Split left and right sides
*/
- if (! array_key_exists ($first, $this->child)) {
- $this->child[$first] =& new ConfigNode;
- }
+ list($left, $right) = explode(' = ', $line);
- $child =& $this->child;
- $subconf =& $child[$first];
+ $subconf = $this->_CreatePath ($left);
+ if ($subconf == NULL) return ret_error;
- /* Configure it
+ /* Assign the value
*/
- if (! empty($rest))
- $subconf->ParseLine ($rest);
- else
+ if (!empty ($right)) {
$subconf->value = $right;
+ }
return ret_ok;
}
@@ -234,13 +247,31 @@ function FindValue ($path)
return $re->value;
}
- function SetValue ($path, $value, $create=0)
+ function AddPath ($path) {
+ $this->_CreatePath ($path);
+ }
+
+ function SetValue ($path, $value, $create=false)
{
+ /* Look for the entry
+ */
$entry =& $this->Find ($path);
-
- if ($entry == NULL)
- return "Node not found";
+ if ($entry == NULL) {
+ /* There is no such element
+ */
+ if (! $create)
+ return "Node not found: ".$path;
+
+ /* Add a new config node
+ */
+ $entry = $this->_CreatePath ($path);
+ if ($entry == NULL)
+ return "Could not create: ".$path;
+ }
+
+ /* Fill it out
+ */
$entry->value = $value;
return NULL;
}
View
@@ -27,6 +27,7 @@
require_once ('config_node.php');
require_once ('page_index.php');
require_once ('page_debug.php');
+require_once ('page_vserver.php');
function &read_configuration () {
@@ -46,18 +47,28 @@ function &instance_page (&$theme, &$conf) {
$params = $_REQUEST;
unset ($params['page']);
+ $ajax = $params['ajax'];
switch ($name) {
- case 'debug':
- $page =& new PageDebug(&$theme, $conf, $params);
- break;
case 'restart':
$server =& new Server ($conf);
$conf->Save (cherokee_default_config_file);
$server->SendHUP();
break;
+
+ case 'debug':
+ $page =& new PageDebug(&$theme, $conf, $params);
+ break;
+
+ case 'vserver':
+ if (!empty($ajax))
+ $page =& new PageVserverAjax ($conf, $params);
+ else
+ $page =& new PageVServer(&$theme, $conf, $params);
+ break;
+
default:
- if (!empty($params['ajax']))
+ if (!empty($ajax))
$page =& new PageIndexAjax ($conf, $params);
else
$page =& new PageIndex ($theme, $conf, $params);
Oops, something went wrong.

0 comments on commit b7f7d10

Please sign in to comment.