当前位置: 首页>>代码示例>>PHP>>正文


PHP dbr函数代码示例

本文整理汇总了PHP中dbr函数的典型用法代码示例。如果您正苦于以下问题:PHP dbr函数的具体用法?PHP dbr怎么用?PHP dbr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了dbr函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: addLocation

function addLocation()
{
    global $strVenueName, $strVenueAddress, $strAPIId, $strLocationId, $strLatitude, $strLongitude;
    //some data is missing;
    if ($strVenueName == "" || $strVenueAddress == "" || $strAPIId == "" || $strLatitude == "" || $strLongitude == "") {
        return 0;
    }
    $strLocationId = "";
    //Check to see if the actual location exists
    db("SELECT LocationId FROM locations WHERE LocationName = '" . $strVenueName . "' AND LocationAddress = '" . $strVenueAddress . "' AND API_ID = '" . $strAPIId . "'");
    $location_exists = dbr();
    if (empty($location_exists) == true) {
        //Check to see if the locationname is in use
        db("SELECT LocationId FROM locations WHERE API_ID = '" . $strAPIId . "'");
        $apiID_exists = dbr();
        if (empty($apiID_exists) == true) {
            //Insert our new location
            dbn("INSERT INTO locations (LocationName, LocationAddress, API_ID, LocationLat, LocationLong) VALUES ('" . $strVenueName . "', '" . $strVenueAddress . "', '" . $strAPIId . "', '" . $strLatitude . "', '" . $strLongitude . "')");
            db("SELECT LocationId FROM locations WHERE LocationName = '" . $strVenueName . "' AND LocationAddress = '" . $strVenueAddress . "' AND API_ID = '" . $strAPIId . "'");
            $location_created = dbr();
            //location has successfully registered
            if (empty($location_created) == false) {
                $strLocationId = $location_created['LocationId'];
                return $location_created['LocationId'];
            } else {
                return -1;
            }
        } else {
            return -2;
        }
    } else {
        $strLocationId = $location_exists['LocationId'];
        return $location_exists['LocationId'];
    }
}
开发者ID:ndy40,项目名称:dashwebsvc,代码行数:35,代码来源:CheckIn.php

示例2: determine_route

function determine_route($dest_sector)
{
    global $user, $cw, $st, $db_name, $autowarp, $num_aw_left, $exp_sys_arr, $GAME_VARS;
    //set starting location
    $start_sector = $user['location'];
    //declare systems array
    //will contain distance travelled ('dist'), and source of link to this system (source)
    $systems = array();
    //declare search_queue, and add the destination sector to it.
    $search_queue = array();
    array_unshift($search_queue, $start_sector);
    #loop through the systems.
    while ($search_sector = array_pop($search_queue)) {
        //skip systems that are unexplored
        if ($GAME_VARS['uv_explored'] == 0 && $exp_sys_arr[0] != -1 && array_search($search_sector, $exp_sys_arr) === false) {
            continue 1;
        }
        //get all systems that link to present system
        db("SELECT wormhole, link_1, link_2, link_3, link_4, link_5, link_6 FROM {$db_name}_stars WHERE star_id = '{$search_sector}'");
        $adj_sectors = dbr(1);
        #loop through all links to system to present system
        foreach ($adj_sectors as $key => $vertex) {
            #have reached the destination sector
            if ($vertex == $dest_sector) {
                $ret_str = "";
                $path = "";
                //jump from system to system from the start sector to the end sector.
                for ($linkback = $search_sector; $linkback != $start_sector;) {
                    $ret_str = "<b>{$linkback}</b> - " . $ret_str;
                    if (!empty($systems[$linkback]['worm'])) {
                        //a mid jump by wormhole
                        $ret_str = $cw['wormhole_to'] . ' ' . $ret_str;
                    } elseif ($key == "wormhole") {
                        //final jump is wormhole one
                        $ret_str .= $cw['wormhole_to'] . ' ';
                    }
                    $path = "{$linkback} " . $path;
                    $linkback = $systems[$linkback]['source'];
                }
                $ret_str = $cw['distance_is'] . " <b>" . (substr_count($ret_str, "-") + 1) . "</b> " . $cw['warps'] . "<br />" . $cw['path_is'] . " <b>{$start_sector}</b> - " . $ret_str . "<b>{$dest_sector}</b><br /><br />";
                $path .= "{$dest_sector}";
                $autowarp = $path;
                return $ret_str;
            }
            //selected linked system has not been visted before, so add as potential destintation.
            if ($vertex > 0 && empty($systems[$vertex])) {
                $systems[$vertex]['source'] = $search_sector;
                //set where came from.
                if ($key == "wormhole") {
                    //a wormhole jump
                    $systems[$vertex]['worm'] = 1;
                }
                //add link destination to list of systems to search.
                array_unshift($search_queue, $vertex);
            }
        }
    }
    return sprintf($st[0], $dest_sector);
}
开发者ID:nilsine,项目名称:Astra-Vires,代码行数:59,代码来源:location.php

