PageRenderTime 26ms CodeModel.GetById 27ms RepoModel.GetById 0ms app.codeStats 0ms

/index.php

https://github.com/zachleat/Parlour
PHP | 61 lines | 56 code | 3 blank | 2 comment | 2 complexity | 603c8a9c24d27ae5c130a4b4448bf675 MD5 | raw file
  1. <?php
  2. include_once('config.php');
  3. include_once('Zend/Service/Flickr.php');
  4. $flickr = new Zend_Service_Flickr(PARLOUR_FLICKR_API_KEY);
  5. ?><!doctype html>
  6. <html>
  7. <head>
  8. <title><?php echo PARLOUR_PAGE_TITLE; ?></title>
  9. <link type="text/css" rel="stylesheet" href="index.css"></link>
  10. </head>
  11. <body>
  12. <div id="album" class="ui-helper-clearfix">
  13. <div id="title">
  14. <?php echo PARLOUR_PAGE_TITLE; ?>
  15. </div>
  16. <?php
  17. $fileName = PARLOUR_CACHE_FILE;
  18. try {
  19. $modificationDifference = time() - filemtime($fileName);
  20. echo '<!-- Time since last modification: ' . $modificationDifference . ' out of ' . PARLOUR_MAX_CACHE_TIME . '-->';
  21. if($modificationDifference < PARLOUR_MAX_CACHE_TIME) { // 24 hours
  22. include $fileName;
  23. } else {
  24. //$results = $flickr->userSearch('user@example.com', array('per_page' => PARLOUR_MAX_IMAGES));
  25. //$results = $flickr->tagSearch('sometag', array('per_page' => PARLOUR_MAX_IMAGES));
  26. $results = $flickr->groupPoolGetPhotos(PARLOUR_FLICKR_POOL_ID, array('per_page' => PARLOUR_MAX_IMAGES));
  27. ob_start();
  28. echo '<!-- dynamically generated -->';
  29. foreach ($results as $result) {
  30. $small = $result->Small;
  31. $large = $result->Large;
  32. ?>
  33. <div class="frame" name="<?php echo $result->id; ?>" fullscreen-photo="<?php echo $large->uri; ?>" fullscreen-width="<?php echo $large->width; ?>" fullscreen-height="<?php echo $large->height; ?>">
  34. <div class="border">
  35. <div class="photo">
  36. <a href="http://www.flickr.com/photos/<?php echo $result->owner . '/' . $result->id; ?>"><img src="<?php echo $small->uri; ?>" style="width: <?php echo $small->width; ?>px; height: <?php echo $small->height; ?>px;"/></a>
  37. </div>
  38. <div class="label"><?php echo $result->title; ?></div>
  39. </div>
  40. </div>
  41. <?php
  42. }
  43. $content = ob_get_contents();
  44. ob_end_flush();
  45. file_put_contents($fileName, $content);
  46. }
  47. } catch(Exception $e) {
  48. include $fileName;
  49. echo '<!-- There was an error fetching the content, using the cached version. -->';
  50. }
  51. ?>
  52. </div>
  53. <div id="previous" class="arrow">&lt;</div>
  54. <div id="next" class="arrow">&gt;</div>
  55. <script src="http://www.google.com/jsapi" type="text/javascript"></script>
  56. <script src="index.js" type="text/javascript"></script>
  57. </body>
  58. </html>