diff options
author | Starla Insigna <hatkirby@fourisland.com> | 2008-11-19 17:27:03 -0500 |
---|---|---|
committer | Starla Insigna <hatkirby@fourisland.com> | 2008-11-19 17:27:03 -0500 |
commit | 24503e3abe705acde2df159aeae61be0d009f92e (patch) | |
tree | 8debbd53dcd0db2f5934c5e2af4e697e3787781d /includes/bbcode.php | |
download | fourisland-24503e3abe705acde2df159aeae61be0d009f92e.tar.gz fourisland-24503e3abe705acde2df159aeae61be0d009f92e.tar.bz2 fourisland-24503e3abe705acde2df159aeae61be0d009f92e.zip |
Imported sources
Diffstat (limited to 'includes/bbcode.php')
-rw-r--r-- | includes/bbcode.php | 151 |
1 files changed, 151 insertions, 0 deletions
diff --git a/includes/bbcode.php b/includes/bbcode.php new file mode 100644 index 0000000..4a1870a --- /dev/null +++ b/includes/bbcode.php | |||
@@ -0,0 +1,151 @@ | |||
1 | <?php | ||
2 | /* | ||
3 | 444444444 | ||
4 | 4::::::::4 | ||
5 | 4:::::::::4 | ||
6 | 4::::44::::4 | ||
7 | 4::::4 4::::4 Four Island | ||
8 | 4::::4 4::::4 | ||
9 | 4::::4 4::::4 Written and maintained by Starla Insigna | ||
10 | 4::::444444::::444 | ||
11 | 4::::::::::::::::4 includes/bbcode.php | ||
12 | 4444444444:::::444 | ||
13 | 4::::4 Please do not use, reproduce or steal the | ||
14 | 4::::4 contents of this file without explicit | ||
15 | 4::::4 permission from Hatkirby. | ||
16 | 44::::::44 | ||
17 | 4::::::::4 | ||
18 | 4444444444 | ||
19 | */ | ||
20 | |||
21 | if (!defined('S_INCLUDE_FILE')) {define('S_INCLUDE_FILE',1);} | ||
22 | |||
23 | require('headerproc.php'); | ||
24 | |||
25 | $bbcode = bbcode_create(array('' => array('type' => BBCODE_TYPE_ROOT))); | ||
26 | |||
27 | // [b][/b] - Bold | ||
28 | bbcode_add_element($bbcode,'b',array( 'type' => BBCODE_TYPE_NOARG, | ||
29 | 'open_tag' => '<B>', | ||
30 | 'close_tag' => '</B>')); | ||
31 | |||
32 | // [i][/i] - Italic | ||
33 | bbcode_add_element($bbcode,'i',array( 'type' => BBCODE_TYPE_NOARG, | ||
34 | 'open_tag' => '<I>', | ||
35 | 'close_tag' => '</I>')); | ||
36 | |||
37 | // [url][/url] - [url=][/url] - Link | ||
38 | bbcode_add_element($bbcode,'url',array( 'type' => BBCODE_TYPE_OPTARG, | ||
39 | 'open_tag' => '<a href="{PARAM}">', | ||
40 | 'close_tag' => '</a>', | ||
41 | 'default_arg' => '{CONTENT}')); | ||
42 | |||
43 | // [img][/img] - [img=][/img] - Image | ||
44 | bbcode_add_element($bbcode,'img',array( 'type' => BBCODE_TYPE_OPTARG, | ||
45 | 'open_tag' => '<IMG SRC="', | ||
46 | 'close_tag' => '" ALT="{PARAM}" ALIGN="RIGHT"></IMG>', | ||
47 | 'default_tag' => '{CONTENT}')); | ||
48 | |||
49 | // [big][/big] - Big | ||
50 | bbcode_add_element($bbcode,'big',array( 'type' => BBCODE_TYPE_NOARG, | ||
51 | 'open_tag' => '<BIG>', | ||
52 | 'close_tag' => '</BIG>')); | ||
53 | |||
54 | // [small][/small] - Small | ||
55 | bbcode_add_element($bbcode,'small',array( 'type' => BBCODE_TYPE_NOARG, | ||
56 | 'open_tag' => '<SMALL>', | ||
57 | 'close_tag' => '</SMALL>')); | ||
58 | |||
59 | // [ul][/ul] - Unordered List | ||
60 | bbcode_add_element($bbcode,'ul',array( 'type' => BBCODE_TYPE_NOARG, | ||
61 | 'open_tag' => '<UL>', | ||
62 | 'close_tag' => '</UL>', | ||
63 | 'childs' => 'li')); | ||
64 | |||
65 | // [ol][/ol] - Ordered List | ||
66 | bbcode_add_element($bbcode,'ol',array( 'type' => BBCODE_TYPE_NOARG, | ||
67 | 'open_tag' => '<OL>', | ||
68 | 'close_tag' => '</OL>', | ||
69 | 'childs' => 'li')); | ||
70 | |||
71 | // [li][/li] - List Item | ||
72 | bbcode_add_element($bbcode,'li',array( 'type' => BBCODE_TYPE_NOARG, | ||
73 | 'open_tag' => '<LI>', | ||
74 | 'close_tag' => '</LI>')); | ||
75 | |||
76 | // [code][/code] - Code | ||
77 | bbcode_add_element($bbcode,'code',array( 'type' => BBCODE_TYPE_NOARG, | ||
78 | 'open_tag' => '<CODE>', | ||
79 | 'close_tag' => '</CODE>')); | ||
80 | |||
81 | // [pre][/pre] - Preformatted Code | ||
82 | bbcode_add_element($bbcode,'pre',array( 'type' => BBCODE_TYPE_NOARG, | ||
83 | 'open_tag' => '<P><DIV CLASS="autosize"><DIV CLASS="bubble"><DIV CLASS="bquote"><BLOCKQUOTE><DIV><PRE>', | ||
84 | 'close_tag' => '</PRE></DIV></BLOCKQUOTE></DIV></DIV></DIV><DIV CLASS="cleardiv"></DIV>')); | ||
85 | |||
86 | function bb_fixCode($string) | ||
87 | { | ||
88 | $he = htmlentities($string); | ||
89 | $br = nl2br($he); | ||
90 | $sp = str_replace(' ',' $nbsp;',$br); | ||
91 | $ta = str_replace(' ',' ',$sp); | ||
92 | return($ta); | ||
93 | } | ||
94 | |||
95 | // [blog][/blog] - Blog Link | ||
96 | bbcode_add_element($bbcode,'blog',array( 'type' => BBCODE_TYPE_OPTARG, | ||
97 | 'open_tag' => (isset($oldBlog) ? '<A HREF="/archives/{CONTENT}.php">' : '<A HREF="/blog/{PARAM}/">'), | ||
98 | 'close_tag' => '</A>', | ||
99 | 'default_arg' => '{CONTENT}')); | ||
100 | |||
101 | // [quote][/quote] - Quotes DB Link | ||
102 | bbcode_add_element($bbcode,'quote',array( 'type' => BBCODE_TYPE_NOARG, | ||
103 | 'open_tag' => (isset($oldBlog) ? '<A HREF="http://quotes.fourisland.com/?{CONTENT}">#' : '<A HREF="/quotes/{CONTENT}.php">#'), | ||
104 | 'close_tag' => '</A>')); | ||
105 | |||
106 | // [ins][/ins] - Insert | ||
107 | bbcode_add_element($bbcode,'ins',array( 'type' => BBCODE_TYPE_NOARG, | ||
108 | 'open_tag' => '<INS>', | ||
109 | 'close_tag' => '</INS>')); | ||
110 | |||
111 | // [del][/del] - Delete | ||
112 | bbcode_add_element($bbcode,'del',array( 'type' => BBCODE_TYPE_NOARG, | ||
113 | 'open_tag' => '<DEL>', | ||
114 | 'close_tag' => '</DEL>')); | ||
115 | |||
116 | // [bquote][/bquote] - Blockquote | ||
117 | bbcode_add_element($bbcode,'bquote',array( 'type' => BBCODE_TYPE_OPTARG, | ||
118 | 'open_tag' => '<P><DIV CLASS="autosize"><DIV CLASS="bubble"><DIV CLASS="bquote"><BLOCKQUOTE><DIV><NOBR>', | ||
119 | 'close_tag' => '</NOBR></DIV></BLOCKQUOTE></DIV><CITE><STRONG>{PARAM}</STRONG></CITE></DIV></DIV><DIV CLASS="cleardiv"></DIV>', | ||
120 | 'default_arg' => 'Anonymous')); | ||
121 | |||
122 | // [project][/project] - Project Link | ||
123 | bbcode_add_element($bbcode,'project',array( 'type' => BBCODE_TYPE_NOARG, | ||
124 | 'open_tag' => (isset($oldBlog) ? '<A HREF="http://projects.fourisland.com/{CONTENT}/">' : '<A HREF="/projects/{CONTENT}/">'), | ||
125 | 'close_tag' => '</A>')); | ||
126 | |||
127 | // [abbr][/abbr] - Abbreviation | ||
128 | bbcode_add_element($bbcode,'abbr',array( 'type' => BBCODE_TYPE_OPTARG, | ||
129 | 'open_tag' => '<ABBR TITLE="{PARAM}">', | ||
130 | 'close_tag' => '</ABBR>', | ||
131 | 'default_arg' => '')); | ||
132 | |||
133 | // [br] - Line Break | ||
134 | bbcode_add_element($bbcode,'br',array( 'type' => BBCODE_TYPE_SINGLE, | ||
135 | 'open_tag' => '<BR>')); | ||
136 | |||
137 | // [hidden][/hidden] - Hidden Text | ||
138 | bbcode_add_element($bbcode,'hidden',array( 'type' => BBCODE_TYPE_OPTARG, | ||
139 | 'open_tag' => '<DIV STYLE="display: none">', | ||
140 | 'close_tag' => '</DIV>', | ||
141 | 'default_arg' => '')); | ||
142 | |||
143 | function parseBBCode($text) | ||
144 | { | ||
145 | global $bbcode; | ||
146 | $to_parse = str_replace("\n",'[br]',htmlentities($text)); | ||
147 | $to_parse = bbcode_parse($bbcode,$to_parse); | ||
148 | return str_replace('[br]','',$to_parse); | ||
149 | } | ||
150 | |||
151 | ?> | ||