示例3: create_tracking_table

function create_tracking_table($substatus, $textstat)
{
    global $status, $login_id;
    $action = "";
    $issue['id'] = "Bug ID";
    $issue['title'] = "Bug Title";
    $issue['status'] = "Status";
    $issue['login_id'] = "Submitted By";
    $issue['action'] = "Action(s)";
    $out = make_table($issue, "WIDTH=55%");
    $counter = 0;
    db("SELECT id, title, login_id FROM server_issuetracking WHERE status= " . $status . $substatus);
    while ($issues = dbr(1)) {
        $action = "<a href='{$_SERVER['PHP_SELF']}?status={$status}&id={$issues['id']}&action=view'>View</a>";
        if ($login_id == OWNER_ID) {
            //server admin only
            if ($status == 1) {
                $action .= " - <a href='{$_SERVER['PHP_SELF']}?&status={$status}&id={$issues['id']}&action=forward'>Outstanding</a>";
                $action .= " - <a href='{$_SERVER['PHP_SELF']}?&status={$status}&id={$issues['id']}&action=resolve'>Close</a>";
            } elseif ($status == 2) {
                $action .= " - <a href='{$_SERVER['PHP_SELF']}?&status={$status}&id={$issues['id']}&action=forward'>Close</a>";
                $action .= " - <a href='{$_SERVER['PHP_SELF']}?&status={$status}&id={$issues['id']}&action=up'>Up</a>";
                $action .= " - <a href='{$_SERVER['PHP_SELF']}?&status={$status}&id={$issues['id']}&action=down'>Down</a>";
            } elseif ($status == 3) {
                $action .= " - <a href='{$_SERVER['PHP_SELF']}?&status={$status}&id={$issues['id']}&action=reopen'>Reopen</a>";
                $action .= " - <a href='{$_SERVER['PHP_SELF']}?&status={$status}&id={$issues['id']}&action=up'>Up</a>";
                $action .= " - <a href='{$_SERVER['PHP_SELF']}?&status={$status}&id={$issues['id']}&action=down'>Down</a>";
            }
        }
        //end of admin only.
        $issue['id'] = $issues['id'];
        $issue['title'] = $issues['title'];
        $issue['status'] = $textstat;
        db2("select login_name from user_accounts where login_id = '{$issues['login_id']}'");
        $temp_store = dbr2(1);
        $issue['login_id'] = $temp_store['login_name'];
        $issue['action'] = $action;
        $out .= make_row($issue);
        $counter++;
    }
    if ($counter == 0) {
        //if no bugs
        $issue['id'] = "NONE";
        $issue['title'] = "";
        $issue['status'] = "";
        $issue['login_id'] = "";
        $issue['action'] = "";
        $out .= make_row($issue);
    }
    $out .= "</table>";
    return " - {$counter} Entries<br />" . $out;
}
开发者ID:nilsine,项目名称:Astra-Vires,代码行数:52,代码来源:bugs_tracker.php

示例4: addReview

function addReview()
{
    global $intLocationId, $intUserId, $strReview, $fltRating;
    if ($intLocationId == "" || $intUserId == "") {
        return 0;
    }
    if ($strReview == "" && $fltRating == "") {
        return -1;
    }
    dbn("INSERT INTO locationreview (LocationId, UserId, DateTime, ReviewText, ReviewRating) VALUES ('" . $intLocationId . "', '" . $intUserId . "', '" . Time() . "', '" . $strReview . "', '" . $fltRating . "')");
    if ($fltRating > 0.0) {
        db("SELECT AVG(ReviewRating) as Average FROM locationreview WHERE LocationId = '" . $intLocationId . "' AND ReviewRating > 0.0");
        $avg = dbr();
        if ($avg['Average'] != null) {
            dbn("UPDATE locations SET LocationRatings = '" . $avg['Average'] . "', LocationUseRatings = '1' WHERE LocationId = '" . $intLocationId . "'");
        }
    }
    return 1;
}
开发者ID:ndy40,项目名称:dashwebsvc,代码行数:19,代码来源:AddReview.php

示例5: db

