diff --git a/.gitignore b/.gitignore
index 00e6e8afd..d06ac5370 100644
--- a/.gitignore
+++ b/.gitignore
@@ -112,3 +112,4 @@ data/json/index.json
*.zip
data/*.db
data/control.conf
+scripts/init.d/mw
diff --git a/class/core/config.py b/class/core/config.py
index 36097e952..84923cb3b 100644
--- a/class/core/config.py
+++ b/class/core/config.py
@@ -31,6 +31,8 @@ class config:
__app = app
self.initDB()
+
+ self.initInitD()
return app
def initDB(self):
@@ -43,6 +45,19 @@ class config:
except Exception, ex:
print str(ex)
+ def initUser(self):
+ pass
+
+ def initInitD(self):
+ script = public.getRunDir() + '/scripts/init.d/mw.tpl'
+ script_bin = public.getRunDir() + '/scripts/init.d/mw'
+
+ content = public.readFile(script)
+ content = content.replace("{$SERVER_PATH}", public.getRunDir())
+
+ public.writeFile(script_bin, content)
+ public.execShell('chmod +x ' + script_bin)
+
def getVersion(self):
return self.__version
diff --git a/data/port.pl b/data/port.pl
new file mode 100755
index 000000000..d4fd586e0
--- /dev/null
+++ b/data/port.pl
@@ -0,0 +1 @@
+7200
\ No newline at end of file
diff --git a/plugins/csvn/js/csvn.js b/plugins/csvn/js/csvn.js
index 96b56cc69..1d9e237e0 100755
--- a/plugins/csvn/js/csvn.js
+++ b/plugins/csvn/js/csvn.js
@@ -325,6 +325,10 @@ function csvnAclDel(pname, uname){
});
}
+function csvnAclSet(pname){
+
+}
+
function csvnAclProject(pname){
csvnPost('project_acl_list', {'name':pname}, function(data){
@@ -335,6 +339,7 @@ function csvnAclProject(pname){
var list = '';
for (i in rdata) {
+ var user = rdata[i]['user'];
var acl = '';
if (rdata[i]['acl'] == 'r'){
acl += ' 只读 | 读写';
@@ -342,8 +347,8 @@ function csvnAclProject(pname){
acl += ' 只读 | 读写';
}
- list += '
'+rdata[i]['user']+' | ' + acl +' | '+
- '删除 | '+'
';
+ list += ''+user+' | ' + acl +' | '+
+ '删除 | '+'
';
}
var loadOpen = layer.open({
diff --git a/route/dashboard.py b/route/dashboard.py
index 9b9a6056c..bea0fbc9e 100644
--- a/route/dashboard.py
+++ b/route/dashboard.py
@@ -79,8 +79,21 @@ def login():
@dashboard.route("/do_login", methods=['POST'])
def doLogin():
- print request.args
-
- # return "123"
- # return public.returnJson(False, 'LOGIN_USER_EMPTY')
- return public.returnJson(True, 'LOGIN_SUCCESS')
+ username = request.form.get('username', '').strip()
+ password = request.form.get('password', '').strip()
+ code = request.form.get('code', '').strip()
+ print session
+ if session.has_key('code'):
+ if session['code'] != public.md5(code):
+ return public.returnJson(False, '验证码错误,请重新输入!')
+
+ userInfo = public.M('users').where(
+ "id=?", (1,)).field('id,username,password').find()
+
+ password = public.md5(password)
+ if userInfo['username'] != username or userInfo['password'] != password:
+ public.writeLog('TYPE_LOGIN', public.getInfo(
+ "< a style='color: red'>密码错误,帐号:{1},密码:{2},登录IP:{3}", (('****', '******', request.remote_addr))))
+ return public.returnJson(False, public.getInfo("用户名或密码错误,您还可以尝试[{1}]次!", ('1')))
+
+ return public.returnJson(True, '登录成功,正在跳转...')
diff --git a/scripts/init.d/mw.sh b/scripts/init.d/mw.sh
deleted file mode 100755
index 67f7878f6..000000000
--- a/scripts/init.d/mw.sh
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/bin/bash
-PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
-
-curPath=`pwd`
-rootPath=$(dirname "$curPath")
diff --git a/scripts/init.d/mw.tpl b/scripts/init.d/mw.tpl
new file mode 100755
index 000000000..c2a53a0ba
--- /dev/null
+++ b/scripts/init.d/mw.tpl
@@ -0,0 +1,35 @@
+#!/bin/bash
+PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
+
+mw_path={$SERVER_PATH}
+
+mw_start(){
+ isStart=`ps -ef|grep 'gunicorn -c setting.py app:app' |grep -v grep|awk '{print $2}'`
+ if [ "$isStart" == '' ];then
+ echo -e "Starting mw... \c"
+ cd $mw_path && gunicorn -c setting.py app:app &
+ sleep 0.1
+ port=$(cat ${mw_path}/data/port.pl)
+ isStart=$(lsof -i :$port|grep LISTEN)
+ if [ "$isStart" == '' ];then
+ echo -e "\033[31mfailed\033[0m"
+ echo '------------------------------------------------------'
+ tail -n 20 $panel_path/logs/error.log
+ echo '------------------------------------------------------'
+ echo -e "\033[31mError: mw service startup failed.\033[0m"
+ return;
+ fi
+ echo -e "\033[32mdone\033[0m"
+ else
+ echo "Starting mw... mw(pid $(echo $isStart)) already running"
+ fi
+}
+
+
+
+
+case "$1" in
+ 'start')
+ mw_start
+ ;;
+esac
\ No newline at end of file
diff --git a/setting.py b/setting.py
new file mode 100755
index 000000000..1df2fc07b
--- /dev/null
+++ b/setting.py
@@ -0,0 +1,27 @@
+import os
+import time
+import sys
+sys.path.append(os.getcwd() + '/class/core')
+import public
+
+
+bt_port = public.readFile('data/port.pl')
+bind = ['0.0.0.0:%s' % bt_port]
+workers = 1
+threads = 1
+backlog = 512
+reload = False
+daemon = False
+timeout = 7200
+keepalive = 1
+# worker_class = 'geventwebsocket.gunicorn.workers.GeventWebSocketWorker'
+chdir = os.getcwd()
+# capture_output = True
+# access_log_format = '%(t)s %(p)s %(h)s "%(r)s" %(s)s %(L)s %(b)s %(f)s" "%(a)s"'
+# loglevel = 'info'
+# errorlog = chdir + '/logs/error.log'
+# accesslog = chdir + '/logs/access.log'
+# pidfile = chdir + '/logs/panel.pid'
+# if os.path.exists(chdir + '/data/ssl.pl'):
+# certfile = 'ssl/certificate.pem'
+# keyfile = 'ssl/privateKey.pem'
diff --git a/start.sh b/start.sh
index ec47fe6c1..47968b2f8 100755
--- a/start.sh
+++ b/start.sh
@@ -1,7 +1,4 @@
#!/bin/sh
-gunicorn -b :7200 app:app &
-
-python task.py &
-
-#open "http://127.0.0.1:7200"
\ No newline at end of file
+gunicorn -c setting.py app:app &
+python task.py &
\ No newline at end of file
diff --git a/task.py b/task.py
index c22844aa5..f57f531fb 100755
--- a/task.py
+++ b/task.py
@@ -7,7 +7,7 @@ import sys
import os
import json
import time
-print sys.path
+# print sys.path
sys.path.append("/usr/local/lib/python2.7/site-packages")
import psutil
diff --git a/templates/default/login.html b/templates/default/login.html
index 0ac5315f6..3332437a3 100755
--- a/templates/default/login.html
+++ b/templates/default/login.html
@@ -10,131 +10,129 @@
mdserver-web
-
+
-
-