Esempio n. 1
0
// configuration
require "../includes/config.php";
if ($_SERVER["REQUEST_METHOD"] == "GET") {
    render("buy_form.php", ["title" => "Sell"]);
} else {
    if ($_SERVER["REQUEST_METHOD"] == "POST") {
        if (!preg_match("/^\\d+\$/", $_POST['quantity'])) {
            apologize("Sale canceled. You can only buy whole shares, please indicate a positive integer");
        }
        if (lookup($_POST["symbol"]) === false) {
            apologize("Sale canceled. Please choose a valid stock symbol");
        }
        $sharearray = lookup(strtoupper($_POST["symbol"]));
        $stock = strtoupper($_POST["symbol"]);
        $idrows = query("SELECT * FROM users WHERE id = ?", $_SESSION["id"]);
        $saleprice = moneyformat($sharearray["price"] * $_POST["quantity"]);
        if ($saleprice > $idrows[0]['cash']) {
            apologize("Sale canceled.  Poor you! you don't have enough money to buy these shares of " . $_POST["symbol"]);
        } else {
            query("INSERT INTO portfolio (id, symbol, shares) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE shares = \n            shares + VALUES(shares)", $_SESSION["id"], "{$stock}", $_POST["quantity"]);
            $newbalance = $idrows[0]['cash'] - $saleprice;
            query("UPDATE users SET cash = ? WHERE id = ?", $newbalance, $_SESSION["id"]);
            query("INSERT INTO history (id, symbol, soldorbought, number, price) VALUES (?, ?, 0, ?, ?)", $_SESSION["id"], "{$stock}", $_POST["quantity"], $saleprice);
            redirect("/");
        }
    }
}
?>
        
        
        
Esempio n. 2
0
<?php

// configuration
require "../includes/config.php";
if ($_SERVER["REQUEST_METHOD"] == "GET") {
    render("quote_form.php", ["title" => "quote"]);
    exit;
} else {
    if ($_SERVER["REQUEST_METHOD"] == "POST") {
        if (lookup($_POST["symbol"]) === false) {
            apologize("please choose a valid stock symbol");
        } else {
            $stock = lookup($_POST["symbol"]);
            $formatedprice = moneyformat($stock["price"]);
            render("price.php", ["title" => "price", "name" => $stock["name"], "price" => $formatedprice]);
        }
    }
}
?>
    
      
        

Esempio n. 3
0
		</tr>
