private bool doPOST() { UserDAO user = (UserDAO)Session["userDAO"]; String pluginName = Request.Form["pluginName"]; String successMessage = ""; if (pluginName == null) { // Redirect them back SendErrorMessage("Please specify a plugin"); return false; } IDBController controller = new SqlController(); PluginDAO plugin = null; try { plugin = controller.RetrievePlugin(pluginName); if (!plugin.OwnerID.Equals(user.UserID)) { SendErrorMessage("That is not a plugin you have written."); return false; } else { // Go ahead and save it String luacodeFileLoc = LUADefinitions.getLuaScriptLocation(plugin.Name); // See if it's there if (File.Exists(luacodeFileLoc)) { String luacode = Request.Form["editorText"]; try { File.WriteAllText(luacodeFileLoc, luacode); controller.ResetPluginFailedAttemptCount(plugin.PluginID); if (controller.GetPluginFailedAttemptCount(plugin.PluginID) == 0) { // Reenable the plugin controller.EnableGlobalPlugin(plugin.PluginID); } successMessage = "Plugin has been updated."; } catch (Exception) { SendErrorMessage("Could not save plugin."); return false; } } else { SendErrorMessage("Could not save plugin."); return false; } } } catch (CouldNotFindException) { SendErrorMessage("That is not a valid plugin"); return false; } // Always redirect on POST Response.Redirect(string.Format("EditPlugin.aspx?pluginname={0}&success={1}", HttpUtility.UrlEncode(pluginName), HttpUtility.UrlEncode(successMessage))); return false; }