load('../pages/' . $theme . '/resources.xml'); if ($type) { $man = new Moxiecode_ManagerEngine($type); require_once($basepath ."CorePlugin.php"); require_once("../config.php"); $man->dispatchEvent("onPreInit", array($type)); $config = $man->getConfig(); // Load plugin resources $plugins = explode(',', $config["general.plugins"]); foreach ($plugins as $plugin) $resources->load('../plugins/' . $plugin . '/resources.xml'); } $file = $resources->getFile($package, $file); header('Content-type: ' . $file->getContentType()); readfile($file->getPath()); die(); } if ($cmd == "") die("No command."); $chunks = explode('.', $cmd); $type = $chunks[0]; $method = $cmd = $chunks[1]; // Clean up type, only a-z stuff. $type = preg_replace("/[^a-z]/i", "", $type); if ($type == "") die("No type set."); // Include Base and Core and Config. $man = new Moxiecode_ManagerEngine($type); require_once($basepath ."CorePlugin.php"); require_once("../config.php"); $man->dispatchEvent("onPreInit", array($type)); $config = $man->getConfig(); // Include all plugins $pluginPaths = $man->getPluginPaths(); foreach ($pluginPaths as $path) require_once("../". $path); // Dispatch onAuthenticate event if ($man->isAuthenticated()) { if ($_SERVER["REQUEST_METHOD"] == "GET") { $args = $_GET; // Dispatch event before starting to stream $man->dispatchEvent("onBeforeStream", array($cmd, &$args)); // Check command, do command, stream file. $man->dispatchEvent("onStream", array($cmd, &$args)); // Dispatch event after stream $man->dispatchEvent("onAfterStream", array($cmd, &$args)); } else if ($_SERVER["REQUEST_METHOD"] == "POST") { $args = array_merge($_POST, $_GET); $json = new Moxiecode_JSON(); // Dispatch event before starting to stream $man->dispatchEvent("onBeforeUpload", array($cmd, &$args)); // Check command, do command, stream file. $result = $man->executeEvent("onUpload", array($cmd, &$args)); $data = $result->toArray(); if (isset($args["chunk"])) { // Output JSON response to multiuploader die('{method:\'' . $method . '\',result:' . $json->encode($data) . ',error:null,id:\'m0\'}'); } else { // Output JSON function echo '
'; } // Dispatch event after stream $man->dispatchEvent("onAfterUpload", array($cmd, &$args)); } } else { if (isset($_GET["format"]) && ($_GET["format"] == "flash")) header("HTTP/1.1 405 Method Not Allowed"); die('{"result":{login_url:"' . addslashes($config["authenticator.login_page"]) . '"},"id":null,"error":{"errstr":"Access denied by authenicator.","errfile":"","errline":null,"errcontext":"","level":"AUTH"}}'); } ?>