diff --git a/index.js b/index.js index 08375f6..74cc782 100644 --- a/index.js +++ b/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) \ No newline at end of file +spider.listen(4445) \ No newline at end of file diff --git a/src/search.js b/src/search.js index 0136981..d9ad6d0 100644 --- a/src/search.js +++ b/src/search.js @@ -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() }} /> +