Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
moodle-qtype_stack
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
elc
moodle-qtype_stack
Commits
a981c04f
Commit
a981c04f
authored
9 years ago
by
Chris Sangwin
Browse files
Options
Downloads
Patches
Plain Diff
First attempt to remove eval() from locallib.
parent
4209745b
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
locallib.php
+28
-32
28 additions, 32 deletions
locallib.php
stack/cas/installhelper.class.php
+1
-1
1 addition, 1 deletion
stack/cas/installhelper.class.php
with
29 additions
and
33 deletions
locallib.php
+
28
−
32
View file @
a981c04f
...
...
@@ -51,29 +51,10 @@ function stack_string($key, $a = null) {
}
/**
* Translates a string taken as output from Maxima.
*
* This function takes a variable number of arguments, the first of which is assumed to be the identifier
* of the string to be translated.
* This function takes a feedback string from Maxima and unpacks and translates it.
* @param string $rawfeedback
* @return string
*/
function
stack_trans
()
{
$nargs
=
func_num_args
();
if
(
$nargs
>
0
)
{
$arglist
=
func_get_args
();
$identifier
=
func_get_arg
(
0
);
$a
=
array
();
if
(
$nargs
>
1
)
{
for
(
$i
=
1
;
$i
<
$nargs
;
$i
++
)
{
$index
=
$i
-
1
;
$a
[
"m
{
$index
}
"
]
=
func_get_arg
(
$i
);
}
}
$return
=
stack_string
(
$identifier
,
$a
);
echo
$return
;
}
}
function
stack_maxima_translate
(
$rawfeedback
)
{
if
(
strpos
(
$rawfeedback
,
'stack_trans'
)
===
false
)
{
...
...
@@ -82,17 +63,32 @@ function stack_maxima_translate($rawfeedback) {
$rawfeedback
=
str_replace
(
'[['
,
''
,
$rawfeedback
);
$rawfeedback
=
str_replace
(
']]'
,
''
,
$rawfeedback
);
$rawfeedback
=
str_replace
(
'\n'
,
''
,
$rawfeedback
);
$rawfeedback
=
str_replace
(
'\\'
,
'\\\\'
,
$rawfeedback
);
$rawfeedback
=
str_replace
(
'!quot!'
,
'"'
,
$rawfeedback
);
// @codingStandardsIgnoreStart
ob_start
();
eval
(
$rawfeedback
);
$translated
=
ob_get_contents
();
ob_end_clean
();
// @codingStandardsIgnoreEnd
$translated
=
array
();
preg_match_all
(
'/stack_trans\(.*?\);/'
,
$rawfeedback
,
$matches
);
$feedback
=
$matches
[
0
];
foreach
(
$feedback
as
$key
=>
$fb
)
{
$fb
=
substr
(
$fb
,
12
,
-
2
);
if
(
strstr
(
$fb
,
"' ,
\"
"
)
===
false
)
{
// We only have a feedback tag, with no optional arguments.
$translated
[]
=
trim
(
stack_string
(
substr
(
$fb
,
1
,
-
1
)));
}
else
{
// We have a feedback tag and some optional arguments.
$tag
=
substr
(
$fb
,
1
,
strpos
(
$fb
,
"' ,
\"
"
)
-
1
);
$arg
=
substr
(
$fb
,
strpos
(
$fb
,
"' ,
\"
"
)
+
5
,
-
2
);
$args
=
explode
(
'" , "'
,
$arg
);
$a
=
array
();
for
(
$i
=
0
;
$i
<
count
(
$args
);
$i
++
)
{
$a
[
"m
{
$i
}
"
]
=
$args
[
$i
];
}
$translated
[]
=
trim
(
stack_string
(
$tag
,
$a
));
}
}
return
trim
(
$translated
);
return
implode
(
' '
,
$translated
);
}
}
...
...
This diff is collapsed.
Click to expand it.
stack/cas/installhelper.class.php
+
1
−
1
View file @
a981c04f
...
...
@@ -73,7 +73,7 @@ class stack_cas_configuration {
$this
->
blocksettings
[
'GNUPLOT_CMD'
]
=
$this
->
get_plotcommand_win
();
}
else
{
$this
->
blocksettings
[
'DEL_CMD'
]
=
'rm'
;
if
(
!
empty
(
$this
->
settings
->
plotcommand
))
{
if
(
!
empty
(
trim
(
$this
->
settings
->
plotcommand
))
)
{
$this
->
blocksettings
[
'GNUPLOT_CMD'
]
=
$this
->
settings
->
plotcommand
;
}
else
if
(
is_readable
(
'/Applications/Gnuplot.app/Contents/Resources/bin/gnuplot'
))
{
$this
->
blocksettings
[
'GNUPLOT_CMD'
]
=
'/Applications/Gnuplot.app/Contents/Resources/bin/gnuplot'
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment