PageRenderTime 54ms CodeModel.GetById 28ms RepoModel.GetById 1ms app.codeStats 0ms

/calendar/Admin/flush.php

https://github.com/convissor/calendar_solution
PHP | 80 lines | 47 code | 14 blank | 19 comment | 11 complexity | 09df8994d85d4a29dcb771138b460529 MD5 | raw file
  1. <?php
  2. // LEAVE THIS STUFF AT THE TOP ALONE ..........................
  3. /**
  4. * The means to flush the Calendar Solution's cache
  5. *
  6. * @package CalendarSolution
  7. */
  8. /**
  9. * Obtain the Calendar Solution's settings and autoload function
  10. *
  11. * @internal Uses dirname(__FILE__) because "./" can be stripped by PHP's
  12. * safety settings and __DIR__ was introduced in PHP 5.3.
  13. */
  14. require dirname(__FILE__) . '/../../include/calendar_solution_settings.php';
  15. /*
  16. * Instantiate the calendar class appropriate for the view the user wants.
  17. */
  18. try {
  19. $calendar = new CalendarSolution;
  20. } catch (Exception $e) {
  21. die('EXCEPTION: ' . $e->getMessage());
  22. }
  23. // BEGIN YOUR PAGE SPECIFIC LAYOUT BELOW HERE ..................
  24. ?>
  25. <html>
  26. <head>
  27. <title>Calendar Solution Cache Flusher</title>
  28. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  29. <link rel="stylesheet" type="text/css" href="admin.css" />
  30. </head>
  31. <body>
  32. <?php
  33. echo $calendar->get_admin_navigation();
  34. /*
  35. * Display the calendar.
  36. */
  37. try {
  38. if ($calendar->is_cache_available()) {
  39. if (!empty($_POST['proceed'])
  40. || (!empty($_SERVER['argv'][1]) && $_SERVER['argv'][1] == 'proceed'))
  41. {
  42. if ($calendar->flush_cache()) {
  43. echo '<p>The cache has been flushed.</p>';
  44. if (!empty($_SERVER['argv'][1])) {
  45. exit(0);
  46. }
  47. } else {
  48. echo '<p>Hmm... There were problems flushing the cache.</p>';
  49. if (!empty($_SERVER['argv'][1])) {
  50. exit(1);
  51. }
  52. }
  53. } else {
  54. echo '<form method="post">';
  55. echo '<input type="submit" name="proceed" value="Flush Cache" />';
  56. echo '</form>';
  57. }
  58. } else {
  59. echo '<p>Caching is not available on this installation.</p>';
  60. }
  61. } catch (Exception $e) {
  62. die('EXCEPTION: ' . $e->getMessage());
  63. }
  64. ?>
  65. </body>
  66. </html>