redirect.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <?php
  2. /**
  3. * <https://y.st./>
  4. * Copyright (C) 2015-2016 y.st. <mailto:copyright@y.st>
  5. *
  6. * This program is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org./licenses/>.
  18. **/
  19. // Older research, now generalized
  20. foreach(array(
  21. 'ccTLDs' => 'ccTLDs',
  22. 'index' => 'best_ccTLDs',
  23. 'special-use' => 'special-use_domains',
  24. 'usable_ccTLDs' => 'usable_ccTLDs',
  25. ) as $key => $value):
  26. $moved["en/domain_research/$key.xhtml"] = "en/URI_research/$value.xhtml";
  27. endforeach;
  28. // Moved directories
  29. foreach(array(
  30. 'weblog/',
  31. 'weblog/2015/',
  32. 'weblog/2015/03-March/',
  33. 'weblog/2015/04-April/',
  34. 'weblog/2015/05-May/',
  35. 'weblog/2015/06-June/',
  36. 'weblog/2015/07-July/',
  37. ) as $value):
  38. $moved[$value.'index.xhtml'] = 'en/'.$value.'index.xhtml';
  39. endforeach;
  40. // Non-weblog files that were moved
  41. foreach(array(
  42. 'a/contact.xhtml',
  43. 'a/hall_of_shame.xhtml',
  44. ) as $value):
  45. $moved[$value] = 'en/'.$value;
  46. endforeach;
  47. // March
  48. for($i=7;$i<=31;$i++):
  49. $value = 'weblog/2015/03-March/'.sprintf('%02d', $i).'.xhtml';
  50. $moved[$value] = 'en/'.$value;
  51. endfor;
  52. // April
  53. for($i=1;$i<=30;$i++):
  54. $value = 'weblog/2015/04-April/'.sprintf('%02d', $i).'.xhtml';
  55. $moved[$value] = 'en/'.$value;
  56. endfor;
  57. // May
  58. for($i=1;$i<=31;$i++):
  59. $value = 'weblog/2015/05-May/'.sprintf('%02d', $i).'.xhtml';
  60. $moved[$value] = 'en/'.$value;
  61. endfor;
  62. // June
  63. for($i=1;$i<=30;$i++):
  64. $value = 'weblog/2015/06-June/'.sprintf('%02d', $i).'.xhtml';
  65. $moved[$value] = 'en/'.$value;
  66. endfor;
  67. // Beginning of July
  68. for($i=1;$i<=22;$i++):
  69. $value = 'weblog/2015/07-July/'.sprintf('%02d', $i).'.xhtml';
  70. $moved[$value] = 'en/'.$value;
  71. endfor;
  72. // Generate redirect files
  73. foreach($moved as $key => $value):
  74. if($value):
  75. $xhtml = array(
  76. 'title' => 'Sorry, we moved that file!',
  77. 'copyright year' => '2015-2016',
  78. 'body' => <<<END
  79. <p>Sorry, we moved that file. But we know where it is!</p>
  80. <p>The page has been moved to <a href="/$value">/$value</a>.</p>
  81. END
  82. );
  83. else:
  84. $xhtml = array(
  85. 'title' => 'Sorry, that page has been deleted!',
  86. 'copyright year' => '2015-2016',
  87. 'body' => <<<END
  88. <p>We apologize, but this page had to be deleted. An effort was made to make this website more professional-looking, and this page was deemed to be too personal in nature.</p>
  89. END
  90. );
  91. endif;
  92. $¢_build_page($key, $xhtml);
  93. endforeach;