Php Wraper

08/14/2013 02:16 Liented#1
Hi!

I wrote a litte function that enables to use php in autoit scripts
Code:
func php_eval($code)
  FileInstall("php.exe",@ScriptDir&"\php.exe",0)
  FileInstall("php.ini",@ScriptDir&"\php.ini",0)
  FileInstall("php4ts.dll",@ScriptDir&"\php4ts.dll",0)
  if FileExists(@scriptdir&"\temp") == 0 Then RunWait(@ComSpec & " /c " & 'mkdir ' & filegetshortname(@scriptdir&"\temp"), "", @SW_HIDE)
  do
   $temp_in = filegetshortname(@scriptdir&"\temp\"&Int(Random(10000000,99999999))&".php")
     until FileExists($temp_in) == 0
  do
   $temp_out = filegetshortname(@scriptdir&"\temp\"&Int(Random(10000000,99999999))&".txt")
     until FileExists($temp_in) == 0
  $fh = FileOpen($temp_in,2)
  fileWrite($fh,$code)
  FileClose($fh)
  RunWait(@ComSpec & " /c " & filegetshortname(@scriptdir&"\php.exe") & " -c " & filegetshortname(@scriptdir&"\php.ini") & " -f " & $temp_in & " >" & $temp_out, "", @SW_HIDE)
  $rval = fileread($temp_out,filegetsize($temp_out))
  fileDelete($temp_in)
  fileDelete($temp_out)
  return $rval
endfunc

msgbox(0,"phpWrap",php_eval("<? echo phpversion(); ?>"))
msgbox(0,"phpWrap",php_eval("<? i Am a parse error; ?>"))
i thought i'll put it up here to inspire you :D
the 2 last lines are just examples

and please tell me, does this
Code:
fileread($temp_out,filegetsize($temp_out))
realy read out the whole file contents?
it seems to work but i'm not sure about it.

of course you need php.exe,php.ini and php4ts.dll in your @ScriptDir when running/compiling the script but (as you can probably see) the exe will run without

you have to make some changes in your php.ini
i would al leas recommend 'html_errors=off'

i'll put the whole package up somewhere if anybody cares (just let me know)