We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 33517
    • 16 Posts
    Hi everybody,

    I was wondering if someone could help me with some how a strange problem. The site was working normaly until today when I tried to change something in my template and now it seems I can not save it anymore if it includes any piece of code with <script type="text/javascript"></script>? If I copy my template into Template Code (html) and it includes any piece of code with <script type="text/javascript"></script> and click save it shows the saving dialog for a second and then it goes back to editing, if I reload after that it show just this: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " and deletes the whole code I pasted inside.

    I am using Modx Revo 2.2.0-pl2 (traditional). I have also tried pasting my code directly into the database in my PHPmyAdmin and it loads for a long time but nothing happens, sometimes I get page not available. O and if I take all of <script type="text/javascript"></script> out of my code it saves normally.

    Any suggestions? I am really stuck on this. Thanks in advance for any solution. [ed. note: zhazhy last edited this post 13 years, 1 month ago.]
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      That very much sounds like your hosting provider has set up some kind of security measure to monitor and block content returned in forms. This will simply abort any POST or GET that has words or HTML tags or javascript that the security software has been configured to block. Ask your hosting provider if they've upgraded or installed suhosin or mod_security or something similar, and if they can disable it or modify it for your site, especially for your site Manager.
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 33517
        • 16 Posts
        Thanks for the reply. I will ask them about this. I have just noticed now that if I put the code without javascript into the template in modx it saves, but if I try to put it in phpmyadmin directly it says page not available. Strange. I just hope I didn t mess something up smiley
          • 33517
          • 16 Posts
          I have now noticed another wierd behaviour - modx allows me to put and save <script type="text/javascript"></script> if it is anywhere else than between <head></head>. So I can actually save and refresh and it stays the same. Any ideas? Do you think this is still our hosting provider?
            • 39404
            • 175 Posts
            stalemate resolution associate Reply #5, 13 years, 1 month ago
            A few ideas:
            1) Try using an external js file, and refer to it like this:
            <script type="text/javascript" src="/assets/components/gallery/packages/galleriffic20/js/jquery.opacityrollover.js"></script>

            2) If you are only pasting in this:
            <script type="text/javascript"></script>
            , your host may be removing it because it doesn't do anything. Try adding something like a fake function that does nothing. For example,
            <script type="text/javascript">function heyThere() { alert('hello world'); }</script>
            
              • 33517
              • 16 Posts
              It actually doesn t make a difference, I have already tried both ways and also the last one you suggested (the fake function). In my template I am using the first way you suggested and also the second one. I stripped my code of all javascripts from <head></head> and tried to put random ones from my code into the head but as soon as I insert it and save it, it just show the save dialog for a second.
                • 39404
                • 175 Posts
                stalemate resolution associate Reply #7, 13 years, 1 month ago
                Yeah, it sounds strange for sure.

                Who is your provider? If they have forums like this one, they might have someone who has experienced the same thing, assuming it's a host provider issue.

                Another place to check is the error logs: MODX (within the manager), PHP and possibly even the web log file.

                Hope this helps.

                  • 33517
                  • 16 Posts
                  Our host provider is checking this for about an hour now and I think they have not found the problem. Is it possible that it has something to do with the System settings or something like that? I see now that all of my system settings are now showing Last modified Jan 01, 1970 01:00 AM. Is this ok?

                  I managed to change the code in phpmyadmin now, after that I went into modx which showed me the template with javascripts and when I tried to save it again it was the same thing.
                    • 33517
                    • 16 Posts
                    It works now. I have asked my host provider to tell me what the problem was so I can post it here if somebody else runs into this problem.

                    The host provider told me that the firewall was detecting this act as an attack and for that reason it was blocking me.

                    I would really thank you sottwell and stalemate resolution associate for taking the time and try to help me. You are the greatest wink
                      • 39404
                      • 175 Posts
                      stalemate resolution associate Reply #10, 13 years, 1 month ago
                      Hi Zhazhy,

                      You're quite welcome!

                      Regards,
                      Tom