예제 #1
0
    def checkDir(self, path):
        path = path.replace('//', '/')
        if path[-1:] == '/':
            path = path[:-1]

        nDirs = ('',
                 '/',
                 '/*',
                 '/www',
                 '/root',
                 '/boot',
                 '/bin',
                 '/etc',
                 '/home',
                 '/dev',
                 '/sbin',
                 '/var',
                 '/usr',
                 '/tmp',
                 '/sys',
                 '/proc',
                 '/media',
                 '/mnt',
                 '/opt',
                 '/lib',
                 '/srv',
                 '/selinux',
                 '/www/server',
                 '/www/server/data',
                 public.getRootDir())

        return not path in nDirs
예제 #2
0
    def removeTaskApi(self):
        mid = request.form.get('id', '').encode('utf-8')
        try:
            name = public.M('tasks').where('id=?', (mid,)).getField('name')
            status = public.M('tasks').where('id=?', (mid,)).getField('status')
            public.M('tasks').delete(mid)
            if status == '-1':
                os.system(
                    "kill `ps -ef |grep 'python panelSafe.pyc'|grep -v grep|grep -v panelExec|awk '{print $2}'`")
                os.system(
                    "kill `ps aux | grep 'python task.pyc$'|awk '{print $2}'`")
                os.system('''
pids=`ps aux | grep 'sh'|grep -v grep|grep install|awk '{print $2}'`
arr=($pids)

for p in ${arr[@]}
do
    kill -9 $p
done
            ''')

                os.system(
                    'rm -f ' + name.replace('扫描目录[', '').replace(']', '') + '/scan.pl')
                isTask = public.getRootDir() + '/tmp/panelTask.pl'
                public.writeFile(isTask, 'True')
                os.system('/etc/init.d/mw start')
        except:
            os.system('/etc/init.d/mw start')
        return public.returnJson(True, '任务已删除!')
예제 #3
0
    def getDirApi(self):
        path = request.form.get('path', '').encode('utf-8')
        if not os.path.exists(path):
            path = public.getRootDir() + "/wwwroot"
        search = request.args.get('search', '').strip().lower()
        page = request.args.get('p', '1').strip().lower()
        row = request.args.get('showRow', '10')
        disk = request.form.get('disk', '')
        if disk == 'True':
            row = 1000

        return self.getDir(path, int(page), int(row), search)
예제 #4
0
    def downloadFileApi(self):
        import db
        import time
        url = request.form.get('url', '').encode('utf-8')
        path = request.form.get('path', '').encode('utf-8')
        filename = request.form.get('filename', '').encode('utf-8')

        isTask = public.getRootDir() + '/tmp/panelTask.pl'
        execstr = url + '|mw|' + path + '/' + filename
        public.M('tasks').add('name,type,status,addtime,execstr',
                              ('下载文件[' + filename + ']', 'download', '0', time.strftime('%Y-%m-%d %H:%M:%S'), execstr))
        public.writeFile(isTask, 'True')
        # self.setFileAccept(path + '/' + filename)
        return public.returnJson(True, '已将下载任务添加到队列!')
예제 #5
0
 def __init__(self):
     self.rPath = public.getRootDir() + '/recycle_bin/'