Created
February 25, 2010 01:56
-
-
Save artlung/314130 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
php_value allow_url_fopen on |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/******************************************************************** | |
* * | |
* Function pulls stock information from the symex belgium website, * | |
* which is where the Schneider Electric Website gets its data * | |
* * | |
* Added 2008-09-04 Joe Crawford * | |
* * | |
********************************************************************/ | |
function stockTickerRevised() | |
{ | |
define(DEFAULT_STOCK_VAL,0); | |
$citation_url = "http://www.schneider-electric.com/sites/corporate/en/finance/general-informations/share-price/share-price.page"; | |
$url = "http://su.symexbelgium.com/new2/finance.html?Language=en"; | |
$schneider_price_page = ""; | |
$schneider_price_page = @file_get_contents($url); | |
if(!$schneider_price_page){ | |
$outstring =<<<ERROR_STOCK | |
<div id="stockquote" class="lcol_widget"> | |
<h3>SCHNEIDER ELECTRIC</h3> | |
<p> | |
Error loading ticker information from | |
<a href="{$citation_url}">Schneider Electric</a>. | |
</p> | |
</div> | |
ERROR_STOCK; | |
} else { | |
$doc = new DOMDocument(); | |
@$doc->loadHTML($schneider_price_page); | |
// key's in this array will be grabbed from the DOM of the html source | |
$values = array( | |
'close' => DEFAULT_STOCK_VAL, | |
'var_veille' => DEFAULT_STOCK_VAL, | |
'veille' => DEFAULT_STOCK_VAL, | |
'high' => DEFAULT_STOCK_VAL, | |
'low' => DEFAULT_STOCK_VAL, | |
'close_cac' => ( DEFAULT_STOCK_VAL . ' Points') | |
); | |
foreach($values as $key => $value) | |
{ | |
$values[$key] = trim($doc->getElementById($key)->nodeValue); | |
// $values[$key] = DEFAULT_STOCK_VAL; | |
} | |
$values['calculated_change'] = $values['close']-$values['veille']; | |
$values['close_cac'] = number_format(str_replace(' ','',$values['close_cac']),2,'.',',') . ' Points'; | |
$currency_symbol = "€"; | |
if($values['veille'] > $values['close']) | |
{ | |
//down | |
$arrow = "↓"; //downarrow | |
$color = "#cc0000"; | |
} elseif ($values['veille'] == $values['close']) { | |
// same | |
$arrow = "↔"; //leftrightarrow | |
$color = "#000000"; | |
} elseif($values['veille'] < $values['close']) { | |
// up | |
$arrow = "↑"; //uparrow | |
$color = "green"; | |
} else { | |
$arrow = "?"; | |
$color = "#cccccc"; | |
} | |
$outstring =<<<HERESTRING | |
<div id="stockquote" class="lcol_widget"> | |
<h3>SCHNEIDER ELECTRIC</h3> | |
<p> | |
<b>{$currency_symbol}</b><big><b>{$values['close']}</b></big> | |
<b style="color:{$color};"> | |
{$arrow} {$values['calculated_change']} | |
({$values['var_veille']}%) | |
</b><br /> | |
<b style="color:#666666">CAC 40 Index: {$values['close_cac']}</b><br /> | |
<small><a href="$citation_url" style="color: #cccccc;text-decoration: none;">[source]</a></small></p> | |
</div><!--stockquote ends--> | |
HERESTRING; | |
} | |
print $outstring; | |
} // end function stockTickerRevised | |
stockTickerRevised(); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment