- Make a .htaccess file in document root.
 - Write the following code:
 - php_value auto_prepend_file before_action.php
php_value auto_append_file after_action.php - create a file before_action.php in document root
 - create a file after_action.php in document root
 - or you can use full file path such: /var/www/html/site.com/before_action.php
 
http://www.php.net/manual/en/ini.core.php#ini.auto-prepend-file