/** * Save changes, either inserting a new docblock or updating an existing docblock */ static function AJAX_Save() { // Which file? $file = $_POST['File']; // Prevent loading illegal files if (strpos($file, ":") !== FALSE || strpos($file, "..") !== FALSE || strtolower(substr(pathinfo($file, PATHINFO_EXTENSION), 0, 3)) != "php") { die("ERR0"); } // Does this file exist? if (!file_exists($file)) { die("ERR2"); } // File too big? if (filesize($file) > 4 * 1024 * 1024) { die("ERR0"); } // Prepare docblock $doc = new DocBlock("", "", ""); $doc->shortDescription = str_replace("*/", "", trim($_POST['SD'])); $doc->longDescription = str_replace("*/", "", trim($_POST['LD'])); $doc->tags = str_replace("*/", "", trim($_POST['TAGS'])); // What are we doing? UPDATING or INSERTING? if ($_POST['MODE'] === "0") { // 0 = Inserting a new doc block // Which block are we inserting? is it the page docblock? if ($_POST['Line'] === "0") { DocBlock::InsertDocBlock($file, $doc, BLOCK_PAGE); die("OK"); } // --Not a page docblock-- DocBlock::InsertDocBlock($file, $doc, BLOCK_CODE, $_POST['Code'], $_POST['Line']); die("OK"); } elseif ($_POST['MODE'] === "1") { // UPDATING a docblock // Lets see... DocBlock::UpdateDocBlock($file, $doc, $_POST['DocLine']); die("OK"); } }