/**
  * A c c e s s   c o m b i n a t i o n s   -   S E T
  */
 public static function setAccessZones()
 {
     $arrAC = array_map('intval', db_select_fields('access_zones', 'UPPER(zone),id'));
     $szFile = PROJECT_RESOURCES . '/access/zones.txt';
     fwrite($h = fopen($szFile, 'w'), serialize($arrAC));
     fclose($h);
 }
Esempio n. 2
0
function makeRDcell($rd, $extra = '', $w = 0)
{
    $html = '';
    $html .= '<td ' . (0 < $w ? 'width="' . $w . '%" ' : '') . '' . $extra . ' class="t' . $rd['T'] . '">';
    $html .= '<div onclick="goto(' . $rd['id'] . ');" class="t">' . $rd['id'] . '. ' . $rd['name'] . '</div>';
    $arrExcludesRD = db_select_fields('d_r_d_excludes e, d_r_d_available a', 'a.id,concat(\'<a class="a\',a.T,\'" href="#" onclick="return goto(\',a.id,\');">\',a.name,\'</a>\')', 'a.id = e.r_d_excludes_id AND e.r_d_id = ' . $rd['id']);
    $arrCosts = db_select_fields('d_r_d_costs c, d_resources r', 'r.id,concat(\'<span title="\',r.resource,\'" style="color:\',r.color,\';">\',c.amount,\'</span>\')', 'c.resource_id = r.id AND 0 < c.amount AND c.r_d_id = ' . $rd['id']);
    $html .= '<div style="display:none;">' . $rd['explanation'] . '<br />Costs: ' . implode(', ', $arrCosts) . '<br />Excludes: ' . implode(', ', $arrExcludesRD) . '</div>';
    $html .= '</td>' . "\n";
    return $html;
}
Esempio n. 3
0
    }
    //	print_r($_POST['r']);
    if (isset($_POST['new'], $_POST['new']['o'], $_POST['new']['type'], $_POST['new']['done_r_d_id'], $_POST['new']['change'], $_POST['new']['unit'], $_POST['new']['explanation'])) {
        if ('0' !== $_POST['new']['o'] && '' !== $_POST['new']['type'] && '' !== $_POST['new']['done_r_d_id'] && '0' !== $_POST['new']['change'] && '' !== $_POST['new']['unit'] && '' !== $_POST['new']['explanation']) {
            echo "\nNEW: ";
            unset($_POST['new']['id']);
            $_POST['new']['enabled'] = '1';
            var_dump(db_insert('d_r_d_results', $_POST['new']));
            echo db_error();
            print_r($_POST['new']);
        }
    }
    exit;
}
$arrRDResults = db_select('d_r_d_results', '1 ORDER BY id DESC');
$RD = db_select_fields('d_r_d_available', 'id, concat(UPPER(T),\' \',id,\'. \',name)', '1 ORDER BY T ASC, id ASC');
echo '<form method="post" action="" autocomplete="off"><table border="1" cellpadding="4" cellspacing="1">';
foreach ($arrRDResults as $k => $r) {
    echo '<tr><th>[' . $r['id'] . '] Type</th><td><input name="r[' . $r['id'] . '][type]" value="' . $r['type'] . '" /></td></tr>';
    echo '<tr><th>R&D</th><td><select name="r[' . $r['id'] . '][done_r_d_id]"><option value="">--</option>';
    foreach ($RD as $iRD => $szRD) {
        echo '<option' . ($iRD == $r['done_r_d_id'] ? ' selected="1"' : '') . ' value="' . $iRD . '">' . $szRD . '</option>';
    }
    echo '</select></td></tr>';
    echo '<tr><th>Change</th><td><input type="text" size="8" name="r[' . $r['id'] . '][`change`]" value="' . $r['change'] . '" /></td></tr>';
    echo '<tr><th>Unit</th><td><select name="r[' . $r['id'] . '][unit]"><option value="">--</option><option' . ('real' == $r['unit'] ? ' selected="1"' : '') . ' value="real">real</option><option' . ('pct' == $r['unit'] ? ' selected="1"' : '') . ' value="pct">pct</option></select></td></tr>';
    echo '<tr><th>Explanation</th><td><input type="text" size="40" name="r[' . $r['id'] . '][explanation]" value="' . $r['explanation'] . '" /></td></tr>';
    echo '<tr><th>`Order`</th><td><input type="text" size="8" name="r[' . $r['id'] . '][o]" value="' . $r['o'] . '" /></td></tr>';
    echo '<tr><th>Enabled</th><td><input type="checkbox" name="r[' . $r['id'] . '][enabled]" value="1"' . ('1' === $r['enabled'] ? ' checked="1"' : '') . ' /></td></tr>';
    echo '<tr><th colspan="2" bgcolor="#666666"></td></tr>';
}
Esempio n. 4
0
<?php