<?php 
    $result = $mysql->query("SELECT `name`, `emblem_data`, `guild_lv`, `exp`, `guild_id`, `average_lv` FROM `guild` WHERE `guild_id` > '1' ORDER BY `guild_lv` DESC, `exp` DESC LIMIT 25", $CONFIG['DBMain']);
    for ($i = 1; $line = $mysql->fetcharray($result); $i++) {
        $emblems[$line['guild_id']] = $line['emblem_data'];
        echo '
				<tr>
					<td align="left">' . $i . '</td>
					<td align="center"><img src="emblema.php?data=' . $line['guild_id'] . '" alt="' . htmlformat($line['name']) . '"></td>
					<td align="left">
						<span title="Ver Profile de Guild" style="color:#3dafff; cursor:pointer" onMouseOver="this.style.color=#3dafff" onMouseOut="this.style.color=#3dafff" onClick="return LINK_ajax(\'guildprofile.php?guild_id=' . $line['guild_id'] . '\',\'main_div\');">
							' . htmlformat($line['name']) . '
						</span>
					</td>
					<td align="left">' . $line['guild_lv'] . '</td>
					<td align="right">' . moneyformat($line['exp']) . '</td>
					<td align="right">' . $line['average_lv'] . '</td>
				</tr>
			';
    }
} else {
    if ($_GET['opt'] == 1) {
        // WoE Castles
        $castles = $_SESSION[$CONFIG['Name'] . 'castles'];
        ?>
	<table width="600">
		<tr>
			<td align="left" class="head">#</td>
			<td align="center" class="head">Emblema</td>
			<td align="left" class="head">Nombre</td>
			<td align="center" class="head">Castillo</td>
Esempio n. 4
0
// imports queries
include_once 'functions.php';
//if (!empty($_SESSION[$CONFIG_name.'account_id'])) {
//	if ($_SESSION[$CONFIG_name.'account_id'] > 0) {
$query = sprintf(GUILD_LADDER);
$result = execute_query($query, "guild.php");
opentable($lang['GUILD_TOP50']);
echo "\r\n\t\t<table width=\"550\">\r\n\t\t<tr>\r\n\t\t\t<td align=\"right\" class=\"head\">" . $lang['POS'] . "</td>\r\n\t\t\t<td align=\"center\" class=\"head\">" . $lang['GUILD_EMBLEM'] . "</td>\r\n\t\t\t<td>&nbsp;</td>\r\n\t\t\t<td align=\"left\" class=\"head\">" . $lang['GUILD_GNAME'] . "</td>\r\n\t\t\t<td>&nbsp;</td>\r\n\t\t\t<td>&nbsp;</td>\r\n\t\t\t<td align=\"left\" class=\"head\">" . $lang['GUILD_GLEVEL'] . "</td>\r\n\t\t\t<td align=\"right\" class=\"head\">" . $lang['GUILD_GEXPERIENCE'] . "</td>\r\n\t\t\t<td>&nbsp;</td>\r\n\t\t\t<td align=\"center\" class=\"head\">" . $lang['GUILD_MEMBERS'] . "</td>\r\n\t\t\t<td align=\"right\" class=\"head\">" . $lang['GUILD_GAVLEVEL'] . "</td>\r\n\t\t</tr>\r\n\t\t";
for ($i = 1; $i < 51; $i++) {
    if (!($line = $result->fetch_row())) {
        break;
    }
    $gname = $line[0];
    $gname = htmlformat($line[0]);
    $emblems[$line[4]] = $line[1];
    $experience = moneyformat($line[3]);
    echo "\r\n\t\t\t<tr>\r\n\t\t\t\t<td align=\"right\">{$i}</td>\r\n\t\t\t\t<td align=\"center\"><img src=\"emblema.php?data={$line['4']}\" alt=\"{$gname}\"></td>\r\n\t\t\t\t<td>&nbsp;</td>\r\n\t\t\t\t<td align=\"left\">{$gname}</td>\r\n\t\t\t\t<td>&nbsp;</td>\r\n\t\t\t\t<td>&nbsp;</td>\r\n\t\t\t\t<td align=\"left\">{$line['2']}</td>\r\n\t\t\t\t<td align=\"right\">{$experience}</td>\r\n\t\t\t\t<td>&nbsp;</td>\r\n\t\t\t\t<td align=\"center\">{$line['6']}</td>\r\n\t\t\t\t<td align=\"right\">{$line['5']}</td>\r\n\t\t\t</tr>";
}
echo "</table>";
closetable();
if (is_woe()) {
    opentable($lang['WOE_TIME']);
    closetable();
} else {
    $query = sprintf(GUILD_CASTLE);
    $result = execute_query($query, "guild.php");
    opentable($lang['GUILD_GCASTLES']);
    $castles = $_SESSION[$CONFIG_name . 'castles'];
    echo "\r\n\t\t\t<table>\r\n\t\t\t<tr>\r\n\t\t\t\t<td align=\"center\" class=\"head\">" . $lang['GUILD_EMBLEM'] . "</td>\r\n\t\t\t\t<td>&nbsp;</td>\r\n\t\t\t\t<td align=\"left\" class=\"head\">" . $lang['GUILD_GNAME'] . "</td>\r\n\t\t\t\t<td>&nbsp;</td>\r\n\t\t\t\t<td>&nbsp;</td>\r\n\t\t\t\t<td align=\"left\" class=\"head\">" . $lang['GUILD_GCASTLE'] . "</td>\r\n\t\t\t\t</tr>\r\n\t\t\t";
    for ($i = $i; $line = $result->fetch_row(); $i++) {
        $gname = htmlformat($line[0]);
Esempio n. 5
0
    echo "<td align=\"right\">" . $lang['ABOUT_RATE'] . "</td><td>&nbsp;</td><td align=\"left\">" . $rate_base . "/" . $rate_job . "/" . $rate_drop . "</td>";
} else {
    echo "<td align=\"right\">" . $lang['ABOUT_RATE'] . "</td><td>&nbsp;</td><td align=\"left\">{$CONFIG_rate}</td>";
}
echo "\n\t</tr>\n\t<tr>\n\t<td>&nbsp;</td>\n\t</tr>\n\t<tr>\n\t\t<td align=\"right\">" . $lang['ABOUT_WOE_TIMES'] . "</td>\n\t</tr>\n\t";
ret_woe_times();
echo "\n\t<tr>\n\t<td>&nbsp;</td>\n\t</tr>\n\t<tr>\n\t\t<td align=\"right\">" . $lang['ABOUT_TOTAL_ACCOUNTS'] . "</td><td>&nbsp;</td><td align=right>{$accounts}</td>\n\t</tr>\n\t<tr>\n\t\t<td align=\"right\">" . $lang['ABOUT_TOTAL_CHAR'] . "</td><td>&nbsp;</td><td align=right>{$chars}</td>\n\t</tr>\n\t<tr>\n\t\t<td align=\"right\">" . $lang['ABOUT_TOTAL_ZENY'] . "</td><td>&nbsp;</td><td align=right>{$zeny}</td>\n\t</tr>\n\t<tr>\n\t<td>&nbsp;</td>\n\t</tr>";
if ($CONFIG_classlist_show) {
    echo "<tr><td align=\"right\">" . $lang['ABOUT_TOTAL_CLASS'] . "</td></tr>";
    for ($i = 0; $i < 26; $i++) {
        $class[$i] = moneyformat($class[$i]);
        if ($i != 13 && $i != 21 && $i != 22 && $i != 26 && !empty($class[$i]) && !empty($jobs[$i])) {
            echo "<tr><td align=\"right\">{$jobs[$i]}</td><td>&nbsp;</td><td align=right>{$class[$i]}</td></tr>";
        }
    }
    for ($i = 4001; $i < 4050; $i++) {
        $class[$i] = moneyformat($class[$i]);
        if ($i != 4014 && $i != 4022 && $i != 4036 && $i != 4044 && $i != 4048 && !empty($class[$i]) && !empty($jobs[$i])) {
            echo "<tr><td align=\"right\">{$jobs[$i]}</td><td>&nbsp;</td><td align=right>{$class[$i]}</td></tr>";
        }
    }
    for ($i = 4054; $i < 4213; $i++) {
        $class[$i] = moneyformat($class[$i]);
        if ($i != 4080 && $i != 4081 && $i != 4082 && $i != 4083 && $i != 4084 && $i != 4085 && $i != 4086 && $i != 4087 && $i != 4109 && $i != 4110 && $i != 4111 && $i != 4112 && !empty($class[$i]) && !empty($jobs[$i])) {
            echo "<tr><td align=\"right\">{$jobs[$i]}</td><td>&nbsp;</td><td align=right>{$class[$i]}</td></tr>";
        }
    }
}
echo "</table>";
closetable();
fim();
Esempio n. 6
0
			<td align="left">|</td>
			<td align="center" width="40"><b>Estado</b></td>
		</tr>
		<tr>
			<td align="center" colspan="13"><hr></td>
		</tr>
<?php 
$count = 0;
$result = $mysql->query("\r\n\t\tSELECT\r\n\t\t\t`account_id`, `nombre`, `email`, `id`, `date`, `reference`, `place`, `amount`, `coin`, `status`\r\n\t\tFROM\r\n\t\t\t`cp_donatives`\r\n\t\tWHERE\r\n\t\t\t`status` != '0'\r\n\t\tORDER BY\r\n\t\t\t`date` DESC\r\n\t\tLIMIT 30\r\n\t", $CONFIG['DBLogs']);
while ($line = $mysql->fetcharray($result)) {
    $count++;
    echo '
			<tr>
				<td align="left">' . $line['account_id'] . '</td>
				<td align="left">&nbsp;</td>
				<td align="left">' . $line['nombre'] . '<br>' . $line['email'] . '</td>
				<td align="left">&nbsp;</td>
				<td align="left" width="60">' . $line['date'] . '</td>
				<td align="left">&nbsp;</td>
				<td align="left">' . $line['reference'] . '<br>' . $line['place'] . '</td>
				<td align="left">&nbsp;</td>
				<td align="right">' . $simbolo[$line['coin']] . ' ' . moneyformat($line['amount']) . '</td>
				<td align="left">&nbsp;</td>
				<td align="center" width="50">
					<b>' . ($line['status'] == 1 ? '<font color="Green">OK</font>' : '<font color="Red">NO</font>') . '</b>
				</td>
			</tr>
		';
}
echo '</table>';
closetable();
Esempio n. 7
0
include_once 'config.php';
// loads config variables
include_once 'query.php';
// imports queries
include_once 'functions.php';
$jobs = $_SESSION[$CONFIG_name . 'jobs'];
$query = sprintf(TOP100ZENY);
$result = execute_query($query, "top100zeny.php");
opentable($lang['TOP100ZENY_TOP100ZENY']);
echo "\r\n<table width=\"400\">\r\n<tr>\r\n\t<td align=\"right\" class=\"head\">" . $lang['POS'] . "</td>\r\n\t<td>&nbsp;</td>\r\n\t<td align=\"left\" class=\"head\">" . $lang['NAME'] . "</td>\r\n\t<td align=\"left\" class=\"head\">" . $lang['CLASS'] . "</td>\r\n\t<td align=\"right\" class=\"head\">" . $lang['ZENY'] . "</td>\r\n</tr>\r\n";
$nusers = 0;
if ($result) {
    while ($line = $result->fetch_row()) {
        $nusers++;
        if ($nusers > 100) {
            break;
        }
        $zeny = moneyformat($line[4]);
        $charname = htmlformat($line[0]);
        echo "    \r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td align=\"right\">{$nusers}</td>\r\n\t\t\t\t\t<td>&nbsp;</td>\r\n\t\t\t\t\t<td align=\"left\">{$charname}</td>\r\n\t\t\t\t\t<td align=\"left\">\r\n\t\t\t\t";
        if (isset($jobs[$line[1]])) {
            echo $jobs[$line[1]];
        } else {
            echo $lang['UNKNOWN'];
        }
        echo "\r\n\t\t\t\t\t</td>\r\n\t\t\t\t\t<td align=\"right\">{$zeny}</td>\r\n\t\t\t\t</tr>\r\n\t\t\t\t";
    }
}
echo "</table>";
closetable();
fim();
Esempio n. 8
0
}
if ($servers & 4) {
    echo '
			 <td><img src="online.png"></td>
		';
} else {
    echo '
			<td><img src="offline.png"></td>
		';
}
echo '
			</tr>
			<tr>
				<td align="center" colspan="3">
					<b>Jugadores Online</b>
				</td>
			</tr>
			<tr>
				<td align="center" colspan="3">
					<font size="3" color="yellow"><b>' . moneyformat($users) . '</b></font>
				</td>
			</tr>
			<tr>
				<td colspan="3">&nbsp;</td>
			</tr>
			<tr>
				<td colspan="3">&nbsp;</td>
			</tr>
		</table>
	';
closetable();
Esempio n. 9
0
<?php

// configuration
require "../includes/config.php";
//go into the table and find out the stocks that are owned
//here we have an array each row as (the same "id", a different "symbol" and the number of "shares" for that symbol}
$rows = query("SELECT * FROM portfolio WHERE id = ?", $_SESSION["id"]);
$positions = [];
foreach ($rows as $row) {
    $stock = lookup($row["symbol"]);
    if ($stock !== false) {
        $positions[] = ["name" => $stock["name"], "price" => moneyformat($stock["price"]), "shares" => $row["shares"], "symbol" => $row["symbol"], "sprice" => moneyformat($stock["price"] * $row["shares"])];
    }
}
$totalassetprice = array_sum(array_column($positions, 'sprice'));
//totalassetprice gives the correct result
$newrows = query("SELECT * FROM users WHERE id = ?", $_SESSION["id"]);
$nrow = $newrows[0];
$totalportfolio = $totalassetprice + $nrow["cash"];
render("portfolio.php", ["title" => "portfolio", "positions" => $positions, "cash" => $nrow["cash"], "name" => $nrow["username"], "totalassetprice" => $totalassetprice, "totalportfolio" => $totalportfolio]);
Esempio n. 10
0
             closetable();
             fim();
         }
     }
     $query = sprintf(GET_ZENY, $_SESSION[$CONFIG_name . 'account_id']);
     $result = execute_query($query, "money.php");
     if ($result->count() < 2) {
         redir("motd.php", "main_div", $lang['MONEY_TWO_CHAR']);
     }
     opentable($lang['MONEY_TRANSFER_FROM']);
     echo "\r\n\t\t<table width=\"400\">\r\n\t\t<tr>\r\n\t\t\t<td align=\"left\" class=\"head\">" . $lang['SLOT'] . "</td>\r\n\t\t\t<td align=\"left\" class=\"head\">" . $lang['NAME'] . "</td>\r\n\t\t\t<td align=\"right\" class=\"head\">" . $lang['ZENY'] . "</td>\r\n\t\t</tr>\r\n\t\t";
     while ($line = $result->fetch_row()) {
         $GID = $line[0];
         $slot = $line[1];
         $charname = htmlformat($line[2]);
         $zeny = moneyformat($line[3]);
         $clevel = $line[4];
         echo "    \r\n\t\t\t<tr>\r\n\t\t\t\t<td align=\"left\">{$slot}</td>\r\n\t\t\t\t<td align=\"left\">{$charname}</td>\r\n\t\t\t\t<td align=\"right\">{$zeny}</td>\r\n\t\t\t\t<td>\r\n\t\t\t";
         if ($clevel >= 20) {
             echo "\r\n\t\t\t\t\t<form id=\"money{$slot}\" onsubmit=\"return GET_ajax('money.php','main_div','money{$slot}')\">\r\n\t\t\t\t\t\t<input type=\"submit\" value=\"select\">\r\n\t\t\t\t\t\t<input type=\"hidden\" name=\"opt\" value=\"1\">\r\n\t\t\t\t\t\t<input type=\"hidden\" name=\"zeny1\" value=\"{$zeny}\">\r\n\t\t\t\t\t\t<input type=\"hidden\" name=\"GID1\" value=\"{$GID}\">\r\n\t\t\t\t\t</form>\r\n\t\t\t\t";
         }
         echo "\r\n\t\t\t\t\t</td>\r\n\t\t\t\t</tr>\r\n\t\t\t";
     }
     echo "</table>";
     if ($CONFIG_money_cost) {
         $cost = $CONFIG_money_cost / 100;
         $lang['MONEY_PS1'] = sprintf($lang['MONEY_PS1'], $cost);
         echo "\r\n\t\t\t\t<table>\r\n\t\t\t\t\t<tr><td align=\"left\">" . $lang['MONEY_PS1'] . "</td></tr>\r\n\t\t\t\t</table>\r\n\t\t\t";
     }
     closetable();
 }
