HEX
Server: Apache
System: Linux vpshost0650.publiccloud.com.br 4.4.79-grsec-1.lc.x86_64 #1 SMP Wed Aug 2 14:18:21 -03 2017 x86_64
User: bandeirantesbomb3 (10068)
PHP: 8.0.7
Disabled: apache_child_terminate,dl,escapeshellarg,escapeshellcmd,exec,link,mail,openlog,passthru,pcntl_alarm,pcntl_exec,pcntl_fork,pcntl_get_last_error,pcntl_getpriority,pcntl_setpriority,pcntl_signal,pcntl_signal_dispatch,pcntl_sigprocmask,pcntl_sigtimedwait,pcntl_sigwaitinfo,pcntl_strerror,pcntl_wait,pcntl_waitpid,pcntl_wexitstatus,pcntl_wifexited,pcntl_wifsignaled,pcntl_wifstopped,pcntl_wstopsig,pcntl_wtermsig,php_check_syntax,php_strip_whitespace,popen,proc_close,proc_open,shell_exec,symlink,system
Upload Files
File: //lib/python2.7/site-packages/lwdbadmin/bottlelibs/bottlemysql.py
import logging
import os

from lwdbadmin.bottle import abort, get, post, delete, request, route
from lwdbadmin.mysql import libmysql


# bottle support for the new API

# Until today, we have the user == database logic
# Someday this will change, but not now

# The ideal would be the control over the database, that is what we sell
# but you can't lock databases, you lock users, so you will see create
# database and lock user

@post('/mysql')
def createDatabase():
    entity = request.json
    database = entity.get('database')
    username = entity.get('username')
    password = entity.get('password')
    osuser   = entity.get('osuser')
    # hide host from panel, it's not wise to let the logic
    # outside the operations side
    host = '%'

    try:
        libmysql.createdatabase(database, username, password, host, osuser)
        logging.info('Database created: {0}'.format(database))
    except Exception, e:
        logging.error("Could not create database {0}: {1}".format(database, str(e)))
        abort(500, str(e))
    return 'Database {0} created'.format(database)


@delete('/mysql/<osuser>/<database>')
@delete('/mysql/:database')
def deleteDatabase(database, osuser=None):
    try:
        libmysql.removedatabase(database, osuser)
        logging.info('Database removed: {0}'.format(database))
    except libmysql.DatabaseNotExists, le:
        abort(404, 'Database does not exists')
    except Exception, e:
        abort(500, str(e))

    return "Database {0} removed".format(database)


@get('/mysql/<osuser>/<database>')
@get('/mysql/:database')
def isActive(database, osuser=None):
    try:
        status = libmysql.isactive(database, osuser)
    except libmysql.DatabaseNotExists, le:
        abort(404, 'Database does not exists')
    except Exception, e:
        abort(500, str(e))

    return { 'database': database,
             'status': "enabled" if status else "disabled"}

@route('/mysql/<osuser>/<database>', 'PATCH')
@route('/mysql/:database', 'PATCH')
def changeDatabase(database, osuser=None):
    entity      = request.json
    password    = entity.get('password')
    status      = entity.get('status')

    try:
        if password:
            libmysql.setpassword(database, password, osuser)
            return 'Password set for user {0}'.format(database)
        if status == 'enabled':
            libmysql.activatedatabase(database, osuser)
            logging.info('Database {0} is now enabled'.format(database))

        elif status == 'disabled':
            libmysql.deactivedatabase(database, osuser)
            logging.info('Database {0} is now disabled'.format(database))
        else:
            abort(400, "'status' must be one of {'enabled', 'disabled'}")

    except libmysql.DatabaseNotExists, le:
        abort(404, 'Database does not exists')
    except Exception, e:
        abort(500, str(e))

    return "Login {0} is now {1}".format(database, status)