Location: PHPKode > projects > pkZoos Website > includes/style.php
<?php
	if(!defined('PK_MAGIC'))
		die('hack or what?');





	/* */

	$style = array();





	/* */

	function style_load()
	{
		global $db;
		global $config;
		global $style;

        $q = "
            SELECT
            	style_name,
            	style_dir,
            	style_author
            FROM " . STYLES_TABLE . "
            WHERE style_id = " . $config['style_id'] . "
        ";

        $style_res = $db->query($q);
        $style_row = $db->fetch_row($style_res);

        $style['name'] = $style_row['style_name'];
        $style['dir'] = $style_row['style_dir'];
        $style['author'] = $style_row['style_author'];

        $config['style_path'] = $config['script_path'] . 'styles/' . $style['dir'] . '/';
        $config['style_url'] = base_url() . 'styles/' . $style['dir'] . '/';
    }





	/* */

	function _encode_pending_links($s)
	{
		$in = array();
		$out = array();

		$in[]  = '#(^|[\\n ])([a-z][a-z0-9]*?://[a-z0-9$%&/=?[\\]+\\-@\\#~.,:;_]+)#si';
		$out[] = '\\1<a href="\\2" target="_blank">\\2</a>';

        return substr(preg_replace($in, $out, ' ' . $s), 1);
	}





	/* */

	function _encode_bbcode($message, $mod_or_admin)
	{
		global $url_register;
		global $url_login;
		global $url_send_password;
		global $url_logout;
		global $url_news;
		global $url_board;

		$in = array();
		$out = array();

		$in[]  = '#\\[b\\](.+?)\\[/b\\]#si';
		$out[] = '<span style="font-weight:bold;">\\1</span>';

		$in[]  = '#\\[i\\](.+?)\\[/i\\]#si';
		$out[] = '<span style="font-style:italic;">\\1</span>';

		$in[]  = '#\\[u\\](.+?)\\[/u\\]#si';
		$out[] = '<span style="text-decoration:underline;">\\1</span>';

		$in[]  = '#\\[c\\](.+?)\\[/c\\]#si';
		$out[] = '<span style="text-decoration:line-through;">\\1</span>';

		$in[]  = '#\\[register\\]#si';
		$out[] = make_url('register', array());

		$in[]  = '#\\[login\\]#si';
		$out[] = make_url('login', array());

		$in[]  = '#\\[send_password\\]#si';
		$out[] = make_url('send_password', array());

		$in[]  = '#\\[logout\\]#si';
		$out[] = make_url('logout', array());

		$in[]  = '#\\[news\\]#si';
		$out[] = make_url('news', array());

		$in[]  = '#\\[board\\]#si';
		$out[] = make_url('board', array());

		$in[]  = '#\\[search\\]#si';
		$out[] = make_url('search', array());

		$in[]  = '#\\[search_post\\]#si';
		$out[] = make_url('search_post', array());

		$in[]  = '#\\[search_topic\\]#si';
		$out[] = make_url('search_topic', array());

		$in[]  = '#\\[search_user\\]#si';
		$out[] = make_url('search_user', array());

		$in[]  = '#\\[cat=([0-9]+?)\\]#si';
		$out[] = make_url('cat', array('cat_id' => '')) . '\\1';

		$in[]  = '#\\[topic=([0-9]+?)\\]#si';
		$out[] = make_url('topic', array('topic_id' => '')) . '\\1';

		$in[]  = '#\\[user=([0-9]+?)\\]#si';
		$out[] = make_url('user', array('user_id' => '')) . '\\1';

		$in[]  = '#\\[irl\\](.+?)\\[/irl\\]#si';
		$out[] = '<a href="\\1">\\1</a>';

		$in[]  = '#\\[irl=(.+?)\\](.+?)\\[/irl\\]#si';
		$out[] = '<a href="\\1">\\2</a>';

		$in[]  = '#\\[url\\](.+?)\\[/url\\]#si';
		$out[] = '<a href="\\1" target="_blank">\\1</a>';

		$in[]  = '#\\[url=(.+?)\\](.+?)\\[/url\\]#si';
		$out[] = '<a href="\\1" target="_blank">\\2</a>';

		$in[]  = '#\\[code\\](.+?)\\[/code\\]#si';
		$out[] = '<div class="code_title">code</div><div class="code">\\1<br></div>';

		$in[]  = '#\\[code=(.+?)\\](.+?)\\[/code\\]#si';
		$out[] = '<div class="code_title">code from \\1</div><div class="code">\\2<br></div>';

		$in[]  = '#\\[quote\\](.+?)\\[/quote\\]#si';
		$out[] = '<div class="quote_title">quote</div><div class="quote">\\1<br></div>';

		$in[]  = '#\\[quote=(.+?)\\](.+?)\\[/quote\\]#si';
		$out[] = '<div class="quote_title">\\1 wrote</div><div class="quote">\\2<br></div>';

		if($mod_or_admin)
		{
            $in[]  = '#\\[size=([0-9]+?)\\](.+?)\\[/size\\]#si';
            $out[] = '<span style="font-size:\\1px;">\\2</span>';

            $in[]  = '#\\[color=\\#([0-9a-f]{6}?)\\](.+?)\\[/color\\]#si';
            $out[] = '<span style="color:#\\1;">\\2</span>';

            $in[]  = '#\\[color=([a-z]+?)\\](.+?)\\[/color\\]#si';
            $out[] = '<span style="color:\\1;">\\2</span>';
		}

		return preg_replace($in, $out, $message);
	}





	/* */

	function output_post($message, $mod_or_admin)
	{
		$message = htmlentities($message, ENT_QUOTES);
		$message = _encode_bbcode($message, $mod_or_admin);
		$message = _encode_pending_links($message);

		$in =  array("\t",             "\n ",      '  ',      '  ',      "\r\n", "\n");
		$out = array('&nbsp; &nbsp; ', "\n&nbsp;", '&nbsp; ', ' &nbsp;', '<br>', '<br>');

		return str_replace($in, $out, $message);
	}





	/* */

	function highlight_post($message, $mod_or_admin)
	{
		return output_post($message, $mod_or_admin);
	}
?>
Return current item: pkZoos Website