Przedszkolak
Postów: 10
v7.00.05 Data rejestracji: 12.08.2012 08:41
|
Mam PHP-Fusion 7.00.05, skórka Gillette. Domyślna lista użytkowników dostępna z panelu logowania (members.php) wyświetla nazwę użytkownika, grupy do jakich należy i poziom użytkownika. Chciałbym aby wyświetlało również datę ostatniego logowania, jak na obrazku poniżej:
Szukałem na forum i jest sporo wątków jak i modyfikacji wyświetlających np. kto był ostatnio online czy dopisanie do uzytkownika, że jest online. Ale nic co mogłoby mnie naprowadzić na właściwy trop w moim problemie. Próbowałem zrobić to samodzielnie i zaczerpując parę linijek kodu z profile.php które ową datę wyświetla edytowałem poniższy plik (plus dodatkowe pola w themes/locale/members.php dla wyświetlania w tabeli nazw "Nigdy" i "Ostatnio online").
<?php
/*-------------------------------------------------------+
| PHP-Fusion Content Management System
| Copyright (C) 2002 - 2008 Nick Jones
| http://www.php-fusion.co.uk/
+--------------------------------------------------------+
| Filename: members.php
| Author: Nick Jones (Digitanium)
+--------------------------------------------------------+
| This program is released as free software under the
| Affero GPL license. You can redistribute it and/or
| modify it under the terms of this license which you
| can read by viewing the included agpl.txt or online
| at http://www.gnu.org/licenses/agpl.html. Removal of this
| copyright header is strictly prohibited without
| written permission from the original author(s).
+--------------------------------------------------------*/
require_once "maincore.php";
require_once THEMES."templates/header.php";
include LOCALE.LOCALESET."members.php";
add_to_title($locale['global_200'].$locale['400']);
opentable($locale['400']);
if (iMEMBER) {
if (!isset($_GET['sortby']) || !preg_match("/^[0-9A-Z]$/", $_GET['sortby'])) { $_GET['sortby'] = "all"; }
$orderby = ($_GET['sortby'] == "all" ? "" : " WHERE user_name LIKE '".stripinput($_GET['sortby'])."%'");
$result = dbquery("SELECT * FROM ".DB_USERS.$orderby."");
$rows = dbrows($result);
if (!isset($_GET['rowstart']) || !isnum($_GET['rowstart'])) { $_GET['rowstart'] = 0; }
if ($rows) {
$i = 0;
echo "<table cellpadding='0' cellspacing='0' width='100%'>\n<tr>\n";
echo "<td align='center' width='25%' class='tbl2'><strong>".$locale['401']."</strong></td>\n";
echo "<td align='center' width='45%' class='tbl2'><strong>".$locale['405']."</strong></td>\n";
[b] echo "<td align='center' width='15%' class='tbl2'><strong>".$locale['402bu']."</strong></td>\n";[/b]
echo "<td align='center' width='15%' class='tbl2' style='white-space:nowrap'><strong>".$locale['402']."</strong></td>\n";
echo "</tr>\n";
$result = dbquery("SELECT * FROM ".DB_USERS.$orderby." ORDER BY user_level DESC, user_name LIMIT ".$_GET['rowstart'].",20");
while ($data = dbarray($result)) {
$cell_color = ($i % 2 == 0 ? "tbl1" : "tbl2"); $i++;
echo "<tr>\n<td align='left' width='25%' class='$cell_color'>\n<a href='profile.php?lookup=".$data['user_id']."'>".$data['user_name']."</a></td>\n";
$groups = "";
$user_groups = explode(".", $data['user_groups']);
$j = 0;
foreach ($user_groups as $key => $value) {
if ($value) {
$groups .= "<a href='profile.php?group_id=".$value."'>".getgroupname($value)."</a>".($j < count($user_groups)-1 ? ", " : "");
}
$j++;
}
echo "<td align='center' width='45%' class='$cell_color'>\n".($groups ? $groups : ($data['user_level']==103 ? $locale['407'] : $locale['406']))."</td>\n";
[b] echo "<td align='center' width='15%' class='$cell_color' style='white-space:nowrap'>".($user_data['user_lastvisit'] ? showdate("longdate", $user_data['user_lastvisit']): $locale['402au'])."</td>\n";[/b]
echo "<td align='center' width='15%' class='$cell_color' style='white-space:nowrap'>".getuserlevel($data['user_level'])."</td>\n</tr>";
}
echo "</table>\n";
} else {
echo "<center><br />\n".$locale['403'].$_GET['sortby']."<br /><br />\n</center>\n";
}
$search = array(
"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R",
"S","T","U","V","W","X","Y","Z","0","1","2","3","4","5","6","7","8","9"
);
echo "<hr />\n<table cellpadding='0' cellspacing='1' class='tbl-border center'>\n<tr>\n";
echo "<td rowspan='2' class='tbl2'><a href='".FUSION_SELF."?sortby=all'>".$locale['404']."</a></td>";
for ($i = 0; $i < 36 != ""; $i++) {
echo "<td align='center' class='tbl1'><div class='small'><a href='".FUSION_SELF."?sortby=".$search[$i]."'>".$search[$i]."</a></div></td>";
echo ($i == 17 ? "<td rowspan='2' class='tbl2'><a href='".FUSION_SELF."?sortby=all'>".$locale['404']."</a></td>\n</tr>\n<tr>\n" : "\n");
}
echo "</tr>\n</table>\n";
} else {
redirect("index.php");
}
closetable();
if ($rows > 20) { echo "<div align='center' style='margin-top:5px;'>".makepagenav($_GET['rowstart'], 20, $rows, 3, FUSION_SELF."?sortby=".$_GET['sortby']."&")."</div>\n"; }
require_once THEMES."templates/footer.php";
?>
Problem w tym, że choć tabela wyświetla się według konstrukcji... to wszędzie jest napisane "Nigdy", a przed listą kont mam cały spam następującego błędu:
[b]Notice[/b]: Undefined variable: user_data in [b]/virtual/ft-guildwars.cba.pl/members.php[/b] on line [b]53[/b]
To się odnosi do wklejonej linijki z profilu o ile rozumiem, natomiast nie rozumiem kompletnie dlaczego user_data jest nie zdefiniowane. Oba pliki wykorzystują przecież jedynie maincore.php, reszta to odwołania do themes tak? Prosiłbym o jakąś pomoc w tej kwestii bo nie potrafię sobie z tym poradzić sam.
Edytowane przez north dnia 21.08.2012 22:24:38
|
Początkujący
Postów: 290 Pomógł: 45
v7.02.06 Data rejestracji: 24.10.2011 14:51
|
Skopiowałeś "na żywca" więc błąd musiał się pojawić. Poniżej poprawiony kod:
<?php
/*-------------------------------------------------------+
| PHP-Fusion Content Management System
| Copyright (C) 2002 - 2008 Nick Jones
| http://www.php-fusion.co.uk/
+--------------------------------------------------------+
| Filename: members.php
| Author: Nick Jones (Digitanium)
+--------------------------------------------------------+
| This program is released as free software under the
| Affero GPL license. You can redistribute it and/or
| modify it under the terms of this license which you
| can read by viewing the included agpl.txt or online
| at http://www.gnu.org/licenses/agpl.html. Removal of this
| copyright header is strictly prohibited without
| written permission from the original author(s).
+--------------------------------------------------------*/
require_once "maincore.php";
require_once THEMES."templates/header.php";
include LOCALE.LOCALESET."members.php";
add_to_title($locale['global_200'].$locale['400']);
opentable($locale['400']);
if (iMEMBER) {
if (!isset($_GET['sortby']) || !preg_match("/^[0-9A-Z]$/", $_GET['sortby'])) { $_GET['sortby'] = "all"; }
$orderby = ($_GET['sortby'] == "all" ? "" : " WHERE user_name LIKE '".stripinput($_GET['sortby'])."%'");
$result = dbquery("SELECT * FROM ".DB_USERS.$orderby."");
$rows = dbrows($result);
if (!isset($_GET['rowstart']) || !isnum($_GET['rowstart'])) { $_GET['rowstart'] = 0; }
if ($rows) {
$i = 0;
echo "<table cellpadding='0' cellspacing='0' width='100%'>\n<tr>\n";
echo "<td align='center' width='25%' class='tbl2'><strong>".$locale['401']."</strong></td>\n";
echo "<td align='center' width='45%' class='tbl2'><strong>".$locale['405']."</strong></td>\n";
echo "<td align='center' width='15%' class='tbl2'><strong>".$locale['402bu']."</strong></td>\n";
echo "<td align='center' width='15%' class='tbl2' style='white-space:nowrap'><strong>".$locale['402']."</strong></td>\n";
echo "</tr>\n";
$result = dbquery("SELECT * FROM ".DB_USERS.$orderby." ORDER BY user_level DESC, user_name LIMIT ".$_GET['rowstart'].",20");
while ($data = dbarray($result)) {
$cell_color = ($i % 2 == 0 ? "tbl1" : "tbl2"); $i++;
echo "<tr>\n<td align='left' width='25%' class='$cell_color'>\n<a href='profile.php?lookup=".$data['user_id']."'>".$data['user_name']."</a></td>\n";
$groups = "";
$user_groups = explode(".", $data['user_groups']);
$j = 0;
foreach ($user_groups as $key => $value) {
if ($value) {
$groups .= "<a href='profile.php?group_id=".$value."'>".getgroupname($value)."</a>".($j < count($user_groups)-1 ? ", " : "");
}
$j++;
}
echo "<td align='center' width='45%' class='$cell_color'>\n".($groups ? $groups : ($data['user_level']==103 ? $locale['407'] : $locale['406']))."</td>\n";
echo "<td align='center' width='15%' class='$cell_color' style='white-space:nowrap'>".($data['user_lastvisit'] ? showdate("longdate", $data['user_lastvisit']): $locale['402au'])."</td>\n";
echo "<td align='center' width='15%' class='$cell_color' style='white-space:nowrap'>".getuserlevel($data['user_level'])."</td>\n</tr>";
}
echo "</table>\n";
} else {
echo "<center><br />\n".$locale['403'].$_GET['sortby']."<br /><br />\n</center>\n";
}
$search = array(
"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R",
"S","T","U","V","W","X","Y","Z","0","1","2","3","4","5","6","7","8","9"
);
echo "<hr />\n<table cellpadding='0' cellspacing='1' class='tbl-border center'>\n<tr>\n";
echo "<td rowspan='2' class='tbl2'><a href='".FUSION_SELF."?sortby=all'>".$locale['404']."</a></td>";
for ($i = 0; $i < 36 != ""; $i++) {
echo "<td align='center' class='tbl1'><div class='small'><a href='".FUSION_SELF."?sortby=".$search[$i]."'>".$search[$i]."</a></div></td>";
echo ($i == 17 ? "<td rowspan='2' class='tbl2'><a href='".FUSION_SELF."?sortby=all'>".$locale['404']."</a></td>\n</tr>\n<tr>\n" : "\n");
}
echo "</tr>\n</table>\n";
} else {
redirect("index.php");
}
closetable();
if ($rows > 20) { echo "<div align='center' style='margin-top:5px;'>".makepagenav($_GET['rowstart'], 20, $rows, 3, FUSION_SELF."?sortby=".$_GET['sortby']."&")."</div>\n"; }
require_once THEMES."templates/footer.php";
?>
|