$array); // base case foreach($array as $key => $val) $array[$key] = add_dimension($val, $dimension); return $array; } // returns a parsed version of $string for use in entry content; removes any php code and applies bbcode function parse($string) { $string = str_replace('', '?>', $string); $string = str_replace('\\', '', $string); // start bbcode // see http://www.think-ink.net/html/bold.htm // for why we use and instead of and $bb_find = array( '/\[b\](.*?)\[\/b\]/is', '/\[i\](.*?)\[\/i\]/is', '/\[u\](.*?)\[\/u\]/is', '/\[url\=(.*?)\](.*?)\[\/url\]/is', '/\[url\](.*?)\[\/url\]/is', '/\[img\](.*?)\[\/img\]/is', ); $bb_replace = array( '$1', '$1', '$1', '$2', '$1', '', ); $string = preg_replace($bb_find, $bb_replace, $string); // end bbcode return $string; } // returns a parsed version of $string for use as an entry filename function parse_title($string) { $string = parse($string); if(strpos($string, '_') || strpos($string, '/') || strpos($string, '\\')|| strpos($string, '|') || strpos($string, ':') || strpos($string, '*') || strpos($string, '?') || strpos($string, '\'')|| strpos($string, '<') || strpos($string, '>') || strpos($string, '../') ) Engine::quit('Invalid characters in title.'); // Convert hyphens to underscores, spaces to hyphens, and remove bad things $string = str_replace('-', '_', $string); $string = str_replace(' ', '-', $string); $string = str_replace('../', '', $string); return $string; } // inverse function of parse_title() function deparse_title($string) { $string = str_replace('-', ' ', $string); $string = str_replace('_', '-', $string); return $string; } // cleans $string of any attempts to access things it shouldn't function sanitize($string) { $string = str_replace('../', '', $string); $string = htmlspecialchars($string); return $string; } function compare_entries($entry_a, $entry_b) { if($entry_a->timestamp == $entry_b->timestamp) return 0; return $entry_a->timestamp > $entry_b->timestamp ? -1 : 1; } function exception_handler($e) { $language = Engine::get_language(); if(get_class($e) == 'CannotFindFileException') $error = $language->cant_find_file; elseif(get_class($e) == 'CannotReadFileException') $error = $language->cant_read_file; elseif(get_class($e) == 'CannotWriteFileException') $error = $language->cant_write_file; elseif(get_class($e) == 'PropertyAccessException') $error = $language->cant_read_property; elseif(get_class($e) == 'PropertyDoesNotExistException') $error = $language->property_doesnt_exist; else Engine::error($language->unknown_exception); Engine::error($error, $e->getMessage() . ' ' . $e->getFile() . ':' . $e->getLine()); } ?>