Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
- <!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
- <!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
- <!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
- <head>
- <meta charset="utf-8" />
- <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
- <title>Sphinx Search</title>
- <link rel="stylesheet" type="text/css" media="screen" href="style.css" />
- <script language="javascript" type="text/javascript" src="jquery-1.7.1.min.js"></script>
- <script type="text/javascript">
- jQuery(document).ready(function(){
- var x = "<?php echo ( isset( $_POST['q'] ) && $_POST['q'] != '') ? $_POST['q'] : '';?>";
- if(x) {
- jQuery('#submit').click();
- }
- });
- </script>
- <body>
- <section>
- <div class="top">
- <a href="index.php" class="logo"><img src="images/findit.png" /></a>
- <form method="get" action="">
- <input type="text" name="q" size="70" id="search" value="<?php if(isset($_POST['q'])){ echo $_POST['q']; }elseif(isset($_GET['q'])){ echo $_GET['q']; }?>"/>
- <input type="submit" name="op" value="search" id="submit"/></p>
- </form>
- </div>
- <div class="result">
- <?php
- if(isset($_GET['q'])){
- require ( "sphinxapi.php" );
- $cl = new SphinxClient();
- $cl->SetArrayResult(TRUE);
- $cl->SetMatchMode(SPH_MATCH_EXTENDED);
- $cl->SetRankingMode (SPH_RANK_BM25);
- $res = $cl->Query($_GET['q']);
- if ( $res===false ){
- print "Query failed: " . $cl->GetLastError() .".\n";
- }else{
- echo '<p>'.$cl->GetLastWarning().'</p>';
- echo '<p class="total">About '.$res['total'].' result for <em><b>'.$_GET['q'].'</em></b> ('.$res['time'].' detik)</p><ol style=font-family:arial,sans-serif;color:black;text-align:left>';
- if($res['total']!=0){
- foreach($res['matches'] as $data){
- //print_r($data);
- //echo "<pre>";
- echo "<li><h1>";
- $katasubject = explode(" ",$data['attrs']['title']);
- for($z=0;$z<=$res['total'];$z++){
- if(strtolower($katasubject[$z]) == $_GET['q'] || strtoupper($katasubject[$z]) == $_GET['q'] || $katasubject[$z] == $_GET['q']){
- echo "<strong style='background:yellow;'>".$katasubject[$z]."</strong>";
- }else{ echo $katasubject[$z]." "; }
- }
- echo "...</h1><p>";
- $katacontent = explode(" ",$data['attrs']['content']);
- for($z=0;$z<=50;$z++)
- {
- if(strtolower($katacontent[$z]) == $_GET['q'] || strtoupper($katacontent[$z]) == $_GET['q'] ||$katacontent[$z] == $_GET['q']) {
- echo "<strong style='background:yellow;'>".$katacontent[$z]." </strong>";
- }else{ echo $katacontent[$z]." "; }
- }
- echo "...</p>";
- echo "</li>";
- }
- }
- }
- }else{ echo 'data tidak ditemukan.'; }
- ?>
- </div>
- </section>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement