Beispiel #1
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);
    }
}
function covertops()
{
    $sth = mysql_query("select * from covertops as c,covertopsmissions as cm where c.time=1 and c.cid=cm.id");
    if (!$sth) {
        echo "Dtaabaser failure!";
    }
    while ($covertops = mysql_fetch_array($sth)) {
        $success = false;
        $sth1 = mysql_query("select sum(c.value) from covertopsupgrades as c,constructions as b,planets as p where p.id=b.pid and b.prod_id=c.prod_id and p.uid=" . $covertops["uid"]);
        if (!$sth1) {
            echo "Dast FDS!";
        }
        $f_co_upgrades = mysql_fetch_row($sth1);
        $sth1 = mysql_query("select count(id) from planets where uid=" . $covertops["uid"]);
        if (!$sth1) {
            echo "Datasbe failure!";
        }
        $f_planets = mysql_fetch_row($sth1);
        $f_rate = $f_co_upgrades[0] / $f_planets[0];
        //      echo("Friendly Rate: ".$f_rate."\n");
        if ($covertops["targettype"] == "I") {
            $imperium = $covertops["target"];
        } else {
            $sth1 = mysql_query("select uid from planets where id=" . $covertops["target"]);
            if (!$sth1) {
                echo "Datasbe failuer!";
            }
            $uid = mysql_fetch_array($sth1);
            $imperium = $uid["uid"];
        }
        $sth1 = mysql_query("select sum(population)/10000 from planets where uid=" . $imperium);
        if (!$sth1) {
            echo "Datasber faileur!";
        }
        $spies = mysql_fetch_row($sth1);
        $sth1 = mysql_query("select sum(count) from covertops where uid=" . $imperium);
        if (!$sth1) {
            echo "Database failuer!";
        }
        $used_spies = mysql_fetch_row($sth1);
        if ($used_spies[0] == NULL) {
            $rate = 100;
        } else {
            $rate = ($spies[0] - $used_spies[0]) / $spies[0] * 100;
        }
        //      echo("Grundrate: $rate\n");
        $sth1 = mysql_query("select sum(c.value) from covertopsupgrades as c,constructions as b,planets as p where p.id=b.pid and b.prod_id=c.prod_id and p.uid={$imperium}");
        if (!$sth1) {
            echo "Dtasabr failuer!";
        }
        $co_upgrades = mysql_fetch_row($sth1);
        $sth1 = mysql_query("select count(id) from planets where uid={$imperium}");
        if (!$sth1) {
            echo "Datasbe failure!";
        }
        $planets = mysql_fetch_row($sth1);
        $rate = $rate + $co_upgrades[0] / $planets[0];
        //      echo("Rate mit Upgrades: $rate\n");
        if ($rate <= 0) {
            $success = true;
        } else {
            mt_srand((double) microtime() * 1000000);
            $random = mt_rand(0, $rate - $f_rate);
            //  echo("Berechnung: Rate->$rate Frindly Rate->$f_rate Zufall->$random Chance->".$covertops["chance"]."\n");
            if ($random <= $covertops["chance"]) {
                $success = true;
            }
        }
        //      if ($success)
        //  echo("Success!\n");
        // DEBUG!
        //      $success=true;
        if ($success) {
            switch ($covertops["missiontype"]) {
                case "S":
                    define("MAX_STEAL", 25);
                    $sth1 = mysql_query("select f.prod_id,f.fid,f.count,p.typ, p.name, f.reload from fleet as f,production as p left join fleet_info as fi on fi.fid=f.fid where fi.uid={$imperium} and fi.mission=0 and fi.tpid=0 and fi.tsid=0 and fi.pid!=0 and f.prod_id=p.prod_id order by rand() limit 1");
                    if (!$sth1) {
                        echo "Datsbe faileur!";
                    }
                    if (mysql_num_rows($sth1) > 0) {
                        $fleet = mysql_fetch_array($sth1);
                        $sth2 = mysql_query("select p.id,p.sid from planets as p,users as u where p.id=u.homeworld and u.id=" . $covertops["uid"]);
                        if (!$sth2) {
                            echo "Dtabaser faileur!";
                        }
                        $home = mysql_fetch_array($sth2);
                        switch ($fleet["typ"]) {
                            case "L":
                                $multiplikator = 1;
                                break;
                            case "M":
                                $multiplikator = 5;
                                break;
                            case "H":
                                $multiplikator = 10;
                                break;
                        }
                        if ($multiplikator * $fleet["count"] > MAX_STEAL) {
                            $fleet["count"] = floor(MAX_STEAL / $multiplikator);
                        }
                        $new_fleet = new fleet();
                        $new_fleet->add_ships_arr(array($fleet["prod_id"] => array($fleet["count"], $fleet["reload"])));
                        $new_fleet->uid = $covertops["uid"];
                        $new_fleet->pid = $home["id"];
                        $new_fleet->sid = $home["sid"];
                        $new_fleet->create_fleet();
                        $sth2 = mysql_query("update fleet set count=count-" . $fleet["count"] . " where fid=" . $fleet["fid"] . " and prod_id=" . $fleet["prod_id"]);
                        delete_empty_fleets();
                        ticker($covertops["uid"], "You have stolen " . $fleet["count"] . " " . $fleet["name"], "s");
                        ticker($imperium, $fleet["count"] . " " . $fleet["name"] . " vanished from your radar!", "s");
                    } else {
                        ticker($covertops["uid"], "Your spies didn't find any ships. The target imperium doesn't have any!", "s");
                    }
                    break;
                case "B":
                    $sth1 = mysql_query("select b.prod_id,b.pid,pl.name,p.name as pname from planets as pl,production as p,constructions as b where b.prod_id=p.prod_id and b.pid=pl.id and pl.uid={$imperium} order by rand()");
                    if (!$sth1) {
                        echo "Database failoer!";
                    }
                    if (mysql_num_rows($sth1) > 0) {
                        $building = mysql_fetch_array($sth1);
                        $sth1 = mysql_query("delete from constructions where prod_id=" . $building["prod_id"] . " and pid=" . $building["pid"]);
                        if (!$sth1) {
                            echo "DDFatabf failur!";
                        }
                        if ($building["name"] == "Unnamed") {
                            $building["name"] = get_planetname("pid");
                        }
                        ticker($covertops["uid"], "Your spies destroyed the " . $building["pname"] . " on planet " . $building["name"] . "!", "s");
                        ticker($imperium, "The " . $building["pname"] . " on planet " . $building["name"] . " was destroyed misteriously!", "s");
                    }
                    break;
                case "F":
                    $sth1 = mysql_query("select f.prod_id,f.fid from fleet as f,fleet_info as fi where fi.uid={$imperium} and fi.fid=f.fid");
                    if (!$sth1) {
                        echo "Datsbe faileur!";
                    }
                    if (mysql_num_rows($sth1) > 0) {
                        if (mysql_num_rows($sth1) == 1) {
                            $random = 0;
                        } else {
                            mt_srand((double) microtime() * 1000000);
                            $random = mt_rand(0, mysql_num_rows($sth1) - 1);
                        }
                        for ($i = 0; $i <= $random; $i++) {
                            $fleet = mysql_fetch_array($sth1);
                        }
                        $sth2 = mysql_query("delete from fleet where fid=" . $fleet["fid"] . " and prod_id=" . $fleet["prod_id"]);
                        delete_empty_fleets();
                        ticker($covertops["uid"], "You spies destroyed some ships!", "s");
                        ticker($imperium, "Enemy spies destroyed some of your ships!", "s");
                    } else {
                        ticker($covertops["uid"], "Your spies didn't find any ships. The target imperium doesn't have any!", "s");
                    }
                    break;
                case "N":
                    $sth1 = mysql_query("select * from ticker where uid={$imperium}");
                    if (!$sth1) {
                        echo "Database failure!";
                    }
                    while ($ticker = mysql_fetch_array($sth1)) {
                        if ($end = strrpos($ticker["text"], "*")) {
                            $text = substr($ticker["text"], $end + 1);
                        } else {
                            $text = $ticker["text"];
                        }
                        $mail = $mail . "\n" . $text;
                    }
                    if (mysql_num_rows($sth1) == 0) {
                        $mail = "This Imperium doesn't have any news at the moment!";
                    }
                    $sth1 = mysql_query("select imperium from users where id=" . $imperium);
                    if (!$sth1) {
                        echo "Datsabe failure!";
                    }
                    $imp_name = mysql_fetch_array($sth1);
                    mail_to_uid($covertops["uid"], "News of " . $imp_name["imperium"], $mail);
                    ticker($covertops["uid"], "Your spies have successfully hacked a news network. Check Mails.", "s");
                    break;
                case "M":
                    $mail = "";
                    $sth1 = mysql_query("select fi.*,f.prod_id,f.count,f.reload,p.name,s.x,s.y  from fleet as f,production as p,systems as s left join fleet_info as fi on fi.fid=f.fid and fi.uid={$imperium} where p.prod_id=f.prod_id and s.id=fi.sid order by fid");
                    if (mysql_num_rows($sth1) == 0) {
                        $mail = "Target imperium doesn't have any fleets";
                    } else {
                        while ($part_fleet = mysql_fetch_array($sth1)) {
                            if ($part_fleet["fid"] != $fid_old) {
                                $fid_old = $part_fleet["fid"];
                                $counter++;
                            }
                            $fleet[$counter][] = $part_fleet;
                        }
                        $counter = 1;
                        for ($i = 1; $i <= sizeof($fleet); $i++) {
                            $mail = $mail . "Fleet " . $counter++ . "<br>";
                            $mail = $mail . "<table>";
                            $head_array = "";
                            $text_arr = "";
                            $prod_arr = "";
                            for ($j = 0; $j < sizeof($fleet[$i]); $j++) {
                                $head_array[$j] = $fleet[$i][$j]["name"];
                                $text_arr[$j] = $fleet[$i][$j]["count"];
                            }
                            switch ($fleet[$i][0]["mission"]) {
                                case "0":
                                    $mission_text["a"] = "Defending";
                                    $mission_text["b"] = "defend";
                                    break;
                                case "1":
                                    $mission_text["a"] = "Attacking";
                                    $mission_text["b"] = "attack";
                                    break;
                                case "4":
                                    $mission_text["a"] = "";
                                    $mission_text["b"] = "colonize";
                                    break;
                            }
                            if ($fleet[$i][0]["pid"] != 0 and $fleet[$i][0]["tsid"] == 0 and $fleet[$i][0]["tpid"] == 0) {
                                $planetname = get_planetname($fleet[$i][0]["pid"]);
                                $mission = $mission_text["a"] . " planet " . $planetname;
                            }
                            if ($fleet[$i][0]["pid"] == 0 and $fleet[$i][0]["tsid"] == 0 and $fleet[$i][0]["tpid"] == 0) {
                                $systemname = get_systemname($fleet[$i][0]["sid"]);
                                $mission = $mission_text["a"] . " system " . $systemname;
                            }
                            if ($fleet[$i][0]["tsid"] != 0 and $fleet[$i][0]["tpid"] == 0) {
                                $systemname = get_systemname($fleet[$i][0]["tsid"]);
                                $mission = "On its way to " . $mission_text["b"] . " system " . $systemname;
                            }
                            if ($fleet[$i][0]["tsid"] != 0 and $fleet[$i][0]["tpid"] != 0) {
                                $planetname = get_planetname($fleet[$i][0]["tpid"]);
                                $mission = "On its way to " . $mission_text["b"] . " planet " . $planetname;
                            }
                            $text_arr[] = $mission;
                            $head_array[] = "Mission";
                            reset($head_array);
                            $mail = $mail . "<tr>";
                            while (list($key, $dummy) = each($head_array)) {
                                //echo($dummy."\n");
                                $mail = $mail . "<th>{$dummy}</th>";
                            }
                            $mail = $mail . "</tr>";
                            reset($text_arr);
                            $mail = $mail . "<tr>";
                            while (list($key, $dummy) = each($text_arr)) {
                                echo $key . " - " . $dummy . "\n";
                                $mail = $mail . "<td>{$dummy}</td>";
                            }
                            $mail = $mail . "</tr>";
                            $mail = $mail . "</table>";
                        }
                    }
                    $sth1 = mysql_query("select imperium from users where id=" . $imperium);
                    if (!$sth1) {
                        echo "Datsabe failure!";
                    }
                    $imp_name = mysql_fetch_array($sth1);
                    mail_to_uid($covertops["uid"], "Military overview of " . $imp_name["imperium"], $mail);
                    ticker($covertops["uid"], "Your spies have successfully hacked a military network. Check Mails.", "s");
                    break;
                case "I":
                    $mail = "";
                    $sth1 = mysql_query("select c.target,cm.descr,cm.targettype from covertops as c,covertopsmissions as cm where uid={$imperium} and cm.id=c.cid");
                    if (!$sth1) {
                        echo "Databasdf faileru!";
                    }
                    while ($missions = mysql_fetch_array($sth1)) {
                        if ($missions["targettype"] == "I") {
                            $sth2 = mysql_query("select imperium from users where id=" . $missions["target"]);
                            if (!$sth2) {
                                echo "Datasbae failuer!";
                            }
                            $imp_tname = mysql_fetch_array($sth2);
                            $target = "Imperium " . $imp_tname["imperium"];
                        } else {
                            $planetname = get_planetname($missions["target"]);
                            $target = "Planet " . $planetname;
                        }
                        $mail = $mail . "\n" . $missions["descr"] . " Target :" . $target;
                    }
                    $sth1 = mysql_query("select imperium from users where id=" . $imperium);
                    if (!$sth1) {
                        echo "Datsabe failure!";
                    }
                    $imp_name = mysql_fetch_array($sth1);
                    mail_to_uid($covertops["uid"], "CovertOps overview of " . $imp_name["imperium"], $mail);
                    break;
                case "C":
                    $sth1 = mysql_query("select population from planets where id=" . $covertops["target"]);
                    if (!$sth1) {
                        echo "Datasb faileur!";
                    }
                    $pop = mysql_fetch_array($sth1);
                    if ($pop["population"] > 10000000) {
                        mt_srand((double) microtime() * 1000000);
                        $killed = mt_rand(5000000, 8000000);
                    } else {
                        mt_srand((double) microtime() * 1000000);
                        $killed = round($pop["population"] * (mt_rand(30, 80) / 100));
                    }
                    $planetname = get_planetname($covertops["target"]);
                    $sth1 = mysql_query("update planets set population=population-{$killed} where id=" . $covertops["target"]);
                    if (!$sth1) {
                        echo "udFH failuewr!";
                    }
                    ticker($covertops["uid"], "Your spies launched a nuclear assault on Planet " . $planetname . " {$killed} were killed!", "s");
                    $sth1 = mysql_query("select uid from planets where id=" . $covertops["target"]);
                    if (!$sth1) {
                        echo "Database dfasi!";
                    }
                    $uid_target = mysql_fetch_array($sth1);
                    ticker($uid_target["uid"], "Enemy spies launched a deadly nuclear attack agaonst Planet " . $planetname . " {$killed} were killed!", "s");
                    break;
                case "V":
                    $sth1 = mysql_query("select population from planets where id=" . $covertops["target"]);
                    if (!$sth1) {
                        echo "Datasb faileur!";
                    }
                    $pop = mysql_fetch_array($sth1);
                    mt_srand((double) microtime() * 1000000);
                    $killed = round($pop["population"] * (mt_rand(30, 80) / 100));
                    $planetname = get_planetname($covertops["target"]);
                    $sth1 = mysql_query("update planets set population=population-{$killed} where id=" . $covertops["target"]);
                    if (!$sth1) {
                        echo "udFH failuewr!";
                    }
                    ticker($covertops["uid"], "Your spies deployed a deadly virus on Planet " . $planetname . " {$killed} were killed!", "s");
                    $sth1 = mysql_query("select uid from planets where id=" . $covertops["target"]);
                    if (!$sth1) {
                        echo "Database dfasi!";
                    }
                    $uid_target = mysql_fetch_array($sth1);
                    ticker($uid_target["uid"], "Enemy spies deployed a deadly virus on Planet " . $planetname . " {$killed} were killed!", "s");
                    break;
                case "A":
                    $sth1 = mysql_query("select imperium from users where id={$imperium}");
                    if (!$sth1) {
                        echo "Databsae faileru!";
                    }
                    $imp_name = mysql_fetch_array($sth1);
                    $sth1 = mysql_query("select id,name,value from admirals where uid={$imperium} order by rand()");
                    if (!$sth1) {
                        echo "Dtzasa faielru!";
                    }
                    if (mysql_num_rows($sth1) == 0) {
                        ticker($covertops["uid"], "Your spies didn't find an admiral of Imperium " . $imp_name["imperium"] . "!", "s");
                        return 0;
                    }
                    $admiral = mysql_fetch_array($sth1);
                    $sth1 = mysql_query("delete from admirals where id=" . $admiral["id"]);
                    if (!$sth1) {
                        echo "Dzasakhbd faileur!";
                    }
                    ticker($covertops["uid"], "Your spies killed Admiral " . $admiral["name"] . " of Imperium " . $imp_name["imperium"] . "!", "s");
                    ticker($imperium, "Admiral " . $admiral["name"] . " was assasinated!", "w");
                    break;
                case "T":
                    $sth1 = mysql_query("select imperium from users where id={$imperium}");
                    if (!$sth1) {
                        echo "Databsae faileru!";
                    }
                    $imp_name = mysql_fetch_array($sth1);
                    $sth1 = mysql_query("select sid from tradestations where uid={$imperium}");
                    if (!$sth1) {
                        echo "Dtasgha faij!";
                    }
                    if (mysql_num_rows($sth1) == 0) {
                        ticker($covertops["uid"], $imp_name["imperium"] . " doesn't have a tradestation. Mission aborted.", "w");
                    }
                    list($stationid) = mysql_fetch_row($sth1);
                    $sth1 = mysql_query("update tradestations set fail_chance=fail_chance+(rand()*10+1) where sid={$stationid}");
                    if (!$sth1) {
                        echo "Datsbae fauO!";
                    }
                    ticker($covertops["uid"], "Your spies have successfully sabotaged " . $imp_name["imperium"] . "'s tradestation", "w");
                    break;
            }
        } else {
            mt_srand((double) microtime() * 10000000);
            $random = mt_rand(0, 100);
            if ($random <= 50) {
                if ($random <= 20) {
                    $sth1 = mysql_query("select name,imperium from users where id=" . $covertops["uid"]);
                    if (!$sth1) {
                        echo "Dtas afa!";
                    }
                    $att_name = mysql_fetch_array($sth1);
                    ticker($imperium, "Your spies intercepted some enemy spies. Their leader is " . $att_name["name"] . " (" . $att_name["imperium"] . ")!", "s");
                } else {
                    ticker($imperium, "Your spies intercepted some enemy spies!", "s");
                }
            }
        }
    }
    $sth = mysql_query("delete from covertops where time<=1");
    if (!$sth) {
        echo "Dtabas faislru!";
    }
    $sth = mysql_query("update covertops set time=time-'1'");
    if (!$sth) {
        echo "Dtasbwer failure!";
    }
}