Problem with tinymce

Discussion in 'PHP' started by saturn100, Jan 24, 2014.

  1. #1
    Dont know if this is the correct place to post this but anyway:

    I am in the process of building a simple CMS system for a site
    I have decided to use Tinymce as my editor
    I have it altering a txt file which is later called in the right place

    While I have installed Tinymce ok and it is writing to the text file it is altering the HTML by putting \ before quotes like so

    <p><span style=\"color: #ff0000;\">test 3</span></p>

    This there for means that it is not formatting properly when displayed

    Any idea why this is

    My code is as follows:

    WYSIWYG editor:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" dir="ltr">
    <head>
    <meta charset="UTF-8">
    <title>My Amin Page</title>
    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
    
    
    <!-- OF COURSE YOU NEED TO ADAPT NEXT LINE TO YOUR tiny_mce.js PATH -->
    <script type="text/javascript" src="tinymce/jscripts/tiny_mce/tiny_mce.js"></script>
    
    <script type="text/javascript">
        tinyMCE.init({
            // General options
            mode : "textareas",
            theme : "advanced",
            plugins : "autolink,lists,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,wordcount,advlist,autosave,visualblocks",
    
            // Theme options
            theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,fontselect,fontsizeselect",
            theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
            theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
            theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak,restoredraft,visualblocks",
            theme_advanced_toolbar_location : "top",
            theme_advanced_toolbar_align : "left",
            theme_advanced_statusbar_location : "bottom",
            theme_advanced_resizing : true,
    
            // Example content CSS (should be your site CSS)
            content_css : "css/content.css",
    
            // Drop lists for link/image/media/template dialogs
            template_external_list_url : "lists/template_list.js",
            external_link_list_url : "lists/link_list.js",
            external_image_list_url : "lists/image_list.js",
            media_external_list_url : "lists/media_list.js",
    
            // Style formats
            style_formats : [
                {title : 'Bold text', inline : 'b'},
                {title : 'Red text', inline : 'span', styles : {color : '#ff0000'}},
                {title : 'Red header', block : 'h1', styles : {color : '#ff0000'}},
                {title : 'Example 1', inline : 'span', classes : 'example1'},
                {title : 'Example 2', inline : 'span', classes : 'example2'},
                {title : 'Table styles'},
                {title : 'Table row 1', selector : 'tr', classes : 'tablerow1'}
            ],
    
            // Replace values for the template plugin
            template_replace_values : {
                username : "Some User",
                staffid : "991234"
            }
        });
    </script>
    </head>
    <body>
    <!-- OF COURSE YOU NEED TO ADAPT ACTION TO WHAT PAGE YOU WANT TO LOAD WHEN HITTING "SAVE" -->
    <form method="post" action="postx.php">
            <p> 
                    <textarea name="content" cols="50" rows="15"><?php include ('myfile.txt'); ?> </textarea>
                    <input type="submit" value="Save" />
            </p>
    </form>
    
    
    </body>
    </html>
    HTML:
    and the form is
    <?php
    file_put_contents("myfile.txt", $_POST['content']);
    ?>
    <!doctype html>
    <html>
    <head>
    <meta charset="UTF-8">
    <title>Post added</title>
    </head>
    <body>
    
    <a href="userpage.php">Userpage</a>
    <a href="adminpage.php">Adminpage</a>
    
    
    <h2>Your post has been added/edited.</h2>
    
    </body>
    </html>
    PHP:
    I havent altered any other code in tinymce

    any ideas

    I am thinking of trying another WYSIWYG plug-in and testing that but would like to figure this out
     
    Last edited: Jan 24, 2014
    saturn100, Jan 24, 2014 IP
  2. Pudge1

    Pudge1 Well-Known Member

    Messages:
    912
    Likes Received:
    6
    Best Answers:
    1
    Trophy Points:
    140
    Digital Goods:
    1
    #2
    
    $content = stripslashes($_POST['content']);
    file_put_contents("myfile.txt",$_POST['content']);
    
    PHP:
     
    Pudge1, Jan 24, 2014 IP
  3. saturn100

    saturn100 Well-Known Member

    Messages:
    465
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    111
    #3
    Thanks man
    That fixed the issue
     
    saturn100, Jan 25, 2014 IP
  4. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #4
    Given that this fixed the issue, something tells me you have some settings enabled in your php.ini which aren't really recommended, for example, you probably have magic quotes on, which is NOT a recommended setting...
     
    PoPSiCLe, Jan 25, 2014 IP
    digitalpoint likes this.