To Dinkar:
The "if(!defined('INC_FROM_INDEX')) DIE" is probably the only good line of code in the whole extract.
The idea is to start each PHP file checking that it is not being called alone from some scam URL-call, but is used only by including into the larger system, after all environment has been set up (including here 'INC_FROM_INDEX', whatever that might to this code).
Systems such as Joomla use he same structure by starting each php included file (except for the normal entry index.php) with a line like
defined('_JEXEC') or die;
_JEXEC being defined by Joomla when loaded normally. Largely prevents from hackers calling on include files that should not be loaded on their own, but only included by the system itself.
To topr8:
100% right. :-) Thats why I mentioned that there are multiple problems in that code. Baaad code.
To greenfeel:
There is nothing wrong with the line
$text = $db->fetch($db->query("SELECT text_lang$LANG[id] AS text FROM pages WHERE slug='privacy_policy'"));
in itself, other than you not providing any context.
The actual SQL in that line should work PROVIDED that the PHP part is OK, which we do not have.
Before the SQL is executed, the PHP piece "$LANG[id]" have to be evaluated by the interpreter to expand the string, and we do not know what the environment has set the array $LANG or the specific index "[id]" to at time of execution.. Without that we cannot know what the resulting SQL actually will end up looking like.
Either use a PHP debugger (which you likely don;t have/use) to step through it, or simply stick some echo's and print_r() calls in the code to see what the results actually look like.