Пример #1
1
function combat_ticker($alliances, $users)
{
    $week = dlookup("week", "timeinfo");
    foreach ($users as $uid => $count) {
        ticker($uid, "*lbattlereport.php?act=show_own&_minw={$week}&_maxw={$week}*You were involved in " . $count . " battles!", "a");
    }
    foreach ($alliances as $aid => $count) {
        $members = get_alliance_members($aid);
        foreach ($members as $uid => $name) {
            // mop: gabs ausser den eigenen auch noch kämpfe?
            if ($count - $users[$uid] > 0) {
                ticker($uid, "*lbattlereport.php?act=show_alliance&_minw={$week}&_maxw={$week}*Your alliance was involved in " . ($count - $users[$uid]) . " battles!", "a");
            }
        }
    }
}
Пример #2
0
function proc_new_account()
{
    global $standard_scan_radius;
    $name = trim($_POST["username"]);
    $imperium = trim($_POST["imperium"]);
    $email = trim($_POST["email"]);
    $password = trim($_POST["password"]);
    $password2 = trim($_POST["password2"]);
    $error = "";
    if ($name == "") {
        $error = $error . "No name selected!<br>";
    }
    $sth = mysql_query("select * from users where name='{$name}'");
    if (mysql_num_rows($sth) > 0) {
        $error = $error . "Name already selected!<br>";
    }
    if ($imperium == "") {
        $error = $error . "No empire selected!<br>";
    }
    $sth = mysql_query("select imperium from users where imperium='{$imperium}'");
    if (!$sth) {
        show_error("Database failure!");
        return 0;
    }
    if (mysql_num_rows($sth) > 0) {
        $error = $error . "empire already selected!<br>";
    }
    if (!mail_check($email)) {
        $error = $error . "You must enter a valid email!<br>";
    }
    $sth = mysql_query("select email from users where email='{$email}'");
    if (mysql_num_rows($sth) > 0) {
        $error = $error . "Email already exists<br>";
    }
    if ($password != $password2) {
        $error = $error . "Passwords don't match!<br>";
    }
    if (strlen($password) < 4) {
        $error = $error . "Your Password must contain at least 4 characters!";
    }
    if (strlen($error) == 0) {
        $sth = mysql_query("insert into users (name,imperium,email,password) values ('{$name}','{$imperium}','{$email}','" . crypt($password) . "')");
        if (!$sth) {
            show_error("Database Failure!");
            return 0;
        }
        $uid = mysql_insert_id();
        $sth = mysql_query("insert into ressources (metal,energy,mopgas,erkunum,gortium,susebloom,colonists,money,uid) values ('1000','1000','0','0','0','0','5','1000000','{$uid}')");
        if (!$sth) {
            show_error("Database Failure!");
            return 0;
        }
        $start = startplanet();
        $sth = mysql_query("update planets set uid='{$uid}',population='1000000' where id='" . $start . "'");
        if (!$sth) {
            show_error("Database Failure!");
            return 0;
        }
        $sth = mysql_query("insert into popgain set pid=" . $start);
        if (!$sth) {
            show_error("ERR::SET POPGAIN");
            return 0;
        }
        $sth = mysql_query("update users set homeworld={$start} where id='" . $uid . "'");
        if (!$sth) {
            show_error("Database Failure!");
            return 0;
        }
        $sth = mysql_query("select p.sid,s.cid from planets p,systems s where p.id=" . $start . " and p.sid=s.id");
        if (!$sth) {
            show_error("ERR::GET SID");
            return 0;
        }
        list($sid, $cid) = mysql_fetch_row($sth);
        $sth1 = mysql_query("replace into __scanranges_" . $cid . " (sid,uid,type,range,last_update) values ('" . $sid . "','" . $uid . "','0','" . $standard_scan_radius . "','" . $time . "')");
        mt_srand((double) microtime() * 1000000);
        $act_code = mt_rand(100000, 99999999);
        $sth = mysql_query("insert into activationcodes (code,uid) values ('" . $act_code . "','{$uid}')");
        // WIIIIIICHTIG!
        $sth = mysql_query("insert into research (uid,t_id) values ('{$uid}','0')");
        $sth = mysql_query("insert into research (uid,t_id) values ('{$uid}','1')");
        $sth = mysql_query("update users set skin=1 where id={$uid}");
        $the_mail = "Welcome to the Pre-Beta-Round Regent!\n\nYour Login: {$name}\nYour Empire: {$imperium}\nYour Pass: {$password}\nYour Activationcode: {$act_code}\n\nTo activate your account click on the following link:\n\nhttp://www.spaceregents.de/spaceregents/login.php?act=activate\n\nPlease not that this is a TEST(!)-Round. That means that SpaceRegents\nmay still be full of bugs and unimplemented features. As a tester you\nare supposed to report any bugs you encounter and report them in\nour forums. You can and (maybe should ;) ) try to hack our scripts\nbut you should (again) report any successfull hacks in the forum.\n\nLast but not least: Good luck and have fun ;)\n\nThe SpaceRegents Team\n";
        mail($email, "Your Spaceregents Activation Code", $the_mail, "From: webmaster@spaceregents.de\nReply-To: webmaster@spaceregents.de\nX-Mailer: PHP/" . phpversion());
        ticker($uid, "*lmail.php*Hi and welcome to SpaceRegents. A mail with quickstart instructions is in your Inbox. Click here to see your Inbox.", "w");
        $quickstart = "Welcome to Spaceregents, the ultimate Space Strategy!\n\nThis is a short quickstart and should give you the\nfirst hints on how to play SpaceRegents.\n\nOn the left you'll find your buddy list and the\nNavgationpanel.\n\nNavigationbuttons (in top-down order):\n\nOverview (the page you saw when logging in)\nCommunication (Communiction, Alliance menus.)\nRanking\nPlanets and Production (Planets, Build menu)\nFleet (Fleetmanagement)\nMap (The SpaceRegents starmap)\nResearch\nCovertops (Espionage and sabotage your enemies)\nTrade (Trading of ressources)\n\nFurthermore you'll see the Preferences and Logout\nbuttons in the lower left corner.\n\nFirst you should start your research and build\nsomething on a planet (Metal mine is recommended).\nThe time is estimated in weeks. 1 week in\nSpaceRegents is equal to 1 hour in reality.\nAfter that you should have a look at the Map (make\nsure you have a supported SVG Viewer on your\nsystem) to get an idea where you are located and\nwho is in your neighbourhood. If you want you can\nexamine the alliances which exist in Spaceregents\nso far. As a neutral player you can't be attacked\nbut you have several limitations in the game. If\nyou join an alliance you don't have these\nlimitations but you can be attacked. So you are\nsafe for now but should consider to join/create an\nalliance soon. It may be a good idea to contact\nyour direct neighbours as well.\n\nThis should have given you a first glance at\nSpaceRegents. More about the features of\nSpaceregents is explained in the manual. If you\nneed help feel free to join the forum and post\nyour questions there.\n\nGood luck and have fun!\n\nThe Spaceregents Team.";
        mail_to_uid($uid, "Quickstart", $quickstart);
        // runelord: options setzen
        $sth = mysql_query("insert into options (uid, map_size) values(" . $uid . ",1)");
        if (!$sth) {
            show_error("Database Failure!");
            return 0;
        }
        // geben wir noch jedem ein scout :)
        // nächste freie fleet_id finden
        $sth = mysql_query("select if(max(fid) is NULL,1,max(fid)+1) from fleet_info");
        if (!$sth) {
            show_error("Database Failure!");
            return 0;
        }
        list($next_fid) = mysql_fetch_row($sth);
        // eintrag in fleet_info
        $sth = mysql_query("insert into fleet_info (fid, pid, sid, name, uid) values('{$next_fid}','{$start}','{$sid}','Explorer','{$uid}')");
        if (!$sth) {
            show_error("Database Failure! 2x");
            return 0;
        }
        $sth = mysql_query("insert into fleet values (2,1,0,'{$next_fid}')");
        if (!$sth) {
            show_error("Database Failure! 3x");
            return 0;
        }
        $sth = mysql_query("insert into income_stats set uid=" . $uid);
        if (!$sth) {
            show_error("ERR::INCOME STATS");
            return 0;
        }
        activate("new_account");
    } else {
        new_account($error);
    }
}
Пример #3
0
function movements()
{
    // mop: reload updaten
    $sth = mysql_query("update fleet set reload=reload-1 where reload>0");
    if (!$sth) {
        echo "Database failure reload!";
    }
    // mop: alle bewegungen erfassen
    $fleets = get_global_movements();
    for ($i = 0; $i < sizeof($fleets); $i++) {
        // mop: bewegung an rand des systems (flotte will springen sitzt aber noch auf nem planeten)
        if ($fleets[$i]["tsid"] != $fleets[$i]["sid"] && $fleets[$i]["pid"] != 0) {
            // mop: einfach an den rand des systems setzen => pid=0 und der rest bleibt
            set_flocation($fleets[$i]["fid"], 0, $fleets[$i]["sid"], $fleets[$i]["tpid"], $fleets[$i]["tsid"]);
        } elseif ($fleets[$i]["tsid"] != $fleets[$i]["sid"]) {
            move_system_system($fleets[$i]);
        } elseif ($fleets[$i]["tsid"] == $fleets[$i]["sid"]) {
            // mop: zu nem planeten
            if ($fleets[$i]["pid"] != $fleets[$i]["tpid"] && $fleets[$i]["tpid"] != 0) {
                ticker($fleets[$i]["uid"], "*lfleet.php*Fleet " . $fleets[$i]["name"] . ": arrived at planet " . get_planetname($fleets[$i]["tpid"]), "w");
            }
            set_flocation($fleets[$i]["fid"], $fleets[$i]["tpid"], $fleets[$i]["tsid"], 0, 0);
        } else {
            echo "Kaputter Flug!!!!!!!!!\n";
            var_dump($fleets[$i]);
            echo "===================\n";
        }
    }
}
Пример #4
0
function accept_pending()
{
    global $uid;
    global $faid;
    if (has_alliance_lock($uid)) {
        show_message("You can't use any alliance options due to an alliance lock!");
        return false;
    }
    $aid = get_alliance($uid);
    if (!is_leader($uid, $aid)) {
        show_message("Be aware of the dark side!");
        return 0;
    }
    $pending_status = get_pending_diplomacy_change($faid, $aid);
    if (!$pending_status) {
        show_message("fu! ;)");
        return 0;
    }
    if (!drop_pending_diplomatic_request($faid, $aid)) {
        show_error("Database failure!");
        return 0;
    }
    if (!change_diplomatic_status($aid, $faid, $pending_status)) {
        show_error("Database failure2!");
        return 0;
    }
    $f_leader = get_leader($faid);
    $f_allies = get_allied_ids($f_leader);
    ticker($f_leader, "*lcommunication.php?act=show_diplomacy*Alliance " . get_alliance_name($aid) . " has accepted your request to change status to " . get_diplomatic_status_text($pending_status), "w");
    for ($i = 0; $i < sizeof($f_allies); $i++) {
        ticker($f_allies[$i], "Alliance " . get_alliance_name($aid) . " has accepted your leaders request to change status to " . get_diplomatic_status_text($pending_status), "w");
    }
    $allies = get_allied_ids(get_leader($aid));
    for ($i = 0; $i < sizeof($allies); $i++) {
        ticker($allies[$i], "Your leader accepted a request from Alliance " . get_alliance_name($faid) . " to change status to " . get_diplomatic_status_text($pending_status), "w");
    }
    show_message("Status changed!");
}
Пример #5
0
     break;
     // Update / insert new entry
 // Update / insert new entry
 case 'upd':
     upd($diary->link);
     break;
 case 's':
     srch();
     break;
     // Not needed
 // Not needed
 case 'notes':
     notes();
     break;
 case 'ticker':
     ticker();
     break;
 case 'cal':
     cal($diary->link);
     break;
 case 'time':
     time2($d_date11);
     break;
 case 'events':
     events($diary->link, $d_date5, $d_date6, $d_date10);
     break;
 case 'eventsadd':
     eventsadd($diary->link);
     break;
 case 'eventsedit':
     eventsedit($diary->link);
 /**
  * speichert einen report
  * @param uid
  * @param report
  *      
  */
 function save_report($alliances, $uids, $battlefield, $report)
 {
     if (BATTLEREPORT_SHOW) {
         echo $report;
     } else {
         $sth = mysql_query("insert into battlereports set pid=" . $battlefield->pid . ",sid=" . $battlefield->sid . ",report='" . addslashes($report) . "',week=" . $this->week);
         if (!$sth) {
             echo "ERR::INSERT BATTLEREPORT\n";
             return false;
         }
         $rid = mysql_insert_id();
         // mop: allen allianzen zugänglich machen
         foreach ($alliances as $alliance) {
             $sth = mysql_query("insert into battlereports_alliance set aid=" . $alliance . ",rid=" . $rid);
             if (!$sth) {
                 echo "ERR::INSERT BATTLEREPORT_ALLIANCE\n";
                 return false;
             }
             // mop: die allianzmitglieder EINMAL über allianzkämpfe infomieren
             if (!in_array($alliance, $this->noticed_alliances)) {
                 $members = get_alliance_members($alliance);
                 foreach ($members as $uid => $name) {
                     // mop: beteiligte user bekommen eh nochmal ne separate message, also ausklammern
                     if (!in_array($uid, $uids)) {
                         ticker($uid, "*lbattlereport.php?act=show_alliance&_minw=" . $this->week . "&_maxw=" . $this->week . "*Your alliance was involved in one or more battles!", "a");
                     }
                 }
                 $this->noticed_alliances[] = $alliance;
             }
         }
         // mop: und auch den jeweiligen usern
         foreach ($uids as $uid) {
             $sth = mysql_query("insert into battlereports_user set uid=" . $uid . ",rid=" . $rid);
             if (!$sth) {
                 echo "ERR::INSERT BATTLEREPORT_UID\n";
                 return false;
             }
             if (!in_array($uid, $this->noticed_users)) {
                 ticker($uid, "*lbattlereport.php?act=show_own&_minw=" . $this->week . "&_maxw=" . $this->week . "*You were involved in one or more battles!", "a");
                 $this->noticed_users[] = $uid;
             }
         }
     }
 }