Revision: 6088
Updated Code
at April 26, 2008 20:36 by mandric
Updated Code
<?php
/*
Requires an .htaccess file that rewrites the request to q=, like,
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
Now tha I look at it, not sure why I just didn't explode $_REQUEST_URI.
*/
$debug = 1;
$q = explode('/', $_REQUEST['q']);
$module = $q[0];
$op = $q[1];
$debug ? '<pre>'.print_r($q).'</pre>' : '';
$source = 'http://finance.yahoo.com/d/quotes.csv?s=';
$nyse_source = 'http://www.csidata.com/factsheets/nyse.txt';
$nyse_index = 'nyse_index.txt';
$nyse_index_path = $files.$nyse_index;
$files_dir = './files/';
$include_dir = './include/';
$module_path = $include_dir.$module.'.inc';
switch ($module) {
case 'fields':
include $module_path;
//$csvdata = get data for $q[1];
break;
case 'nyse':
include $module_path;
if ($op == 'refresh') {
$new_index = nyse_fetch();
$ret = nyse_compare($new_index);
print $ret;
}
elseif ($op == 'load') {
$ret = nyse_load_db();
print $ret;
}
else {
// for now just redirect
header('Location: http://www.xyz.com/api/files/'.$nyse_index);
// in the future print header and read text file
//nyse_send_index();
}
break;
} //close switch
echo 'hello';
?>
Revision: 6087
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at April 26, 2008 16:30 by mandric
Initial Code
<?php
$debug = 1;
$q = explode('/', $_REQUEST['q']);
$module = $q[0];
$op = $q[1];
$debug ? '<pre>'.print_r($q).'</pre>' : '';
$source = 'http://finance.yahoo.com/d/quotes.csv?s=';
$nyse_source = 'http://www.csidata.com/factsheets/nyse.txt';
$nyse_index = 'nyse_index.txt';
$nyse_index_path = $files.$nyse_index;
$files_dir = './files/';
$include_dir = './include/';
$module_path = $include_dir.$module.'.inc';
switch ($module) {
case 'fields':
include $module_path;
//$csvdata = get data for $q[1];
break;
case 'nyse':
include $module_path;
if ($op == 'refresh') {
$new_index = nyse_fetch();
$ret = nyse_compare($new_index);
print $ret;
}
elseif ($op == 'load') {
$ret = nyse_load_db();
print $ret;
}
else {
// for now just redirect
header('Location: http://www.xyz.com/api/files/'.$nyse_index);
// in the future print header and read text file
//nyse_send_index();
}
break;
} //close switch
echo 'hello';
?>
Initial URL
Initial Description
Very minimal. Some homegrown API seeds from a while ago. Just posting for use as some php examples.
Initial Title
Minimal PHP Controller URL dispatch
Initial Tags
url, php
Initial Language
PHP