безопасный поиск
This commit is contained in:
parent
731ce1f7c8
commit
00256750e0
10
index.js
10
index.js
@ -252,10 +252,12 @@ io.on('connection', function(socket)
|
||||
return;
|
||||
}
|
||||
|
||||
const safeSearch = !!navigation.safeSearch;
|
||||
|
||||
const index = navigation.index || 0;
|
||||
const limit = navigation.limit || 10;
|
||||
let search = {};
|
||||
sphinx.query('SELECT * FROM `torrents_index`,`torrents_index_delta` WHERE MATCH(?) LIMIT ?,?', [text, index, limit], function (error, rows, fields) {
|
||||
sphinx.query('SELECT * FROM `torrents_index`,`torrents_index_delta` WHERE MATCH(?) ' + (safeSearch ? "and contentcategory != 'xxx'" : '') + ' LIMIT ?,?', [text, index, limit], function (error, rows, fields) {
|
||||
if(!rows) {
|
||||
callback(undefined)
|
||||
return;
|
||||
@ -279,10 +281,12 @@ io.on('connection', function(socket)
|
||||
return;
|
||||
}
|
||||
|
||||
const safeSearch = !!navigation.safeSearch;
|
||||
|
||||
const index = navigation.index || 0;
|
||||
const limit = navigation.limit || 10;
|
||||
let search = {};
|
||||
sphinx.query('SELECT * FROM `files_index`,`files_index_delta` WHERE MATCH(?) LIMIT ?,?', [text, index, limit], function (error, rows, fields) {
|
||||
sphinx.query('SELECT * FROM `files_index`,`files_index_delta` WHERE MATCH(?) ' + (safeSearch ? "and contentcategory != 'xxx'" : '') + ' LIMIT ?,?', [text, index, limit], function (error, rows, fields) {
|
||||
if(!rows) {
|
||||
callback(undefined)
|
||||
return;
|
||||
@ -505,4 +509,4 @@ client.on('complete', function (metadata, infohash, rinfo) {
|
||||
|
||||
// spider.on('nodes', (nodes)=>console.log('foundNodes'))
|
||||
|
||||
//spider.listen(4445)
|
||||
spider.listen(4445)
|
@ -5,13 +5,21 @@ import TextField from 'material-ui/TextField';
|
||||
import RaisedButton from 'material-ui/RaisedButton';
|
||||
import RefreshIndicator from 'material-ui/RefreshIndicator';
|
||||
|
||||
import Checkbox from 'material-ui/Checkbox';
|
||||
import Visibility from 'material-ui/svg-icons/action/visibility';
|
||||
import VisibilityOff from 'material-ui/svg-icons/action/visibility-off';
|
||||
|
||||
import formatBytes from './format-bytes'
|
||||
|
||||
export default class Search extends Component {
|
||||
constructor(props)
|
||||
{
|
||||
super(props)
|
||||
this.state = { searchingIndicator: false }
|
||||
this.state = {
|
||||
searchingIndicator: false,
|
||||
safeSearchText: 'safe search enabled',
|
||||
safeSearchColor: 'rgb(0, 188, 212)'
|
||||
}
|
||||
}
|
||||
|
||||
search() {
|
||||
@ -20,7 +28,7 @@ export default class Search extends Component {
|
||||
});
|
||||
this.searchData = [];
|
||||
let queries = 2;
|
||||
window.torrentSocket.emit('searchTorrent', this.searchValue, {limit: 10}, window.customLoader((torrents) => {
|
||||
window.torrentSocket.emit('searchTorrent', this.searchValue, {limit: 10, safeSearch: this.refs.safeSearch.checked}, window.customLoader((torrents) => {
|
||||
if(torrents) {
|
||||
this.searchData = this.searchData.concat(torrents);
|
||||
}
|
||||
@ -32,7 +40,7 @@ export default class Search extends Component {
|
||||
this.forceUpdate();
|
||||
}
|
||||
}));
|
||||
window.torrentSocket.emit('searchFiles', this.searchValue, {limit: 10}, window.customLoader((torrents) => {
|
||||
window.torrentSocket.emit('searchFiles', this.searchValue, {limit: 10, safeSearch: this.refs.safeSearch.checked}, window.customLoader((torrents) => {
|
||||
if(torrents) {
|
||||
this.searchData = this.searchData.concat(torrents);
|
||||
}
|
||||
@ -87,6 +95,25 @@ export default class Search extends Component {
|
||||
this.search()
|
||||
}} />
|
||||
</div>
|
||||
<div className='row'>
|
||||
<Checkbox
|
||||
ref='safeSearch'
|
||||
checkedIcon={<Visibility />}
|
||||
uncheckedIcon={<VisibilityOff />}
|
||||
label={<span className='text-nowrap' style={{fontSize: '0.9em', color: 'grey'}}>{this.state.safeSearchText}</span>}
|
||||
iconStyle={{fill: this.state.safeSearchColor}}
|
||||
onCheck={(ev, ch) => {
|
||||
if(ch)
|
||||
{
|
||||
this.setState({safeSearchText: 'safe search disabled', safeSearchColor: '#EC407A'});
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setState({safeSearchText: 'safe search enabled', safeSearchColor: 'rgb(0, 188, 212)'});
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
{
|
||||
this.stats
|
||||
?
|
||||
|
Loading…
Reference in New Issue
Block a user