do { $rd = isset($rd) ? dirname($rd) : realpath(dirname(__FILE__)); $tp = "{$rd}/rootpath.php"; if (file_exists($tp)) { require_once $tp; break; } } while ($rd != '/'); } $title = "Theater Creator"; if (isset($_REQUEST['fetch'])) { require_once "{$includepath}/functions.php"; } else { require_once "{$includepath}/header.php"; } LoadSnippets($snippets); $theater = ParseTheaterFile("{$theaterfile}.theater", $mod, $version, $theaterpath); if (isset($_REQUEST['fetch'])) { switch ($_REQUEST['fetch']) { case 'snippets': $fetch_data = $snippets; break; case 'Download Theater': $data = $_REQUEST['theaterdata']; //GenerateTheater(); $filename = $_REQUEST['filename']; header('Content-type: text/plain'); header("Content-Disposition: attachment; filename=\"{$filename}\""); header('Expires: 0'); header('Cache-Control: must-revalidate'); header('Pragma: public');
function LoadSnippets(&$snippets, $path = '') { global $sections, $snippet_path, $version, $mod, $mods; if ($path == '') { $path = $snippet_path; } $files = glob("{$path}/*"); foreach ($files as $file) { $path_parts = pathinfo($file); if ($path_parts['basename'] != "." && $path_parts['basename'] != "..") { // echo "{$file}\n"; if (is_dir($file)) { $sections[$path_parts['basename']] = $path_parts['basename']; LoadSnippets($snippets[$path_parts['basename']], $file); } else { switch ($path_parts['extension']) { case 'yaml': $snippets[$path_parts['filename']] = Spyc::YAMLLoad($file); break; case 'theater': $lines = preg_split('/\\n|\\r\\n?/', file_get_contents($file)); $header = ""; foreach ($lines as $line) { $line = trim($line); if ($line[0] != $line[1] || $line[1] != '/') { break; } $line = trim(preg_replace('/^[\\/ \\t]*/', '', $line)); $header .= "{$line}\n"; } $snippets[$path_parts['filename']] = array('name' => $path_parts['filename'], 'desc' => trim($header), 'settings' => ParseTheaterFile($file, $mod, $version, $path_parts['dirname'])); break; } } } } }