Skip to content

Instantly share code, notes, and snippets.

@dlenettr
Created September 19, 2014 09:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dlenettr/21f5a4c969ae6426314c to your computer and use it in GitHub Desktop.
Save dlenettr/21f5a4c969ae6426314c to your computer and use it in GitHub Desktop.
İlave Alanlar için Çoklu Arama (252)
// İlave alan çoklu arama
} elseif ($do == 'xfsearch') {
if ($cstart) {
$cstart = $cstart - 1;
$cstart = $cstart * $config['news_number'];
}
$fields = array(
'year' => "Yıl",
'country' => "Ülke",
'rating' => "Değerlendirme",
'il' => "İl",
'ilce' => "İlçe", // Bu alanların nasıl kullanıldığı hakkında bilgi: http://dle.net.tr/dle-eklenti/252-ilave-alanlar-icin-coklu-arama.html
);
$newsmodule = true; $stop_xf = false;
$xf = $_GET['xf'];
if ( $config['charset'] == "utf-8" AND $config['charset'] != detect_encoding($xf) ) {
$xf = iconv( "UTF-8", "utf-8//IGNORE", $xf );
}
// Field Control
if ( strpos($xf, "|") !== false ) { $xfs = explode("|", $xf); $xfs = array_filter( $xfs ); foreach( $xfs as $xfv ) { $_tmp = explode( ":", $xfv); if (!in_array( $_tmp[0], array_keys( $fields ))) { msgbox( "Hata", "Bu alan için arama yapamazsınız." ); break; } } }
if ( strpos($xf, "|") !== false ) {
$xfs = explode("|", $xf); $xfs = array_filter( $xfs ); $_xf = array();
foreach( $xfs as $xfk => $xfv ) {
if (!empty($xfv)) {
$xfv = @$db->safesql ( htmlspecialchars ( strip_tags ( stripslashes ( trim ( $xfv ) ) ), ENT_QUOTES, $config['charset'] ) );
$xfv = str_replace( ":", "|", $xfv );
$_xf[] = "xfields LIKE '%{$xfv}%'";
}
}
$_xf = implode( " AND ", $_xf );
$url_page = $config['http_home_url'] . "xfsearch/" . urlencode ( str_replace("'", "'", $xf) );
$user_query = "do=xfsearch&xf=" . urlencode ( str_replace("'", "'", $xf) );
$sql_select = "SELECT SQL_CALC_FOUND_ROWS p.id, p.autor, p.date, p.short_story, CHAR_LENGTH(p.full_story) as full_story, p.xfields, p.title, p.category, p.alt_name, p.comm_num, p.allow_comm, p.fixed, p.tags, e.news_read, e.allow_rate, e.rating, e.vote_num, e.votes, e.view_edit, e.editdate, e.editor, e.reason FROM " . PREFIX . "_post p LEFT JOIN " . PREFIX . "_post_extras e ON (p.id=e.news_id) WHERE {$stop_list}{$_xf} AND approve=1" . $where_date . " ORDER BY " . $news_sort_by . " " . $news_direction_by . " LIMIT " . $cstart . "," . $config['news_number'];
$sql_count = "SELECT FOUND_ROWS() as count";
$allow_active_news = true;
$spdbar = array();
foreach ($xfs as $xfsv) {
$_tmp = explode( ":", $xfsv);
$spdbar[] = $fields[ $_tmp[0] ] . " : " . $_tmp[1];
}
$xf = implode( " & ", $spdbar ); // Speedbar aralardaki işaret: & yani &
} else {
$xf = @$db->safesql ( htmlspecialchars ( strip_tags ( stripslashes ( trim ( $xf ) ) ), ENT_QUOTES, $config['charset'] ) );
$url_page = $config['http_home_url'] . "xfsearch/" . urlencode ( str_replace("'", "'", $xf) );
$user_query = "do=xfsearch&xf=" . urlencode ( str_replace("'", "'", $xf) );
if (isset ( $_SESSION['dle_sort_xfsearch'] )) $news_sort_by = $_SESSION['dle_sort_xfsearch'];
if (isset ( $_SESSION['dle_direction_xfsearch'] )) $news_direction_by = $_SESSION['dle_direction_xfsearch'];
$sql_select = "SELECT SQL_CALC_FOUND_ROWS p.id, p.autor, p.date, p.short_story, CHAR_LENGTH(p.full_story) as full_story, p.xfields, p.title, p.category, p.alt_name, p.comm_num, p.allow_comm, p.fixed, p.tags, e.news_read, e.allow_rate, e.rating, e.vote_num, e.votes, e.view_edit, e.editdate, e.editor, e.reason FROM " . PREFIX . "_post p LEFT JOIN " . PREFIX . "_post_extras e ON (p.id=e.news_id) WHERE {$stop_list}xfields LIKE '%{$xf}%' AND approve=1" . $where_date . " ORDER BY " . $news_sort_by . " " . $news_direction_by . " LIMIT " . $cstart . "," . $config['news_number'];
$sql_count = "SELECT FOUND_ROWS() as count";
$allow_active_news = true;
}
// İlave alan çoklu arama
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment