Guest User

Untitled

a guest
Jun 24th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1.  
  2. import subprocess
  3. import re
  4. import time
  5.  
  6. class PHPCli(object):
  7.  
  8. def __init__(self, libObj):
  9. self.irc = libObj
  10.  
  11. def runScript(self, user, target, code):
  12. if target[0] == '#':
  13. runTime = time.time()
  14. input = ['php']
  15. input.append('-e')
  16. input.append('-c php.ini')
  17. input.append("-r $_SERVER=array();error_reporting(E_ALL);" + code)
  18. output = str(subprocess.Popen(input, stdout=subprocess.PIPE).stdout.read()).strip()
  19. print output
  20. runTime = (time.time() - runTime) * 1000
  21. runTime = str(round(runTime, 2))
  22. output = output.replace("\r\n", '')
  23. output = output.replace(' in Command line code on line 1', '')
  24. m = re.search('print_r|var_dump', output)
  25. if m:
  26. output = output.replace(' ', '')
  27. if output == '':
  28. output = 'None'
  29. self.irc.say(target, user['nick'] + ' - ' + runTime + 'ms: ' + output)
Add Comment
Please, Sign In to add comment