diff --git a/Config/Memcache.sample.php b/Config/Memcache.sample.php deleted file mode 100644 index a22615f..0000000 --- a/Config/Memcache.sample.php +++ /dev/null @@ -1,43 +0,0 @@ - 'Server', - 'slabs_api' => 'Server', - 'items_api' => 'Server', - 'get_api' => 'Server', - 'set_api' => 'Server', - 'delete_api' => 'Server', - 'flush_all_api' => 'Server', - 'connection_timeout' => '1', - 'max_item_dump' => '100', - 'refresh_rate' => 2, - 'memory_alert' => '80', - 'hit_rate_alert' => '90', - 'eviction_alert' => '0', - 'file_path' => 'Temp/', - 'servers' => - array ( - 'Default' => - array ( - '127.0.0.1:11211' => - array ( - 'hostname' => '127.0.0.1', - 'port' => '11211', - ), - '127.0.0.2:11211' => - array ( - 'hostname' => '127.0.0.2', - 'port' => '11211', - ), - '127.0.0.3:11211' => - array ( - 'hostname' => '127.0.0.1', - 'port' => '11211', - ), - '127.0.0.4:11211' => - array ( - 'hostname' => '127.0.0.1', - 'port' => '11211', - ), - ), - ), -); \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..6a4c478 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,4 @@ +FROM php:7.0-apache +COPY config/php.ini /usr/local/etc/php/ +COPY src/ /var/www/html/ +RUN chown -R www-data /var/www/html/Config /var/www/html/Temp diff --git a/config/php.ini b/config/php.ini new file mode 100644 index 0000000..8168d87 --- /dev/null +++ b/config/php.ini @@ -0,0 +1,82 @@ +[PHP] +engine = On +short_open_tag = Off +precision = 14 +output_buffering = 4096 +zlib.output_compression = Off +implicit_flush = Off +unserialize_callback_func = +serialize_precision = -1 +disable_functions = +disable_classes = +zend.enable_gc = On +expose_php = On +max_execution_time = 30 +max_input_time = 60 +memory_limit = 128M +error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT +;display_errors = Off +display_errors = On +display_startup_errors = Off +log_errors = On +log_errors_max_len = 1024 +ignore_repeated_errors = Off +ignore_repeated_source = Off +report_memleaks = On +html_errors = Off +error_log = /dev/null +variables_order = "GPCS" +request_order = "GP" +register_argc_argv = Off +auto_globals_jit = On +post_max_size = 8M +auto_prepend_file = +auto_append_file = +default_mimetype = "text/html" +default_charset = "UTF-8" +doc_root = +user_dir = +enable_dl = Off +file_uploads = On +upload_max_filesize = 2M +max_file_uploads = 20 +allow_url_fopen = On +allow_url_include = Off +default_socket_timeout = 60 +[CLI Server] +cli_server.color = On +[bcmath] +bcmath.scale = 0 +[Session] +session.save_handler = files +session.use_strict_mode = 0 +session.use_cookies = 1 +session.use_only_cookies = 1 +session.name = PHPMEMCACHEDADMIN +session.auto_start = 0 +session.cookie_lifetime = 0 +session.cookie_path = / +session.cookie_domain = +session.cookie_httponly = +session.serialize_handler = php +session.gc_probability = 1 +session.gc_divisor = 1000 +session.gc_maxlifetime = 1440 +session.referer_check = +session.cache_limiter = nocache +session.cache_expire = 180 +session.use_trans_sid = 0 +session.sid_length = 26 +session.trans_sid_tags = "a=href,area=href,frame=src,form=" +session.sid_bits_per_character = 5 +[Assertion] +zend.assertions = -1 +[Tidy] +tidy.clean_output = Off +[soap] +soap.wsdl_cache_enabled=1 +soap.wsdl_cache_dir="/tmp" +soap.wsdl_cache_ttl=86400 +soap.wsdl_cache_limit = 5 +[ldap] +ldap.max_links = -1 diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..60b2ea8 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,23 @@ +version: '2' +services: + phpmemcachedadmin: + build: . + ports: + - "8000:80" + links: + - memcached + environment: + - MEMCACHED_GROUPS=2 + - MEMCACHED_GROUP_0_NAME=docker + - MEMCACHED_GROUP_0_HOST_COUNT=1 + - MEMCACHED_GROUP_0_HOST_0=memcached + - MEMCACHED_GROUP_0_PORT_0=11211 + - MEMCACHED_GROUP_1_NAME=cluster + - MEMCACHED_GROUP_1_HOST_COUNT=2 + - MEMCACHED_GROUP_1_HOST_0=memcached01 + - MEMCACHED_GROUP_1_PORT_0=11211 + - MEMCACHED_GROUP_1_HOST_1=memcached02 + - MEMCACHED_GROUP_1_PORT_1=11211 + + memcached: + image: memcached:alpine diff --git a/src/Config/Memcache.php b/src/Config/Memcache.php new file mode 100644 index 0000000..491aa48 --- /dev/null +++ b/src/Config/Memcache.php @@ -0,0 +1,71 @@ + $hostname, + 'port' => $port, + ]; + $j++; + } + $i++; + } +} else { + $servers = + [ + 'Default' => + [ + '127.0.0.1:11211' => + [ + 'hostname' => '127.0.0.1', + 'port' => '11211', + ], + '127.0.0.2:11211' => + [ + 'hostname' => '127.0.0.2', + 'port' => '11211', + ], + '127.0.0.3:11211' => + [ + 'hostname' => '127.0.0.1', + 'port' => '11211', + ], + '127.0.0.4:11211' => + [ + 'hostname' => '127.0.0.1', + 'port' => '11211', + ], + ], + ]; +} + +$array = [ + 'stats_api' => 'Server', + 'slabs_api' => 'Server', + 'items_api' => 'Server', + 'get_api' => 'Server', + 'set_api' => 'Server', + 'delete_api' => 'Server', + 'flush_all_api' => 'Server', + 'connection_timeout' => '1', + 'max_item_dump' => '100', + 'refresh_rate' => 5, + 'memory_alert' => '80', + 'hit_rate_alert' => '90', + 'eviction_alert' => '0', + 'file_path' => 'Temp/', + 'servers' => $servers, +]; + +return $array; diff --git a/src/Config/Memcache.sample.php b/src/Config/Memcache.sample.php new file mode 100644 index 0000000..db551c6 --- /dev/null +++ b/src/Config/Memcache.sample.php @@ -0,0 +1,96 @@ + $hostname, + 'port' => $port, + ]; + $j++; + } + $i++; + } +} else { + $servers = + [ + 'Default' => + [ + '127.0.0.1:11211' => + [ + 'hostname' => '127.0.0.1', + 'port' => '11211', + ], + '127.0.0.2:11211' => + [ + 'hostname' => '127.0.0.2', + 'port' => '11211', + ], + '127.0.0.3:11211' => + [ + 'hostname' => '127.0.0.1', + 'port' => '11211', + ], + '127.0.0.4:11211' => + [ + 'hostname' => '127.0.0.1', + 'port' => '11211', + ], + ], + ]; +} + +$array = [ + 'stats_api' => 'Server', + 'slabs_api' => 'Server', + 'items_api' => 'Server', + 'get_api' => 'Server', + 'set_api' => 'Server', + 'delete_api' => 'Server', + 'flush_all_api' => 'Server', + 'connection_timeout' => '1', + 'max_item_dump' => '100', + 'refresh_rate' => 5, + 'memory_alert' => '80', + 'hit_rate_alert' => '90', + 'eviction_alert' => '0', + 'file_path' => 'Temp/', + 'servers' => $servers, +]; + +return $array; + [ + 'Default' => + [ + '127.0.0.1:11211' => + [ + 'hostname' => '127.0.0.1', + 'port' => '11211', + ], + '127.0.0.2:11211' => + [ + 'hostname' => '127.0.0.2', + 'port' => '11211', + ], + '127.0.0.3:11211' => + [ + 'hostname' => '127.0.0.1', + 'port' => '11211', + ], + '127.0.0.4:11211' => + [ + 'hostname' => '127.0.0.1', + 'port' => '11211', + ], + ], + ]; diff --git a/Library/Bootstrap.php b/src/Library/Bootstrap.php similarity index 57% rename from Library/Bootstrap.php rename to src/Library/Bootstrap.php index b433c9e..e39ae85 100644 --- a/Library/Bootstrap.php +++ b/src/Library/Bootstrap.php @@ -11,10 +11,20 @@ define('ENT_IGNORE', 0); } + # XSS / User input check -foreach ($_REQUEST as $index => $data) { - $_REQUEST[$index] = htmlentities($data); +function xss_check($request) +{ + foreach ($request as $index => $data) { + if (gettype($data) == 'string') { + $request[$index] = htmlentities($data); + } elseif (gettype($data) == 'array') { + $data = xss_check($data); + } + } + return $request; } +$_REQUEST=xss_check($_REQUEST); # Autoloader function __autoload($class) @@ -26,4 +36,4 @@ function __autoload($class) $_ini = Library_Configuration_Loader::singleton(); # Date timezone -date_default_timezone_set('Europe/Paris'); \ No newline at end of file +date_default_timezone_set('Europe/Paris'); diff --git a/Library/Command/Factory.php b/src/Library/Command/Factory.php similarity index 100% rename from Library/Command/Factory.php rename to src/Library/Command/Factory.php diff --git a/Library/Command/Interface.php b/src/Library/Command/Interface.php similarity index 100% rename from Library/Command/Interface.php rename to src/Library/Command/Interface.php diff --git a/Library/Command/Memcache.php b/src/Library/Command/Memcache.php similarity index 100% rename from Library/Command/Memcache.php rename to src/Library/Command/Memcache.php diff --git a/Library/Command/Memcached.php b/src/Library/Command/Memcached.php similarity index 100% rename from Library/Command/Memcached.php rename to src/Library/Command/Memcached.php diff --git a/Library/Command/Server.php b/src/Library/Command/Server.php similarity index 100% rename from Library/Command/Server.php rename to src/Library/Command/Server.php diff --git a/Library/Configuration/Loader.php b/src/Library/Configuration/Loader.php similarity index 100% rename from Library/Configuration/Loader.php rename to src/Library/Configuration/Loader.php diff --git a/Library/Data/Analysis.php b/src/Library/Data/Analysis.php similarity index 100% rename from Library/Data/Analysis.php rename to src/Library/Data/Analysis.php diff --git a/Library/Data/Error.php b/src/Library/Data/Error.php similarity index 100% rename from Library/Data/Error.php rename to src/Library/Data/Error.php diff --git a/Library/Data/Version.php b/src/Library/Data/Version.php similarity index 100% rename from Library/Data/Version.php rename to src/Library/Data/Version.php diff --git a/Library/HTML/Components.php b/src/Library/HTML/Components.php similarity index 100% rename from Library/HTML/Components.php rename to src/Library/HTML/Components.php diff --git a/Public/Scripts/Highcharts/highcharts.js b/src/Public/Scripts/Highcharts/highcharts.js similarity index 100% rename from Public/Scripts/Highcharts/highcharts.js rename to src/Public/Scripts/Highcharts/highcharts.js diff --git a/Public/Scripts/Highcharts/standalone-framework.js b/src/Public/Scripts/Highcharts/standalone-framework.js similarity index 100% rename from Public/Scripts/Highcharts/standalone-framework.js rename to src/Public/Scripts/Highcharts/standalone-framework.js diff --git a/Public/Scripts/script.js b/src/Public/Scripts/script.js similarity index 99% rename from Public/Scripts/script.js rename to src/Public/Scripts/script.js index a7f5db6..79e95fe 100644 --- a/Public/Scripts/script.js +++ b/src/Public/Scripts/script.js @@ -258,7 +258,7 @@ function portOnBlur(object) { } } function hostOrPortOnChange(target) { - + nameObject = document.getElementById('name_' + target); hostObject = document.getElementById('host_' + target); portObject = document.getElementById('port_' + target); @@ -296,4 +296,4 @@ function ajaxDone(target) { + req.statusText; } } -} \ No newline at end of file +} diff --git a/Public/Styles/Style.css b/src/Public/Styles/Style.css similarity index 99% rename from Public/Styles/Style.css rename to src/Public/Styles/Style.css index a97b1a6..4785d82 100644 --- a/Public/Styles/Style.css +++ b/src/Public/Styles/Style.css @@ -235,4 +235,4 @@ hr { background: #b5463f; color: #fff; font-weight: bold -} \ No newline at end of file +} diff --git a/Temp/.version b/src/Temp/.version similarity index 100% rename from Temp/.version rename to src/Temp/.version diff --git a/View/Commands/Commands.phtml b/src/View/Commands/Commands.phtml similarity index 100% rename from View/Commands/Commands.phtml rename to src/View/Commands/Commands.phtml diff --git a/View/Configure/Configure.phtml b/src/View/Configure/Configure.phtml similarity index 100% rename from View/Configure/Configure.phtml rename to src/View/Configure/Configure.phtml diff --git a/View/Footer.phtml b/src/View/Footer.phtml similarity index 100% rename from View/Footer.phtml rename to src/View/Footer.phtml diff --git a/View/Header.phtml b/src/View/Header.phtml similarity index 100% rename from View/Header.phtml rename to src/View/Header.phtml diff --git a/View/LiveStats/Frame.phtml b/src/View/LiveStats/Frame.phtml similarity index 100% rename from View/LiveStats/Frame.phtml rename to src/View/LiveStats/Frame.phtml diff --git a/View/LiveStats/Stats.phtml b/src/View/LiveStats/Stats.phtml similarity index 100% rename from View/LiveStats/Stats.phtml rename to src/View/LiveStats/Stats.phtml diff --git a/View/Stats/Error.phtml b/src/View/Stats/Error.phtml similarity index 100% rename from View/Stats/Error.phtml rename to src/View/Stats/Error.phtml diff --git a/View/Stats/Items.phtml b/src/View/Stats/Items.phtml similarity index 100% rename from View/Stats/Items.phtml rename to src/View/Stats/Items.phtml diff --git a/View/Stats/Slabs.phtml b/src/View/Stats/Slabs.phtml similarity index 100% rename from View/Stats/Slabs.phtml rename to src/View/Stats/Slabs.phtml diff --git a/View/Stats/Stats.phtml b/src/View/Stats/Stats.phtml similarity index 100% rename from View/Stats/Stats.phtml rename to src/View/Stats/Stats.phtml diff --git a/commands.php b/src/commands.php similarity index 100% rename from commands.php rename to src/commands.php diff --git a/configure.php b/src/configure.php similarity index 100% rename from configure.php rename to src/configure.php diff --git a/index.php b/src/index.php similarity index 100% rename from index.php rename to src/index.php diff --git a/spam.php b/src/spam.php similarity index 100% rename from spam.php rename to src/spam.php diff --git a/stats.php b/src/stats.php similarity index 100% rename from stats.php rename to src/stats.php