I am very much new to Asterisk/freeswitch integration to web apps running on PHP,Node.js or any other server side languages.What i would like to achieve is to create a new SIP user in Asterisk/Freeswitch conf files or database files from within a web application. How can i modify/write the config files or SIP database on these Asterisk/Freeswitch PBX software hosted in the same server ?
You can achieve your purpose in multiple way. Maybe the simplest and the direct is to add in sip.conf (asterisk) a few lines that describe the new user, like described in here. Then you just need to restart asterisk (or better to call a reload config through Asterisk cli. Here is a maybe useful link: Asterisk php cli. For freeswitch is the same, but you have to enter the new user in xml format, as specified in this page. Maybe if you use asterisk or freeswitch over a db it will be even simpler: just add a line in the db!
Be sure to verify user input to create only valid user (block xml tags, hashes, ; and other dangerous symbol)