GameCMS Вывод в профиль время в игре, последний вход на сервер

kestprod

Новенький
Пользователь
02.12.2022
1
0
Полистал бы тему,увидел бы решение
if($profile->steam_id == '0') {
$timer = '<a href="../settings"><span style="color: #F00;font-weight: bold;text-decoration:underline;">Steam ID не привязан</span></a>';
$last_j = '<a href="../settings"><span style="color: #F00;font-weight: bold;text-decoration:underline;">Steam ID не привязан</span></a>';
}
else{
$STH = $pdo->query("SELECT id,st_db_host,st_db_user,st_db_pass,st_db_db,st_type,st_db_table,ip,port FROM servers WHERE st_type!=0 and id=1 LIMIT 1");
$STH->setFetchMode(PDO::FETCH_OBJ);
$row1 = $STH->fetch();
$db_host = $row1->st_db_host;
$db_user = $row1->st_db_user;
$db_pass = $row1->st_db_pass;
$db_db = $row1->st_db_db;
$table = $row1->st_db_table;
$error = "";
if(!$pdo2 = db_connect($db_host, $db_db, $db_user, $db_pass)) {
$error = $messages['Unable_connect_to_db'];
}

if($error == ""){
$STH1 = $pdo2->query("SELECT playtime, lastconnect FROM $table WHERE steam='$profile->steam_id'");
$STH1->setFetchMode(PDO::FETCH_OBJ);
}

$row = $STH1->fetch();
if ($row->playtime != 0) {
$timer1 = $row->playtime;
$last_j = expand_date($row->lastconnect, 7);
$sec = $timer1 % 60;
$timer1 = floor($timer1 / 60);
$min = $timer1 % 60;
$timer1 = floor($timer1 / 60);
$timer = $timer1 . " ч. " . $min . " м. " . $sec . " с. ";
}
else {
$timer = '<a href="../settings"><span style="color: #F00;font-weight: bold;text-decoration:underline;">Игрок ещё не был на сервере</span></a>';
$last_j = '<a href="../settings"><span style="color: #F00;font-weight: bold;text-decoration:underline;">Игрок ещё не был на сервере</span></a>';
}
}
Кто возьмется доработать , разные таблицы
За денюшку
 

amega

Супер активный
Пользователь
02.11.2022
47
3
с помощью этого скрипта можно вывести в профиль звание-скил игрока ?
 

Pr[E]fix

vk.com/cyxaruk1337
Пользователь
28.05.2022
109
436
Оказывается я тут оставлял коммент ну еще оставлю:
if($profile->steam_id == '0') {
    $timer = '<a href="../settings"><span style="color: #A52A2A;font-weight: bold;text-decoration:underline;">Steam ID не привязан</span></a>';
    $last_j = '<a href="../settings"><span style="color: #A52A2A;font-weight: bold;text-decoration:underline;">Steam ID не привязан</span></a>';
}
else{
    $STH = $pdo->query("SELECT id,st_db_host,st_db_user,st_db_pass,st_db_db,st_type,st_db_table,ip,port FROM servers WHERE st_type!=0 and id=1 LIMIT 1");
    $STH->setFetchMode(PDO::FETCH_OBJ);
    $row1 = $STH->fetch();
    $db_host = $row1->st_db_host;
    $db_user = $row1->st_db_user;
    $db_pass = $row1->st_db_pass;
    $db_db = $row1->st_db_db;
    $table = $row1->st_db_table;
    $error = "";
    if(!$pdo2 = db_connect($db_host, $db_db, $db_user, $db_pass)) {
        $error = $messages['Unable_connect_to_db'];
    }

    if($error == ""){
      // $STH1 = $pdo2->query("SELECT id, connection_time, last_join FROM $table WHERE steamid='$profile->steam_id'");
     // в этом запросе вместо id,connection_time,last_join  открываешь свою таблицу со статой и смотришь поля и по логике вставляешь вместо этих
        $STH1 = $pdo2->query("SELECT id, connection_time, last_join FROM $table WHERE steamid='$profile->steam_id'");
        $STH1->setFetchMode(PDO::FETCH_OBJ);
    }

    $row = $STH1->fetch();
    if ($row->id != 0) {
        $timer1 = $row->connection_time;
        $last_j = expand_date($row->last_join, 7);
        $sec = $timer1 % 60;
        $timer1 = floor($timer1 / 60);
        $min = $timer1 % 60;
        $timer1 = floor($timer1 / 60);
        $timer = $timer1 . " ч. " . $min . " м. " . $sec . " с. ";
    }
    else {
        $timer = '<a href="../settings"><span style="color: #A52A2A;font-weight: bold;text-decoration:underline;">Игрок ещё не был на сервере</span></a>';
        $last_j = '<a href="../settings"><span style="color: #A52A2A;font-weight: bold;text-decoration:underline;">Игрок ещё не был на сервере</span></a>';
    }
}
 

