Fix search.php to more properly handle multibyte strings
This commit is contained in:
parent
f3f9923c5d
commit
19143de4d7
|
@ -126,12 +126,25 @@ $results=0;
|
||||||
$database = $spooldir.'/'.$config_name.'-overview.db3';
|
$database = $spooldir.'/'.$config_name.'-overview.db3';
|
||||||
$table = 'overview';
|
$table = 'overview';
|
||||||
$dbh = rslight_db_open($database, $table);
|
$dbh = rslight_db_open($database, $table);
|
||||||
|
$overview = array();
|
||||||
if($dbh) {
|
if($dbh) {
|
||||||
// $stmt = $dbh->prepare("SELECT * FROM $table WHERE ".$_POST['searchpoint']." like '%".$_POST['terms']."%' ORDER BY date DESC");
|
if(is_multibyte($_POST['terms'])) {
|
||||||
$stmt = $dbh->prepare("SELECT * FROM $table WHERE ".$_POST['searchpoint']." like :terms ORDER BY date DESC");
|
$stmt = $dbh->query("SELECT * FROM $table");
|
||||||
$stmt->bindParam(':terms', $searchterms);
|
while($row = $stmt->fetch()) {
|
||||||
$stmt->execute();
|
if(stripos(quoted_printable_decode(mb_decode_mimeheader($row[$_POST['searchpoint']])), $_POST['terms']) !== false) {
|
||||||
while($overviewline = $stmt->fetch()) {
|
$overview[] = $row;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$stmt = $dbh->prepare("SELECT * FROM $table WHERE ".$_POST['searchpoint']." like :terms ORDER BY date DESC");
|
||||||
|
$stmt->bindParam(':terms', $searchterms);
|
||||||
|
$stmt->execute();
|
||||||
|
while($found = $stmt->fetch()) {
|
||||||
|
$overview[] = $found;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$dbh = null;
|
||||||
|
foreach($overview as $overviewline) {
|
||||||
# Generate link
|
# Generate link
|
||||||
$url = $thissite."/article-flat.php?id=".$overviewline['number']."&group="._rawurlencode($overviewline['newsgroup'])."#".$overviewline['number'];
|
$url = $thissite."/article-flat.php?id=".$overviewline['number']."&group="._rawurlencode($overviewline['newsgroup'])."#".$overviewline['number'];
|
||||||
$groupurl = $thissite."/thread.php?group="._rawurlencode($overviewline['newsgroup']);
|
$groupurl = $thissite."/thread.php?group="._rawurlencode($overviewline['newsgroup']);
|
||||||
|
@ -164,12 +177,11 @@ $results=0;
|
||||||
echo '<a href="'.$groupurl.'">'.$overviewline['newsgroup'].'</a>';
|
echo '<a href="'.$groupurl.'">'.$overviewline['newsgroup'].'</a>';
|
||||||
echo '</p>';
|
echo '</p>';
|
||||||
|
|
||||||
echo '<p class=np_ob_posted_date>Posted: '.$newdate.' by: '.mb_decode_mimeheader($lastname).'</p>';
|
echo '<p class=np_ob_posted_date>Posted: '.$newdate.' by: '.mb_decode_mimeheader($overviewline['name']).'</p>';
|
||||||
echo '</td></tr>';
|
echo '</td></tr>';
|
||||||
if($results++ > ($maxdisplay - 2))
|
if($results++ > ($maxdisplay - 2))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$dbh = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
echo '</table>';
|
echo '</table>';
|
||||||
|
|
Loading…
Reference in New Issue