Call C binary from PHP


I would like to put a database connection string into a compiled C binary and call it from PHP. Does anyone know how I might do this?


PHP: system - Manual

you should use the proc_open() function to call the binary from php.

however, to “put a database connection string into a compiled C binary” you have to place the string into the source code, compile it, then execute it.

That of course, does not make any sense rotfl!

If you are concerned about showing the DB connection parameters on the Web by accident, there are ways of stopping that. You can put that information in included PHP source files that are outside of the webserver area or you can forbid web access to those files. Of course the information is still visible to anybody with sysadmin privilege on the webserver. There’s no point trying to prevent that because a sysadmin can simply trace the calls or snoop on the packets to work out which machine, which DB and what account you are connecting to.

Anything would be better than having the connection string sitting in a settings.ini file as it is now :expressionless: If it’s in a compiled binary then it would be much harder to get at it… although not impossible I realise…

Use Apache rules to forbid fetching of .ini files or put the file outside of the webserver area. PHP can still include them but the webserver won’t be able to serve them.

it wont be any better…place it in whatever file outside your document root… placing it on a compiled C binary is a complete insecure non-sense.:sarcastic:

Also limit the privileges of the file that contains your database connection settings.