mirror of
https://bitbucket.org/jsuto/piler.git
synced 2024-12-25 06:20:12 +01:00
Introduced sphinx strict mode variable
Signed-off-by: Janos SUTO <sj@acts.hu>
This commit is contained in:
parent
ea16911a03
commit
b2fd28423b
@ -238,6 +238,7 @@ $config['SPHINX_MAIN_INDEX'] = 'main1,dailydelta1,delta1';
|
|||||||
$config['SPHINX_ATTACHMENT_INDEX'] = 'att1';
|
$config['SPHINX_ATTACHMENT_INDEX'] = 'att1';
|
||||||
$config['SPHINX_TAG_INDEX'] = 'tag1';
|
$config['SPHINX_TAG_INDEX'] = 'tag1';
|
||||||
$config['SPHINX_NOTE_INDEX'] = 'note1';
|
$config['SPHINX_NOTE_INDEX'] = 'note1';
|
||||||
|
$config['SPHINX_STRICT_SCHEMA'] = 0;
|
||||||
|
|
||||||
$config['RELOAD_COMMAND'] = 'sudo -n /etc/init.d/rc.piler reload';
|
$config['RELOAD_COMMAND'] = 'sudo -n /etc/init.d/rc.piler reload';
|
||||||
$config['PILERIMPORT_IMAP_COMMAND'] = '/usr/local/bin/pilerimport -d /var/piler/imap -q -r';
|
$config['PILERIMPORT_IMAP_COMMAND'] = '/usr/local/bin/pilerimport -d /var/piler/imap -q -r';
|
||||||
@ -517,5 +518,14 @@ if(!isset($health_smtp_servers)) {
|
|||||||
$health_smtp_servers = array( array(PILER_HOST, PILER_PORT, "piler"), array(SMARTHOST, SMARTHOST_PORT, "smarthost") );
|
$health_smtp_servers = array( array(PILER_HOST, PILER_PORT, "piler"), array(SMARTHOST, SMARTHOST_PORT, "smarthost") );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(SPHINX_STRICT_SCHEMA) {
|
||||||
?>
|
define('FROM_TOKEN', '@sender');
|
||||||
|
define('FROMDOMAIN_TOKEN', '@senderdomain');
|
||||||
|
define('TO_TOKEN', '@rcpt');
|
||||||
|
define('TODOMAIN_TOKEN', '@rcptdomain');
|
||||||
|
} else {
|
||||||
|
define('FROM_TOKEN', '@from');
|
||||||
|
define('FROMDOMAIN_TOKEN', '@fromdomain');
|
||||||
|
define('TO_TOKEN', '@to');
|
||||||
|
define('TODOMAIN_TOKEN', '@todomain');
|
||||||
|
}
|
||||||
|
@ -13,7 +13,19 @@ define('SPHINX_CHARSET_TABLE', "0..9, english, _, \
|
|||||||
U+01FD->U+E6, U+1D01->U+E6, U+1D02->U+E6, U+1D2D->U+E6, U+1D46->U+E6, \
|
U+01FD->U+E6, U+1D01->U+E6, U+1D02->U+E6, U+1D2D->U+E6, U+1D46->U+E6, \
|
||||||
U+DF, U+E1, U+E4, U+E5, U+E6, U+E9, U+ED, U+00F3, U+F6, U+F8, U+FA, U+FC, U+0151, U+0153, U+0171\n");
|
U+DF, U+E1, U+E4, U+E5, U+E6, U+E9, U+ED, U+00F3, U+F6, U+F8, U+FA, U+FC, U+0151, U+0153, U+0171\n");
|
||||||
|
|
||||||
define('SELECT_FIELDS', 'id, `from`, `to`, `fromdomain`, `todomain`, `subject`, `arrived`, `sent`, `body`, `size`, `direction`, `folder`, `attachments`, `attachment_types`');
|
// Sphinx 3.3.1 introduced some strict rules for fulltext search column names
|
||||||
|
// In order to comply with it you must enable SPHINX_STRICT_SCHEMA variable
|
||||||
|
// Be sure to check out http://www.mailpiler.org/wiki/current:sphinx3 for more
|
||||||
|
// NB: The SPHINX_STRICT_SCHEMA in sphinx.conf MUST BE THE SAME as in config.php (or in config-site.php)
|
||||||
|
//
|
||||||
|
define('SPHINX_STRICT_SCHEMA', 0);
|
||||||
|
|
||||||
|
|
||||||
|
if(SPHINX_STRICT_SCHEMA) {
|
||||||
|
define('SELECT_FIELDS', 'id, `from` as sender, `to` as rcpt, `fromdomain` as senderdomain, `todomain` as rcptdomain, `subject`, `arrived`, `sent`, `body`, `size`, `direction`, `folder`, `attachments`, `attachment_types`');
|
||||||
|
} else {
|
||||||
|
define('SELECT_FIELDS', 'id, `from`, `to`, `fromdomain`, `todomain`, `subject`, `arrived`, `sent`, `body`, `size`, `direction`, `folder`, `attachments`, `attachment_types`');
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
@ -98,8 +98,8 @@ class ControllerSearchHelper extends Controller {
|
|||||||
private function fixup_post_simple_request() {
|
private function fixup_post_simple_request() {
|
||||||
$match = '';
|
$match = '';
|
||||||
|
|
||||||
if(isset($this->request->post['from']) && $this->request->post['from']) { $match .= "@from " . $this->request->post['from'] . ' '; }
|
if(isset($this->request->post['from']) && $this->request->post['from']) { $match .= sprintf('%s %s ', FROM_TOKEN, $this->request->post['from']); }
|
||||||
if(isset($this->request->post['to']) && $this->request->post['to']) { $match .= "@to " . $this->request->post['to'] . ' '; }
|
if(isset($this->request->post['to']) && $this->request->post['to']) { $match .= sprintf('%s %s ', TO_TOKEN, $this->request->post['to']); }
|
||||||
if(isset($this->request->post['subject']) && $this->request->post['subject']) { $match .= "@subject " . $this->request->post['subject'] . ' '; }
|
if(isset($this->request->post['subject']) && $this->request->post['subject']) { $match .= "@subject " . $this->request->post['subject'] . ' '; }
|
||||||
if(isset($this->request->post['body']) && $this->request->post['body']) { $match .= "@body " . $this->request->post['body'] . ' '; }
|
if(isset($this->request->post['body']) && $this->request->post['body']) { $match .= "@body " . $this->request->post['body'] . ' '; }
|
||||||
|
|
||||||
@ -149,7 +149,7 @@ class ControllerSearchHelper extends Controller {
|
|||||||
}
|
}
|
||||||
else if(strchr($v, '@')) {
|
else if(strchr($v, '@')) {
|
||||||
$prev_token_is_email = 1;
|
$prev_token_is_email = 1;
|
||||||
if($from == '') { $from = "@from"; }
|
if($from == '') { $from = FROM_TOKEN; }
|
||||||
$from .= " $v";
|
$from .= " $v";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -73,7 +73,7 @@ class ModelSearchSearch extends Model {
|
|||||||
|
|
||||||
$sd = preg_replace("/^\|/", "", $sd);
|
$sd = preg_replace("/^\|/", "", $sd);
|
||||||
|
|
||||||
return " (@todomain $sd | @fromdomain $sd ) ";
|
return sprintf(" (%s %s | %s %s ) ", TODOMAIN_TOKEN, $sd, FROMDOMAIN_TOKEN, $sd);
|
||||||
}
|
}
|
||||||
|
|
||||||
else { return ""; }
|
else { return ""; }
|
||||||
@ -82,7 +82,7 @@ class ModelSearchSearch extends Model {
|
|||||||
if(ENABLE_FOLDER_RESTRICTIONS == 1) { return ""; }
|
if(ENABLE_FOLDER_RESTRICTIONS == 1) { return ""; }
|
||||||
|
|
||||||
$all_your_addresses = $this->get_all_your_address();
|
$all_your_addresses = $this->get_all_your_address();
|
||||||
return " (@from $all_your_addresses | @to $all_your_addresses) ";
|
return sprintf(" (%s %s | %s %s) ", FROM_TOKEN, $all_your_addresses, TO_TOKEN, $all_your_addresses);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -96,7 +96,7 @@ class ModelSearchSearch extends Model {
|
|||||||
$id = "";
|
$id = "";
|
||||||
$offset = 0;
|
$offset = 0;
|
||||||
$total_sphx_hits = $num_rows = 0;
|
$total_sphx_hits = $num_rows = 0;
|
||||||
$fields = array("@(subject,body)", "@from", "@to", "@subject", "@body", "@attachment_types");
|
$fields = ["@(subject,body)", FROM_TOKEN, TO_TOKEN, "@subject", "@body", "@attachment_types"];
|
||||||
|
|
||||||
|
|
||||||
$pagelen = get_page_length();
|
$pagelen = get_page_length();
|
||||||
@ -128,8 +128,8 @@ class ModelSearchSearch extends Model {
|
|||||||
|
|
||||||
if(substr($v, 0, 1) == "@") {
|
if(substr($v, 0, 1) == "@") {
|
||||||
$v = substr($v, 1, strlen($v)-1);
|
$v = substr($v, 1, strlen($v)-1);
|
||||||
if($data['match'][$i-1] == "@from") { $data['match'][$i-1] = "@fromdomain"; }
|
if($data['match'][$i-1] == FROM_TOKEN) { $data['match'][$i-1] = FROMDOMAIN_TOKEN; }
|
||||||
if($data['match'][$i-1] == "@to") { $data['match'][$i-1] = "@todomain"; }
|
if($data['match'][$i-1] == TO_TOKEN) { $data['match'][$i-1] = TODOMAIN_TOKEN; }
|
||||||
}
|
}
|
||||||
|
|
||||||
$data['match'][$i] = $this->fix_email_address_for_sphinx($v);
|
$data['match'][$i] = $this->fix_email_address_for_sphinx($v);
|
||||||
@ -351,8 +351,8 @@ class ModelSearchSearch extends Model {
|
|||||||
while(list($k, $v) = each($b)) {
|
while(list($k, $v) = each($b)) {
|
||||||
if($v == '') { continue; }
|
if($v == '') { continue; }
|
||||||
|
|
||||||
if($v == 'from:') { $token = 'match'; $a['match'][] = '@from'; continue; }
|
if($v == 'from:') { $token = 'match'; $a['match'][] = FROM_TOKEN; continue; }
|
||||||
else if($v == 'to:') { $token = 'match'; $a['match'][] = '@to'; continue; }
|
else if($v == 'to:') { $token = 'match'; $a['match'][] = TO_TOKEN; continue; }
|
||||||
else if($v == 'subject:') { $token = 'match'; $a['match'][] = '@subject'; continue; }
|
else if($v == 'subject:') { $token = 'match'; $a['match'][] = '@subject'; continue; }
|
||||||
else if($v == 'body:') { $token = 'match'; $a['match'][] = '@body'; continue; }
|
else if($v == 'body:') { $token = 'match'; $a['match'][] = '@body'; continue; }
|
||||||
else if($v == 'direction:' || $v == 'd:') { $token = 'direction'; continue; }
|
else if($v == 'direction:' || $v == 'd:') { $token = 'direction'; continue; }
|
||||||
|
Loading…
Reference in New Issue
Block a user