$dir) { // remove everything except color _directories_ if(strstr($dir, "admin") != false || strstr($dir, "img") != false || !is_dir($dir)) { // we use strstr because the various ../ / etc will get in the way of a == unset($allcolors[$key]); } else { // strip it down to only the word of the color $allcolors[$key] = str_replace(".", "", $allcolors[$key]); $allcolors[$key] = str_replace("/", "", $allcolors[$key]); } } $allcolors = array_values($allcolors); // and reform the array to reorganize the keys function print_post($title, $body, $time, $author, $id, $indie = false) { // in this function, $author is the author of the post that will be displayed, NOT $color // $color is what it always is; the current color of the blog being viewed, or "" on homepage global $root, $color; // implemented for White: // $author is the name of the author, e.g. "White"; // $authcol is the coloring to use, e.g. "Gray" if($author == "White") $authcol = "Gray"; else $authcol = $author; print("

"); if(!$indie) // link the title only if there are other posts being displayed print("" . postparse($title) . ""); else print("" . postparse($title) . ""); print("

\n
" . date("M j, Y") . " by "); if(isset($_GET['p']) || !isset($color)) // link author name if we're not at the author's page print("" . $author . ""); else // otherwise, don't link it print("" . $author . ""); print("
\n
" . postparse($body) . "

\n"); $query = mysql_query("SELECT * FROM comments WHERE post = '" . $id . "' ORDER BY time ASC"); $num_comments = 0; while($comment = mysql_fetch_assoc($query)) { // this scroll through is only meant to count comments $num_comments++; } if($indie) print("" . $num_comments . " comments

\n"); else print("" . $num_comments . " comments
\n"); if($indie) { // display comments if only this post is the only one being displayed $query = mysql_query("SELECT * FROM comments WHERE post = '" . $id . "' ORDER BY time ASC"); while($comment = mysql_fetch_assoc($query)) { // $query is still set from the first scroll through comments $query2 = mysql_query("SELECT * FROM commenters WHERE id = '" . $comment['commenter'] . "'"); $commenter = mysql_fetch_assoc($query2); // grab info about commenter print("
" . $commenter['alias'] . " says:
\n"); print("
" . $comment['body'] . "
"); } print("

Comment on this post

\n"); print("
\n"); print("
Email (need to register?)
\n"); print("
\n"); print("
Password

\n"); print("
Body
\n

\n"); print(""); } } function preparse($string) { // use this function to parse text for entrance into the database $string = addslashes($string); return $string; } function postparse($string) { global $allcolors; // use this function to parse text for display $string = stripslashes($string); $string = nl2br($string); // start bbcode if(is_array($allcolors)) // tbh i have NO idea why this IF works, but if it's not here we get an invalid implode() error all over the place $allcolors2 = !empty($allcolors) ? implode('|', $allcolors) : 'Red'; // make sure allcolors always has a value $replace = array('~\[url=(https?://.*?/)(' . $allcolors2 . ')(/.*?)\](.*?)\[/url\]~si' => '\\4'); $string = preg_replace(array_keys($replace), array_values($replace), $string); $preg_find[] = '/\[url\=(.*?)\](.*?)\[\/url\]/is'; $preg_replace[] = '$2'; // removed because of conflictions //$preg_find[] = '/\[url\](.*?)\[\/url\]/is'; //$preg_replace[] = '$1'; $preg_find[] = '/\[b\](.*?)\[\/b\]/is'; $preg_replace[] = '$1'; $preg_find[] = '/\[i\](.*?)\[\/i\]/is'; $preg_replace[] = '$1'; $preg_find[] = '/\[u\](.*?)\[\/u\]/is'; $preg_replace[] = '$1'; $preg_find[] = '/\[img\](.*?)\[\/img\]/is'; $preg_replace[] = ''; $preg_find[] = '/\[blockquote\](.*?)\[\/blockquote\]/is'; $preg_replace[] = '
$1
'; $string = preg_replace($preg_find, $preg_replace, $string); // end bbcode return $string; }