Skip to content

Commit affc02d

Browse files
committed
v1.6.3 bugfix multibyte substr mwords
1 parent 83ebd58 commit affc02d

4 files changed

Lines changed: 25 additions & 22 deletions

File tree

‎edit_mword.php‎

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,10 @@
130130
$termchar = $record['LgRegexpWordCharacters'];
131131
$splitEachChar = $record['LgSplitEachChar'];
132132
$rtlScript = $record['LgRightToLeft'];
133-
mysql_free_result($res);$appendtext=array();
133+
mysql_free_result($res);
134+
$appendtext=array();
135+
$sid=array();
136+
$sqlarr=array();
134137
if ($splitEachChar) {
135138
$textlc = preg_replace('/([^\s])/u', "$1 ", $textlc);
136139
}
@@ -144,12 +147,12 @@
144147
$string= ' ' . ($splitEachChar?preg_replace('/([^\s])/u', "$1 ", $record['SeText']):$record['SeText']) . ' ';
145148
$txtid =$record['SeTxID'];
146149
$sentid =$record['SeID'];
147-
$last_pos = strripos ( $string , $textlc );
150+
$last_pos = mb_strripos ( $string , $textlc , 0, 'UTF-8');
148151
$sentoffset = preg_match('/[^' . $termchar . ']/ui', mb_substr($string,1,1, 'UTF-8'));
149152
while($last_pos!==false){
150153
$matches=array();
151154
if($splitEachChar || preg_match ( $notermchar, $string, $matches, 0, $last_pos - 1)==1){
152-
$string = substr ( $string, 0, $last_pos );
155+
$string = mb_substr ( $string, 0, $last_pos, 'UTF-8' );
153156
$cnt = preg_match_all('/([' . $termchar . ']+)/u',$string,$ma);
154157
$pos=2*$cnt+$record['SeFirstPos'] + $sentoffset;
155158
$txt='';
@@ -162,11 +165,11 @@
162165
}
163166
else $appendtext[$pos]=$splitEachChar?$wis:$matches[1];
164167
}
165-
$last_pos = strripos ( $string , $textlc );
168+
$last_pos = mb_strripos ( $string , $textlc , 0, 'UTF-8' );
166169
}
167170
else{
168-
$string = substr ( $string, 0, $last_pos );
169-
$last_pos = strripos ( $string , $textlc );
171+
$string = mb_substr ( $string, 0, $last_pos, 'UTF-8' );
172+
$last_pos = mb_strripos ( $string , $textlc , 0, 'UTF-8' );
170173
}
171174
}
172175
}
@@ -304,7 +307,7 @@
304307
<table class="tab2" cellspacing="0" cellpadding="5">
305308
<tr title="Only change uppercase/lowercase!">
306309
<td class="td1 right"><b>New Term:</b></td>
307-
<td class="td1"><input <?php echo $scrdir; ?> class="notempty" type="text" name="WoText" id="wordfield" value="<?php echo tohtml($term); ?>" maxlength="250" size="35" /> <img src="icn/status-busy.png" title="Field must not be empty" alt="Field must not be empty" />
310+
<td class="td1" style="border-top-right-radius:inherit;"><input <?php echo $scrdir; ?> class="notempty" type="text" name="WoText" id="wordfield" value="<?php echo tohtml($term); ?>" maxlength="250" size="35" /> <img src="icn/status-busy.png" title="Field must not be empty" alt="Field must not be empty" />
308311
</td></tr>
309312
<?php print_similar_terms_tabrow(); ?>
310313
<tr>

‎edit_words.php‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -405,22 +405,22 @@
405405
$string= ' ' . ($splitEachChar?preg_replace('/([^\s])/u', "$1 ", $record['SeText']):$record['SeText']) . ' ';
406406
$txtid =$record['SeTxID'];
407407
$sentid =$record['SeID'];
408-
$last_pos = strripos ( $string , $textlc );
408+
$last_pos = mb_strripos ( $string , $textlc , 0, 'UTF-8' );
409409
$sentoffset = preg_match('/[^' . $termchar . ']/ui', mb_substr($string,1,1, 'UTF-8'));
410410
while($last_pos!==false){
411411
$matches=array();
412412
if($splitEachChar || preg_match ( $notermchar, $string, $matches, 0, $last_pos - 1)==1){
413-
$string = substr ( $string, 0, $last_pos );
413+
$string = mb_substr ( $string, 0, $last_pos , 'UTF-8');
414414
$cnt = preg_match_all('/([' . $termchar . ']+)/u',$string,$ma);
415415
$pos=2*$cnt+$record['SeFirstPos'] + $sentoffset;
416416
$txt='';
417417
if($len==1 || !($matches[1]==$textlc))$txt=$splitEachChar?$wis:$matches[1];
418418
$sqlarr[] = '(' . $wid . ',' . $lid . ',' . $txtid . ',' . $sentid . ',' . $pos . ',' . $len . ',' . convert_string_to_sqlsyntax_notrim_nonull($txt) . ')';
419-
$last_pos = strripos ( $string , $textlc );
419+
$last_pos = mb_strripos ( $string , $textlc , 0, 'UTF-8' );
420420
}
421421
else{
422-
$string = substr ( $string, 0, $last_pos );
423-
$last_pos = strripos ( $string , $textlc );
422+
$string = mb_substr ( $string, 0, $last_pos, 'UTF-8' );
423+
$last_pos = mb_strripos ( $string , $textlc , 0, 'UTF-8' );
424424
}
425425
}
426426
}

