<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>INSTALL</filename>
    </added>
    <added>
      <filename>bin/bootstrap_db.php</filename>
    </added>
    <added>
      <filename>bin/finish_url.php</filename>
    </added>
    <added>
      <filename>bin/prepare_db.php</filename>
    </added>
    <added>
      <filename>conf/lighttpd/single_wiki.conf</filename>
    </added>
    <added>
      <filename>files/singlewiki-dump.sql</filename>
    </added>
    <added>
      <filename>php/actions/ManageSuperUserAction.php</filename>
    </added>
    <added>
      <filename>php/actions/ManageUsersAction.php</filename>
    </added>
    <added>
      <filename>php/class/Wikidot/Form.php</filename>
    </added>
    <added>
      <filename>php/class/Wikidot/Yaml.php</filename>
    </added>
    <added>
      <filename>php/modules/manage/ManageSuperUserModule.php</filename>
    </added>
    <added>
      <filename>php/modules/manage/ManageUsersModule.php</filename>
    </added>
    <added>
      <filename>templates/modules/manage/ManageSuperUserModule.tpl</filename>
    </added>
    <added>
      <filename>templates/modules/manage/ManageUsersModule.tpl</filename>
    </added>
    <added>
      <filename>web/files--common/modules/js/manage/ManageSuperUserModule.js</filename>
    </added>
    <added>
      <filename>web/files--common/modules/js/manage/ManageUsersModule.js</filename>
    </added>
    <added>
      <filename>wikidotctl</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -1,3 +1,4 @@
+#!/usr/bin/env php
 &lt;?php
 /**
  * Wikidot - free wiki collaboration software
@@ -28,53 +29,42 @@
  * this file creates configuration files that is needed to run Wikidot
  */
 
-$files = array(&quot;/web/.htaccess&quot;, &quot;/files/apache.vhost.wikidot.conf&quot;, &quot;/files/crontab&quot;, &quot;/files/lighttpd-wikidot.conf&quot;);
+$files = array(&quot;/files/crontab&quot;, &quot;/conf/lighttpd/wikidot_ini.conf&quot;, &quot;/conf/secret&quot;);
 
 chdir(dirname(__FILE__));
 require(&quot;../php/setup.php&quot;);
 
 chdir(WIKIDOT_ROOT);
 
+$random = random(64);
+
 foreach ($files as $file) {
 	$src = WIKIDOT_ROOT.&quot;$file.orig&quot;;
 	$dst = WIKIDOT_ROOT.$file;
 	echo &quot;Processing $file .&quot;;
 	$s = file_get_contents($src);
 	echo &quot;.&quot;;
-	$s = sed($s);
+	$s = sed($s, $random);
 	echo &quot;.&quot;;
 	file_put_contents($dst, $s);
 	echo &quot;.\n&quot;;
 }
 
-// generate RSA key
-
-echo &quot;Generating RSA keys ..\n&quot;;
-exec('sh bin/generate_keys.sh');
-
-echo &quot;Done!!!\n&quot;;
-
-echo &lt;&lt;&lt;EOT
-
-Now please use the following files:
-
-files/apache.vhost.wikidot.conf - append to your Apache configuration,
-OR files/lighttpd-wikidot.conf - include to lighttpd configuration (sample Lighttpd configuration: files/lighttpd.conf)
-files/crontab - append to your Crontab configuration
-
-You might also get a Flickr API key from http://flickr.com and
-put it to files/flickr-api-key.txt
-
-
-EOT;
-
+function random($length) {
+	$r = &quot;&quot;;
+	for ($i = 0; $i &lt; $length; $i++) {
+		$r .= dechex(rand(0, 15));
+	}
+	return $r;
+}
 
