Board-Funktionen... was kommt wann am besten ?!

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

  • Board-Funktionen... was kommt wann am besten ?!

    Hi Leutz,

    bastel gerade an ein paar Funktionen für mein Forum.
    Dabei gehst um die Formatierung der Beiträge
    wie zum Beispiel ob es sich beim Text um einen Link,
    einen Fetten Text oder ein Bild oder
    gar php-code handelt.

    Mein Problem liegt unter anderem bei
    der Darstellung von Php-code.
    Bei einer kleinen Funktion wie
    folgender als Beispiel

    PHP-Code:
    function FetchUserIcon($userid) {
    global 
    $templ;

    $templ['usericon']['userid'] = $userid;
    return 
    $this->FetchModTpl("""ls_usericon");

    spuckt er mir folgenden Regex mitten im Beitrag aus:
    Warning: Unexpected character in input:
    '' (ASCII=92) state=1 in DrogrammeTSWApache2htdocsparty
    bilderincclasses
    class_func.php(332) : regexp code on line 8

    Allerdings kein plan woran das liegen könnte.
    Sieht dann im Beitrag etwa so aus:

    PHP-Code:
    function FetchUserIcon($userid) {
    global 
    $templ;

    $templ['usericon']['userid'] = $userid;
    return 
    $this->FetchModTpl(Warning
    Unexpected character in input'' (ASCII=92
    state=1 in DrogrammeTSWApache2htdocspartybilderinc
    classesclass_func
    .php(332) : regexp code on line 8"""ls_usericon");


    Hier mal meine Funktionen:

    PHP-Code:
    // Text aus der DB zu Html
    function db2text2html($text) {
                
    $text $this->db2text($text);
                
    $text $this->text2html($text);
                return 
    $text;
    }

    // Text DB-Tauglich
    function text2db($text) {
                
    $text trim($text);
                return 
    $text;
    }

    // DB-Eintrag zu normalem Text
    function db2text($text) {
                
    $text stripslashes($text);
                return 
    $text;


    // Text zu HTML   hier funktioniert unter anderem der Code-highlighter nicht

    function text2html($string)
    {
    global 
    $cfg$db;

    $img_start "<img src=\"design/".$GLOBALS["config"]["xinux"]["default_design"]."/images/";
    $img_start2 "<img src=\"ext_inc/smilies/";
    $img_end   "\" border=\"0\">";


     
    $string stripslashes(preg_replace('#\[c\](.+)\[/c\]#Uise',"'[blockquote]'.
    highlight_string('\\1', TRUE).'[/blockquote]'"
    $string));
    if(
    $cfg[$_GET["mod"]."_html"] == 0) {
        
    $string strip_tags($string"<font></font>");
    }

    $string eregi_replace("([ \n])[url]http://[/url]([^ ,\n]*)"
    "\\1[url]http://\\2[/url]"$string);
            
    $string eregi_replace("([ \n])[url]ftp://[/url]([^ ,\n]*)",
    "\\1[url]ftp://\\2[/url]"$string);
             
    $string eregi_replace("([ \n])www\\.([^ ,\n]*)"
    "\\1[url]http://www.\\2[/url]"$string);
            
    $string eregi_replace("^[url]http://[/url]([^ ,\n]*)"
    "[url]http://\\1[/url]"$string);
            
    $string eregi_replace("^[url]ftp://[/url]([^ ,\n]*)"
    "[url]ftp://\\1[/url]"$string);
            
    $string eregi_replace("^www\\.([^ ,\n]*)"
    "[url]http://www.\\1[/url]"$string);
            
     
    $string eregi_replace('\[url\]www.([^\[]*)\[/url\]'
    '<b><a href="http://www.\1" target="_blank" class="admin">\1</a></b>'$string);
            
    $string eregi_replace('\[url\]([^\[]*)\[/url\]'
    '<b><a href="\1" target="_blank" class="admin">\1</a></b>'$string);
            
    $string eregi_replace('\[mailurl\]([^\[]*)\[/mailurl\]'
    '<b><a href="\1" class="admin">Link</a></b>'$string);
            
    $string eregi_replace('\[url=www.([^\[]*)\]([^\[]*)\[/url\]'
    '<b><a href="http://www.\1" target="_blank" class="admin">\2</a></b>'$string);
            
    $string eregi_replace('\[url=http://www.([^\[]*)\]([^\[]*)\[/url\]'
    '<b><a href="http://www.\1" target="_blank" class="admin">\2</a></b>'$string);
             
    $string eregi_replace('\[url=([^\[]*)\]([^\[]*)\[/url\]'
    '<b><a href="\1" target="_blank" class="admin">\2</a></b>'$string);
            
    $string eregi_replace('\[url_www.([^\[]*)\]([^\[]*)\[/url\]'
    '<b><a href="http://www.\1" target="_self" class="admin">\2</a></b>'$string);
             
    $string eregi_replace('\[url_([^\[]*)\]([^\[]*)\[/url\]'
    '<b><a href="\1" target="_self" class="admin">\2</a></b>'$string);

    $string str_replace("\n""<br>"$string);
    // $string = nl2br($string);
            
    $string str_replace('[bold]''<b>'$string);
    $string str_replace('[/bold]''</b>'$string);
    $string str_replace('[inverted]''<i>'$string);
    $string str_replace('[/inverted]''</i>'$string);
    $string str_replace('[underlined]''<u>'$string);
    $string str_replace('[/underlined]''</u>'$string);
            
    $string str_replace('[blockquote]'
    '<blockquote><div class="stil_small">Code:
    </div><table width="70%" 
    cellspacing="1" cellpadding="2" class="code"><tr class="code"><td>'
    $string);
            
    $string str_replace('[/blockquote]'
    '</td></tr></table></blockquote>'$string);
            
    $string str_replace('[quotes]'
    '<blockquote><div class="stil_small">Zitat:
    </div>
    <table width="70%" 
    cellspacing="1" cellpadding="2" class="code">
    <tr class="code"><td>'
    $string);
            
    $string str_replace('[/quotes]''</td></tr></table></blockquote>'$string);
            
    $hits eregi_replace('\[img\]([^\[]*)\[/img\]''\1'$string);
            
    /* Prüft Breite und Höhe der Bildquelle */
    $img = @imagecreatefromgif($hits);
    if (
    $img) {
    if(
    imagesy($img) > "300") {
     
    $img_width "width = \"300\"";

    else {
     
    $width "";
    }
    }
    $img = @imagecreatefromjpeg($hits);
    echo 
    $img;
    if (
    $img) {
    if(
    imagesy($img) > "300") {
    $img_width "width = \"300\"";

    else {
    $img_width "";
    }
    }
    $img = @imagecreatefrompng($hits);
    if (
    $img) {
    if(
    imagesy($img) > "300") {
    $img_width "width = \"300\"";

    else {
    $img_width "";
    }
    }

    /* Ende Bildquellenüberprüfung */
            
    if($img == "" AND $img_width == "") {
     
    $img_width "width=\"300\"";
    }
    $string eregi_replace('\[img\]([^\[]*)\[/img\]'
    '<div align="left"><img src="\1" '.$img_width.' border="0"></div>'$string);
            
    $string eregi_replace('\[img=www.([^\[]*)\]([^\[]*)\[/img\]'
    '<div align="left"><a href="http://www.\1" target="_blank" class="admin">
    <img src="\2" '
    .$img_width.' border="0"></a></div>'$string);
            
    $string eregi_replace('\[img=http://www.([^\[]*)\]([^\[]*)\[/img\]'
    '<div align="left"><a href="http://www.\1" target="_blank" class="admin">
    <img src="\2" '
    .$img_width.' border="0"></a></div>'$string);
             
    $string eregi_replace('\[img=([^\[]*)\]([^\[]*)\[/img\]'
    '<div align="left">
    <a href="\1" target="_blank" class="admin">
    <img src="\2" '
    .$img_width.' border="0"></a></div>'$string);

    $string eregi_replace('\[img_www.([^\[]*)\]([^\[]*)\[/img\]'
    '<div align="left">
    <a href="http://www.\1" target="_self" class="admin">
    <img src="\2" '
    .$img_width.' border="0"></a></div>'$string);
     
    $string eregi_replace('\[img_([^\[]*)\]([^\[]*)\[/img\]'
    '<div align="left"><a href="\1" target="_self" class="admin">
    <img src="\2" '
    .$img_width.' border="0"></a></div>'$string);
            
    $get_smilie $db->query("SELECT shortcut, image FROM {$GLOBALS["config"]["tables"]["smilies"]}");
    while(
    $row=$db->fetch_array($get_smilie))
    {
    $string str_replace($row['shortcut'], $img_start2 $row['image'] . $img_end$string);
    }
    $string str_replace('[colored=darkred]''<font color="darkred">'$string);
    $string str_replace('[colored=red]''<font color="red">'$string);
    $string str_replace('[colored=orange]''<font color="orange">'$string);
    $string str_replace('[colored=brown]''<font color="brown">'$string);
    $string str_replace('[colored=yellow]''<font color="yellow">'$string);
    $string str_replace('[colored=green]''<font color="green">'$string);
    $string str_replace('[colored=olive]''<font color="olive">'$string);
    $string str_replace('[colored=cyan]''<font color="cyan">'$string);
    $string str_replace('[colored=blue]''<font color="blue">'$string);
    $string str_replace('[colored=darkblue]''<font color="darkblue">'$string);
    $string str_replace('[colored=indigo]''<font color="indigo">'$string);
    $string str_replace('[colored=violet]''<font color="violet">'$string);
    $string str_replace('[colored=black]''<font color="black">'$string);
    $string str_replace('[/colored]''</font>'$string);
    $string str_replace('[size=7]''<font style="font-size:7px">'$string);
    $string str_replace('[size=8]''<font style="font-size:8px">'$string);
    $string str_replace('[size=9]''<font style="font-size:9px">'$string);
    $string str_replace('[size=10]''<font style="font-size:10px">'$string);
    $string str_replace('[size=11]''<font style="font-size:11px">'$string);
    $string str_replace('[size=12]''<font style="font-size:12px">'$string);
    $string str_replace('[size=18]''<font style="font-size:18px">'$string);
    $string str_replace('[size=24]''<font style="font-size:24px">'$string);
    $string str_replace('[/size]''</font>'$string);
    return 
    $string;


    Für Verbesserungsvorschläge zur Struktur bzw. des Aufbaus der ganzen Sache wäre ich auch dankbar.
    Zuletzt geändert von deschmiddi; 26.10.2005, 22:50.
    Geht net gibts net...

  • #2
    also das Problem mit den Slashes hab ich gelöst...

    PHP-Code:
    $string stripslashes(preg_replace('#\[c\](.+)\[/c\]#Uise',"'[blockquote]'.highlight_string('\\1', TRUE).'[/blockquote]'"$string)); 
    manchmal sieht man den Wald vor lauter bäumen nicht *g*
    highliten tut er trotzdem nicht
    Geht net gibts net...

    Kommentar


    • #3
      PHP-Code:
       $string str_replace('[blockquote]''<blockquote><div class="stil_small">Code:</div><table width="70%" cellspacing="1" cellpadding="2" class="code"><tr class="code"><td>'$string);
              
      $string str_replace('[/blockquote]''</td></tr></table></blockquote>'$string); 
      Das ergibt aber ziemliches AUA wenn man nur [blockquote] schreibt..

      Kommentar


      • #4
        *scroll - srcoll - scroll*

        Bitte Zeilen umbrechen

        Kommentar


        • #5
          @ matzor

          das war ja auch nur die Zeile die ich geändert hab...
          die zeile die du noch hinzugefügt hast ist bei mir ja oben auch drin.

          Ja ich versuchs mal besser umzubrechen
          Geht net gibts net...

          Kommentar


          • #6
            *scroll - srcoll - scroll*
            wozu? einfach solche threads ignorieren.

            wer hilfe will, muss schlicht und einfach die board-regeln beachten.
            INFO: Erst suchen, dann posten![color=red] | [/color]MANUAL(s): PHP | MySQL | HTML/JS/CSS[color=red] | [/color]NICE: GNOME Do | TESTS: Gästebuch[color=red] | [/color]IM: Jabber.org |


            Kommentar


            • #7
              wie soll ich es denn noch umbrechen?kürzer gehts net
              und ich kenn die Boardregel...
              War allerdings der Meinung dass diesmal wirklich jede Zeile wichtig ist weil ich ja Vorschläge und Kritik zum sinnvollsten Aufbau des Ablaufes des ganzen wollte, und nicht nur ne Antwort auf die Frage: was ist an dem highlighter falsch.
              Das geht aber schlecht wenn ich die Hälfte weglasse oder?

              Naja und wie gesagt Manual und Board hab ich schon durchsucht aber sowas hier in der art hab ich nicht gefunden...
              Geht net gibts net...

              Kommentar


              • #8
                Du sollst nix weglassen (jedenfalls nix was wichtig ist), aber du sollst die Zeilen umbrechen. Z.B. so :

                PHP-Code:
                $string str_replace('[blockquote]''<blockquote>
                <div class="stil_small">Code:</div>
                <table width="70%" cellspacing="1" cellpadding="2" class="code">
                <tr class="code"><td>'
                $string); 
                Dann ist noch alles da, es ist halbwegs übersichtlich und keiner muss ständig nach links und rechts scrollen

                Kommentar


                • #9
                  So habs jetzt nochmal so versucht es so gut wies geht umzubrechen.
                  Codehighlighter funzt auch,
                  soweit allerdings bekomm ich jetzt nen Regex fehler.

                  er spuckt mir folgenden Regex mitten im Beitrag aus:
                  Warning: Unexpected character in input:
                  '' (ASCII=92) state=1 in DrogrammeTSWApache2htdocsparty
                  bilderincclasses
                  class_func.php(332) : regexp code on line 8

                  Allerdings kein plan woran das liegen könnte.
                  Sieht dann im Beitrag etwa so aus:

                  PHP-Code:
                  function FetchUserIcon($userid) {
                  global 
                  $templ;

                  $templ['usericon']['userid'] = $userid;
                  return 
                  $this->FetchModTpl(Warning
                  Unexpected character in input'' (ASCII=92
                  state=1 in DrogrammeTSWApache2htdocspartybilderinc
                  classesclass_func
                  .php(332) : regexp code on line 8"""ls_usericon");

                  jemand ne idee?
                  Geht net gibts net...

                  Kommentar


                  • #10
                    Original geschrieben von deschmiddi
                    Warning: Unexpected character in input:
                    '' (ASCII=92)
                    Also ein unerwarteter \
                    I don't believe in rebirth. Actually, I never did in my whole lives.

                    Kommentar

                    Lädt...
                    X