Jurpopage Free Dynamic Website Script

 » Jurpopage Download Navigation
 » Jurpopage Web Designer Help
 » Jurpopage Source Code Help
 

  Welcome to Jurpopage Official Navigation for project updates, readme, change log, help, & download

New version update. Download navigation here...


   
  <?php

//- update
//- mendukung tag :panah:

// Make sure no one attempts to run this script "directly"
if (!defined('JURPO')) exit;


// Here you can add additional smilies if you like (please note that you must escape singlequote and backslash)
$smiley_text = array(':)', '=)', ':|', '=|', ':(', '=(', ':D', '=D', ':o', ':O', ';)', ':/', ':P', ':lol:', ':mad:', ':rolleyes:', ':cool:', ':panah:');
$smiley_img = array('smile.png', 'smile.png', 'neutral.png', 'neutral.png', 'sad.png', 'sad.png', 'big_smile.png', 'big_smile.png', 'yikes.png', 'yikes.png', 'wink.png', 'hmm.png', 'tongue.png', 'lol.png', 'mad.png', 'roll.png', 'cool.png', 'panah.png');

//
// Split text into chunks ($inside contains all text inside $start and $end, and $outside contains all text outside)
//
function split_text($text, $start, $end)
{
global $FORUM_config;

$tokens = explode($start, $text);

$outside[] = $tokens[0];

$num_tokens = count($tokens);
for ($i = 1; $i < $num_tokens; ++$i)
{
$temp = explode($end, $tokens[$i]);
$inside[] = $temp[0];
$outside[] = $temp[1];
}

if ($FORUM_config['o_indent_num_spaces'] != 8 && $start == '[code]')
{
$spaces = str_repeat(' ', $FORUM_config['o_indent_num_spaces']);
$inside = str_replace("\t", $spaces, $inside);
}

return array($inside, $outside);
}


//
// Truncate URL if longer than 55 characters (add http:// or ftp:// if missing)
//
function handle_url_tag($url, $link = '')
{
global $FORUM_user;

$full_url = str_replace(array(' ', '\'', '`', '"'), array('%20', '', '', ''), $url);
if (strpos($url, 'www.') === 0) // If it starts with www, we add http://
$full_url = 'http://'.$full_url;
else if (strpos($url, 'ftp.') === 0) // Else if it starts with ftp, we add ftp://
$full_url = 'ftp://'.$full_url;
else if (!preg_match('#^([a-z0-9]{3,6})://#', $url, $bah)) // Else if it doesn't start with abcdef://, we add http://
$full_url = 'http://'.$full_url;

// Ok, not very pretty :-)
$link = ($link == '' || $link == $url) ? ((strlen($url) > 55) ? substr($url, 0 , 39).' &hellip; '.substr($url, -10) : $url) : stripslashes($link);

return '<a href="'.$full_url.'">'.$link.'</a>';
}


//
// Turns an URL from the [img] tag into an <img> tag or a <a href...> tag
//
function handle_img_tag($url, $is_signature = false)
{
global $lang_common, $FORUM_config, $FORUM_user;

$img_tag = '<a href="'.$url.'">&lt;'.$lang_common['Image link'].'&gt;</a>';

if ($is_signature && $FORUM_user['show_img_sig'] != '0')
$img_tag = '<img class="sigimage" src="'.$url.'" alt="'.htmlspecialchars($url).'" />';
else if (!$is_signature && $FORUM_user['show_img'] != '0')
$img_tag = '<img class="postimg" src="'.$url.'" alt="'.htmlspecialchars($url).'" />';

return $img_tag;
}


//
// Convert BBCodes to their HTML equivalent
//
function do_bbcode($text)
{
global $lang_common, $FORUM_user;

if (strpos($text, 'quote') !== false)
{
$text = str_replace('[quote]', '</p><blockquote><div class="incqbox"><p>', $text);
$text = preg_replace('#\[quote=(&quot;|"|\'|)(.*)\\1\]#seU', '"</p><blockquote><div class=\"incqbox\"><h4>".str_replace(array(\'[\', \'\\"\'), array(\'&#91;\', \'"\'), \'$2\')." ".$lang_common[\'wrote\'].":</h4><p>"', $text);
$text = preg_replace('#\[\/quote\]\s*#', '</p></div></blockquote><p>', $text);
}

$pattern = array('#\[b\](.*?)\[/b\]#s',
'#\[i\](.*?)\[/i\]#s',
'#\[u\](.*?)\[/u\]#s',
'#\[url\]([^\[]*?)\[/url\]#e',
'#\[url=([^\[]*?)\](.*?)\[/url\]#e',
'#\[email\]([^\[]*?)\[/email\]#',
'#\[email=([^\[]*?)\](.*?)\[/email\]#',
'#\[color=([a-zA-Z]*|\#?[0-9a-fA-F]{6})](.*?)\[/color\]#s');

$replace = array('<strong>$1</strong>',
'<em>$1</em>',
'<span class="bbu">$1</span>',
'handle_url_tag(\'$1\')',
'handle_url_tag(\'$1\', \'$2\')',
'<a href="mailto:$1">$1</a>',
'<a href="mailto:$1">$2</a>',
'<span style="color: $1">$2</span>');

// This thing takes a while! :)
$text = preg_replace($pattern, $replace, $text);

return $text;
}


