function umc_display_guestinfo() { global $UMC_USER, $UMC_DOMAIN; XMPP_ERROR_trace(__FUNCTION__, func_get_args()); if ($UMC_USER) { $uuid = $UMC_USER['uuid']; $userlevel = $UMC_USER['userlevel']; $username = $UMC_USER['username']; } $latest_settlers = implode(", ", umc_get_latest_settlers(5)); $notice = ''; $content = ""; # If not logged in if (!$UMC_USER) { $title = 'Welcome, stranger!'; $content = "Please feel free to look around! In order to start building with us, please <a href=\"{$UMC_DOMAIN}/wp-login.php\">whitelist yourself</a>. " . "To know more about how to join us, please <a href=\"{$UMC_DOMAIN}/server-access/whitelist/\">continue here</a>.<br>" . "If you are a member already, don\\'t be a stranger and <a href=\"{$UMC_DOMAIN}/wp-login.php\">login</a>!<br><br>" . 'If you want to see what awaits you inside, watch our trailer!<br>' . '<iframe width="550" height="315" src="//www.youtube.com/embed/RjfZaDpGCLA" allowfullscreen></iframe><br><br>'; } else { if ($userlevel == 'Guest') { $title = "Welcome, {$username}!"; $content = "Thanks for white-listing on our server.<br>We would love to see you building with us. " . "<a href=\"{$UMC_DOMAIN}/server-access/buildingrights/\">Get builder rights now</a>!"; } else { $content = "<ul>\n"; $title = "Welcome, <span class='" . strtolower($userlevel) . "'>{$username}</span>"; if (strpos($userlevel, 'Donator')) { $title .= "<span class='pluscolor'>+</span>"; } if (strpos($userlevel, 'Plus')) { $title .= "<span class='pluscolor'>+</span>"; } $votables = umc_vote_get_votable($username, true); // Teamspeak information $content .= "<li><strong>Join us</strong> on <a href=\"{$UMC_DOMAIN}/communication/teamspeak/\">Teamspeak</a>!</li>"; // Elder/Owner information if (strstr($userlevel, 'Elder') || $userlevel == 'Owner') { // elders only content $ban_arr = umc_get_recent_bans(3); $content .= "<li><strong>Logs:</strong> <a href=\"{$UMC_DOMAIN}/kills-logfile/\">Kills Logs</a>, <a href=\"{$UMC_DOMAIN}/logblock-logfile/\">Block Logs</a></li>\n" . "<li><strong>Recent Bans:</strong> "; foreach ($ban_arr as $ban => $reason) { $reason = trim($reason); $content .= "{$ban} ({$reason}), "; } $content = rtrim($content, ", "); $content .= "</li>\n"; } // Latest settlers $content .= "<li><strong>Please welcome our latest settlers:</strong> {$latest_settlers}</li>\n"; // Voting information if ($votables) { $content .= "<li>{$votables}</li>\n"; } // Group information $content .= '<li><strong>Your stats:</strong> Your level is <strong>' . $UMC_USER['userlevel'] . '</strong>'; // Online time information $online_time = umc_get_lot_owner_age('days', $uuid); if ($online_time) { $days = $online_time[$uuid]['firstlogin']['days']; $content .= ", you are on the server since <strong> {$days} days</strong>"; $online_hours = umc_get_online_hours($uuid); $content .= " and have been online for <strong> {$online_hours} hours</strong>"; if ($online_hours < 60) { $remaining = 60 - $online_hours; $content .= " but you need <strong>{$remaining}</strong> more hours online until Citizen status"; } } $content .= "!</li>\n"; // Deposit information $deposit = umc_show_depotlist(true, $username, true); if (is_array($deposit) && count($deposit) > 0) { $content .= "<li><strong><a href=\"http://uncovery.me/server-access/shop-manager/?page=deposit\">Your Deposit:</a></strong><ul>"; foreach ($deposit as $depot_content) { $content .= "<li>" . $depot_content['item'] . "</li>"; } $content .= "</ul></li>"; } $content .= "</ul>\n"; } } echo "<div class=\"welcome-block\"><h1 class=\"entry-title\">{$title}</h1>{$notice}\n{$content}\n</div>\n"; }
function umc_user_directory() { XMPP_ERROR_trace(__FUNCTION__, func_get_args()); // list all users $username_get = filter_input(INPUT_GET, 'u', FILTER_SANITIZE_STRING); if (!is_null($username_get)) { $O = array(); $wordpress_id = umc_user_get_wordpress_id($username_get); $username = strtolower(umc_check_user($username_get)); if (!$wordpress_id) { return "User does not exist!"; } $uuid = umc_user2uuid($username); // check if the user is active $count_lots = umc_user_countlots($uuid); if ($count_lots == 0) { return "User is not active!"; } // user icon $O['User'] = get_avatar($wordpress_id, $size = '96') . "<p><strong>Username:</strong> {$username}</p>\n" . "<p><strong>UUID:</strong> {$uuid}</p>\n"; $previous_names = umc_uuid_username_history($uuid); if ($previous_names) { $O['User'] .= "<p><strong>Usernames History:</strong> {$previous_names}</p>\n"; } // is user banned? if (umc_user_is_banned($uuid)) { $O['User'] .= "<p><strong>User is BANNED!</strong></p>\n"; return; } // get userlevel $level = umc_get_uuid_level($uuid); $karma = umc_getkarma($uuid, true); $money = umc_money_check($uuid); $O['User'] .= "<p><strong>Level:</strong> {$level}</p>\n" . "<p><strong>Karma:</strong> {$karma}</p>\n" . "<p><strong>Money:</strong> {$money} Uncs</p>\n"; // get lots $lots = umc_user_getlots($uuid); foreach ($lots as $data) { $world = ucwords($data['world']); $combined_worlds = array('Empire', 'Flatlands', 'Skyblock'); if (in_array($world, $combined_worlds)) { $world = 'Small lots'; } if (!isset($O[$world])) { $O[$world] = ''; } $O[$world] .= $data['image']; } $donator_level = umc_users_donators($uuid); if ($donator_level > 12) { $donator_str = 'More than 1 year'; } else { if ($donator_level) { $donator_level_rounded = round($donator_level, 1); $donator_str = "{$donator_level_rounded} Months"; } else { $donator_str = "Not a donator"; } } $O['User'] .= "<p><strong>Donations remaining:</strong> {$donator_str}</p>\n"; // get member since $online_time = umc_get_lot_owner_age('days', $uuid); if ($online_time) { $lastlogin = $online_time[$uuid]['lastlogin']['days']; $firstlogin = $online_time[$uuid]['firstlogin']['days']; $O['User'] .= "<p><strong>Member since:</strong> {$firstlogin} days</p>\n" . "<p><strong>Offline since:</strong> {$lastlogin} days</p>\n"; } // get user bio $sql = "SELECT meta_value FROM minecraft.wp_users\r\n LEFT JOIN minecraft.wp_usermeta ON wp_users.ID = wp_usermeta.user_id\r\n WHERE display_name='{$username}' AND meta_key='description';"; $D = umc_mysql_fetch_all($sql); if (count($D) > 0) { $row = $D[0]; $O['User'] .= "<p><strong>Bio:</strong> " . $row['meta_value'] . "</p>\n"; } // comments $sql2 = "SELECT comment_date, comment_author, id, comment_id, post_title FROM minecraft.wp_comments\r\n LEFT JOIN minecraft.wp_posts ON comment_post_id=id\r\n WHERE comment_author = '{$username}' AND comment_approved='1' AND id <> 'NULL'\r\n ORDER BY comment_date DESC"; $D2 = umc_mysql_fetch_all($sql2); if (count($D2) > 0) { $O['Comments'] = "<strong>Comments:</strong> (" . count($D2) . ")\n<ul>\n"; foreach ($D2 as $row) { $O['Comments'] .= "<li>" . $row['comment_date'] . " on <a href=\"/index.php?p=" . $row['id'] . "#comment-" . $row['comment_id'] . "\">" . $row['post_title'] . "</a></li>\n"; } $O['Comments'] .= "</ul>\n"; } //forum posts $sql3 = "SELECT wpp.id AS id, wpp.post_title AS title, wpp.post_date AS date,\r\n\t\twpp.post_parent AS parent, wpp.post_type AS type, parent.post_title AS parent_title\r\n FROM minecraft.wp_posts AS wpp\r\n\t LEFT JOIN minecraft.wp_users ON wpp.post_author=wp_users.id\r\n\t LEFT JOIN minecraft.wp_posts AS parent ON parent.id=wpp.post_parent\r\n\t WHERE wp_users.display_name='{$username}'\r\n\t\tAND (wpp.post_type='reply' OR wpp.post_type='topic')\r\n\t\tAND wpp.post_status='publish'\r\n\t ORDER BY wpp.post_date DESC"; $D3 = umc_mysql_fetch_all($sql3); // echo $sql; if (count($D3) > 0) { $O['Forum'] = "<strong>Forum Posts:</strong> (" . count($D3) . ")\n<ul>\n"; foreach ($D3 as $row) { $date = $row['date']; if ($row['type'] == 'reply') { $link = $row['parent'] . "#post-" . $row['id']; $title = $row['parent_title']; } else { $link = $row['id']; $title = $row['title']; } $O['Forum'] .= "<li>{$date} on <a href=\"/index.php?p={$link}\">{$title}</a></li>\n"; } $O['Forum'] .= "</ul>\n"; } echo umc_jquery_tabs($O); } else { // $bans = umc_get_banned_users(); //var_dump($bans); $out = "<script type=\"text/javascript\" src=\"/admin/js/jquery.dataTables.min.js\"></script>\n" . "<script type=\"text/javascript\">\n" . 'jQuery(document).ready(function() {jQuery' . "('#shoptable_users').dataTable( {\"order\": [[ 2, \"desc\" ]],\"paging\": false,\"ordering\": true,\"info\": true} );;} );\n" . "</script>\n" . "This table only tracks online time since 2013-11-20.<br>" . '<table id="shoptable_users"><thead>' . "<th>Username</th>" . "<th>Level</th>" . "<th>Registered days</th>" . "<th>Offline days</th>" . "<th>Lots</th>" . "<th>Online min/day</th>" . "<th>Online hrs</th>" . "</thead>\n<tbody>\n"; $sql = "SELECT username, DATEDIFF(NOW(),firstlogin) as registered_since, parent as userlevel, count(owner) as lot_count, onlinetime, DATEDIFF(NOW(), lastlogin) as days_offline\r\n FROM minecraft_srvr.UUID\r\n LEFT JOIN minecraft_srvr.permissions_inheritance ON UUID.uuid=child\r\n LEFT JOIN minecraft_worldguard.user ON UUID.uuid = user.uuid\r\n LEFT JOIN minecraft_worldguard.region_players ON user.id=region_players.user_id\r\n WHERE owner = 1 AND firstlogin >'0000-00-00 00:00:00' AND username <> '_abandoned_'\r\n GROUP BY username, owner\r\n ORDER BY firstlogin"; $rst = umc_mysql_query($sql); $now = time(); // or your date as well $your_date = strtotime("2013-11-20"); $datediff = $now - $your_date; $alt_days = floor($datediff / (60 * 60 * 24)); while ($row = umc_mysql_fetch_array($rst)) { $days_offline = $row['days_offline']; $settler_levels = array('Settler', 'SettlerDonator', 'SettlerDonatorPlus'); if (in_array($row['userlevel'], $settler_levels) && $row['onlinetime'] >= 60) { umc_promote_citizen(strtolower($row['username']), $row['userlevel']); } if ($row['registered_since'] - $days_offline > 1) { if ($alt_days < $row['registered_since']) { // people who are not in the lb-players database should not be listed, they are too old if ($alt_days - $days_offline == 0) { continue; } $avg_online = floor($row['onlinetime'] / 60 / $alt_days); } else { $avg_online = floor($row['onlinetime'] / 60 / $row['registered_since']); } } else { $avg_online = 0; } $online_total = round($row['onlinetime'] / 60 / 60); $icon_url = umc_user_get_icon_url($row['username']); $out .= "<tr>" . "<td><img title='{$row['username']}' src='{$icon_url}' alt=\"{$row['username']}\"> <a href=\"?u={$row['username']}\">{$row['username']}</a></td>" . "<td>{$row['userlevel']}</td>" . "<td class='numeric_td'>{$row['registered_since']}</td>" . "<td class='numeric_td'>{$days_offline}</td>" . "<td class='numeric_td'>{$row['lot_count']}</td>" . "<td class='numeric_td'>{$avg_online}</td>" . "<td class='numeric_td'>{$online_total}</td>" . "</tr>\n"; } $out .= "</tbody>\n</table>\n"; echo $out; } }