db("select * from {$db_name}_planets where planet_id = '{$planet_id}'");
$planet = dbr(1);
$out = "";
$header = $cw['error'];
$status_bar_help = "?topic=Planets";
if ($user['location'] != $planet['location']) {
    $out = $st[107];
} elseif ($planet['login_id'] != $user['login_id']) {
    $out = $st[108];
    #build a research facility
} elseif ($GAME_VARS['uv_num_bmrkt'] > 0 && isset($_REQUEST['research_fac'])) {
    $header = $cw['research_facility'];
    $status_bar_help = "?topic=Blackmarkets";
    #check to see how many research centres the user has.
    db("select count(planet_id) from {$db_name}_planets where research_fac = 1 && login_id = '{$user['login_id']}'");
    $num_research = dbr();
    if ($user['cash'] < $research_fac_cost) {
        $out .= $st[109];
    } elseif (!avail_check(4000)) {
        $out .= $st[110];
    } elseif ($planet['research_fac'] != 0) {
        $out .= $st[111];
    } elseif ($num_research[0] > 1) {
        $out .= $st[112];
    } elseif (!isset($_POST['sure'])) {
        get_var($cw['buy_research_facility'], $_SERVER['PHP_SELF'], sprintf($st[113], $GAME_VARS[hourly_tech]) . popup_help("help.php?topic=Blackmarkets&sub_topic=Research_Facilities_and_Support_Units&popup=1", 500, 400, $cw['click_here']) . ".", 'sure', 'yes');
    } else {
        take_cash($research_fac_cost);
        $out .= sprintf($st[114], $planet[planet_name], $research_fac_cost);
        dbn("update {$db_name}_planets set research_fac = '1' where planet_id = '{$planet['planet_id']}'");
    }
开发者ID:nilsine,项目名称:Astra-Vires,代码行数:31,代码来源:add_planetary.php

示例6: checkbox_ship_list

function checkbox_ship_list($select_sql, $command_option = 0)
{
    global $user, $user_ship, $planet_id, $type, $cw, $st, $table_head_array, $db_name;
    db2($select_sql);
    $ships = dbr2(1);
    $ret_str = "";
    $plocation = 0;
    if (empty($ships)) {
        return -1;
    } else {
        $i = 0;
        $last_fleet = '';
        while ($ships) {
            $ship_cargo = "";
            $ships['fighters'] = $ships['fighters'] . " / " . $ships['max_fighters'];
            $ships['shields'] = $ships['shields'] . " / " . $ships['max_shields'];
            $ships['armour'] = $ships['armour'] . " / " . $ships['max_armour'];
            unset($ships['max_fighters'], $ships['max_shields'], $ships['max_armour']);
            $ships['ship_name'] = popup_help("ship_info.php?s_id={$ships['ship_id']}", 320, 520, $ships['ship_name']);
            //Si db_name est inexistant, la popup n'est pas affichée.
            if ($db_name) {
                $ships['class_name_abbr'] = popup_help("help.php?popup=1&ship_info={$ships['shipclass']}&db_name={$db_name}", 300, 600, $ships['class_name_abbr']);
            }
            if (empty($ships['config'])) {
                $ships['config'] = $cw['none'];
            } else {
                $ships['config'] = config_list(0, $ships['config']);
            }
            if ($command_option == 1) {
                if ($ships['ship_id'] == $user_ship['ship_id']) {
                    $bgcolor = '000000';
                    array_push($ships, "<i>" . $cw['aux_commandes'] . "</i>");
                } else {
                    $bgcolor = '333333';
                    array_push($ships, "<a href='location.php?command={$ships['ship_id']}'>" . $cw['command'] . "</a>");
                }
            } elseif ($command_option == 2) {
                array_push($ships, "<a href='planet.php?planet_id={$planet_id}&amp;chosen_ship={$ships['ship_id']}&amp;single_ship_deal=1&amp;type={$type}'>" . $cw['load/unload'] . "</a>" . $cw['ship']);
            }
            $ships['cargo_bays'] = bay_storage_little($ships);
            unset($ships['metal'], $ships['fuel'], $ships['elect'], $ships['colon']);
            $ships['ship_id'] = "<input type='checkbox' name='do_ship[{$ships['ship_id']}]' value='{$ships['ship_id']}' />";
            //$bgcolor = ($i % 2 == 0) ? '444444':'333333';
            // if the location is different of the previous
            if ($plocation && $plocation != $ships['location'] && $command_option == 1) {
                $ret_str .= "</table><br /><h2>Système " . $ships['location'] . "</h2>";
                $ret_str .= make_table($table_head_array);
            } elseif (!$plocation) {
                // if this is the first ship listed
                if ($command_option == 1) {
                    $ret_str .= "<h2>Système " . $ships['location'] . "</h2>";
                }
                $ret_str .= make_table($table_head_array);
            }
            // suppression du champ ship class (utilisé pour la popup)
            unset($ships['shipclass']);
            // previous location
            $plocation = $ships['location'];
            $rowspan = array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1);
            //var_dump($ships);
            if ($last_fleet != $ships['fleet_id']) {
                //calcul du nombre de vaisseaux dans la flotte actuelle
                db("select count(ship_id) from {$db_name}_ships where login_id = " . $user['login_id'] . " AND fleet_id = " . $ships['fleet_id'] . " AND location = " . $ships['location']);
                $rowspan_count = dbr();
                //rowspan[4] = nombre de vaisseaux dans la flottte ($rowspan_count[0];)
                $rowspan['fleet_id'] = $rowspan_count[0];
                $last_fleet = $ships['fleet_id'];
            } else {
                unset($ships['fleet_id']);
            }
            if ($command_option == 2) {
                unset($ships['location']);
            }
            $ret_str .= "\n" . make_row($ships, $bgcolor, $rowspan);
            $i++;
            $ships = dbr2(1);
        }
        $ret_str .= "</table><br />";
        return $ret_str;
    }
}
开发者ID:nilsine,项目名称:Astra-Vires,代码行数:81,代码来源:user.inc.php

