2012-07-13 7 views
0

사용자가 정보 (특히 정수)를 양식 필드에 입력하고 .def 파일에 항목으로 입력 한 정보를 추가 할 수있게 해주는 웹 기반 응용 프로그램을 프로그래밍하려고합니다. 파일에 C++로 작성된 '.exe'파일을 실행 한 다음 '제출'버튼을 클릭하면 화면에 결과가 표시됩니다. .exe 파일을 JavaScript로 실행하는 함수를 작성했지만 작동하지 않습니다. 여기웹 응용 프로그램에서 .exe 파일 실행

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 
<html><head></head>><body><h1><i>The University of Vermont<br>Department of Medical  Biostatistics<br>Study Randomization Page</i></h1> 
<?php 
    $study = "study"; 
    $site = "site"; 
    $gender = "gender"; 
    $age = "age"; 
    $result = "result"; 
?> 

Please Input Your Study Information Below:<br><br> 
<form id="form1" action="file:///C:/Documents and Settings/cody/Desktop/DMB_RD_2.php"  method="post"> 
Study Number:<br> <input name="study" type="int"><br> 
Site Number:<br> <input name="site" type="int"><br> 
Subject Gender:<br> <input name="gender" type="int"><br> 
Subject Age:<br> <input name="age" type="int"><br> 
Lab Result:<br>  <input name="result" type="int"><br> 
<input value="Submit" class="button" type="submit"> 
</form> 
</body></html> 
Here is the page it is connected to (PHP file); 
<script type="text/javascript" src="DMB++2JS.js"></script> 
<script type="text" src="DMB Round 2.html"></script> 
</head> 
Here is the information that you input:<br /><br /> 
Study Number: <?php echo $_POST["study"]; ?><br /> 
Site Number: <?php echo $_POST["site"]; ?><br /> 
Subject Gender: <?php echo $_POST["gender"]; ?><br /> 
Subject Age: <?php echo $_POST["age"]; ?><br /> 
Lab Result: <?php echo $_POST["result"]; ?><br /> 
<br /> 
The following functions will randomize your data. Please indicated which method you would like to use by clicking on the button of the randomization method that you would like to use:<br /><br /> 
<input type="button" href="blockfn()" onclick="javascript:blockfn(); return  true;">Block Function</button><br /> 
<input type="button" href="d2rfn()" onclick="javascript:d2rfn(); return true;">Random Distance Function</button><br /> 
<input type="button" href="d2dfn()" onclick="javascript:d2dfn(); return true;">Determinate Distance Function</button><br /> 
<input type="button" href="minimizefn()" onclick="javascript:minimizefn(); return true;">Minimization Function</button><br /> 
<input type="button" href="pocockfn()" onclick="javascript:pocockfn(); return true;">Pocock Function</button><br /> 
</body> 
</html> 

는 자바 스크립트로 작성된 기능 파일입니다 : 마지막으로

function d2rfn(){ 
    var oShell = new ActiveXObject("Shell.Application"); 
    var commandtoRun = "C:\Documents and Settings\cody\Desktop\C++ Programs\D2R001.def"; 
    oShell.ShellExecute(commandtoRun,"","","open","1"); 
} 
function d2dfn(){ 
    var oShell = new ActiveXObject("Shell.Application"); 
    var commandtoRun = "C:\Documents and Settings\cody\Desktop\C++ Programs\D2D001.def"; 
    oShell.ShellExecute(commandtoRun,"","","open","1"); 
} 
function minimizefn(){ 
    var oShell = new ActiveXObject("Shell.Application"); 
    var commandtoRun = "C:\Documents and Settings\cody\Desktop\C++ Programs\MINIMIZE001.def"; 
    oShell.ShellExecute(commandtoRun,"","","open","1"); 
} 
function pocockfn(){ 
    var oShell = new ActiveXObject("Shell.Application"); 
    var commandtoRun = "C:\\Documents and Settings\\cody\\Desktop\\C++ Programs\\POCOCK2001.def"; 
    oShell.ShellExecute(commandtoRun,"","","open","1"); 
} 
//Another possible way of calling the .exe file from the web interface. 
var objShell = new ActiveXObject("WScript.Shell"); 
</script> 

입력 화면이 코드 (HTML 파일)가 : 여기에 지금까지 무엇을 가지고 , 나는 (작동하지 않는) ASP에 파일을 씁니다 :

<% 
    dim Study 
    Study=Request.QueryString("Study") 
    If Study<>"" Then 
     Response.Write(Study) 
    End If 
    dim Site 
    Site=Request.QueryString("Site") 
    If Site<>"" Then 
     Response.Write(Site) 
    End If  
    dim Gender 
    Gender=Request.QueryString("Gender") 
    If Gender<>"" Then 
     Response.Write(Gender) 
    End If 
    dim Age 
    Age=Request.QueryString("Age") 
    If Age<>"" Then 
     Response.Write(Age) 
    End If 
    dim Result 
    Result=Response.QueryString("Result") 
    If Result<>"" Then 
     Response.Write(Result) 
    End If 
%> 

아무도 깨끗한 방법으로 cre 이 응용 프로그램을 먹었습니까? 대단히 감사하겠습니다. 감사!

+3

정말로 웹 페이지에서 컴퓨터에서 프로그램을 실행할 수 있다고 생각하십니까? 일반적으로 이것은 취약점이라고합니다 ... :) –

+0

클리너는 ASP와 PHP를 섞어서는 안 될까요? 그래서 당신은 웹이 아닌 윈도우 애플 리케이션으로 이것을하고 있습니까? –

+0

그것이 바이러스가 전파되는 방식입니다. 왜 exe는 서버 측을 처리합니까? – jrummell

답변

0

하지 마십시오. 자바 스크립트는 클라이언트 컴퓨터에서 실행되기 때문에 프로그램이 클라이언트의 컴퓨터에서 실행되고 파일도 함께 있어야합니다. 웹 응용 프로그램을 만드는 목적에 위배됩니다.

또한 브라우저에 자바 스크립트가 로컬 실행 파일을 실행하지 못하게하는 모든 종류의 보안상의 이유가 있습니다. 지원되는 경우 웹 사이트를 방문하면 컴퓨터가 실행될 수 있습니다 (예 : format.exe).

먼저 단일 서버 측 웹 개발 프레임 워크를 선택하십시오. PHP & ASP.NET을 결합하지 마십시오. 둘째, 파일 시스템과 명령 행 유틸리티에 파일이 없으면이를 처리 할 수있는 방법이 있는지 알아 내십시오. 선택한 모든 개발 프레임 워크에서이 논리를 수행 할 수 있습니까? 할 수 없다면 파일 작성 방법, .exe 호출을위한 쉘 아웃 방법 및 결과 반환 방법을 알아야합니다. 이 문제들 중 어느 것도 그 자체로 특별히 까다 롭지는 않습니다. 나는 한 번에 하나씩 문제를 해결하려고합니다.

관련 문제