diff --git a/api/public/cors.php b/api/public/cors.php
index 35fc6faad784f923ee96fb796e84d5e6d234aac4..1cd68d2cfb75bdc640253ee03ed8abb038d6aac2 100644
--- a/api/public/cors.php
+++ b/api/public/cors.php
@@ -27,9 +27,9 @@ if (isset($_GET['question'])) {
$is_question = false;
}
-if (str_contains($scriptname, '..')
- || str_contains($scriptname, '/')
- || str_contains($scriptname, '\\')) {
+if (str_pos($scriptname, '..') !== false
+ || strpos($scriptname, '/') !== false
+ || strpos($scriptname, '\\') !== false) {
die("No such script here.");
}
diff --git a/classes/library_render.php b/classes/library_render.php
index 9c39b56b911336d3f0f052d5ffbe1aeb3a880981..1ed5fe0a9abfef8d58862e59c5b6a3387762d476 100644
--- a/classes/library_render.php
+++ b/classes/library_render.php
@@ -136,7 +136,7 @@ class library_render extends \external_api {
} catch (\stack_exception $e) {
// If the question is not a STACK question we can't render it
// but we still want users to be able to import it.
- if (str_contains($e->getMessage(), 'not of type STACK')) {
+ if (strpos($e->getMessage(), 'not of type STACK') !== false) {
$xmldata = new SimpleXMLElement($qcontents);
$questiontext = (string) $xmldata->question->questiontext->text;
$questionname = (string) $xmldata->question->name->text;
diff --git a/cli/ast_filter_tester.php b/cli/ast_filter_tester.php
index de1234fca02dfc7a67abc6f6db68f538beaaa2d4..69eb9425eafa276cccd06c24f55505da7bed85f9 100644
--- a/cli/ast_filter_tester.php
+++ b/cli/ast_filter_tester.php
@@ -133,7 +133,7 @@ $filters = stack_parsing_rule_factory::list_filters();
if ($only !== false) {
$f = [];
foreach ($filters as $filter) {
- if (str_contains($filter, $only)) {
+ if (strpos($filter, $only) !== false) {
$f[] = $filter;
}
}
diff --git a/cli/maximalibcheck.php b/cli/maximalibcheck.php
index ce8b1ddac585fd7c81a47bca1280bb469f5c9064..11abc8616a1da0ff2c524acbc23e36737b0d25b2 100644
--- a/cli/maximalibcheck.php
+++ b/cli/maximalibcheck.php
@@ -35,10 +35,10 @@ $globalvariablesused = [];
// Get the files ../stack/maxima/*.mac.
foreach (glob("../stack/maxima/*.mac") as $filename) {
- if (str_contains($filename, 'rtest_')) {
+ if (strpos($filename, 'rtest_') !== false) {
continue;
}
- if (str_contains($filename, 'unittests_load.mac')) {
+ if (strpos($filename, 'unittests_load.mac') !== false) {
continue;
}
@@ -62,7 +62,7 @@ foreach (glob("../stack/maxima/*.mac") as $filename) {
}
}
- if (str_contains($filename, 'assessment.mac')) {
+ if (strpos($filename, 'assessment.mac') !== false) {
// Some parser breaking cases. List calling and the wacky syntax of defines.
$contents = str_replace('?\*autoconf\-version\*', '"cencored"', $contents);
$contents = str_replace('define(UNARY_RECIP a, a^(-1)),', '"cencored",', $contents);
@@ -76,12 +76,12 @@ foreach (glob("../stack/maxima/*.mac") as $filename) {
$contents = str_replace('ret:ev(exc1 %or exc2, simp)', 'ret:ev(exc1 or exc2, simp)', $contents);
}
- if (str_contains($filename, 'stackmaxima.mac')) {
+ if (strpos($filename, 'stackmaxima.mac') !== false) {
// Some parser breaking cases.
$contents = str_replace('?\*autoconf\-version\*', '"cencored"', $contents);
}
- if (str_contains($filename, 'intervals.mac')) {
+ if (strpos($filename, 'intervals.mac') !== false) {
// Some parser breaking cases.
$contents = str_replace('stack_single_variable_solver_rec(ex %and (v>=0), v)',
'stack_single_variable_solver_rec(ex and (v>=0), v)', $contents);
diff --git a/corsscripts/cors.php b/corsscripts/cors.php
index ed11d73cd169e25668fc1cbecb5973ffb61e56cc..74a86e0c9236deb7e3a22abad83d8f6d638a4894 100644
--- a/corsscripts/cors.php
+++ b/corsscripts/cors.php
@@ -22,9 +22,9 @@
$scriptname = urldecode($_GET['name']);
-if (str_contains($scriptname, '..')
- || str_contains($scriptname, '/')
- || str_contains($scriptname, '\\')) {
+if (strpos($scriptname, '..') !== false
+ || strpos($scriptname, '/') !== false
+ || strpos($scriptname, '\\') !== false) {
die("No such script here.");
}
diff --git a/doc/docslib.php b/doc/docslib.php
index 676964f133c82bc2234bd6caef837b98889f6832..bc002b3a4fbeecd24e1c830084e3cd279ab122cd 100644
--- a/doc/docslib.php
+++ b/doc/docslib.php
@@ -136,7 +136,7 @@ function stack_docs_no_found($links) {
function stack_docs_page($links, $file) {
$preprocess = true;
// This auto-generated file does not need maths processing.
- if (str_contains($file, 'Answer_Tests/Results')) {
+ if (strpos($file, 'Answer_Tests/Results') !== false) {
$preprocess = false;
}
$body = '';
diff --git a/doc/maintenance.php b/doc/maintenance.php
index e5c72f639e184f26cbe3fbf29d0e3bccdc5850c1..8e8065da64a63c7d21e640e962f0305ee996d6f6 100644
--- a/doc/maintenance.php
+++ b/doc/maintenance.php
@@ -120,12 +120,12 @@ function report($d) {
$link = implode('/', $segs);
// Finally it looks like #--- are getting parsed in the request, let's omit them.
- if (str_contains($link, '#')) {
+ if (strpos($link, '#') !== false) {
$link = substr($link, 0, strpos($link, '#'));
}
}
$hs = get_headers($link);
- if (str_contains($hs[0], '404')) {
+ if (strpos($hs[0], '404') !== false) {
$a[] = [$fpath, 'E', 'Error 404 [' . $found[1][$i] . '] appears to be a dead link.'];
} else {
$fileslinkedto[$found[0][$i]] = true;
diff --git a/questiontype.php b/questiontype.php
index c1456e2d744ef8026d98cdee752849b113c9e582..c309f9a00f6434d2d708bba862e2aed220489d8a 100644
--- a/questiontype.php
+++ b/questiontype.php
@@ -1926,7 +1926,7 @@ class qtype_stack extends question_type {
* @return array updated $errors array.
*/
protected function validate_cas_text($errors, $value, $fieldname, $fixingdollars, $session = null) {
- if (!$fixingdollars && str_contains($value, '$$')) {
+ if (!$fixingdollars && strpos($value, '$$') !== false) {
$errors[$fieldname][] = stack_string('forbiddendoubledollars');
}
diff --git a/stack/cas/cassession2.class.php b/stack/cas/cassession2.class.php
index 2b4ef77c1c414505e1875da90f3d126d8be59097..5805b89684e3bc21ee5a25bfbfd1f6a01caae7cf 100644
--- a/stack/cas/cassession2.class.php
+++ b/stack/cas/cassession2.class.php
@@ -454,7 +454,7 @@ class stack_cas_session2 {
$last = null;
$errb = [];
foreach ($err as $error) {
- if (str_contains($error->get_legacy_error(), 'STACK: ignore previous error.')) {
+ if (strpos($error->get_legacy_error(), 'STACK: ignore previous error.') !== false) {
$last = null;
} else {
if ($last !== null) {
diff --git a/stack/cas/castext2/blocks/iframe.block.php b/stack/cas/castext2/blocks/iframe.block.php
index fe9e929ba5c4f5ee7aa546140c86bb792f0e2aec..d9b206f4555d140793e1af8d9e0a2754d7179c83 100644
--- a/stack/cas/castext2/blocks/iframe.block.php
+++ b/stack/cas/castext2/blocks/iframe.block.php
@@ -151,7 +151,7 @@ class stack_cas_castext2_iframe extends stack_cas_castext2_block {
$title = $parameters['title'];
// Counter updates.
foreach (self::$counters as $key => $value) {
- if (str_contains($title, $key)) {
+ if (strpos($title, $key) !== false) {
$title = str_replace($key, '' . $value, $title);
self::$counters[$key] = $value + 1;
}
diff --git a/stack/cas/castext2/castext2_evaluatable.class.php b/stack/cas/castext2/castext2_evaluatable.class.php
index 4a76a624c97175cd6a80088ee16086de648ed8aa..14ebc52b03f676595011f44bb0733dab85ea8e79 100644
--- a/stack/cas/castext2/castext2_evaluatable.class.php
+++ b/stack/cas/castext2/castext2_evaluatable.class.php
@@ -173,7 +173,7 @@ class castext2_evaluatable implements cas_raw_value_extractor {
}
if ($this->valid) {
- if ($this->context === '/qt' || str_contains($this->context, 'scenetext') ||
+ if ($this->context === '/qt' || strpos($this->context, 'scenetext') !== false ||
$this->context === 'validation-questiontext') {
$options['in main content'] = true;
}
diff --git a/stack/cas/connector.class.php b/stack/cas/connector.class.php
index f12a89197236989cb52ea57218262f2d9afce83b..0ddc28450f97c417583930bf1d43955808d4318b 100644
--- a/stack/cas/connector.class.php
+++ b/stack/cas/connector.class.php
@@ -190,7 +190,7 @@ abstract class stack_cas_connection_base implements stack_cas_connection {
$this->timeout = $settings->castimeout;
$this->serveruserpass = $settings->serveruserpass;
$this->debug = $debuglog;
- if (str_contains($CFG->wwwroot, '_')) {
+ if (strpos($CFG->wwwroot, '_') !== false) {
$this->wwwroothasunderscores = true;
$this->wwwrootfixupfind = str_replace('_', '\_', $CFG->wwwroot);
$this->wwwrootfixupreplace = $CFG->wwwroot;
@@ -334,15 +334,15 @@ abstract class stack_cas_connection_base implements stack_cas_connection {
$errorclean = [];
foreach ($error as $err) {
// This case arises when we use a numerical test for algebraic equivalence.
- if (str_contains($err, 'STACK: ignore previous error.')) {
+ if (strpos($err, 'STACK: ignore previous error.') !== false) {
$err = '';
}
- if (str_contains($err, '0 to a negative exponent')) {
+ if (strpos($err, '0 to a negative exponent') !== false) {
$err = stack_string('Maxima_DivisionZero');
}
- if (str_contains($err, 'args: argument must be a non-atomic expression;')) {
+ if (strpos($err, 'args: argument must be a non-atomic expression;') !== false) {
$err = stack_string('Maxima_Args');
}
diff --git a/stack/cas/connectorhelper.class.php b/stack/cas/connectorhelper.class.php
index 796ac4eafbcdff60a3e2be8d23e174cdc5f71701..57d2030eaa3221e61f41d4970416e22232734f91 100644
--- a/stack/cas/connectorhelper.class.php
+++ b/stack/cas/connectorhelper.class.php
@@ -374,7 +374,7 @@ abstract class stack_connection_helper {
}
}
- if (str_contains($debug, 'failed to load')) {
+ if (strpos($debug, 'failed to load') !== false) {
$message[] = stack_string('settingmaximalibraries_failed');
$success = false;
}
diff --git a/stack/cas/keyval.class.php b/stack/cas/keyval.class.php
index 7375538b6ec12872f50b4488161497d1c34c5121..37050bb6f2cd0acc169cd7ae3305c9a5c9540dc1 100644
--- a/stack/cas/keyval.class.php
+++ b/stack/cas/keyval.class.php
@@ -109,7 +109,7 @@ class stack_cas_keyval {
$str = str_replace('?', 'QMCHAR', $str);
// CAS keyval may not contain @ outside strings.
- if (str_contains($str, '@')) {
+ if (strpos($str, '@') !== false {
$this->errors[] = new $this->errclass(stack_string('illegalcaschars'), $this->context);
$this->valid = false;
return false;
diff --git a/stack/cas/parsingrules/201_sig_figs_validation.filter.php b/stack/cas/parsingrules/201_sig_figs_validation.filter.php
index f70a5c970b30cd354e7bf5e641d948f147a5a8f5..694fb172eed1b95b4c033faf609e7ad530264aca 100644
--- a/stack/cas/parsingrules/201_sig_figs_validation.filter.php
+++ b/stack/cas/parsingrules/201_sig_figs_validation.filter.php
@@ -63,7 +63,7 @@ class stack_ast_filter_201_sig_figs_validation implements stack_cas_astfilter_pa
$pre = explode('.', $raw)[0];
$post = '';
- if (str_contains($raw, '.')) {
+ if (strpos($raw, '.') !== false) {
$post = explode('.', $raw)[1];
}
$min = null;
diff --git a/stack/cas/parsingrules/202_decimal_places_validation.filter.php b/stack/cas/parsingrules/202_decimal_places_validation.filter.php
index 7db8adb9d68415facea455905f20f756a243c4bc..c243e6a0a8fb38a1a334c5e3518e92495403dea4 100644
--- a/stack/cas/parsingrules/202_decimal_places_validation.filter.php
+++ b/stack/cas/parsingrules/202_decimal_places_validation.filter.php
@@ -60,7 +60,7 @@ class stack_ast_filter_202_decimal_places_validation implements stack_cas_astfil
$raw = explode('e', $raw)[0];
$post = '';
- if (str_contains($raw, '.')) {
+ if (strpos($raw, '.') !== false) {
$post = explode('.', $raw)[1];
}
if ($this->min !== null && $this->min > 0) {
diff --git a/stack/cas/parsingrules/450_split_floats.filter.php b/stack/cas/parsingrules/450_split_floats.filter.php
index ed4430d1e14c00bc6fbaa1c87d27b8bc6b07c0da..1136aa73bb5565923e667cb274a695f9c9134ca6 100644
--- a/stack/cas/parsingrules/450_split_floats.filter.php
+++ b/stack/cas/parsingrules/450_split_floats.filter.php
@@ -31,9 +31,9 @@ class stack_ast_filter_450_split_floats implements stack_cas_astfilter_exclusion
$process = function($node) use (&$answernotes) {
if ($node instanceof MP_Float && $node->raw !== null) {
$replacement = false;
- if (str_contains($node->raw, 'e')) {
+ if (strpos($node->raw, 'e') !== false) {
$parts = explode('e', $node->raw);
- if (str_contains($parts[0], '.')) {
+ if (strpos($parts[0], '.') !== false) {
$replacement = new MP_Operation('*', new MP_Float(floatval($parts[0]), $parts[0]),
new MP_Operation('*', new MP_Identifier('e'), new MP_Integer(intval($parts[1]))));
} else {
@@ -49,9 +49,9 @@ class stack_ast_filter_450_split_floats implements stack_cas_astfilter_exclusion
new MP_Identifier('e')), new MP_Integer($val));
$replacement->lhs->position['insertstars'] = true;
}
- } else if (str_contains($node->raw, 'E')) {
+ } else if (strpos($node->raw, 'E') !== false) {
$parts = explode('E', $node->raw);
- if (str_contains($parts[0], '.')) {
+ if (strpos($parts[0], '.') !== false) {
$replacement = new MP_Operation('*', new MP_Float(floatval($parts[0]), $parts[0]),
new MP_Operation('*', new MP_Identifier('E'), new MP_Integer(intval($parts[1]))));
} else {
diff --git a/stack/cas/parsingrules/801_singleton_numeric.filter.php b/stack/cas/parsingrules/801_singleton_numeric.filter.php
index 7f169279f6267a541c8f048adad731782daf508a..8fa4502e826f0a6b4a0d3754eb3aace2b34e2320 100644
--- a/stack/cas/parsingrules/801_singleton_numeric.filter.php
+++ b/stack/cas/parsingrules/801_singleton_numeric.filter.php
@@ -73,7 +73,7 @@ class stack_ast_filter_801_singleton_numeric implements stack_cas_astfilter_para
if ($this->float) {
// Turn floats that are to small or large to powers of ten.
$p = 0;
- if (str_contains($node->toString(), 'E')) {
+ if (strpos($node->toString(), 'E') !== false) {
$p = intval(explode('E', $node->toString())[1]);
}
@@ -279,12 +279,12 @@ class stack_ast_filter_801_singleton_numeric implements stack_cas_astfilter_para
public function float_to_power(MP_Float $float): MP_Node {
$raw = strtolower($float->raw);
$p = 0;
- if (str_contains($raw, 'e')) {
+ if (strpos($raw, 'e') !== false) {
$parts = explode('e', $raw);
$raw = $parts[0];
$p = intval($parts[1]);
}
- if (str_contains($raw, '.')) {
+ if (strpos($raw, '.') !== false) {
$parts = explode('.', $raw);
$raw = $parts[0] . $parts[1];
$p = $p - strlen($parts[1]);
diff --git a/stack/cas/parsingrules/802_singleton_units.filter.php b/stack/cas/parsingrules/802_singleton_units.filter.php
index a7467ad0223b96d81a29fa7308501ba16a2acea2..27d0d113842404b3054d8206bfeb8eb98efb3793 100644
--- a/stack/cas/parsingrules/802_singleton_units.filter.php
+++ b/stack/cas/parsingrules/802_singleton_units.filter.php
@@ -201,7 +201,7 @@ class stack_ast_filter_802_singleton_units implements stack_cas_astfilter_parame
// Check floats and fix if need be.
foreach ($floats as $node) {
- if ((str_contains($node->toString(), 'E') || $this->floattopower) && $node->raw !== null) {
+ if ((strpos($node->toString(), 'E') !== false || $this->floattopower) && $node->raw !== null) {
$p = 0;
$parts = explode('E', $node->toString());
$p = intval($parts[1]);
diff --git a/stack/cas/parsingrules/910_inert_float_for_display.filter.php b/stack/cas/parsingrules/910_inert_float_for_display.filter.php
index 29a1169b2014a7692c74e35c8ee89aedbe37e72f..b6413e654ebfb24e2fda6ab0e17233ffc3fc5549 100644
--- a/stack/cas/parsingrules/910_inert_float_for_display.filter.php
+++ b/stack/cas/parsingrules/910_inert_float_for_display.filter.php
@@ -47,7 +47,7 @@ class stack_ast_filter_910_inert_float_for_display implements stack_cas_astfilte
return true;
}
$dp = 0;
- if (str_contains($raw, '.')) {
+ if (strpos($raw, '.') !== false) {
$parts = explode('.', $raw);
$dp = strlen(explode('e', $parts[1])[0]);
}
diff --git a/stack/input/dropdown/dropdown.class.php b/stack/input/dropdown/dropdown.class.php
index df5bd5caaa61fb970002dbde8ffd2d877c2f18cf..6c33c26ce39ef5e77c644e63637cac244de9b169 100644
--- a/stack/input/dropdown/dropdown.class.php
+++ b/stack/input/dropdown/dropdown.class.php
@@ -176,7 +176,7 @@ class stack_dropdown_input extends stack_input {
if (is_array($value)) {
// Inject strings back if they exist.
foreach ($value as $key => $something) {
- if (str_contains($something, '[STR:')) {
+ if (strpos($something, '[STR:') !== false) {
foreach ($strings as $skey => $string) {
$value[$key] = str_replace("[STR:$skey]", '"' . $string . '"', $value[$key]);
}
diff --git a/stack/maximaparser/corrective_parser.php b/stack/maximaparser/corrective_parser.php
index c79d6c7df3b9c034f25669b46f070da390fc5a13..8865e46d4849ed26c5cebfa4cc41f7304733bedc 100644
--- a/stack/maximaparser/corrective_parser.php
+++ b/stack/maximaparser/corrective_parser.php
@@ -79,9 +79,9 @@ class maxima_corrective_parser {
$stringles = str_replace(array_keys($letters), array_values($letters), $stringles);
// Check for all three of . and , and ; which must indicate inconsistency.
- if (str_contains($stringles, '.') &&
- str_contains($stringles, ',') &&
- str_contains($stringles, ';')) {
+ if (strpos($stringles, '.') !== false &&
+ strpos($stringles, ',') !== false &&
+ strpos($stringles, ';') !== false) {
$errors[] = stack_string('stackCas_decimal_usedthreesep');
}
$decimals = '.';
@@ -90,7 +90,7 @@ class maxima_corrective_parser {
}
if ($decimals == ',') {
// Clearly there is a lot more work to do here to get this all to work!
- if (str_contains($stringles, '.')) {
+ if (strpos($stringles, '.') !== false) {
$answernote[] = 'forbiddenCharDecimal';
$errors[] = stack_string('stackCas_decimal_usedcomma');
return null;
@@ -188,7 +188,7 @@ class maxima_corrective_parser {
$stringles = trim($stringles);
$stringles = preg_replace('!\s+!', ' ', $stringles);
- if (str_contains($stringles, ' ')) {
+ if (strpos($stringles, ' ') !== false) {
// Special cases: allow students to type in expressions such as "x>1 and x<4".
foreach ($safespacepatterns as $key => $pat) {
$stringles = str_replace($key, $pat, $stringles);
@@ -449,7 +449,7 @@ class maxima_corrective_parser {
$cmds = str_replace('@@Is@@', '[[syntaxexamplehighlight]_[syntaxexamplehighlight]]', $cmds);
$answernote[] = 'spaces';
$errors[] = stack_string('stackCas_spaces', ['expr' => stack_maxima_format_casstring($cmds)]);
- } else if ($foundchar === ':' && (str_contains($string, ':lisp'))) {
+ } else if ($foundchar === ':' && (strpos($string, ':lisp') !== false)) {
$errors[] = stack_string('stackCas_forbiddenWord',
['forbid' => stack_maxima_format_casstring('lisp')]);
$answernote[] = 'forbiddenWord';
diff --git a/stack/prt.evaluatable.class.php b/stack/prt.evaluatable.class.php
index 37152a5c60ac7ce4e6c4dda67f76eeb0b2fb8877..3c4a077f0729a3701a92518391fba1d7733d9b67 100644
--- a/stack/prt.evaluatable.class.php
+++ b/stack/prt.evaluatable.class.php
@@ -271,7 +271,7 @@ class prt_evaluatable implements cas_raw_value_extractor {
public function get_fverrors($format='strings') {
$err = [];
foreach ($this->errors as $er) {
- if (str_contains($er->get_context(), '/fv')) {
+ if (strpos($er->get_context(), '/fv') !== false) {
if ($format === 'strings') {
$err[] = $er->get_legacy_error();
} else {
diff --git a/stack/questionreport.class.php b/stack/questionreport.class.php
index 2e52f26f15a5f864f63a62bf7fd5249323260c79..f762fbf8fdc238841ab5b5275cbcc0a4892df7c7 100644
--- a/stack/questionreport.class.php
+++ b/stack/questionreport.class.php
@@ -292,13 +292,13 @@ class stack_question_report {
// Tidy up inputs by (i) trimming status and whitespace, and (2) removing input name.
$datas = trim(substr($data, strlen($input . ':')));
$status = 'other';
- if (str_contains($datas, '[score]')) {
+ if (strpos($datas, '[score]') !== false) {
$status = 'score';
$datas = trim(substr($datas, 0, -7));
- } else if (str_contains($datas, '[valid]')) {
+ } else if (strpos($datas, '[valid]') !== false) {
$status = 'valid';
$datas = trim(substr($datas, 0, -7));
- } else if (str_contains($datas, '[invalid]')) {
+ } else if (strpos($datas, '[invalid]') !== false) {
$status = 'invalid';
$datas = trim(substr($datas, 0, -9));
}
diff --git a/stack/utils.class.php b/stack/utils.class.php
index 53f162ccd3f2a9561cd58564a6c04043d0592514..906293b0e4629bcf95f4495989dce132f654633a 100644
--- a/stack/utils.class.php
+++ b/stack/utils.class.php
@@ -181,7 +181,7 @@ class stack_utils {
$length = strlen($string);
for ($i = 0; $i < $length; $i++) {
$char = $string[$i];
- if (str_contains($lefts, $char)) {
+ if (strpos($lefts, $char) !== false) {
array_push($openstack, $char);
} else if (($closerpos = strpos($rights, $char)) !== false) {
@@ -828,9 +828,9 @@ class stack_utils {
*/
public static function maxima_translate_string(string $string) {
$fixed = $string;
- if (str_contains($string, '0 to a negative exponent')) {
+ if (strpos($string, '0 to a negative exponent') !== false) {
$fixed = stack_string('Maxima_DivisionZero');
- } else if (str_contains($string, 'args: argument must be a non-atomic expression;')) {
+ } else if (strpos($string, 'args: argument must be a non-atomic expression;') !== false) {
$fixed = stack_string('Maxima_Args');
}
return $fixed;
diff --git a/tests/cassession2_test.php b/tests/cassession2_test.php
index 1cec9631b735e26ea628ed3798be3c2721029870..0481d095cc252e9478641f96a5d92fbe76ef87c4 100644
--- a/tests/cassession2_test.php
+++ b/tests/cassession2_test.php
@@ -2190,7 +2190,7 @@ class cassession2_test extends qtype_stack_testcase {
$at1->instantiate();
$actual = $s1[0]->get_dispvalue();
- if (str_contains($actual, 'quantile_gamma(')) {
+ if (strpos($actual, 'quantile_gamma(') !== false) {
// Seems that the distrib package is not available. Skip this test.
$this->markTestSkipped('Skipping because it seems the distrib package is not installed.');
}
diff --git a/tests/fixtures/test_base.php b/tests/fixtures/test_base.php
index c4b3a9524ee3f8ceb228cc9b22435d463544bd64..2c64d00566139c20863c02768c361b1b5d79fbba 100644
--- a/tests/fixtures/test_base.php
+++ b/tests/fixtures/test_base.php
@@ -180,7 +180,7 @@ abstract class qtype_stack_testcase extends advanced_testcase {
function(array $matches): string {
$decimals = strlen(explode('.', $matches[1])[1] ?? '') ?: 0;
$fixedbase = sprintf("%.{$decimals}E", (float)$matches[0]);
- return str_contains($matches[2], '+') ? $fixedbase : str_replace('+', '', $fixedbase);
+ return strpos($matches[2], '+') !== false ? $fixedbase : str_replace('+', '', $fixedbase);
},
$content
);
@@ -317,7 +317,7 @@ abstract class qtype_stack_walkthrough_test_base extends \qbehaviour_walkthrough
$question = $this->quba->get_question($this->slot);
$attempt = $this->quba->get_question_attempt($this->slot);
$qs = $attempt->get_last_step();
- $this->assertTrue(str_contains($qs->get_new_response_summary(), $note));
+ $this->assertTrue(strpos($qs->get_new_response_summary(), $note) !== false);
}
protected function check_output_contains_text_input($name, $value = null, $enabled = true) {
diff --git a/vle_specific.php b/vle_specific.php
index 311fcbcb024a85406caf20ae13408449edac266c..54e22ea675d2eca213676a0fa360a77418b0cd68 100644
--- a/vle_specific.php
+++ b/vle_specific.php
@@ -277,7 +277,7 @@ function stack_fetch_included_content(string $url) {
if (strpos($lc, 'http://') === 0 || strpos($lc, 'https://') === 0) {
$good = true;
} else {
- if (str_contains($path, '..') || strpos($path, '/') === 0 || strpos($path, '~') === 0) {
+ if (strpos($path, '..') !== false || strpos($path, '/') === 0 || strpos($path, '~') === 0) {
$error = 'Traversing the directory tree is forbidden.';
$good = false;
return false;