-
Notifications
You must be signed in to change notification settings - Fork 72
/
configure.php
114 lines (98 loc) · 3.57 KB
/
configure.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<?php
/**
* Copyright 2010 Cyrille Mahieux
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and limitations
* under the License.
*
* ><)))°> ><)))°> ><)))°> ><)))°> ><)))°> ><)))°> ><)))°> ><)))°> ><)))°>
*
* Configuration
*
* @author [email protected]
* @since 06/04/2010
*/
# Require
require_once 'Library/Bootstrap.php';
# Initializing requests
$request = (isset($_REQUEST['request_write'])) ? $_REQUEST['request_write'] : null;
$write = null;
# Display by request type
switch ($request) {
# Unlock configuration file & temp directory
case 'unlock' :
# chmod 0755
chmod(Library_Configuration_Loader::path(), 0755);
chmod($_ini->get('file_path'), 0755);
break;
# Live stats configuration save
case 'live_stats' :
# Updating configuration
$_ini->set('refresh_rate', round(max(2, $_POST['refresh_rate'])));
$_ini->set('memory_alert', $_POST['memory_alert']);
$_ini->set('hit_rate_alert', $_POST['hit_rate_alert']);
$_ini->set('eviction_alert', $_POST['eviction_alert']);
$_ini->set('file_path', $_POST['file_path']);
# Writing configuration file
$write = Library_Configuration_Loader::singleton()->write();
break;
# Commands configuration save
case 'commands' :
# Updating configuration
$_ini->set('stats_api', $_POST['stats_api']);
$_ini->set('slabs_api', $_POST['slabs_api']);
$_ini->set('items_api', $_POST['items_api']);
$_ini->set('get_api', $_POST['get_api']);
$_ini->set('set_api', $_POST['set_api']);
$_ini->set('delete_api', $_POST['delete_api']);
$_ini->set('flush_all_api', $_POST['flush_all_api']);
# Writing configuration file
$write = Library_Configuration_Loader::singleton()->write();
break;
# Server configuration save
case 'servers' :
$array = array();
foreach ($_POST['server'] as $cluster => $servers) {
foreach ($servers as $data) {
$array[$_POST['cluster'][$cluster]][$data['name']] = $data;
unset($array[$_POST['cluster'][$cluster]][$data['name']]['name']);
}
}
# Sorting clusters
ksort($array);
foreach ($array as $cluster => $servers) {
# Sorting servers
ksort($servers);
$array[$cluster] = $servers;
}
# Updating configuration
$_ini->set('servers', $array);
# Writing configuration file
$write = Library_Configuration_Loader::singleton()->write();
break;
# Miscellaneous configuration save
case 'miscellaneous' :
# Updating configuration
$_ini->set('connection_timeout', $_POST['connection_timeout']);
$_ini->set('max_item_dump', $_POST['max_item_dump']);
# Writing configuration file
$write = Library_Configuration_Loader::singleton()->write();
break;
# Default : No command
default :
break;
}
# Showing header
include 'View/Header.phtml';
# Showing formulary
include 'View/Configure/Configure.phtml';
# Showing footer
include 'View/Footer.phtml';