• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Javascript in a file

#1
[eluser]Fr3aked0ut[/eluser]
Hi, I'm having a problem with script in a textarea.

Let's say I have this code in the textarea:
Code:
[removed][removed]
Some HTML CODE

And when clicking "Send" button, I'm writing this code to a file:
Code:
$file = APPPATH. 'views/'. $this->template. '/'. strtolower($this->skin). '.php';
$Data = stripslashes( $_POST['data'] );
if ( is_writeable($file) )
{
        $f = fopen($file, 'w+');
        if ($f !== FALSE)
        {
        $Data = str_replace("&lt;", "<", $Data);
        $Data = str_replace("&gt;", ">", $Data);
        $Data = preg_replace("#<if=\"(.+?)\">\n(.+?)\n</if>#is", "if(\\1)\n{\n\\2\n}", $Data);
        $Data = preg_replace("#<else>\n(.+?)\n</else>#is", "else\n{\n\\1\n}", $Data);
        $Data = str_replace("[php]", "&lt;?php", $Data);
        $Data = str_replace("[php]", "&lt;?", $Data);
        $Data = str_replace("[/php]", "?&gt;", $Data);
        fwrite( $f, $Data );
        }
        fclose($f);
        $mess = "Well done";
}
else
{
    $mess = "An error";
}

Now, when I'm saving it, the script area is changing to [remove][remove].

I dont know why, maybe you can help me.

Thanks alot!!

#2
[eluser]Fr3aked0ut[/eluser]
Never mind, figured that out.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.