direction = $instruction; } function processBBCode($str, $unique=''){ //lets do some simple caching here as well... if(!empty($unique) && $content = @file_get_contents(CACHE_PATH.'bbc-'.$unique.'.txt')){ //$assocArray = unserialize($content); //if(is_array($assocArray)){ //make sure this array is stored and ready to roll... return $content; //} } $simple_search = array( '/\[b\](.*?)\[\/b\]/is', '/\[i\](.*?)\[\/i\]/is', '/\[u\](.*?)\[\/u\]/is', '/\[link\=(.*?)\](.*?)\[\/link\]/is', '/\[link\](.*?)\[\/link\]/is', '/\[url\=(.*?)\](.*?)\[\/url\]/is', '/\[url\](.*?)\[\/url\]/is', '/\[align\=(left|center|right)\](.*?)\[\/align\]/is', '/\[mail\=(.*?)\](.*?)\[\/mail\]/is', '/\[mail\](.*?)\[\/mail\]/is', '/\[font\=(.*?)\](.*?)\[\/font\]/is', '/\[size\=(.*?)\](.*?)\[\/size\]/is', '/\[quoteby\=(.*?)\](.*?)\[\/quoteby\]/is', '/\[img\=(left|right)\](.*?)\[\/img\]/is', '/\[deathstarchris\](.*?)\[\/deathstarchris\]/is', '/\[color\=(.*?)\](.*?)\[\/color\]/is', '/\[ageCheck\]/is' ); $simple_replace = array( '$1', '$1', '$1', '$2', '$1', '$2', '$1', '
$2
', '$2', '$1', '$2', '$2', '
$1$2
', '
', '$1', '$2', '' ); // Do simple BBCode's $str = preg_replace ($simple_search, $simple_replace, $str); global $theCase; if($theCase != "default" && $theCase != ""){ $simple_search2 = array('/\[ageCheck\]/is'); $simple_replace2 = array(''); // Do simple BBCode's $str = preg_replace ($simple_search2, $simple_replace2, $str); } // Do
BBCode $str = $this->parseBBCSmiles($str); $str = $this->bbcode_quote ($str); $str = $this->bbcImageSizing($str); $str = $this->bbcImageThumb($str); $str = $this->parseLinks($str); $str = $this->parseYouTube($str); $str = $this->parsePimpinRigz($str); $str = $this->parseFlash($str); $str = $this->parseDeals($str); if(!empty($unique)){ //serialize the results and store it... @unlink(CACHE_PATH.'bbc-'.$unique.'.txt'); //kill the old content $content = $str;//serialize($assocArray); file_put_contents(CACHE_PATH.'bbc-'.$unique.'.txt', $content); } return $str; } function bbcode_quote($str) { $open = '
'; $close = '
'; // How often is the open tag? preg_match_all ('/\[quote\]/i', $str, $matches); $opentags = count($matches['0']); // How often is the close tag? preg_match_all ('/\[\/quote\]/i', $str, $matches); $closetags = count($matches['0']); // Check how many tags have been unclosed // And add the unclosing tag at the end of the message $unclosed = $opentags - $closetags; for ($i = 0; $i < $unclosed; $i++) { $str .= '
'; } // Do replacement $str = str_replace ('[quote]', $open, $str); $str = str_replace ('[/quote]', $close, $str); return $str; } //used in the forum function parseLinks($str){ //shorten the links, long links look ugly $str2 = $str; /************************************************************************************/ /******************************* http://link.com ************************************/ /************************************************************************************/ $simple_search = "#(^|[\n ])([\w]+?://[\w\#$%&~/.\-;:=,?@\[\]+]*)#is"; preg_match_all($simple_search,$str2,$out, PREG_SET_ORDER); //echo $out[0][0] . ", " . $out[0][1] . "\n"; //echo $out[1][0] . ", " . $out[1][1] . "\n"; //number of array items $len = count($out); // so our indexes line up $counter = 0; //now we loop making each link smaller while($counter < $len){ $link = $out[$counter][0]; if(strlen($link) >= 45){ //echo "++ ".$out[0][0] ." - OUT
"; $linkLen = strlen($link); $part1 = substr($link,1,20); // start at the first character and get the first 20 $part2 = "....."; $part3 = substr($link,$linkLen-20,20); // start at the last 20 chars and get them all $condensedLink = "$part1$part2$part3"; $simple_replace = "\\1$condensedLink"; // Do simple BBCode's $str2 = preg_replace($simple_search, $simple_replace, $str2, 1); //preg_replace($patterns, $replacements, $str, 1); // each replacement will be done one at a time } else{ //for the already shortened links $simple_replace = " \\2"; // Do simple BBCode's $str2 = preg_replace($simple_search, $simple_replace, $str2, 1); } $counter += 1; } /************************************************************************************/ /******************************* www.link.com ************************************/ /************************************************************************************/ $simple_search = "#(^|[\n ])((www|ftp)\.[\w\#$%&~/.\-;:=,?@\[\]+]*)#is"; preg_match_all($simple_search,$str2,$out2, PREG_SET_ORDER); //echo $out[0][0] . ", " . $out[0][1] . "\n"; //echo $out[1][0] . ", " . $out[1][1] . "\n"; //number of array items $len = count($out2); // so our indexes line up $counter = 0; //now we loop making each link smaller while($counter < $len){ $link = $out2[$counter][0]; if(strlen($link) >= 45){ //echo "++ ".$out[0][0] ." - OUT
"; $linkLen = strlen($link); $part1 = substr($link,1,20); // start at the first character and get the first five $part2 = "....."; $part3 = substr($link,$linkLen-20,20); // start at the last 5 chars and get them all $condensedLink = "$part1$part2$part3"; $simple_replace = "\\1$condensedLink"; // Do simple BBCode's $str2 = preg_replace ($simple_search, $simple_replace, $str2,1); } else{ //for the already shortened links $simple_replace = "\\1\\2"; // Do simple BBCode's $str2 = preg_replace ($simple_search, $simple_replace, $str2,1); } $counter += 1; } return $str2; } //used in the thread to parse the link with a defined text header function parseLinksSite($site,$msg){ $str2 = $site; $str2 = preg_replace("#(^|[\n ])([\w]+?://[\w\#$%&~/.\-;:=,?@\[\]+]*)#is", "\\1$msg", $str2); // http://link.com $str2 = preg_replace("#(^|[\n ])((www|ftp)\.[\w\#$%&~/.\-;:=,?@\[\]+]*)#is", "\\1$msg", $str2); // www.link.com // borrowed from phpbb2 return $str2; } function parseDeals($str){ $str2 = $str; $pattern = '/\[deal\](.*?)\[\/deal\]/is'; preg_match_all($pattern, $str, $matches, PREG_SET_ORDER); $count = count($matches); $inti = 0; //run the loop once for each occurance while($inti < $count){ //get the youtube vid name $dealID = $matches[$inti][1]; $stringVid = $dealID; //grab the deal right here $adhost = "db892.perfora.net"; $adsqlName = "dbo203389596"; $adsqlPass = "Cvxehg2H"; $addatabase = "db203389596"; $conn = mysql_connect("$adhost","$adsqlName","$adsqlPass"); // pick the db to use mysql_select_db("db203389596",$conn); $sql = "SELECT * FROM `cjdeals` WHERE `dealID` = '$dealID' LIMIT 1"; $res = mysql_query($sql,$conn) or die(mysql_error()); if(mysql_num_rows($res) > 0){ while($row = mysql_fetch_array($res)){ $dealID = $row['dealID']; $deal = $row['deal']; $notes = processBBCode($row['notes']); $replacement = "
$deal
$notes
"; } } else{ $replacement = ""; } $str2 = preg_replace($pattern, $replacement, $str2, 1); // replace each individual occurance //print("here $inti, string $replacement -- String $str2 -- ". $peices[1] ."
"); $inti += 1; } return $str2; } function parseYouTube($str){ $str2 = $str; $pattern = '/\[youtube\](.*?)\[\/youtube\]/is'; preg_match_all($pattern, $str, $matches, PREG_SET_ORDER); $count = count($matches); $inti = 0; //run the loop once for each occurance while($inti < $count){ //get the youtube vid name $peices = explode("=", $matches[$inti][1]); $stringVid = $peices[1]; $pattern = '/\[youtube\](.*?)\[\/youtube\]/is'; $replacement = '
'; $str2 = preg_replace($pattern, $replacement, $str2, 1); // replace each individual occurance //print("here $inti, string $replacement -- String $str2 -- ". $peices[1] ."
"); $inti += 1; } return $str2; } function parsePimpinRigz($str){ $str2 = $str; $pattern = '/\[pimpinrigz\](.*?)\[\/pimpinrigz\]/is'; preg_match_all($pattern, $str, $matches, PREG_SET_ORDER); $count = count($matches); $inti = 0; //run the loop once for each occurance while($inti < $count){ //get the youtube vid name $peices = explode("=", $matches[$inti][1]); $stringVid = $peices[1]; $pattern = '/\[pimpinrigz\](.*?)\[\/pimpinrigz\]/is'; $replacement = '
'; $str2 = preg_replace($pattern, $replacement, $str2, 1); // replace each individual occurance //print("here $inti, string $replacement -- String $str2 -- ". $peices[1] ."
"); $inti += 1; } return $str2; } function parseFlash($str){ $str2 = $str; $pattern = '/\[flash\](.*?)\[\/flash\]/is'; preg_match_all($pattern, $str, $matches, PREG_SET_ORDER); $count = count($matches); $inti = 0; //run the loop once for each occurance while($inti < $count){ //get the youtube vid name $peices = explode("=", $matches[$inti][1]); $stringVid = $peices[1]; $pattern = '/\[flash\](.*?)\[\/flash\]/is'; $replacement = ' '; $str2 = preg_replace($pattern, $replacement, $str2, 1); // replace each individual occurance //print("here $inti, string $replacement -- String $str2 -- ". $peices[1] ."
"); $inti += 1; } return $str2; } function bbcImageSizing($str){ $str2 = $str; //this is a scope thing, if i dont do this then the replace keeps grabbing the origional str, even after changes are made, they are undone //the search pattern for bbc images $pattern = '/\[img\](.*?)\[\/img\]/is'; //get the number of matches so we know how many times this function needs to run preg_match_all($pattern, $str, $matches, PREG_SET_ORDER); $count = count($matches); //setup the loop $inti = 0; $max_height = 427; //Maximum resize height $max_width = 470; //Maximum resize width while($inti < $count){ if(url_exists($matches[$inti][1])){ //print("This image Exists: ". $matches[$inti][1] ."
"); //get the image dimensions $size = $this->sizeIt($matches[$inti][1]); //$size = getimagesize(); $width = $size[0]; $height = $size[1]; //Now checking for new dimensions //these will resize it to 640X480 or a respective width no bigger then 640 if($width > $max_width){ // $timed <= 2 && $new_width = $max_width; $new_height = round($new_width*($height / $width)); if($this->direction == "sig"){ $replacement = ''; } else{ $replacement = ''; } $str2 = preg_replace($pattern, $replacement, $str2, 1); } else{ //neither is bigger, this should fix it all, or i've been waiting to long and dont want to check the sizes anymore $replacement = ''; $str2 = preg_replace($pattern, $replacement, $str2, 1); } } else{ $replacement = '
This image no longer exists
'; $str2 = preg_replace($pattern, $replacement, $str2, 1); } $inti += 1; } // end of the loop return $str2; } //helper function that I can timeout function sizeIt($image){ set_time_limit(7); $picSize = getimagesize($image); return $picSize; } function bbcImageThumb($str){ $str2 = $str; //this is a scope thing, if i dont do this then the replace keeps grabbing the origional str, even after changes are made, they are undone //the search pattern for bbc images $pattern = '/\[thumb\](.*?)\[\/thumb\]/is'; //get the number of matches so we know how many times this function needs to run preg_match_all($pattern, $str, $matches, PREG_SET_ORDER); $count = count($matches); //setup the loop $inti = 0; $max_height = 120; //Maximum resize height $max_width = 160; //Maximum resize width while($inti < $count){ if(url_exists($matches[$inti][1])){ //print("This image Exists: ". $matches[$inti][1] ."
"); //get the image dimensions $size = $this->sizeIt($matches[$inti][1]); //$size = getimagesize(); $width = $size[0]; $height = $size[1]; //Now checking for new dimensions //these will resize it to 640X480 or a respective width no bigger then 640 if($width > $max_width){ // $timed <= 2 && $new_width = $max_width; $new_height = round($new_width*($height / $width)); if($this->direction == "sig"){ $replacement = ''; } else{ $replacement = ''; } $str2 = preg_replace($pattern, $replacement, $str2, 1); } else{ //neither is bigger, this should fix it all, or i've been waiting to long and dont want to check the sizes anymore $replacement = ''; $str2 = preg_replace($pattern, $replacement, $str2, 1); } } else{ $replacement = '
This image no longer exists
'; $str2 = preg_replace($pattern, $replacement, $str2, 1); } $inti += 1; } // end of the loop return $str2; } //replaces the bbc smiles and puts in the images function parseBBCSmiles($str){ $str2 = $str; $simple_search = array( '/\[smile1\]/is', '/\[smile2\]/is', '/\[smile3\]/is', '/\[smile4\]/is', '/\[smile5\]/is', '/\[smile6\]/is', '/\[smile7\]/is', '/\[smile8\]/is', '/\[smile9\]/is', '/\[smile10\]/is', '/\[smile11\]/is', '/\[smile12\]/is', '/\[smile13\]/is', '/\[smile14\]/is', '/\[smile15\]/is', '/\[smile16\]/is', '/\[smile17\]/is', '/\[smile18\]/is', '/\[smile19\]/is', '/\[smile20\]/is', '/\[smile21\]/is', '/\[smile22\]/is', '/\[smile23\]/is' ); $simple_replace = array( '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '' ); // Do simple BBCode's $str2 = preg_replace ($simple_search, $simple_replace, $str); return $str2; } } ?> Fusion Mods - A Modding Community
User CP
Name:  
Pass:

Register
Latest News Access denied for user 'bro105_admin'@'localhost' (using password: YES)