Archive for August, 2004

31Augmblog3.0xtc.com

mblog3.0xtc.com is a subdomain I set up to do my MagnaBlog 3 hacks and bugfixes on. If you’re using Magnablog 3 and you want to check out things of Magna-Blogmatical interest, it’s worth taking a look at.


26AugI love The Daily Show

And since I don’t have Comedy Central on TV here, I just can’t stop watching these videos.
Simply hilarious.
John Stuwart


24AugHow to write code without making your head explode:

Soooo…you want attributes in bbcode links, huh?

Take a deep breath…and let’s think about what we really want here. We want something that thinks like a human when it sees something. When a human sees something like "...url=http://magnablog.0xtc.com title=T's site class=alink rel=Alternate Start...", it knows that the link is to 0xtc.com, the title is “T’s site”, the class is “alink” and the “rel” attribute is “Alternate Start”…How ? Because humans are good at patterns. Humans know that in our case, “class” isn’t “alink rel=Alternate Start” because “rel” is an attribute of its own! That’s what we want our function to do: To recognize not only the right pattern, but also where an attribute starts and more importantly, where it STOPS!

And since I couldn’t get preg_replace to recognize negative RegEx patterns….I wrote functions :-D

function url2ahref($code)
{
$code = trim($code);
$link_text = explode("]", $code);
$code = $link_text[0];
$link_text = $link_text[1];
$linkurl = explode(" ",$code);
$linkurl = $linkurl[0];
$rest = strstr($code," ");
$rest = preg_replace ("# ([a-zA-Z]+)=#is", "\" $1=\"",$rest);
$atts = $rest;
return "<a href=\"$linkurl$atts\">$link_text</a>";
} /*......*/

$pattern = "#\[url=(.*?)\[\/url\]#ise";
$replace = "url2ahref('$1')";
$content = preg_replace ($pattern, $replace, $content);

/*......*/

function href2url($code)
{
$code = trim($code);
$link_text = explode(">", $code);
$code = $link_text[0];
$link_text = $link_text[1];
$linkstring = str_replace("href=","url=", $code);
$linkstring = str_replace("\\\"","", $linkstring);
return "[".$linkstring."]".$link_text."[/url]";
}

/*......*/

$pattern = '/<a (.*?)<\/a>/ise';
$replace = "href2url('$1')";
$content = preg_replace ($pattern, $replace, $content);

/*......*/


21AugIt came to me while I was taking pictures at the lingerie show

After working for hours on end on my html2bbcode function, I had a mind block when it came to <a href> tags. Some <a href> links have “titles” and some don’t and if you mix the two variations in one string, you’re bound to get in trouble when converting them to bbCode. i couldn’t get it work for hours and decided to go out for a hair cut since i’d worked for so long, that the hair on my head had grown so long that it was impairing my sight to the monitor.

I couldn’t help but take some pictures while I was out.models
It was the sight of the models at the lingerie show that inspired me the to answer of my preg_replace problem….Strip! Just strip away the “titles”…who cares about titles anyway? F#?$K titles! If you have a better idea, by all means let me know.

$pattern = "#&lt;a href=\"(.*?)\"(.*?)&gt;(.*?)&lt; \/a&gt;#is";
$replace = '[url=$1]$3[/url]';
$content = preg_replace ($pattern, $replace, $content);
/*......*/

Oh, and this picture has got to be the funniest picture I took today. I didn’t think it was funny when taking it, but when I came home and saw it…haha…The two ladies are looking straight at me thinking I’m taking a picture of them, when actually they just happen to be in the general area. (Click to see the full picture.)
what are you looking at




You are currently browsing the archives...