Código PHP:
Ver original
function markup($string, $bbcode=true, $smilies=true, $html=false, $rss_mode=false, $links=true) { global $db, $template, $lang; static $random; // // Needed by some BBCode regexps and smilies // $string = ' '.$string.' '; if ( !$html ) $string = unhtml($string, $rss_mode); if ( $smilies ) { $all_smilies = $template->get_config('smilies'); $full_path = ( $rss_mode ) ? $this->get_config('board_url') : ROOT_PATH; foreach ( $all_smilies as $pattern => $img ) $string = preg_replace('#([^"])('.preg_quote(unhtml($pattern), '#').')#', '\\1<img src="'.$full_path.'templates/'.$this->get_config('template').'/smilies/'.$img.'" alt="'.unhtml($pattern).'" />', $string); // // Entity + smiley fix // } if ( $bbcode ) { $string = ' '.$this->bbcode_prepare($string).' '; if ( $this->get_config('target_blank') ) $rel[] = 'external'; if ( $this->get_config('rel_nofollow') ) $rel[] = 'nofollow'; // // Protect from infinite loops. // The while loop to parse nested quote tags has the sad side-effect of entering an infinite loop // when the parsed text contains $0 or \0. // Admittedly, this is a quick and dirty fix. For a nice "fix" I refer to the stack based parser in 2.0. // if ( $random == NULL ) $random = $this->random_key(); // // Parse quote tags // // Might seem a bit difficultly done, but trimming doesn't work the usual way // $string = preg_replace("#\[quote\]".preg_quote($matches[1], '#')."\[/quote\]#is", sprintf($template->get_config('quote_format'), $lang['Quote'], ' '.trim($matches[1])).' ', $string); } $string = preg_replace("#\[quote=".preg_quote($matches[1], '#')."\]".preg_quote($matches[2], '#')."\[/quote\]#is", sprintf($template->get_config('quote_format'), sprintf($lang['Wrote'], $matches[1]), ' '.trim($matches[2]).' '), $string); } // // Undo the dirty fixing. // // // Parse code tags // foreach ( $matches[1] as $oldpart ) { $newpart = preg_replace(array('#<img src="[^"]+" alt="([^"]+)" />#', "#\n#", "#\r#"), array('\\1', '<br />', ''), $oldpart); // replace smiley image tags } $string = preg_replace("#\[code\](.*?)\[/code\]#is", sprintf($template->get_config('code_format'), '\\1'), $string); // // Parse URL's and e-mail addresses enclosed in special characters // if ( $links ) { $ignore_chars = "([^a-z0-9/]|&\#?[a-z0-9]+;)*?"; for ( $i = 0; $i < 2; $i++ ) { "#([\s]".$ignore_chars.")([\w]+?://[\w\#\$%&~/\.\-;:=,\?@\[\]\+\\\\\'!\(\)\*]*?)(".$ignore_chars."[\s])#is", "#([\s]".$ignore_chars.")(www\.[\w\#\$%&~/\.\-;:=,\?@\[\]\+\\\\\'!\(\)\*]*?)(".$ignore_chars."[\s])#is", "#([\s]".$ignore_chars.")([a-z0-9&\-_\.\+]+?@[\w\-]+\.([\w\-\.]+\.)?[\w]+)(".$ignore_chars."[\s])#is" '\\1<a href="\\3" title="\\3"'.$rel.'>\\3</a>\\4', '\\1<a href="http://\\3" title="http://\\3"'.$rel.'>\\3</a>\\4', '\\1<a href="mailto:\\2" title="\\3">\\3</a>\\5' ), $string); } } // // All kinds of BBCode regexps // // [b]text[/b] "#\[b\](.*?)\[/b\]#is" => '<strong>\\1</strong>', // [i]text[/i] "#\[i\](.*?)\[/i\]#is" => '<em>\\1</em>', // [u]text[/u] "#\[u\](.*?)\[/u\]#is" => '<span style="text-decoration:underline">\\1</span>', // [s]text[/s] "#\[s\](.*?)\[/s\]#is" => '<del>\\1</del>', // [left]text[/left] "#\[left\](.*?)\[/left\]#is" => '<div style="text-align:left">\\1</div>', // [right]text[/right] "#\[right\](.*?)\[/right\]#is" => '<div style="text-align:right">\\1</div>', // [center]text[/center] "#\[center\](.*?)\[/center\]#is" => '<div style="text-align:center">\\1</div>', // [img]image[/img] "#\[img\]([\w]+?://[\w\#\$%&~/\.\-;:=,\?@\[\]\+\\\\\'!\(\)\*]*?)\[/img\]#is" => ( $links ) ? '<img src="\\1" alt="'.$lang['UserPostedImage'].'" />' : '\\1', // www.usebb.net "#([\s])(www\.[\w\#\$%&~/\.\-;:=,\?@\[\]\+\\\\\'!\(\)\*]*?)#is" => ( $links ) ? '\\1<a href="http://\\2" '.$rel.'>\\2</a>\\3' : '\\1\\2\\3', // ftp.usebb.net "#([\s])(ftp\.[\w\#\$%&~/\.\-;:=,\?@\[\]\+\\\\\'!\(\)\*]*?)([\s])#is" => ( $links ) ? '\\1<a href="ftp://\\2" title="ftp://\\2"'.$rel.'>\\2</a>\\3' : '\\1\\2\\3', // [url]http://www.usebb.net[/url] "#\[url\]([\w]+?://[\w\#\$%&~/\.\-;:=,\?@\[\]\+\\\\\'!\(\)\*]*?)\[/url\]#is" => ( $links ) ? '<a href="\\1" '.$rel.'>\\1</a>' : '\\1', // [url=http://www.usebb.net]UseBB[/url] "#\[url=([\w]+?://[\w\#\$%&~/\.\-;:=,\?@\[\]\+\\\\\'!\(\)\*]*?)\](.*?)\[/url\]#is" => ( $links ) ? '<a href="\\1" '.$rel.'>\\2</a>' : '\\2 [\\1]', // [mailto][email protected][/mailto] "#\[mailto\]([a-z0-9&\-_\.\+]+?@[\w\-]+\.([\w\-\.]+\.)?[\w]+)\[/mailto\]#is" => ( $links ) ? '<a href="mailto:\\1" title="\\1">\\1</a>' : '\\1', // [[email protected]]mail me[/mailto] "#\[mailto=([a-z0-9&\-_\.\+]+?@[\w\-]+\.([\w\-\.]+\.)?[\w]+)\](.*?)\[/mailto\]#is" => ( $links ) ? '<a href="mailto:\\1" title="\\1">\\3</a>' : '\\3 [\\1]', // [color=red]text[/color] "#\[color=([\#a-z0-9]+)\](.*?)\[/color\]#is" => '<span style="color:\\1">\\2</span>', // [size=999]too big text[/size] "#\[size=([0-9]{3,})\](.*?)\[/size\]#is" => '\\2', // [size=14]text[/size] "#\[size=([0-9]*?)\](.*?)\[/size\]#is" => '<span style="font-size:\\1pt">\\2</span>', // [google=keyword]text[/google] "#\[google=(.*?)\](.*?)\[/google\]#is" => '<a href="http://www.google.com/search?q=\\1"'.$rel.'>\\2</a>', // [youtube]text[/youtube] "#\[youtube\](.*?)\[/youtube\]#is" => '<iframe width="450" height="299" style="padding: 5px; background-color: #FFF; border: 1px solid silver;" src="http://www.youtube.com/embed/\\1?theme=light&color=red&fs=0" frameborder="0"></iframe>', ); // // Now parse those regexps // foreach ( $regexps as $find => $replace ) // // Remove tags from attributes // foreach ( $matches[0] as $match ) } } if ( !$html ) { } // // XML (RSS/Atom) does not define elements such as a, pre, etc. // Though, make sure the already escaped < and > are still/double escaped. // if ( $rss_mode ) $string = str_replace(array('<', '>', '<', '>'), array('&lt;', '&gt;', '<', '>'), $string); }
Código PHP:
Ver original
/** * Return the BBCode control buttons * * @param bool $links Enable controls for links * @returns string HTML BBCode controls */ function get_bbcode_controls($links=true) { global $lang, $template; ); if ( $links ) { )); } )); foreach ( $controls as $data ) $out[] = '<a href="javascript:void(0);" onclick="insert_tags(\''.$data[0].'\', \''.$data[1].'\')" style="'.$data[3].'">'.$data[2].'</a>'; }
La API de adf.ly no es mas que esto, & hacer un llamado con file_get_contents:
http://api.adf.ly/api.php?key=XXX&uid=XXX&advert_type=int&domain=adf.ly&url=http://somewebsite.com
Pero el problema es que no se como reemplazar las urls..
Como lo puedo hacer..?
De antemano, gracias.