[dev] Patch to Jonah/stockquotes.php
Joe Wilson
joe.wilson at mindcandy.org
Tue Jun 3 05:56:50 PDT 2003
Please use this instead of the diff I sent last night. One typo that I failed
to catch last night.
Joe
-------------- next part --------------
Index: stockquote.php
===================================================================
RCS file: /usr/local/cvs/horde/jonah/stockquote.php,v
retrieving revision 1.11
diff -u -r1.11 stockquote.php
--- stockquote.php 27 Apr 2003 00:32:05 -0000 1.11
+++ stockquote.php 3 Jun 2003 12:51:27 -0000
@@ -1,14 +1,14 @@
<?php
/**
- * $Horde: jonah/stockquote.php,v 1.10 2003/04/27 00:27:40 chuck Exp $
- *
- * Copyright 2002-2003 Eric Rechlin <eric at hpcalc.org>
- *
- * Returns detailed information about the specified ticker symbol.
- *
- * See the enclosed file LICENSE for license information (BSD). If you
- * did not receive this file, see http://cvs.horde.org/co.php/jonah/LICENSE.
- */
+* $Horde: jonah/stockquote.php,v 1.10 2003/04/27 00:27:40 chuck Exp $
+*
+* Copyright 2002-2003 Eric Rechlin <eric at hpcalc.org>
+*
+* Returns detailed information about the specified ticker symbol.
+*
+* See the enclosed file LICENSE for license information (BSD). If you
+* did not receive this file, see http://cvs.horde.org/co.php/jonah/LICENSE.
+*/
define('JONAH_BASE', dirname(__FILE__));
require_once JONAH_BASE . '/lib/base.php';
@@ -20,7 +20,7 @@
$tickerSymbol = Horde::getFormData('ticker');
-require_once JONAH_BASE . '/lib/Stocks/nasdaq.php';
+require_once JONAH_BASE . '/lib/Stocks/yahoo.php';
if (!@is_dir($conf['paths']['data'])) {
$umask = umask(0);
@@ -40,117 +40,115 @@
<?php
if (!empty($tickerSymbol)) {
$tickerSymbol = String::lower($tickerSymbol);
- Jonah::jonahUpdateStock($tickerSymbol);
- $quotes = &new Jonah_Stocks_nasdaq();
-
- $quotes->parse($conf['paths']['data'] . '/stocks/' . $tickerSymbol . '.xml');
+ $quotes = Jonah::jonahUpdateStocks();
echo '<table border="0" cellpadding="1" cellspacing="0" width="100%">';
- if (array_key_exists('name', $quotes->quote)) {
+ if (array_key_exists('name', $quotes[$tickerSymbol])) {
echo '<tr><td class="text" valign="top">';
echo 'Name:</td><td>';
- if (array_key_exists('website', $quotes->quote)) {
- echo '<a href="' . $quotes->quote['website'] . '">';
+ if (array_key_exists('website', $quotes[$tickerSymbol])) {
+ echo '<a href="' . $quotes[$tickerSymbol]['website'] . '">';
}
- echo htmlentities($quotes->quote['name']);
- if (array_key_exists('website', $quotes->quote)) {
+ echo htmlentities($quotes[$tickerSymbol]['name']);
+ if (array_key_exists('website', $quotes[$tickerSymbol])) {
echo '</a>';
}
echo '</td></tr>';
}
- if (array_key_exists('marketCenter', $quotes->quote)) {
+ if (array_key_exists('marketCenter', $quotes[$tickerSymbol])) {
echo '<tr><td class="text" valign="top">';
- echo 'Market Center:</td><td>' . htmlentities($quotes->quote['marketCenter']) . '</td></tr>';
+ echo 'Market Center:</td><td>' . htmlentities($quotes[$tickerSymbol]['marketCenter']) . '</td></tr>';
}
- if (array_key_exists('lastPrice', $quotes->quote)) {
+ if (array_key_exists('lastPrice', $quotes[$tickerSymbol])) {
echo '<tr><td class="text" valign="top">';
- echo 'Last price:</td><td>' . $quotes->quote['lastPrice'] . '</td></tr>';
+ echo 'Last price:</td><td>' . $quotes[$tickerSymbol]['lastPrice'] . '</td></tr>';
}
- if (array_key_exists('changePrice', $quotes->quote)) {
+ if (array_key_exists('changePrice', $quotes[$tickerSymbol])) {
echo '<tr><td class="text" valign="top">';
echo 'Change:</td><td>';
- if ($quotes->quote['changePrice'] > 0) {
+ if ($quotes[$tickerSymbol]['changePrice'] > 0) {
echo '<font color="green">';
- } elseif ($quotes->quote['changePrice'] < 0) {
+ } elseif ($quotes[$tickerSymbol]['changePrice'] < 0) {
echo '<font color="red">';
}
- echo $quotes->quote['changePrice'];
- if ($quotes->quote['changePrice'] != 0) {
+ echo $quotes[$tickerSymbol]['changePrice'];
+ if ($quotes[$tickerSymbol]['changePrice'] != 0) {
echo '</font>';
}
echo '</td></tr>';
}
- if (array_key_exists('changePct', $quotes->quote)) {
+ if (array_key_exists('changePct', $quotes[$tickerSymbol])) {
echo '<tr><td class="text" valign="top">';
echo 'Change %:</td><td>';
- if ($quotes->quote['changePct'] > 0) {
+ if ($quotes[$tickerSymbol]['changePct'] > 0) {
echo '<font color="green">';
- } elseif ($quotes->quote['changePct'] < 0) {
+ } elseif ($quotes[$tickerSymbol]['changePct'] < 0) {
echo '<font color="red">';
}
- echo $quotes->quote['changePct'];
- if ($quotes->quote['changePct'] != 0) {
+ echo $quotes[$tickerSymbol]['changePct'];
+ if ($quotes[$tickerSymbol]['changePct'] != 0) {
echo '</font>';
}
echo '</td></tr>';
}
- if (array_key_exists('high', $quotes->quote)) {
+ if (array_key_exists('high', $quotes[$tickerSymbol])) {
echo '<tr><td class="text" valign="top">';
- echo "Today's high:</td><td>" . $quotes->quote['high'] . '</td></tr>';
+ echo "Today's high:</td><td>" . $quotes[$tickerSymbol]['high'] . '</td></tr>';
}
- if (array_key_exists('low', $quotes->quote)) {
+ if (array_key_exists('low', $quotes[$tickerSymbol])) {
echo '<tr><td class="text" valign="top">';
- echo "Today's low:</td><td>" . $quotes->quote['low'] . '</td></tr>';
+ echo "Today's low:</td><td>" . $quotes[$tickerSymbol]['low'] . '</td></tr>';
}
- if (array_key_exists('yearlyHigh', $quotes->quote)) {
+ if (array_key_exists('yearlyHigh', $quotes[$tickerSymbol])) {
echo '<tr><td class="text" valign="top">';
- echo "52-week high:</td><td>" . $quotes->quote['yearlyHigh'] . '</td></tr>';
+ echo "52-week high:</td><td>" . $quotes[$tickerSymbol]['yearlyHigh'] . '</td></tr>';
}
- if (array_key_exists('yearlyLow', $quotes->quote)) {
+ if (array_key_exists('yearlyLow', $quotes[$tickerSymbol])) {
echo '<tr><td class="text" valign="top">';
- echo "52-week low:</td><td>" . $quotes->quote['yearlyLow'] . '</td></tr>';
+ echo "52-week low:</td><td>" . $quotes[$tickerSymbol]['yearlyLow'] . '</td></tr>';
}
- if (array_key_exists('lastClose', $quotes->quote)) {
+ if (array_key_exists('lastClose', $quotes[$tickerSymbol])) {
echo '<tr><td class="text" valign="top">';
- echo "Previous close:</td><td>" . $quotes->quote['lastClose'] . '</td></tr>';
+ echo "Previous close:</td><td>" . $quotes[$tickerSymbol]['lastClose'] . '</td></tr>';
}
- if (array_key_exists('volume', $quotes->quote)) {
+ if (array_key_exists('volume', $quotes[$tickerSymbol])) {
echo '<tr><td class="text" valign="top">';
- echo "Volume:</td><td>" . number_format($quotes->quote['volume']) . '</td></tr>';
+ echo "Volume:</td><td>" . number_format($quotes[$tickerSymbol]['volume']) . '</td></tr>';
}
- if (array_key_exists('peRatio', $quotes->quote)) {
+ if (array_key_exists('peRatio', $quotes[$tickerSymbol])) {
echo '<tr><td class="text" valign="top">';
- echo "P-E ratio:</td><td>" . $quotes->quote['peRatio'] . '</td></tr>';
+ echo "P-E ratio:</td><td>" . $quotes[$tickerSymbol]['peRatio'] . '</td></tr>';
}
- if (array_key_exists('yieldPct', $quotes->quote)) {
+ if (array_key_exists('yieldPct', $quotes[$tickerSymbol])) {
echo '<tr><td class="text" valign="top">';
- echo "Yield %:</td><td>" . $quotes->quote['yieldPct'] . '</td></tr>';
+ echo "Yield %:</td><td>" . $quotes[$tickerSymbol]['yieldPct'] . '</td></tr>';
}
- if (array_key_exists('earnings', $quotes->quote)) {
+ if (array_key_exists('earnings', $quotes[$tickerSymbol])) {
echo '<tr><td class="text" valign="top">';
- echo "Earnings:</td><td>" . $quotes->quote['earnings'] . '</td></tr>';
+ echo "Earnings:</td><td>" . $quotes[$tickerSymbol]['earnings'] . '</td></tr>';
}
- if (array_key_exists('dividendAmt', $quotes->quote)) {
+ if (array_key_exists('dividendAmt', $quotes[$tickerSymbol])) {
echo '<tr><td class="text" valign="top">';
- echo "Last dividend:</td><td>" . $quotes->quote['dividendAmt'] . '</td></tr>';
+ echo "Last dividend:</td><td>" . $quotes[$tickerSymbol]['dividendAmt'] . '</td></tr>';
}
- if (array_key_exists('dividendDate', $quotes->quote)) {
- if ($quotes->quote['dividendDate'] > 19700000) {
+ if (array_key_exists('dividendDate', $quotes[$tickerSymbol])) {
+ if ($quotes[$tickerSymbol]['dividendDate'] > 19700000) {
echo '<tr><td class="text" valign="top">';
- echo "Last dividend date:</td><td>" . $quotes->quote['dividendDate'] . '</td></tr>';
+ echo "Last dividend date:</td><td>" . $quotes[$tickerSymbol]['dividendDate'] . '</td></tr>';
}
}
- if (array_key_exists('sp500Beta', $quotes->quote)) {
+ if (array_key_exists('sp500Beta', $quotes[$tickerSymbol])) {
echo '<tr><td class="text" valign="top">';
- echo "S&P 500 beta:</td><td>" . $quotes->quote['sp500Beta'] . '</td></tr>';
+ echo "S&P 500 beta:</td><td>" . $quotes[$tickerSymbol]['sp500Beta'] . '</td></tr>';
}
- if (array_key_exists('tradeDate', $quotes->quote)) {
+ if (array_key_exists('tradeDate', $quotes[$tickerSymbol])) {
echo '<tr><td class="text" valign="top">';
- echo "Quote date:</td><td>" . $quotes->quote['tradeDate'] . '</td></tr>';
+ echo "Quote date:</td><td>" . $quotes[$tickerSymbol]['tradeDate'] . '</td></tr>';
}
- if (array_key_exists('marketCap', $quotes->quote)) {
+ if (array_key_exists('marketCap', $quotes[$tickerSymbol])) {
echo '<tr><td class="text" valign="top">';
- echo "Market cap:</td><td>" . number_format($quotes->quote['marketCap']) . '</td></tr>';
+// echo "Market cap:</td><td>" . number_format($quotes[$tickerSymbol]['marketCap']) . '</td></tr>';
+ echo "Market cap:</td><td>" . $quotes[$tickerSymbol]['marketCap'] . '</td></tr>';
}
/* We're done -- now clean up. */
@@ -161,3 +159,4 @@
echo '</td></tr></table>';
require JONAH_TEMPLATES . '/common-footer.inc';
+
More information about the dev
mailing list