Jump to content

Need help with creating constants through a form


eldan88
Go to solution Solved by Jessica,

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>");
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.