Example #1
0
def start():
    initDreplace()

    path = getConf()
    conf = mw.readFile(path)
    conf = conf.replace('#include luawaf.conf;', "include luawaf.conf;")

    mw.writeFile(path, conf)
    mw.restartWeb()
    return 'ok'
Example #2
0
def checkPhpinfoFile(v):
    if mw.isInstalledWeb():
        sdir = mw.getServerDir()
        dfile = sdir + '/openresty/nginx/conf/php_status/phpinfo_' + v + '.conf'
        if not os.path.exists(dfile):
            tpl = getPluginDir() + '/conf/phpinfo.conf'
            content = mw.readFile(tpl)
            content = contentReplace(content, v)
            mw.writeFile(dfile, content)
            mw.restartWeb()
Example #3
0
def start():
    file_tpl = getPluginDir() + '/conf/xhprof.conf'
    file_run = getConf()

    if not os.path.exists(file_run):
        centent = mw.readFile(file_tpl)
        centent = contentReplace(centent)
        mw.writeFile(file_run, centent)

    mw.restartWeb()
    return 'ok'
Example #4
0
def stop():
    path = mw.getServerDir() + "/openresty/nginx/conf/waf"
    if os.path.exists(path):
        cmd = 'rm -rf ' + path
        mw.execShell(cmd)

    path = getConf()
    conf = mw.readFile(path)
    conf = conf.replace('include luawaf.conf;', "#include luawaf.conf;")

    mw.writeFile(path, conf)
    mw.restartWeb()
    return 'ok'
Example #5
0
def setXhPort():
    args = getArgs()
    if not 'port' in args:
        return mw.returnJson(False, 'port missing!')

    port = args['port']
    if port == '80':
        return mw.returnJson(False, '80端不能使用!')

    file = getConf()
    if not os.path.exists(file):
        return mw.returnJson(False, '插件未启动!')
    content = mw.readFile(file)
    rep = 'listen\s*(.*);'
    content = re.sub(rep, "listen " + port + ';', content)
    mw.writeFile(file, content)
    mw.restartWeb()
    return mw.returnJson(True, '修改成功!')
Example #6
0
def start():
    file_tpl = getPluginDir() + '/conf/phpmyadmin.conf'
    file_run = getConf()

    if not os.path.exists(file_run):
        centent = mw.readFile(file_tpl)
        centent = contentReplace(centent)
        mw.writeFile(file_run, centent)

    conf_run = getServerDir() + '/phpmyadmin/config.inc.php'
    if not os.path.exists(conf_run):
        conf_tpl = getPluginDir() + '/conf/config.inc.php'
        centent = mw.readFile(conf_tpl)
        # centent = contentReplace(centent)
        print mw.writeFile(conf_run, centent)

    mw.restartWeb()
    return 'ok'
Example #7
0
def setPhpVer():
    args = getArgs()

    if not 'phpver' in args:
        return 'phpver missing'

    cacheFile = getServerDir() + '/php.pl'
    mw.writeFile(cacheFile, args['phpver'])

    file_tpl = getPluginDir() + '/conf/xhprof.conf'
    file_run = getConf()

    centent = mw.readFile(file_tpl)
    centent = contentReplacePHP(centent, args['phpver'])
    mw.writeFile(file_run, centent)

    mw.restartWeb()

    return 'ok'
Example #8
0
    def saveBody(self, path, data, encoding='utf-8'):
        if not os.path.exists(path):
            return mw.returnJson(False, '文件不存在')
        try:
            if encoding == 'ascii':
                encoding = 'utf-8'
            if sys.version_info[0] == 2:
                data = data.encode(encoding, errors='ignore')
                fp = open(path, 'w+')
            else:
                data = data.encode(encoding, errors='ignore').decode(encoding)
                fp = open(path, 'w+', encoding=encoding)
            fp.write(data)
            fp.close()

            if path.find("web_conf") > 0:
                mw.restartWeb()

            mw.writeLog('文件管理', '文件保存成功', (path, ))
            return mw.returnJson(True, '文件保存成功')
        except Exception as ex:
            return mw.returnJson(False, 'FILE_SAVE_ERR:' + str(ex))
Example #9
0
def makeOpenrestyConf():
    phpversions = [
        '00', '52', '53', '54', '55', '56', '70', '71', '72', '73', '74', '80',
        '81'
    ]
    if mw.isInstalledWeb():
        sdir = mw.getServerDir()
        d_pathinfo = sdir + '/openresty/nginx/conf/pathinfo.conf'
        if not os.path.exists(d_pathinfo):
            s_pathinfo = getPluginDir() + '/conf/pathinfo.conf'
            shutil.copyfile(s_pathinfo, d_pathinfo)

        info = getPluginDir() + '/info.json'
        content = mw.readFile(info)
        content = json.loads(content)
        versions = content['versions']
        tpl = getPluginDir() + '/conf/enable-php.conf'
        tpl_content = mw.readFile(tpl)
        for x in phpversions:
            dfile = sdir + '/openresty/nginx/conf/enable-php-' + x + '.conf'
            if not os.path.exists(dfile):
                if x == '00':
                    mw.writeFile(dfile, '')
                else:
                    w_content = contentReplace(tpl_content, x)
                    mw.writeFile(dfile, w_content)

        # php-fpm status
        for version in phpversions:
            dfile = sdir + '/openresty/nginx/conf/php_status/phpfpm_status_' + version + '.conf'
            tpl = getPluginDir() + '/conf/phpfpm_status.conf'
            if not os.path.exists(dfile):
                content = mw.readFile(tpl)
                content = contentReplace(content, version)
                mw.writeFile(dfile, content)
        mw.restartWeb()
Example #10
0
def stop():
    conf = getConf()
    if os.path.exists(conf):
        os.remove(conf)
    mw.restartWeb()
    return 'ok'
Example #11
0
def restart():
    mw.restartWeb()
    return 'ok'