require_once 'inc.config.php';
logincheck();
if (isset($_POST['order_units'])) {
    addProductions('ship,defence', $_POST['order_units']);
    $arrJson = array(array('eval', "\$('f_order_units').reset();"), array('html', 'div_productionlist', getProductionList('ship,defence')), array('msg', 'Productions added!'));
    foreach (db_select_fields('planet_resources', 'resource_id,amount', 'planet_id = ' . PLANET_ID) as $iResourceId => $iAmount) {
        $arrJson[] = array('html', 'res_amount_' . $iResourceId, nummertje($iAmount));
    }
    exit(json::encode($arrJson));
}
_header();
?>
<div class="header">Production<?php 
if ((int) $GAMEPREFS['havoc_production']) {
    echo ' (<b style="color:red;">HAVOC!</b>)';
}
?>
</div>

<br />

<?php 
echo getProductionForm('ship,defence');
?>

<br />

<div id="div_productionlist">
<?php 
Esempio n. 5
0
// PRE
echo 'Pre: ';
print_r(db_select_fields('d_resources r, planet_resources p', 'resource_id,amount', 'p.resource_id = r.id AND p.planet_id = 1'));
echo "\n";
/**/
exit;
/**/
$arrUpdates = array(1 => 300000, 2 => 50, 3 => 50);
function db_transaction_update($f_arrUpdates, $f_szIfField, $f_szUpdateField)
{
    db_query("BEGIN;");
    $szIfClause = '__N__';
    $szIfClause0 = 'IF(' . $f_szIfField . '=__X__,__Y__,__N__)';
    foreach ($f_arrUpdates as $x => $y) {
        $szIfClause = str_replace('__N__', str_replace('__X__', $x, str_replace('__Y__', $y, $szIfClause0)), $szIfClause);
    }
    $szIfClause = str_replace('__N__', '0', $szIfClause);
    db_query('UPDATE planet_resources SET ' . $f_szUpdateField . ' = ' . $f_szUpdateField . ' - ' . $szIfClause . ' WHERE ' . $f_szUpdateField . ' >= ' . $szIfClause . ' AND planet_id = 1;');
    if (count($f_arrUpdates) === (int) db_affected_rows()) {
        db_query("COMMIT;");
        return true;
    }
    db_query("ROLLBACK;");
    return false;
}
var_dump(db_transaction_update($arrUpdates, 'resource_id', 'amount'));
echo "\n";
// POST
echo 'Post: ';
print_r(db_select_fields('d_resources r, planet_resources p', 'resource_id,amount', 'p.resource_id = r.id AND p.planet_id = 1'));
Esempio n. 6
0
    echo "--\n";
    // Costs
    db_delete('d_unit_costs', 'unit_id = ' . $iUnitId);
    foreach ($arrCosts as $iResourceId => $iAmount) {
        var_dump(db_replace_into('d_unit_costs', array('unit_id' => $iUnitId, 'resource_id' => $iResourceId, 'amount' => $iAmount)));
    }
    db_delete('d_unit_costs', 'amount = 0');
    exit;
}
if (isset($_GET['new_unit_T'], $_GET['required'])) {
    var_dump(db_insert('d_all_units', array('T' => $_GET['new_unit_T'], 'unit' => 'NEW', 'r_d_required_id' => $_GET['required'])));
    echo db_error();
    header('Location: ' . $_SERVER['HTTP_REFERER']);
    exit;
}
$arrRD = db_select_fields('d_r_d_available', 'id, CONCAT(UPPER(T),\': \',name)', '1 ORDER BY T ASC, id ASC');
?>
<style type="text/css">
select, input { font-size : 9px; }
</style>

<div><form action="" method="get">
	<select name="new_unit_T"><option value="ship">ship</option><option value="defence">defence</option><option value="roidscan">roidscan</option><option value="power">power</option><option value="scan">scan</option><option value="amp">amp</option><option value="block">block</option></select>
	<select name="required"><?php 
foreach ($arrRD as $id => $name) {
    echo '<option value="' . $id . '">' . $name . '</option>';
}
?>
</select>
	<input type="submit" value="New" />
</form></div>
Esempio n. 7
0
	<td>To:</td>
	<td>
		<input type="text" id="recip_x" name="x" style="width:30;text-align:center;" value="<?php 
echo isset($_GET['x']) ? (int) $_GET['x'] : 'X';
?>
" onfocus="this.select();"> :
		<input type="text" id="recip_y" name="y" style="width:30;text-align:center;" value="<?php 
echo isset($_GET['y']) ? (int) $_GET['y'] : 'Y';
?>
" onfocus="this.select();"> :
		<input type="text" id="recip_z" name="z" style="width:30;text-align:center;" value="<?php 
echo isset($_GET['z']) ? (int) $_GET['z'] : 'Z';
?>
" onfocus="this.select();">
		<select onchange="var c=this.value.split(',');if(c.join('')){$('recip_x').value=c[0];$('recip_y').value=c[1];$('recip_z').value=c[2];}"><option value="">--</option><?php 
$arrPlanets = db_select_fields('planets p, galaxies g', "concat(g.x,',',g.y,',',p.z),concat(rulername,' of ',planetname)", 'p.galaxy_id = g.id AND p.id != ' . PLANET_ID . ' AND p.galaxy_id = ' . $g_arrUser['galaxy_id']);
foreach ($arrPlanets as $c => $p) {
    echo '<option value="' . $c . '">' . $p . '</option>';
}
?>
</select>
	</td>
