NamelessMC

Internet Explorer

Internet Explorer is not supported. Please upgrade to a more modern browser.

com.google.gson.stream.MalformedJsonException: Use JsonReader.se
Started by felipesavazi

felipesavazi

felipesavazi

Member
Joined
20 Oct 2021
Last Seen
28 Oct 2022
Topics
1
Posts
3

How to fix it?

felipesavazi · over 2 years ago
felipesavazi

felipesavazi

Member
Joined
20 Oct 2021
Last Seen
28 Oct 2022
Topics
1
Posts
3

It is API error

felipesavazi · over 2 years ago
felipesavazi

felipesavazi

Member
Joined
20 Oct 2021
Last Seen
28 Oct 2022
Topics
1
Posts
3



Uncaught Error

Undefined constant "PAGE"

(File: /data/core/templates/frontend_init.php)


Frame #3
/data/core/templates/frontend_init.php:32
Frame #2
/data/modules/Core/pages/api/v2/index.php:17
Frame #1
/data/index.php:115
File: /data/core/templates/frontend_init.php

define('FRONT_END', true);

// Set current page URL in session, provided it's not the login page
if(defined('PAGE') && PAGE != 'login' && PAGE != 'register' && PAGE != 404 && PAGE != 'maintenance' && (!isset($_GET['route']) || strpos($_GET['route'], '/queries') === false)){
	if(FRIENDLY_URLS === true){
		$split = explode('?', $_SERVER['REQUEST_URI']);

		if(count($split) > 1)
			$_SESSION['last_page'] = URL::build($split[0], $split[1]);
		else
			$_SESSION['last_page'] = URL::build($split[0]);

		if(defined('CONFIG_PATH'))
			$_SESSION['last_page'] = substr($_SESSION['last_page'], strlen(CONFIG_PATH));

	} else
		$_SESSION['last_page'] = URL::build($_GET['route']);

}

if (PAGE != 404) {
    // Auto unset signin tfa variables if set
    if (strpos($_GET['route'], '/queries/') === false && (isset($_SESSION['remember']) || isset($_SESSION['username']) || isset($_SESSION['email']) || isset($_SESSION['password'])) && (!isset($_POST['tfa_code']) && !isset($_SESSION['mcassoc']))) {
        unset($_SESSION['remember']);
        unset($_SESSION['username']);
        unset($_SESSION['email']);
        unset($_SESSION['password']);
    }
}

$template_path = ROOT_PATH . '/custom/templates/' . TEMPLATE;
$smarty->setTemplateDir($template_path);
$smarty->setCompileDir(ROOT_PATH . '/cache/templates_c');

if(file_exists(ROOT_PATH . '/custom/templates/' . TEMPLATE . '/template.php'))
	require(ROOT_PATH . '/custom/templates/' . TEMPLATE . '/template.php');
else
	require(ROOT_PATH . '/custom/templates/DefaultRevamp/template.php');

// User related actions
if($user->isLoggedIn()){
File: /data/modules/Core/pages/api/v2/index.php

            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, $modules)) {
                $path = join(DIRECTORY_SEPARATOR, array(ROOT_PATH, 'modules', $modules[$new_path]['module'], $modules[$new_path]['file']));

                if (file_exists($path)) {
                    $pages->setActivePage($modules[$new_path]);
                    require($path);
                    die();
                }
            }

        }

        // 404
        require(ROOT_PATH . '/404.php');
    }
}
felipesavazi · over 2 years ago · Last edited: over 2 years ago
Samerton

Samerton

Owner
Joined
30 Mar 2015
Last Seen
29 Mar 2024
Topics
41
Posts
1042

@felipesavazi Please see the "Broken API" section here: https://github.com/NamelessMC/Nameless/issues/2446

Following these instructions will resolve the issue for pre-release 12.

Also, I would recommend generating a new API key in the StaffCP -> Configuration -> API tab as this should be kept a secret.

Samerton · over 2 years ago