示例7: print_page

    print_page($cw['error'], $st[388]);
}
// Tech and Credit costs of Advanced Upgrades
// Credit Cost
#turret costs - based on size of ship
$cost_temp = get_cost("pc");
$plasma_cannon_c = round($cost_temp['cost'] * ($user_ship['size'] / 100)) * 15;
$plasma_cannon_t = round($cost_temp['tech_cost'] * ($user_ship['size'] / 100)) * 5;
$cost_temp = get_cost("bo");
$bio_armour_c = $cost_temp['cost'] * $user_ship['max_armour'];
$bio_armour_t = $cost_temp['tech_cost'] * $user_ship['max_armour'];
$cost_temp = get_cost("e2");
$advanced_engine_c = round($cost_temp['cost'] * ($user_ship['size'] / 100)) * 15;
$advanced_engine_t = round($cost_temp['tech_cost'] * ($user_ship['size'] / 100)) * 5;
db("select upgrade_slots from {$db_name}_ships where ship_id = {$user['ship_id']}");
$upgrade_pods = dbr();
$old_config = $user_ship['config'];
// value of $buy determines upgrade to be purchased
// new if statement to prevent multiple occurance of config abbrs
// new addition of num_ot,num_dt, etc to allow multiple upgrades of same type
if ($buy == 3) {
    //Plasma Cannon
    if (isset($many_pc) && $many_pc > 1) {
        $plasma_cannon_c *= $many_pc;
        $plasma_cannon_t *= $many_pc;
        $num_to_buy = $many_pc;
    } else {
        $num_to_buy = 1;
    }
    if ($user['cash'] < $plasma_cannon_c) {
        $error_str .= $st[389];
开发者ID:nilsine,项目名称:Astra-Vires,代码行数:31,代码来源:bm_upgrades.php

示例8: insert_history

            insert_history($user['login_id'], sprintf($st[750], $transfer_counter, $target[login_name]));
        }
    }
    print_page($cw['transfer_ship'], $text);
}
$text .= sprintf($st[751], $target[login_name]) . "<br /><br />";
$text .= "<b class='b1'>" . $st[752] . "<br />";
$text .= "<form action=send_ship.php method=POST name=transfer_ships><table>";
db("select ship_name, class_name, location, fighters, max_fighters, shields, max_shields, armour, max_armour, config, ship_id from {$db_name}_ships where login_id = '{$user['login_id']}' && ship_id != '{$user['ship_id']}' order by class_name");
$ships = dbr(1);
if (!isset($ships)) {
    #ensure there are some ships to display
    $text .= $st[753];
} else {
    $text .= make_table(array("Nom du vaisseau", "Type de vaisseau", "Emplacement", "Chasseurs", "Boucliers", "Coques", "Configuration"));
    while ($ships) {
        $ships['fighters'] = $ships['fighters'] . " / " . $ships['max_fighters'];
        $ships['shields'] = $ships['shields'] . " / " . $ships['max_shields'];
        $ships['armour'] = $ships['armour'] . " / " . $ships['max_armour'];
        #remove the un-necassaries from the array. As well as their numerical counterparts (it's a multi-indexed array).
        unset($ships['max_fighters']);
        unset($ships['max_shields']);
        unset($ships['max_armour']);
        $ships['ship_id'] = "<input type=checkbox name=do_ship[{$ships['ship_id']}] value={$ships['ship_id']} /> - <a href='send_ship.php?target={$target['login_id']}&do_ship[{$ships['ship_id']}]={$ships['ship_id']}'>" . $cw['sign_over'] . "</a>";
        $text .= make_row($ships);
        $ships = dbr(1);
    }
}
$text .= "</table><br /><input type=hidden name=target value={$target['login_id']} /><input type='submit' name='submit' value='Envoyer les vaisseaux' /> - <a href=javascript:TickAll(\"transfer_ships\")>" . $st[754] . "</a><br /></form>";
$text .= "<br /><a href='send_ship.php?target={$target['login_id']}'>" . $st[755] . "</a>";
print_page($cw['transfer_ship_registration'], $text);
开发者ID:nilsine,项目名称:Astra-Vires,代码行数:31,代码来源:send_ship.php

示例9: print_page

// change password
if (isset($_REQUEST['changepass'])) {
    $rs = "<br /><a href='options.php'>" . $cw['back_to_options'] . "</a>";
    if (isset($_GET['changepass']) && $_GET['changepass'] == 'change') {
        $temp_str = $st[946];
        $temp_str .= "<table><form action='options.php' method='post'><input type='hidden' name='changepass' value='changed' />";
        $temp_str .= "<tr><td align='right'>" . $st[947] . ":</td><td><input type='password' name='oldpass' /></td></tr>";
        $temp_str .= "<tr><td align='right'>" . $st[948] . ":</td><td><input type='password' name='newpass' /></td></tr>";
        $temp_str .= "<tr><td align='right'>" . $st[949] . ":</td><td><input type='password' name='newpass2' /></td></tr>";
        $temp_str .= "<tr><td></td><td><input type='submit' value='" . $st[950] . "' /></td></tr></form></table><br />";
        print_page($st[950], $temp_str);
    } elseif ($_POST['changepass'] == 'changed') {
        if ($user['login_id'] == 1) {
            //admin pass. Not encrypted
            db("select admin_pw from se_games where db_name = '{$db_name}'");
            $a_pas_temp = dbr();
            $enc_newpass = $p_user['passwd'] = $a_pas_temp[0];
            $enc_oldpass = $_POST['oldpass'];
            //make sure there are two letters and two nums in it.
            if (!preg_match("/[0-9].*[0-9]/", $_POST['newpass']) || !preg_match("/[a-z].*[a-z]/i", $_POST['newpass'])) {
                print_page($cw['error'], $st[951]);
            }
        } else {
            //user passes are encrypted
            $enc_oldpass = md5($_POST['oldpass']);
            $enc_newpass = md5($_POST['newpass']);
        }
        if (!empty($_POST['newpass']) && $_POST['newpass'] == $_POST['newpass2']) {
            if (strlen($_POST['newpass']) < 5) {
                //ensure length
                $temp_str = $st[952] . "<br />";
开发者ID:nilsine,项目名称:Astra-Vires,代码行数:31,代码来源:options.php

示例10: add_settings_link

         * Links in plugin listing.
         *
         * @since 1.0.0
         *
         * @param array $links Array of links.
         * @return array Modified array of links.
         */
        public static function add_settings_link($links)
        {
            $url = add_query_arg(array('page' => 'demo-bar', 'post_type' => 'dbsite'), admin_url('edit.php'));
            $settings_link = '<a href="' . esc_url($url) . '">' . __('Settings', 'demo-bar') . '</a>';
            array_unshift($links, $settings_link);
            return $links;
        }
    }
}
/**
 * Main instance of DemoBar.
 *
 * Returns the main instance of dbr to prevent the need to use globals.
 *
 * @since  1.0.0
 * @return DemoBar
 */
function dbr()
{
    return DemoBar::instance();
}
// Global for backwards compatibility.
$GLOBALS['demobar'] = dbr();
开发者ID:wensolutions,项目名称:demo-bar,代码行数:30,代码来源:demo-bar.php

示例11: elseif

        //	echo "<br /><a href='bugs_submit.php'>".$cw['report_a_bug']."</a>\n";
        /*echo "<br /> - <a href='bugs_tracker.php'>Bug Tracking</a><br />\n";
        	echo "<br /> - <a href='http://se.cornerjukebox.com/forum/' target='_blank'>Global Forums</a>";*/
        if ($p_user['login_id'] != 1) {
            //		echo "<br><a href='logout.php?logout_game_listing=1'>".$cw['complete_logout']."</a>";
        }
        $admin_req_str = "";
        //echo "<td>$admin_req_str<br /><br /><B>Server News</b><br /><br />";
        //require_once("$directories[includes]/server_news.inc.htm");
        /*echo "</td></tr></table><br /><br /><br /><center>
        	<p /><a href='credits.php' target='_blank'>Credits</a> - <a href='old_news.php' target='_blank'>Old News</a>
        	<br /><br /><a href='http://www.solarempire.com/' target='_blank'><img src='$directories[images]/logos/se_small.gif' border='0' /></a><br />";*/
        $rs = "";
    } elseif ($p_user['ban']) {
        echo "<p>Votre compte a été banni pour la raison suivante :<br /><br /><b>" . $p_user['raison'] . "</b><br /><br />Pour toute réclamation vous pouvez envoyer un e-mail à info@astravires.fr</p>";
    }
}
db("select login_count from user_accounts where login_id=" . $p_user['login_id']);
$res = dbr(1);
if ($res['login_count'] == 2) {
    $nom_page_analytics = '2e_login';
}
?>
	</div>

	<div class="spacer"></div>

</div>
<?php 
//print_footer($nom_page_analytics);
include 'includes/bas_index.inc.php';
开发者ID:nilsine,项目名称:Astra-Vires,代码行数:31,代码来源:game_listing.php

