diff --git a/.github/workflows/phpcsfixer.yml b/.github/workflows/phpcsfixer.yml new file mode 100644 index 0000000..251dc51 --- /dev/null +++ b/.github/workflows/phpcsfixer.yml @@ -0,0 +1,32 @@ +name: "PHP-CS-Fixer" + +on: + push: + branches: + - master + pull_request: + schedule: + - cron: '0 15 * * 2' + +jobs: + code-style: + strategy: + fail-fast: false + matrix: + php_versions: [ + '8.1', # PHP 8.2 is currently not (fully) supported by PHP-CS-Fixer + ] + name: PHP ${{ matrix.php_versions }} + runs-on: ubuntu-latest + steps: + - name: checkout repository + uses: actions/checkout@v3 + + - name: install dependencies + uses: php-actions/composer@v6 + with: + dev: yes + php_version: ${{ matrix.php_versions }} + + - name: run php-cs-fixer + run: ./vendor/bin/php-cs-fixer fix --config .php-cs-fixer.php --diff --dry-run diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6d0b1b1 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +vendor/ +.php-cs-fixer.cache diff --git a/.php-cs-fixer.php b/.php-cs-fixer.php new file mode 100644 index 0000000..0868a80 --- /dev/null +++ b/.php-cs-fixer.php @@ -0,0 +1,167 @@ + true, + 'array_syntax' => ['syntax' => 'short'], + 'binary_operator_spaces' => [ + 'default' => 'single_space', + 'operators' => ['=>' => null], + ], + 'blank_line_after_namespace' => true, + 'blank_line_after_opening_tag' => true, + 'blank_line_before_statement' => [ + 'statements' => ['return'], + ], + 'braces' => true, + 'cast_spaces' => true, + 'class_attributes_separation' => [ + 'elements' => [ + 'const' => 'one', + 'method' => 'one', + 'property' => 'one', + 'trait_import' => 'none', + ], + ], + 'class_definition' => [ + 'multi_line_extends_each_single_line' => true, + 'single_item_single_line' => true, + 'single_line' => true, + ], + 'curly_braces_position' => [ + 'anonymous_classes_opening_brace' => 'next_line_unless_newline_at_signature_end', + ], + 'concat_space' => [ + 'spacing' => 'none', + ], + 'constant_case' => ['case' => 'lower'], + 'declare_equal_normalize' => true, + 'elseif' => true, + 'encoding' => true, + 'full_opening_tag' => true, + 'fully_qualified_strict_types' => true, // added by Shift + 'function_declaration' => true, + 'function_typehint_space' => true, + 'general_phpdoc_tag_rename' => true, + 'heredoc_to_nowdoc' => true, + 'include' => true, + 'increment_style' => ['style' => 'post'], + 'indentation_type' => true, + 'linebreak_after_opening_tag' => true, + 'line_ending' => true, + 'lowercase_cast' => true, + 'lowercase_keywords' => true, + 'lowercase_static_reference' => true, // added from Symfony + 'magic_method_casing' => true, // added from Symfony + 'magic_constant_casing' => true, + 'method_argument_space' => [ + 'on_multiline' => 'ignore', + ], + 'multiline_whitespace_before_semicolons' => [ + 'strategy' => 'no_multi_line', + ], + 'native_function_casing' => true, + 'no_alias_functions' => true, + 'no_extra_blank_lines' => [ + 'tokens' => [ + 'extra', + 'throw', + 'use', + ], + ], + 'no_blank_lines_after_class_opening' => true, + 'no_blank_lines_after_phpdoc' => true, + 'no_closing_tag' => true, + 'no_empty_phpdoc' => true, + 'no_empty_statement' => true, + 'no_leading_import_slash' => true, + 'no_leading_namespace_whitespace' => true, + 'no_mixed_echo_print' => [ + 'use' => 'echo', + ], + 'no_multiline_whitespace_around_double_arrow' => true, + 'no_short_bool_cast' => true, + 'no_singleline_whitespace_before_semicolons' => true, + 'no_spaces_after_function_name' => true, + 'no_spaces_around_offset' => [ + 'positions' => ['inside', 'outside'], + ], + 'no_spaces_inside_parenthesis' => true, + 'no_trailing_comma_in_list_call' => true, + 'no_trailing_comma_in_singleline_array' => true, + 'no_trailing_whitespace' => true, + 'no_trailing_whitespace_in_comment' => true, + 'no_unneeded_control_parentheses' => [ + 'statements' => ['break', 'clone', 'continue', 'echo_print', 'return', 'switch_case', 'yield'], + ], + 'no_unreachable_default_argument_value' => true, + 'no_useless_return' => true, + 'no_whitespace_before_comma_in_array' => true, + 'no_whitespace_in_blank_line' => true, + 'normalize_index_brace' => true, + 'not_operator_with_successor_space' => true, + 'object_operator_without_whitespace' => true, + 'ordered_imports' => ['sort_algorithm' => 'alpha'], + 'psr_autoloading' => true, + 'phpdoc_indent' => true, + 'phpdoc_inline_tag_normalizer' => true, + 'phpdoc_no_access' => true, + 'phpdoc_no_package' => true, + 'phpdoc_no_useless_inheritdoc' => true, + 'phpdoc_scalar' => true, + 'phpdoc_single_line_var_spacing' => true, + 'phpdoc_summary' => false, + 'phpdoc_to_comment' => false, // override to preserve user preference + 'phpdoc_tag_type' => true, + 'phpdoc_trim' => true, + 'phpdoc_types' => true, + 'phpdoc_var_without_name' => true, + 'self_accessor' => true, + 'short_scalar_cast' => true, + 'simplified_null_return' => false, // disabled as "risky" + 'single_blank_line_at_eof' => true, + 'single_blank_line_before_namespace' => true, + 'single_class_element_per_statement' => [ + 'elements' => ['const', 'property'], + ], + 'single_import_per_statement' => true, + 'single_line_after_imports' => true, + 'single_line_comment_style' => [ + 'comment_types' => ['hash'], + ], + 'single_quote' => true, + 'space_after_semicolon' => true, + 'standardize_not_equals' => true, + 'switch_case_semicolon_to_colon' => true, + 'switch_case_space' => true, + 'ternary_operator_spaces' => true, + 'trailing_comma_in_multiline' => ['elements' => ['arrays']], + 'trim_array_spaces' => true, + 'unary_operator_spaces' => true, + 'visibility_required' => [ + 'elements' => ['method', 'property'], + ], + 'whitespace_after_comma_in_array' => true, +]; + + +$finder = Finder::create() + ->in([ + __DIR__ . '/api', + __DIR__ . '/jobs', + __DIR__ . '/languages', + __DIR__ . '/other', + __DIR__ . '/stats', + __DIR__ . '/webinterface', + ]) + ->name('*.php') + ->ignoreDotFiles(true) + ->ignoreVCS(true); + +return (new Config) + ->setFinder($finder) + ->setRules($rules) + ->setRiskyAllowed(true) + ->setUsingCache(true); diff --git a/README.md b/README.md index 34f49a8..966201b 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,28 @@ # TSN-Ranksystem ![license: GPL v3](https://img.shields.io/badge/license-GPL%20v3-brightgreen.svg) ![forks](https://img.shields.io/github/forks/Newcomer1989/TSN-Ranksystem.svg) ![stars](https://img.shields.io/github/stars/Newcomer1989/TSN-Ranksystem.svg) [![GitHub issues](https://img.shields.io/github/issues/Newcomer1989/TSN-Ranksystem.svg)](https://github.com/Newcomer1989/TSN-Ranksystem/issues) +[![Code-Style](https://github.com/Newcomer1989/TSN-Ranksystem/actions/workflows/phpcsfixer.yml/badge.svg?branch=master)](https://github.com/Newcomer1989/TSN-Ranksystem/actions/workflows/phpcsfixer.yml?branch=master) The TSN Ranksystem is an easy to handle Level System to automatically grant ranks (servergroups) to users on a TeamSpeak Server for online time or online activity. You can create your own servergroups, with permissions, icons etc. of your choice, and define these for the Ranksystem. Its open source and so its free to use under the GNU license with version 3. #### Official website: [TS-Ranksystem.com](https://ts-ranksystem.com) + + +## Contributions / Development + +This section is only relevant, if you want to contribute to this project with code changes. + + +### Code Style + +Please ensure, that you apply the current PHP-CS-Fixer rules for a standard coding style. + +This can be easily done using composer: + +```shell +composer install +``` + +```shell +composer run code-style +``` diff --git a/api/index.php b/api/index.php index 7644ae5..5996e17 100644 --- a/api/index.php +++ b/api/index.php @@ -1,588 +1,660 @@ - $desc) { - if (hash_equals($apikey, $_GET['apikey'])) $matchkey = 1; - } - if ($matchkey == 0) { - $json = array( - "Error" => array( - "invalid" => array( - "apikey" => "API Key is invalid" - ) - ) - ); - echo json_encode($json); - exit; - } -} else { - $json = array( - "Error" => array( - "required" => array( - "apikey" => array( - "desc" => "API Key for authentification. API keys can be created inside the Ranksystem Webinterface", - "usage" => "Use \$_GET parameter 'apikey' and add as value a valid API key", - "example" => "/api/?apikey=XXXXX" - ) - ) - ) - ); - echo json_encode($json); - exit; -} - -$limit = (isset($_GET['limit']) && is_numeric($_GET['limit']) && $_GET['limit'] > 0 && $_GET['limit'] <= 1000) ? $_GET['limit'] : 100; -$sort = (isset($_GET['sort'])) ? htmlspecialchars_decode($_GET['sort']) : '1'; -$order = (isset($_GET['order']) && strtolower($_GET['order']) == 'desc') ? 'DESC' : 'ASC'; -$part = (isset($_GET['part']) && is_numeric($_GET['part']) && $_GET['part'] > 0) ? (($_GET['part'] - 1) * $limit) : 0; - -if (isset($_GET['bot'])) { - if(!isset($_GET['check']) && !isset($_GET['restart']) && !isset($_GET['start']) && !isset($_GET['stop'])) { - $json = array( - "usage" => array( - "_desc" => array( - "0" => "You are able to use bot commands with this function (start, stop, ..).", - "1" => "Use the Parameter, which are described below!", - "2" => "", - "3" => "Return values are:", - "4" => "- 'rc'", - "5" => "- 'msg'", - "6" => "- 'ranksystemlog'", - "7" => "", - "8" => "# RC", - "9" => "The return Code of the transaction (i.e. start process):", - "10" => "0 - EXIT_SUCCESS", - "11" => "1 - EXIT_FAILURE", - "12" => "", - "13" => "# MSG", - "14" => "An additional message of the process. In case of EXIT_FAILURE, you will receive here an error message.", - "15" => "", - "16" => "# RANKSYSTEMLOG", - "17" => "A short log extract of the last rows of the Ranksystem logfile to get more information about the Bot itself.", - ), - "check" => array( - "desc" => "Check the Ranksystem Bot is running. If not, it will be started with this.", - "usage" => "Use \$_GET parameter 'check' without any value", - "example" => "/api/?bot&check" - ), - "restart" => array( - "desc" => "Restarts the Ranksystem Bot.", - "usage" => "Use \$_GET parameter 'restart' without any value", - "example" => "/api/?bot&restart" - ), - "start" => array( - "desc" => "Starts the Ranksystem Bot.", - "usage" => "Use \$_GET parameter 'start' without any value", - "example" => "/api/?bot&start" - ), - "stop" => array( - "desc" => "Stops the Ranksystem Bot", - "usage" => "Use \$_GET parameter 'stop' without any value", - "example" => "/api/?bot&stop" - ) - ) - ); - } else { - $check_permission = 0; - foreach($cfg['stats_api_keys'] as $apikey => $desc) { - if (hash_equals($apikey, $_GET['apikey']) && $desc['perm_bot'] == 1) { - $check_permission = 1; - break; - } - } - if ($check_permission == 1) { - if(isset($_GET['check'])) { - $result = bot_check(); - } elseif(isset($_GET['restart'])) { - $result = bot_restart(); - } elseif(isset($_GET['start'])) { - $result = bot_start(); - } elseif(isset($_GET['stop'])) { - $result = bot_stop(); - } - if(isset($result['log']) && $result['log'] != NULL) { - $ranksystemlog = $result['log']; - } else { - $ranksystemlog = "NULL"; - } - $json = array( - "rc" => $result['rc'], - "msg" => $result['msg'], - "ranksystemlog" => $ranksystemlog - ); - } else { - $json = array( - "Error" => array( - "invalid" => array( - "permissions" => "API Key is not permitted to start/stop the Ranksystem Bot" - ) - ) - ); - echo json_encode($json); - exit; - } - } -} elseif (isset($_GET['groups'])) { - $sgidname = $all = '----------_none_selected_----------'; - $sgid = -1; - if(isset($_GET['all'])) $all = 1; - if(isset($_GET['sgid'])) $sgid = htmlspecialchars_decode($_GET['sgid']); - if(isset($_GET['sgidname'])) $sgidname = htmlspecialchars_decode($_GET['sgidname']); - - if($sgid == -1 && $sgidname == '----------_none_selected_----------' && $all == '----------_none_selected_----------') { - $json = array( - "usage" => array( - "all" => array( - "desc" => "Get details about all TeamSpeak servergroups", - "usage" => "Use \$_GET parameter 'all' without any value", - "example" => "/api/?groups&all" - ), - "limit" => array( - "desc" => "Define a number that limits the number of results. Maximum value is 1000. Default is 100.", - "usage" => "Use \$_GET parameter 'limit' and add as value a number above 1", - "example" => "/api/?groups&limit=10" - ), - "order" => array( - "desc" => "Define a sorting order. Value of 'sort' param is necessary.", - "usage" => "Use \$_GET parameter 'order' and add as value 'asc' for ascending or 'desc' for descending", - "example" => "/api/?groups&all&sort=sgid&order=asc" - ), - "sgid" => array( - "desc" => "Get details about TeamSpeak servergroups by the servergroup TS-database-ID", - "usage" => "Use \$_GET parameter 'sgid' and add as value the servergroup TS-database-ID", - "example" => "/api/?groups&sgid=123" - ), - "sgidname" => array( - "desc" => "Get details about TeamSpeak servergroups by servergroup name or a part of it", - "usage" => "Use \$_GET parameter 'sgidname' and add as value a name or a part of it", - "example" => array( - "1" => array( - "desc" => "Filter by servergroup name", - "url" => "/api/?groups&sgidname=Level01" - ), - "2" => array( - "desc" => "Filter by servergroup name with a percent sign as placeholder", - "url" => "/api/?groups&sgidname=Level%" - ) - ) - ), - "sort" => array( - "desc" => "Define a sorting. Available is each column name, which is given back as a result.", - "usage" => "Use \$_GET parameter 'sort' and add as value a column name", - "example" => array( - "1" => array( - "desc" => "Sort by servergroup name", - "url" => "/api/?groups&all&sort=sgidname" - ), - "2" => array( - "desc" => "Sort by TeamSpeak sort-ID", - "url" => "/api/?groups&all&sort=sortid" - ) - ) - ) - ) - ); - } else { - if ($all == 1) { - $dbdata = $mysqlcon->prepare("SELECT * FROM `$dbname`.`groups` ORDER BY {$sort} {$order} LIMIT :start, :limit"); - } else { - $dbdata = $mysqlcon->prepare("SELECT * FROM `$dbname`.`groups` WHERE (`sgidname` LIKE :sgidname OR `sgid` LIKE :sgid) ORDER BY {$sort} {$order} LIMIT :start, :limit"); - $dbdata->bindValue(':sgidname', '%'.$sgidname.'%', PDO::PARAM_STR); - $dbdata->bindValue(':sgid', (int) $sgid, PDO::PARAM_INT); - } - $dbdata->bindValue(':start', (int) $part, PDO::PARAM_INT); - $dbdata->bindValue(':limit', (int) $limit, PDO::PARAM_INT); - $dbdata->execute(); - $json = $dbdata->fetchAll(PDO::FETCH_ASSOC|PDO::FETCH_UNIQUE); - foreach ($json as $sgid => $sqlpart) { - if ($sqlpart['icondate'] != 0 && $sqlpart['sgidname'] == 'ServerIcon') { - $json[$sgid]['iconpath'] = './tsicons/servericon.'.$sqlpart['ext']; - } elseif ($sqlpart['icondate'] == 0 && $sqlpart['iconid'] > 0 && $sqlpart['iconid'] < 601) { - $json[$sgid]['iconpath'] = './tsicons/'.$sqlpart['iconid'].'.'.$sqlpart['ext']; - } elseif ($sqlpart['icondate'] != 0) { - $json[$sgid]['iconpath'] = './tsicons/'.$sgid.'.'.$sqlpart['ext']; - } else { - $json[$sgid]['iconpath'] = ''; - } - } - } -} elseif (isset($_GET['rankconfig'])) { - $dbdata = $mysqlcon->prepare("SELECT * FROM `$dbname`.`cfg_params` WHERE `param` in ('rankup_definition', 'rankup_time_assess_mode')"); - $dbdata->execute(); - $sql = $dbdata->fetchAll(PDO::FETCH_KEY_PAIR); - $json = array(); - if ($sql['rankup_time_assess_mode'] == 1) { - $modedesc = "active time"; - } else { - $modedesc = "online time"; - } - $json['rankup_time_assess_mode'] = array ( - "mode" => $sql['rankup_time_assess_mode'], - "mode_desc" => $modedesc - ); - $count = 0; - foreach (explode(',', $sql['rankup_definition']) as $entry) { - list($key, $value) = explode('=>', $entry); - $addnewvalue1[$count] = array( - "grpid" => $value, - "seconds" => $key - ); - $count++; - $json['rankup_definition'] = $addnewvalue1; - } -} elseif (isset($_GET['server'])) { - $dbdata = $mysqlcon->prepare("SELECT 0 as `row`, `$dbname`.`stats_server`.* FROM `$dbname`.`stats_server`"); - $dbdata->execute(); - $json = $dbdata->fetchAll(PDO::FETCH_ASSOC|PDO::FETCH_UNIQUE); -} elseif (isset($_GET['user'])) { - $filter = ' WHERE'; - if(isset($_GET['cldbid'])) { - $cldbid = htmlspecialchars_decode($_GET['cldbid']); - if($filter != ' WHERE') $filter .= " AND"; - $filter .= ' `cldbid` LIKE :cldbid'; - } - if(isset($_GET['groupid'])) { - $groupid = htmlspecialchars_decode($_GET['groupid']); - $explode_groupid = explode(',', $groupid); - if($filter != ' WHERE') $filter .= " AND"; - $filter .= " ("; - $cnt = 0; - foreach($explode_groupid as $groupid) { - if($cnt > 0) $filter .= " OR "; - $filter .= "`cldgroup` = :groupid".$cnt; $cnt++; - $filter .= " OR `cldgroup` LIKE (:groupid".$cnt.")"; $cnt++; - $filter .= " OR `cldgroup` LIKE (:groupid".$cnt.")"; $cnt++; - $filter .= " OR `cldgroup` LIKE (:groupid".$cnt.")"; $cnt++; - } - $filter .= ")"; - } - if(isset($_GET['name'])) { - $name = htmlspecialchars_decode($_GET['name']); - if($filter != ' WHERE') $filter .= " AND"; - $filter .= ' `name` LIKE :name'; - } - if(!isset($_GET['sort'])) $sort = '`rank`'; - if(isset($_GET['status']) && $_GET['status'] == strtolower('online')) { - if($filter != ' WHERE') $filter .= " AND"; - $filter .= " `online`=1"; - } elseif(isset($_GET['status']) && $_GET['status'] == strtolower('offline')) { - if($filter != ' WHERE') $filter .= " AND"; - $filter .= " `online`=0"; - } - if(isset($_GET['uuid'])) { - $uuid = htmlspecialchars_decode($_GET['uuid']); - if($filter != ' WHERE') $filter .= " AND"; - $filter .= ' `uuid` LIKE :uuid'; - } - if($filter == ' WHERE') $filter = ''; - - if($filter == '' && !isset($_GET['all']) && !isset($_GET['cldbid']) && !isset($_GET['name']) && !isset($_GET['uuid'])) { - $json = array( - "usage" => array( - "all" => array( - "desc" => "Get details about all TeamSpeak user. Result is limited by 100 entries.", - "usage" => "Use \$_GET parameter 'all' without any value", - "example" => "/api/?user&all" - ), - "cldbid" => array( - "desc" => "Get details about TeamSpeak user by client TS-database ID", - "usage" => "Use \$_GET parameter 'cldbid' and add as value a single client TS-database ID", - "example" => "/api/?user&cldbid=7775" - ), - "groupid" => array( - "desc" => "Get only user, which are in the given servergroup database ID", - "usage" => "Use \$_GET parameter 'groupid' and add as value a database ID of a servergroup. Multiple servergroups can be specified comma-separated.", - "example" => array( - "1" => array( - "desc" => "Filter by a single servergroup database ID", - "url" => "/api/?userstats&groupid=6" - ), - "2" => array( - "desc" => "Filter by multiple servergroup database IDs. Only one of the specified groups must apply to get the concerned user.", - "url" => "/api/?userstats&groupid=6,9,48" - ) - ) - ), - "limit" => array( - "desc" => "Define a number that limits the number of results. Maximum value is 1000. Default is 100.", - "usage" => "Use \$_GET parameter 'limit' and add as value a number above 1", - "example" => "/api/?user&all&limit=10" - ), - "name" => array( - "desc" => "Get details about TeamSpeak user by client nickname", - "usage" => "Use \$_GET parameter 'name' and add as value a name or a part of it", - "example" => array( - "1" => array( - "desc" => "Filter by client nickname", - "url" => "/api/?user&name=Newcomer1989" - ), - "2" => array( - "desc" => "Filter by client nickname with a percent sign as placeholder", - "url" => "/api/?user&name=%user%" - ) - ) - ), - "order" => array( - "desc" => "Define a sorting order.", - "usage" => "Use \$_GET parameter 'order' and add as value 'asc' for ascending or 'desc' for descending", - "example" => "/api/?user&all&order=asc" - ), - "part" => array( - "desc" => "Define, which part of the result you want to get. This is needed, when more then 100 clients are inside the result. At default you will get the first 100 clients. To get the next 100 clients, you will need to ask for part 2.", - "usage" => "Use \$_GET parameter 'part' and add as value a number above 1", - "example" => "/api/?user&name=TeamSpeakUser&part=2" - ), - "sort" => array( - "desc" => "Define a sorting. Available is each column name, which is given back as a result.", - "usage" => "Use \$_GET parameter 'sort' and add as value a column name", - "example" => array( - "1" => array( - "desc" => "Sort by online time", - "url" => "/api/?user&all&sort=count" - ), - "2" => array( - "desc" => "Sort by active time", - "url" => "/api/?user&all&sort=(count-idle)" - ), - "3" => array( - "desc" => "Sort by rank", - "url" => "/api/?user&all&sort=rank" - ) - ) - ), - "status" => array( - "desc" => "List only clients, which status is online or offline.", - "usage" => "Use \$_GET parameter 'status' and add as value 'online' or 'offline'", - "example" => "/api/?userstats&status=online" - ), - "uuid" => array( - "desc" => "Get details about TeamSpeak user by unique client ID", - "usage" => "Use \$_GET parameter 'uuid' and add as value one unique client ID or a part of it", - "example" => "/api/?user&uuid=xrTKhT/HDl4ea0WoFDQH2zOpmKg=" - ) - ) - ); - } else { - $dbdata = $mysqlcon->prepare("SELECT * FROM `$dbname`.`user` {$filter} ORDER BY {$sort} {$order} LIMIT :start, :limit"); - if(isset($_GET['cldbid'])) $dbdata->bindValue(':cldbid', (int) $cldbid, PDO::PARAM_INT); - if(isset($_GET['groupid'])) { - $groupid = htmlspecialchars_decode($_GET['groupid']); - $explode_groupid = explode(',', $groupid); - $cnt = 0; - foreach($explode_groupid as $groupid) { - $dbdata->bindValue(':groupid'.$cnt, $groupid, PDO::PARAM_STR); $cnt++; - $dbdata->bindValue(':groupid'.$cnt, $groupid.',%', PDO::PARAM_STR); $cnt++; - $dbdata->bindValue(':groupid'.$cnt, '%,'.$groupid.',%', PDO::PARAM_STR); $cnt++; - $dbdata->bindValue(':groupid'.$cnt, '%,'.$groupid, PDO::PARAM_STR); $cnt++; - } - } - if(isset($_GET['name'])) $dbdata->bindValue(':name', '%'.$name.'%', PDO::PARAM_STR); - if(isset($_GET['uuid'])) $dbdata->bindValue(':uuid', '%'.$uuid.'%', PDO::PARAM_STR); - - $dbdata->bindValue(':start', (int) $part, PDO::PARAM_INT); - $dbdata->bindValue(':limit', (int) $limit, PDO::PARAM_INT); - $dbdata->execute(); - $json = $dbdata->fetchAll(PDO::FETCH_ASSOC|PDO::FETCH_UNIQUE); - } -} elseif (isset($_GET['userstats'])) { - $filter = ' WHERE'; - if(isset($_GET['cldbid'])) { - $cldbid = htmlspecialchars_decode($_GET['cldbid']); - if($filter != ' WHERE') $filter .= " AND"; - $filter .= ' `cldbid` LIKE :cldbid'; - } - if(isset($_GET['groupid'])) { - $groupid = htmlspecialchars_decode($_GET['groupid']); - $explode_groupid = explode(',', $groupid); - if($filter != ' WHERE') $filter .= " AND"; - $filter .= " ("; - $cnt = 0; - foreach($explode_groupid as $groupid) { - if($cnt > 0) $filter .= " OR "; - $filter .= "`user`.`cldgroup` = :groupid".$cnt; $cnt++; - $filter .= " OR `user`.`cldgroup` LIKE (:groupid".$cnt.")"; $cnt++; - $filter .= " OR `user`.`cldgroup` LIKE (:groupid".$cnt.")"; $cnt++; - $filter .= " OR `user`.`cldgroup` LIKE (:groupid".$cnt.")"; $cnt++; - } - $filter .= ")"; - } - if(isset($_GET['name'])) { - $name = htmlspecialchars_decode($_GET['name']); - if($filter != ' WHERE') $filter .= " AND"; - $filter .= ' `user`.`name` LIKE :name'; - } - if(!isset($_GET['sort'])) $sort = '`count_week`'; - if(isset($_GET['status']) && $_GET['status'] == strtolower('online')) { - if($filter != ' WHERE') $filter .= " AND"; - $filter .= " `user`.`online`=1"; - } elseif(isset($_GET['status']) && $_GET['status'] == strtolower('offline')) { - if($filter != ' WHERE') $filter .= " AND"; - $filter .= " `user`.`online`=0"; - } - if(isset($_GET['uuid'])) { - $uuid = htmlspecialchars_decode($_GET['uuid']); - if($filter != ' WHERE') $filter .= " AND"; - $filter .= ' `user`.`uuid` LIKE :uuid'; - } - if($filter == ' WHERE') $filter = ''; - - if($filter == '' && !isset($_GET['all']) && !isset($_GET['cldbid']) && !isset($_GET['name']) && !isset($_GET['uuid'])) { - $json = array( - "usage" => array( - "all" => array( - "desc" => "Get additional statistics about all TeamSpeak user. Result is limited by 100 entries.", - "usage" => "Use \$_GET parameter 'all' without any value", - "example" => "/api/?userstats&all" - ), - "cldbid" => array( - "desc" => "Get details about TeamSpeak user by client TS-database ID", - "usage" => "Use \$_GET parameter 'cldbid' and add as value a single client TS-database ID", - "example" => "/api/?userstats&cldbid=7775" - ), - "groupid" => array( - "desc" => "Get only user, which are in the given servergroup database ID", - "usage" => "Use \$_GET parameter 'groupid' and add as value a database ID of a servergroup. Multiple servergroups can be specified comma-separated.", - "example" => array( - "1" => array( - "desc" => "Filter by a single servergroup database ID", - "url" => "/api/?userstats&groupid=6" - ), - "2" => array( - "desc" => "Filter by multiple servergroup database IDs. Only one of the specified groups must apply to get the concerned user.", - "url" => "/api/?userstats&groupid=6,9,48" - ) - ) - ), - "limit" => array( - "desc" => "Define a number that limits the number of results. Maximum value is 1000. Default is 100.", - "usage" => "Use \$_GET parameter 'limit' and add as value a number above 1", - "example" => "/api/?userstats&limit=10" - ), - "name" => array( - "desc" => "Get details about TeamSpeak user by client nickname", - "usage" => "Use \$_GET parameter 'name' and add as value a name or a part of it", - "example" => array( - "1" => array( - "desc" => "Filter by client nickname", - "url" => "/api/?userstats&name=Newcomer1989" - ), - "2" => array( - "desc" => "Filter by client nickname with a percent sign as placeholder", - "url" => "/api/?userstats&name=%user%" - ) - ) - ), - "order" => array( - "desc" => "Define a sorting order.", - "usage" => "Use \$_GET parameter 'order' and add as value 'asc' for ascending or 'desc' for descending", - "example" => "/api/?userstats&all&order=asc" - ), - "part" => array( - "desc" => "Define, which part of the result you want to get. This is needed, when more then 100 clients are inside the result. At default you will get the first 100 clients. To get the next 100 clients, you will need to ask for part 2.", - "usage" => "Use \$_GET parameter 'part' and add as value a number above 1", - "example" => "/api/?userstats&all&part=2" - ), - "sort" => array( - "desc" => "Define a sorting. Available is each column name, which is given back as a result.", - "usage" => "Use \$_GET parameter 'sort' and add as value a column name", - "example" => array( - "1" => array( - "desc" => "Sort by online time of the week", - "url" => "/api/?userstats&all&sort=count_week" - ), - "2" => array( - "desc" => "Sort by active time of the week", - "url" => "/api/?userstats&all&sort=(count_week-idle_week)" - ), - "3" => array( - "desc" => "Sort by online time of the month", - "url" => "/api/?userstats&all&sort=count_month" - ) - ) - ), - "status" => array( - "desc" => "List only clients, which status is online or offline.", - "usage" => "Use \$_GET parameter 'status' and add as value 'online' or 'offline'", - "example" => "/api/?userstats&status=online" - ), - "uuid" => array( - "desc" => "Get additional statistics about TeamSpeak user by unique client ID", - "usage" => "Use \$_GET parameter 'uuid' and add as value one unique client ID or a part of it", - "example" => "/api/?userstats&uuid=xrTKhT/HDl4ea0WoFDQH2zOpmKg=" - ) - ) - ); - } else { - $dbdata = $mysqlcon->prepare("SELECT * FROM `$dbname`.`stats_user` INNER JOIN `$dbname`.`user` ON `user`.`uuid` = `stats_user`.`uuid` {$filter} ORDER BY {$sort} {$order} LIMIT :start, :limit"); - if(isset($_GET['cldbid'])) $dbdata->bindValue(':cldbid', (int) $cldbid, PDO::PARAM_INT); - if(isset($_GET['groupid'])) { - $groupid = htmlspecialchars_decode($_GET['groupid']); - $explode_groupid = explode(',', $groupid); - $cnt = 0; - foreach($explode_groupid as $groupid) { - $dbdata->bindValue(':groupid'.$cnt, $groupid, PDO::PARAM_STR); $cnt++; - $dbdata->bindValue(':groupid'.$cnt, $groupid.',%', PDO::PARAM_STR); $cnt++; - $dbdata->bindValue(':groupid'.$cnt, '%,'.$groupid.',%', PDO::PARAM_STR); $cnt++; - $dbdata->bindValue(':groupid'.$cnt, '%,'.$groupid, PDO::PARAM_STR); $cnt++; - } - } - if(isset($_GET['name'])) $dbdata->bindValue(':name', '%'.$name.'%', PDO::PARAM_STR); - if(isset($_GET['uuid'])) $dbdata->bindValue(':uuid', '%'.$uuid.'%', PDO::PARAM_STR); - - $dbdata->bindValue(':start', (int) $part, PDO::PARAM_INT); - $dbdata->bindValue(':limit', (int) $limit, PDO::PARAM_INT); - $dbdata->execute(); - $json = $dbdata->fetchAll(PDO::FETCH_ASSOC|PDO::FETCH_UNIQUE); - } -} else { - $json = array( - "usage" => array( - "bot" => array( - "desc" => "Use this to trigger Bot commands as starting or stopping the Ranksystem Bot.", - "usage" => "Use \$_GET parameter 'bot'", - "example" => "/api/?bot" - ), - "groups" => array( - "desc" => "Get details about the TeamSpeak servergroups", - "usage" => "Use \$_GET parameter 'groups'", - "example" => "/api/?groups" - ), - "rankconfig" => array( - "desc" => "Get the rankup definition, which contains the assignment of (needed) time to servergroup", - "usage" => "Use \$_GET parameter 'rankconfig'", - "example" => "/api/?rankconfig" - ), - "server" => array( - "desc" => "Get details about the TeamSpeak server", - "usage" => "Use \$_GET parameter 'server'", - "example" => "/api/?server" - ), - "user" => array( - "desc" => "Get details about the TeamSpeak user", - "usage" => "Use \$_GET parameter 'user'", - "example" => "/api/?user" - ), - "userstats" => array( - "desc" => "Get additional statistics about the TeamSpeak user", - "usage" => "Use \$_GET parameter 'userstats'", - "example" => "/api/?userstats" - ) - ) - ); -} - -echo json_encode($json); -?> \ No newline at end of file + $desc) { + if (hash_equals($apikey, $_GET['apikey'])) { + $matchkey = 1; + } + } + if ($matchkey == 0) { + $json = [ + 'Error' => [ + 'invalid' => [ + 'apikey' => 'API Key is invalid', + ], + ], + ]; + echo json_encode($json); + exit; + } +} else { + $json = [ + 'Error' => [ + 'required' => [ + 'apikey' => [ + 'desc' => 'API Key for authentification. API keys can be created inside the Ranksystem Webinterface', + 'usage' => "Use \$_GET parameter 'apikey' and add as value a valid API key", + 'example' => '/api/?apikey=XXXXX', + ], + ], + ], + ]; + echo json_encode($json); + exit; +} + +$limit = (isset($_GET['limit']) && is_numeric($_GET['limit']) && $_GET['limit'] > 0 && $_GET['limit'] <= 1000) ? $_GET['limit'] : 100; +$sort = (isset($_GET['sort'])) ? htmlspecialchars_decode($_GET['sort']) : '1'; +$order = (isset($_GET['order']) && strtolower($_GET['order']) == 'desc') ? 'DESC' : 'ASC'; +$part = (isset($_GET['part']) && is_numeric($_GET['part']) && $_GET['part'] > 0) ? (($_GET['part'] - 1) * $limit) : 0; + +if (isset($_GET['bot'])) { + if (! isset($_GET['check']) && ! isset($_GET['restart']) && ! isset($_GET['start']) && ! isset($_GET['stop'])) { + $json = [ + 'usage' => [ + '_desc' => [ + '0' => 'You are able to use bot commands with this function (start, stop, ..).', + '1' => 'Use the Parameter, which are described below!', + '2' => '', + '3' => 'Return values are:', + '4' => "- 'rc'", + '5' => "- 'msg'", + '6' => "- 'ranksystemlog'", + '7' => '', + '8' => '# RC', + '9' => 'The return Code of the transaction (i.e. start process):', + '10' => '0 - EXIT_SUCCESS', + '11' => '1 - EXIT_FAILURE', + '12' => '', + '13' => '# MSG', + '14' => 'An additional message of the process. In case of EXIT_FAILURE, you will receive here an error message.', + '15' => '', + '16' => '# RANKSYSTEMLOG', + '17' => 'A short log extract of the last rows of the Ranksystem logfile to get more information about the Bot itself.', + ], + 'check' => [ + 'desc' => 'Check the Ranksystem Bot is running. If not, it will be started with this.', + 'usage' => "Use \$_GET parameter 'check' without any value", + 'example' => '/api/?bot&check', + ], + 'restart' => [ + 'desc' => 'Restarts the Ranksystem Bot.', + 'usage' => "Use \$_GET parameter 'restart' without any value", + 'example' => '/api/?bot&restart', + ], + 'start' => [ + 'desc' => 'Starts the Ranksystem Bot.', + 'usage' => "Use \$_GET parameter 'start' without any value", + 'example' => '/api/?bot&start', + ], + 'stop' => [ + 'desc' => 'Stops the Ranksystem Bot', + 'usage' => "Use \$_GET parameter 'stop' without any value", + 'example' => '/api/?bot&stop', + ], + ], + ]; + } else { + $check_permission = 0; + foreach ($cfg['stats_api_keys'] as $apikey => $desc) { + if (hash_equals($apikey, $_GET['apikey']) && $desc['perm_bot'] == 1) { + $check_permission = 1; + break; + } + } + if ($check_permission == 1) { + if (isset($_GET['check'])) { + $result = bot_check(); + } elseif (isset($_GET['restart'])) { + $result = bot_restart(); + } elseif (isset($_GET['start'])) { + $result = bot_start(); + } elseif (isset($_GET['stop'])) { + $result = bot_stop(); + } + if (isset($result['log']) && $result['log'] != null) { + $ranksystemlog = $result['log']; + } else { + $ranksystemlog = 'NULL'; + } + $json = [ + 'rc' => $result['rc'], + 'msg' => $result['msg'], + 'ranksystemlog' => $ranksystemlog, + ]; + } else { + $json = [ + 'Error' => [ + 'invalid' => [ + 'permissions' => 'API Key is not permitted to start/stop the Ranksystem Bot', + ], + ], + ]; + echo json_encode($json); + exit; + } + } +} elseif (isset($_GET['groups'])) { + $sgidname = $all = '----------_none_selected_----------'; + $sgid = -1; + if (isset($_GET['all'])) { + $all = 1; + } + if (isset($_GET['sgid'])) { + $sgid = htmlspecialchars_decode($_GET['sgid']); + } + if (isset($_GET['sgidname'])) { + $sgidname = htmlspecialchars_decode($_GET['sgidname']); + } + + if ($sgid == -1 && $sgidname == '----------_none_selected_----------' && $all == '----------_none_selected_----------') { + $json = [ + 'usage' => [ + 'all' => [ + 'desc' => 'Get details about all TeamSpeak servergroups', + 'usage' => "Use \$_GET parameter 'all' without any value", + 'example' => '/api/?groups&all', + ], + 'limit' => [ + 'desc' => 'Define a number that limits the number of results. Maximum value is 1000. Default is 100.', + 'usage' => "Use \$_GET parameter 'limit' and add as value a number above 1", + 'example' => '/api/?groups&limit=10', + ], + 'order' => [ + 'desc' => "Define a sorting order. Value of 'sort' param is necessary.", + 'usage' => "Use \$_GET parameter 'order' and add as value 'asc' for ascending or 'desc' for descending", + 'example' => '/api/?groups&all&sort=sgid&order=asc', + ], + 'sgid' => [ + 'desc' => 'Get details about TeamSpeak servergroups by the servergroup TS-database-ID', + 'usage' => "Use \$_GET parameter 'sgid' and add as value the servergroup TS-database-ID", + 'example' => '/api/?groups&sgid=123', + ], + 'sgidname' => [ + 'desc' => 'Get details about TeamSpeak servergroups by servergroup name or a part of it', + 'usage' => "Use \$_GET parameter 'sgidname' and add as value a name or a part of it", + 'example' => [ + '1' => [ + 'desc' => 'Filter by servergroup name', + 'url' => '/api/?groups&sgidname=Level01', + ], + '2' => [ + 'desc' => 'Filter by servergroup name with a percent sign as placeholder', + 'url' => '/api/?groups&sgidname=Level%', + ], + ], + ], + 'sort' => [ + 'desc' => 'Define a sorting. Available is each column name, which is given back as a result.', + 'usage' => "Use \$_GET parameter 'sort' and add as value a column name", + 'example' => [ + '1' => [ + 'desc' => 'Sort by servergroup name', + 'url' => '/api/?groups&all&sort=sgidname', + ], + '2' => [ + 'desc' => 'Sort by TeamSpeak sort-ID', + 'url' => '/api/?groups&all&sort=sortid', + ], + ], + ], + ], + ]; + } else { + if ($all == 1) { + $dbdata = $mysqlcon->prepare("SELECT * FROM `$dbname`.`groups` ORDER BY {$sort} {$order} LIMIT :start, :limit"); + } else { + $dbdata = $mysqlcon->prepare("SELECT * FROM `$dbname`.`groups` WHERE (`sgidname` LIKE :sgidname OR `sgid` LIKE :sgid) ORDER BY {$sort} {$order} LIMIT :start, :limit"); + $dbdata->bindValue(':sgidname', '%'.$sgidname.'%', PDO::PARAM_STR); + $dbdata->bindValue(':sgid', (int) $sgid, PDO::PARAM_INT); + } + $dbdata->bindValue(':start', (int) $part, PDO::PARAM_INT); + $dbdata->bindValue(':limit', (int) $limit, PDO::PARAM_INT); + $dbdata->execute(); + $json = $dbdata->fetchAll(PDO::FETCH_ASSOC | PDO::FETCH_UNIQUE); + foreach ($json as $sgid => $sqlpart) { + if ($sqlpart['icondate'] != 0 && $sqlpart['sgidname'] == 'ServerIcon') { + $json[$sgid]['iconpath'] = './tsicons/servericon.'.$sqlpart['ext']; + } elseif ($sqlpart['icondate'] == 0 && $sqlpart['iconid'] > 0 && $sqlpart['iconid'] < 601) { + $json[$sgid]['iconpath'] = './tsicons/'.$sqlpart['iconid'].'.'.$sqlpart['ext']; + } elseif ($sqlpart['icondate'] != 0) { + $json[$sgid]['iconpath'] = './tsicons/'.$sgid.'.'.$sqlpart['ext']; + } else { + $json[$sgid]['iconpath'] = ''; + } + } + } +} elseif (isset($_GET['rankconfig'])) { + $dbdata = $mysqlcon->prepare("SELECT * FROM `$dbname`.`cfg_params` WHERE `param` in ('rankup_definition', 'rankup_time_assess_mode')"); + $dbdata->execute(); + $sql = $dbdata->fetchAll(PDO::FETCH_KEY_PAIR); + $json = []; + if ($sql['rankup_time_assess_mode'] == 1) { + $modedesc = 'active time'; + } else { + $modedesc = 'online time'; + } + $json['rankup_time_assess_mode'] = [ + 'mode' => $sql['rankup_time_assess_mode'], + 'mode_desc' => $modedesc, + ]; + $count = 0; + foreach (explode(',', $sql['rankup_definition']) as $entry) { + list($key, $value) = explode('=>', $entry); + $addnewvalue1[$count] = [ + 'grpid' => $value, + 'seconds' => $key, + ]; + $count++; + $json['rankup_definition'] = $addnewvalue1; + } +} elseif (isset($_GET['server'])) { + $dbdata = $mysqlcon->prepare("SELECT 0 as `row`, `$dbname`.`stats_server`.* FROM `$dbname`.`stats_server`"); + $dbdata->execute(); + $json = $dbdata->fetchAll(PDO::FETCH_ASSOC | PDO::FETCH_UNIQUE); +} elseif (isset($_GET['user'])) { + $filter = ' WHERE'; + if (isset($_GET['cldbid'])) { + $cldbid = htmlspecialchars_decode($_GET['cldbid']); + if ($filter != ' WHERE') { + $filter .= ' AND'; + } + $filter .= ' `cldbid` LIKE :cldbid'; + } + if (isset($_GET['groupid'])) { + $groupid = htmlspecialchars_decode($_GET['groupid']); + $explode_groupid = explode(',', $groupid); + if ($filter != ' WHERE') { + $filter .= ' AND'; + } + $filter .= ' ('; + $cnt = 0; + foreach ($explode_groupid as $groupid) { + if ($cnt > 0) { + $filter .= ' OR '; + } + $filter .= '`cldgroup` = :groupid'.$cnt; + $cnt++; + $filter .= ' OR `cldgroup` LIKE (:groupid'.$cnt.')'; + $cnt++; + $filter .= ' OR `cldgroup` LIKE (:groupid'.$cnt.')'; + $cnt++; + $filter .= ' OR `cldgroup` LIKE (:groupid'.$cnt.')'; + $cnt++; + } + $filter .= ')'; + } + if (isset($_GET['name'])) { + $name = htmlspecialchars_decode($_GET['name']); + if ($filter != ' WHERE') { + $filter .= ' AND'; + } + $filter .= ' `name` LIKE :name'; + } + if (! isset($_GET['sort'])) { + $sort = '`rank`'; + } + if (isset($_GET['status']) && $_GET['status'] == strtolower('online')) { + if ($filter != ' WHERE') { + $filter .= ' AND'; + } + $filter .= ' `online`=1'; + } elseif (isset($_GET['status']) && $_GET['status'] == strtolower('offline')) { + if ($filter != ' WHERE') { + $filter .= ' AND'; + } + $filter .= ' `online`=0'; + } + if (isset($_GET['uuid'])) { + $uuid = htmlspecialchars_decode($_GET['uuid']); + if ($filter != ' WHERE') { + $filter .= ' AND'; + } + $filter .= ' `uuid` LIKE :uuid'; + } + if ($filter == ' WHERE') { + $filter = ''; + } + + if ($filter == '' && ! isset($_GET['all']) && ! isset($_GET['cldbid']) && ! isset($_GET['name']) && ! isset($_GET['uuid'])) { + $json = [ + 'usage' => [ + 'all' => [ + 'desc' => 'Get details about all TeamSpeak user. Result is limited by 100 entries.', + 'usage' => "Use \$_GET parameter 'all' without any value", + 'example' => '/api/?user&all', + ], + 'cldbid' => [ + 'desc' => 'Get details about TeamSpeak user by client TS-database ID', + 'usage' => "Use \$_GET parameter 'cldbid' and add as value a single client TS-database ID", + 'example' => '/api/?user&cldbid=7775', + ], + 'groupid' => [ + 'desc' => 'Get only user, which are in the given servergroup database ID', + 'usage' => "Use \$_GET parameter 'groupid' and add as value a database ID of a servergroup. Multiple servergroups can be specified comma-separated.", + 'example' => [ + '1' => [ + 'desc' => 'Filter by a single servergroup database ID', + 'url' => '/api/?userstats&groupid=6', + ], + '2' => [ + 'desc' => 'Filter by multiple servergroup database IDs. Only one of the specified groups must apply to get the concerned user.', + 'url' => '/api/?userstats&groupid=6,9,48', + ], + ], + ], + 'limit' => [ + 'desc' => 'Define a number that limits the number of results. Maximum value is 1000. Default is 100.', + 'usage' => "Use \$_GET parameter 'limit' and add as value a number above 1", + 'example' => '/api/?user&all&limit=10', + ], + 'name' => [ + 'desc' => 'Get details about TeamSpeak user by client nickname', + 'usage' => "Use \$_GET parameter 'name' and add as value a name or a part of it", + 'example' => [ + '1' => [ + 'desc' => 'Filter by client nickname', + 'url' => '/api/?user&name=Newcomer1989', + ], + '2' => [ + 'desc' => 'Filter by client nickname with a percent sign as placeholder', + 'url' => '/api/?user&name=%user%', + ], + ], + ], + 'order' => [ + 'desc' => 'Define a sorting order.', + 'usage' => "Use \$_GET parameter 'order' and add as value 'asc' for ascending or 'desc' for descending", + 'example' => '/api/?user&all&order=asc', + ], + 'part' => [ + 'desc' => 'Define, which part of the result you want to get. This is needed, when more then 100 clients are inside the result. At default you will get the first 100 clients. To get the next 100 clients, you will need to ask for part 2.', + 'usage' => "Use \$_GET parameter 'part' and add as value a number above 1", + 'example' => '/api/?user&name=TeamSpeakUser&part=2', + ], + 'sort' => [ + 'desc' => 'Define a sorting. Available is each column name, which is given back as a result.', + 'usage' => "Use \$_GET parameter 'sort' and add as value a column name", + 'example' => [ + '1' => [ + 'desc' => 'Sort by online time', + 'url' => '/api/?user&all&sort=count', + ], + '2' => [ + 'desc' => 'Sort by active time', + 'url' => '/api/?user&all&sort=(count-idle)', + ], + '3' => [ + 'desc' => 'Sort by rank', + 'url' => '/api/?user&all&sort=rank', + ], + ], + ], + 'status' => [ + 'desc' => 'List only clients, which status is online or offline.', + 'usage' => "Use \$_GET parameter 'status' and add as value 'online' or 'offline'", + 'example' => '/api/?userstats&status=online', + ], + 'uuid' => [ + 'desc' => 'Get details about TeamSpeak user by unique client ID', + 'usage' => "Use \$_GET parameter 'uuid' and add as value one unique client ID or a part of it", + 'example' => '/api/?user&uuid=xrTKhT/HDl4ea0WoFDQH2zOpmKg=', + ], + ], + ]; + } else { + $dbdata = $mysqlcon->prepare("SELECT * FROM `$dbname`.`user` {$filter} ORDER BY {$sort} {$order} LIMIT :start, :limit"); + if (isset($_GET['cldbid'])) { + $dbdata->bindValue(':cldbid', (int) $cldbid, PDO::PARAM_INT); + } + if (isset($_GET['groupid'])) { + $groupid = htmlspecialchars_decode($_GET['groupid']); + $explode_groupid = explode(',', $groupid); + $cnt = 0; + foreach ($explode_groupid as $groupid) { + $dbdata->bindValue(':groupid'.$cnt, $groupid, PDO::PARAM_STR); + $cnt++; + $dbdata->bindValue(':groupid'.$cnt, $groupid.',%', PDO::PARAM_STR); + $cnt++; + $dbdata->bindValue(':groupid'.$cnt, '%,'.$groupid.',%', PDO::PARAM_STR); + $cnt++; + $dbdata->bindValue(':groupid'.$cnt, '%,'.$groupid, PDO::PARAM_STR); + $cnt++; + } + } + if (isset($_GET['name'])) { + $dbdata->bindValue(':name', '%'.$name.'%', PDO::PARAM_STR); + } + if (isset($_GET['uuid'])) { + $dbdata->bindValue(':uuid', '%'.$uuid.'%', PDO::PARAM_STR); + } + + $dbdata->bindValue(':start', (int) $part, PDO::PARAM_INT); + $dbdata->bindValue(':limit', (int) $limit, PDO::PARAM_INT); + $dbdata->execute(); + $json = $dbdata->fetchAll(PDO::FETCH_ASSOC | PDO::FETCH_UNIQUE); + } +} elseif (isset($_GET['userstats'])) { + $filter = ' WHERE'; + if (isset($_GET['cldbid'])) { + $cldbid = htmlspecialchars_decode($_GET['cldbid']); + if ($filter != ' WHERE') { + $filter .= ' AND'; + } + $filter .= ' `cldbid` LIKE :cldbid'; + } + if (isset($_GET['groupid'])) { + $groupid = htmlspecialchars_decode($_GET['groupid']); + $explode_groupid = explode(',', $groupid); + if ($filter != ' WHERE') { + $filter .= ' AND'; + } + $filter .= ' ('; + $cnt = 0; + foreach ($explode_groupid as $groupid) { + if ($cnt > 0) { + $filter .= ' OR '; + } + $filter .= '`user`.`cldgroup` = :groupid'.$cnt; + $cnt++; + $filter .= ' OR `user`.`cldgroup` LIKE (:groupid'.$cnt.')'; + $cnt++; + $filter .= ' OR `user`.`cldgroup` LIKE (:groupid'.$cnt.')'; + $cnt++; + $filter .= ' OR `user`.`cldgroup` LIKE (:groupid'.$cnt.')'; + $cnt++; + } + $filter .= ')'; + } + if (isset($_GET['name'])) { + $name = htmlspecialchars_decode($_GET['name']); + if ($filter != ' WHERE') { + $filter .= ' AND'; + } + $filter .= ' `user`.`name` LIKE :name'; + } + if (! isset($_GET['sort'])) { + $sort = '`count_week`'; + } + if (isset($_GET['status']) && $_GET['status'] == strtolower('online')) { + if ($filter != ' WHERE') { + $filter .= ' AND'; + } + $filter .= ' `user`.`online`=1'; + } elseif (isset($_GET['status']) && $_GET['status'] == strtolower('offline')) { + if ($filter != ' WHERE') { + $filter .= ' AND'; + } + $filter .= ' `user`.`online`=0'; + } + if (isset($_GET['uuid'])) { + $uuid = htmlspecialchars_decode($_GET['uuid']); + if ($filter != ' WHERE') { + $filter .= ' AND'; + } + $filter .= ' `user`.`uuid` LIKE :uuid'; + } + if ($filter == ' WHERE') { + $filter = ''; + } + + if ($filter == '' && ! isset($_GET['all']) && ! isset($_GET['cldbid']) && ! isset($_GET['name']) && ! isset($_GET['uuid'])) { + $json = [ + 'usage' => [ + 'all' => [ + 'desc' => 'Get additional statistics about all TeamSpeak user. Result is limited by 100 entries.', + 'usage' => "Use \$_GET parameter 'all' without any value", + 'example' => '/api/?userstats&all', + ], + 'cldbid' => [ + 'desc' => 'Get details about TeamSpeak user by client TS-database ID', + 'usage' => "Use \$_GET parameter 'cldbid' and add as value a single client TS-database ID", + 'example' => '/api/?userstats&cldbid=7775', + ], + 'groupid' => [ + 'desc' => 'Get only user, which are in the given servergroup database ID', + 'usage' => "Use \$_GET parameter 'groupid' and add as value a database ID of a servergroup. Multiple servergroups can be specified comma-separated.", + 'example' => [ + '1' => [ + 'desc' => 'Filter by a single servergroup database ID', + 'url' => '/api/?userstats&groupid=6', + ], + '2' => [ + 'desc' => 'Filter by multiple servergroup database IDs. Only one of the specified groups must apply to get the concerned user.', + 'url' => '/api/?userstats&groupid=6,9,48', + ], + ], + ], + 'limit' => [ + 'desc' => 'Define a number that limits the number of results. Maximum value is 1000. Default is 100.', + 'usage' => "Use \$_GET parameter 'limit' and add as value a number above 1", + 'example' => '/api/?userstats&limit=10', + ], + 'name' => [ + 'desc' => 'Get details about TeamSpeak user by client nickname', + 'usage' => "Use \$_GET parameter 'name' and add as value a name or a part of it", + 'example' => [ + '1' => [ + 'desc' => 'Filter by client nickname', + 'url' => '/api/?userstats&name=Newcomer1989', + ], + '2' => [ + 'desc' => 'Filter by client nickname with a percent sign as placeholder', + 'url' => '/api/?userstats&name=%user%', + ], + ], + ], + 'order' => [ + 'desc' => 'Define a sorting order.', + 'usage' => "Use \$_GET parameter 'order' and add as value 'asc' for ascending or 'desc' for descending", + 'example' => '/api/?userstats&all&order=asc', + ], + 'part' => [ + 'desc' => 'Define, which part of the result you want to get. This is needed, when more then 100 clients are inside the result. At default you will get the first 100 clients. To get the next 100 clients, you will need to ask for part 2.', + 'usage' => "Use \$_GET parameter 'part' and add as value a number above 1", + 'example' => '/api/?userstats&all&part=2', + ], + 'sort' => [ + 'desc' => 'Define a sorting. Available is each column name, which is given back as a result.', + 'usage' => "Use \$_GET parameter 'sort' and add as value a column name", + 'example' => [ + '1' => [ + 'desc' => 'Sort by online time of the week', + 'url' => '/api/?userstats&all&sort=count_week', + ], + '2' => [ + 'desc' => 'Sort by active time of the week', + 'url' => '/api/?userstats&all&sort=(count_week-idle_week)', + ], + '3' => [ + 'desc' => 'Sort by online time of the month', + 'url' => '/api/?userstats&all&sort=count_month', + ], + ], + ], + 'status' => [ + 'desc' => 'List only clients, which status is online or offline.', + 'usage' => "Use \$_GET parameter 'status' and add as value 'online' or 'offline'", + 'example' => '/api/?userstats&status=online', + ], + 'uuid' => [ + 'desc' => 'Get additional statistics about TeamSpeak user by unique client ID', + 'usage' => "Use \$_GET parameter 'uuid' and add as value one unique client ID or a part of it", + 'example' => '/api/?userstats&uuid=xrTKhT/HDl4ea0WoFDQH2zOpmKg=', + ], + ], + ]; + } else { + $dbdata = $mysqlcon->prepare("SELECT * FROM `$dbname`.`stats_user` INNER JOIN `$dbname`.`user` ON `user`.`uuid` = `stats_user`.`uuid` {$filter} ORDER BY {$sort} {$order} LIMIT :start, :limit"); + if (isset($_GET['cldbid'])) { + $dbdata->bindValue(':cldbid', (int) $cldbid, PDO::PARAM_INT); + } + if (isset($_GET['groupid'])) { + $groupid = htmlspecialchars_decode($_GET['groupid']); + $explode_groupid = explode(',', $groupid); + $cnt = 0; + foreach ($explode_groupid as $groupid) { + $dbdata->bindValue(':groupid'.$cnt, $groupid, PDO::PARAM_STR); + $cnt++; + $dbdata->bindValue(':groupid'.$cnt, $groupid.',%', PDO::PARAM_STR); + $cnt++; + $dbdata->bindValue(':groupid'.$cnt, '%,'.$groupid.',%', PDO::PARAM_STR); + $cnt++; + $dbdata->bindValue(':groupid'.$cnt, '%,'.$groupid, PDO::PARAM_STR); + $cnt++; + } + } + if (isset($_GET['name'])) { + $dbdata->bindValue(':name', '%'.$name.'%', PDO::PARAM_STR); + } + if (isset($_GET['uuid'])) { + $dbdata->bindValue(':uuid', '%'.$uuid.'%', PDO::PARAM_STR); + } + + $dbdata->bindValue(':start', (int) $part, PDO::PARAM_INT); + $dbdata->bindValue(':limit', (int) $limit, PDO::PARAM_INT); + $dbdata->execute(); + $json = $dbdata->fetchAll(PDO::FETCH_ASSOC | PDO::FETCH_UNIQUE); + } +} else { + $json = [ + 'usage' => [ + 'bot' => [ + 'desc' => 'Use this to trigger Bot commands as starting or stopping the Ranksystem Bot.', + 'usage' => "Use \$_GET parameter 'bot'", + 'example' => '/api/?bot', + ], + 'groups' => [ + 'desc' => 'Get details about the TeamSpeak servergroups', + 'usage' => "Use \$_GET parameter 'groups'", + 'example' => '/api/?groups', + ], + 'rankconfig' => [ + 'desc' => 'Get the rankup definition, which contains the assignment of (needed) time to servergroup', + 'usage' => "Use \$_GET parameter 'rankconfig'", + 'example' => '/api/?rankconfig', + ], + 'server' => [ + 'desc' => 'Get details about the TeamSpeak server', + 'usage' => "Use \$_GET parameter 'server'", + 'example' => '/api/?server', + ], + 'user' => [ + 'desc' => 'Get details about the TeamSpeak user', + 'usage' => "Use \$_GET parameter 'user'", + 'example' => '/api/?user', + ], + 'userstats' => [ + 'desc' => 'Get additional statistics about the TeamSpeak user', + 'usage' => "Use \$_GET parameter 'userstats'", + 'example' => '/api/?userstats', + ], + ], + ]; +} + +echo json_encode($json); diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..ffecd44 --- /dev/null +++ b/composer.json @@ -0,0 +1,10 @@ +{ + "require-dev": { + "friendsofphp/php-cs-fixer": "^3.21" + }, + "scripts": { + "code-style": [ + "\"vendor/bin/php-cs-fixer\" fix --config .php-cs-fixer.php --diff" + ] + } +} diff --git a/composer.lock b/composer.lock new file mode 100644 index 0000000..8adc487 --- /dev/null +++ b/composer.lock @@ -0,0 +1,2045 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", + "This file is @generated automatically" + ], + "content-hash": "9c0a435b6b08561c362b45df3d7d7cb1", + "packages": [], + "packages-dev": [ + { + "name": "composer/pcre", + "version": "3.1.0", + "source": { + "type": "git", + "url": "https://github.com/composer/pcre.git", + "reference": "4bff79ddd77851fe3cdd11616ed3f92841ba5bd2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/pcre/zipball/4bff79ddd77851fe3cdd11616ed3f92841ba5bd2", + "reference": "4bff79ddd77851fe3cdd11616ed3f92841ba5bd2", + "shasum": "" + }, + "require": { + "php": "^7.4 || ^8.0" + }, + "require-dev": { + "phpstan/phpstan": "^1.3", + "phpstan/phpstan-strict-rules": "^1.1", + "symfony/phpunit-bridge": "^5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "3.x-dev" + } + }, + "autoload": { + "psr-4": { + "Composer\\Pcre\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be", + "homepage": "http://seld.be" + } + ], + "description": "PCRE wrapping library that offers type-safe preg_* replacements.", + "keywords": [ + "PCRE", + "preg", + "regex", + "regular expression" + ], + "support": { + "issues": "https://github.com/composer/pcre/issues", + "source": "https://github.com/composer/pcre/tree/3.1.0" + }, + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" + }, + { + "url": "https://github.com/composer", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/composer/composer", + "type": "tidelift" + } + ], + "time": "2022-11-17T09:50:14+00:00" + }, + { + "name": "composer/semver", + "version": "3.3.2", + "source": { + "type": "git", + "url": "https://github.com/composer/semver.git", + "reference": "3953f23262f2bff1919fc82183ad9acb13ff62c9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/semver/zipball/3953f23262f2bff1919fc82183ad9acb13ff62c9", + "reference": "3953f23262f2bff1919fc82183ad9acb13ff62c9", + "shasum": "" + }, + "require": { + "php": "^5.3.2 || ^7.0 || ^8.0" + }, + "require-dev": { + "phpstan/phpstan": "^1.4", + "symfony/phpunit-bridge": "^4.2 || ^5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "3.x-dev" + } + }, + "autoload": { + "psr-4": { + "Composer\\Semver\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nils Adermann", + "email": "naderman@naderman.de", + "homepage": "http://www.naderman.de" + }, + { + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be", + "homepage": "http://seld.be" + }, + { + "name": "Rob Bast", + "email": "rob.bast@gmail.com", + "homepage": "http://robbast.nl" + } + ], + "description": "Semver library that offers utilities, version constraint parsing and validation.", + "keywords": [ + "semantic", + "semver", + "validation", + "versioning" + ], + "support": { + "irc": "irc://irc.freenode.org/composer", + "issues": "https://github.com/composer/semver/issues", + "source": "https://github.com/composer/semver/tree/3.3.2" + }, + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" + }, + { + "url": "https://github.com/composer", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/composer/composer", + "type": "tidelift" + } + ], + "time": "2022-04-01T19:23:25+00:00" + }, + { + "name": "composer/xdebug-handler", + "version": "3.0.3", + "source": { + "type": "git", + "url": "https://github.com/composer/xdebug-handler.git", + "reference": "ced299686f41dce890debac69273b47ffe98a40c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/ced299686f41dce890debac69273b47ffe98a40c", + "reference": "ced299686f41dce890debac69273b47ffe98a40c", + "shasum": "" + }, + "require": { + "composer/pcre": "^1 || ^2 || ^3", + "php": "^7.2.5 || ^8.0", + "psr/log": "^1 || ^2 || ^3" + }, + "require-dev": { + "phpstan/phpstan": "^1.0", + "phpstan/phpstan-strict-rules": "^1.1", + "symfony/phpunit-bridge": "^6.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Composer\\XdebugHandler\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "John Stevenson", + "email": "john-stevenson@blueyonder.co.uk" + } + ], + "description": "Restarts a process without Xdebug.", + "keywords": [ + "Xdebug", + "performance" + ], + "support": { + "irc": "irc://irc.freenode.org/composer", + "issues": "https://github.com/composer/xdebug-handler/issues", + "source": "https://github.com/composer/xdebug-handler/tree/3.0.3" + }, + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" + }, + { + "url": "https://github.com/composer", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/composer/composer", + "type": "tidelift" + } + ], + "time": "2022-02-25T21:32:43+00:00" + }, + { + "name": "doctrine/annotations", + "version": "2.0.1", + "source": { + "type": "git", + "url": "https://github.com/doctrine/annotations.git", + "reference": "e157ef3f3124bbf6fe7ce0ffd109e8a8ef284e7f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/annotations/zipball/e157ef3f3124bbf6fe7ce0ffd109e8a8ef284e7f", + "reference": "e157ef3f3124bbf6fe7ce0ffd109e8a8ef284e7f", + "shasum": "" + }, + "require": { + "doctrine/lexer": "^2 || ^3", + "ext-tokenizer": "*", + "php": "^7.2 || ^8.0", + "psr/cache": "^1 || ^2 || ^3" + }, + "require-dev": { + "doctrine/cache": "^2.0", + "doctrine/coding-standard": "^10", + "phpstan/phpstan": "^1.8.0", + "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5", + "symfony/cache": "^5.4 || ^6", + "vimeo/psalm": "^4.10" + }, + "suggest": { + "php": "PHP 8.0 or higher comes with attributes, a native replacement for annotations" + }, + "type": "library", + "autoload": { + "psr-4": { + "Doctrine\\Common\\Annotations\\": "lib/Doctrine/Common/Annotations" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + } + ], + "description": "Docblock Annotations Parser", + "homepage": "https://www.doctrine-project.org/projects/annotations.html", + "keywords": [ + "annotations", + "docblock", + "parser" + ], + "support": { + "issues": "https://github.com/doctrine/annotations/issues", + "source": "https://github.com/doctrine/annotations/tree/2.0.1" + }, + "time": "2023-02-02T22:02:53+00:00" + }, + { + "name": "doctrine/lexer", + "version": "3.0.0", + "source": { + "type": "git", + "url": "https://github.com/doctrine/lexer.git", + "reference": "84a527db05647743d50373e0ec53a152f2cde568" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/lexer/zipball/84a527db05647743d50373e0ec53a152f2cde568", + "reference": "84a527db05647743d50373e0ec53a152f2cde568", + "shasum": "" + }, + "require": { + "php": "^8.1" + }, + "require-dev": { + "doctrine/coding-standard": "^10", + "phpstan/phpstan": "^1.9", + "phpunit/phpunit": "^9.5", + "psalm/plugin-phpunit": "^0.18.3", + "vimeo/psalm": "^5.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Doctrine\\Common\\Lexer\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + } + ], + "description": "PHP Doctrine Lexer parser library that can be used in Top-Down, Recursive Descent Parsers.", + "homepage": "https://www.doctrine-project.org/projects/lexer.html", + "keywords": [ + "annotations", + "docblock", + "lexer", + "parser", + "php" + ], + "support": { + "issues": "https://github.com/doctrine/lexer/issues", + "source": "https://github.com/doctrine/lexer/tree/3.0.0" + }, + "funding": [ + { + "url": "https://www.doctrine-project.org/sponsorship.html", + "type": "custom" + }, + { + "url": "https://www.patreon.com/phpdoctrine", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/doctrine%2Flexer", + "type": "tidelift" + } + ], + "time": "2022-12-15T16:57:16+00:00" + }, + { + "name": "friendsofphp/php-cs-fixer", + "version": "v3.21.1", + "source": { + "type": "git", + "url": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer.git", + "reference": "229b55b3eae4729a8e2a321441ba40fcb3720b86" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/229b55b3eae4729a8e2a321441ba40fcb3720b86", + "reference": "229b55b3eae4729a8e2a321441ba40fcb3720b86", + "shasum": "" + }, + "require": { + "composer/semver": "^3.3", + "composer/xdebug-handler": "^3.0.3", + "doctrine/annotations": "^2", + "doctrine/lexer": "^2 || ^3", + "ext-json": "*", + "ext-tokenizer": "*", + "php": "^8.0.1", + "sebastian/diff": "^4.0 || ^5.0", + "symfony/console": "^5.4 || ^6.0", + "symfony/event-dispatcher": "^5.4 || ^6.0", + "symfony/filesystem": "^5.4 || ^6.0", + "symfony/finder": "^5.4 || ^6.0", + "symfony/options-resolver": "^5.4 || ^6.0", + "symfony/polyfill-mbstring": "^1.27", + "symfony/polyfill-php80": "^1.27", + "symfony/polyfill-php81": "^1.27", + "symfony/process": "^5.4 || ^6.0", + "symfony/stopwatch": "^5.4 || ^6.0" + }, + "require-dev": { + "justinrainbow/json-schema": "^5.2", + "keradus/cli-executor": "^2.0", + "mikey179/vfsstream": "^1.6.11", + "php-coveralls/php-coveralls": "^2.5.3", + "php-cs-fixer/accessible-object": "^1.1", + "php-cs-fixer/phpunit-constraint-isidenticalstring": "^1.2", + "php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "^1.2.1", + "phpspec/prophecy": "^1.16", + "phpspec/prophecy-phpunit": "^2.0", + "phpunit/phpunit": "^9.5", + "phpunitgoodpractices/polyfill": "^1.6", + "phpunitgoodpractices/traits": "^1.9.2", + "symfony/phpunit-bridge": "^6.2.3", + "symfony/yaml": "^5.4 || ^6.0" + }, + "suggest": { + "ext-dom": "For handling output formats in XML", + "ext-mbstring": "For handling non-UTF8 characters." + }, + "bin": [ + "php-cs-fixer" + ], + "type": "application", + "autoload": { + "psr-4": { + "PhpCsFixer\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Dariusz Rumiński", + "email": "dariusz.ruminski@gmail.com" + } + ], + "description": "A tool to automatically fix PHP code style", + "keywords": [ + "Static code analysis", + "fixer", + "standards", + "static analysis" + ], + "support": { + "issues": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues", + "source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.21.1" + }, + "funding": [ + { + "url": "https://github.com/keradus", + "type": "github" + } + ], + "time": "2023-07-05T21:50:25+00:00" + }, + { + "name": "psr/cache", + "version": "3.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/cache.git", + "reference": "aa5030cfa5405eccfdcb1083ce040c2cb8d253bf" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/cache/zipball/aa5030cfa5405eccfdcb1083ce040c2cb8d253bf", + "reference": "aa5030cfa5405eccfdcb1083ce040c2cb8d253bf", + "shasum": "" + }, + "require": { + "php": ">=8.0.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Cache\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common interface for caching libraries", + "keywords": [ + "cache", + "psr", + "psr-6" + ], + "support": { + "source": "https://github.com/php-fig/cache/tree/3.0.0" + }, + "time": "2021-02-03T23:26:27+00:00" + }, + { + "name": "psr/container", + "version": "2.0.2", + "source": { + "type": "git", + "url": "https://github.com/php-fig/container.git", + "reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/container/zipball/c71ecc56dfe541dbd90c5360474fbc405f8d5963", + "reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963", + "shasum": "" + }, + "require": { + "php": ">=7.4.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Container\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common Container Interface (PHP FIG PSR-11)", + "homepage": "https://github.com/php-fig/container", + "keywords": [ + "PSR-11", + "container", + "container-interface", + "container-interop", + "psr" + ], + "support": { + "issues": "https://github.com/php-fig/container/issues", + "source": "https://github.com/php-fig/container/tree/2.0.2" + }, + "time": "2021-11-05T16:47:00+00:00" + }, + { + "name": "psr/event-dispatcher", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/event-dispatcher.git", + "reference": "dbefd12671e8a14ec7f180cab83036ed26714bb0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/event-dispatcher/zipball/dbefd12671e8a14ec7f180cab83036ed26714bb0", + "reference": "dbefd12671e8a14ec7f180cab83036ed26714bb0", + "shasum": "" + }, + "require": { + "php": ">=7.2.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\EventDispatcher\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Standard interfaces for event handling.", + "keywords": [ + "events", + "psr", + "psr-14" + ], + "support": { + "issues": "https://github.com/php-fig/event-dispatcher/issues", + "source": "https://github.com/php-fig/event-dispatcher/tree/1.0.0" + }, + "time": "2019-01-08T18:20:26+00:00" + }, + { + "name": "psr/log", + "version": "3.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/log.git", + "reference": "fe5ea303b0887d5caefd3d431c3e61ad47037001" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/log/zipball/fe5ea303b0887d5caefd3d431c3e61ad47037001", + "reference": "fe5ea303b0887d5caefd3d431c3e61ad47037001", + "shasum": "" + }, + "require": { + "php": ">=8.0.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Log\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common interface for logging libraries", + "homepage": "https://github.com/php-fig/log", + "keywords": [ + "log", + "psr", + "psr-3" + ], + "support": { + "source": "https://github.com/php-fig/log/tree/3.0.0" + }, + "time": "2021-07-14T16:46:02+00:00" + }, + { + "name": "sebastian/diff", + "version": "5.0.3", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/diff.git", + "reference": "912dc2fbe3e3c1e7873313cc801b100b6c68c87b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/912dc2fbe3e3c1e7873313cc801b100b6c68c87b", + "reference": "912dc2fbe3e3c1e7873313cc801b100b6c68c87b", + "shasum": "" + }, + "require": { + "php": ">=8.1" + }, + "require-dev": { + "phpunit/phpunit": "^10.0", + "symfony/process": "^4.2 || ^5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "5.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Kore Nordmann", + "email": "mail@kore-nordmann.de" + } + ], + "description": "Diff implementation", + "homepage": "https://github.com/sebastianbergmann/diff", + "keywords": [ + "diff", + "udiff", + "unidiff", + "unified diff" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/diff/issues", + "security": "https://github.com/sebastianbergmann/diff/security/policy", + "source": "https://github.com/sebastianbergmann/diff/tree/5.0.3" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2023-05-01T07:48:21+00:00" + }, + { + "name": "symfony/console", + "version": "v6.3.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/console.git", + "reference": "8788808b07cf0bdd6e4b7fdd23d8ddb1470c83b7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/console/zipball/8788808b07cf0bdd6e4b7fdd23d8ddb1470c83b7", + "reference": "8788808b07cf0bdd6e4b7fdd23d8ddb1470c83b7", + "shasum": "" + }, + "require": { + "php": ">=8.1", + "symfony/deprecation-contracts": "^2.5|^3", + "symfony/polyfill-mbstring": "~1.0", + "symfony/service-contracts": "^2.5|^3", + "symfony/string": "^5.4|^6.0" + }, + "conflict": { + "symfony/dependency-injection": "<5.4", + "symfony/dotenv": "<5.4", + "symfony/event-dispatcher": "<5.4", + "symfony/lock": "<5.4", + "symfony/process": "<5.4" + }, + "provide": { + "psr/log-implementation": "1.0|2.0|3.0" + }, + "require-dev": { + "psr/log": "^1|^2|^3", + "symfony/config": "^5.4|^6.0", + "symfony/dependency-injection": "^5.4|^6.0", + "symfony/event-dispatcher": "^5.4|^6.0", + "symfony/lock": "^5.4|^6.0", + "symfony/process": "^5.4|^6.0", + "symfony/var-dumper": "^5.4|^6.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Console\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Eases the creation of beautiful and testable command line interfaces", + "homepage": "https://symfony.com", + "keywords": [ + "cli", + "command-line", + "console", + "terminal" + ], + "support": { + "source": "https://github.com/symfony/console/tree/v6.3.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2023-05-29T12:49:39+00:00" + }, + { + "name": "symfony/deprecation-contracts", + "version": "v3.3.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/deprecation-contracts.git", + "reference": "7c3aff79d10325257a001fcf92d991f24fc967cf" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/7c3aff79d10325257a001fcf92d991f24fc967cf", + "reference": "7c3aff79d10325257a001fcf92d991f24fc967cf", + "shasum": "" + }, + "require": { + "php": ">=8.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "3.4-dev" + }, + "thanks": { + "name": "symfony/contracts", + "url": "https://github.com/symfony/contracts" + } + }, + "autoload": { + "files": [ + "function.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "A generic function and convention to trigger deprecation notices", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/deprecation-contracts/tree/v3.3.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2023-05-23T14:45:45+00:00" + }, + { + "name": "symfony/event-dispatcher", + "version": "v6.3.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/event-dispatcher.git", + "reference": "3af8ac1a3f98f6dbc55e10ae59c9e44bfc38dfaa" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/3af8ac1a3f98f6dbc55e10ae59c9e44bfc38dfaa", + "reference": "3af8ac1a3f98f6dbc55e10ae59c9e44bfc38dfaa", + "shasum": "" + }, + "require": { + "php": ">=8.1", + "symfony/event-dispatcher-contracts": "^2.5|^3" + }, + "conflict": { + "symfony/dependency-injection": "<5.4", + "symfony/service-contracts": "<2.5" + }, + "provide": { + "psr/event-dispatcher-implementation": "1.0", + "symfony/event-dispatcher-implementation": "2.0|3.0" + }, + "require-dev": { + "psr/log": "^1|^2|^3", + "symfony/config": "^5.4|^6.0", + "symfony/dependency-injection": "^5.4|^6.0", + "symfony/error-handler": "^5.4|^6.0", + "symfony/expression-language": "^5.4|^6.0", + "symfony/http-foundation": "^5.4|^6.0", + "symfony/service-contracts": "^2.5|^3", + "symfony/stopwatch": "^5.4|^6.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\EventDispatcher\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides tools that allow your application components to communicate with each other by dispatching events and listening to them", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/event-dispatcher/tree/v6.3.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2023-04-21T14:41:17+00:00" + }, + { + "name": "symfony/event-dispatcher-contracts", + "version": "v3.3.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/event-dispatcher-contracts.git", + "reference": "a76aed96a42d2b521153fb382d418e30d18b59df" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/event-dispatcher-contracts/zipball/a76aed96a42d2b521153fb382d418e30d18b59df", + "reference": "a76aed96a42d2b521153fb382d418e30d18b59df", + "shasum": "" + }, + "require": { + "php": ">=8.1", + "psr/event-dispatcher": "^1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "3.4-dev" + }, + "thanks": { + "name": "symfony/contracts", + "url": "https://github.com/symfony/contracts" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Contracts\\EventDispatcher\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Generic abstractions related to dispatching event", + "homepage": "https://symfony.com", + "keywords": [ + "abstractions", + "contracts", + "decoupling", + "interfaces", + "interoperability", + "standards" + ], + "support": { + "source": "https://github.com/symfony/event-dispatcher-contracts/tree/v3.3.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2023-05-23T14:45:45+00:00" + }, + { + "name": "symfony/filesystem", + "version": "v6.3.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/filesystem.git", + "reference": "edd36776956f2a6fcf577edb5b05eb0e3bdc52ae" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/edd36776956f2a6fcf577edb5b05eb0e3bdc52ae", + "reference": "edd36776956f2a6fcf577edb5b05eb0e3bdc52ae", + "shasum": "" + }, + "require": { + "php": ">=8.1", + "symfony/polyfill-ctype": "~1.8", + "symfony/polyfill-mbstring": "~1.8" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Filesystem\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides basic utilities for the filesystem", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/filesystem/tree/v6.3.1" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2023-06-01T08:30:39+00:00" + }, + { + "name": "symfony/finder", + "version": "v6.3.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/finder.git", + "reference": "d9b01ba073c44cef617c7907ce2419f8d00d75e2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/finder/zipball/d9b01ba073c44cef617c7907ce2419f8d00d75e2", + "reference": "d9b01ba073c44cef617c7907ce2419f8d00d75e2", + "shasum": "" + }, + "require": { + "php": ">=8.1" + }, + "require-dev": { + "symfony/filesystem": "^6.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Finder\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Finds files and directories via an intuitive fluent interface", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/finder/tree/v6.3.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2023-04-02T01:25:41+00:00" + }, + { + "name": "symfony/options-resolver", + "version": "v6.3.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/options-resolver.git", + "reference": "a10f19f5198d589d5c33333cffe98dc9820332dd" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/options-resolver/zipball/a10f19f5198d589d5c33333cffe98dc9820332dd", + "reference": "a10f19f5198d589d5c33333cffe98dc9820332dd", + "shasum": "" + }, + "require": { + "php": ">=8.1", + "symfony/deprecation-contracts": "^2.5|^3" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\OptionsResolver\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides an improved replacement for the array_replace PHP function", + "homepage": "https://symfony.com", + "keywords": [ + "config", + "configuration", + "options" + ], + "support": { + "source": "https://github.com/symfony/options-resolver/tree/v6.3.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2023-05-12T14:21:09+00:00" + }, + { + "name": "symfony/polyfill-ctype", + "version": "v1.27.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-ctype.git", + "reference": "5bbc823adecdae860bb64756d639ecfec17b050a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/5bbc823adecdae860bb64756d639ecfec17b050a", + "reference": "5bbc823adecdae860bb64756d639ecfec17b050a", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "provide": { + "ext-ctype": "*" + }, + "suggest": { + "ext-ctype": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.27-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Ctype\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Gert de Pagter", + "email": "BackEndTea@gmail.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for ctype functions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "ctype", + "polyfill", + "portable" + ], + "support": { + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.27.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2022-11-03T14:55:06+00:00" + }, + { + "name": "symfony/polyfill-intl-grapheme", + "version": "v1.27.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-intl-grapheme.git", + "reference": "511a08c03c1960e08a883f4cffcacd219b758354" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/511a08c03c1960e08a883f4cffcacd219b758354", + "reference": "511a08c03c1960e08a883f4cffcacd219b758354", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "suggest": { + "ext-intl": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.27-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Intl\\Grapheme\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for intl's grapheme_* functions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "grapheme", + "intl", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.27.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2022-11-03T14:55:06+00:00" + }, + { + "name": "symfony/polyfill-intl-normalizer", + "version": "v1.27.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-intl-normalizer.git", + "reference": "19bd1e4fcd5b91116f14d8533c57831ed00571b6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/19bd1e4fcd5b91116f14d8533c57831ed00571b6", + "reference": "19bd1e4fcd5b91116f14d8533c57831ed00571b6", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "suggest": { + "ext-intl": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.27-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Intl\\Normalizer\\": "" + }, + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for intl's Normalizer class and related functions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "intl", + "normalizer", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.27.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2022-11-03T14:55:06+00:00" + }, + { + "name": "symfony/polyfill-mbstring", + "version": "v1.27.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-mbstring.git", + "reference": "8ad114f6b39e2c98a8b0e3bd907732c207c2b534" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/8ad114f6b39e2c98a8b0e3bd907732c207c2b534", + "reference": "8ad114f6b39e2c98a8b0e3bd907732c207c2b534", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "provide": { + "ext-mbstring": "*" + }, + "suggest": { + "ext-mbstring": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.27-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Mbstring\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for the Mbstring extension", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "mbstring", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.27.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2022-11-03T14:55:06+00:00" + }, + { + "name": "symfony/polyfill-php80", + "version": "v1.27.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php80.git", + "reference": "7a6ff3f1959bb01aefccb463a0f2cd3d3d2fd936" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/7a6ff3f1959bb01aefccb463a0f2cd3d3d2fd936", + "reference": "7a6ff3f1959bb01aefccb463a0f2cd3d3d2fd936", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.27-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Php80\\": "" + }, + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ion Bazan", + "email": "ion.bazan@gmail.com" + }, + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-php80/tree/v1.27.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2022-11-03T14:55:06+00:00" + }, + { + "name": "symfony/polyfill-php81", + "version": "v1.27.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php81.git", + "reference": "707403074c8ea6e2edaf8794b0157a0bfa52157a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php81/zipball/707403074c8ea6e2edaf8794b0157a0bfa52157a", + "reference": "707403074c8ea6e2edaf8794b0157a0bfa52157a", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.27-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Php81\\": "" + }, + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 8.1+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-php81/tree/v1.27.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2022-11-03T14:55:06+00:00" + }, + { + "name": "symfony/process", + "version": "v6.3.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/process.git", + "reference": "8741e3ed7fe2e91ec099e02446fb86667a0f1628" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/process/zipball/8741e3ed7fe2e91ec099e02446fb86667a0f1628", + "reference": "8741e3ed7fe2e91ec099e02446fb86667a0f1628", + "shasum": "" + }, + "require": { + "php": ">=8.1" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Process\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Executes commands in sub-processes", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/process/tree/v6.3.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2023-05-19T08:06:44+00:00" + }, + { + "name": "symfony/service-contracts", + "version": "v3.3.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/service-contracts.git", + "reference": "40da9cc13ec349d9e4966ce18b5fbcd724ab10a4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/service-contracts/zipball/40da9cc13ec349d9e4966ce18b5fbcd724ab10a4", + "reference": "40da9cc13ec349d9e4966ce18b5fbcd724ab10a4", + "shasum": "" + }, + "require": { + "php": ">=8.1", + "psr/container": "^2.0" + }, + "conflict": { + "ext-psr": "<1.1|>=2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "3.4-dev" + }, + "thanks": { + "name": "symfony/contracts", + "url": "https://github.com/symfony/contracts" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Contracts\\Service\\": "" + }, + "exclude-from-classmap": [ + "/Test/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Generic abstractions related to writing services", + "homepage": "https://symfony.com", + "keywords": [ + "abstractions", + "contracts", + "decoupling", + "interfaces", + "interoperability", + "standards" + ], + "support": { + "source": "https://github.com/symfony/service-contracts/tree/v3.3.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2023-05-23T14:45:45+00:00" + }, + { + "name": "symfony/stopwatch", + "version": "v6.3.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/stopwatch.git", + "reference": "fc47f1015ec80927ff64ba9094dfe8b9d48fe9f2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/stopwatch/zipball/fc47f1015ec80927ff64ba9094dfe8b9d48fe9f2", + "reference": "fc47f1015ec80927ff64ba9094dfe8b9d48fe9f2", + "shasum": "" + }, + "require": { + "php": ">=8.1", + "symfony/service-contracts": "^2.5|^3" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Stopwatch\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides a way to profile code", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/stopwatch/tree/v6.3.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2023-02-16T10:14:28+00:00" + }, + { + "name": "symfony/string", + "version": "v6.3.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/string.git", + "reference": "f2e190ee75ff0f5eced645ec0be5c66fac81f51f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/string/zipball/f2e190ee75ff0f5eced645ec0be5c66fac81f51f", + "reference": "f2e190ee75ff0f5eced645ec0be5c66fac81f51f", + "shasum": "" + }, + "require": { + "php": ">=8.1", + "symfony/polyfill-ctype": "~1.8", + "symfony/polyfill-intl-grapheme": "~1.0", + "symfony/polyfill-intl-normalizer": "~1.0", + "symfony/polyfill-mbstring": "~1.0" + }, + "conflict": { + "symfony/translation-contracts": "<2.5" + }, + "require-dev": { + "symfony/error-handler": "^5.4|^6.0", + "symfony/http-client": "^5.4|^6.0", + "symfony/intl": "^6.2", + "symfony/translation-contracts": "^2.5|^3.0", + "symfony/var-exporter": "^5.4|^6.0" + }, + "type": "library", + "autoload": { + "files": [ + "Resources/functions.php" + ], + "psr-4": { + "Symfony\\Component\\String\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides an object-oriented API to strings and deals with bytes, UTF-8 code points and grapheme clusters in a unified way", + "homepage": "https://symfony.com", + "keywords": [ + "grapheme", + "i18n", + "string", + "unicode", + "utf-8", + "utf8" + ], + "support": { + "source": "https://github.com/symfony/string/tree/v6.3.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2023-03-21T21:06:29+00:00" + } + ], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": [], + "platform-dev": [], + "plugin-api-version": "2.3.0" +} diff --git a/index.php b/index.php index b125c42..b7a0bfc 100644 --- a/index.php +++ b/index.php @@ -1,8 +1,8 @@ - \ No newline at end of file + + @@ -21,81 +21,86 @@
-'; - - if(!is_writable('./other/dbconfig.php')) { - $err_msg = $lang['isntwicfg']; - $err_lvl = 2; - } else { - $count = 1; - $stmt = $mysqlcon->query('SHOW DATABASES'); - while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { - if ($row['Database'] == $dbname) { - $dbExists = true; - break; - } - } - if ($dbExists) { - if(($mysqlcon->exec("DROP DATABASE `$dbname`")) === false) { } - } - - if($mysqlcon->exec("CREATE DATABASE `$dbname`") === false) { - $err_msg .= $lang['isntwidbmsg'].$mysqlcon->errorCode()." ".print_r($mysqlcon->errorInfo(), true).'
'; $err_lvl = 2; - $count++; - } - - if($mysqlcon->exec("CREATE TABLE `$dbname`.`user` ( +?>'; + + if (! is_writable('./other/dbconfig.php')) { + $err_msg = $lang['isntwicfg']; + $err_lvl = 2; + } else { + $count = 1; + $stmt = $mysqlcon->query('SHOW DATABASES'); + while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { + if ($row['Database'] == $dbname) { + $dbExists = true; + break; + } + } + if ($dbExists) { + if (($mysqlcon->exec("DROP DATABASE `$dbname`")) === false) { + } + } + + if ($mysqlcon->exec("CREATE DATABASE `$dbname`") === false) { + $err_msg .= $lang['isntwidbmsg'].$mysqlcon->errorCode().' '.print_r($mysqlcon->errorInfo(), true).'
'; + $err_lvl = 2; + $count++; + } + + if ($mysqlcon->exec("CREATE TABLE `$dbname`.`user` ( `uuid` char(28) CHARACTER SET utf8 COLLATE utf8_unicode_ci PRIMARY KEY, `cldbid` int(10) NOT NULL default '0', `count` DECIMAL(14,3) NOT NULL default '0', @@ -115,25 +120,29 @@ function install($type, $host, $user, $pass, $dbname, $lang, $mysqlcon, &$err_ms `except` tinyint(1) NOT NULL default '0', `grpsince` int(10) UNSIGNED NOT NULL default '0', `cid` int(10) NOT NULL default '0' - );") === false) { - $err_msg .= $lang['isntwidbmsg'].$mysqlcon->errorCode()." ".print_r($mysqlcon->errorInfo(), true).'
'; $err_lvl = 2; - $count++; - } else { - if($mysqlcon->exec("CREATE INDEX `user_version` ON `$dbname`.`user` (`version`)") === false) { - $err_msg .= $lang['isntwidbmsg'].$mysqlcon->errorCode()." ".print_r($mysqlcon->errorInfo(), true).'
'; $err_lvl = 2; - $count++; - } - if($mysqlcon->exec("CREATE INDEX `user_cldbid` ON `$dbname`.`user` (`cldbid` ASC,`uuid`,`rank`)") === false) { - $err_msg .= $lang['isntwidbmsg'].$mysqlcon->errorCode()." ".print_r($mysqlcon->errorInfo(), true).'
'; $err_lvl = 2; - $count++; - } - if($mysqlcon->exec("CREATE INDEX `user_online` ON `$dbname`.`user` (`online`,`lastseen`)") === false) { - $err_msg .= $lang['isntwidbmsg'].$mysqlcon->errorCode()." ".print_r($mysqlcon->errorInfo(), true).'
'; $err_lvl = 2; - $count++; - } - } - - if($mysqlcon->exec("CREATE TABLE `$dbname`.`groups` ( + );") === false) { + $err_msg .= $lang['isntwidbmsg'].$mysqlcon->errorCode().' '.print_r($mysqlcon->errorInfo(), true).'
'; + $err_lvl = 2; + $count++; + } else { + if ($mysqlcon->exec("CREATE INDEX `user_version` ON `$dbname`.`user` (`version`)") === false) { + $err_msg .= $lang['isntwidbmsg'].$mysqlcon->errorCode().' '.print_r($mysqlcon->errorInfo(), true).'
'; + $err_lvl = 2; + $count++; + } + if ($mysqlcon->exec("CREATE INDEX `user_cldbid` ON `$dbname`.`user` (`cldbid` ASC,`uuid`,`rank`)") === false) { + $err_msg .= $lang['isntwidbmsg'].$mysqlcon->errorCode().' '.print_r($mysqlcon->errorInfo(), true).'
'; + $err_lvl = 2; + $count++; + } + if ($mysqlcon->exec("CREATE INDEX `user_online` ON `$dbname`.`user` (`online`,`lastseen`)") === false) { + $err_msg .= $lang['isntwidbmsg'].$mysqlcon->errorCode().' '.print_r($mysqlcon->errorInfo(), true).'
'; + $err_lvl = 2; + $count++; + } + } + + if ($mysqlcon->exec("CREATE TABLE `$dbname`.`groups` ( `sgid` int(10) UNSIGNED NOT NULL default '0' PRIMARY KEY, `sgidname` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, `iconid` bigint(10) NOT NULL default '0', @@ -141,54 +150,61 @@ function install($type, $host, $user, $pass, $dbname, $lang, $mysqlcon, &$err_ms `sortid` int(10) NOT NULL default '0', `type` tinyint(1) NOT NULL default '0', `ext` char(3) CHARACTER SET utf8 COLLATE utf8_unicode_ci - );") === false) { - $err_msg .= $lang['isntwidbmsg'].$mysqlcon->errorCode()." ".print_r($mysqlcon->errorInfo(), true).'
'; $err_lvl = 2; - $count++; - } - - if($mysqlcon->exec("CREATE TABLE `$dbname`.`cfg_params` ( + );") === false) { + $err_msg .= $lang['isntwidbmsg'].$mysqlcon->errorCode().' '.print_r($mysqlcon->errorInfo(), true).'
'; + $err_lvl = 2; + $count++; + } + + if ($mysqlcon->exec("CREATE TABLE `$dbname`.`cfg_params` ( `param` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci PRIMARY KEY, `value` varchar(21588) CHARACTER SET utf8 COLLATE utf8_unicode_ci - );") === false) { - $err_msg .= $lang['isntwidbmsg'].$mysqlcon->errorCode()." ".print_r($mysqlcon->errorInfo(), true).'
'; $err_lvl = 2; - $count++; - } - - if($mysqlcon->exec("CREATE TABLE `$dbname`.`server_usage` ( + );") === false) { + $err_msg .= $lang['isntwidbmsg'].$mysqlcon->errorCode().' '.print_r($mysqlcon->errorInfo(), true).'
'; + $err_lvl = 2; + $count++; + } + + if ($mysqlcon->exec("CREATE TABLE `$dbname`.`server_usage` ( `timestamp` int(10) UNSIGNED NOT NULL default '0', `clients` smallint(5) UNSIGNED NOT NULL default '0', `channel` smallint(5) UNSIGNED NOT NULL default '0' - );") === false) { - $err_msg .= $lang['isntwidbmsg'].$mysqlcon->errorCode()." ".print_r($mysqlcon->errorInfo(), true).'
'; $err_lvl = 2; - $count++; - } else { - if($mysqlcon->exec("CREATE INDEX `serverusage_timestamp` ON `$dbname`.`server_usage` (`timestamp`)") === false) { - $err_msg .= $lang['isntwidbmsg'].$mysqlcon->errorCode()." ".print_r($mysqlcon->errorInfo(), true).'
'; $err_lvl = 2; - $count++; - } - } - - if($mysqlcon->exec("CREATE TABLE `$dbname`.`user_snapshot` ( + );") === false) { + $err_msg .= $lang['isntwidbmsg'].$mysqlcon->errorCode().' '.print_r($mysqlcon->errorInfo(), true).'
'; + $err_lvl = 2; + $count++; + } else { + if ($mysqlcon->exec("CREATE INDEX `serverusage_timestamp` ON `$dbname`.`server_usage` (`timestamp`)") === false) { + $err_msg .= $lang['isntwidbmsg'].$mysqlcon->errorCode().' '.print_r($mysqlcon->errorInfo(), true).'
'; + $err_lvl = 2; + $count++; + } + } + + if ($mysqlcon->exec("CREATE TABLE `$dbname`.`user_snapshot` ( `id` tinyint(3) UNSIGNED NOT NULL default '0', `cldbid` int(10) UNSIGNED NOT NULL default '0', `count` int(10) UNSIGNED NOT NULL default '0', `idle` int(10) UNSIGNED NOT NULL default '0', PRIMARY KEY (`id`,`cldbid`) - );") === false) { - $err_msg .= $lang['isntwidbmsg'].$mysqlcon->errorCode()." ".print_r($mysqlcon->errorInfo(), true).'
'; $err_lvl = 2; - $count++; - } else { - if($mysqlcon->exec("CREATE INDEX `snapshot_id` ON `$dbname`.`user_snapshot` (`id`)") === false) { - $err_msg .= $lang['isntwidbmsg'].$mysqlcon->errorCode()." ".print_r($mysqlcon->errorInfo(), true).'
'; $err_lvl = 2; - $count++; - } - if($mysqlcon->exec("CREATE INDEX `snapshot_cldbid` ON `$dbname`.`user_snapshot` (`cldbid`)") === false) { - $err_msg .= $lang['isntwidbmsg'].$mysqlcon->errorCode()." ".print_r($mysqlcon->errorInfo(), true).'
'; $err_lvl = 2; - $count++; - } - } - - if($mysqlcon->exec("CREATE TABLE `$dbname`.`stats_server` ( + );") === false) { + $err_msg .= $lang['isntwidbmsg'].$mysqlcon->errorCode().' '.print_r($mysqlcon->errorInfo(), true).'
'; + $err_lvl = 2; + $count++; + } else { + if ($mysqlcon->exec("CREATE INDEX `snapshot_id` ON `$dbname`.`user_snapshot` (`id`)") === false) { + $err_msg .= $lang['isntwidbmsg'].$mysqlcon->errorCode().' '.print_r($mysqlcon->errorInfo(), true).'
'; + $err_lvl = 2; + $count++; + } + if ($mysqlcon->exec("CREATE INDEX `snapshot_cldbid` ON `$dbname`.`user_snapshot` (`cldbid`)") === false) { + $err_msg .= $lang['isntwidbmsg'].$mysqlcon->errorCode().' '.print_r($mysqlcon->errorInfo(), true).'
'; + $err_lvl = 2; + $count++; + } + } + + if ($mysqlcon->exec("CREATE TABLE `$dbname`.`stats_server` ( `total_user` int(10) NOT NULL default '0', `total_online_time` bigint(13) NOT NULL default '0', `total_online_month` bigint(11) NOT NULL default '0', @@ -243,12 +259,13 @@ function install($type, $host, $user, $pass, $dbname, $lang, $mysqlcon, &$err_ms `user_week` int(10) NOT NULL default '0', `user_month` int(10) NOT NULL default '0', `user_quarter` int(10) NOT NULL default '0' - );") === false) { - $err_msg .= $lang['isntwidbmsg'].$mysqlcon->errorCode()." ".print_r($mysqlcon->errorInfo(), true).'
'; $err_lvl = 2; - $count++; - } - - if($mysqlcon->exec("CREATE TABLE `$dbname`.`stats_user` ( + );") === false) { + $err_msg .= $lang['isntwidbmsg'].$mysqlcon->errorCode().' '.print_r($mysqlcon->errorInfo(), true).'
'; + $err_lvl = 2; + $count++; + } + + if ($mysqlcon->exec("CREATE TABLE `$dbname`.`stats_user` ( `uuid` char(28) CHARACTER SET utf8 COLLATE utf8_unicode_ci PRIMARY KEY, `active_day` mediumint(8) UNSIGNED NOT NULL default '0', `active_month` mediumint(8) UNSIGNED NOT NULL default '0', @@ -266,44 +283,49 @@ function install($type, $host, $user, $pass, $dbname, $lang, $mysqlcon, &$err_ms `last_calculated` int(10) UNSIGNED NOT NULL default '0', `removed` tinyint(1) NOT NULL default '0', `total_connections` MEDIUMINT(8) UNSIGNED NOT NULL default '0' - );") === false) { - $err_msg .= $lang['isntwidbmsg'].$mysqlcon->errorCode()." ".print_r($mysqlcon->errorInfo(), true).'
'; $err_lvl = 2; - $count++; - } - - if($mysqlcon->exec("INSERT INTO `$dbname`.`stats_server` SET `total_user`='9999'") === false) { - $err_msg .= $lang['isntwidbmsg'].$mysqlcon->errorCode()." ".print_r($mysqlcon->errorInfo(), true).'
'; $err_lvl = 2; - $count++; - } - - if($mysqlcon->exec("CREATE TABLE `$dbname`.`admin_addtime` ( + );") === false) { + $err_msg .= $lang['isntwidbmsg'].$mysqlcon->errorCode().' '.print_r($mysqlcon->errorInfo(), true).'
'; + $err_lvl = 2; + $count++; + } + + if ($mysqlcon->exec("INSERT INTO `$dbname`.`stats_server` SET `total_user`='9999'") === false) { + $err_msg .= $lang['isntwidbmsg'].$mysqlcon->errorCode().' '.print_r($mysqlcon->errorInfo(), true).'
'; + $err_lvl = 2; + $count++; + } + + if ($mysqlcon->exec("CREATE TABLE `$dbname`.`admin_addtime` ( `uuid` char(28) CHARACTER SET utf8 COLLATE utf8_unicode_ci, `timestamp` int(10) UNSIGNED NOT NULL default '0', `timecount` int(10) NOT NULL default '0', PRIMARY KEY (`uuid`,`timestamp`) - );") === false) { - $err_msg .= $lang['isntwidbmsg'].$mysqlcon->errorCode()." ".print_r($mysqlcon->errorInfo(), true).'
'; $err_lvl = 2; - $count++; - } - - if($mysqlcon->exec("CREATE TABLE `$dbname`.`user_iphash` ( + );") === false) { + $err_msg .= $lang['isntwidbmsg'].$mysqlcon->errorCode().' '.print_r($mysqlcon->errorInfo(), true).'
'; + $err_lvl = 2; + $count++; + } + + if ($mysqlcon->exec("CREATE TABLE `$dbname`.`user_iphash` ( `uuid` char(28) CHARACTER SET utf8 COLLATE utf8_unicode_ci PRIMARY KEY, `iphash` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci, `ip` varchar(39) CHARACTER SET utf8 COLLATE utf8_unicode_ci - );") === false) { - $err_msg .= $lang['isntwidbmsg'].$mysqlcon->errorCode()." ".print_r($mysqlcon->errorInfo(), true).'
'; $err_lvl = 2; - $count++; - } - - if($mysqlcon->exec("CREATE TABLE `$dbname`.`job_check` ( + );") === false) { + $err_msg .= $lang['isntwidbmsg'].$mysqlcon->errorCode().' '.print_r($mysqlcon->errorInfo(), true).'
'; + $err_lvl = 2; + $count++; + } + + if ($mysqlcon->exec("CREATE TABLE `$dbname`.`job_check` ( `job_name` varchar(20) CHARACTER SET utf8 COLLATE utf8_unicode_ci PRIMARY KEY, `timestamp` int(10) UNSIGNED NOT NULL default '0' - );") === false) { - $err_msg .= $lang['isntwidbmsg'].$mysqlcon->errorCode()." ".print_r($mysqlcon->errorInfo(), true).'
'; $err_lvl = 2; - $count++; - } - - if($mysqlcon->exec("INSERT INTO `$dbname`.`job_check` (`job_name`) VALUES + );") === false) { + $err_msg .= $lang['isntwidbmsg'].$mysqlcon->errorCode().' '.print_r($mysqlcon->errorInfo(), true).'
'; + $err_lvl = 2; + $count++; + } + + if ($mysqlcon->exec("INSERT INTO `$dbname`.`job_check` (`job_name`) VALUES ('calc_donut_chars'), ('calc_server_stats'), ('calc_user_lastscan'), @@ -331,55 +353,61 @@ function install($type, $host, $user, $pass, $dbname, $lang, $mysqlcon, &$err_ms ('runtime_check'), ('update_channel'), ('update_groups') - ;") === false) { - $err_msg .= $lang['isntwidbmsg'].$mysqlcon->errorCode()." ".print_r($mysqlcon->errorInfo(), true).'
'; $err_lvl = 2; - $count++; - } - - if($mysqlcon->exec("CREATE TABLE `$dbname`.`stats_nations` ( + ;") === false) { + $err_msg .= $lang['isntwidbmsg'].$mysqlcon->errorCode().' '.print_r($mysqlcon->errorInfo(), true).'
'; + $err_lvl = 2; + $count++; + } + + if ($mysqlcon->exec("CREATE TABLE `$dbname`.`stats_nations` ( `nation` char(2) CHARACTER SET utf8 COLLATE utf8_unicode_ci PRIMARY KEY, `count` smallint(5) UNSIGNED NOT NULL default '0' - );") === false) { - $err_msg .= $lang['isntwidbmsg'].$mysqlcon->errorCode()." ".print_r($mysqlcon->errorInfo(), true).'
'; $err_lvl = 2; - $count++; - } - - if($mysqlcon->exec("CREATE TABLE `$dbname`.`stats_versions` ( + );") === false) { + $err_msg .= $lang['isntwidbmsg'].$mysqlcon->errorCode().' '.print_r($mysqlcon->errorInfo(), true).'
'; + $err_lvl = 2; + $count++; + } + + if ($mysqlcon->exec("CREATE TABLE `$dbname`.`stats_versions` ( `version` varchar(64) CHARACTER SET utf8 COLLATE utf8_unicode_ci PRIMARY KEY, `count` smallint(5) UNSIGNED NOT NULL default '0' - );") === false) { - $err_msg .= $lang['isntwidbmsg'].$mysqlcon->errorCode()." ".print_r($mysqlcon->errorInfo(), true).'
'; $err_lvl = 2; - $count++; - } - - if($mysqlcon->exec("CREATE TABLE `$dbname`.`stats_platforms` ( + );") === false) { + $err_msg .= $lang['isntwidbmsg'].$mysqlcon->errorCode().' '.print_r($mysqlcon->errorInfo(), true).'
'; + $err_lvl = 2; + $count++; + } + + if ($mysqlcon->exec("CREATE TABLE `$dbname`.`stats_platforms` ( `platform` varchar(32) CHARACTER SET utf8 COLLATE utf8_unicode_ci PRIMARY KEY, `count` smallint(5) UNSIGNED NOT NULL default '0' - );") === false) { - $err_msg .= $lang['isntwidbmsg'].$mysqlcon->errorCode()." ".print_r($mysqlcon->errorInfo(), true).'
'; $err_lvl = 2; - $count++; - } else { - if($mysqlcon->exec("INSERT INTO `$dbname`.`stats_platforms` (`platform`,`count`) VALUES + );") === false) { + $err_msg .= $lang['isntwidbmsg'].$mysqlcon->errorCode().' '.print_r($mysqlcon->errorInfo(), true).'
'; + $err_lvl = 2; + $count++; + } else { + if ($mysqlcon->exec("INSERT INTO `$dbname`.`stats_platforms` (`platform`,`count`) VALUES ('Windows',0), ('Android',0), ('OSX',0), ('iOS',0), ('Linux',0) - ;") === false) { - $err_msg .= $lang['isntwidbmsg'].$mysqlcon->errorCode()." ".print_r($mysqlcon->errorInfo(), true).'
'; $err_lvl = 2; - $count++; - } - } - - if($mysqlcon->exec("CREATE TABLE `$dbname`.`addons_config` ( + ;") === false) { + $err_msg .= $lang['isntwidbmsg'].$mysqlcon->errorCode().' '.print_r($mysqlcon->errorInfo(), true).'
'; + $err_lvl = 2; + $count++; + } + } + + if ($mysqlcon->exec("CREATE TABLE `$dbname`.`addons_config` ( `param` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci UNIQUE, `value` varchar(16000) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci - );") === false) { - $err_msg .= $lang['isntwidbmsg'].$mysqlcon->errorCode()." ".print_r($mysqlcon->errorInfo(), true).'
'; $err_lvl = 2; - $count++; - } - - $channelinfo_desc = $mysqlcon->quote('[CENTER][B][SIZE=15]User Toplist (last week)[/SIZE][/B][/CENTER] + );") === false) { + $err_msg .= $lang['isntwidbmsg'].$mysqlcon->errorCode().' '.print_r($mysqlcon->errorInfo(), true).'
'; + $err_lvl = 2; + $count++; + } + + $channelinfo_desc = $mysqlcon->quote('[CENTER][B][SIZE=15]User Toplist (last week)[/SIZE][/B][/CENTER] [SIZE=11][B]1st[/B] [URL=client://0/{$CLIENT_UNIQUE_IDENTIFIER_1}]{$CLIENT_NICKNAME_1}[/URL][/SIZE][SIZE=7] {if {$CLIENT_ONLINE_STATUS_1} === \'Online\'}[COLOR=GREEN](Online)[/COLOR] currently in channel [URL=channelid://{$CLIENT_CURRENT_CHANNEL_ID_1}]{$CLIENT_CURRENT_CHANNEL_NAME_1}[/URL]{else}[COLOR=RED](Offline)[/COLOR] @@ -432,9 +460,9 @@ function install($type, $host, $user, $pass, $dbname, $lang, $mysqlcon, &$err_ms [SIZE=8]Last week active: {$CLIENT_ACTIVE_TIME_LAST_WEEK_10}; reached Servergroup: [IMG]https://domain.com/ranksystem/{$CLIENT_CURRENT_RANK_GROUP_ICON_URL_10}[/IMG] {$CLIENT_CURRENT_RANK_GROUP_NAME_10}[/SIZE] -[SIZE=6]Updated: {$LAST_UPDATE_TIME}[/SIZE]', ENT_QUOTES); - - if($mysqlcon->exec("INSERT INTO `$dbname`.`addons_config` (`param`,`value`) VALUES +[SIZE=6]Updated: {$LAST_UPDATE_TIME}[/SIZE]', ENT_QUOTES); + + if ($mysqlcon->exec("INSERT INTO `$dbname`.`addons_config` (`param`,`value`) VALUES ('assign_groups_active','0'), ('assign_groups_name',''), ('assign_groups_excepted_groupids',''), @@ -447,123 +475,132 @@ function install($type, $host, $user, $pass, $dbname, $lang, $mysqlcon, &$err_ms ('channelinfo_toplist_channelid','0'), ('channelinfo_toplist_modus','1'), ('channelinfo_toplist_lastupdate','0') - ;") === false) { - $err_msg .= $lang['isntwidbmsg'].$mysqlcon->errorCode()." ".print_r($mysqlcon->errorInfo(), true).'
'; $err_lvl = 2; - $count++; - } - - if($mysqlcon->exec("CREATE TABLE `$dbname`.`addon_assign_groups` ( + ;") === false) { + $err_msg .= $lang['isntwidbmsg'].$mysqlcon->errorCode().' '.print_r($mysqlcon->errorInfo(), true).'
'; + $err_lvl = 2; + $count++; + } + + if ($mysqlcon->exec("CREATE TABLE `$dbname`.`addon_assign_groups` ( `uuid` char(28) CHARACTER SET utf8 COLLATE utf8_unicode_ci PRIMARY KEY, `grpids` varchar(1000) CHARACTER SET utf8 COLLATE utf8_unicode_ci - );") === false) { - $err_msg .= $lang['isntwidbmsg'].$mysqlcon->errorCode()." ".print_r($mysqlcon->errorInfo(), true).'
'; $err_lvl = 2; - $count++; - } - - if($mysqlcon->exec("CREATE TABLE `$dbname`.`csrf_token` ( + );") === false) { + $err_msg .= $lang['isntwidbmsg'].$mysqlcon->errorCode().' '.print_r($mysqlcon->errorInfo(), true).'
'; + $err_lvl = 2; + $count++; + } + + if ($mysqlcon->exec("CREATE TABLE `$dbname`.`csrf_token` ( `token` varchar(64) CHARACTER SET utf8 COLLATE utf8_unicode_ci PRIMARY KEY, `timestamp` int(10) UNSIGNED NOT NULL default '0', `sessionid` varchar(128) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL - );") === false) { - $err_msg .= $lang['isntwidbmsg'].$mysqlcon->errorCode()." ".print_r($mysqlcon->errorInfo(), true).'
'; $err_lvl = 2; - $count++; - } - - if($mysqlcon->exec("CREATE TABLE `$dbname`.`channel` ( + );") === false) { + $err_msg .= $lang['isntwidbmsg'].$mysqlcon->errorCode().' '.print_r($mysqlcon->errorInfo(), true).'
'; + $err_lvl = 2; + $count++; + } + + if ($mysqlcon->exec("CREATE TABLE `$dbname`.`channel` ( `cid` int(10) UNSIGNED NOT NULL default '0' PRIMARY KEY, `pid` int(10) UNSIGNED NOT NULL default '0', `channel_order` int(10) UNSIGNED NOT NULL default '0', `channel_name` varchar(40) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL - );") === false) { - $err_msg .= $lang['isntwidbmsg'].$mysqlcon->errorCode()." ".print_r($mysqlcon->errorInfo(), true).'
'; $err_lvl = 2; - $count++; - } - - if($count == 1) { - $err_msg = sprintf($lang['instdbsuc'], $dbname); $err_lvl = NULL; - $install_webuser = 1; - - $dbconfig = fopen('./other/dbconfig.php','w'); - if(!fwrite($dbconfig, $newconfig)) { - $err_msg = $lang['isntwicfg']; - $err_lvl = 2; - } - fclose($dbconfig); - } - } -} - -if (isset($_POST['install'])) { - unset($err_msg); - if ($_POST['dbtype'] == 'mysql') { - if(!in_array('pdo_mysql', get_loaded_extensions())) { - unset($err_msg); $err_msg = sprintf($lang['insterr2'],'PHP MySQL','//php.net/manual/en/ref.pdo-mysql.php',get_cfg_var('cfg_file_path')); $err_lvl = 3; - } else { - $dboptions = array(); - } - } else { - $dboptions = array(); - } - - if(!isset($err_msg)) { - $dbserver = $_POST['dbtype'].':host='.$_POST['dbhost'].'; dbname='.$_POST['dbname'].';charset=utf8mb4'; - $dbserver2 = $_POST['dbtype'].':host='.$_POST['dbhost'].';charset=utf8mb4'; - $dbexists = 0; - try { - $mysqlcon = new PDO($dbserver, $_POST['dbuser'], $_POST['dbpass'], $dboptions); - $dbexists = 1; - } catch (PDOException $e) { - try { - $mysqlcon = new PDO($dbserver2, $_POST['dbuser'], $_POST['dbpass'], $dboptions); - } catch (PDOException $e) { - $err_msg = htmlspecialchars($lang['dbconerr'].$e->getMessage()); $err_lvl = 1; - } - } - - if(!is_writable('./other/dbconfig.php')) { - $err_msg = $lang['isntwicfg']; - $err_lvl = 2; - } - } - - if(!isset($err_msg)) { - if(isset($_POST['installchecked'])) { - install($_POST['dbtype'], $_POST['dbhost'], $_POST['dbuser'], $_POST['dbpass'], $_POST['dbname'], $lang, $mysqlcon, $err_msg, $err_lvl, $install_webuser); - } elseif($dbexists == 1) { - $err_msg = sprintf($lang['insterr1'],$_POST['dbname']); - $err_lvl = 2; - $show_warning = 1; - } else { - install($_POST['dbtype'], $_POST['dbhost'], $_POST['dbuser'], $_POST['dbpass'], $_POST['dbname'], $lang, $mysqlcon, $err_msg, $err_lvl, $install_webuser); - } - } -} - -if(isset($_POST['confweb'])) { - require_once('other/dbconfig.php'); - $user=$_POST['user']; - $pass=password_hash($_POST['pass'], PASSWORD_DEFAULT); - $logpath = addslashes(__DIR__.DIRECTORY_SEPARATOR."logs".DIRECTORY_SEPARATOR); - $dbname = $db['dbname']; - $dbserver = $db['type'].':host='.$db['host'].'; dbname=`'.$db['dbname'].'`;charset=utf8mb4'; - $dbserver2 = $db['type'].':host='.$db['host']; - try { - $mysqlcon = new PDO($dbserver, $db['user'], $db['pass']); - } catch (PDOException $e) { - try { - $mysqlcon = new PDO($dbserver2, $db['user'], $db['pass']); - } catch (PDOException $e) { - $err_msg = htmlspecialchars($lang['dbconerr'].$e->getMessage()); $err_lvl = 1; - } - } - if(!isset($err_lvl) || $err_lvl != 1) { - $dateformat = $mysqlcon->quote("%a days, %h hours, %i mins, %s secs"); - $nextupinfomsg1 = $mysqlcon->quote("Your next rank up will be in %1\$s days, %2\$s hours, %3\$s minutes and %4\$s seconds. The next servergroup you will reach is [B]%5\$s[/B]."); - $nextupinfomsg2 = $mysqlcon->quote("You have already reached the highest rank."); - $nextupinfomsg3 = $mysqlcon->quote("You are excepted from the Ranksystem. If you wish to rank contact an admin on the TS3 server."); - $servernews = $mysqlcon->quote("Message
This is an example Message.
Change this Message inside the webinterface."); - $rankupmsg = $mysqlcon->quote('Hey, you reached a higher rank, since you already connected for %1$s days, %2$s hours and %3$s minutes to our TS3 server.[B]Keep it up![/B] ;-) '); - if($mysqlcon->exec("INSERT INTO `$dbname`.`cfg_params` (`param`,`value`) VALUES + );") === false) { + $err_msg .= $lang['isntwidbmsg'].$mysqlcon->errorCode().' '.print_r($mysqlcon->errorInfo(), true).'
'; + $err_lvl = 2; + $count++; + } + + if ($count == 1) { + $err_msg = sprintf($lang['instdbsuc'], $dbname); + $err_lvl = null; + $install_webuser = 1; + + $dbconfig = fopen('./other/dbconfig.php', 'w'); + if (! fwrite($dbconfig, $newconfig)) { + $err_msg = $lang['isntwicfg']; + $err_lvl = 2; + } + fclose($dbconfig); + } + } +} + +if (isset($_POST['install'])) { + unset($err_msg); + if ($_POST['dbtype'] == 'mysql') { + if (! in_array('pdo_mysql', get_loaded_extensions())) { + unset($err_msg); + $err_msg = sprintf($lang['insterr2'], 'PHP MySQL', '//php.net/manual/en/ref.pdo-mysql.php', get_cfg_var('cfg_file_path')); + $err_lvl = 3; + } else { + $dboptions = []; + } + } else { + $dboptions = []; + } + + if (! isset($err_msg)) { + $dbserver = $_POST['dbtype'].':host='.$_POST['dbhost'].'; dbname='.$_POST['dbname'].';charset=utf8mb4'; + $dbserver2 = $_POST['dbtype'].':host='.$_POST['dbhost'].';charset=utf8mb4'; + $dbexists = 0; + try { + $mysqlcon = new PDO($dbserver, $_POST['dbuser'], $_POST['dbpass'], $dboptions); + $dbexists = 1; + } catch (PDOException $e) { + try { + $mysqlcon = new PDO($dbserver2, $_POST['dbuser'], $_POST['dbpass'], $dboptions); + } catch (PDOException $e) { + $err_msg = htmlspecialchars($lang['dbconerr'].$e->getMessage()); + $err_lvl = 1; + } + } + + if (! is_writable('./other/dbconfig.php')) { + $err_msg = $lang['isntwicfg']; + $err_lvl = 2; + } + } + + if (! isset($err_msg)) { + if (isset($_POST['installchecked'])) { + install($_POST['dbtype'], $_POST['dbhost'], $_POST['dbuser'], $_POST['dbpass'], $_POST['dbname'], $lang, $mysqlcon, $err_msg, $err_lvl, $install_webuser); + } elseif ($dbexists == 1) { + $err_msg = sprintf($lang['insterr1'], $_POST['dbname']); + $err_lvl = 2; + $show_warning = 1; + } else { + install($_POST['dbtype'], $_POST['dbhost'], $_POST['dbuser'], $_POST['dbpass'], $_POST['dbname'], $lang, $mysqlcon, $err_msg, $err_lvl, $install_webuser); + } + } +} + +if (isset($_POST['confweb'])) { + require_once 'other/dbconfig.php'; + $user = $_POST['user']; + $pass = password_hash($_POST['pass'], PASSWORD_DEFAULT); + $logpath = addslashes(__DIR__.DIRECTORY_SEPARATOR.'logs'.DIRECTORY_SEPARATOR); + $dbname = $db['dbname']; + $dbserver = $db['type'].':host='.$db['host'].'; dbname=`'.$db['dbname'].'`;charset=utf8mb4'; + $dbserver2 = $db['type'].':host='.$db['host']; + try { + $mysqlcon = new PDO($dbserver, $db['user'], $db['pass']); + } catch (PDOException $e) { + try { + $mysqlcon = new PDO($dbserver2, $db['user'], $db['pass']); + } catch (PDOException $e) { + $err_msg = htmlspecialchars($lang['dbconerr'].$e->getMessage()); + $err_lvl = 1; + } + } + if (! isset($err_lvl) || $err_lvl != 1) { + $dateformat = $mysqlcon->quote('%a days, %h hours, %i mins, %s secs'); + $nextupinfomsg1 = $mysqlcon->quote('Your next rank up will be in %1$s days, %2$s hours, %3$s minutes and %4$s seconds. The next servergroup you will reach is [B]%5$s[/B].'); + $nextupinfomsg2 = $mysqlcon->quote('You have already reached the highest rank.'); + $nextupinfomsg3 = $mysqlcon->quote('You are excepted from the Ranksystem. If you wish to rank contact an admin on the TS3 server.'); + $servernews = $mysqlcon->quote('Message
This is an example Message.
Change this Message inside the webinterface.'); + $rankupmsg = $mysqlcon->quote('Hey, you reached a higher rank, since you already connected for %1$s days, %2$s hours and %3$s minutes to our TS3 server.[B]Keep it up![/B] ;-) '); + if ($mysqlcon->exec("INSERT INTO `$dbname`.`cfg_params` (`param`,`value`) VALUES ('default_cmdline_sec_switch', '1'), ('default_date_format', {$dateformat}), ('default_header_contenttyp', '1'), @@ -670,142 +707,164 @@ function install($type, $host, $user, $pass, $dbname, $lang, $mysqlcon, &$err_ms ('webinterface_fresh_installation', '1'), ('webinterface_pass', '{$pass}'), ('webinterface_user', '{$user}') - ;") === false) { - $err_msg = $lang['isntwidbmsg'].$mysqlcon->errorCode()." ".print_r($mysqlcon->errorInfo(), true); $err_lvl = 2; - } else { - $err_msg = $lang['isntwiusr'].'

'; - $err_msg = $lang['isntwiusr2'].'

'; - $err_msg .= sprintf($lang['isntwiconf'],"/webinterface/").'

'; - if(!unlink('./install.php')) { - $err_msg .= $lang['isntwidel']; - } - $install_finished = 1; $err_lvl = NULL; - } - } -} - -if (!isset($_POST['install']) && !isset($_POST['confweb'])) { - unset($err_msg); - unset($err_lvl); - $err_msg = ''; - if(!is_writable('./other/dbconfig.php')) { - $err_msg = $lang['isntwicfg']; $err_lvl = 3; - } - - $file_err_count=0; - $file_err_msg = ''; - try { - $scandir = new RecursiveIteratorIterator(new RecursiveDirectoryIterator(__DIR__)); - $files = array(); - foreach ($scandir as $object) { - if(!strstr($object, '/.') && !strstr($object, '\.')) { - if (!$object->isDir()) { - if(!is_writable($object->getPathname())) { - $file_err_msg .= "File is not writeable ".$object."
"; - $file_err_count++; - } - } else { - if(!is_writable($object->getPathname())) { - $file_err_msg .= "Folder is not writeable ".$object."
"; - $file_err_count++; - } - } - } - } - } catch (Exception $e) { - $err_msg .= "File Permissions Error: ".$e->getCode()." ".$e->getMessage(); - $err_lvl = 3; - } - - if($file_err_count!=0) { - $err_msg = "Wrong file/folder permissions!
You need to correct the owner and access permissions of the named files/folders!

The owner of all files and folders of the Ranksystem installation folder must be the user of your webserver (e.g.: www-data).
On Linux systems you may do something like this (linux shell command):
chown -R www-data:www-data ".__DIR__."

Also the access permission must be set, that the user of your webserver is able to read, write and execute files.
On Linux systems you may do something like this (linux shell command):
chmod -R 640 ".__DIR__."


List of concerned files/folders:
"; - $err_lvl = 3; - $err_msg .= $file_err_msg; - } - - if(!class_exists('PDO')) { - $err_msg = sprintf($lang['insterr2'],'PHP PDO','//php.net/manual/en/book.pdo.php',get_cfg_var('cfg_file_path')); $err_lvl = 3; - } - if(version_compare(phpversion(), '5.5.0', '<')) { - $err_msg = sprintf($lang['insterr4'],phpversion()); $err_lvl = 3; - } - if(!function_exists('simplexml_load_file')) { - $err_msg = sprintf($lang['insterr2'],'PHP SimpleXML','//php.net/manual/en/book.simplexml.php',get_cfg_var('cfg_file_path')); $err_lvl = 3; - } - if(!in_array('curl', get_loaded_extensions())) { - $err_msg = sprintf($lang['insterr2'],'PHP cURL','//php.net/manual/en/book.curl.php',get_cfg_var('cfg_file_path')); $err_lvl = 3; - } - if(!in_array('zip', get_loaded_extensions())) { - $err_msg = sprintf($lang['insterr2'],'PHP Zip','//php.net/manual/en/book.zip.php',get_cfg_var('cfg_file_path')); $err_lvl = 3; - } - if(!in_array('mbstring', get_loaded_extensions())) { - $err_msg = sprintf($lang['insterr2'],'PHP mbstring','//php.net/manual/en/book.mbstring.php',get_cfg_var('cfg_file_path')); $err_lvl = 3; - } - if(!in_array('openssl', get_loaded_extensions())) { - unset($err_msg); $err_msg = sprintf($lang['insterr2'],'PHP OpenSSL','//php.net/manual/en/book.openssl.php',get_cfg_var('cfg_file_path')); $err_lvl = 3; $dis_login = 1; - } - if(strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { - if(!in_array('com_dotnet', get_loaded_extensions())) { - $err_msg = sprintf($lang['insterr2'],'PHP COM and .NET (Windows only)','//php.net/manual/en/book.com.php',get_cfg_var('cfg_file_path')); $err_lvl = 3; - } - } - if(!function_exists('exec')) { - unset($err_msg); $err_msg = sprintf($lang['insterr3'],'exec','//php.net/manual/en/book.exec.php',get_cfg_var('cfg_file_path')); $err_lvl = 3; - } else { - if ($err_msg == NULL) { - require_once('other/phpcommand.php'); - exec("$phpcommand -v", $phpversioncheck); - $output = ''; - foreach($phpversioncheck as $line) $output .= print_r($line, true).'
'; - if(empty($phpversioncheck) || strtoupper(substr($phpversioncheck[0], 0, 3)) != "PHP") { - $err_msg .= sprintf($lang['chkphpcmd'], "\"other/phpcommand.php\"", "\"other/phpcommand.php\"", '
'.$phpcommand.'
', '
'.$output.'


', '
php -v
'); $err_lvl = 3; - } else { - $exploded = explode(' ',$phpversioncheck[0]); - if($exploded[1] != phpversion()) { - $err_msg .= sprintf($lang['chkphpmulti'], phpversion(), "\"other/phpcommand.php\"", $exploded[1], "\"other/phpcommand.php\"", "\"other/phpcommand.php\"", '
'.$phpcommand.'
'); - if(getenv('PATH')!='') { - $err_msg .= "

".sprintf($lang['chkphpmulti2'], '
'.getenv('PATH')); $err_lvl = 2; - } - } - } - } - } - - if($err_msg == '' && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != "on")) { - $host = ""; - $err_msg = sprintf($lang['winav10'], $host,'!
', '
'); $err_lvl = 2; - } - - if(!isset($err_lvl)) { - unset($err_msg); - } -} - -if ((!isset($_POST['install']) && !isset($_POST['confweb'])) || $err_lvl == 1 || $err_lvl == 2 || $err_lvl == 3) { - if(isset($show_warning)) { - $dbhost = $_POST['dbhost']; - $dbname = $_POST['dbname']; - $dbuser = $_POST['dbuser']; - $dbpass = $_POST['dbpass']; - } elseif(isset($_GET["dbhost"]) && isset($_GET["dbname"]) && isset($_GET["dbuser"]) && isset($_GET["dbpass"])) { - $dbhost = $_GET["dbhost"]; - $dbname = $_GET['dbname']; - $dbuser = $_GET['dbuser']; - $dbpass = $_GET['dbpass']; - } else { - $dbhost = ""; - $dbname = ""; - $dbuser = ""; - $dbpass = ""; - } - ?> + ;") === false) { + $err_msg = $lang['isntwidbmsg'].$mysqlcon->errorCode().' '.print_r($mysqlcon->errorInfo(), true); + $err_lvl = 2; + } else { + $err_msg = $lang['isntwiusr'].'

'; + $err_msg = $lang['isntwiusr2'].'

'; + $err_msg .= sprintf($lang['isntwiconf'], '/webinterface/').'

'; + if (! unlink('./install.php')) { + $err_msg .= $lang['isntwidel']; + } + $install_finished = 1; + $err_lvl = null; + } + } +} + +if (! isset($_POST['install']) && ! isset($_POST['confweb'])) { + unset($err_msg); + unset($err_lvl); + $err_msg = ''; + if (! is_writable('./other/dbconfig.php')) { + $err_msg = $lang['isntwicfg']; + $err_lvl = 3; + } + + $file_err_count = 0; + $file_err_msg = ''; + try { + $scandir = new RecursiveIteratorIterator(new RecursiveDirectoryIterator(__DIR__)); + $files = []; + foreach ($scandir as $object) { + if (! strstr($object, '/.') && ! strstr($object, '\.')) { + if (! $object->isDir()) { + if (! is_writable($object->getPathname())) { + $file_err_msg .= 'File is not writeable '.$object.'
'; + $file_err_count++; + } + } else { + if (! is_writable($object->getPathname())) { + $file_err_msg .= 'Folder is not writeable '.$object.'
'; + $file_err_count++; + } + } + } + } + } catch (Exception $e) { + $err_msg .= 'File Permissions Error: '.$e->getCode().' '.$e->getMessage(); + $err_lvl = 3; + } + + if ($file_err_count != 0) { + $err_msg = 'Wrong file/folder permissions!
You need to correct the owner and access permissions of the named files/folders!

The owner of all files and folders of the Ranksystem installation folder must be the user of your webserver (e.g.: www-data).
On Linux systems you may do something like this (linux shell command):
chown -R www-data:www-data '.__DIR__.'

Also the access permission must be set, that the user of your webserver is able to read, write and execute files.
On Linux systems you may do something like this (linux shell command):
chmod -R 640 '.__DIR__.'


List of concerned files/folders:
'; + $err_lvl = 3; + $err_msg .= $file_err_msg; + } + + if (! class_exists('PDO')) { + $err_msg = sprintf($lang['insterr2'], 'PHP PDO', '//php.net/manual/en/book.pdo.php', get_cfg_var('cfg_file_path')); + $err_lvl = 3; + } + if (version_compare(phpversion(), '5.5.0', '<')) { + $err_msg = sprintf($lang['insterr4'], phpversion()); + $err_lvl = 3; + } + if (! function_exists('simplexml_load_file')) { + $err_msg = sprintf($lang['insterr2'], 'PHP SimpleXML', '//php.net/manual/en/book.simplexml.php', get_cfg_var('cfg_file_path')); + $err_lvl = 3; + } + if (! in_array('curl', get_loaded_extensions())) { + $err_msg = sprintf($lang['insterr2'], 'PHP cURL', '//php.net/manual/en/book.curl.php', get_cfg_var('cfg_file_path')); + $err_lvl = 3; + } + if (! in_array('zip', get_loaded_extensions())) { + $err_msg = sprintf($lang['insterr2'], 'PHP Zip', '//php.net/manual/en/book.zip.php', get_cfg_var('cfg_file_path')); + $err_lvl = 3; + } + if (! in_array('mbstring', get_loaded_extensions())) { + $err_msg = sprintf($lang['insterr2'], 'PHP mbstring', '//php.net/manual/en/book.mbstring.php', get_cfg_var('cfg_file_path')); + $err_lvl = 3; + } + if (! in_array('openssl', get_loaded_extensions())) { + unset($err_msg); + $err_msg = sprintf($lang['insterr2'], 'PHP OpenSSL', '//php.net/manual/en/book.openssl.php', get_cfg_var('cfg_file_path')); + $err_lvl = 3; + $dis_login = 1; + } + if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { + if (! in_array('com_dotnet', get_loaded_extensions())) { + $err_msg = sprintf($lang['insterr2'], 'PHP COM and .NET (Windows only)', '//php.net/manual/en/book.com.php', get_cfg_var('cfg_file_path')); + $err_lvl = 3; + } + } + if (! function_exists('exec')) { + unset($err_msg); + $err_msg = sprintf($lang['insterr3'], 'exec', '//php.net/manual/en/book.exec.php', get_cfg_var('cfg_file_path')); + $err_lvl = 3; + } else { + if ($err_msg == null) { + require_once 'other/phpcommand.php'; + exec("$phpcommand -v", $phpversioncheck); + $output = ''; + foreach ($phpversioncheck as $line) { + $output .= print_r($line, true).'
'; + } + if (empty($phpversioncheck) || strtoupper(substr($phpversioncheck[0], 0, 3)) != 'PHP') { + $err_msg .= sprintf($lang['chkphpcmd'], '"other/phpcommand.php"', '"other/phpcommand.php"', '
'.$phpcommand.'
', '
'.$output.'


', '
php -v
'); + $err_lvl = 3; + } else { + $exploded = explode(' ', $phpversioncheck[0]); + if ($exploded[1] != phpversion()) { + $err_msg .= sprintf($lang['chkphpmulti'], phpversion(), '"other/phpcommand.php"', $exploded[1], '"other/phpcommand.php"', '"other/phpcommand.php"', '
'.$phpcommand.'
'); + if (getenv('PATH') != '') { + $err_msg .= '

'.sprintf($lang['chkphpmulti2'], '
'.getenv('PATH')); + $err_lvl = 2; + } + } + } + } + } + + if ($err_msg == '' && (! isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) { + $host = ''; + $err_msg = sprintf($lang['winav10'], $host, '!
', '
'); + $err_lvl = 2; + } + + if (! isset($err_lvl)) { + unset($err_msg); + } +} + +if ((! isset($_POST['install']) && ! isset($_POST['confweb'])) || $err_lvl == 1 || $err_lvl == 2 || $err_lvl == 3) { + if (isset($show_warning)) { + $dbhost = $_POST['dbhost']; + $dbname = $_POST['dbname']; + $dbuser = $_POST['dbuser']; + $dbpass = $_POST['dbpass']; + } elseif (isset($_GET['dbhost']) && isset($_GET['dbname']) && isset($_GET['dbuser']) && isset($_GET['dbpass'])) { + $dbhost = $_GET['dbhost']; + $dbname = $_GET['dbname']; + $dbuser = $_GET['dbuser']; + $dbpass = $_GET['dbpass']; + } else { + $dbhost = ''; + $dbname = ''; + $dbuser = ''; + $dbpass = ''; + } + ?>
- +

- +

@@ -869,16 +928,16 @@ function install($type, $host, $user, $pass, $dbname, $lang, $mysqlcon, &$err_ms
 
- ",$lang['instdb'],""; - } else { - echo ""; - } - if(isset($show_warning)) { - echo ''; - } - ?> + ',$lang['instdb'],''; + } else { + echo ''; + } + if (isset($show_warning)) { + echo ''; + } + ?>
 
@@ -894,10 +953,10 @@ function install($type, $host, $user, $pass, $dbname, $lang, $mysqlcon, &$err_ms
@@ -910,10 +969,10 @@ function install($type, $host, $user, $pass, $dbname, $lang, $mysqlcon, &$err_ms @@ -926,10 +985,10 @@ function install($type, $host, $user, $pass, $dbname, $lang, $mysqlcon, &$err_ms @@ -942,10 +1001,10 @@ function install($type, $host, $user, $pass, $dbname, $lang, $mysqlcon, &$err_ms @@ -958,10 +1017,10 @@ function install($type, $host, $user, $pass, $dbname, $lang, $mysqlcon, &$err_ms @@ -974,27 +1033,29 @@ function install($type, $host, $user, $pass, $dbname, $lang, $mysqlcon, &$err_ms - +
- +

- +

- +

 
@@ -1031,32 +1092,34 @@ function install($type, $host, $user, $pass, $dbname, $lang, $mysqlcon, &$err_ms
 
- ",$lang['isntwiusrcr'],""; - } else { - echo ""; - } - ?> + ',$lang['isntwiusrcr'],''; + } else { + echo ''; + } + ?>
 
- +
- +
- + '; - } - return $selectbox; -} - -function set_language($language) { - if(is_dir($GLOBALS['langpath'])) { - foreach(scandir($GLOBALS['langpath']) as $file) { - if ('.' === $file || '..' === $file || is_dir($file)) continue; - $sep_lang = preg_split("/[._]/", $file); - if(isset($sep_lang[0]) && $sep_lang[0] == 'core' && isset($sep_lang[1]) && strlen($sep_lang[1]) == 2 && isset($sep_lang[4]) && strtolower($sep_lang[4]) == 'php') { - if(strtolower($language) == strtolower($sep_lang[1])) { - include($GLOBALS['langpath'].DIRECTORY_SEPARATOR.'/core_'.$sep_lang[1].'_'.$sep_lang[2].'_'.$sep_lang[3].'.'.$sep_lang[4]); - $_SESSION[get_rspath().'language'] = $sep_lang[1]; - $required_lang = 1; - break; - } - } - } - } - if(!isset($required_lang)) { - include($GLOBALS['langpath'].DIRECTORY_SEPARATOR.'core_en_english_gb.php'); - } - return $lang; -} - -function set_session_ts3($mysqlcon,$cfg,$lang,$dbname) { - $hpclientip = getclientip(); - $rspathhex = get_rspath(); - - $allclients = $mysqlcon->query("SELECT `u`.`uuid`,`u`.`cldbid`,`u`.`name`,`u`.`firstcon`,`s`.`total_connections` FROM `$dbname`.`user` AS `u` LEFT JOIN `$dbname`.`stats_user` AS `s` ON `u`.`uuid`=`s`.`uuid` WHERE `online`='1'")->fetchAll(); - $iptable = $mysqlcon->query("SELECT `uuid`,`iphash`,`ip` FROM `$dbname`.`user_iphash`")->fetchAll(PDO::FETCH_ASSOC|PDO::FETCH_UNIQUE); - if(!isset($_SESSION[$rspathhex.'connected']) && isset($cfg['stats_news_html'])) $_SESSION[$rspathhex.'stats_news_html'] = $cfg['stats_news_html']; - $_SESSION[$rspathhex.'connected'] = 0; - $_SESSION[$rspathhex.'tsname'] = $lang['stag0016']; - $_SESSION[$rspathhex.'serverport'] = $cfg['teamspeak_voice_port']; - $_SESSION[$rspathhex.'multiple'] = array(); - - - if($cfg['rankup_hash_ip_addresses_mode'] == 2) { - $salt = md5(dechex(crc32(dirname(__DIR__)))); - $hashedip = crypt($hpclientip, '$2y$10$'.$salt.'$'); - } - - foreach ($allclients as $client) { - if(isset($_SESSION[$rspathhex.'uuid_verified']) && $_SESSION[$rspathhex.'uuid_verified'] != $client['uuid']) { - continue; - } - $verify = FALSE; - if($cfg['rankup_hash_ip_addresses_mode'] == 1) { - if (isset($iptable[$client['uuid']]['iphash']) && $iptable[$client['uuid']]['iphash'] != NULL && password_verify($hpclientip, $iptable[$client['uuid']]['iphash'])) { - $verify = TRUE; - } - } elseif($cfg['rankup_hash_ip_addresses_mode'] == 2) { - if (isset($iptable[$client['uuid']]['iphash']) && $hashedip == $iptable[$client['uuid']]['iphash'] && $iptable[$client['uuid']]['iphash'] != NULL) { - $verify = TRUE; - } - } else { - if (isset($iptable[$client['uuid']]['ip']) && $hpclientip == $iptable[$client['uuid']]['ip'] && $iptable[$client['uuid']]['ip'] != NULL) { - $verify = TRUE; - } - } - if ($verify == TRUE) { - $_SESSION[$rspathhex.'tsname'] = htmlspecialchars($client['name']); - if(isset($_SESSION[$rspathhex.'tsuid']) && $_SESSION[$rspathhex.'tsuid'] != $client['uuid']) { - $_SESSION[$rspathhex.'multiple'][$client['uuid']] = htmlspecialchars($client['name']); - $_SESSION[$rspathhex.'tsname'] = "verification needed (multiple)!"; - unset($_SESSION[$rspathhex.'admin']); - } elseif (!isset($_SESSION[$rspathhex.'tsuid'])) { - $_SESSION[$rspathhex.'multiple'][$client['uuid']] = htmlspecialchars($client['name']); - } - $_SESSION[$rspathhex.'tsuid'] = $client['uuid']; - if(isset($cfg['webinterface_admin_client_unique_id_list']) && $cfg['webinterface_admin_client_unique_id_list'] != NULL) { - foreach(array_flip($cfg['webinterface_admin_client_unique_id_list']) as $auuid) { - if ($_SESSION[$rspathhex.'tsuid'] == $auuid) { - $_SESSION[$rspathhex.'admin'] = TRUE; - } - } - } - $_SESSION[$rspathhex.'tscldbid'] = $client['cldbid']; - if ($client['firstcon'] == 0) { - $_SESSION[$rspathhex.'tscreated'] = $lang['unknown']; - } else { - $_SESSION[$rspathhex.'tscreated'] = date('d-m-Y', $client['firstcon']); - } - if ($client['total_connections'] != NULL) { - $_SESSION[$rspathhex.'tsconnections'] = $client['total_connections']; - } else { - $_SESSION[$rspathhex.'tsconnections'] = 0; - } - $convert = array('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p'); - $uuidasbase16 = ''; - for ($i = 0; $i < 20; $i++) { - $char = ord(substr(base64_decode($_SESSION[$rspathhex.'tsuid']), $i, 1)); - $uuidasbase16 .= $convert[($char & 0xF0) >> 4]; - $uuidasbase16 .= $convert[$char & 0x0F]; - } - if (is_file('../avatars/' . $uuidasbase16 . '.png')) { - $_SESSION[$rspathhex.'tsavatar'] = $uuidasbase16 . '.png'; - } else { - $_SESSION[$rspathhex.'tsavatar'] = "none"; - } - $_SESSION[$rspathhex.'connected'] = 1; - $_SESSION[$rspathhex.'language'] = $cfg['default_language']; - $_SESSION[$rspathhex.'style'] = $cfg['default_style']; - } - } -} - -function sendmessage($ts3, $cfg, $uuid, $msg, $targetmode, $targetid=NULL, $erromsg=NULL, $loglevel=NULL, $successmsg=NULL, $nolog=NULL) { - try { - if(strlen($msg) > 1024) { - $fragarr = explode("##*##", wordwrap($msg, 1022, "##*##", TRUE), 1022); - foreach($fragarr as $frag) { - usleep($cfg['teamspeak_query_command_delay']); - if ($targetmode==2 && $targetid!=NULL) { - $ts3->serverGetSelected()->channelGetById($targetid)->message("\n".$frag); - if($nolog==NULL) enter_logfile(6,"sendmessage fragment to channel (ID: $targetid): ".$frag); - } elseif ($targetmode==3) { - $ts3->serverGetSelected()->message("\n".$frag); - if($nolog==NULL) enter_logfile(6,"sendmessage fragment to server: ".$frag); - } elseif ($targetmode==1 && $targetid!=NULL) { - $ts3->serverGetSelected()->clientGetById($targetid)->message("\n".$frag); - if($nolog==NULL) enter_logfile(6,"sendmessage fragment to connectionID $targetid (uuid $uuid): ".$frag); - } else { - $ts3->serverGetSelected()->clientGetByUid($uuid)->message("\n".$frag); - if($nolog==NULL) enter_logfile(6,"sendmessage fragment to uuid $uuid (connectionID $targetid): ".$frag); - } - } - } else { - usleep($cfg['teamspeak_query_command_delay']); - if ($targetmode==2 && $targetid!=NULL) { - $ts3->serverGetSelected()->channelGetById($targetid)->message($msg); - if($nolog==NULL) enter_logfile(6,"sendmessage to channel (ID: $targetid): ".$msg); - } elseif ($targetmode==3) { - $ts3->serverGetSelected()->message($msg); - if($nolog==NULL) enter_logfile(6,"sendmessage to server: ".$msg); - } elseif ($targetmode==1 && $targetid!=NULL) { - $ts3->serverGetSelected()->clientGetById($targetid)->message($msg); - if($nolog==NULL) enter_logfile(6,"sendmessage to connectionID $targetid (uuid $uuid): ".$msg); - } else { - $ts3->serverGetSelected()->clientGetByUid($uuid)->message($msg); - if($nolog==NULL) enter_logfile(6,"sendmessage to uuid $uuid (connectionID $targetid): ".$msg); - } - - } - if($successmsg!=NULL) { - enter_logfile(5,$successmsg); - } - } catch (Exception $e) { - if($loglevel!=NULL) { - enter_logfile($loglevel,$erromsg." TS3: ".$e->getCode().': '.$e->getMessage()); - } else { - enter_logfile(3,"sendmessage: ".$e->getCode().': '.$e->getMessage().", targetmode: $targetmode, targetid: $targetid"); - } - } -} - -function shutdown($mysqlcon,$loglevel,$reason,$nodestroypid = TRUE) { - if($nodestroypid === TRUE) { - if (file_exists($GLOBALS['pidfile'])) { - unlink($GLOBALS['pidfile']); - } - } - if($nodestroypid === TRUE) { - enter_logfile($loglevel,$reason." Shutting down!"); - enter_logfile(9,"###################################################################"); - } else { - enter_logfile($loglevel,$reason." Ignore request!"); - } - if(isset($mysqlcon)) { - $mysqlcon = null; - } - exit; -} - -function sort_channel_tree($channellist) { - foreach($channellist as $cid => $results) { - $channel['channel_order'][$results['pid']][$results['channel_order']] = $cid; - $channel['pid'][$results['pid']][] = $cid; - } - - foreach($channel['pid'] as $pid => $pid_value) { - $channel_order = 0; - $count_pid = count($pid_value); - for($y=0; $y<$count_pid; $y++) { - foreach($channellist as $cid => $value) { - if(isset($channel['channel_order'][$pid][$channel_order]) && $channel['channel_order'][$pid][$channel_order] == $cid) { - $channel['sorted'][$pid][$cid] = $channellist[$cid]; - $channel_order = $cid; - } - } - } - } - - function channel_list($channel, $channel_list, $pid, $sub) { - if($channel['sorted'][$pid]) { - foreach($channel['sorted'][$pid] as $cid => $value) { - $channel_list[$cid] = $value; - $channel_list[$cid]['sub_level'] = $sub; - if(isset($channel['pid'][$cid])) { - $sub++; - $channel_list[$cid]['has_childs'] = 1; - $channel_list = channel_list($channel, $channel_list, $cid, $sub); - $sub--; - } - } - } - return $channel_list; - } - - $sorted_channel = channel_list($channel, array(), 0, 1); - return $sorted_channel; -} - -function sort_options($lang) { - $arr_sort_options = array( - array('option' => 'rank', 'title' => $lang['listrank'], 'icon' => 'fas fa-hashtag', 'config' => 'stats_column_rank_switch'), - array('option' => 'name', 'title' => $lang['listnick'], 'icon' => 'fas fa-user', 'config' => 'stats_column_client_name_switch'), - array('option' => 'uuid', 'title' => $lang['listuid'], 'icon' => 'fas fa-id-card', 'config' => 'stats_column_unique_id_switch'), - array('option' => 'cldbid', 'title' => $lang['listcldbid'], 'icon' => 'fas fa-database', 'config' => 'stats_column_client_db_id_switch'), - array('option' => 'lastseen', 'title' => $lang['listseen'], 'icon' => 'fas fa-user-clock', 'config' => 'stats_column_last_seen_switch'), - array('option' => 'nation', 'title' => $lang['listnat'], 'icon' => 'fas fa-globe-europe', 'config' => 'stats_column_nation_switch'), - array('option' => 'version', 'title' => $lang['listver'], 'icon' => 'fas fa-tag', 'config' => 'stats_column_version_switch'), - array('option' => 'platform', 'title' => $lang['listpla'], 'icon' => 'fas fa-server', 'config' => 'stats_column_platform_switch'), - array('option' => 'count', 'title' => $lang['listsumo'], 'icon' => 'fas fa-hourglass-start', 'config' => 'stats_column_online_time_switch'), - array('option' => 'idle', 'title' => $lang['listsumi'], 'icon' => 'fas fa-hourglass-end', 'config' => 'stats_column_idle_time_switch'), - array('option' => 'active', 'title' => $lang['listsuma'], 'icon' => 'fas fa-hourglass-half', 'config' => 'stats_column_active_time_switch'), - array('option' => 'count_day', 'title' => $lang['listsumo'].' '.$lang['stix0013'], 'icon' => 'fas fa-hourglass-start', 'config' => 'stats_column_online_day_switch'), - array('option' => 'idle_day', 'title' => $lang['listsumi'].' '.$lang['stix0013'], 'icon' => 'fas fa-hourglass-half', 'config' => 'stats_column_idle_day_switch'), - array('option' => 'active_day', 'title' => $lang['listsuma'].' '.$lang['stix0013'], 'icon' => 'fas fa-hourglass-end', 'config' => 'stats_column_active_day_switch'), - array('option' => 'count_week', 'title' => $lang['listsumo'].' '.$lang['stix0014'], 'icon' => 'fas fa-hourglass-start', 'config' => 'stats_column_online_week_switch'), - array('option' => 'idle_week', 'title' => $lang['listsumi'].' '.$lang['stix0014'], 'icon' => 'fas fa-hourglass-half', 'config' => 'stats_column_idle_week_switch'), - array('option' => 'active_week', 'title' => $lang['listsuma'].' '.$lang['stix0014'], 'icon' => 'fas fa-hourglass-end', 'config' => 'stats_column_active_week_switch'), - array('option' => 'count_month', 'title' => $lang['listsumo'].' '.$lang['stix0015'], 'icon' => 'fas fa-hourglass-start', 'config' => 'stats_column_online_month_switch'), - array('option' => 'idle_month', 'title' => $lang['listsumi'].' '.$lang['stix0015'], 'icon' => 'fas fa-hourglass-half', 'config' => 'stats_column_idle_month_switch'), - array('option' => 'active_month', 'title' => $lang['listsuma'].' '.$lang['stix0015'], 'icon' => 'fas fa-hourglass-end', 'config' => 'stats_column_active_month_switch'), - array('option' => 'grpid', 'title' => $lang['listacsg'], 'icon' => 'fas fa-clipboard-check', 'config' => 'stats_column_current_server_group_switch'), - array('option' => 'grpidsince', 'title' => $lang['listgrps'], 'icon' => 'fas fa-history', 'config' => 'stats_column_current_group_since_switch'), - array('option' => 'nextup', 'title' => $lang['listnxup'], 'icon' => 'fas fa-clock', 'config' => 'stats_column_next_rankup_switch'), - array('option' => 'active', 'title' => $lang['listnxsg'], 'icon' => 'fas fa-clipboard-list', 'config' => 'stats_column_next_server_group_switch') - ); - return $arr_sort_options; -} - -function start_session($cfg) { - ini_set('session.cookie_httponly', 1); - ini_set('session.use_strict_mode', 1); - ini_set('session.sid_length', 128); - if(isset($cfg['default_header_xss'])) { - header("X-XSS-Protection: ".$cfg['default_header_xss']); - } else { - header("X-XSS-Protection: 1; mode=block"); - } - if(!isset($cfg['default_header_contenttyp']) || $cfg['default_header_contenttyp'] == 1) { - header("X-Content-Type-Options: nosniff"); - } - if(isset($cfg['default_header_frame']) && $cfg['default_header_frame'] != NULL) { - header("X-Frame-Options: ".$cfg['default_header_frame']); - } - - if(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on") { - $prot = 'https'; - ini_set('session.cookie_secure', 1); - if(!headers_sent()) { - header("Strict-Transport-Security: max-age=31536000; includeSubDomains; preload;"); - } - } else { - $prot = 'http'; - } - - if(isset($cfg['default_header_origin']) && $cfg['default_header_origin'] != NULL && $cfg['default_header_origin'] != 'null') { - if(strstr($cfg['default_header_origin'], ',')) { - $origin_arr = explode(',', $cfg['default_header_origin']); - if(isset($_SERVER['HTTP_ORIGIN']) && in_array($_SERVER['HTTP_ORIGIN'], $origin_arr)) { - header("Access-Control-Allow-Origin: ".$_SERVER['HTTP_ORIGIN']); - } - } else { - header("Access-Control-Allow-Origin: ".$cfg['default_header_origin']); - } - } - - if(version_compare(PHP_VERSION, '7.3.0', '>=')) { - if(isset($cfg['default_session_sametime'])) { - ini_set('session.cookie_samesite', $cfg['default_session_sametime']); - } else { - ini_set('session.cookie_samesite', "Strict"); - } - } - - session_start(); - return $prot; -} -?> \ No newline at end of file + });'; + } + + return $selectbox; +} + +function set_language($language) +{ + if (is_dir($GLOBALS['langpath'])) { + foreach (scandir($GLOBALS['langpath']) as $file) { + if ('.' === $file || '..' === $file || is_dir($file)) { + continue; + } + $sep_lang = preg_split('/[._]/', $file); + if (isset($sep_lang[0]) && $sep_lang[0] == 'core' && isset($sep_lang[1]) && strlen($sep_lang[1]) == 2 && isset($sep_lang[4]) && strtolower($sep_lang[4]) == 'php') { + if (strtolower($language) == strtolower($sep_lang[1])) { + include $GLOBALS['langpath'].DIRECTORY_SEPARATOR.'/core_'.$sep_lang[1].'_'.$sep_lang[2].'_'.$sep_lang[3].'.'.$sep_lang[4]; + $_SESSION[get_rspath().'language'] = $sep_lang[1]; + $required_lang = 1; + break; + } + } + } + } + if (! isset($required_lang)) { + include $GLOBALS['langpath'].DIRECTORY_SEPARATOR.'core_en_english_gb.php'; + } + + return $lang; +} + +function set_session_ts3($mysqlcon, $cfg, $lang, $dbname) +{ + $hpclientip = getclientip(); + $rspathhex = get_rspath(); + + $allclients = $mysqlcon->query("SELECT `u`.`uuid`,`u`.`cldbid`,`u`.`name`,`u`.`firstcon`,`s`.`total_connections` FROM `$dbname`.`user` AS `u` LEFT JOIN `$dbname`.`stats_user` AS `s` ON `u`.`uuid`=`s`.`uuid` WHERE `online`='1'")->fetchAll(); + $iptable = $mysqlcon->query("SELECT `uuid`,`iphash`,`ip` FROM `$dbname`.`user_iphash`")->fetchAll(PDO::FETCH_ASSOC | PDO::FETCH_UNIQUE); + if (! isset($_SESSION[$rspathhex.'connected']) && isset($cfg['stats_news_html'])) { + $_SESSION[$rspathhex.'stats_news_html'] = $cfg['stats_news_html']; + } + $_SESSION[$rspathhex.'connected'] = 0; + $_SESSION[$rspathhex.'tsname'] = $lang['stag0016']; + $_SESSION[$rspathhex.'serverport'] = $cfg['teamspeak_voice_port']; + $_SESSION[$rspathhex.'multiple'] = []; + + if ($cfg['rankup_hash_ip_addresses_mode'] == 2) { + $salt = md5(dechex(crc32(dirname(__DIR__)))); + $hashedip = crypt($hpclientip, '$2y$10$'.$salt.'$'); + } + + foreach ($allclients as $client) { + if (isset($_SESSION[$rspathhex.'uuid_verified']) && $_SESSION[$rspathhex.'uuid_verified'] != $client['uuid']) { + continue; + } + $verify = false; + if ($cfg['rankup_hash_ip_addresses_mode'] == 1) { + if (isset($iptable[$client['uuid']]['iphash']) && $iptable[$client['uuid']]['iphash'] != null && password_verify($hpclientip, $iptable[$client['uuid']]['iphash'])) { + $verify = true; + } + } elseif ($cfg['rankup_hash_ip_addresses_mode'] == 2) { + if (isset($iptable[$client['uuid']]['iphash']) && $hashedip == $iptable[$client['uuid']]['iphash'] && $iptable[$client['uuid']]['iphash'] != null) { + $verify = true; + } + } else { + if (isset($iptable[$client['uuid']]['ip']) && $hpclientip == $iptable[$client['uuid']]['ip'] && $iptable[$client['uuid']]['ip'] != null) { + $verify = true; + } + } + if ($verify == true) { + $_SESSION[$rspathhex.'tsname'] = htmlspecialchars($client['name']); + if (isset($_SESSION[$rspathhex.'tsuid']) && $_SESSION[$rspathhex.'tsuid'] != $client['uuid']) { + $_SESSION[$rspathhex.'multiple'][$client['uuid']] = htmlspecialchars($client['name']); + $_SESSION[$rspathhex.'tsname'] = 'verification needed (multiple)!'; + unset($_SESSION[$rspathhex.'admin']); + } elseif (! isset($_SESSION[$rspathhex.'tsuid'])) { + $_SESSION[$rspathhex.'multiple'][$client['uuid']] = htmlspecialchars($client['name']); + } + $_SESSION[$rspathhex.'tsuid'] = $client['uuid']; + if (isset($cfg['webinterface_admin_client_unique_id_list']) && $cfg['webinterface_admin_client_unique_id_list'] != null) { + foreach (array_flip($cfg['webinterface_admin_client_unique_id_list']) as $auuid) { + if ($_SESSION[$rspathhex.'tsuid'] == $auuid) { + $_SESSION[$rspathhex.'admin'] = true; + } + } + } + $_SESSION[$rspathhex.'tscldbid'] = $client['cldbid']; + if ($client['firstcon'] == 0) { + $_SESSION[$rspathhex.'tscreated'] = $lang['unknown']; + } else { + $_SESSION[$rspathhex.'tscreated'] = date('d-m-Y', $client['firstcon']); + } + if ($client['total_connections'] != null) { + $_SESSION[$rspathhex.'tsconnections'] = $client['total_connections']; + } else { + $_SESSION[$rspathhex.'tsconnections'] = 0; + } + $convert = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p']; + $uuidasbase16 = ''; + for ($i = 0; $i < 20; $i++) { + $char = ord(substr(base64_decode($_SESSION[$rspathhex.'tsuid']), $i, 1)); + $uuidasbase16 .= $convert[($char & 0xF0) >> 4]; + $uuidasbase16 .= $convert[$char & 0x0F]; + } + if (is_file('../avatars/'.$uuidasbase16.'.png')) { + $_SESSION[$rspathhex.'tsavatar'] = $uuidasbase16.'.png'; + } else { + $_SESSION[$rspathhex.'tsavatar'] = 'none'; + } + $_SESSION[$rspathhex.'connected'] = 1; + $_SESSION[$rspathhex.'language'] = $cfg['default_language']; + $_SESSION[$rspathhex.'style'] = $cfg['default_style']; + } + } +} + +function sendmessage($ts3, $cfg, $uuid, $msg, $targetmode, $targetid = null, $erromsg = null, $loglevel = null, $successmsg = null, $nolog = null) +{ + try { + if (strlen($msg) > 1024) { + $fragarr = explode('##*##', wordwrap($msg, 1022, '##*##', true), 1022); + foreach ($fragarr as $frag) { + usleep($cfg['teamspeak_query_command_delay']); + if ($targetmode == 2 && $targetid != null) { + $ts3->serverGetSelected()->channelGetById($targetid)->message("\n".$frag); + if ($nolog == null) { + enter_logfile(6, "sendmessage fragment to channel (ID: $targetid): ".$frag); + } + } elseif ($targetmode == 3) { + $ts3->serverGetSelected()->message("\n".$frag); + if ($nolog == null) { + enter_logfile(6, 'sendmessage fragment to server: '.$frag); + } + } elseif ($targetmode == 1 && $targetid != null) { + $ts3->serverGetSelected()->clientGetById($targetid)->message("\n".$frag); + if ($nolog == null) { + enter_logfile(6, "sendmessage fragment to connectionID $targetid (uuid $uuid): ".$frag); + } + } else { + $ts3->serverGetSelected()->clientGetByUid($uuid)->message("\n".$frag); + if ($nolog == null) { + enter_logfile(6, "sendmessage fragment to uuid $uuid (connectionID $targetid): ".$frag); + } + } + } + } else { + usleep($cfg['teamspeak_query_command_delay']); + if ($targetmode == 2 && $targetid != null) { + $ts3->serverGetSelected()->channelGetById($targetid)->message($msg); + if ($nolog == null) { + enter_logfile(6, "sendmessage to channel (ID: $targetid): ".$msg); + } + } elseif ($targetmode == 3) { + $ts3->serverGetSelected()->message($msg); + if ($nolog == null) { + enter_logfile(6, 'sendmessage to server: '.$msg); + } + } elseif ($targetmode == 1 && $targetid != null) { + $ts3->serverGetSelected()->clientGetById($targetid)->message($msg); + if ($nolog == null) { + enter_logfile(6, "sendmessage to connectionID $targetid (uuid $uuid): ".$msg); + } + } else { + $ts3->serverGetSelected()->clientGetByUid($uuid)->message($msg); + if ($nolog == null) { + enter_logfile(6, "sendmessage to uuid $uuid (connectionID $targetid): ".$msg); + } + } + } + if ($successmsg != null) { + enter_logfile(5, $successmsg); + } + } catch (Exception $e) { + if ($loglevel != null) { + enter_logfile($loglevel, $erromsg.' TS3: '.$e->getCode().': '.$e->getMessage()); + } else { + enter_logfile(3, 'sendmessage: '.$e->getCode().': '.$e->getMessage().", targetmode: $targetmode, targetid: $targetid"); + } + } +} + +function shutdown($mysqlcon, $loglevel, $reason, $nodestroypid = true) +{ + if ($nodestroypid === true) { + if (file_exists($GLOBALS['pidfile'])) { + unlink($GLOBALS['pidfile']); + } + } + if ($nodestroypid === true) { + enter_logfile($loglevel, $reason.' Shutting down!'); + enter_logfile(9, '###################################################################'); + } else { + enter_logfile($loglevel, $reason.' Ignore request!'); + } + if (isset($mysqlcon)) { + $mysqlcon = null; + } + exit; +} + +function sort_channel_tree($channellist) +{ + foreach ($channellist as $cid => $results) { + $channel['channel_order'][$results['pid']][$results['channel_order']] = $cid; + $channel['pid'][$results['pid']][] = $cid; + } + + foreach ($channel['pid'] as $pid => $pid_value) { + $channel_order = 0; + $count_pid = count($pid_value); + for ($y = 0; $y < $count_pid; $y++) { + foreach ($channellist as $cid => $value) { + if (isset($channel['channel_order'][$pid][$channel_order]) && $channel['channel_order'][$pid][$channel_order] == $cid) { + $channel['sorted'][$pid][$cid] = $channellist[$cid]; + $channel_order = $cid; + } + } + } + } + + function channel_list($channel, $channel_list, $pid, $sub) + { + if ($channel['sorted'][$pid]) { + foreach ($channel['sorted'][$pid] as $cid => $value) { + $channel_list[$cid] = $value; + $channel_list[$cid]['sub_level'] = $sub; + if (isset($channel['pid'][$cid])) { + $sub++; + $channel_list[$cid]['has_childs'] = 1; + $channel_list = channel_list($channel, $channel_list, $cid, $sub); + $sub--; + } + } + } + + return $channel_list; + } + + $sorted_channel = channel_list($channel, [], 0, 1); + + return $sorted_channel; +} + +function sort_options($lang) +{ + $arr_sort_options = [ + ['option' => 'rank', 'title' => $lang['listrank'], 'icon' => 'fas fa-hashtag', 'config' => 'stats_column_rank_switch'], + ['option' => 'name', 'title' => $lang['listnick'], 'icon' => 'fas fa-user', 'config' => 'stats_column_client_name_switch'], + ['option' => 'uuid', 'title' => $lang['listuid'], 'icon' => 'fas fa-id-card', 'config' => 'stats_column_unique_id_switch'], + ['option' => 'cldbid', 'title' => $lang['listcldbid'], 'icon' => 'fas fa-database', 'config' => 'stats_column_client_db_id_switch'], + ['option' => 'lastseen', 'title' => $lang['listseen'], 'icon' => 'fas fa-user-clock', 'config' => 'stats_column_last_seen_switch'], + ['option' => 'nation', 'title' => $lang['listnat'], 'icon' => 'fas fa-globe-europe', 'config' => 'stats_column_nation_switch'], + ['option' => 'version', 'title' => $lang['listver'], 'icon' => 'fas fa-tag', 'config' => 'stats_column_version_switch'], + ['option' => 'platform', 'title' => $lang['listpla'], 'icon' => 'fas fa-server', 'config' => 'stats_column_platform_switch'], + ['option' => 'count', 'title' => $lang['listsumo'], 'icon' => 'fas fa-hourglass-start', 'config' => 'stats_column_online_time_switch'], + ['option' => 'idle', 'title' => $lang['listsumi'], 'icon' => 'fas fa-hourglass-end', 'config' => 'stats_column_idle_time_switch'], + ['option' => 'active', 'title' => $lang['listsuma'], 'icon' => 'fas fa-hourglass-half', 'config' => 'stats_column_active_time_switch'], + ['option' => 'count_day', 'title' => $lang['listsumo'].' '.$lang['stix0013'], 'icon' => 'fas fa-hourglass-start', 'config' => 'stats_column_online_day_switch'], + ['option' => 'idle_day', 'title' => $lang['listsumi'].' '.$lang['stix0013'], 'icon' => 'fas fa-hourglass-half', 'config' => 'stats_column_idle_day_switch'], + ['option' => 'active_day', 'title' => $lang['listsuma'].' '.$lang['stix0013'], 'icon' => 'fas fa-hourglass-end', 'config' => 'stats_column_active_day_switch'], + ['option' => 'count_week', 'title' => $lang['listsumo'].' '.$lang['stix0014'], 'icon' => 'fas fa-hourglass-start', 'config' => 'stats_column_online_week_switch'], + ['option' => 'idle_week', 'title' => $lang['listsumi'].' '.$lang['stix0014'], 'icon' => 'fas fa-hourglass-half', 'config' => 'stats_column_idle_week_switch'], + ['option' => 'active_week', 'title' => $lang['listsuma'].' '.$lang['stix0014'], 'icon' => 'fas fa-hourglass-end', 'config' => 'stats_column_active_week_switch'], + ['option' => 'count_month', 'title' => $lang['listsumo'].' '.$lang['stix0015'], 'icon' => 'fas fa-hourglass-start', 'config' => 'stats_column_online_month_switch'], + ['option' => 'idle_month', 'title' => $lang['listsumi'].' '.$lang['stix0015'], 'icon' => 'fas fa-hourglass-half', 'config' => 'stats_column_idle_month_switch'], + ['option' => 'active_month', 'title' => $lang['listsuma'].' '.$lang['stix0015'], 'icon' => 'fas fa-hourglass-end', 'config' => 'stats_column_active_month_switch'], + ['option' => 'grpid', 'title' => $lang['listacsg'], 'icon' => 'fas fa-clipboard-check', 'config' => 'stats_column_current_server_group_switch'], + ['option' => 'grpidsince', 'title' => $lang['listgrps'], 'icon' => 'fas fa-history', 'config' => 'stats_column_current_group_since_switch'], + ['option' => 'nextup', 'title' => $lang['listnxup'], 'icon' => 'fas fa-clock', 'config' => 'stats_column_next_rankup_switch'], + ['option' => 'active', 'title' => $lang['listnxsg'], 'icon' => 'fas fa-clipboard-list', 'config' => 'stats_column_next_server_group_switch'], + ]; + + return $arr_sort_options; +} + +function start_session($cfg) +{ + ini_set('session.cookie_httponly', 1); + ini_set('session.use_strict_mode', 1); + ini_set('session.sid_length', 128); + if (isset($cfg['default_header_xss'])) { + header('X-XSS-Protection: '.$cfg['default_header_xss']); + } else { + header('X-XSS-Protection: 1; mode=block'); + } + if (! isset($cfg['default_header_contenttyp']) || $cfg['default_header_contenttyp'] == 1) { + header('X-Content-Type-Options: nosniff'); + } + if (isset($cfg['default_header_frame']) && $cfg['default_header_frame'] != null) { + header('X-Frame-Options: '.$cfg['default_header_frame']); + } + + if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') { + $prot = 'https'; + ini_set('session.cookie_secure', 1); + if (! headers_sent()) { + header('Strict-Transport-Security: max-age=31536000; includeSubDomains; preload;'); + } + } else { + $prot = 'http'; + } + + if (isset($cfg['default_header_origin']) && $cfg['default_header_origin'] != null && $cfg['default_header_origin'] != 'null') { + if (strstr($cfg['default_header_origin'], ',')) { + $origin_arr = explode(',', $cfg['default_header_origin']); + if (isset($_SERVER['HTTP_ORIGIN']) && in_array($_SERVER['HTTP_ORIGIN'], $origin_arr)) { + header('Access-Control-Allow-Origin: '.$_SERVER['HTTP_ORIGIN']); + } + } else { + header('Access-Control-Allow-Origin: '.$cfg['default_header_origin']); + } + } + + if (version_compare(PHP_VERSION, '7.3.0', '>=')) { + if (isset($cfg['default_session_sametime'])) { + ini_set('session.cookie_samesite', $cfg['default_session_sametime']); + } else { + ini_set('session.cookie_samesite', 'Strict'); + } + } + + session_start(); + + return $prot; +} diff --git a/other/config.php b/other/config.php index 06ad353..d8e54a9 100644 --- a/other/config.php +++ b/other/config.php @@ -1,110 +1,118 @@ -query("SELECT * FROM `$dbname`.`cfg_params`"))) { - if(isset($newcfg) && $newcfg != NULL) { - $cfg = $newcfg->fetchAll(PDO::FETCH_KEY_PAIR); - if(empty($cfg['webinterface_admin_client_unique_id_list'])) { - $cfg['webinterface_admin_client_unique_id_list'] = NULL; - } else { - $cfg['webinterface_admin_client_unique_id_list'] = array_flip(explode(',', $cfg['webinterface_admin_client_unique_id_list'])); - } - if(empty($cfg['rankup_excepted_unique_client_id_list'])) { - $cfg['rankup_excepted_unique_client_id_list'] = NULL; - } else { - $cfg['rankup_excepted_unique_client_id_list'] = array_flip(explode(',', $cfg['rankup_excepted_unique_client_id_list'])); - } - if(empty($cfg['rankup_excepted_group_id_list'])) { - $cfg['rankup_excepted_group_id_list'] = NULL; - } else { - $cfg['rankup_excepted_group_id_list'] = array_flip(explode(',', $cfg['rankup_excepted_group_id_list'])); - } - if(empty($cfg['rankup_excepted_channel_id_list'])) { - $cfg['rankup_excepted_channel_id_list'] = NULL; - } else { - $cfg['rankup_excepted_channel_id_list'] = array_flip(explode(',', $cfg['rankup_excepted_channel_id_list'])); - } - if(empty($cfg['rankup_definition'])) { - $cfg['rankup_definition'] = NULL; - } else { - foreach (explode(',', $cfg['rankup_definition']) as $entry) { - if(substr_count($entry, '=>') > 1) { - list($time, $group, $keepflag) = explode('=>', $entry); - } else { - list($time, $group) = explode('=>', $entry); - $keepflag = 0; - } - $addnewvalue1[$time] = array("time"=>$time,"group"=>$group,"keep"=>$keepflag); - $cfg['rankup_definition'] = $addnewvalue1; - } - } - if(empty($cfg['rankup_boost_definition'])) { - $cfg['rankup_boost_definition'] = NULL; - } else { - foreach (explode(',', $cfg['rankup_boost_definition']) as $entry) { - list($key, $value1, $value2) = explode('=>', $entry); - $addnewvalue2[$key] = array("group"=>$key,"factor"=>$value1,"time"=>$value2); - $cfg['rankup_boost_definition'] = $addnewvalue2; - } - } - if(empty($cfg['stats_api_keys'])) { - $cfg['stats_api_keys'] = NULL; - } else { - foreach (explode(',', $cfg['stats_api_keys']) as $entry) { - list($key, $desc, $perm_bot) = array_pad(explode('=>', $entry), 3, null); - if(!$perm_bot) $perm_bot = 0; - $addnewvalue3[$key] = array("key"=>$key,"desc"=>$desc,"perm_bot"=>$perm_bot); - $cfg['stats_api_keys'] = $addnewvalue3; - } - } - unset($addnewvalue1, $addnewvalue2, $addnewvalue3, $newcfg); - } -} - -if(empty($cfg['logs_debug_level'])) { - $GLOBALS['logs_debug_level'] = $cfg['logs_debug_level'] = "5"; -} else { - $GLOBALS['logs_debug_level'] = $cfg['logs_debug_level']; -} -if(empty($cfg['logs_rotation_size'])) { - $GLOBALS['logs_rotation_size'] = $cfg['logs_rotation_size'] = "5"; -} else { - $GLOBALS['logs_rotation_size'] = $cfg['logs_rotation_size']; -} - -if(!isset($cfg['logs_path']) || $cfg['logs_path'] == NULL) { $cfg['logs_path'] = dirname(__DIR__).DIRECTORY_SEPARATOR."logs".DIRECTORY_SEPARATOR; } -if(!isset($cfg['logs_timezone'])) { - $GLOBALS['logs_timezone'] = "Europe/Berlin"; -} else { - $GLOBALS['logs_timezone'] = $cfg['logs_timezone']; -} -date_default_timezone_set($GLOBALS['logs_timezone']); -$GLOBALS['logpath'] = $cfg['logs_path']; -$GLOBALS['logfile'] = $cfg['logs_path'].'ranksystem.log'; -$GLOBALS['pidfile'] = $cfg['logs_path'].'pid'; -$GLOBALS['autostart'] = $cfg['logs_path'].'autostart_deactivated'; -$GLOBALS['langpath'] = dirname(__DIR__).DIRECTORY_SEPARATOR.'languages'.DIRECTORY_SEPARATOR; -if(!isset($cfg['default_language']) || $cfg['default_language'] == NULL) { - $GLOBALS['default_language'] = 'en'; -} else { - $GLOBALS['default_language'] = $cfg['default_language']; -} -$GLOBALS['stylepath'] = dirname(__DIR__).DIRECTORY_SEPARATOR.'styles'.DIRECTORY_SEPARATOR; -if(isset($cfg['default_style'])) $GLOBALS['style'] = get_style($cfg['default_style']); -$GLOBALS['avatarpath'] = dirname(__DIR__).DIRECTORY_SEPARATOR.'avatars'.DIRECTORY_SEPARATOR; - -require_once(__DIR__.DIRECTORY_SEPARATOR.'phpcommand.php'); -$GLOBALS['phpcommand'] = $phpcommand; -?> \ No newline at end of file +query("SELECT * FROM `$dbname`.`cfg_params`"))) { + if (isset($newcfg) && $newcfg != null) { + $cfg = $newcfg->fetchAll(PDO::FETCH_KEY_PAIR); + if (empty($cfg['webinterface_admin_client_unique_id_list'])) { + $cfg['webinterface_admin_client_unique_id_list'] = null; + } else { + $cfg['webinterface_admin_client_unique_id_list'] = array_flip(explode(',', $cfg['webinterface_admin_client_unique_id_list'])); + } + if (empty($cfg['rankup_excepted_unique_client_id_list'])) { + $cfg['rankup_excepted_unique_client_id_list'] = null; + } else { + $cfg['rankup_excepted_unique_client_id_list'] = array_flip(explode(',', $cfg['rankup_excepted_unique_client_id_list'])); + } + if (empty($cfg['rankup_excepted_group_id_list'])) { + $cfg['rankup_excepted_group_id_list'] = null; + } else { + $cfg['rankup_excepted_group_id_list'] = array_flip(explode(',', $cfg['rankup_excepted_group_id_list'])); + } + if (empty($cfg['rankup_excepted_channel_id_list'])) { + $cfg['rankup_excepted_channel_id_list'] = null; + } else { + $cfg['rankup_excepted_channel_id_list'] = array_flip(explode(',', $cfg['rankup_excepted_channel_id_list'])); + } + if (empty($cfg['rankup_definition'])) { + $cfg['rankup_definition'] = null; + } else { + foreach (explode(',', $cfg['rankup_definition']) as $entry) { + if (substr_count($entry, '=>') > 1) { + list($time, $group, $keepflag) = explode('=>', $entry); + } else { + list($time, $group) = explode('=>', $entry); + $keepflag = 0; + } + $addnewvalue1[$time] = ['time'=>$time, 'group'=>$group, 'keep'=>$keepflag]; + $cfg['rankup_definition'] = $addnewvalue1; + } + } + if (empty($cfg['rankup_boost_definition'])) { + $cfg['rankup_boost_definition'] = null; + } else { + foreach (explode(',', $cfg['rankup_boost_definition']) as $entry) { + list($key, $value1, $value2) = explode('=>', $entry); + $addnewvalue2[$key] = ['group'=>$key, 'factor'=>$value1, 'time'=>$value2]; + $cfg['rankup_boost_definition'] = $addnewvalue2; + } + } + if (empty($cfg['stats_api_keys'])) { + $cfg['stats_api_keys'] = null; + } else { + foreach (explode(',', $cfg['stats_api_keys']) as $entry) { + list($key, $desc, $perm_bot) = array_pad(explode('=>', $entry), 3, null); + if (! $perm_bot) { + $perm_bot = 0; + } + $addnewvalue3[$key] = ['key'=>$key, 'desc'=>$desc, 'perm_bot'=>$perm_bot]; + $cfg['stats_api_keys'] = $addnewvalue3; + } + } + unset($addnewvalue1, $addnewvalue2, $addnewvalue3, $newcfg); + } +} + +if (empty($cfg['logs_debug_level'])) { + $GLOBALS['logs_debug_level'] = $cfg['logs_debug_level'] = '5'; +} else { + $GLOBALS['logs_debug_level'] = $cfg['logs_debug_level']; +} +if (empty($cfg['logs_rotation_size'])) { + $GLOBALS['logs_rotation_size'] = $cfg['logs_rotation_size'] = '5'; +} else { + $GLOBALS['logs_rotation_size'] = $cfg['logs_rotation_size']; +} + +if (! isset($cfg['logs_path']) || $cfg['logs_path'] == null) { + $cfg['logs_path'] = dirname(__DIR__).DIRECTORY_SEPARATOR.'logs'.DIRECTORY_SEPARATOR; +} +if (! isset($cfg['logs_timezone'])) { + $GLOBALS['logs_timezone'] = 'Europe/Berlin'; +} else { + $GLOBALS['logs_timezone'] = $cfg['logs_timezone']; +} +date_default_timezone_set($GLOBALS['logs_timezone']); +$GLOBALS['logpath'] = $cfg['logs_path']; +$GLOBALS['logfile'] = $cfg['logs_path'].'ranksystem.log'; +$GLOBALS['pidfile'] = $cfg['logs_path'].'pid'; +$GLOBALS['autostart'] = $cfg['logs_path'].'autostart_deactivated'; +$GLOBALS['langpath'] = dirname(__DIR__).DIRECTORY_SEPARATOR.'languages'.DIRECTORY_SEPARATOR; +if (! isset($cfg['default_language']) || $cfg['default_language'] == null) { + $GLOBALS['default_language'] = 'en'; +} else { + $GLOBALS['default_language'] = $cfg['default_language']; +} +$GLOBALS['stylepath'] = dirname(__DIR__).DIRECTORY_SEPARATOR.'styles'.DIRECTORY_SEPARATOR; +if (isset($cfg['default_style'])) { + $GLOBALS['style'] = get_style($cfg['default_style']); +} +$GLOBALS['avatarpath'] = dirname(__DIR__).DIRECTORY_SEPARATOR.'avatars'.DIRECTORY_SEPARATOR; + +require_once __DIR__.DIRECTORY_SEPARATOR.'phpcommand.php'; +$GLOBALS['phpcommand'] = $phpcommand; diff --git a/other/dbconfig.php b/other/dbconfig.php index 16e07a2..c0b3e9e 100644 --- a/other/dbconfig.php +++ b/other/dbconfig.php @@ -1,7 +1,7 @@ \ No newline at end of file + +$db['type'] = 'type'; +$db['host'] = 'hostname'; +$db['user'] = 'dbuser'; +$db['pass'] = 'dbpass'; +$db['dbname'] = 'ts3_ranksystem'; diff --git a/other/load_addons_config.php b/other/load_addons_config.php index 02209f0..4b66577 100644 --- a/other/load_addons_config.php +++ b/other/load_addons_config.php @@ -1,14 +1,15 @@ -query("SELECT * FROM `$dbname`.`addons_config`")) === false) { - if(function_exists('enter_logfile')) { - enter_logfile($cfg,2,"Error on loading addons config.. Database down, not reachable, corrupt or empty?"); - } else { - echo 'Error on loading addons config..

Check:
- You have already installed the Ranksystem? Run install.php first!
- Is the database reachable?
- You have installed all needed PHP extenstions? Have a look here for Windows or Linux?'; - } - } else { - return $addons_config->fetchAll(PDO::FETCH_GROUP|PDO::FETCH_UNIQUE|PDO::FETCH_ASSOC); - } - //$addons_config['assign_groups_groupids']['value']; -} -?> \ No newline at end of file +query("SELECT * FROM `$dbname`.`addons_config`")) === false) { + if (function_exists('enter_logfile')) { + enter_logfile($cfg, 2, 'Error on loading addons config.. Database down, not reachable, corrupt or empty?'); + } else { + echo 'Error on loading addons config..

Check:
- You have already installed the Ranksystem? Run install.php first!
- Is the database reachable?
- You have installed all needed PHP extenstions? Have a look here for Windows or Linux?'; + } + } else { + return $addons_config->fetchAll(PDO::FETCH_GROUP | PDO::FETCH_UNIQUE | PDO::FETCH_ASSOC); + } + //$addons_config['assign_groups_groupids']['value']; +} diff --git a/other/phpcommand.php b/other/phpcommand.php index 5c3f899..99a3a58 100644 --- a/other/phpcommand.php +++ b/other/phpcommand.php @@ -1,30 +1,30 @@ - \" <-- at the beginning and end of the path, see example below -#$phpcommand = '\"C:\Program Files (x86)\PHP\php.exe\"'; -#$phpcommand = '\"C:\Program Files (x86)\Plesk\Additional\PHP73\php.exe\"'; -## -## -## OTHER -## Synology NAS -#$phpcommand = '/volume1/@appstore/PHP7.2/usr/local/bin/php72'; -?> \ No newline at end of file +//# +//# LINUX +//$phpcommand = 'php74'; +//$phpcommand = '/usr/bin/php7.3'; +//$phpcommand = '/usr/bin/php7.4'; +//$phpcommand = '/opt/plesk/php/7.3/bin/php'; +//$phpcommand = '/opt/plesk/php/7.4/bin/php'; +//# +//# +//# WINDOWS +//$phpcommand = 'C:\PHP7\php.exe'; +//$phpcommand = 'C:\wamp\bin\php\php.exe'; +//$phpcommand = 'C:\xampp\php80\php.exe'; +// On blanks or special characters inside the path, you need to escape these with special marks --> \" <-- at the beginning and end of the path, see example below +//$phpcommand = '\"C:\Program Files (x86)\PHP\php.exe\"'; +//$phpcommand = '\"C:\Program Files (x86)\Plesk\Additional\PHP73\php.exe\"'; +//# +//# +//# OTHER +//# Synology NAS +//$phpcommand = '/volume1/@appstore/PHP7.2/usr/local/bin/php72'; diff --git a/other/session_handling.php b/other/session_handling.php index 0e93232..631ce9a 100644 --- a/other/session_handling.php +++ b/other/session_handling.php @@ -1,10 +1,10 @@ - \ No newline at end of file +',$lang['imprint'],''; - } else { - echo ''; +',$lang['imprint'],''; + } else { + echo ''; } -?> \ No newline at end of file diff --git a/stats/_nav.php b/stats/_nav.php index ff5d723..7145cb2 100644 --- a/stats/_nav.php +++ b/stats/_nav.php @@ -1,188 +1,189 @@ -query("SELECT * FROM `$dbname`.`job_check`")->fetchAll(PDO::FETCH_UNIQUE|PDO::FETCH_ASSOC); -if((time() - $job_check['last_update']['timestamp']) < 259200 && !isset($_SESSION[$rspathhex.'upinfomsg'])) { - if(!isset($err_msg)) { - $err_msg = ''.sprintf($lang['upinf2'], date("Y-m-d H:i",$job_check['last_update']['timestamp']), '', ''); $err_lvl = 1; - $_SESSION[$rspathhex.'upinfomsg'] = 1; - } -} - -if(isset($_POST['username'])) { - $_GET["search"] = $_POST['usersuche']; - $_GET["seite"] = 1; -} -$filter = $searchstring = NULL; -if(isset($_GET["search"]) && $_GET["search"] != '') { - $getstring = htmlspecialchars($_GET['search']); -} -if(isset($getstring) && strstr($getstring, 'filter:excepted:')) { - if(str_replace('filter:excepted:','',$getstring)!='') { - $searchstring = str_replace('filter:excepted:','',$getstring); - } - $filter .= " AND `except` IN ('2','3')"; -} elseif(isset($getstring) && strstr($getstring, 'filter:nonexcepted:')) { - if(str_replace('filter:nonexcepted:','',$getstring)!='') { - $searchstring = str_replace('filter:nonexcepted:','',$getstring); - } - $filter .= " AND `except` IN ('0','1')"; -} else { - if(isset($getstring)) { - $searchstring = $getstring; - } else { - $searchstring = ''; - } - if($cfg['stats_show_excepted_clients_switch'] == 0) { - $filter .= " AND `except` IN ('0','1')"; - } -} -if(isset($getstring) && strstr($getstring, 'filter:online:')) { - $searchstring = preg_replace('/filter\:online\:/','',$searchstring); - $filter .= " AND `online`='1'"; -} elseif(isset($getstring) && strstr($getstring, 'filter:nononline:')) { - $searchstring = preg_replace('/filter\:nononline\:/','',$searchstring); - $filter .= " AND `online`='0'"; -} -if(isset($getstring) && strstr($getstring, 'filter:actualgroup:')) { - preg_match('/filter\:actualgroup\:(.*)\:/',$searchstring,$grpvalue); - $searchstring = preg_replace('/filter\:actualgroup\:(.*)\:/','',$searchstring); - $filter .= " AND `grpid`='".$grpvalue[1]."'"; -} -if(isset($getstring) && strstr($getstring, 'filter:country:')) { - preg_match('/filter\:country\:(.*)\:/',$searchstring,$grpvalue); - $searchstring = preg_replace('/filter\:country\:(.*)\:/','',$searchstring); - $filter .= " AND `nation`='".$grpvalue[1]."'"; -} -if(isset($getstring) && strstr($getstring, 'filter:lastseen:')) { - preg_match('/filter\:lastseen\:(.*)\:(.*)\:/',$searchstring,$seenvalue); - $searchstring = preg_replace('/filter\:lastseen\:(.*)\:(.*)\:/','',$searchstring); - if(isset($seenvalue[2]) && is_numeric($seenvalue[2])) { - $lastseen = $seenvalue[2]; - } elseif(isset($seenvalue[2])) { - $r = date_parse_from_format("Y-m-d H-i",$seenvalue[2]); - $lastseen = mktime($r['hour'], $r['minute'], $r['second'], $r['month'], $r['day'], $r['year']); - } else { - $lastseen = 0; - } - if(isset($seenvalue[1]) && ($seenvalue[1] == '<' || $seenvalue[1] == '<')) { - $operator = '<'; - } elseif(isset($seenvalue[1]) && ($seenvalue[1] == '>' || $seenvalue[1] == '>')) { - $operator = '>'; - } elseif(isset($seenvalue[1]) && $seenvalue[1] == '!=') { - $operator = '!='; - } else { - $operator = '='; - } - $filter .= " AND `lastseen`".$operator."'".$lastseen."'"; -} -$searchstring = htmlspecialchars_decode($searchstring); - -if(isset($getstring)) { - $dbdata_full = $mysqlcon->prepare("SELECT COUNT(*) FROM `$dbname`.`user` WHERE (`uuid` LIKE :searchvalue OR `cldbid` LIKE :searchvalue OR `name` LIKE :searchvalue)$filter"); - $dbdata_full->bindValue(':searchvalue', '%'.$searchstring.'%', PDO::PARAM_STR); - $dbdata_full->execute(); - $sumentries = $dbdata_full->fetch(PDO::FETCH_NUM); - $getstring = rawurlencode($getstring); -} else { - $getstring = ''; - $sumentries = $mysqlcon->query("SELECT COUNT(*) FROM `$dbname`.`user`")->fetch(PDO::FETCH_NUM); -} - -if(!isset($_GET["seite"])) { - $seite = 1; -} else { - $_GET["seite"] = preg_replace('/\D/', '', $_GET["seite"]); - if($_GET["seite"] > 0) { - $seite = $_GET["seite"]; - } else { - $seite = 1; - } -} -$adminlogin = 0; -$sortarr = array_flip(array("active","cldbid","count","grpid","grpsince","idle","lastseen","name","nation","nextup","platform","rank","uuid","version","count_day","count_week","count_month","idle_day","idle_week","idle_month","active_day","active_week","active_month")); - -if(isset($_GET['sort']) && isset($sortarr[$_GET['sort']])) { - $keysort = $_GET['sort']; -} else { - $keysort = $cfg['stats_column_default_sort']; -} -if(isset($_GET['order']) && $_GET['order'] == 'desc') { - $keyorder = 'desc'; -} elseif(isset($_GET['order']) && $_GET['order'] == 'asc') { - $keyorder = 'asc'; -} else { - $keyorder = $cfg['stats_column_default_order']; -} - -if(isset($_GET['admin'])) { - if(hash_equals($_SESSION[$rspathhex.'username'], $cfg['webinterface_user']) && hash_equals($_SESSION[$rspathhex.'password'], $cfg['webinterface_pass']) && hash_equals($_SESSION[$rspathhex.'clientip'], getclientip())) { - $adminlogin = 1; - } -} - -if(!isset($_GET["user"])) { - $user_pro_seite = 25; -} elseif($_GET['user'] == "all") { - if($sumentries[0] > 1000) { - $user_pro_seite = 1000; - } else { - $user_pro_seite = $sumentries[0]; - } -} else { - $_GET["user"] = preg_replace('/\D/', '', $_GET["user"]); - if($_GET["user"] > 1000) { - $user_pro_seite = 1000; - } elseif($_GET["user"] > 0) { - $user_pro_seite = $_GET["user"]; - } else { - $user_pro_seite = 25; - } -} -?> +query("SELECT * FROM `$dbname`.`job_check`")->fetchAll(PDO::FETCH_UNIQUE | PDO::FETCH_ASSOC); +if ((time() - $job_check['last_update']['timestamp']) < 259200 && ! isset($_SESSION[$rspathhex.'upinfomsg'])) { + if (! isset($err_msg)) { + $err_msg = ''.sprintf($lang['upinf2'], date('Y-m-d H:i', $job_check['last_update']['timestamp']), '', ''); + $err_lvl = 1; + $_SESSION[$rspathhex.'upinfomsg'] = 1; + } +} + +if (isset($_POST['username'])) { + $_GET['search'] = $_POST['usersuche']; + $_GET['seite'] = 1; +} +$filter = $searchstring = null; +if (isset($_GET['search']) && $_GET['search'] != '') { + $getstring = htmlspecialchars($_GET['search']); +} +if (isset($getstring) && strstr($getstring, 'filter:excepted:')) { + if (str_replace('filter:excepted:', '', $getstring) != '') { + $searchstring = str_replace('filter:excepted:', '', $getstring); + } + $filter .= " AND `except` IN ('2','3')"; +} elseif (isset($getstring) && strstr($getstring, 'filter:nonexcepted:')) { + if (str_replace('filter:nonexcepted:', '', $getstring) != '') { + $searchstring = str_replace('filter:nonexcepted:', '', $getstring); + } + $filter .= " AND `except` IN ('0','1')"; +} else { + if (isset($getstring)) { + $searchstring = $getstring; + } else { + $searchstring = ''; + } + if ($cfg['stats_show_excepted_clients_switch'] == 0) { + $filter .= " AND `except` IN ('0','1')"; + } +} +if (isset($getstring) && strstr($getstring, 'filter:online:')) { + $searchstring = preg_replace('/filter\:online\:/', '', $searchstring); + $filter .= " AND `online`='1'"; +} elseif (isset($getstring) && strstr($getstring, 'filter:nononline:')) { + $searchstring = preg_replace('/filter\:nononline\:/', '', $searchstring); + $filter .= " AND `online`='0'"; +} +if (isset($getstring) && strstr($getstring, 'filter:actualgroup:')) { + preg_match('/filter\:actualgroup\:(.*)\:/', $searchstring, $grpvalue); + $searchstring = preg_replace('/filter\:actualgroup\:(.*)\:/', '', $searchstring); + $filter .= " AND `grpid`='".$grpvalue[1]."'"; +} +if (isset($getstring) && strstr($getstring, 'filter:country:')) { + preg_match('/filter\:country\:(.*)\:/', $searchstring, $grpvalue); + $searchstring = preg_replace('/filter\:country\:(.*)\:/', '', $searchstring); + $filter .= " AND `nation`='".$grpvalue[1]."'"; +} +if (isset($getstring) && strstr($getstring, 'filter:lastseen:')) { + preg_match('/filter\:lastseen\:(.*)\:(.*)\:/', $searchstring, $seenvalue); + $searchstring = preg_replace('/filter\:lastseen\:(.*)\:(.*)\:/', '', $searchstring); + if (isset($seenvalue[2]) && is_numeric($seenvalue[2])) { + $lastseen = $seenvalue[2]; + } elseif (isset($seenvalue[2])) { + $r = date_parse_from_format('Y-m-d H-i', $seenvalue[2]); + $lastseen = mktime($r['hour'], $r['minute'], $r['second'], $r['month'], $r['day'], $r['year']); + } else { + $lastseen = 0; + } + if (isset($seenvalue[1]) && ($seenvalue[1] == '<' || $seenvalue[1] == '<')) { + $operator = '<'; + } elseif (isset($seenvalue[1]) && ($seenvalue[1] == '>' || $seenvalue[1] == '>')) { + $operator = '>'; + } elseif (isset($seenvalue[1]) && $seenvalue[1] == '!=') { + $operator = '!='; + } else { + $operator = '='; + } + $filter .= ' AND `lastseen`'.$operator."'".$lastseen."'"; +} +$searchstring = htmlspecialchars_decode($searchstring); + +if (isset($getstring)) { + $dbdata_full = $mysqlcon->prepare("SELECT COUNT(*) FROM `$dbname`.`user` WHERE (`uuid` LIKE :searchvalue OR `cldbid` LIKE :searchvalue OR `name` LIKE :searchvalue)$filter"); + $dbdata_full->bindValue(':searchvalue', '%'.$searchstring.'%', PDO::PARAM_STR); + $dbdata_full->execute(); + $sumentries = $dbdata_full->fetch(PDO::FETCH_NUM); + $getstring = rawurlencode($getstring); +} else { + $getstring = ''; + $sumentries = $mysqlcon->query("SELECT COUNT(*) FROM `$dbname`.`user`")->fetch(PDO::FETCH_NUM); +} + +if (! isset($_GET['seite'])) { + $seite = 1; +} else { + $_GET['seite'] = preg_replace('/\D/', '', $_GET['seite']); + if ($_GET['seite'] > 0) { + $seite = $_GET['seite']; + } else { + $seite = 1; + } +} +$adminlogin = 0; +$sortarr = array_flip(['active', 'cldbid', 'count', 'grpid', 'grpsince', 'idle', 'lastseen', 'name', 'nation', 'nextup', 'platform', 'rank', 'uuid', 'version', 'count_day', 'count_week', 'count_month', 'idle_day', 'idle_week', 'idle_month', 'active_day', 'active_week', 'active_month']); + +if (isset($_GET['sort']) && isset($sortarr[$_GET['sort']])) { + $keysort = $_GET['sort']; +} else { + $keysort = $cfg['stats_column_default_sort']; +} +if (isset($_GET['order']) && $_GET['order'] == 'desc') { + $keyorder = 'desc'; +} elseif (isset($_GET['order']) && $_GET['order'] == 'asc') { + $keyorder = 'asc'; +} else { + $keyorder = $cfg['stats_column_default_order']; +} + +if (isset($_GET['admin'])) { + if (hash_equals($_SESSION[$rspathhex.'username'], $cfg['webinterface_user']) && hash_equals($_SESSION[$rspathhex.'password'], $cfg['webinterface_pass']) && hash_equals($_SESSION[$rspathhex.'clientip'], getclientip())) { + $adminlogin = 1; + } +} + +if (! isset($_GET['user'])) { + $user_pro_seite = 25; +} elseif ($_GET['user'] == 'all') { + if ($sumentries[0] > 1000) { + $user_pro_seite = 1000; + } else { + $user_pro_seite = $sumentries[0]; + } +} else { + $_GET['user'] = preg_replace('/\D/', '', $_GET['user']); + if ($_GET['user'] > 1000) { + $user_pro_seite = 1000; + } elseif ($_GET['user'] > 0) { + $user_pro_seite = $_GET['user']; + } else { + $user_pro_seite = 25; + } +} +?> - + - + TSN Ranksystem - ts-ranksystem.com - -'; - } - switch(basename($_SERVER['SCRIPT_NAME'])) { - case "index.php": - ?> - - - - - - + +'; + } + switch(basename($_SERVER['SCRIPT_NAME'])) { + case 'index.php': + ?> + + + + + + - '; - } - if(isset($cfg['stats_show_site_navigation_switch']) && $cfg['stats_show_site_navigation_switch'] == 0) { ?> - + '; + } + if (isset($cfg['stats_show_site_navigation_switch']) && $cfg['stats_show_site_navigation_switch'] == 0) { ?> + @@ -221,16 +222,16 @@ @@ -241,14 +242,14 @@
@@ -258,17 +259,17 @@ @@ -281,43 +282,43 @@ - +
-'; - } +'; + } ?> \ No newline at end of file diff --git a/stats/_preload.php b/stats/_preload.php index 8ba1f13..3397668 100644 --- a/stats/_preload.php +++ b/stats/_preload.php @@ -1,27 +1,28 @@ - \ No newline at end of file +

This addon is (currently) disabled!

'; - exit; - } - - if(isset($_SESSION[$rspathhex.'tsuid'])) { - $uuid = $_SESSION[$rspathhex.'tsuid']; - } else { - $uuid = "no_uuid_found"; - } - if(($dbdata = $mysqlcon->query("SELECT `cldgroup` FROM `$dbname`.`user` WHERE `uuid`='$uuid'")->fetch()) === false) { - $err_msg = print_r($mysqlcon->errorInfo(), true); $err_lvl = 3; - } - $cld_groups = array(); - if(isset($dbdata['cldgroup']) && $dbdata['cldgroup'] != '') { - $cld_groups = explode(',', $dbdata['cldgroup']); - } - - $disabled = ''; - $allowed_groups_arr = array(); - - $csrf_token = bin2hex(openssl_random_pseudo_bytes(32)); - - if ($mysqlcon->exec("INSERT INTO `$dbname`.`csrf_token` (`token`,`timestamp`,`sessionid`) VALUES ('$csrf_token','".time()."','".session_id()."')") === false) { - $err_msg = print_r($mysqlcon->errorInfo(), true); - $err_lvl = 3; - } - - if (($db_csrf = $mysqlcon->query("SELECT * FROM `$dbname`.`csrf_token` WHERE `sessionid`='".session_id()."'")->fetchALL(PDO::FETCH_UNIQUE|PDO::FETCH_ASSOC)) === false) { - $err_msg = print_r($mysqlcon->errorInfo(), true); - $err_lvl = 3; - } - - if(($sqlhisgroup = $mysqlcon->query("SELECT * FROM `$dbname`.`groups`")->fetchAll(PDO::FETCH_ASSOC|PDO::FETCH_UNIQUE)) === false) { - $err_msg = print_r($mysqlcon->errorInfo(), true); $err_lvl = 3; - } - - if(count($_SESSION[$rspathhex.'multiple']) > 1 and !isset($_SESSION[$rspathhex.'uuid_verified'])) { - $disabled = 1; - $err_msg = sprintf($lang['stag0006'], '', ''); $err_lvl = 3; - } elseif ($_SESSION[$rspathhex.'connected'] == 0) { - $err_msg = sprintf($lang['stag0015'], '', ''); $err_lvl = 3; - $disabled = 1; - } else { - - - $name = explode(';',$addons_config['assign_groups_name']['value']); - $alwgr = explode(';',$addons_config['assign_groups_groupids']['value']); - $limit = explode(';',$addons_config['assign_groups_limit']['value']); - $excgr = explode(';',$addons_config['assign_groups_excepted_groupids']['value']); - - if(isset($_POST['update']) && isset($db_csrf[$_POST['csrf_token']])) { - if(($sumentries = $mysqlcon->query("SELECT COUNT(*) FROM `$dbname`.`addon_assign_groups` WHERE `uuid`='$uuid'")->fetch(PDO::FETCH_NUM)) === false) { - $err_msg = print_r($mysqlcon->errorInfo(), true); $err_lvl = 3; - } else { - if($sumentries[0] > 0) { - $err_msg = $lang['stag0007']; $err_lvl = 3; - } else { - $set_groups = $err_msg = ''; - $limit_raised = $excepted = 0; - - foreach($alwgr as $rowid => $value) { - $count_limit = $changed_group = 0; - - $allowed_groups_arr = explode(',', $alwgr[$rowid]); - $excepted_groups_arr = explode(',', $excgr[$rowid]); - - foreach($allowed_groups_arr as $allowed_group) { - if(in_array($allowed_group, $cld_groups)) { - $count_limit++; - } - if(isset($_POST[$allowed_group]) && $_POST[$allowed_group] == 1 && !in_array($allowed_group, $cld_groups)) { - $set_groups .= $allowed_group.','; - array_push($cld_groups, $allowed_group); - $count_limit++; - $changed_group++; - } - if(!isset($_POST[$allowed_group]) && in_array($allowed_group, $cld_groups)) { - $set_groups .= '-'.$allowed_group.','; - $position = array_search($allowed_group, $cld_groups); - array_splice($cld_groups, $position, 1); - $count_limit--; - $changed_group++; - } - } - - if(isset($excepted_groups_arr) && $excepted_groups_arr != '') { - foreach($excepted_groups_arr as $excepted_group) { - if(in_array($excepted_group, $cld_groups) && $changed_group != 0) { - $excepted++; - if($err_msg != '') { - $err_msg .= '#####'; - $err_lvl .= '#3'; - } else { - $err_lvl = 3; - } - $err_msg .= "".$name[$rowid]."
".sprintf($lang['stag0019'], $sqlhisgroup[$excepted_group]['sgidname'], $excepted_group); - break; - } - } - } - - if($set_groups != '' && $count_limit > $limit[$rowid]) { - if($err_msg != '') { - $err_msg .= '#####'; - $err_lvl .= '#3'; - } else { - $err_lvl = 3; - } - $err_msg .= "".$name[$rowid]."
".sprintf($lang['stag0009'], $limit[$rowid]); - $limit_raised = 1; - } - } - $set_groups = substr($set_groups, 0, -1); - - if($set_groups != '' && $limit_raised == 0 && $excepted == 0) { - if ($mysqlcon->exec("INSERT INTO `$dbname`.`addon_assign_groups` SET `uuid`='$uuid',`grpids`='$set_groups'; DELETE FROM `$dbname`.`csrf_token` WHERE `token`='{$_POST['csrf_token']}'") === false) { - $err_msg = $lang['isntwidbmsg'].print_r($mysqlcon->errorInfo(), true); $err_lvl = 3; - } elseif($mysqlcon->exec("UPDATE `$dbname`.`job_check` SET `timestamp`=1 WHERE `job_name`='reload_trigger'; ") === false) { - $err_msg = $lang['isntwidbmsg'].print_r($mysqlcon->errorInfo(), true); $err_lvl = 3; - } else { - $err_msg = $lang['stag0008']; $err_lvl = NULL; - } - } elseif($limit_raised != 0) { - #message above generated - } elseif($excepted > 0) { - #message above generated - } else { - $err_msg = $lang['stag0010']; $err_lvl = 3; - } - } - } - } elseif(isset($_POST['update'])) { - echo '
',$lang['errcsrf'],'
'; - rem_session_ts3(); - exit; - } - } - ?> +

This addon is (currently) disabled!

'; + exit; + } + + if (isset($_SESSION[$rspathhex.'tsuid'])) { + $uuid = $_SESSION[$rspathhex.'tsuid']; + } else { + $uuid = 'no_uuid_found'; + } + if (($dbdata = $mysqlcon->query("SELECT `cldgroup` FROM `$dbname`.`user` WHERE `uuid`='$uuid'")->fetch()) === false) { + $err_msg = print_r($mysqlcon->errorInfo(), true); + $err_lvl = 3; + } + $cld_groups = []; + if (isset($dbdata['cldgroup']) && $dbdata['cldgroup'] != '') { + $cld_groups = explode(',', $dbdata['cldgroup']); + } + + $disabled = ''; + $allowed_groups_arr = []; + + $csrf_token = bin2hex(openssl_random_pseudo_bytes(32)); + + if ($mysqlcon->exec("INSERT INTO `$dbname`.`csrf_token` (`token`,`timestamp`,`sessionid`) VALUES ('$csrf_token','".time()."','".session_id()."')") === false) { + $err_msg = print_r($mysqlcon->errorInfo(), true); + $err_lvl = 3; + } + + if (($db_csrf = $mysqlcon->query("SELECT * FROM `$dbname`.`csrf_token` WHERE `sessionid`='".session_id()."'")->fetchALL(PDO::FETCH_UNIQUE | PDO::FETCH_ASSOC)) === false) { + $err_msg = print_r($mysqlcon->errorInfo(), true); + $err_lvl = 3; + } + + if (($sqlhisgroup = $mysqlcon->query("SELECT * FROM `$dbname`.`groups`")->fetchAll(PDO::FETCH_ASSOC | PDO::FETCH_UNIQUE)) === false) { + $err_msg = print_r($mysqlcon->errorInfo(), true); + $err_lvl = 3; + } + + if (count($_SESSION[$rspathhex.'multiple']) > 1 and ! isset($_SESSION[$rspathhex.'uuid_verified'])) { + $disabled = 1; + $err_msg = sprintf($lang['stag0006'], '', ''); + $err_lvl = 3; + } elseif ($_SESSION[$rspathhex.'connected'] == 0) { + $err_msg = sprintf($lang['stag0015'], '', ''); + $err_lvl = 3; + $disabled = 1; + } else { + $name = explode(';', $addons_config['assign_groups_name']['value']); + $alwgr = explode(';', $addons_config['assign_groups_groupids']['value']); + $limit = explode(';', $addons_config['assign_groups_limit']['value']); + $excgr = explode(';', $addons_config['assign_groups_excepted_groupids']['value']); + + if (isset($_POST['update']) && isset($db_csrf[$_POST['csrf_token']])) { + if (($sumentries = $mysqlcon->query("SELECT COUNT(*) FROM `$dbname`.`addon_assign_groups` WHERE `uuid`='$uuid'")->fetch(PDO::FETCH_NUM)) === false) { + $err_msg = print_r($mysqlcon->errorInfo(), true); + $err_lvl = 3; + } else { + if ($sumentries[0] > 0) { + $err_msg = $lang['stag0007']; + $err_lvl = 3; + } else { + $set_groups = $err_msg = ''; + $limit_raised = $excepted = 0; + + foreach ($alwgr as $rowid => $value) { + $count_limit = $changed_group = 0; + + $allowed_groups_arr = explode(',', $alwgr[$rowid]); + $excepted_groups_arr = explode(',', $excgr[$rowid]); + + foreach ($allowed_groups_arr as $allowed_group) { + if (in_array($allowed_group, $cld_groups)) { + $count_limit++; + } + if (isset($_POST[$allowed_group]) && $_POST[$allowed_group] == 1 && ! in_array($allowed_group, $cld_groups)) { + $set_groups .= $allowed_group.','; + array_push($cld_groups, $allowed_group); + $count_limit++; + $changed_group++; + } + if (! isset($_POST[$allowed_group]) && in_array($allowed_group, $cld_groups)) { + $set_groups .= '-'.$allowed_group.','; + $position = array_search($allowed_group, $cld_groups); + array_splice($cld_groups, $position, 1); + $count_limit--; + $changed_group++; + } + } + + if (isset($excepted_groups_arr) && $excepted_groups_arr != '') { + foreach ($excepted_groups_arr as $excepted_group) { + if (in_array($excepted_group, $cld_groups) && $changed_group != 0) { + $excepted++; + if ($err_msg != '') { + $err_msg .= '#####'; + $err_lvl .= '#3'; + } else { + $err_lvl = 3; + } + $err_msg .= ''.$name[$rowid].'
'.sprintf($lang['stag0019'], $sqlhisgroup[$excepted_group]['sgidname'], $excepted_group); + break; + } + } + } + + if ($set_groups != '' && $count_limit > $limit[$rowid]) { + if ($err_msg != '') { + $err_msg .= '#####'; + $err_lvl .= '#3'; + } else { + $err_lvl = 3; + } + $err_msg .= ''.$name[$rowid].'
'.sprintf($lang['stag0009'], $limit[$rowid]); + $limit_raised = 1; + } + } + $set_groups = substr($set_groups, 0, -1); + + if ($set_groups != '' && $limit_raised == 0 && $excepted == 0) { + if ($mysqlcon->exec("INSERT INTO `$dbname`.`addon_assign_groups` SET `uuid`='$uuid',`grpids`='$set_groups'; DELETE FROM `$dbname`.`csrf_token` WHERE `token`='{$_POST['csrf_token']}'") === false) { + $err_msg = $lang['isntwidbmsg'].print_r($mysqlcon->errorInfo(), true); + $err_lvl = 3; + } elseif ($mysqlcon->exec("UPDATE `$dbname`.`job_check` SET `timestamp`=1 WHERE `job_name`='reload_trigger'; ") === false) { + $err_msg = $lang['isntwidbmsg'].print_r($mysqlcon->errorInfo(), true); + $err_lvl = 3; + } else { + $err_msg = $lang['stag0008']; + $err_lvl = null; + } + } elseif ($limit_raised != 0) { + //message above generated + } elseif ($excepted > 0) { + //message above generated + } else { + $err_msg = $lang['stag0010']; + $err_lvl = 3; + } + } + } + } elseif (isset($_POST['update'])) { + echo '
',$lang['errcsrf'],'
'; + rem_session_ts3(); + exit; + } + } + ?>
- +

- +

- +
- $value) { - $output[$forcount]['output'] = ''; - $allowed_groups_arr = explode(',', $alwgr[$rowid]); - $excepted_groups_arr = explode(',', $excgr[$rowid]); - if(isset($excepted_groups_arr) && $excepted_groups_arr != '') { - foreach($excepted_groups_arr as $excepted_group) { - if(in_array($excepted_group, $cld_groups)) { - $output[$forcount]['except'] = 1; - $excepted_group = "".$name[$rowid]."
".sprintf($lang['stag0019'], $sqlhisgroup[$excepted_group]['sgidname'], $excepted_group); - $exception_count++; - break; - } - } - } - $output[$forcount]['output'] .= '

'.$name[$rowid].'

'.$lang['stag0011'].$limit[$rowid].'
'; - foreach($allowed_groups_arr as $allowed_group) { - $output[$forcount]['output'] .= '
'; - if (isset($sqlhisgroup[$allowed_group]['iconid']) && $sqlhisgroup[$allowed_group]['iconid'] != 0) { - $output[$forcount]['output'] .= ''; - } else { - $output[$forcount]['output'] .= ''; - } - $output[$forcount]['output'] .= '
'; - if(in_array($allowed_group, $cld_groups)) { - $output[$forcount]['output'] .= ''; - } else { - $output[$forcount]['output'] .= ''; - } - $output[$forcount]['output'] .= '
'; - } - $output[$forcount]['output'] .= '
'; - $forcount++; - } - - foreach($output as $value) { - if(isset($value['except']) && $value['except'] == 1) { - echo '
- + - diff --git a/stats/index.php b/stats/index.php index 6e556f2..5b6374f 100644 --- a/stats/index.php +++ b/stats/index.php @@ -1,39 +1,45 @@ -query("SELECT * FROM `$dbname`.`stats_server`")->fetch()) === false) { - $err_msg = print_r($mysqlcon->errorInfo(), true); $err_lvl = 3; - } - - if(($groupslist = $mysqlcon->query("SELECT * FROM `$dbname`.`groups` WHERE `sgid`=0")->fetchAll(PDO::FETCH_UNIQUE|PDO::FETCH_ASSOC)) === false) { - $err_msg = print_r($mysqlcon->errorInfo(), true); $err_lvl = 3; - } - ?> +query("SELECT * FROM `$dbname`.`stats_server`")->fetch()) === false) { + $err_msg = print_r($mysqlcon->errorInfo(), true); + $err_lvl = 3; + } + + if (($groupslist = $mysqlcon->query("SELECT * FROM `$dbname`.`groups` WHERE `sgid`=0")->fetchAll(PDO::FETCH_UNIQUE | PDO::FETCH_ASSOC)) === false) { + $err_msg = print_r($mysqlcon->errorInfo(), true); + $err_lvl = 3; + } + ?>
- +

- + @@ -49,14 +55,14 @@

-
-
+
+
@@ -71,14 +77,18 @@
-
-
+
+
@@ -93,14 +103,22 @@
-
-
+
+
@@ -115,14 +133,22 @@
-
-
+
+
@@ -136,15 +162,15 @@
-

+

@@ -160,7 +186,7 @@
- + @@ -294,14 +320,14 @@
-
-
+
+
- + @@ -311,102 +337,137 @@
-

+

- - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + +
'.$lang['stix0024'].''; } else { echo ''.$lang['stix0025'].''; } ?>'.$lang['stix0024'].''; + } else { + echo ''.$lang['stix0025'].''; + } ?>
'.$lang['stix0032'].''.(new DateTime("@0"))->diff($serveruptime)->format($cfg['default_date_format']).')'; } else { echo $lang['stix0033']; } ?>'.$lang['stix0032'].''.(new DateTime('@0'))->diff($serveruptime)->format($cfg['default_date_format']).')'; + } else { + echo $lang['stix0033']; + } ?>
-

+

- - + + - - - - + + - - + + - - + + - - + + - - + + - - + +
servericon'; - } else { echo $sql_res['server_name']; } ?>servericon'; + } else { + echo $sql_res['server_name']; + } ?>
"> -
@@ -416,60 +477,60 @@
- - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - '; - } else { - echo ''; - } - if (isset($nation[$sql_res['country_nation_name_2']])) { - echo ''; - } else { - echo ''; - } - if (isset($nation[$sql_res['country_nation_name_3']])) { - echo ''; - } else { - echo ''; - } - if (isset($nation[$sql_res['country_nation_name_4']])) { - echo ''; - } else { - echo ''; - } - if (isset($nation[$sql_res['country_nation_name_5']])) { - echo ''; - } else { - echo ''; - } - ?> - - - - - - - - - + '; + } else { + echo ''; + } + if (isset($nation[$sql_res['country_nation_name_2']])) { + echo ''; + } else { + echo ''; + } + if (isset($nation[$sql_res['country_nation_name_3']])) { + echo ''; + } else { + echo ''; + } + if (isset($nation[$sql_res['country_nation_name_4']])) { + echo ''; + } else { + echo ''; + } + if (isset($nation[$sql_res['country_nation_name_5']])) { + echo ''; + } else { + echo ''; + } + ?> + + + + + + + + + @@ -497,9 +558,10 @@ - + - \ No newline at end of file diff --git a/stats/info.php b/stats/info.php index 96fe8a7..19daeca 100644 --- a/stats/info.php +++ b/stats/info.php @@ -1,48 +1,50 @@ - +
- +

- +

-

-

+

+


-

+

The Ranksystem was coded by Newcomer1989 Copyright © 2009-2023 powered by TS-N.NET


-

-

-

-

-

+

+

+

+

+


-

-

+

+

PHP - Copyright © 2001-2023 the PHP Group


-

+

jQuery v3.6.2 - Copyright © 2020 The jQuery Foundation

Font Awesome 5.15.1 - Copyright © Fonticons, Inc.

flag-icon-css 3.5.0 - Copyright © 2020 flag-icons

@@ -62,33 +64,34 @@
-

-

Shad86 -'); ?>

-

mightyBroccoli -'); ?>

-

Arselopster, DeviantUser & kidi -'); ?>

-

-

ZanK & jacopomozzy -'); ?>

-

DeStRoYzR & Jehad -'); ?>

-

SakaLuX -'); ?>

-

0x0539 -'); ?>

-

-

Pasha -'); ?>

-

KeviN & Stetinac -'); ?>

-

DoktorekOne & toster234 -'); ?>

-

JavierlechuXD -'); ?>

-

ExXeL -'); ?>

-

G. FARZALIYEV -'); ?>

-

Nick Slowinski -'); ?>

-

JimmyNail -'); ?>

+

+

Shad86 -'); ?>

+

mightyBroccoli -'); ?>

+

Arselopster, DeviantUser & kidi -'); ?>

+

+

ZanK & jacopomozzy -'); ?>

+

DeStRoYzR & Jehad -'); ?>

+

SakaLuX -'); ?>

+

0x0539 -'); ?>

+

+

Pasha -'); ?>

+

KeviN & Stetinac -'); ?>

+

DoktorekOne & toster234 -'); ?>

+

JavierlechuXD -'); ?>

+

ExXeL -'); ?>

+

G. FARZALIYEV -'); ?>

+

Nick Slowinski -'); ?>

+

JimmyNail -'); ?>


- + - \ No newline at end of file diff --git a/stats/list_rankup.php b/stats/list_rankup.php index 7a7a8b7..beb78b6 100644 --- a/stats/list_rankup.php +++ b/stats/list_rankup.php @@ -1,148 +1,154 @@ -prepare("SELECT * FROM `$dbname`.`user`$stats_user_tbl WHERE 1=1$filter$stats_user_where ORDER BY $order LIMIT :start, :userproseite"); - } else { - $dbdata = $mysqlcon->prepare("SELECT * FROM `$dbname`.`user`$stats_user_tbl WHERE (`user`.`uuid` LIKE :searchvalue OR `user`.`cldbid` LIKE :searchvalue OR `user`.`name` LIKE :searchvalue) $filter$stats_user_where ORDER BY $order LIMIT :start, :userproseite"); - $dbdata->bindValue(':searchvalue', '%'.$searchstring.'%', PDO::PARAM_STR); - } - - $dbdata->bindValue(':start', (int) $start, PDO::PARAM_INT); - $dbdata->bindValue(':userproseite', (int) $user_pro_seite, PDO::PARAM_INT); - $dbdata->execute(); - - if($user_pro_seite > 0 && isset($sumentries[0])) { - $seiten_anzahl_gerundet = ceil($sumentries[0] / $user_pro_seite); - } else { - $seiten_anzahl_gerundet = 0; - } - - if(($sqlhisgroup = $mysqlcon->query("SELECT * FROM `$dbname`.`groups`")->fetchAll(PDO::FETCH_ASSOC|PDO::FETCH_UNIQUE)) === false) { - $err_msg = print_r($mysqlcon->errorInfo(), true); $err_lvl = 3; - } - - $sqlhis = $dbdata->fetchAll(PDO::FETCH_ASSOC|PDO::FETCH_UNIQUE); - - if($adminlogin == 1) { - switch ($keyorder) { - case "asc": - $keyorder2 = "desc&admin=true"; - break; - case "desc": - $keyorder2 = "asc&admin=true"; - } - $keyorder .= "&admin=true"; - } else { - switch ($keyorder) { - case "asc": - $keyorder2 = "desc"; - break; - case "desc": - $keyorder2 = "asc"; - } - } - ?> +prepare("SELECT * FROM `$dbname`.`user`$stats_user_tbl WHERE 1=1$filter$stats_user_where ORDER BY $order LIMIT :start, :userproseite"); + } else { + $dbdata = $mysqlcon->prepare("SELECT * FROM `$dbname`.`user`$stats_user_tbl WHERE (`user`.`uuid` LIKE :searchvalue OR `user`.`cldbid` LIKE :searchvalue OR `user`.`name` LIKE :searchvalue) $filter$stats_user_where ORDER BY $order LIMIT :start, :userproseite"); + $dbdata->bindValue(':searchvalue', '%'.$searchstring.'%', PDO::PARAM_STR); + } + + $dbdata->bindValue(':start', (int) $start, PDO::PARAM_INT); + $dbdata->bindValue(':userproseite', (int) $user_pro_seite, PDO::PARAM_INT); + $dbdata->execute(); + + if ($user_pro_seite > 0 && isset($sumentries[0])) { + $seiten_anzahl_gerundet = ceil($sumentries[0] / $user_pro_seite); + } else { + $seiten_anzahl_gerundet = 0; + } + + if (($sqlhisgroup = $mysqlcon->query("SELECT * FROM `$dbname`.`groups`")->fetchAll(PDO::FETCH_ASSOC | PDO::FETCH_UNIQUE)) === false) { + $err_msg = print_r($mysqlcon->errorInfo(), true); + $err_lvl = 3; + } + + $sqlhis = $dbdata->fetchAll(PDO::FETCH_ASSOC | PDO::FETCH_UNIQUE); + + if ($adminlogin == 1) { + switch ($keyorder) { + case 'asc': + $keyorder2 = 'desc&admin=true'; + break; + case 'desc': + $keyorder2 = 'asc&admin=true'; + } + $keyorder .= '&admin=true'; + } else { + switch ($keyorder) { + case 'asc': + $keyorder2 = 'desc'; + break; + case 'desc': + $keyorder2 = 'asc'; + } + } + ?>
- +
- + - $val) { - if ($cfg[$val['config']] == 1 || $adminlogin == 1) { - echo ''; - $count_columns++; - } - } - echo ''; - ksort($cfg['rankup_definition']); - if (count($sqlhis) > 0) { - foreach ($sqlhis as $uuid => $value) { - if ($cfg['rankup_time_assess_mode'] == 1) { - $activetime = $value['count'] - $value['idle']; - } else { - $activetime = $value['count']; - } - $grpcount=0; - if($cfg['stats_column_next_server_group_switch'] != 1) { - echo list_rankup($cfg,$lang,$sqlhisgroup,$value,$adminlogin,$nation,$grpcount); - } else { - foreach ($cfg['rankup_definition'] as $rank) { - $grpcount++; - if ($activetime < $rank['time'] || $grpcount == count($cfg['rankup_definition']) && $value['nextup'] <= 0 && $cfg['stats_show_clients_in_highest_rank_switch'] == 1 || $grpcount == count($cfg['rankup_definition']) && $value['nextup'] == 0 && $adminlogin == 1) { - echo list_rankup($cfg,$lang,$sqlhisgroup,$value,$adminlogin,$nation,$grpcount,$rank); - break; - } - } - } - } - } else { - echo ''; - } - echo '
',$val['title'],'
',$lang['noentry'],'
'; - if($user_pro_seite != "all") { - echo pagination($keysort,$keyorder,$user_pro_seite,$seiten_anzahl_gerundet,$seite,$getstring); - } - ?> + $val) { + if ($cfg[$val['config']] == 1 || $adminlogin == 1) { + echo '',$val['title'],''; + $count_columns++; + } + } + echo ''; + ksort($cfg['rankup_definition']); + if (count($sqlhis) > 0) { + foreach ($sqlhis as $uuid => $value) { + if ($cfg['rankup_time_assess_mode'] == 1) { + $activetime = $value['count'] - $value['idle']; + } else { + $activetime = $value['count']; + } + $grpcount = 0; + if ($cfg['stats_column_next_server_group_switch'] != 1) { + echo list_rankup($cfg, $lang, $sqlhisgroup, $value, $adminlogin, $nation, $grpcount); + } else { + foreach ($cfg['rankup_definition'] as $rank) { + $grpcount++; + if ($activetime < $rank['time'] || $grpcount == count($cfg['rankup_definition']) && $value['nextup'] <= 0 && $cfg['stats_show_clients_in_highest_rank_switch'] == 1 || $grpcount == count($cfg['rankup_definition']) && $value['nextup'] == 0 && $adminlogin == 1) { + echo list_rankup($cfg, $lang, $sqlhisgroup, $value, $adminlogin, $nation, $grpcount, $rank); + break; + } + } + } + } + } else { + echo '',$lang['noentry'],''; + } + echo ''; + if ($user_pro_seite != 'all') { + echo pagination($keysort, $keyorder, $user_pro_seite, $seiten_anzahl_gerundet, $seite, $getstring); + } + ?>
- + - \ No newline at end of file diff --git a/stats/my_stats.php b/stats/my_stats.php index fc99386..61c7644 100644 --- a/stats/my_stats.php +++ b/stats/my_stats.php @@ -1,91 +1,130 @@ - 1 && !isset($_SESSION[$rspathhex.'uuid_verified'])) { - $err_msg = sprintf($lang['stag0006'], '', ''); $err_lvl = 3; - } elseif (isset($_SESSION[$rspathhex.'connected']) && $_SESSION[$rspathhex.'connected'] == 0 || !isset($_SESSION[$rspathhex.'connected'])) { - $err_msg = sprintf($lang['stag0015'], '', ''); $err_lvl = 3; - } else { - $dbdata_fetched = $mysqlcon->query("SELECT * FROM `$dbname`.`user` WHERE `uuid` LIKE '%".$_SESSION[$rspathhex.'tsuid']."%'")->fetch(); - $count_hours = round($dbdata_fetched['count']/3600); - $idle_hours = round($dbdata_fetched['idle']/3600); - $dbdata_fetched['count'] = round($dbdata_fetched['count']); - $dbdata_fetched['idle'] = round($dbdata_fetched['idle']); - - if ($cfg['rankup_time_assess_mode'] == 1) { - $activetime = $dbdata_fetched['count'] - $dbdata_fetched['idle']; - } else { - $activetime = $dbdata_fetched['count']; - } - $active_count = $dbdata_fetched['count'] - $dbdata_fetched['idle']; - - krsort($cfg['rankup_definition']); - $nextgrp = ''; - - foreach ($cfg['rankup_definition'] as $rank) { - $actualgrp = $rank['time']; - if ($activetime > $rank['time']) { - break; - } else { - $nextgrp = $rank['time']; - } - } - if($actualgrp==$nextgrp) { - $actualgrp = 0; - } - if($activetime>$nextgrp) { - $percentage_rankup = 100; - } else { - $takedtime = $activetime - $actualgrp; - $neededtime = $nextgrp - $actualgrp; - $percentage_rankup = round($takedtime/$neededtime*100, 2); - } - - $stats_user = $mysqlcon->query("SELECT `count_week`,`active_week`,`count_month`,`active_month`,`last_calculated` FROM `$dbname`.`stats_user` WHERE `uuid`='".$_SESSION[$rspathhex.'tsuid']."'")->fetch(); - - if (isset($stats_user['count_week'])) $count_week = $stats_user['count_week']; else $count_week = 0; - $dtF = new DateTime("@0"); $dtT = new DateTime("@$count_week"); $count_week = $dtF->diff($dtT)->format($cfg['default_date_format']); - if (isset($stats_user['active_week'])) $active_week = $stats_user['active_week']; else $active_week = 0; - $dtF = new DateTime("@0"); $dtT = new DateTime("@$active_week"); $active_week = $dtF->diff($dtT)->format($cfg['default_date_format']); - if (isset($stats_user['count_month'])) $count_month = $stats_user['count_month']; else $count_month = 0; - $dtF = new DateTime("@0"); $dtT = new DateTime("@$count_month"); $count_month = $dtF->diff($dtT)->format($cfg['default_date_format']); - if (isset($stats_user['active_month'])) $active_month = $stats_user['active_month']; else $active_month = 0; - $dtF = new DateTime("@0"); $dtT = new DateTime("@$active_month"); $active_month = $dtF->diff($dtT)->format($cfg['default_date_format']); - if (isset($dbdata_fetched['count'])) $count_total = $dbdata_fetched['count']; else $count_total = 0; - $dtF = new DateTime("@0"); $dtT = new DateTime("@".round($count_total)); $count_total = $dtF->diff($dtT)->format($cfg['default_date_format']); - $dtF = new DateTime("@0"); $dtT = new DateTime("@$active_count"); $active_count = $dtF->diff($dtT)->format($cfg['default_date_format']); - - $achievements_done = 0; - - if($count_hours >= $cfg['stats_time_legend']) { - $achievements_done = $achievements_done + 4; - } elseif($count_hours >= $cfg['stats_time_gold']) { - $achievements_done = $achievements_done + 3; - } elseif($count_hours >= $cfg['stats_time_silver']) { - $achievements_done = $achievements_done + 2; - } else { - $achievements_done = $achievements_done + 1; - } - if($_SESSION[$rspathhex.'tsconnections'] >= $cfg['stats_connects_legend']) { - $achievements_done = $achievements_done + 4; - } elseif($_SESSION[$rspathhex.'tsconnections'] >= $cfg['stats_connects_gold']) { - $achievements_done = $achievements_done + 3; - } elseif($_SESSION[$rspathhex.'tsconnections'] >= $cfg['stats_connects_silver']) { - $achievements_done = $achievements_done + 2; - } else { - $achievements_done = $achievements_done + 1; - } - } - ?> + 1 && ! isset($_SESSION[$rspathhex.'uuid_verified'])) { + $err_msg = sprintf($lang['stag0006'], '', ''); + $err_lvl = 3; + } elseif (isset($_SESSION[$rspathhex.'connected']) && $_SESSION[$rspathhex.'connected'] == 0 || ! isset($_SESSION[$rspathhex.'connected'])) { + $err_msg = sprintf($lang['stag0015'], '', ''); + $err_lvl = 3; + } else { + $dbdata_fetched = $mysqlcon->query("SELECT * FROM `$dbname`.`user` WHERE `uuid` LIKE '%".$_SESSION[$rspathhex.'tsuid']."%'")->fetch(); + $count_hours = round($dbdata_fetched['count'] / 3600); + $idle_hours = round($dbdata_fetched['idle'] / 3600); + $dbdata_fetched['count'] = round($dbdata_fetched['count']); + $dbdata_fetched['idle'] = round($dbdata_fetched['idle']); + + if ($cfg['rankup_time_assess_mode'] == 1) { + $activetime = $dbdata_fetched['count'] - $dbdata_fetched['idle']; + } else { + $activetime = $dbdata_fetched['count']; + } + $active_count = $dbdata_fetched['count'] - $dbdata_fetched['idle']; + + krsort($cfg['rankup_definition']); + $nextgrp = ''; + + foreach ($cfg['rankup_definition'] as $rank) { + $actualgrp = $rank['time']; + if ($activetime > $rank['time']) { + break; + } else { + $nextgrp = $rank['time']; + } + } + if ($actualgrp == $nextgrp) { + $actualgrp = 0; + } + if ($activetime > $nextgrp) { + $percentage_rankup = 100; + } else { + $takedtime = $activetime - $actualgrp; + $neededtime = $nextgrp - $actualgrp; + $percentage_rankup = round($takedtime / $neededtime * 100, 2); + } + + $stats_user = $mysqlcon->query("SELECT `count_week`,`active_week`,`count_month`,`active_month`,`last_calculated` FROM `$dbname`.`stats_user` WHERE `uuid`='".$_SESSION[$rspathhex.'tsuid']."'")->fetch(); + + if (isset($stats_user['count_week'])) { + $count_week = $stats_user['count_week']; + } else { + $count_week = 0; + } + $dtF = new DateTime('@0'); + $dtT = new DateTime("@$count_week"); + $count_week = $dtF->diff($dtT)->format($cfg['default_date_format']); + if (isset($stats_user['active_week'])) { + $active_week = $stats_user['active_week']; + } else { + $active_week = 0; + } + $dtF = new DateTime('@0'); + $dtT = new DateTime("@$active_week"); + $active_week = $dtF->diff($dtT)->format($cfg['default_date_format']); + if (isset($stats_user['count_month'])) { + $count_month = $stats_user['count_month']; + } else { + $count_month = 0; + } + $dtF = new DateTime('@0'); + $dtT = new DateTime("@$count_month"); + $count_month = $dtF->diff($dtT)->format($cfg['default_date_format']); + if (isset($stats_user['active_month'])) { + $active_month = $stats_user['active_month']; + } else { + $active_month = 0; + } + $dtF = new DateTime('@0'); + $dtT = new DateTime("@$active_month"); + $active_month = $dtF->diff($dtT)->format($cfg['default_date_format']); + if (isset($dbdata_fetched['count'])) { + $count_total = $dbdata_fetched['count']; + } else { + $count_total = 0; + } + $dtF = new DateTime('@0'); + $dtT = new DateTime('@'.round($count_total)); + $count_total = $dtF->diff($dtT)->format($cfg['default_date_format']); + $dtF = new DateTime('@0'); + $dtT = new DateTime("@$active_count"); + $active_count = $dtF->diff($dtT)->format($cfg['default_date_format']); + + $achievements_done = 0; + + if ($count_hours >= $cfg['stats_time_legend']) { + $achievements_done = $achievements_done + 4; + } elseif ($count_hours >= $cfg['stats_time_gold']) { + $achievements_done = $achievements_done + 3; + } elseif ($count_hours >= $cfg['stats_time_silver']) { + $achievements_done = $achievements_done + 2; + } else { + $achievements_done = $achievements_done + 1; + } + if ($_SESSION[$rspathhex.'tsconnections'] >= $cfg['stats_connects_legend']) { + $achievements_done = $achievements_done + 4; + } elseif ($_SESSION[$rspathhex.'tsconnections'] >= $cfg['stats_connects_gold']) { + $achievements_done = $achievements_done + 3; + } elseif ($_SESSION[$rspathhex.'tsconnections'] >= $cfg['stats_connects_silver']) { + $achievements_done = $achievements_done + 2; + } else { + $achievements_done = $achievements_done + 1; + } + } + ?>
- 1 || isset($_SESSION[$rspathhex.'connected']) && $_SESSION[$rspathhex.'connected'] == 0 || !isset($_SESSION[$rspathhex.'connected'])) { echo "
"; exit; } ?> + 1 || isset($_SESSION[$rspathhex.'connected']) && $_SESSION[$rspathhex.'connected'] == 0 || ! isset($_SESSION[$rspathhex.'connected'])) { + echo ''; + exit; + } ?>

- + @@ -98,262 +137,263 @@
-
-
+
- '; - } else { - echo ''; - } - ?> + '; + } else { + echo ''; + } + ?>

- +
-

+

-
- +
+
- +
-

- = $cfg['stats_time_legend']) { ?> +

+ = $cfg['stats_time_legend']) { ?>
- +
-
+
- +
- = $cfg['stats_time_gold']) { ?> + = $cfg['stats_time_gold']) { ?>
- +
-
+
-
- +
+
- = $cfg['stats_time_silver']) { ?> + = $cfg['stats_time_silver']) { ?>
- +
-
+
-
- +
+
- = $cfg['stats_time_bronze']) { ?> + = $cfg['stats_time_bronze']) { ?>
- +
-
+
-
- +
+
- +
- +
-
+
-
- +
+
- +
-

- = $cfg['stats_connects_legend']) { ?> +

+ = $cfg['stats_connects_legend']) { ?>
-
+
-
+
- +
- = $cfg['stats_connects_gold']) { ?> + = $cfg['stats_connects_gold']) { ?>
-
+
-
+
-
- +
+
- = $cfg['stats_connects_silver']) { ?> + = $cfg['stats_connects_silver']) { ?>
-
+
-
+
-
- +
+
- = $cfg['stats_connects_bronze']) { ?> + = $cfg['stats_connects_bronze']) { ?>
-
+
-
+
-
- +
+
- +
-
+
-
+
-
- +
+
- +
- + - \ No newline at end of file diff --git a/stats/nations.php b/stats/nations.php index 67c1bb3..9923fb4 100644 --- a/stats/nations.php +++ b/stats/nations.php @@ -1,33 +1,37 @@ -query("SELECT * FROM `$dbname`.`stats_nations` ORDER BY `count` DESC")->fetchAll(PDO::FETCH_UNIQUE|PDO::FETCH_ASSOC); - ?> +query("SELECT * FROM `$dbname`.`stats_nations` ORDER BY `count` DESC")->fetchAll(PDO::FETCH_UNIQUE | PDO::FETCH_ASSOC); + ?>
- + - \ No newline at end of file diff --git a/stats/platforms.php b/stats/platforms.php index e4d87a4..ed4e4db 100644 --- a/stats/platforms.php +++ b/stats/platforms.php @@ -1,16 +1,18 @@ -query("SELECT * FROM `$dbname`.`stats_platforms` ORDER BY `count` DESC")->fetchALL(PDO::FETCH_UNIQUE|PDO::FETCH_ASSOC); - ?> +query("SELECT * FROM `$dbname`.`stats_platforms` ORDER BY `count` DESC")->fetchALL(PDO::FETCH_UNIQUE | PDO::FETCH_ASSOC); + ?>
- +

- +

@@ -21,27 +23,27 @@ # - - - + + + - $value) { - $sum_of_all = $sum_of_all + $value['count']; - } - foreach ($sql_res as $platform => $value) { - $count++; - echo ' + $value) { + $sum_of_all = $sum_of_all + $value['count']; + } + foreach ($sql_res as $platform => $value) { + $count++; + echo ' ',$count,' ',$platform,' ',$value['count'],' ',number_format(round(($value['count'] * 100 / $sum_of_all), 1), 1),' % - '; - } - ?> + '; + } + ?>
@@ -50,9 +52,10 @@
- + - \ No newline at end of file diff --git a/stats/privacy_policy.php b/stats/privacy_policy.php index 6b25a0c..8e5b687 100644 --- a/stats/privacy_policy.php +++ b/stats/privacy_policy.php @@ -1,37 +1,40 @@ - + ?>
- +

- +

- +
- +
- +
-
+
- +
- + - \ No newline at end of file diff --git a/stats/top_all.php b/stats/top_all.php index 08e5018..b1655b0 100644 --- a/stats/top_all.php +++ b/stats/top_all.php @@ -1,82 +1,84 @@ - $value) { - $notinuuid .= "'".$uuid."',"; - } - $notinuuid = substr($notinuuid, 0, -1); - } else { - $notinuuid = "'0'"; - } - - $notingroup = ''; - $andnotgroup = ''; - if($cfg['rankup_excepted_group_id_list'] != NULL) { - foreach($cfg['rankup_excepted_group_id_list'] as $group => $value) { - $notingroup .= "'".$group."',"; - $andnotgroup .= " AND `u`.`cldgroup` NOT LIKE ('".$group.",%') AND `u`.`cldgroup` NOT LIKE ('%,".$group.",%') AND `u`.`cldgroup` NOT LIKE ('%,".$group."')"; - } - $notingroup = substr($notingroup, 0, -1); - } else { - $notingroup = '0'; - } - - if ($cfg['rankup_time_assess_mode'] == 1) { - $order = "(`count` - `idle`)"; - $texttime = $lang['sttw0013']; - } else { - $order = "`count`"; - $texttime = $lang['sttw0003']; - } - - $db_arr = $mysqlcon->query("SELECT `u`.`uuid`,`u`.`name`,`u`.`count`,`u`.`idle`,`u`.`cldgroup`,`u`.`online` FROM (SELECT `uuid`,`removed` FROM `$dbname`.`stats_user` WHERE `removed`!=1) `s` INNER JOIN `$dbname`.`user` `u` ON `u`.`uuid`=`s`.`uuid` WHERE `u`.`uuid` NOT IN ($notinuuid) AND `u`.`cldgroup` NOT IN ($notingroup) $andnotgroup ORDER BY $order DESC LIMIT 10")->fetchAll(PDO::FETCH_UNIQUE|PDO::FETCH_ASSOC); - - $count10 = 0; - $top10_sum = 0; - $top10_idle_sum = 0; - - foreach ($db_arr as $uuid => $client) { - if ($cfg['rankup_time_assess_mode'] == 1) { - $hours = $client['count'] - $client['idle']; - } else { - $hours = $client['count']; - } - $top10_sum = round(($client['count']/3600)) + $top10_sum; - $top10_idle_sum = round(($client['idle']/3600)) + $top10_idle_sum; - $client_data[$count10] = array( - 'name' => htmlspecialchars($client['name']), - 'title' => htmlspecialchars($client['name']), - 'count' => $hours, - 'online' => $client['online'] - ); - $count10++; - } - - for($count10 = $count10; $count10 <= 10; $count10++) { - $client_data[$count10] = array( - 'name' => "".$lang['unknown']."", - 'title' => $lang['unknown'], - 'count' => 0, - 'online' => 0 - ); - } - - $sum = $mysqlcon->query("SELECT SUM(`count`) AS `count`, SUM(`idle`) AS `idle`, COUNT(*) AS `user` FROM `$dbname`.`user` `u` WHERE `uuid` NOT IN ($notinuuid) AND `cldgroup` NOT IN ($notingroup) $andnotgroup")->fetch(); - $others_sum = round(($sum['count']/3600)) - $top10_sum; - $others_idle_sum = round(($sum['idle']/3600)) - $top10_idle_sum; - $sumentries = $sum['user'] - 10; - ?> + $value) { + $notinuuid .= "'".$uuid."',"; + } + $notinuuid = substr($notinuuid, 0, -1); + } else { + $notinuuid = "'0'"; + } + + $notingroup = ''; + $andnotgroup = ''; + if ($cfg['rankup_excepted_group_id_list'] != null) { + foreach ($cfg['rankup_excepted_group_id_list'] as $group => $value) { + $notingroup .= "'".$group."',"; + $andnotgroup .= " AND `u`.`cldgroup` NOT LIKE ('".$group.",%') AND `u`.`cldgroup` NOT LIKE ('%,".$group.",%') AND `u`.`cldgroup` NOT LIKE ('%,".$group."')"; + } + $notingroup = substr($notingroup, 0, -1); + } else { + $notingroup = '0'; + } + + if ($cfg['rankup_time_assess_mode'] == 1) { + $order = '(`count` - `idle`)'; + $texttime = $lang['sttw0013']; + } else { + $order = '`count`'; + $texttime = $lang['sttw0003']; + } + + $db_arr = $mysqlcon->query("SELECT `u`.`uuid`,`u`.`name`,`u`.`count`,`u`.`idle`,`u`.`cldgroup`,`u`.`online` FROM (SELECT `uuid`,`removed` FROM `$dbname`.`stats_user` WHERE `removed`!=1) `s` INNER JOIN `$dbname`.`user` `u` ON `u`.`uuid`=`s`.`uuid` WHERE `u`.`uuid` NOT IN ($notinuuid) AND `u`.`cldgroup` NOT IN ($notingroup) $andnotgroup ORDER BY $order DESC LIMIT 10")->fetchAll(PDO::FETCH_UNIQUE | PDO::FETCH_ASSOC); + + $count10 = 0; + $top10_sum = 0; + $top10_idle_sum = 0; + + foreach ($db_arr as $uuid => $client) { + if ($cfg['rankup_time_assess_mode'] == 1) { + $hours = $client['count'] - $client['idle']; + } else { + $hours = $client['count']; + } + $top10_sum = round(($client['count'] / 3600)) + $top10_sum; + $top10_idle_sum = round(($client['idle'] / 3600)) + $top10_idle_sum; + $client_data[$count10] = [ + 'name' => htmlspecialchars($client['name']), + 'title' => htmlspecialchars($client['name']), + 'count' => $hours, + 'online' => $client['online'], + ]; + $count10++; + } + + for ($count10 = $count10; $count10 <= 10; $count10++) { + $client_data[$count10] = [ + 'name' => ''.$lang['unknown'].'', + 'title' => $lang['unknown'], + 'count' => 0, + 'online' => 0, + ]; + } + + $sum = $mysqlcon->query("SELECT SUM(`count`) AS `count`, SUM(`idle`) AS `idle`, COUNT(*) AS `user` FROM `$dbname`.`user` `u` WHERE `uuid` NOT IN ($notinuuid) AND `cldgroup` NOT IN ($notingroup) $andnotgroup")->fetch(); + $others_sum = round(($sum['count'] / 3600)) - $top10_sum; + $others_idle_sum = round(($sum['idle'] / 3600)) - $top10_idle_sum; + $sumentries = $sum['user'] - 10; + ?>
- +

- - + +

@@ -91,8 +93,12 @@
 
-
',$client_data[0]['name']; ?>
-
+
',$client_data[0]['name']; ?>
+
@@ -110,8 +116,12 @@
 
-
',$client_data[1]['name']; ?>
-
+
',$client_data[1]['name']; ?>
+
@@ -127,8 +137,12 @@
 
-
',$client_data[2]['name']; ?>
-
+
',$client_data[2]['name']; ?>
+
@@ -144,8 +158,12 @@ #4th
-
',$client_data[3]['name']; ?>
-
+
',$client_data[3]['name']; ?>
+
@@ -159,8 +177,12 @@ #5th
-
',$client_data[4]['name']; ?>
-
+
',$client_data[4]['name']; ?>
+
@@ -174,8 +196,12 @@ #6th
-
',$client_data[5]['name']; ?>
-
+
',$client_data[5]['name']; ?>
+
@@ -194,8 +220,12 @@ #7th
-
',$client_data[6]['name']; ?>
-
+
',$client_data[6]['name']; ?>
+
@@ -212,8 +242,12 @@ #8th
-
',$client_data[7]['name']; ?>
-
+
',$client_data[7]['name']; ?>
+
@@ -230,8 +264,12 @@ #9th
-
',$client_data[8]['name']; ?>
-
+
',$client_data[8]['name']; ?>
+
@@ -248,8 +286,12 @@ #10th
-
',$client_data[9]['name']; ?>
-
+
',$client_data[9]['name']; ?>
+
@@ -258,66 +300,66 @@
-

-

#1 '.$lang['stix0024'].')' : ' (Status: '.$lang['stix0025'].')' ?>

+

+

#1 '.$lang['stix0024'].')' : ' (Status: '.$lang['stix0025'].')' ?>

-
+
-

#2 '.$lang['stix0024'].')' : ' (Status: '.$lang['stix0025'].')' ?>

+

#2 '.$lang['stix0024'].')' : ' (Status: '.$lang['stix0025'].')' ?>

-
+
-

#3 '.$lang['stix0024'].')' : ' (Status: '.$lang['stix0025'].')' ?>

+

#3 '.$lang['stix0024'].')' : ' (Status: '.$lang['stix0025'].')' ?>

-
+
-

#4 '.$lang['stix0024'].')' : ' (Status: '.$lang['stix0025'].')' ?>

+

#4 '.$lang['stix0024'].')' : ' (Status: '.$lang['stix0025'].')' ?>

-
+
-

#5 '.$lang['stix0024'].')' : ' (Status: '.$lang['stix0025'].')' ?>

+

#5 '.$lang['stix0024'].')' : ' (Status: '.$lang['stix0025'].')' ?>

-
+
-

#6 '.$lang['stix0024'].')' : ' (Status: '.$lang['stix0025'].')' ?>

+

#6 '.$lang['stix0024'].')' : ' (Status: '.$lang['stix0025'].')' ?>

-
+
-

#7 '.$lang['stix0024'].')' : ' (Status: '.$lang['stix0025'].')' ?>

+

#7 '.$lang['stix0024'].')' : ' (Status: '.$lang['stix0025'].')' ?>

-
+
-

#8 '.$lang['stix0024'].')' : ' (Status: '.$lang['stix0025'].')' ?>

+

#8 '.$lang['stix0024'].')' : ' (Status: '.$lang['stix0025'].')' ?>

-
+
-

#9 '.$lang['stix0024'].')' : ' (Status: '.$lang['stix0025'].')' ?>

+

#9 '.$lang['stix0024'].')' : ' (Status: '.$lang['stix0025'].')' ?>

-
+
-

#10 '.$lang['stix0024'].')' : ' (Status: '.$lang['stix0025'].')' ?>

+

#10 '.$lang['stix0024'].')' : ' (Status: '.$lang['stix0025'].')' ?>

-
+
-

+

-

+

@@ -328,7 +370,7 @@
-

+

@@ -339,7 +381,7 @@
-

+

@@ -351,7 +393,7 @@
- + @@ -369,30 +411,31 @@ Morris.Donut({ element: 'top10vs_donut1', data: [ - {label: , value: }, - {label: , value: }, + {label: , value: }, + {label: , value: }, ], colors: [donut_time_color_1, donut_time_color_2] }); Morris.Donut({ element: 'top10vs_donut2', data: [ - {label: , value: }, - {label: , value: }, + {label: , value: }, + {label: , value: }, ], colors: [donut_version_color_1, donut_version_color_2] }); Morris.Donut({ element: 'top10vs_donut3', data: [ - {label: , value: }, - {label: , value: }, + {label: , value: }, + {label: , value: }, ], colors: [donut_nation_color_1, donut_nation_color_2] }); - \ No newline at end of file diff --git a/stats/top_month.php b/stats/top_month.php index 211b4f2..4231f04 100644 --- a/stats/top_month.php +++ b/stats/top_month.php @@ -1,91 +1,95 @@ - $value) { - $notinuuid .= "'".$uuid."',"; - } - $notinuuid = substr($notinuuid, 0, -1); - } else { - $notinuuid = "'0'"; - } - - $notingroup = ''; - $andnotgroup = ''; - if($cfg['rankup_excepted_group_id_list'] != NULL) { - foreach($cfg['rankup_excepted_group_id_list'] as $group => $value) { - $notingroup .= "'".$group."',"; - $andnotgroup .= " AND `u`.`cldgroup` NOT LIKE ('".$group.",%') AND `u`.`cldgroup` NOT LIKE ('%,".$group.",%') AND `u`.`cldgroup` NOT LIKE ('%,".$group."')"; - } - $notingroup = substr($notingroup, 0, -1); - } else { - $notingroup = '0'; - } - - if ($cfg['rankup_time_assess_mode'] == 1) { - $order = "(`s`.`count_month` - `s`.`idle_month`)"; - $texttime = $lang['sttw0013']; - } else { - $order = "`s`.`count_month`"; - $texttime = $lang['sttw0003']; - } - - $timeago = time() - 2592000; - $db_arr = $mysqlcon->query("SELECT `s`.`uuid`,`s`.`count_month`,`s`.`idle_month`,`u`.`name`,`u`.`online`,`u`.`cldgroup` FROM `$dbname`.`stats_user` `s`, `$dbname`.`user` `u` WHERE `u`.`uuid` = `s`.`uuid` AND `s`.`removed`!=1 AND `u`.`lastseen`>{$timeago} AND `u`.`uuid` NOT IN ({$notinuuid}) AND `u`.`cldgroup` NOT IN ({$notingroup}) {$andnotgroup} AND `s`.`idle_month`<`s`.`count_month` AND `s`.`count_month`>=0 AND `s`.`idle_month`>=0 ORDER BY $order DESC LIMIT 10")->fetchAll(PDO::FETCH_UNIQUE|PDO::FETCH_ASSOC); - - $count_ids = $mysqlcon->query("SELECT COUNT(DISTINCT(`id`)) AS `count` from `$dbname`.`user_snapshot`")->fetch(); - - $count10 = 0; - $top10_sum = 0; - $top10_idle_sum = 0; - - foreach ($db_arr as $uuid => $client) { - if ($cfg['rankup_time_assess_mode'] == 1) { - $hours = $client['count_month'] - $client['idle_month']; - } else { - $hours = $client['count_month']; - } - $top10_sum += $client['count_month']; - $top10_idle_sum += $client['idle_month']; - $client_data[$count10] = array( - 'name' => htmlspecialchars($client['name']), - 'title' => htmlspecialchars($client['name']), - 'count' => $hours, - 'online' => $client['online'] - ); - $count10++; - } - - for($count10 = $count10; $count10 <= 10; $count10++) { - $client_data[$count10] = array( - 'name' => "".$lang['unknown']."", - 'title' => $lang['unknown'], - 'count' => 0, - 'online' => 0 - ); - } - - $sum = $mysqlcon->query("SELECT SUM(`s`.`count_month`) AS `count`, SUM(`s`.`idle_month`) AS `idle`, COUNT(*) AS `user` FROM `$dbname`.`stats_user` `s`, `$dbname`.`user` `u` WHERE `u`.`uuid` = `s`.`uuid` AND `s`.`removed`!=1 AND `u`.`lastseen`>{$timeago} AND `u`.`uuid` NOT IN ({$notinuuid}) AND `u`.`cldgroup` NOT IN ({$notingroup}) {$andnotgroup} AND `s`.`idle_month`<`s`.`count_month` AND `s`.`count_month`>=0 AND `s`.`idle_month`>=0;")->fetch(); - $top10_sum = round(($top10_sum/3600)); - $top10_idle_sum = round(($top10_idle_sum/3600)); - $others_sum = round(($sum['count']/3600)) - $top10_sum; - $others_idle_sum = round(($sum['idle']/3600)) - $top10_idle_sum; - $sumentries = $sum['user'] - 10; - ?> + $value) { + $notinuuid .= "'".$uuid."',"; + } + $notinuuid = substr($notinuuid, 0, -1); + } else { + $notinuuid = "'0'"; + } + + $notingroup = ''; + $andnotgroup = ''; + if ($cfg['rankup_excepted_group_id_list'] != null) { + foreach ($cfg['rankup_excepted_group_id_list'] as $group => $value) { + $notingroup .= "'".$group."',"; + $andnotgroup .= " AND `u`.`cldgroup` NOT LIKE ('".$group.",%') AND `u`.`cldgroup` NOT LIKE ('%,".$group.",%') AND `u`.`cldgroup` NOT LIKE ('%,".$group."')"; + } + $notingroup = substr($notingroup, 0, -1); + } else { + $notingroup = '0'; + } + + if ($cfg['rankup_time_assess_mode'] == 1) { + $order = '(`s`.`count_month` - `s`.`idle_month`)'; + $texttime = $lang['sttw0013']; + } else { + $order = '`s`.`count_month`'; + $texttime = $lang['sttw0003']; + } + + $timeago = time() - 2592000; + $db_arr = $mysqlcon->query("SELECT `s`.`uuid`,`s`.`count_month`,`s`.`idle_month`,`u`.`name`,`u`.`online`,`u`.`cldgroup` FROM `$dbname`.`stats_user` `s`, `$dbname`.`user` `u` WHERE `u`.`uuid` = `s`.`uuid` AND `s`.`removed`!=1 AND `u`.`lastseen`>{$timeago} AND `u`.`uuid` NOT IN ({$notinuuid}) AND `u`.`cldgroup` NOT IN ({$notingroup}) {$andnotgroup} AND `s`.`idle_month`<`s`.`count_month` AND `s`.`count_month`>=0 AND `s`.`idle_month`>=0 ORDER BY $order DESC LIMIT 10")->fetchAll(PDO::FETCH_UNIQUE | PDO::FETCH_ASSOC); + + $count_ids = $mysqlcon->query("SELECT COUNT(DISTINCT(`id`)) AS `count` from `$dbname`.`user_snapshot`")->fetch(); + + $count10 = 0; + $top10_sum = 0; + $top10_idle_sum = 0; + + foreach ($db_arr as $uuid => $client) { + if ($cfg['rankup_time_assess_mode'] == 1) { + $hours = $client['count_month'] - $client['idle_month']; + } else { + $hours = $client['count_month']; + } + $top10_sum += $client['count_month']; + $top10_idle_sum += $client['idle_month']; + $client_data[$count10] = [ + 'name' => htmlspecialchars($client['name']), + 'title' => htmlspecialchars($client['name']), + 'count' => $hours, + 'online' => $client['online'], + ]; + $count10++; + } + + for ($count10 = $count10; $count10 <= 10; $count10++) { + $client_data[$count10] = [ + 'name' => ''.$lang['unknown'].'', + 'title' => $lang['unknown'], + 'count' => 0, + 'online' => 0, + ]; + } + + $sum = $mysqlcon->query("SELECT SUM(`s`.`count_month`) AS `count`, SUM(`s`.`idle_month`) AS `idle`, COUNT(*) AS `user` FROM `$dbname`.`stats_user` `s`, `$dbname`.`user` `u` WHERE `u`.`uuid` = `s`.`uuid` AND `s`.`removed`!=1 AND `u`.`lastseen`>{$timeago} AND `u`.`uuid` NOT IN ({$notinuuid}) AND `u`.`cldgroup` NOT IN ({$notingroup}) {$andnotgroup} AND `s`.`idle_month`<`s`.`count_month` AND `s`.`count_month`>=0 AND `s`.`idle_month`>=0;")->fetch(); + $top10_sum = round(($top10_sum / 3600)); + $top10_idle_sum = round(($top10_idle_sum / 3600)); + $others_sum = round(($sum['count'] / 3600)) - $top10_sum; + $others_idle_sum = round(($sum['idle'] / 3600)) - $top10_idle_sum; + $sumentries = $sum['user'] - 10; + ?>
- +

- - + +

- +
@@ -97,8 +101,12 @@
 
-
',$client_data[0]['name']; ?>
-
+
',$client_data[0]['name']; ?>
+
@@ -116,8 +124,12 @@
 
-
',$client_data[1]['name']; ?>
-
+
',$client_data[1]['name']; ?>
+
@@ -133,8 +145,12 @@
 
-
',$client_data[2]['name']; ?>
-
+
',$client_data[2]['name']; ?>
+
@@ -150,8 +166,12 @@ #4th
-
',$client_data[3]['name']; ?>
-
+
',$client_data[3]['name']; ?>
+
@@ -165,8 +185,12 @@ #5th
-
',$client_data[4]['name']; ?>
-
+
',$client_data[4]['name']; ?>
+
@@ -180,8 +204,12 @@ #6th
-
',$client_data[5]['name']; ?>
-
+
',$client_data[5]['name']; ?>
+
@@ -200,8 +228,12 @@ #7th
-
',$client_data[6]['name']; ?>
-
+
',$client_data[6]['name']; ?>
+
@@ -218,8 +250,12 @@ #8th
-
',$client_data[7]['name']; ?>
-
+
',$client_data[7]['name']; ?>
+
@@ -236,8 +272,12 @@ #9th
-
',$client_data[8]['name']; ?>
-
+
',$client_data[8]['name']; ?>
+
@@ -254,8 +294,12 @@ #10th
-
',$client_data[9]['name']; ?>
-
+
',$client_data[9]['name']; ?>
+
@@ -264,66 +308,66 @@
-

-

#1 '.$lang['stix0024'].')' : ' (Status: '.$lang['stix0025'].')' ?>

+

+

#1 '.$lang['stix0024'].')' : ' (Status: '.$lang['stix0025'].')' ?>

-
+
-

#2 '.$lang['stix0024'].')' : ' (Status: '.$lang['stix0025'].')' ?>

+

#2 '.$lang['stix0024'].')' : ' (Status: '.$lang['stix0025'].')' ?>

-
+
-

#3 '.$lang['stix0024'].')' : ' (Status: '.$lang['stix0025'].')' ?>

+

#3 '.$lang['stix0024'].')' : ' (Status: '.$lang['stix0025'].')' ?>

-
+
-

#4 '.$lang['stix0024'].')' : ' (Status: '.$lang['stix0025'].')' ?>

+

#4 '.$lang['stix0024'].')' : ' (Status: '.$lang['stix0025'].')' ?>

-
+
-

#5 '.$lang['stix0024'].')' : ' (Status: '.$lang['stix0025'].')' ?>

+

#5 '.$lang['stix0024'].')' : ' (Status: '.$lang['stix0025'].')' ?>

-
+
-

#6 '.$lang['stix0024'].')' : ' (Status: '.$lang['stix0025'].')' ?>

+

#6 '.$lang['stix0024'].')' : ' (Status: '.$lang['stix0025'].')' ?>

-
+
-

#7 '.$lang['stix0024'].')' : ' (Status: '.$lang['stix0025'].')' ?>

+

#7 '.$lang['stix0024'].')' : ' (Status: '.$lang['stix0025'].')' ?>

-
+
-

#8 '.$lang['stix0024'].')' : ' (Status: '.$lang['stix0025'].')' ?>

+

#8 '.$lang['stix0024'].')' : ' (Status: '.$lang['stix0025'].')' ?>

-
+
-

#9 '.$lang['stix0024'].')' : ' (Status: '.$lang['stix0025'].')' ?>

+

#9 '.$lang['stix0024'].')' : ' (Status: '.$lang['stix0025'].')' ?>

-
+
-

#10 '.$lang['stix0024'].')' : ' (Status: '.$lang['stix0025'].')' ?>

+

#10 '.$lang['stix0024'].')' : ' (Status: '.$lang['stix0025'].')' ?>

-
+
-

+

-

+

@@ -334,7 +378,7 @@
-

+

@@ -345,7 +389,7 @@
-

+

@@ -354,11 +398,11 @@
- +
- + @@ -376,30 +420,31 @@ Morris.Donut({ element: 'top10vs_donut1', data: [ - {label: , value: }, - {label: , value: }, + {label: , value: }, + {label: , value: }, ], colors: [donut_time_color_1, donut_time_color_2] }); Morris.Donut({ element: 'top10vs_donut2', data: [ - {label: , value: }, - {label: , value: }, + {label: , value: }, + {label: , value: }, ], colors: [donut_version_color_1, donut_version_color_2] }); Morris.Donut({ element: 'top10vs_donut3', data: [ - {label: , value: }, - {label: , value: }, + {label: , value: }, + {label: , value: }, ], colors: [donut_nation_color_1, donut_nation_color_2] }); - \ No newline at end of file diff --git a/stats/top_week.php b/stats/top_week.php index ca7244a..8eea986 100644 --- a/stats/top_week.php +++ b/stats/top_week.php @@ -1,91 +1,95 @@ - $value) { - $notinuuid .= "'".$uuid."',"; - } - $notinuuid = substr($notinuuid, 0, -1); - } else { - $notinuuid = "'0'"; - } - - $notingroup = ''; - $andnotgroup = ''; - if($cfg['rankup_excepted_group_id_list'] != NULL) { - foreach($cfg['rankup_excepted_group_id_list'] as $group => $value) { - $notingroup .= "'".$group."',"; - $andnotgroup .= " AND `u`.`cldgroup` NOT LIKE ('".$group.",%') AND `u`.`cldgroup` NOT LIKE ('%,".$group.",%') AND `u`.`cldgroup` NOT LIKE ('%,".$group."')"; - } - $notingroup = substr($notingroup, 0, -1); - } else { - $notingroup = "'0'"; - } - - if ($cfg['rankup_time_assess_mode'] == 1) { - $order = "(`s`.`count_week` - `s`.`idle_week`)"; - $texttime = $lang['sttw0013']; - } else { - $order = "`s`.`count_week`"; - $texttime = $lang['sttw0003']; - } - - $timeago = time() - 604800; - $db_arr = $mysqlcon->query("SELECT `s`.`uuid`,`s`.`count_week`,`s`.`idle_week`,`u`.`name`,`u`.`online`,`u`.`cldgroup` FROM `$dbname`.`stats_user` `s`, `$dbname`.`user` `u` WHERE `u`.`uuid` = `s`.`uuid` AND `s`.`removed`!=1 AND `u`.`lastseen`>{$timeago} AND `u`.`uuid` NOT IN ({$notinuuid}) AND `u`.`cldgroup` NOT IN ({$notingroup}) {$andnotgroup} AND `s`.`idle_week`<`s`.`count_week` AND `s`.`count_week`>=0 AND `s`.`idle_week`>=0 ORDER BY $order DESC LIMIT 10")->fetchAll(PDO::FETCH_UNIQUE|PDO::FETCH_ASSOC); - - $count_ids = $mysqlcon->query("SELECT COUNT(DISTINCT(`id`)) AS `count` from `$dbname`.`user_snapshot`")->fetch(); - - $count10 = 0; - $top10_sum = 0; - $top10_idle_sum = 0; - - foreach ($db_arr as $uuid => $client) { - if ($cfg['rankup_time_assess_mode'] == 1) { - $hours = $client['count_week'] - $client['idle_week']; - } else { - $hours = $client['count_week']; - } - $top10_sum += $client['count_week']; - $top10_idle_sum += $client['idle_week']; - $client_data[$count10] = array( - 'name' => htmlspecialchars($client['name']), - 'title' => htmlspecialchars($client['name']), - 'count' => $hours, - 'online' => $client['online'] - ); - $count10++; - } - - for($count10 = $count10; $count10 < 10; $count10++) { - $client_data[$count10] = array( - 'name' => "".$lang['unknown']."", - 'title' => $lang['unknown'], - 'count' => 0, - 'online' => 0 - ); - } - - $sum = $mysqlcon->query("SELECT SUM(`s`.`count_week`) AS `count`, SUM(`s`.`idle_week`) AS `idle`, COUNT(*) AS `user` FROM `$dbname`.`stats_user` `s`, `$dbname`.`user` `u` WHERE `u`.`uuid` = `s`.`uuid` AND `s`.`removed`!=1 AND `u`.`lastseen`>{$timeago} AND `u`.`uuid` NOT IN ({$notinuuid}) AND `u`.`cldgroup` NOT IN ({$notingroup}) {$andnotgroup} AND `s`.`idle_week`<`s`.`count_week` AND `s`.`count_week`>=0 AND `s`.`idle_week`>=0;")->fetch(); - $top10_sum = round(($top10_sum/3600)); - $top10_idle_sum = round(($top10_idle_sum/3600)); - $others_sum = round(($sum['count']/3600)) - $top10_sum; - $others_idle_sum = round(($sum['idle']/3600)) - $top10_idle_sum; - $sumentries = $sum['user'] - 10; - ?> + $value) { + $notinuuid .= "'".$uuid."',"; + } + $notinuuid = substr($notinuuid, 0, -1); + } else { + $notinuuid = "'0'"; + } + + $notingroup = ''; + $andnotgroup = ''; + if ($cfg['rankup_excepted_group_id_list'] != null) { + foreach ($cfg['rankup_excepted_group_id_list'] as $group => $value) { + $notingroup .= "'".$group."',"; + $andnotgroup .= " AND `u`.`cldgroup` NOT LIKE ('".$group.",%') AND `u`.`cldgroup` NOT LIKE ('%,".$group.",%') AND `u`.`cldgroup` NOT LIKE ('%,".$group."')"; + } + $notingroup = substr($notingroup, 0, -1); + } else { + $notingroup = "'0'"; + } + + if ($cfg['rankup_time_assess_mode'] == 1) { + $order = '(`s`.`count_week` - `s`.`idle_week`)'; + $texttime = $lang['sttw0013']; + } else { + $order = '`s`.`count_week`'; + $texttime = $lang['sttw0003']; + } + + $timeago = time() - 604800; + $db_arr = $mysqlcon->query("SELECT `s`.`uuid`,`s`.`count_week`,`s`.`idle_week`,`u`.`name`,`u`.`online`,`u`.`cldgroup` FROM `$dbname`.`stats_user` `s`, `$dbname`.`user` `u` WHERE `u`.`uuid` = `s`.`uuid` AND `s`.`removed`!=1 AND `u`.`lastseen`>{$timeago} AND `u`.`uuid` NOT IN ({$notinuuid}) AND `u`.`cldgroup` NOT IN ({$notingroup}) {$andnotgroup} AND `s`.`idle_week`<`s`.`count_week` AND `s`.`count_week`>=0 AND `s`.`idle_week`>=0 ORDER BY $order DESC LIMIT 10")->fetchAll(PDO::FETCH_UNIQUE | PDO::FETCH_ASSOC); + + $count_ids = $mysqlcon->query("SELECT COUNT(DISTINCT(`id`)) AS `count` from `$dbname`.`user_snapshot`")->fetch(); + + $count10 = 0; + $top10_sum = 0; + $top10_idle_sum = 0; + + foreach ($db_arr as $uuid => $client) { + if ($cfg['rankup_time_assess_mode'] == 1) { + $hours = $client['count_week'] - $client['idle_week']; + } else { + $hours = $client['count_week']; + } + $top10_sum += $client['count_week']; + $top10_idle_sum += $client['idle_week']; + $client_data[$count10] = [ + 'name' => htmlspecialchars($client['name']), + 'title' => htmlspecialchars($client['name']), + 'count' => $hours, + 'online' => $client['online'], + ]; + $count10++; + } + + for ($count10 = $count10; $count10 < 10; $count10++) { + $client_data[$count10] = [ + 'name' => ''.$lang['unknown'].'', + 'title' => $lang['unknown'], + 'count' => 0, + 'online' => 0, + ]; + } + + $sum = $mysqlcon->query("SELECT SUM(`s`.`count_week`) AS `count`, SUM(`s`.`idle_week`) AS `idle`, COUNT(*) AS `user` FROM `$dbname`.`stats_user` `s`, `$dbname`.`user` `u` WHERE `u`.`uuid` = `s`.`uuid` AND `s`.`removed`!=1 AND `u`.`lastseen`>{$timeago} AND `u`.`uuid` NOT IN ({$notinuuid}) AND `u`.`cldgroup` NOT IN ({$notingroup}) {$andnotgroup} AND `s`.`idle_week`<`s`.`count_week` AND `s`.`count_week`>=0 AND `s`.`idle_week`>=0;")->fetch(); + $top10_sum = round(($top10_sum / 3600)); + $top10_idle_sum = round(($top10_idle_sum / 3600)); + $others_sum = round(($sum['count'] / 3600)) - $top10_sum; + $others_idle_sum = round(($sum['idle'] / 3600)) - $top10_idle_sum; + $sumentries = $sum['user'] - 10; + ?>
- +

- - + +

- +
@@ -97,8 +101,12 @@
 
-
',$client_data[0]['name']; ?>
-
+
',$client_data[0]['name']; ?>
+
@@ -116,8 +124,12 @@
 
-
',$client_data[1]['name']; ?>
-
+
',$client_data[1]['name']; ?>
+
@@ -133,8 +145,12 @@
 
-
',$client_data[2]['name']; ?>
-
+
',$client_data[2]['name']; ?>
+
@@ -150,8 +166,12 @@ #4th
-
',$client_data[3]['name']; ?>
-
+
',$client_data[3]['name']; ?>
+
@@ -165,8 +185,12 @@ #5th
-
',$client_data[4]['name']; ?>
-
+
',$client_data[4]['name']; ?>
+
@@ -180,8 +204,12 @@ #6th
-
',$client_data[5]['name']; ?>
-
+
',$client_data[5]['name']; ?>
+
@@ -200,8 +228,12 @@ #7th
-
',$client_data[6]['name']; ?>
-
+
',$client_data[6]['name']; ?>
+
@@ -218,8 +250,12 @@ #8th
-
',$client_data[7]['name']; ?>
-
+
',$client_data[7]['name']; ?>
+
@@ -236,8 +272,12 @@ #9th
-
',$client_data[8]['name']; ?>
-
+
',$client_data[8]['name']; ?>
+
@@ -254,8 +294,12 @@ #10th
-
',$client_data[9]['name']; ?>
-
+
',$client_data[9]['name']; ?>
+
@@ -264,66 +308,66 @@
-

-

#1 '.$lang['stix0024'].')' : ' (Status: '.$lang['stix0025'].')' ?>

+

+

#1 '.$lang['stix0024'].')' : ' (Status: '.$lang['stix0025'].')' ?>

-
+
-

#2 '.$lang['stix0024'].')' : ' (Status: '.$lang['stix0025'].')' ?>

+

#2 '.$lang['stix0024'].')' : ' (Status: '.$lang['stix0025'].')' ?>

-
+
-

#3 '.$lang['stix0024'].')' : ' (Status: '.$lang['stix0025'].')' ?>

+

#3 '.$lang['stix0024'].')' : ' (Status: '.$lang['stix0025'].')' ?>

-
+
-

#4 '.$lang['stix0024'].')' : ' (Status: '.$lang['stix0025'].')' ?>

+

#4 '.$lang['stix0024'].')' : ' (Status: '.$lang['stix0025'].')' ?>

-
+
-

#5 '.$lang['stix0024'].')' : ' (Status: '.$lang['stix0025'].')' ?>

+

#5 '.$lang['stix0024'].')' : ' (Status: '.$lang['stix0025'].')' ?>

-
+
-

#6 '.$lang['stix0024'].')' : ' (Status: '.$lang['stix0025'].')' ?>

+

#6 '.$lang['stix0024'].')' : ' (Status: '.$lang['stix0025'].')' ?>

-
+
-

#7 '.$lang['stix0024'].')' : ' (Status: '.$lang['stix0025'].')' ?>

+

#7 '.$lang['stix0024'].')' : ' (Status: '.$lang['stix0025'].')' ?>

-
+
-

#8 '.$lang['stix0024'].')' : ' (Status: '.$lang['stix0025'].')' ?>

+

#8 '.$lang['stix0024'].')' : ' (Status: '.$lang['stix0025'].')' ?>

-
+
-

#9 '.$lang['stix0024'].')' : ' (Status: '.$lang['stix0025'].')' ?>

+

#9 '.$lang['stix0024'].')' : ' (Status: '.$lang['stix0025'].')' ?>

-
+
-

#10 '.$lang['stix0024'].')' : ' (Status: '.$lang['stix0025'].')' ?>

+

#10 '.$lang['stix0024'].')' : ' (Status: '.$lang['stix0025'].')' ?>

-
+
-

+

-

+

@@ -334,7 +378,7 @@
-

+

@@ -345,7 +389,7 @@
-

+

@@ -354,11 +398,11 @@
- +
- + @@ -376,30 +420,31 @@ Morris.Donut({ element: 'top10vs_donut1', data: [ - {label: , value: }, - {label: , value: }, + {label: , value: }, + {label: , value: }, ], colors: [donut_time_color_1, donut_time_color_2] }); Morris.Donut({ element: 'top10vs_donut2', data: [ - {label: , value: }, - {label: , value: }, + {label: , value: }, + {label: , value: }, ], colors: [donut_version_color_1, donut_version_color_2] }); Morris.Donut({ element: 'top10vs_donut3', data: [ - {label: , value: }, - {label: , value: }, + {label: , value: }, + {label: , value: }, ], colors: [donut_nation_color_1, donut_nation_color_2] }); - \ No newline at end of file diff --git a/stats/update_graph.php b/stats/update_graph.php index 4d9fec2..2291b03 100644 --- a/stats/update_graph.php +++ b/stats/update_graph.php @@ -1,53 +1,53 @@ -query("SET @a:=0"); - -switch($_GET['serverusagechart']) { - case 'week': - $server_usage = $mysqlcon->query("SELECT `u1`.`timestamp`,`u1`.`clients`,`u1`.`channel` FROM (SELECT @a:=@a+1,mod(@a,2) AS `row_count`,`timestamp`,`clients`,`channel` FROM `$dbname`.`server_usage`) AS `u2`, `$dbname`.`server_usage` AS `u1` WHERE `u1`.`timestamp`=`u2`.`timestamp` AND `u2`.`row_count`='1' ORDER BY `u2`.`timestamp` DESC LIMIT 336")->fetchAll(PDO::FETCH_ASSOC); - //MySQL 8 above - //SELECT `timestamp`, `clients`, `channel` FROM (SELECT ROW_NUMBER() OVER (ORDER BY `timestamp`) AS `id`, `timestamp`, `clients`, `channel` FROM `$dbname`.`server_usage` WHERE `timestamp` > (UNIX_TIMESTAMP() - 604800) ORDER BY `timestamp` DESC) AS `u2` WHERE (`u2`.`id` % 2) = 1; - break; - case 'month': - $server_usage = $mysqlcon->query("SELECT `u1`.`timestamp`,`u1`.`clients`,`u1`.`channel` FROM (SELECT @a:=@a+1,mod(@a,4) AS `row_count`,`timestamp`,`clients`,`channel` FROM `$dbname`.`server_usage`) AS `u2`, `$dbname`.`server_usage` AS `u1` WHERE `u1`.`timestamp`=`u2`.`timestamp` AND `u2`.`row_count`='1' ORDER BY `u2`.`timestamp` DESC LIMIT 720")->fetchAll(PDO::FETCH_ASSOC); - //MySQL 8 above - //SELECT `timestamp`, `clients`, `channel` FROM (SELECT ROW_NUMBER() OVER (ORDER BY `timestamp`) AS `id`, `timestamp`, `clients`, `channel` FROM `$dbname`.`server_usage` WHERE `timestamp` > (UNIX_TIMESTAMP() - 2592000) ORDER BY `timestamp` DESC) AS `u2` WHERE (`u2`.`id` % 4) = 1; - break; - case '3month': - $server_usage = $mysqlcon->query("SELECT `u1`.`timestamp`,`u1`.`clients`,`u1`.`channel` FROM (SELECT @a:=@a+1,mod(@a,16) AS `row_count`,`timestamp`,`clients`,`channel` FROM `$dbname`.`server_usage`) AS `u2`, `$dbname`.`server_usage` AS `u1` WHERE `u1`.`timestamp`=`u2`.`timestamp` AND `u2`.`row_count`='1' ORDER BY `u2`.`timestamp` DESC LIMIT 548")->fetchAll(PDO::FETCH_ASSOC); - //MySQL 8 above - //SELECT `timestamp`, `clients`, `channel` FROM (SELECT ROW_NUMBER() OVER (ORDER BY `timestamp`) AS `id`, `timestamp`, `clients`, `channel` FROM `$dbname`.`server_usage` WHERE `timestamp` > (UNIX_TIMESTAMP() - 7776000) ORDER BY `timestamp` DESC LIMIT 8640) AS `u2` WHERE (`u2`.`id` % 16) = 1; - break; - default: - $server_usage = $mysqlcon->query("SELECT `timestamp`,`clients`,`channel` FROM `$dbname`.`server_usage` ORDER BY `timestamp` DESC LIMIT 96")->fetchAll(PDO::FETCH_ASSOC); -} - -$chart_data = array(); - -foreach($server_usage as $chart_value) { - $chart_data[] = array( - "y" => date('Y-m-d H:i',$chart_value['timestamp']), - "a" => $chart_value['clients'], - "b" => $chart_value['channel'] - ); -} - -echo json_encode($chart_data); -?> \ No newline at end of file +query('SET @a:=0'); + +switch($_GET['serverusagechart']) { + case 'week': + $server_usage = $mysqlcon->query("SELECT `u1`.`timestamp`,`u1`.`clients`,`u1`.`channel` FROM (SELECT @a:=@a+1,mod(@a,2) AS `row_count`,`timestamp`,`clients`,`channel` FROM `$dbname`.`server_usage`) AS `u2`, `$dbname`.`server_usage` AS `u1` WHERE `u1`.`timestamp`=`u2`.`timestamp` AND `u2`.`row_count`='1' ORDER BY `u2`.`timestamp` DESC LIMIT 336")->fetchAll(PDO::FETCH_ASSOC); + //MySQL 8 above + //SELECT `timestamp`, `clients`, `channel` FROM (SELECT ROW_NUMBER() OVER (ORDER BY `timestamp`) AS `id`, `timestamp`, `clients`, `channel` FROM `$dbname`.`server_usage` WHERE `timestamp` > (UNIX_TIMESTAMP() - 604800) ORDER BY `timestamp` DESC) AS `u2` WHERE (`u2`.`id` % 2) = 1; + break; + case 'month': + $server_usage = $mysqlcon->query("SELECT `u1`.`timestamp`,`u1`.`clients`,`u1`.`channel` FROM (SELECT @a:=@a+1,mod(@a,4) AS `row_count`,`timestamp`,`clients`,`channel` FROM `$dbname`.`server_usage`) AS `u2`, `$dbname`.`server_usage` AS `u1` WHERE `u1`.`timestamp`=`u2`.`timestamp` AND `u2`.`row_count`='1' ORDER BY `u2`.`timestamp` DESC LIMIT 720")->fetchAll(PDO::FETCH_ASSOC); + //MySQL 8 above + //SELECT `timestamp`, `clients`, `channel` FROM (SELECT ROW_NUMBER() OVER (ORDER BY `timestamp`) AS `id`, `timestamp`, `clients`, `channel` FROM `$dbname`.`server_usage` WHERE `timestamp` > (UNIX_TIMESTAMP() - 2592000) ORDER BY `timestamp` DESC) AS `u2` WHERE (`u2`.`id` % 4) = 1; + break; + case '3month': + $server_usage = $mysqlcon->query("SELECT `u1`.`timestamp`,`u1`.`clients`,`u1`.`channel` FROM (SELECT @a:=@a+1,mod(@a,16) AS `row_count`,`timestamp`,`clients`,`channel` FROM `$dbname`.`server_usage`) AS `u2`, `$dbname`.`server_usage` AS `u1` WHERE `u1`.`timestamp`=`u2`.`timestamp` AND `u2`.`row_count`='1' ORDER BY `u2`.`timestamp` DESC LIMIT 548")->fetchAll(PDO::FETCH_ASSOC); + //MySQL 8 above + //SELECT `timestamp`, `clients`, `channel` FROM (SELECT ROW_NUMBER() OVER (ORDER BY `timestamp`) AS `id`, `timestamp`, `clients`, `channel` FROM `$dbname`.`server_usage` WHERE `timestamp` > (UNIX_TIMESTAMP() - 7776000) ORDER BY `timestamp` DESC LIMIT 8640) AS `u2` WHERE (`u2`.`id` % 16) = 1; + break; + default: + $server_usage = $mysqlcon->query("SELECT `timestamp`,`clients`,`channel` FROM `$dbname`.`server_usage` ORDER BY `timestamp` DESC LIMIT 96")->fetchAll(PDO::FETCH_ASSOC); +} + +$chart_data = []; + +foreach ($server_usage as $chart_value) { + $chart_data[] = [ + 'y' => date('Y-m-d H:i', $chart_value['timestamp']), + 'a' => $chart_value['clients'], + 'b' => $chart_value['channel'], + ]; +} + +echo json_encode($chart_data); diff --git a/stats/verify.php b/stats/verify.php index ed78af9..df6f1ff 100644 --- a/stats/verify.php +++ b/stats/verify.php @@ -1,192 +1,209 @@ -prepare("SELECT `a`.`firstcon` AS `firstcon`, `b`.`total_connections` AS `total_connections` FROM `$dbname`.`user` `a` INNER JOIN `$dbname`.`stats_user` `b` ON `a`.`uuid`=`b`.`uuid` WHERE `b`.`uuid` = :uuid"); - $dbdata->bindValue(':uuid', $_SESSION[$rspathhex.'tsuid'], PDO::PARAM_STR); - $dbdata->execute(); - $clientinfo = $dbdata->fetchAll(); - if ($clientinfo[0]['total_connections'] != NULL) { - $_SESSION[$rspathhex.'tsconnections'] = $clientinfo[0]['total_connections']; - } else { - $_SESSION[$rspathhex.'tsconnections'] = 0; - } - if ($clientinfo[0]['firstcon'] == 0) { - $_SESSION[$rspathhex.'tscreated'] = $lang['unknown']; - } else { - $_SESSION[$rspathhex.'tscreated'] = date('d-m-Y', $clientinfo[0]['firstcon']); - } - $convert = array('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p'); - $uuidasbase16 = ''; - for ($i = 0; $i < 20; $i++) { - $char = ord(substr(base64_decode($_SESSION[$rspathhex.'tsuid']), $i, 1)); - $uuidasbase16 .= $convert[($char & 0xF0) >> 4]; - $uuidasbase16 .= $convert[$char & 0x0F]; - } - if (is_file('../avatars/' . $uuidasbase16 . '.png')) { - $_SESSION[$rspathhex.'tsavatar'] = $uuidasbase16 . '.png'; - } else { - $_SESSION[$rspathhex.'tsavatar'] = "none"; - } - $_SESSION[$rspathhex.'language'] = $cfg['default_language']; - } else { - $err_msg = $lang['stve0006']; $err_lvl = 3; - } - } - - if((!isset($_SESSION[$rspathhex.'multiple']) || count($_SESSION[$rspathhex.'multiple']) == 0) && ($cfg['teamspeak_verification_channel_id'] == NULL || $cfg['teamspeak_verification_channel_id'] == 0)) { - $err_msg = $lang['verify0001']."

".$lang['verify0003']; - $err_lvl = 3; - } elseif((isset($_SESSION[$rspathhex.'connected']) && $_SESSION[$rspathhex.'connected'] == 0 || !isset($_SESSION[$rspathhex.'connected'])) && $cfg['teamspeak_verification_channel_id'] != NULL && $cfg['teamspeak_verification_channel_id'] != 0) { - $err_msg = $lang['verify0001']; $err_lvl = 1; - $uuids = $mysqlcon->query("SELECT `name`,`uuid` FROM `$dbname`.`user` WHERE `online`='1' AND `cid`='{$cfg['teamspeak_verification_channel_id']}' ORDER BY `name` ASC")->fetchAll(); - foreach($uuids as $entry) { - $_SESSION[$rspathhex.'multiple'][$entry['uuid']] = $entry['name']; - } - } elseif(count($_SESSION[$rspathhex.'multiple']) == 1 && $_SESSION[$rspathhex.'connected'] == 1) { - $err_msg = $lang['stve0005']; $err_lvl = 1; - } - - if(isset($_POST['uuid']) && !isset($_SESSION[$rspathhex.'temp_uuid'])) { - if(array_key_exists($_POST['uuid'], $_SESSION[$rspathhex.'multiple'])) { - require_once('../libs/ts3_lib/TeamSpeak3.php'); - try { - if($cfg['teamspeak_query_encrypt_switch'] == 1) { - $ts3 = TeamSpeak3::factory("serverquery://".rawurlencode($cfg['teamspeak_query_user']).":".rawurlencode($cfg['teamspeak_query_pass'])."@".$cfg['teamspeak_host_address'].":".$cfg['teamspeak_query_port']."/?server_port=".$cfg['teamspeak_voice_port']."&ssh=1"); - } else { - $ts3 = TeamSpeak3::factory("serverquery://".rawurlencode($cfg['teamspeak_query_user']).":".rawurlencode($cfg['teamspeak_query_pass'])."@".$cfg['teamspeak_host_address'].":".$cfg['teamspeak_query_port']."/?server_port=".$cfg['teamspeak_voice_port']."&blocking=0"); - } - - try { - usleep($cfg['teamspeak_query_command_delay']); - $ts3->selfUpdate(array('client_nickname' => "Ranksystem - Verification")); - } catch (Exception $e) { - $err_msg = $lang['errorts3'].$e->getCode().': '.$e->getMessage(); $err_lvl = 3; - } - - try { - usleep($cfg['teamspeak_query_command_delay']); - $allclients = $ts3->clientList(); - } catch (Exception $e) { - $err_msg = $lang['errorts3'].$e->getCode().': '.$e->getMessage(); $err_lvl = 3; - } - - foreach ($allclients as $client) { - if($client['client_unique_identifier'] == $_POST['uuid']) { - $cldbid = $client['client_database_id']; - $nickname = htmlspecialchars($client['client_nickname'], ENT_QUOTES); - $_SESSION[$rspathhex.'temp_uuid'] = htmlspecialchars($client['client_unique_identifier'], ENT_QUOTES); - $_SESSION[$rspathhex.'temp_cldbid'] = $cldbid; - $_SESSION[$rspathhex.'temp_name'] = $nickname; - $pwd = substr(str_shuffle("abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789"),0,6); - $_SESSION[$rspathhex.'token'] = $pwd; - $tokenlink = '[URL]http'.(!empty($_SERVER['HTTPS'])?'s':'').'://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'].'?token='.$pwd.'[/URL]'; - try { - $ts3->clientGetByUid($_SESSION[$rspathhex.'temp_uuid'])->message(sprintf($lang['stve0001'], $nickname, $tokenlink, $pwd)); - $err_msg = $lang['stve0002']; $err_lvl = 1; - } catch (Exception $e) { - $err_msg = $lang['errorts3'].$e->getCode().': '.$e->getMessage(); $err_lvl = 3; - } - break; - } - } - } catch (Exception $e) { - $err_msg = $lang['errorts3'].$e->getCode().': '.$e->getMessage(); $err_lvl = 3; - } - } else { - $err_msg = "The chosen user couldn't found! You are still connected on the TS server? Please stay connected on the server during the verification process!"; - $err_lvl = 3; - } - } - ?> +prepare("SELECT `a`.`firstcon` AS `firstcon`, `b`.`total_connections` AS `total_connections` FROM `$dbname`.`user` `a` INNER JOIN `$dbname`.`stats_user` `b` ON `a`.`uuid`=`b`.`uuid` WHERE `b`.`uuid` = :uuid"); + $dbdata->bindValue(':uuid', $_SESSION[$rspathhex.'tsuid'], PDO::PARAM_STR); + $dbdata->execute(); + $clientinfo = $dbdata->fetchAll(); + if ($clientinfo[0]['total_connections'] != null) { + $_SESSION[$rspathhex.'tsconnections'] = $clientinfo[0]['total_connections']; + } else { + $_SESSION[$rspathhex.'tsconnections'] = 0; + } + if ($clientinfo[0]['firstcon'] == 0) { + $_SESSION[$rspathhex.'tscreated'] = $lang['unknown']; + } else { + $_SESSION[$rspathhex.'tscreated'] = date('d-m-Y', $clientinfo[0]['firstcon']); + } + $convert = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p']; + $uuidasbase16 = ''; + for ($i = 0; $i < 20; $i++) { + $char = ord(substr(base64_decode($_SESSION[$rspathhex.'tsuid']), $i, 1)); + $uuidasbase16 .= $convert[($char & 0xF0) >> 4]; + $uuidasbase16 .= $convert[$char & 0x0F]; + } + if (is_file('../avatars/'.$uuidasbase16.'.png')) { + $_SESSION[$rspathhex.'tsavatar'] = $uuidasbase16.'.png'; + } else { + $_SESSION[$rspathhex.'tsavatar'] = 'none'; + } + $_SESSION[$rspathhex.'language'] = $cfg['default_language']; + } else { + $err_msg = $lang['stve0006']; + $err_lvl = 3; + } + } + + if ((! isset($_SESSION[$rspathhex.'multiple']) || count($_SESSION[$rspathhex.'multiple']) == 0) && ($cfg['teamspeak_verification_channel_id'] == null || $cfg['teamspeak_verification_channel_id'] == 0)) { + $err_msg = $lang['verify0001'].'

'.$lang['verify0003']; + $err_lvl = 3; + } elseif ((isset($_SESSION[$rspathhex.'connected']) && $_SESSION[$rspathhex.'connected'] == 0 || ! isset($_SESSION[$rspathhex.'connected'])) && $cfg['teamspeak_verification_channel_id'] != null && $cfg['teamspeak_verification_channel_id'] != 0) { + $err_msg = $lang['verify0001']; + $err_lvl = 1; + $uuids = $mysqlcon->query("SELECT `name`,`uuid` FROM `$dbname`.`user` WHERE `online`='1' AND `cid`='{$cfg['teamspeak_verification_channel_id']}' ORDER BY `name` ASC")->fetchAll(); + foreach ($uuids as $entry) { + $_SESSION[$rspathhex.'multiple'][$entry['uuid']] = $entry['name']; + } + } elseif (count($_SESSION[$rspathhex.'multiple']) == 1 && $_SESSION[$rspathhex.'connected'] == 1) { + $err_msg = $lang['stve0005']; + $err_lvl = 1; + } + + if (isset($_POST['uuid']) && ! isset($_SESSION[$rspathhex.'temp_uuid'])) { + if (array_key_exists($_POST['uuid'], $_SESSION[$rspathhex.'multiple'])) { + require_once '../libs/ts3_lib/TeamSpeak3.php'; + try { + if ($cfg['teamspeak_query_encrypt_switch'] == 1) { + $ts3 = TeamSpeak3::factory('serverquery://'.rawurlencode($cfg['teamspeak_query_user']).':'.rawurlencode($cfg['teamspeak_query_pass']).'@'.$cfg['teamspeak_host_address'].':'.$cfg['teamspeak_query_port'].'/?server_port='.$cfg['teamspeak_voice_port'].'&ssh=1'); + } else { + $ts3 = TeamSpeak3::factory('serverquery://'.rawurlencode($cfg['teamspeak_query_user']).':'.rawurlencode($cfg['teamspeak_query_pass']).'@'.$cfg['teamspeak_host_address'].':'.$cfg['teamspeak_query_port'].'/?server_port='.$cfg['teamspeak_voice_port'].'&blocking=0'); + } + + try { + usleep($cfg['teamspeak_query_command_delay']); + $ts3->selfUpdate(['client_nickname' => 'Ranksystem - Verification']); + } catch (Exception $e) { + $err_msg = $lang['errorts3'].$e->getCode().': '.$e->getMessage(); + $err_lvl = 3; + } + + try { + usleep($cfg['teamspeak_query_command_delay']); + $allclients = $ts3->clientList(); + } catch (Exception $e) { + $err_msg = $lang['errorts3'].$e->getCode().': '.$e->getMessage(); + $err_lvl = 3; + } + + foreach ($allclients as $client) { + if ($client['client_unique_identifier'] == $_POST['uuid']) { + $cldbid = $client['client_database_id']; + $nickname = htmlspecialchars($client['client_nickname'], ENT_QUOTES); + $_SESSION[$rspathhex.'temp_uuid'] = htmlspecialchars($client['client_unique_identifier'], ENT_QUOTES); + $_SESSION[$rspathhex.'temp_cldbid'] = $cldbid; + $_SESSION[$rspathhex.'temp_name'] = $nickname; + $pwd = substr(str_shuffle('abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789'), 0, 6); + $_SESSION[$rspathhex.'token'] = $pwd; + $tokenlink = '[URL]http'.(! empty($_SERVER['HTTPS']) ? 's' : '').'://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'].'?token='.$pwd.'[/URL]'; + try { + $ts3->clientGetByUid($_SESSION[$rspathhex.'temp_uuid'])->message(sprintf($lang['stve0001'], $nickname, $tokenlink, $pwd)); + $err_msg = $lang['stve0002']; + $err_lvl = 1; + } catch (Exception $e) { + $err_msg = $lang['errorts3'].$e->getCode().': '.$e->getMessage(); + $err_lvl = 3; + } + break; + } + } + } catch (Exception $e) { + $err_msg = $lang['errorts3'].$e->getCode().': '.$e->getMessage(); + $err_lvl = 3; + } + } else { + $err_msg = "The chosen user couldn't found! You are still connected on the TS server? Please stay connected on the server during the verification process!"; + $err_lvl = 3; + } + } + ?>
- 1 || ((isset($_SESSION[$rspathhex.'connected']) && $_SESSION[$rspathhex.'connected'] == 0 || !isset($_SESSION[$rspathhex.'connected'])) && $cfg['teamspeak_verification_channel_id'] != NULL && $cfg['teamspeak_verification_channel_id'] != 0)) { - ?> + 1 || ((isset($_SESSION[$rspathhex.'connected']) && $_SESSION[$rspathhex.'connected'] == 0 || ! isset($_SESSION[$rspathhex.'connected'])) && $cfg['teamspeak_verification_channel_id'] != null && $cfg['teamspeak_verification_channel_id'] != 0)) { + ?> - + - \ No newline at end of file diff --git a/stats/versions.php b/stats/versions.php index f3881a2..114b9b1 100644 --- a/stats/versions.php +++ b/stats/versions.php @@ -1,16 +1,18 @@ -query("SELECT * FROM `$dbname`.`stats_versions` ORDER BY `count` DESC")->fetchAll(PDO::FETCH_UNIQUE|PDO::FETCH_ASSOC); - ?> +query("SELECT * FROM `$dbname`.`stats_versions` ORDER BY `count` DESC")->fetchAll(PDO::FETCH_UNIQUE | PDO::FETCH_ASSOC); + ?>
- +

- +

@@ -21,27 +23,27 @@ # - - - + + + - $value) { - $sum_of_all = $sum_of_all + $value['count']; - } - foreach ($sql_res as $version => $value) { - $count++; - echo ' + $value) { + $sum_of_all = $sum_of_all + $value['count']; + } + foreach ($sql_res as $version => $value) { + $count++; + echo ' ',$count,' ',$version,' ',$value['count'],' ',number_format(round(($value['count'] * 100 / $sum_of_all), 1), 1),' % - '; - } - ?> + '; + } + ?>
@@ -50,9 +52,10 @@
- + - \ No newline at end of file diff --git a/webinterface/_nav.php b/webinterface/_nav.php index 6597e78..b102555 100644 --- a/webinterface/_nav.php +++ b/webinterface/_nav.php @@ -1,69 +1,75 @@ -query("SELECT * FROM `$dbname`.`job_check`")->fetchAll(PDO::FETCH_UNIQUE|PDO::FETCH_ASSOC)) === false) { - $err_msg = print_r($mysqlcon->errorInfo(), true); $err_lvl = 3; -} else { - if((time() - $job_check['last_update']['timestamp']) < 259200 && !isset($_SESSION[$rspathhex.'upinfomsg'])) { - if(!isset($err_msg)) { - $err_msg = ''.sprintf($lang['upinf2'], date("Y-m-d H:i",$job_check['last_update']['timestamp']), '', ''); $err_lvl = 1; - $_SESSION[$rspathhex.'upinfomsg'] = 1; - } - } -} - -if(!isset($_POST['start']) && !isset($_POST['stop']) && !isset($_POST['restart']) && isset($_SESSION[$rspathhex.'username']) && hash_equals($_SESSION[$rspathhex.'username'], $cfg['webinterface_user']) && hash_equals($_SESSION[$rspathhex.'password'], $cfg['webinterface_pass'])) { - if (substr(php_uname(), 0, 7) == "Windows") { - if (file_exists($GLOBALS['pidfile'])) { - $pid = str_replace(array("\r", "\n"), '', file_get_contents($GLOBALS['pidfile'])); - exec("wmic process where \"processid=".$pid."\" get processid 2>nul", $result); - if(isset($result[1]) && is_numeric($result[1])) { - $botstatus = 1; - } else { - $botstatus = 0; - } - } else { - $botstatus = 0; - } - } else { - if (file_exists($GLOBALS['pidfile'])) { - $check_pid = str_replace(array("\r", "\n"), '', file_get_contents($GLOBALS['pidfile'])); - $result = str_replace(array("\r", "\n"), '', shell_exec("ps ".$check_pid)); - if (strstr($result, $check_pid)) { - $botstatus = 1; - } else { - $botstatus = 0; - } - } else { - $botstatus = 0; - } - } -} - -if(isset($_POST['switchexpert']) && isset($_SESSION[$rspathhex.'username']) && hash_equals($_SESSION[$rspathhex.'username'], $cfg['webinterface_user']) && hash_equals($_SESSION[$rspathhex.'password'], $cfg['webinterface_pass'])) { - if ($_POST['switchexpert'] == "check") $cfg['webinterface_advanced_mode'] = 1; else $cfg['webinterface_advanced_mode'] = 0; - - if (($mysqlcon->exec("INSERT INTO `$dbname`.`cfg_params` (`param`,`value`) VALUES ('webinterface_advanced_mode','{$cfg['webinterface_advanced_mode']}') ON DUPLICATE KEY UPDATE `value`=VALUES(`value`);")) === false) { - print_r($mysqlcon->errorInfo(), true); - $err_msg = print_r($mysqlcon->errorInfo(), true); - $err_lvl = 3; - } -} -?> +query("SELECT * FROM `$dbname`.`job_check`")->fetchAll(PDO::FETCH_UNIQUE | PDO::FETCH_ASSOC)) === false) { + $err_msg = print_r($mysqlcon->errorInfo(), true); + $err_lvl = 3; +} else { + if ((time() - $job_check['last_update']['timestamp']) < 259200 && ! isset($_SESSION[$rspathhex.'upinfomsg'])) { + if (! isset($err_msg)) { + $err_msg = ''.sprintf($lang['upinf2'], date('Y-m-d H:i', $job_check['last_update']['timestamp']), '', ''); + $err_lvl = 1; + $_SESSION[$rspathhex.'upinfomsg'] = 1; + } + } +} + +if (! isset($_POST['start']) && ! isset($_POST['stop']) && ! isset($_POST['restart']) && isset($_SESSION[$rspathhex.'username']) && hash_equals($_SESSION[$rspathhex.'username'], $cfg['webinterface_user']) && hash_equals($_SESSION[$rspathhex.'password'], $cfg['webinterface_pass'])) { + if (substr(php_uname(), 0, 7) == 'Windows') { + if (file_exists($GLOBALS['pidfile'])) { + $pid = str_replace(["\r", "\n"], '', file_get_contents($GLOBALS['pidfile'])); + exec('wmic process where "processid='.$pid.'" get processid 2>nul', $result); + if (isset($result[1]) && is_numeric($result[1])) { + $botstatus = 1; + } else { + $botstatus = 0; + } + } else { + $botstatus = 0; + } + } else { + if (file_exists($GLOBALS['pidfile'])) { + $check_pid = str_replace(["\r", "\n"], '', file_get_contents($GLOBALS['pidfile'])); + $result = str_replace(["\r", "\n"], '', shell_exec('ps '.$check_pid)); + if (strstr($result, $check_pid)) { + $botstatus = 1; + } else { + $botstatus = 0; + } + } else { + $botstatus = 0; + } + } +} + +if (isset($_POST['switchexpert']) && isset($_SESSION[$rspathhex.'username']) && hash_equals($_SESSION[$rspathhex.'username'], $cfg['webinterface_user']) && hash_equals($_SESSION[$rspathhex.'password'], $cfg['webinterface_pass'])) { + if ($_POST['switchexpert'] == 'check') { + $cfg['webinterface_advanced_mode'] = 1; + } else { + $cfg['webinterface_advanced_mode'] = 0; + } + + if (($mysqlcon->exec("INSERT INTO `$dbname`.`cfg_params` (`param`,`value`) VALUES ('webinterface_advanced_mode','{$cfg['webinterface_advanced_mode']}') ON DUPLICATE KEY UPDATE `value`=VALUES(`value`);")) === false) { + print_r($mysqlcon->errorInfo(), true); + $err_msg = print_r($mysqlcon->errorInfo(), true); + $err_lvl = 3; + } +} +?> - + - + TSN Ranksystem - ts-ranksystem.com - - '; - } - ?> - + + '; + } +?> + - '; - } - ?> + '; +} +?>
'; - } - } - } - ?> + '; + if ($botstatus == 1) { + echo '
  • '.$lang['boton'].'
  • '; + } else { + echo '
  • '.$lang['botoff'].''; + if (file_exists($GLOBALS['autostart'])) { + echo '

    ',$lang['autooff'],'
  • '; + } else { + echo '
    '; + } + } +} +?>
    -"; - $err_msg = sprintf($lang['winav10'], $host,'!
    ', '
    '); $err_lvl = 2; -} +'; + $err_msg = sprintf($lang['winav10'], $host, '!
    ', '
    '); + $err_lvl = 2; +} ?> \ No newline at end of file diff --git a/webinterface/_preload.php b/webinterface/_preload.php index 862f2f3..8ced0cc 100644 --- a/webinterface/_preload.php +++ b/webinterface/_preload.php @@ -1,28 +1,29 @@ - \ No newline at end of file +exec("INSERT INTO `$dbname`.`csrf_token` (`token`,`timestamp`,`sessionid`) VALUES ('$csrf_token','".time()."','".session_id()."')") === false) { - $err_msg = print_r($mysqlcon->errorInfo(), true); - $err_lvl = 3; - } - - if (($db_csrf = $mysqlcon->query("SELECT * FROM `$dbname`.`csrf_token` WHERE `sessionid`='".session_id()."'")->fetchALL(PDO::FETCH_UNIQUE|PDO::FETCH_ASSOC)) === false) { - $err_msg = print_r($mysqlcon->errorInfo(), true); - $err_lvl = 3; - } - - if(($groupslist = $mysqlcon->query("SELECT * FROM `$dbname`.`groups` ORDER BY `sortid`,`sgidname` ASC")->fetchAll(PDO::FETCH_UNIQUE|PDO::FETCH_ASSOC)) === false) { - $err_msg = print_r($mysqlcon->errorInfo(), true); - $err_lvl = 3; - } - - $assign_groups_active = 0; - if (isset($_POST['update']) && isset($db_csrf[$_POST['csrf_token']]) && isset($_POST['assign_groups_active']) && !isset($_POST['assign_groups_groupids']) && !isset($_POST['assign_groups_excepted_groupids'])) { - $err_msg = $lang['stag0010']; - $err_lvl = 3; - } elseif (isset($_POST['update']) && isset($db_csrf[$_POST['csrf_token']])) { - $limit = $alwgr = $excgr = $name = ''; - if (isset($_POST['assign_groups_active'])) $assign_groups_active = 1; - foreach($_POST['assign_groups_limit'] as $rowid => $value) { - $name .= isset($_POST["assign_groups_name"][$rowid]) ? $_POST["assign_groups_name"][$rowid].';' : ';'; - $limit .= isset($_POST["assign_groups_limit"][$rowid]) ? intval($_POST["assign_groups_limit"][$rowid]).';' : '1;'; - if(isset($_POST['assign_groups_groupids'][$rowid])) { - foreach ($_POST['assign_groups_groupids'][$rowid] as $group) { - $alwgr .= $group.','; - } - $alwgr = substr($alwgr,0,-1); - } else { - $err_msg = $lang['stag0010']; - $err_lvl = 3; - } - $alwgr .= ';'; - if(isset($_POST['assign_groups_excepted_groupids'][$rowid])) { - foreach ($_POST['assign_groups_excepted_groupids'][$rowid] as $group) { - $excgr .= $group.','; - } - $excgr = substr($excgr,0,-1); - } else { - - } - $excgr .= ';'; - } - $name = substr($name,0,-1); - $limit = substr($limit,0,-1); - $alwgr = substr($alwgr,0,-1); - $excgr = substr($excgr,0,-1); - - if(!isset($err_lvl) || $err_lvl < 3) { - $sqlexec = $mysqlcon->prepare("INSERT INTO `$dbname`.`addons_config` (`param`,`value`) VALUES ('assign_groups_name', :assign_groups_name), ('assign_groups_active', :assign_groups_active), ('assign_groups_limit', :assign_groups_limit), ('assign_groups_groupids', :assign_groups_groupids), ('assign_groups_excepted_groupids', :assign_groups_excepted_groupids) ON DUPLICATE KEY UPDATE `value`=VALUES(`value`); DELETE FROM `$dbname`.`csrf_token` WHERE `token`= :csrf_token;"); - $sqlexec->bindParam(':assign_groups_name', $name, PDO::PARAM_STR); - $sqlexec->bindParam(':assign_groups_active', $assign_groups_active, PDO::PARAM_STR); - $sqlexec->bindParam(':assign_groups_limit', $limit, PDO::PARAM_STR); - $sqlexec->bindParam(':assign_groups_groupids', $alwgr, PDO::PARAM_STR); - $sqlexec->bindParam(':assign_groups_excepted_groupids', $excgr, PDO::PARAM_STR); - $sqlexec->bindParam(':csrf_token', $_POST['csrf_token']); - $sqlexec->execute(); - - if ($sqlexec->errorCode() != 0) { - $err_msg = print_r($sqlexec->errorInfo(), true); - $err_lvl = 3; - } elseif($addons_config['assign_groups_active']['value'] != $assign_groups_active && $assign_groups_active == 1) { - $err_msg = $lang['wisvsuc']." ".sprintf($lang['wisvres'], '
    '); - $err_lvl = NULL; - } else { - $err_msg = $lang['wisvsuc']; - $err_lvl = NULL; - } - } - - $addons_config['assign_groups_groupids']['value'] = $alwgr; - $addons_config['assign_groups_excepted_groupids']['value'] = $excgr; - $addons_config['assign_groups_name']['value'] = $name; - $addons_config['assign_groups_limit']['value'] = $limit; - $addons_config['assign_groups_active']['value'] = $assign_groups_active; - } elseif(isset($_POST['update'])) { - echo '
    ',$lang['errcsrf'],'
    '; - rem_session_ts3(); - exit; - } - ?> +exec("INSERT INTO `$dbname`.`csrf_token` (`token`,`timestamp`,`sessionid`) VALUES ('$csrf_token','".time()."','".session_id()."')") === false) { + $err_msg = print_r($mysqlcon->errorInfo(), true); + $err_lvl = 3; + } + + if (($db_csrf = $mysqlcon->query("SELECT * FROM `$dbname`.`csrf_token` WHERE `sessionid`='".session_id()."'")->fetchALL(PDO::FETCH_UNIQUE | PDO::FETCH_ASSOC)) === false) { + $err_msg = print_r($mysqlcon->errorInfo(), true); + $err_lvl = 3; + } + + if (($groupslist = $mysqlcon->query("SELECT * FROM `$dbname`.`groups` ORDER BY `sortid`,`sgidname` ASC")->fetchAll(PDO::FETCH_UNIQUE | PDO::FETCH_ASSOC)) === false) { + $err_msg = print_r($mysqlcon->errorInfo(), true); + $err_lvl = 3; + } + + $assign_groups_active = 0; + if (isset($_POST['update']) && isset($db_csrf[$_POST['csrf_token']]) && isset($_POST['assign_groups_active']) && ! isset($_POST['assign_groups_groupids']) && ! isset($_POST['assign_groups_excepted_groupids'])) { + $err_msg = $lang['stag0010']; + $err_lvl = 3; + } elseif (isset($_POST['update']) && isset($db_csrf[$_POST['csrf_token']])) { + $limit = $alwgr = $excgr = $name = ''; + if (isset($_POST['assign_groups_active'])) { + $assign_groups_active = 1; + } + foreach ($_POST['assign_groups_limit'] as $rowid => $value) { + $name .= isset($_POST['assign_groups_name'][$rowid]) ? $_POST['assign_groups_name'][$rowid].';' : ';'; + $limit .= isset($_POST['assign_groups_limit'][$rowid]) ? intval($_POST['assign_groups_limit'][$rowid]).';' : '1;'; + if (isset($_POST['assign_groups_groupids'][$rowid])) { + foreach ($_POST['assign_groups_groupids'][$rowid] as $group) { + $alwgr .= $group.','; + } + $alwgr = substr($alwgr, 0, -1); + } else { + $err_msg = $lang['stag0010']; + $err_lvl = 3; + } + $alwgr .= ';'; + if (isset($_POST['assign_groups_excepted_groupids'][$rowid])) { + foreach ($_POST['assign_groups_excepted_groupids'][$rowid] as $group) { + $excgr .= $group.','; + } + $excgr = substr($excgr, 0, -1); + } else { + } + $excgr .= ';'; + } + $name = substr($name, 0, -1); + $limit = substr($limit, 0, -1); + $alwgr = substr($alwgr, 0, -1); + $excgr = substr($excgr, 0, -1); + + if (! isset($err_lvl) || $err_lvl < 3) { + $sqlexec = $mysqlcon->prepare("INSERT INTO `$dbname`.`addons_config` (`param`,`value`) VALUES ('assign_groups_name', :assign_groups_name), ('assign_groups_active', :assign_groups_active), ('assign_groups_limit', :assign_groups_limit), ('assign_groups_groupids', :assign_groups_groupids), ('assign_groups_excepted_groupids', :assign_groups_excepted_groupids) ON DUPLICATE KEY UPDATE `value`=VALUES(`value`); DELETE FROM `$dbname`.`csrf_token` WHERE `token`= :csrf_token;"); + $sqlexec->bindParam(':assign_groups_name', $name, PDO::PARAM_STR); + $sqlexec->bindParam(':assign_groups_active', $assign_groups_active, PDO::PARAM_STR); + $sqlexec->bindParam(':assign_groups_limit', $limit, PDO::PARAM_STR); + $sqlexec->bindParam(':assign_groups_groupids', $alwgr, PDO::PARAM_STR); + $sqlexec->bindParam(':assign_groups_excepted_groupids', $excgr, PDO::PARAM_STR); + $sqlexec->bindParam(':csrf_token', $_POST['csrf_token']); + $sqlexec->execute(); + + if ($sqlexec->errorCode() != 0) { + $err_msg = print_r($sqlexec->errorInfo(), true); + $err_lvl = 3; + } elseif ($addons_config['assign_groups_active']['value'] != $assign_groups_active && $assign_groups_active == 1) { + $err_msg = $lang['wisvsuc'].' '.sprintf($lang['wisvres'], '
    '); + $err_lvl = null; + } else { + $err_msg = $lang['wisvsuc']; + $err_lvl = null; + } + } + + $addons_config['assign_groups_groupids']['value'] = $alwgr; + $addons_config['assign_groups_excepted_groupids']['value'] = $excgr; + $addons_config['assign_groups_name']['value'] = $name; + $addons_config['assign_groups_limit']['value'] = $limit; + $addons_config['assign_groups_active']['value'] = $assign_groups_active; + } elseif (isset($_POST['update'])) { + echo '
    ',$lang['errcsrf'],'
    '; + rem_session_ts3(); + exit; + } + ?>
    - +

    - +

    - +
    @@ -116,11 +119,11 @@
    - '; - } else { - echo ''; - } ?> + '; + } else { + echo ''; + } ?>
     
    @@ -143,17 +146,31 @@
    @@ -175,35 +192,49 @@
    - $value) { - ?> + $value) { + ?>
    @@ -217,20 +248,40 @@
    - + $groupParam) { + if (in_array($groupID, $assign_groups_groupids)) { + $selected = ' selected'; + } else { + $selected = ''; + } + if (isset($groupParam['iconid']) && $groupParam['iconid'] != 0) { + $iconid = $groupParam['iconid'].'.'; + } else { + $iconid = 'placeholder.png'; + } + if ($groupParam['type'] == 0 || $groupParam['type'] == 2) { + $disabled = ' disabled'; + } else { + $disabled = ''; + } + if ($groupParam['type'] == 0) { + $grouptype = ' [TEMPLATE GROUP]'; + } else { + $grouptype = ''; + } + if ($groupParam['type'] == 2) { + $grouptype = ' [QUERY GROUP]'; + } + if ($groupID != 0) { + echo ''; + } + } + ?>
    @@ -251,29 +302,47 @@
    - + $groupParam) { + if (in_array($groupID, $assign_groups_excepted_groupids)) { + $selected = ' selected'; + } else { + $selected = ''; + } + if (isset($groupParam['iconid']) && $groupParam['iconid'] != 0) { + $iconid = $groupParam['iconid'].'.'; + } else { + $iconid = 'placeholder.png'; + } + if ($groupParam['type'] == 0 || $groupParam['type'] == 2) { + $disabled = ' disabled'; + } else { + $disabled = ''; + } + if ($groupParam['type'] == 0) { + $grouptype = ' [TEMPLATE GROUP]'; + } else { + $grouptype = ''; + } + if ($groupParam['type'] == 2) { + $grouptype = ' [QUERY GROUP]'; + } + if ($groupID != 0) { + echo ''; + } + } + ?>
    - +
    @@ -315,10 +384,10 @@
    @@ -331,10 +400,10 @@
    @@ -347,10 +416,10 @@
    @@ -363,10 +432,10 @@
    @@ -379,10 +448,10 @@ @@ -395,10 +464,10 @@ @@ -438,6 +507,7 @@ function addboostgroup() { - \ No newline at end of file diff --git a/webinterface/addon_channelinfo_toplist.php b/webinterface/addon_channelinfo_toplist.php index 61b8546..6e0fd23 100644 --- a/webinterface/addon_channelinfo_toplist.php +++ b/webinterface/addon_channelinfo_toplist.php @@ -1,74 +1,80 @@ -exec("INSERT INTO `$dbname`.`csrf_token` (`token`,`timestamp`,`sessionid`) VALUES ('$csrf_token','".time()."','".session_id()."')") === false) { - $err_msg = print_r($mysqlcon->errorInfo(), true); - $err_lvl = 3; - } - - if (($db_csrf = $mysqlcon->query("SELECT * FROM `$dbname`.`csrf_token` WHERE `sessionid`='".session_id()."'")->fetchALL(PDO::FETCH_UNIQUE|PDO::FETCH_ASSOC)) === false) { - $err_msg = print_r($mysqlcon->errorInfo(), true); - $err_lvl = 3; - } - - if(($channellist = $mysqlcon->query("SELECT * FROM `$dbname`.`channel` ORDER BY `pid`,`channel_order`,`channel_name` ASC")->fetchAll(PDO::FETCH_UNIQUE|PDO::FETCH_ASSOC)) === false) { - $err_msg = print_r($mysqlcon->errorInfo(), true); - $err_lvl = 3; - } - - $channelinfo_toplist_active = 0; - - if (isset($_POST['update']) && isset($db_csrf[$_POST['csrf_token']])) { - if (isset($_POST['channelinfo_toplist_active'])) $channelinfo_toplist_active = 1; - if(is_array($_POST['channelid'])) $_POST['channelid'] = $_POST['channelid'][0]; - - if(!isset($err_lvl) || $err_lvl < 3) { - $sqlexec = $mysqlcon->prepare("INSERT INTO `$dbname`.`addons_config` (`param`,`value`) VALUES ('channelinfo_toplist_active', :channelinfo_toplist_active), ('channelinfo_toplist_desc', :channelinfo_toplist_desc), ('channelinfo_toplist_delay', :channelinfo_toplist_delay), ('channelinfo_toplist_channelid', :channelinfo_toplist_channelid), ('channelinfo_toplist_modus', :channelinfo_toplist_modus) ON DUPLICATE KEY UPDATE `value`=VALUES(`value`); DELETE FROM `$dbname`.`csrf_token` WHERE `token`= :csrf_token"); - $sqlexec->bindParam(':channelinfo_toplist_active', $channelinfo_toplist_active, PDO::PARAM_STR); - $sqlexec->bindParam(':channelinfo_toplist_desc', $_POST['channelinfo_toplist_desc'], PDO::PARAM_STR); - $sqlexec->bindParam(':channelinfo_toplist_delay', $_POST['channelinfo_toplist_delay'], PDO::PARAM_STR); - $sqlexec->bindParam(':channelinfo_toplist_channelid', $_POST['channelid'], PDO::PARAM_STR); - $sqlexec->bindParam(':channelinfo_toplist_modus', $_POST['channelinfo_toplist_modus'], PDO::PARAM_STR); - $sqlexec->bindParam(':csrf_token', $_POST['csrf_token']); - $sqlexec->execute(); - - if ($sqlexec->errorCode() != 0) { - $err_msg = print_r($sqlexec->errorInfo(), true); - $err_lvl = 3; - } else { - $err_msg = $lang['wisvsuc']." ".sprintf($lang['wisvres'], ''); - $err_lvl = NULL; - } - } - - $addons_config['channelinfo_toplist_active']['value'] = $channelinfo_toplist_active; - $addons_config['channelinfo_toplist_channelid']['value'] = $_POST['channelid']; - $addons_config['channelinfo_toplist_modus']['value'] = $_POST['channelinfo_toplist_modus']; - $addons_config['channelinfo_toplist_delay']['value'] = $_POST['channelinfo_toplist_delay']; - $addons_config['channelinfo_toplist_desc']['value'] = $_POST['channelinfo_toplist_desc']; - } elseif(isset($_POST['update'])) { - echo '
    ',$lang['errcsrf'],'
    '; - rem_session_ts3(); - exit; - } - ?> +exec("INSERT INTO `$dbname`.`csrf_token` (`token`,`timestamp`,`sessionid`) VALUES ('$csrf_token','".time()."','".session_id()."')") === false) { + $err_msg = print_r($mysqlcon->errorInfo(), true); + $err_lvl = 3; + } + + if (($db_csrf = $mysqlcon->query("SELECT * FROM `$dbname`.`csrf_token` WHERE `sessionid`='".session_id()."'")->fetchALL(PDO::FETCH_UNIQUE | PDO::FETCH_ASSOC)) === false) { + $err_msg = print_r($mysqlcon->errorInfo(), true); + $err_lvl = 3; + } + + if (($channellist = $mysqlcon->query("SELECT * FROM `$dbname`.`channel` ORDER BY `pid`,`channel_order`,`channel_name` ASC")->fetchAll(PDO::FETCH_UNIQUE | PDO::FETCH_ASSOC)) === false) { + $err_msg = print_r($mysqlcon->errorInfo(), true); + $err_lvl = 3; + } + + $channelinfo_toplist_active = 0; + + if (isset($_POST['update']) && isset($db_csrf[$_POST['csrf_token']])) { + if (isset($_POST['channelinfo_toplist_active'])) { + $channelinfo_toplist_active = 1; + } + if (is_array($_POST['channelid'])) { + $_POST['channelid'] = $_POST['channelid'][0]; + } + + if (! isset($err_lvl) || $err_lvl < 3) { + $sqlexec = $mysqlcon->prepare("INSERT INTO `$dbname`.`addons_config` (`param`,`value`) VALUES ('channelinfo_toplist_active', :channelinfo_toplist_active), ('channelinfo_toplist_desc', :channelinfo_toplist_desc), ('channelinfo_toplist_delay', :channelinfo_toplist_delay), ('channelinfo_toplist_channelid', :channelinfo_toplist_channelid), ('channelinfo_toplist_modus', :channelinfo_toplist_modus) ON DUPLICATE KEY UPDATE `value`=VALUES(`value`); DELETE FROM `$dbname`.`csrf_token` WHERE `token`= :csrf_token"); + $sqlexec->bindParam(':channelinfo_toplist_active', $channelinfo_toplist_active, PDO::PARAM_STR); + $sqlexec->bindParam(':channelinfo_toplist_desc', $_POST['channelinfo_toplist_desc'], PDO::PARAM_STR); + $sqlexec->bindParam(':channelinfo_toplist_delay', $_POST['channelinfo_toplist_delay'], PDO::PARAM_STR); + $sqlexec->bindParam(':channelinfo_toplist_channelid', $_POST['channelid'], PDO::PARAM_STR); + $sqlexec->bindParam(':channelinfo_toplist_modus', $_POST['channelinfo_toplist_modus'], PDO::PARAM_STR); + $sqlexec->bindParam(':csrf_token', $_POST['csrf_token']); + $sqlexec->execute(); + + if ($sqlexec->errorCode() != 0) { + $err_msg = print_r($sqlexec->errorInfo(), true); + $err_lvl = 3; + } else { + $err_msg = $lang['wisvsuc'].' '.sprintf($lang['wisvres'], '
    '); + $err_lvl = null; + } + } + + $addons_config['channelinfo_toplist_active']['value'] = $channelinfo_toplist_active; + $addons_config['channelinfo_toplist_channelid']['value'] = $_POST['channelid']; + $addons_config['channelinfo_toplist_modus']['value'] = $_POST['channelinfo_toplist_modus']; + $addons_config['channelinfo_toplist_delay']['value'] = $_POST['channelinfo_toplist_delay']; + $addons_config['channelinfo_toplist_desc']['value'] = $_POST['channelinfo_toplist_desc']; + } elseif (isset($_POST['update'])) { + echo '
    ',$lang['errcsrf'],'
    '; + rem_session_ts3(); + exit; + } + ?>
    - +

    - +

    - +
    @@ -84,11 +90,11 @@
    - '; - } else { - echo ''; - } ?> + '; + } else { + echo ''; + } ?>
     
    @@ -102,23 +108,41 @@
    - +
    @@ -165,10 +189,10 @@
    @@ -181,10 +205,10 @@
    @@ -197,10 +221,10 @@ @@ -213,10 +237,10 @@ @@ -229,10 +253,10 @@ @@ -254,6 +278,7 @@ - \ No newline at end of file diff --git a/webinterface/admin_addtime.php b/webinterface/admin_addtime.php index b0df830..bb6a2cb 100644 --- a/webinterface/admin_addtime.php +++ b/webinterface/admin_addtime.php @@ -1,76 +1,92 @@ -exec("INSERT INTO `$dbname`.`csrf_token` (`token`,`timestamp`,`sessionid`) VALUES ('$csrf_token','".time()."','".session_id()."')") === false) { - $err_msg = print_r($mysqlcon->errorInfo(), true); - $err_lvl = 3; - } - - if (($db_csrf = $mysqlcon->query("SELECT * FROM `$dbname`.`csrf_token` WHERE `sessionid`='".session_id()."'")->fetchALL(PDO::FETCH_UNIQUE|PDO::FETCH_ASSOC)) === false) { - $err_msg = print_r($mysqlcon->errorInfo(), true); - $err_lvl = 3; - } - - if(!isset($_POST['number']) || $_POST['number'] == "yes") { - $_SESSION[$rspathhex.'showexcepted'] = "yes"; - $filter = " WHERE `except`='0'"; - } else { - $_SESSION[$rspathhex.'showexcepted'] = "no"; - $filter = ""; - } - - if(($user_arr = $mysqlcon->query("SELECT `uuid`,`cldbid`,`name` FROM `$dbname`.`user` $filter ORDER BY `name` ASC")->fetchAll(PDO::FETCH_ASSOC)) === false) { - $err_msg = "DB Error1: ".print_r($mysqlcon->errorInfo(), true); $err_lvl = 3; - } - - if (isset($_POST['update']) && isset($db_csrf[$_POST['csrf_token']])) { - $setontime = 0; - if($_POST['setontime_day']) { $setontime = $setontime + $_POST['setontime_day'] * 86400; } - if($_POST['setontime_hour']) { $setontime = $setontime + $_POST['setontime_hour'] * 3600; } - if($_POST['setontime_min']) { $setontime = $setontime + $_POST['setontime_min'] * 60; } - if($_POST['setontime_sec']) { $setontime = $setontime + $_POST['setontime_sec']; } - if($setontime == 0) { - $err_msg = $lang['errseltime']; $err_lvl = 3; - } elseif($_POST['user'] == NULL) { - $err_msg = $lang['errselusr']; $err_lvl = 3; - } else { - $allinsertdata = ''; - $succmsg = ''; - $nowtime = time(); - foreach($_POST['user'] as $uuid) { - $allinsertdata .= "('".$uuid."', ".$nowtime.", ".$setontime."),"; - $succmsg .= sprintf($lang['sccupcount'],$setontime,$uuid)."
    "; - } - $allinsertdata = substr($allinsertdata, 0, -1); - if($mysqlcon->exec("INSERT INTO `$dbname`.`admin_addtime` (`uuid`,`timestamp`,`timecount`) VALUES $allinsertdata;") === false) { - $err_msg = $lang['isntwidbmsg'].print_r($mysqlcon->errorInfo(), true); $err_lvl = 3; - } elseif($mysqlcon->exec("UPDATE `$dbname`.`job_check` SET `timestamp`=1 WHERE `job_name`='reload_trigger'; ") === false) { - $err_msg = $lang['isntwidbmsg'].print_r($mysqlcon->errorInfo(), true); $err_lvl = 3; - } else { - $err_msg = substr($succmsg,0,-4); $err_lvl = NULL; - } - } - } elseif(isset($_POST['update'])) { - echo '
    ',$lang['errcsrf'],'
    '; - rem_session_ts3(); - exit; - } - ?> +exec("INSERT INTO `$dbname`.`csrf_token` (`token`,`timestamp`,`sessionid`) VALUES ('$csrf_token','".time()."','".session_id()."')") === false) { + $err_msg = print_r($mysqlcon->errorInfo(), true); + $err_lvl = 3; + } + + if (($db_csrf = $mysqlcon->query("SELECT * FROM `$dbname`.`csrf_token` WHERE `sessionid`='".session_id()."'")->fetchALL(PDO::FETCH_UNIQUE | PDO::FETCH_ASSOC)) === false) { + $err_msg = print_r($mysqlcon->errorInfo(), true); + $err_lvl = 3; + } + + if (! isset($_POST['number']) || $_POST['number'] == 'yes') { + $_SESSION[$rspathhex.'showexcepted'] = 'yes'; + $filter = " WHERE `except`='0'"; + } else { + $_SESSION[$rspathhex.'showexcepted'] = 'no'; + $filter = ''; + } + + if (($user_arr = $mysqlcon->query("SELECT `uuid`,`cldbid`,`name` FROM `$dbname`.`user` $filter ORDER BY `name` ASC")->fetchAll(PDO::FETCH_ASSOC)) === false) { + $err_msg = 'DB Error1: '.print_r($mysqlcon->errorInfo(), true); + $err_lvl = 3; + } + + if (isset($_POST['update']) && isset($db_csrf[$_POST['csrf_token']])) { + $setontime = 0; + if ($_POST['setontime_day']) { + $setontime = $setontime + $_POST['setontime_day'] * 86400; + } + if ($_POST['setontime_hour']) { + $setontime = $setontime + $_POST['setontime_hour'] * 3600; + } + if ($_POST['setontime_min']) { + $setontime = $setontime + $_POST['setontime_min'] * 60; + } + if ($_POST['setontime_sec']) { + $setontime = $setontime + $_POST['setontime_sec']; + } + if ($setontime == 0) { + $err_msg = $lang['errseltime']; + $err_lvl = 3; + } elseif ($_POST['user'] == null) { + $err_msg = $lang['errselusr']; + $err_lvl = 3; + } else { + $allinsertdata = ''; + $succmsg = ''; + $nowtime = time(); + foreach ($_POST['user'] as $uuid) { + $allinsertdata .= "('".$uuid."', ".$nowtime.', '.$setontime.'),'; + $succmsg .= sprintf($lang['sccupcount'], $setontime, $uuid).'
    '; + } + $allinsertdata = substr($allinsertdata, 0, -1); + if ($mysqlcon->exec("INSERT INTO `$dbname`.`admin_addtime` (`uuid`,`timestamp`,`timecount`) VALUES $allinsertdata;") === false) { + $err_msg = $lang['isntwidbmsg'].print_r($mysqlcon->errorInfo(), true); + $err_lvl = 3; + } elseif ($mysqlcon->exec("UPDATE `$dbname`.`job_check` SET `timestamp`=1 WHERE `job_name`='reload_trigger'; ") === false) { + $err_msg = $lang['isntwidbmsg'].print_r($mysqlcon->errorInfo(), true); + $err_lvl = 3; + } else { + $err_msg = substr($succmsg, 0, -4); + $err_lvl = null; + } + } + } elseif (isset($_POST['update'])) { + echo '
    ',$lang['errcsrf'],'
    '; + rem_session_ts3(); + exit; + } + ?>
    - +

    - +

    - +
    @@ -89,10 +105,16 @@
    @@ -100,11 +122,11 @@
    @@ -117,7 +139,7 @@ min: 0, max: 11574, verticalbuttons: true, - prefix: '' + prefix: '' });
    @@ -131,7 +153,7 @@ min: 0, max: 277777, verticalbuttons: true, - prefix: '' + prefix: '' });
    @@ -145,7 +167,7 @@ min: 0, max: 16666666, verticalbuttons: true, - prefix: '' + prefix: '' });
    @@ -159,7 +181,7 @@ min: 0, max: 999999999, verticalbuttons: true, - prefix: '' + prefix: '' }); @@ -189,10 +211,10 @@ @@ -205,10 +227,10 @@ @@ -221,16 +243,17 @@ - \ No newline at end of file diff --git a/webinterface/admin_delclient.php b/webinterface/admin_delclient.php index c88f345..d91f293 100644 --- a/webinterface/admin_delclient.php +++ b/webinterface/admin_delclient.php @@ -1,82 +1,89 @@ -exec("INSERT INTO `$dbname`.`csrf_token` (`token`,`timestamp`,`sessionid`) VALUES ('$csrf_token','".time()."','".session_id()."')") === false) { - $err_msg = print_r($mysqlcon->errorInfo(), true); - $err_lvl = 3; - } - - if (($db_csrf = $mysqlcon->query("SELECT * FROM `$dbname`.`csrf_token` WHERE `sessionid`='".session_id()."'")->fetchALL(PDO::FETCH_UNIQUE|PDO::FETCH_ASSOC)) === false) { - $err_msg = print_r($mysqlcon->errorInfo(), true); - $err_lvl = 3; - } - - if(!isset($_POST['number']) || $_POST['number'] == "yes") { - $_SESSION[$rspathhex.'showexcepted'] = "yes"; - $filter = " WHERE `except`='0'"; - } else { - $_SESSION[$rspathhex.'showexcepted'] = "no"; - $filter = ""; - } - - if(($user_arr = $mysqlcon->query("SELECT `uuid`,`cldbid`,`name`,`lastseen` FROM `$dbname`.`user` $filter ORDER BY `name` ASC")->fetchAll(PDO::FETCH_ASSOC|PDO::FETCH_UNIQUE)) === false) { - $err_msg = "DB Error1: ".print_r($mysqlcon->errorInfo(), true); $err_lvl = 3; - } - - if (isset($_POST['confirm']) && isset($db_csrf[$_POST['csrf_token']])) { - $allinsertdata = ''; - $succmsg = ''; - $del_arr = explode(';',$_POST['uuids']); - foreach($del_arr as $uuid) { - $allinsertdata .= "('".$uuid."', '4273093200', '0'),"; - $succmsg .= sprintf($lang['wihladm44'], $user_arr[$uuid]['name'], $uuid, $user_arr[$uuid]['cldbid'])."
    "; - } - $allinsertdata = substr($allinsertdata, 0, -1); - if($mysqlcon->exec("INSERT INTO `$dbname`.`admin_addtime` (`uuid`,`timestamp`,`timecount`) VALUES $allinsertdata;") === false) { - $err_msg = $lang['isntwidbmsg'].print_r($mysqlcon->errorInfo(), true); $err_lvl = 3; - } elseif($mysqlcon->exec("UPDATE `$dbname`.`job_check` SET `timestamp`=1 WHERE `job_name`='reload_trigger'; ") === false) { - $err_msg = $lang['isntwidbmsg'].print_r($mysqlcon->errorInfo(), true); $err_lvl = 3; - } else { - $err_msg = substr($succmsg,0,-4); $err_lvl = NULL; - } - } elseif(isset($_POST['update']) && $_POST['user'] == NULL && isset($db_csrf[$_POST['csrf_token']])) { - $err_msg = $lang['errselusr']; $err_lvl = 3; - } elseif(isset($_POST['update']) && isset($db_csrf[$_POST['csrf_token']])) { - $err_msg = ''.$lang['wihladm41'].'
    '.$lang['wihladm42'].'

    '; - $uuids = ''; - foreach($_POST['user'] as $uuid) { - $uuids .= $uuid.';'; - $err_msg .= ' - '.sprintf("%s (UUID: %s; DBID: %s)",$user_arr[$uuid]['name'],$uuid,$user_arr[$uuid]['cldbid']).' - '.$lang['listseen'].' '.date('Y-m-d H:i:s',$user_arr[$uuid]['lastseen']).'
    '; - } - $uuids = substr($uuids,0,-1); - $err_msg .= '

    +exec("INSERT INTO `$dbname`.`csrf_token` (`token`,`timestamp`,`sessionid`) VALUES ('$csrf_token','".time()."','".session_id()."')") === false) { + $err_msg = print_r($mysqlcon->errorInfo(), true); + $err_lvl = 3; + } + + if (($db_csrf = $mysqlcon->query("SELECT * FROM `$dbname`.`csrf_token` WHERE `sessionid`='".session_id()."'")->fetchALL(PDO::FETCH_UNIQUE | PDO::FETCH_ASSOC)) === false) { + $err_msg = print_r($mysqlcon->errorInfo(), true); + $err_lvl = 3; + } + + if (! isset($_POST['number']) || $_POST['number'] == 'yes') { + $_SESSION[$rspathhex.'showexcepted'] = 'yes'; + $filter = " WHERE `except`='0'"; + } else { + $_SESSION[$rspathhex.'showexcepted'] = 'no'; + $filter = ''; + } + + if (($user_arr = $mysqlcon->query("SELECT `uuid`,`cldbid`,`name`,`lastseen` FROM `$dbname`.`user` $filter ORDER BY `name` ASC")->fetchAll(PDO::FETCH_ASSOC | PDO::FETCH_UNIQUE)) === false) { + $err_msg = 'DB Error1: '.print_r($mysqlcon->errorInfo(), true); + $err_lvl = 3; + } + + if (isset($_POST['confirm']) && isset($db_csrf[$_POST['csrf_token']])) { + $allinsertdata = ''; + $succmsg = ''; + $del_arr = explode(';', $_POST['uuids']); + foreach ($del_arr as $uuid) { + $allinsertdata .= "('".$uuid."', '4273093200', '0'),"; + $succmsg .= sprintf($lang['wihladm44'], $user_arr[$uuid]['name'], $uuid, $user_arr[$uuid]['cldbid']).'
    '; + } + $allinsertdata = substr($allinsertdata, 0, -1); + if ($mysqlcon->exec("INSERT INTO `$dbname`.`admin_addtime` (`uuid`,`timestamp`,`timecount`) VALUES $allinsertdata;") === false) { + $err_msg = $lang['isntwidbmsg'].print_r($mysqlcon->errorInfo(), true); + $err_lvl = 3; + } elseif ($mysqlcon->exec("UPDATE `$dbname`.`job_check` SET `timestamp`=1 WHERE `job_name`='reload_trigger'; ") === false) { + $err_msg = $lang['isntwidbmsg'].print_r($mysqlcon->errorInfo(), true); + $err_lvl = 3; + } else { + $err_msg = substr($succmsg, 0, -4); + $err_lvl = null; + } + } elseif (isset($_POST['update']) && $_POST['user'] == null && isset($db_csrf[$_POST['csrf_token']])) { + $err_msg = $lang['errselusr']; + $err_lvl = 3; + } elseif (isset($_POST['update']) && isset($db_csrf[$_POST['csrf_token']])) { + $err_msg = ''.$lang['wihladm41'].'
    '.$lang['wihladm42'].'

    '; + $uuids = ''; + foreach ($_POST['user'] as $uuid) { + $uuids .= $uuid.';'; + $err_msg .= ' - '.sprintf('%s (UUID: %s; DBID: %s)', $user_arr[$uuid]['name'], $uuid, $user_arr[$uuid]['cldbid']).' - '.$lang['listseen'].' '.date('Y-m-d H:i:s', $user_arr[$uuid]['lastseen']).'
    '; + } + $uuids = substr($uuids, 0, -1); + $err_msg .= '

    -
    '; - $err_lvl = 1; - } elseif(isset($_POST['update'])) { - echo '
    ',$lang['errcsrf'],'
    '; - rem_session_ts3(); - exit; - } - ?> + '; + $err_lvl = 1; + } elseif (isset($_POST['update'])) { + echo '
    ',$lang['errcsrf'],'
    '; + rem_session_ts3(); + exit; + } + ?>
    - +

    - +

    - +
    @@ -95,10 +102,16 @@
    @@ -106,11 +119,11 @@
    @@ -139,10 +152,10 @@
    @@ -155,10 +168,10 @@ @@ -171,16 +184,17 @@ - \ No newline at end of file diff --git a/webinterface/admin_remtime.php b/webinterface/admin_remtime.php index 847990f..31d13d1 100644 --- a/webinterface/admin_remtime.php +++ b/webinterface/admin_remtime.php @@ -1,77 +1,93 @@ -exec("INSERT INTO `$dbname`.`csrf_token` (`token`,`timestamp`,`sessionid`) VALUES ('$csrf_token','".time()."','".session_id()."')") === false) { - $err_msg = print_r($mysqlcon->errorInfo(), true); - $err_lvl = 3; - } - - if (($db_csrf = $mysqlcon->query("SELECT * FROM `$dbname`.`csrf_token` WHERE `sessionid`='".session_id()."'")->fetchALL(PDO::FETCH_UNIQUE|PDO::FETCH_ASSOC)) === false) { - $err_msg = print_r($mysqlcon->errorInfo(), true); - $err_lvl = 3; - } - - if(!isset($_POST['number']) || $_POST['number'] == "yes") { - $_SESSION[$rspathhex.'showexcepted'] = "yes"; - $filter = " WHERE `except`='0'"; - } else { - $_SESSION[$rspathhex.'showexcepted'] = "no"; - $filter = ""; - } - - if(($user_arr = $mysqlcon->query("SELECT `uuid`,`cldbid`,`name` FROM `$dbname`.`user` $filter ORDER BY `name` ASC")->fetchAll(PDO::FETCH_ASSOC)) === false) { - $err_msg = "DB Error: ".print_r($mysqlcon->errorInfo(), true); $err_lvl = 3; - } - - if (isset($_POST['update']) && isset($db_csrf[$_POST['csrf_token']])) { - $setontime = 0; - if($_POST['setontime_day']) { $setontime = $setontime + $_POST['setontime_day'] * 86400; } - if($_POST['setontime_hour']) { $setontime = $setontime + $_POST['setontime_hour'] * 3600; } - if($_POST['setontime_min']) { $setontime = $setontime + $_POST['setontime_min'] * 60; } - if($_POST['setontime_sec']) { $setontime = $setontime + $_POST['setontime_sec']; } - if($setontime == 0) { - $err_msg = $lang['errseltime']; $err_lvl = 3; - } elseif($_POST['user'] == NULL) { - $err_msg = $lang['errselusr']; $err_lvl = 3; - } else { - $allinsertdata = ''; - $succmsg = ''; - $nowtime = time(); - $setontime = $setontime * -1; - foreach($_POST['user'] as $uuid) { - $allinsertdata .= "('".$uuid."', ".$nowtime.", ".$setontime."),"; - $succmsg .= sprintf($lang['sccupcount'],$setontime,$uuid)."
    "; - } - $allinsertdata = substr($allinsertdata, 0, -1); - if($mysqlcon->exec("INSERT INTO `$dbname`.`admin_addtime` (`uuid`,`timestamp`,`timecount`) VALUES $allinsertdata;") === false) { - $err_msg = $lang['isntwidbmsg'].print_r($mysqlcon->errorInfo(), true); $err_lvl = 3; - } elseif($mysqlcon->exec("UPDATE `$dbname`.`job_check` SET `timestamp`=1 WHERE `job_name`='reload_trigger'; ") === false) { - $err_msg = $lang['isntwidbmsg'].print_r($mysqlcon->errorInfo(), true); $err_lvl = 3; - } else { - $err_msg = substr($succmsg,0,-4); $err_lvl = NULL; - } - } - } elseif(isset($_POST['update'])) { - echo '
    ',$lang['errcsrf'],'
    '; - rem_session_ts3(); - exit; - } - ?> +exec("INSERT INTO `$dbname`.`csrf_token` (`token`,`timestamp`,`sessionid`) VALUES ('$csrf_token','".time()."','".session_id()."')") === false) { + $err_msg = print_r($mysqlcon->errorInfo(), true); + $err_lvl = 3; + } + + if (($db_csrf = $mysqlcon->query("SELECT * FROM `$dbname`.`csrf_token` WHERE `sessionid`='".session_id()."'")->fetchALL(PDO::FETCH_UNIQUE | PDO::FETCH_ASSOC)) === false) { + $err_msg = print_r($mysqlcon->errorInfo(), true); + $err_lvl = 3; + } + + if (! isset($_POST['number']) || $_POST['number'] == 'yes') { + $_SESSION[$rspathhex.'showexcepted'] = 'yes'; + $filter = " WHERE `except`='0'"; + } else { + $_SESSION[$rspathhex.'showexcepted'] = 'no'; + $filter = ''; + } + + if (($user_arr = $mysqlcon->query("SELECT `uuid`,`cldbid`,`name` FROM `$dbname`.`user` $filter ORDER BY `name` ASC")->fetchAll(PDO::FETCH_ASSOC)) === false) { + $err_msg = 'DB Error: '.print_r($mysqlcon->errorInfo(), true); + $err_lvl = 3; + } + + if (isset($_POST['update']) && isset($db_csrf[$_POST['csrf_token']])) { + $setontime = 0; + if ($_POST['setontime_day']) { + $setontime = $setontime + $_POST['setontime_day'] * 86400; + } + if ($_POST['setontime_hour']) { + $setontime = $setontime + $_POST['setontime_hour'] * 3600; + } + if ($_POST['setontime_min']) { + $setontime = $setontime + $_POST['setontime_min'] * 60; + } + if ($_POST['setontime_sec']) { + $setontime = $setontime + $_POST['setontime_sec']; + } + if ($setontime == 0) { + $err_msg = $lang['errseltime']; + $err_lvl = 3; + } elseif ($_POST['user'] == null) { + $err_msg = $lang['errselusr']; + $err_lvl = 3; + } else { + $allinsertdata = ''; + $succmsg = ''; + $nowtime = time(); + $setontime = $setontime * -1; + foreach ($_POST['user'] as $uuid) { + $allinsertdata .= "('".$uuid."', ".$nowtime.', '.$setontime.'),'; + $succmsg .= sprintf($lang['sccupcount'], $setontime, $uuid).'
    '; + } + $allinsertdata = substr($allinsertdata, 0, -1); + if ($mysqlcon->exec("INSERT INTO `$dbname`.`admin_addtime` (`uuid`,`timestamp`,`timecount`) VALUES $allinsertdata;") === false) { + $err_msg = $lang['isntwidbmsg'].print_r($mysqlcon->errorInfo(), true); + $err_lvl = 3; + } elseif ($mysqlcon->exec("UPDATE `$dbname`.`job_check` SET `timestamp`=1 WHERE `job_name`='reload_trigger'; ") === false) { + $err_msg = $lang['isntwidbmsg'].print_r($mysqlcon->errorInfo(), true); + $err_lvl = 3; + } else { + $err_msg = substr($succmsg, 0, -4); + $err_lvl = null; + } + } + } elseif (isset($_POST['update'])) { + echo '
    ',$lang['errcsrf'],'
    '; + rem_session_ts3(); + exit; + } + ?>
    - +

    - +

    - +
    @@ -90,10 +106,16 @@
    @@ -101,11 +123,11 @@
    @@ -118,7 +140,7 @@ min: 0, max: 11574, verticalbuttons: true, - prefix: '' + prefix: '' });
    @@ -132,7 +154,7 @@ min: 0, max: 277777, verticalbuttons: true, - prefix: '' + prefix: '' });
    @@ -146,7 +168,7 @@ min: 0, max: 16666666, verticalbuttons: true, - prefix: '' + prefix: '' });
    @@ -160,7 +182,7 @@ min: 0, max: 999999999, verticalbuttons: true, - prefix: '' + prefix: '' }); @@ -190,10 +212,10 @@ @@ -206,10 +228,10 @@ @@ -222,16 +244,17 @@ - \ No newline at end of file diff --git a/webinterface/api.php b/webinterface/api.php index 98f51cf..040eca6 100644 --- a/webinterface/api.php +++ b/webinterface/api.php @@ -1,63 +1,69 @@ -exec("INSERT INTO `$dbname`.`csrf_token` (`token`,`timestamp`,`sessionid`) VALUES ('$csrf_token','".time()."','".session_id()."')") === false) { - $err_msg = print_r($mysqlcon->errorInfo(), true); - $err_lvl = 3; - } - - if (($db_csrf = $mysqlcon->query("SELECT * FROM `$dbname`.`csrf_token` WHERE `sessionid`='".session_id()."'")->fetchALL(PDO::FETCH_UNIQUE|PDO::FETCH_ASSOC)) === false) { - $err_msg = print_r($mysqlcon->errorInfo(), true); - $err_lvl = 3; - } - - if (isset($_POST['update']) && isset($db_csrf[$_POST['csrf_token']])) { - $stats_api_keys = $err_msg = ""; - - if (isset($_POST['apikey']) && isset($_POST['desc'])) { - $apidefinition = []; - foreach($_POST['apikey'] as $rowid => $apikey) { - $desc = isset($_POST["desc"][$rowid]) ? $_POST["desc"][$rowid] : null; - if(isset($_POST["perm_bot"]) && in_array($rowid,$_POST["perm_bot"])) $perm_bot = 1; else $perm_bot = 0; - $apidefinition[] = "$apikey=>$desc=>$perm_bot"; - } - - $stats_api_keys = implode(",", $apidefinition); - - $cfg['stats_api_keys'] = $stats_api_keys; - } else { - $cfg['stats_api_keys'] = NULL; - } - - if ($mysqlcon->exec("INSERT INTO `$dbname`.`cfg_params` (`param`,`value`) VALUES ('stats_api_keys',".$mysqlcon->quote($cfg['stats_api_keys']).") ON DUPLICATE KEY UPDATE `value`=VALUES(`value`); DELETE FROM `$dbname`.`csrf_token` WHERE `token`='{$_POST['csrf_token']}'") === false) { - $err_msg = print_r($mysqlcon->errorInfo(), true); - $err_lvl = 3; - } else { - $err_msg = $lang['wisvsuc']; - $err_lvl = NULL; - } - - if(empty($stats_api_keys)) { - $cfg['stats_api_keys'] = NULL; - } else { - $keyarr = explode(',', $stats_api_keys); - foreach ($keyarr as $entry) { - list($key, $desc, $perm_bot) = explode('=>', $entry); - $addnewvalue[$key] = array("key"=>$key,"desc"=>$desc,"perm_bot"=>$perm_bot); - $cfg['stats_api_keys'] = $addnewvalue; - } - } - } elseif(isset($_POST['update'])) { - echo '
    ',$lang['errcsrf'],'
    '; - rem_session_ts3(); - exit; - } - ?> +exec("INSERT INTO `$dbname`.`csrf_token` (`token`,`timestamp`,`sessionid`) VALUES ('$csrf_token','".time()."','".session_id()."')") === false) { + $err_msg = print_r($mysqlcon->errorInfo(), true); + $err_lvl = 3; + } + + if (($db_csrf = $mysqlcon->query("SELECT * FROM `$dbname`.`csrf_token` WHERE `sessionid`='".session_id()."'")->fetchALL(PDO::FETCH_UNIQUE | PDO::FETCH_ASSOC)) === false) { + $err_msg = print_r($mysqlcon->errorInfo(), true); + $err_lvl = 3; + } + + if (isset($_POST['update']) && isset($db_csrf[$_POST['csrf_token']])) { + $stats_api_keys = $err_msg = ''; + + if (isset($_POST['apikey']) && isset($_POST['desc'])) { + $apidefinition = []; + foreach ($_POST['apikey'] as $rowid => $apikey) { + $desc = isset($_POST['desc'][$rowid]) ? $_POST['desc'][$rowid] : null; + if (isset($_POST['perm_bot']) && in_array($rowid, $_POST['perm_bot'])) { + $perm_bot = 1; + } else { + $perm_bot = 0; + } + $apidefinition[] = "$apikey=>$desc=>$perm_bot"; + } + + $stats_api_keys = implode(',', $apidefinition); + + $cfg['stats_api_keys'] = $stats_api_keys; + } else { + $cfg['stats_api_keys'] = null; + } + + if ($mysqlcon->exec("INSERT INTO `$dbname`.`cfg_params` (`param`,`value`) VALUES ('stats_api_keys',".$mysqlcon->quote($cfg['stats_api_keys']).") ON DUPLICATE KEY UPDATE `value`=VALUES(`value`); DELETE FROM `$dbname`.`csrf_token` WHERE `token`='{$_POST['csrf_token']}'") === false) { + $err_msg = print_r($mysqlcon->errorInfo(), true); + $err_lvl = 3; + } else { + $err_msg = $lang['wisvsuc']; + $err_lvl = null; + } + + if (empty($stats_api_keys)) { + $cfg['stats_api_keys'] = null; + } else { + $keyarr = explode(',', $stats_api_keys); + foreach ($keyarr as $entry) { + list($key, $desc, $perm_bot) = explode('=>', $entry); + $addnewvalue[$key] = ['key'=>$key, 'desc'=>$desc, 'perm_bot'=>$perm_bot]; + $cfg['stats_api_keys'] = $addnewvalue; + } + } + } elseif (isset($_POST['update'])) { + echo '
    ',$lang['errcsrf'],'
    '; + rem_session_ts3(); + exit; + } + ?>
    - +
    @@ -68,7 +74,7 @@
    - +
    @@ -84,7 +90,7 @@
    - +
    @@ -93,7 +99,8 @@
    '; + } else { + echo '
    '; + }?>
    @@ -178,12 +185,12 @@
    @@ -266,6 +273,7 @@ function copyurl(url) { - \ No newline at end of file diff --git a/webinterface/boost.php b/webinterface/boost.php index 9117b09..cde9673 100644 --- a/webinterface/boost.php +++ b/webinterface/boost.php @@ -1,149 +1,149 @@ -exec("INSERT INTO `$dbname`.`csrf_token` (`token`,`timestamp`,`sessionid`) VALUES ('$csrf_token','".time()."','".session_id()."')") === false) { - $err_msg = print_r($mysqlcon->errorInfo(), true); - $err_lvl = 3; - } - - if (($db_csrf = $mysqlcon->query("SELECT * FROM `$dbname`.`csrf_token` WHERE `sessionid`='".session_id()."'")->fetchALL(PDO::FETCH_UNIQUE|PDO::FETCH_ASSOC)) === false) { - $err_msg = print_r($mysqlcon->errorInfo(), true); - $err_lvl = 3; - } - - if(($groupslist = $mysqlcon->query("SELECT * FROM `$dbname`.`groups` ORDER BY `sortid`,`sgidname` ASC")->fetchAll(PDO::FETCH_UNIQUE|PDO::FETCH_ASSOC)) === false) { - $err_msg = print_r($mysqlcon->errorInfo(), true); - $err_lvl = 3; - } - - if(!isset($groupslist) || $groupslist == NULL) { - $err_msg = 'No servergroups found inside the Ranksystem cache!

    Please connect the Ranksystem Bot to the TS server. The Ranksystem will download the servergroups when it is connected to the server.
    Give it a few minutes and reload this page. The dropdown field should contain your groups after.'; - $err_lvl = 1; - } - - if (isset($_POST['update_old']) && isset($db_csrf[$_POST['csrf_token']])) { - if(empty($_POST['rankup_boost_definition'])) { - $grouparr_old = null; - } else { - foreach (explode(',', $_POST['rankup_boost_definition']) as $entry) { - list($key, $value1, $value2) = explode('=>', $entry); - $grouparr_old[$key] = array("group"=>$key,"factor"=>$value1,"time"=>$value2); - $cfg['rankup_boost_definition'] = $grouparr_old; - } - } - - if(isset($cfg['rankup_boost_definition']) && $cfg['rankup_boost_definition'] != NULL) { - foreach($cfg['rankup_boost_definition'] as $groupid => $value) { - if(!isset($groupslist[$groupid]) && $groupid != NULL) { - $err_msg .= sprintf($lang['upgrp0001'], $groupid, $lang['wiboost']).'
    '; - $err_lvl = 3; - $errcnf++; - } - } - } - - $cfg['rankup_boost_definition'] = $_POST['rankup_boost_definition']; - - if($errcnf == 0) { - if ($mysqlcon->exec("INSERT INTO `$dbname`.`cfg_params` (`param`,`value`) VALUES ('rankup_boost_definition','{$cfg['rankup_boost_definition']}') ON DUPLICATE KEY UPDATE `value`=VALUES(`value`); DELETE FROM `$dbname`.`csrf_token` WHERE `token`='{$_POST['csrf_token']}'") === false) { - $err_msg = print_r($mysqlcon->errorInfo(), true); - $err_lvl = 3; - } else { - $err_msg = $lang['wisvsuc']." ".sprintf($lang['wisvres'], ''); - $err_lvl = NULL; - } - } else { - $err_msg .= "
    ".$lang['errgrpid']; - } - - if(empty($_POST['rankup_boost_definition'])) { - $cfg['rankup_boost_definition'] = NULL; - } else { - foreach (explode(',', $_POST['rankup_boost_definition']) as $entry) { - list($key, $value1, $value2) = explode('=>', $entry); - $addnewvalue2[$key] = array("group"=>$key,"factor"=>$value1,"time"=>$value2); - $cfg['rankup_boost_definition'] = $addnewvalue2; - } - } - - } elseif (isset($_POST['update']) && isset($db_csrf[$_POST['csrf_token']])) { - $rankup_boost_definition = $err_msg = ""; - $errcnf = 0; - - if (isset($_POST['boostduration']) && !isset($_POST['boostgroup']) && isset($_POST['boostfactor'])) { - $errcnf++; - $err_msg = "Missing servergroup in your defintion!
    "; - $err_lvl = 3; - $cfg['rankup_boost_definition'] = null; - } elseif (isset($_POST['boostduration']) && isset($_POST['boostgroup']) && isset($_POST['boostfactor'])) { - $boostdefinition = []; - foreach($_POST['boostgroup'] as $rowid => $groupid) { - $factor = isset($_POST["boostfactor"][$rowid]) ? floatval($_POST["boostfactor"][$rowid]) : 1; - $duration = isset($_POST["boostduration"][$rowid]) ? intval($_POST["boostduration"][$rowid]) : 1; - $boostdefinition[] = "$groupid=>$factor=>$duration"; - } - - $rankup_boost_definition = implode(",", $boostdefinition); - - $grouparr = []; - foreach(explode(',', $rankup_boost_definition) as $entry) { - list($groupid, $factor, $duration) = explode('=>', $entry); - $grouparr[$groupid] = $factor; - } - - if(isset($groupslist) && $groupslist != NULL) { - foreach($grouparr as $groupid => $time) { - if((!isset($groupslist[$groupid]) && $groupid != NULL) || $groupid == 0) { - $err_msg .= sprintf($lang['upgrp0001'], $groupid, $lang['wigrptime']).'
    '; - $err_lvl = 3; - $errcnf++; - } - } - } - - $cfg['rankup_boost_definition'] = $rankup_boost_definition; - } else { - $cfg['rankup_boost_definition'] = null; - if ($mysqlcon->exec("UPDATE `$dbname`.`user` SET `boosttime`=0;") === false) { - $err_msg = print_r($mysqlcon->errorInfo(), true); - $err_lvl = 3; - } - } - - if($errcnf == 0) { - if ($mysqlcon->exec("INSERT INTO `$dbname`.`cfg_params` (`param`,`value`) VALUES ('rankup_boost_definition','{$cfg['rankup_boost_definition']}') ON DUPLICATE KEY UPDATE `value`=VALUES(`value`); DELETE FROM `$dbname`.`csrf_token` WHERE `token`='{$_POST['csrf_token']}'") === false) { - $err_msg = print_r($mysqlcon->errorInfo(), true); - $err_lvl = 3; - } else { - $err_msg = $lang['wisvsuc']." ".sprintf($lang['wisvres'], '
    '); - $err_lvl = NULL; - } - } else { - $err_msg .= "
    ".$lang['errgrpid']; - } - - if(empty($rankup_boost_definition)) { - $cfg['rankup_boost_definition'] = NULL; - } else { - $boostexp = explode(',', $rankup_boost_definition); - foreach ($boostexp as $entry) { - list($key, $value1, $value2) = explode('=>', $entry); - $addnewvalue2[$key] = array("group"=>$key,"factor"=>$value1,"time"=>$value2); - $cfg['rankup_boost_definition'] = $addnewvalue2; - } - } - - } elseif(isset($_POST['update']) || isset($_POST['update_old'])) { - echo '
    ',$lang['errcsrf'],'
    '; - rem_session_ts3(); - exit; - } - ?> +exec("INSERT INTO `$dbname`.`csrf_token` (`token`,`timestamp`,`sessionid`) VALUES ('$csrf_token','".time()."','".session_id()."')") === false) { + $err_msg = print_r($mysqlcon->errorInfo(), true); + $err_lvl = 3; + } + + if (($db_csrf = $mysqlcon->query("SELECT * FROM `$dbname`.`csrf_token` WHERE `sessionid`='".session_id()."'")->fetchALL(PDO::FETCH_UNIQUE | PDO::FETCH_ASSOC)) === false) { + $err_msg = print_r($mysqlcon->errorInfo(), true); + $err_lvl = 3; + } + + if (($groupslist = $mysqlcon->query("SELECT * FROM `$dbname`.`groups` ORDER BY `sortid`,`sgidname` ASC")->fetchAll(PDO::FETCH_UNIQUE | PDO::FETCH_ASSOC)) === false) { + $err_msg = print_r($mysqlcon->errorInfo(), true); + $err_lvl = 3; + } + + if (! isset($groupslist) || $groupslist == null) { + $err_msg = 'No servergroups found inside the Ranksystem cache!

    Please connect the Ranksystem Bot to the TS server. The Ranksystem will download the servergroups when it is connected to the server.
    Give it a few minutes and reload this page. The dropdown field should contain your groups after.'; + $err_lvl = 1; + } + + if (isset($_POST['update_old']) && isset($db_csrf[$_POST['csrf_token']])) { + if (empty($_POST['rankup_boost_definition'])) { + $grouparr_old = null; + } else { + foreach (explode(',', $_POST['rankup_boost_definition']) as $entry) { + list($key, $value1, $value2) = explode('=>', $entry); + $grouparr_old[$key] = ['group'=>$key, 'factor'=>$value1, 'time'=>$value2]; + $cfg['rankup_boost_definition'] = $grouparr_old; + } + } + + if (isset($cfg['rankup_boost_definition']) && $cfg['rankup_boost_definition'] != null) { + foreach ($cfg['rankup_boost_definition'] as $groupid => $value) { + if (! isset($groupslist[$groupid]) && $groupid != null) { + $err_msg .= sprintf($lang['upgrp0001'], $groupid, $lang['wiboost']).'
    '; + $err_lvl = 3; + $errcnf++; + } + } + } + + $cfg['rankup_boost_definition'] = $_POST['rankup_boost_definition']; + + if ($errcnf == 0) { + if ($mysqlcon->exec("INSERT INTO `$dbname`.`cfg_params` (`param`,`value`) VALUES ('rankup_boost_definition','{$cfg['rankup_boost_definition']}') ON DUPLICATE KEY UPDATE `value`=VALUES(`value`); DELETE FROM `$dbname`.`csrf_token` WHERE `token`='{$_POST['csrf_token']}'") === false) { + $err_msg = print_r($mysqlcon->errorInfo(), true); + $err_lvl = 3; + } else { + $err_msg = $lang['wisvsuc'].' '.sprintf($lang['wisvres'], '
    '); + $err_lvl = null; + } + } else { + $err_msg .= '
    '.$lang['errgrpid']; + } + + if (empty($_POST['rankup_boost_definition'])) { + $cfg['rankup_boost_definition'] = null; + } else { + foreach (explode(',', $_POST['rankup_boost_definition']) as $entry) { + list($key, $value1, $value2) = explode('=>', $entry); + $addnewvalue2[$key] = ['group'=>$key, 'factor'=>$value1, 'time'=>$value2]; + $cfg['rankup_boost_definition'] = $addnewvalue2; + } + } + } elseif (isset($_POST['update']) && isset($db_csrf[$_POST['csrf_token']])) { + $rankup_boost_definition = $err_msg = ''; + $errcnf = 0; + + if (isset($_POST['boostduration']) && ! isset($_POST['boostgroup']) && isset($_POST['boostfactor'])) { + $errcnf++; + $err_msg = 'Missing servergroup in your defintion!
    '; + $err_lvl = 3; + $cfg['rankup_boost_definition'] = null; + } elseif (isset($_POST['boostduration']) && isset($_POST['boostgroup']) && isset($_POST['boostfactor'])) { + $boostdefinition = []; + foreach ($_POST['boostgroup'] as $rowid => $groupid) { + $factor = isset($_POST['boostfactor'][$rowid]) ? floatval($_POST['boostfactor'][$rowid]) : 1; + $duration = isset($_POST['boostduration'][$rowid]) ? intval($_POST['boostduration'][$rowid]) : 1; + $boostdefinition[] = "$groupid=>$factor=>$duration"; + } + + $rankup_boost_definition = implode(',', $boostdefinition); + + $grouparr = []; + foreach (explode(',', $rankup_boost_definition) as $entry) { + list($groupid, $factor, $duration) = explode('=>', $entry); + $grouparr[$groupid] = $factor; + } + + if (isset($groupslist) && $groupslist != null) { + foreach ($grouparr as $groupid => $time) { + if ((! isset($groupslist[$groupid]) && $groupid != null) || $groupid == 0) { + $err_msg .= sprintf($lang['upgrp0001'], $groupid, $lang['wigrptime']).'
    '; + $err_lvl = 3; + $errcnf++; + } + } + } + + $cfg['rankup_boost_definition'] = $rankup_boost_definition; + } else { + $cfg['rankup_boost_definition'] = null; + if ($mysqlcon->exec("UPDATE `$dbname`.`user` SET `boosttime`=0;") === false) { + $err_msg = print_r($mysqlcon->errorInfo(), true); + $err_lvl = 3; + } + } + + if ($errcnf == 0) { + if ($mysqlcon->exec("INSERT INTO `$dbname`.`cfg_params` (`param`,`value`) VALUES ('rankup_boost_definition','{$cfg['rankup_boost_definition']}') ON DUPLICATE KEY UPDATE `value`=VALUES(`value`); DELETE FROM `$dbname`.`csrf_token` WHERE `token`='{$_POST['csrf_token']}'") === false) { + $err_msg = print_r($mysqlcon->errorInfo(), true); + $err_lvl = 3; + } else { + $err_msg = $lang['wisvsuc'].' '.sprintf($lang['wisvres'], '
    '); + $err_lvl = null; + } + } else { + $err_msg .= '
    '.$lang['errgrpid']; + } + + if (empty($rankup_boost_definition)) { + $cfg['rankup_boost_definition'] = null; + } else { + $boostexp = explode(',', $rankup_boost_definition); + foreach ($boostexp as $entry) { + list($key, $value1, $value2) = explode('=>', $entry); + $addnewvalue2[$key] = ['group'=>$key, 'factor'=>$value1, 'time'=>$value2]; + $cfg['rankup_boost_definition'] = $addnewvalue2; + } + } + } elseif (isset($_POST['update']) || isset($_POST['update_old'])) { + echo '
    ',$lang['errcsrf'],'
    '; + rem_session_ts3(); + exit; + } + ?>
    - +
    @@ -157,7 +157,7 @@
    - +
    @@ -180,17 +180,31 @@ '; + } else { + echo '
    '; + }?>
    @@ -277,7 +309,7 @@
    - +
    @@ -288,16 +320,16 @@
    - +
    @@ -323,10 +355,10 @@
    @@ -339,10 +371,10 @@
    @@ -410,6 +442,7 @@ function addboostgroup() { - \ No newline at end of file diff --git a/webinterface/bot.php b/webinterface/bot.php index 6896ac0..2ca4b89 100644 --- a/webinterface/bot.php +++ b/webinterface/bot.php @@ -1,207 +1,222 @@ -exec("INSERT INTO `$dbname`.`csrf_token` (`token`,`timestamp`,`sessionid`) VALUES ('$csrf_token','".time()."','".session_id()."')") === false) { - $err_msg = print_r($mysqlcon->errorInfo(), true); - $err_lvl = 3; - } - - if (($db_csrf = $mysqlcon->query("SELECT * FROM `$dbname`.`csrf_token` WHERE `sessionid`='".session_id()."'")->fetchALL(PDO::FETCH_UNIQUE|PDO::FETCH_ASSOC)) === false) { - $err_msg = print_r($mysqlcon->errorInfo(), true); - $err_lvl = 3; - } - - if ((isset($_POST['start']) || isset($_POST['stop']) || isset($_POST['restart']) || isset($_POST['logfilter'])) && !isset($db_csrf[$_POST['csrf_token']])) { - echo '
    ',$lang['errcsrf'],'
    '; - rem_session_ts3(); - exit; - } - - $logoutput = getlog($number_lines,$filters,$filter2,$inactivefilter); - - if (isset($_POST['start']) && isset($db_csrf[$_POST['csrf_token']])) { - if(!is_writable($GLOBALS['logpath'])) { - $err_msg = "!!!! Logs folder is not writable !!!!
    Cancel start request!"; $err_lvl = 3; - } else { - $output = ''; - exec($phpcommand." ".dirname(__DIR__).DIRECTORY_SEPARATOR."worker.php start", $resultexec); - if (file_exists($GLOBALS['autostart'])) { - unlink($GLOBALS['autostart']); - } - foreach($resultexec as $line) $output .= print_r($line, true).'
    '; - $err_msg = $lang['wibot2'].'

    Result of worker.php:
    '.$output.'
    '; - $err_lvl = 1; - usleep(80000); - $logoutput = getlog($number_lines,$filters,$filter2,$inactivefilter); - } - } - - if (isset($_POST['stop']) && isset($db_csrf[$_POST['csrf_token']])) { - if(!is_writable($GLOBALS['logpath'])) { - $err_msg = "!!!! Logs folder is not writable !!!!
    Cancel stop request!"; $err_lvl = 3; - } else { - $output = ''; - exec($phpcommand." ".dirname(__DIR__).DIRECTORY_SEPARATOR."worker.php stop", $resultexec); - file_put_contents($GLOBALS['autostart'],""); - foreach($resultexec as $line) $output .= print_r($line, true).'
    '; - $err_msg = $lang['wibot1'].'

    Result of worker.php:
    '.$output.'
    ';; - $err_lvl = 1; - usleep(80000); - $logoutput = getlog($number_lines,$filters,$filter2,$inactivefilter); - } - } - - if (isset($_POST['restart']) && isset($db_csrf[$_POST['csrf_token']])) { - if(!is_writable($GLOBALS['logpath'])) { - $err_msg = "!!!! Logs folder is not writable !!!!
    Cancel restart request!"; $err_lvl = 3; - } else { - $output = ''; - exec($phpcommand." ".dirname(__DIR__).DIRECTORY_SEPARATOR."worker.php restart", $resultexec); - if (file_exists($GLOBALS['autostart'])) { - unlink($GLOBALS['autostart']); - } - foreach($resultexec as $line) $output .= print_r($line, true).'
    '; - $err_msg = $lang['wibot3'].'

    Result of worker.php:
    '.$output.'
    '; - $err_lvl = 1; - usleep(80000); - $logoutput = getlog($number_lines,$filters,$filter2,$inactivefilter); - } - } - - $disabled = ''; - if($cfg['teamspeak_host_address'] == NULL || $cfg['teamspeak_query_port'] == NULL || $cfg['teamspeak_voice_port'] == NULL || $cfg['teamspeak_query_user'] == NULL || $cfg['teamspeak_query_pass'] == NULL || $cfg['teamspeak_query_nickname'] == NULL || $cfg['rankup_definition'] == NULL || $GLOBALS['logpath'] == NULL) { - $disabled = 1; - $err_msg = $lang['wibot9']; - $err_lvl = 2; - } - ?> +exec("INSERT INTO `$dbname`.`csrf_token` (`token`,`timestamp`,`sessionid`) VALUES ('$csrf_token','".time()."','".session_id()."')") === false) { + $err_msg = print_r($mysqlcon->errorInfo(), true); + $err_lvl = 3; + } + + if (($db_csrf = $mysqlcon->query("SELECT * FROM `$dbname`.`csrf_token` WHERE `sessionid`='".session_id()."'")->fetchALL(PDO::FETCH_UNIQUE | PDO::FETCH_ASSOC)) === false) { + $err_msg = print_r($mysqlcon->errorInfo(), true); + $err_lvl = 3; + } + + if ((isset($_POST['start']) || isset($_POST['stop']) || isset($_POST['restart']) || isset($_POST['logfilter'])) && ! isset($db_csrf[$_POST['csrf_token']])) { + echo '
    ',$lang['errcsrf'],'
    '; + rem_session_ts3(); + exit; + } + + $logoutput = getlog($number_lines, $filters, $filter2, $inactivefilter); + + if (isset($_POST['start']) && isset($db_csrf[$_POST['csrf_token']])) { + if (! is_writable($GLOBALS['logpath'])) { + $err_msg = '!!!! Logs folder is not writable !!!!
    Cancel start request!'; + $err_lvl = 3; + } else { + $output = ''; + exec($phpcommand.' '.dirname(__DIR__).DIRECTORY_SEPARATOR.'worker.php start', $resultexec); + if (file_exists($GLOBALS['autostart'])) { + unlink($GLOBALS['autostart']); + } + foreach ($resultexec as $line) { + $output .= print_r($line, true).'
    '; + } + $err_msg = $lang['wibot2'].'

    Result of worker.php:
    '.$output.'
    '; + $err_lvl = 1; + usleep(80000); + $logoutput = getlog($number_lines, $filters, $filter2, $inactivefilter); + } + } + + if (isset($_POST['stop']) && isset($db_csrf[$_POST['csrf_token']])) { + if (! is_writable($GLOBALS['logpath'])) { + $err_msg = '!!!! Logs folder is not writable !!!!
    Cancel stop request!'; + $err_lvl = 3; + } else { + $output = ''; + exec($phpcommand.' '.dirname(__DIR__).DIRECTORY_SEPARATOR.'worker.php stop', $resultexec); + file_put_contents($GLOBALS['autostart'], ''); + foreach ($resultexec as $line) { + $output .= print_r($line, true).'
    '; + } + $err_msg = $lang['wibot1'].'

    Result of worker.php:
    '.$output.'
    '; + $err_lvl = 1; + usleep(80000); + $logoutput = getlog($number_lines, $filters, $filter2, $inactivefilter); + } + } + + if (isset($_POST['restart']) && isset($db_csrf[$_POST['csrf_token']])) { + if (! is_writable($GLOBALS['logpath'])) { + $err_msg = '!!!! Logs folder is not writable !!!!
    Cancel restart request!'; + $err_lvl = 3; + } else { + $output = ''; + exec($phpcommand.' '.dirname(__DIR__).DIRECTORY_SEPARATOR.'worker.php restart', $resultexec); + if (file_exists($GLOBALS['autostart'])) { + unlink($GLOBALS['autostart']); + } + foreach ($resultexec as $line) { + $output .= print_r($line, true).'
    '; + } + $err_msg = $lang['wibot3'].'

    Result of worker.php:
    '.$output.'
    '; + $err_lvl = 1; + usleep(80000); + $logoutput = getlog($number_lines, $filters, $filter2, $inactivefilter); + } + } + + $disabled = ''; + if ($cfg['teamspeak_host_address'] == null || $cfg['teamspeak_query_port'] == null || $cfg['teamspeak_voice_port'] == null || $cfg['teamspeak_query_user'] == null || $cfg['teamspeak_query_pass'] == null || $cfg['teamspeak_query_nickname'] == null || $cfg['rankup_definition'] == null || $GLOBALS['logpath'] == null) { + $disabled = 1; + $err_msg = $lang['wibot9']; + $err_lvl = 2; + } + ?>
    - +

    - +

    - +
     
    -
     
    - +
     
     
    - +
     
    -
    @@ -211,74 +226,107 @@

    - +

    - +
    - - - + + + - +
    @@ -286,7 +334,9 @@
    -
    +
    @@ -294,6 +344,7 @@
    - \ No newline at end of file diff --git a/webinterface/changepassword.php b/webinterface/changepassword.php index cbf47f8..479f060 100644 --- a/webinterface/changepassword.php +++ b/webinterface/changepassword.php @@ -1,74 +1,80 @@ -exec("INSERT INTO `$dbname`.`csrf_token` (`token`,`timestamp`,`sessionid`) VALUES ('$csrf_token','".time()."','".session_id()."')") === false) { - $err_msg = print_r($mysqlcon->errorInfo(), true); - $err_lvl = 3; - } - - if (($db_csrf = $mysqlcon->query("SELECT * FROM `$dbname`.`csrf_token` WHERE `sessionid`='".session_id()."'")->fetchALL(PDO::FETCH_UNIQUE|PDO::FETCH_ASSOC)) === false) { - $err_msg = print_r($mysqlcon->errorInfo(), true); - $err_lvl = 3; - } - - if (isset($_POST['changepw']) && isset($db_csrf[$_POST['csrf_token']])) { - if (!password_verify($_POST['oldpwd'], $cfg['webinterface_pass'])) { - $err_msg = $lang['wichpw1']; $err_lvl = 3; - } else { - $cfg['webinterface_pass'] = password_hash($_POST['newpwd1'], PASSWORD_DEFAULT); - if (!hash_equals($_POST['newpwd1'], $_POST['newpwd2']) || $_POST['newpwd1'] == NULL) { - $err_msg = $lang['wichpw2']; $err_lvl = 3; - } elseif($mysqlcon->exec("INSERT INTO `$dbname`.`cfg_params` (`param`,`value`) VALUES ('webinterface_pass','{$cfg['webinterface_pass']}') ON DUPLICATE KEY UPDATE `value`=VALUES(`value`)") === false) { - $err_msg = print_r($mysqlcon->errorInfo(), true); $err_lvl = 3; - } else { - enter_logfile(3,sprintf($lang['wichpw3'],getclientip())); - $err_msg = $lang['wisvsuc']; $err_lvl = NULL; - } - } - } elseif(isset($_POST['changepw'])) { - echo '
    ',$lang['errcsrf'],'
    '; - rem_session_ts3(); - exit; - } - ?> +exec("INSERT INTO `$dbname`.`csrf_token` (`token`,`timestamp`,`sessionid`) VALUES ('$csrf_token','".time()."','".session_id()."')") === false) { + $err_msg = print_r($mysqlcon->errorInfo(), true); + $err_lvl = 3; + } + + if (($db_csrf = $mysqlcon->query("SELECT * FROM `$dbname`.`csrf_token` WHERE `sessionid`='".session_id()."'")->fetchALL(PDO::FETCH_UNIQUE | PDO::FETCH_ASSOC)) === false) { + $err_msg = print_r($mysqlcon->errorInfo(), true); + $err_lvl = 3; + } + + if (isset($_POST['changepw']) && isset($db_csrf[$_POST['csrf_token']])) { + if (! password_verify($_POST['oldpwd'], $cfg['webinterface_pass'])) { + $err_msg = $lang['wichpw1']; + $err_lvl = 3; + } else { + $cfg['webinterface_pass'] = password_hash($_POST['newpwd1'], PASSWORD_DEFAULT); + if (! hash_equals($_POST['newpwd1'], $_POST['newpwd2']) || $_POST['newpwd1'] == null) { + $err_msg = $lang['wichpw2']; + $err_lvl = 3; + } elseif ($mysqlcon->exec("INSERT INTO `$dbname`.`cfg_params` (`param`,`value`) VALUES ('webinterface_pass','{$cfg['webinterface_pass']}') ON DUPLICATE KEY UPDATE `value`=VALUES(`value`)") === false) { + $err_msg = print_r($mysqlcon->errorInfo(), true); + $err_lvl = 3; + } else { + enter_logfile(3, sprintf($lang['wichpw3'], getclientip())); + $err_msg = $lang['wisvsuc']; + $err_lvl = null; + } + } + } elseif (isset($_POST['changepw'])) { + echo '
    ',$lang['errcsrf'],'
    '; + rem_session_ts3(); + exit; + } + ?>
    - +
    - \ No newline at end of file diff --git a/webinterface/db.php b/webinterface/db.php index 02c801c..5c7da17 100644 --- a/webinterface/db.php +++ b/webinterface/db.php @@ -1,68 +1,69 @@ -exec("INSERT INTO `$dbname`.`csrf_token` (`token`,`timestamp`,`sessionid`) VALUES ('$csrf_token','".time()."','".session_id()."')") === false) { - $err_msg = print_r($mysqlcon->errorInfo(), true); - $err_lvl = 3; - } - - if (($db_csrf = $mysqlcon->query("SELECT * FROM `$dbname`.`csrf_token` WHERE `sessionid`='".session_id()."'")->fetchALL(PDO::FETCH_UNIQUE|PDO::FETCH_ASSOC)) === false) { - $err_msg = print_r($mysqlcon->errorInfo(), true); - $err_lvl = 3; - } - - if (isset($_POST['update']) && isset($db_csrf[$_POST['csrf_token']])) { - $newconfig='exec("INSERT INTO `$dbname`.`csrf_token` (`token`,`timestamp`,`sessionid`) VALUES ('$csrf_token','".time()."','".session_id()."')") === false) { + $err_msg = print_r($mysqlcon->errorInfo(), true); + $err_lvl = 3; + } + + if (($db_csrf = $mysqlcon->query("SELECT * FROM `$dbname`.`csrf_token` WHERE `sessionid`='".session_id()."'")->fetchALL(PDO::FETCH_UNIQUE | PDO::FETCH_ASSOC)) === false) { + $err_msg = print_r($mysqlcon->errorInfo(), true); + $err_lvl = 3; + } + + if (isset($_POST['update']) && isset($db_csrf[$_POST['csrf_token']])) { + $newconfig = ''; - $dbserver = $_POST['dbtype'].':host='.$_POST['dbhost'].';dbname='.$_POST['dbname'].';charset=utf8mb4'; - try { - $mysqlcon = new PDO($dbserver, $_POST['dbuser'], $_POST['dbpass']); - $handle=fopen('../other/dbconfig.php','w'); - if(!fwrite($handle,$newconfig)) - { - $err_msg = sprintf($lang['widbcfgerr']); - $err_lvl = 3; - } else { - $err_msg = $lang['wisvsuc']." ".sprintf($lang['wisvres'], ''); - $err_lvl = 0; - $db['type'] = $_POST['dbtype']; - $db['host'] = $_POST['dbhost']; - $dbname = $_POST['dbname']; - $db['user'] = $_POST['dbuser']; - $db['pass'] = $_POST['dbpass']; - } - fclose($handle); - } catch (PDOException $e) { - $err_msg = sprintf($lang['widbcfgerr']); - $err_lvl = 3; - } - } elseif(isset($_POST['update'])) { - echo '
    ',$lang['errcsrf'],'
    '; - rem_session_ts3(); - exit; - } - ?> + ?>'; + $dbserver = $_POST['dbtype'].':host='.$_POST['dbhost'].';dbname='.$_POST['dbname'].';charset=utf8mb4'; + try { + $mysqlcon = new PDO($dbserver, $_POST['dbuser'], $_POST['dbpass']); + $handle = fopen('../other/dbconfig.php', 'w'); + if (! fwrite($handle, $newconfig)) { + $err_msg = sprintf($lang['widbcfgerr']); + $err_lvl = 3; + } else { + $err_msg = $lang['wisvsuc'].' '.sprintf($lang['wisvres'], '
    '); + $err_lvl = 0; + $db['type'] = $_POST['dbtype']; + $db['host'] = $_POST['dbhost']; + $dbname = $_POST['dbname']; + $db['user'] = $_POST['dbuser']; + $db['pass'] = $_POST['dbpass']; + } + fclose($handle); + } catch (PDOException $e) { + $err_msg = sprintf($lang['widbcfgerr']); + $err_lvl = 3; + } + } elseif (isset($_POST['update'])) { + echo '
    ',$lang['errcsrf'],'
    '; + rem_session_ts3(); + exit; + } + ?>
    - +

    - +

    - +
    @@ -75,20 +76,56 @@
    @@ -154,10 +191,10 @@
    @@ -170,10 +207,10 @@ @@ -186,10 +223,10 @@ @@ -202,10 +239,10 @@ @@ -218,10 +255,10 @@ @@ -242,6 +279,7 @@ - \ No newline at end of file diff --git a/webinterface/download_file.php b/webinterface/download_file.php index 4033db7..22bfcaa 100644 --- a/webinterface/download_file.php +++ b/webinterface/download_file.php @@ -1,31 +1,32 @@ -exec("INSERT INTO `$dbname`.`csrf_token` (`token`,`timestamp`,`sessionid`) VALUES ('$csrf_token','".time()."','".session_id()."')") === false) { - $err_msg = $lang['isntwidbmsg'].print_r($mysqlcon->errorInfo(), true); - $err_lvl = 3; - } - - if (($db_csrf = $mysqlcon->query("SELECT * FROM `$dbname`.`csrf_token` WHERE `sessionid`='".session_id()."'")->fetchALL(PDO::FETCH_UNIQUE|PDO::FETCH_ASSOC)) === false) { - $err_msg = $lang['isntwidbmsg'].print_r($mysqlcon->errorInfo(), true); - $err_lvl = 3; - } - - if (isset($db_csrf[$_GET['csrf_token']]) && isset($_GET['file']) && substr($_GET['file'],0,10) == "db_export_" && file_exists($GLOBALS['logpath'].$_GET['file']) && isset($_SESSION[$rspathhex.'username']) && hash_equals($_SESSION[$rspathhex.'username'], $cfg['webinterface_user']) && hash_equals($_SESSION[$rspathhex.'password'], $cfg['webinterface_pass'])) { - header('Content-Description: File Transfer'); - header('Content-Type: application/octet-stream'); - header('Content-Disposition: attachment; filename="'.basename($GLOBALS['logpath'].$_GET['file']).'"'); - header('Expires: 0'); - header('Cache-Control: must-revalidate'); - header('Pragma: public'); - header('Content-Length: ' . filesize($GLOBALS['logpath'].$_GET['file'])); - readfile($GLOBALS['logpath'].$_GET['file']); - } else { - rem_session_ts3(); - echo "Error on downloading file. File do not exists (anymore)? If yes, try it again. There could happened a problem with your session."; - } - ?> -exec("INSERT INTO `$dbname`.`csrf_token` (`token`,`timestamp`,`sessionid`) VALUES ('$csrf_token','".time()."','".session_id()."')") === false) { + $err_msg = $lang['isntwidbmsg'].print_r($mysqlcon->errorInfo(), true); + $err_lvl = 3; + } + + if (($db_csrf = $mysqlcon->query("SELECT * FROM `$dbname`.`csrf_token` WHERE `sessionid`='".session_id()."'")->fetchALL(PDO::FETCH_UNIQUE | PDO::FETCH_ASSOC)) === false) { + $err_msg = $lang['isntwidbmsg'].print_r($mysqlcon->errorInfo(), true); + $err_lvl = 3; + } + + if (isset($db_csrf[$_GET['csrf_token']]) && isset($_GET['file']) && substr($_GET['file'], 0, 10) == 'db_export_' && file_exists($GLOBALS['logpath'].$_GET['file']) && isset($_SESSION[$rspathhex.'username']) && hash_equals($_SESSION[$rspathhex.'username'], $cfg['webinterface_user']) && hash_equals($_SESSION[$rspathhex.'password'], $cfg['webinterface_pass'])) { + header('Content-Description: File Transfer'); + header('Content-Type: application/octet-stream'); + header('Content-Disposition: attachment; filename="'.basename($GLOBALS['logpath'].$_GET['file']).'"'); + header('Expires: 0'); + header('Cache-Control: must-revalidate'); + header('Pragma: public'); + header('Content-Length: '.filesize($GLOBALS['logpath'].$_GET['file'])); + readfile($GLOBALS['logpath'].$_GET['file']); + } else { + rem_session_ts3(); + echo 'Error on downloading file. File do not exists (anymore)? If yes, try it again. There could happened a problem with your session.'; + } + ?> + \ No newline at end of file diff --git a/webinterface/except.php b/webinterface/except.php index 045a53f..7389430 100644 --- a/webinterface/except.php +++ b/webinterface/except.php @@ -1,78 +1,85 @@ -exec("INSERT INTO `$dbname`.`csrf_token` (`token`,`timestamp`,`sessionid`) VALUES ('$csrf_token','".time()."','".session_id()."')") === false) { - $err_msg = print_r($mysqlcon->errorInfo(), true); - $err_lvl = 3; - } - - if (($db_csrf = $mysqlcon->query("SELECT * FROM `$dbname`.`csrf_token` WHERE `sessionid`='".session_id()."'")->fetchALL(PDO::FETCH_UNIQUE|PDO::FETCH_ASSOC)) === false) { - $err_msg = print_r($mysqlcon->errorInfo(), true); - $err_lvl = 3; - } - - if(($groupslist = $mysqlcon->query("SELECT * FROM `$dbname`.`groups` ORDER BY `sortid`,`sgidname` ASC")->fetchAll(PDO::FETCH_UNIQUE|PDO::FETCH_ASSOC)) === false) { - $err_msg = print_r($mysqlcon->errorInfo(), true); - $err_lvl = 3; - } - - if(($channellist = $mysqlcon->query("SELECT * FROM `$dbname`.`channel` ORDER BY `pid`,`channel_order`,`channel_name` ASC")->fetchAll(PDO::FETCH_UNIQUE|PDO::FETCH_ASSOC)) === false) { - $err_msg = print_r($mysqlcon->errorInfo(), true); - $err_lvl = 3; - } - - if(($user_arr = $mysqlcon->query("SELECT `uuid`,`cldbid`,`name` FROM `$dbname`.`user` ORDER BY `name` ASC")->fetchAll(PDO::FETCH_ASSOC)) === false) { - $err_msg = "DB Error1: ".print_r($mysqlcon->errorInfo(), true); $err_lvl = 3; - } - - if (isset($_POST['update']) && isset($db_csrf[$_POST['csrf_token']])) { - $err_msg = $cfg['rankup_excepted_group_id_list'] = $cfg['rankup_excepted_unique_client_id_list'] = $cfg['rankup_excepted_channel_id_list'] = ''; - $errcnf = 0; - $cfg['rankup_excepted_mode'] = $_POST['rankup_excepted_mode']; - - if (isset($_POST['rankup_excepted_unique_client_id_list']) && $_POST['rankup_excepted_unique_client_id_list'] != NULL) { - $cfg['rankup_excepted_unique_client_id_list'] = implode(',',$_POST['rankup_excepted_unique_client_id_list']); - } - if (isset($_POST['rankup_excepted_group_id_list']) && $_POST['rankup_excepted_group_id_list'] != NULL) { - $cfg['rankup_excepted_group_id_list'] = implode(',',$_POST['rankup_excepted_group_id_list']); - } - if (isset($_POST['channelid']) && $_POST['channelid'] != NULL) { - $cfg['rankup_excepted_channel_id_list'] = implode(',',$_POST['channelid']); - } - if (isset($_POST['rankup_excepted_remove_group_switch'])) $cfg['rankup_excepted_remove_group_switch'] = 1; else $cfg['rankup_excepted_remove_group_switch'] = 0; - - if($errcnf == 0) { - if ($mysqlcon->exec("INSERT INTO `$dbname`.`cfg_params` (`param`,`value`) VALUES ('rankup_excepted_mode','{$cfg['rankup_excepted_mode']}'),('rankup_excepted_unique_client_id_list','{$cfg['rankup_excepted_unique_client_id_list']}'),('rankup_excepted_group_id_list','{$cfg['rankup_excepted_group_id_list']}'),('rankup_excepted_channel_id_list','{$cfg['rankup_excepted_channel_id_list']}'),('rankup_excepted_remove_group_switch','{$cfg['rankup_excepted_remove_group_switch']}') ON DUPLICATE KEY UPDATE `value`=VALUES(`value`); DELETE FROM `$dbname`.`csrf_token` WHERE `token`='{$_POST['csrf_token']}'") === false) { - $err_msg = print_r($mysqlcon->errorInfo(), true); - $err_lvl = 3; - } else { - $err_msg = $lang['wisvsuc']." ".sprintf($lang['wisvres'], ''); - $err_lvl = NULL; - } - } else { - $err_msg .= "
    ".$lang['errgrpid']; - } - - if (isset($_POST['rankup_excepted_unique_client_id_list']) && $_POST['rankup_excepted_unique_client_id_list'] != NULL) { - $cfg['rankup_excepted_unique_client_id_list'] = array_flip($_POST['rankup_excepted_unique_client_id_list']); - } - if (isset($_POST['rankup_excepted_group_id_list']) && $_POST['rankup_excepted_group_id_list'] != NULL) { - $cfg['rankup_excepted_group_id_list'] = array_flip($_POST['rankup_excepted_group_id_list']); - } - if (isset($_POST['channelid']) && $_POST['channelid'] != NULL) { - $cfg['rankup_excepted_channel_id_list'] = array_flip($_POST['channelid']); - } - } elseif(isset($_POST['update'])) { - echo '
    ',$lang['errcsrf'],'
    '; - rem_session_ts3(); - exit; - } - ?> +exec("INSERT INTO `$dbname`.`csrf_token` (`token`,`timestamp`,`sessionid`) VALUES ('$csrf_token','".time()."','".session_id()."')") === false) { + $err_msg = print_r($mysqlcon->errorInfo(), true); + $err_lvl = 3; + } + + if (($db_csrf = $mysqlcon->query("SELECT * FROM `$dbname`.`csrf_token` WHERE `sessionid`='".session_id()."'")->fetchALL(PDO::FETCH_UNIQUE | PDO::FETCH_ASSOC)) === false) { + $err_msg = print_r($mysqlcon->errorInfo(), true); + $err_lvl = 3; + } + + if (($groupslist = $mysqlcon->query("SELECT * FROM `$dbname`.`groups` ORDER BY `sortid`,`sgidname` ASC")->fetchAll(PDO::FETCH_UNIQUE | PDO::FETCH_ASSOC)) === false) { + $err_msg = print_r($mysqlcon->errorInfo(), true); + $err_lvl = 3; + } + + if (($channellist = $mysqlcon->query("SELECT * FROM `$dbname`.`channel` ORDER BY `pid`,`channel_order`,`channel_name` ASC")->fetchAll(PDO::FETCH_UNIQUE | PDO::FETCH_ASSOC)) === false) { + $err_msg = print_r($mysqlcon->errorInfo(), true); + $err_lvl = 3; + } + + if (($user_arr = $mysqlcon->query("SELECT `uuid`,`cldbid`,`name` FROM `$dbname`.`user` ORDER BY `name` ASC")->fetchAll(PDO::FETCH_ASSOC)) === false) { + $err_msg = 'DB Error1: '.print_r($mysqlcon->errorInfo(), true); + $err_lvl = 3; + } + + if (isset($_POST['update']) && isset($db_csrf[$_POST['csrf_token']])) { + $err_msg = $cfg['rankup_excepted_group_id_list'] = $cfg['rankup_excepted_unique_client_id_list'] = $cfg['rankup_excepted_channel_id_list'] = ''; + $errcnf = 0; + $cfg['rankup_excepted_mode'] = $_POST['rankup_excepted_mode']; + + if (isset($_POST['rankup_excepted_unique_client_id_list']) && $_POST['rankup_excepted_unique_client_id_list'] != null) { + $cfg['rankup_excepted_unique_client_id_list'] = implode(',', $_POST['rankup_excepted_unique_client_id_list']); + } + if (isset($_POST['rankup_excepted_group_id_list']) && $_POST['rankup_excepted_group_id_list'] != null) { + $cfg['rankup_excepted_group_id_list'] = implode(',', $_POST['rankup_excepted_group_id_list']); + } + if (isset($_POST['channelid']) && $_POST['channelid'] != null) { + $cfg['rankup_excepted_channel_id_list'] = implode(',', $_POST['channelid']); + } + if (isset($_POST['rankup_excepted_remove_group_switch'])) { + $cfg['rankup_excepted_remove_group_switch'] = 1; + } else { + $cfg['rankup_excepted_remove_group_switch'] = 0; + } + + if ($errcnf == 0) { + if ($mysqlcon->exec("INSERT INTO `$dbname`.`cfg_params` (`param`,`value`) VALUES ('rankup_excepted_mode','{$cfg['rankup_excepted_mode']}'),('rankup_excepted_unique_client_id_list','{$cfg['rankup_excepted_unique_client_id_list']}'),('rankup_excepted_group_id_list','{$cfg['rankup_excepted_group_id_list']}'),('rankup_excepted_channel_id_list','{$cfg['rankup_excepted_channel_id_list']}'),('rankup_excepted_remove_group_switch','{$cfg['rankup_excepted_remove_group_switch']}') ON DUPLICATE KEY UPDATE `value`=VALUES(`value`); DELETE FROM `$dbname`.`csrf_token` WHERE `token`='{$_POST['csrf_token']}'") === false) { + $err_msg = print_r($mysqlcon->errorInfo(), true); + $err_lvl = 3; + } else { + $err_msg = $lang['wisvsuc'].' '.sprintf($lang['wisvres'], '
    '); + $err_lvl = null; + } + } else { + $err_msg .= '
    '.$lang['errgrpid']; + } + + if (isset($_POST['rankup_excepted_unique_client_id_list']) && $_POST['rankup_excepted_unique_client_id_list'] != null) { + $cfg['rankup_excepted_unique_client_id_list'] = array_flip($_POST['rankup_excepted_unique_client_id_list']); + } + if (isset($_POST['rankup_excepted_group_id_list']) && $_POST['rankup_excepted_group_id_list'] != null) { + $cfg['rankup_excepted_group_id_list'] = array_flip($_POST['rankup_excepted_group_id_list']); + } + if (isset($_POST['channelid']) && $_POST['channelid'] != null) { + $cfg['rankup_excepted_channel_id_list'] = array_flip($_POST['channelid']); + } + } elseif (isset($_POST['update'])) { + echo '
    ',$lang['errcsrf'],'
    '; + rem_session_ts3(); + exit; + } + ?>
    - +
    @@ -80,7 +87,7 @@
    - +
    @@ -90,11 +97,20 @@
    @@ -103,12 +119,16 @@
    @@ -116,18 +136,36 @@
    @@ -137,9 +175,9 @@
    - +
    @@ -147,11 +185,11 @@
    - '; - } else { - echo ''; - } ?> + '; + } else { + echo ''; + } ?>
    @@ -177,10 +215,10 @@ @@ -193,10 +231,10 @@ @@ -209,10 +247,10 @@ @@ -225,10 +263,10 @@ @@ -241,10 +279,10 @@ @@ -266,6 +304,7 @@ - \ No newline at end of file diff --git a/webinterface/export.php b/webinterface/export.php index d8c3a9a..8ca5d2a 100644 --- a/webinterface/export.php +++ b/webinterface/export.php @@ -1,127 +1,137 @@ -exec("INSERT INTO `$dbname`.`csrf_token` (`token`,`timestamp`,`sessionid`) VALUES ('$csrf_token','".time()."','".session_id()."')") === false) { - $err_msg = $lang['isntwidbmsg'].print_r($mysqlcon->errorInfo(), true); - $err_lvl = 3; - } - - if (($db_csrf = $mysqlcon->query("SELECT * FROM `$dbname`.`csrf_token` WHERE `sessionid`='".session_id()."'")->fetchALL(PDO::FETCH_UNIQUE|PDO::FETCH_ASSOC)) === false) { - $err_msg = $lang['isntwidbmsg'].print_r($mysqlcon->errorInfo(), true); - $err_lvl = 3; - } - - if(!is_int($job_check['database_export']['timestamp'])) { - $job_check['database_export']['timestamp'] = intval($job_check['database_export']['timestamp']); - } - function get_status($lang, $job_check, $check = NULL) { - $err_msg = "".$lang['wihladmex'].": "; - switch($job_check['database_export']['timestamp']) { - case 1: - if($check == 1) { - $err_msg .= $lang['wihladmrs16']."
    "; break; - } else { - $err_msg .= $lang['wihladmrs1']."
    "; break; - } - case 2: - $err_msg .= "".$lang['wihladmrs2']."
    "; break; - case 3: - $err_msg .= "".$lang['wihladmrs3']."
    "; break; - case 4: - $err_msg .= "".$lang['wihladmrs4']."
    "; break; - default: - $err_msg .= "".$lang['wihladmrs0']."
    "; - } - - return $err_msg; - } - - if($job_check['database_export']['timestamp'] != 0) { - $err_msg = ''.$lang['wihladmrs'].":

    "; $err_lvl = 2;
    -		$err_msg .= get_status($lang, $job_check);
    -
    -		if(in_array($job_check['database_export']['timestamp'], [0,3,4], true)) {
    -			$err_msg .= '

    '; - if($job_check['database_export']['timestamp'] == 4) { - $err_msg .= "Exported file successfully."; - if(version_compare(phpversion(), '7.2', '>=') && version_compare(phpversion("zip"), '1.2.0', '>=')) { - $err_msg .= "
    ".sprintf($lang['wihladmex2'], "")."
    ".$cfg['teamspeak_query_pass']."
    "; - } - } - $err_msg .= '
    '.sprintf($lang['wihladmrs9'], ''); - } else { - $err_msg .= '
    '.sprintf($lang['wihladmrs7'], '
    ').'

    '.$lang['wihladmrs8'].'

    '.sprintf($lang['wihladmrs17'], '
    '); - } - } - - if (isset($_POST['confirm']) && isset($db_csrf[$_POST['csrf_token']])) { - if(in_array($job_check['database_export']['timestamp'], [0,3,4], true)) { - if ($mysqlcon->exec("INSERT INTO `$dbname`.`job_check` (`job_name`,`timestamp`) VALUES ('database_export','0') ON DUPLICATE KEY UPDATE `timestamp`=VALUES(`timestamp`); DELETE FROM `$dbname`.`csrf_token` WHERE `token`='{$_POST['csrf_token']}'") === false) { - $err_msg = $lang['isntwidbmsg'].print_r($mysqlcon->errorInfo(), true); - $err_lvl = 3; - } else { - $err_msg = $lang['wihladmrs10']; - $err_lvl = NULL; - } - } else { - $err_msg = $lang['errukwn']; - $err_lvl = 3; - } - } elseif (isset($_POST['cancel']) && isset($db_csrf[$_POST['csrf_token']])) { - if(in_array($job_check['database_export']['timestamp'], [0,1,2,4], true)) { - if ($mysqlcon->exec("INSERT INTO `$dbname`.`job_check` (`job_name`,`timestamp`) VALUES ('database_export','3') ON DUPLICATE KEY UPDATE `timestamp`=VALUES(`timestamp`); DELETE FROM `$dbname`.`csrf_token` WHERE `token`='{$_POST['csrf_token']}'") === false) { - $err_msg = $lang['isntwidbmsg'].print_r($mysqlcon->errorInfo(), true); - $err_lvl = 3; - } else { - $err_msg = $lang['wihladmrs18']; - $err_lvl = NULL; - } - } else { - $err_msg = $lang['errukwn']; - $err_lvl = 3; - } - } elseif (isset($_POST['delete']) && isset($db_csrf[$_POST['csrf_token']])) { - if(substr($_POST['delete'],0,10) == "db_export_" && unlink($GLOBALS['logpath'].$_POST['delete'])) { - $err_msg = sprintf($lang['wihladmex3'], $_POST['delete']); - $err_lvl = NULL; - } else { - $err_msg = sprintf($lang['wihladmex4'], $_POST['delete']); - $err_lvl = 3; - } - } elseif (isset($_POST['download']) && isset($db_csrf[$_POST['csrf_token']])) { - $err_msg = "download request: ".$_POST['download']; - $err_lvl = 3; - } elseif (isset($_POST['export']) && isset($db_csrf[$_POST['csrf_token']])) { - if ($mysqlcon->exec("INSERT INTO `$dbname`.`job_check` (`job_name`,`timestamp`) VALUES ('database_export','1') ON DUPLICATE KEY UPDATE `timestamp`=VALUES(`timestamp`); DELETE FROM `$dbname`.`csrf_token` WHERE `token`='{$_POST['csrf_token']}'") === false) { - $err_msg = $lang['isntwidbmsg'].print_r($mysqlcon->errorInfo(), true); - $err_lvl = 3; - } else { - $err_msg = ''.$lang['wihladmex1'].'

    '.sprintf($lang['wihladmrs7'], '
    ').'

    '.$lang['wihladmrs8']; - if(($snapshot = $mysqlcon->query("SELECT COUNT(*) AS `count` from `$dbname`.`user_snapshot`")->fetch()) === false) { } else { - $est_time = round($snapshot['count'] * 0.00005) + 5; - $dtF = new \DateTime('@0'); - $dtT = new \DateTime("@$est_time"); - $est_time = $dtF->diff($dtT)->format($cfg['default_date_format']); - $err_msg .= '

    '.$lang['wihladmrs11'].': '.$est_time.'.
    '; - } - $err_lvl = NULL; - } - } elseif(isset($_POST['update'])) { - echo '
    ',$lang['errcsrf'],'
    '; - rem_session_ts3(); - exit; - } - ?> +exec("INSERT INTO `$dbname`.`csrf_token` (`token`,`timestamp`,`sessionid`) VALUES ('$csrf_token','".time()."','".session_id()."')") === false) { + $err_msg = $lang['isntwidbmsg'].print_r($mysqlcon->errorInfo(), true); + $err_lvl = 3; + } + + if (($db_csrf = $mysqlcon->query("SELECT * FROM `$dbname`.`csrf_token` WHERE `sessionid`='".session_id()."'")->fetchALL(PDO::FETCH_UNIQUE | PDO::FETCH_ASSOC)) === false) { + $err_msg = $lang['isntwidbmsg'].print_r($mysqlcon->errorInfo(), true); + $err_lvl = 3; + } + + if (! is_int($job_check['database_export']['timestamp'])) { + $job_check['database_export']['timestamp'] = intval($job_check['database_export']['timestamp']); + } + function get_status($lang, $job_check, $check = null) + { + $err_msg = ''.$lang['wihladmex'].': '; + switch($job_check['database_export']['timestamp']) { + case 1: + if ($check == 1) { + $err_msg .= $lang['wihladmrs16'].'
    '; + break; + } else { + $err_msg .= $lang['wihladmrs1'].'
    '; + break; + } + case 2: + $err_msg .= ''.$lang['wihladmrs2'].'
    '; + break; + case 3: + $err_msg .= ''.$lang['wihladmrs3'].'
    '; + break; + case 4: + $err_msg .= ''.$lang['wihladmrs4'].'
    '; + break; + default: + $err_msg .= ''.$lang['wihladmrs0'].'
    '; + } + + return $err_msg; + } + + if ($job_check['database_export']['timestamp'] != 0) { + $err_msg = ''.$lang['wihladmrs'].':

    ';
    +        $err_lvl = 2;
    +        $err_msg .= get_status($lang, $job_check);
    +
    +        if (in_array($job_check['database_export']['timestamp'], [0, 3, 4], true)) {
    +            $err_msg .= '

    '; + if ($job_check['database_export']['timestamp'] == 4) { + $err_msg .= 'Exported file successfully.'; + if (version_compare(phpversion(), '7.2', '>=') && version_compare(phpversion('zip'), '1.2.0', '>=')) { + $err_msg .= '
    '.sprintf($lang['wihladmex2'], '').'
    '.$cfg['teamspeak_query_pass'].'
    '; + } + } + $err_msg .= '
    '.sprintf($lang['wihladmrs9'], '
    '); + } else { + $err_msg .= '
    '.sprintf($lang['wihladmrs7'], '
    ').'

    '.$lang['wihladmrs8'].'

    '.sprintf($lang['wihladmrs17'], '
    '); + } + } + + if (isset($_POST['confirm']) && isset($db_csrf[$_POST['csrf_token']])) { + if (in_array($job_check['database_export']['timestamp'], [0, 3, 4], true)) { + if ($mysqlcon->exec("INSERT INTO `$dbname`.`job_check` (`job_name`,`timestamp`) VALUES ('database_export','0') ON DUPLICATE KEY UPDATE `timestamp`=VALUES(`timestamp`); DELETE FROM `$dbname`.`csrf_token` WHERE `token`='{$_POST['csrf_token']}'") === false) { + $err_msg = $lang['isntwidbmsg'].print_r($mysqlcon->errorInfo(), true); + $err_lvl = 3; + } else { + $err_msg = $lang['wihladmrs10']; + $err_lvl = null; + } + } else { + $err_msg = $lang['errukwn']; + $err_lvl = 3; + } + } elseif (isset($_POST['cancel']) && isset($db_csrf[$_POST['csrf_token']])) { + if (in_array($job_check['database_export']['timestamp'], [0, 1, 2, 4], true)) { + if ($mysqlcon->exec("INSERT INTO `$dbname`.`job_check` (`job_name`,`timestamp`) VALUES ('database_export','3') ON DUPLICATE KEY UPDATE `timestamp`=VALUES(`timestamp`); DELETE FROM `$dbname`.`csrf_token` WHERE `token`='{$_POST['csrf_token']}'") === false) { + $err_msg = $lang['isntwidbmsg'].print_r($mysqlcon->errorInfo(), true); + $err_lvl = 3; + } else { + $err_msg = $lang['wihladmrs18']; + $err_lvl = null; + } + } else { + $err_msg = $lang['errukwn']; + $err_lvl = 3; + } + } elseif (isset($_POST['delete']) && isset($db_csrf[$_POST['csrf_token']])) { + if (substr($_POST['delete'], 0, 10) == 'db_export_' && unlink($GLOBALS['logpath'].$_POST['delete'])) { + $err_msg = sprintf($lang['wihladmex3'], $_POST['delete']); + $err_lvl = null; + } else { + $err_msg = sprintf($lang['wihladmex4'], $_POST['delete']); + $err_lvl = 3; + } + } elseif (isset($_POST['download']) && isset($db_csrf[$_POST['csrf_token']])) { + $err_msg = 'download request: '.$_POST['download']; + $err_lvl = 3; + } elseif (isset($_POST['export']) && isset($db_csrf[$_POST['csrf_token']])) { + if ($mysqlcon->exec("INSERT INTO `$dbname`.`job_check` (`job_name`,`timestamp`) VALUES ('database_export','1') ON DUPLICATE KEY UPDATE `timestamp`=VALUES(`timestamp`); DELETE FROM `$dbname`.`csrf_token` WHERE `token`='{$_POST['csrf_token']}'") === false) { + $err_msg = $lang['isntwidbmsg'].print_r($mysqlcon->errorInfo(), true); + $err_lvl = 3; + } else { + $err_msg = ''.$lang['wihladmex1'].'

    '.sprintf($lang['wihladmrs7'], '
    ').'

    '.$lang['wihladmrs8']; + if (($snapshot = $mysqlcon->query("SELECT COUNT(*) AS `count` from `$dbname`.`user_snapshot`")->fetch()) === false) { + } else { + $est_time = round($snapshot['count'] * 0.00005) + 5; + $dtF = new \DateTime('@0'); + $dtT = new \DateTime("@$est_time"); + $est_time = $dtF->diff($dtT)->format($cfg['default_date_format']); + $err_msg .= '

    '.$lang['wihladmrs11'].': '.$est_time.'.
    '; + } + $err_lvl = null; + } + } elseif (isset($_POST['update'])) { + echo '
    ',$lang['errcsrf'],'
    '; + rem_session_ts3(); + exit; + } + ?>
    - +

    - +

    @@ -135,61 +145,69 @@ function get_status($lang, $job_check, $check = NULL) {
     
    - +
    - +
    - +
    - +
    - +
    - +
    - +
    -
    - - - - - + + + + + + - +
    - +
    @@ -197,7 +215,7 @@ function get_status($lang, $job_check, $check = NULL) {
     
    - +
    @@ -218,16 +236,17 @@ function get_status($lang, $job_check, $check = NULL) {
    - \ No newline at end of file diff --git a/webinterface/imprint.php b/webinterface/imprint.php index bd79e4f..c6b2265 100644 --- a/webinterface/imprint.php +++ b/webinterface/imprint.php @@ -1,58 +1,64 @@ -exec("INSERT INTO `$dbname`.`csrf_token` (`token`,`timestamp`,`sessionid`) VALUES ('$csrf_token','".time()."','".session_id()."')") === false) { - $err_msg = print_r($mysqlcon->errorInfo(), true); - $err_lvl = 3; - } - - if (($db_csrf = $mysqlcon->query("SELECT * FROM `$dbname`.`csrf_token` WHERE `sessionid`='".session_id()."'")->fetchALL(PDO::FETCH_UNIQUE|PDO::FETCH_ASSOC)) === false) { - $err_msg = print_r($mysqlcon->errorInfo(), true); - $err_lvl = 3; - } - - if (isset($_POST['update']) && isset($db_csrf[$_POST['csrf_token']])) { - $cfg['stats_imprint_address'] = addslashes($_POST['stats_imprint_address']); - $cfg['stats_imprint_address_url'] = addslashes($_POST['stats_imprint_address_url']); - $cfg['stats_imprint_email'] = addslashes($_POST['stats_imprint_email']); - $cfg['stats_imprint_phone'] = addslashes($_POST['stats_imprint_phone']); - $cfg['stats_imprint_notes'] = addslashes($_POST['stats_imprint_notes']); - $cfg['stats_imprint_privacypolicy'] = addslashes($_POST['stats_imprint_privacypolicy']); - $cfg['stats_imprint_privacypolicy_url'] = addslashes($_POST['stats_imprint_privacypolicy_url']); - if (isset($_POST['stats_imprint_switch'])) $cfg['stats_imprint_switch'] = 1; else $cfg['stats_imprint_switch'] = 0; - if ($mysqlcon->exec("INSERT INTO `$dbname`.`cfg_params` (`param`,`value`) VALUES ('stats_imprint_switch','{$cfg['stats_imprint_switch']}'),('stats_imprint_address','{$cfg['stats_imprint_address']}'),('stats_imprint_address_url','{$cfg['stats_imprint_address_url']}'),('stats_imprint_email','{$cfg['stats_imprint_email']}'),('stats_imprint_phone','{$cfg['stats_imprint_phone']}'),('stats_imprint_notes','{$cfg['stats_imprint_notes']}'),('stats_imprint_privacypolicy','{$cfg['stats_imprint_privacypolicy']}'),('stats_imprint_privacypolicy_url','{$cfg['stats_imprint_privacypolicy_url']}') ON DUPLICATE KEY UPDATE `value`=VALUES(`value`); DELETE FROM `$dbname`.`csrf_token` WHERE `token`='{$_POST['csrf_token']}'") === false) { - $err_msg = print_r($mysqlcon->errorInfo(), true); - $err_lvl = 3; - } else { - $err_msg = $lang['wisvsuc']; - $err_lvl = NULL; - } - $cfg['stats_imprint_address'] = $_POST['stats_imprint_address']; - $cfg['stats_imprint_email'] = $_POST['stats_imprint_email']; - $cfg['stats_imprint_phone'] = $_POST['stats_imprint_phone']; - $cfg['stats_imprint_notes'] = $_POST['stats_imprint_notes']; - $cfg['stats_imprint_privacypolicy'] = $_POST['stats_imprint_privacypolicy']; - } elseif(isset($_POST['update'])) { - echo '
    ',$lang['errcsrf'],'
    '; - rem_session_ts3(); - exit; - } - ?> +exec("INSERT INTO `$dbname`.`csrf_token` (`token`,`timestamp`,`sessionid`) VALUES ('$csrf_token','".time()."','".session_id()."')") === false) { + $err_msg = print_r($mysqlcon->errorInfo(), true); + $err_lvl = 3; + } + + if (($db_csrf = $mysqlcon->query("SELECT * FROM `$dbname`.`csrf_token` WHERE `sessionid`='".session_id()."'")->fetchALL(PDO::FETCH_UNIQUE | PDO::FETCH_ASSOC)) === false) { + $err_msg = print_r($mysqlcon->errorInfo(), true); + $err_lvl = 3; + } + + if (isset($_POST['update']) && isset($db_csrf[$_POST['csrf_token']])) { + $cfg['stats_imprint_address'] = addslashes($_POST['stats_imprint_address']); + $cfg['stats_imprint_address_url'] = addslashes($_POST['stats_imprint_address_url']); + $cfg['stats_imprint_email'] = addslashes($_POST['stats_imprint_email']); + $cfg['stats_imprint_phone'] = addslashes($_POST['stats_imprint_phone']); + $cfg['stats_imprint_notes'] = addslashes($_POST['stats_imprint_notes']); + $cfg['stats_imprint_privacypolicy'] = addslashes($_POST['stats_imprint_privacypolicy']); + $cfg['stats_imprint_privacypolicy_url'] = addslashes($_POST['stats_imprint_privacypolicy_url']); + if (isset($_POST['stats_imprint_switch'])) { + $cfg['stats_imprint_switch'] = 1; + } else { + $cfg['stats_imprint_switch'] = 0; + } + if ($mysqlcon->exec("INSERT INTO `$dbname`.`cfg_params` (`param`,`value`) VALUES ('stats_imprint_switch','{$cfg['stats_imprint_switch']}'),('stats_imprint_address','{$cfg['stats_imprint_address']}'),('stats_imprint_address_url','{$cfg['stats_imprint_address_url']}'),('stats_imprint_email','{$cfg['stats_imprint_email']}'),('stats_imprint_phone','{$cfg['stats_imprint_phone']}'),('stats_imprint_notes','{$cfg['stats_imprint_notes']}'),('stats_imprint_privacypolicy','{$cfg['stats_imprint_privacypolicy']}'),('stats_imprint_privacypolicy_url','{$cfg['stats_imprint_privacypolicy_url']}') ON DUPLICATE KEY UPDATE `value`=VALUES(`value`); DELETE FROM `$dbname`.`csrf_token` WHERE `token`='{$_POST['csrf_token']}'") === false) { + $err_msg = print_r($mysqlcon->errorInfo(), true); + $err_lvl = 3; + } else { + $err_msg = $lang['wisvsuc']; + $err_lvl = null; + } + $cfg['stats_imprint_address'] = $_POST['stats_imprint_address']; + $cfg['stats_imprint_email'] = $_POST['stats_imprint_email']; + $cfg['stats_imprint_phone'] = $_POST['stats_imprint_phone']; + $cfg['stats_imprint_notes'] = $_POST['stats_imprint_notes']; + $cfg['stats_imprint_privacypolicy'] = $_POST['stats_imprint_privacypolicy']; + } elseif (isset($_POST['update'])) { + echo '
    ',$lang['errcsrf'],'
    '; + rem_session_ts3(); + exit; + } + ?>
    - +

    - +

    - +
    @@ -60,17 +66,17 @@
    - '; - } else { - echo ''; - } ?> + '; + } else { + echo ''; + } ?>
    - + '>
    @@ -82,13 +88,13 @@
    - + '>
    - + '>
    @@ -106,7 +112,7 @@
    - + '>
    @@ -139,10 +145,10 @@
    @@ -155,10 +161,10 @@
    @@ -171,10 +177,10 @@
    @@ -187,10 +193,10 @@ @@ -203,10 +209,10 @@ @@ -219,10 +225,10 @@ @@ -235,10 +241,10 @@ @@ -251,10 +257,10 @@ @@ -264,6 +270,7 @@ - \ No newline at end of file diff --git a/webinterface/index.php b/webinterface/index.php index 34523f0..c1fd307 100644 --- a/webinterface/index.php +++ b/webinterface/index.php @@ -1,147 +1,183 @@ -chown -R www-data:www-data '.$GLOBALS['logpath'].'
    ', '
    chmod 0740 '.$GLOBALS['logfile'].'


    ', '
    '.$GLOBALS['logfile'].'
    '); - $err_lvl = 3; $dis_login = 0; - } - - if(!is_writable($GLOBALS['logpath'])) { - $err_msg = sprintf($lang['chkfileperm'], '
    chown -R www-data:www-data '.$GLOBALS['logpath'].'

    ', '
    chmod 0740 '.$GLOBALS['logpath'].'


    ', '
    '.$GLOBALS['logpath'].'
    '); - $err_lvl = 3; $dis_login = 0; - } - - if(!function_exists('exec')) { - unset($err_msg); $err_msg = sprintf($lang['insterr3'],'exec','//php.net/manual/en/book.exec.php',get_cfg_var('cfg_file_path')); $err_lvl = 3; $dis_login = 1; - } else { - exec("$phpcommand -v", $phpversioncheck); - $output = ''; - foreach($phpversioncheck as $line) $output .= print_r($line, true).'
    '; - if(empty($phpversioncheck) || strtoupper(substr($phpversioncheck[0], 0, 3)) != "PHP") { - $err_msg = sprintf($lang['chkphpcmd'], "\"other/phpcommand.php\"", "\"other/phpcommand.php\"", '
    '.$phpcommand.'
    ', '
    '.$output.'


    ', '
    php -v
    '); - $err_lvl = 3; $dis_login = 1; - } else { - $exploded = explode(' ',$phpversioncheck[0]); - if($exploded[1] != phpversion()) { - $err_msg = sprintf($lang['chkphpmulti'], phpversion(), "\"other/phpcommand.php\"", $exploded[1], "\"other/phpcommand.php\"", "\"other/phpcommand.php\"", '
    '.$phpcommand.'
    '); - if(getenv('PATH')!='') { - $err_msg .= "

    ".sprintf($lang['chkphpmulti2'], '
    '.getenv('PATH')); - } - $err_lvl = 2; - } - } - } - - if(!isset($err_msg) && version_compare(PHP_VERSION, '7.2.0', '<')) { - $err_msg = "Your PHP Version: (".PHP_VERSION.") is outdated and no longer supported. Please update it!"; - $err_lvl = 2; - } - - if(!isset($cfg['webinterface_access_count']) || $cfg['webinterface_access_count'] != NULL) $cfg['webinterface_access_count'] = 0; - if(!isset($cfg['webinterface_access_last']) || $cfg['webinterface_access_last'] != NULL) $cfg['webinterface_access_last'] = 0; - - if(($cfg['webinterface_access_last'] + 1) >= time()) { - $waittime = $cfg['webinterface_access_last'] + 2 - time(); - $err_msg = sprintf($lang['errlogin2'],$waittime); - $err_lvl = 3; - } elseif ($cfg['webinterface_access_count'] >= 10) { - enter_logfile(3,sprintf($lang['brute'], getclientip())); - $err_msg = $lang['errlogin3']; - $err_lvl = 3; - $bantime = time() + 299; - if($mysqlcon->exec("INSERT INTO `$dbname`.`cfg_params` (`param`,`value`) VALUES ('webinterface_access_last','{$bantime}'),('webinterface_access_count','0') ON DUPLICATE KEY UPDATE `value`=VALUES(`value`)") === false) { } - } elseif (isset($_POST['username']) && hash_equals($_POST['username'], $cfg['webinterface_user']) && password_verify($_POST['password'], $cfg['webinterface_pass'])) { - $_SESSION[$rspathhex.'username'] = $cfg['webinterface_user']; - $_SESSION[$rspathhex.'password'] = $cfg['webinterface_pass']; - $_SESSION[$rspathhex.'clientip'] = getclientip(); - $_SESSION[$rspathhex.'newversion'] = $cfg['version_latest_available']; - if(isset($cfg['stats_news_html'])) $_SESSION[$rspathhex.'stats_news_html'] = $cfg['stats_news_html']; - enter_logfile(6,sprintf($lang['brute2'], getclientip())); - if($mysqlcon->exec("INSERT INTO `$dbname`.`cfg_params` (`param`,`value`) VALUES ('webinterface_access_count','0') ON DUPLICATE KEY UPDATE `value`=VALUES(`value`)") === false) { } - header("Location: $prot://".$_SERVER['HTTP_HOST'].rtrim(dirname($_SERVER['PHP_SELF']), '/\\')."/bot.php"); - exit; - } elseif(isset($_POST['username'])) { - $nowtime = time(); - enter_logfile(5,sprintf($lang['brute1'], getclientip(), htmlspecialchars($_POST['username']))); - $cfg['webinterface_access_count']++; - if($mysqlcon->exec("INSERT INTO `$dbname`.`cfg_params` (`param`,`value`) VALUES ('webinterface_access_last','{$nowtime}'),('webinterface_access_count','{$cfg['webinterface_access_count']}') ON DUPLICATE KEY UPDATE `value`=VALUES(`value`)") === false) { } - $err_msg = $lang['errlogin']; - $err_lvl = 3; - } - - if(isset($_SESSION[$rspathhex.'username']) && hash_equals($_SESSION[$rspathhex.'username'], $cfg['webinterface_user']) && hash_equals($_SESSION[$rspathhex.'password'], $cfg['webinterface_pass'])) { - header("Location: $prot://".$_SERVER['HTTP_HOST'].rtrim(dirname($_SERVER['PHP_SELF']), '/\\')."/bot.php"); - exit; - } - - require_once('_nav.php'); - ?> +chown -R www-data:www-data '.$GLOBALS['logpath'].'
    ', '
    chmod 0740 '.$GLOBALS['logfile'].'


    ', '
    '.$GLOBALS['logfile'].'
    '); + $err_lvl = 3; + $dis_login = 0; + } + + if (! is_writable($GLOBALS['logpath'])) { + $err_msg = sprintf($lang['chkfileperm'], '
    chown -R www-data:www-data '.$GLOBALS['logpath'].'

    ', '
    chmod 0740 '.$GLOBALS['logpath'].'


    ', '
    '.$GLOBALS['logpath'].'
    '); + $err_lvl = 3; + $dis_login = 0; + } + + if (! function_exists('exec')) { + unset($err_msg); + $err_msg = sprintf($lang['insterr3'], 'exec', '//php.net/manual/en/book.exec.php', get_cfg_var('cfg_file_path')); + $err_lvl = 3; + $dis_login = 1; + } else { + exec("$phpcommand -v", $phpversioncheck); + $output = ''; + foreach ($phpversioncheck as $line) { + $output .= print_r($line, true).'
    '; + } + if (empty($phpversioncheck) || strtoupper(substr($phpversioncheck[0], 0, 3)) != 'PHP') { + $err_msg = sprintf($lang['chkphpcmd'], '"other/phpcommand.php"', '"other/phpcommand.php"', '
    '.$phpcommand.'
    ', '
    '.$output.'


    ', '
    php -v
    '); + $err_lvl = 3; + $dis_login = 1; + } else { + $exploded = explode(' ', $phpversioncheck[0]); + if ($exploded[1] != phpversion()) { + $err_msg = sprintf($lang['chkphpmulti'], phpversion(), '"other/phpcommand.php"', $exploded[1], '"other/phpcommand.php"', '"other/phpcommand.php"', '
    '.$phpcommand.'
    '); + if (getenv('PATH') != '') { + $err_msg .= '

    '.sprintf($lang['chkphpmulti2'], '
    '.getenv('PATH')); + } + $err_lvl = 2; + } + } + } + + if (! isset($err_msg) && version_compare(PHP_VERSION, '7.2.0', '<')) { + $err_msg = 'Your PHP Version: ('.PHP_VERSION.') is outdated and no longer supported. Please update it!'; + $err_lvl = 2; + } + + if (! isset($cfg['webinterface_access_count']) || $cfg['webinterface_access_count'] != null) { + $cfg['webinterface_access_count'] = 0; + } + if (! isset($cfg['webinterface_access_last']) || $cfg['webinterface_access_last'] != null) { + $cfg['webinterface_access_last'] = 0; + } + + if (($cfg['webinterface_access_last'] + 1) >= time()) { + $waittime = $cfg['webinterface_access_last'] + 2 - time(); + $err_msg = sprintf($lang['errlogin2'], $waittime); + $err_lvl = 3; + } elseif ($cfg['webinterface_access_count'] >= 10) { + enter_logfile(3, sprintf($lang['brute'], getclientip())); + $err_msg = $lang['errlogin3']; + $err_lvl = 3; + $bantime = time() + 299; + if ($mysqlcon->exec("INSERT INTO `$dbname`.`cfg_params` (`param`,`value`) VALUES ('webinterface_access_last','{$bantime}'),('webinterface_access_count','0') ON DUPLICATE KEY UPDATE `value`=VALUES(`value`)") === false) { + } + } elseif (isset($_POST['username']) && hash_equals($_POST['username'], $cfg['webinterface_user']) && password_verify($_POST['password'], $cfg['webinterface_pass'])) { + $_SESSION[$rspathhex.'username'] = $cfg['webinterface_user']; + $_SESSION[$rspathhex.'password'] = $cfg['webinterface_pass']; + $_SESSION[$rspathhex.'clientip'] = getclientip(); + $_SESSION[$rspathhex.'newversion'] = $cfg['version_latest_available']; + if (isset($cfg['stats_news_html'])) { + $_SESSION[$rspathhex.'stats_news_html'] = $cfg['stats_news_html']; + } + enter_logfile(6, sprintf($lang['brute2'], getclientip())); + if ($mysqlcon->exec("INSERT INTO `$dbname`.`cfg_params` (`param`,`value`) VALUES ('webinterface_access_count','0') ON DUPLICATE KEY UPDATE `value`=VALUES(`value`)") === false) { + } + header("Location: $prot://".$_SERVER['HTTP_HOST'].rtrim(dirname($_SERVER['PHP_SELF']), '/\\').'/bot.php'); + exit; + } elseif (isset($_POST['username'])) { + $nowtime = time(); + enter_logfile(5, sprintf($lang['brute1'], getclientip(), htmlspecialchars($_POST['username']))); + $cfg['webinterface_access_count']++; + if ($mysqlcon->exec("INSERT INTO `$dbname`.`cfg_params` (`param`,`value`) VALUES ('webinterface_access_last','{$nowtime}'),('webinterface_access_count','{$cfg['webinterface_access_count']}') ON DUPLICATE KEY UPDATE `value`=VALUES(`value`)") === false) { + } + $err_msg = $lang['errlogin']; + $err_lvl = 3; + } + + if (isset($_SESSION[$rspathhex.'username']) && hash_equals($_SESSION[$rspathhex.'username'], $cfg['webinterface_user']) && hash_equals($_SESSION[$rspathhex.'password'], $cfg['webinterface_pass'])) { + header("Location: $prot://".$_SERVER['HTTP_HOST'].rtrim(dirname($_SERVER['PHP_SELF']), '/\\').'/bot.php'); + exit; + } + + require_once '_nav.php'; + ?>
    - +
    @@ -179,10 +194,10 @@
    @@ -195,10 +210,10 @@ @@ -211,10 +226,10 @@ @@ -224,6 +239,7 @@ - \ No newline at end of file diff --git a/webinterface/other.php b/webinterface/other.php index 1e068cc..7416bbf 100644 --- a/webinterface/other.php +++ b/webinterface/other.php @@ -1,93 +1,116 @@ -exec("INSERT INTO `$dbname`.`csrf_token` (`token`,`timestamp`,`sessionid`) VALUES ('$csrf_token','".time()."','".session_id()."')") === false) { - $err_msg = print_r($mysqlcon->errorInfo(), true); - $err_lvl = 3; - } - - if (($db_csrf = $mysqlcon->query("SELECT * FROM `$dbname`.`csrf_token` WHERE `sessionid`='".session_id()."'")->fetchALL(PDO::FETCH_UNIQUE|PDO::FETCH_ASSOC)) === false) { - $err_msg = print_r($mysqlcon->errorInfo(), true); - $err_lvl = 3; - } - - if (isset($_POST['update']) && isset($db_csrf[$_POST['csrf_token']])) { - if ($_POST['rankup_hash_ip_addresses_mode'] != $cfg['rankup_hash_ip_addresses_mode']) { - $err_msg2 = $lang['wisvinfo1']; - $err_lvl2 = 2; - } - $cfg['rankup_hash_ip_addresses_mode'] = $_POST['rankup_hash_ip_addresses_mode']; - $cfg['default_session_sametime'] = $_POST['default_session_sametime']; - $cfg['default_header_origin'] = htmlspecialchars($_POST['default_header_origin'], ENT_QUOTES); - $cfg['default_header_xss'] = htmlspecialchars($_POST['default_header_xss'], ENT_QUOTES); - if (isset($_POST['default_header_contenttyp'])) $cfg['default_header_contenttyp'] = 1; else $cfg['default_header_contenttyp'] = 0; - $cfg['default_header_frame'] = htmlspecialchars($_POST['default_header_frame'], ENT_QUOTES); - if (isset($_POST['default_cmdline_sec_switch'])) $cfg['default_cmdline_sec_switch'] = 1; else $cfg['default_cmdline_sec_switch'] = 0; - $cfg['logs_timezone'] = $_POST['logs_timezone']; - $cfg['default_date_format'] = $_POST['default_date_format']; - $cfg['logs_path'] = addslashes($_POST['logs_path']); - $cfg['logs_debug_level'] = $_POST['logs_debug_level']; - $cfg['logs_rotation_size'] = $_POST['logs_rotation_size']; - $cfg['default_language'] = $_SESSION[$rspathhex.'language'] = $_POST['default_language']; - unset($lang); $lang = set_language($cfg['default_language']); - $cfg['version_update_channel'] = $_POST['version_update_channel']; - if (isset($_POST['rankup_client_database_id_change_switch'])) $cfg['rankup_client_database_id_change_switch'] = 1; else $cfg['rankup_client_database_id_change_switch'] = 0; - if (isset($_POST['rankup_clean_clients_switch'])) $cfg['rankup_clean_clients_switch'] = 1; else $cfg['rankup_clean_clients_switch'] = 0; - $cfg['rankup_clean_clients_period'] = $_POST['rankup_clean_clients_period']; - - if ($mysqlcon->exec("INSERT INTO `$dbname`.`cfg_params` (`param`,`value`) VALUES ('logs_timezone','{$cfg['logs_timezone']}'),('default_date_format','{$cfg['default_date_format']}'),('logs_path','{$cfg['logs_path']}'),('logs_debug_level','{$cfg['logs_debug_level']}'),('logs_rotation_size','{$cfg['logs_rotation_size']}'),('default_language','{$cfg['default_language']}'),('default_style','{$cfg['default_style']}'),('version_update_channel','{$cfg['version_update_channel']}'),('rankup_hash_ip_addresses_mode','{$cfg['rankup_hash_ip_addresses_mode']}'),('default_session_sametime','{$cfg['default_session_sametime']}'),('default_header_origin','{$cfg['default_header_origin']}'),('default_header_xss','{$cfg['default_header_xss']}'),('default_header_contenttyp','{$cfg['default_header_contenttyp']}'),('default_header_frame','{$cfg['default_header_frame']}'),('default_cmdline_sec_switch','{$cfg['default_cmdline_sec_switch']}'),('rankup_client_database_id_change_switch','{$cfg['rankup_client_database_id_change_switch']}'),('rankup_clean_clients_switch','{$cfg['rankup_clean_clients_switch']}'),('rankup_clean_clients_period','{$cfg['rankup_clean_clients_period']}') ON DUPLICATE KEY UPDATE `value`=VALUES(`value`); DELETE FROM `$dbname`.`csrf_token` WHERE `token`='{$_POST['csrf_token']}'") === false) { - $err_msg = print_r($mysqlcon->errorInfo(), true); - $err_lvl = 3; - } else { - $err_msg = $lang['wisvsuc']." ".sprintf($lang['wisvres'], ''); - $err_lvl = NULL; - } - $cfg['logs_path'] = $_POST['logs_path']; - } elseif(isset($_POST['update'])) { - echo '
    ',$lang['errcsrf'],'
    '; - rem_session_ts3(); - exit; - } - ?> +exec("INSERT INTO `$dbname`.`csrf_token` (`token`,`timestamp`,`sessionid`) VALUES ('$csrf_token','".time()."','".session_id()."')") === false) { + $err_msg = print_r($mysqlcon->errorInfo(), true); + $err_lvl = 3; + } + + if (($db_csrf = $mysqlcon->query("SELECT * FROM `$dbname`.`csrf_token` WHERE `sessionid`='".session_id()."'")->fetchALL(PDO::FETCH_UNIQUE | PDO::FETCH_ASSOC)) === false) { + $err_msg = print_r($mysqlcon->errorInfo(), true); + $err_lvl = 3; + } + + if (isset($_POST['update']) && isset($db_csrf[$_POST['csrf_token']])) { + if ($_POST['rankup_hash_ip_addresses_mode'] != $cfg['rankup_hash_ip_addresses_mode']) { + $err_msg2 = $lang['wisvinfo1']; + $err_lvl2 = 2; + } + $cfg['rankup_hash_ip_addresses_mode'] = $_POST['rankup_hash_ip_addresses_mode']; + $cfg['default_session_sametime'] = $_POST['default_session_sametime']; + $cfg['default_header_origin'] = htmlspecialchars($_POST['default_header_origin'], ENT_QUOTES); + $cfg['default_header_xss'] = htmlspecialchars($_POST['default_header_xss'], ENT_QUOTES); + if (isset($_POST['default_header_contenttyp'])) { + $cfg['default_header_contenttyp'] = 1; + } else { + $cfg['default_header_contenttyp'] = 0; + } + $cfg['default_header_frame'] = htmlspecialchars($_POST['default_header_frame'], ENT_QUOTES); + if (isset($_POST['default_cmdline_sec_switch'])) { + $cfg['default_cmdline_sec_switch'] = 1; + } else { + $cfg['default_cmdline_sec_switch'] = 0; + } + $cfg['logs_timezone'] = $_POST['logs_timezone']; + $cfg['default_date_format'] = $_POST['default_date_format']; + $cfg['logs_path'] = addslashes($_POST['logs_path']); + $cfg['logs_debug_level'] = $_POST['logs_debug_level']; + $cfg['logs_rotation_size'] = $_POST['logs_rotation_size']; + $cfg['default_language'] = $_SESSION[$rspathhex.'language'] = $_POST['default_language']; + unset($lang); + $lang = set_language($cfg['default_language']); + $cfg['version_update_channel'] = $_POST['version_update_channel']; + if (isset($_POST['rankup_client_database_id_change_switch'])) { + $cfg['rankup_client_database_id_change_switch'] = 1; + } else { + $cfg['rankup_client_database_id_change_switch'] = 0; + } + if (isset($_POST['rankup_clean_clients_switch'])) { + $cfg['rankup_clean_clients_switch'] = 1; + } else { + $cfg['rankup_clean_clients_switch'] = 0; + } + $cfg['rankup_clean_clients_period'] = $_POST['rankup_clean_clients_period']; + + if ($mysqlcon->exec("INSERT INTO `$dbname`.`cfg_params` (`param`,`value`) VALUES ('logs_timezone','{$cfg['logs_timezone']}'),('default_date_format','{$cfg['default_date_format']}'),('logs_path','{$cfg['logs_path']}'),('logs_debug_level','{$cfg['logs_debug_level']}'),('logs_rotation_size','{$cfg['logs_rotation_size']}'),('default_language','{$cfg['default_language']}'),('default_style','{$cfg['default_style']}'),('version_update_channel','{$cfg['version_update_channel']}'),('rankup_hash_ip_addresses_mode','{$cfg['rankup_hash_ip_addresses_mode']}'),('default_session_sametime','{$cfg['default_session_sametime']}'),('default_header_origin','{$cfg['default_header_origin']}'),('default_header_xss','{$cfg['default_header_xss']}'),('default_header_contenttyp','{$cfg['default_header_contenttyp']}'),('default_header_frame','{$cfg['default_header_frame']}'),('default_cmdline_sec_switch','{$cfg['default_cmdline_sec_switch']}'),('rankup_client_database_id_change_switch','{$cfg['rankup_client_database_id_change_switch']}'),('rankup_clean_clients_switch','{$cfg['rankup_clean_clients_switch']}'),('rankup_clean_clients_period','{$cfg['rankup_clean_clients_period']}') ON DUPLICATE KEY UPDATE `value`=VALUES(`value`); DELETE FROM `$dbname`.`csrf_token` WHERE `token`='{$_POST['csrf_token']}'") === false) { + $err_msg = print_r($mysqlcon->errorInfo(), true); + $err_lvl = 3; + } else { + $err_msg = $lang['wisvsuc'].' '.sprintf($lang['wisvres'], '
    '); + $err_lvl = null; + } + $cfg['logs_path'] = $_POST['logs_path']; + } elseif (isset($_POST['update'])) { + echo '
    ',$lang['errcsrf'],'
    '; + rem_session_ts3(); + exit; + } + ?>
    - - + +

    - +

    - +
    @@ -95,16 +118,16 @@
    @@ -128,14 +151,14 @@
    @@ -161,24 +184,30 @@
    @@ -187,10 +216,16 @@
    @@ -200,12 +235,21 @@
    @@ -216,59 +260,59 @@
    - '; - echo ''; - echo ''; - echo ''; - echo ''; - ?> + '; + echo ''; + echo ''; + echo ''; + echo ''; + ?>
    - '; - } else { - echo ''; - } ?> + '; + } else { + echo ''; + } ?>
    - '; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - ?> + '; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + ?>
    @@ -277,22 +321,22 @@
    - '; - } else { - echo ''; - } ?> + '; + } else { + echo ''; + } ?>
     
    - '; - } else { - echo ''; - } ?> + '; + } else { + echo ''; + } ?>
     
    @@ -301,11 +345,11 @@
    - '; - } else { - echo ''; - } ?> + '; + } else { + echo ''; + } ?>
     
    @@ -347,10 +391,10 @@ @@ -363,10 +407,10 @@ @@ -379,10 +423,10 @@ @@ -395,10 +439,10 @@ @@ -411,10 +455,10 @@ @@ -427,10 +471,10 @@ @@ -443,10 +487,10 @@ @@ -459,10 +503,10 @@ @@ -475,10 +519,10 @@ @@ -491,10 +535,10 @@ @@ -507,10 +551,10 @@ @@ -523,10 +567,10 @@ @@ -539,10 +583,10 @@ @@ -555,10 +599,10 @@ @@ -571,10 +615,10 @@ @@ -587,10 +631,10 @@ @@ -603,10 +647,10 @@ @@ -619,10 +663,10 @@ @@ -669,6 +713,7 @@ - \ No newline at end of file diff --git a/webinterface/rank.php b/webinterface/rank.php index 204eb0b..8769ac6 100644 --- a/webinterface/rank.php +++ b/webinterface/rank.php @@ -1,143 +1,148 @@ -exec("INSERT INTO `$dbname`.`csrf_token` (`token`,`timestamp`,`sessionid`) VALUES ('$csrf_token','".time()."','".session_id()."')") === false) { - $err_msg = print_r($mysqlcon->errorInfo(), true); - $err_lvl = 3; - } - - if (($db_csrf = $mysqlcon->query("SELECT * FROM `$dbname`.`csrf_token` WHERE `sessionid`='".session_id()."'")->fetchALL(PDO::FETCH_UNIQUE|PDO::FETCH_ASSOC)) === false) { - $err_msg = print_r($mysqlcon->errorInfo(), true); - $err_lvl = 3; - } - - if(($groupslist = $mysqlcon->query("SELECT * FROM `$dbname`.`groups` ORDER BY `sortid`,`sgidname` ASC")->fetchAll(PDO::FETCH_UNIQUE|PDO::FETCH_ASSOC)) === false) { - $err_msg = print_r($mysqlcon->errorInfo(), true); - $err_lvl = 3; - } - - if(!isset($groupslist) || $groupslist == NULL) { - $err_msg = 'No servergroups found inside the Ranksystem cache!

    Please connect the Ranksystem Bot to the TS server. The Ranksystem will download the servergroups when it is connected to the server.
    Give it a few minutes and reload this page. The dropdown field should contain your groups after.'; - $err_lvl = 1; - } - - if (isset($_POST['update_old']) && isset($db_csrf[$_POST['csrf_token']])) { - if(empty($_POST['rankup_definition'])) { - $grouparr_old = null; - } else { - foreach (explode(',', $_POST['rankup_definition']) as $entry) { - list($time, $groupid, $keepflag) = explode('=>', $entry); - if($keepflag == NULL) $keepflag = 0; - $grouparr_old[$time] = array("time"=>$time,"group"=>$groupid,"keep"=>$keepflag); - $cfg['rankup_definition'] = $grouparr_old; - } - } - - $errcnf = 0; - if(isset($groupslist) && $groupslist != NULL) { - if(isset($cfg['rankup_definition']) && $cfg['rankup_definition'] != NULL) { - foreach($cfg['rankup_definition'] as $time => $value) { - if(!isset($groupslist[$value['group']]) && $value['group'] != NULL) { - if(!isset($err_msg)) $err_msg = ''; - $err_msg .= sprintf($lang['upgrp0001'], $value['group'], $lang['wigrptime']).'
    '; - $err_lvl = 3; - $errcnf++; - } - } - } - } - - if($_POST['rankup_definition'] == "") { - $err_msg = "Saving of empty defintion prevented.

    Your changes were not be saved!

    You need at least one entry to be able to save the configuration!"; - $err_lvl = 3; - } else { - if($errcnf == 0) { - if ($mysqlcon->exec("INSERT INTO `$dbname`.`cfg_params` (`param`,`value`) VALUES ('rankup_definition','{$_POST['rankup_definition']}') ON DUPLICATE KEY UPDATE `value`=VALUES(`value`); DELETE FROM `$dbname`.`csrf_token` WHERE `token`='{$_POST['csrf_token']}'") === false) { - $err_msg = print_r($mysqlcon->errorInfo(), true); - $err_lvl = 3; - } else { - $err_msg = $lang['wisvsuc']." ".sprintf($lang['wisvres'], ''); - $err_lvl = NULL; - } - } else { - $err_msg .= "
    ".$lang['errgrpid']; - } - } - - } elseif (isset($_POST['update']) && isset($db_csrf[$_POST['csrf_token']])) { - $rankup_definition = ""; - if(isset($_POST['rankuptime']) && isset($_POST['rankupgroup'])) { - $rankupgroups = []; - foreach($_POST['rankuptime'] as $key => $entry) { - $servergroupId = isset($_POST["rankupgroup"][$key]) ? $_POST["rankupgroup"][$key] : 0; - if(isset($_POST["rankupkeep"]) && in_array($key,$_POST["rankupkeep"])) { - $keepflag = 1; - } else { - $keepflag = 0; - } - if(empty($entry)) { - $entry = 0; - } - $rankupgroups[] = "$entry=>$servergroupId=>$keepflag"; - } - $rankup_definition = implode(",", $rankupgroups); - $grouparr = []; - foreach(explode(',', $rankup_definition) as $entry) { - list($time, $groupid, $keepflag) = explode('=>', $entry); - $grouparr[$groupid] = $time; - } - - $err_msg = ''; - $errcnf = 0; - if(isset($groupslist) && $groupslist != NULL) { - foreach($grouparr as $groupid => $time) { - if((!isset($groupslist[$groupid]) && $groupid != NULL) || $groupid == 0) { - $err_msg .= sprintf($lang['upgrp0001'], $groupid, $lang['wigrptime']).'
    '; - $err_lvl = 3; - $errcnf++; - } - } - } - - $cfg['rankup_definition'] = $rankup_definition; - - if($errcnf == 0) { - if ($mysqlcon->exec("INSERT INTO `$dbname`.`cfg_params` (`param`,`value`) VALUES ('rankup_definition','{$cfg['rankup_definition']}') ON DUPLICATE KEY UPDATE `value`=VALUES(`value`); DELETE FROM `$dbname`.`csrf_token` WHERE `token`='{$_POST['csrf_token']}'") === false) { - $err_msg = print_r($mysqlcon->errorInfo(), true); - $err_lvl = 3; - } else { - $err_msg = $lang['wisvsuc']." ".sprintf($lang['wisvres'], '
    '); - $err_lvl = NULL; - } - } else { - $err_msg .= "
    ".$lang['errgrpid']; - } - - if(empty($rankup_definition)) { - $cfg['rankup_definition'] = NULL; - } else { - $grouptimearr = explode(',', $rankup_definition); - foreach ($grouptimearr as $entry) { - list($time, $groupid, $keepflag) = explode('=>', $entry); - $addnewvalue1[$time] = array("time"=>$time,"group"=>$groupid,"keep"=>$keepflag); - $cfg['rankup_definition'] = $addnewvalue1; - } - } - } else { - $err_msg = $lang['errukwn']; - $err_lvl = 3; - } - } elseif(isset($_POST['update']) || isset($_POST['update_old'])) { - echo '
    ',$lang['errcsrf'],'
    '; - rem_session_ts3(); - exit; - } - ?> +exec("INSERT INTO `$dbname`.`csrf_token` (`token`,`timestamp`,`sessionid`) VALUES ('$csrf_token','".time()."','".session_id()."')") === false) { + $err_msg = print_r($mysqlcon->errorInfo(), true); + $err_lvl = 3; + } + + if (($db_csrf = $mysqlcon->query("SELECT * FROM `$dbname`.`csrf_token` WHERE `sessionid`='".session_id()."'")->fetchALL(PDO::FETCH_UNIQUE | PDO::FETCH_ASSOC)) === false) { + $err_msg = print_r($mysqlcon->errorInfo(), true); + $err_lvl = 3; + } + + if (($groupslist = $mysqlcon->query("SELECT * FROM `$dbname`.`groups` ORDER BY `sortid`,`sgidname` ASC")->fetchAll(PDO::FETCH_UNIQUE | PDO::FETCH_ASSOC)) === false) { + $err_msg = print_r($mysqlcon->errorInfo(), true); + $err_lvl = 3; + } + + if (! isset($groupslist) || $groupslist == null) { + $err_msg = 'No servergroups found inside the Ranksystem cache!

    Please connect the Ranksystem Bot to the TS server. The Ranksystem will download the servergroups when it is connected to the server.
    Give it a few minutes and reload this page. The dropdown field should contain your groups after.'; + $err_lvl = 1; + } + + if (isset($_POST['update_old']) && isset($db_csrf[$_POST['csrf_token']])) { + if (empty($_POST['rankup_definition'])) { + $grouparr_old = null; + } else { + foreach (explode(',', $_POST['rankup_definition']) as $entry) { + list($time, $groupid, $keepflag) = explode('=>', $entry); + if ($keepflag == null) { + $keepflag = 0; + } + $grouparr_old[$time] = ['time'=>$time, 'group'=>$groupid, 'keep'=>$keepflag]; + $cfg['rankup_definition'] = $grouparr_old; + } + } + + $errcnf = 0; + if (isset($groupslist) && $groupslist != null) { + if (isset($cfg['rankup_definition']) && $cfg['rankup_definition'] != null) { + foreach ($cfg['rankup_definition'] as $time => $value) { + if (! isset($groupslist[$value['group']]) && $value['group'] != null) { + if (! isset($err_msg)) { + $err_msg = ''; + } + $err_msg .= sprintf($lang['upgrp0001'], $value['group'], $lang['wigrptime']).'
    '; + $err_lvl = 3; + $errcnf++; + } + } + } + } + + if ($_POST['rankup_definition'] == '') { + $err_msg = 'Saving of empty defintion prevented.

    Your changes were not be saved!

    You need at least one entry to be able to save the configuration!'; + $err_lvl = 3; + } else { + if ($errcnf == 0) { + if ($mysqlcon->exec("INSERT INTO `$dbname`.`cfg_params` (`param`,`value`) VALUES ('rankup_definition','{$_POST['rankup_definition']}') ON DUPLICATE KEY UPDATE `value`=VALUES(`value`); DELETE FROM `$dbname`.`csrf_token` WHERE `token`='{$_POST['csrf_token']}'") === false) { + $err_msg = print_r($mysqlcon->errorInfo(), true); + $err_lvl = 3; + } else { + $err_msg = $lang['wisvsuc'].' '.sprintf($lang['wisvres'], '
    '); + $err_lvl = null; + } + } else { + $err_msg .= '
    '.$lang['errgrpid']; + } + } + } elseif (isset($_POST['update']) && isset($db_csrf[$_POST['csrf_token']])) { + $rankup_definition = ''; + if (isset($_POST['rankuptime']) && isset($_POST['rankupgroup'])) { + $rankupgroups = []; + foreach ($_POST['rankuptime'] as $key => $entry) { + $servergroupId = isset($_POST['rankupgroup'][$key]) ? $_POST['rankupgroup'][$key] : 0; + if (isset($_POST['rankupkeep']) && in_array($key, $_POST['rankupkeep'])) { + $keepflag = 1; + } else { + $keepflag = 0; + } + if (empty($entry)) { + $entry = 0; + } + $rankupgroups[] = "$entry=>$servergroupId=>$keepflag"; + } + $rankup_definition = implode(',', $rankupgroups); + $grouparr = []; + foreach (explode(',', $rankup_definition) as $entry) { + list($time, $groupid, $keepflag) = explode('=>', $entry); + $grouparr[$groupid] = $time; + } + + $err_msg = ''; + $errcnf = 0; + if (isset($groupslist) && $groupslist != null) { + foreach ($grouparr as $groupid => $time) { + if ((! isset($groupslist[$groupid]) && $groupid != null) || $groupid == 0) { + $err_msg .= sprintf($lang['upgrp0001'], $groupid, $lang['wigrptime']).'
    '; + $err_lvl = 3; + $errcnf++; + } + } + } + + $cfg['rankup_definition'] = $rankup_definition; + + if ($errcnf == 0) { + if ($mysqlcon->exec("INSERT INTO `$dbname`.`cfg_params` (`param`,`value`) VALUES ('rankup_definition','{$cfg['rankup_definition']}') ON DUPLICATE KEY UPDATE `value`=VALUES(`value`); DELETE FROM `$dbname`.`csrf_token` WHERE `token`='{$_POST['csrf_token']}'") === false) { + $err_msg = print_r($mysqlcon->errorInfo(), true); + $err_lvl = 3; + } else { + $err_msg = $lang['wisvsuc'].' '.sprintf($lang['wisvres'], '
    '); + $err_lvl = null; + } + } else { + $err_msg .= '
    '.$lang['errgrpid']; + } + + if (empty($rankup_definition)) { + $cfg['rankup_definition'] = null; + } else { + $grouptimearr = explode(',', $rankup_definition); + foreach ($grouptimearr as $entry) { + list($time, $groupid, $keepflag) = explode('=>', $entry); + $addnewvalue1[$time] = ['time'=>$time, 'group'=>$groupid, 'keep'=>$keepflag]; + $cfg['rankup_definition'] = $addnewvalue1; + } + } + } else { + $err_msg = $lang['errukwn']; + $err_lvl = 3; + } + } elseif (isset($_POST['update']) || isset($_POST['update_old'])) { + echo '
    ',$lang['errcsrf'],'
    '; + rem_session_ts3(); + exit; + } + ?>
    - +
    @@ -151,7 +156,7 @@
    - +
    @@ -171,43 +176,61 @@
    - +
    - +
    - '; - } else { - echo ''; - } ?> + '; + } else { + echo ''; + } ?>
    - +
    @@ -242,7 +265,7 @@
    - +
    @@ -254,7 +277,11 @@
    - +
    @@ -280,10 +307,10 @@
    @@ -296,10 +323,10 @@
    @@ -369,6 +396,7 @@ function addrankupgroup() { - \ No newline at end of file diff --git a/webinterface/ranklist.php b/webinterface/ranklist.php index 7ec27bb..fd4b0c4 100644 --- a/webinterface/ranklist.php +++ b/webinterface/ranklist.php @@ -1,77 +1,183 @@ -exec("INSERT INTO `$dbname`.`csrf_token` (`token`,`timestamp`,`sessionid`) VALUES ('$csrf_token','".time()."','".session_id()."')") === false) { - $err_msg = print_r($mysqlcon->errorInfo(), true); - $err_lvl = 3; - } - - if (($db_csrf = $mysqlcon->query("SELECT * FROM `$dbname`.`csrf_token` WHERE `sessionid`='".session_id()."'")->fetchALL(PDO::FETCH_UNIQUE|PDO::FETCH_ASSOC)) === false) { - $err_msg = print_r($mysqlcon->errorInfo(), true); - $err_lvl = 3; - } - - if (isset($_POST['update']) && isset($db_csrf[$_POST['csrf_token']])) { - if (isset($_POST['stats_column_rank_switch'])) $cfg['stats_column_rank_switch'] = 1; else $cfg['stats_column_rank_switch'] = 0; - if (isset($_POST['stats_column_client_name_switch'])) $cfg['stats_column_client_name_switch'] = 1; else $cfg['stats_column_client_name_switch'] = 0; - if (isset($_POST['stats_column_unique_id_switch'])) $cfg['stats_column_unique_id_switch'] = 1; else $cfg['stats_column_unique_id_switch'] = 0; - if (isset($_POST['stats_column_client_db_id_switch'])) $cfg['stats_column_client_db_id_switch'] = 1; else $cfg['stats_column_client_db_id_switch'] = 0; - if (isset($_POST['stats_column_last_seen_switch'])) $cfg['stats_column_last_seen_switch'] = 1; else $cfg['stats_column_last_seen_switch'] = 0; - if (isset($_POST['stats_column_nation_switch'])) $cfg['stats_column_nation_switch'] = 1; else $cfg['stats_column_nation_switch'] = 0; - if (isset($_POST['stats_column_version_switch'])) $cfg['stats_column_version_switch'] = 1; else $cfg['stats_column_version_switch'] = 0; - if (isset($_POST['stats_column_platform_switch'])) $cfg['stats_column_platform_switch'] = 1; else $cfg['stats_column_platform_switch'] = 0; - if (isset($_POST['stats_column_online_time_switch'])) $cfg['stats_column_online_time_switch'] = 1; else $cfg['stats_column_online_time_switch'] = 0; - if (isset($_POST['stats_column_idle_time_switch'])) $cfg['stats_column_idle_time_switch'] = 1; else $cfg['stats_column_idle_time_switch'] = 0; - if (isset($_POST['stats_column_active_time_switch'])) $cfg['stats_column_active_time_switch'] = 1; else $cfg['stats_column_active_time_switch'] = 0; - if (isset($_POST['stats_column_current_server_group_switch'])) $cfg['stats_column_current_server_group_switch'] = 1; else $cfg['stats_column_current_server_group_switch'] = 0; - if (isset($_POST['stats_column_next_rankup_switch'])) $cfg['stats_column_next_rankup_switch'] = 1; else $cfg['stats_column_next_rankup_switch'] = 0; - if (isset($_POST['stats_column_next_server_group_switch'])) $cfg['stats_column_next_server_group_switch'] = 1; else $cfg['stats_column_next_server_group_switch'] = 0; - if (isset($_POST['stats_column_current_group_since_switch'])) $cfg['stats_column_current_group_since_switch'] = 1; else $cfg['stats_column_current_group_since_switch'] = 0; - if (isset($_POST['stats_column_online_day_switch'])) $cfg['stats_column_online_day_switch'] = 1; else $cfg['stats_column_online_day_switch'] = 0; - if (isset($_POST['stats_column_idle_day_switch'])) $cfg['stats_column_idle_day_switch'] = 1; else $cfg['stats_column_idle_day_switch'] = 0; - if (isset($_POST['stats_column_active_day_switch'])) $cfg['stats_column_active_day_switch'] = 1; else $cfg['stats_column_active_day_switch'] = 0; - if (isset($_POST['stats_column_online_week_switch'])) $cfg['stats_column_online_week_switch'] = 1; else $cfg['stats_column_online_week_switch'] = 0; - if (isset($_POST['stats_column_idle_week_switch'])) $cfg['stats_column_idle_week_switch'] = 1; else $cfg['stats_column_idle_week_switch'] = 0; - if (isset($_POST['stats_column_active_week_switch'])) $cfg['stats_column_active_week_switch'] = 1; else $cfg['stats_column_active_week_switch'] = 0; - if (isset($_POST['stats_column_online_month_switch'])) $cfg['stats_column_online_month_switch'] = 1; else $cfg['stats_column_online_month_switch'] = 0; - if (isset($_POST['stats_column_idle_month_switch'])) $cfg['stats_column_idle_month_switch'] = 1; else $cfg['stats_column_idle_month_switch'] = 0; - if (isset($_POST['stats_column_active_month_switch'])) $cfg['stats_column_active_month_switch'] = 1; else $cfg['stats_column_active_month_switch'] = 0; - if (isset($_POST['stats_show_excepted_clients_switch'])) $cfg['stats_show_excepted_clients_switch'] = 1; else $cfg['stats_show_excepted_clients_switch'] = 0; - if (isset($_POST['stats_show_clients_in_highest_rank_switch'])) $cfg['stats_show_clients_in_highest_rank_switch'] = 1; else $cfg['stats_show_clients_in_highest_rank_switch'] = 0; - - $cfg['stats_column_default_order'] = $_POST['stats_column_default_order']; - $cfg['stats_column_default_sort'] = $_POST['stats_column_default_sort']; - $cfg['stats_column_default_order_2'] = $_POST['stats_column_default_order_2']; - $cfg['stats_column_default_sort_2'] = $_POST['stats_column_default_sort_2']; - - if ($mysqlcon->exec("INSERT INTO `$dbname`.`cfg_params` (`param`,`value`) VALUES ('stats_column_rank_switch','{$cfg['stats_column_rank_switch']}'),('stats_column_client_name_switch','{$cfg['stats_column_client_name_switch']}'),('stats_column_unique_id_switch','{$cfg['stats_column_unique_id_switch']}'),('stats_column_client_db_id_switch','{$cfg['stats_column_client_db_id_switch']}'),('stats_column_last_seen_switch','{$cfg['stats_column_last_seen_switch']}'),('stats_column_nation_switch','{$cfg['stats_column_nation_switch']}'),('stats_column_version_switch','{$cfg['stats_column_version_switch']}'),('stats_column_platform_switch','{$cfg['stats_column_platform_switch']}'),('stats_column_online_time_switch','{$cfg['stats_column_online_time_switch']}'),('stats_column_idle_time_switch','{$cfg['stats_column_idle_time_switch']}'),('stats_column_active_time_switch','{$cfg['stats_column_active_time_switch']}'),('stats_column_current_server_group_switch','{$cfg['stats_column_current_server_group_switch']}'),('stats_column_current_group_since_switch','{$cfg['stats_column_current_group_since_switch']}'),('stats_column_online_day_switch','{$cfg['stats_column_online_day_switch']}'),('stats_column_idle_day_switch','{$cfg['stats_column_idle_day_switch']}'),('stats_column_active_day_switch','{$cfg['stats_column_active_day_switch']}'),('stats_column_online_week_switch','{$cfg['stats_column_online_week_switch']}'),('stats_column_idle_week_switch','{$cfg['stats_column_idle_week_switch']}'),('stats_column_active_week_switch','{$cfg['stats_column_active_week_switch']}'),('stats_column_online_month_switch','{$cfg['stats_column_online_month_switch']}'),('stats_column_idle_month_switch','{$cfg['stats_column_idle_month_switch']}'),('stats_column_active_month_switch','{$cfg['stats_column_active_month_switch']}'),('stats_column_next_rankup_switch','{$cfg['stats_column_next_rankup_switch']}'),('stats_column_next_server_group_switch','{$cfg['stats_column_next_server_group_switch']}'),('stats_column_default_order','{$cfg['stats_column_default_order']}'),('stats_column_default_sort','{$cfg['stats_column_default_sort']}'),('stats_column_default_order_2','{$cfg['stats_column_default_order_2']}'),('stats_column_default_sort_2','{$cfg['stats_column_default_sort_2']}'),('stats_show_excepted_clients_switch','{$cfg['stats_show_excepted_clients_switch']}'),('stats_show_clients_in_highest_rank_switch','{$cfg['stats_show_clients_in_highest_rank_switch']}') ON DUPLICATE KEY UPDATE `value`=VALUES(`value`); DELETE FROM `$dbname`.`csrf_token` WHERE `token`='{$_POST['csrf_token']}'") === false) { - $err_msg = print_r($mysqlcon->errorInfo(), true); - $err_lvl = 3; - } else { - $err_msg = $lang['wisvsuc']; - $err_lvl = NULL; - } - } elseif(isset($_POST['update'])) { - echo '
    ',$lang['errcsrf'],'
    '; - rem_session_ts3(); - exit; - } - ?> +exec("INSERT INTO `$dbname`.`csrf_token` (`token`,`timestamp`,`sessionid`) VALUES ('$csrf_token','".time()."','".session_id()."')") === false) { + $err_msg = print_r($mysqlcon->errorInfo(), true); + $err_lvl = 3; + } + + if (($db_csrf = $mysqlcon->query("SELECT * FROM `$dbname`.`csrf_token` WHERE `sessionid`='".session_id()."'")->fetchALL(PDO::FETCH_UNIQUE | PDO::FETCH_ASSOC)) === false) { + $err_msg = print_r($mysqlcon->errorInfo(), true); + $err_lvl = 3; + } + + if (isset($_POST['update']) && isset($db_csrf[$_POST['csrf_token']])) { + if (isset($_POST['stats_column_rank_switch'])) { + $cfg['stats_column_rank_switch'] = 1; + } else { + $cfg['stats_column_rank_switch'] = 0; + } + if (isset($_POST['stats_column_client_name_switch'])) { + $cfg['stats_column_client_name_switch'] = 1; + } else { + $cfg['stats_column_client_name_switch'] = 0; + } + if (isset($_POST['stats_column_unique_id_switch'])) { + $cfg['stats_column_unique_id_switch'] = 1; + } else { + $cfg['stats_column_unique_id_switch'] = 0; + } + if (isset($_POST['stats_column_client_db_id_switch'])) { + $cfg['stats_column_client_db_id_switch'] = 1; + } else { + $cfg['stats_column_client_db_id_switch'] = 0; + } + if (isset($_POST['stats_column_last_seen_switch'])) { + $cfg['stats_column_last_seen_switch'] = 1; + } else { + $cfg['stats_column_last_seen_switch'] = 0; + } + if (isset($_POST['stats_column_nation_switch'])) { + $cfg['stats_column_nation_switch'] = 1; + } else { + $cfg['stats_column_nation_switch'] = 0; + } + if (isset($_POST['stats_column_version_switch'])) { + $cfg['stats_column_version_switch'] = 1; + } else { + $cfg['stats_column_version_switch'] = 0; + } + if (isset($_POST['stats_column_platform_switch'])) { + $cfg['stats_column_platform_switch'] = 1; + } else { + $cfg['stats_column_platform_switch'] = 0; + } + if (isset($_POST['stats_column_online_time_switch'])) { + $cfg['stats_column_online_time_switch'] = 1; + } else { + $cfg['stats_column_online_time_switch'] = 0; + } + if (isset($_POST['stats_column_idle_time_switch'])) { + $cfg['stats_column_idle_time_switch'] = 1; + } else { + $cfg['stats_column_idle_time_switch'] = 0; + } + if (isset($_POST['stats_column_active_time_switch'])) { + $cfg['stats_column_active_time_switch'] = 1; + } else { + $cfg['stats_column_active_time_switch'] = 0; + } + if (isset($_POST['stats_column_current_server_group_switch'])) { + $cfg['stats_column_current_server_group_switch'] = 1; + } else { + $cfg['stats_column_current_server_group_switch'] = 0; + } + if (isset($_POST['stats_column_next_rankup_switch'])) { + $cfg['stats_column_next_rankup_switch'] = 1; + } else { + $cfg['stats_column_next_rankup_switch'] = 0; + } + if (isset($_POST['stats_column_next_server_group_switch'])) { + $cfg['stats_column_next_server_group_switch'] = 1; + } else { + $cfg['stats_column_next_server_group_switch'] = 0; + } + if (isset($_POST['stats_column_current_group_since_switch'])) { + $cfg['stats_column_current_group_since_switch'] = 1; + } else { + $cfg['stats_column_current_group_since_switch'] = 0; + } + if (isset($_POST['stats_column_online_day_switch'])) { + $cfg['stats_column_online_day_switch'] = 1; + } else { + $cfg['stats_column_online_day_switch'] = 0; + } + if (isset($_POST['stats_column_idle_day_switch'])) { + $cfg['stats_column_idle_day_switch'] = 1; + } else { + $cfg['stats_column_idle_day_switch'] = 0; + } + if (isset($_POST['stats_column_active_day_switch'])) { + $cfg['stats_column_active_day_switch'] = 1; + } else { + $cfg['stats_column_active_day_switch'] = 0; + } + if (isset($_POST['stats_column_online_week_switch'])) { + $cfg['stats_column_online_week_switch'] = 1; + } else { + $cfg['stats_column_online_week_switch'] = 0; + } + if (isset($_POST['stats_column_idle_week_switch'])) { + $cfg['stats_column_idle_week_switch'] = 1; + } else { + $cfg['stats_column_idle_week_switch'] = 0; + } + if (isset($_POST['stats_column_active_week_switch'])) { + $cfg['stats_column_active_week_switch'] = 1; + } else { + $cfg['stats_column_active_week_switch'] = 0; + } + if (isset($_POST['stats_column_online_month_switch'])) { + $cfg['stats_column_online_month_switch'] = 1; + } else { + $cfg['stats_column_online_month_switch'] = 0; + } + if (isset($_POST['stats_column_idle_month_switch'])) { + $cfg['stats_column_idle_month_switch'] = 1; + } else { + $cfg['stats_column_idle_month_switch'] = 0; + } + if (isset($_POST['stats_column_active_month_switch'])) { + $cfg['stats_column_active_month_switch'] = 1; + } else { + $cfg['stats_column_active_month_switch'] = 0; + } + if (isset($_POST['stats_show_excepted_clients_switch'])) { + $cfg['stats_show_excepted_clients_switch'] = 1; + } else { + $cfg['stats_show_excepted_clients_switch'] = 0; + } + if (isset($_POST['stats_show_clients_in_highest_rank_switch'])) { + $cfg['stats_show_clients_in_highest_rank_switch'] = 1; + } else { + $cfg['stats_show_clients_in_highest_rank_switch'] = 0; + } + + $cfg['stats_column_default_order'] = $_POST['stats_column_default_order']; + $cfg['stats_column_default_sort'] = $_POST['stats_column_default_sort']; + $cfg['stats_column_default_order_2'] = $_POST['stats_column_default_order_2']; + $cfg['stats_column_default_sort_2'] = $_POST['stats_column_default_sort_2']; + + if ($mysqlcon->exec("INSERT INTO `$dbname`.`cfg_params` (`param`,`value`) VALUES ('stats_column_rank_switch','{$cfg['stats_column_rank_switch']}'),('stats_column_client_name_switch','{$cfg['stats_column_client_name_switch']}'),('stats_column_unique_id_switch','{$cfg['stats_column_unique_id_switch']}'),('stats_column_client_db_id_switch','{$cfg['stats_column_client_db_id_switch']}'),('stats_column_last_seen_switch','{$cfg['stats_column_last_seen_switch']}'),('stats_column_nation_switch','{$cfg['stats_column_nation_switch']}'),('stats_column_version_switch','{$cfg['stats_column_version_switch']}'),('stats_column_platform_switch','{$cfg['stats_column_platform_switch']}'),('stats_column_online_time_switch','{$cfg['stats_column_online_time_switch']}'),('stats_column_idle_time_switch','{$cfg['stats_column_idle_time_switch']}'),('stats_column_active_time_switch','{$cfg['stats_column_active_time_switch']}'),('stats_column_current_server_group_switch','{$cfg['stats_column_current_server_group_switch']}'),('stats_column_current_group_since_switch','{$cfg['stats_column_current_group_since_switch']}'),('stats_column_online_day_switch','{$cfg['stats_column_online_day_switch']}'),('stats_column_idle_day_switch','{$cfg['stats_column_idle_day_switch']}'),('stats_column_active_day_switch','{$cfg['stats_column_active_day_switch']}'),('stats_column_online_week_switch','{$cfg['stats_column_online_week_switch']}'),('stats_column_idle_week_switch','{$cfg['stats_column_idle_week_switch']}'),('stats_column_active_week_switch','{$cfg['stats_column_active_week_switch']}'),('stats_column_online_month_switch','{$cfg['stats_column_online_month_switch']}'),('stats_column_idle_month_switch','{$cfg['stats_column_idle_month_switch']}'),('stats_column_active_month_switch','{$cfg['stats_column_active_month_switch']}'),('stats_column_next_rankup_switch','{$cfg['stats_column_next_rankup_switch']}'),('stats_column_next_server_group_switch','{$cfg['stats_column_next_server_group_switch']}'),('stats_column_default_order','{$cfg['stats_column_default_order']}'),('stats_column_default_sort','{$cfg['stats_column_default_sort']}'),('stats_column_default_order_2','{$cfg['stats_column_default_order_2']}'),('stats_column_default_sort_2','{$cfg['stats_column_default_sort_2']}'),('stats_show_excepted_clients_switch','{$cfg['stats_show_excepted_clients_switch']}'),('stats_show_clients_in_highest_rank_switch','{$cfg['stats_show_clients_in_highest_rank_switch']}') ON DUPLICATE KEY UPDATE `value`=VALUES(`value`); DELETE FROM `$dbname`.`csrf_token` WHERE `token`='{$_POST['csrf_token']}'") === false) { + $err_msg = print_r($mysqlcon->errorInfo(), true); + $err_lvl = 3; + } else { + $err_msg = $lang['wisvsuc']; + $err_lvl = null; + } + } elseif (isset($_POST['update'])) { + echo '
    ',$lang['errcsrf'],'
    '; + rem_session_ts3(); + exit; + } + ?>
    - +

    - +

    - +
    @@ -79,51 +185,51 @@
    - '; - } else { - echo ''; - } ?> + '; + } else { + echo ''; + } ?>
    - '; - } else { - echo ''; - } ?> + '; + } else { + echo ''; + } ?>
    - '; - } else { - echo ''; - } ?> + '; + } else { + echo ''; + } ?>
    - '; - } else { - echo ''; - } ?> + '; + } else { + echo ''; + } ?>
    - '; - } else { - echo ''; - } ?> + '; + } else { + echo ''; + } ?>
    @@ -131,183 +237,183 @@
    - '; - } else { - echo ''; - } ?> + '; + } else { + echo ''; + } ?>
    - '; - } else { - echo ''; - } ?> + '; + } else { + echo ''; + } ?>
    - '; - } else { - echo ''; - } ?> + '; + } else { + echo ''; + } ?>
    - '; - } else { - echo ''; - } ?> + '; + } else { + echo ''; + } ?>
    - '; - } else { - echo ''; - } ?> + '; + } else { + echo ''; + } ?>
    - '; - } else { - echo ''; - } ?> + '; + } else { + echo ''; + } ?>
    - '; - } else { - echo ''; - } ?> + '; + } else { + echo ''; + } ?>
    - '; - } else { - echo ''; - } ?> + '; + } else { + echo ''; + } ?>
    - '; - } else { - echo ''; - } ?> + '; + } else { + echo ''; + } ?>
    - '; - } else { - echo ''; - } ?> + '; + } else { + echo ''; + } ?>
    - '; - } else { - echo ''; - } ?> + '; + } else { + echo ''; + } ?>
    - '; - } else { - echo ''; - } ?> + '; + } else { + echo ''; + } ?>
    - '; - } else { - echo ''; - } ?> + '; + } else { + echo ''; + } ?>
    - '; - } else { - echo ''; - } ?> + '; + } else { + echo ''; + } ?>
    - '; - } else { - echo ''; - } ?> + '; + } else { + echo ''; + } ?>
    - '; - } else { - echo ''; - } ?> + '; + } else { + echo ''; + } ?>
    - '; - } else { - echo ''; - } ?> + '; + } else { + echo ''; + } ?>
    - '; - } else { - echo ''; - } ?> + '; + } else { + echo ''; + } ?>
    - '; - } else { - echo ''; - } ?> + '; + } else { + echo ''; + } ?>
    @@ -320,12 +426,12 @@
    @@ -333,10 +439,10 @@
    @@ -345,11 +451,11 @@
    @@ -357,10 +463,10 @@
    @@ -370,21 +476,21 @@
    - '; - } else { - echo ''; - } ?> + '; + } else { + echo ''; + } ?>
    - '; - } else { - echo ''; - } ?> + '; + } else { + echo ''; + } ?>
    @@ -410,10 +516,10 @@ @@ -426,10 +532,10 @@ @@ -442,10 +548,10 @@ @@ -458,10 +564,10 @@ @@ -474,10 +580,10 @@ @@ -490,10 +596,10 @@ @@ -506,10 +612,10 @@ @@ -544,6 +650,7 @@ - \ No newline at end of file diff --git a/webinterface/reset.php b/webinterface/reset.php index 6f75e7c..6753cd5 100644 --- a/webinterface/reset.php +++ b/webinterface/reset.php @@ -1,218 +1,276 @@ -exec("INSERT INTO `$dbname`.`csrf_token` (`token`,`timestamp`,`sessionid`) VALUES ('$csrf_token','".time()."','".session_id()."')") === false) { - $err_msg = $lang['isntwidbmsg'].print_r($mysqlcon->errorInfo(), true); - $err_lvl = 3; - } - - if (($db_csrf = $mysqlcon->query("SELECT * FROM `$dbname`.`csrf_token` WHERE `sessionid`='".session_id()."'")->fetchALL(PDO::FETCH_UNIQUE|PDO::FETCH_ASSOC)) === false) { - $err_msg = $lang['isntwidbmsg'].print_r($mysqlcon->errorInfo(), true); - $err_lvl = 3; - } - - if(($job_check = $mysqlcon->query("SELECT * FROM `$dbname`.`job_check`")->fetchAll(PDO::FETCH_UNIQUE|PDO::FETCH_ASSOC)) === false) { - $err_msg = $lang['isntwidbmsg'].print_r($mysqlcon->errorInfo(), true); $err_lvl = 3; - } - - function reset_status($lang, $job_check, $check = NULL) { - $err_msg = "".$lang['wihladm31'].": "; - - switch([$job_check['reset_user_time']['timestamp'],$job_check['reset_user_delete']['timestamp']]) { - case [0,1]: - if($check == 1) { - $err_msg .= $lang['wihladmrs16']." (".$lang['wisupidle'].": ".$lang['wihladm312'].")
    "; break; - } else { - $err_msg .= $lang['wihladmrs1']." (".$lang['wisupidle'].": ".$lang['wihladm312'].")
    "; break; - } - case [0,2]: - $err_msg .= "".$lang['wihladmrs2']." (".$lang['wisupidle'].": ".$lang['wihladm312'].")
    "; break; - case [0,3]: - $err_msg .= "".$lang['wihladmrs3']." (".$lang['wisupidle'].": ".$lang['wihladm312'].")
    "; break; - case [0,4]: - $err_msg .= "".$lang['wihladmrs4']." (".$lang['wisupidle'].": ".$lang['wihladm312'].")
    "; break; - case [1,0]: - if($check == 1) { - $err_msg .= $lang['wihladmrs16']." (".$lang['wisupidle'].": ".$lang['wihladm311'].")
    "; break; - } else { - $err_msg .= $lang['wihladmrs1']." (".$lang['wisupidle'].": ".$lang['wihladm311'].")
    "; break; - } - case [2,0]: - $err_msg .= "".$lang['wihladmrs2']." (".$lang['wisupidle'].": ".$lang['wihladm311'].")
    "; break; - case [3,0]: - $err_msg .= "".$lang['wihladmrs3']." (".$lang['wisupidle'].": ".$lang['wihladm311'].")
    "; break; - case [4,0]: - $err_msg .= "".$lang['wihladmrs4']." (".$lang['wisupidle'].": ".$lang['wihladm311'].")
    "; break; - default: - $err_msg .= "".$lang['wihladmrs0']."
    "; - } - - $err_msg .= "".$lang['wihladm32'].": "; - switch($job_check['reset_group_withdraw']['timestamp']) { - case 1: - if($check == 1) { - $err_msg .= $lang['wihladmrs16']."
    "; break; - } else { - $err_msg .= $lang['wihladmrs1']."
    "; break; - } - case 2: - $err_msg .= "".$lang['wihladmrs2']."
    "; break; - case 3: - $err_msg .= "".$lang['wihladmrs3']."
    "; break; - case 4: - $err_msg .= "".$lang['wihladmrs4']."
    "; break; - default: - $err_msg .= "".$lang['wihladmrs0']."
    "; - } - - $err_msg .= "".$lang['wihladm33'].": "; - switch($job_check['reset_webspace_cache']['timestamp']) { - case 1: - if($check == 1) { - $err_msg .= $lang['wihladmrs16']."
    "; break; - } else { - $err_msg .= $lang['wihladmrs1']."
    "; break; - } - case 2: - $err_msg .= "".$lang['wihladmrs2']."
    "; break; - case 3: - $err_msg .= "".$lang['wihladmrs3']."
    "; break; - case 4: - $err_msg .= "".$lang['wihladmrs4']."
    "; break; - default: - $err_msg .= "".$lang['wihladmrs0']."
    "; - } - - $err_msg .= "".$lang['wihladm34'].": "; - switch($job_check['reset_usage_graph']['timestamp']) { - case 1: - if($check == 1) { - $err_msg .= $lang['wihladmrs16']."
    "; break; - } else { - $err_msg .= $lang['wihladmrs1']."
    "; break; - } - case 2: - $err_msg .= "".$lang['wihladmrs2']."
    "; break; - case 3: - $err_msg .= "".$lang['wihladmrs3']."
    "; break; - case 4: - $err_msg .= "".$lang['wihladmrs4']."
    "; break; - default: - $err_msg .= "".$lang['wihladmrs0']."
    "; - } - - $err_msg .= "

    ".$lang['wihladm36'].": "; - switch($job_check['reset_stop_after']['timestamp']) { - case 1: - $err_msg .= $lang['wihladmrs16']."
    "; break; - default: - $err_msg .= "".$lang['wihladmrs0']."
    "; - } - - return $err_msg; - } - - - if($job_check['reset_user_time']['timestamp'] != 0 || $job_check['reset_user_delete']['timestamp'] != 0 || $job_check['reset_group_withdraw']['timestamp'] != 0 || $job_check['reset_webspace_cache']['timestamp'] != 0 || $job_check['reset_usage_graph']['timestamp'] != 0) { - $err_msg = ''.$lang['wihladmrs'].":

    "; $err_lvl = 2;
    -		$err_msg .= reset_status($lang, $job_check);
    -
    -		if(in_array(intval($job_check['reset_user_time']['timestamp']), [0,4], true) && in_array(intval($job_check['reset_user_delete']['timestamp']), [0,4], true) && in_array(intval($job_check['reset_group_withdraw']['timestamp']), [0,4], true) && in_array(intval($job_check['reset_webspace_cache']['timestamp']), [0,4], true) && in_array(intval($job_check['reset_usage_graph']['timestamp']), [0,4], true)) {
    -			$err_msg .= '



    '.sprintf($lang['wihladmrs9'], ''); - } else { - $err_msg .= '
    '.sprintf($lang['wihladmrs7'], '
    ').'

    '.$lang['wihladmrs8']; - } - } - - if (isset($_POST['confirm']) && isset($db_csrf[$_POST['csrf_token']])) { - if(in_array(intval($job_check['reset_user_time']['timestamp']), [0,4], true) && in_array(intval($job_check['reset_user_delete']['timestamp']), [0,4], true) && in_array(intval($job_check['reset_group_withdraw']['timestamp']), [0,4], true) && in_array(intval($job_check['reset_webspace_cache']['timestamp']), [0,4], true) && in_array(intval($job_check['reset_usage_graph']['timestamp']), [0,4], true)) { - if ($mysqlcon->exec("INSERT INTO `$dbname`.`job_check` (`job_name`,`timestamp`) VALUES ('reset_user_time','0'),('reset_user_delete','0'),('reset_group_withdraw','0'),('reset_webspace_cache','0'),('reset_usage_graph','0'),('reset_stop_after','0') ON DUPLICATE KEY UPDATE `timestamp`=VALUES(`timestamp`); DELETE FROM `$dbname`.`csrf_token` WHERE `token`='{$_POST['csrf_token']}'") === false) { - $err_msg = $lang['isntwidbmsg'].print_r($mysqlcon->errorInfo(), true); - $err_lvl = 3; - } else { - $err_msg = $lang['wihladmrs10']; - $err_lvl = NULL; - } - } else { - $err_msg = $lang['errukwn']; $err_lvl = 3; - } - } elseif (isset($_POST['update']) && isset($db_csrf[$_POST['csrf_token']])) { - if($job_check['reset_user_time']['timestamp'] != 0 || $job_check['reset_user_delete']['timestamp'] != 0 || $job_check['reset_group_withdraw']['timestamp'] != 0 || $job_check['reset_webspace_cache']['timestamp'] != 0 || $job_check['reset_usage_graph']['timestamp'] != 0) { - $err_msg = ''.$lang['wihladmrs6'].'

    '.sprintf($lang['wihladmrs7'], '
    ').'

    '.$lang['wihladmrs8']; - $err_lvl = 3; - } elseif($_POST['reset_user_time'] == 0 && !isset($_POST['reset_group_withdraw']) && !isset($_POST['reset_webspace_cache']) && !isset($_POST['reset_usage_graph'])) { - $err_msg = $lang['wihladmrs15']; $err_lvl = 3; - } else { - if(($stats_server = $mysqlcon->query("SELECT * FROM `$dbname`.`stats_server`")->fetch()) === false) { - $err_msg .= print_r($mysqlcon->errorInfo(), true); $err_lvl = 3; - } - if(($groups = $mysqlcon->query("SELECT COUNT(*) AS `count` from `$dbname`.`groups`")->fetch()) === false) { - $err_msg .= print_r($mysqlcon->errorInfo(), true); $err_lvl = 3; - } - - if (isset($_POST['reset_user_time']) && $_POST['reset_user_time'] == 1) { - $job_check['reset_user_time']['timestamp'] = 1; - } elseif (isset($_POST['reset_user_time']) && $_POST['reset_user_time'] == 2) { - $job_check['reset_user_delete']['timestamp'] = 1; - } - if (isset($_POST['reset_group_withdraw'])) $_POST['reset_group_withdraw'] = $job_check['reset_group_withdraw']['timestamp'] = 1; else $_POST['reset_group_withdraw'] = $job_check['reset_group_withdraw']['timestamp'] = 0; - if (isset($_POST['reset_webspace_cache'])) $_POST['reset_webspace_cache'] = $job_check['reset_webspace_cache']['timestamp'] = 1; else $_POST['reset_webspace_cache'] = $job_check['reset_webspace_cache']['timestamp'] = 0; - if (isset($_POST['reset_usage_graph'])) $_POST['reset_usage_graph'] = $job_check['reset_usage_graph']['timestamp'] = 1; else $_POST['reset_usage_graph'] = $job_check['reset_usage_graph']['timestamp'] = 0; - if (isset($_POST['reset_stop_after'])) $_POST['reset_stop_after'] = $job_check['reset_stop_after']['timestamp'] = 1; else $_POST['reset_stop_after'] = $job_check['reset_stop_after']['timestamp'] = 0; - - if ($_POST['reset_group_withdraw'] == 0) $delay = 0; else $delay = ($cfg['teamspeak_query_command_delay'] / 1000000) + 0.05; - if ($_POST['reset_webspace_cache'] == 0) $cache_needed_time = 0; else $cache_needed_time = $stats_server['total_user'] / 10 * 0.005; - $time_to_begin = 5 * $cfg['teamspeak_query_command_delay'] / 1000000; - $est_time = round($delay * ($stats_server['total_user'] + $groups['count']) + $time_to_begin + $cache_needed_time); - $dtF = new \DateTime('@0'); - $dtT = new \DateTime("@$est_time"); - $est_time = $dtF->diff($dtT)->format($cfg['default_date_format']); - - $err_msg = $lang['wihladmrs11'].': '.$est_time.'.
    '.$lang['wihladmrs12'].'

    ';
    -			$err_msg .= reset_status($lang, $job_check, $check = 1);
    -			$err_msg .= '


    '; - $err_lvl = 1; - } - } elseif(isset($_POST['startjobs']) && isset($db_csrf[$_POST['csrf_token']])) { - if($_POST['reset_user_time'] == 1) { - $reset_user_time = 1; - $reset_user_delete = 0; - } elseif($_POST['reset_user_time'] == 2) { - $reset_user_delete = 1; - $reset_user_time = 0; - } else { - $reset_user_time = 0; - $reset_user_delete = 0; - } - - if ($mysqlcon->exec("INSERT INTO `$dbname`.`job_check` (`job_name`,`timestamp`) VALUES ('reset_user_time','{$reset_user_time}'),('reset_user_delete','{$reset_user_delete}'),('reset_group_withdraw','{$_POST['reset_group_withdraw']}'),('reset_webspace_cache','{$_POST['reset_webspace_cache']}'),('reset_usage_graph','{$_POST['reset_usage_graph']}'),('reset_stop_after','{$_POST['reset_stop_after']}') ON DUPLICATE KEY UPDATE `timestamp`=VALUES(`timestamp`); DELETE FROM `$dbname`.`csrf_token` WHERE `token`='{$_POST['csrf_token']}'") === false) { - $err_msg = $lang['isntwidbmsg'].print_r($mysqlcon->errorInfo(), true); - $err_lvl = 3; - } else { - $err_msg = ''.$lang['wihladmrs5'].'

    '.sprintf($lang['wihladmrs7'], '
    ').'

    '.$lang['wihladmrs8']; - $err_lvl = NULL; - } - } elseif(isset($_POST['update']) || isset($_POST['confirm'])) { - echo '
    ',$lang['errcsrf'],'
    '; - rem_session_ts3(); - exit; - } - ?> +exec("INSERT INTO `$dbname`.`csrf_token` (`token`,`timestamp`,`sessionid`) VALUES ('$csrf_token','".time()."','".session_id()."')") === false) { + $err_msg = $lang['isntwidbmsg'].print_r($mysqlcon->errorInfo(), true); + $err_lvl = 3; + } + + if (($db_csrf = $mysqlcon->query("SELECT * FROM `$dbname`.`csrf_token` WHERE `sessionid`='".session_id()."'")->fetchALL(PDO::FETCH_UNIQUE | PDO::FETCH_ASSOC)) === false) { + $err_msg = $lang['isntwidbmsg'].print_r($mysqlcon->errorInfo(), true); + $err_lvl = 3; + } + + if (($job_check = $mysqlcon->query("SELECT * FROM `$dbname`.`job_check`")->fetchAll(PDO::FETCH_UNIQUE | PDO::FETCH_ASSOC)) === false) { + $err_msg = $lang['isntwidbmsg'].print_r($mysqlcon->errorInfo(), true); + $err_lvl = 3; + } + + function reset_status($lang, $job_check, $check = null) + { + $err_msg = ''.$lang['wihladm31'].': '; + + switch([$job_check['reset_user_time']['timestamp'], $job_check['reset_user_delete']['timestamp']]) { + case [0, 1]: + if ($check == 1) { + $err_msg .= $lang['wihladmrs16'].' ('.$lang['wisupidle'].': '.$lang['wihladm312'].')
    '; + break; + } else { + $err_msg .= $lang['wihladmrs1'].' ('.$lang['wisupidle'].': '.$lang['wihladm312'].')
    '; + break; + } + case [0, 2]: + $err_msg .= ''.$lang['wihladmrs2'].' ('.$lang['wisupidle'].': '.$lang['wihladm312'].')
    '; + break; + case [0, 3]: + $err_msg .= ''.$lang['wihladmrs3'].' ('.$lang['wisupidle'].': '.$lang['wihladm312'].')
    '; + break; + case [0, 4]: + $err_msg .= ''.$lang['wihladmrs4'].' ('.$lang['wisupidle'].': '.$lang['wihladm312'].')
    '; + break; + case [1, 0]: + if ($check == 1) { + $err_msg .= $lang['wihladmrs16'].' ('.$lang['wisupidle'].': '.$lang['wihladm311'].')
    '; + break; + } else { + $err_msg .= $lang['wihladmrs1'].' ('.$lang['wisupidle'].': '.$lang['wihladm311'].')
    '; + break; + } + case [2, 0]: + $err_msg .= ''.$lang['wihladmrs2'].' ('.$lang['wisupidle'].': '.$lang['wihladm311'].')
    '; + break; + case [3, 0]: + $err_msg .= ''.$lang['wihladmrs3'].' ('.$lang['wisupidle'].': '.$lang['wihladm311'].')
    '; + break; + case [4, 0]: + $err_msg .= ''.$lang['wihladmrs4'].' ('.$lang['wisupidle'].': '.$lang['wihladm311'].')
    '; + break; + default: + $err_msg .= ''.$lang['wihladmrs0'].'
    '; + } + + $err_msg .= ''.$lang['wihladm32'].': '; + switch($job_check['reset_group_withdraw']['timestamp']) { + case 1: + if ($check == 1) { + $err_msg .= $lang['wihladmrs16'].'
    '; + break; + } else { + $err_msg .= $lang['wihladmrs1'].'
    '; + break; + } + case 2: + $err_msg .= ''.$lang['wihladmrs2'].'
    '; + break; + case 3: + $err_msg .= ''.$lang['wihladmrs3'].'
    '; + break; + case 4: + $err_msg .= ''.$lang['wihladmrs4'].'
    '; + break; + default: + $err_msg .= ''.$lang['wihladmrs0'].'
    '; + } + + $err_msg .= ''.$lang['wihladm33'].': '; + switch($job_check['reset_webspace_cache']['timestamp']) { + case 1: + if ($check == 1) { + $err_msg .= $lang['wihladmrs16'].'
    '; + break; + } else { + $err_msg .= $lang['wihladmrs1'].'
    '; + break; + } + case 2: + $err_msg .= ''.$lang['wihladmrs2'].'
    '; + break; + case 3: + $err_msg .= ''.$lang['wihladmrs3'].'
    '; + break; + case 4: + $err_msg .= ''.$lang['wihladmrs4'].'
    '; + break; + default: + $err_msg .= ''.$lang['wihladmrs0'].'
    '; + } + + $err_msg .= ''.$lang['wihladm34'].': '; + switch($job_check['reset_usage_graph']['timestamp']) { + case 1: + if ($check == 1) { + $err_msg .= $lang['wihladmrs16'].'
    '; + break; + } else { + $err_msg .= $lang['wihladmrs1'].'
    '; + break; + } + case 2: + $err_msg .= ''.$lang['wihladmrs2'].'
    '; + break; + case 3: + $err_msg .= ''.$lang['wihladmrs3'].'
    '; + break; + case 4: + $err_msg .= ''.$lang['wihladmrs4'].'
    '; + break; + default: + $err_msg .= ''.$lang['wihladmrs0'].'
    '; + } + + $err_msg .= '

    '.$lang['wihladm36'].': '; + switch($job_check['reset_stop_after']['timestamp']) { + case 1: + $err_msg .= $lang['wihladmrs16'].'
    '; + break; + default: + $err_msg .= ''.$lang['wihladmrs0'].'
    '; + } + + return $err_msg; + } + + if ($job_check['reset_user_time']['timestamp'] != 0 || $job_check['reset_user_delete']['timestamp'] != 0 || $job_check['reset_group_withdraw']['timestamp'] != 0 || $job_check['reset_webspace_cache']['timestamp'] != 0 || $job_check['reset_usage_graph']['timestamp'] != 0) { + $err_msg = ''.$lang['wihladmrs'].':

    ';
    +        $err_lvl = 2;
    +        $err_msg .= reset_status($lang, $job_check);
    +
    +        if (in_array(intval($job_check['reset_user_time']['timestamp']), [0, 4], true) && in_array(intval($job_check['reset_user_delete']['timestamp']), [0, 4], true) && in_array(intval($job_check['reset_group_withdraw']['timestamp']), [0, 4], true) && in_array(intval($job_check['reset_webspace_cache']['timestamp']), [0, 4], true) && in_array(intval($job_check['reset_usage_graph']['timestamp']), [0, 4], true)) {
    +            $err_msg .= '



    '.sprintf($lang['wihladmrs9'], '
    '); + } else { + $err_msg .= '
    '.sprintf($lang['wihladmrs7'], '
    ').'

    '.$lang['wihladmrs8']; + } + } + + if (isset($_POST['confirm']) && isset($db_csrf[$_POST['csrf_token']])) { + if (in_array(intval($job_check['reset_user_time']['timestamp']), [0, 4], true) && in_array(intval($job_check['reset_user_delete']['timestamp']), [0, 4], true) && in_array(intval($job_check['reset_group_withdraw']['timestamp']), [0, 4], true) && in_array(intval($job_check['reset_webspace_cache']['timestamp']), [0, 4], true) && in_array(intval($job_check['reset_usage_graph']['timestamp']), [0, 4], true)) { + if ($mysqlcon->exec("INSERT INTO `$dbname`.`job_check` (`job_name`,`timestamp`) VALUES ('reset_user_time','0'),('reset_user_delete','0'),('reset_group_withdraw','0'),('reset_webspace_cache','0'),('reset_usage_graph','0'),('reset_stop_after','0') ON DUPLICATE KEY UPDATE `timestamp`=VALUES(`timestamp`); DELETE FROM `$dbname`.`csrf_token` WHERE `token`='{$_POST['csrf_token']}'") === false) { + $err_msg = $lang['isntwidbmsg'].print_r($mysqlcon->errorInfo(), true); + $err_lvl = 3; + } else { + $err_msg = $lang['wihladmrs10']; + $err_lvl = null; + } + } else { + $err_msg = $lang['errukwn']; + $err_lvl = 3; + } + } elseif (isset($_POST['update']) && isset($db_csrf[$_POST['csrf_token']])) { + if ($job_check['reset_user_time']['timestamp'] != 0 || $job_check['reset_user_delete']['timestamp'] != 0 || $job_check['reset_group_withdraw']['timestamp'] != 0 || $job_check['reset_webspace_cache']['timestamp'] != 0 || $job_check['reset_usage_graph']['timestamp'] != 0) { + $err_msg = ''.$lang['wihladmrs6'].'

    '.sprintf($lang['wihladmrs7'], '
    ').'

    '.$lang['wihladmrs8']; + $err_lvl = 3; + } elseif ($_POST['reset_user_time'] == 0 && ! isset($_POST['reset_group_withdraw']) && ! isset($_POST['reset_webspace_cache']) && ! isset($_POST['reset_usage_graph'])) { + $err_msg = $lang['wihladmrs15']; + $err_lvl = 3; + } else { + if (($stats_server = $mysqlcon->query("SELECT * FROM `$dbname`.`stats_server`")->fetch()) === false) { + $err_msg .= print_r($mysqlcon->errorInfo(), true); + $err_lvl = 3; + } + if (($groups = $mysqlcon->query("SELECT COUNT(*) AS `count` from `$dbname`.`groups`")->fetch()) === false) { + $err_msg .= print_r($mysqlcon->errorInfo(), true); + $err_lvl = 3; + } + + if (isset($_POST['reset_user_time']) && $_POST['reset_user_time'] == 1) { + $job_check['reset_user_time']['timestamp'] = 1; + } elseif (isset($_POST['reset_user_time']) && $_POST['reset_user_time'] == 2) { + $job_check['reset_user_delete']['timestamp'] = 1; + } + if (isset($_POST['reset_group_withdraw'])) { + $_POST['reset_group_withdraw'] = $job_check['reset_group_withdraw']['timestamp'] = 1; + } else { + $_POST['reset_group_withdraw'] = $job_check['reset_group_withdraw']['timestamp'] = 0; + } + if (isset($_POST['reset_webspace_cache'])) { + $_POST['reset_webspace_cache'] = $job_check['reset_webspace_cache']['timestamp'] = 1; + } else { + $_POST['reset_webspace_cache'] = $job_check['reset_webspace_cache']['timestamp'] = 0; + } + if (isset($_POST['reset_usage_graph'])) { + $_POST['reset_usage_graph'] = $job_check['reset_usage_graph']['timestamp'] = 1; + } else { + $_POST['reset_usage_graph'] = $job_check['reset_usage_graph']['timestamp'] = 0; + } + if (isset($_POST['reset_stop_after'])) { + $_POST['reset_stop_after'] = $job_check['reset_stop_after']['timestamp'] = 1; + } else { + $_POST['reset_stop_after'] = $job_check['reset_stop_after']['timestamp'] = 0; + } + + if ($_POST['reset_group_withdraw'] == 0) { + $delay = 0; + } else { + $delay = ($cfg['teamspeak_query_command_delay'] / 1000000) + 0.05; + } + if ($_POST['reset_webspace_cache'] == 0) { + $cache_needed_time = 0; + } else { + $cache_needed_time = $stats_server['total_user'] / 10 * 0.005; + } + $time_to_begin = 5 * $cfg['teamspeak_query_command_delay'] / 1000000; + $est_time = round($delay * ($stats_server['total_user'] + $groups['count']) + $time_to_begin + $cache_needed_time); + $dtF = new \DateTime('@0'); + $dtT = new \DateTime("@$est_time"); + $est_time = $dtF->diff($dtT)->format($cfg['default_date_format']); + + $err_msg = $lang['wihladmrs11'].': '.$est_time.'.
    '.$lang['wihladmrs12'].'

    ';
    +            $err_msg .= reset_status($lang, $job_check, $check = 1);
    +            $err_msg .= '


    '; + $err_lvl = 1; + } + } elseif (isset($_POST['startjobs']) && isset($db_csrf[$_POST['csrf_token']])) { + if ($_POST['reset_user_time'] == 1) { + $reset_user_time = 1; + $reset_user_delete = 0; + } elseif ($_POST['reset_user_time'] == 2) { + $reset_user_delete = 1; + $reset_user_time = 0; + } else { + $reset_user_time = 0; + $reset_user_delete = 0; + } + + if ($mysqlcon->exec("INSERT INTO `$dbname`.`job_check` (`job_name`,`timestamp`) VALUES ('reset_user_time','{$reset_user_time}'),('reset_user_delete','{$reset_user_delete}'),('reset_group_withdraw','{$_POST['reset_group_withdraw']}'),('reset_webspace_cache','{$_POST['reset_webspace_cache']}'),('reset_usage_graph','{$_POST['reset_usage_graph']}'),('reset_stop_after','{$_POST['reset_stop_after']}') ON DUPLICATE KEY UPDATE `timestamp`=VALUES(`timestamp`); DELETE FROM `$dbname`.`csrf_token` WHERE `token`='{$_POST['csrf_token']}'") === false) { + $err_msg = $lang['isntwidbmsg'].print_r($mysqlcon->errorInfo(), true); + $err_lvl = 3; + } else { + $err_msg = ''.$lang['wihladmrs5'].'

    '.sprintf($lang['wihladmrs7'], '
    ').'

    '.$lang['wihladmrs8']; + $err_lvl = null; + } + } elseif (isset($_POST['update']) || isset($_POST['confirm'])) { + echo '
    ',$lang['errcsrf'],'
    '; + rem_session_ts3(); + exit; + } + ?>
    - +

    - +

    - +
    @@ -231,10 +289,10 @@ function reset_status($lang, $job_check, $check = NULL) {
    @@ -288,10 +346,10 @@ function reset_status($lang, $job_check, $check = NULL) {
    @@ -304,10 +362,10 @@ function reset_status($lang, $job_check, $check = NULL) {
    @@ -320,10 +378,10 @@ function reset_status($lang, $job_check, $check = NULL) { @@ -336,10 +394,10 @@ function reset_status($lang, $job_check, $check = NULL) { @@ -352,10 +410,10 @@ function reset_status($lang, $job_check, $check = NULL) { @@ -368,10 +426,10 @@ function reset_status($lang, $job_check, $check = NULL) { @@ -384,6 +442,7 @@ function reset_status($lang, $job_check, $check = NULL) { - \ No newline at end of file diff --git a/webinterface/resetpassword.php b/webinterface/resetpassword.php index 32dd7bc..6c5adcc 100644 --- a/webinterface/resetpassword.php +++ b/webinterface/resetpassword.php @@ -1,113 +1,125 @@ -exec("INSERT INTO `$dbname`.`csrf_token` (`token`,`timestamp`,`sessionid`) VALUES ('$csrf_token','".time()."','".session_id()."')") === false) { - $err_msg = print_r($mysqlcon->errorInfo(), true); - $err_lvl = 3; - } - - if (($db_csrf = $mysqlcon->query("SELECT * FROM `$dbname`.`csrf_token` WHERE `sessionid`='".session_id()."'")->fetchALL(PDO::FETCH_UNIQUE|PDO::FETCH_ASSOC)) === false) { - $err_msg = print_r($mysqlcon->errorInfo(), true); - $err_lvl = 3; - } - - if (($cfg['webinterface_access_last'] + 1) >= time()) { - $again = $cfg['webinterface_access_last'] + 2 - time(); - $err_msg = sprintf($lang['errlogin2'],$again); - $err_lvl = 3; - } elseif (isset($_POST['resetpw']) && isset($db_csrf[$_POST['csrf_token']]) && ($cfg['webinterface_admin_client_unique_id_list']==NULL || count($cfg['webinterface_admin_client_unique_id_list']) == 0)) { - $err_msg = sprintf($lang['wirtpw1'], 'https://github.com/Newcomer1989/TSN-Ranksystem/wiki#reset-password-webinterface'); $err_lvl=3; - } elseif (isset($_POST['resetpw']) && isset($db_csrf[$_POST['csrf_token']])) { - $nowtime = time(); - $newcount = $cfg['webinterface_access_count'] + 1; - if($mysqlcon->exec("INSERT INTO `$dbname`.`cfg_params` (`param`,`value`) VALUES ('webinterface_access_last','{$nowtime}'),('webinterface_access_count','{$newcount}') ON DUPLICATE KEY UPDATE `value`=VALUES(`value`)") === false) { } - - require_once(dirname(__DIR__).DIRECTORY_SEPARATOR.'libs/ts3_lib/TeamSpeak3.php'); - try { - if($cfg['teamspeak_query_encrypt_switch'] == 1) { - $ts3 = TeamSpeak3::factory("serverquery://".rawurlencode($cfg['teamspeak_query_user']).":".rawurlencode($cfg['teamspeak_query_pass'])."@".$cfg['teamspeak_host_address'].":".$cfg['teamspeak_query_port']."/?server_port=".$cfg['teamspeak_voice_port']."&ssh=1"); - } else { - $ts3 = TeamSpeak3::factory("serverquery://".rawurlencode($cfg['teamspeak_query_user']).":".rawurlencode($cfg['teamspeak_query_pass'])."@".$cfg['teamspeak_host_address'].":".$cfg['teamspeak_query_port']."/?server_port=".$cfg['teamspeak_voice_port']."&blocking=0"); - } - - try { - usleep($cfg['teamspeak_query_command_delay']); - $ts3->selfUpdate(array('client_nickname' => "Ranksystem - Reset Password")); - } catch (Exception $e) { } - - try { - usleep($cfg['teamspeak_query_command_delay']); - $allclients = $ts3->clientList(); - - $pwd = substr(str_shuffle('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789#*+;:-_~?=%&!()'),0,12); - $cfg['webinterface_pass'] = password_hash($pwd, PASSWORD_DEFAULT); - $err_msg = ''; - - foreach($allclients as $client) { - if(array_key_exists(htmlspecialchars($client['client_unique_identifier'], ENT_QUOTES), $cfg['webinterface_admin_client_unique_id_list'])) { - $checkuuid = 1; - if($client['connection_client_ip'] == getclientip()) { - $checkip = 1; - if($mysqlcon->exec("INSERT INTO `$dbname`.`cfg_params` (`param`,`value`) VALUES ('webinterface_pass','{$cfg['webinterface_pass']}'),('webinterface_access_last','0') ON DUPLICATE KEY UPDATE `value`=VALUES(`value`)") === false) { - $err_msg .= $lang['isntwidbmsg'].print_r($mysqlcon->errorInfo(), true); $err_lvl = 3; - } else { - try { - usleep($cfg['teamspeak_query_command_delay']); - $ts3->clientGetByUid($client['client_unique_identifier'])->message(sprintf($lang['wirtpw4'], $cfg['webinterface_user'], $pwd, '[URL=http'.(!empty($_SERVER['HTTPS'])?"s":"").'://'.$_SERVER['SERVER_NAME'].dirname($_SERVER['SCRIPT_NAME']).']','[/URL]')); - $err_msg .= sprintf($lang['wirtpw5'],'',''); $err_lvl = 1; - enter_logfile(3,sprintf($lang['wirtpw6'],getclientip())); - } catch (Exception $e) { - $err_msg .= $lang['errorts3'].$e->getCode().': '.$e->getMessage(); $err_lvl = 3; - } - } - } - } - } - - if (!isset($checkuuid)) { - $err_msg = $lang['wirtpw2']; $err_lvl = 3; - } elseif (!isset($checkip)) { - $err_msg = $lang['wirtpw3']; $err_lvl = 3; - } - } catch (Exception $e) { - $err_msg = $lang['errorts3'].$e->getCode().': '.$e->getMessage(); $err_lvl = 3; - } - } catch (Exception $e) { - $err_msg = $lang['errorts3'].$e->getCode().': '.$e->getMessage(); $err_lvl = 3; - } - } elseif(isset($_POST['resetpw'])) { - echo '
    ',$lang['errcsrf'],'
    '; - rem_session_ts3(); - exit; - } - ?> +exec("INSERT INTO `$dbname`.`csrf_token` (`token`,`timestamp`,`sessionid`) VALUES ('$csrf_token','".time()."','".session_id()."')") === false) { + $err_msg = print_r($mysqlcon->errorInfo(), true); + $err_lvl = 3; + } + + if (($db_csrf = $mysqlcon->query("SELECT * FROM `$dbname`.`csrf_token` WHERE `sessionid`='".session_id()."'")->fetchALL(PDO::FETCH_UNIQUE | PDO::FETCH_ASSOC)) === false) { + $err_msg = print_r($mysqlcon->errorInfo(), true); + $err_lvl = 3; + } + + if (($cfg['webinterface_access_last'] + 1) >= time()) { + $again = $cfg['webinterface_access_last'] + 2 - time(); + $err_msg = sprintf($lang['errlogin2'], $again); + $err_lvl = 3; + } elseif (isset($_POST['resetpw']) && isset($db_csrf[$_POST['csrf_token']]) && ($cfg['webinterface_admin_client_unique_id_list'] == null || count($cfg['webinterface_admin_client_unique_id_list']) == 0)) { + $err_msg = sprintf($lang['wirtpw1'], 'https://github.com/Newcomer1989/TSN-Ranksystem/wiki#reset-password-webinterface'); + $err_lvl = 3; + } elseif (isset($_POST['resetpw']) && isset($db_csrf[$_POST['csrf_token']])) { + $nowtime = time(); + $newcount = $cfg['webinterface_access_count'] + 1; + if ($mysqlcon->exec("INSERT INTO `$dbname`.`cfg_params` (`param`,`value`) VALUES ('webinterface_access_last','{$nowtime}'),('webinterface_access_count','{$newcount}') ON DUPLICATE KEY UPDATE `value`=VALUES(`value`)") === false) { + } + + require_once dirname(__DIR__).DIRECTORY_SEPARATOR.'libs/ts3_lib/TeamSpeak3.php'; + try { + if ($cfg['teamspeak_query_encrypt_switch'] == 1) { + $ts3 = TeamSpeak3::factory('serverquery://'.rawurlencode($cfg['teamspeak_query_user']).':'.rawurlencode($cfg['teamspeak_query_pass']).'@'.$cfg['teamspeak_host_address'].':'.$cfg['teamspeak_query_port'].'/?server_port='.$cfg['teamspeak_voice_port'].'&ssh=1'); + } else { + $ts3 = TeamSpeak3::factory('serverquery://'.rawurlencode($cfg['teamspeak_query_user']).':'.rawurlencode($cfg['teamspeak_query_pass']).'@'.$cfg['teamspeak_host_address'].':'.$cfg['teamspeak_query_port'].'/?server_port='.$cfg['teamspeak_voice_port'].'&blocking=0'); + } + + try { + usleep($cfg['teamspeak_query_command_delay']); + $ts3->selfUpdate(['client_nickname' => 'Ranksystem - Reset Password']); + } catch (Exception $e) { + } + + try { + usleep($cfg['teamspeak_query_command_delay']); + $allclients = $ts3->clientList(); + + $pwd = substr(str_shuffle('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789#*+;:-_~?=%&!()'), 0, 12); + $cfg['webinterface_pass'] = password_hash($pwd, PASSWORD_DEFAULT); + $err_msg = ''; + + foreach ($allclients as $client) { + if (array_key_exists(htmlspecialchars($client['client_unique_identifier'], ENT_QUOTES), $cfg['webinterface_admin_client_unique_id_list'])) { + $checkuuid = 1; + if ($client['connection_client_ip'] == getclientip()) { + $checkip = 1; + if ($mysqlcon->exec("INSERT INTO `$dbname`.`cfg_params` (`param`,`value`) VALUES ('webinterface_pass','{$cfg['webinterface_pass']}'),('webinterface_access_last','0') ON DUPLICATE KEY UPDATE `value`=VALUES(`value`)") === false) { + $err_msg .= $lang['isntwidbmsg'].print_r($mysqlcon->errorInfo(), true); + $err_lvl = 3; + } else { + try { + usleep($cfg['teamspeak_query_command_delay']); + $ts3->clientGetByUid($client['client_unique_identifier'])->message(sprintf($lang['wirtpw4'], $cfg['webinterface_user'], $pwd, '[URL=http'.(! empty($_SERVER['HTTPS']) ? 's' : '').'://'.$_SERVER['SERVER_NAME'].dirname($_SERVER['SCRIPT_NAME']).']', '[/URL]')); + $err_msg .= sprintf($lang['wirtpw5'], '', ''); + $err_lvl = 1; + enter_logfile(3, sprintf($lang['wirtpw6'], getclientip())); + } catch (Exception $e) { + $err_msg .= $lang['errorts3'].$e->getCode().': '.$e->getMessage(); + $err_lvl = 3; + } + } + } + } + } + + if (! isset($checkuuid)) { + $err_msg = $lang['wirtpw2']; + $err_lvl = 3; + } elseif (! isset($checkip)) { + $err_msg = $lang['wirtpw3']; + $err_lvl = 3; + } + } catch (Exception $e) { + $err_msg = $lang['errorts3'].$e->getCode().': '.$e->getMessage(); + $err_lvl = 3; + } + } catch (Exception $e) { + $err_msg = $lang['errorts3'].$e->getCode().': '.$e->getMessage(); + $err_lvl = 3; + } + } elseif (isset($_POST['resetpw'])) { + echo '
    ',$lang['errcsrf'],'
    '; + rem_session_ts3(); + exit; + } + ?>
    - +
    @@ -301,10 +325,10 @@ @@ -317,10 +341,10 @@ @@ -333,10 +357,10 @@ @@ -346,6 +370,7 @@ - \ No newline at end of file diff --git a/webinterface/ts.php b/webinterface/ts.php index 42ca402..509b884 100644 --- a/webinterface/ts.php +++ b/webinterface/ts.php @@ -1,89 +1,96 @@ -exec("INSERT INTO `$dbname`.`csrf_token` (`token`,`timestamp`,`sessionid`) VALUES ('$csrf_token','".time()."','".session_id()."')") === false) { - $err_msg = print_r($mysqlcon->errorInfo(), true); - $err_lvl = 3; - } - - if (($db_csrf = $mysqlcon->query("SELECT * FROM `$dbname`.`csrf_token` WHERE `sessionid`='".session_id()."'")->fetchALL(PDO::FETCH_UNIQUE|PDO::FETCH_ASSOC)) === false) { - $err_msg = print_r($mysqlcon->errorInfo(), true); - $err_lvl = 3; - } - - $monthago = time() - 2592000; - if(($user_arr = $mysqlcon->query("SELECT `uuid`,`cldbid`,`name` FROM `$dbname`.`user` WHERE `lastseen`>'{$monthago}' ORDER BY `name` ASC")->fetchAll(PDO::FETCH_ASSOC)) === false) { - $err_msg = print_r($mysqlcon->errorInfo(), true); - $err_lvl = 3; - } - - if(($channellist = $mysqlcon->query("SELECT * FROM `$dbname`.`channel` ORDER BY `pid`,`channel_order`,`channel_name` ASC")->fetchAll(PDO::FETCH_UNIQUE|PDO::FETCH_ASSOC)) === false) { - $err_msg = print_r($mysqlcon->errorInfo(), true); - $err_lvl = 3; - } - - if (isset($_POST['update']) && isset($db_csrf[$_POST['csrf_token']])) { - $cfg['webinterface_admin_client_unique_id_list'] = ''; - if(is_array($_POST['channelid'])) $_POST['channelid'] = $_POST['channelid'][0]; - - if (isset($_POST['webinterface_admin_client_unique_id_list']) && $_POST['webinterface_admin_client_unique_id_list'] != NULL) { - $cfg['webinterface_admin_client_unique_id_list'] = implode(',',$_POST['webinterface_admin_client_unique_id_list']); - } - - if(isset($_POST['teamspeak_host_address']) && $_POST['teamspeak_host_address'] != NULL) { - $cfg['teamspeak_host_address'] = preg_replace('/\s/', '', $_POST['teamspeak_host_address']); - } else { - $cfg['teamspeak_host_address'] = ''; - } - $cfg['teamspeak_query_port'] = $_POST['teamspeak_query_port']; - if (isset($_POST['teamspeak_query_encrypt_switch'])) $cfg['teamspeak_query_encrypt_switch'] = 1; else $cfg['teamspeak_query_encrypt_switch'] = 0; - $cfg['teamspeak_voice_port'] = $_POST['teamspeak_voice_port']; - $cfg['teamspeak_query_user'] = htmlspecialchars($_POST['teamspeak_query_user'], ENT_QUOTES); - $cfg['teamspeak_query_pass'] = htmlspecialchars($_POST['teamspeak_query_pass'], ENT_QUOTES); - $cfg['teamspeak_query_nickname'] = htmlspecialchars($_POST['teamspeak_query_nickname'], ENT_QUOTES); - $cfg['teamspeak_default_channel_id'] = $_POST['channelid']; - $cfg['teamspeak_query_command_delay'] = $_POST['teamspeak_query_command_delay']; - $cfg['teamspeak_avatar_download_delay']= $_POST['teamspeak_avatar_download_delay']; - if(isset($_POST['teamspeak_chatcommand_prefix']) && $_POST['teamspeak_chatcommand_prefix'] != NULL) { - $cfg['teamspeak_chatcommand_prefix'] = htmlspecialchars($_POST['teamspeak_chatcommand_prefix'], ENT_QUOTES); - } else { - $cfg['teamspeak_chatcommand_prefix'] = "!"; - } - - if ($mysqlcon->exec("INSERT INTO `$dbname`.`cfg_params` (`param`,`value`) VALUES ('teamspeak_host_address','{$cfg['teamspeak_host_address']}'),('teamspeak_query_encrypt_switch','{$cfg['teamspeak_query_encrypt_switch']}'),('teamspeak_query_port','{$cfg['teamspeak_query_port']}'),('teamspeak_voice_port','{$cfg['teamspeak_voice_port']}'),('teamspeak_query_user','{$cfg['teamspeak_query_user']}'),('teamspeak_query_pass','{$cfg['teamspeak_query_pass']}'),('teamspeak_query_nickname','{$cfg['teamspeak_query_nickname']}'),('teamspeak_default_channel_id','{$cfg['teamspeak_default_channel_id']}'),('teamspeak_query_command_delay','{$cfg['teamspeak_query_command_delay']}'),('teamspeak_avatar_download_delay','{$cfg['teamspeak_avatar_download_delay']}'),('webinterface_admin_client_unique_id_list','{$cfg['webinterface_admin_client_unique_id_list']}'),('teamspeak_chatcommand_prefix','{$cfg['teamspeak_chatcommand_prefix']}') ON DUPLICATE KEY UPDATE `value`=VALUES(`value`); DELETE FROM `$dbname`.`csrf_token` WHERE `token`='{$_POST['csrf_token']}'") === false) { - $err_msg = print_r($mysqlcon->errorInfo(), true); - $err_lvl = 3; - } else { - $err_msg = $lang['wisvsuc']." ".sprintf($lang['wisvres'], ''); - $err_lvl = NULL; - } - - if (isset($_POST['webinterface_admin_client_unique_id_list']) && $_POST['webinterface_admin_client_unique_id_list'] != NULL) { - $cfg['webinterface_admin_client_unique_id_list'] = array_flip($_POST['webinterface_admin_client_unique_id_list']); - } - - } elseif(isset($_POST['update'])) { - echo '
    ',$lang['errcsrf'],'
    '; - rem_session_ts3(); - exit; - } - ?> +exec("INSERT INTO `$dbname`.`csrf_token` (`token`,`timestamp`,`sessionid`) VALUES ('$csrf_token','".time()."','".session_id()."')") === false) { + $err_msg = print_r($mysqlcon->errorInfo(), true); + $err_lvl = 3; + } + + if (($db_csrf = $mysqlcon->query("SELECT * FROM `$dbname`.`csrf_token` WHERE `sessionid`='".session_id()."'")->fetchALL(PDO::FETCH_UNIQUE | PDO::FETCH_ASSOC)) === false) { + $err_msg = print_r($mysqlcon->errorInfo(), true); + $err_lvl = 3; + } + + $monthago = time() - 2592000; + if (($user_arr = $mysqlcon->query("SELECT `uuid`,`cldbid`,`name` FROM `$dbname`.`user` WHERE `lastseen`>'{$monthago}' ORDER BY `name` ASC")->fetchAll(PDO::FETCH_ASSOC)) === false) { + $err_msg = print_r($mysqlcon->errorInfo(), true); + $err_lvl = 3; + } + + if (($channellist = $mysqlcon->query("SELECT * FROM `$dbname`.`channel` ORDER BY `pid`,`channel_order`,`channel_name` ASC")->fetchAll(PDO::FETCH_UNIQUE | PDO::FETCH_ASSOC)) === false) { + $err_msg = print_r($mysqlcon->errorInfo(), true); + $err_lvl = 3; + } + + if (isset($_POST['update']) && isset($db_csrf[$_POST['csrf_token']])) { + $cfg['webinterface_admin_client_unique_id_list'] = ''; + if (is_array($_POST['channelid'])) { + $_POST['channelid'] = $_POST['channelid'][0]; + } + + if (isset($_POST['webinterface_admin_client_unique_id_list']) && $_POST['webinterface_admin_client_unique_id_list'] != null) { + $cfg['webinterface_admin_client_unique_id_list'] = implode(',', $_POST['webinterface_admin_client_unique_id_list']); + } + + if (isset($_POST['teamspeak_host_address']) && $_POST['teamspeak_host_address'] != null) { + $cfg['teamspeak_host_address'] = preg_replace('/\s/', '', $_POST['teamspeak_host_address']); + } else { + $cfg['teamspeak_host_address'] = ''; + } + $cfg['teamspeak_query_port'] = $_POST['teamspeak_query_port']; + if (isset($_POST['teamspeak_query_encrypt_switch'])) { + $cfg['teamspeak_query_encrypt_switch'] = 1; + } else { + $cfg['teamspeak_query_encrypt_switch'] = 0; + } + $cfg['teamspeak_voice_port'] = $_POST['teamspeak_voice_port']; + $cfg['teamspeak_query_user'] = htmlspecialchars($_POST['teamspeak_query_user'], ENT_QUOTES); + $cfg['teamspeak_query_pass'] = htmlspecialchars($_POST['teamspeak_query_pass'], ENT_QUOTES); + $cfg['teamspeak_query_nickname'] = htmlspecialchars($_POST['teamspeak_query_nickname'], ENT_QUOTES); + $cfg['teamspeak_default_channel_id'] = $_POST['channelid']; + $cfg['teamspeak_query_command_delay'] = $_POST['teamspeak_query_command_delay']; + $cfg['teamspeak_avatar_download_delay'] = $_POST['teamspeak_avatar_download_delay']; + if (isset($_POST['teamspeak_chatcommand_prefix']) && $_POST['teamspeak_chatcommand_prefix'] != null) { + $cfg['teamspeak_chatcommand_prefix'] = htmlspecialchars($_POST['teamspeak_chatcommand_prefix'], ENT_QUOTES); + } else { + $cfg['teamspeak_chatcommand_prefix'] = '!'; + } + + if ($mysqlcon->exec("INSERT INTO `$dbname`.`cfg_params` (`param`,`value`) VALUES ('teamspeak_host_address','{$cfg['teamspeak_host_address']}'),('teamspeak_query_encrypt_switch','{$cfg['teamspeak_query_encrypt_switch']}'),('teamspeak_query_port','{$cfg['teamspeak_query_port']}'),('teamspeak_voice_port','{$cfg['teamspeak_voice_port']}'),('teamspeak_query_user','{$cfg['teamspeak_query_user']}'),('teamspeak_query_pass','{$cfg['teamspeak_query_pass']}'),('teamspeak_query_nickname','{$cfg['teamspeak_query_nickname']}'),('teamspeak_default_channel_id','{$cfg['teamspeak_default_channel_id']}'),('teamspeak_query_command_delay','{$cfg['teamspeak_query_command_delay']}'),('teamspeak_avatar_download_delay','{$cfg['teamspeak_avatar_download_delay']}'),('webinterface_admin_client_unique_id_list','{$cfg['webinterface_admin_client_unique_id_list']}'),('teamspeak_chatcommand_prefix','{$cfg['teamspeak_chatcommand_prefix']}') ON DUPLICATE KEY UPDATE `value`=VALUES(`value`); DELETE FROM `$dbname`.`csrf_token` WHERE `token`='{$_POST['csrf_token']}'") === false) { + $err_msg = print_r($mysqlcon->errorInfo(), true); + $err_lvl = 3; + } else { + $err_msg = $lang['wisvsuc'].' '.sprintf($lang['wisvres'], '
    '); + $err_lvl = null; + } + + if (isset($_POST['webinterface_admin_client_unique_id_list']) && $_POST['webinterface_admin_client_unique_id_list'] != null) { + $cfg['webinterface_admin_client_unique_id_list'] = array_flip($_POST['webinterface_admin_client_unique_id_list']); + } + } elseif (isset($_POST['update'])) { + echo '
    ',$lang['errcsrf'],'
    '; + rem_session_ts3(); + exit; + } + ?>
    - +

    - +

    - +
    @@ -98,11 +105,11 @@
    - '; - } else { - echo ''; - } ?> + '; + } else { + echo ''; + } ?>
    @@ -173,9 +180,9 @@
    - +
     
    @@ -183,15 +190,33 @@
    @@ -210,30 +235,38 @@
    - +
     
    - " minlength="1" maxlength="30" required> +
    - +
    @@ -256,10 +289,10 @@ @@ -272,10 +305,10 @@ @@ -288,10 +321,10 @@ @@ -304,10 +337,10 @@ @@ -320,10 +353,10 @@ @@ -336,10 +369,10 @@ @@ -352,10 +385,10 @@ @@ -368,10 +401,10 @@ @@ -384,10 +417,10 @@ @@ -400,10 +433,10 @@ @@ -416,10 +449,10 @@ @@ -432,10 +465,10 @@ @@ -457,6 +490,7 @@ - \ No newline at end of file diff --git a/worker.php b/worker.php index fefb70c..1ed5280 100644 --- a/worker.php +++ b/worker.php @@ -1,223 +1,244 @@ -nul", $result); - if(isset($result[1]) && is_numeric($result[1])) { - return TRUE; - } else { - return FALSE; - } - } else { - if (file_exists($GLOBALS['pidfile'])) { - $pid = str_replace(array("\r", "\n"), '', file_get_contents($GLOBALS['pidfile'])); - exec("wmic process where \"processid=".$pid."\" get processid 2>nul", $result); - if(isset($result[1]) && is_numeric($result[1])) { - return TRUE; - } else { - return FALSE; - } - } else { - return FALSE; - } - } - } else { - if(!empty($pid)) { - $result = str_replace(array("\r", "\n"), '', shell_exec("ps ".$pid)); - if (strstr($result, $pid)) { - return TRUE; - } else { - return FALSE; - } - } else { - if (file_exists($GLOBALS['pidfile'])) { - $check_pid = str_replace(array("\r", "\n"), '', file_get_contents($GLOBALS['pidfile'])); - $result = str_replace(array("\r", "\n"), '', shell_exec("ps ".$check_pid)); - if (strstr($result, $check_pid)) { - return TRUE; - } else { - return FALSE; - } - } else { - return FALSE; - } - } - } -} - -function start($delay = 0) { - usleep($delay); - global $phpcommand; - if(isset($_SERVER['USER']) && $_SERVER['USER'] == "root" || isset($_SERVER['USERNAME']) && $_SERVER['USERNAME'] == "administrator") { - echo "\n !!!! Do not start the Ranksystem with root privileges !!!!\n\n"; - echo " Start Ranksystem Bot in 10 seconds...\n\n"; - sleep(10); - } - - if(!is_writable($GLOBALS['logpath'])) { - echo "\n !!!! Logs folder is not writable !!!!\n\n"; - echo " Cancel start request...\n\n"; - exit; - } - - if(file_exists($GLOBALS['logfile']) && !is_writable($GLOBALS['logfile'])) { - echo "\n !!!! Log file is not writable !!!!\n\n"; - echo " Cancel start request...\n\n"; - exit; - } - - if (substr(php_uname(), 0, 7) == "Windows") { - if (checkProcess() == FALSE) { - echo "Starting the Ranksystem Bot."; - try { - $WshShell = new COM("WScript.Shell"); - } catch (Exception $e) { - echo "\n Error due loading the PHP COM module (wrong server configuration!): ",$e->getMessage(),"\n"; - } - try { - $wcmd = "cmd /C ".$phpcommand." ".__DIR__."\jobs\bot.php"; - $oExec = $WshShell->Run($wcmd, 0, false); - } catch (Exception $e) { - echo "\n Error due starting Bot (exec command enabled?): ",$e->getMessage(),"\n"; - } - try { - exec("wmic process where \"Name LIKE \"%php%\" AND CommandLine LIKE \"%bot.php%\"\" get ProcessId", $pid); - } catch (Exception $e) { - echo "\n Error due getting process list (wmic command enabled?): ",$e->getMessage(),"\n"; - } - if(isset($pid[1]) && is_numeric($pid[1])) { - exec("echo ".$pid[1]." > ".$GLOBALS['pidfile']); - echo " [OK]"; - if (file_exists($GLOBALS['autostart'])) { - unlink($GLOBALS['autostart']); - } - } else { - echo " [Failed]\n"; - } - } else { - echo "The Ranksystem is already running.\n"; - } - $GLOBALS['exec'] = TRUE; - } else { - if (checkProcess() == FALSE) { - echo "Starting the Ranksystem Bot."; - exec($phpcommand." ".__DIR__."/jobs/bot.php >/dev/null 2>&1 & echo $! > ".$GLOBALS['pidfile']); - if (checkProcess() == FALSE) { - echo " [Failed]\n"; - } else { - echo " [OK]\n"; - if (file_exists($GLOBALS['autostart'])) { - unlink($GLOBALS['autostart']); - } - } - } else { - echo "The Ranksystem is already running.\n"; - } - $GLOBALS['exec'] = TRUE; - } -} - -function stop() { - if (checkProcess() == TRUE) { - echo "Stopping the Ranksystem Bot.\n"; - $pid = str_replace(array("\r", "\n"), '', file_get_contents($GLOBALS['pidfile'])); - unlink($GLOBALS['pidfile']); - echo "Wait until Bot is down"; - $count_check=0; - while (checkProcess($pid) == TRUE) { - sleep(1); - echo "."; - $count_check ++; - if($count_check > 10) { - if (substr(php_uname(), 0, 7) == "Windows") { - exec("taskkill /F /PID ".$pid); - } else { - exec("kill -9 ".$pid); - } - echo "Stop command received! Bot does not react, process killed!"; - break; - } - } - if (checkProcess($pid) == TRUE) { - echo " [Failed]\n"; - } else { - file_put_contents($GLOBALS['autostart'],""); - echo " [OK]\n"; - } - } else { - if(is_file($GLOBALS['pidfile'])) { - unlink($GLOBALS['pidfile']); - } - echo "The Ranksystem seems not running.\n"; - } - $GLOBALS['exec'] = TRUE; -} - -function check() { - if (checkProcess() == FALSE) { - if (!file_exists($GLOBALS['autostart'])) { - if (file_exists($GLOBALS['pidfile'])) { - unlink($GLOBALS['pidfile']); - } - start(); - } else { - echo "Starting the Ranksystem Bot. [Failed]\nAutostart is deactivated. Use start command instead.\n"; - } - } - $GLOBALS['exec'] = TRUE; -} - -function restart() { - stop(); - start(); - $GLOBALS['exec'] = TRUE; -} - -function status() { - if (checkProcess() == FALSE) { - echo "The Ranksystem Bot is stopped.\n"; - } else { - echo "The Ranksystem process is running.\n"; - } - $GLOBALS['exec'] = TRUE; -} - -function help() { - echo " Usage: php worker.php {start|stop|restart|check|status}\n\n", - "\t* start \t\t [start Ranksystem Bot]\n", - "\t* stop \t\t [stop Ranksystem Bot]\n", - "\t* restart \t\t [restart Ranksystem Bot]\n", - "\t* check \t\t [check Ranksystem Bot is running; if not, start it; no output if all is ok]\n", - "\t* status \t\t [output status Ranksystem Bot]\n"; - $GLOBALS['exec'] = TRUE; -} - -if (isset($_SERVER['argv'][1]) == 0) { - help(); -} else { - $cmd = $_SERVER['argv'][1]; - if(isset($_SERVER['argv'][2]) && is_numeric($_SERVER['argv'][2]) && $cmd == 'start') { - start($_SERVER['argv'][2]); - } elseif ($cmd == 'start') { - start(); - } - if ($cmd == 'stop') stop(); - if ($cmd == 'restart') restart(); - if ($cmd == 'check') check(); - if ($cmd == 'status') status(); - if ($cmd == 'help') help(); - - if ($GLOBALS['exec'] == FALSE) echo " Error parameter '$cmd' not valid. Type \"php worker.php help\" to get a list of valid parameter.\n"; -} -?> \ No newline at end of file +nul', $result); + if (isset($result[1]) && is_numeric($result[1])) { + return true; + } else { + return false; + } + } else { + if (file_exists($GLOBALS['pidfile'])) { + $pid = str_replace(["\r", "\n"], '', file_get_contents($GLOBALS['pidfile'])); + exec('wmic process where "processid='.$pid.'" get processid 2>nul', $result); + if (isset($result[1]) && is_numeric($result[1])) { + return true; + } else { + return false; + } + } else { + return false; + } + } + } else { + if (! empty($pid)) { + $result = str_replace(["\r", "\n"], '', shell_exec('ps '.$pid)); + if (strstr($result, $pid)) { + return true; + } else { + return false; + } + } else { + if (file_exists($GLOBALS['pidfile'])) { + $check_pid = str_replace(["\r", "\n"], '', file_get_contents($GLOBALS['pidfile'])); + $result = str_replace(["\r", "\n"], '', shell_exec('ps '.$check_pid)); + if (strstr($result, $check_pid)) { + return true; + } else { + return false; + } + } else { + return false; + } + } + } +} + +function start($delay = 0) +{ + usleep($delay); + global $phpcommand; + if (isset($_SERVER['USER']) && $_SERVER['USER'] == 'root' || isset($_SERVER['USERNAME']) && $_SERVER['USERNAME'] == 'administrator') { + echo "\n !!!! Do not start the Ranksystem with root privileges !!!!\n\n"; + echo " Start Ranksystem Bot in 10 seconds...\n\n"; + sleep(10); + } + + if (! is_writable($GLOBALS['logpath'])) { + echo "\n !!!! Logs folder is not writable !!!!\n\n"; + echo " Cancel start request...\n\n"; + exit; + } + + if (file_exists($GLOBALS['logfile']) && ! is_writable($GLOBALS['logfile'])) { + echo "\n !!!! Log file is not writable !!!!\n\n"; + echo " Cancel start request...\n\n"; + exit; + } + + if (substr(php_uname(), 0, 7) == 'Windows') { + if (checkProcess() == false) { + echo 'Starting the Ranksystem Bot.'; + try { + $WshShell = new COM('WScript.Shell'); + } catch (Exception $e) { + echo "\n Error due loading the PHP COM module (wrong server configuration!): ",$e->getMessage(),"\n"; + } + try { + $wcmd = 'cmd /C '.$phpcommand.' '.__DIR__."\jobs\bot.php"; + $oExec = $WshShell->Run($wcmd, 0, false); + } catch (Exception $e) { + echo "\n Error due starting Bot (exec command enabled?): ",$e->getMessage(),"\n"; + } + try { + exec('wmic process where "Name LIKE "%php%" AND CommandLine LIKE "%bot.php%"" get ProcessId', $pid); + } catch (Exception $e) { + echo "\n Error due getting process list (wmic command enabled?): ",$e->getMessage(),"\n"; + } + if (isset($pid[1]) && is_numeric($pid[1])) { + exec('echo '.$pid[1].' > '.$GLOBALS['pidfile']); + echo ' [OK]'; + if (file_exists($GLOBALS['autostart'])) { + unlink($GLOBALS['autostart']); + } + } else { + echo " [Failed]\n"; + } + } else { + echo "The Ranksystem is already running.\n"; + } + $GLOBALS['exec'] = true; + } else { + if (checkProcess() == false) { + echo 'Starting the Ranksystem Bot.'; + exec($phpcommand.' '.__DIR__.'/jobs/bot.php >/dev/null 2>&1 & echo $! > '.$GLOBALS['pidfile']); + if (checkProcess() == false) { + echo " [Failed]\n"; + } else { + echo " [OK]\n"; + if (file_exists($GLOBALS['autostart'])) { + unlink($GLOBALS['autostart']); + } + } + } else { + echo "The Ranksystem is already running.\n"; + } + $GLOBALS['exec'] = true; + } +} + +function stop() +{ + if (checkProcess() == true) { + echo "Stopping the Ranksystem Bot.\n"; + $pid = str_replace(["\r", "\n"], '', file_get_contents($GLOBALS['pidfile'])); + unlink($GLOBALS['pidfile']); + echo 'Wait until Bot is down'; + $count_check = 0; + while (checkProcess($pid) == true) { + sleep(1); + echo '.'; + $count_check++; + if ($count_check > 10) { + if (substr(php_uname(), 0, 7) == 'Windows') { + exec('taskkill /F /PID '.$pid); + } else { + exec('kill -9 '.$pid); + } + echo 'Stop command received! Bot does not react, process killed!'; + break; + } + } + if (checkProcess($pid) == true) { + echo " [Failed]\n"; + } else { + file_put_contents($GLOBALS['autostart'], ''); + echo " [OK]\n"; + } + } else { + if (is_file($GLOBALS['pidfile'])) { + unlink($GLOBALS['pidfile']); + } + echo "The Ranksystem seems not running.\n"; + } + $GLOBALS['exec'] = true; +} + +function check() +{ + if (checkProcess() == false) { + if (! file_exists($GLOBALS['autostart'])) { + if (file_exists($GLOBALS['pidfile'])) { + unlink($GLOBALS['pidfile']); + } + start(); + } else { + echo "Starting the Ranksystem Bot. [Failed]\nAutostart is deactivated. Use start command instead.\n"; + } + } + $GLOBALS['exec'] = true; +} + +function restart() +{ + stop(); + start(); + $GLOBALS['exec'] = true; +} + +function status() +{ + if (checkProcess() == false) { + echo "The Ranksystem Bot is stopped.\n"; + } else { + echo "The Ranksystem process is running.\n"; + } + $GLOBALS['exec'] = true; +} + +function help() +{ + echo " Usage: php worker.php {start|stop|restart|check|status}\n\n", + "\t* start \t\t [start Ranksystem Bot]\n", + "\t* stop \t\t [stop Ranksystem Bot]\n", + "\t* restart \t\t [restart Ranksystem Bot]\n", + "\t* check \t\t [check Ranksystem Bot is running; if not, start it; no output if all is ok]\n", + "\t* status \t\t [output status Ranksystem Bot]\n"; + $GLOBALS['exec'] = true; +} + +if (isset($_SERVER['argv'][1]) == 0) { + help(); +} else { + $cmd = $_SERVER['argv'][1]; + if (isset($_SERVER['argv'][2]) && is_numeric($_SERVER['argv'][2]) && $cmd == 'start') { + start($_SERVER['argv'][2]); + } elseif ($cmd == 'start') { + start(); + } + if ($cmd == 'stop') { + stop(); + } + if ($cmd == 'restart') { + restart(); + } + if ($cmd == 'check') { + check(); + } + if ($cmd == 'status') { + status(); + } + if ($cmd == 'help') { + help(); + } + + if ($GLOBALS['exec'] == false) { + echo " Error parameter '$cmd' not valid. Type \"php worker.php help\" to get a list of valid parameter.\n"; + } +}