Example #1
0
function prefs_smarty_show($user_id)
{
    assert(is_numeric($user_id));
    global $_RUN;
    global $_USER;
    $template = new Smarty();
    help_set_template_vars($template, "PREFERENCES");
    $template->debugging = true;
    $result = sql_query("SELECT * FROM perihelion.t_themes");
    while ($row = sql_fetchrow($result)) {
        $tmpvar['ids'][] = $row['id'];
        $tmpvar['names'][] = $row['name'];
    }
    $template->assign("themes_ids", $tmpvar['ids']);
    $template->assign("themes_names", $tmpvar['names']);
    $user = user_get_perihelion_user($_USER['id']);
    if (SmartyValidate::is_init()) {
        $template->assign($_POST);
    } else {
        SmartyValidate::init();
        SmartyValidate::register_criteria("validate_email_is_ours_or_does_not_exists");
        SmartyValidate::register_criteria("validate_passwd");
        $template->assign("name", $user['name']);
        $template->assign("email", $user['email']);
        $template->assign("inform", $user['inform']);
        $template->assign("gender", $user['gender']);
        $template->assign("country", $user['country']);
        $template->assign("city", $user['city']);
        $template->assign("tag", $user['tag']);
        $tmp = split('-', $user['birthday']);
        $template->assign("dob_Day", $tmp[2]);
        $template->assign("dob_Month", $tmp[1]);
        $template->assign("dob_Year", $tmp[0]);
        $template->assign("theme", $user['theme_id']);
    }
    $template->assign("uid", encrypt_get_vars($user_id));
    $template->assign("cmd", encrypt_get_vars("post"));
    $template->assign("frmid", encrypt_get_vars(get_form_id()));
    $template->display($_RUN['theme_path'] . "/preferences.tpl");
}
Example #2
0
function sector_show_sector($sector_id, $user_id)
{
    assert(!empty($sector_id));
    assert(!empty($user_id));
    global $_RUN;
    // Create the submenu where we can easily move between sectors
    $result = sql_query("SELECT * FROM g_sectors WHERE user_id = " . $user_id);
    $tmp = sql_fetchrow($result);
    $sectors = csl($tmp['csl_sector_id']);
    $idx = array_search($sector_id, $sectors);
    $first = reset($sectors);
    $last = end($sectors);
    if ($idx == 0) {
        $prev = $sectors[$idx];
    } else {
        $prev = $sectors[$idx - 1];
    }
    if ($idx == count($sectors) - 1) {
        $next = $sectors[$idx];
    } else {
        $next = $sectors[$idx + 1];
    }
    create_submenu(array("First Sector" => "sector.php?cmd=" . encrypt_get_vars("show") . "&sid=" . encrypt_get_vars($first), "Previous Sector" => "sector.php?cmd=" . encrypt_get_vars("show") . "&sid=" . encrypt_get_vars($prev), "Next Sector" => "sector.php?cmd=" . encrypt_get_vars("show") . "&sid=" . encrypt_get_vars($next), "Last Sector" => "sector.php?cmd=" . encrypt_get_vars("show") . "&sid=" . encrypt_get_vars($last)));
    $sector = sector_get_sector($sector_id);
    $template = new Smarty();
    $template->debugging = true;
    help_set_template_vars($template);
    $template->assign("sector_id", $sector['sector']);
    $template->assign("sector_name", $sector['name']);
    $template->assign("sector_coordinate", $sector['distance'] . " / " . $sector['angle']);
    if ($sector['user_id'] == UID_NOBODY) {
        $template->assign("rename_form_visible", "true");
    } else {
        $template->assign("rename_form_visible", "false");
    }
    // And now, do all anomalies
    $tmp = user_get_all_anomalies_from_user($user_id);
    $anomalies = csl($tmp['csl_discovered_id']);
    $undiscovered_anomalies = csl($tmp['csl_undiscovered_id']);
    $anomalies = csl_merge_fields($anomalies, $tmp['csl_undiscovered_id']);
    // We didn't find any discovered anomalies in this sector per default
    $i = 0;
    $tmpvar = array();
    // Get anomaly information for all anomalies in the sector
    $result = sql_query("SELECT * FROM s_anomalies WHERE sector_id=" . $sector_id . " ORDER BY distance");
    while ($anomaly = sql_fetchrow($result)) {
        // We didn't discover this anomaly yet, continue with another
        if (!in_array($anomaly['id'], $anomalies)) {
            continue;
        }
        // Thread undiscovered planets different...
        if (in_array($anomaly['id'], $undiscovered_anomalies)) {
            $tmp['name'] = "Unknown";
            $tmp['class'] = "";
            $tmp['population'] = "";
            $tmp['owner'] = "";
            $tmp['status'] = "";
            $tmp['radius'] = $anomaly['radius'];
            $tmp['distance'] = $anomaly['distance'];
            $tmpvar[] = $tmp;
            continue;
        }
        // If we are here, we have found an anomaly with we already
        // discovered and explored, show all the info about it...
        $state = sql_get_state($anomaly['state_id']);
        if ($anomaly['user_id'] != 0) {
            $race = user_get_race($anomaly['user_id']);
        } else {
            $race = "Nobody";
        }
        // Show the population status in a different color
        if ($anomaly['population_capacity'] == 0) {
            $p = 0;
        } else {
            $p = $anomaly['population'] / $anomaly['population_capacity'] * 100;
        }
        $popcol = 'people_class1';
        if ($p > 50) {
            $popcol = 'people_class2';
        }
        if ($p > 75) {
            $popcol = 'people_class3';
        }
        if ($p > 99) {
            $popcol = 'people_class4';
        }
        if (!anomaly_is_planet($anomaly['id'])) {
            $anomaly['class'] = "";
            $anomaly['population'] = "";
        }
        // Show the class in different colors, A..J are orange... K..M are white... L..Z are red
        $classcol = "class_normal";
        if (planet_is_habitable($anomaly['id'])) {
            $classcol = 'class_habitable';
        } elseif (planet_is_minable($anomaly['id'])) {
            $classcol = 'class_minable';
        } else {
            $classcol = 'class_unusable';
        }
        $tmp = array();
        $tmp['name_href'] = "anomaly.php?cmd=" . encrypt_get_vars("show") . "&aid=" . encrypt_get_vars($anomaly['id']);
        $tmp['name'] = $anomaly['name'];
        $tmp['class'] = $anomaly['class'];
        $tmp['class_class'] = $classcol;
        if (planet_is_habitable($anomaly['id'])) {
            $tmp['population'] = $anomaly['population'];
        } else {
            $tmp['population'] = "---";
        }
        $tmp['population_class'] = $popcol;
        $tmp['owner'] = $race;
        $tmp['status'] = $state;
        $tmp['radius'] = $anomaly['radius'];
        $tmp['distance'] = $anomaly['distance'];
        $tmpvar[] = $tmp;
    }
    $template->assign("anomalies", $tmpvar);
    $template->display($_RUN['theme_path'] . "/sectors-item.tpl");
}
Example #3
0
<?php

