Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import subprocess
- import re
- import time
- class PHPCli(object):
- def __init__(self, libObj):
- self.irc = libObj
- def runScript(self, user, target, code):
- if target[0] == '#':
- runTime = time.time()
- input = ['php']
- input.append('-e')
- input.append('-c php.ini')
- input.append("-r $_SERVER=array();error_reporting(E_ALL);" + code)
- output = str(subprocess.Popen(input, stdout=subprocess.PIPE).stdout.read()).strip()
- print output
- runTime = (time.time() - runTime) * 1000
- runTime = str(round(runTime, 2))
- output = output.replace("\r\n", '')
- output = output.replace(' in Command line code on line 1', '')
- m = re.search('print_r|var_dump', output)
- if m:
- output = output.replace(' ', '')
- if output == '':
- output = 'None'
- self.irc.say(target, user['nick'] + ' - ' + runTime + 'ms: ' + output)
Add Comment
Please, Sign In to add comment