-function sed($s) {
-	$s = preg_replace('/%{WIKIDOT:WIKIDOT_ROOT}/', WIKIDOT_ROOT, $s);
-	$s = preg_replace('/%{WIKIDOT:URL_HOST}/', GlobalProperties::$URL_HOST, $s);
-	$s = preg_replace('/%{WIKIDOT:URL_HOST_PREG}/', GlobalProperties::$URL_HOST_PREG, $s);
-	$s = preg_replace('/%{WIKIDOT:URL_DOMAIN}/', GlobalProperties::$URL_DOMAIN, $s);
-	$s = preg_replace('/%{WIKIDOT:URL_DOMAIN_PREG}/', GlobalProperties::$URL_DOMAIN_PREG, $s);
-	$s = preg_replace('/%{WIKIDOT:SUPPORT_EMAIL}/', GlobalProperties::$SUPPORT_EMAIL, $s);
+function sed($s, $random) {
+	$s = preg_replace('/%{WIKIDOT:WIKIDOT_ROOT}/', addslashes(WIKIDOT_ROOT), $s);
+	$s = preg_replace('/%{WIKIDOT:URL_HOST}/', addslashes(GlobalProperties::$URL_HOST), $s);
+	$s = preg_replace('/%{WIKIDOT:URL_HOST_PREG}/', addslashes(GlobalProperties::$URL_HOST_PREG), $s);
+	$s = preg_replace('/%{WIKIDOT:URL_DOMAIN}/', addslashes(GlobalProperties::$URL_DOMAIN), $s);
+	$s = preg_replace('/%{WIKIDOT:URL_DOMAIN_PREG}/', addslashes(GlobalProperties::$URL_DOMAIN_PREG), $s);
+	$s = preg_replace('/%{WIKIDOT:HTTP_PORT}/', addslashes(GlobalProperties::$HTTP_PORT), $s);
+	$s = preg_replace('/%{WIKIDOT:RANDOM_STRING}/', $random, $s);
 	return $s;
 }</diff>
      <filename>bin/configure.php</filename>
    </modified>
    <modified>
      <diff>@@ -1,3 +1,4 @@
+#!/usr/bin/env php
 &lt;?php
 
 /**</diff>
      <filename>bin/generate_om.php</filename>
    </modified>
    <modified>
      <diff>@@ -75,4 +75,6 @@ CreateAccount createaccount2/CreateAccountModule
 CreateAccount2 createaccount2/CreateAccount2Module
 CreateAccount3 createaccount2/CreateAccount3Module
 WantedPages sitetools/WantedPagesStandaloneModule
-OrphanedPages sitetools/OrphanedPagesStandaloneModule
\ No newline at end of file
+OrphanedPages sitetools/OrphanedPagesStandaloneModule
+ManageSuperUser manage/ManageSuperUserModule
+ManageUsers manage/ManageUsersModule</diff>
      <filename>conf/wiki_modules/default.conf</filename>
    </modified>
    <modified>
      <diff>@@ -1,31 +1,10 @@
-[main]
-; the following option determines the master domain for your Wikidot installation
-domain = wikidot1.dev
-; the name of the Wikidot service 
-service = Wikidot custom installation
-
-[security]
-; string that is used to generate unpredictable hashes for authentication
-; YOU MUST CHANGE IT or otherwise, anyone can predict the authentication
-; cookies and thus steal any session from your users
-secret = enter some random phrase here
-domain_upload = wikifiles.wikidot.dev
-
 [db]
 ; PostgreSQL connection parameters 
 host = localhost
-user = wd
-password = wdpass
-database = wd1
+user = wikidot
+password = wikidot
+database = wikidot
 
-[mail]
-; simple mail sending parameters
-host = smtp.gmail.com
-port = 465
-ssl = true
-auth = true
-user = wikidot.quake
-password = testpass
+[main]
+port = 8080
 
-[misc]
-custom_domains = true
\ No newline at end of file</diff>
      <filename>conf/wikidot.ini</filename>
    </modified>
    <modified>
      <diff>@@ -30,21 +30,34 @@ class LoginStatusModule extends Module{
 		// Smarty if not required!
 		
 		$user = $runData-&gt;getUser();
+	
+		if (GlobalProperties::$WIKI_FARM) {
+			$url_prefix = 'http://'.$loginDomain.'.'.GlobalProperties::$URL_DOMAIN;
+		} else {
+			$url_prefix = '';
+		}
 		
 		if($user == null){
 			$site = $runData-&gt;getTemp('site');
-			$originalUrl = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
+			
+			$originalUrl = $_SERVER['REQUEST_URI'];
+			if (GlobalProperties::$WIKI_FARM) {
+				$originalUrl = 'http://' . $_SERVER['HTTP_HOST'] . $originalUrl;
+			}
+			
 			if(preg_match(';\?origUrl=.*$;', $originalUrl)){
 				$o = array();
 				parse_str(preg_replace(';^.*?\?;', '', $_SERVER['REQUEST_URI']), $o);
 				$originalUrl = $o['origUrl'];
 			}
+			
 			$loginDomain = 'www';
 			if($site-&gt;getLanguage() != 'en'){
 				$loginDomain = $site-&gt;getLanguage();
 			}
-			$out = '&lt;a href=&quot;http://'.$loginDomain.'.'.GlobalProperties::$URL_DOMAIN . '/auth:newaccount?origUrl='.urlencode($originalUrl).'&quot;&gt;'._('create account').'&lt;/a&gt; '._('or') . ' ';
-			$out .= '&lt;a href=&quot;http://'.$loginDomain.'.'.GlobalProperties::$URL_DOMAIN . '/auth:login?origUrl='.urlencode($originalUrl).'&quot;&gt;'._('login').'&lt;/a&gt; ';
+			
+			$out  = '&lt;a href=&quot;' . $url_prefix . '/auth:newaccount?origUrl='.urlencode($originalUrl).'&quot;&gt;'._('create account').'&lt;/a&gt; '._('or') . ' ';
+			$out .= '&lt;a href=&quot;' . $url_prefix . '/auth:login?origUrl='.urlencode($originalUrl).'&quot;&gt;'._('login').'&lt;/a&gt; ';
 			
 			//$out = '&lt;a href=&quot;javascript:;&quot; onclick=&quot;WIKIDOT.page.listeners.createAccount(event)&quot;&gt;'._('create account').'&lt;/a&gt; '._('or').' &lt;a href=&quot;javascript:;&quot; onclick=&quot;WIKIDOT.page.listeners.loginClick(event)&quot;&gt;'._('login').'&lt;/a&gt;';
 		} else {
@@ -65,24 +78,24 @@ class LoginStatusModule extends Module{
 			setlocale(LC_ALL, $glang.'.UTF-8');
 		
 			$userId = $user-&gt;getUserId();
-			$linkInner = 'href=&quot;http://' . GlobalProperties::$URL_HOST . '/user:info/'.$user-&gt;getUnixName().'&quot; onclick=&quot;WIKIDOT.page.listeners.userInfo('.$user-&gt;getUserId().'); return false;&quot; ';
+			$linkInner = 'href=&quot;' . $url_prefix . '/user:info/'.$user-&gt;getUnixName().'&quot; onclick=&quot;WIKIDOT.page.listeners.userInfo('.$user-&gt;getUserId().'); return false;&quot; ';
 			
 			$out = '&lt;span class=&quot;printuser&quot;&gt;&lt;a '.$linkInner.'&gt;&lt;img class=&quot;small&quot; src=&quot;/common--images/avatars/'.floor($userId/1000).'/'.$userId.'/a16.png&quot; alt=&quot;avatar&quot;';
 			/* karma: */
-			$out .= ' style=&quot;background-image:url(http://' . GlobalProperties::$URL_HOST . '/userkarma.php?u=' .$userId  . ')&quot;';
+			$out .= ' style=&quot;background-image:url(' . $url_prefix . '/userkarma.php?u=' .$userId  . ')&quot;';
 			/* end of karma */
 			$out .= '/&gt;&lt;/a&gt;';
 			$out .= $user-&gt;getNickName().'&lt;/span&gt;'.
-					' | &lt;a href=&quot;http://'.GlobalProperties::$URL_HOST.'/account:you&quot;&gt;'._('my account').'&lt;/a&gt;' .
+					' | &lt;a href=&quot;' . $url_prefix .'/account:you&quot;&gt;'._('my account').'&lt;/a&gt;' .
 					'&lt;a  id=&quot;account-topbutton&quot; href=&quot;javascript:;&quot;&gt;&amp;nabla;&lt;/a&gt;';
 			$out .= '&lt;div id=&quot;account-options&quot;&gt;' .
 					'&lt;ul&gt;' .
-					'&lt;li&gt;&lt;a href=&quot;http://'.GlobalProperties::$URL_HOST.'/account:you&quot;&gt;'._('account summary').'&lt;/a&gt;&lt;/li&gt;' .
-					'&lt;li&gt;&lt;a href=&quot;http://'.GlobalProperties::$URL_HOST.'/account:you/start/messages&quot;&gt;'._('private messages').'&lt;/a&gt;&lt;/li&gt;' .
-					'&lt;li&gt;&lt;a href=&quot;http://'.GlobalProperties::$URL_HOST.'/account:you/start/contacts&quot;&gt;'._('my contacts').'&lt;/a&gt;&lt;/li&gt;' .
-					'&lt;li&gt;&lt;a href=&quot;http://'.GlobalProperties::$URL_HOST.'/account:you/start/notifications&quot;&gt;'._('notifications').'&lt;/a&gt;&lt;/li&gt;'.
-					'&lt;li&gt;&lt;a href=&quot;http://'.GlobalProperties::$URL_HOST.'/account:you/start/watched-changes&quot;&gt;'._('watched pages').'&lt;/a&gt;&lt;/li&gt;'.
-					'&lt;li&gt;&lt;a href=&quot;http://'.GlobalProperties::$URL_HOST.'/account:you/start/watched-forum&quot;&gt;'._('watched discussions').'&lt;/a&gt;&lt;/li&gt;'.
+					'&lt;li&gt;&lt;a href=&quot;' . $url_prefix . '/account:you&quot;&gt;'._('account summary').'&lt;/a&gt;&lt;/li&gt;' .
+					'&lt;li&gt;&lt;a href=&quot;' . $url_prefix . '/account:you/start/messages&quot;&gt;'._('private messages').'&lt;/a&gt;&lt;/li&gt;' .
+					'&lt;li&gt;&lt;a href=&quot;' . $url_prefix . '/account:you/start/contacts&quot;&gt;'._('my contacts').'&lt;/a&gt;&lt;/li&gt;' .
+					'&lt;li&gt;&lt;a href=&quot;' . $url_prefix . '/account:you/start/notifications&quot;&gt;'._('notifications').'&lt;/a&gt;&lt;/li&gt;'.
+					'&lt;li&gt;&lt;a href=&quot;' . $url_prefix . '/account:you/start/watched-changes&quot;&gt;'._('watched pages').'&lt;/a&gt;&lt;/li&gt;'.
+					'&lt;li&gt;&lt;a href=&quot;' . $url_prefix . '/account:you/start/watched-forum&quot;&gt;'._('watched discussions').'&lt;/a&gt;&lt;/li&gt;'.
 					'&lt;li&gt;&lt;a href=&quot;javascript:;&quot; onclick=&quot;WIKIDOT.page.listeners.logoutClick(event)&quot;&gt;'._('logout').'&lt;/a&gt;&lt;/li&gt;' .
 					'&lt;/ul&gt;&lt;/div&gt;';
 </diff>
      <filename>php/modules/LoginStatusModule.php</filename>
    </modified>
    <modified>
      <diff>@@ -44,5 +44,10 @@ if(!defined('WIKIDOT_SETUP_COMPLETED')){
 	require_once (WIKIDOT_ROOT.DIRECTORY_SEPARATOR.&quot;lib/ozone/php/core/functions.php&quot;);
 	require_once (WIKIDOT_ROOT.DIRECTORY_SEPARATOR.&quot;lib/ozone/php/core/autoload.inc.php&quot;);
 	
+	if (! GlobalProperties::$WIKI_FARM) {
+		$_SERVER['HTTP_HOST'] = GlobalProperties::$URL_HOST;
+		GlobalProperties::$SESSION_COOKIE_DOMAIN = null;
+	}
+	
 	define('WIKIDOT_SETUP_COMPLETED', true);
 }</diff>
      <filename>php/setup.php</filename>
    </modified>
    <modified>
      <diff>@@ -18,7 +18,7 @@
  * 
  * @category Wikidot
  * @package Wikidot
- * @version $Id$
+ * @version $Id: CodeblockExtractor.php,v 1.2 2008/08/05 21:00:26 quake Exp $
  * @copyright Copyright (c) 2008, Wikidot Inc.
  * @license http://www.gnu.org/licenses/agpl-3.0.html GNU Affero General Public License
  */
@@ -27,45 +27,37 @@ class CodeblockExtractor {
 
 	protected $mimeType = null;
 	protected $contents = &quot;&quot;;
+	protected $treatAsTemplate = false;
+	protected $templateVariables = array();
 	
 	protected $mimeMap = array(
 		&quot;css&quot;	=&gt; &quot;text/css&quot;,
 		&quot;html&quot;	=&gt; &quot;text/html&quot;,
 	);
 	
-	public function __construct($site, $pageName, $codeblockNo = 1){
+	public function __construct($site, $pageName, $codeblockNo = 1, $templateVars = null){
 		try {
 			$codeblockNo = (int) $codeblockNo;
 			if ($codeblockNo &lt; 1) {
 				$codeblockNo = 1;
 			}
 			
-			/* Check the cache. */
+			$page = DB_PagePeer::instance()-&gt;selectByName($site-&gt;getSiteId(), $pageName);
 			
-			$mkey = 'pagecodeblocks..' . $site-&gt;getSiteId() . '..' . $pageName;
-			$m = OZONE::$memcache;
-			$allMatches = $m-&gt;get($mkey);
-			if(!$allMatches) {
-				
-				$page = DB_PagePeer::instance()-&gt;selectByName($site-&gt;getSiteId(), $pageName);
-				
-				if($page == null){
-					throw new ProcessException(&quot;No such page&quot;);
-				}
-				// page exists!!! wooo!!!
-				
-				$source = $page-&gt;getSource();
-				/* Get code block. */
-				
-				$regex = ';^\[\[code(\s[^\]]*)?\]\]((?:(?R)|.)*?)\[\[/code\]\](\s|$);msi';
-				
-				$allMatches = array();
-				preg_match_all($regex, $source, $allMatches);
-				
-				$m-&gt;set($mkey, $allMatches, 0, 3600);
+			if($page == null){
+				throw new ProcessException(&quot;No such page&quot;);
 			}
+			// page exists!!! wooo!!!
+			
+			$source = $page-&gt;getSource();
+			/* Get code block. */
+			
+			$regex = ';^\[\[code(\s[^\]]*)?\]\]((?:(?R)|.)*?)\[\[/code\]\](\s|$);msi';
 			
-			if(count($allMatches[2]) &lt; $codeblockNo ) {
+			$allMatches = array();
+			preg_match_all($regex, $source, $allMatches);
+			
+			if(count($allMatches[2]) &lt; $codeblockNo) {
 				throw new ProcessException('No valid codeblock found.');
 			}
 			
@@ -82,7 +74,13 @@ class CodeblockExtractor {
 				}
 			}
 			
-			$this-&gt;contents = trim($code).&quot;\n&quot;;
+			$code = trim($code) . &quot;\n&quot;;
+			
+			if (is_array($templateVars)) {
+				$this-&gt;contents = $this-&gt;renderSimpleTemplate($code, $templateVars);
+			} else {
+				$this-&gt;contents = $code;
+			}
 			
 		} catch(Exception $e) {
 			$this-&gt;contents = $e-&gt;getMessage();
@@ -99,5 +97,24 @@ class CodeblockExtractor {
 		}
 		return &quot;text/plain&quot;;
 	}
+	
+	public function renderSimpleTemplate($template, $context) {
+		$template = &quot;\n$template\n&quot;;
+		$template_parts = explode(&quot;\n---\n&quot;, $template);
+		$form_def = array_shift($template_parts);
+		$template = trim(implode(&quot;\n---\n&quot;, $template_parts));
+		
+		$form = Wikidot_Form::fromYaml($form_def);
+		
+		foreach ($form-&gt;fields as $name =&gt; $field) {
+			$variable = '$(' . $name . ')';
+			$value = $field['default'];
+			if (isset($context[$name])) {
+				$value = $context[$name];
+			}
+			$template = str_replace($variable, $value, $template);
+		}
+		return $template;
+	}
 
 }</diff>
      <filename>php/utils/CodeblockExtractor.php</filename>
    </modified>
    <modified>
      <diff>@@ -38,6 +38,8 @@ class GlobalProperties {
 	public static $SERVICE_NAME;
 	public static $URL_DOMAIN;
 	public static $URL_HOST;
+	public static $WIKI_FARM;
+	public static $HTTP_PORT;
 	
 	// security settings
 	public static $USE_SSL;
@@ -46,6 +48,7 @@ class GlobalProperties {
 	public static $USE_UPLOAD_DOMAIN;
 	public static $URL_UPLOAD_DOMAIN;
 	public static $RESTRICT_HTML;
+	public static $SECRET_MANAGE_SUPERADMIN;
 	
 	// database settings
 	public static $DATABASE_SERVER;
@@ -143,6 +146,16 @@ class GlobalProperties {
 		}
 		return $value;
 	}
+
+	protected static function fromFile($file) {
+		if ($fp = @fopen(WIKIDOT_ROOT . '/conf/' . $file, 'r')) {
+			$s = fread($fp, 4096);
+			fclose($fp);
+		} else {
+			$s = &quot;&quot;;
+		}
+		return trim($s);
+	}
 	
 	/**
 	 * read wikidot.ini file
@@ -154,17 +167,27 @@ class GlobalProperties {
 		self::$iniConfig = parse_ini_file(WIKIDOT_ROOT . &quot;/conf/wikidot.ini&quot;, true);
 		
 		// main settings
-		self::$SERVICE_NAME				= self::fromIni(&quot;main&quot;,		&quot;service&quot;);			// no default!
-		self::$URL_DOMAIN				= self::fromIni(&quot;main&quot;,		&quot;domain&quot;);			// no default!
-		self::$URL_HOST					= self::fromIni(&quot;main&quot;,		&quot;main_wiki&quot;,		&quot;www.&quot; . self::$URL_DOMAIN);
+		self::$WIKI_FARM				= self::fromIni(&quot;main&quot;,		&quot;wiki_farm&quot;,	false);
+		self::$HTTP_PORT				= self::fromIni(&quot;main&quot;,		&quot;port&quot;,			8080);
+
+		if (self::$WIKI_FARM) {
+			self::$SERVICE_NAME			= self::fromIni(&quot;main&quot;,		&quot;service&quot;);		//no default
+			self::$URL_DOMAIN			= self::fromIni(&quot;main&quot;,		&quot;domain&quot;,		&quot;singlewiki.wikidot.dev&quot;);
+			self::$URL_HOST				= self::fromIni(&quot;main&quot;,		&quot;main_wiki&quot;,	&quot;www.&quot; . self::$URL_DOMAIN);
+		} else {
+			self::$SERVICE_NAME			= &quot;&quot;;
+			self::$URL_DOMAIN			= self::fromIni(&quot;main&quot;,		&quot;domain&quot;,		&quot;singlewiki.wikidot.dev&quot;);
+			self::$URL_HOST				= self::fromIni(&quot;main&quot;,		&quot;main_wiki&quot;,	&quot;www.&quot; . self::$URL_DOMAIN);
+		}
 		
 		// security settings
-		self::$SECRET					= self::fromIni(&quot;security&quot;,	&quot;secret&quot;);					// no default!
+		self::$SECRET					= self::fromIni(&quot;security&quot;,	&quot;secret&quot;,					self::fromFile('secret'));
 		self::$USE_SSL					= self::fromIni(&quot;security&quot;,	&quot;ssl&quot;,						false);
 		self::$SECRET_DOMAIN_LOGIN		= self::fromIni(&quot;security&quot;,	&quot;secret_login&quot;,				self::$SECRET . &quot;_custom_domain_login&quot;);
 		self::$USE_UPLOAD_DOMAIN		= self::fromIni(&quot;security&quot;,	&quot;upload_separate_domain&quot;,	false);
 		self::$URL_UPLOAD_DOMAIN		= self::fromIni(&quot;security&quot;,	&quot;upload_domain&quot;,			&quot;wd.files.&quot; . self::$URL_DOMAIN);
 		self::$RESTRICT_HTML			= self::fromIni(&quot;security&quot;,	&quot;upload_restrict_html&quot;,		true);
+		self::$SECRET_MANAGE_SUPERADMIN = self::fromIni(&quot;security&quot;, &quot;secret_manage_superuser&quot;,  md5(self::$SECRET . '_super_admin'));
 		
 		// database settings
 		self::$DATABASE_USER			= self::fromIni(&quot;db&quot;,		&quot;user&quot;);			// no default!</diff>
      <filename>php/utils/GlobalProperties.php</filename>
    </modified>
    <modified>
      <diff>@@ -158,20 +158,28 @@ class UploadedFileFlowController extends WikidotController {
 	 * @param string $fileName code/pagename/number
 	 * @param int $expires timeout in seconds
 	 */
-	protected function serveCode($site, $fileName, $expires = 0) {
+	protected function serveCode($site, $fileName, $expires = 0, $restrict_html = false) {
 		$m = array();
 
-		if (preg_match(&quot;;^code/([^/]+)(?:/([0-9]+))?$;&quot;, $fileName, $m)) {
+		if (preg_match(&quot;;^code/([^/]+)/?(?:/([0-9]+))?(?:(/r/)(.*))?$;&quot;, $fileName, $m)) {
 			$pageName = $m[1];
 			$number = 1;
 			if (isset($m[2])) {
 				$number = (int) $m[2];
 			}
-				
-			$ext = new CodeblockExtractor($site, $pageName, $number);
+			if (isset($m[3])) {
+				$params = array();
+				if (isset($m[4])) {
+					parse_str($m[4], $params);
+				}
+			} else {
+				$params = null;
+			}
+			
+			$ext = new CodeblockExtractor($site, $pageName, $number, $params);
 			
 			$mime = $ext-&gt;getMimeType();
-			if (GlobalProperties::$RESTRICT_HTML &amp;&amp; in_array($mime, self::$HTML_MIME_TYPES)) {
+			if ($restrict_html &amp;&amp; preg_match(self::$HTML_MIME_TYPES, $mime)) {
 				$mime = self::$HTML_SERVE_AS;
 			}
 			$this-&gt;setContentTypeHeader($mime);
@@ -237,7 +245,7 @@ class UploadedFileFlowController extends WikidotController {
 			if ($this-&gt;publicArea($site, $file)) {
 					
 				if ($this-&gt;isCodeRequest($file)) {
-					$this-&gt;serveCode($site, $file, 3600);
+					$this-&gt;serveCode($site, $file, 3600, GlobalProperties::$RESTRICT_HTML);
 				} else {
 					$this-&gt;serveFileWithMime($path, 3600, GlobalProperties::$RESTRICT_HTML);
 				}</diff>
      <filename>php/utils/UploadedFileFlowController.php</filename>
    </modified>
    <modified>
      <diff>@@ -175,8 +175,10 @@
 			 		&lt;/a&gt;
 			 		
 	 			&lt;/div&gt;
-	 			Part of &lt;a href=&quot;http://{$URL_HOST}&quot;&gt;{$SERVICE_NAME|escape}&lt;/a&gt;
-	 			&amp;#8212; 
+				{if $SERVICE_NAME!=&quot;&quot;}
+	 				Part of &lt;a href=&quot;http://{$URL_HOST}&quot;&gt;{$SERVICE_NAME|escape}&lt;/a&gt;
+	 				&amp;#8212; 
+				{/if}
  				Powered by &lt;a href=&quot;http://www.wikidot.org/&quot;&gt;Wikidot&lt;/a&gt;
 	 		&lt;/div&gt;
 	 		{if $licenseText!=&quot;&quot;}
@@ -247,4 +249,4 @@
  	&lt;div style=&quot;display:none&quot; id=&quot;dummy-ondomready-block&quot;&gt;&lt;/div&gt;
   &lt;/body&gt;
 
-&lt;/html&gt;
\ No newline at end of file
+&lt;/html&gt;</diff>
      <filename>templates/layouts/WikiLayout.tpl</filename>
    </modified>
    <modified>
      <diff>@@ -38,6 +38,7 @@ WIKIDOT.modules.LoginModule.listeners = {
 	
 	switchUser: function(e){
 		setCookie('welcome', null, -100000, '/', '.'+URL_DOMAIN);
+		setCookie('welcome', null, -100000, '/');
 		window.location.reload();
 	},
 	
@@ -72,12 +73,12 @@ WIKIDOT.modules.LoginModule.callbacks = {
 		if(originalUrl){
 			window.location.href=originalUrl;
 		}else{
-			window.location.href='http://'+URL_HOST;
+			window.location.href='http://'+window.location.host;
 		}
 	},
 	
 	cancel: function(r){
-		window.location.href='http://'+window.location.hostname;
+		window.location.href='http://'+window.location.host;
 	}
 }
 </diff>
      <filename>web/files--common/modules/js/login/LoginModule.js</filename>
    </modified>
  </modified>
  <removed type="array">
    <removed>
      <filename>files/lighttpd-wikidot.conf.orig</filename>
    </removed>
    <removed>
      <filename>files/lighttpd.conf</filename>
    </removed>
  </removed>
  <parents type="array">
    <parent>
      <id>93be9c3a45412a3781628939a9a25d5e70718d77</id>
    </parent>
  </parents>
  <author>
    <name>Piotr Gabryjeluk</name>
    <email>piotr@wikidot.com</email>
  </author>
  <url>http://github.com/gabrys/wikidot/commit/d60ca315c645f068421183d1f19ff684227340cf</url>
  <id>d60ca315c645f068421183d1f19ff684227340cf</id>
  <committed-date>2009-05-14T15:22:38-07:00</committed-date>
  <authored-date>2009-05-14T15:22:38-07:00</authored-date>
  <message>* a draft code templating system
* single wiki mode as the default
* Makefile-based build
* other improvements</message>
  <tree>c03408a31e24561ec1474af52240ba0d125c7784</tree>
  <committer>
    <name>Piotr Gabryjeluk</name>
    <email>piotr@wikidot.com</email>
  </committer>
</commit>
