Jump to content

Need help with creating constants through a form


eldan88

Recommended Posts

Hey,

 

 I have a from on a custom web application that sets up constants. The issue that I am running into is that, I am trying to Define a constant called "Google analytics" However when I enter the google analytics in the text area, there are double quotes within double quotes, when it defines the constant

 

How do a escape that using my form?

 

Below is the code I am using for the form .......

 

This is the text area where I enter my constants

 <textarea style="width:153px; height:70px" name="GOOGLE_ANALYTICS"><?=defined("GOOGLE_ANALYTICS")?GOOGLE_ANALYTICS:"";?></textarea>

This is the code that process's the constant

$config_file_contents="<?php \n";
foreach($_POST as $key => $value){	
$config_file_contents.="define(\"{$key}\",\"{$value}\");\n";

And this is how it looks on the file it creates using fwrite

define("GOOGLE_ANALYTICS","<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-40512701-1']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

</script>");

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.