Integrate Sphider search engine with CodeIgniter

2019-09-03 11:26发布

问题:

I want to integrate Sphider search engine with CodeIgniter framework, but I have no idea how to do it.

Someone have a solution for this?

回答1:

This can be done by marge core php and codeigniter .. put your sphider folder with your application folder

-application

-sphider

-system

-etc

Make sure set database setting in sphider folder /sphider/setting/database.php

if u r using .htaccess then add sphider folder to it.

Then Make One controller in application like this

public function index()
{
        $url = $this->base_url.'sphider/admin/spider.php';
        $fields = array(
                    'url' => urlencode("URL OF YOUR Page That you want to index"),
                    'soption' => urlencode("level"),
                    'maxlavel' => urlencode("0"),//1,2
                    'reindex' => urlencode("1") //0,1
            );


    $fields_string="";
    foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
    rtrim($fields_string, '&');

    //open connection
    $ch = curl_init();

    //set the url, number of POST vars, POST data
    curl_setopt($ch,CURLOPT_URL, $url);
    curl_setopt($ch,CURLOPT_POST, count($fields));
    curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);

    //execute post
    //error_reporting(E_ERROR | E_PARSE);
    $result = curl_exec($ch);
    error_reporting(E_ERROR | E_PARSE);
    //close connection
    curl_close($ch);

    redirect("YOUR REDIRECTING URL");
}

}

and you are done with indexing.