/[drupal]/contributions/modules/drutex/drutex_security.inc
ViewVC logotype

Diff of /contributions/modules/drutex/drutex_security.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.4, Wed Sep 6 04:20:08 2006 UTC revision 1.4.8.1, Mon Nov 17 09:05:37 2008 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id$  // $Id: drutex_security.inc,v 1.4 2006/09/06 04:20:08 dfg Exp $
3    
4  /**  /**
5   * @file   * @file
# Line 16  function drutex_security_info($format = Line 16  function drutex_security_info($format =
16    return (object) array(    return (object) array(
17      'title' => t('Security restrictions'),      'title' => t('Security restrictions'),
18      'description' => t('Restricts the set of allowed LaTeX commands.'),      'description' => t('Restricts the set of allowed LaTeX commands.'),
19      'toggle' => true,      'toggle' => TRUE,
20      'weight' => 20      'weight' => 20
21    );    );
22  }  }
23    
24  /**  /**
25     * Implementation of subhook_filter_tips().
26     */
27    
28    function drutex_security_filter_tips($delta, $format, $long = FALSE) {
29    
30      if (drutex_var_get("drutex_security_active_$format") == TRUE) {
31        $allowed_commands = drutex_var_get("drutex_security_allowedcommands_$format");
32        $allowed_environments = drutex_var_get("drutex_security_allowedenvironments_$format");
33        $text = t('Allowed commands include: %cmd', array('%cmd' => $allowed_commands));
34        $text .= '<br />'. t('Allowed environments include: %env', array('%env' => $allowed_environments));
35      }
36      else {
37        $text = '';
38      }
39      return $text;
40    }
41    
42    /**
43   * Implementation of subhook_defaults().   * Implementation of subhook_defaults().
44   */   */
45  function drutex_security_defaults() {  function drutex_security_defaults() {
46    $D['drutex_security_active'] = false;    $D['drutex_security_active'] = FALSE;
47    $D['drutex_security_allowedcommands'] = '\atop \binom \cdot \cfrac \choose \frac \int \ln \over \sum \to';    $D['drutex_security_allowedcommands'] = '\atop \binom \cdot \cfrac \choose \frac \int \ln \over \sum \to';
48    $D['drutex_security_allowedenvironments'] = 'align array equation equations gather matrix split';    $D['drutex_security_allowedenvironments'] = 'align array equation equations gather matrix split';
49    
# Line 54  function drutex_security($text, $format Line 72  function drutex_security($text, $format
72    $commands = $matches[0];    $commands = $matches[0];
73    
74    foreach ($commands as $command) {    foreach ($commands as $command) {
75      if (array_search($command, $allowed_commands[$format]) === false) {      if (array_search($command, $allowed_commands[$format]) === FALSE) {
76        watchdog('DruTeX', "Unallowed command (by security submodule): $command", WATCHDOG_WARNING);        watchdog('DruTeX', "Unallowed command (by security submodule): %cmd", array('%cmd' => $command), WATCHDOG_WARNING);
77        return false;        return FALSE;
78      }      }
79    }    }
80    
81    return true;    return TRUE;
82  }  }
83    
84  /**  /**

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.4.8.1

  ViewVC Help
Powered by ViewVC 1.1.2