Jump to content

Matty999555

Members
  • Posts

    14
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Matty999555's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. The Quote doesn't work while in wysiwyg mode function doQuote() { if (editorVisible) { ifm.contentWindow.focus(); if (isIE) { //IE var range = ifm.contentWindow.document.selection.createRange(); if (range.text == '') { range.pasteHTML("<blockquote></blockquote>"); } else myeditor.execCommand('inserthtml', false, "<blockquote>" + range.text + "</blockquote>"); } else if (window.getSelection) { //FF var userSelection = ifm.contentWindow.getSelection().getRangeAt(0); if(userSelection.toString().length==0) myeditor.execCommand('inserthtml', false, "<blockquote>" + userSelection.toString() + "</blockquote>"); else myeditor.execCommand('inserthtml', false, "<blockquote>" + userSelection.toString() + "</blockquote>"); } else myeditor.execCommand('inserthtml', false, "<blockquote>" + userSelection.toString() + "</blockquote>"); } else { AddTag('[quote]', '[/quote]'); } }
  2. Fixed Text Size: function doSize() { if (editorVisible) { ifm.contentWindow.focus(); var mylink = prompt("Enter a text-size:", "14px"); if ((mylink != null) && (mylink != "")) { if (isIE) { //IE var range = ifm.contentWindow.document.selection.createRange(); if (range.text == '') { range.pasteHTML("<span style=\"font-size: " + mylink + ";\"></span>"); } else myeditor.execCommand('inserthtml', false, "<span style=\"font-size: " + mylink + ";\">" + range.text + "</span>"); } else if (window.getSelection) { //FF var userSelection = ifm.contentWindow.getSelection().getRangeAt(0); if(userSelection.toString().length==0) myeditor.execCommand('inserthtml', false, "<span style=\"font-size: " + mylink + ";\">" + userSelection.toString() + "</span>"); else myeditor.execCommand('inserthtml', false, "<span style=\"font-size: " + mylink + ";\">" + userSelection.toString() + "</span>"); } else myeditor.execCommand('inserthtml', false, "<span style=\"font-size: " + mylink + ";\">" + userSelection.toString() + "</span>"); } } else { AddTag('[size=]','[/size]'); } }
  3. Now works almost perfectly, todo: text-size quote
  4. Fixed the Mail function: function doMail() { if (editorVisible) { ifm.contentWindow.focus(); var mylink = prompt("Enter an Email:", ""); var mylink = "mailto:" + mylink; if ((mylink != null) && (mylink != "")) { if (isIE) { //IE var range = ifm.contentWindow.document.selection.createRange(); if (range.text == '') { range.pasteHTML("<a href='" + mylink + "'>" + mylink + "</a>"); } else myeditor.execCommand("CreateLink", false, mylink); } else if (window.getSelection) { //FF var userSelection = ifm.contentWindow.getSelection().getRangeAt(0); if(userSelection.toString().length==0) myeditor.execCommand('inserthtml', false, "<a href='" + mylink + "'>" + mylink + "</a>"); else myeditor.execCommand("CreateLink", false, mylink); } else myeditor.execCommand("CreateLink", false, mylink); } } else { AddTag('[url=mailto:',']click here[/url]'); } }
  5. I found this great peice of code: http://wysiwygbbcode.codeplex.com/ I have added a few extra functions into but I can't work out how this one line works: myeditor.execCommand("CreateLink", false, mylink); heres the code so far: http://pastebin.com/Axe6emk9 Thanks EDIT: As it contains BBCode i screwed the page.
  6. FINALLLLLLLLLY tested it and it worked perfectly, thanks sooooooooo much
  7. Thank you so much !!! I will try in a sec. If possible in the future I'll stick to simpleXML
  8. Theres no error message because of this line: if($searchNode == $check) { It would redirect to the page: /error.php ANd put up an error that way.
  9. Realised my mistake. I was Doing Tag.onfocus istead of Tag.setAttribute("onfocus", ""); Solved
  10. I have this form here: <html> <head> <script type="text/javascript" language="javascript"> function createDiv() { var Tag = document.createElement("input"); Tag.id = "url_name[]"; Tag.type = "text"; Tag.value = "Insert Name Here"; Tag.onfocus = "if(this.value=='Insert Name Here')this.value='';"; Tag.onblur = "if(this.value=='')this.value='Insert Name Here';"; document.getElementById("input").appendChild(Tag); var Tag = document.createElement("input"); Tag.id = "url_url[]"; Tag.type = "text"; Tag.value = "Insert URL Here"; Tag.onfocus = "if(this.value=='Insert URL Here')this.value='';"; Tag.onblur = "if(this.value=='')this.value='Insert URL Here';"; document.getElementById("input").appendChild(Tag); var Tag = document.createElement("br"); document.getElementById("input").appendChild(Tag); } </script> </head> <body> <p align="center"> <b>Click this button to create div element dynamically:</b> <input id="btn1" type="button" value="create div" onclick="createDiv();" /> </p> <div id="input"> <input id="url_name[]" type="text" value="Insert Name Here" onfocus="if(this.value=='Insert Name Here')this.value='';" onblur="if(this.value=='')this.value='Insert Name Here';" /> <input id="url_url[]" type="text" value="Insert URL Here" onfocus="if(this.value=='Insert URL Here')this.value='';" onblur="if(this.value=='')this.value='Insert URL Here';" /> <br /> </div> </body> </html> It SHOULD create two inputs with onfocus and onblur attributes but It doesn't. Can someone tell me what I am doing wrong. Thanks
  11. I think this is wrong: $searchNodes = $doc->getElementsByTagName("comment")->item(0); It should be $searchNodes = $doc->getElementsByTagName("comment"); EDIT Tried this: $count = 0; $searchNodes = $doc->getElementsByTagName("id"); foreach($searchNodes as $searchNode) { $check = preg_replace("/%20/", "", $_GET['delid']); if($searchNode == $check) { $remove = $doc->getElementsByTagName("comment")->item($count); $doc = $doc->removeChild($remove); $deleted = "deleted"; } $count = $count + 1; } Didn't work
  12. That happened a little while ago, it doesn't happen at the mo. What I think is wrong Is that I am failing to properly locate the element so nothing is deleted. Full code: <?php /* COMMENT BLOCK * THIS IS THE SAME LENGTH AS IT WAS ORIGINALLY * I HAVE JUST REMOVED THE DETAILS * * * * * * * * * * * * **********************************************************************************/ session_start(); if(!empty($_GET['delid']) && $_SESSION['login'] == "true" && !empty($_GET['article'])) { if($_SESSION['level'] == "rootuser" || $_SESSION['level'] == "admin" || $_SESSION['level'] == "moderator") { $comments['article'] = $_GET['article'] . ".xml"; $doc = new DOMDocument(); $doc->load("../../xml/" . $comments['article'] . ".comments"); $count = 0; $searchNodes = $doc->getElementsByTagName("comment")->item(0); foreach($searchNodes as $searchNode) { $check = preg_replace("/%20/", "", $_GET['delid']); $valueID = $searchNode->getElementsByTagName("id")->item(0); //if($valueID == $check) { $doc = $doc->removeChild($searchNode); $deleted = "deleted"; //} $count = $count + 1; } // Fine below if($deleted == "deleted") { $doc->save("../../xml/" . $comments['article'] . ".comments"); header("Location: /error.php?title=Comment%20Deleted&msg=Comment%20Deleted"); } else { header("Location: /error.php?title=Error&msg=ID%20Does%20Not%20Exist!"); } } else { header("Location: /error.php?title=Error!&msg=You%20do%20not%20have%20Permission%20to%20delete%20Comments!"); } } elseif(!empty($_GET['article'])) { if(preg_match("/^[a-zA-Z0-9_-]*$/", $_GET['article'])) { if(preg_match("/^[a-zA-Z0-9_-\s]*$/", $_POST['name'])) { if(preg_match("/^[a-zA-Z0-9_-\s\[\],.:;\"'\(\)\\/]*$/", $_POST['comment'])) { if(preg_match("(\w+@[a-zA-Z_]+?\.[a-zA-Z])", $_POST['email']) || $_POST['email'] == "userloggedinnoneedtocheck") { $comments['article'] = htmlentities($_GET['article']) . ".xml"; $comments['name'] = htmlentities($_POST['name']); $comments['email'] = htmlentities($_POST['email']); $comments['comment'] = htmlentities($_POST['comment']); if(preg_match("([http://]\w+.+w|[http://www.]\w+.+w|[http://]\w+.+w+.+w|[http://www.]\w+.+w+.+w)", $_POST['website']) || empty($_POST['website'])) { $comments['website'] = htmlentities($_POST['website']); } $comments['time'] = date('l jS \of F Y h:i:s A'); $ipadress = $_SERVER['REMOTE_ADDR']; $returnlink = $_SERVER['HTTP_REFERER']; if(empty($_POST['name']) || empty($_POST['email']) || empty($_POST['comment'])) { header("Location: /error.php?title=Error&msg=You%20didn't%20fill%20in%20a%20required Field!"); } else { if(file_exists("../../xml/" . $comments['article'] . ".comments")) { $doc = new DOMDocument(); $doc->load("../../xml/" . $comments['article'] . ".comments"); $root = $doc->getElementsByTagName("index")->item(0); $doc->appendChild($root); $comment = $doc->createElement("comment"); $root->appendChild($comment); $element = $doc->createElement("name"); $element->appendChild($doc->createTextNode($comments['name'])); $comment->appendChild($element); $element = $doc->createElement("email"); $element->appendChild($doc->createTextNode($comments['email'])); $comment->appendChild($element); $element = $doc->createElement("website"); $element->appendChild($doc->createTextNode($comments['website'])); $comment->appendChild($element); $element = $doc->createElement("content"); $element->appendChild($doc->createTextNode($comments['comment'])); $comment->appendChild($element); $element = $doc->createElement("time"); $element->appendChild($doc->createTextNode($comments['time'])); $comment->appendChild($element); $element = $doc->createElement("ip"); $element->appendChild($doc->createTextNode($ipadress)); $comment->appendChild($element); $element = $doc->createElement("id"); $element->appendChild($doc->createTextNode(date("H:i:s, dmY"))); $comment->appendChild($element); $commentfile = file_get_contents("../../xml/" . $comments['article'] . ".comments"); if(strpos($_SERVER["REMOTE_ADDR"], $commentfile)) { header("Location: /error.php?title=Error&msg=You%20have%20already%20posted%20a%20Message!"); } $doc->save("../../xml/" . $comments['article'] . ".comments"); header("Location: /error.php?title=Comments%20Saved&msg=Thanks%20for%20submitting%20a%20comment"); } else { header("Location: /error.php?title=Error&msg=Comments%20are%20not%20enabled%20for%20this%20page!%20Please%20update%20links"); } } } else {header("Location: /error.php?title=Invalid Email!&msg=The%20email%20entered%20was%20invalid!");} } else {header("Location: /error.php?title=Invalid%20Comment!&msg=You%20put%20a%20forbidden%20character%20in%20the%20message!");} } else {header("Location: /error.php?title=Invalid%20Name!&msg=You%20didn't%20fill%20in%20your%20name%20Correctly!");} } else {header("Location: /error.php?title=Invalid%20ID!&msg=We're%20sorry%20to%20say%20that%20the%20ID%20was%20Invalid");} } else { header("Location: /index.php"); } die("ERROR"); ?> I can think of a different way to do this. I'm going to try in a sec
  13. Please, If you need more of the source code to help I'll give it to you.
  14. I've been using SimpleXML for most of my xml functions but as it doesn't contain functions for deleting elements. I have come across problems such as : Fatal error: Uncaught exception 'DOMException' with message 'Not Found Error' PHP Code: session_start(); if(!empty($_GET['delid']) && $_SESSION['login'] == "true" && !empty($_GET['article'])) { if($_SESSION['level'] == "rootuser" || $_SESSION['level'] == "admin" || $_SESSION['level'] == "moderator") { $comments['article'] = $_GET['article'] . ".xml"; $doc = new DOMDocument(); $doc->load("../../xml/" . $comments['article'] . ".comments"); $count = 0; $searchNodes = $doc->getElementsByTagName("comment")->item(0); foreach($searchNodes as $searchNode) { $check = preg_replace("/%20/", "", $_GET['delid']); $valueID = $searchNode->getElementsByTagName("id")->item(0); //if($valueID == $check) { $doc = $doc->removeChild($searchNode); $deleted = "deleted"; //} $count = $count + 1; } // Fine below if($deleted == "deleted") { $doc->save("../../xml/" . $comments['article'] . ".comments"); header("Location: /error.php?title=Comment%20Deleted&msg=Comment%20Deleted"); } else { header("Location: /error.php?title=Error&msg=ID%20Does%20Not%20Exist!"); } } else { header("Location: /error.php?title=Error!&msg=You%20do%20not%20have%20Permission%20to%20delete%20Comments!"); } } My code is above and this is a sample file: Code: <?xml version="1.0"?> <index> <about>Comments Ver 1.0</about> <comment><name>Matthew</name><email>n/a</email><website/><content>Content</content><time>Friday 18th of June 2010 08:23:40 AM</time><ip>n/a</ip><id>08:23:40, 18062010</id></comment></index> It is meant to be access like this: ?delid=08:23:40,%2018062010&article=test However I cannot find a working solution to my problem. I know that it it these two lines which are causing it. $searchNodes = $doc->getElementsByTagName("comment")->item(0); $valueID = $searchNode->getElementsByTagName("id")->item(0); Can someone help me, thanks.
×
×
  • 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.