__EOF
cruciforum = {
init: function() {
cruciforum.hideUsernamesOnThreadList();
cruciforum.hijackSubmitMethod();
cruciforum.loadSavedUserDetails();
cruciforum.focusTextArea();
},
focusTextArea: function() {
var tas = document.getElementsByTagName('textarea');
if (tas.length > 0) {
tas[0].focus();
tas[0].onkeypress = function() {
// enable submit button!
var inps = document.getElementsByTagName('input');
for (var j=0; j 0) {
var last_style_node = document.styleSheets[document.styleSheets.length - 1];
if (typeof(last_style_node.addRule) == "object") last_style_node.addRule(selector, declaration);
}
},
createCookie: function (name,value,days) {
if (days) {
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else var expires = "";
document.cookie = name+"="+value+expires+"; path=/";
},
readCookie: function(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
}
return null;
},
eraseCookie: function(name) {
createCookie(name,"",-1);
}
};
/* DOMContentLoaded: http://www.kryogenix.org/days/2007/09/26/shortloaded */
(function(i) {
var u =navigator.userAgent;
var e=/*@cc_on!@*/false; var st =setTimeout;
if(/webkit/i.test(u)){st(function(){var dr=document.readyState;
if(dr=="loaded"||dr=="complete"){i()}else{st(arguments.callee,10);}},10);}
else if((/mozilla/i.test(u)&&!/(compati)/.test(u)) || (/opera/i.test(u))){
document.addEventListener("DOMContentLoaded",i,false); } else if(e){ (
function(){var t=document.createElement('doc:rdy');try{t.doScroll('left');
i();t=null;}catch(e){st(arguments.callee,0);}})();}else{window.onload=i;}})(cruciforum.init);
__EOF
,
"themes/selected/cruciforum.css" => <<<__EOF
body {
color: #343;
background-color: #cec;
font-family: "Lucida Bright", Lucidabright, Georgia,
"Bitstream Vera Serif", serif; /* http://clagnut.com/blog/266/ */
}
h1 {
background: #bdb;
margin: 0 0 1em 0;
padding: 0.3em;
}
#posts dt { clear: left; }
#posts dt p { margin: 0; font-size: 10px; display: inline; color: #666;
}
#posts dt p a { color: #66c;}
#posts dd { padding-left: 43px; float: left; margin: 0;
min-height: 30px; }
#posts dd p { margin-top: 0; }
p.gravatar img { position: relative; top: 32px; }
#nav { clear: left; padding-top: 1em; text-align: center; }
#nav p { display: inline; border: 1px solid #666; border-width: 0 1px;
padding: 0 5px; }
#threads, #threads li {
list-style: none;
margin: 0;
padding: 0;
}
#threads li a {
padding-left: 20px;
background-color: #bdb;
}
#threads li a:visited {
background-color: #cec;
}
label {
float: left;
clear: left;
width: 10em;
}
input, textarea {
border: 2px solid #666;
padding: 0.5em;
width: 25em;
}
.postform p.submit { margin-left: 10em; }
p.submit input {
width: auto;
border-style: outset;
}
.postform p { margin: 1em 0 0 0; }
.postform p.note {
margin-left: 14.28em; /* 10em / 0.7em */
margin-top: 0;
font-size: 0.7em;
}
p.note, p.note a {
color: #999;
}
__EOF
,
"list.tmpl" => <<<__EOF
{{FORUMNAME}}
{{FORUMNAME}}
__EOF
,
"thread.tmpl" => <<<__EOF
{{THREADTITLE}} : {{FORUMNAME}}
{{THREADTITLE}} - {{FORUMNAME}}
{{FIRSTPOST}}
__EOF
,
"new.html" => <<<__EOF
{{FORUMNAME}}
Start a new topic
Back to the list
__EOF
,
"tpost.tmpl" => <<<__EOF
{{THREADTITLE}} - {{FORUMNAME}}
Reply to {{THREADTITLE}}
Message:
HTML will not be interpreted. Use Textile to get formatting.
__EOF
);
$extras = Array(
"installation_header" => <<<__EOF
Installing Cruciforum
Installing Cruciforum
Welcome to Cruciforum! The installation process will now run.
__EOF
,
"thread_page_post" => <<<__EOF
Author: {{NAME}}
Web: {{WEBSITE}}
Email: {{EMAIL}}
(all posts by {{NAME}} )
When: {{DATE}}
{{TEXT}}
__EOF
,
"index_page_link" => <<<__EOF
{{THREADTITLE}}
by {{NAME}}
on {{DATE}}
__EOF
,
"ask_for_forum_name" => <<<__EOF
Please choose a name for your forum!
__EOF
);
$action = $_REQUEST["action"];
if (!isset($action)) $action = "check_install";
if ($action != "upgrade") check_if_upgrade_required();
switch ($action) {
case "check_install": check_install(); break;
case "install": install(); break;
case "newthread": newthread(); break;
case "newpost": newpost(); break;
case "search": search(); break;
case "email": email(); break;
case "upgrade": upgrade(); break;
default: badcall();
}
function check_if_upgrade_required() {
if (!file_exists("list.tmpl")) return;
$fromto = get_upgrade_values();
if ($fromto[0] != $fromto[1]) {
echo "This forum is currently Cruciforum $fromto[0] and needs to be upgraded to $fromto[1]. ";
echo 'You need to run the upgrade process .';
die();
}
}
function get_upgrade_values() {
// open list.tmpl and check its generator tag
global $VERSION;
$listtmpl = file_get_contents("list.tmpl");
$lines = explode("\n", $listtmpl);
$generated_by = "1.1";
foreach ($lines as $line) {
$isgen = preg_match(
'/ /',
$line,
$matches);
if ($isgen) {
$generated_by = $matches[1];
}
}
return array($generated_by, $VERSION);
}
function upgrade() {
$fromto = get_upgrade_values();
$from = floatval($fromto[0]);
echo "Upgrading Cruciforum \n";
// notice that we fall through from each case
switch(true) {
case $from < 1.1: upgrade10to11();
case $from < 1.2: upgrade11to12();
case $from < 1.21: upgrade12to121();
}
write_out_template_files();
echo "Your forum is now upgraded to Cruciforum $fromto[1]. ";
echo 'Knock yourself out! ';
die();
}
function upgrade10to11() {
echo "Upgrade from 1.0 to 1.1 \n";
// empty upgrade!
echo "Done.
";
}
function upgrade11to12() {
echo "Upgrade from 1.1 to 1.2 \n";
$allfiles = get_all_html_filenames();
echo "Add generator tag to files ";
echo "";
foreach ($allfiles as $file) {
$data = file_get_contents($file);
$data = str_replace(
"
\n",
"\n \n",
$data);
file_put_contents($file, $data);
echo $file . " ";
}
echo "
";
echo "Done.
";
}
function upgrade12to121() {
echo "Upgrade from 1.2 to 1.21 \n";
$allfiles = get_all_html_filenames();
echo "\n";
echo "Add content type \n";
echo "Make individual posts hyperlinkable \n";
echo "Add script type \n";
echo "Upgrade generator tag \n";
echo "Fix ampersand and alt attribute in gravatar URL \n";
echo "Fix ampersand in email URL \n";
echo "Fix ampersand in search URL \n";
echo " \n";
echo "";
foreach ($allfiles as $file) {
$data = file_get_contents($file);
// add content type
$data = str_replace(
"
\n",
"\n \n",
$data);
// make individual posts hyperlinkable
$data = preg_replace(
'/When: ([^<]+)<\/p>/',
'
When: $1
',
$data);
// add script type
$data = preg_replace(
'/