Stimayk

Черный список
Заблокирован
14.11.2022
0
22
  • Заблокирован
  • #66
А если несколько серверов, то с какого конкретно будет браться последний актив?
 

Pr[E]fix

vk.com/cyxaruk1337
Пользователь
28.05.2022
109
436
там немного можно переделать просто пробегаться через цикл while по всем списком серверов
и указывать для каждого отдельо
 

PvE

Супер активный
Участник
18.07.2022
71
32
pro-vipelite.ru
Полистал бы тему,увидел бы решение
if($profile->steam_id == '0') {
$timer = '<a href="../settings"><span style="color: #F00;font-weight: bold;text-decoration:underline;">Steam ID не привязан</span></a>';
$last_j = '<a href="../settings"><span style="color: #F00;font-weight: bold;text-decoration:underline;">Steam ID не привязан</span></a>';
}
else{
$STH = $pdo->query("SELECT id,st_db_host,st_db_user,st_db_pass,st_db_db,st_type,st_db_table,ip,port FROM servers WHERE st_type!=0 and id=1 LIMIT 1");
$STH->setFetchMode(PDO::FETCH_OBJ);
$row1 = $STH->fetch();
$db_host = $row1->st_db_host;
$db_user = $row1->st_db_user;
$db_pass = $row1->st_db_pass;
$db_db = $row1->st_db_db;
$table = $row1->st_db_table;
$error = "";
if(!$pdo2 = db_connect($db_host, $db_db, $db_user, $db_pass)) {
$error = $messages['Unable_connect_to_db'];
}

if($error == ""){
$STH1 = $pdo2->query("SELECT playtime, lastconnect FROM $table WHERE steam='$profile->steam_id'");
$STH1->setFetchMode(PDO::FETCH_OBJ);
}

$row = $STH1->fetch();
if ($row->playtime != 0) {
$timer1 = $row->playtime;
$last_j = expand_date($row->lastconnect, 7);
$sec = $timer1 % 60;
$timer1 = floor($timer1 / 60);
$min = $timer1 % 60;
$timer1 = floor($timer1 / 60);
$timer = $timer1 . " ч. " . $min . " м. " . $sec . " с. ";
}
else {
$timer = '<a href="../settings"><span style="color: #F00;font-weight: bold;text-decoration:underline;">Игрок ещё не был на сервере</span></a>';
$last_j = '<a href="../settings"><span style="color: #F00;font-weight: bold;text-decoration:underline;">Игрок ещё не был на сервере</span></a>';
}
}
У меня почему то вот такое получается в профиле (статистика lvl)
Как можно исправить?
 

Вложения

  • Opera Снимок_2023-01-30_013831_cs-energy.su.png
    Opera Снимок_2023-01-30_013831_cs-energy.su.png
    6,8 KB · Просмотры: 58

redage

Новенький
Пользователь
05.02.2023
17
7
Не заходит в профиль хотя пробовал разные ваши варики. Статат LVLRANK игра CSS панель UNI
 

redage

Новенький
Пользователь
05.02.2023
17
7

