-1

我正在尝试创建一个系统,您可以在其中编辑带有文本字段的网页中的 config.php 文件,这是我的网页代码,但是当我通过此处http://color的网页编辑 config.php 时发生了什么-craft.info/dayzlegendz/controlpanel它用 / 替换 " 阻止配置工作

<?php

// First bring the actual value of the file:
$file = 'config.php';
// Uncomment next line to check if the file exists in the path
// print_r( glob( dirname(__FILE__) . "/*.php"  ) );

$configFile = html_entity_decode( file_get_contents($file) );

// On submit on the changes update the file
if ( isset( $_POST["save_button"] ) && $_POST["config_changes"]){
  # This doesn't work: $changes = $path = str_replace("\"", "'", $_POST["config_changes"]);
  file_put_contents($file, $_POST["config_changes"]);
}
header("Location: " . $_SERVER["SCRIPT_FILENAME"] );
?>

<html>
  <body>
    <!-- HTML form to send the changes to php -->
    <form method="post" action="file.php">
      <textarea name="config_changes"><?php echo $configFile ?></textarea>
      <button name="save_button">Save</button>
    </form>
  </body>
</html>

这是我的 config.php 代码

<?php

$site_title = "Shopname";
$site_name = "Shopname"; 

$mainpage_header = "Welcome";

$mainpage_content = "Buy A Key"; 

$dbhost = "nolooky"; 
$dbuser = "nolooky"; 
$dbpass = "nolooky"; 
$db = "nolooky"; 

$price1 = "2.50"; 
$price1keys = "1"; 

$price2 = "5.00"; 
$price2keys = "2";

$price3 = "7.50";
$price3keys = "3";

$price4 = "10.00";
$price4keys = "4";

$price5 = "12.50";
$price5keys = "5";

$paypal_email = "myemail"; 
$confirm_email = "myemail";
$fulldomain = "mydomain";

?>
4

2 回答 2

0

以下行将转换双引号

$configFile = html_entity_decode(file_get_contents($file));

你能把它改成如下

$configFile = html_entity_decode(file_get_contents($file), ENT_NOQUOTES);
于 2013-04-13T07:58:45.437 回答
0

听起来您在服务器上启用了 magic_quotes。在写入文件之前尝试放置它,如果它修复它,您可以保留它,或者最好禁用魔术引号/升级到更新的 php 版本。

`

$process = array(&$_GET, &$_POST, &$_COOKIE, &$_REQUEST);
while (list($key, $val) = each($process)) {
    foreach ($val as $k => $v) {
        unset($process[$key][$k]);
        if (is_array($v)) {
            $process[$key][stripslashes($k)] = $v;
            $process[] = &$process[$key][stripslashes($k)];
        } else {
            $process[$key][stripslashes($k)] = stripslashes($v);
        }
    }
}
unset($process);

} ?>`

于 2013-04-13T08:54:03.120 回答