From 5121e99dbe6ac18fe80fee627eb05d0f2921d5cb Mon Sep 17 00:00:00 2001
From: Shish <shish@shishnet.org>
Date: Sat, 24 Dec 2011 14:49:55 +0000
Subject: [PATCH] speed hax and niceurl forcing from r34

---
 core/imageboard.pack.php |  9 ++++++---
 core/util.inc.php        |  2 +-
 ext/comment/theme.php    | 10 +++++++++-
 index.php                |  2 ++
 4 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/core/imageboard.pack.php b/core/imageboard.pack.php
index 0b2c89b8..5f110f07 100644
--- a/core/imageboard.pack.php
+++ b/core/imageboard.pack.php
@@ -500,9 +500,12 @@ class Image {
 		$tmpl = str_replace('$filename', $_escape($base_fname), $tmpl);
 		$tmpl = str_replace('$title', $_escape($config->get_string("title")), $tmpl);
 
-		$plte = new ParseLinkTemplateEvent($tmpl, $this);
-		send_event($plte);
-		$tmpl = $plte->link;
+		// nothing seems to use this, sending the event out to 50 exts is a lot of overhead
+		if(!SPEED_HAX) {
+			$plte = new ParseLinkTemplateEvent($tmpl, $this);
+			send_event($plte);
+			$tmpl = $plte->link;
+		}
 
 		return $tmpl;
 	}
diff --git a/core/util.inc.php b/core/util.inc.php
index c1333151..32523ac4 100644
--- a/core/util.inc.php
+++ b/core/util.inc.php
@@ -178,7 +178,7 @@ function make_link($page=null, $query=null) {
 
 	if(is_null($page)) $page = $config->get_string('main_page');
 
-	if($config->get_bool('nice_urls', false)) {
+	if(FORCE_NICE_URLS || $config->get_bool('nice_urls', false)) {
 		#$full = "http://" . $_SERVER["SERVER_NAME"] . $_SERVER["PHP_SELF"];
 		$full = $_SERVER["PHP_SELF"];
 		$base = str_replace("/index.php", "", $full);
diff --git a/ext/comment/theme.php b/ext/comment/theme.php
index 9c76f723..746d5a88 100644
--- a/ext/comment/theme.php
+++ b/ext/comment/theme.php
@@ -118,7 +118,15 @@ class CommentListTheme extends Themelet {
 		global $user;
 
 		$tfe = new TextFormattingEvent($comment->comment);
-		send_event($tfe);
+
+		// sending this event to all ~50 exts has a lot of overhead
+		if(SPEED_HAX) {
+			$bb = new BBCode();
+			$bb->receive_event($tfe);
+		}
+		else {
+			send_event($tfe);
+		}
 
 		$i_uid = int_escape($comment->owner_id);
 		$h_name = html_escape($comment->owner_name);
diff --git a/index.php b/index.php
index df3179d6..47ef6c56 100644
--- a/index.php
+++ b/index.php
@@ -59,6 +59,8 @@ define("CACHE_DIR", false);
 define("VERSION", 'trunk');
 define("SCORE_VERSION", 's2hack/'.VERSION);
 define("COOKIE_PREFIX", 'shm');
+define("SPEED_HAX", false);
+define("FORCE_NICE_URLS", false);
 
 if(empty($database_dsn) && !file_exists("config.php")) {
 	header("Location: install.php");