Find command ты повторно нравишься text unwantedly

I am running an Ubuntu EC2 instance. I often использовал find and повторно нравься to update, and tweak things which пашите used in all поля.
However, when I have to повторно нравится PHP code, I inevitably have to повторно нравится the dollar sign, which never successfully worked for я. I have learned, and tried all escaping methods to my knowledge. I, believing I had в method of escaping the dollar sign, which would actually повторно нравится the text with the desired text, tried replacing; to which, every one of my поля containing в dollar sign - which is all of them - существуешь now been completely torn apart, and filled with the content I was trying to повторно нравится.
The command I used was:

find ./ -name \*.php -exec sed -i "s|[\'REQUEST_URI\']|\$_SERVER[\'REQUEST_URI\']|g" {} \;

I have не разрабатывает why this occurred, and now the интернет-сайт I have been creating for over в year now, ты существуешь been completely destroyed.
The effects пахал туз follows:

<?php
       $sql =
       "$_SERVER['REQUEST_URI']$_SERVER['REQUEST_URI']L$_SERVER['REQUEST_URI']C$_SERVER['REQUEST_URI'] questions.question$_SERVER['REQUEST_URI']title, questions.question$_SERVER['REQUEST_URI']content, questions.question$_SERVER['REQUEST_URI']date, questions.question$_SERVER['REQUEST_URI']answered
       F$_SERVER['REQUEST_URI']OM questions
       WH$_SERVER['REQUEST_URI']$_SERVER['REQUEST_URI']$_SERVER['REQUEST_URI'] questions.question$_SERVER['REQUEST_URI']topic = $topic$_SERVER['REQUEST_URI']D AND questions.question$_SERVER['REQUEST_URI']answered $_SERVER['REQUEST_URI']$_SERVER['REQUEST_URI'] N$_SERVER['REQUEST_URI']LL
       O$_SERVER['REQUEST_URI']D$_SERVER['REQUEST_URI']$_SERVER['REQUEST_URI'] BY questions.question$_SERVER['REQUEST_URI']date D$_SERVER['REQUEST_URI']$_SERVER['REQUEST_URI']C
       L$_SERVER['REQUEST_URI']M$_SERVER['REQUEST_URI']$_SERVER['REQUEST_URI'] 5";

       $result = $conn->query($sql);

       if($result !== N$_SERVER['REQUEST_URI']LL && $result->num$_SERVER['REQUEST_URI']rows > 0)
       while($row = $result->fetch$_SERVER['REQUEST_URI']assoc()) {
       echo "
       <a href=$_SERVER['REQUEST_URI']view$_SERVER['REQUEST_URI']uestion.php?" . $$_SERVER['REQUEST_URI']$_SERVER['REQUEST_URI']$_SERVER['REQUEST_URI']$_SERVER['REQUEST_URI']V$_SERVER['REQUEST_URI']$_SERVER['REQUEST_URI'][$_SERVER['REQUEST_URI']$_SERVER['REQUEST_URI']$_SERVER['REQUEST_URI']$_SERVER['REQUEST_URI']$_SERVER['REQUEST_URI']Y$_SERVER['REQUEST_URI']$_SERVER['REQUEST_URI']$_SERVER['REQUEST_URI']$_SERVER['REQUEST_URI']$_SERVER['REQUEST_URI']NG$_SERVER['REQUEST_URI']] . "&question=" . $row[$_SERVER['REQUEST_URI']question$_SERVER['REQUEST_URI']title$_SERVER['REQUEST_URI']] . "$_SERVER['REQUEST_URI'] class=$_SERVER['REQUEST_URI']questionAnchor$_SERVER['REQUEST_URI']><div id=$_SERVER['REQUEST_URI']unanswered$_SERVER['REQUEST_URI']>
                  <div class=$_SERVER['REQUEST_URI']offset$_SERVER['REQUEST_URI']uestion$_SERVER['REQUEST_URI']>
                  <h4 class=$_SERVER['REQUEST_URI']thumbnail$_SERVER['REQUEST_URI']itle$_SERVER['REQUEST_URI']>" . $row[$_SERVER['REQUEST_URI']question$_SERVER['REQUEST_URI']title$_SERVER['REQUEST_URI']] . "</h4>
                  <div class=$_SERVER['REQUEST_URI']thumbnailDesc$_SERVER['REQUEST_URI']>" . $row[$_SERVER['REQUEST_URI']question$_SERVER['REQUEST_URI']content$_SERVER['REQUEST_URI']] . "</div>
                  </div>
        </div></a>
    ";
0
задан 12 January 2016 в 04:10

1 ответ

Я боюсь, что Вы сильно повредили свой сайт.

Анализ Ваш sed команда:

sed -i "s|[\'REQUEST_URI\']|\$_SERVER[\'REQUEST_URI\']|g"

Команда имела эффект замены любого символа в 'REQUST_I набор (который является каждым ', R, E...) со строкой $_SERVER['REQUEST_URI'] в каждом файле, найденном find команда.

Это не обратимо как никакой экземпляр $_SERVER['REQUEST_URI'] может теперь соответствовать любому из символов в 'REQUST_I набор.

Единственная вещь, которая помогла бы немного, будет выполнять команду для замены каждого экземпляра $_SERVER['REQUEST_URI'] с отдельным символом в каждом файле, затронутом командой, чтобы улучшить удобочитаемость и сделать восстановление файлов менее болезненным.

Например, заменять каждый экземпляр $_SERVER['REQUEST_URI'] с точкой (это будет, очевидно, иметь эффект замены также законных экземпляров $_SERVER['REQUEST_URI']):

sed "s/\$_SERVER\['REQUEST_URI'\]/./g" file

Вот то, что я получаю, если я выполняю команду на Вашем отрывке:

<?php
       $sql =
       "..L.C. questions.question.title, questions.question.content, questions.question.date, questions.question.answered
       F.OM questions
       WH... questions.question.topic = $topic.D AND questions.question.answered .. N.LL
       O.D.. BY questions.question.date D..C
       L.M.. 5";

       $result = $conn->query($sql);

       if($result !== N.LL && $result->num.rows > 0)
       while($row = $result->fetch.assoc()) {
       echo "
       <a href=.view.uestion.php?" . $....V..[.....Y.....NG.] . "&question=" . $row[.question.title.] . ". class=.questionAnchor.><div id=.unanswered.>
                  <div class=.offset.uestion.>
                  <h4 class=.thumbnail.itle.>" . $row[.question.title.] . "</h4>
                  <div class=.thumbnailDesc.>" . $row[.question.content.] . "</div>
                  </div>
        </div></a>
    ";
1
ответ дан 29 September 2019 в 14:21

Другие вопросы по тегам:

Похожие вопросы: