Hello Everyone,
I have the following code below for BB codes in my coded forum and want to use an IF statement to not show the links if the user is not registered so below is the code working without the if statement and the second piece of code is what i'm aiming for but obviously it doesn't work
Thanks in advance!
<?
function BBCode ($string) {
$search = array(
'#\[b\](.*?)\[/b\]#',
'#\[i\](.*?)\[/i\]#',
'#\[u\](.*?)\[/u\]#',
'#\[youtube\](.*?)\[/youtube\]#',
'#\[img\](.*?)\[/img\]#',
'#\[link=(.*?)\](.*?)\[/link\]#',
'#\[code\](.*?)\[/code\]#'
);
$replace = array(
'<b>\\1</b>',
'<i>\\1</i>',
'<u>\\1</u>',
'<br /><br /><center><object width="640" height="385"><param name="movie" value="http://www.youtube.com/v/\\1?fs=1&hl=en_US&color1=0x234900&color2=0x4e9e00"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/\\1?fs=1&hl=en_US&color1=0x234900&color2=0x4e9e00" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="500" height="306"></embed></object></center><br /><br />',
'<img src="\\1">',
'<a href="\\1" target="_blank">\\2</a>',
'<code>\\1</code>'
);
return preg_replace($search , $replace, $string);
}
?>
<?
function BBCode ($string) {
$search = array(
'#\[b\](.*?)\[/b\]#',
'#\[i\](.*?)\[/i\]#',
'#\[u\](.*?)\[/u\]#',
'#\[youtube\](.*?)\[/youtube\]#',
'#\[img\](.*?)\[/img\]#',
'#\[link=(.*?)\](.*?)\[/link\]#',
'#\[code\](.*?)\[/code\]#'
);
$replace = array(
'<b>\\1</b>',
'<i>\\1</i>',
'<u>\\1</u>',
'<br /><br /><center><object width="640" height="385"><param name="movie" value="http://www.youtube.com/v/\\1?fs=1&hl=en_US&color1=0x234900&color2=0x4e9e00"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/\\1?fs=1&hl=en_US&color1=0x234900&color2=0x4e9e00" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="500" height="306"></embed></object></center><br /><br />',
'<img src="\\1">',
if($_COOKIE['userloggedin'] == "") { echo "Register for links"; }else{ echo '<a href="\\1" target="_blank">\\2</a>'; },
'<code>\\1</code>'
);
return preg_replace($search , $replace, $string);
}
?>