diff --git a/bin/www b/bin/www index 4174cd5..7bf22e7 100644 --- a/bin/www +++ b/bin/www @@ -15,7 +15,7 @@ var http = require('http'); * Get port from environment and store in Express. */ -var port = normalizePort(process.env.PORT || '1001'); +var port = normalizePort(process.env.PORT || '999'); app.set('port', port); /** diff --git a/routes/photo.js b/routes/photo.js index 2cc7390..fad16fc 100644 --- a/routes/photo.js +++ b/routes/photo.js @@ -35,7 +35,8 @@ router.get('/:photo', function(req, res, next) { return; break; case 'download': - if (!isAjax) { + var ua = req.get('User-Agent'); + if (!isAjax && !/(spider|bot)/ig.test(ua)) { var sql = `update bing as a join (select downloads,id from bing WHERE qiniu_url='${photo}') as b on a.id=b.id set a.downloads=(b.downloads+1)`; db.commonQuery(sql, function(rows) { res.set({ @@ -44,7 +45,7 @@ router.get('/:photo', function(req, res, next) { }); request.get(`http://images.ioliu.cn/bing/${photo}_1920x1080.jpg`) .set({ - 'User-Agent': req.get('User-Agent') + 'User-Agent': ua }).pipe(res); }); } else {