' . t('The PHP filter adds the ability to include PHP code in posts. PHP is a general-purpose scripting language widely-used for web development; the content management system used by this website has been developed using PHP.') . '

'; $output .= '

' . t('Through the PHP filter, users with the proper permission may include custom PHP code within a page of the site. While this is a powerful and flexible feature if used by a trusted user with PHP experience, it is a significant and dangerous security risk in the hands of a malicious user. Even a trusted user may accidentally compromise the site by entering malformed or incorrect PHP code. Only the most trusted users should be granted permission to use the PHP filter, and all PHP code added through the PHP filter should be carefully examined before use.') . '

'; $output .= '

' . t('Drupal.org offers some example PHP snippets, or you can create your own with some PHP experience and knowledge of the Drupal system.', array('@drupal' => url('http://drupal.org'), '@php-snippets' => url('http://drupal.org/handbook/customization/php-snippets'))) . '

'; $output .= '

' . t('For more information, see the online handbook entry for PHP module.', array('@php' => 'http://drupal.org/handbook/modules/php/')) . '

'; return $output; } } /** * Implementation of hook_filter_tips(). */ function php_filter_tips($delta, $format, $long = FALSE) { global $base_url; if ($delta == 0) { switch ($long) { case 0: return t('You may post PHP code. You should include <?php ?> tags.'); case 1: $output = '

' . t('Using custom PHP code') . '

'; $output .= '

' . t('Custom PHP code may be embedded in some types of site content, including posts and blocks. While embedding PHP code inside a post or block is a powerful and flexible feature when used by a trusted user with PHP experience, it is a significant and dangerous security risk when used improperly. Even a small mistake when posting PHP code may accidentally compromise your site.') . '

'; $output .= '

' . t('If you are unfamiliar with PHP, SQL, or Drupal, avoid using custom PHP code within posts. Experimenting with PHP may corrupt your database, render your site inoperable, or significantly compromise security.') . '

'; $output .= '

' . t('Notes:') . '

'; $output .= ''; $output .= '

' . t('A basic example: Creating a "Welcome" block that greets visitors with a simple message.') . '

'; $output .= ''; $output .= '

' . t('Drupal.org offers some example PHP snippets, or you can create your own with some PHP experience and knowledge of the Drupal system.', array('@drupal' => url('http://drupal.org'), '@php-snippets' => url('http://drupal.org/handbook/customization/php-snippets'))) . '

'; return $output; } } } /** * Implementation of hook_filter(). Contains a basic PHP evaluator. * * Executes PHP code. Use with care. */ function php_filter($op, $delta = 0, $format = -1, $text = '') { switch ($op) { case 'list': return array(0 => t('PHP evaluator')); case 'no cache': // No caching for the PHP evaluator. return $delta == 0; case 'description': return t('Executes a piece of PHP code. The usage of this filter should be restricted to administrators only!'); case 'process': return drupal_eval($text); default: return $text; } }