variables.php 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495
  1. <?php
  2. /**
  3. * <https://y.st./>
  4. * Copyright © 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 <https://www.gnu.org./licenses/>.
  18. **/
  19. /**
  20. * It got to be too difficult keeping track of variable names
  21. * throughout this website's source code to prevent variable name
  22. * clashes. All variables are either declared in this file now or have
  23. * names that are reserved by the comments in this file. That way, new
  24. * variable names need only be checked against the variable names from
  25. * this file instead of checked against variable names from every file
  26. * of this project.
  27. **/
  28. use st\y\abbr, st\y\day_number;
  29. // Objects:
  30. $a = abbr::construct_from_file(__DIR__.'/abbr.txt');
  31. $entry = new day_number(2015, 3, 7);
  32. // In-string alias:
  33. $syntax = '\\st\\y\\highlight_string';
  34. // Please note that for signatures to be effective, I cannot give you my key.
  35. // If you want to compile the site on your own machine, you will need to edit the PGP lines here.
  36. $pgp = new gnupg;
  37. $pgp->addsignkey('D135B061DBED690B479FE2E37D83E1E5E7464A03');
  38. // These intervals are used in the navigation menus.
  39. $interval = array(
  40. 'year' => new DateInterval('P1Y'),
  41. 'month' => new DateInterval('P1M'),
  42. 'day' => new DateInterval('P1D'),
  43. );
  44. // When compiling the weblog navigation, it would be helpful to know when the latest entry is.
  45. $latest_entry = array(
  46. 'year' => '',
  47. 'month' => '',
  48. 'day' => '',
  49. );
  50. foreach(scandir(__DIR__.'/pages/en/weblog') as $year):
  51. if($year > $latest_entry['year']):
  52. $latest_entry['year'] = $year;
  53. endif;
  54. endforeach;
  55. foreach(scandir(__DIR__."/pages/en/weblog/$latest_entry[year]") as $month):
  56. if($month > $latest_entry['month']):
  57. $latest_entry['month'] = $month;
  58. endif;
  59. endforeach;
  60. foreach(scandir(__DIR__."/pages/en/weblog/$latest_entry[year]/$latest_entry[month]") as $day):
  61. if($day > $latest_entry['day']):
  62. $latest_entry['day'] = $day;
  63. endif;
  64. endforeach;
  65. $latest_copyright_year = $latest_entry['year'];
  66. $latest_entry = array(
  67. 'year' => "/en/weblog/$latest_entry[year]/",
  68. 'month' => "/en/weblog/$latest_entry[year]/$latest_entry[month]/",
  69. 'day' => "/en/weblog/$latest_entry[year]/$latest_entry[month]/$latest_entry[day]",
  70. );
  71. // This is just to catch invalid arguments
  72. $valid_arguments = array(
  73. '--canary',
  74. );
  75. foreach($argv as $key => $value):
  76. // The "and $key" part prevents the script from treating the file name as an invalid argument.
  77. // $argv[0] will always be the file name and 0 evaluates to false.
  78. if(!in_array($value, $valid_arguments) and $key):
  79. $invalid_arguments[] = $value;
  80. endif;
  81. endforeach;
  82. // This array includes the names of all files that should not be
  83. // deleted from the compiled version of the website. Any page that
  84. // still has source code should have an entry in this array. If a page
  85. // is removed from the source code, it shouldn't be added to this array
  86. // during compilation time, which will result in that page being
  87. // removed from the compiled version. That way, we can recompile the
  88. // website without keeping pages that should be removed and without
  89. // erasing all already-compiled pages from disk before compiling them
  90. // if their source code hasn't been modified.
  91. $should_exist = array();
  92. // Used by the ASCII calendar pages:
  93. $months = array(
  94. 1 => '01-January',
  95. 2 => '02-February',
  96. 3 => '03-March',
  97. 4 => '04-April',
  98. 5 => '05-May',
  99. 6 => '06-June',
  100. 7 => '07-July',
  101. 8 => '08-August',
  102. 9 => '09-September',
  103. 10 => '10-October',
  104. 11 => '11-November',
  105. 12 => '12-December',
  106. );
  107. $monthheads = array(
  108. 1 => ' January',
  109. 2 => ' February',
  110. 3 => ' March',
  111. 4 => ' April',
  112. 5 => ' May',
  113. 6 => ' June',
  114. 7 => ' July',
  115. 8 => ' August',
  116. 9 => 'September',
  117. 10 => ' October',
  118. 11 => ' November',
  119. 12 => ' December',
  120. );
  121. // Previously, when I added new assignment submissions to my list of
  122. // coursework, I had to manually update both the coursework index and
  123. // the navigation menu of the course that the assignment was for. With
  124. // this array, I can now instead only update in one place instead of
  125. // two.
  126. $coursework = array(
  127. 'BUS1101' => array(
  128. 'title' => 'BUS 1101: Principles of Business Management',
  129. 'subtitle' => "<span title=\"{$entry(2016, 11, 10)}\">2016-11-10</span> to <span title=\"{$entry(2017, 1, 11)}\">2017-01-11</span>",
  130. 'assignments' => array(
  131. 'Leadership_Entrepreneurship_and_Strategy' => array(
  132. 'title' => 'Leadership, Entrepreneurship, and Strategy',
  133. 'unit' => '1',
  134. ),
  135. 'Behavior_management_at_the_SAS_Institute' => array(
  136. 'title' => 'Behavior management at the SAS Institute',
  137. 'unit' => '2',
  138. ),
  139. 'How_Coca-Cola_should_deal_with_globalization' => array(
  140. 'title' => 'How Coca-Cola should deal with globalization',
  141. 'unit' => '3',
  142. ),
  143. 'SCAMPER' => array(
  144. 'title' => 'SCAMPER',
  145. 'unit' => '4',
  146. ),
  147. 'Strengths_weaknesses_opportunities_and_threats' => array(
  148. 'title' => 'Strengths, weaknesses, opportunities, and threats',
  149. 'unit' => '5',
  150. ),
  151. 'Microsoft_and_corporate_social_responsibility' => array(
  152. 'title' => 'Microsoft and corporate social responsibility',
  153. 'unit' => '6',
  154. ),
  155. 'Three_types_of_organizational_structures' => array(
  156. 'title' => 'Three types of organizational structures',
  157. 'unit' => '7',
  158. ),
  159. 'Little_Caesars_culture' => array(
  160. 'title' => 'Little Caesars culture',
  161. 'unit' => '8',
  162. ),
  163. ),
  164. ),
  165. 'CS1101' => array(
  166. 'title' => 'CS 1101: Programming Fundamentals',
  167. 'subtitle' => "<span title=\"{$entry(2017, 1, 26)}\">2017-01-26</span> to <span title=\"{$entry(2017, 3, 29)}\">2017-03-29</span>",
  168. 'assignments' => array(
  169. 't_area.py' => array(
  170. 'title' => 't_area.py',
  171. 'unit' => '2',
  172. ),
  173. 'calculator_flowchart' => array(
  174. 'title' => 'calculator flowchart',
  175. 'unit' => '3',
  176. ),
  177. 'tryme3.py' => array(
  178. 'title' => 'tryme3.py',
  179. 'unit' => '4',
  180. ),
  181. 'mycalc.py' => array(
  182. 'title' => 'mycalc.py',
  183. 'unit' => '5',
  184. ),
  185. 'bool.py' => array(
  186. 'title' => 'bool.py',
  187. 'unit' => '6',
  188. ),
  189. 'sort_fruits.py' => array(
  190. 'title' => 'sort_fruits.py',
  191. 'unit' => '7',
  192. ),
  193. ),
  194. ),
  195. 'CS1102' => array(
  196. 'title' => 'CS 1102: Programming 1',
  197. 'subtitle' => "<span title=\"{$entry(2017, 4, 6)}\">2017-04-06</span> to <span title=\"{$entry(2017, 6, 7)}\">2017-06-07</span>",
  198. 'assignments' => array(
  199. 'GravityCalculator.java' => array(
  200. 'title' => 'GravityCalculator.java',
  201. 'unit' => '1',
  202. ),
  203. 'SnakeEyesCount.java' => array(
  204. 'title' => 'SnakeEyesCount.java',
  205. 'unit' => '2',
  206. ),
  207. 'Unit3.java' => array(
  208. 'title' => 'Unit3.java',
  209. 'unit' => '3',
  210. ),
  211. 'firstsubroutines.java' => array(
  212. 'title' => 'firstsubroutines.java',
  213. 'unit' => '4',
  214. ),
  215. 'Unit5.java' => array(
  216. 'title' => 'Unit5.java',
  217. 'unit' => '5',
  218. ),
  219. 'payrollsystem' => array(
  220. 'title' => 'package payrollsystem;',
  221. 'unit' => '7',
  222. ),
  223. 'matchbox' => array(
  224. 'title' => 'package matchbox;',
  225. 'unit' => '6',
  226. ),
  227. 'Unit7.java' => array(
  228. 'title' => 'Unit7.java',
  229. 'unit' => '7',
  230. ),
  231. ),
  232. ),
  233. 'CS1103' => array(
  234. 'title' => 'CS 1103: Programming 2',
  235. 'subtitle' => "<span title=\"{$entry(2017, 6, 15)}\">2017-06-15</span> to <span title=\"{$entry(2017, 8, 16)}\">2017-08-16</span>",
  236. 'assignments' => array(
  237. 'Unit1.java' => array(
  238. 'title' => 'Unit1.java',
  239. 'unit' => '1',
  240. ),
  241. 'SimpleRandomSentences.java' => array(
  242. 'title' => 'SimpleRandomSentences.java',
  243. 'unit' => '2',
  244. ),
  245. 'Tape.java' => array(
  246. 'title' => 'Tape.java',
  247. 'unit' => '3',
  248. ),
  249. 'Debugging' => array(
  250. 'title' => 'Debugging',
  251. 'unit' => '4',
  252. ),
  253. 'Unit5.java' => array(
  254. 'title' => 'Unit5.java',
  255. 'unit' => '5',
  256. ),
  257. 'DrawTextPanel.java' => array(
  258. 'title' => 'DrawTextPanel.java',
  259. 'unit' => '6',
  260. ),
  261. 'Unit7.java' => array(
  262. 'title' => 'Unit7.java',
  263. 'unit' => '7',
  264. ),
  265. ),
  266. ),
  267. 'CS2203' => array(
  268. 'title' => 'CS 2203: Databases 1',
  269. 'subtitle' => "<span title=\"{$entry(2017, 6, 15)}\">2017-06-15</span> to <span title=\"{$entry(2017, 8, 16)}\">2017-08-16</span>",
  270. 'assignments' => array(
  271. 'Library_database_relations' => array(
  272. 'title' => 'Library database relations',
  273. 'unit' => '1',
  274. ),
  275. 'Library_database_relations~_continued' => array(
  276. 'title' => 'Library database relations, continued',
  277. 'unit' => '2',
  278. ),
  279. 'Library_database_relation_diagram' => array(
  280. 'title' => 'Library database relation diagram',
  281. 'unit' => '3',
  282. ),
  283. 'Library_database_normalisation' => array(
  284. 'title' => 'Library database normalisation',
  285. 'unit' => '4',
  286. ),
  287. 'Library_database_SQL' => array(
  288. 'title' => 'Library database SQL',
  289. 'unit' => '5',
  290. ),
  291. 'Library_database_SQL~_continued' => array(
  292. 'title' => 'Library database SQL, continued',
  293. 'unit' => '6',
  294. ),
  295. 'Library_database_SQL_select' => array(
  296. 'title' => 'Library database SQL select',
  297. 'unit' => '7',
  298. ),
  299. ),
  300. ),
  301. 'CS2205' => array(
  302. 'title' => 'CS 2205: Web Programming 1',
  303. 'subtitle' => "<span title=\"{$entry(2017, 9, 7)}\">2017-09-07</span> to <span title=\"{$entry(2017, 11, 8)}\">2017-11-08</span>",
  304. 'assignments' => array(
  305. 'Markup_validation' => array(
  306. 'title' => 'Markup validation',
  307. 'unit' => '1',
  308. ),
  309. ),
  310. ),
  311. 'CS2301' => array(
  312. 'title' => 'CS 2301: Operating Systems 1',
  313. 'subtitle' => "<span title=\"{$entry(2017, 9, 7)}\">2017-09-07</span> to <span title=\"{$entry(2017, 11, 8)}\">2017-11-08</span>",
  314. 'assignments' => array(),
  315. ),
  316. 'HIST1421' => array(
  317. 'title' => 'HIST 1421: Greek and Roman Civilization',
  318. 'subtitle' => "<span title=\"{$entry(2017, 4, 6)}\">2017-04-06</span> to <span title=\"{$entry(2017, 6, 7)}\">2017-06-07</span>",
  319. 'assignments' => array(
  320. 'Politics_in_Athens_and_Sparta' => array(
  321. 'title' => 'Politics in Athens and Sparta',
  322. 'unit' => '1',
  323. ),
  324. 'Forms_of_government_in_ancient_Greece' => array(
  325. 'title' => 'Forms of government in ancient Greece',
  326. 'unit' => '2',
  327. ),
  328. 'Inequalities_in_Rome' => array(
  329. 'title' => 'Inequalities in Rome',
  330. 'unit' => '4',
  331. ),
  332. 'The_first_Punic_war' => array(
  333. 'title' => 'The first Punic war',
  334. 'unit' => '5',
  335. ),
  336. 'Concrete_and_arches' => array(
  337. 'title' => 'Concrete and arches',
  338. 'unit' => '7',
  339. ),
  340. ),
  341. ),
  342. 'PHIL1404' => array(
  343. 'title' => 'PHIL 1404: Ethics and Social Responsibility',
  344. 'subtitle' => "<span title=\"{$entry(2017, 1, 26)}\">2017-01-26</span> to <span title=\"{$entry(2017, 3, 29)}\">2017-03-29</span>",
  345. 'assignments' => array(
  346. 'Apple_and_ethics' => array(
  347. 'title' => 'Apple and ethics',
  348. 'unit' => '1',
  349. ),
  350. 'Cultural_relativism' => array(
  351. 'title' => 'Cultural relativism',
  352. 'unit' => '3',
  353. ),
  354. 'Artificial_value' => array(
  355. 'title' => 'Artificial value',
  356. 'unit' => '5',
  357. ),
  358. 'Caveat_emptor_and_the_McDonald~s_coffee_case' => array(
  359. 'title' => 'Caveat emptor and the McDonald&apos;s coffee case',
  360. 'unit' => '7',
  361. ),
  362. ),
  363. ),
  364. 'POLS1503' => array(
  365. 'title' => 'POLS 1503: Globalization',
  366. 'subtitle' => "<span title=\"{$entry(2016, 9, 1)}\">2016-09-01</span> to <span title=\"{$entry(2016, 11, 2)}\">2016-11-02</span>",
  367. 'assignments' => array(
  368. 'The_World_Bank_and_the_Integrated_Storm_Water_Drain_project_in_Chennai' => array(
  369. 'title' => 'The World Bank and the Integrated Storm Water Drain project in Chennai',
  370. 'unit' => '2',
  371. ),
  372. 'The_Electronic_Frontier_Foundation' => array(
  373. 'title' => 'The Electronic Frontier Foundation',
  374. 'unit' => '3',
  375. ),
  376. 'The_Canadian_Magazine_Dispute_and_an_Exemption_for_Whaling' => array(
  377. 'title' => 'The Canadian Magazine Dispute and an Exemption for Whaling',
  378. 'unit' => '6',
  379. ),
  380. 'Global_pathogens_and_GMOs' => array(
  381. 'title' => 'Global pathogens and GMOs',
  382. 'unit' => '7',
  383. ),
  384. ),
  385. ),
  386. 'UNIV1001' => array(
  387. 'title' => 'UNIV 1001: Online Education Strategies',
  388. 'subtitle' => "<span title=\"{$entry(2016, 9, 1)}\">2016-09-01</span> to <span title=\"{$entry(2016, 11, 2)}\">2016-11-02</span>",
  389. 'assignments' => array(
  390. 'Free_Business_Models_and_Why_They_Matter_to_Me' => array(
  391. 'title' => 'Free Business Models and Why They Matter to Me',
  392. 'unit' => '2',
  393. ),
  394. 'Proctoring' => array(
  395. 'title' => 'Proctoring',
  396. 'unit' => '3',
  397. ),
  398. 'Student_Success' => array(
  399. 'title' => 'Student Success',
  400. 'unit' => '4',
  401. ),
  402. 'Notes' => array(
  403. 'title' => 'Notes',
  404. 'unit' => '6',
  405. ),
  406. 'A_conflict_with_T-Mobile' => array(
  407. 'title' => 'A conflict with T-Mobile',
  408. 'unit' => '7',
  409. ),
  410. ),
  411. ),
  412. );
  413. // Automated navigation menu for the coursework section
  414. foreach($coursework as $key_code => $value_array):
  415. $assignment_array = array();
  416. foreach($value_array['assignments'] as $key_href => $value_assignment):
  417. $assignment_array[] = "<a href=\"/en/coursework/$key_code/$key_href.xhtml\" title=\"{$value_assignment['title']}\">Unit {$value_assignment['unit']}</a>";
  418. endforeach;
  419. $coursework_nav[$key_code] = implode(" |\n\t\t\t\t", $assignment_array);
  420. endforeach;
  421. unset($key_code, $value_array, $assignment_array, $key_href, $value_assignment);
  422. // The following variable names are reserved, and may be declared in
  423. // in any file. However, because they can be declared in any file, they
  424. // cannot be assumed in any file to be empty before use.
  425. //
  426. // $key and variable names beginning in "$key_":
  427. // Reserved for use in "foreach" statements.
  428. // $value and variable names beginning in "$value_":
  429. // Reserved for use in "foreach" statements.
  430. // $i:
  431. // Reserved for use in "for" statements.
  432. // $canary:
  433. // Currently used by the main build script to contain the warrant
  434. // canary's contents.
  435. // $dirname:
  436. // Used in any file to refer to the name of a directory that needs
  437. // to be checked for existence, then created if nonexistent. (This
  438. // should be fixed with a function at some point.)
  439. // $moved:
  440. // Currently used in the file dealing with redirect pages.
  441. // $_:
  442. // Used when a value is required to be assigned to a variable, but
  443. // we have no intention of actually reading that variable's value.
  444. // $current_entry:
  445. // Used in some of the weblog-specific code to hold the year,
  446. // month, and day numbers. This code may need to be rewritten once
  447. // path-specific code has been set up.
  448. // $datetime:
  449. // Used in some navigation code that needs to be cleaned up.
  450. // $previous:
  451. // Used in some navigation code that needs to be cleaned up.
  452. // $next:
  453. // Used in some navigation code that needs to be cleaned up.
  454. // $URI_path_minus_slash:
  455. // Set to the HTTP path of the webpage, minus the slash at the
  456. // beginning.
  457. // $xhtml:
  458. // An array of page-specific variables used by the main template.
  459. // $checkpath:
  460. // A variable used on the main template to build the links to the
  461. // XHTML/CSS conformance checker. This code should probably be
  462. // cleaned up.
  463. // $time_script_started:
  464. // This variable holds the time that the script started, for
  465. // statistical purposes. It can't be declared in this file simply
  466. // because it needs to be declared before this file is require()d.
  467. // $time_until_script_ended:
  468. // This variable holds the time that the script took to complete,
  469. // for statistical purposes. It can't be declared in this file
  470. // simply because it needs to be declared at the end of the main
  471. // script.
  472. // NOTES:
  473. // "weblog_index.php" majorly needs to be cleaned up later.
  474. //
  475. // Closures are also not included in this file. All variable names
  476. // beginning in "$¢" are reserved for use as closures.