<?
/*
** All Quotes ver 1.2 mach3.php3
** Author: toastboy@mindless.com
** Date: Sept 8 1999
**
** All Quotes steals quotes from quote.com
** without there permission.
** So use this at your own risk and feel
** free to customize it to your liking
**
*/
$symbols = ereg_replace(32, ":", $s) ;
$ticker = split(":", $symbols, 2) ;
$hostname = "mach.quote.com";
$port = 80;
$uri = "/fq/fq_quote.asp?symbols=" ;
$uri .= (Chop($ticker[0])) ;
$uri .= "&symtype=" ;
$uri .= (Chop($symtype)) ;
$uri .= "&mode=" ;
$uri .= (Chop($mode)) ;
$header_passed = 0;
$cache_file = "/tmp/mach.cache";
system("rm -f $cache_file") ;
if($symbols != "") {
if ((!file_exists($cache_file)) ||
(!filesize($cache_file))) {
$fpread = fsockopen("$hostname",
$port, &$errno, &$errstr);
if(!$fpread) {
echo "$errstr ($errno)<br>\n";
} else {
fputs($fpread,"GET $uri HTTP/1.0\n\n");
$fpwrite = fopen($cache_file, "w");
while (!feof($fpread)) {
$page = Chop(fgets($fpread, 1500));
fputs($fpwrite, "$page\r\n");
}
fclose($fpwrite);
}
fclose($fpread);
}
$web_content = fopen($cache_file, "r") ;
function clean(&$inputString) {
$inputString = ereg_replace("\ \;", "", $inputString) ;
$inputString = strip_tags($inputString);
}
while(!feof($web_content)) {
$line = fgets($web_content, 1500) ;
// remove all tabs
$line = ereg_replace(9, "", $line) ;
/*
** Check to see if they can validate the
** symbol first.
**
*/
if(ereg("Unable.*$", $line)){
print "<html>\n";
print "<head>\n\n" ;
print "<title>Delayed Quotes for " ;
print strtoupper($ticker[0]) ;
print " - $company</title>\n" ;
print "</head>\n" ;
print "<body bgcolor=\"#ffffff\">\n" ;
print "<table width=\"780\">\n" ;
print "<tr>\n" ;
print "<td width=\"150\">" ;
print "<form method=post>\n" ;
print "Symbol: <input type=\"text\" name=\"s\" value=$s size=\"8\" maxlength=\"6\">\n" ;
print "</form>" ;
print "</td>\n" ;
print "<td width=\"530\" valign=\"top\">\n";
print "<table width=\"100%\" border=\"0\"" ;
print " cellPadding=\"1\" cellSpacing=\"0\">\n" ;
print " <tr>\n" ;
print "<td colspan=5 bgcolor=\"#eeeeee\">" ;
print "<p><font face=\"Arial,Helvetica,Sans-Serif\"";
print " size=\"2\"><center>\n" ;
print $line ;
print "</font></center></p>\n";
print "</td></tr>" ;
print "</table>\n" ;
print "</table>\n" ;
print "</body>\n</html>" ;
exit ;
}
/*
** Because the +/- comes in a gif
** find the gif and replace with
** proper symbol +/-
*/
// down_arrow now is minus
if(ereg(".*down_arrow.*$", $line))
{
$line = ereg_replace("^\<img
src\=\"images/down\_arrow\.gif\" WIDTH\=10 HEIGHT\=8\>", "-", $line) ;
$change = $line ;
$font_color = "#ff0000" ;
}
// up_arrow now is plus
elseif(ereg(".*up_arrow.*$", $line))
{
$line = ereg_replace("^\<img src\=\"images/up\_arrow\.gif\"
WIDTH\=10 HEIGHT\=8\>", "+", $line) ;
$change = $line ;
$font_color = "#000000" ;
}
// get company name or ticker
// if on the Bulletin Board
if(ereg("^<b>\ \;.*<\/b><\/font><\/td>.*$", $line)){
clean($line) ;
if(ereg(".*\:.*", $line)) # then must be a BB stock
{
$market = split("[\:]", $line,5);
$company = $market[1] ;
} else {
$company = $line;
}
}
// get the trading time
if(ereg("^<b>.*\ \;<\/b><\/font><\/td>.*$", $line)) #then we have a date
{
$trade_time = trim($line) ;
$trade_time = ereg_replace("<b>", "", $trade_time);
$trade_time = ereg_replace("\ \;<\/b><\/font><\/td>", "", $trade_time);
$trade_time = trim($trade_time) ;
}
// get numbers to play with
if(ereg(".*<\/font>\ \;<\/td>.*$", $line))
{
$line = ereg_replace("<\/FONT>", "", $line) ;
$line = ereg_replace("<\/font>\ \;<\/td>", ":", $line) ;
$line = ereg_replace("\ \;", "", $line) ;
$line = ereg_replace(10, "", $line) ;
$bers = ereg_replace(13, "", $line) ;
$new .= $bers ;
}
}
$sentence = split("[\:]", $new, 18) ;
$last_sale = $sentence[0];
$open = $sentence[1];
$change = $sentence[2];
$prev_close = $sentence[3];
$percent_change = $sentence[4];
$week_high = $sentence[5];
$volume = $sentence[6];
$week_low = $sentence[7];
$high = $sentence[8];
$EPS = $sentence[9];
$low = $sentence[10];
$ratio = $sentence[11];
$bid = $sentence[12];
$div_per_share = $sentence[13];
$ask = $sentence[14];
$exchange = $sentence[15];
$last_trade_size = $sentence[16];
$ind = split("\:", $sentence[17],2) ;
$industry = $ind[0] ;
$company = trim($company) ;
/*
** Generate HTML page with output
** values.
*/
print "<html>\n";
print "<head>\n\n" ;
print "<title>Delayed Quotes for " ;
print strtoupper($ticker[0]) ;
print " - $company</title>\n" ;
print "</head>\n" ;
print "<body bgcolor=\"#ffffff\">\n" ;
// start of left hand side
print "<table width=\"780\">\n" ;
print "<tr>\n" ;
print "<td width=\"150\" valign=\"top\">" ;
print "<form method=post>\n" ;
print "Symbol: <input type=\"text\" name=\"s\" value=\"$s\" size=\"8\" maxlength=\"6
\">\n" ;
print "</form>" ;
print "</td>\n" ;
// end left side
print "<td width=\"530\" valign=\"top\">\n" ;
print "<table width=\"100%\" border=\"0\"" ;
print " cellPadding=\"1\" cellSpacing=\"0\">\n" ;
print " <tr>\n" ;
print "<td colspan=3 bgcolor=\"#ffffff\">" ;
print "<font color=\"#413d92\" face=\"Arial,Geneva,Helvetica\"" ;
print " size=\"2\">" ;
print "<b>$company</b></font></td>\n" ;
print "<td colspan=2 bgcolor=\"#ffffff\" align=right>";
print "<font color=\"#413d92\" face=\"Arial,Geneva,Helvetica\"" ;
print "size=\"2\">" ;
print "<b>$trade_time</b></font></td>\n" ;
print "</tr>\n" ;
print "<tr bgcolor=\"#eeeeee\">\n" ;
print "<td width=20%><font FACE=\"Arial,Geneva,Helvetica\"" ;
print " SIZE=\"2\"> Last Sale</font></td>\n" ;
print "<td width=22% align=right><font FACE=\"Arial,Geneva,Helvetica\"";
print " SIZE=\"2\">$last_sale</FONT></font> </td>\n" ;
print "<td width=7%> </td>\n" ;
print "<td width=20%><font FACE=\"Arial,Geneva,Helvetica\"" ;
print " SIZE=\"2\">Open</font></td>\n" ;
print "<td width=31% align=right><font FACE=\"Arial,Geneva,Helvetica\"" ;
print " SIZE=\"2\">$open</FONT></font> </td>\n" ;
print "</tr>\n" ;
print "<tr bgcolor=\"#cccccc\">\n" ;
print "<td><font FACE=\"Arial,Geneva,Helvetica\"";
print " SIZE=\"2\"> Change</font></td>\n" ;
print "<td align=\"right\"><font FACE=\"Arial,Geneva,Helvetica\"";
print " SIZE=\"2\" color=$font_color>$change</font> </td>\n" ;
print "<td> </td>\n" ;
print "<td><font FACE=\"Arial,Geneva,Helvetica\"";
print " SIZE=\"2\">Previous Close</font></td>\n" ;
print "<td align=\"right\"><font FACE=\"Arial,Geneva,Helvetica\"";
print " SIZE=\"2\">$prev_close</FONT></font> </td>\n" ;
print "</tr>\n" ;
print "<tr bgcolor=\"#eeeeee\">\n" ;
print "<td><font FACE=\"Arial,Geneva,Helvetica\"" ;
print " SIZE=\"2\"> % Change</font></td>\n" ;
print "<td align=\"right\"><font FACE=\"Arial,Geneva,Helvetica\"" ;
print " SIZE=\"2\">$percent_change</font> </td>\n" ;
print "<td> </td>\n" ;
print "<td><font FACE=\"Arial,Geneva,Helvetica\"" ;
print " SIZE=\"2\">52 Week High</font></td>\n" ;
print "<td align=\"right\"><font FACE=\"Arial,Geneva,Helvetica\"" ;
print " SIZE=\"2\">$week_high</FONT></font> </td>\n" ;
print "</tr>\n" ;
print "<tr bgcolor=\"#cccccc\">\n" ;
print "<td><font FACE=\"Arial,Geneva,Helvetica\"" ;
print " SIZE=\"2\"> Volume</font></td>\n" ;
print "<td align=\"right\"><font FACE=\"Arial,Geneva,Helvetica\"" ;
print " SIZE=\"2\">$volume</font> </td>\n" ;
print "<td> </td>\n" ;
print "<td><font FACE=\"Arial,Geneva,Helvetica\"" ;
print " SIZE=\"2\">52 Week Low</font></td>\n" ;
print "<td align=\"right\"><font FACE=\"Arial,Geneva,Helvetica\"" ;
print " SIZE=\"2\">$week_low</FONT></font> </td>\n" ;
print "</tr>\n" ;
print "<tr bgcolor=\"#eeeeee\">\n" ;
print "<td><font FACE=\"Arial,Geneva,Helvetica\"" ;
print " SIZE=\"2\"> Today's High</font></td>\n" ;
print "<td align=\"right\"><font FACE=\"Arial,Geneva,Helvetica\"" ;
print " SIZE=\"2\">$high</FONT></font> </td>\n" ;
print "<td> </td>\n" ;
print "<td><font FACE=\"Arial,Geneva,Helvetica\"" ;
print " SIZE=\"2\">EPS</font></td>\n" ;
print "<td align=\"right\"><font FACE=\"Arial,Geneva,Helvetica\"" ;
print " SIZE=\"2\">$EPS</font> </td>\n" ;
print "</tr>\n" ;
print "<tr bgcolor=\"#cccccc\">\n" ;
print "<td><font FACE=\"Arial,Geneva,Helvetica\"" ;
print " SIZE=\"2\"> Today's Low</font></td>\n" ;
print "<td align=\"right\"><font FACE=\"Arial,Geneva,Helvetica\"" ;
print " SIZE=\"2\">$low</FONT></font> </td>\n" ;
print "<td> </td>\n" ;
print "<td><font FACE=\"Arial,Geneva,Helvetica\"" ;
print " SIZE=\"2\">P/E Ratio</font></td>\n" ;
print "<td align=\"right\"><font FACE=\"Arial,Geneva,Helvetica\"" ;
print " SIZE=\"2\">$ratio</font> </td>\n" ;
print "</tr>\n" ;
print "<tr bgcolor=\"#eeeeee\">\n" ;
print "<td><font FACE=\"Arial,Geneva,Helvetica\"" ;
print " SIZE=\"2\"> Bid</font></td>\n" ;
print "<td align=\"right\"><font FACE=\"Arial,Geneva,Helvetica\"" ;
print " SIZE=\"2\">$bid</FONT></font> </td>\n" ;
print "<td> </td>\n" ;
print "<td><font FACE=\"Arial,Geneva,Helvetica\"" ;
print " SIZE=\"2\">Dividend Per Share</font></td>\n" ;
print "<td align=\"right\"><font FACE=\"Arial,Geneva,Helvetica\"" ;
print " SIZE=\"2\">$div_per_share</font> </td>\n" ;
print "</tr>\n" ;
print "<tr bgcolor=\"#cccccc\">\n" ;
print "<td><font FACE=\"Arial,Geneva,Helvetica\"" ;
print " SIZE=\"2\"> Ask</font></td>\n" ;
print "<td align=\"right\"><font FACE=\"Arial,Geneva,Helvetica\"" ;
print " SIZE=\"2\">$ask</FONT></font> </td>\n" ;
print "<td> </td>\n" ;
print "<td><font face=\"Arial,Geneva,Helvetica\"" ;
print " size=\"2\">Exchange</font></td>\n" ;
print "<td align=\"right\"><font FACE=\"Arial,Geneva,Helvetica\"" ;
print " SIZE=\"2\">$exchange</font> </td>\n" ;
print "</tr>\n" ;
print "<tr bgcolor=\"#eeeeee\">\n" ;
print "<td><font FACE=\"Arial,Geneva,Helvetica\"" ;
print " SIZE=\"2\"> Last Trade Size</font></td>\n" ;
print "<td align=\"right\"><font FACE=\"Arial,Geneva,Helvetica\"" ;
print " SIZE=\"2\">$last_trade_size</font> </td>\n" ;
print "<td> </td>\n" ;
print "<td><font FACE=\"Arial,Geneva,Helvetica\"" ;
print " SIZE=\"2\">Industry</font></td>\n" ;
print "<td align=\"right\"><font FACE=\"Arial,Geneva,Helvetica\"" ;
print " SIZE=\"2\">$industry</font> </td>\n" ;
print "</tr>\n" ;
print "</table>\n" ;
print "</body>\n</html>\n" ;
}else {
print "<html>\n";
print "<head>\n\n" ;
print "<title>Delayed Quotes for " ;
print strtoupper($ticker[0]) ;
print " - $company</title>\n" ;
print "</head>\n" ;
print "<body bgcolor=\"#ffffff\">\n" ;
// start of left hand side
print "<table width=\"780\">\n" ;
print "<tr>\n" ;
print "<td width=\"150\">" ;
print "<form method=post>\n" ;
print "Symbol: <input type=\"text\" name=\"s\" value=\"$s\" size=\"8\" maxlength=\"6
\">\n" ;
print "</form>" ;
print "</td>\n" ;
// end left side
// start right side
print "<td width=\"530\" valign=\"top\">\n";
print "<table width=\"100%\" border=\"0\"" ;
print " cellPadding=\"1\" cellSpacing=\"0\">\n" ;
print " <tr>\n" ;
print "<td colspan=5 bgcolor=\"#eeeeee\">" ;
print "<p><font face=\"Arial,Helvetica,Sans-Serif\"";
print " size=\"2\"><center>\n" ;
print "Please enter a stock symbol.<br>\n" ;
print "</font></center></p></td>\n" ;
print "</tr>" ;
print "</table>\n" ;
print "</body>\n</html>" ;
}
?>
phpYellow Pages Standard Categories : PHP , Complete Programs , Databases , Directories , Search Accepts a database & hostname from a user and then HTTP username and password. Uses this to connect to a MySQL database. Produces a form based on the tables it finds there to allow the user to do SELECTs, INSERTs, and DELETEs. Categories : Databases , PHP , MySQL , Complete Programs phpAds, a complete banner and ad management system with detailled tracking and stats. Categories : MySQL , Complete Programs , Ecommerce , PHP , Databases Point and Click Interface ala MS Access for creating SQL statements. Categories : MySQL , Complete Programs , General SQL , PHP , Databases Client classes for Dictionary servers UPDATED: 2000-06-06 Categories : Network , Search , Complete Programs , PHP Classes , PHP Example voting script. Lets people enter suggestions and vote for existing ones. Categories : MySQL , PHP , Cookies , Complete Programs , Databases Functions to access a NNTP/NNRP newsserver. Complete set with examples is at ftp://ftp.nederland.net/pub/nnrplib Categories : Search , PHP , Complete Programs php Free chat simple fast and customizable chat server that uses a simple filesystem for message and nickname storage Categories : PHP , AJAX , XML , Complete Programs A set of functions sitting on top of the abstraction layer that makes it a little easier to do SQL stuff. Documentation is within Categories : Databases , ODBC , Complete Programs , PHP simple shopping cart for php3 Categories : PHP , PHP Classes , Complete Programs , Ecommerce A simple and fast calendar combining PHP and tables. Use this as a base for applications in which a calendar is needed. Categories : Date Time , PHP , Complete Programs , Calendar A simple bubblesort that takes 2 arrays as argument.The first one is the actual data used for sorting, the second is data that will "tag along" with the first array, for instance a descriptive text about the data in the first array. Categories : Algorithms , Arrays , PHP , Complete Programs PHP-MySQL shopping cart
Categories : PHP , Ecommerce , Complete Programs Searches through a local INN server's discussions Categories : Search , Complete Programs , PHP An email validation script that actually checks against the recipient's mail server. Categories : Email , Complete Programs , PHP , Network , Debugging
Andrew Bonar wrote : 143
I downloaded and uploaded it
http://www.necromancer.co.uk/test.asp . It does not
seem to bring any info back.....
Toast Boy wrote : 261
To get a working copy of the script just visit toastboy.com
Click on the Stock Quote Link.
I have had to rewrite the script as quote.com changes their data format often. I have a working version
using Yahoo! feed.