示例12: damage_ship

function damage_ship($amount, $fig_dam, $s_dam, $from, $target, $target_ship)
{
    global $db_name, $query;
    //set the shields down first off (if needed).
    if ($s_dam > 0) {
        $target_ship['shields'] -= $s_dam;
        if ($target_ship['shields'] < 0) {
            $target_ship['shields'] == 0;
        }
        dbn("update {$db_name}_ships set shields = shields - '{$s_dam}' where ship_id = '{$target_ship['ship_id']}'");
    }
    //take the fighters down next (if needed).
    if ($fig_dam > 0) {
        $target_ship['fighters'] -= $fig_dam;
        if ($target_ship['fighters'] < 0) {
            $target_ship['fighters'] == 0;
        }
        dbn("update {$db_name}_ships set fighters = fighters - '{$fig_dam}' where ship_id = '{$target_ship['ship_id']}'");
    }
    //don't want to hurt the admin now do we?
    if ($target['login_id'] != 1) {
        //only play with the amount distribution if there is no value to amount
        if ($amount > 0) {
            $shield_damage = $amount;
            if ($shield_damage > $target_ship['shields']) {
                $shield_damage = $target_ship['shields'];
            }
            $amount -= $shield_damage;
        }
        if ($amount >= $target_ship['fighters'] || $amount < 0) {
            //destroy ship
            //Minerals go to the system
            if ($from['location'] != 1 && ($target_ship['fuel'] > 0 || $target_ship['metal']) > 0) {
                dbn("update {$db_name}_stars set fuel = fuel + " . round($target_ship[fuel] * (mt_rand(20, 80) / 100)) . ", metal = metal + " . round($target_ship[metal] * (mt_rand(40, 90) / 100)) . " where star_id = {$target_ship['location']}");
            }
            dbn("delete from {$db_name}_ships where ship_id = '{$target_ship['ship_id']}'");
            dbn("update {$db_name}_users set fighters_killed = fighters_killed + '{$target_ship['fighters']}', ships_killed = ships_killed + '1', ships_killed_points = ships_killed_points + '{$target_ship['point_value']}' where login_id = '{$from['login_id']}'");
            dbn("update {$db_name}_users set fighters_lost = fighters_lost + '{$target_ship['fighters']}', ships_lost = ships_lost + '1', ships_lost_points = ships_lost_points + '{$target_ship['point_value']}' where login_id = '{$target['login_id']}'");
            if (eregi($cw['escape'], $target_ship['class_name'])) {
                // escape pod lost
                dbn("update {$db_name}_users set location = '1', ship_id = '1', last_attack = " . time() . ", last_attack_by = '{$from['login_name']}', explored_sys = '1' where login_id = '{$target['login_id']}'");
                wipe_player($target['login_id'], $target['clan_id']);
                return 1;
            } else {
                // normal ship lost
                //don't bother putting an AI into a new ship to command etc.
                if ($target['login_id'] > 5) {
                    if ($target['ship_id'] != $target_ship['ship_id']) {
                        $new_ship_id = $target['ship_id'];
                    } else {
                        db("select ship_id from {$db_name}_ships where login_id = '{$target_ship['login_id']}' LIMIT 1");
                        $other_ship = dbr();
                        if (!empty($other_ship['ship_id'])) {
                            // jump to other ship
                            $new_ship_id = $other_ship['ship_id'];
                        } else {
                            // build the escape pod
                            create_escape_pod($target);
                            return 2;
                        }
                    }
                    // set ships_killed
                    if ($target['login_id'] > 5) {
                        db("select location from {$db_name}_ships where ship_id = '{$new_ship_id}'");
                        $other_ship = dbr();
                    } else {
                        $other_ship['location'] = 1;
                    }
                    dbn("update {$db_name}_users set ship_id = '{$new_ship_id}', location = '{$other_ship['location']}', last_attack =" . time() . ", last_attack_by = '{$from['login_name']}' where login_id = '{$target['login_id']}'");
                }
            }
            return 1;
        } else {
            // ship not destroyed
            dbn("update {$db_name}_users set last_attack = " . time() . ", last_attack_by = '{$from['login_name']}' where login_id = '{$target['login_id']}'");
            dbn("update {$db_name}_ships set fighters = fighters - '{$amount}', shields = shields - '{$shield_damage}' where ship_id = '{$target_ship['ship_id']}'");
            dbn("update {$db_name}_users set fighters_lost = fighters_lost + '{$amount}' where login_id = '{$target['login_id']}'");
            dbn("update {$db_name}_users set fighters_killed = fighters_killed + '{$amount}' where login_id = '{$from['login_id']}'");
            return 0;
        }
    }
    return 0;
}
开发者ID:nilsine,项目名称:Astra-Vires,代码行数:83,代码来源:bombs.php

