diff --git a/do_feeds.php b/do_feeds.php
index 66d8a8a47..ca1a23517 100644
--- a/do_feeds.php
+++ b/do_feeds.php
@@ -113,19 +113,29 @@ function dummy_function_1(): array
Tags: |
-
+
-
diff --git a/edit_tword.php b/edit_tword.php
index 9c8053657..550f8389f 100644
--- a/edit_tword.php
+++ b/edit_tword.php
@@ -144,9 +144,9 @@
$sql = 'select WoText, WoLgID, WoTranslation, WoSentence, WoRomanization, WoStatus from ' . $tbpref . 'words where WoID = ' . $wid;
$res = do_mysqli_query($sql);
$record = mysqli_fetch_assoc($res);
- if ($record ) {
- $term = $record['WoText'];
- $lang = $record['WoLgID'];
+ if ($record) {
+ $term = (string) $record['WoText'];
+ $lang = (int) $record['WoLgID'];
$transl = repl_tab_nl($record['WoTranslation']);
if($transl == '*') {
$transl='';
@@ -159,7 +159,7 @@
}
mysqli_free_result($res);
- $termlc = mb_strtolower($term, 'UTF-8');
+ $termlc = mb_strtolower($term, 'UTF-8');
$titletext = "Edit Term: " . tohtml($term);
pagestart_nobody($titletext);
$scrdir = getScriptDirectionTag($lang);
diff --git a/edit_word.php b/edit_word.php
index 806c258e7..cc5d4589d 100644
--- a/edit_word.php
+++ b/edit_word.php
@@ -249,8 +249,8 @@ function edit_word_do_form($wid, $text_id, $ord, $fromAnn)
if ($record === null) {
my_die("Cannot access Term and Language in edit_word.php");
}
- $term = $record['Ti2Text'];
- $lang = $record['Ti2LgID'];
+ $term = (string) $record['Ti2Text'];
+ $lang = (int) $record['Ti2LgID'];
mysqli_free_result($res);
$termlc = mb_strtolower($term, 'UTF-8');
@@ -274,8 +274,8 @@ function edit_word_do_form($wid, $text_id, $ord, $fromAnn)
if (!$record) {
my_die("Cannot access Term and Language in edit_word.php");
}
- $term = $record['WoText'];
- $lang = $record['WoLgID'];
+ $term = (string) $record['WoText'];
+ $lang = (int) $record['WoLgID'];
mysqli_free_result($res);
$termlc = mb_strtolower($term, 'UTF-8');
$new = false;
diff --git a/edit_words.php b/edit_words.php
index ec6014e7f..9218fc8ab 100644
--- a/edit_words.php
+++ b/edit_words.php
@@ -669,7 +669,7 @@
if (isset($_REQUEST['new']) && isset($_REQUEST['lang'])) {
// NEW
- $scrdir = getScriptDirectionTag($_REQUEST['lang']);
+ $scrdir = getScriptDirectionTag((int) $_REQUEST['lang']);
?>
diff --git a/inc/session_utility.php b/inc/session_utility.php
index 2ffe968d5..ebde526f3 100644
--- a/inc/session_utility.php
+++ b/inc/session_utility.php
@@ -3993,7 +3993,7 @@ function get_languages(): array
{
global $tbpref;
$langs = array();
- $sql = "SELECT LgID, LgName FROM " . $tbpref . "languages WHERE LgName<>''";
+ $sql = "SELECT LgID, LgName FROM {$tbpref}languages WHERE LgName<>''";
$res = do_mysqli_query($sql);
while ($record = mysqli_fetch_assoc($res)) {
$langs[(string)$record['LgName']] = (int)$record['LgID'];
@@ -4016,10 +4016,11 @@ function getLanguage($lid)
if (!isset($lid) || trim($lid) == '' || !is_numeric($lid)) {
return '';
}
+ $lg_id = (int) $lid;
$r = get_first_value(
"SELECT LgName AS value
- FROM " . $tbpref . "languages
- WHERE LgID='" . $lid . "'"
+ FROM {$tbpref}languages
+ WHERE LgID = $lg_id"
);
if (isset($r)) {
return (string)$r;
@@ -4027,29 +4028,26 @@ function getLanguage($lid)
return '';
}
-// -------------------------------------------------------------
-
+/**
+ * Return a right-to-left direction indication in HTML if language is right-to-left.
+ *
+ * @param int $lid Language ID
+ *
+ * @return string ' dir="rtl" '|''
+ */
function getScriptDirectionTag($lid): string
{
global $tbpref;
- if (!isset($lid) ) {
- return '';
- }
- if (trim($lid) == '' ) {
- return '';
- }
- if (!is_numeric($lid) ) {
+ if (!isset($lid) || trim($lid) == '' || !is_numeric($lid)) {
return '';
}
$r = get_first_value(
- "select LgRightToLeft as value
- from " . $tbpref . "languages
- where LgID='" . $lid . "'"
+ "SELECT LgRightToLeft as value
+ from {$tbpref}languages
+ where LgID = $lid"
);
- if (isset($r) ) {
- if ($r) {
- return ' dir="rtl" ';
- }
+ if (isset($r) && $r) {
+ return ' dir="rtl" ';
}
return '';
}
diff --git a/long_text_import.php b/long_text_import.php
index b576cfaf2..d188390ff 100644
--- a/long_text_import.php
+++ b/long_text_import.php
@@ -29,11 +29,11 @@
function long_text_check($max_input_vars): void
{
- $langid = $_REQUEST["LgID"];
- $title = $_REQUEST["TxTitle"];
- $paragraph_handling = (int)$_REQUEST["paragraph_handling"];
- $maxsent = $_REQUEST["maxsent"];
- $source_uri = $_REQUEST["TxSourceURI"];
+ $langid = (int) $_REQUEST["LgID"];
+ $title = (string) $_REQUEST["TxTitle"];
+ $paragraph_handling = (int) $_REQUEST["paragraph_handling"];
+ $maxsent = (int) $_REQUEST["maxsent"];
+ $source_uri = (string) $_REQUEST["TxSourceURI"];
$texttags = null;
if (isset($_REQUEST["TextTags"])) {
$texttags = json_encode($_REQUEST["TextTags"]);
@@ -142,7 +142,9 @@ function long_text_check($max_input_vars): void
Length:
Bytes
|
- |
diff --git a/show_word.php b/show_word.php
index 2bc6d841b..5e5c47c06 100644
--- a/show_word.php
+++ b/show_word.php
@@ -31,7 +31,7 @@
$tags = getWordTagList($wid, '', 0, 0);
$rom = $record['WoRomanization'];
- $scrdir = getScriptDirectionTag($record['WoLgID']);
+ $scrdir = getScriptDirectionTag((int) $record['WoLgID']);
?>