Esempio n. 11
0
	';
$nusers = 0;
if ($result) {
    while ($char = $mysql->fetcharray($result)) {
        $nusers++;
        echo '
				<tr>
					<td align="left">' . $nusers . '</td>
					<td>&nbsp;</td>
					<td align="center" width=30><img src="' . $char['sex'] . '.gif"></td>
					<td align="left">
						' . htmlformat($char['name']) . '
			';
        if ($char['gname'] != '') {
            echo '<br>
					<span title="Ver Profile de Guild" style="color:#0000FF; cursor:pointer" onMouseOver="this.style.color=#0000FF" onMouseOut="this.style.color=#0000FF" onClick="return LINK_ajax(\'guildprofile.php?guild_id=' . $char['guild_id'] . '\',\'main_div\');">
						<font color="Navy"><b>[' . htmlformat($char['gname']) . ']</b></font>
					</span>
				';
        }
        echo '
					</td>
					<td align="center"><img src="./imgwm/' . $char['class'] . '.gif"><br>' . $jobs[$char['class']] . '</td>
					<td align="center">' . $char['base_level'] . '/' . $char['job_level'] . '</td>
					<td align="right">' . moneyformat($char['zeny']) . '</td>
				</tr>
			';
    }
}
echo "</table>";
closetable();
// imports queries
include_once 'functions.php';
$servers = server_status();
$quantos = moneyformat(online_count());
//Dynamic Info Check [ABOUT_RATES|RATES_AGIT]
if ($CONFIG_dynamic_info || $CONFIG_agit_check) {
    if ($CONFIG_agit_check) {
        $query = sprintf(RATES_AGIT, $CONFIG_dynamic_name);
    } else {
        $query = sprintf(ABOUT_RATES, $CONFIG_dynamic_name);
    }
    $result = execute_query($query, 'server_status.php');
    $line = $result->fetch_row();
    $rate_base = moneyformat($line[0] / 100);
    $rate_job = moneyformat($line[1] / 100);
    $rate_drop = moneyformat($line[2] / 100);
    if (isset($line[3])) {
        if ($line[3] == 1) {
            $agit_status = "<font color=\"green\">" . $lang['AGIT_ON'] . "</font>";
        } else {
            $agit_status = "<font color=\"red\">" . $lang['AGIT_OFF'] . "</font>";
        }
    }
}
opentable($CONFIG_name);
echo "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\">";
if ($servers & 1) {
    echo "<tr><td align=\"left\"><b>" . $lang['SERVERSTATUS_LOGIN'] . "&nbsp;</b></td><td> <font color=\"green\">" . $lang['SERVERSTATUS_ONLINE'] . "</font></td></td></tr>";
} else {
    echo "<tr><td align=\"left\"><b>" . $lang['SERVERSTATUS_LOGIN'] . "&nbsp;</b></td><td> <font color=\"red\">" . $lang['SERVERSTATUS_OFFLINE'] . "</font></td></td></tr>";
}
Esempio n. 13
0
				<td align="center">&nbsp;</td>
				<td align="left"><b>Nivel de Guild :</b> ' . $guild['guild_lv'] . '</td>
				<td align="center">&nbsp;</td>
				<td align="right"><b>Miembros Actuales :</b> ' . $mysql->countrows($all_members) . '</td>
				<td align="center">&nbsp;</td>
			</tr>
			<tr>
				<td align="center">&nbsp;</td>
				<td align="left"><b>Experiencia :</b> ' . moneyformat($guild['exp']) . '</td>
				<td align="center">&nbsp;</td>
				<td align="right"><b>Cupos Totales :</b> ' . $guild['max_member'] . '</td>
				<td align="center">&nbsp;</td>
			</tr>
			<tr>
				<td align="center">&nbsp;</td>
				<td align="left"><b>Siguiente Lvl :</b> ' . moneyformat($guild['next_exp']) . '</td>
				<td align="center">&nbsp;</td>
				<td align="right"><b>Nivel Promedio :</b> ' . $guild['average_lv'] . '</td>
				<td align="center">&nbsp;</td>
			</tr>
		</table>
	';
