function umc_github_link()
{
    global $GITHUB;
    $repo = $GITHUB['repo'];
    $owner = $GITHUB['owner'];
    $client = umc_github_client_connect($owner, $repo);
    $out = '';
    $paginator = new Github\ResultPager($client);
    $items = array('open_issues' => array('state' => array('state' => 'open'), 'fetch' => 'all'), 'closed_issues' => array('state' => array('state' => 'closed'), 'fetch' => 'all'), 'comments' => array('state' => 'comments', 'fetch' => 'show'));
    foreach ($items as $item => $I) {
        $api = $client->api('issue');
        $parameters = array($owner, $repo, $I['state']);
        ${$item} = $paginator->fetchAll($api, $I['fetch'], $parameters);
    }
    $parameters = array('sha' => 'master', 'per_page' => 100);
    $commits = $client->api('repo')->commits()->all($owner, $repo, $parameters);
    $out .= '<script type="text/javascript" src="/admin/js/jquery.dataTables.min.js"></script>
    <script type="text/javascript">
        jQuery(document).ready(function() {jQuery("#shoptable_open").dataTable( {"autoWidth": false, "order": [[ 4 ]], "paging": false, "ordering": true, "info": false});;} );
        jQuery(document).ready(function() {jQuery("#shoptable_closed").dataTable( {"autoWidth": false, "order": [[ 4 ]], "paging": false, "ordering": true, "info": false});;} );
        jQuery(document).ready(function() {jQuery("#shoptable_commits").dataTable( {"autoWidth": false, "order": [[ 0 ]], "paging": false, "ordering": true, "info": false});;} );
    </script>
';
    $tab1 = "            <table class='unc_datatables' id='shoptable_open'>\r\n                <thead>\r\n                    <tr><th>#</th><th>Title</th><th style='display:none;'>hidden data</th><th>Labels</th><th>Updated</th></tr>\r\n                </thead>\r\n                <tbody>" . umc_github_issue_body($open_issues, $comments) . "</tbody>\r\n            </table>";
    $tab2 = "            <table class='unc_datatables' id='shoptable_closed'>\r\n                <thead>\r\n                    <tr><th>#</th><th>Title</th><th style='display:none;'>hidden data</th><th>Labels</th><th>Updated</th></tr>\r\n                </thead>\r\n                <tbody>" . umc_github_issue_body($closed_issues, $comments) . "</tbody>\r\n            </table>";
    $tab3 = "            <table class='unc_datatables' id='shoptable_commits'>\r\n                <thead>\r\n                    <tr><th>Date</th><th>User</th><th>Message</th></tr>\r\n                </thead>\r\n                <tbody>" . umc_github_commit_body($commits) . "</tbody>\r\n             </table>";
    $o_count = count($open_issues);
    $c_count = count($closed_issues);
    $out .= umc_jquery_tabs(array("Open Issues ({$o_count})" => $tab1, "Closed Issues ({$c_count})" => $tab2, 'Commits' => $tab3));
    return $out;
}
示例#2
0
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;
    }
}