forked from wp-cloud/phpmemcacheadmin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.php
119 lines (99 loc) · 3.34 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
115
116
117
118
119
<?php
/**
* @author Cyrille Mahieux <elijaa(at)free.fr>
* @copyright Copyright (c) 2010-2015, Cyrille Mahieux
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache-2.0
* @package phpMemcachedAdmin
*/
/**
* Configuration
*
* @since 06/04/2010
*/
# Headers
header('Content-type: text/html;');
header('Cache-Control: no-cache, must-revalidate');
# Require
require_once 'Library/Loader.php';
# Date timezone
date_default_timezone_set('Europe/Paris');
# Loading ini file
$_ini = Library_Configuration_Loader::singleton();
# Initializing requests
$request = (isset($_GET['request_write'])) ? $_GET['request_write'] : null;
$write = null;
# Display by request rype
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';