‎new_word.php‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,12 @@
111111
$string= ' ' . ($splitEachChar?preg_replace('/([^\s])/u', "$1 ", $record['SeText']):$record['SeText']) . ' ';
112112
$txtid =$record['SeTxID'];
113113
$sentid =$record['SeID'];
114-
$last_pos = strripos ( $string , $textlc );
114+
$last_pos = mb_strripos ( $string , $textlc , 0, 'UTF-8' );
115115
$sentoffset = preg_match('/[^' . $termchar . ']/ui', mb_substr($string,1,1, 'UTF-8'));
116116
while($last_pos!==false){
117117
$matches=array();
118118
if($splitEachChar || preg_match ( $notermchar, $string, $matches, 0, $last_pos - 1)==1){
119-
$string = substr ( $string, 0, $last_pos );
119+
$string = mb_substr ( $string, 0, $last_pos, 'UTF-8' );
120120
$cnt = preg_match_all('/([' . $termchar . ']+)/u',$string,$ma);
121121
$pos=2*$cnt+$record['SeFirstPos'] + $sentoffset;
122122
$txt='';
@@ -129,11 +129,11 @@
129129
}
130130
else $appendtext[$pos]=$splitEachChar?$wis:$matches[1];
131131
}
132-
$last_pos = strripos ( $string , $textlc );
132+
$last_pos = mb_strripos ( $string , $textlc , 0, 'UTF-8' );
133133
}
134134
else{
135-
$string = substr ( $string, 0, $last_pos );
136-
$last_pos = strripos ( $string , $textlc );
135+
$string = mb_substr ( $string, 0, $last_pos , 'UTF-8');
136+
$last_pos = mb_strripos ( $string , $textlc , 0, 'UTF-8' );
137137
}
138138
}
139139
}

‎upload_words.php‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -226,12 +226,12 @@ function savetag($item, $key, $wid) {
226226
$string= ' ' . ($splitEachChar?preg_replace('/([^\s])/u', "$1 ", $record2['SeText']):$record2['SeText']) . ' ';
227227
$txtid =$record2['SeTxID'];
228228
$sentid =$record2['SeID'];
229-
$last_pos = strripos ( $string , $textlc );
229+
$last_pos = mb_strripos ( $string , $textlc , 0, 'UTF-8' );
230230
$sentoffset = preg_match('/[^' . $termchar . ']/ui', mb_substr($string,1,1, 'UTF-8'));
231231
while($last_pos!==false){
232232
$matches=array();
233233
if($splitEachChar || preg_match ( $notermchar, $string, $matches, 0, $last_pos - 1)==1){
234-
$string = substr ( $string, 0, $last_pos );
234+
$string = mb_substr ( $string, 0, $last_pos , 'UTF-8' );
235235
$cnt = preg_match_all('/([' . $termchar . ']+)/u',$string,$ma);
236236
$pos=2*$cnt+$record2['SeFirstPos'] + $sentoffset;
237237
if($len!=1){
@@ -242,11 +242,11 @@ function savetag($item, $key, $wid) {
242242
else{
243243
$twidarr[] = ' WHEN Ti2SeID = ' . $sentid . ' AND Ti2Order = ' . $pos . ' THEN ' . $wid;
244244
}
245-
$last_pos = strripos ( $string , $textlc );
245+
$last_pos = mb_strripos ( $string , $textlc , 0, 'UTF-8' );
246246
}
247247
else{
248-
$string = substr ( $string, 0, $last_pos );
249-
$last_pos = strripos ( $string , $textlc );
248+
$string = mb_substr ( $string, 0, $last_pos , 'UTF-8' );
249+
$last_pos = mb_strripos ( $string , $textlc , 0, 'UTF-8' );
250250
}
251251
}
252252
}

0 commit comments

Comments
 (0)