From 37e2d30c847ad0973bf732daef2b3fa9bcdb9d2f Mon Sep 17 00:00:00 2001 From: Daniel Thies Date: Thu, 18 Dec 2014 16:30:52 -0600 Subject: [PATCH] MDL-48213 filter_algebra,filter_tex: Require sesskey for debug actions --- filter/algebra/algebradebug.php | 40 +++++++++++++++++---------------- filter/tex/texdebug.php | 5 +++++ 2 files changed, 26 insertions(+), 19 deletions(-) diff --git a/filter/algebra/algebradebug.php b/filter/algebra/algebradebug.php index 24eb0310821..52cf0680eb2 100644 --- a/filter/algebra/algebradebug.php +++ b/filter/algebra/algebradebug.php @@ -12,20 +12,21 @@ require_once($CFG->libdir.'/filelib.php'); require_once($CFG->dirroot.'/filter/tex/lib.php'); + $action = optional_param('action', '', PARAM_ALPHANUM); + $algebra = optional_param('algebra', '', PARAM_RAW); + require_login(); require_capability('moodle/site:config', context_system::instance()); + if ($action || $algebra) { + require_sesskey(); + } - $query = urldecode($_SERVER['QUERY_STRING']); - - if ($query) { - $output = $query; - $splitpos = strpos($query,'&')-8; - $algebra = substr($query,8,$splitpos); + if ($algebra && $action) { $md5 = md5($algebra); - if (strpos($query,'ShowDB') || strpos($query,'DeleteDB')) { + if ($action == 'ShowDB' || $action == 'DeleteDB') { $texcache = $DB->get_record("cache_filters", array("filter"=>"algebra", "md5key"=>$md5)); } - if (strpos($query,'ShowDB')) { + if ($action == 'ShowDB') { if ($texcache) { $output = "DB cache_filters entry for $algebra\n"; $output .= "id = $texcache->id\n"; @@ -38,7 +39,7 @@ $output = "DB cache_filters entry for $algebra not found\n"; } } - if (strpos($query,'DeleteDB')) { + if ($action == 'DeleteDB') { if ($texcache) { $output = "Deleting DB cache_filters entry for $algebra\n"; $result = $DB->delete_records("cache_filters", array("id"=>$texcache->id)); @@ -52,17 +53,17 @@ $output = "Could not delete DB cache_filters entry for $algebra\nbecause it could not be found.\n"; } } - if (strpos($query,'TeXStage1')) { + if ($action == 'TeXStage1') { $output = algebra2tex($algebra); } - if (strpos($query,'TeXStage2')) { + if ($action == 'TexStage2') { $output = algebra2tex($algebra); $output = refineTeX($output); } - if (strpos($query,'ShowImage')||strpos($query,'SlashArguments')) { + if ($action == 'ShowImage'|| $action == 'SlashArguments') { $output = algebra2tex($algebra); $output = refineTeX($output); - if (strpos($query,'ShowImage')) { + if ($action == 'ShowImage') { tex2image($output, $md5); } else { slasharguments($output, $md5); @@ -283,19 +284,20 @@ function slasharguments($texexp, $md5) { value="sin(z)/(x^2+y^2)" />
    -
  1. First click on this button +
  2. First click on this button to see the cache_filters database entry for this expression.
  3. If the database entry looks corrupt, click on this button to delete it: -
  4. -
  5. Now click on this button . +
  6. +
  7. Now click on this button . A preliminary translation into TeX will appear in the box below.
  8. -
  9. Next click on this button . +
  10. Next click on this button . A more refined translation into TeX will appear in the box below.
  11. -
  12. Then click on this button +
  13. Then click on this button to show a graphic image of the algebraic expression.
  14. Finally check your slash arguments setting -
  15. +
+