Auto Link and Auto Mail BBCode in Lavalair

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • metulj
    replied
    Originally posted by subzero View Post
    This does not look safe lol ....
    true.. but it's a good start

    Leave a comment:


  • Dj_ThimirA
    replied
    Last edited by Dj_ThimirA; 27.01.11, 12:46.

    Leave a comment:


  • subzero
    replied
    This does not look safe lol ....

    Leave a comment:


  • Auto Link and Auto Mail BBCode in Lavalair

    01.Insert this functions into core.php.

    PHP Code:
    function trimlink($text, $length) {
        
    $dec = array("&", "\"", "'", "\\", '\"', "\'", "<", ">");
        
    $enc = array("&amp;", "&quot;", "'", "\", "&quot;", "'", "&lt;", "&gt;");
        
    $text = str_replace($enc, $dec, $text);
        if (
    strlen($text) > $length) $text = substr($text, 0, ($length-3))."...";
        
    $text = str_replace($dec, $enc, $text);
        return 
    $text;
    }
    function 
    hide_email($email, $title = "", $subject = "") {
        if (
    strpos($email, "@")) {
            
    $parts = explode("@", $email);
            
    $MailLink = "<a href='mailto:".$parts[0]."@".$parts[1];
            if (
    $subject != "") { $MailLink .= "?subject=".urlencode($subject); }
            
    $MailLink .= "'>".($title?$title:$parts[0]."@".$parts[1])."</a>";
            
    $MailLetters = "";
            for (
    $i = 0; $i < strlen($MailLink); $i++) {
                
    $l = substr($MailLink, $i, 1);
                if (
    strpos($MailLetters, $l) === false) {
                    
    $p = rand(0, strlen($MailLetters));
                    
    $MailLetters = substr($MailLetters, 0, $p).$l.substr($MailLetters, $p, strlen($MailLetters));
                }
            }
            
    $MailLettersEnc = str_replace("\\", "\\\\", $MailLetters);
            
    $MailLettersEnc = str_replace("\"", "\\\"", $MailLettersEnc);
            
    $MailIndexes = "";
            for (
    $i = 0; $i < strlen($MailLink); $i ++) {
                
    $index = strpos($MailLetters, substr($MailLink, $i, 1));
                
    $index += 48;
                
    $MailIndexes .= chr($index);
            }
            
    $MailIndexes = str_replace("\\", "\\\\", $MailIndexes);
            
    $MailIndexes = str_replace("\"", "\\\"", $MailIndexes);
            
            
    $res = "<script type='text/javascript'>";
            
    $res .= "ML=\"".str_replace("<", "xxxx", $MailLettersEnc)."\";";
            
    $res .= "MI=\"".str_replace("<", "xxxx", $MailIndexes)."\";";
            
    $res .= "ML=ML.replace(/xxxx/g, '<');";
            
    $res .= "MI=MI.replace(/xxxx/g, '<');";    $res .= "OT=\"\";";
            
    $res .= "for(j=0;j < MI.length;j++){";
            
    $res .= "OT+=ML.charAt(MI.charCodeAt(j)-48);";
            
    $res .= "}document.write(OT);";
            
    $res .= "</script>";
        
            return 
    $res;
        } else {
            return 
    $email;
        }
    } 

    02.Insert below lines into "function getbbcode" in core.php

    PHP Code:
    $text = preg_replace('#(^|[\n ])((http|https|ftp|ftps)://[\w\#$%&~/.\-;:=,?@\[\]\(\)+]*)#sie', "'\\1<br/>External Link:<a href=\"'.trim('\\2').'\" target=\"_blank\" title=\"autolink\">'.trimlink('\\2', 20).(strlen('\\2')>30?substr('\\2', strlen('\\2')-10, strlen('\\2')):'').'</a>'", $text);
    $text = preg_replace("#(^|[\n ])((www|ftp)\.[\w\#$%&~/.\-;:=,?@\[\]\(\)+]*)#sie", "'\\1<br/>External Link:<a href=\"http://'.trim('\\2').'\" target=\"_blank\" title=\"autolink\">'.trimlink('\\2', 20).(strlen('\\1')>30?substr('\\2', strlen('\\2')-10, strlen('\\2')):'').'</a>'", $text);
    $text = preg_replace("#([a-z0-9&\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)*[\w]+)#sie", "hide_email('\\1@\\2')", $text); 
    Last edited by Dj_ThimirA; 27.01.11, 12:43. Reason: forgot to post something
Working...
X