You are here

function drupalforfirebug_get_php_exec in Drupal For Firebug 5

Same name and namespace in other branches
  1. 6 drupalforfirebug.module \drupalforfirebug_get_php_exec()
  2. 7.2 drupalforfirebug.module \drupalforfirebug_get_php_exec()
  3. 7 drupalforfirebug.module \drupalforfirebug_get_php_exec()
1 call to drupalforfirebug_get_php_exec()
drupalforfirebug_get_exec_php_callback in ./drupalforfirebug.module
Outputs a Execute PHP Form

File

./drupalforfirebug.module, line 154

Code

function drupalforfirebug_get_php_exec($code = NULL, $token = NULL) {
  $output = '<fieldset>';
  if (!user_access('Execute Firebug PHP') || !is_null($code) && !drupal_valid_token($token)) {
    $output .= '<legend>' . t('Execute Firebug PHP') . '</legend>';
    $output .= 'You do not have the proper permissions to use this functionality.';
    $output .= '</fieldset>';
    print $output;
    exit;
  }
  else {
    if (!$code) {
      $output .= '<legend>' . t('Execute Firebug PHP') . '</legend>';
      $output .= drupal_get_form('drupalforfirebug_execute_form');
      $output .= '</fieldset>';
      print $output;
      exit;
    }
    else {
      $output = '<legend>PHP Code Execution Results</legend>';

      // Run the PHP command, get output in variable
      ob_start();
      eval($code);
      $eval_result = ob_get_contents();
      ob_end_clean();
      $output .= '<PRE>' . $eval_result . '</PRE>';
      $output .= '</fieldset>';
      $output .= '<fieldset>';
      $output .= '<legend>' . t('Execute Firebug PHP') . '</legend>';
      $output .= drupal_get_form('drupalforfirebug_execute_form');
      $output .= '</fieldset>';
      print $output;
      exit;
    }
  }
}