示例13: db

 db("select count(login_id) from {$db_name}_users where ship_id != 1 && login_id > 5");
 $ct2 = dbr();
 db("select count(login_id),sum(fighters) from {$db_name}_ships where login_id > 5");
 $ct3 = dbr();
 db("select count(planet_id),sum(fighters),sum(colon),sum(elect),sum(metal),sum(fuel) from {$db_name}_planets where login_id != 1");
 $ct4 = dbr();
 db("select count(distinct clan_id),count(login_id) from {$db_name}_users where clan_id > 0 && login_id > 5");
 $ct5 = dbr();
 db("select count(*) from {$db_name}_news");
 $ct6 = dbr();
 db("select count(message_id) from {$db_name}_messages where login_id = -1");
 $forum_posts = dbr();
 db("select count(message_id) from {$db_name}_messages where login_id > 1");
 $player_mess = dbr();
 db("select count(message_id) from {$db_name}_messages where login_id = -5");
 $clan_forum_posts = dbr();
 $out_str .= "<table border=0 cellpadding=5><tr valign=top><td colspan=3>";
 $out_str .= make_table(array("", ""));
 $out_str .= quick_row("Game Name:", "{$game['name']}");
 $out_str .= quick_row("Game ID:", "{$game['game_id']}");
 $out_str .= quick_row("db_name: ", "{$game['db_name']}");
 $out_str .= quick_row("Paused: ", "{$game['paused']}");
 $out_str .= quick_row("Status: ", "{$game['status']}");
 $out_str .= quick_row("", "");
 $out_str .= quick_row("", "");
 $out_str .= quick_row("Admin Name:", "{$game['admin_name']}");
 $out_str .= quick_row("Description:", "{$game['description']}");
 $out_str .= quick_row("Intro Message:", "{$game['intro_message']}");
 $out_str .= quick_row("Num Stars:", "{$game['num_stars']}");
 $out_str .= quick_row("", "");
 $out_str .= "</table></td></tr><tr><td>";
开发者ID:nilsine,项目名称:Astra-Vires,代码行数:31,代码来源:developer.php

示例14: load_unload_planet