//
// Make hyperlinks clickable
//
function do_clickable($text)
{
global $FORUM_user;

$text = ' '.$text;

$text = preg_replace('#([\s\(\)])(https?|ftp|news){1}://([\w\-]+\.([\w\-]+\.)*[\w]+(:[0-9]+)?(/[^"\s\(\)<\[]*)?)#ie', '\'$1\'.handle_url_tag(\'$2://$3\')', $text);
$text = preg_replace('#([\s\(\)])(www|ftp)\.(([\w\-]+\.)*[\w]+(:[0-9]+)?(/[^"\s\(\)<\[]*)?)#ie', '\'$1\'.handle_url_tag(\'$2.$3\', \'$2.$3\')', $text);

return substr($text, 1);
}


//
// Convert a series of smilies to images
//
function do_smilies($text)
{
global $smiley_text, $smiley_img;

$text = ' '.$text.' ';

$num_smilies = count($smiley_text);

//- update : lebar dan tinggi gambar otomatis

//-upper text ?????/ testing
for ($i = 0; $i < $num_smilies; ++$i)
$text = preg_replace("#(?<=.\W|\W.|^\W)".preg_quote($smiley_text[$i], '#')."(?=.\W|\W.|\W$)#m", '$1<img src="library/smilies/'.$smiley_img[$i].'" alt="'.substr($smiley_img[$i], 0, strrpos($smiley_img[$i], '.')).'" />$2', $text);
//-lower text ?????? testing
for ($i = 0; $i < $num_smilies; ++$i)
$text = preg_replace("#(?<=.\W|\W.|^\W)".preg_quote(strtolower($smiley_text[$i]), '#')."(?=.\W|\W.|\W$)#m", '$1<img src="library/smilies/'.$smiley_img[$i].'" alt="'.substr($smiley_img[$i], 0, strrpos($smiley_img[$i], '.')).'" />$2', $text);

return substr($text, 1, -1);
}


//
// Parse message text
//
function parse_message($text, $hide_smilies)
{
global $FORUM_config, $lang_common, $FORUM_user;

if ($FORUM_config['o_censoring'] == '1')
$text = censor_words($text);

// Convert applicable characters to HTML entities
$text = FORUM_htmlspecialchars($text);

// If the message contains a code tag we have to split it up (text within [code][/code] shouldn't be touched)
if (strpos($text, '[code]') !== false && strpos($text, '[/code]') !== false)
{
list($inside, $outside) = split_text($text, '[code]', '[/code]');
$outside = array_map('ltrim', $outside);
$text = implode('<">', $outside);
}

//if ($FORUM_config['o_make_links'] == '1')
$text = do_clickable($text); //buat link

//if ($FORUM_config['o_smilies'] == '1' && $FORUM_user['show_smilies'] == '1' && $hide_smilies == '0')
$text = do_smilies($text); //alwais show smilies

if ($FORUM_config['p_message_bbcode'] == '1' && strpos($text, '[') !== false && strpos($text, ']') !== false)
{
$text = do_bbcode($text);

if ($FORUM_config['p_message_img_tag'] == '1')
{
// $text = preg_replace('#\[img\]((ht|f)tps?://)([^\s<"]*?)\.(jpg|jpeg|png|gif)\[/img\]#e', 'handle_img_tag(\'$1$3.$4\')', $text);
$text = preg_replace('#\[img\]((ht|f)tps?://)([^\s<"]*?)\[/img\]#e', 'handle_img_tag(\'$1$3\')', $text);
}
}

// Deal with newlines, tabs and multiple spaces
$pattern = array("\n", "\t", ' ', ' ');
$replace = array('<br />', '&nbsp; &nbsp; ', '&nbsp; ', ' &nbsp;');
$text = str_replace($pattern, $replace, $text);

// If we split up the message before we have to concatenate it together again (code tags)
if (isset($inside))
{
$outside = explode('<">', $text);
$text = '';

$num_tokens = count($outside);

for ($i = 0; $i < $num_tokens; ++$i)
{
$text .= $outside[$i];
if (isset($inside[$i]))
{
$num_lines = ((substr_count($inside[$i], "\n")) + 3) * 1.5;
$height_str = ($num_lines > 35) ? '35em' : $num_lines.'em';
$text .= '</p><div class="codebox"><div class="incqbox"><h4>'.$lang_common['Code'].':</h4><div class="scrollbox" style="height: '.$height_str.'"><pre>'.$inside[$i].'</pre></div></div></div><p>';
}
}
}

// Add paragraph tag around post, but make sure there are no empty paragraphs
$text = str_replace('<p></p>', '', '<p>'.$text.'</p>');

return $text;
}

?>