/data/custom/templates/DefaultRevamp/monitoring/index.tpl
{extends file='monitoring/layouts/main.tpl'}
{block name='content'}
{include file='monitoring/partials/filter_field.tpl'}
<div class="ui stackable grid">
{if $SERVERS|@count}
<div class="sixteen wide column">
{foreach $SERVERS as $server}
{assign var='card' value=mon_setting('server_card_template','server_card.tpl')}
{include file='monitoring/partials/'|cat:$card server=$server}
{/foreach}
</div>
{/if}
{if $PAGINATION['active']}
<div class="row">
<div class="ui pagination menu">
<a href="{$PAGINATION['pages']['prev']}"
class="icon item {if !$PAGINATION['pages']['prev']} disabled {/if}">
<i class="angle left icon"></i>
</a>
{foreach $PAGINATION['links'] as $page}
<a href="{$page['url']}" class="item {if $page['active']} active {/if}">
{$page['label']}
</a>
{/foreach}
<a href="{$PAGINATION['pages']['next']}"
/data/vendor/smarty/smarty/libs/sysplugins/smarty_security.php
public function __construct($smarty)
{
$this->smarty = $smarty;
}
/**
* Check if PHP function is trusted.
*
* @param string $function_name
* @param object $compiler compiler object
* @deprecated
* @return boolean true if function is trusted
*/
public function isTrustedPhpFunction($function_name, $compiler)
{
if (isset($this->php_functions)
&& (empty($this->php_functions) || in_array($function_name, $this->php_functions))
) {
return true;
}
$compiler->trigger_template_error("PHP function '{$function_name}' not allowed by security setting");
return false; // should not, but who knows what happens to the compiler in the future?
}
/**
* Check if static class is trusted.
*
* @param string $class_name
* @param object $compiler compiler object
*
* @return boolean true if class is trusted
*/
public function isTrustedStaticClass($class_name, $compiler)
{
if (isset($this->static_classes)
&& (empty($this->static_classes) || in_array($class_name, $this->static_classes))
) {
return true;
}
$compiler->trigger_template_error("access to static class '{$class_name}' not allowed by security setting");
return false; // should not, but who knows what happens to the compiler in the future?
/data/vendor/smarty/smarty/libs/sysplugins/smarty_internal_templatecompilerbase.php
*
* @return string
*/
public function compileConfigVariable($variable)
{
// return '$_smarty_tpl->config_vars[' . $variable . ']';
return '$_smarty_tpl->smarty->ext->configLoad->_getConfigVariable($_smarty_tpl, ' . $variable . ')';
}
/**
* compile PHP function call
*
* @param string $name
* @param array $parameter
*
* @return string
* @throws \SmartyCompilerException
*/
public function compilePHPFunctionCall($name, $parameter)
{
if (!$this->smarty->security_policy || $this->smarty->security_policy->isTrustedPhpFunction($name, $this)) {
if (strcasecmp($name, 'isset') === 0 || strcasecmp($name, 'empty') === 0
|| strcasecmp($name, 'array') === 0 || is_callable($name)
) {
$func_name = smarty_strtolower_ascii($name);
if ($func_name === 'isset') {
if (count($parameter) === 0) {
$this->trigger_template_error('Illegal number of parameter in "isset()"');
}
$pa = array();
foreach ($parameter as $p) {
$pa[] = $this->syntaxMatchesVariable($p) ? 'isset(' . $p . ')' : '(' . $p . ' !== null )';
}
return '(' . implode(' && ', $pa) . ')';
} elseif (in_array(
$func_name,
array(
'empty',
/data/vendor/smarty/smarty/libs/sysplugins/smarty_internal_templateparser.php
// line 1001 "../smarty/lexer/smarty_internal_templateparser.y"
public function yy_r140(){
if ($this->security) {
$this->compiler->trigger_template_error (self::ERR2);
}
$this->_retvalue = '->{'.$this->yystack[$this->yyidx + -2]->minor.$this->yystack[$this->yyidx + 0]->minor.'}';
}
// line 1008 "../smarty/lexer/smarty_internal_templateparser.y"
public function yy_r141(){
if ($this->security) {
$this->compiler->trigger_template_error (self::ERR2);
}
$this->_retvalue = '->{\''.$this->yystack[$this->yyidx + -4]->minor.'\'.'.$this->yystack[$this->yyidx + -2]->minor.$this->yystack[$this->yyidx + 0]->minor.'}';
}
// line 1016 "../smarty/lexer/smarty_internal_templateparser.y"
public function yy_r142(){
$this->_retvalue = '->'.$this->yystack[$this->yyidx + 0]->minor;
}
// line 1024 "../smarty/lexer/smarty_internal_templateparser.y"
public function yy_r143(){
$this->_retvalue = $this->compiler->compilePHPFunctionCall($this->yystack[$this->yyidx + -3]->minor, $this->yystack[$this->yyidx + -1]->minor);
}
// line 1032 "../smarty/lexer/smarty_internal_templateparser.y"
public function yy_r144(){
if ($this->security && substr($this->yystack[$this->yyidx + -3]->minor,0,1) === '_') {
$this->compiler->trigger_template_error (self::ERR1);
}
$this->_retvalue = $this->yystack[$this->yyidx + -3]->minor . '('. implode(',',$this->yystack[$this->yyidx + -1]->minor) .')';
}
// line 1039 "../smarty/lexer/smarty_internal_templateparser.y"
public function yy_r145(){
if ($this->security) {
$this->compiler->trigger_template_error (self::ERR2);
}
$prefixVar = $this->compiler->getNewPrefixVariable();
$this->compiler->appendPrefixCode("<?php {$prefixVar} = ".$this->compiler->compileVariable('\''.substr($this->yystack[$this->yyidx + -3]->minor,1).'\'').';?>');
$this->_retvalue = $prefixVar .'('. implode(',',$this->yystack[$this->yyidx + -1]->minor) .')';
}
// line 1050 "../smarty/lexer/smarty_internal_templateparser.y"
public function yy_r146(){
$this->_retvalue = array_merge($this->yystack[$this->yyidx + -2]->minor,array($this->yystack[$this->yyidx + 0]->minor));
/data/vendor/smarty/smarty/libs/sysplugins/smarty_internal_templateparser.php
// line 1263 "../smarty/lexer/smarty_internal_templateparser.y"
public function yy_r185(){
$this->_retvalue = new Smarty_Internal_ParseTree_DqContent($this->yystack[$this->yyidx + 0]->minor);
}
private $_retvalue;
public function yy_reduce($yyruleno)
{
if ($this->yyTraceFILE && $yyruleno >= 0
&& $yyruleno < count(self::$yyRuleName)) {
fprintf($this->yyTraceFILE, "%sReduce (%d) [%s].\n",
$this->yyTracePrompt, $yyruleno,
self::$yyRuleName[$yyruleno]);
}
$this->_retvalue = $yy_lefthand_side = null;
if (isset(self::$yyReduceMap[$yyruleno])) {
// call the action
$this->_retvalue = null;
$this->{'yy_r' . self::$yyReduceMap[$yyruleno]}();
$yy_lefthand_side = $this->_retvalue;
}
$yygoto = self::$yyRuleInfo[$yyruleno][0];
$yysize = self::$yyRuleInfo[$yyruleno][1];
$this->yyidx -= $yysize;
for ($i = $yysize; $i; $i--) {
// pop all of the right-hand side parameters
array_pop($this->yystack);
}
$yyact = $this->yy_find_reduce_action($this->yystack[$this->yyidx]->stateno, $yygoto);
if ($yyact < self::YYNSTATE) {
if (!$this->yyTraceFILE && $yysize) {
$this->yyidx++;
$x = new TP_yyStackEntry;
$x->stateno = $yyact;
$x->major = $yygoto;
$x->minor = $yy_lefthand_side;
$this->yystack[$this->yyidx] = $x;
} else {
$this->yy_shift($yyact, $yygoto, $yy_lefthand_side);
/data/vendor/smarty/smarty/libs/sysplugins/smarty_internal_templateparser.php
fprintf($this->yyTraceFILE, "%sInput %s\n",
$this->yyTracePrompt, $this->yyTokenName[$yymajor]);
}
do {
$yyact = $this->yy_find_shift_action($yymajor);
if ($yymajor < self::YYERRORSYMBOL &&
!$this->yy_is_expected_token($yymajor)) {
// force a syntax error
$yyact = self::YY_ERROR_ACTION;
}
if ($yyact < self::YYNSTATE) {
$this->yy_shift($yyact, $yymajor, $yytokenvalue);
$this->yyerrcnt--;
if ($yyendofinput && $this->yyidx >= 0) {
$yymajor = 0;
} else {
$yymajor = self::YYNOCODE;
}
} elseif ($yyact < self::YYNSTATE + self::YYNRULE) {
$this->yy_reduce($yyact - self::YYNSTATE);
} elseif ($yyact === self::YY_ERROR_ACTION) {
if ($this->yyTraceFILE) {
fprintf($this->yyTraceFILE, "%sSyntax Error!\n",
$this->yyTracePrompt);
}
if (self::YYERRORSYMBOL) {
if ($this->yyerrcnt < 0) {
$this->yy_syntax_error($yymajor, $yytokenvalue);
}
$yymx = $this->yystack[$this->yyidx]->major;
if ($yymx === self::YYERRORSYMBOL || $yyerrorhit) {
if ($this->yyTraceFILE) {
fprintf($this->yyTraceFILE, "%sDiscard input token %s\n",
$this->yyTracePrompt, $this->yyTokenName[$yymajor]);
}
$this->yy_destructor($yymajor, $yytokenvalue);
$yymajor = self::YYNOCODE;
} else {
while ($this->yyidx >= 0 &&
$yymx !== self::YYERRORSYMBOL &&
/data/vendor/smarty/smarty/libs/sysplugins/smarty_internal_smartytemplatecompiler.php
}
if (function_exists('mb_internal_encoding')
&& function_exists('ini_get')
&& ((int)ini_get('mbstring.func_overload')) & 2
) {
$mbEncoding = mb_internal_encoding();
mb_internal_encoding('ASCII');
} else {
$mbEncoding = null;
}
if ($this->smarty->_parserdebug) {
$this->parser->PrintTrace();
$this->parser->lex->PrintTrace();
}
// get tokens from lexer and parse them
while ($this->parser->lex->yylex()) {
if ($this->smarty->_parserdebug) {
echo "<pre>Line {$this->parser->lex->line} Parsing {$this->parser->yyTokenName[$this->parser->lex->token]} Token " .
htmlentities($this->parser->lex->value) . "</pre>";
}
$this->parser->doParse($this->parser->lex->token, $this->parser->lex->value);
}
// finish parsing process
$this->parser->doParse(0, 0);
if ($mbEncoding) {
mb_internal_encoding($mbEncoding);
}
// check for unclosed tags
if (count($this->_tag_stack) > 0) {
// get stacked info
list($openTag, $_data) = array_pop($this->_tag_stack);
$this->trigger_template_error(
"unclosed {$this->smarty->left_delimiter}" . $openTag .
"{$this->smarty->right_delimiter} tag"
);
}
// call post compile callbacks
foreach ($this->postCompileCallbacks as $cb) {
$parameter = $cb;
$parameter[ 0 ] = $this;
call_user_func_array($cb[ 0 ], $parameter);
/data/vendor/smarty/smarty/libs/sysplugins/smarty_internal_templatecompilerbase.php
$i = 0;
$reversed_components = array_reverse($this->template->getSource()->components);
foreach ($reversed_components as $source) {
$i++;
if ($i === count($reversed_components)) {
$_compiled_code .= '<?php $_smarty_tpl->inheritance->endChild($_smarty_tpl); ?>';
}
$_compiled_code .= $this->compileTag(
'include',
[
var_export($source->resource, true),
['scope' => 'parent'],
]
);
}
$_compiled_code = $this->postFilter($_compiled_code, $this->template);
} else {
// get template source
$_content = $this->template->source->getContent();
$_compiled_code = $this->postFilter($this->doCompile($this->preFilter($_content), true));
}
if (!empty($this->required_plugins[ 'compiled' ]) || !empty($this->required_plugins[ 'nocache' ])) {
$_compiled_code = '<?php ' . $this->compileRequiredPlugins() . "?>\n" . $_compiled_code;
}
} catch (Exception $e) {
if ($this->smarty->debugging) {
$this->smarty->_debug->end_compile($this->template);
}
$this->_tag_stack = array();
// free memory
$this->parent_compiler = null;
$this->template = null;
$this->parser = null;
throw $e;
}
if ($this->smarty->debugging) {
$this->smarty->_debug->end_compile($this->template);
}
$this->parent_compiler = null;
$this->parser = null;
/data/vendor/smarty/smarty/libs/sysplugins/smarty_internal_templatecompilerbase.php
}
/**
* Method to compile a Smarty template
*
* @param Smarty_Internal_Template $template template object to compile
* @param bool $nocache true is shall be compiled in nocache mode
* @param null|Smarty_Internal_TemplateCompilerBase $parent_compiler
*
* @return bool true if compiling succeeded, false if it failed
* @throws \Exception
*/
public function compileTemplate(
Smarty_Internal_Template $template,
$nocache = null,
?Smarty_Internal_TemplateCompilerBase $parent_compiler = null
) {
// get code frame of compiled template
$_compiled_code = $template->smarty->ext->_codeFrame->create(
$template,
$this->compileTemplateSource(
$template,
$nocache,
$parent_compiler
),
$this->postFilter($this->blockOrFunctionCode) .
join('', $this->mergedSubTemplatesCode),
false,
$this
);
return $_compiled_code;
}
/**
* Compile template source and run optional post filter
*
* @param \Smarty_Internal_Template $template
* @param null|bool $nocache flag if template must be compiled in nocache mode
* @param \Smarty_Internal_TemplateCompilerBase|null $parent_compiler
*
* @return string
/data/vendor/smarty/smarty/libs/sysplugins/smarty_template_compiled.php
*
* @param Smarty_Internal_Template $_template
*
* @throws Exception
*/
public function compileTemplateSource(Smarty_Internal_Template $_template)
{
$this->file_dependency = array();
$this->includes = array();
$this->nocache_hash = null;
$this->unifunc = null;
// compile locking
if ($saved_timestamp = (!$_template->source->handler->recompiled && is_file($this->filepath))) {
$saved_timestamp = $this->getTimeStamp();
touch($this->filepath);
}
// compile locking
try {
// call compiler
$_template->loadCompiler();
$this->write($_template, $_template->compiler->compileTemplate($_template));
} catch (Exception $e) {
// restore old timestamp in case of error
if ($saved_timestamp && is_file($this->filepath)) {
touch($this->filepath, $saved_timestamp);
}
unset($_template->compiler);
throw $e;
}
// release compiler object to free memory
unset($_template->compiler);
}
/**
* Write compiled code by handler
*
* @param Smarty_Internal_Template $_template template object
* @param string $code compiled code
*
* @return bool success
* @throws \SmartyException
/data/vendor/smarty/smarty/libs/sysplugins/smarty_template_compiled.php
}
}
/**
* load compiled template or compile from source
*
* @param Smarty_Internal_Template $_smarty_tpl do not change variable name, is used by compiled template
*
* @throws Exception
*/
public function process(Smarty_Internal_Template $_smarty_tpl)
{
$source = &$_smarty_tpl->source;
$smarty = &$_smarty_tpl->smarty;
if ($source->handler->recompiled) {
$source->handler->process($_smarty_tpl);
} elseif (!$source->handler->uncompiled) {
if (!$this->exists || $smarty->force_compile
|| ($_smarty_tpl->compile_check && $source->getTimeStamp() > $this->getTimeStamp())
) {
$this->compileTemplateSource($_smarty_tpl);
$compileCheck = $_smarty_tpl->compile_check;
$_smarty_tpl->compile_check = Smarty::COMPILECHECK_OFF;
$this->loadCompiledTemplate($_smarty_tpl);
$_smarty_tpl->compile_check = $compileCheck;
} else {
$_smarty_tpl->mustCompile = true;
@include $this->filepath;
if ($_smarty_tpl->mustCompile) {
$this->compileTemplateSource($_smarty_tpl);
$compileCheck = $_smarty_tpl->compile_check;
$_smarty_tpl->compile_check = Smarty::COMPILECHECK_OFF;
$this->loadCompiledTemplate($_smarty_tpl);
$_smarty_tpl->compile_check = $compileCheck;
}
}
$_smarty_tpl->_subTemplateRegister();
$this->processed = true;
}
}
/data/vendor/smarty/smarty/libs/sysplugins/smarty_template_compiled.php
*
* @param Smarty_Internal_Template $_template
*
* @return void
* @throws Exception
*/
public function render(Smarty_Internal_Template $_template)
{
// checks if template exists
if (!$_template->source->exists) {
$type = $_template->source->isConfig ? 'config' : 'template';
throw new SmartyException("Unable to load {$type} '{$_template->source->type}:{$_template->source->name}'");
}
if ($_template->smarty->debugging) {
if (!isset($_template->smarty->_debug)) {
$_template->smarty->_debug = new Smarty_Internal_Debug();
}
$_template->smarty->_debug->start_render($_template);
}
if (!$this->processed) {
$this->process($_template);
}
if (isset($_template->cached)) {
$_template->cached->file_dependency =
array_merge($_template->cached->file_dependency, $this->file_dependency);
}
if ($_template->source->handler->uncompiled) {
$_template->source->handler->renderUncompiled($_template->source, $_template);
} else {
$this->getRenderedTemplateCode($_template);
}
if ($_template->caching && $this->has_nocache_code) {
$_template->cached->hashes[ $this->nocache_hash ] = true;
}
if ($_template->smarty->debugging) {
$_template->smarty->_debug->end_render($_template);
}
}
/**
* load compiled template or compile from source
/data/vendor/smarty/smarty/libs/sysplugins/smarty_internal_template.php
"Unable to load template '{$this->source->type}:{$this->source->name}'" .
($this->_isSubTpl() ? " in '{$this->parent->template_resource}'" : '')
);
}
// disable caching for evaluated code
if ($this->source->handler->recompiled) {
$this->caching = Smarty::CACHING_OFF;
}
// read from cache or render
if ($this->caching === Smarty::CACHING_LIFETIME_CURRENT || $this->caching === Smarty::CACHING_LIFETIME_SAVED) {
if (!isset($this->cached) || $this->cached->cache_id !== $this->cache_id
|| $this->cached->compile_id !== $this->compile_id
) {
$this->loadCached(true);
}
$this->cached->render($this, $no_output_filter);
} else {
if (!isset($this->compiled) || $this->compiled->compile_id !== $this->compile_id) {
$this->loadCompiled(true);
}
$this->compiled->render($this);
}
// display or fetch
if ($display) {
if ($this->caching && $this->smarty->cache_modified_check) {
$this->smarty->ext->_cacheModify->cacheModifiedCheck(
$this->cached,
$this,
isset($content) ? $content : ob_get_clean()
);
} else {
if ((!$this->caching || $this->cached->has_nocache_code || $this->source->handler->recompiled)
&& !$no_output_filter && (isset($this->smarty->autoload_filters[ 'output' ])
|| isset($this->smarty->registered_filters[ 'output' ]))
) {
echo $this->smarty->ext->_filterHandler->runFilter('output', ob_get_clean(), $this);
} else {
echo ob_get_clean();
}
}
if ($this->smarty->debugging) {
/data/vendor/smarty/smarty/libs/sysplugins/smarty_internal_templatebase.php
if ($template->caching) {
// return cache status of template
if (!isset($template->cached)) {
$template->loadCached();
}
$result = $template->cached->isCached($template);
Smarty_Internal_Template::$isCacheTplObj[ $template->_getTemplateId() ] = $template;
} else {
return false;
}
} else {
if ($saveVars) {
$savedTplVars = $template->tpl_vars;
$savedConfigVars = $template->config_vars;
}
ob_start();
$template->_mergeVars();
if (!empty(Smarty::$global_tpl_vars)) {
$template->tpl_vars = array_merge(Smarty::$global_tpl_vars, $template->tpl_vars);
}
$result = $template->render(false, $function);
$template->_cleanUp();
if ($saveVars) {
$template->tpl_vars = $savedTplVars;
$template->config_vars = $savedConfigVars;
} else {
if (!$function && !isset(Smarty_Internal_Template::$tplObjCache[ $template->templateId ])) {
$template->parent = null;
$template->tpl_vars = $template->config_vars = array();
Smarty_Internal_Template::$tplObjCache[ $template->templateId ] = $template;
}
}
}
if (isset($errorHandler)) {
$errorHandler->deactivate();
}
if (isset($_smarty_old_error_level)) {
error_reporting($_smarty_old_error_level);
}
/data/vendor/smarty/smarty/libs/sysplugins/smarty_internal_templatebase.php
* universal cache
*
* @var array()
*/
public $_cache = array();
/**
* fetches a rendered Smarty template
*
* @param string $template the resource handle of the template file or template object
* @param mixed $cache_id cache id to be used with this template
* @param mixed $compile_id compile id to be used with this template
* @param object $parent next higher level of Smarty variables
*
* @throws Exception
* @throws SmartyException
* @return string rendered template output
*/
public function fetch($template = null, $cache_id = null, $compile_id = null, $parent = null)
{
$result = $this->_execute($template, $cache_id, $compile_id, $parent, 0);
return $result === null ? ob_get_clean() : $result;
}
/**
* displays a Smarty template
*
* @param string $template the resource handle of the template file or template object
* @param mixed $cache_id cache id to be used with this template
* @param mixed $compile_id compile id to be used with this template
* @param object $parent next higher level of Smarty variables
*
* @throws \Exception
* @throws \SmartyException
*/
public function display($template = null, $cache_id = null, $compile_id = null, $parent = null)
{
// display template
$this->_execute($template, $cache_id, $compile_id, $parent, 1);
}
/data/core/classes/Templates/SmartyTemplateEngine.php
DebugBarHelper::getInstance()->addSmartyCollector($smarty);
}
$this->_securityPolicy = $securityPolicy;
$this->_smarty = $smarty;
parent::__construct();
}
public function render(string $templateFile): void
{
echo $this->fetch($templateFile);
}
public function fetch(string $templateFile): string
{
$templateFile = str_replace('.tpl', '', $templateFile);
$this->_smarty->assign($this->getVariables());
return $this->_smarty->fetch("$templateFile.tpl");
}
public function clearCache(): void
{
$this->_smarty->clearAllCache();
}
/**
* Add an extra directory to the Smarty security policy.
*
* @param string $dir Directory to add to policy
* @return void
*/
public function addSecurityPolicyDirectory(string $dir): void
{
$this->_securityPolicy->secure_dir = [...$this->_securityPolicy->secure_dir, $dir];
$this->_smarty->enableSecurity($this->_securityPolicy);
}
}
/data/core/classes/Templates/SmartyTemplateEngine.php
'array_key_exists',
];
$securityPolicy->secure_dir = [ROOT_PATH . '/custom/templates', ROOT_PATH . '/custom/panel_templates'];
$smarty->enableSecurity($securityPolicy);
$smarty->setCompileDir(ROOT_PATH . '/cache/templates_c');
$smarty->setTemplateDir($dir);
if (defined('PHPDEBUGBAR')) {
DebugBarHelper::getInstance()->addSmartyCollector($smarty);
}
$this->_securityPolicy = $securityPolicy;
$this->_smarty = $smarty;
parent::__construct();
}
public function render(string $templateFile): void
{
echo $this->fetch($templateFile);
}
public function fetch(string $templateFile): string
{
$templateFile = str_replace('.tpl', '', $templateFile);
$this->_smarty->assign($this->getVariables());
return $this->_smarty->fetch("$templateFile.tpl");
}
public function clearCache(): void
{
$this->_smarty->clearAllCache();
}
/**
* Add an extra directory to the Smarty security policy.
*
* @param string $dir Directory to add to policy
/data/core/classes/Templates/TemplateBase.php
{
[$css, $js] = $this->assets()->compile();
// Put the assets at the start of the arrays, so they load first (SBAdmin requires JQuery first, etc.)
array_unshift($this->_css, ...$css);
array_unshift($this->_js, ...$js);
$this->_engine->addVariables([
'TEMPLATE_CSS' => $this->getCSS(),
'TEMPLATE_JS' => $this->getJS(),
]);
if (defined('PHPDEBUGBAR') && PHPDEBUGBAR) {
$debugBar = DebugBarHelper::getInstance()->getDebugBar()->getJavascriptRenderer();
$this->_engine->addVariables([
'DEBUGBAR_JS' => $debugBar->renderHead(),
'DEBUGBAR_HTML' => $debugBar->render(),
]);
}
$this->_engine->render($template);
}
/**
* Get all internal CSS styles.
*
* @return array Array of strings of CSS.
*/
public function getCSS(): array
{
return $this->_css;
}
/**
* Get all internal JS code.
*
* @return array Array of strings of JS.
*/
public function getJS(): array
{
return $this->_js;
/data/modules/Monitoring/pages/servers/index.php
'CATEGORY_LABEL' => mon_trans('category_label', 'Category'),
'SEARCH_LABEL' => mon_trans('search', global: true),
'COPIED' => mon_trans('copied', 'Copied'),
'CLICK_TO_COPY' => mon_trans('click_to_copy', 'Click to copy'),
'CLICK_TO_GO' => mon_trans('click_to_go', 'Click to go'),
'VOTES_LABEL' => mon_trans('votes', 'Votes'),
'PLAYERS_LABEL' => mon_trans('players', 'Players'),
'NEW_LABEL' => mon_trans('new', 'New'),
'SORT_LABEL' => mon_trans('sort', 'Sort'),
'OFFLINE_LABEL' => mon_trans('offline', 'Offline'),
'ONLINE_LABEL' => mon_trans('online', 'Online'),
'OLD_LABEL' => mon_trans('old', 'Old'),
'SPONSOR_LABEL' => mon_trans('sponsor', 'Sponsor'),
'JAVA_LABEL' => mon_trans('java', 'Java'),
'BEDROCK_LABEL' => mon_trans('bedrock', 'Bedrock'),
'VERIFIED_LABEL' => mon_trans('verified', 'Verified'),
'UNVERIFIED_LABEL' => mon_trans('unverified', 'Not verified'),
]);
$template->getEngine()->addVariables(MonServerVote::getModalDataToTemplate());
require_once __DIR__ . '/includes/footer.php';
$template->displayTemplate('monitoring/index');
/data/index.php
require(ROOT_PATH . '/modules/Core/pages/index.php');
}
}
die;
}
$route = rtrim(strtok($_GET['route'], '?'), '/');
$all_pages = $pages->returnPages();
if (array_key_exists($route, $all_pages)) {
$pages->setActivePage($all_pages[$route]);
if (isset($all_pages[$route]['custom'])) {
require(implode(DIRECTORY_SEPARATOR, [ROOT_PATH, 'modules', 'Core', 'pages', 'custom.php']));
die;
}
$path = implode(DIRECTORY_SEPARATOR, [ROOT_PATH, 'modules', $all_pages[$route]['module'], $all_pages[$route]['file']]);
if (file_exists($path)) {
require($path);
die;
}
} else {
// Use recursion to check - might have URL parameters in path
$path_array = explode('/', $route);
for ($i = count($path_array) - 2; $i > 0; $i--) {
$new_path = '/';
for ($n = 1; $n <= $i; $n++) {
$new_path .= $path_array[$n] . '/';
}
$new_path = rtrim($new_path, '/');
if (array_key_exists($new_path, $all_pages)) {
$path = implode(DIRECTORY_SEPARATOR, [ROOT_PATH, 'modules', $all_pages[$new_path]['module'], $all_pages[$new_path]['file']]);
if (file_exists($path)) {
$pages->setActivePage($all_pages[$new_path]);
require($path);
/data/core/templates/frontend_init.php
SELECT * FROM nl2_page_descriptions WHERE `page` = '/servers';
}
}
}
// Does the account need verifying?
// Get default group ID
$cache->setCache('default_group');
$default_group = $cache->fetch('default_group', function () {
return Group::find(1, 'default_group')->id;
});
}
// Page metadata
if (isset($_GET['route']) && $_GET['route'] != '/') {
$route = rtrim($_GET['route'], '/');
} else {
$route = '/';
}
if (!defined('PAGE_DESCRIPTION')) {
$page_metadata = DB::getInstance()->get('page_descriptions', ['page', $route]);
if ($page_metadata->count()) {
$page_metadata = $page_metadata->first();
$template->getEngine()->addVariables([
'PAGE_DESCRIPTION' => str_replace('{site}', Output::getClean(SITE_NAME), addslashes(strip_tags($page_metadata->description))),
'PAGE_KEYWORDS' => addslashes(strip_tags($page_metadata->tags)),
]);
$og_image = $page_metadata->image;
if ($og_image) {
$template->getEngine()->addVariable('OG_IMAGE', rtrim(URL::getSelfURL(), '/') . $og_image);
}
} else {
$template->getEngine()->addVariables([
'PAGE_DESCRIPTION' => str_replace('{site}', Output::getClean(SITE_NAME), addslashes(strip_tags(Settings::get('default_meta_description', '')))),
'PAGE_KEYWORDS' => addslashes(strip_tags(Settings::get('default_meta_keywords', ''))),
]);
}
} else {
$template->getEngine()->addVariables([
'PAGE_DESCRIPTION' => str_replace('{site}', Output::getClean(SITE_NAME), addslashes(strip_tags(PAGE_DESCRIPTION))),
/data/core/classes/Integrations/IntegrationBase.php
SELECT * FROM nl2_integrations WHERE name = 'Discord';
* @author Partydragen
* @version 2.1.0
* @license MIT
*/
abstract class IntegrationBase
{
private DB $_db;
private IntegrationData $_data;
protected string $_icon;
private array $_errors = [];
protected Language $_language;
protected ?string $_settings = null;
protected string $_name;
protected ?int $_order;
public function __construct()
{
$this->_db = DB::getInstance();
$integration = $this->_db->query('SELECT * FROM nl2_integrations WHERE name = ?', [$this->_name]);
if ($integration->count()) {
$integration = $integration->first();
$this->_data = new IntegrationData($integration);
$this->_order = $integration->order;
} else {
// Register integration to database
$this->_db->query('INSERT INTO nl2_integrations (name) VALUES (?)', [
$this->_name,
]);
$integration = $this->_db->query('SELECT * FROM nl2_integrations WHERE name = ?', [$this->_name])->first();
$this->_data = new IntegrationData($integration);
$this->_order = $integration->order;
}
}
/**
* Get the name of this integration.
/data/core/classes/Core/Module.php
SELECT * FROM nl2_modules WHERE `name` = 'Core';
/**
* Get this module's ID.
*
* @return int The ID for the module
*/
public function getId(): int
{
return DB::getInstance()->query('SELECT `id` FROM nl2_modules WHERE `name` = ?', [$this->_name])->first()->id;
}
/**
* Get a module ID from name.
*
* @param string $name Module name
*
* @return ?int Module ID
*/
public static function getIdFromName(string $name): ?int
{
$query = DB::getInstance()->get('modules', ['name', $name]);
if ($query->count()) {
return $query->first()->id;
}
return null;
}
/**
* Get a module name from ID.
*
* @param int $id Module ID
*
* @return ?string Module name
*/
public static function getNameFromId(int $id): ?string
{
$query = DB::getInstance()->get('modules', ['id', $id]);
if ($query->count()) {
/data/core/classes/Core/Module.php
SELECT * FROM nl2_modules WHERE `name` = 'Core';
/**
* Get this module's ID.
*
* @return int The ID for the module
*/
public function getId(): int
{
return DB::getInstance()->query('SELECT `id` FROM nl2_modules WHERE `name` = ?', [$this->_name])->first()->id;
}
/**
* Get a module ID from name.
*
* @param string $name Module name
*
* @return ?int Module ID
*/
public static function getIdFromName(string $name): ?int
{
$query = DB::getInstance()->get('modules', ['name', $name]);
if ($query->count()) {
return $query->first()->id;
}
return null;
}
/**
* Get a module name from ID.
*
* @param int $id Module ID
*
* @return ?string Module name
*/
public static function getNameFromId(int $id): ?string
{
$query = DB::getInstance()->get('modules', ['id', $id]);
if ($query->count()) {
/data/core/classes/Integrations/IntegrationBase.php
SELECT * FROM nl2_integrations WHERE name = 'Google';
* @author Partydragen
* @version 2.1.0
* @license MIT
*/
abstract class IntegrationBase
{
private DB $_db;
private IntegrationData $_data;
protected string $_icon;
private array $_errors = [];
protected Language $_language;
protected ?string $_settings = null;
protected string $_name;
protected ?int $_order;
public function __construct()
{
$this->_db = DB::getInstance();
$integration = $this->_db->query('SELECT * FROM nl2_integrations WHERE name = ?', [$this->_name]);
if ($integration->count()) {
$integration = $integration->first();
$this->_data = new IntegrationData($integration);
$this->_order = $integration->order;
} else {
// Register integration to database
$this->_db->query('INSERT INTO nl2_integrations (name) VALUES (?)', [
$this->_name,
]);
$integration = $this->_db->query('SELECT * FROM nl2_integrations WHERE name = ?', [$this->_name])->first();
$this->_data = new IntegrationData($integration);
$this->_order = $integration->order;
}
}
/**
* Get the name of this integration.
/data/modules/Core/module.php
SELECT * FROM nl2_custom_pages WHERE `id` <> '0';
$pages->add('Core', '/panel/users/sessions', 'pages/panel/users_sessions.php');
$pages->add('Core', '/panel/user', 'pages/panel/user.php');
// Ajax GET requests
$pages->addAjaxScript(URL::build('/queries/servers'));
if (Settings::get('queue_runner', 'ajax') == 'ajax') {
$pages->addAjaxScript(URL::build('/queries/queue'));
}
// "More" dropdown
$cache->setCache('navbar_icons');
$icon = $cache->fetch('more_dropdown_icon', '');
$cache->setCache('navbar_order');
$order = $cache->fetch('more_dropdown_order', 2500);
$navigation->addDropdown('more_dropdown', $language->get('general', 'more'), 'top', $order, $icon);
// Custom pages
$custom_pages = DB::getInstance()->get('custom_pages', ['id', '<>', 0])->results();
if (count($custom_pages)) {
$more = [];
$cache->setCache('navbar_order');
if ($user->isLoggedIn()) {
// Check all groups
$user_groups = $user->getAllGroupIds();
foreach ($custom_pages as $custom_page) {
$redirect = null;
// Get redirect URL if enabled
if ($custom_page->redirect == 1) {
$redirect = $custom_page->link;
}
$pages->addCustom(Output::urlEncodeAllowSlashes($custom_page->url), Output::getClean($custom_page->title), !$custom_page->basic);
foreach ($user_groups as $user_group) {
$custom_page_permissions = DB::getInstance()->get('custom_pages_permissions', ['group_id', $user_group])->results();
/data/core/classes/Core/Settings.php
SELECT `name`, `value` FROM `nl2_settings` WHERE `module` IS NULL;
private static function setSettingsCache(?string $module, array $cache): void
{
$cache_name = $module !== null ? $module : 'core';
self::$_cached_settings[$cache_name] = $cache;
}
/**
* Get a setting from the database table `nl2_settings`.
*
* @param string $setting Setting to check.
* @param ?string $fallback Fallback to return if $setting is not set in DB. Defaults to null.
* @param string $module Module name to keep settings separate from other modules. Set module
* to 'Core' for global settings.
* @return ?string Setting from DB or $fallback.
*/
public static function get(string $setting, ?string $fallback = null, string $module = 'core'): ?string
{
if (!self::hasSettingsCache($module)) {
// Load all settings for this module and store it as a dictionary
if ($module === 'core') {
$result = DB::getInstance()->query('SELECT `name`, `value` FROM `nl2_settings` WHERE `module` IS NULL')->results();
} else {
$result = DB::getInstance()->query('SELECT `name`, `value` FROM `nl2_settings` WHERE `module` = ?', [$module])->results();
}
$cache = [];
foreach ($result as $row) {
$cache[$row->name] = $row->value;
}
self::setSettingsCache($module, $cache);
}
$cache = &self::getSettingsCache($module);
return $cache[$setting] ?? $fallback;
}
/**
* Modify a setting in the database table `nl2_settings`.
*
* @param string $setting Setting name.
/data/core/classes/Database/PhinxAdapter.php
SELECT version, migration_name FROM nl2_phinxlog;
if (!$migrationDir) {
$migrationDir = __DIR__ . '/../../migrations';
}
$migration_files = array_map(
static function ($file_name) {
[$version, $migration_name] = explode('_', $file_name, 2);
$migration_name = str_replace(['.php', '_'], '', ucwords($migration_name, '_'));
return $version . '_' . $migration_name;
},
array_filter(scandir($migrationDir), static function ($file_name) {
// Pattern that matches Phinx migration file names (eg: 20230403000000_create_stroopwafel_table.php)
return preg_match('/^\d{14}_\w+\.php$/', $file_name);
}),
);
$migration_database_entries = array_map(static function ($row) {
return $row->version . '_' . $row->migration_name;
}, DB::getInstance()->query("SELECT version, migration_name FROM $table")->results());
$missing = array_diff($migration_files, $migration_database_entries);
$extra = array_diff($migration_database_entries, $migration_files);
if ($returnResults) {
return [
'missing' => count($missing),
'extra' => count($extra),
];
}
// Likely a pull from the repo dev branch or migrations
// weren't run during an upgrade script.
if (($missing_count = count($missing)) > 0) {
echo "There are $missing_count migrations files which have not been executed:" . '<br>';
foreach ($missing as $missing_migration) {
echo " - $missing_migration" . '<br>';
}
}