-1

Is there a way to include_once ("somefiles.php") in PhP that only that code can read.

Other people cannot read that, at least not in human readable format.

somefiles.php can be put on other server but must be cached. Perhaps there is some encoding?

user4951
  • 32,206
  • 53
  • 172
  • 282
  • 2
    The short answer is 'no' if they have access to the server. – Jay Blanchard Dec 30 '16 at 12:04
  • so far i know you can do this http://www.phpeasystep.com/phptu/28.html – Ahad Dec 30 '16 at 12:05
  • You could potentially change the permissions of that file so that only your script and specific users have access to them but unless you know what you're doing I would recommend it. – Rwd Dec 30 '16 at 12:10
  • Why would you want to do that? Is it about accessibility to other code or to humans? To humans, it's simple: If they can't access the server, they can't access the file, because PHP code won't be shown, it'll be executed serverside. – KhorneHoly Dec 30 '16 at 12:15
  • 2
    Why normal linux permissions don't work for you? `chmod`, `umask`, or facl rules, if installed. Mark the file readable by owner only, so only root and web user could read. – Alex Blex Dec 30 '16 at 12:28

2 Answers2

3

There's a lot of tools to obfuscate php code around the web, some are free and others paid. Here's some links to start:

http://www.phpprotect.info/

http://www.pipsomania.com/best_php_obfuscator.do

http://www.fopo.com.ar/

Be aware that are, also, a lot of tools that do the opposite, "unobfuscating" your code, its a good practice to try your code on some of these:

http://www.unphp.net/

http://jonhburn2.freehostia.com/decode/

http://ddecode.com/phpdecoder/

leoap
  • 1,684
  • 3
  • 24
  • 32
1

Don't give other people root access, then run this for all your code:

chmod -R ug+r path/to/your/code
chmod -R o-r path/to/your/code
chown -R your-name path/to/your/code
chgrp -R www-data path/to/your/code
SOFe
  • 7,867
  • 4
  • 33
  • 61