azerothcore / playermap

WoW playermap
37 stars 20 forks source link

Data not displayed #4

Closed spiffynacho closed 2 months ago

spiffynacho commented 6 months ago

I followed the installation instructions by editing playermap_config.php and pomm_conf.php. The map loads, but no data is displayed: https://scientia.access.ly/playermap/. I added the following to index.php:

ini_set('display_errors', '1');
ini_set('display_startup_errors', '1');
error_reporting(E_ALL);

No errors are displayed. I am running PHP 8.2.4. Here is the content of my playermap_config.php file, with the MySQL login omitted:

<?php
// Player map configuration
$language         = "en";
$site_encoding    = "utf-8";

$db_type          = 'MySQL';

$realm_db['addr']     = '127.0.0.1:3306';         // SQL server IP:port this realmd located on
$realm_db['user']     = '*****';                   // SQL server login this realmd located on
$realm_db['pass']     = '*****';               // SQL server pass this realmd located on
$realm_db['name']     = 'acore_auth';                   // realmd DB name
$realm_db['encoding'] = 'utf8';                   // SQL connection encoding

//==== For each realm, you must have $world_db and $characters_db and $server filled in, label each with the realm id: ex: $world_db[REALMID]['addr'] === //

// position in array must represent realmd ID
$world_db[1]['addr']          = '127.0.0.1:3306'; // SQL server IP:port this DB located on
$world_db[1]['user']          = '*****';           // SQL server login this DB located on
$world_db[1]['pass']          = '*****';       // SQL server pass this DB located on
$world_db[1]['name']          = 'acore_world';          // World Database name, by default "mangos" for MaNGOS, "world" for AzerothCore/TrinityCore
$world_db[1]['encoding']      = 'utf8';           // SQL connection encoding

// position in array must represent realmd ID
$characters_db[1]['addr']     = '127.0.0.1:3306'; // SQL server IP:port this DB located on
$characters_db[1]['user']     = '*****';           // SQL server login this DB located on
$characters_db[1]['pass']     = '*****';       // SQL server pass this DB located on
$characters_db[1]['name']     = 'acore_characters';     // Character Database name
$characters_db[1]['encoding'] = 'utf8';           // SQL connection encoding

//---- Game Server Configuration ----

$server_type        =  1;           // 0=MaNGOS, 1=AzerothCore/TrinityCore

// position in array must represent realmd ID, same as in $world_db
$server[1]['addr']          = 'scientia.access.ly'; // Game Server IP, as seen by MiniManager, from your webhost
$server[1]['addr_wan']      = 'scientia.access.ly'; // Game Server IP, as seen by clients - Must be external address
$server[1]['game_port']     =  8085;       // Game Server port
$server[1]['rev']           = '';          // MaNGOS rev. used (AzerothCore/TrinityCore does not need this)
$server[1]['both_factions'] =  true;       // Allow to see opponent faction characters. Affects only players.

// === Player Map configuration === //

// GM online options
$gm_online                         = true;
$gm_online_count                   = 100;

$map_gm_show_online_only_gmoff     = 1; // show GM point only if in '.gm off' [1/0]
$map_gm_show_online_only_gmvisible = 1; // show GM point only if in '.gm visible on' [1/0]
$map_gm_add_suffix                 = 1; // add '{GM}' to name [1/0]
$map_status_gm_include_all         = 0; // include 'all GMs in game'/'who on map' [1/0]

// status window options:
$map_show_status =  1;                  // show server status window [1/0]
$map_show_time   =  1;                  // Show autoupdate timer 1 - on, 0 - off
$map_time        =  5;                  // Map autoupdate time (seconds), 0 - not update.

// all times set in msec (do not set time < 1500 for show), 0 to disable.
$map_time_to_show_uptime    = 3000;     // time to show uptime string
$map_time_to_show_maxonline = 3000;     // time to show max online
$map_time_to_show_gmonline  = 3000;     // time to show GM online

$developer_test_mode =  false;

$multi_realm_mode    =  true;

?>

And here is my pomm_conf.php file:

<?php
require_once("func.php");

require_once("config/playermap_config.php");
require_once 'libs/data_lib.php';

//$realm_id = intval( $_COOKIE['cur_selected_realmd'] );

$realm_id = 1; // Set the realm_id

$server_arr = $server;

if (isset($_COOKIE["lang"])) {
    $lang = "en";
    if (!file_exists("map_".$lang.".php") && !file_exists("zone_names_".$lang.".php")) {
        $lang = $language;
    }
} else {
    $lang = $language;
}

$database_encoding = $site_encoding;

$server = $server_arr[$realm_id]["addr"];
$port = $server_arr[$realm_id]["game_port"];

$host = $characters_db[$realm_id]["addr"];
$user = $characters_db[$realm_id]["user"];
$password = $characters_db[$realm_id]["pass"];
$db = $characters_db[$realm_id]["name"];

