| 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 |
| 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 |
|
|
| 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 |
/** |
/** |