function create_idle_time($time)
{
    $timestamp = strtotime($time);
    $str = calculate_uptime(mktime() - $timestamp);
    return array($str . " ago", mktime() - $timestamp);
}
Example #2
0
function show_info($user_id)
{
    global $_USER;
    global $_CONFIG;
    global $_RUN;
    $user = user_get_user($user_id);
    // User Information
    $template = new Smarty();
    help_set_template_vars($template, "INFO");
    $planets_owned = info_get_planetown_count($user_id);
    $template->assign("stardate", info_get_stardate());
    $template->assign("credits", $user['credits']);
    $template->assign("population", info_get_population_count($user_id));
    $template->assign("sectors_owned", info_get_sectorown_count($user_id));
    $template->assign("planets_owned", $planets_owned);
    list($minable_count, $habitable_count, $unusable_count, $starbase_count, $wormhole_count, $blackhole_count, $anomalie_count) = info_get_anomaly_statistics($user_id);
    $template->assign("minable_count", $minable_count);
    $template->assign("minable_percentage", round($minable_count / $planets_owned * 100, 2));
    $template->assign("habitable_count", $habitable_count);
    $template->assign("habitable_percentage", round($habitable_count / $planets_owned * 100, 2));
    $template->assign("unusable_count", $unusable_count);
    $template->assign("unusable_percentage", round($unusable_count / $planets_owned * 100, 2));
    $template->assign("wormhole_count", $wormhole_count);
    $template->assign("wormhole_percentage", round($wormhole_count / $planets_owned * 100, 2));
    $template->assign("starbase_count", $starbase_count);
    $template->assign("starbase_percentage", round($starbase_count / $planets_owned * 100, 2));
    $template->assign("anomalie_count", $anomalie_count);
    $template->assign("anomalie_percentage", round($anomalie_count / $planets_owned * 100, 2));
    // Tactical Information
    list($total_vessels, $evd, $tvd, $bvd) = info_get_vessel_statistics($user_id);
    $template->assign("total_vessels", $total_vessels);
    $template->assign("bvd", $bvd);
    $template->assign("bvd_percentage", round($bvd / $total_vessels * 100, 2));
    $template->assign("tvd", $tvd);
    $template->assign("tvd_percentage", round($tvd / $total_vessels * 100, 2));
    $template->assign("evd", $evd);
    $template->assign("evd_percentage", round($evd / $total_vessels * 100, 2));
    list($weak_ship_id, $ws_a) = user_get_weakest_ship($user_id);
    $weak_ship = vessel_get_vessel($weak_ship_id);
    $template->assign("weakship_name", $weak_ship['name']);
    $template->assign("weakship_href", "vessel.php?cmd=" . encrypt_get_vars("show") . "&vid=" . encrypt_get_vars($weak_ship_id));
    $template->assign("weakship_percentage", $ws_a);
    list($strong_ship_id, $ss_a) = user_get_strongest_ship($user_id);
    $strong_ship = vessel_get_vessel($strong_ship_id);
    $template->assign("strongship_name", $strong_ship['name']);
    $template->assign("strongship_href", "vessel.php?cmd=" . encrypt_get_vars("show") . "&vid=" . encrypt_get_vars($strong_ship_id));
    $template->assign("strongship_percentage", $ss_a);
    list($weak_planet_id, $wp_a) = user_get_weakest_planet($user_id);
    $weak_planet = anomaly_get_anomaly($weak_planet_id);
    $template->assign("weakplanet_name", $weak_planet['name']);
    $template->assign("weakplanet_href", "anomaly.php?cmd=" . encrypt_get_vars("show") . "&aid=" . encrypt_get_vars($weak_planet_id));
    $template->assign("weakplanet_percentage", $wp_a);
    list($strong_planet_id, $sp_a) = user_get_strongest_planet($user_id);
    $strong_planet = anomaly_get_anomaly($strong_planet_id);
    $template->assign("strongplanet_name", $strong_planet['name']);
    $template->assign("strongplanet_href", "anomaly.php?cmd=" . encrypt_get_vars("show") . "&aid=" . encrypt_get_vars($strong_planet_id));
    $template->assign("strongplanet_percentage", $sp_a);
    // Other Information
    list($bd, $vd, $id) = info_get_invention_statistics($user_id);
    $template->assign("buildings_discovered_percentage", $bd);
    $template->assign("vessels_discovered_percentage", $vd);
    $template->assign("inventions_discovered_percentage", $id);
    $template->assign("impulse_discovered", $user['impulse']);
    $template->assign("warp_discovered", number_format($user['warp'] / 10, 1));
    // Server status
    if (check_heartbeat_online()) {
        $template->assign("heartbeat_status", "online");
    } else {
        $template->assign("heartbeat_status", "offline");
    }
    if (check_server_online()) {
        $template->assign("commserver_status", "online");
        $result = sql_query("SELECT * FROM perihelion.pxs_info WHERE galaxy_id LIKE '" . $_USER['galaxy_db'] . "'");
        $server_status = sql_fetchrow($result);
        $result = sql_query("SELECT UNIX_TIMESTAMP()");
        $row = sql_fetchrow($result);
        $server_status['uptime'] = $row['0'] - $server_status['uptime'];
        $template->assign("commserver_uptime", calculate_uptime($server_status['uptime']));
        $template->assign("commserver_spawns", $server_status['spawns']);
        $template->assign("commserver_commands", $server_status['commands']);
        $template->assign("commserver_status_ok", $server_status['status_ok']);
        $template->assign("commserver_status_err", $server_status['status_err']);
    } else {
        $template->assign("commserver_status", "offline");
    }
    if (check_mysql_online()) {
        $template->assign("mysql_status", "online");
        // Get the mysql status and make it a nice hash
        $result = sql_query("SHOW STATUS");
        while ($row = sql_fetchrow($result)) {
            $sql_status[$row['Variable_name']] = $row['Value'];
        }
        $template->assign("mysql_uptime", calculate_uptime($sql_status['Uptime']));
        $template->assign("mysql_queries", $sql_status['Questions']);
        $template->assign("mysql_select", $sql_status['Com_select']);
        $template->assign("mysql_insert", $sql_status['Com_insert']);
        $template->assign("mysql_update", $sql_status['Com_update']);
        $template->assign("mysql_bytes_received", $sql_status['Bytes_received']);
        $template->assign("mysql_bytes_sent", $sql_status['Bytes_sent']);
    } else {
        $template->assign("mysql_status", "offline");
    }
    $template->display($_RUN['theme_path'] . "/info.tpl");
}