$hostr = $realm_db["addr"];
$userr = $realm_db["user"];
$passwordr = $realm_db["pass"];
$dbr = $realm_db["name"];

$sql = new DBLayer($hostr, $userr, $passwordr, $dbr);
$query = $sql->query("SELECT name FROM realmlist WHERE id = ".$realm_id);
$realm_name = $sql->fetch_assoc($query);
$realm_name = htmlentities($realm_name["name"]);

$gm_show_online = $gm_online;
$gm_show_online_only_gmoff = $map_gm_show_online_only_gmoff;
$gm_show_online_only_gmvisible = $map_gm_show_online_only_gmvisible;
$gm_add_suffix = $map_gm_add_suffix;
$gm_include_online = $gm_online_count;
$show_status = $map_show_status;
$time_to_show_uptime = $map_time_to_show_uptime;
$time_to_show_maxonline = $map_time_to_show_maxonline;
$time_to_show_gmonline = $map_time_to_show_gmonline;
$status_gm_include_all = $map_status_gm_include_all;
$time = $map_time;
$show_time = $map_show_time;

// points located on these maps(do not modify it)
$maps_for_points = "0,1,530,571,609";

$img_base = "img/map/";
$img_base2 = "img/c_icons/";

$PLAYER_FLAGS       = CHAR_DATA_OFFSET_FLAGS;
spiffynacho commented 6 months ago

In reviewing my PHP error log, I found the following entry related to the issue was repeated: [Wed Jan 03 14:46:29.540172 2024] [php:error] [pid 6272:tid 1916] [client *****] PHP Fatal error: Uncaught mysqli_sql_exception: Unknown character set: 'utf' in C:\\xampp\\htdocs\\scientia\\playermap\\func.php:39\nStack trace:\n#0 C:\\xampp\\htdocs\\scientia\\playermap\\func.php(39): mysqli_query(Object(mysqli), 'SET NAMES utf-8')\n#1 C:\\xampp\\htdocs\\scientia\\playermap\\pomm_play.php(25): DBLayer->query('SET NAMES utf-8')\n#2 {main}\n thrown in C:\\xampp\\htdocs\\scientia\\playermap\\func.php on line 39, referer: https://scientia.access.ly/playermap/

spiffynacho commented 6 months ago

AzerothCore uses the "utf8mb4" charset. I can confirm my databases are using that standard.

spiffynacho commented 6 months ago

I worked through the code and discovered a few things and have partially-resolved the issue. First, I made the following code changes in playermap_config.php:

$site_encoding = "utf8";

PHP 8 does not recognize utf-8, so reformatting the encoding type resolves that error. Next, I noticed leaderGuid is in the groups table, not the group_member table. To resolve this issue, I modified the query:

// ... [previous code]

$characters_db = new DBLayer($host, $user, $password, $db); if (!$characters_db->isValid()) { $_RESULT['status']['online'] = 2; exit(); } $characters_db->query("SET NAMES $database_encoding");

// Modify this query to join 'group_member' with 'groups' $query = $characters_db->query( "SELECT gm.memberGuid, g.leaderGuid FROM group_member gm JOIN groups g ON gm.groupId = g.id WHERE gm.memberGuid IN (SELECT guid FROM characters WHERE online='1')" );

if ($query) { while ($result = $characters_db->fetch_assoc($query)) { $groups[$result['memberGuid']] = $result['leaderGuid']; } }

// ... [rest of the code]

Next, groupId is not a column in the group_member table. I modified the query to reflect the correct column:

// ... [previous code]

$characters_db = new DBLayer($host, $user, $password, $db); if (!$characters_db->isValid()) { $_RESULT['status']['online'] = 2; exit(); } $characters_db->query("SET NAMES $database_encoding");

// Updated query to join 'group_member' and 'groups' tables using 'Guid' $query = $characters_db->query( "SELECT gm.memberGuid, g.leaderGuid FROM group_member gm JOIN groups g ON gm.Guid = g.Guid WHERE gm.memberGuid IN (SELECT guid FROM characters WHERE online='1')" );

if ($query) { while ($result = $characters_db->fetch_assoc($query)) { $groups[$result['memberGuid']] = $result['leaderGuid']; } }

// ... [rest of the code]

Next, I received an error about status being referenced before it was defined. To correct this, I modified the code:

<?php

require_once("defines.php");
// ... [other require_once calls]

$_RESULT = null;
$status = []; // Initialize $status

// ... [rest of your code]

if ($show_status) {
    $query = $realm_db->query("SELECT UNIX_TIMESTAMP(),`starttime`,`maxplayers` FROM `uptime` WHERE `starttime`=(SELECT MAX(`starttime`) FROM `uptime`)");
    if ($result = $realm_db->fetch_row($query)) {
        $status['online'] = test_realm() ? 1 : 0;
        $status['uptime'] = $result[0] - $result[1];
        $status['maxplayers'] = $result[2];
        $status['gmonline'] = $gm_online;
    } else {
        $status = null; // Or set to some default value
    }
} else {
    $status = null; // Or set to some default value
}

