static string UseInterpreter(string php, string file)
{
//php - путь до интерпретатора, в нашем случае php-cgi.exe
//file - реальный путь до файла: C:\\...\...
ProcessStartInfo info = new ProcessStartInfo(php);//, file
info.UseShellExecute = false;
info.ErrorDialog = false;
info.RedirectStandardError = true;
info.RedirectStandardInput = true;
info.RedirectStandardOutput = true;
info.CreateNoWindow = true;
info.EnvironmentVariables.Add("REQUEST_METHOD", "POST");
info.EnvironmentVariables.Add("HTTP_CONNECTION", "keep-alive");
info.EnvironmentVariables.Add("REDIRECT_STATUS", "false");
info.EnvironmentVariables.Add("CONTENT_TYPE", "multipart/form-data");
info.EnvironmentVariables.Add("QUERY_STRING", "login=admin&pass=secretpass&but=%D0%92%D0%BE%D0%B9%D1%82%D0%B8");
//info.EnvironmentVariables.Add("CONTENT_LENGTH", Encoding.UTF8.GetBytes("login=admin&pass=secretpass&but=%D0%92%D0%BE%D0%B9%D1%82%D0%B8").Length.ToString());
info.EnvironmentVariables.Add("SCRIPT_FILENAME", file);
//Console.WriteLine(Encoding.UTF8.GetBytes("login=admin&pass=secretpass&but=%D0%92%D0%BE%D0%B9%D1%82%D0%B8").Length.ToString());
Process p = new Process();
p.StartInfo = info;
bool pStarted = p.Start();
StreamWriter input = p.StandardInput;
StreamReader output = p.StandardOutput;
StreamReader error = p.StandardError;
byte[] cp866_byte = output.CurrentEncoding.GetBytes(output.ReadToEnd());
string cp866_byte_to_utf8 = Encoding.UTF8.GetString(cp866_byte);
return cp866_byte_to_utf8;
}