// Include Files
include "includes.inc.php";
session_start();
print_header();
print_title("Registration", "With this form you can register yourself as a new player of perihelion. Please fill in all information below");
$template = new Smarty();
help_set_template_vars($template, "REGISTER");
$template->debugging = true;
$result = sql_query("SELECT * FROM perihelion.t_themes");
while ($row = sql_fetchrow($result)) {
    $tmpvar['ids'][] = $row['id'];
    $tmpvar['names'][] = $row['name'];
}
$template->assign("themes_ids", $tmpvar['ids']);
$template->assign("themes_names", $tmpvar['names']);
if (!SmartyValidate::is_init() && !isset($_POST['submit'])) {
    SmartyValidate::init();
    SmartyValidate::register_criteria("validate_email");
    SmartyValidate::register_criteria("validate_login");
    SmartyValidate::register_criteria("validate_specie");
    SmartyValidate::register_criteria("validate_sector");
    SmartyValidate::register_criteria("validate_planet");
    $template->display($_RUN['theme_path'] . "/register.tpl");
} else {
    if (SmartyValidate::is_valid($_POST)) {
        SmartyValidate::clear();
        $ok = "";
        $errors['PARAMS'] = "Incorrect parameters specified..\n";
        $data['tag'] = $_POST['tag'];
Example #4
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");
}