diff --git a/phpBB/admin/admin_board.php b/phpBB/admin/admin_board.php
new file mode 100644
index 0000000000..b4278d1182
--- /dev/null
+++ b/phpBB/admin/admin_board.php
@@ -0,0 +1,27 @@
+
diff --git a/phpBB/admin/admin_forums.php b/phpBB/admin/admin_forums.php
new file mode 100644
index 0000000000..b4278d1182
--- /dev/null
+++ b/phpBB/admin/admin_forums.php
@@ -0,0 +1,27 @@
+
diff --git a/phpBB/admin/admin_users.php b/phpBB/admin/admin_users.php
new file mode 100644
index 0000000000..b4278d1182
--- /dev/null
+++ b/phpBB/admin/admin_users.php
@@ -0,0 +1,27 @@
+
diff --git a/phpBB/admin/index.php b/phpBB/admin/index.php
new file mode 100644
index 0000000000..b4278d1182
--- /dev/null
+++ b/phpBB/admin/index.php
@@ -0,0 +1,27 @@
+
diff --git a/phpBB/config.php b/phpBB/config.php
new file mode 100644
index 0000000000..b4278d1182
--- /dev/null
+++ b/phpBB/config.php
@@ -0,0 +1,27 @@
+
diff --git a/phpBB/db.php b/phpBB/db.php
new file mode 100644
index 0000000000..b4278d1182
--- /dev/null
+++ b/phpBB/db.php
@@ -0,0 +1,27 @@
+
diff --git a/phpBB/db/mssql.php b/phpBB/db/mssql.php
new file mode 100644
index 0000000000..0b0ce5cf8a
--- /dev/null
+++ b/phpBB/db/mssql.php
@@ -0,0 +1,208 @@
+persistency = $persistency;
+ $this->user = $sqluser;
+ $this->password = $sqlpassword;
+ $this->host = $sqlserver;
+ $this->dbname = $database;
+
+ if($this->persistency){
+ $this->db_connect_id = @mssql_pconnect($this->server,$this->user,$this->password);
+ } else {
+ $this->db_connect_id = @mssql_connect($this->server,$this->user,$this->password);
+ }
+ if($this->db_connect_id){
+ if($this->dbname != ""){
+ $dbselect = @mssql_select_db($this->dbname);
+ if(!$dbselect){
+ @mssql_close($this->db_connect_id);
+ $this->db_connect_id = $dbselect;
+ }
+ }
+ }
+ return $this->db_connect_id;
+ }
+ //
+ // Other base methods
+ //
+ function sql_setdb($database){
+ $this->dbname = $database;
+ $dbselect = @mssql_select_db($this->dbname);
+ if(!$dbselect){
+ sql_close();
+ $this->db_connect_id = $dbselect;
+ }
+ return $this->db_connect_id;
+ }
+ function sql_close(){
+ if($this->db_connect_id){
+ if($this->query_result){
+ @mssql_free_result($this->query_result);
+ }
+ $result = @mssql_close($this->db_connect_id);
+ return $result;
+ } else {
+ return false;
+ }
+ }
+
+
+ //
+ // Query method
+ //
+ function sql_query($query=""){
+ // Remove any pre-existing queries
+ unset($this->query_result);
+ unset($this->row);
+ if($query != ""){
+ // Does query contain any LIMIT code?
+ // If so pull out relevant start and num_results
+ // This isn't terribly easy with MSSQL, the best way is
+ // to use a temporary table.
+ if(eregi("LIMIT ",$query){
+ eregi("LIMIT ([0-9]+)[, ]+([0-9]+)", $query, $limits);
+ $row_offset = $limits[1];
+ if($limits[2])
+ $num_rows = $limits[2];
+ } else {
+ $this->query_result = @mssql_query($query, $this->db_connect_id);
+ }
+ return $this->query_result;
+ } else {
+ return 0;
+ }
+ }
+ //
+ // Other query methods
+ //
+ function sql_numrows(){
+ if($this->query_result){
+ $result = @mssql_num_rows($this->query_result);
+ return $result;
+ } else {
+ return false;
+ }
+ }
+ function sql_numfields(){
+ if($this->query_result){
+ $result = @mssql_num_fields($this->query_result);
+ return $result;
+ } else {
+ return false;
+ }
+ }
+ function sql_fieldname($offset){
+ if($this->query_result){
+ $result = @mssql_field_name($this->query_result, $offset);
+ return $result;
+ } else {
+ return false;
+ }
+ }
+ function sql_fieldtype($offset){
+ if($this->query_result){
+ $result = @mssql_field_type($this->query_result, $offset);
+ return $result;
+ } else {
+ return false;
+ }
+ }
+ function sql_fetchrow(){
+ if($this->query_result){
+ $this->row = @mssql_fetch_array($this->query_result);
+ return $this->row;
+ } else {
+ return false;
+ }
+ }
+ function sql_fetchrowset(){
+ if($this->query_result){
+ empty($this->rowset);
+ while($this->rowset = @mssql_fetch_array($this->query_result)){
+ $result[] = $this->rowset;
+ }
+ return $result;
+ } else {
+ return false;
+ }
+ }
+ function sql_fetchfield($field, $row=-1) {
+ if($this->query_result){
+ if($row != -1){
+ $result=@mssql_result($this->query_result, $row, $field);
+ } else {
+ if(empty($this->row))
+ $this->row = @mssql_fetch_array($this->query_result);
+ $result = $this->row[$field];
+ }
+ return $result;
+ } else {
+ return false;
+ }
+ }
+ function sql_rowseek($offset){
+ if($this->query_result){
+ $result = @mssql_data_seek($this->query_result, $rownum);
+ return $result;
+ } else {
+ return false;
+ }
+ }
+ function sql_nextid(){
+ if($this->query_result){
+ return $result;
+ } else {
+ return false;
+ }
+ }
+ function sql_freeresult(){
+ if($this->query_result){
+ @mssql_free_result($this->query_result);
+ return;
+ } else {
+ return false;
+ }
+ }
+ function sql_error(){
+ $result[message] = @mssql_get_last_message();
+ return $result;
+ }
+
+} // class sql_db
+
+} // if ... define
+
+?>
diff --git a/phpBB/db/mysql.php b/phpBB/db/mysql.php
new file mode 100644
index 0000000000..3b592f048c
--- /dev/null
+++ b/phpBB/db/mysql.php
@@ -0,0 +1,235 @@
+persistency = $persistency;
+ $this->user = $sqluser;
+ $this->password = $sqlpassword;
+ $this->host = $sqlserver;
+
+ if($this->persistency){
+ $this->db_connect_id = @mysql_pconnect($this->server, $this->user, $this->password);
+ } else {
+ $this->db_connect_id = @mysql_connect($this->server, $this->user, $this->password);
+ }
+ if($this->db_connect_id){
+ if($database != ""){
+ $this->dbname = $database;
+ $dbselect = @mysql_select_db($this->dbname);
+ if(!$dbselect){
+ mysql_close($this->db_connect_id);
+ $this->db_connect_id = $dbselect;
+ }
+ }
+ }
+ return $this->db_connect_id;
+ }
+ //
+ // Other base methods
+ //
+ function sql_setdb($database){
+ if($database != ""){
+ $this->dbname = $database;
+ $dbselect = @mysql_select_db($this->dbname);
+ if(!$dbselect){
+ sql_close();
+ $this->db_connect_id = $dbselect;
+ }
+ return $this->db_connect_id;
+ } else {
+ return false;
+ }
+ }
+ function sql_close(){
+ if($this->db_connect_id){
+ if($this->query_result){
+ @mysql_free_result($this->query_result);
+ }
+ $result = @mysql_close($this->db_connect_id);
+ return $result;
+ } else {
+ return false;
+ }
+ }
+
+ //
+ // Base query method
+ //
+ function sql_query($query=""){
+ // Remove any pre-existing queries
+ unset($this->query_result);
+ if($query != ""){
+ $this->query_result = @mysql_query($query, $this->db_connect_id);
+ }
+ if($this->query_result){
+ unset($this->row[$this->query_result]);
+ unset($this->rowset[$this->query_result]);
+ return $this->query_result;
+ } else {
+ return false;
+ }
+ }
+ //
+ // Other query methods
+ //
+ function sql_numrows($query_id = 0){
+ if(!$query_id)
+ $query_id = $this->query_result;
+ if($query_id){
+ $result = @mysql_num_rows($query_id);
+ return $result;
+ } else {
+ return false;
+ }
+ }
+ function sql_numfields($query_id = 0){
+ if(!$query_id)
+ $query_id = $this->query_result;
+ if($query_id){
+ $result = @mysql_num_fields($query_id);
+ return $result;
+ } else {
+ return false;
+ }
+ }
+ function sql_fieldname($offset, $query_id = 0){
+ if(!$query_id)
+ $query_id = $this->query_result;
+ if($query_id){
+ $result = @mysql_field_name($query_id, $offset);
+ return $result;
+ } else {
+ return false;
+ }
+ }
+ function sql_fieldtype($offset, $query_id = 0){
+ if(!$query_id)
+ $query_id = $this->query_result;
+ if($query_id){
+ $result = @mysql_field_type($query_id, $offset);
+ return $result;
+ } else {
+ return false;
+ }
+ }
+ function sql_fetchrow($query_id = 0){
+ if(!$query_id)
+ $query_id = $this->query_result;
+ if($query_id){
+ $this->row[$query_id] = @mysql_fetch_array($query_id);
+ return $this->row[$query_id];
+ } else {
+ return false;
+ }
+ }
+ function sql_fetchrowset($query_id = 0){
+ if(!$query_id)
+ $query_id = $this->query_result;
+ if($query_id){
+ unset($this->rowset[$query_id]);
+ unset($this->row[$query_id]);
+ while($this->rowset[$query_id] = @mysql_fetch_array($query_id)){
+ $result[] = $this->rowset[$query_id];
+ }
+ return $result;
+ } else {
+ return false;
+ }
+ }
+ function sql_fetchfield($field, $rownum=-1, $query_id = 0) {
+ if(!$query_id)
+ $query_id = $this->query_result;
+ if($query_id){
+ if($rownum > -1){
+ $result = @mysql_result($query_id, $rownum, $field);
+ } else {
+ if(empty($this->row[$query_id]) && empty($this->rowset[$query_id])){
+ if($this->sql_fetchrow())
+ $result = $this->row[$query_id][$field];
+ } else {
+ if($this->rowset[$query_id]){
+ $result = $this->rowset[$query_id][$field];
+ } else if($this->row[$query_id]){
+ $result = $this->row[$query_id][$field];
+ }
+ }
+ }
+ return $result;
+ } else {
+ return false;
+ }
+ }
+ function sql_rowseek($rownum, $query_id = 0){
+ if(!$query_id)
+ $query_id = $this->query_result;
+ if($query_id){
+ $result = @mysql_data_seek($query_id, $rownum);
+ return $result;
+ } else {
+ return false;
+ }
+ }
+ function sql_nextid(){
+ if($this->db_connection_id){
+ $result = @mysql_insert_id();
+ return $result;
+ } else {
+ return false;
+ }
+ }
+ function sql_freeresult($query_id = 0){
+ if(!$query_id)
+ $query_id = $this->query_result;
+ if($query_id){
+ $result = @mysql_free_result($query_id);
+ return $result;
+ } else {
+ return false;
+ }
+ }
+ function sql_error($query_id = 0){
+ if(!$query_id)
+ $query_id = $this->query_result;
+ $result[message] = @mysql_error($query_id);
+ $result[code] = @mysql_errno($query_id);
+
+ return $result;
+ }
+
+} // class sql_db
+
+} // if ... define
+
+?>
diff --git a/phpBB/db/postgres7.php b/phpBB/db/postgres7.php
new file mode 100644
index 0000000000..a2a848204a
--- /dev/null
+++ b/phpBB/db/postgres7.php
@@ -0,0 +1,278 @@
+connect_string = "";
+ if($sqluser){
+ $this->connect_string .= "user=$sqluser ";
+ }
+ if($sqlpassword){
+ $this->connect_string .= "password=$sqlpassword ";
+ }
+ if($sqlserver){
+ if(ereg(":",$sqlserver)){
+ list($sqlserver,$sqlport) = split(":",$sqlserver);
+ $this->connect_string .= "host=$sqlserver port=$sqlport ";
+ } else {
+ $this->connect_string .= "host=$sqlserver ";
+ }
+ }
+ if($database){
+ $this->dbname = $database;
+ $make_connect = $this->connect_string . "dbname=$database";
+ } else {
+ $make_connect = $this->connect_string;
+ }
+ $this->persistency = $persistency;
+
+ if($this->persistency){
+ $this->db_connect_id = @pg_pconnect($make_connect);
+ } else {
+ $this->db_connect_id = @pg_connect($make_connect);
+ }
+ return $this->db_connect_id;
+ }
+ //
+ // Other base methods
+ //
+ function sql_setdb($database){
+ if($this->db_connect_id){
+ if($this->query_result){
+ @pg_freeresult($this->query_result);
+ unset($this->query_result);
+ unset($this->row);
+ }
+ $result = @pg_close($this->db_connect_id);
+ if($result){
+ $this->dbname = $database;
+ $make_connect = $this->connect_string . "dbname=$database";
+ if($this->persistency){
+ $this->db_connect_id = @pg_pconnect($make_connect);
+ } else {
+ $this->db_connect_id = @pg_connect($make_connect);
+ }
+ }
+ }
+ return $this->db_connect_id;
+ }
+ function sql_close(){
+ if($this->db_connect_id){
+ if($this->query_result){
+ @pg_freeresult($this->query_result);
+ }
+ $result = @pg_close($this->db_connect_id);
+ return $result;
+ } else {
+ return false;
+ }
+ }
+
+
+ //
+ // Query method
+ //
+ function sql_query($query=""){
+ // Remove any pre-existing queries
+ unset($this->query_result);
+ if($query != ""){
+ $this->query_result = @pg_exec($this->db_connect_id, $query);
+ if($this->query_result){
+
+ $this->last_query_text[$this->query_result] = $query;
+ $this->rownum[$this->query_result] = 0;
+ unset($this->row[$this->query_result]);
+ unset($this->rowset[$this->query_result]);
+
+ return $this->query_result;
+ } else {
+ return false;
+ }
+ } else {
+ return 0;
+ }
+ }
+ //
+ // Other query methods
+ //
+ function sql_numrows($query_id = 0){
+ if(!$query_id)
+ $query_id = $this->query_result;
+ if($query_id){
+ $result = @pg_numrows($query_id);
+ return $result;
+ } else {
+ return false;
+ }
+ }
+ function sql_numfields($query_id = 0){
+ if(!$query_id)
+ $query_id = $this->query_result;
+ if($query_id){
+ $result = @pg_numfields($query_id);
+ return $result;
+ } else {
+ return false;
+ }
+ }
+ function sql_fieldname($offset, $query_id = 0){
+ if(!$query_id)
+ $query_id = $this->query_result;
+ if($query_id){
+ $result = @pg_fieldname($query_id, $offset);
+ return $result;
+ } else {
+ return false;
+ }
+ }
+ function sql_fieldtype($offset, $query_id = 0){
+ if(!$query_id)
+ $query_id = $this->query_result;
+ if($query_id){
+ $result = @pg_fieldtype($query_id, $offset);
+ return $result;
+ } else {
+ return false;
+ }
+ }
+ function sql_fetchrow($query_id = 0){
+ if(!$query_id)
+ $query_id = $this->query_result;
+ if($query_id){
+ $this->row = @pg_fetch_array($query_id, $this->rownum[$query_id]);
+ if($this->row)
+ $this->rownum[$query_id]++;
+ return $this->row;
+ } else {
+ return false;
+ }
+ }
+ function sql_fetchrowset($query_id = 0){
+ if(!$query_id)
+ $query_id = $this->query_result;
+ if($query_id){
+ unset($this->rowset[$query_id]);
+ unset($this->row[$query_id]);
+ $this->rownum[$query_id] = 0;
+ while($this->rowset = @pg_fetch_array($query_id, $this->rownum[$query_id])){
+ $result[] = $this->rowset;
+ $this->rownum[$query_id]++;
+ }
+ return $result;
+ } else {
+ return false;
+ }
+ }
+ function sql_fetchfield($field, $row_offset=-1, $query_id = 0) {
+ if(!$query_id)
+ $query_id = $this->query_result;
+ if($query_id){
+ if($row_offset != -1){
+ $this->row = @pg_fetch_array($query_id, $row_offset);
+ } else {
+ if($this->rownum[$query_id]){
+ $this->row = @pg_fetch_array($query_id, $this->rownum[$query_id]-1);
+ } else {
+ $this->row = @pg_fetch_array($query_id, $this->rownum[$query_id]);
+ if($this->row)
+ $this->rownum[$query_id]++;
+ }
+ }
+ $result = $this->row[$field];
+ return $result;
+ } else {
+ return false;
+ }
+ }
+ function sql_rowseek($offset, $query_id = 0){
+ if(!$query_id)
+ $query_id = $this->query_result;
+ if($query_id){
+ if($offset>-1){
+ $this->rownum[$query_id] = $offset;
+ return true;
+ } else {
+ return false;
+ }
+ } else {
+ return false;
+ }
+ }
+ function sql_nextid($query_id = 0){
+ if(!$query_id)
+ $query_id = $this->query_result;
+ if($query_id && $this->last_query_text[$query_id] != ""){
+ if(eregi("^(INSERT{1}|^INSERT INTO{1})[[:space:]][\"]?([[:alnum:]]+)[\"]?", $this->last_query_text[$query_id], $tablename);
+ $query = "SELECT last_value FROM ".$tablename[2]."_id_seq";
+ $temp_q_id = @pg_exec($this->db_connect_id, $query);
+ if($query_id){
+ $temp_result = @pg_fetch_array($temp_q_id, 0);
+ if($temp_result){
+ return $temp_result["last_value"]+1;
+ } else {
+ return false;
+ }
+ } else {
+ return false;
+ }
+ } else {
+ return false;
+ }
+ } else {
+ return false;
+ }
+ }
+ function sql_freeresult($query_id = 0){
+ if(!$query_id)
+ $query_id = $this->query_result;
+ if($query_id){
+ $result = @pg_freeresult($query_id);
+ return $result;
+ } else {
+ return false;
+ }
+ }
+ function sql_error($query_id = 0){
+ if(!$query_id)
+ $query_id = $this->query_result;
+ $result[message] = @pg_errormessage($query_id);
+ $result[code] = -1;
+ return $result;
+ }
+
+} // class ... db_sql
+
+} // if ... defined
+
+?>
diff --git a/phpBB/functions/auth.php b/phpBB/functions/auth.php
new file mode 100644
index 0000000000..b4278d1182
--- /dev/null
+++ b/phpBB/functions/auth.php
@@ -0,0 +1,27 @@
+
diff --git a/phpBB/functions/bbcode.php b/phpBB/functions/bbcode.php
new file mode 100644
index 0000000000..112c8763c6
--- /dev/null
+++ b/phpBB/functions/bbcode.php
@@ -0,0 +1,1038 @@
+', $text);
+ // li tags
+ $text = str_replace("[*:$uid]", '
', $text);
+ // ending tags
+ $text = str_replace("[/list:u:$uid]", '', $text);
+ $text = str_replace("[/list:o:$uid]", '', $text);
+ // Ordered lists
+ $text = preg_replace("/\[list=([a1]):$uid\]/si", '', $text);
+
+ // [QUOTE] and [/QUOTE] for posting replies with quote, or just for quoting stuff.
+ $text = str_replace("[quote:$uid]", 'Quote:
|
', $text);
+ $text = str_replace("[/quote:$uid]", ' |
|
', $text);
+
+ // [b] and [/b] for bolding text.
+ $text = str_replace("[b:$uid]", '', $text);
+ $text = str_replace("[/b:$uid]", '', $text);
+
+ // [i] and [/i] for italicizing text.
+ $text = str_replace("[i:$uid]", '', $text);
+ $text = str_replace("[/i:$uid]", '', $text);
+
+ // [img]image_url_here[/img] code..
+ $text = str_replace("[img:$uid]", '
', $text);
+
+ // Patterns and replacements for URL and email tags..
+ $patterns = array();
+ $replacements = array();
+
+ // [url]xxxx://www.phpbb.com[/url] code..
+ $patterns[0] = "#\[url\]([a-z]+?://){1}(.*?)\[/url\]#si";
+ $replacements[0] = '\1\2';
+
+ // [url]www.phpbb.com[/url] code.. (no xxxx:// prefix).
+ $patterns[1] = "#\[url\](.*?)\[/url\]#si";
+ $replacements[1] = '\1';
+
+ // [url=xxxx://www.phpbb.com]phpBB[/url] code..
+ $patterns[2] = "#\[url=([a-z]+?://){1}(.*?)\](.*?)\[/url\]#si";
+ $replacements[2] = '\3';
+
+ // [url=www.phpbb.com]phpBB[/url] code.. (no xxxx:// prefix).
+ $patterns[3] = "#\[url=(.*?)\](.*?)\[/url\]#si";
+ $replacements[3] = '\2';
+
+ // [email]user@domain.tld[/email] code..
+ $patterns[4] = "#\[email\](.*?)\[/email\]#si";
+ $replacements[4] = '\1';
+
+ $text = preg_replace($patterns, $replacements, $text);
+
+ // Remove our padding from the string..
+ $text = substr($text, 1);
+
+ return TRUE;
+}
+
+
+
+function bbencode_first_pass($text)
+{
+ // Unique ID for this message..
+ $uid = md5(uniqid(rand()));
+ $uid = substr($uid, 0, BBCODE_UID_LEN);
+
+ echo "UID LENGTH: " . strlen($uid) . "
";
+
+ // pad it with a space so we can distinguish between FALSE and matching the 1st char (index 0).
+ // This is important; bbencode_quote(), bbencode_list(), and bbencode_code() all depend on it.
+ $text = " " . $text;
+
+ // [CODE] and [/CODE] for posting code (HTML, PHP, C etc etc) in your posts.
+ $max_code_nesting = bbencode_first_pass_code($text, $uid);
+
+ // [QUOTE] and [/QUOTE] for posting replies with quote, or just for quoting stuff.
+ bbencode_first_pass_quote($text, $uid);
+
+ // [list] and [list=x] for (un)ordered lists.
+ bbencode_first_pass_list($text, $uid);
+
+ // [b] and [/b] for bolding text.
+ $text = preg_replace("#\[b\](.*?)\[/b\]#si", "[b:$uid]\\1[/b:$uid]", $text);
+
+ // [i] and [/i] for italicizing text.
+ $text = preg_replace("#\[i\](.*?)\[/i\]#si", "[i:$uid]\\1[/i:$uid]", $text);
+
+ // [img]image_url_here[/img] code..
+ $text = preg_replace("#\[img\](.*?)\[/img\]#si", "[img:$uid]\\1[/img:$uid]", $text);
+
+ // Remove our padding from the string..
+ $text = substr($text, 1);
+
+ // Add the uid tag to the start of the string..
+ $text = '[uid=' . $uid . ':' . $max_code_nesting . ']' . $text;
+
+ return $text;
+
+} // bbencode_first_pass()
+
+
+/**
+ * Nathan Codding - Feb. 14, 2001.
+ * Performs [quote][/quote] bbencoding on the given string.
+ * Any unmatched "[quote]" or "[/quote]" token will just be left alone.
+ * This works fine with both having more than one quote in a message, and with nested quotes.
+ * Since that is not a regular language, this is actually a PDA and uses a stack. Great fun.
+ *
+ * Note: This function assumes the first character of $text is a space, which is added by
+ * bbencode().
+ */
+function bbencode_first_pass_quote(&$text, $uid)
+{
+ // First things first: If there aren't any "[quote]" strings in the message, we don't
+ // need to process it at all.
+
+ if (!strpos(strtolower($text), "[quote]"))
+ {
+ return TRUE;
+ }
+
+ $stack = Array();
+ $curr_pos = 1;
+ while ($curr_pos && ($curr_pos < strlen($text)))
+ {
+ $curr_pos = strpos($text, "[", $curr_pos);
+
+ // If not found, $curr_pos will be 0, and the loop will end.
+ if ($curr_pos)
+ {
+ // We found a [. It starts at $curr_pos.
+ // check if it's a starting or ending quote tag.
+ $possible_start = substr($text, $curr_pos, 7);
+ $possible_end = substr($text, $curr_pos, 8);
+ if (strcasecmp("[quote]", $possible_start) == 0)
+ {
+ // We have a starting quote tag.
+ // Push its position on to the stack, and then keep going to the right.
+ bbcode_array_push($stack, $curr_pos);
+ ++$curr_pos;
+ }
+ else if (strcasecmp("[/quote]", $possible_end) == 0)
+ {
+ // We have an ending quote tag.
+ // Check if we've already found a matching starting tag.
+ if (sizeof($stack) > 0)
+ {
+ // There exists a starting tag.
+ // We need to do 2 replacements now.
+ $start_index = bbcode_array_pop($stack);
+
+ // everything before the [quote] tag.
+ $before_start_tag = substr($text, 0, $start_index);
+
+ // everything after the [quote] tag, but before the [/quote] tag.
+ $between_tags = substr($text, $start_index + 7, $curr_pos - $start_index - 7);
+
+ // everything after the [/quote] tag.
+ $after_end_tag = substr($text, $curr_pos + 8);
+
+ $text = $before_start_tag . "[quote:$uid]";
+ $text .= $between_tags . "[/quote:$uid]";
+ $text .= $after_end_tag;
+
+ // Now.. we've screwed up the indices by changing the length of the string.
+ // So, if there's anything in the stack, we want to resume searching just after it.
+ // otherwise, we go back to the start.
+ if (sizeof($stack) > 0)
+ {
+ $curr_pos = array_pop($stack);
+ bbcode_array_push($stack, $curr_pos);
+ ++$curr_pos;
+ }
+ else
+ {
+ $curr_pos = 1;
+ }
+ }
+ else
+ {
+ // No matching start tag found. Increment pos, keep going.
+ ++$curr_pos;
+ }
+ }
+ else
+ {
+ // No starting tag or ending tag.. Increment pos, keep looping.,
+ ++$curr_pos;
+ }
+ }
+ } // while
+
+ return TRUE;
+
+} // bbencode_first_pass_quote()
+
+
+/**
+ * Nathan Codding - Feb. 14, 2001.
+ * Performs [code][/code] bbencoding on the given string.
+ * Any unmatched "[code]" or "[/code]" token will just be left alone.
+ * This works fine with both having more than one code block in a message, and with nested code blocks.
+ * Since that is not a regular language, this is actually a PDA and uses a stack. Great fun.
+ *
+ * Note: This function assumes the first character of $message is a space, which is added by
+ * bbencode().
+ */
+function bbencode_first_pass_code(&$text, $uid)
+{
+ // First things first: If there aren't any "[code]" strings in the message, we don't
+ // need to process it at all.
+ if (!strpos(strtolower($text), "[code]"))
+ {
+ return 0;
+ }
+
+ // Second things second: we have to watch out for stuff like [1code] or [/code1] in the
+ // input.. So escape them to [#1code] or [/code#1] for now:
+ $temp_uid = md5(uniqid(rand()));
+
+ $text = preg_replace("#\[([0-9]+?)code\]#si", "[$temp_uid:\\1code]", $text);
+ $text = preg_replace("#\[/code([0-9]+?)\]#si", "[/code$temp_uid:\\1]", $text);
+
+ $stack = Array();
+ $curr_pos = 1;
+ $max_nesting_depth = 0;
+ while ($curr_pos && ($curr_pos < strlen($text)))
+ {
+ $curr_pos = strpos($text, "[", $curr_pos);
+
+ // If not found, $curr_pos will be 0, and the loop will end.
+ if ($curr_pos)
+ {
+ // We found a [. It starts at $curr_pos.
+ // check if it's a starting or ending code tag.
+ $possible_start = substr($text, $curr_pos, 6);
+ $possible_end = substr($text, $curr_pos, 7);
+ if (strcasecmp("[code]", $possible_start) == 0)
+ {
+ // We have a starting code tag.
+ // Push its position on to the stack, and then keep going to the right.
+ bbcode_array_push($stack, $curr_pos);
+ ++$curr_pos;
+ }
+ else if (strcasecmp("[/code]", $possible_end) == 0)
+ {
+ // We have an ending code tag.
+ // Check if we've already found a matching starting tag.
+ if (sizeof($stack) > 0)
+ {
+ // There exists a starting tag.
+ $curr_nesting_depth = sizeof($stack);
+ $max_nesting_depth = ($curr_nesting_depth > $max_nesting_depth) ? $curr_nesting_depth : $max_nesting_depth;
+
+ // We need to do 2 replacements now.
+ $start_index = bbcode_array_pop($stack);
+
+ // everything before the [code] tag.
+ $before_start_tag = substr($text, 0, $start_index);
+
+ // everything after the [code] tag, but before the [/code] tag.
+ $between_tags = substr($text, $start_index + 6, $curr_pos - $start_index - 6);
+
+ // everything after the [/code] tag.
+ $after_end_tag = substr($text, $curr_pos + 7);
+
+ $text = $before_start_tag . '[code:' . $curr_nesting_depth . ':' . $uid . ']';
+ $text .= $between_tags . '[/code:' . $curr_nesting_depth . ':' . $uid . ']';
+ $text .= $after_end_tag;
+
+ // Now.. we've screwed up the indices by changing the length of the string.
+ // So, if there's anything in the stack, we want to resume searching just after it.
+ // otherwise, we go back to the start.
+ if (sizeof($stack) > 0)
+ {
+ $curr_pos = bbcode_array_pop($stack);
+ bbcode_array_push($stack, $curr_pos);
+ ++$curr_pos;
+ }
+ else
+ {
+ $curr_pos = 1;
+ }
+ }
+ else
+ {
+ // No matching start tag found. Increment pos, keep going.
+ ++$curr_pos;
+ }
+ }
+ else
+ {
+ // No starting tag or ending tag.. Increment pos, keep looping.,
+ ++$curr_pos;
+ }
+ }
+ } // while
+
+ // Undo our escaping from "second things second" above..
+ $text = preg_replace("#\[$temp_uid:([0-9]+?)code\]#si", "[\\1code]", $text);
+ $text = preg_replace("#\[/code$temp_uid:([0-9]+?)\]#si", "[/code\\1]", $text);
+
+ return $max_nesting_depth;
+
+} // bbencode_first_pass_code()
+
+
+
+function bbencode_second_pass_code(&$text, $uid, $max_nesting_depth)
+{
+ for ($i = 1; $i <= $max_nesting_depth; ++$i)
+ {
+ $match_count = preg_match_all("#\[code:$i:$uid\](.*?)\[/code:$i:$uid\]#si", $text, $matches);
+
+ for ($j = 0; $j < $match_count; $j++)
+ {
+ $before_replace = $matches[1][$j];
+ $after_replace = $matches[1][$j];
+
+ if ($i < 2)
+ {
+ // don't escape special chars when we're nested, 'cause it was already done
+ // at the lower level..
+ $after_replace = htmlspecialchars($after_replace);
+ }
+
+ $str_to_match = "[code:$i:$uid]" . $before_replace . "[/code:$i:$uid]";
+
+ $replacement = 'Code:
|
';
+ $replacement .= $after_replace;
+ $replacement .= ' |
|
';
+
+ $text = str_replace($str_to_match, $replacement, $text);
+
+ }
+ }
+
+} // bbencode_second_pass_code()
+
+
+
+/**
+ * Nathan Codding - Jan. 12, 2001.
+ * Performs [list][/list] and [list=?][/list] bbencoding on the given string, and returns the results.
+ * Any unmatched "[list]" or "[/list]" token will just be left alone.
+ * This works fine with both having more than one list in a message, and with nested lists.
+ * Since that is not a regular language, this is actually a PDA and uses a stack. Great fun.
+ *
+ * Note: This function assumes the first character of $message is a space, which is added by
+ * bbencode().
+ */
+function bbencode_first_pass_list(&$text, $uid)
+{
+ $start_length = Array();
+ $start_length['ordered'] = 8;
+ $start_length['unordered'] = 6;
+
+ // First things first: If there aren't any "[list" strings in the message, we don't
+ // need to process it at all.
+
+ if (!strpos(strtolower($text), "[list"))
+ {
+ return TRUE;
+ }
+
+ $stack = Array();
+ $curr_pos = 1;
+ while ($curr_pos && ($curr_pos < strlen($text)))
+ {
+ $curr_pos = strpos($text, "[", $curr_pos);
+
+ // If not found, $curr_pos will be 0, and the loop will end.
+ if ($curr_pos)
+ {
+ // We found a [. It starts at $curr_pos.
+ // check if it's a starting or ending list tag.
+ $possible_ordered_start = substr($text, $curr_pos, $start_length[ordered]);
+ $possible_unordered_start = substr($text, $curr_pos, $start_length[unordered]);
+ $possible_end = substr($text, $curr_pos, 7);
+ if (strcasecmp("[list]", $possible_unordered_start) == 0)
+ {
+ // We have a starting unordered list tag.
+ // Push its position on to the stack, and then keep going to the right.
+ bbcode_array_push($stack, array($curr_pos, ""));
+ ++$curr_pos;
+ }
+ else if (preg_match("/\[list=([a1])\]/si", $possible_ordered_start, $matches))
+ {
+ // We have a starting ordered list tag.
+ // Push its position on to the stack, and the starting char onto the start
+ // char stack, the keep going to the right.
+ bbcode_array_push($stack, array($curr_pos, $matches[1]));
+ ++$curr_pos;
+ }
+ else if (strcasecmp("[/list]", $possible_end) == 0)
+ {
+ // We have an ending list tag.
+ // Check if we've already found a matching starting tag.
+ if (sizeof($stack) > 0)
+ {
+ // There exists a starting tag.
+ // We need to do 2 replacements now.
+ $start = bbcode_array_pop($stack);
+ $start_index = $start[0];
+ $start_char = $start[1];
+ $is_ordered = ($start_char != "");
+ $start_tag_length = ($is_ordered) ? $start_length[ordered] : $start_length[unordered];
+
+ // everything before the [list] tag.
+ $before_start_tag = substr($text, 0, $start_index);
+
+ // everything after the [list] tag, but before the [/list] tag.
+ $between_tags = substr($text, $start_index + $start_tag_length, $curr_pos - $start_index - $start_tag_length);
+ // Need to replace [*] with - inside the list.
+ $between_tags = str_replace('[*]', "[*:$uid]", $between_tags);
+
+ // everything after the [/list] tag.
+ $after_end_tag = substr($text, $curr_pos + 7);
+
+ if ($is_ordered)
+ {
+ $text = $before_start_tag . '[list=' . $start_char . ':' . $uid . ']';
+ $text .= $between_tags . '[/list:o:' . $uid . ']';
+ }
+ else
+ {
+ $text = $before_start_tag . '[list:' . $uid . ']';
+ $text .= $between_tags . '[/list:u:' . $uid . ']';
+ }
+
+ $text .= $after_end_tag;
+
+ // Now.. we've screwed up the indices by changing the length of the string.
+ // So, if there's anything in the stack, we want to resume searching just after it.
+ // otherwise, we go back to the start.
+ if (sizeof($stack) > 0)
+ {
+ $a = bbcode_array_pop($stack);
+ $curr_pos = $a[0];
+ bbcode_array_push($stack, $a);
+ ++$curr_pos;
+ }
+ else
+ {
+ $curr_pos = 1;
+ }
+ }
+ else
+ {
+ // No matching start tag found. Increment pos, keep going.
+ ++$curr_pos;
+ }
+ }
+ else
+ {
+ // No starting tag or ending tag.. Increment pos, keep looping.,
+ ++$curr_pos;
+ }
+ }
+ } // while
+
+ return TRUE;
+
+} // bbencode_first_pass_list()
+
+
+
+
+// END new 2-pass functions.
+
+
+
+
+/**
+ * bbdecode/bbencode functions:
+ * Rewritten - Nathan Codding - Aug 24, 2000
+ * quote, code, and list rewritten again in Jan. 2001.
+ * All BBCode tags now implemented. Nesting and multiple occurances should be
+ * handled fine for all of them. Using str_replace() instead of regexps often
+ * for efficiency. quote, list, and code are not regular, so they are
+ * implemented as PDAs - probably not all that efficient, but that's the way it is.
+ *
+ * Note: all BBCode tags are case-insensitive.
+ */
+function bbdecode($message) {
+
+ // Undo [code]
+ $code_start_html = "
Code:
|
";
+ $code_end_html = " |
|
";
+ $message = str_replace($code_start_html, "[code]", $message);
+ $message = str_replace($code_end_html, "[/code]", $message);
+
+ // Undo [quote]
+ $quote_start_html = "Quote:
|
";
+ $quote_end_html = " |
|
";
+ $message = str_replace($quote_start_html, "[quote]", $message);
+ $message = str_replace($quote_end_html, "[/quote]", $message);
+
+ // Undo [b] and [i]
+ $message = preg_replace("#(.*?)#s", "[b]\\1[/b]", $message);
+ $message = preg_replace("#(.*?)#s", "[i]\\1[/i]", $message);
+
+ // Undo [url] (both forms)
+ $message = preg_replace("#(.*?)#s", "[url=\\1\\2]\\3[/url]", $message);
+
+ // Undo [email]
+ $message = preg_replace("#(.*?)#s", "[email]\\1[/email]", $message);
+
+ // Undo [img]
+ $message = preg_replace("#
#s", "[img]\\1[/img]", $message);
+
+ // Undo lists (unordered/ordered)
+
+ // - tags:
+ $message = str_replace("
- ", "[*]", $message);
+
+ // [list] tags:
+ $message = str_replace("
", "[list]", $message);
+
+ // [list=x] tags:
+ $message = preg_replace("##si", "[list=\\1]", $message);
+
+ // [/list] tags:
+ $message = str_replace("
", "[/list]", $message);
+ $message = str_replace("
", "[/list]", $message);
+
+ return($message);
+}
+
+/**
+ * Nathan Codding - Jan. 12, 2001.
+ * Performs [quote][/quote] bbencoding on the given string, and returns the results.
+ * Any unmatched "[quote]" or "[/quote]" token will just be left alone.
+ * This works fine with both having more than one quote in a message, and with nested quotes.
+ * Since that is not a regular language, this is actually a PDA and uses a stack. Great fun.
+ *
+ * Note: This function assumes the first character of $message is a space, which is added by
+ * bbencode().
+ */
+function bbencode_quote($message)
+{
+ // First things first: If there aren't any "[quote]" strings in the message, we don't
+ // need to process it at all.
+
+ if (!strpos(strtolower($message), "[quote]"))
+ {
+ return $message;
+ }
+
+ $stack = Array();
+ $curr_pos = 1;
+ while ($curr_pos && ($curr_pos < strlen($message)))
+ {
+ $curr_pos = strpos($message, "[", $curr_pos);
+
+ // If not found, $curr_pos will be 0, and the loop will end.
+ if ($curr_pos)
+ {
+ // We found a [. It starts at $curr_pos.
+ // check if it's a starting or ending quote tag.
+ $possible_start = substr($message, $curr_pos, 7);
+ $possible_end = substr($message, $curr_pos, 8);
+ if (strcasecmp("[quote]", $possible_start) == 0)
+ {
+ // We have a starting quote tag.
+ // Push its position on to the stack, and then keep going to the right.
+ bbcode_array_push($stack, $curr_pos);
+ ++$curr_pos;
+ }
+ else if (strcasecmp("[/quote]", $possible_end) == 0)
+ {
+ // We have an ending quote tag.
+ // Check if we've already found a matching starting tag.
+ if (sizeof($stack) > 0)
+ {
+ // There exists a starting tag.
+ // We need to do 2 replacements now.
+ $start_index = bbcode_array_pop($stack);
+
+ // everything before the [quote] tag.
+ $before_start_tag = substr($message, 0, $start_index);
+
+ // everything after the [quote] tag, but before the [/quote] tag.
+ $between_tags = substr($message, $start_index + 7, $curr_pos - $start_index - 7);
+
+ // everything after the [/quote] tag.
+ $after_end_tag = substr($message, $curr_pos + 8);
+
+ $message = $before_start_tag . "Quote:
|
";
+ $message .= $between_tags . " |
|
";
+ $message .= $after_end_tag;
+
+ // Now.. we've screwed up the indices by changing the length of the string.
+ // So, if there's anything in the stack, we want to resume searching just after it.
+ // otherwise, we go back to the start.
+ if (sizeof($stack) > 0)
+ {
+ $curr_pos = array_pop($stack);
+ bbcode_array_push($stack, $curr_pos);
+ ++$curr_pos;
+ }
+ else
+ {
+ $curr_pos = 1;
+ }
+ }
+ else
+ {
+ // No matching start tag found. Increment pos, keep going.
+ ++$curr_pos;
+ }
+ }
+ else
+ {
+ // No starting tag or ending tag.. Increment pos, keep looping.,
+ ++$curr_pos;
+ }
+ }
+ } // while
+
+ return $message;
+
+} // bbencode_quote()
+
+
+/**
+ * Nathan Codding - Jan. 12, 2001.
+ * Performs [code][/code] bbencoding on the given string, and returns the results.
+ * Any unmatched "[code]" or "[/code]" token will just be left alone.
+ * This works fine with both having more than one code block in a message, and with nested code blocks.
+ * Since that is not a regular language, this is actually a PDA and uses a stack. Great fun.
+ *
+ * Note: This function assumes the first character of $message is a space, which is added by
+ * bbencode().
+ */
+function bbencode_code($message)
+{
+ // First things first: If there aren't any "[code]" strings in the message, we don't
+ // need to process it at all.
+ if (!strpos(strtolower($message), "[code]"))
+ {
+ return $message;
+ }
+
+ // Second things second: we have to watch out for stuff like [1code] or [/code1] in the
+ // input.. So escape them to [#1code] or [/code#1] for now:
+ $message = preg_replace("/\[([0-9]+?)code\]/si", "[#\\1code]", $message);
+ $message = preg_replace("/\[\/code([0-9]+?)\]/si", "[/code#\\1]", $message);
+
+ $stack = Array();
+ $curr_pos = 1;
+ $max_nesting_depth = 0;
+ while ($curr_pos && ($curr_pos < strlen($message)))
+ {
+ $curr_pos = strpos($message, "[", $curr_pos);
+
+ // If not found, $curr_pos will be 0, and the loop will end.
+ if ($curr_pos)
+ {
+ // We found a [. It starts at $curr_pos.
+ // check if it's a starting or ending code tag.
+ $possible_start = substr($message, $curr_pos, 6);
+ $possible_end = substr($message, $curr_pos, 7);
+ if (strcasecmp("[code]", $possible_start) == 0)
+ {
+ // We have a starting code tag.
+ // Push its position on to the stack, and then keep going to the right.
+ bbcode_array_push($stack, $curr_pos);
+ ++$curr_pos;
+ }
+ else if (strcasecmp("[/code]", $possible_end) == 0)
+ {
+ // We have an ending code tag.
+ // Check if we've already found a matching starting tag.
+ if (sizeof($stack) > 0)
+ {
+ // There exists a starting tag.
+ $curr_nesting_depth = sizeof($stack);
+ $max_nesting_depth = ($curr_nesting_depth > $max_nesting_depth) ? $curr_nesting_depth : $max_nesting_depth;
+
+ // We need to do 2 replacements now.
+ $start_index = bbcode_array_pop($stack);
+
+ // everything before the [code] tag.
+ $before_start_tag = substr($message, 0, $start_index);
+
+ // everything after the [code] tag, but before the [/code] tag.
+ $between_tags = substr($message, $start_index + 6, $curr_pos - $start_index - 6);
+
+ // everything after the [/code] tag.
+ $after_end_tag = substr($message, $curr_pos + 7);
+
+ $message = $before_start_tag . "[" . $curr_nesting_depth . "code]";
+ $message .= $between_tags . "[/code" . $curr_nesting_depth . "]";
+ $message .= $after_end_tag;
+
+ // Now.. we've screwed up the indices by changing the length of the string.
+ // So, if there's anything in the stack, we want to resume searching just after it.
+ // otherwise, we go back to the start.
+ if (sizeof($stack) > 0)
+ {
+ $curr_pos = bbcode_array_pop($stack);
+ bbcode_array_push($stack, $curr_pos);
+ ++$curr_pos;
+ }
+ else
+ {
+ $curr_pos = 1;
+ }
+ }
+ else
+ {
+ // No matching start tag found. Increment pos, keep going.
+ ++$curr_pos;
+ }
+ }
+ else
+ {
+ // No starting tag or ending tag.. Increment pos, keep looping.,
+ ++$curr_pos;
+ }
+ }
+ } // while
+
+ if ($max_nesting_depth > 0)
+ {
+ for ($i = 1; $i <= $max_nesting_depth; ++$i)
+ {
+ $start_tag = escape_slashes(preg_quote("[" . $i . "code]"));
+ $end_tag = escape_slashes(preg_quote("[/code" . $i . "]"));
+
+ $match_count = preg_match_all("/$start_tag(.*?)$end_tag/si", $message, $matches);
+
+ for ($j = 0; $j < $match_count; $j++)
+ {
+ $before_replace = escape_slashes(preg_quote($matches[1][$j]));
+ $after_replace = $matches[1][$j];
+
+ if ($i < 2)
+ {
+ // don't escape special chars when we're nested, 'cause it was already done
+ // at the lower level..
+ $after_replace = htmlspecialchars($after_replace);
+ }
+
+ $str_to_match = $start_tag . $before_replace . $end_tag;
+
+ $message = preg_replace("/$str_to_match/si", "", $message);
+ }
+ }
+ }
+
+ // Undo our escaping from "second things second" above..
+ $message = preg_replace("/\[#([0-9]+?)code\]/si", "[\\1code]", $message);
+ $message = preg_replace("/\[\/code#([0-9]+?)\]/si", "[/code\\1]", $message);
+
+ return $message;
+
+} // bbencode_code()
+
+
+/**
+ * Nathan Codding - Jan. 12, 2001.
+ * Performs [list][/list] and [list=?][/list] bbencoding on the given string, and returns the results.
+ * Any unmatched "[list]" or "[/list]" token will just be left alone.
+ * This works fine with both having more than one list in a message, and with nested lists.
+ * Since that is not a regular language, this is actually a PDA and uses a stack. Great fun.
+ *
+ * Note: This function assumes the first character of $message is a space, which is added by
+ * bbencode().
+ */
+function bbencode_list($message)
+{
+ $start_length = Array();
+ $start_length[ordered] = 8;
+ $start_length[unordered] = 6;
+
+ // First things first: If there aren't any "[list" strings in the message, we don't
+ // need to process it at all.
+
+ if (!strpos(strtolower($message), "[list"))
+ {
+ return $message;
+ }
+
+ $stack = Array();
+ $curr_pos = 1;
+ while ($curr_pos && ($curr_pos < strlen($message)))
+ {
+ $curr_pos = strpos($message, "[", $curr_pos);
+
+ // If not found, $curr_pos will be 0, and the loop will end.
+ if ($curr_pos)
+ {
+ // We found a [. It starts at $curr_pos.
+ // check if it's a starting or ending list tag.
+ $possible_ordered_start = substr($message, $curr_pos, $start_length[ordered]);
+ $possible_unordered_start = substr($message, $curr_pos, $start_length[unordered]);
+ $possible_end = substr($message, $curr_pos, 7);
+ if (strcasecmp("[list]", $possible_unordered_start) == 0)
+ {
+ // We have a starting unordered list tag.
+ // Push its position on to the stack, and then keep going to the right.
+ bbcode_array_push($stack, array($curr_pos, ""));
+ ++$curr_pos;
+ }
+ else if (preg_match("/\[list=([a1])\]/si", $possible_ordered_start, $matches))
+ {
+ // We have a starting ordered list tag.
+ // Push its position on to the stack, and the starting char onto the start
+ // char stack, the keep going to the right.
+ bbcode_array_push($stack, array($curr_pos, $matches[1]));
+ ++$curr_pos;
+ }
+ else if (strcasecmp("[/list]", $possible_end) == 0)
+ {
+ // We have an ending list tag.
+ // Check if we've already found a matching starting tag.
+ if (sizeof($stack) > 0)
+ {
+ // There exists a starting tag.
+ // We need to do 2 replacements now.
+ $start = bbcode_array_pop($stack);
+ $start_index = $start[0];
+ $start_char = $start[1];
+ $is_ordered = ($start_char != "");
+ $start_tag_length = ($is_ordered) ? $start_length[ordered] : $start_length[unordered];
+
+ // everything before the [list] tag.
+ $before_start_tag = substr($message, 0, $start_index);
+
+ // everything after the [list] tag, but before the [/list] tag.
+ $between_tags = substr($message, $start_index + $start_tag_length, $curr_pos - $start_index - $start_tag_length);
+ // Need to replace [*] with inside the list.
+ $between_tags = str_replace("[*]", "", $between_tags);
+
+ // everything after the [/list] tag.
+ $after_end_tag = substr($message, $curr_pos + 7);
+
+ if ($is_ordered)
+ {
+ $message = $before_start_tag . "";
+ $message .= $between_tags . "
";
+ }
+ else
+ {
+ $message = $before_start_tag . "";
+ $message .= $between_tags . "
";
+ }
+
+ $message .= $after_end_tag;
+
+ // Now.. we've screwed up the indices by changing the length of the string.
+ // So, if there's anything in the stack, we want to resume searching just after it.
+ // otherwise, we go back to the start.
+ if (sizeof($stack) > 0)
+ {
+ $a = bbcode_array_pop($stack);
+ $curr_pos = $a[0];
+ bbcode_array_push($stack, $a);
+ ++$curr_pos;
+ }
+ else
+ {
+ $curr_pos = 1;
+ }
+ }
+ else
+ {
+ // No matching start tag found. Increment pos, keep going.
+ ++$curr_pos;
+ }
+ }
+ else
+ {
+ // No starting tag or ending tag.. Increment pos, keep looping.,
+ ++$curr_pos;
+ }
+ }
+ } // while
+
+ return $message;
+
+} // bbencode_list()
+
+
+function bbencode($message) {
+
+ // pad it with a space so we can distinguish between FALSE and matching the 1st char (index 0).
+ // This is important; bbencode_quote(), bbencode_list(), and bbencode_code() all depend on it.
+ $message = " " . $message;
+
+ // First: If there isn't a "[" and a "]" in the message, don't bother.
+ if (! (strpos($message, "[") && strpos($message, "]")) )
+ {
+ // Remove padding, return.
+ $message = substr($message, 1);
+ return $message;
+ }
+
+ // [CODE] and [/CODE] for posting code (HTML, PHP, C etc etc) in your posts.
+ $message = bbencode_code($message);
+
+ // [QUOTE] and [/QUOTE] for posting replies with quote, or just for quoting stuff.
+ $message = bbencode_quote($message);
+
+ // [list] and [list=x] for (un)ordered lists.
+ $message = bbencode_list($message);
+
+ // [b] and [/b] for bolding text.
+ $message = preg_replace("/\[b\](.*?)\[\/b\]/si", "\\1", $message);
+
+ // [i] and [/i] for italicizing text.
+ $message = preg_replace("/\[i\](.*?)\[\/i\]/si", "\\1", $message);
+
+ // [url]www.phpbb.com[/url] code..
+ $message = preg_replace("/\[url\](http:\/\/)?(.*?)\[\/url\]/si", "\\2", $message);
+
+ // [url=xxxx://www.phpbb.com]phpBB[/url] code..
+ $message = preg_replace("#\[url=([a-z]+?://)?(.*?)\](.*?)\[/url\]#si", "\\3", $message);
+
+ // [email]user@domain.tld[/email] code..
+ $message = preg_replace("/\[email\](.*?)\[\/email\]/si", "\\1", $message);
+
+ // [img]image_url_here[/img] code..
+ $message = preg_replace("/\[img\](.*?)\[\/img\]/si", "
", $message);
+
+ // Remove our padding from the string..
+ $message = substr($message, 1);
+ return $message;
+
+} // bbencode()
+
+
+/**
+ * Nathan Codding - Oct. 30, 2000
+ *
+ * Escapes the "/" character with "\/". This is useful when you need
+ * to stick a runtime string into a PREG regexp that is being delimited
+ * with slashes.
+ */
+function escape_slashes($input)
+{
+ $output = str_replace('/', '\/', $input);
+ return $output;
+}
+
+
+
+/**
+ * James Atkinson - Feb 5, 2001
+ * This function does exactly what the PHP4 function array_push() does
+ * however, to keep phpBB compatable with PHP 3 we had to come up with out own
+ * method of doing it.
+ */
+function bbcode_array_push(&$stack, $value) {
+ $stack[] = $value;
+ return(sizeof($stack));
+}
+
+/**
+ * James Atkinson - Feb 5, 2001
+ * This function does exactly what the PHP4 function array_pop() does
+ * however, to keep phpBB compatable with PHP 3 we had to come up with out own
+ * method of doing it.
+ */
+function bbcode_array_pop(&$stack) {
+ $arrSize = count($stack);
+ $x = 1;
+ while(list($key, $val) = each($stack)) {
+ if($x < count($stack)) {
+ $tmpArr[] = $val;
+ }
+ else {
+ $return_val = $val;
+ }
+ $x++;
+ }
+ $stack = $tmpArr;
+ return($return_val);
+}
+
+
+?>
diff --git a/phpBB/functions/post.php b/phpBB/functions/post.php
new file mode 100644
index 0000000000..b4278d1182
--- /dev/null
+++ b/phpBB/functions/post.php
@@ -0,0 +1,27 @@
+
diff --git a/phpBB/functions/sessions.php b/phpBB/functions/sessions.php
new file mode 100644
index 0000000000..b4278d1182
--- /dev/null
+++ b/phpBB/functions/sessions.php
@@ -0,0 +1,27 @@
+
diff --git a/phpBB/index.php b/phpBB/index.php
new file mode 100644
index 0000000000..b4278d1182
--- /dev/null
+++ b/phpBB/index.php
@@ -0,0 +1,27 @@
+
diff --git a/phpBB/posting.php b/phpBB/posting.php
new file mode 100644
index 0000000000..b4278d1182
--- /dev/null
+++ b/phpBB/posting.php
@@ -0,0 +1,27 @@
+
diff --git a/phpBB/priv_msgs.php b/phpBB/priv_msgs.php
new file mode 100644
index 0000000000..b4278d1182
--- /dev/null
+++ b/phpBB/priv_msgs.php
@@ -0,0 +1,27 @@
+
diff --git a/phpBB/profile.php b/phpBB/profile.php
new file mode 100644
index 0000000000..b4278d1182
--- /dev/null
+++ b/phpBB/profile.php
@@ -0,0 +1,27 @@
+
diff --git a/phpBB/topicadmin.php b/phpBB/topicadmin.php
new file mode 100644
index 0000000000..b4278d1182
--- /dev/null
+++ b/phpBB/topicadmin.php
@@ -0,0 +1,27 @@
+
diff --git a/phpBB/viewforum.php b/phpBB/viewforum.php
new file mode 100644
index 0000000000..b4278d1182
--- /dev/null
+++ b/phpBB/viewforum.php
@@ -0,0 +1,27 @@
+
diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php
new file mode 100644
index 0000000000..b4278d1182
--- /dev/null
+++ b/phpBB/viewtopic.php
@@ -0,0 +1,27 @@
+