</tr>
<tr valign="top">
	<td>Text:</td>
	<td><textarea name="message" cols="50" rows="7"></textarea></td>
</tr>
<tr>
	<td></td>
	<td><input type=submit value="Send"></td>
</tr>
Esempio n. 8
0
    if (!($arrSkill = db_select('d_skills s, planet_skills p', 'p.skill_id = s.id AND s.id = ' . (int) $_GET['train'] . ' AND p.planet_id = ' . PLANET_ID))) {
        exit('Invalid skill!');
    }
    $arrSkill = $arrSkill[0];
    if (0 < db_count('skill_training', 'planet_id = ' . PLANET_ID)) {
        exit('Already training a skill!');
    }
    $iEta = pow(5 + (int) $arrSkill['value'], 2);
    db_insert('skill_training', array('planet_id' => PLANET_ID, 'skill_id' => $arrSkill['id'], 'eta' => $iEta));
    header('Location: skills.php');
    exit;
}
_header();
$arrSkills = db_fetch('SELECT * FROM d_skills s LEFT JOIN planet_skills p ON p.skill_id = s.id AND p.planet_id = ' . PLANET_ID . ';');
//echo '<pre>';print_r($arrSkills);
$arrTraining = db_select_fields('skill_training', 'skill_id,eta', '0 <= eta AND planet_id = ' . PLANET_ID);
echo db_error();
?>

<div class="header">Skills</div>

<br />

<table border="0" bordercolor="#dddddd" cellspacing="0" cellpadding="3" align="center" class="widecells">
<tr>
	<th width="10"></th>
	<th width="100%" class="left">Name</th>
	<th align="center">ETA</th>
	<th align="right">Progress</th>
	<th align="center">Action</th>
	<th nowrap="1" align="right">Current level</th>
Esempio n. 9
0
<?php

require_once '../inc.connect.php';
echo '<pre>';
$arrResourceIds = db_select_fields('d_resources', 'LOWER(resource),id');
print_r($arrResourceIds);
/** R & D **
$arrRD = db_select('d_r_d_available');
foreach ( $arrRD AS $rd ) {
	foreach ( $arrResourceIds AS $szResource => $iResource ) {
		if ( isset($rd[$szResource]) && 0 < $rd[$szResource] ) {
			var_dump(db_update('d_r_d_costs', 'amount = '.(int)$rd[$szResource], 'resource_id = '.$iResource.' AND r_d_id = '.(int)$rd['id']));
		}
	}
}
/**/
/** Units **
$arrUnits = db_select('d_all_units');
foreach ( $arrUnits AS $u ) {
	foreach ( $arrResourceIds AS $szResource => $iResource ) {
		if ( isset($u[$szResource]) && 0 < $u[$szResource] ) {
			var_dump(db_update('d_unit_costs', 'amount = '.(int)$u[$szResource], 'resource_id = '.$iResource.' AND unit_id = '.(int)$u['id']));
		}
	}
}
/**/
Esempio n. 10
0
$g_arrRequires = array();
foreach ($arrRequires as $rd) {
    $g_arrRequires[$rd['r_d_id']][$rd['r_d_requires_id']] = true;
}
$arrExcludes = db_select('d_r_d_excludes');
$g_arrExcludes = array();
foreach ($arrExcludes as $rd) {
    $g_arrExcludes[$rd['r_d_id']][$rd['r_d_excludes_id']] = true;
}
$arrForRaces = db_select('d_r_d_per_race');
$g_arrForRaces = array();
foreach ($arrForRaces as $rd) {
    $g_arrForRaces[$rd['r_d_id']][$rd['race_id']] = true;
}
$arrRaces = db_select_fields('d_races', 'id,race', '1 ORDER BY id ASC');
$arrSkills = db_select_fields('d_skills', 'id,skill', '1 ORDER BY id ASC');
printRDSelect($RD, 'r', $arrRaces, $arrSkills);
echo '</td><td align="center">';
printRDSelect($RD, 'd', $arrRaces, $arrSkills);
echo '</td></tr><tr bgcolor="#dddddd"><th class="rb">RESEARCHES</th><th>DEVELOPMENTS</th></tr><tr><th colspan="2"><input type="submit" value="Opslaan" /></th></tr></table>';
?>
</form>

<form method="post" action="">
<table border="1" cellpadding="4" cellspacing="1">
<tr>
	<th>Name</th>
	<td><input type="text" size="40" value="" name="name" /></td>
	<th>Type</th>
	<td><select name="T"><option value="r">r</option><option value="d">d</option></select></td>
</tr>
Esempio n. 11
0
To be able to login, you\'re going to need to activate your account.
Your actination code = ' . $arrInsert['activationcode'] . '


Have fun playing.

