topical media & game development

talk show tell print

professional-web-01-v4-index.php / php



  <?php 
  //require_once ('html.inc');
  require_once ('db.inc');
  require_once ('cache.inc');
  require_once ('yahoo_quotes.inc');
  require_once ('yahoo_finance_news.inc');
  require_once ('delicious.inc');
  require_once ('watch.inc');
  
  global document;
  
  function appendDocument(document, xml){
    fragment = new DOMDocument();
    fragment->loadXML(xml);
    importedFragment = document->importNode(fragment->documentElement, true);
    document->documentElement->appendChild(importedFragment);
  }
  
  db=openDb();
  query = queryOneWatch(db);
  watchRow = query->fetch(SQLITE_ASSOC);
  
  document = new DOMDocument();
  root = document->createElement("root");
  document->appendChild(root);
  appendDocument(
    document,
    getAllWatches(db)
    );
  if (watchRow) {
  appendDocument(
    document,
    getAWatch(db, _GET['name'])
    );
  appendDocument(
    document,
    get_cached_data(
      getUrlQuotes(watchRow['symbol']), 
      get_quotes_as_xml, 
      YAHOOFINANCE_QUOTES_LIFETIME
      )
    );
  appendDocument(
    document,
    get_cached_data(
      getUrlFinancialNews(watchRow['symbol']), 
      defaultCacheGet, 
      YAHOOFINANCE_NEWS_LIFETIME
      )
    );
  appendDocument(
    document,
    get_cached_data(
      getUrlDelicious(watchRow['tag']), 
      defaultCacheGet, 
      DELICIOUS_LIFETIME
      )
    );
  }
  if (_GET['format'] == 'xml') {
    header("Cache-Control: max-age=60");
    header("Content-type: application/xml");
    print document->saveXML();
    exit;
  }
  
  xsltSource = new DOMDocument();
  xsltProc = new XSLTProcessor();
  
  xsltSource->load('format.xsl');
  xsltProc->importStyleSheet(xsltSource);
  
  header("Cache-Control: max-age=60");
  header("Content-type: text/html");
  print xsltProc->transformToXML(document);
  
  ?>
  


(C) Æliens 20/2/2008

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.