Browse Source

Fix the search engine, more or less

pjc 5 years ago
parent
commit
00eb520c51

+ 125
- 115
classes/sphinxql.class.php View File

@@ -1,121 +1,130 @@
1
-<?
1
+<?php
2 2
 if (!extension_loaded('mysqli')) {
3
-  error('Mysqli Extension not loaded.');
3
+    error('Mysqli Extension not loaded.');
4 4
 }
5 5
 
6
-class Sphinxql extends mysqli {
7
-  private static $Connections = [];
8
-  private $Server;
9
-  private $Port;
10
-  private $Socket;
11
-  private $Ident;
12
-  private $Connected = false;
6
+class Sphinxql extends mysqli
7
+{
8
+    private static $Connections = [];
9
+    private $Server;
10
+    private $Port;
11
+    private $Socket;
12
+    private $Ident;
13
+    private $Connected = false;
13 14
 
14
-  public static $Queries = [];
15
-  public static $Time = 0.0;
15
+    public static $Queries = [];
16
+    public static $Time = 0.0;
16 17
 
17 18
 
18
-  /**
19
-   * Initialize Sphinxql object
20
-   *
21
-   * @param string $Server server address or hostname
22
-   * @param int $Port listening port
23
-   * @param string $Socket Unix socket address, overrides $Server:$Port
24
-   */
25
-  public function __construct($Server, $Port, $Socket) {
26
-    $this->Server = $Server;
27
-    $this->Port = $Port;
28
-    $this->Socket = $Socket;
29
-    $this->Ident = self::get_ident($Server, $Port, $Socket);
30
-  }
31
-
32
-  /**
33
-   * Create server ident based on connection information
34
-   *
35
-   * @param string $Server server address or hostname
36
-   * @param int $Port listening port
37
-   * @param string $Socket Unix socket address, overrides $Server:$Port
38
-   * @return identification string
39
-   */
40
-  private static function get_ident($Server, $Port, $Socket) {
41
-    if ($Socket) {
42
-      return $Socket;
43
-    } else {
44
-      return "$Server:$Port";
19
+    /**
20
+     * Initialize Sphinxql object
21
+     *
22
+     * @param string $Server server address or hostname
23
+     * @param int $Port listening port
24
+     * @param string $Socket Unix socket address, overrides $Server:$Port
25
+     */
26
+    public function __construct($Server, $Port, $Socket)
27
+    {
28
+        $this->Server = $Server;
29
+        $this->Port = $Port;
30
+        $this->Socket = $Socket;
31
+        $this->Ident = self::get_ident($Server, $Port, $Socket);
45 32
     }
46
-  }
47 33
 
48
-  /**
49
-   * Create Sphinxql object or return existing one
50
-   *
51
-   * @param string $Server server address or hostname
52
-   * @param int $Port listening port
53
-   * @param string $Socket Unix socket address, overrides $Server:$Port
54
-   * @return Sphinxql object
55
-   */
56
-  public static function init_connection($Server, $Port, $Socket) {
57
-    $Ident = self::get_ident($Server, $Port, $Socket);
58
-    if (!isset(self::$Connections[$Ident])) {
59
-      self::$Connections[$Ident] = new Sphinxql($Server, $Port, $Socket);
34
+    /**
35
+     * Create server ident based on connection information
36
+     *
37
+     * @param string $Server server address or hostname
38
+     * @param int $Port listening port
39
+     * @param string $Socket Unix socket address, overrides $Server:$Port
40
+     * @return identification string
41
+     */
42
+    private static function get_ident($Server, $Port, $Socket)
43
+    {
44
+        if ($Socket) {
45
+            return $Socket;
46
+        } else {
47
+            return "$Server:$Port";
48
+        }
60 49
     }
61
-    return self::$Connections[$Ident];
62
-  }
63 50
 
64
-  /**
65
-   * Connect the Sphinxql object to the Sphinx server
66
-   */
67
-  public function sph_connect() {
68
-    if ($this->Connected || $this->connect_errno) {
69
-      return;
70
-    }
71
-    global $Debug;
72
-    $Debug->set_flag("Connecting to Sphinx server $this->Ident");
73
-    for ($Attempt = 0; $Attempt < 3; $Attempt++) {
74
-      parent::__construct($this->Server, '', '', '', $this->Port, $this->Socket);
75
-      if (!$this->connect_errno) {
76
-        $this->Connected = true;
77
-        break;
78
-      }
79
-      sleep(1);
51
+    /**
52
+     * Create Sphinxql object or return existing one
53
+     *
54
+     * @param string $Server server address or hostname
55
+     * @param int $Port listening port
56
+     * @param string $Socket Unix socket address, overrides $Server:$Port
57
+     * @return Sphinxql object
58
+     */
59
+    public static function init_connection($Server, $Port, $Socket)
60
+    {
61
+        $Ident = self::get_ident($Server, $Port, $Socket);
62
+        if (!isset(self::$Connections[$Ident])) {
63
+            self::$Connections[$Ident] = new Sphinxql($Server, $Port, $Socket);
64
+        }
65
+        return self::$Connections[$Ident];
80 66
     }
81
-    if ($this->connect_errno) {
82
-      $Errno = $this->connect_errno;
83
-      $Error = $this->connect_error;
84
-      $this->error("Connection failed. (".strval($Errno).": ".strval($Error).")");
85
-      $Debug->set_flag("Could not connect to Sphinx server $this->Ident. (".strval($Errno).": ".strval($Error).")");
86
-    } else {
87
-      $Debug->set_flag("Connected to Sphinx server $this->Ident");
67
+
68
+    /**
69
+     * Connect the Sphinxql object to the Sphinx server
70
+     */
71
+    public function sph_connect()
72
+    {
73
+        if ($this->Connected || $this->connect_errno) {
74
+            return;
75
+        }
76
+        global $Debug;
77
+        $Debug->set_flag("Connecting to Sphinx server $this->Ident");
78
+        for ($Attempt = 0; $Attempt < 3; $Attempt++) {
79
+            parent::__construct($this->Server, '', '', '', $this->Port, $this->Socket);
80
+            if (!$this->connect_errno) {
81
+                $this->Connected = true;
82
+                break;
83
+            }
84
+            sleep(1);
85
+        }
86
+        if ($this->connect_errno) {
87
+            $Errno = $this->connect_errno;
88
+            $Error = $this->connect_error;
89
+            $this->error("Connection failed. (".strval($Errno).": ".strval($Error).")");
90
+            $Debug->set_flag("Could not connect to Sphinx server $this->Ident. (".strval($Errno).": ".strval($Error).")");
91
+        } else {
92
+            $Debug->set_flag("Connected to Sphinx server $this->Ident");
93
+        }
88 94
     }
89
-  }
90 95
 
91
-  /**
92
-   * Print a message to privileged users and optionally halt page processing
93
-   *
94
-   * @param string $Msg message to display
95
-   * @param bool $Halt halt page processing. Default is to continue processing the page
96
-   * @return Sphinxql object
97
-   */
98
-  public function error($Msg, $Halt = false) {
99
-    global $Debug;
100
-    $ErrorMsg = 'SphinxQL ('.$this->Ident.'): '.strval($Msg);
101
-    $Debug->analysis('SphinxQL Error', $ErrorMsg, 3600*24);
102
-    if ($Halt === true && (DEBUG_MODE || check_perms('site_debug'))) {
103
-      echo '<pre>'.display_str($ErrorMsg).'</pre>';
104
-      die();
105
-    } elseif ($Halt === true) {
106
-      error('-1');
96
+    /**
97
+     * Print a message to privileged users and optionally halt page processing
98
+     *
99
+     * @param string $Msg message to display
100
+     * @param bool $Halt halt page processing. Default is to continue processing the page
101
+     * @return Sphinxql object
102
+     */
103
+    public function error($Msg, $Halt = false)
104
+    {
105
+        global $Debug;
106
+        $ErrorMsg = 'SphinxQL ('.$this->Ident.'): '.strval($Msg);
107
+        $Debug->analysis('SphinxQL Error', $ErrorMsg, 3600*24);
108
+        if ($Halt === true && (DEBUG_MODE || check_perms('site_debug'))) {
109
+            echo '<pre>'.display_str($ErrorMsg).'</pre>';
110
+            die();
111
+        } elseif ($Halt === true) {
112
+            error('-1');
113
+        }
107 114
     }
108
-  }
109 115
 
110
-  /**
111
-   * Escape special characters before sending them to the Sphinx server.
112
-   * Two escapes needed because the first one is eaten up by the mysql driver.
113
-   *
114
-   * @param string $String string to escape
115
-   * @return escaped string
116
-   */
117
-  public static function sph_escape_string($String) {
118
-    return strtr(strtolower($String), array(
116
+    /**
117
+     * Escape special characters before sending them to the Sphinx server.
118
+     * Two escapes needed because the first one is eaten up by the mysql driver.
119
+     *
120
+     * @param string $String string to escape
121
+     * @return escaped string
122
+     */
123
+    public static function sph_escape_string($String)
124
+    {
125
+        return strtr(
126
+            strtolower($String),
127
+            array(
119 128
       '('=>'\\\\(',
120 129
       ')'=>'\\\\)',
121 130
       '|'=>'\\\\|',
@@ -132,17 +141,18 @@ class Sphinxql extends mysqli {
132 141
       '$'=>'\\\\$',
133 142
       '^'=>'\\\\^',
134 143
       '\\'=>'\\\\\\\\')
135
-    );
136
-  }
144
+        );
145
+    }
137 146
 
138
-  /**
139
-   * Register sent queries globally for later retrieval by debug functions
140
-   *
141
-   * @param string $QueryString query text
142
-   * @param param $QueryProcessTime time building and processing the query
143
-   */
144
-  public static function register_query($QueryString, $QueryProcessTime) {
145
-    self::$Queries[] = array($QueryString, $QueryProcessTime);
146
-    self::$Time += $QueryProcessTime;
147
-  }
147
+    /**
148
+     * Register sent queries globally for later retrieval by debug functions
149
+     *
150
+     * @param string $QueryString query text
151
+     * @param param $QueryProcessTime time building and processing the query
152
+     */
153
+    public static function register_query($QueryString, $QueryProcessTime)
154
+    {
155
+        self::$Queries[] = array($QueryString, $QueryProcessTime);
156
+        self::$Time += $QueryProcessTime;
157
+    }
148 158
 }

+ 372
- 350
classes/sphinxqlquery.class.php View File

@@ -1,387 +1,409 @@
1
-<?
2
-class SphinxqlQuery {
3
-  private $Sphinxql;
1
+<?php
2
+class SphinxqlQuery
3
+{
4
+    private $Sphinxql;
5
+    private $Errors;
6
+    private $Expressions;
7
+    private $Filters;
8
+    private $GroupBy;
9
+    private $Indexes;
10
+    private $Limits;
11
+    private $Options;
12
+    private $QueryString;
13
+    private $Select;
14
+    private $SortBy;
15
+    private $SortGroupBy;
4 16
 
5
-  private $Errors;
6
-  private $Expressions;
7
-  private $Filters;
8
-  private $GroupBy;
9
-  private $Indexes;
10
-  private $Limits;
11
-  private $Options;
12
-  private $QueryString;
13
-  private $Select;
14
-  private $SortBy;
15
-  private $SortGroupBy;
16
-
17
-  /**
18
-   * Initialize Sphinxql object
19
-   *
20
-   * @param string $Server server address or hostname
21
-   * @param int $Port listening port
22
-   * @param string $Socket Unix socket address, overrides $Server:$Port
23
-   */
24
-  public function __construct($Server = SPHINXQL_HOST, $Port = SPHINXQL_PORT, $Socket = SPHINXQL_SOCK) {
25
-    $this->Sphinxql = Sphinxql::init_connection($Server, $Port, $Socket);
26
-    $this->reset();
27
-  }
28
-
29
-  /**
30
-   * Specify what data the Sphinx query is supposed to return
31
-   *
32
-   * @param string $Fields Attributes and expressions
33
-   * @return current Sphinxql query object
34
-   */
35
-  public function select($Fields) {
36
-    $this->Select = $Fields;
37
-    return $this;
38
-  }
17
+    /**
18
+     * Initialize Sphinxql object
19
+     *
20
+     * @param string $Server server address or hostname
21
+     * @param int $Port listening port
22
+     * @param string $Socket Unix socket address, overrides $Server:$Port
23
+     */
24
+    public function __construct($Server = SPHINXQL_HOST, $Port = SPHINXQL_PORT, $Socket = SPHINXQL_SOCK)
25
+    {
26
+        $this->Sphinxql = Sphinxql::init_connection($Server, $Port, $Socket);
27
+        $this->reset();
28
+    }
39 29
 
40
-  /**
41
-   * Specify the indexes to use in the search
42
-   *
43
-   * @param string $Indexes comma-separated list of indexes
44
-   * @return current Sphinxql query object
45
-   */
46
-  public function from($Indexes) {
47
-    $this->Indexes = $Indexes;
48
-    return $this;
49
-  }
30
+    /**
31
+     * Specify what data the Sphinx query is supposed to return
32
+     *
33
+     * @param string $Fields Attributes and expressions
34
+     * @return current Sphinxql query object
35
+     */
36
+    public function select($Fields)
37
+    {
38
+        $this->Select = $Fields;
39
+        return $this;
40
+    }
50 41
 
51
-  /**
52
-   * Add attribute filter. Calling multiple filter functions results in boolean AND between each condition.
53
-   *
54
-   * @param string $Attribute attribute which the filter will apply to
55
-   * @param mixed $Values scalar or array of numerical values. Array uses boolean OR in query condition
56
-   * @param bool $Exclude whether to exclude or include matching documents. Default mode is to include matches
57
-   * @return current Sphinxql query object
58
-   */
59
-  public function where($Attribute, $Values, $Exclude = false) {
60
-    if (empty($Attribute) || !isset($Values)) {
61
-      $this->error("Attribute name and filter value are required.");
62
-      return $this;
42
+    /**
43
+     * Specify the indexes to use in the search
44
+     *
45
+     * @param string $Indexes comma-separated list of indexes
46
+     * @return current Sphinxql query object
47
+     */
48
+    public function from($Indexes)
49
+    {
50
+        $this->Indexes = $Indexes;
51
+        return $this;
63 52
     }
64
-    $Filters = [];
65
-    if (is_array($Values)) {
66
-      foreach ($Values as $Value) {
67
-        if (!is_number($Value)) {
68
-          $this->error("Filters only support numeric values.");
69
-          return $this;
53
+
54
+    /**
55
+     * Add attribute filter. Calling multiple filter functions results in boolean AND between each condition.
56
+     *
57
+     * @param string $Attribute attribute which the filter will apply to
58
+     * @param mixed $Values scalar or array of numerical values. Array uses boolean OR in query condition
59
+     * @param bool $Exclude whether to exclude or include matching documents. Default mode is to include matches
60
+     * @return current Sphinxql query object
61
+     */
62
+    public function where($Attribute, $Values, $Exclude = false)
63
+    {
64
+        if (empty($Attribute) || !isset($Values)) {
65
+            $this->error("Attribute name and filter value are required.");
66
+            return $this;
70 67
         }
71
-      }
72
-      if ($Exclude) {
73
-        $Filters[] = "$Attribute NOT IN (".implode(",", $Values).")";
74
-      } else {
75
-        $Filters[] = "$Attribute IN (".implode(",", $Values).")";
76
-      }
77
-    } else {
78
-      if (!is_number($Values)) {
79
-        $this->error("Filters only support numeric values.");
68
+        $Filters = [];
69
+        if (is_array($Values)) {
70
+            foreach ($Values as $Value) {
71
+                if (!is_number($Value)) {
72
+                    $this->error("Filters only support numeric values.");
73
+                    return $this;
74
+                }
75
+            }
76
+            if ($Exclude) {
77
+                $Filters[] = "$Attribute NOT IN (".implode(",", $Values).")";
78
+            } else {
79
+                $Filters[] = "$Attribute IN (".implode(",", $Values).")";
80
+            }
81
+        } else {
82
+            if (!is_number($Values)) {
83
+                $this->error("Filters only support numeric values.");
84
+                return $this;
85
+            }
86
+            if ($Exclude) {
87
+                $Filters[] = "$Attribute != $Values";
88
+            } else {
89
+                $Filters[] = "$Attribute = $Values";
90
+            }
91
+        }
92
+        $this->Filters[] = implode(" AND ", $Filters);
80 93
         return $this;
81
-      }
82
-      if ($Exclude) {
83
-        $Filters[] = "$Attribute != $Values";
84
-      } else {
85
-        $Filters[] = "$Attribute = $Values";
86
-      }
87 94
     }
88
-    $this->Filters[] = implode(" AND ", $Filters);
89
-    return $this;
90
-  }
91 95
 
92
-  /**
93
-   * Add attribute less-than filter. Calling multiple filter functions results in boolean AND between each condition.
94
-   *
95
-   * @param string $Attribute attribute which the filter will apply to
96
-   * @param array $Value upper limit for matches
97
-   * @param bool $Inclusive whether to use <= or <
98
-   * @return current Sphinxql query object
99
-   */
100
-  public function where_lt($Attribute, $Value, $Inclusive = false) {
101
-    if (empty($Attribute) || !isset($Value) || !is_number($Value)) {
102
-      $this->error("Attribute name is required and only numeric filters are supported.");
103
-      return $this;
96
+    /**
97
+     * Add attribute less-than filter. Calling multiple filter functions results in boolean AND between each condition.
98
+     *
99
+     * @param string $Attribute attribute which the filter will apply to
100
+     * @param array $Value upper limit for matches
101
+     * @param bool $Inclusive whether to use <= or <
102
+     * @return current Sphinxql query object
103
+     */
104
+    public function where_lt($Attribute, $Value, $Inclusive = false)
105
+    {
106
+        if (empty($Attribute) || !isset($Value) || !is_number($Value)) {
107
+            $this->error("Attribute name is required and only numeric filters are supported.");
108
+            return $this;
109
+        }
110
+        $this->Filters[] = $Inclusive ? "$Attribute <= $Value" : "$Attribute < $Value";
111
+        return $this;
104 112
     }
105
-    $this->Filters[] = $Inclusive ? "$Attribute <= $Value" : "$Attribute < $Value";
106
-    return $this;
107
-  }
108 113
 
109
-  /**
110
-   * Add attribute greater-than filter. Calling multiple filter functions results in boolean AND between each condition.
111
-   *
112
-   * @param string $Attribute attribute which the filter will apply to
113
-   * @param array $Value lower limit for matches
114
-   * @param bool $Inclusive whether to use >= or >
115
-   * @return current Sphinxql query object
116
-   */
117
-  public function where_gt($Attribute, $Value, $Inclusive = false) {
118
-    if (empty($Attribute) || !isset($Value) || !is_number($Value)) {
119
-      $this->error("Attribute name is required and only numeric filters are supported.");
120
-      return $this;
114
+    /**
115
+     * Add attribute greater-than filter. Calling multiple filter functions results in boolean AND between each condition.
116
+     *
117
+     * @param string $Attribute attribute which the filter will apply to
118
+     * @param array $Value lower limit for matches
119
+     * @param bool $Inclusive whether to use >= or >
120
+     * @return current Sphinxql query object
121
+     */
122
+    public function where_gt($Attribute, $Value, $Inclusive = false)
123
+    {
124
+        if (empty($Attribute) || !isset($Value) || !is_number($Value)) {
125
+            $this->error("Attribute name is required and only numeric filters are supported.");
126
+            return $this;
127
+        }
128
+        $this->Filters[] = $Inclusive ? "$Attribute >= $Value" : "$Attribute > $Value";
129
+        return $this;
121 130
     }
122
-    $this->Filters[] = $Inclusive ? "$Attribute >= $Value" : "$Attribute > $Value";
123
-    return $this;
124
-  }
125 131
 
126
-  /**
127
-   * Add attribute range filter. Calling multiple filter functions results in boolean AND between each condition.
128
-   *
129
-   * @param string $Attribute attribute which the filter will apply to
130
-   * @param array $Values pair of numerical values that defines the filter range
131
-   * @return current Sphinxql query object
132
-   */
133
-  public function where_between($Attribute, $Values) {
134
-    if (empty($Attribute) || empty($Values) || count($Values) != 2 || !is_number($Values[0]) || !is_number($Values[1])) {
135
-      $this->error("Filter range requires array of two numerical boundaries as values.");
136
-      return $this;
132
+    /**
133
+     * Add attribute range filter. Calling multiple filter functions results in boolean AND between each condition.
134
+     *
135
+     * @param string $Attribute attribute which the filter will apply to
136
+     * @param array $Values pair of numerical values that defines the filter range
137
+     * @return current Sphinxql query object
138
+     */
139
+    public function where_between($Attribute, $Values)
140
+    {
141
+        if (empty($Attribute) || empty($Values) || count($Values) != 2 || !is_number($Values[0]) || !is_number($Values[1])) {
142
+            $this->error("Filter range requires array of two numerical boundaries as values.");
143
+            return $this;
144
+        }
145
+        $this->Filters[] = "$Attribute BETWEEN $Values[0] AND $Values[1]";
146
+        return $this;
137 147
     }
138
-    $this->Filters[] = "$Attribute BETWEEN $Values[0] AND $Values[1]";
139
-    return $this;
140
-  }
141 148
 
142
-  /**
143
-   * Add fulltext query expression. Calling multiple filter functions results in boolean AND between each condition.
144
-   * Query expression is escaped automatically
145
-   *
146
-   * @param string $Expr query expression
147
-   * @param string $Field field to match $Expr against. Default is *, which means all available fields
148
-   * @return current Sphinxql query object
149
-   */
150
-  public function where_match($Expr, $Field = '*', $Escape = true) {
151
-    if (empty($Expr)) {
152
-      return $this;
153
-    }
154
-    if ($Field !== false) {
155
-      $Field = "@$Field ";
156
-    }
157
-    if ($Escape === true) {
158
-      $this->Expressions[] = "$Field".Sphinxql::sph_escape_string($Expr);
159
-    } else {
160
-      $this->Expressions[] = $Field.$Expr;
149
+    /**
150
+     * Add fulltext query expression. Calling multiple filter functions results in boolean AND between each condition.
151
+     * Query expression is escaped automatically
152
+     *
153
+     * @param string $Expr query expression
154
+     * @param string $Field field to match $Expr against. Default is *, which means all available fields
155
+     * @return current Sphinxql query object
156
+     */
157
+    public function where_match($Expr, $Field = '*', $Escape = true)
158
+    {
159
+        if (empty($Expr)) {
160
+            return $this;
161
+        }
162
+        if ($Field !== false) {
163
+            $Field = "@$Field ";
164
+        }
165
+        if ($Escape === true) {
166
+            $this->Expressions[] = "$Field".Sphinxql::sph_escape_string($Expr);
167
+        } else {
168
+            $this->Expressions[] = $Field.$Expr;
169
+        }
170
+        return $this;
161 171
     }
162
-    return $this;
163
-  }
164 172
 
165
-  /**
166
-   * Specify the order of the matches. Calling this function multiple times sets secondary priorities
167
-   *
168
-   * @param string $Attribute attribute to use for sorting.
169
-   *     Passing an empty attribute value will clear the current sort settings
170
-   * @param string $Mode sort method to apply to the selected attribute
171
-   * @return current Sphinxql query object
172
-   */
173
-  public function order_by($Attribute = false, $Mode = false) {
174
-    if (empty($Attribute)) {
175
-      $this->SortBy = [];
176
-    } else {
177
-      $this->SortBy[] = "$Attribute $Mode";
173
+    /**
174
+     * Specify the order of the matches. Calling this function multiple times sets secondary priorities
175
+     *
176
+     * @param string $Attribute attribute to use for sorting.
177
+     *     Passing an empty attribute value will clear the current sort settings
178
+     * @param string $Mode sort method to apply to the selected attribute
179
+     * @return current Sphinxql query object
180
+     */
181
+    public function order_by($Attribute = false, $Mode = false)
182
+    {
183
+        if (empty($Attribute)) {
184
+            $this->SortBy = [];
185
+        } else {
186
+            $this->SortBy[] = "$Attribute $Mode";
187
+        }
188
+        return $this;
178 189
     }
179
-    return $this;
180
-  }
181 190
 
182
-  /**
183
-   * Specify how the results are grouped
184
-   *
185
-   * @param string $Attribute group matches with the same $Attribute value.
186
-   *     Passing an empty attribute value will clear the current group settings
187
-   * @return current Sphinxql query object
188
-   */
189
-  public function group_by($Attribute = false) {
190
-    if (empty($Attribute)) {
191
-      $this->GroupBy = '';
192
-    } else {
193
-      $this->GroupBy = $Attribute;
191
+    /**
192
+     * Specify how the results are grouped
193
+     *
194
+     * @param string $Attribute group matches with the same $Attribute value.
195
+     *     Passing an empty attribute value will clear the current group settings
196
+     * @return current Sphinxql query object
197
+     */
198
+    public function group_by($Attribute = false)
199
+    {
200
+        if (empty($Attribute)) {
201
+            $this->GroupBy = '';
202
+        } else {
203
+            $this->GroupBy = $Attribute;
204
+        }
205
+        return $this;
194 206
     }
195
-    return $this;
196
-  }
197 207
 
198
-  /**
199
-   * Specify the order of the results within groups
200
-   *
201
-   * @param string $Attribute attribute to use for sorting.
202
-   *     Passing an empty attribute will clear the current group sort settings
203
-   * @param string $Mode sort method to apply to the selected attribute
204
-   * @return current Sphinxql query object
205
-   */
206
-  public function order_group_by($Attribute = false, $Mode = false) {
207
-    if (empty($Attribute)) {
208
-      $this->SortGroupBy = '';
209
-    } else {
210
-      $this->SortGroupBy = "$Attribute $Mode";
208
+    /**
209
+     * Specify the order of the results within groups
210
+     *
211
+     * @param string $Attribute attribute to use for sorting.
212
+     *     Passing an empty attribute will clear the current group sort settings
213
+     * @param string $Mode sort method to apply to the selected attribute
214
+     * @return current Sphinxql query object
215
+     */
216
+    public function order_group_by($Attribute = false, $Mode = false)
217
+    {
218
+        if (empty($Attribute)) {
219
+            $this->SortGroupBy = '';
220
+        } else {
221
+            $this->SortGroupBy = "$Attribute $Mode";
222
+        }
223
+        return $this;
211 224
     }
212
-    return $this;
213
-  }
214
-
215
-  /**
216
-   * Specify the offset and amount of matches to return
217
-   *
218
-   * @param int $Offset number of matches to discard
219
-   * @param int $Limit number of matches to return
220
-   * @param int $MaxMatches number of results to store in the Sphinx server's memory. Must be >= ($Offset+$Limit)
221
-   * @return current Sphinxql query object
222
-   */
223
-  public function limit($Offset, $Limit, $MaxMatches = SPHINX_MAX_MATCHES) {
224
-    $this->Limits = "$Offset, $Limit";
225
-    $this->set('max_matches', $MaxMatches);
226
-    return $this;
227
-  }
228
-
229
-  /**
230
-   * Tweak the settings to use for the query. Sanity checking shouldn't be needed as Sphinx already does it
231
-   *
232
-   * @param string $Name setting name
233
-   * @param mixed $Value value
234
-   * @return current Sphinxql query object
235
-   */
236
-  public function set($Name, $Value) {
237
-    $this->Options[$Name] = $Value;
238
-    return $this;
239
-  }
240 225
 
241
-  /**
242
-   * Combine the query options into a valid Sphinx query segment
243
-   *
244
-   * @return string of options
245
-   */
246
-  private function build_options() {
247
-    $Options = [];
248
-    foreach ($this->Options as $Option => $Value) {
249
-      $Options[] = "$Option = $Value";
226
+    /**
227
+     * Specify the offset and amount of matches to return
228
+     *
229
+     * @param int $Offset number of matches to discard
230
+     * @param int $Limit number of matches to return
231
+     * @param int $MaxMatches number of results to store in the Sphinx server's memory. Must be >= ($Offset+$Limit)
232
+     * @return current Sphinxql query object
233
+     */
234
+    public function limit($Offset, $Limit, $MaxMatches = SPHINX_MAX_MATCHES)
235
+    {
236
+        $this->Limits = "$Offset, $Limit";
237
+        $this->set('max_matches', $MaxMatches);
238
+        return $this;
250 239
     }
251
-    return implode(', ', $Options);
252
-  }
253 240
 
254
-  /**
255
-   * Combine the query conditions into a valid Sphinx query segment
256
-   */
257
-  private function build_query() {
258
-    if (!$this->Indexes) {
259
-      $this->error('Index name is required.');
260
-      return false;
261
-    }
262
-    $this->QueryString = "SELECT $this->Select\nFROM $this->Indexes";
263
-    if (!empty($this->Expressions)) {
264
-      $this->Filters['expr'] = "MATCH('".implode(' ', $this->Expressions)."')";
265
-    }
266
-    if (!empty($this->Filters)) {
267
-      $this->QueryString .= "\nWHERE ".implode("\n\tAND ", $this->Filters);
268
-    }
269
-    if (!empty($this->GroupBy)) {
270
-      $this->QueryString .= "\nGROUP BY $this->GroupBy";
271
-    }
272
-    if (!empty($this->SortGroupBy)) {
273
-      $this->QueryString .= "\nWITHIN GROUP ORDER BY $this->SortGroupBy";
274
-    }
275
-    if (!empty($this->SortBy)) {
276
-      $this->QueryString .= "\nORDER BY ".implode(", ", $this->SortBy);
277
-    }
278
-    if (!empty($this->Limits)) {
279
-      $this->QueryString .= "\nLIMIT $this->Limits";
241
+    /**
242
+     * Tweak the settings to use for the query. Sanity checking shouldn't be needed as Sphinx already does it
243
+     *
244
+     * @param string $Name setting name
245
+     * @param mixed $Value value
246
+     * @return current Sphinxql query object
247
+     */
248
+    public function set($Name, $Value)
249
+    {
250
+        $this->Options[$Name] = $Value;
251
+        return $this;
280 252
     }
281
-    if (!empty($this->Options)) {
282
-      $Options = $this->build_options();
283
-      $this->QueryString .= "\nOPTION $Options";
253
+
254
+    /**
255
+     * Combine the query options into a valid Sphinx query segment
256
+     *
257
+     * @return string of options
258
+     */
259
+    private function build_options()
260
+    {
261
+        $Options = [];
262
+        foreach ($this->Options as $Option => $Value) {
263
+            $Options[] = "$Option = $Value";
264
+        }
265
+        return implode(', ', $Options);
284 266
     }
285
-  }
286 267
 
287
-  /**
288
-   * Construct and send the query. Register the query in the global Sphinxql object
289
-   *
290
-   * @param bool GetMeta whether to fetch meta data for the executed query. Default is yes
291
-   * @return Sphinxql result object
292
-   */
293
-  public function query($GetMeta = true) {
294
-    $QueryStartTime = microtime(true);
295
-    $this->build_query();
296
-    if (count($this->Errors) > 0) {
297
-      $ErrorMsg = implode("\n", $this->Errors);
298
-      $this->Sphinxql->error("Query builder found errors:\n$ErrorMsg");
299
-      return new SphinxqlResult(null, null, 1, $ErrorMsg);
268
+    /**
269
+     * Combine the query conditions into a valid Sphinx query segment
270
+     */
271
+    private function build_query()
272
+    {
273
+        if (!$this->Indexes) {
274
+            $this->error('Index name is required.');
275
+            return false;
276
+        }
277
+        $this->QueryString = "SELECT $this->Select\nFROM $this->Indexes";
278
+        if (!empty($this->Expressions)) {
279
+            $this->Filters['expr'] = "MATCH('".implode(' ', $this->Expressions)."')";
280
+        }
281
+        if (!empty($this->Filters)) {
282
+            $this->QueryString .= "\nWHERE ".implode("\n\tAND ", $this->Filters);
283
+        }
284
+        if (!empty($this->GroupBy)) {
285
+            $this->QueryString .= "\nGROUP BY $this->GroupBy";
286
+        }
287
+        if (!empty($this->SortGroupBy)) {
288
+            $this->QueryString .= "\nWITHIN GROUP ORDER BY $this->SortGroupBy";
289
+        }
290
+        if (!empty($this->SortBy)) {
291
+            $this->QueryString .= "\nORDER BY ".implode(", ", $this->SortBy);
292
+        }
293
+        if (!empty($this->Limits)) {
294
+            $this->QueryString .= "\nLIMIT $this->Limits";
295
+        }
296
+        if (!empty($this->Options)) {
297
+            $Options = $this->build_options();
298
+            $this->QueryString .= "\nOPTION $Options";
299
+        }
300 300
     }
301
-    $QueryString = $this->QueryString;
302
-    $Result = $this->send_query($GetMeta);
303
-    $QueryProcessTime = (microtime(true) - $QueryStartTime)*1000;
304
-    Sphinxql::register_query($QueryString, $QueryProcessTime);
305
-    return $Result;
306
-  }
307 301
 
308
-  /**
309
-   * Run a manually constructed query
310
-   *
311
-   * @param string Query query expression
312
-   * @param bool GetMeta whether to fetch meta data for the executed query. Default is yes
313
-   * @return Sphinxql result object
314
-   */
315
-  public function raw_query($Query, $GetMeta = true) {
316
-    $this->QueryString = $Query;
317
-    return $this->send_query($GetMeta);
318
-  }
302
+    /**
303
+     * Construct and send the query. Register the query in the global Sphinxql object
304
+     *
305
+     * @param bool GetMeta whether to fetch meta data for the executed query. Default is yes
306
+     * @return Sphinxql result object
307
+     */
308
+    public function query($GetMeta = true)
309
+    {
310
+        $QueryStartTime = microtime(true);
311
+        $this->build_query();
312
+        if (count($this->Errors) > 0) {
313
+            $ErrorMsg = implode("\n", $this->Errors);
314
+            $this->Sphinxql->error("Query builder found errors:\n$ErrorMsg");
315
+            return new SphinxqlResult(null, null, 1, $ErrorMsg);
316
+        }
317
+        $QueryString = $this->QueryString;
318
+        $Result = $this->send_query($GetMeta);
319
+        $QueryProcessTime = (microtime(true) - $QueryStartTime)*1000;
320
+        Sphinxql::register_query($QueryString, $QueryProcessTime);
321
+        return $Result;
322
+    }
319 323
 
320
-  /**
321
-   * Run a pre-processed query. Only used internally
322
-   *
323
-   * @param bool GetMeta whether to fetch meta data for the executed query
324
-   * @return Sphinxql result object
325
-   */
326
-  private function send_query($GetMeta) {
327
-    if (!$this->QueryString) {
328
-      return false;
324
+    /**
325
+     * Run a manually constructed query
326
+     *
327
+     * @param string Query query expression
328
+     * @param bool GetMeta whether to fetch meta data for the executed query. Default is yes
329
+     * @return Sphinxql result object
330
+     */
331
+    public function raw_query($Query, $GetMeta = true)
332
+    {
333
+        $this->QueryString = $Query;
334
+        return $this->send_query($GetMeta);
329 335
     }
330
-    $this->Sphinxql->sph_connect();
331
-    $Result = $this->Sphinxql->query($this->QueryString);
332
-    if ($Result === false) {
333
-      $Errno = $this->Sphinxql->errno;
334
-      $Error = $this->Sphinxql->error;
335
-      $this->Sphinxql->error("Query returned error $Errno ($Error).\n$this->QueryString");
336
-      $Meta = null;
337
-    } else {
338
-      $Errno = 0;
339
-      $Error = '';
340
-      $Meta = $GetMeta ? $this->get_meta() : null;
336
+
337
+    /**
338
+     * Run a pre-processed query. Only used internally
339
+     *
340
+     * @param bool GetMeta whether to fetch meta data for the executed query
341
+     * @return Sphinxql result object
342
+     */
343
+    private function send_query($GetMeta)
344
+    {
345
+        if (!$this->QueryString) {
346
+            return false;
347
+        }
348
+        $this->Sphinxql->sph_connect();
349
+        $Result = $this->Sphinxql->query($this->QueryString);
350
+        if ($Result === false) {
351
+            $Errno = $this->Sphinxql->errno;
352
+            $Error = $this->Sphinxql->error;
353
+            $this->Sphinxql->error("Query returned error $Errno ($Error).\n$this->QueryString");
354
+            $Meta = null;
355
+        } else {
356
+            $Errno = 0;
357
+            $Error = '';
358
+            $Meta = $GetMeta ? $this->get_meta() : null;
359
+        }
360
+        return new SphinxqlResult($Result, $Meta, $Errno, $Error);
341 361
     }
342
-    return new SphinxqlResult($Result, $Meta, $Errno, $Error);
343
-  }
344 362
 
345
-  /**
346
-   * Reset all query options and conditions
347
-   */
348
-  public function reset() {
349
-    $this->Errors = [];
350
-    $this->Expressions = [];
351
-    $this->Filters = [];
352
-    $this->GroupBy = '';
353
-    $this->Indexes = '';
354
-    $this->Limits = [];
355
-    $this->Options = array('ranker' => 'none');
356
-    $this->QueryString = '';
357
-    $this->Select = '*';
358
-    $this->SortBy = [];
359
-    $this->SortGroupBy = '';
360
-  }
363
+    /**
364
+     * Reset all query options and conditions
365
+     */
366
+    public function reset()
367
+    {
368
+        $this->Errors = [];
369
+        $this->Expressions = [];
370
+        $this->Filters = [];
371
+        $this->GroupBy = '';
372
+        $this->Indexes = '';
373
+        $this->Limits = [];
374
+        $this->Options = array('ranker' => 'none');
375
+        $this->QueryString = '';
376
+        $this->Select = '*';
377
+        $this->SortBy = [];
378
+        $this->SortGroupBy = '';
379
+    }
361 380
 
362
-  /**
363
-   * Fetch and store meta data for the last executed query
364
-   *
365
-   * @return meta data
366
-   */
367
-  private function get_meta() {
368
-    return $this->raw_query("SHOW META", false)->to_pair(0, 1);
369
-  }
381
+    /**
382
+     * Fetch and store meta data for the last executed query
383
+     *
384
+     * @return meta data
385
+     */
386
+    private function get_meta()
387
+    {
388
+        return $this->raw_query("SHOW META", false)->to_pair(0, 1);
389
+    }
370 390
 
371
-  /**
372
-   * Copy attribute filters from another SphinxqlQuery object
373
-   *
374
-   * @param SphinxqlQuery $SphQLSource object to copy the filters from
375
-   * @return current SphinxqlQuery object
376
-   */
377
-  public function copy_attributes_from($SphQLSource) {
378
-    $this->Filters = $SphQLSource->Filters;
379
-  }
391
+    /**
392
+     * Copy attribute filters from another SphinxqlQuery object
393
+     *
394
+     * @param SphinxqlQuery $SphQLSource object to copy the filters from
395
+     * @return current SphinxqlQuery object
396
+     */
397
+    public function copy_attributes_from($SphQLSource)
398
+    {
399
+        $this->Filters = $SphQLSource->Filters;
400
+    }
380 401
 
381
-  /**
382
-   * Store error messages
383
-   */
384
-  private function error($Msg) {
385
-    $this->Errors[] = $Msg;
386
-  }
402
+    /**
403
+     * Store error messages
404
+     */
405
+    private function error($Msg)
406
+    {
407
+        $this->Errors[] = $Msg;
408
+    }
387 409
 }

+ 134
- 125
classes/sphinxqlresult.class.php View File

@@ -1,143 +1,152 @@
1
-<?
2
-class SphinxqlResult {
3
-  private $Result;
4
-  private $Meta;
5
-  public $Errno;
6
-  public $Error;
1
+<?php
2
+class SphinxqlResult
3
+{
4
+    private $Result;
5
+    private $Meta;
6
+    public $Errno;
7
+    public $Error;
7 8
 
8
-  /**
9
-   * Create Sphinxql result object
10
-   *
11
-   * @param mysqli_result $Result query results
12
-   * @param array $Meta meta data for the query
13
-   * @param int $Errno error code returned by the query upon failure
14
-   * @param string $Error error message returned by the query upon failure
15
-   */
16
-  public function __construct($Result, $Meta, $Errno, $Error) {
17
-    $this->Result = $Result;
18
-    $this->Meta = $Meta;
19
-    $this->Errno = $Errno;
20
-    $this->Error = $Error;
21
-  }
22
-
23
-  /**
24
-   * Redirect to the Mysqli result object if a nonexistent method is called
25
-   *
26
-   * @param string $Name method name
27
-   * @param array $Arguments arguments used in the function call
28
-   * @return whatever the parent function returns
29
-   */
30
-  public function __call($Name, $Arguments) {
31
-    return call_user_func_array(array($this->Result, $Name), $Arguments);
32
-  }
33
-
34
-  /**
35
-   * Did the query find anything?
36
-   *
37
-   * @return bool results were found
38
-   */
39
-  public function has_results() {
40
-    return $this->get_meta('total') > 0;
41
-  }
9
+    /**
10
+     * Create Sphinxql result object
11
+     *
12
+     * @param mysqli_result $Result query results
13
+     * @param array $Meta meta data for the query
14
+     * @param int $Errno error code returned by the query upon failure
15
+     * @param string $Error error message returned by the query upon failure
16
+     */
17
+    public function __construct($Result, $Meta, $Errno, $Error)
18
+    {
19
+        $this->Result = $Result;
20
+        $this->Meta = $Meta;
21
+        $this->Errno = $Errno;
22
+        $this->Error = $Error;
23
+    }
42 24
 
43
-  /**
44
-   * Collect and return the specified key of all results as a list
45
-   *
46
-   * @param string $Key key containing the desired data
47
-   * @return array with the $Key value of all results
48
-   */
49
-  public function collect($Key) {
50
-    $Return = [];
51
-    while ($Row = $this->fetch_array()) {
52
-      $Return[] = $Row[$Key];
25
+    /**
26
+     * Redirect to the Mysqli result object if a nonexistent method is called
27
+     *
28
+     * @param string $Name method name
29
+     * @param array $Arguments arguments used in the function call
30
+     * @return whatever the parent function returns
31
+     */
32
+    public function __call($Name, $Arguments)
33
+    {
34
+        return call_user_func_array(array($this->Result, $Name), $Arguments);
53 35
     }
54
-    $this->data_seek(0);
55
-    return $Return;
56
-  }
57 36
 
58
-  /**
59
-   * Collect and return all available data for the matches optionally indexed by a specified key
60
-   *
61
-   * @param string $Key key to use as indexing value
62
-   * @param string $ResultType method to use when fetching data from the mysqli_result object. Default is MYSQLI_ASSOC
63
-   * @return array with all available data for the matches
64
-   */
65
-  public function to_array($Key, $ResultType = MYSQLI_ASSOC) {
66
-    $Return = [];
67
-    while ($Row = $this->fetch_array($ResultType)) {
68
-      if ($Key !== false) {
69
-        $Return[$Row[$Key]] = $Row;
70
-      } else {
71
-        $Return[] = $Row;
72
-      }
37
+    /**
38
+     * Did the query find anything?
39
+     *
40
+     * @return bool results were found
41
+     */
42
+    public function has_results()
43
+    {
44
+        return $this->get_meta('total') > 0;
73 45
     }
74
-    $this->data_seek(0);
75
-    return $Return;
76
-  }
77 46
 
78
-  /**
79
-   * Collect pairs of keys for all matches
80
-   *
81
-   * @param string $Key1 key to use as indexing value
82
-   * @param string $Key2 key to use as value
83
-   * @return array with $Key1 => $Key2 pairs for matches
84
-   */
85
-  public function to_pair($Key1, $Key2) {
86
-    $Return = [];
87
-    while ($Row = $this->fetch_array()) {
88
-      $Return[$Row[$Key1]] = $Row[$Key2];
47
+    /**
48
+     * Collect and return the specified key of all results as a list
49
+     *
50
+     * @param string $Key key containing the desired data
51
+     * @return array with the $Key value of all results
52
+     */
53
+    public function collect($Key)
54
+    {
55
+        $Return = [];
56
+        while ($Row = $this->fetch_array()) {
57
+            $Return[] = $Row[$Key];
58
+        }
59
+        $this->data_seek(0);
60
+        return $Return;
89 61
     }
90
-    $this->data_seek(0);
91
-    return $Return;
92
-  }
93 62
 
94
-  /**
95
-   * Return specified portions of the current Sphinxql result object's meta data
96
-   *
97
-   * @param mixed $Keys scalar or array with keys to return. Default is false, which returns all meta data
98
-   * @return array with meta data
99
-   */
100
-  public function get_meta($Keys = false) {
101
-    if ($Keys !== false) {
102
-      if (is_array($Keys)) {
63
+    /**
64
+     * Collect and return all available data for the matches optionally indexed by a specified key
65
+     *
66
+     * @param string $Key key to use as indexing value
67
+     * @param string $ResultType method to use when fetching data from the mysqli_result object. Default is MYSQLI_ASSOC
68
+     * @return array with all available data for the matches
69
+     */
70
+    public function to_array($Key, $ResultType = MYSQLI_ASSOC)
71
+    {
103 72
         $Return = [];
104
-        foreach ($Keys as $Key) {
105
-          if (!isset($this->Meta[$Key])) {
106
-            continue;
107
-          }
108
-          $Return[$Key] = $this->Meta[$Key];
73
+        while ($Row = $this->fetch_array($ResultType)) {
74
+            if ($Key !== false) {
75
+                $Return[$Row[$Key]] = $Row;
76
+            } else {
77
+                $Return[] = $Row;
78
+            }
109 79
         }
80
+        $this->data_seek(0);
110 81
         return $Return;
111
-      } else {
112
-        return isset($this->Meta[$Keys]) ? $this->Meta[$Keys] : false;
113
-      }
114
-    } else {
115
-      return $this->Meta;
116 82
     }
117
-  }
118 83
 
119
-  /**
120
-   * Return specified portions of the current Mysqli result object's information
121
-   *
122
-   * @param mixed $Keys scalar or array with keys to return. Default is false, which returns all available information
123
-   * @return array with result information
124
-   */
125
-  public function get_result_info($Keys = false) {
126
-    if ($Keys !== false) {
127
-      if (is_array($Keys)) {
84
+    /**
85
+     * Collect pairs of keys for all matches
86
+     *
87
+     * @param string $Key1 key to use as indexing value
88
+     * @param string $Key2 key to use as value
89
+     * @return array with $Key1 => $Key2 pairs for matches
90
+     */
91
+    public function to_pair($Key1, $Key2)
92
+    {
128 93
         $Return = [];
129
-        foreach ($Keys as $Key) {
130
-          if (!isset($this->Result->$Key)) {
131
-            continue;
132
-          }
133
-          $Return[$Key] = $this->Result->$Key;
94
+        while ($Row = $this->fetch_array()) {
95
+            $Return[$Row[$Key1]] = $Row[$Key2];
134 96
         }
97
+        $this->data_seek(0);
135 98
         return $Return;
136
-      } else {
137
-        return isset($this->Result->$Keys) ? $this->Result->$Keys : false;
138
-      }
139
-    } else {
140
-      return $this->Result;
141 99
     }
142
-  }
100
+
101
+    /**
102
+     * Return specified portions of the current Sphinxql result object's meta data
103
+     *
104
+     * @param mixed $Keys scalar or array with keys to return. Default is false, which returns all meta data
105
+     * @return array with meta data
106
+     */
107
+    public function get_meta($Keys = false)
108
+    {
109
+        if ($Keys !== false) {
110
+            if (is_array($Keys)) {
111
+                $Return = [];
112
+                foreach ($Keys as $Key) {
113
+                    if (!isset($this->Meta[$Key])) {
114
+                        continue;
115
+                    }
116
+                    $Return[$Key] = $this->Meta[$Key];
117
+                }
118
+                return $Return;
119
+            } else {
120
+                return isset($this->Meta[$Keys]) ? $this->Meta[$Keys] : false;
121
+            }
122
+        } else {
123
+            return $this->Meta;
124
+        }
125
+    }
126
+
127
+    /**
128
+     * Return specified portions of the current Mysqli result object's information
129
+     *
130
+     * @param mixed $Keys scalar or array with keys to return. Default is false, which returns all available information
131
+     * @return array with result information
132
+     */
133
+    public function get_result_info($Keys = false)
134
+    {
135
+        if ($Keys !== false) {
136
+            if (is_array($Keys)) {
137
+                $Return = [];
138
+                foreach ($Keys as $Key) {
139
+                    if (!isset($this->Result->$Key)) {
140
+                        continue;
141
+                    }
142
+                    $Return[$Key] = $this->Result->$Key;
143
+                }
144
+                return $Return;
145
+            } else {
146
+                return isset($this->Result->$Keys) ? $this->Result->$Keys : false;
147
+            }
148
+        } else {
149
+            return $this->Result;
150
+        }
151
+    }
143 152
 }

+ 11
- 8
classes/torrentsearch.class.php View File

@@ -51,25 +51,25 @@ class TorrentSearch
51 51
     // List of fields that can be used for fulltext searches
52 52
     private static $Fields = [
53 53
     'artistname' => 1,
54
-    'audioformat' => 1,
54
+    #'audioformat' => 1,
55 55
     'cataloguenumber' => 1,
56 56
     'codec' => 1,
57 57
     'container' => 1,
58 58
     'description' => 1,
59
-    'dlsiteid' => 1,
59
+    #'dlsiteid' => 1,
60 60
     'filelist' => 1,
61 61
     'groupname' => 1,
62 62
     'groupnamerj' => 1,
63 63
     'groupnamejp' => 1,
64 64
     'advgroupname' => 1,
65
-    'language' => 1,
65
+    #'language' => 1,
66 66
     'media' => 1,
67 67
     'resolution' => 1,
68 68
     'searchstr' => 1,
69 69
     'series' => 1,
70 70
     'studio' => 1,
71
-    'subber' => 1,
72
-    'subbing' => 1,
71
+    #'subber' => 1,
72
+    #'subbing' => 1,
73 73
     'taglist' => 1
74 74
   ];
75 75
 
@@ -86,8 +86,11 @@ class TorrentSearch
86 86
 
87 87
     // Some form field names don't match the ones in the index
88 88
     private static $FormsToFields = [
89
-    'searchstr' => '(groupname,groupnamerj,groupnamejp,artistname,studio,series,dlsiteid,cataloguenumber,yearfulltext)',
90
-    'advgroupname' => '(groupname,groupnamerj,groupnamejp)'
89
+        # todo: Make these filters significantly less broad
90
+        'searchstr' => '*',
91
+        'advgroupname' => '*'
92
+        #'searchstr' => '(groupname,groupnamerj,groupnamejp,artistname,studio,series,dlsiteid,cataloguenumber,yearfulltext)',
93
+        #'advgroupname' => '(groupname,groupnamerj,groupnamejp)'
91 94
   ];
92 95
 
93 96
     // Specify the operator type to use for fields. Empty key sets the default
@@ -201,7 +204,7 @@ class TorrentSearch
201 204
         }
202 205
         $Offset = ($this->Page - 1) * $ResultLimit;
203 206
         $MinMax = G::$Cache->get_value('sphinx_min_max_matches');
204
-        $MaxMatches = max($Offset + $ResultLimit, $MinMax ? $MinMax : 2000);
207
+        $MaxMatches = max($Offset + $ResultLimit, $MinMax ? $MinMax : 1000); # todo: Keep an eye on this
205 208
         $this->SphQL->from('torrents, delta')
206 209
       ->limit($Offset, $ResultLimit, $MaxMatches);
207 210
     }

+ 1
- 1
design/publicheader.php View File

@@ -29,7 +29,7 @@ define('FOOTER_FILE', SERVER_ROOT.'/design/publicfooter.php');
29 29
 </head>
30 30
 <body>
31 31
 <div id="head"><span>
32
-<a href="login.php">Log in</a>
32
+<a href="login.php">Log In</a>
33 33
 <?php if (OPEN_REGISTRATION) { ?>
34 34
  | <a href="register.php">Register</a>
35 35
 <?php } ?>

+ 25
- 15
sections/donate/donate.php View File

@@ -20,14 +20,19 @@ View::show_header('Donate');
20 20
   <span class="donation_info_title">Why donate?</span>
21 21
   <div class="box pad donation_info">
22 22
     <p>
23
-      <?= SITE_NAME ?> has no advertisements, is not sponsored, and provides its services free of charge.
24
-      For these reasons, <?= SITE_NAME ?>'s financial obligations can only be met with the help of voluntary user donations.
25
-      Supporting <?= SITE_NAME ?> is and will always remain voluntary.
26
-      If you are financially able, please help pay <?= SITE_NAME ?>'s bills by donating.
23
+      <?= SITE_NAME ?> has no advertisements, is not sponsored, and
24
+      provides its services free of charge.
25
+      For these reasons, <?= SITE_NAME ?>'s financial obligations can
26
+      only be met with the help of voluntary user donations.
27
+      Supporting <?= SITE_NAME ?> is and will always remain
28
+      voluntary.
29
+      If you are financially able, please help pay <?= SITE_NAME ?>'s
30
+      bills by donating.
27 31
     </p>
28 32
 
29 33
     <p>
30
-      <?= SITE_NAME ?> uses all voluntary donations to cover the costs of running the site, tracker, and IRC network.
34
+      <?= SITE_NAME ?> uses all voluntary donations to cover the
35
+      costs of running the site, tracker, and IRC network.
31 36
       These costs represent the hardware the site runs on (e.g., servers, upgrades, fixes),
32 37
       and recurring operating expenses (e.g., hosting, bandwidth, power).
33 38
     </p>
@@ -42,18 +47,22 @@ View::show_header('Donate');
42 47
   <span class="donation_info_title">What you will receive for donating</span>
43 48
   <div class="box pad donation_info">
44 49
     <p>
45
-      Please see <a href="https://www.patreon.com/biotorrents" target="_blank"><?= SITE_NAME ?>'s Patreon</a> for a detailed overview of funding goals.
50
+      Please see <a href="https://www.patreon.com/biotorrents" target="_blank"><?= SITE_NAME ?>'s Patreon</a> for a detailed overview of funding
51
+      goals.
46 52
       There are some benefits to donating that culmulate at each tier pledged.
47 53
       Each tier's awards include those already listed.
48 54
       Bitcoin donations are privately negotiable.
49 55
 
50 56
       <ul>
51
-        <li><strong>Bronze:</strong> A donor badge and forum access for your user account on the BioTorrents.de website</li>
57
+        <li><strong>Bronze:</strong> A donor badge and forum access for your user account on the BioTorrents.de website
58
+        </li>
52 59
         <li><strong>Silver:</strong> Unlimited API calls to the BioTorrents.de database</li>
53 60
         <li><strong>Gold:</strong> Monthly Skype calls to discuss wetlab and software ideas.
54 61
           My expertise includes fungal biotechnology, nonprofit administration, and LEMP development</li>
55
-        <li><strong>Sponsor a Seedbox:</strong> Shell access to, and share ratio credit from, a seedbox that I manage on your behalf.
56
-          Please understand that network services beyond the scope of seedbox administration should be negotiated separately</li>
62
+        <li><strong>Sponsor a Seedbox:</strong> Shell access to, and share ratio credit from, a seedbox that I manage on
63
+          your behalf.
64
+          Please understand that network services beyond the scope of seedbox administration should be negotiated
65
+          separately</li>
57 66
       </ul>
58 67
 
59 68
       <!-- Any donation or contribution option listed above gives you the opportunity to receive Donor Points.
@@ -72,12 +81,13 @@ View::show_header('Donate');
72 81
       <li>Absolutely nothing else</li>
73 82
     </ul> -->
74 83
 
75
-    <p>
76
-      Be reminded that when you make a donation, you aren't "purchasing" Donor Ranks, invites, or any <?= SITE_NAME ?>-specific benefit.
77
-      When donating, you are helping <?= SITE_NAME ?> pay its bills, and your donation should be made in this spirit.
78
-      The <?= SITE_NAME ?> Staff does its best to recognize <?= SITE_NAME ?>'s financial supporters in a fair and fun way,
79
-      but all Donor Perks are subject to change or cancellation at any time, without notice.
80
-    </p>
84
+      <p>
85
+        Be reminded that when you make a donation, you aren't "purchasing" Donor Ranks, invites, or any <?= SITE_NAME ?>-specific benefit.
86
+        When donating, you are helping <?= SITE_NAME ?> pay its
87
+        bills, and your donation should be made in this spirit.
88
+        The <?= SITE_NAME ?> staff does its best to recognize <?= SITE_NAME ?>'s financial supporters in a fair and fun way,
89
+        but all Donor Perks are subject to change or cancellation at any time, without notice.
90
+      </p>
81 91
   </div>
82 92
 
83 93
   <span class="donation_info_title">What you won't receive for donating</span>

+ 1
- 1
sections/login/login.php View File

@@ -51,7 +51,7 @@ if (!$Banned) {
51 51
     </tr>
52 52
     <tr>
53 53
       <td colspan="2">
54
-        <input type="submit" name="login" value="Log in" class="submit" />
54
+        <input type="submit" name="login" value="Log In" class="submit" />
55 55
       </td>
56 56
     </tr>
57 57
   </table>

Loading…
Cancel
Save