|
 |
|
ใช้คำสั่งอะไรแทน exec() ได้บ้างคะ รบกวนทีค่ะ พอดีเขียน run ภาษาซีค่ะ |
|
 |
|
|
 |
 |
|
คำสั่งนี้ค่อนข้างจะอันตรายครับ เกือบทุกโฮสปิดหมดครับ ไม่น่าจะมี function อื่นแทนได้ครับ 
|
 |
 |
 |
 |
Date :
2011-05-19 17:01:27 |
By :
webmaster |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
พี่วินค แล้วมีการเขียน script ไรมั้ยคะ ที่ปรับให้ register_globals = on ได้น่ะคะ
เขียน .htaccess ก็ไม่ได้ค่ะ
|
 |
 |
 |
 |
Date :
2011-05-19 17:23:01 |
By :
thaimaster |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (PHP)
<?
//*** Register Global =On/Off Function ***//
$phpVersion = phpversion();
list($v_Upper,$v_Major,$v_Minor) = explode(".",$phpVersion);
if (($v_Upper == 4 && $v_Major < 1) || $v_Upper < 4) {
$_FILES = $HTTP_POST_FILES;
$_ENV = $HTTP_ENV_VARS;
$_GET = $HTTP_GET_VARS;
$_POST = $HTTP_POST_VARS;
$_COOKIE = $HTTP_COOKIE_VARS;
$_SERVER = $HTTP_SERVER_VARS;
$_SESSION = $HTTP_SESSION_VARS;
$_FILES = $HTTP_POST_FILES;
}
if (!ini_get('register_globals')) {
while(list($key,$value)=each($_FILES)) $GLOBALS[$key]=$value;
while(list($key,$value)=each($_ENV)) $GLOBALS[$key]=$value;
while(list($key,$value)=each($_GET)) $GLOBALS[$key]=$value;
while(list($key,$value)=each($_POST)) $GLOBALS[$key]=$value;
while(list($key,$value)=each($_COOKIE)) $GLOBALS[$key]=$value;
while(list($key,$value)=each($_SERVER)) $GLOBALS[$key]=$value;
while(list($key,$value)=@each($_SESSION)) $GLOBALS[$key]=$value;
foreach($_FILES as $key => $value){
$GLOBALS[$key]=$_FILES[$key]['tmp_name'];
foreach($value as $ext => $value2){
$key2 = $key."_".$ext;
$GLOBALS[$key2]=$value2;
}
}
}
?>
เอาตัวนี้สร้างเป็น include ไฟล์แล้วเรียกใช้ทุกหน้าครับ ใช้ได้ปกติครับ
Go to : PHP register_global = On/Off
|
 |
 |
 |
 |
Date :
2011-05-19 17:42:34 |
By :
webmaster |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ท่าทางไม่อนุญาติแน่นอนค่ะพี่วิน
ลองแล้ว งั้นดู code .ห้ทีนะคะ ว่าผิดตรงไหนหรือเปล่าคะ เพราะมันยัง error ว่า
Warning: exec() has been disabled for security reasons in /home/webcai/domains/webcai.com/public_html/sandbox/index.php on line 71
index.php
Code (PHP)
<?php
require_once "regon.php";
$docompile = intval($_REQUEST['docompile']);
if($docompile)
{
CreateFile();
Compile();
}
$defaultSource = "#include <stdio.h>
int main()
{
printf(\"Hello world!\");
return 0;
}
";
?>
<body>
<title>Test compile C code on PHP</title>
<form name="compile" method="post">
<p align="center">
<input type="hidden" name="docompile" value="1" />
<strong>Source file Output</strong></p>
<p align="center">
<textarea name="source" rows="20" cols="80"><?php
if($docompile) echo stripslashes($_REQUEST['source']);
else echo $defaultSource;
?>
</textarea>
<textarea name="source2" rows="20" cols="80"><?php
if(file_exists("a.exe"))
{
echo exec('a.exe');
}
else
{
echo "Not output file";
}
?>
</textarea>
<br />
</p>
<p>
<input type="submit" name="Submit" value="Compile">
____
<input name="btnButton" type="reset" value="Clear output" onClick="<?php unlink("a.exe");?>javascript:history.go(0)">
</p>
<p> </p>
<p>
<label></label>
</p>
</form>
<?php
function CreateFile()
{
$source2 = stripslashes($_REQUEST['source']);
file_put_contents('source.c', $source2);
}
function Compile()
{
global $Output;
exec('Compiler\Dev-Cpp\bin\gcc.exe source.c');
}
?>
</body>
</html>
regon.php
Code (PHP)
<?
//*** Register Global =On/Off Function ***//
$phpVersion = phpversion();
list($v_Upper,$v_Major,$v_Minor) = explode(".",$phpVersion);
if (($v_Upper == 4 && $v_Major < 1) || $v_Upper < 4) {
$_FILES = $HTTP_POST_FILES;
$_ENV = $HTTP_ENV_VARS;
$_GET = $HTTP_GET_VARS;
$_POST = $HTTP_POST_VARS;
$_COOKIE = $HTTP_COOKIE_VARS;
$_SERVER = $HTTP_SERVER_VARS;
$_SESSION = $HTTP_SESSION_VARS;
$_FILES = $HTTP_POST_FILES;
}
if (!ini_get('register_globals')) {
while(list($key,$value)=each($_FILES)) $GLOBALS[$key]=$value;
while(list($key,$value)=each($_ENV)) $GLOBALS[$key]=$value;
while(list($key,$value)=each($_GET)) $GLOBALS[$key]=$value;
while(list($key,$value)=each($_POST)) $GLOBALS[$key]=$value;
while(list($key,$value)=each($_COOKIE)) $GLOBALS[$key]=$value;
while(list($key,$value)=each($_SERVER)) $GLOBALS[$key]=$value;
while(list($key,$value)=@each($_SESSION)) $GLOBALS[$key]=$value;
foreach($_FILES as $key => $value){
$GLOBALS[$key]=$_FILES[$key]['tmp_name'];
foreach($value as $ext => $value2){
$key2 = $key."_".$ext;
$GLOBALS[$key2]=$value2;
}
}
}
?>
|
 |
 |
 |
 |
Date :
2011-05-19 19:18:27 |
By :
thaimaster |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
vps ไปเลยครับ หุหุ
|
 |
 |
 |
 |
Date :
2011-05-19 20:23:33 |
By :
sakang |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
พี่วินคะ ต้องตัดออกเปล่า หรือแก้จุดนี้ยังไงคะ
Code (PHP)
echo exec('a.exe');
|
 |
 |
 |
 |
Date :
2011-05-19 22:45:58 |
By :
thaimaster |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ลองตัดออกดูครับ
|
 |
 |
 |
 |
Date :
2011-05-20 10:05:57 |
By :
webmaster |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 03
|