Menu

Test for BBCode

Sugestions
2010-01-18
2013-04-24
  • Andrzej Kmicic

    Andrzej Kmicic - 2010-01-18

    This example serves to illustrate for admins of SF networks, the error code display tags (BBCode).

    Welcome
    The error lies in the fact that if you use code tag in square brackets is the code is ill-formed.
    Square brackets  is used interchangeably with {} brackets 'Championships' so you can easily see them. In another tako {code} {/code} inserts a piece of code:
    Additional suggestion: In the CODE section of text should be a fixed width eg. CourierNew, is more understandable.

    Example1 :

    <?php
     $ first {'first'} = 1; 
     $ first {'first'} = 1; 
     $ first {'first'} = 1; 
     $ first {'first'} = 1; 
     $ first {'first'} = 1; 
     $ first {'first'} = 1; 
     $ first {'first'} = 1; 
     ?>
    

    It is well-formatted because I swapped the brackets  in brackets ().

    Example 2:
    If in the code inserts NORMAL in PHP sqare brackets with the text inside, ruins the whole BBCode formatting.

    <?php
     $ first ['first'] = 1; 
     $ first ['first'] = 1; 
     $ first ['first'] = 1; 
     $ first ['first'] = 1; 
     $ first ['first'] = 1; 
     $ first ['first'] = 1; 
     $ first ['first'] = 1; 
     ?>
    

    regards
    Wojtek Jarzecki

     
  • Andrzej Kmicic

    Andrzej Kmicic - 2010-01-20

    if remove square brackets all is good :

     $variable{'hash_name'} 
     $variable{'hash_name'} 
     $variable{'hash_name'} 
     $variable{'hash_name'}
    

    If square brackets is in code then be formating error:

     $variable['hash_name'] 
     $variable['hash_name'] 
     $variable['hash_name'] 
     $variable['hash_name']
    

    breaks all the formatting.

     
  • Andrzej Kmicic

    Andrzej Kmicic - 2010-01-20

    test for any squate brackets and text inside :

    if remove square brackets all is good :

     $variable{'hash_name'} 
     $variable{'hash_name'} 
     $variable{'hash_name'} 
     $variable{'hash_name'}
    

    If square brackets is in code then be formating error:

     $variable['hash_name'] 
     $variable['hash_name'] 
     $variable['hash_name'] 
     $variable['hash_name']
    
     
  • Andrzej Kmicic

    Andrzej Kmicic - 2010-01-20

    test for any squate brackets and text inside :

    test code blabla

    ['blabla']
    ['blabla']
    ['blabla']
    ['blabla']
    

    if remove square brackets all is good :

     $variable{'hash_name'} 
     $variable{'hash_name'} 
     $variable{'hash_name'} 
     $variable{'hash_name'}
    

    If square brackets is in code then be formating error:

     $variable['hash_name'] 
     $variable['hash_name'] 
     $variable['hash_name'] 
     $variable['hash_name']
    

    breaks all the formatting.

     
  • Andrzej Kmicic

    Andrzej Kmicic - 2010-01-21
    <?php
        nppUserCommand("NPPM_ACTIVATEDOC",0,0); 
        // activate first view and first document
        $logtxt = sciGetText();
        // get text from active document text
        $logtxt=nl2br($logtxt);
        $base_url="http://www.google.com/uds/Gtranslate";
        $l_from="en"; 
        // translate language from
        $l_to="pl";   
        // translate language to
        $url="$base_url?v=1.0&key=notsupplied&q=".
        urlencode($logtxt)."&langpair=".$l_from. "|" .$l_to;
        $contents=file_post_contents($url);
        $json = json_decode($contents, true); 
        if($json{'responseStatus'} == 200) 
        print preg_replace("#<br\s*?/?>#si","
    ", $json{'responseData'}{'translatedText'}); 
        else
        print "Error Response status:{$json{'responseStatus'}},".
        " details: {$json{'responseDetails'}}";
    function file_post_contents($url,$remove_headers=true) {
        $url = parse_url($url); 
        if (!isset($url{'port'})) {
          if ($url{'scheme'} == 'http') { $url{'port'}=80; }
          elseif ($url{'scheme'} == 'https') { $url{'port'}=443; }
        }
        $url{'query'}=isset($url{'query'})?$url{'query'}:'';
        $url{'protocol'}=$url{'scheme'}.'://';
        $eol="\r\n";
        $headers =  "POST ".$url{'protocol'}.$url{'host'}.$url{'path'}." HTTP/1.0".$eol. 
                    "Host: ".$url{'host'}.$eol. 
                    "Referer: ".$url{'protocol'}.$url{'host'}.$url{'path'}.$eol. 
                    "Content-Type: application/x-www-form-urlencoded".$eol. 
                    "Content-Length: ".strlen($url{'query'}).$eol.
                    $eol.$url{'query'};
        $fp = fsockopen($url{'host'}, $url{'port'}, $errno, $errstr, 30); 
        if($fp) {
          fputs($fp, $headers);
          $result = '';
          while(!feof($fp)) { $result .= fgets($fp, 128); }
          fclose($fp);
          if ($remove_headers) {
            //removes headers
            $pattern="/^.*\r\n\r\n/s";
            $result=preg_replace($pattern,'',$result);
          }
          return $result;
        }
    }
    ?>
    
     
  • Andrzej Kmicic

    Andrzej Kmicic - 2010-01-21
    $x["start"]=0;
    $x["start"]=1;
    $x['start']=2;
    $x["start"]=0;
    $x["start"]=0;
    
     
  • Luke Crouch

    Luke Crouch - 2010-01-25

    $array[$key] = 'value'

     
  • Luke Crouch

    Luke Crouch - 2010-01-25

    $array['first'] = 1;

     
  • Luke Crouch

    Luke Crouch - 2010-01-25

    $array['first'] = 1;

     
  • Luke Crouch

    Luke Crouch - 2010-01-25

    `$array = 1;`

     
  • Luke Crouch

    Luke Crouch - 2010-01-25

    $array[bracket]'first'[/bracket] = 1;

     
  • Luke Crouch

    Luke Crouch - 2010-01-25

    $array = 1;

     
  • Luke Crouch

    Luke Crouch - 2010-01-25

    Have you tested with

    $GLOBALS['concurrent_layout']
    

    set to 0 and 1?  Need to make sure those work.

    This code in messages.php will not work properly:

            $note = formData("note");
            $note = strip_escape_custom($note);
    

    … because formData always delivers escaped text, but strip_escape_custom strips escaped conditionally.  Instead, try:

            $note = strip_escape_custom($_POST['note']);
    

    This code needs a bit of work:

              // add message function
              addPnote($reply_to, $note, $userauthorized, '1', $form_note_type, $assigned_to);
              $row = sqlQuery("SELECT id FROM pnotes order by id DESC limit 0,1");
              sqlQuery("update pnotes set message_status='".$form_messsage_status."' where id = '".$row['id']."'");
    

    Problem is, getting the ID after you insert the new note might get you the wrong ID, if someone else added a note at the same time.  I'm pretty sure addPnote() returns the new ID, so just use that.

     
  • Luke Crouch

    Luke Crouch - 2010-01-25

    $array['first'] = 1;

     
  • Andrzej Kmicic

    Andrzej Kmicic - 2010-01-25
    $first_section_code['key_example']=123;
    $first_section_code['key_example']=123;
    $first_section_code['key_example']=123;
    $first_section_code['key_example']=123;
    $first_section_code['key_example']=123;
    
    $second_section_code['key_example']=123;
    $second_section_code['key_example']=123;
    $second_section_code['key_example']=123;
    $second_section_code['key_example']=123;
    $second_section_code['key_example']=123;
    
     
  • Andrzej Kmicic

    Andrzej Kmicic - 2010-01-25

    Bad is if key is in #39 characters 'bad key'

    $first_section_code["key_example"]=123;
    $first_section_code["key_example"]=123;
    $first_section_code["key_example"]=123;
    $first_section_code["key_example"]=123;
    $first_section_code["key_example"]=123;
    
    $second_section_code['key_example']=123;
    $second_section_code['key_example']=123;
    $second_section_code['key_example']=123;
    $second_section_code['key_example']=123;
    $second_section_code['key_example']=123;
    
     
  • Andrzej Kmicic

    Andrzej Kmicic - 2010-02-01

    $code=$arr['test'];
    $code=$arr['test'];
    $code=$arr['test'];

     

Log in to post a comment.