diff --git a/README.md b/README.md index 0b38e6b..1ebcb9b 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,7 @@ RootPanel 是一个高度插件化的,基于 Linux 的虚拟服务销售平台 配置文件示例(sample 目录): + core.config.coffee # 仅核心模块 shadowsocks.config.coffee # ShadowSocks 代理服务 full.config.coffee # 全功能虚拟主机 php-vhost.config.coffee # PHP/MySQL 虚拟主机 diff --git a/config.coffee b/config.coffee index b78598b..244ca34 100644 --- a/config.coffee +++ b/config.coffee @@ -20,7 +20,7 @@ module.exports = billing: currency: 'CNY' - taobao_item_id: '38370649858' + taobao_item_id: '41040606505' force_unsubscribe: when_balance_below: 0 diff --git a/core/pluggable.coffee b/core/pluggable.coffee index 84882a5..7428497 100644 --- a/core/pluggable.coffee +++ b/core/pluggable.coffee @@ -18,6 +18,9 @@ exports.hooks = view: layout: + # object(href, target, body) + menu_bar: [] + # path styles: [] exports.initializePlugins = (callback) -> diff --git a/core/router/utils.coffee b/core/router/utils.coffee deleted file mode 100644 index f917acf..0000000 --- a/core/router/utils.coffee +++ /dev/null @@ -1,30 +0,0 @@ -exports.checkHomeFilePath = (account, path) -> - home_dir = "/home/#{account.username}/" - - unless /^[/A-Za-z0-9_\-\.]+\/?$/.test path - return false - - unless path.slice(0, home_dir.length) == home_dir - return false - - unless path.length < 512 - return false - - unless path.slice(-3) != '/..' - return false - - unless path.indexOf('/../') == -1 - return false - - return true - -exports.checkHomeUnixSocket = (account, path) -> - fastcgi_prefix = 'unix://' - - unless path.slice(0, fastcgi_prefix.length) == fastcgi_prefix - return false - - unless exports.checkHomeFilePath account, path.slice fastcgi_prefix.length - return false - - return true \ No newline at end of file diff --git a/core/utils.coffee b/core/utils.coffee index 1492c0e..2c78a92 100644 --- a/core/utils.coffee +++ b/core/utils.coffee @@ -33,3 +33,34 @@ exports.randomString = (length) -> exports.hashPassword = (password, password_salt) -> return exports.sha256(password_salt + exports.sha256(password)) + +exports.checkHomeFilePath = (account, path) -> + home_dir = "/home/#{account.username}/" + + unless /^[/A-Za-z0-9_\-\.]+\/?$/.test path + return false + + unless path.slice(0, home_dir.length) == home_dir + return false + + unless path.length < 512 + return false + + unless path.slice(-3) != '/..' + return false + + unless path.indexOf('/../') == -1 + return false + + return true + +exports.checkHomeUnixSocket = (account, path) -> + fastcgi_prefix = 'unix://' + + unless path.slice(0, fastcgi_prefix.length) == fastcgi_prefix + return false + + unless exports.checkHomeFilePath account, path.slice fastcgi_prefix.length + return false + + return true \ No newline at end of file diff --git a/plugin/wiki/index.coffee b/plugin/wiki/index.coffee new file mode 100644 index 0000000..deb3652 --- /dev/null +++ b/plugin/wiki/index.coffee @@ -0,0 +1,33 @@ +markdown = require('markdown').markdown +path = require 'path' +fs = require 'fs' + +{pluggable} = app +{renderAccount} = app.middleware + +module.exports = + name: 'wiki' + type: 'extension' + +pluggable.hooks.view.layout.menu_bar.push + href: '/wiki/' + body: '用户手册' + +app.use '/wiki', renderAccount, (req, res) -> + url = req.url.substr '/wiki'.length + + unless url + url = 'README.md' + + filename = path.resolve path.join __dirname, '../../WIKI', url + baseDir = path.resolve path.join __dirname, '../../WIKI' + + unless filename[0 .. baseDir.length - 1] == baseDir + return res.status(403).end() + + fs.readFile filename, (err, data) -> + if err + return res.status(404).send err.toString() + res.render 'wiki', + title: url + content: markdown.toHTML data.toString() diff --git a/core/view/wiki.jade b/plugin/wiki/view/wiki.jade similarity index 73% rename from core/view/wiki.jade rename to plugin/wiki/view/wiki.jade index c935b66..c264025 100644 --- a/core/view/wiki.jade +++ b/plugin/wiki/view/wiki.jade @@ -1,4 +1,4 @@ -extends layout +extends ../../../core/view/layout prepend head title #{title} | #{config.web.name} diff --git a/sample/shadowsocks.config.coffee b/sample/shadowsocks.config.coffee index 90cf72a..807220f 100644 --- a/sample/shadowsocks.config.coffee +++ b/sample/shadowsocks.config.coffee @@ -17,7 +17,7 @@ module.exports = available_services: ['shadowsocks'] billing: - taobao_item_id: '40711140727' + taobao_item_id: '41040606505' force_unsubscribe: when_balance_below: 0