// Diplomacia
$diplomacy = $mysql->query("\r\n\t\tSELECT\r\n\t\t\t`guild`.`guild_id`, `guild`.`name`, `guild`.`emblem_data`, `guild_alliance`.`opposition`\r\n\t\tFROM\r\n\t\t\t`guild_alliance` JOIN `guild` ON `guild`.`guild_id` = `guild_alliance`.`alliance_id`\r\n\t\tWHERE\r\n\t\t\t`guild_alliance`.`guild_id` = '{$guild_id}'\r\n\t\tORDER BY\r\n\t\t\t`guild_alliance`.`opposition`\r\n\t", $CONFIG['DBMain']);
$count = $mysql->countrows($diplomacy);
if ($count) {
    echo '
			<table width="550">
				<tr><td align="center" colspan="2" bgcolor="#FFCC00" height="30"><font size="2"><b>Diplomacy</b></font></td></tr>
				<tr>
					<td align="center" width="50%"><font color="blue"><b>Ally</b></font></td>
Esempio n. 14
0
File: board.php Progetto: hdp/brass
function pricelegend($x, $y)
{
    return '<div style="position: absolute; top: ' . $y . 'px; left: ' . $x . 'px; width: 160px; border: 1px solid black"><center><table cellpadding=0 cellspacing=0 border=0><tr><td align=right><font size=2>Canal:&nbsp;</font></td><td><font size=2>' . moneyformat(3) . '</font></td></tr><tr><td align=right><font size=2>Rail:&nbsp;</font></td><td><font size=2>' . moneyformat(5) . ' + ' . transtext('Coal') . '</font></td></tr><tr><td align=right><font size=2>2 &times; Rail:&nbsp</font></td><td><font size=2>' . moneyformat(15) . ' + 2 &times; ' . transtext('Coal') . '</font></td></tr></table></center></div>';
}
Esempio n. 15
0
             apologize("Sale canceled. You can only sell whole shares of " . $row['symbol'] . ", please indicate a positive integer");
         }
         if ($_POST[$row['symbol']] > $number[0]["shares"]) {
             apologize("Sale canceled. Poor you! You don't own enough shares of " . $row['symbol'] . " to sell");
         }
     }
     //if validated we go through and make the purchase
     foreach ($rows as $row) {
         $number = query("SELECT shares FROM portfolio WHERE id = ? AND symbol = ?", $_SESSION["id"], $row['symbol']);
         if (empty($_POST[$row['symbol']])) {
             continue;
         }
         if ($_POST[$row['symbol']] === $number[0]["shares"]) {
             query("DELETE from portfolio WHERE id = ? AND symbol = ?", $_SESSION["id"], $row['symbol']);
             $stock = lookup($row["symbol"]);
             $sale = moneyformat($stock[price] * $_POST[$row['symbol']]);
             query("UPDATE users SET cash = cash+ ? WHERE id = ?", $sale, $_SESSION["id"]);
             query("INSERT INTO history (id, symbol, soldorbought, number, price) VALUES (?, ?, 1, ?, ?)", $_SESSION["id"], $row['symbol'], $_POST[$row['symbol']], $sale);
         } else {
             if ($_POST[$row['symbol']] < $number[0]["shares"]) {
                 $newshares = $number[0]["shares"] - $_POST[$row['symbol']];
                 query("UPDATE portfolio SET shares = ? WHERE id = ? AND symbol = ?", $newshares, $_SESSION["id"], $row['symbol']);
                 $stock = lookup($row["symbol"]);
                 $sale = $stock["price"] * $_POST[$row['symbol']];
                 query("UPDATE users SET cash = cash+ ? WHERE id = ?", $sale, $_SESSION["id"]);
                 query("INSERT INTO history (id, symbol, soldorbought, number, price) VALUES (?, ?, 1, ?, ?)", $_SESSION["id"], $row['symbol'], $_POST[$row['symbol']], $sale);
             }
         }
     }
     redirect("/");
 }