Главное что с кодом ниже. Он открывает страницы других пользователей. Но свою страницу сайт обработать не может.
Это скрин на чужом пользаке без привязке стима
1675717230735.png
А это на своем профиле с привязкой.
1675717286802.png
С этим кодом:
if($profile->steam_id == '0') {
$timer = '<a href="../settings"><span style="color: #F00;font-weight: bold;text-decoration:underline;">Steam ID не привязан</span></a>';
$last_j = '<a href="../settings"><span style="color: #F00;font-weight: bold;text-decoration:underline;">Steam ID не привязан</span></a>';
}
else{
$STH = $pdo->query("SELECT id,st_db_host,st_db_user,st_db_pass,st_db_db,st_type,st_db_table,ip,port FROM servers WHERE st_type!=0 and id=1 LIMIT 1");
$STH->setFetchMode(PDO::FETCH_OBJ);
$row1 = $STH->fetch();
$db_host = $row1->st_db_host;
$db_user = $row1->st_db_user;
$db_pass = $row1->st_db_pass;
$db_db = $row1->st_db_db;
$table = $row1->st_db_table;
$error = "";
if(!$pdo2 = db_connect($db_host, $db_db, $db_user, $db_pass)) {
$error = $messages['Unable_connect_to_db'];
}

if($error == ""){
$STH1 = $pdo2->query("SELECT playtime, lastconnect FROM $table WHERE steam='$profile->steam_id'");
$STH1->setFetchMode(PDO::FETCH_OBJ);
}

$row = $STH1->fetch();
if ($row->playtime != 0) {
$timer1 = $row->playtime;
$last_j = expand_date($row->lastconnect, 7);
$sec = $timer1 % 60;
$timer1 = floor($timer1 / 60);
$min = $timer1 % 60;
$timer1 = floor($timer1 / 60);
$timer = $timer1 . " ч. " . $min . " м. " . $sec . " с. ";
}
else {
$timer = '<a href="../settings"><span style="color: #F00;font-weight: bold;text-decoration:underline;">Игрок ещё не был на сервере</span></a>';
$last_j = '<a href="../settings"><span style="color: #F00;font-weight: bold;text-decoration:underline;">Игрок ещё не был на сервере</span></a>';
}
}
 

KHRYSTRAJ

vk.com/korolevkillo
Пользователь
15.05.2021
116
169
Главное что с кодом ниже. Он открывает страницы других пользователей. Но свою страницу сайт обработать не может.
Это скрин на чужом пользаке без привязке стима
Посмотреть вложение 2207
А это на своем профиле с привязкой.
Посмотреть вложение 2208
С этим кодом:
if($profile->steam_id == '0') {
$timer = '<a href="../settings"><span style="color: #F00;font-weight: bold;text-decoration:underline;">Steam ID не привязан</span></a>';
$last_j = '<a href="../settings"><span style="color: #F00;font-weight: bold;text-decoration:underline;">Steam ID не привязан</span></a>';
}
else{
$STH = $pdo->query("SELECT id,st_db_host,st_db_user,st_db_pass,st_db_db,st_type,st_db_table,ip,port FROM servers WHERE st_type!=0 and id=1 LIMIT 1");
$STH->setFetchMode(PDO::FETCH_OBJ);
$row1 = $STH->fetch();
$db_host = $row1->st_db_host;
$db_user = $row1->st_db_user;
$db_pass = $row1->st_db_pass;
$db_db = $row1->st_db_db;
$table = $row1->st_db_table;
$error = "";
if(!$pdo2 = db_connect($db_host, $db_db, $db_user, $db_pass)) {
$error = $messages['Unable_connect_to_db'];
}

if($error == ""){
$STH1 = $pdo2->query("SELECT playtime, lastconnect FROM $table WHERE steam='$profile->steam_id'");
$STH1->setFetchMode(PDO::FETCH_OBJ);
}

$row = $STH1->fetch();
if ($row->playtime != 0) {
$timer1 = $row->playtime;
$last_j = expand_date($row->lastconnect, 7);
$sec = $timer1 % 60;
$timer1 = floor($timer1 / 60);
$min = $timer1 % 60;
$timer1 = floor($timer1 / 60);
$timer = $timer1 . " ч. " . $min . " м. " . $sec . " с. ";
}
else {
$timer = '<a href="../settings"><span style="color: #F00;font-weight: bold;text-decoration:underline;">Игрок ещё не был на сервере</span></a>';
$last_j = '<a href="../settings"><span style="color: #F00;font-weight: bold;text-decoration:underline;">Игрок ещё не был на сервере</span></a>';
}
}
Приложите фаил ваш-сайт/modules/profile/index.php
 