function load_unload_planet($selected_ships, $load_or_unload, $do_ship = 0)
{
    global $user, $user_ship, $db_name, $tech_mat, $text_mat, $planet, $sure, $type, $dump_all, $cw, $st;
    discern_type($type);
    $extra_where = "";
    $captaining = 0;
    if ($selected_ships == 1) {
        foreach ($do_ship as $ship_id) {
            $extra_where .= "ship_id = '{$ship_id}' || ";
            if ($ship_id == $user['ship_id']) {
                $captaining = 1;
            }
        }
        $extra_where = preg_replace("/\\|\\| \$/", "", $extra_where);
        $extra_where = "&& ({$extra_where})";
    }
    if ($load_or_unload == 2) {
        //unloading the ship
        //select all ships that are valid
        db("select sum({$tech_mat}) as goods, count(ship_id) as ship_count from {$db_name}_ships where login_id = '{$user['login_id']}' && location = '{$user['location']}' && {$tech_mat} > 0 " . $extra_where);
        $results = dbr(1);
        $turn_cost = ceil($results['ship_count'] * 0.75);
        $max_reached = "";
        if (!isset($results['goods'])) {
            //no goods on any ships
            return sprintf($st[1535], $text_mat);
        } elseif ($user['turns'] < $turn_cost && !isset($dump_all)) {
            //insufficient turns
            return sprintf($st[1536], $turn_cost);
            unset($results);
        } elseif ($results['goods'] + $planet['colon'] > $planet['max_population'] && $type == 1) {
            $max_reached = "<b class='b1'>" . $cw['warning'] . "</b>: " . $st[1537];
        } elseif (!isset($sure) && $selected_ships == 0 && !isset($dump_all)) {
            //confirmation
            get_var($st[1538] . " {$text_mat}", 'planet.php', sprintf($st[1539], $text_mat, $results[goods], $results[ship_count], $turn_cost) . $max_reached, 'sure', 'yes');
        } else {
            //finish unloading the planets.
            $t_cost_str = "";
            dbn("update {$db_name}_planets set {$tech_mat} = {$tech_mat} + '{$results['goods']}' where planet_id = '{$user['on_planet']}'");
            dbn("update {$db_name}_ships set {$tech_mat} = 0 where login_id = '{$user['login_id']}' && location = '{$user['location']}' && {$tech_mat} > 0 " . $extra_where);
            if (!isset($dump_all)) {
                charge_turns($turn_cost);
                $t_cost_str = " pour un coût total de <b>{$turn_cost}</b> cycles.";
            }
            if ($captaining == 1 || $selected_ships == 0 && $user_ship[$tech_mat] > 0) {
                $user_ship[$tech_mat] = 0;
                empty_bays($user_ship);
            }
            $planet[$tech_mat] += $results['goods'];
            return "<b>{$results['goods']}</b> " . sprintf($st[1540], $text_mat, $results[ship_count]) . $t_cost_str;
        }
    } else {
        //loading the ship
        $taken = 0;
        //goods taken from planet so far.
        $ship_counter = 0;
        if ($planet[$tech_mat] < 1) {
            //can't take stuff if there isn't any to take
            return sprintf($st[1541], $text_mat);
        } elseif ($type == 0) {
            //fighters
            db2("select ship_id,(max_fighters - fighters) as free,ship_name, {$tech_mat} from {$db_name}_ships where login_id = '{$user['login_id']}' && location = '{$user['location']}' && (max_fighters - fighters) > 0 {$extra_where} order by free desc");
        } elseif ($type != 0) {
            db2("select ship_id, (cargo_bays - metal - fuel - elect - colon) as free, ship_name, {$tech_mat} from {$db_name}_ships where login_id = '{$user['login_id']}' && location = '{$user['location']}' && (cargo_bays - metal - fuel - elect - colon) > 0 {$extra_where} order by free desc");
        }
        $ships = dbr2(1);
        $first_mess = "";
        $sec_mess = "";
        $turns_txt = "";
        $out = "";
        if ($type == 0 && $planet['allocated_to_fleet'] > 0) {
            //warning about fighter allocation
            $first_mess = $cw['warning'] . ".<br /> " . $st[1542];
            $sec_mess = $cw['warning'] . ":<br />" . $st[1543];
        }
        if (!isset($ships['ship_id']) && $selected_ships == 0) {
            //check to see if there are any ships
            return $st[1544] . " <b class='b1'>{$text_mat}</b>.";
        } elseif (!isset($ships['ship_id']) && $selected_ships == 1) {
            //check to see if there are any ships
            return $st[1545] . " <b class='b1'>{$text_mat}</b>.";
        } else {
            while ($ships) {
                $ship_counter++;
                //planet can load ship w/ spare fighters.
                if ($ships['free'] < $planet[$tech_mat] - $taken) {
                    if (isset($sure) || $selected_ships == 1) {
                        //only run during the real thing.
                        dbn("update {$db_name}_ships set {$tech_mat} = {$tech_mat} + '{$ships['free']}' where ship_id = '{$ships['ship_id']}'");
                        $out .= "<br /><b class='b1'>{$ships['ship_name']}</b> : " . sprintf($st[1546], $ships[free], $text_mat);
                        if ($ships['ship_id'] == $user_ship['ship_id'] && $type == 0) {
                            #update user ship
                            $user_ship['fighters'] = $user_ship['max_fighters'];
                        } elseif ($ships['ship_id'] == $user_ship['ship_id'] && $type > 0) {
                            #update user ship
                            $user_ship[$tech_mat] += $ships['free'];
                            $user_ship['empty_bays'] -= $ships['free'];
                        }
                    }
                    $taken += $ships['free'];
//.........这里部分代码省略.........
开发者ID:nilsine,项目名称:Astra-Vires,代码行数:101,代码来源:planet.php

示例15: elseif

    } elseif (isset($gen_tab) && $gen_tab == 5) {
        $sql_order_str = "turns_run";
        $order_by_str = $cw['turns_run'];
    } else {
        $sql_order_str = "score";
        $order_by_str = $cw['score'];
    }
    db("select cash,login_name,fighters_killed,ships_killed,ships_lost,turns_run,score,login_id from {$db_name}_users where login_id > 5 order by {$sql_order_str} {$order_dir}");
    $text .= "<br />" . $st[992] . " <b>{$order_by_str}</b>";
    $text .= make_table(array($cw['rank'], $cw['name'], $cw['fighters'] . "<br />" . $cw['killed'], $cw['ships'] . " <br />" . $cw['killed'], $cw['ships'] . " <br />" . $st[995], $cw['turns'] . " <br />" . $st[996], $cw['score']));
}
$text .= '<br />';
$ct1 = 1;
$ct2 = 1;
$last = "";
while ($player = dbr(1)) {
    if (isset($player[$sql_order_str]) && $player[$sql_order_str] != $last) {
        $last = $player[$sql_order_str];
        if ($ct2 > 1) {
            $ct1 = $ct2;
        }
    }
    if ($table != 2) {
        $player['cash'] = $ct1;
    }
    if (!isset($player['last_attack_by']) && $table == 2) {
        $player['last_attack_by'] = "~";
    }
    if (isset($player['clan_sym']) && $table == 2) {
        $player['clan_sym'] = "<font color=#{$player['clan_sym_color']}>{$player['clan_sym']}</font>";
        $player['clan_sym_color'] = "";
开发者ID:nilsine,项目名称:Astra-Vires,代码行数:31,代码来源:player_stat.php


注:本文中的dbr函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。