You have to look at content plugins and maybe editors-xtd plugins.
The content plugin will detect the special markup you put into the article and do whatever you need it to do with it. That is your whole script code should go into this plugin, not the require_once
stuff. Usually plugin markup uses {
and }
, but you could use anything you want. You just create a proper REGEX for it to detect.
If this works you can also look at an editors-xtd plugin. This will then create a button below the editor which allows your authors to input the markup into the editor.
For examples, you can look at one of the simpler existing plugins.