redage

Новенький
Пользователь
05.02.2023
17
7
Приложите фаил ваш-сайт/modules/profile/index.php
index.php:
<?php
if($page->privacy == 1 && !is_auth()) {
    show_error_page('not_auth');
}

$urlParts = explode('/', $page->originalUrl);

if(count($urlParts) > 1) {
    $row = Users::getIdByRoute($pdo, $urlParts[1]);
    $id = empty($row->id) ? null : $row->id;
} else {
    if(array_key_exists('id', $_GET) || is_auth()) {
        if(array_key_exists('id', $_GET)) {
            $id = clean($_GET['id'], "int");
        } else {
            $id = $_SESSION['id'];
        }

        $row = Users::getRouteById($pdo, $id);

        if(!empty($row->route)) {
            http_response_code(301);
            header('Location: ../' .  PagesInfo::PROFILE_PAGE_URL . '/' . $row->route);
            exit();
        } elseif(!array_key_exists('id', $_GET)) {
            header('Location: ../' .  PagesInfo::PROFILE_PAGE_URL . '?id=' . $id);
            exit();
        }
    } else {
        show_error_page('not_settings');
    }
}

global $profile;

if(!$profile = Users::getUserData($pdo, $id)) {
    show_error_page();
}

if(!empty($profile->last_topic)) {
    $STH = $pdo->prepare("SELECT `name` FROM `forums__topics` WHERE `id`=:id LIMIT 1");
    $STH->setFetchMode(PDO::FETCH_OBJ);
    $STH->execute(array(':id' => $profile->last_topic));
    $row = $STH->fetch();
    if(isset($row->name)) {
        $profile->topic_name = $row->name;
    } else {
        $profile->topic_name = '';
        $profile->last_topic = 0;
    }
} else {
    $profile->last_topic = 0;
    $profile->topic_name = '';
}

$tpl->load_template('elements/title.tpl');
$tpl->set("{title}", $PI->compile_str($page->title, $profile->login));
$tpl->set("{name}", $conf->name);
$tpl->compile('title');
$tpl->clear();

$tpl->load_template('head.tpl');
$tpl->set("{title}", $tpl->result['title']);
$tpl->set("{site_name}", $conf->name);
$tpl->set("{image}", $PI->compile_img_str($profile->avatar));
$tpl->set("{robots}", $page->robots);
$tpl->set("{type}", $page->kind);
$tpl->set("{description}", $PI->compile_str($page->description, $profile->login));
$tpl->set("{keywords}", $PI->compile_str($page->keywords, $profile->login));
$tpl->set("{url}", $page->full_url);
$tpl->set("{other}", '<script src="{site_host}modules/editors/tinymce/tinymce.min.js"></script>');
$tpl->set("{token}", $token);
$tpl->set("{cache}", $conf->cache);
$tpl->set("{template}", $conf->template);
$tpl->set("{site_host}", $site_host);
$tpl->compile('content');
$tpl->clear();

$menu = $tpl->get_menu($pdo);

$nav = array($PI->to_nav('main', 0, 0),
             $PI->to_nav('users', 0, 0),
             $PI->to_nav('profile', 1, 0, $profile->login));
$nav = $tpl->get_nav($nav, 'elements/nav_li.tpl');

if(is_auth()) {
    include_once "inc/authorized.php";
} else {
    include_once "inc/not_authorized.php";
}

