<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wikidot="http://www.wikidot.com/rss-namespace">

	<channel>
		<title>Smiliecode wird in Shoutbox nicht geparst</title>
		<link>http://webseiten-professionell.wikidot.com/forum/t-101383/smiliecode-wird-in-shoutbox-nicht-geparst</link>
		<description>Posts in the discussion thread &quot;Smiliecode wird in Shoutbox nicht geparst&quot;</description>
				<copyright></copyright>
		<lastBuildDate></lastBuildDate>
		
					<item>
				<guid>http://webseiten-professionell.wikidot.com/forum/t-101383#post-297157</guid>
				<title>Smiliecode wird in Shoutbox nicht geparst</title>
				<link>http://webseiten-professionell.wikidot.com/forum/t-101383/smiliecode-wird-in-shoutbox-nicht-geparst#post-297157</link>
				<description></description>
				<pubDate>Fri, 31 Oct 2008 11:30:24 +0000</pubDate>
				<wikidot:authorName>Anonymous</wikidot:authorName>								<content:encoded>
					<![CDATA[
						 <p>Ich wollte vor einigen Tagen die Shoutbox aus dem Buch um eine Smilie-Funktion erweitern.</p> <p>Leider wird der von der PHP-Datei ausgegebene img-Code in der Shoutbox angezeigt und nicht geparst.</p> <p>Hier ist der PHP-Code:</p> <div class="code"> <pre> <code>&lt;?php if(isset($_POST['name']) and isset($_POST['text']) and $_POST['name'] != "" and $_POST['name'] != "Your message?" and $_POST['text'] != "" and $_POST['name'] != "Your name?") { $name = strip_tags($_POST['name']); $text = strip_tags($_POST['text']); # Smilies $umwandlung1 = str_replace('[Wütend]', '&lt;img src="angry.gif" /&gt;', $text); $umwandlung2 = str_replace('[breites Grinsen]', '&lt;img src="biggrin.gif" /&gt;', $umwandlung1); $umwandlung3 = str_replace('[Hunde Augen]', '&lt;img src="dogeyes.gif" /&gt;', $umwandlung2); $umwandlung4 = str_replace('[Nichts wissen]', '&lt;img src="dontknow.gif" /&gt;', $umwandlung3); $umwandlung5 = str_replace('[Hausaufgaben]', '&lt;img src="homework.gif" /&gt;', $umwandlung4); $umwandlung6 = str_replace('[Idee]', '&lt;img src="idee.gif" /&gt;', $umwandlung5); $umwandlung7 = str_replace('[Augenrollen]', '&lt;img src="rolleyes.gif" /&gt;', $umwandlung6); $umwandlung8 = str_replace('[Schlaumeier]', '&lt;img src="schlaumeier.gif" /&gt;', $umwandlung7); $umwandlung9 = str_replace('[schreiben]', '&lt;img src=schreiben.gif"" /&gt;', $umwandlung8); $text_fertig = str_replace('[Grinsen]', '&lt;img src="smile.gif" /&gt;', $umwandlung9); $dom = new DOMDocument("1.0", "UTF-8"); if(!$dom) exit("FEHLER(1)!"); $dom-&gt;preserveWhiteSpace = false; if(!$dom-&gt;load("shoutbox.xml")) { $shoutbox = $dom-&gt;createElement("shoutbox"); $dom-&gt;appendChild($shoutbox); } $new_entry_elem = $dom-&gt;createElement("entry"); $new_entry_elem-&gt;setAttribute("datetime", date("Y-m-d H:i")); $new_name_elem = $dom-&gt;createElement("name", substr($name, 0, 256)); $new_text_elem = $dom-&gt;createElement("text", substr($text_fertig, 0, 1024)); $new_entry_elem-&gt;appendChild($new_name_elem); $new_entry_elem-&gt;appendChild($new_text_elem); $shoutbox_elem = get_node($dom, '/shoutbox'); if($shoutbox_elem-&gt;firstChild) $shoutbox_elem-&gt;insertBefore($new_entry_elem, $shoutbox_elem-&gt;firstChild); else $shoutbox_elem-&gt;appendChild($new_entry_elem); $i = 0; $entry_elems = $dom-&gt;getElementsByTagName('entry'); if($entry_elems-&gt;length &gt; 10) $shoutbox_elem-&gt;removeChild($shoutbox_elem-&gt;lastChild); $dom-&gt;save("shoutbox.xml"); } $content = file_get_contents("shoutbox.xml"); header('Content-Type: text/xml'); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header("Cache-Control: no-store, no-cache, must-revalidate"); echo $content; function get_node($dom, $xpath) { $path = new DOMXPath($dom); $nodes = @$path-&gt;query($xpath); if(!is_object($nodes)) return(false); else return($nodes-&gt;item(0)); } ?&gt;</code> </pre></div> <p>Und hier der HTML-Code:</p> <div class="code"> <pre> <code>&lt;script type="text/javascript"&gt; var xml_response_handler = function(content, output_id) { var entries = content.getElementsByTagName("entry"); document.getElementById(output_id).innerHTML = ""; for(i = 0; i &lt;= entries.length; i++) { var entry_name = entries[i].getElementsByTagName("name")[0]; var entry_text = entries[i].getElementsByTagName("text")[0]; var p = document.createElement("P"); var b = document.createElement("B"); var br = document.createElement("BR"); var text_1 = document.createTextNode(entries[i].getAttribute("datetime")); var text_2 = document.createTextNode(" wrote "); var text_3 = document.createTextNode(entry_name.firstChild.nodeValue); var text_4 = document.createTextNode(":"); var text_5 = document.createTextNode(entry_text.firstChild.nodeValue); p.appendChild(b); b.appendChild(text_1); b.appendChild(text_2); b.appendChild(text_3); b.appendChild(text_4); p.appendChild(br); p.appendChild(text_5); document.getElementById(output_id).appendChild(p); } }; function show_shoutbox() { if(!document.getElementById) return; script_url = "shoutbox.php"; do_http_get_request("xml", script_url, "shoutbox_entries"); } function post_to_shoutbox() { if(!document.getElementById) return; script_url = "shoutbox.php"; post_field_ids = "name+text"; do_http_post_request("xml", script_url, post_field_ids, "shoutbox_entries"); } &lt;/script&gt; &lt;script type="text/Javascript"&gt; &lt;!-- var art; function smilie(art){ document.formular.text.value += "[" + art + "]"; document.formular.text.focus(); } //--&gt; &lt;/script&gt; &lt;/head&gt; &lt;body onload="show_shoutbox(); window.setInterval(show_shoutbox, 10000);"&gt; &lt;form action="#" method="post" name="formular" style=""&gt; &lt;div&gt;&lt;textarea name="text" rows="3" cols="20" id="text" style="width:490px; height: 4em; border: solid 1px silver; font-family: Arial,sans-serif; font-size: 11px; padding: 1px"&gt; Your message? &lt;/textarea&gt;&lt;/div&gt; &lt;div&gt;&lt;input type="text" name="name" id="name" style="width:460px; border: solid 1px silver; font-family: Arial,sans-serif; font-size: 11px; padding: 1px" value="Your name?"&gt; &lt;input type="button" name="send" style="width:30px; border: solid 1px silver; background-color: #EEE; font-family: Arial,sans-serif; font-size: 11px;" value="OK" onclick="post_to_shoutbox()"&gt;&lt;/div&gt; &lt;/form&gt;&lt;br&gt; &lt;div style="border:1px black dashed; width:498px;"&gt; &lt;p align="center"&gt; &lt;img src=angry.gif" alt="Wütend" title="Wütend" onClick="smilie('Wütend')"&gt; &lt;img src="biggrin.gif" alt="breites Grinsen" title="breites Grinsen" onClick="smilie('breites Grinsen')"&gt; &lt;img src="dogeyes.gif" alt="Hunde Augen" title="Hunde Augen" onClick="smilie('Hunde Augen')"&gt; &lt;img src="dontknow.gif" alt="Nichts wissen" title="Nichts wissen" onClick="smilie('Nichts wissen')"&gt; &lt;img src="homework.gif" alt="Hausaufgaben" title="Hausaufgaben" onClick="smilie('Hausaufgaben')"&gt; &lt;img src="idee.gif" alt="Idee" title="Idee" onClick="smilie('Idee')"&gt; &lt;img src="rolleyes.gif" alt="Augenrollen" title="Augenrollen" onClick="smilie('Augenrollen')"&gt; &lt;img src="schlaumeier.gif" alt="Schlaumeier" title="Schlaumeier" onClick="smilie('Schlaumeier')"&gt; &lt;img src="schreiben.gif" alt="schreiben" title="schreiben" onClick="smilie('schreiben')"&gt; &lt;img src="smile.gif" alt="Grinsen" title="Grinsen" onClick="smilie('Grinsen')"&gt; &lt;/p&gt; &lt;p align="center"&gt;Auf einen Smilie klicken, um ihn hinzuzufügen&lt;/p&gt; &lt;/div&gt; &lt;/div&gt;</code> </pre></div> <p>Was habe ich falsch gemacht, oder wie kann ich das Problem beheben?</p> 
				 	]]>
				</content:encoded>							</item>
				</channel>
</rss>