str_replace

Einklappen
X
 
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

  • str_replace

    hallo zusammen,

    ich bin gerade dabei mein erstes forum zu programmieren. ich lasse im inhalt alle tag entfernen... also keine html möglich.

    was mache ich aber, um links herauszufiltern und sie auch als solche anzeigen zu lassen.
    über die suchfunktion in diesem forum bin ich leider nicht fündig geworden. also, ich hoffe, jemand von euch erbarmt sich, mir zu helfen.

    gruß wingfighter

  • #2
    das geht mir eregi_replace() !
    Schau dir mal Powie's-Forum an (http://www.powie.de) da findest du sowas !

    Kommentar


    • #3
      hmmm,

      so lösen wir das auf unserem JBB Board, die Tags sind noch nicht absolut wasserdicht aber sie funzen schon ganz gut

      Code:
      function checkJBBTag($text, $user, $userClass, $configdaten)
        {
           // JBB Code Konfiguration auslesen
              if($configdaten["generalCode"] != "on")
                     {
                       return $text;
                     }
      
              if ($configdaten["listTag"] == "on")
                 {
                   $hack = "|(\[list\])(.*?)(\[/list\])|s";
                   $code = "<!-- JBB List Code --><ul>\\2</ul><!-- JBB List Code -->";
                   $text = preg_replace($hack,$code,$text);
                   $hack = "|(\[\*])(.*?)(\[/\*])|s";
                   $code = "<!-- JBB List Code --><li>\\2<!-- JBB List Code -->";
                   $text = preg_replace($hack,$code,$text);
                 }
      
              if($configdaten["codeTag"] == "on")
                {
                   $hack = "|(\[code\])(.*?)(\[/code\])|s";
                   $code = "\n<br><!--zitat-->\n<table border='0' cellpadding='0' cellspacing='0'>\n".
                                              "<tr><td colspan='2'><img src='bilder/klara.gif' width='400' height='1'></td></tr>".
                                              "<tr>\n\t<td><img src='bilder/klara.gif' width='10' height='1'></td><td><img src='bilder/klara.gif' width='400' height='1'></td>\n</tr>\n".
                                              "<tr>\n\t<td colspan='2'><b class='zitattitle'>CODE:</b></td>\n</tr>\n".
                                              "<tr><td colspan='2' background='bilder/strichel.gif'><img src='bilder/klara.gif' width='1' height='1'></td></tr>".
                                              "<tr valign='top'>\n".
                                                      "\t<td><img src='bilder/klara.gif' width='1' height='1'></td>".
                                                      "\t<td >".
                                                      "<b class='code'>\\2</b></td>\n</tr>\n".
                                                      "<tr><td colspan='2'><img src='bilder/klara.gif' width='1' height='10'></td></tr>".
                                                      "<tr><td colspan='2' background='bilder/strichel.gif'><img src='bilder/klara.gif' width='1' height='1'></td></tr>".
                                                      "</table>\n<!--endZitat-->\n";
                   $text = preg_replace($hack,$code,$text);
                }
      
              if($configdaten["quoteTag"] == "on")
                {
                     $hack = "|(\[quote\])(.*?)(\[/quote\])|s";
                     $code = "\n<br><!--zitat-->\n<table border='0' cellpadding='0' cellspacing='0'>\n".
                                              "<tr><td colspan='2'><img src='bilder/klara.gif' width='400' height='1'></td></tr>".
                                              "<tr>\n\t<td><img src='bilder/klara.gif' width='10' height='1'></td><td><img src='bilder/klara.gif' width='400' height='1'></td>\n</tr>\n".
                                              "<tr>\n\t<td colspan='2'><b class='zitattitle'>Zitat:</b></td>\n</tr>\n".
                                              "<tr>\n\t<td colspan='2' background='bilder/strichel.gif'><img src='bilder/klara.gif' width='1' height='1'></td>\n</tr>\n".
                                              "<tr valign='top'>\n".
                                                      "\t<td><img src='bilder/klara.gif' width='1' height='1'></td>\n".
                                                      "\t<td class=\"zitat\">\\2</td>\n</tr>\n".
                                                      "<tr><td colspan='2'><img src='bilder/klara.gif' width='1' height='10'></td></tr>".
                                                      "<tr><td colspan='2' background='bilder/strichel.gif'><img src='bilder/klara.gif' width='1' height='1'></td></tr>".
                                                      "</table>\n<!--endZitat-->\n";
                     $text = preg_replace($hack,$code,$text);
                }
      
              if ($configdaten["boldTag"] == "on")
                {
                     $hack = "|(\[b\])(.*?)(\[/b\])|s";
                     $code = "<b class='bred'>\\2</b>";
                     $text = preg_replace($hack,$code,$text);
                }
      
              if($configdaten["italicTag"] == "on") {
              $hack = "|(\[i\])(.*?)(\[/i\])|s";
              $code = "<i>\\2</i>";
              $text = preg_replace($hack,$code,$text);
              }
      
              if($configdaten["editTag"]== "on") {
              $hack = "|(\[edit\])(.*?)(\[/edit\])|s";
              $code = "\n<br>\n<table border='0' cellpadding='0' cellspacing='0'>\n".
                                              "<tr>\n\t<td><img alt=\"\" src='bilder/klara.gif' width='13' height='10'></td>\n\t<td><img src='bilder/klara.gif' width='400' height='10'></td>\n</tr>".
                                              "\n<tr valign=\"top\">\n\t<td class='editedText' rowspan=\"2\">". /*<img src=\"bilder/edited.gif\" width=8 height=19 alt=\"LALALA\" border=\"0\">*/
                                              "</td></tr>".
                                              "\n<tr>\n\t<td class=\"editedText\">".
                                              "\\2</td>\n</tr>".
                                                      "\n</table>\n\n";
      
              $text = preg_replace($hack,$code,$text);
      
              $hack = "|(\[stillEdit\])(.*?)(\[/stillEdit\])|s";
              $code = "<!-- edit -->\\2<!-- edit -->";
              $text = preg_replace($hack,$code,$text);
      
              $hack = "|(\[user\])(.*?)(\[/user\])|s";
              $code = "<b class=\"user\" style=\"font-size: 10px; font-style:normal;\"> \\2</b><br>";
              $text = preg_replace($hack,$code,$text);
              }
      
              if($configdaten["imgTag"]== "on") {
              $hack = "|(\[img\])(.*?)(\[/img\])|";
              $code = "<img src=\"\\2\" border=\"0\"><br>";
              $text = preg_replace($hack,$code,$text);
              $hack = "|(\[bild\])(.*?)(\[/bild\])|";
              $code = "<img src=\"\\2\" border=\"0\"><br>";
              $text = preg_replace($hack,$code,$text);
              }
      
              if($configdaten["autolink"] == "on") {
              $hack = '§(?<!(\]|=|"|>))(http://)([;_=\-\#\?\/\&a-zA-Z0-9\.]*)§';
              $code = "<!-- JBB URL Auto-Linker --><a target=\"_blank\" class=\"red\" href=\"http://\\3\">\\3</a> <!-- JBB URL Auto-Linker -->";
              $text = preg_replace($hack,$code,$text);
              $hack = '§(?<!(/|\]|>|=|"))(www.)([;_=\-\#\?\/\&a-zA-Z0-9\.]*)§';
              $code = "<!-- JBB URL Auto-Linker --><a target=\"_blank\" class=\"red\" href=\"http://www.\\3\">www.\\3</a> <!-- JBB URL Auto-Linker -->";
              $text = preg_replace($hack,$code,$text);
              }
      
              if($configdaten["urlTag"] == "on") {
              $hack = "|(\[url\])(http://)([;_=\-\#\?\/\&a-zA-Z0-9\.]*)(\[/url\])|";
              $code = "<!-- JBB URL Code --><a target=\"_blank\" class=\"red\" href=\"http://\\3\">\\3</a><!-- JBB URL Code -->";
              $text = preg_replace($hack,$code,$text);
              $hack = "|(\[url\])([;=\-\#\?\/\&_a-zA-Z0-9\.]*)(\[/url\])|";
              $code = "<!-- JBB URL Code --><a target=\"_blank\" class=\"red\" href=\"http://\\2\">\\2</a><!-- JBB URL Code -->";
              $text = preg_replace($hack,$code,$text);
              $hack = "|(\[url=http://)([;=\-\#\?\/\&_a-zA-Z0-9\.]*)(\])(.*)(\[/url\])|";
              $code = "[url=\\2]\\4[/url]";
              $text = preg_replace($hack,$code,$text);
              $hack = "|(\[url=)([;=\-\#\?\/\&_a-zA-Z0-9\.]*)(\])(.*)(\[/url\])|";
              $code = "<!-- JBB URL Code --><a target=\"_blank\" class=\"red\" href=\"http://\\2\">\\4</a><!-- JBB URL Code -->";
              $text = preg_replace($hack,$code,$text);
              }
      
              if($configdaten["emailTag"] == "on") {
              $hack = "|(\[email\])(.*)(@)(.*)(\[/email\])|";
              $code = "<!-- JBB eMail --><a class=\"red\" href=\"mailto:\\2\\3\\4\">\\2\\3\\4</a><!-- JBB eMail -->";
              $text = preg_replace($hack,$code,$text);
              $hack = "|(\[email=)(.*)(@)(.*)(\])(.*)(\[/email\])|";
              $code = "<!-- JBB eMail --><a class=\"red\" href=\"mailto:\\2\\3\\4\">\\6</a><!-- JBB eMail -->";
              $text = preg_replace($hack,$code,$text);
              }
      
              if($configdaten["pollTag"] == "on") {
              $hack = "|(\[poll\])(2)(%%)(.*)(%%)(.*)(%%)(.*)(%%)(.*)(%%)(\[/poll\])|";
              $code = "<!-- JBB Poll --><form action=\"showpoll.php\" method=\"post\" target=\"Showpoll\" onSubmit=\"window.open('', 'Showpoll','height=350,width=400,toolbar=no');\">";
              $code .= "<table cols=2 border=1><input type=\"hidden\" name=\"tid\" value=\"\\4\">";
              $code .= "<input type=\"hidden\" name=\"anzahl\" value=\"2\">";
              $code .= "<input type=\"hidden\" name=\"frage\" value=\"\\6\">";
              $code .= "<input type=\"hidden\" name=\"antwort1\" value=\"\\8\">";
              $code .= "<input type=\"hidden\" name=\"antwort2\" value=\"\\10\">";
              $code .= "<tr><td colspan=2><b class='code'>\\6</b></td></tr>";
              $code .= "<tr><td align=\"left\"><input type=\"radio\" name=\"antwort\" value=\"1\">";
              $code .= "</td><td align=\"left\"><b class='code'>\\8</b></td></tr>";
              $code .= "<tr><td align=\"left\"><input type=\"radio\" name=\"antwort\" value=\"2\">";
              $code .= "</td><td align=\"left\"><b class='code'>\\10</b></td></tr>";
              $code .= "<tr><td colspan=\"2\" align=\"center\"><input type=\"submit\" value=\"Abstimmen\"></td></tr>";
              $code .= "<tr><td colspan=\"2\" align=\"center\"><input type=\"submit\" value=\"Ansehen\"></td></tr>";
              $code .= "</table></form>";
              $code .= "<!-- JBB Poll -->";
              $text = preg_replace($hack,$code,$text);
      
              $hack = "|(\[poll\])(3)(%%)(.*)(%%)(.*)(%%)(.*)(%%)(.*)(%%)(.*)(%%)(\[/poll\])|";
              $code = "<!-- JBB Poll --><form action=\"showpoll.php\" method=\"post\" target=\"Showpoll\" onSubmit=\"window.open('', 'Showpoll','height=350,width=400,toolbar=no');\">";
              $code .= "<table cols=2 border=1><input type=\"hidden\" name=\"tid\" value=\"\\4\">";
              $code .= "<input type=\"hidden\" name=\"anzahl\" value=\"3\">";
              $code .= "<input type=\"hidden\" name=\"frage\" value=\"\\6\">";
              $code .= "<input type=\"hidden\" name=\"antwort1\" value=\"\\8\">";
              $code .= "<input type=\"hidden\" name=\"antwort2\" value=\"\\10\">";
              $code .= "<input type=\"hidden\" name=\"antwort3\" value=\"\\12\">";
              $code .= "<tr><td colspan=2><b class='code'>\\6</b></td></tr>";
              $code .= "<tr><td align=\"left\"><input type=\"radio\" name=\"antwort\" value=\"1\">";
              $code .= "</td><td align=\"left\"><b class='code'>\\8</b></td></tr>";
              $code .= "<tr><td align=\"left\"><input type=\"radio\" name=\"antwort\" value=\"2\">";
              $code .= "</td><td align=\"left\"><b class='code'>\\10</b></td></tr>";
              $code .= "<tr><td align=\"left\"><input type=\"radio\" name=\"antwort\" value=\"3\">";
              $code .= "</td><td align=\"left\"><b class='code'>\\12</b></td></tr>";
              $code .= "<tr><td colspan=\"2\" align=\"center\"><input type=\"submit\" value=\"Abstimmen\"></td></tr>";
              $code .= "<tr><td colspan=\"2\" align=\"center\"><input type=\"submit\" value=\"Ansehen\"></td></tr>";
              $code .= "</table></form>";
              $code .= "<!-- JBB Poll -->";
              $text = preg_replace($hack,$code,$text);
      
              $hack = "|(\[poll\])(4)(%%)(.*)(%%)(.*)(%%)(.*)(%%)(.*)(%%)(.*)(%%)(.*)(%%)(\[/poll\])|";
              $code = "<!-- JBB Poll --><form action=\"showpoll.php\" method=\"post\" target=\"Showpoll\" onSubmit=\"window.open('', 'Showpoll','height=350,width=400,toolbar=no');\">";
              $code .= "<table cols=2 border=1><input type=\"hidden\" name=\"tid\" value=\"\\4\">";
              $code .= "<input type=\"hidden\" name=\"anzahl\" value=\"4\">";
              $code .= "<input type=\"hidden\" name=\"frage\" value=\"\\6\">";
              $code .= "<input type=\"hidden\" name=\"antwort1\" value=\"\\8\">";
              $code .= "<input type=\"hidden\" name=\"antwort2\" value=\"\\10\">";
              $code .= "<input type=\"hidden\" name=\"antwort3\" value=\"\\12\">";
              $code .= "<input type=\"hidden\" name=\"antwort4\" value=\"\\14\">";
              $code .= "<tr><td colspan=2><b class='code'>\\6</b></td></tr>";
              $code .= "<tr><td align=\"left\"><input type=\"radio\" name=\"antwort\" value=\"1\">";
              $code .= "</td><td align=\"left\"><b class='code'>\\8</b></td></tr>";
              $code .= "<tr><td align=\"left\"><input type=\"radio\" name=\"antwort\" value=\"2\">";
              $code .= "</td><td align=\"left\"><b class='code'>\\10</b></td></tr>";
              $code .= "<tr><td align=\"left\"><input type=\"radio\" name=\"antwort\" value=\"3\">";
              $code .= "</td><td align=\"left\"><b class='code'>\\12</b></td></tr>";
              $code .= "<tr><td align=\"left\"><input type=\"radio\" name=\"antwort\" value=\"4\">";
              $code .= "</td><td align=\"left\"><b class='code'>\\14</b></td></tr>";
              $code .= "<tr><td colspan=\"2\" align=\"center\"><input type=\"submit\" value=\"Abstimmen\"></td></tr>";
              $code .= "<tr><td colspan=\"2\" align=\"center\"><input type=\"submit\" value=\"Ansehen\"></td></tr>";
              $code .= "</table></form>";
              $code .= "<!-- JBB Poll -->";
              $text = preg_replace($hack,$code,$text);
      
              $hack = "|(\[poll\])(5)(%%)(.*)(%%)(.*)(%%)(.*)(%%)(.*)(%%)(.*)(%%)(.*)(%%)(.*)(%%)(\[/poll\])|";
              $code = "<!-- JBB Poll --><form action=\"showpoll.php\" method=\"post\" target=\"Showpoll\" onSubmit=\"window.open('', 'Showpoll','height=450,width=400,toolbar=no');\">";
              $code .= "<table cols=2 border=1><input type=\"hidden\" name=\"tid\" value=\"\\4\">";
              $code .= "<input type=\"hidden\" name=\"anzahl\" value=\"5\">";
              $code .= "<input type=\"hidden\" name=\"frage\" value=\"\\6\">";
              $code .= "<input type=\"hidden\" name=\"antwort1\" value=\"\\8\">";
              $code .= "<input type=\"hidden\" name=\"antwort2\" value=\"\\10\">";
              $code .= "<input type=\"hidden\" name=\"antwort3\" value=\"\\12\">";
              $code .= "<input type=\"hidden\" name=\"antwort4\" value=\"\\14\">";
              $code .= "<input type=\"hidden\" name=\"antwort5\" value=\"\\16\">";
              $code .= "<tr><td colspan=2><b class='code'>\\6</b></td></tr>";
              $code .= "<tr><td align=\"left\"><input type=\"radio\" name=\"antwort\" value=\"1\">";
              $code .= "</td><td align=\"left\"><b class='code'>\\8</b></td></tr>";
              $code .= "<tr><td align=\"left\"><input type=\"radio\" name=\"antwort\" value=\"2\">";
              $code .= "</td><td align=\"left\"><b class='code'>\\10</b></td></tr>";
              $code .= "<tr><td align=\"left\"><input type=\"radio\" name=\"antwort\" value=\"3\">";
              $code .= "</td><td align=\"left\"><b class='code'>\\12</b></td></tr>";
              $code .= "<tr><td align=\"left\"><input type=\"radio\" name=\"antwort\" value=\"4\">";
              $code .= "</td><td align=\"left\"><b class='code'>\\14</b></td></tr>";
              $code .= "<tr><td align=\"left\"><input type=\"radio\" name=\"antwort\" value=\"5\">";
              $code .= "</td><td align=\"left\"><b class='code'>\\16</b></td></tr>";
              $code .= "<tr><td colspan=\"2\" align=\"center\"><input type=\"submit\" value=\"Abstimmen\"></td></tr>";
              $code .= "<tr><td colspan=\"2\" align=\"center\"><input type=\"submit\" value=\"Ansehen\"></td></tr>";
              $code .= "</table></form>";
              $code .= "<!-- JBB Poll -->";
              $text = preg_replace($hack,$code,$text);
      
              }
              //echo "<input type=\"text\" value=\"$hacks\">";
              // $text = preg_replace($hack,$code,$text);
              return $text;
      }
      Da sind sehr verschiedene Sache dabei, siehst du ja unter den verschiedenen if Abfrage was bearbeitet wird.

      Kommentar

      Lädt...
      X