if(is_auth()) {
    $STH = $pdo->query("SELECT id FROM users__friends WHERE ((id_sender = '$id' AND id_taker = '$_SESSION[id]') OR (id_sender = '$_SESSION[id]' AND id_taker = '$id')) AND accept = '1' LIMIT 1");
    $STH->setFetchMode(PDO::FETCH_OBJ);
    $row = $STH->fetch();
    if(empty($row->id)) {
        if($_SESSION['id'] != $profile->id) {
            $checker = '1';
        } else {
            $checker = '2';
        }
    } else {
        $checker = '2';
    }
} else {
    $checker = '1';
}

$STH = $pdo->query("SELECT id FROM users__online WHERE user_id='$id' LIMIT 1");
$STH->setFetchMode(PDO::FETCH_OBJ);
$row = $STH->fetch();
if(isset($row->id)) {
    $last_activity = '<span id="sonline">'.'</span>'.$messages['Online'];
} else {
    if($profile->last_activity == '0000-00-00 00:00:00') {
        $last_activity = $messages['Was_online'].$messages['Bc'];
    } else {
        $last_activity = expand_date($profile->last_activity, 7);
        $last_activity = '<span id="soffline">'.'</span>'.$messages['Was_online'].$last_activity;
    }
}

$tpl->result['friends'] = '';

$STH = $pdo->query("SELECT users__friends.id_taker, users.id, users.login, users.avatar, users.rights FROM users__friends LEFT JOIN users on users__friends.id_taker = users.id WHERE (users__friends.id_sender='$profile->id') AND users__friends.accept='1' UNION SELECT users__friends.id_sender, users.id, users.login, users.avatar, users.rights FROM users__friends LEFT JOIN users ON users__friends.id_sender = users.id WHERE (users__friends.id_taker='$profile->id') AND users__friends.accept='1'");
$STH->setFetchMode(PDO::FETCH_OBJ);
while($row = $STH->fetch()) {
    $friend_group = $users_groups[$row->rights];
    $tpl->load_template('elements/mini_friend.tpl');
    $tpl->set("{id}", $row->id);
    $tpl->set("{avatar}", $row->avatar);
    $tpl->set("{login}", $row->login);
    $tpl->set("{gp_color}", $friend_group['color']);
    $tpl->set("{gp_name}", $friend_group['name']);
    $tpl->compile('friends');
    $tpl->clear();
}
if($tpl->result['friends'] == '') {
    $tpl->result['friends'] = '<span class="empty-element">'.$messages['There_are_no_friends'].'</span>';
}

if(empty($profile->fb)) {
    $profile->fb = 0;
}
if(empty($profile->fb_api)) {
    $profile->fb_api = 0;
}

$isFriend = 'false';
$issetFriendRequestFromMe = 'false';
$issetFriendRequestFromHim = 'false';

if(is_auth()) {
    $STH = $pdo->prepare("SELECT id, id_sender, id_taker, accept FROM users__friends WHERE (id_sender=:friend_id AND id_taker=:my_id) OR (id_sender=:my_id AND id_taker=:friend_id) LIMIT 1");
    $STH->setFetchMode(PDO::FETCH_OBJ);
    $STH->execute([':my_id' => $_SESSION['id'], ':friend_id' => $profile->id]);
    $row = $STH->fetch();
}