// ... [rest of your code]

$res['status'] = $status; // This line is now using an initialized variable

$_RESULT = $res;

// ... [rest of your code]
?>
spiffynacho commented 6 months ago

The map now shows the online time, but it says no players are online, even though I know players ARE online. https://scientia.access.ly/playermap/

Helias commented 6 months ago

I think that you have a wrong AC version, I've just tried to run it on acore-docker and it works perfectly

image

spiffynacho commented 6 months ago

I can confirm that I am using the latest build. If you look on GitHub, the variables referenced in the code are in different tables. guid leaderGuid

Helias commented 6 months ago

your tables seems correct, I have the same, indeed playermap should need some updates about that, but the main functionalities should work anyway

Helias commented 6 months ago

try to put instead of 127.0.0.1:3306 as 'addr' the realmlist scientia.access.ly:3306

spiffynacho commented 6 months ago

I manually compiled AzerothCore using the instructions here: https://www.azerothcore.org/wiki/classic-installation I understand you are using Docker. That's one difference that may be an issue. Which version of PHP are you running?

Helias commented 6 months ago

php 8.0.8 using MAMP

leilei1881 commented 2 months ago

I worked through the code and discovered a few things and have partially-resolved the issue. First, I made the following code changes in playermap_config.php:

$site_encoding = "utf8";

PHP 8 does not recognize utf-8, so reformatting the encoding type resolves that error. Next, I noticed leaderGuid is in the groups table, not the group_member table. To resolve this issue, I modified the query:

// ... [previous code]

$characters_db = new DBLayer($host, $user, $password, $db); if (!$characters_db->isValid()) { $_RESULT['status']['online'] = 2; exit(); } $characters_db->query("SET NAMES $database_encoding");

// Modify this query to join 'group_member' with 'groups' $query = $characters_db->query( "SELECT gm.memberGuid, g.leaderGuid FROM group_member gm JOIN groups g ON gm.groupId = g.id WHERE gm.memberGuid IN (SELECT guid FROM characters WHERE online='1')" );

if ($query) { while ($result = $characters_db->fetch_assoc($query)) { $groups[$result['memberGuid']] = $result['leaderGuid']; } }

// ... [rest of the code]

Next, groupId is not a column in the group_member table. I modified the query to reflect the correct column:

// ... [previous code]

$characters_db = new DBLayer($host, $user, $password, $db); if (!$characters_db->isValid()) { $_RESULT['status']['online'] = 2; exit(); } $characters_db->query("SET NAMES $database_encoding");

// Updated query to join 'group_member' and 'groups' tables using 'Guid' $query = $characters_db->query( "SELECT gm.memberGuid, g.leaderGuid FROM group_member gm JOIN groups g ON gm.Guid = g.Guid WHERE gm.memberGuid IN (SELECT guid FROM characters WHERE online='1')" );

if ($query) { while ($result = $characters_db->fetch_assoc($query)) { $groups[$result['memberGuid']] = $result['leaderGuid']; } }

// ... [rest of the code]

Next, I received an error about status being referenced before it was defined. To correct this, I modified the code:

<?php

require_once("defines.php");
// ... [other require_once calls]

$_RESULT = null;
$status = []; // Initialize $status

// ... [rest of your code]

if ($show_status) {
    $query = $realm_db->query("SELECT UNIX_TIMESTAMP(),`starttime`,`maxplayers` FROM `uptime` WHERE `starttime`=(SELECT MAX(`starttime`) FROM `uptime`)");
    if ($result = $realm_db->fetch_row($query)) {
        $status['online'] = test_realm() ? 1 : 0;
        $status['uptime'] = $result[0] - $result[1];
        $status['maxplayers'] = $result[2];
        $status['gmonline'] = $gm_online;
    } else {
        $status = null; // Or set to some default value
    }
} else {
    $status = null; // Or set to some default value
}

// ... [rest of your code]

$res['status'] = $status; // This line is now using an initialized variable

$_RESULT = $res;

// ... [rest of your code]
?>

The solution in the pomm_play.php:

$query = $characters_db->query("SELECT `guid` as `leaderGuid`,`memberGuid` FROM `group_member` WHERE `memberGuid` IN(SELECT `guid` FROM `characters` WHERE `online`='1')");

I tried and it worked!

Helias commented 2 months ago

on chromiecraft.com we keep the core update and we are still using the same version of this repository the playermap still works without changing that SQL query https://www.chromiecraft.com/en/playermap/ with last commit 41e28ee24c7e501430b71107ac90176d8abaaa02

We should do a docker container of this playermap to make it always work in any case without changing anything