Direct any questions to the Help section of the game or ask another player to contact an Admin in the game.
';
    if (mail($arrInsert['email'], "PORNSTARS - NEW PLANET", $szMessage, $headers)) {
        exit('If your e-mail was valid, you have mail! If not, or you can\'t find it, you are owner of planet # ' . $iPlanetId . '. Contact an Admin!');
    }
    db_update('planets', 'activationcode = \'\'', 'id = ' . (int) $iPlanetId);
    exit('Sending a mail failed!!! You might not be able to login now... In that case, contact an admin through the Help section! You are owner of planet # ' . $iPlanetId . '!');
}
echo $indextitel;
$arrRaces = db_select_fields('d_races', 'id,race', '1 ORDER BY id ASC');
?>
<html>

<head>
<title><?php 
echo $GAMENAME;
?>
</title>
<link rel="stylesheet" type="text/css" href="css/styles.css">
<script type="text/javascript" src="general_1_2_6.js"></script>
<script type="text/javascript" src="ajax_1_3_1.js"></script>
</head>

<body bgcolor="black">
Esempio n. 12
0
    // ETA
    echo '<td align="center">' . $szEta . '</td>';
    // Progress
    echo '<td align="right">' . (isset($arrPlanetRD[$r['id']]) ? round(($r['eta'] - $arrPlanetRD[$r['id']]) / max(1, $r['eta']) * 100) . ' %' : '-') . '</td>';
    // Action
    echo '<td align="center">' . (!isset($arrPlanetRD[$r['id']]) ? $bInProgess ? '-' : '<a onclick="return R(this);" href="?r_d_id=' . $r['id'] . '">start</a>' : '-') . '</td>';
    $arrPreCosts = db_select_fields('d_r_d_costs', 'resource_id,amount', '0 < amount AND r_d_id = ' . (int) $r['id'] . ' ORDER BY resource_id ASC');
    $arrCosts = array();
    foreach ($arrPreCosts as $iResourceId => $iAmount) {
        $iAmount = max(0, applyRDChange('r_d_costs', (int) $iAmount));
        $arrCosts[] = '<span style="color:' . $g_arrResources[$iResourceId]['color'] . ';">' . nummertje($iAmount) . '&nbsp;' . strtolower($g_arrResources[$iResourceId]['resource']) . '</span>';
    }
    $szCosts = $arrCosts ? implode('<br />', $arrCosts) : '-';
    // Costs
    echo '<td align="right">' . $szCosts . '</td>';
    $arrRequiredSkills = db_select_fields('d_skills s, d_skills_per_r_d r', 's.id,concat(s.skill,\': \',r.required_value)', 'r.skill_id = s.id AND r.r_d_id = ' . (int) $r['id'] . ' AND 0 < required_value');
    foreach ($arrRequiredSkills as $iSkill => &$szSkill) {
        $x = explode(':', $szSkill);
        $iValue = (int) trim($x[1]);
        if ((double) $arrSkills[$iSkill] < (double) $iValue) {
            $szSkill = '<span style="color:red;">' . $szSkill . '</span>';
        }
        unset($szSkill);
    }
    $szSkills = $arrRequiredSkills ? implode('<br />', $arrRequiredSkills) : '-';
    // Skills
    echo '<td align="right" style="font-size:10px;" nowrap="1" wrap="off">' . $szSkills . '</td>';
    echo '</tr>' . "\n";
}
if (empty($bNoMsg)) {
    echo '<tr><td colspan="6" align="center">' . $szAllRDDone . '</td></tr>';
Esempio n. 13
0
	<th align="center" style="border-right:solid 1px black;" title="Tertiary Target (value is `Short`)">T3</th>
	<?php 
foreach ($rs as $r) {
    echo '<th align="right">' . $r['resource'] . '</th>' . "\n";
}
?>
	<th align="right" style="border-right:solid 1px black;">ETA</th>
	<th align="right">Fuel/tick</th>
	<th align="right">Min. ETA</th>
</tr>
<?php 
$c = array('#333333', '#222222');
$i = $t = 0;
$arrFighterUnits = db_select_by_field('d_all_units', 'id', 'T IN (\'ship\', \'defence\') ORDER BY T ASC, o ASC');
foreach ($arrFighterUnits as $iUnitId => &$arrUnit) {
    $arrUnit['targets'] = array_values(db_select_fields('d_combat_stats', 'receiving_unit_id,receiving_unit_id', 'shooting_unit_id = ' . (int) $arrUnit['id'] . ' ORDER BY target_priority ASC LIMIT 3'));
    $szType = 'defence' === $arrUnit['T'] ? 'DEF' : ($arrUnit['is_stealth'] ? 'STE' : (!$arrUnit['is_offensive'] ? 'NLF' : 'NOR'));
    $szTypes = array('NOR' => 'Normal', 'NLF' => 'Non-lethal', 'STE' => 'Stealth', 'DEF' => 'Defensive');
    echo '<tr' . (0 < $i && $t !== $arrUnit['T'] ? ' class="bt"' : '') . ' bgcolor="' . $c[$i++ % 2] . '">';
    echo '<td align="right" width="10">' . $arrUnit['id'] . '</td>';
    echo '<td align="right">' . $arrUnit['unit'] . '</td>';
    echo '<td align="center">' . strtolower($arrUnit['unit_short']) . '</td>';
    echo '<td align="center" title="' . $szTypes[$szType] . '">' . $szType . '</td>';
    echo '<td align="center">' . (isset($arrUnit['targets'][0]) ? strtolower($arrFighterUnits[$arrUnit['targets'][0]]['unit_short']) : '-') . '</td>';
    echo '<td align="center">' . (isset($arrUnit['targets'][1]) ? strtolower($arrFighterUnits[$arrUnit['targets'][1]]['unit_short']) : '-') . '</td>';
    echo '<td align="center" style="border-right:solid 1px black;">' . (isset($arrUnit['targets'][2]) ? strtolower($arrFighterUnits[$arrUnit['targets'][2]]['unit_short']) : '-') . '</td>';
    foreach (db_fetch('SELECT c.*, r.resource FROM d_resources r LEFT JOIN d_unit_costs c ON r.id = c.resource_id AND c.unit_id = ' . $arrUnit['id'] . ' WHERE 1 ORDER BY r.id ASC') as $costs) {
        echo '<td align="right" title="' . $costs['resource'] . '">' . nummertje($costs['amount']) . '</td>';
    }
    echo '<td align="right" style="border-right:solid 1px black;">' . $arrUnit['build_eta'] . '</td>';
    echo '<td align="right">' . nummertje($arrUnit['fuel']) . '</td>';
 /**
  * P r e p a r e   a   r e s e r v a t i o n   f o r   i n s e r t   /   u p d a t e
  */
 public static function prepareReservationPlayers($f_arrPlayers, $f_arrResource, $f_iUtcTime, $f_iGames, $f_bDoRoundPrices = true, &$f_parrIsPeakTime = array())
 {
     $arrResource = $f_arrResource;
     $iUtcStartTime = $f_iUtcTime;
     $szDate = date('Y-m-d', $f_iUtcTime);
     $szStartTime = date('H:i:00', $f_iUtcTime);
     $iToday = (int) date('w', $f_iUtcTime);
     $bIsWeekend = 0 == $iToday || 6 == $iToday;
     $arrPlayers = $f_arrPlayers;
     $objTime = new Time($szStartTime);
     $arrIsPeakTime = array();
     $p1 = array();
     for ($i = 0; $i < $f_iGames; $i++) {
         if (0 < $i) {
             $objTime->addMinutes($f_arrResource['slotsize'] * $f_arrResource['game_length']);
         }
         $szTime = $objTime->getTimeAsString();
         $arrIsPeakTime[] = $bIsPeakTime = common::isPeakTime($f_arrResource['id'], $szDate, $szTime);
         foreach ($arrPlayers as $k => &$arrPlayer) {
             if (null === $arrPlayer['user_id'] || !empty($p1) && '1' === $p1['mt']['strips'] && '1' === $p1['pays_strips_for_coplayers'] && 0 < (int) $p1['balance_strips']) {
                 // GUEST || P1 pays for Px
                 if (!empty($p1) && '1' === $p1['mt']['strips'] && 0 < (int) $p1['balance_strips']) {
                     // P1 pays in strips
                     $arrPlayers[0]['strips']++;
                     $arrPlayer['actual_strips']++;
                     #						$p1['balance_strips']--;
                 } else {
                     // P1 pays in money
                     $c = round(1 * user::getPrice($f_arrResource['id'], $bIsWeekend, $bIsPeakTime, $szDate, $arrPlayer['user_id']), 2);
                     $cc = round(1 * user::getCancelPrice($f_arrResource['id'], $bIsWeekend, $bIsPeakTime, $szDate, $arrPlayer['user_id']), 2);
                     $arrPlayer['actual_costs'] += $c;
                     $arrPlayers[0]['costs'] += $c;
                     $arrPlayer['actual_cancellation'] += $cc;
                     $arrPlayers[0]['cancellation'] += $cc;
                 }
             } else {
                 // MEMBER || Px pays for himself
                 // Assign member to buffer
                 $arrPlayer['user'] = user::get($arrPlayer['user_id']);
                 $arrPlayer['mt'] = user::getMembership($arrPlayer['user_id'], $szDate);
                 if (0 === $k && array() === $p1 && null !== $arrPlayer['user_id']) {
                     $p1 = $arrPlayer['user'];
                     $p1['mt'] = $arrPlayer['mt'];
                 }
                 // Payment method
                 if ('1' === $arrPlayer['mt']['strips'] && 0 < (int) $arrPlayer['user']['balance_strips']) {
                     // Player has strips
                     $arrPlayer['actual_strips']++;
                     $arrPlayer['strips']++;
                     #						if ( 0 === $k ) {
                     #							$p1['balance_strips']--;
                     #						}
                 } else {
                     // Player pays with money
                     $c = round(1 * user::getPrice($f_arrResource['id'], $bIsWeekend, $bIsPeakTime, $szDate, $arrPlayer['user_id']), 2);
                     $cc = round(1 * user::getCancelPrice($f_arrResource['id'], $bIsWeekend, $bIsPeakTime, $szDate, $arrPlayer['user_id']), 2);
                     $arrPlayer['actual_costs'] += $c;
                     $arrPlayer['costs'] += $c;
                     $arrPlayer['actual_cancellation'] += $cc;
                     $arrPlayer['cancellation'] += $cc;
                 }
             }
             unset($arrPlayer);
         }
     }
     if (empty($f_parrIsPeakTime)) {
         $f_parrIsPeakTime = $arrIsPeakTime;
     }
     $fTotalCancellationCosts = 0;
     foreach ($arrPlayers as $p) {
         $fTotalCancellationCosts += (double) $p['cancellation'];
     }
     foreach ($arrPlayers as &$arrPlayer) {
         if (0 < $arrPlayer['strips']) {
             $arrPlayer['strips'] /= $f_iGames;
         }
         if ($f_bDoRoundPrices) {
             $arrPlayer['costs'] = 0.05 * round($arrPlayer['costs'] / 0.05);
             $arrPlayer['cancellation'] = 0.05 * round($arrPlayer['cancellation'] / 0.05);
         }
         $arrPlayer['cancellation'] = null !== $arrPlayer['user_id'] ? $fTotalCancellationCosts : 0.0;
         unset($arrPlayer);
     }
     // R U L E S //
     global $g_arrClub;
     $bImmune = defined('USER_ID') ? user::access('IMMUNE_TO_RULES') : false;
     $bFFA = common::freeForAll($szDate);
     $bDoAllRules = !$bImmune && !$bFFA;
     $arrRules = db_select_fields('rules_for_clubs c, rules r', 'r.id,r.rule', 'r.id = c.rule_id AND c.club_id = ' . (int) $g_arrClub['id'] . ' AND ( type = \'costs\'' . ($bDoAllRules ? ' OR type = \'reservation\'' : '') . ' )');
     foreach ($arrRules as $szRule) {
         if (is_string($r = @eval($szRule))) {
             return $r;
         }
     }
     // R U L E S //
     /*foreach ( $arrPlayers AS &$p ) {
     			unset($p['user'], $p['mt']);
     			unset($p);
     		}*/
     return $arrPlayers;
 }
Esempio n. 15
0
        foreach ($arrDInitialTotalShips as $iUnitId => $iAmount) {
            $szCombatReport .= '<tr>';
            $szCombatReport .= '<th align="right">' . $g_arrUnits[$iUnitId]['name'] . ' [' . $iUnitId . ']</th>';
            $szCombatReport .= '<td align="right">' . nummertje($iAmount) . '</td>';
            //			$szCombatReport .= '<td align="right">'.nummertje($arrDTotalShips[$iUnitId]).'</td>';
            $szCombatReport .= '<td align="right">' . nummertje($iAmount - $arrDTotalShips[$iUnitId]) . '</td>';
            $szCombatReport .= '<td align="right">' . nummertje($arrDBlockedShips[$iUnitId]) . '</td>';
            $szCombatReport .= '</tr>';
        }
        $szCombatReport .= '<tr><td align="center" colspan="4">Asteroids lost: ' . nummertje($iSnatchedAsteroids) . '</td></tr>';
        foreach ($arrSnatchedRoidsPerResource as $iResource => $iAsteroidsLost) {
            $szCombatReport .= '<tr><th colspan="3" align="right">Resource ' . $iResource . '</th><td align="right">' . nummertje($iAsteroidsLost) . '</td></tr>';
        }
        $szCombatReport .= '</table>';
        // - save combat report - //
        $arrPlanetIds = db_select_fields('fleets', 'owner_planet_id,1', 'id IN (' . implode(',', array_keys($arrDShipsInFleet)) . ') OR id IN (' . implode(',', array_keys($arrDShipsInFleet)) . ')');
        $arrPlanetIds[$id] = '1';
        $arrPlanetIds = array_keys($arrPlanetIds);
        foreach ($arrPlanetIds as $iPlanetId) {
            AddNews(NEWS_SUBJECT_COMBAT, $szCombatReport, $iPlanetId);
        }
    }
    // 0 < count($arrAttackingFleets)
}
// foreach $allusers
// decrease actiontime
db_update('fleets', 'actiontime=actiontime-1', 'actiontime > 0 AND eta = 0 AND activated = \'1\'');
/** CHECK NUM FLEETS **
$a = db_query("SELECT owner_id,owner_x,owner_y,COUNT(*) AS num FROM $TABLE[fleets] GROUP BY owner_id ASC");
while (list($owner_id,$owner_x,$owner_y,$num_fleets) = mysql_fetch_row($a))
{
// Misc
$PWD_MUST_CHANGE = (bool) (int) $GAMEPREFS['must_change_pwd'];
// Password must be changed in order to play when set to TRUE
$CHECK_TIME_BETWEEN_LOGINS = (int) $GAMEPREFS['between_logins_time'];
// If 0, disabled. Else you can't login for this amount of seconds after your last login
$PLANETS_IN_ONE_GALAXY = (int) $GAMEPREFS['planets_per_galaxy'];
// Duh
$RESCON_NEWS_ON = (bool) (int) $GAMEPREFS['news_for_done_rd'];
// If TRUE, the engine will check R&D per planet (takes a bit longer, but sends a Msg when finished)
$GALFORUM_WAIT_FOR_TURN = (bool) (int) $GAMEPREFS['galaxy_forum_wait_for_turn'];
// If TRUE, you cant post 2 posts after eachother without anyone posting in between
$FLEETNAMES = explode(',', trim($GAMEPREFS['fleetnames']) ? $GAMEPREFS['fleetnames'] : 'Base');
// The names for BASEFLEET and $NUM_OUTGOING_FLEETS outgoing fleets
$NUM_OUTGOING_FLEETS = min(count($FLEETNAMES) - 1, (int) $GAMEPREFS['num_outgoing_fleets']);
// Duh
foreach (db_select_fields('d_news_subjects', 'id,const_name', '1 ORDER BY id ASC') as $iSubjectId => $szConstant) {
    define('NEWS_SUBJECT_' . strtoupper($szConstant), (int) $iSubjectId);
}
// Preferences
$TICKERTIME = $GAMEPREFS['tickertime'];
$tickertime = $GAMEPREFS['tickertime'];
$MyT = $GAMEPREFS['tickcount'];
$GAMENAME = $GAMEPREFS['gamename'];
$showcolors['metal'] = '#555555';
$showcolors['crystal'] = '#2244dd';
$showcolors['energy'] = '#228800';
$showcolors['gc'] = '#8080ff';
$showcolors['mow'] = '#ff3333';
$showcolors['moc'] = 'green';
$showcolors['mof'] = 'gold';
$showcolors['attack'] = 'red';
Esempio n. 17
0
<tr>
	<th colspan="2"<?php 
if ((int) $g_arrUser['mof_planet_id'] === PLANET_ID) {
    echo ' style="color:' . $showcolors['mof'] . ';";';
}
?>
>The Galaxy Fund</th>
	<th class="br bl"><br /></th>
	<th nowrap="1" wrap="off" style="cursor:help;" title="Donating to a Planet costs 10%">Planet donation</th>
</tr>
<tr class="bt">
	<th class="right">Fund</th>
	<th style="cursor:help;" title="Donating to The Fund costs 5%">Donate</th>
	<th class="br bl">Type</th>
	<td align="center"><select name="to_planet_id"><option value="">-- Recipient Planet</option><?php 
$p = db_select_fields('planets', 'id,concat(z,\'. \',rulername,\' of \',planetname)', 'id <> ' . PLANET_ID . ' AND galaxy_id = ' . (int) $g_arrUser['galaxy_id'] . ' ORDER BY z ASC');
foreach ($p as $iP => $szP) {
    echo '<option value="' . $iP . '">' . $szP . '</option>';
}
?>
</select></td>
</tr>
<?php 
foreach ($g_arrResources as $r) {
    ?>
<tr class="bt" style="color:<?php 
    echo $r['color'];
    ?>
;">
	<td class="right">????</td>
	<td class="c"><input type="text" name="donate_to_fund[<?php 
Esempio n. 18
0
echo isset($_GET['tbl']) && 'galaxies' == $_GET['tbl'] ? ' selected="1"' : '';
?>
>galaxies</option></select></div>
<div id="planets" style="display:none;"><select onchange="if(this.value){document.location='?tbl=planets&pk=id&id='+this.value;}" style="width:100%;">
<option value="">-- planets</option>
<?php 
$arrPlanets = db_select_fields('galaxies g, planets p', 'p.id,concat(p.id,\'. \',email,\' - \',rulername,\' of \',planetname,\' (\',x,\':\',y,\':\',z,\')\')', 'g.id = p.galaxy_id ORDER BY g.x ASC, g.y ASC, p.z ASC');
foreach ($arrPlanets as $k => $v) {
    echo '<option value="' . $k . '">' . $v . '</option>';
}
?>
</select></div>
<div id="galaxies" style="display:none;"><select onchange="if(this.value){document.location='?tbl=galaxies&pk=id&id='+this.value;}" style="width:100%;">
<option value="">-- galaxies</option>
<?php 
$arrGalaxies = db_select_fields('galaxies', 'id,concat(id,\'. \',name,\' (\',x,\':\',y,\')\')', '1 ORDER BY x ASC, y ASC');
foreach ($arrGalaxies as $k => $v) {
    echo '<option value="' . $k . '">' . $v . '</option>';
}
?>
</select></div>
<script type="text/javascript">document.getElementById(g_szTable).style.display='';</script>
</td>
<td width=20 bgcolor=#dddddd rowspan=2>&nbsp;&nbsp;&nbsp;<br></td>
<td width=50%>Gameprefs</td>
</tr>
<tr valign=top>
<td>
<?php 
if (isset($_GET['tbl'], $_GET['pk'], $_GET[$_GET['pk']]) && 0 < count($arrRecords = db_fetch('SELECT * FROM `' . $_GET['tbl'] . '` WHERE `' . addslashes($_GET['pk']) . '` = ' . (int) $_GET[$_GET['pk']] . ';'))) {
    $arrRecord = $arrRecords[0];
Esempio n. 19
0
function getProductionForm($f_szTypes, $f_iPlanetId = PLANET_ID)
{
    $szSqlQuery = '
	SELECT
		u.*
	FROM
		d_all_units u,
		planet_r_d p
	WHERE
		u.r_d_required_id = p.r_d_id AND
		p.planet_id = ' . (int) $f_iPlanetId . ' AND
		p.eta = 0 AND
		u.T IN (\'' . str_replace(',', "','", $f_szTypes) . '\')
	ORDER BY
		u.T ASC,
		u.o ASC;
	';
    $arrUnits = db_fetch($szSqlQuery);
    global $showcolors, $GAMEPREFS, $g_arrResources;
    $szHtml = $szLastType = '';
    $szHtml .= '
<form id="f_order_units" method="post" action="" autocomplete="off" onsubmit="return postForm(this,H);">
<table border="0" cellpadding="3" cellspacing="0" width="90%" align="center" class="widecells">
<tr>
	<th>&nbsp;</th>
	<th class="left">Name</th>
	<th>ETA</th>
	<th class="right">Costs</th>
	<th class="right">In&nbsp;stock</th>
	<th>Order</th>
</tr>';
    foreach ($arrUnits as $k => $arrUnit) {
        if ($szLastType !== $arrUnit['T']) {
            if ($k) {
                $szHtml .= '<tr class="bt"><td colspan="6">&nbsp;</td></tr>';
            }
            switch ($arrUnit['T']) {
                case 'ship':
                    $szSqlTable = 'ships_in_fleets s, fleets f';
                    $szSqlWhere = 's.ship_id = __UNIT_ID__ AND f.id = s.fleet_id AND f.owner_planet_id = ' . (int) $f_iPlanetId;
                    break;
                case 'defence':
                    $szSqlTable = 'defence_on_planets';
                    $szSqlWhere = 'defence_id = __UNIT_ID__ AND planet_id = ' . (int) $f_iPlanetId;
                    break;
                case 'roidscan':
                case 'scan':
                case 'block':
                case 'amp':
                    $szSqlTable = 'waves_on_planets';
                    $szSqlWhere = 'wave_id = __UNIT_ID__ AND planet_id = ' . (int) $f_iPlanetId;
                    break;
                case 'power':
                    $szSqlTable = 'power_on_planets';
                    $szSqlWhere = 'power_id = __UNIT_ID__ AND planet_id = ' . (int) $f_iPlanetId;
                    break;
                default:
                    return '';
                    break;
            }
            $szLastType = $arrUnit['T'];
        }
        $szHtml .= '<tr valign="top" class="bt">';
        // ID
        $szHtml .= '<td width="10%" align="right">' . $arrUnit['id'] . '</td>';
        // Name
        $szHtml .= '<td width="100%"><i onclick="TD(this.parentNode.getElementsByTagName(\'div\')[0]);" style="cursor:pointer;">' . $arrUnit['unit_plural'] . '</i><div style="display:none;font-size:10px;">' . $arrUnit['explanation'] . '</div></td>';
        // ETA
        $szHtml .= '<td width="10%" align="center">' . ((int) $GAMEPREFS['havoc_production'] ? '0' : $arrUnit['build_eta']) . '</td>';
        $arrPreCosts = db_select_fields('d_unit_costs', 'resource_id,amount', '0 < amount AND unit_id = ' . (int) $arrUnit['id'] . ' ORDER BY resource_id ASC');
        $arrCosts = array();
        foreach ($arrPreCosts as $iResourceId => $iAmount) {
            $iAmount = (int) $iAmount;
            $arrCosts[] = '<span style="color:' . $g_arrResources[$iResourceId]['color'] . ';">' . nummertje($iAmount) . '&nbsp;' . strtolower($g_arrResources[$iResourceId]['resource']) . '</span>';
        }
        $szCosts = $arrCosts ? implode('<br />', $arrCosts) : '-';
        // Costs
        $szHtml .= '<td width="10%" class="right">' . $szCosts . '</td>';
        $iInStock = (int) db_select_one($szSqlTable, 'SUM(amount)', str_replace('__UNIT_ID__', (int) $arrUnit['id'], $szSqlWhere));
        // In stock
        $szHtml .= '<td width="10%" class="right" id="unit_amount_' . $arrUnit['id'] . '">' . nummertje($iInStock) . '</td>';
        // Order
        $szHtml .= '<td width="10%" class="c"><input autocomplete="off" type="text" name="order_units[' . $arrUnit['id'] . ']" value="" style="width:45px;text-align:right;padding:2px;" maxlength="5" /></td>';
        $szHtml .= '</tr>';
    }
    $szHtml .= '
<tr>
	<td colspan="5">&nbsp;</td>
	<td class="c"><input type="submit" value="Order" /></td>
</tr>
</table>
</form>';
    return $szHtml;
}