if(isset($row->id) && ($row->accept == 1)) {
    $isFriend = 'true';
}
if(isset($row->id) && ($row->accept == 0)) {
    if($row->id_sender == $_SESSION['id']) {
        $issetFriendRequestFromMe = 'true';
    }
    if($row->id_taker == $_SESSION['id']) {
        $issetFriendRequestFromHim = 'true';
    }
}
//Время на сервере
/*if($profile->steam_id == '0') {
$timer = '<a href="../settings"><span style="color: #F00;font-weight: bold;text-decoration:underline;">Steam ID не привязан</span></a>';
$last_j = '<a href="../settings"><span style="color: #F00;font-weight: bold;text-decoration:underline;">Steam ID не привязан</span></a>';
}
else{
$STH = $pdo->query("SELECT id,st_db_host,st_db_user,st_db_pass,st_db_db,st_type,st_db_table,ip,port FROM servers WHERE st_type!=1 and id=1 LIMIT 1");
$STH->setFetchMode(PDO::FETCH_OBJ);
$row1 = $STH->fetch();
$db_host = $row1->st_db_host;
$db_user = $row1->st_db_user;
$db_pass = $row1->st_db_pass;
$db_db = $row1->st_db_db;
$table = $row1->st_db_table;
$error = "";
if(!$pdo2 = db_connect($db_host, $db_db, $db_user, $db_pass)) {
$error = $messages['Unable_connect_to_db'];
}

if($error == ""){
$STH1 = $pdo2->query("SELECT playtime, lastconnect FROM $table WHERE steam='$profile->steam_id'");
$STH1->setFetchMode(PDO::FETCH_OBJ);
}

$row = $STH1->fetch();
if ($row->playtime != 0) {
$timer1 = $row->playtime;
$last_j = expand_date($row->lastconnect, 7);
$sec = $timer1 % 60;
$timer1 = floor($timer1 / 60);
$min = $timer1 % 60;
$timer1 = floor($timer1 / 60);
$timer = $timer1 . " ч. " . $min . " м. " . $sec . " с. ";
}
else {
$timer = '<a href="../settings"><span style="color: #F00;font-weight: bold;text-decoration:underline;">Игрок ещё не был на сервере</span></a>';
$last_j = '<a href="../settings"><span style="color: #F00;font-weight: bold;text-decoration:underline;">Игрок ещё не был на сервере</span></a>';
}
}
$tpl->set("{timer}", $timer);
$tpl->set("{last_j}", $last_j);*/
//Онлайн на сервере
$editor_settings = get_editor_settings($pdo);
$tpl->load_template('/home/profile.tpl');
$tpl->set("{file_manager}", $editor_settings['file_manager']);
$tpl->set("{file_manager_theme}", $editor_settings['file_manager_theme']);
$tpl->set("{site_host}", $site_host);
$tpl->set("{last_activity}", $last_activity);
$tpl->set("{template}", $conf->template);
$tpl->set("{profile_id}", $profile->id);
$tpl->set("{login}", $profile->login);
$tpl->set("{avatar}", $profile->avatar);
$tpl->set("{group}", $users_groups[$profile->rights]['name']);
$tpl->set("{group_color}", $users_groups[$profile->rights]['color']);
$tpl->set("{regdate}", expand_date($profile->regdate, 1));
$tpl->set("{name}", $profile->name);
$tpl->set("{answers}", $profile->answers);
$tpl->set("{thanks}", $profile->thanks);
$tpl->set("{telegram}", $profile->telegram);
$tpl->set("{nick}", $profile->nick);
$tpl->set("{skype}", $profile->skype);
$tpl->set("{discord}", $profile->discord);
$tpl->set("{reit}", $profile->reit);
$tpl->set("{topic_id}", $profile->last_topic);
$tpl->set("{topic_name}", $profile->topic_name);
$tpl->set("{checker}", $checker);
$tpl->set("{vk}", $profile->vk);
$tpl->set("{vk_api}", $profile->vk_api);
$tpl->set("{fb}", $profile->fb);
$tpl->set("{fb_api}", $profile->fb_api);
$tpl->set("{steam_api}", $profile->steam_api);
$tpl->set("{steam_id}", $profile->steam_id);
$tpl->set("{birth}", expand_date($profile->birth, 2));
$tpl->set("{dell}", $profile->dell);
$tpl->set("{friends}", $tpl->result['friends']);
$tpl->set("{isFriend}", $isFriend);
$tpl->set("{issetFriendRequestFromMe}", $issetFriendRequestFromMe);
$tpl->set("{issetFriendRequestFromHim}", $issetFriendRequestFromHim);
$tpl->set("{shilings}", $profile->shilings);
$tpl->set("{points}", $profile->playground);
$tpl->set("{proc}", $profile->proc);
$tpl->set("{ip}", $profile->ip);
$tpl->compile('content');
$tpl->clear();
?>
 

Вложения

  • index.rar
    2,7 KB · Просмотры: 4
Сверху Снизу