$standard = $nextStandard; } else { if ($total !== false && !empty($course)) { $level[] = $total; } } } } $map[] = ['standard' => array_combine(array('code', 'description'), explode(' - ', $standard)), "marks" => $level]; /* and send it off to Smarty to display */ $smarty->assign('courses', $courses); $smarty->assign('map', $map); $smarty->assign('timestamp', $cache->getCacheTimestamp($_REQUEST['map'])->format('F j, Y')); $smarty->display('standards-map/sheet.tpl'); exit; /* ...or are we being given data to cache? */ } elseif (!empty($_REQUEST['analysis'])) { /* allow access via bookmarklet */ header("Access-Control-Allow-Origin: {$_SERVER['HTTP_ORIGIN']}"); /* the POST parameter is not URL-encoded, which breaks $_POST */ $data = substr(file_get_contents('php://input'), strlen('analysis=')); $key = 'analysis.' . md5($data); $cache->setCache($key, $data); echo $key; exit; /* ...or should we show some instructions? */ } else { $smarty->addStylesheet('css/standards-map/instructions.css'); $smarty->assign('bookmarklet', "javascript: (function () {\n var jsCode = document.createElement('script');\n jsCode.setAttribute('src', 'https://skunkworks.stmarksschool.org/printable-forms/standards-map.js');\n document.body.appendChild(jsCode);\n }());"); $smarty->display('standards-map/instructions.tpl'); }