function validate_request_checksum()
{
    global $_USER;
    // No formid found, means we don't have a form posted or getted
    if (!isset($_REQUEST['frmid'])) {
        return true;
    }
    // Grab the form id, either by get or by post.
    $formid = decrypt_get_vars($_REQUEST['frmid']);
    // Check if the result is already found, if so, we can't resend the form
    $result = sql_query("SELECT * FROM perihelion.formid WHERE user_id = " . $_USER['id'] . " AND id LIKE '" . $formid . "'");
    if (sql_countrows($result) == 1) {
        sql_query("UPDATE perihelion.formid SET tries=tries+1 WHERE id='" . $formid . "'");
        return false;
    }
    // Not found, so it's the first time we send this form, save it in the database...
    sql_query("INSERT INTO perihelion.formid (id,tries,user_id,page) VALUES ('" . $formid . "', 0, " . $_USER['id'] . ", '" . $_SERVER['PHP_SELF'] . "')");
    return true;
}
Example #2
0
function validate_planet($value, $empty, &$params, &$formvars)
{
    global $_CONFIG;
    $result = sql_query("SELECT * FROM " . $_CONFIG['default_db'] . ".s_anomalies WHERE name LIKE '{$value}'");
    if (sql_countrows($result) == 0) {
        return true;
    }
    return false;
}
Example #3
0
function validate_email_is_ours_or_does_not_exists($value, $empty, &$params, &$formvars)
{
    $result = sql_query("SELECT * FROM perihelion.u_users WHERE email LIKE '{$value}'");
    if (sql_countrows($result) == 0) {
        return true;
    }
    // Check if it's ours, if so, then this one is allright..
    $uid = decrypt_get_vars($formvars['uid']);
    $row = sql_fetchrow($result);
    if ($row['id'] == $uid) {
        return true;
    }
    return false;
}
Example #4
0
function sql_fetchrow($result, $override_row_check = false)
{
    assert(!empty($result));
    assert(is_bool($override_row_check));
    if ($override_row_check == true && sql_countrows($result) == 0) {
        perihelion_die("Empty Record Set", "Perihelion found an empty record set.");
    }
    return @mysql_fetch_array($result);
}
function vessel_in_traderoute($vessel_id)
{
    assert(is_numeric($vessel_id));
    $result = sql_query("SELECT id FROM a_trades WHERE vessel_id=" . $vessel_id);
    if (sql_countrows($result) == 0) {
        return false;
    }
    return true;
}
function user_showinfo($user_id, $extended_info = USER_SHOWINFO_NORMAL)
{
    assert(is_numeric($user_id));
    $user = user_get_user($user_id);
    $px_user = user_get_perihelion_user($user_id);
    $result = sql_query("SELECT * FROM perihelion.u_access WHERE user_id=" . $user_id . " ORDER BY login DESC LIMIT 1");
    $access = sql_fetchrow($result);
    sql_query("USE " . $px_user['galaxy_db']);
    $result = sql_query("SELECT SUM(population) FROM s_anomalies WHERE user_id=" . $user_id);
    $row = sql_fetchrow($result);
    $people = $row['0'];
    $result = sql_query("SELECT COUNT(*) FROM s_sectors WHERE user_id=" . $user_id);
    $row = sql_fetchrow($result);
    $sectors_owned = $row['0'];
    $result = sql_query("SELECT COUNT(*) FROM s_anomalies WHERE user_id=" . $user_id);
    $row = sql_fetchrow($result);
    $planets_owned = $row['0'];
    $result = sql_query("SELECT DISTINCT sector_id, COUNT(*) FROM s_anomalies WHERE user_id=" . $user_id . " GROUP BY sector_id");
    $sector_count = sql_countrows($result);
    $sector = sector_get_sector(user_get_home_sector($user_id));
    $planet = anomaly_get_anomaly(user_get_home_planet($user_id));
    $race = user_get_race($user_id);
    $result = sql_query("SELECT * FROM g_alliance WHERE id=" . $user['alliance_id']);
    $alliance = sql_fetchrow($result);
    if ($user['alliance_id'] != 0) {
        $result = sql_query("SELECT COUNT(*) AS count FROM g_users WHERE alliance_id = " . $alliance['id']);
        $tmp = sql_fetchrow($result);
        $alliance_size = $tmp['count'];
    }
    $status = "Unknown";
    if (user_is_friend(user_ourself(), $user_id)) {
        $status = "Single side friend";
    }
    if (user_is_mutual_friend(user_ourself(), $user_id)) {
        $status = "Mutual friend";
    }
    if (user_is_neutral(user_ourself(), $user_id)) {
        $status = "Neutral";
    }
    if (user_is_enemy(user_ourself(), $user_id)) {
        $status = "Enemy";
    }
    if (user_ourself() == $user_id) {
        $status = "";
    }
    echo "<table border=0 align=center width=60%>";
    echo "<tr><th class=white colspan=2>" . $px_user['name'] . "</th><th>&nbsp;</th></tr>";
    echo "<tr><th colspan=2><b>" . $px_user['tag'] . "</b></th></tr>";
    echo "<tr valign=top>";
    echo "  <td width=120>";
    echo "    <img width=100 height=100 src='images/users/" . $px_user['avatar'] . "'><br>";
    echo "    <br>";
    if ($user['alliance_id'] != 0) {
        echo "    <img width=100 height=100 src='images/users/" . $alliance['avatar'] . "'><br>";
    }
    echo "  </td>";
    echo "  <td><table border=0 nowrap>";
    echo "        <tr class=bl><td>&nbsp;Full Name       &nbsp;</td><td>:</td><td>&nbsp;" . $px_user['name'] . "&nbsp;</td></tr>";
    echo "        <tr class=bl><td>&nbsp;User ID         &nbsp;</td><td>:</td><td>&nbsp;" . $px_user['id'] . "&nbsp;</td></tr>";
    echo "        <tr class=bl><td>&nbsp;City            &nbsp;</td><td>:</td><td>&nbsp;" . $px_user['city'] . "&nbsp;</td></tr>";
    echo "        <tr class=bl><td>&nbsp;Country         &nbsp;</td><td>:</td><td>&nbsp;" . $px_user['country'] . "&nbsp;</td></tr>";
    echo "        <tr><td colspan=3>&nbsp;</td></tr>";
    if ($status != "") {
        echo "        <tr class=bl><td>&nbsp;Diplomatic Status &nbsp;</td><td>:</td><td>&nbsp;" . $status . "&nbsp;</td></tr>";
    }
    echo "        <tr class=bl><td>&nbsp;Race              &nbsp;</td><td>:</td><td>&nbsp;" . $race . "&nbsp;</td></tr>";
    echo "        <tr class=bl><td>&nbsp;Home Planet       &nbsp;</td><td>:</td><td>&nbsp;" . $planet['name'] . "&nbsp;</td></tr>";
    echo "        <tr class=bl><td>&nbsp;Home Sector       &nbsp;</td><td>:</td><td>&nbsp;" . $sector['name'] . "&nbsp;</td></tr>";
    echo "        <tr class=bl><td>&nbsp;Population        &nbsp;</td><td>:</td><td>&nbsp;" . $people . "&nbsp;</td></tr>";
    echo "        <tr class=bl><td>&nbsp;Sectors Owned     &nbsp;</td><td>:</td><td>&nbsp;" . $sectors_owned . "&nbsp;</td></tr>";
    echo "        <tr class=bl><td>&nbsp;Planets Owned     &nbsp;</td><td>:</td><td>&nbsp;" . $planets_owned . " planet(s) in " . $sector_count . " sector(s)&nbsp;</td></tr>";
    if ($user['alliance_id'] != 0) {
        echo "        <tr class=bl><td>&nbsp;Alliance        &nbsp;</td><td>:</td><td>&nbsp;<a href=alliance.php?cmd=" . encrypt_get_vars("show") . "&aid=" . encrypt_get_vars($alliance['id']) . ">" . $alliance['name'] . "</a>&nbsp;</td></tr>";
        echo "        <tr class=bl><td>&nbsp;Alliance Size   &nbsp;</td><td>:</td><td>&nbsp;" . $alliance_size . " user(s)&nbsp;</td></tr>";
    }
    echo "        <tr><td colspan=3>&nbsp;</td></tr>";
    echo "        <tr class=bl><td>&nbsp;Times logged in   &nbsp;</td><td>:</td><td>&nbsp;" . $px_user['login_count'] . "&nbsp;</td></tr>";
    echo "        <tr class=bl><td>&nbsp;Last login        &nbsp;</td><td>:</td><td>&nbsp;" . $access['login'] . "&nbsp;</td></tr>";
    echo "        <tr class=bl><td>&nbsp;Last action       &nbsp;</td><td>:</td><td>&nbsp;" . $access['logout'] . "&nbsp;</td></tr>";
    if ($extended_info == USER_SHOWINFO_EXTENDED) {
        if ($px_user['gender'] == "M") {
            $gender = "Male";
        } else {
            $gender = "Female";
        }
        echo "        <tr><td colspan=3>&nbsp;</td></tr>";
        echo "        <tr class=bl><td>&nbsp;Email      &nbsp;</td><td>:</td><td>&nbsp;" . $px_user['email'] . "&nbsp;</td></tr>";
        echo "        <tr class=bl><td>&nbsp;Login Name &nbsp;</td><td>:</td><td>&nbsp;" . $px_user['login_name'] . "&nbsp;</td></tr>";
        echo "        <tr><td colspan=3>&nbsp;</td></tr>";
        echo "        <tr class=bl><td>&nbsp;City       &nbsp;</td><td>:</td><td>&nbsp;" . $px_user['city'] . "&nbsp;</td></tr>";
        echo "        <tr class=bl><td>&nbsp;Country    &nbsp;</td><td>:</td><td>&nbsp;" . $px_user['country'] . "&nbsp;</td></tr>";
        echo "        <tr><td colspan=3>&nbsp;</td></tr>";
        echo "        <tr class=bl><td>&nbsp;Birthday   &nbsp;</td><td>:</td><td>&nbsp;" . $px_user['birthday'] . "&nbsp;</td></tr>";
        echo "        <tr class=bl><td>&nbsp;Gender     &nbsp;</td><td>:</td><td>&nbsp;" . $gender . "&nbsp;</td></tr>";
    }
    if ($user_id != user_ourself()) {
        echo "<tr><th colspan=3>";
        echo "[ <a href=message.php?uid=" . encrypt_get_vars($user_id) . ">Send Message</a> ]";
        echo "</th></tr>";
        echo "<tr><th colspan=3>";
        echo "[ <a href=user.php?cmd=" . encrypt_get_vars("relation") . "&uid=" . encrypt_get_vars($user_id) . "&wid=" . encrypt_get_vars(RELATION_FRIEND) . ">Set as friend</a>  ] - ";
        echo "[ <a href=user.php?cmd=" . encrypt_get_vars("relation") . "&uid=" . encrypt_get_vars($user_id) . "&wid=" . encrypt_get_vars(RELATION_NEUTRAL) . ">Set as neutral</a>  ] - ";
        echo "[ <a href=user.php?cmd=" . encrypt_get_vars("relation") . "&uid=" . encrypt_get_vars($user_id) . "&wid=" . encrypt_get_vars(RELATION_ENEMY) . ">Set as enemy</a> ]";
        echo "</th></tr>";
    }
    echo "  </table></td>";
    echo "</tr>";
    echo "</table>";
    echo "<br><br>";
}
<?php

// Include Files
include "../includes.inc.php";
// Session Identification
session_identification("admin");
print_header();
print_title("Create Test users for scoring purposes...", "Make sure you have set the correct tables_priv rows for u_users and u_score in the database!");
$result = sql_query("SELECT * FROM perihelion.u_users WHERE id >= 1000");
if (sql_countrows($result) != 0) {
    print_line("User Id 1000 or above already exists!");
    print_footer();
    exit;
}
// Create 1000 users....
for ($i = 1000; $i != 2000; $i++) {
    sql_query("INSERT INTO perihelion.u_users (id, login_name, name) VALUES ({$i}, 'plyr{$i}', 'Player {$i}')");
    sql_query("INSERT INTO perihelion.u_score (user_id, overall, resource, strategic, exploration) VALUES ({$i}, RAND()*1000, RAND()*1000, RAND()*1000, RAND()*1000)");
    echo "Done with player {$i}<br>\n";
}
print_footer();
exit;