@Evgeniymarkov

Как правильно записать код счетчика посещаемости в файл на php?

Пытаюсь записать в файл analytics.js из формы в админке код счетчика
public function save()
    {
        $data = $_POST['code'];
        file_put_contents(Config::get('PATH_VIEW') . 'analytics.js', $data);
        header('Location: /counter/index');
        exit;
    }


Сам код счетчика
<!--LiveInternet counter--><script type="text/javascript">
document.write("<a href='//www.liveinternet.ru/click' "+
"target=_blank><img src='//counter.yadro.ru/hit?t44.6;r"+
escape(document.referrer)+((typeof(screen)=="undefined")?"":
";s"+screen.width+"*"+screen.height+"*"+(screen.colorDepth?
screen.colorDepth:screen.pixelDepth))+";u"+escape(document.URL)+
";h"+escape(document.title.substring(0,150))+";"+Math.random()+
"' alt='' title='LiveInternet' "+
"border='0' width='31' height='31'><\/a>")
</script><!--/LiveInternet-->


Код в файле принимает такой вид
&lt;!--LiveInternet counter--&gt;&lt;script type=&quot;text/javascript&quot;&gt;
document.write(&quot;&lt;a href=&#039;//www.liveinternet.ru/click&#039; &quot;+
&quot;target=_blank&gt;&lt;img src=&#039;//counter.yadro.ru/hit?t44.6;r&quot;+
escape(document.referrer)+((typeof(screen)==&quot;undefined&quot;)?&quot;&quot;:
&quot;;s&quot;+screen.width+&quot;*&quot;+screen.height+&quot;*&quot;+(screen.colorDepth?
screen.colorDepth:screen.pixelDepth))+&quot;;u&quot;+escape(document.URL)+
&quot;;h&quot;+escape(document.title.substring(0,150))+&quot;;&quot;+Math.random()+
&quot;&#039; alt=&#039;&#039; title=&#039;LiveInternet&#039; &quot;+
&quot;border=&#039;0&#039; width=&#039;31&#039; height=&#039;31&#039;&gt;&lt;\/a&gt;&quot;)
&lt;/script&gt;&lt;!--/LiveInternet--&gt;


Как правильно записывать в файл без этих символов? Прошу помочь.
  • Вопрос задан
  • 132 просмотра
Решения вопроса 1
@grinat
Комментировать
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы