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

Pr[E]fix

vk.com/cyxaruk1337
Пользователь
28.05.2022
110
424
у всех разные статы, по этому смотрите на название таблицы к который обращается sql запрос
в данном случае он оброщаеться к этой таблице
csstats
хотя в запросе выбраны поля и там таблица которая использует тот или иной сервер:
$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);
 

Pr[E]fix

vk.com/cyxaruk1337
Пользователь
28.05.2022
110
424
у всех разные статы, по этому смотрите на название таблицы к который обращается sql запрос
в данном случае он оброщаеться к этой таблице
csstats
хотя в запросе выбраны поля и там таблица которая использует тот или иной сервер:
$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);
и еще не понял прикола в этом
 

Вложения

  • 1668842407133.png
    1668842407133.png
    4,9 KB · Просмотры: 257

Pr[E]fix

vk.com/cyxaruk1337
Пользователь
28.05.2022
110
424
в директорию ваш-сайт/modules/profile/index.php

Добавить в строку 172

*** Скрытый текст не может быть процитирован. ***

Далее добавить в строку после 210
$tpl->set("{timer}", $timer);
$tpl->set("{last_j}", $last_j);
Далее добавить код в ваш-сайт/tempates/standart/tpl/home/profile.tpl
profile.tpl:
 <tr>

                            <td class="w30"> <span class="fas fa-step-forward"></span> Был на сервере</td>

                            <td>{last_j}</td>

                        </tr>

                         <tr>

                            <td class="w30"> <span class="fas fa-clock"></span> Времени в игре</td>

                            <td>{timer}</td>

                        </tr>
Немного дал оптимизации (Админы под хайд если можно)
Скрытое содержимое доступно для зарегистрированных пользователей!
 

PPD

Активный
Участник
23.03.2022
31
10
Я почитал и не понял,нужно запрос менять к таблицам или оставить всё так?
 

PPD

Активный
Участник
23.03.2022
31
10
Я почитал и не понял,нужно запрос менять к таблицам или оставить всё так?
Редактировать текст почему-то нельзя и простите за 2 подряд. У меня не открывается профиль Unigamecms 5.8.9( статистика LevelRanks)
<?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 = $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 = $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-&gt;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-&gt;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-&gt;setFetchMode(PDO::FETCH_OBJ);

$row1 = $STH-&gt;fetch();

$db_host = $row1-&gt;st_db_host;

$db_user = $row1-&gt;st_db_user;

$db_pass = $row1-&gt;st_db_pass;

$db_db = $row1-&gt;st_db_db;

$table = $row1-&gt;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-&gt;query("SELECT id, playtime, lastconnect FROM lvl_base WHERE steam='$profile-&gt;steam_id'");
$STH1-&gt;setFetchMode(PDO::FETCH_OBJ);
}

$row = $STH1-&gt;fetch();

if ($row-&gt;id != 0) {
$timer1 = $row-&gt;playtime;
$last_j = expand_date($row-&gt;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: #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>';

}

$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("{timer}", $timer);
$tpl->set("{last_j}", $last_j);
$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("{proc}", $profile->proc);
$tpl->set("{ip}", $profile->ip);
$tpl->compile('content');
$tpl->clear();
?>
 

KHRYSTRAJ

vk.com/korolevkillo
Участник
15.05.2021
117
153
Редактировать текст почему-то нельзя и простите за 2 подряд. У меня не открывается профиль Unigamecms 5.8.9( статистика LevelRanks)
<?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 = $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 = $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-&gt;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-&gt;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-&gt;setFetchMode(PDO::FETCH_OBJ);

$row1 = $STH-&gt;fetch();

$db_host = $row1-&gt;st_db_host;

$db_user = $row1-&gt;st_db_user;

$db_pass = $row1-&gt;st_db_pass;

$db_db = $row1-&gt;st_db_db;

$table = $row1-&gt;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-&gt;query("SELECT id, playtime, lastconnect FROM lvl_base WHERE steam='$profile-&gt;steam_id'");
$STH1-&gt;setFetchMode(PDO::FETCH_OBJ);
}

$row = $STH1-&gt;fetch();

if ($row-&gt;id != 0) {
$timer1 = $row-&gt;playtime;
$last_j = expand_date($row-&gt;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: #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>';

}

$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("{timer}", $timer);
$tpl->set("{last_j}", $last_j);
$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("{proc}", $profile->proc);
$tpl->set("{ip}", $profile->ip);
$tpl->compile('content');
$tpl->clear();
?>
Отключи безопасный режим
 
Сверху Снизу