/onorder-test.php

https://github.com/tmacon/test_myrcpl · PHP · 78 lines · 30 code · 17 blank · 31 comment · 2 complexity · a2628d8e270ecbe6c59322e96b8b2e6c MD5 · raw file

  1. <?php
  2. require('sycom.inc');
  3. require('feedcreator.class.php');
  4. # RSS file name
  5. define('RSS_FILENAME', 'onorder-test');
  6. # get today's date in correct format for query
  7. $ret_date = strftime('%e %B %Y', time());
  8. # date function
  9. $date_string = gmstrftime('%Y-%m-%dT%T-08:00', gmmktime());
  10. # end date function
  11. $rss = new UniversalFeedCreator();
  12. # Prep the RSS.
  13. $rss->title = 'Most recently ordered items at the Richland County Public Library';
  14. $rss->description = 'Most recently ordered items for our collection. Some items show duplicates because they have more than one isbn number. Click on a title to place a hold request on that item.';
  15. $rss->link = 'http://www.myrcpl.com';
  16. $rss->lastBuildDate = $date_string;
  17. $rss->pubDate = $date_string;
  18. $rss->copyright = 'Copyright 2009-2011, Richland County Public Library';
  19. /* These options are not supported by RSS 0.92
  20. syn => {
  21. updatePeriod => "daily",
  22. updateFrequency => "1",
  23. updateBase => "2005-11-21T12:00:00+00:00",
  24. }
  25. */
  26. # RSS feed image
  27. /*$image = new FeedImage();
  28. $image->title = 'Book Feed';
  29. $image->url = 'http://www.ylpl.lib.ca.us/images/bookfeed.gif';
  30. $image->link = 'http://hip.richland.lib.sc.us/ipac20/ipac.jsp';
  31. $image->width = 88;
  32. $image->height = 15;
  33. $rss->image = $image;
  34. */
  35. # Database query
  36. sycom('SET ROWCOUNT 150');
  37. $sdbh = sycom("select distinct a15.title title, a11.author author, a14.processed processed, a12.creation_date creation_day, a13.collection collection, a16.descr descr
  38. from rv_bib_author a11, rv_bib_control a12, rv_item a13, rv_isbn a14, rv_title_inverted a15, collection a16 where a11.bib_id = a12.bib_id and a11.bib_id = a13.bib_id and a11.bib_id = a14.bib_id and a11.bib_id = a15.bib_id and a13.collection = a16.collection and (a13.collection in ('le')and (a14.processed IS NOT NULL) and a12.creation_date between '03/01/2009' and '05/30/2019') order by a12.creation_date desc");
  39. if($sdbh != NULL)
  40. {
  41. while($srow = sybase_fetch_array($sdbh))
  42. {var_dump($srow);
  43. # Replace '&' characters with '&amp;'
  44. /*$srow = str_replace('&', '&amp;', $srow);*/
  45. /*foreach($srow as $scolumn)
  46. {
  47. # Remove non-text characters
  48. $scolumn = preg_replace('/\x1f[a-z]|\x1e/', '', $scolumn);
  49. $scolumn = preg_replace('/[\x00-\x1F\x80-\xFF]/', '', $scolumn);
  50. } */
  51. $srow[0] = preg_replace('/\x1f[a-z]|\x1e/', '', $srow[0]);
  52. $item = new FeedItem();
  53. $item->title = $srow[0];
  54. $item->link = ' http://hip.richland.lib.sc.us/ipac20/ipac.jsp?&index=ISBNEX&term=' . trim($srow[2]).'&profile=int';
  55. $item->description = $srow[1]. ' &nbsp;&nbsp;<i>' . $srow[5] .'</i> &nbsp;&nbsp; Ordered on-' . substr($srow[3], '0', '6') ;
  56. $rss->addItem($item);
  57. }
  58. }
  59. $rss->saveFeed('RSS0.92', RSS_FILENAME . '.rss');
  60. ?>