Esempio n. 16
0
     }
     $MoveFormScript .= ' document.getElementById(\'dButtons\').style.display = \'block\';';
     if ($HandSize[$PlayerToMove] < 3) {
         $MoveFormScript .= ' AlterForm();';
     } else {
         $MoveFormScript .= ' document.getElementById(\'dSwapCards\').style.display = \'block\';';
     }
     $MoveFormScript .= ' }';
 } else {
     $NormalMoveForm = 0;
     if ($SecondRailMode) {
         $Height = 230 + 80 * $AlertDisplay;
         if ($Administrator and $MyColour != $PlayerToMove) {
             $Height += 50;
         }
         $MoveForm .= '<p><div style="position: relative; border: 1px solid black; padding: 15px; width: 650px; height: ' . $Height . 'px; background-color: #' . $DivBGCol . '">' . str_replace(array('\\ten', '\\five'), array(moneyformat(10), moneyformat(5)), transtext('mi2ndRailLink')) . '<p><select name="LinkToBuild">';
         for ($i = 0; $i < $NumRailLinks; $i++) {
             if ($LinkStatus[$i] == 9 and ($RailAlwaysExists[$i] or $ModularBoardParts & $RailExistenceArray[$i])) {
                 $MoveForm .= '<option value="' . $i . '">' . $locationnames[$RailStarts[$i]] . ' - ' . $locationnames[$RailEnds[$i]];
             }
         }
         $MoveForm .= '<option value="StopBuilding">' . transtext('miStopBuilding') . '</select>';
         if ($RemainingTiles[5][$PlayerToMove] == 1) {
             $MoveForm .= ' <b>Warning: You have only one rail marker left!</b>';
         } else {
             if ($RemainingTiles[5][$PlayerToMove] < 7) {
                 $MoveForm .= ' <b>Warning: You have only ' . $RemainingTiles[5][$PlayerToMove] . ' rail markers left!</b>';
             }
         }
         $MoveForm .= '<p>' . transtext('miCoalSource') . ' <select name="CoalSource">';
         $havenotprintedselected = 1;