<<<__EOF cruciforum = { init: function() { cruciforum.hideUsernamesOnThreadList(); cruciforum.hijackSubmitMethod(); cruciforum.loadSavedUserDetails(); }, hijackSubmitMethod: function() { var forms = document.getElementsByTagName('form'); console.log("hijacking"); for (var i=0; i 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

HTML will not be interpreted. Use Textile to get formatting.

About you

Not required, but it's sensible to put it in

Not required

Not required: obscured on the page, available so you can be emailed, and to get a Gravatar

Back to the list

__EOF , "tpost.tmpl" => <<<__EOF {{THREADTITLE}} - {{FORUMNAME}}

Reply to {{THREADTITLE}}

HTML will not be interpreted. Use Textile to get formatting.

About you

Not required, but it's sensible to put it in

Not required

Not required: obscured on the page, available so you can be emailed, and to get a Gravatar

__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 __EOF , "ask_for_forum_name" => <<<__EOF

Please choose a name for your forum!

__EOF ); $action = $_REQUEST["action"]; if (!isset($action)) $action = "check_install"; 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; default: badcall(); } function badcall() { echo "Bad call"; die(); } function check_install() { if (file_exists("list.tmpl")) { badcall(); } else { ask_for_forum_name(); } } function ask_for_forum_name() { global $extras, $files; echo $extras["installation_header"]; echo $extras["ask_for_forum_name"]; } function install() { global $extras, $files; $FORUMNAME = htmlentities(stripslashes($_POST["forumname"])); echo $extras["installation_header"]; // confirm that we can write files in this folder echo "

Checking that I can write files in this folder... "; $ret = @touch("index.html"); if (!$ret) failed_install_writing(); echo "done.

"; // write out template files echo "

Writing template files... "; foreach ($files as $fname => $text) { if (strpos($fname,"/") !== FALSE) { // name contains a folder @createfolder(dirname($fname)); } echo "$fname "; if ($fname == "new.html") { $text = str_replace("{{FORUMNAME}}", $FORUMNAME, $text); } $ret = @file_put_contents($fname, $text); if ($ret === FALSE) failed_install_template($fname); } echo "done.

"; // Create index.html write_from_template("list.tmpl", "index.html", Array("FORUMNAME"=>$FORUMNAME, "PREVPAGE"=>"index.html")); echo "

Writing forum name... "; file_put_contents("forumname", $FORUMNAME); echo "done.

"; echo '

Cruciform is now installed! Please go to your new forum.

'; } function write_from_template($tpl, $out, $vars) { $data = file_get_contents($tpl); $data = fill_template($data, $vars); createfolder(dirname($out)); file_put_contents($out,$data); } function fill_template($data, $vars) { foreach ($vars as $k => $v) { $data = str_replace("{{".$k."}}", $v, $data); } return $data; } function failed_install_writing() { echo 'FAIL

'; $curdir = getcwd(); if (stristr($_SERVER['SERVER_SOFTWARE'], 'apache')) { $soft = "Apache, which is likely to be called www-data, "; } elseif (stristr($_SERVER['SERVER_SOFTWARE'], 'IIS')) { $soft = "IIS, which is likely to be called IUSR_".php_uname("n").", "; } else { $soft = ""; } $uname = php_uname("s"); if (strtoupper(substr($uname, 0, 3)) === 'WIN') { $os = "Windows"; } else { $os = "a Unix of some description"; } echo <<<__EOF

Installation failed. I do not have permission to write files in this folder.

This machine appears to be using $os. You should give write permissions to this folder ($curdir) to the user account that runs $soft and then refresh this page.

__EOF; die(); } function failed_install_template($fname) { echo 'FAIL

'; echo <<<__EOF

Installation failed. Writing out the template file "$fname" failed.

__EOF; die(); } function search() { $parts = explode("cruciforum.php",$_SERVER["SCRIPT_NAME"]); $url = "http://" . $_SERVER["HTTP_HOST"] . $parts[0]; $user = $_GET["user"]; $srch = "http://www.google.com/search?q=inurl:$url+%22Author: $user%22"; header("Location: $srch"); } function email() { echo "not yet "; echo "email to "; global $FROMTR, $TOTR; $decemail = strtr($_GET["email"], $TOTR, $FROMTR); echo $decemail; die(); } function newthread() { // load passed data $textile = new Textile; $text = $textile->TextileRestricted(stripslashes($_POST["text"]),1); $name = trim(htmlentities(stripslashes($_POST["name"]))); if ($name == "") $name = "anonymous"; $subject = htmlentities(stripslashes($_POST["threadsubject"])); if ($subject == "") $subject = "(post by $name)"; $website = trim(htmlentities(stripslashes($_POST["website"]))); if ($website != "") { // prefix http if required if (strpos($website,"http") != 0) { $website = "http://" . $website; } $website = ""; } $email = trim(htmlentities(stripslashes($_POST["email"]))); global $FORUMNAME; if ($email != "") { global $FROMTR, $TOTR; $encemail = strtr($email, $FROMTR, $TOTR); $emailhref = ""; } else { $emailhref = ""; } // get the lock $lockfile = fopen('editing.lock','w'); flock($lockfile,LOCK_EX); // find highest post number and add 1 $next_post_number = getNextPostNumber(); $long_next_post_number = sprintf('%09d',$next_post_number); // create dt/dl for tN.html global $extras; $dtdl = fill_template($extras["thread_page_post"], Array( "TEXT" => $text, "NAME" => $name, "EMAIL" => $emailhref, "WEBSITE" => $website, "EMAILMD5" => md5($email), "DATE" => date('d/m/y H.i') )); // load thread.tmpl, write out tN.html write_from_template("thread.tmpl", makeFilename($next_post_number,"t"), Array( "THREADTITLE" => $subject, "FORUMNAME" => $FORUMNAME, "THREADID" => $long_next_post_number, "FIRSTPOST" => $dtdl )); // load tpost.tmpl, write out tpostN.html write_from_template("tpost.tmpl", makeFilename($next_post_number,"tpost"), Array( "THREADTITLE" => $subject, "FORUMNAME" => $FORUMNAME, "THREADID" => $long_next_post_number )); // create LI for index.html $li = fill_template($extras["index_page_link"], Array( "THREADTITLE" => $subject, "NAME" => $name, "THREADFILE" => makeFilename($next_post_number,"t"), "DATE" => date("jS M y") )); // load index.html $indexdata = file_get_contents("index.html"); // does index.html have too many threads in? $threadcount = substr_count($indexdata, '
  • s from index.html preg_match_all('/
  • .*?<\/li>/s', $indexdata, $matches); // use . instead of " or it doesn't work $new_page_parts = array_slice($matches[0], -$THREADS_PER_LIST_PAGE); $index_page_parts = array_slice($matches[0], 0, -($THREADS_PER_LIST_PAGE)); $new_page_lis = ""; $index_page_lis = ""; foreach ($new_page_parts as $part) { $new_page_lis .= $part . "\n"; } foreach ($index_page_parts as $part) { $index_page_lis .= $part . "\n"; } // remove all lis from indexdata $indexdata = preg_replace('/