Forum core source dump (as of July 31)

I would have finished this a while ago, but I’m in the middle of moving to a new apartment. Until that’s over, I figured I’ll dump what I have so far on the forum.

And I’ve finally settled on a name for this. I shall hereby call this forum script : theForum. Yeah, points for originality there. And of course, this will contain errors, incomplete functions/functionality and other terrible things, so be careful when using any part of this in your own projects. And on top of that the WordPress source code formatting is a bit off making error checking even more vital.

WARNING: This will be a very, very, very long post (7 pages total)!

index.php

/*

	#### theForum : A brand you can trust ####

*/



/******************************************************************************

	Modifying anything below will void the (non-existent) warranty!

*******************************************************************************/

// WARNING: Keep these intact.

// Root location
$rt = dirname(__FILE__) . '/';

// Get the main logic
require_once($rt . 'lib/main.php');

config.php

/******************************************************************************

	Edit your database settings here... (These values go in quotes)

*******************************************************************************/

// Your database server
$presets['db_host'] = 'localhost';

// Database name
$presets['db_name'] = 'wrex';

// Database admin name
$presets['db_user'] = 'wrex_user';

// Database admin password
$presets['db_pass'] = 'password';

// Database type
$presets['db_type'] = 'MySQL';


/******************************************************************************

	Edit your forum settings here... (Some settings require quotes)

*******************************************************************************/


// Forum title (you can include some HTML tags, but they will be stripped for page <title> tags)
$presets['site_title'] = 'the<span>Forum</span>';

// Slogan
$presets['site_slogan'] = 'A brand you can trust';

// Copyright notice
$presets['site_copyright'] = 'Copyright © 2009. All rights reserved.';

// Full site url
$presets['site_url'] = 'http://localhost/';


// Topics per page
$presets['page_topic_limit'] = 15;

// Replies per page
$presets['page_reply_limit'] = 10;


// The relative path to the forums for various paths in themes
$presets['site_path'] = '/';

$presets['site_path_seperator'] = ' » ';

// Present friendly, SEO friendly, URLs by avoiding querystring usage
// (this requires a .htaccess file for Apache or a map/ISAPI filter for IIS)
$presets['site_friendly_urls'] = '1';

// Allow self service creation of accounts. Admins can still create users. (True = 1 / False = 0)
$presets['site_registration'] = '1';

// The default template and styles.
$presets['site_theme'] = 'Section5';

// Closed for maintenance. If set to true, the "Forums closed" message will be displayed
// True = 1 / False = 0
$presets['site_closed'] = '0';

// Forums closed message in HTML format
$presets['site_closed_message'] = '<p>The forums are closed for maintenance. Please check back later.</p>';

// Welcome message (Don't change the "WELCOME" parts). You need to use HTML.
$presets['site_welcome'] =< <<WELCOME



<h2>Welcome
<h3>This is a demonstration template</h3>
<p>Rockwell Accessible is an experimental theme designed to improve web accessibility while maintaining a logical HTML structure. This is one variation of the base theme which is an example of customizability. The idea is to make any changes to the stylesheet while leaving the rest of the HTML intact. It includes provisions for error/notification formatting as well as text and link highlighting.</p>
<p>Read the accompanying <a href="https://eksith.wordpress.com/2009/02/16/rockwell-accessible/">blog post</a>.</p>



WELCOME;

// Footer HTML including copyrights and links etc...
$presets['site_footer'] =< <<FOOTER

	<p>
	<p class="powered">
		<a href="https://eksith.wordpress.com/"><img src="/templates/RockwellGradient/img/ouroboros.png" alt="Design by Eksith" longdesc="https://eksith.wordpress.com/" height="30" width="30" /></a>
	</p>

FOOTER;


/******************************************************************************

	##################### End casual editing #####################
	Edit below (if you know what you're doing) at your own risk!

*******************************************************************************/



// Root location of this file. All file inclusions depend on this.
$presets['site_root'] = dirname(__FILE__) . '/';

// Write enabled directories are required. Please disable execute privileges on these as a security precaution.
$presets['site_upload_directory'] = $presets['site_root'] . 'data/uploads';
$presets['site_cache_directory'] = $presets['site_root'] . 'data/cache';
$presets['site_cache_duration'] = '160';

// The template url is dependent on the SITE_THEME and SITE_TEMPLATE values.

$presets['site_template_directory'] = $presets['site_path'] . 'templates/';
$presets['site_template_url'] = $presets['site_path'] . 'templates/' . $presets['site_theme'] . '/';

// Default language to use in two letter format (preset is English).
$presets['site_lang'] = 'en';


// Security regular expressions
$presets['core_regex_valid_username'] = '/^[\w-_]{4,50}/iu';
$presets['core_regex_valid_displayname'] = '/^[\w\s\.-_]{0,100}/iu';
$presets['core_regex_valid_email'] = '/^[a-zA-Z0-9._-]+@[a-zA-Z0-9-]+\.[a-zA-Z.]{2,5}$/i';
$presets['core_regex_valid_querystring'] = '/^[\d-_a-zA-Z]/i';
$presets['core_regex_valid_htmlparams'] = '/^[\w-_]{4,20}/i';
$presets['core_regex_valid_colors'] = '/^#(([a-fA-F0-9]{3}$)|([a-fA-F0-9]{6}$))/i';
$presets['core_regex_invalid_search'] = '/^[~!\|\'()\[\]\< \>;]/i';

// Formatting allowed HTML tags and allowed corresponding attributes

// Convert deprecated tags.
// Convention: array([old tag], [new tag + formatting], [end tag]);
$presets['ui_format_tags_deprecated'] = array(
	array('b', 'strong', 'strong'),
	array('i', 'em', 'em'),
	array('s', 'span style="text-decoration:strikethrough;"', 'span'),
	array('strike', 'span style="text-decoration:strikethrough;"', 'span'),
	array('center', 'div style="text-align:center"', 'div'),
	array('left', 'div style="text-align:left"', 'div'),
	array('right', 'div style="text-align:right"', 'div'),
	array('u', 'span style="text-decoration:underline;"', 'span')
);

// Allowed HTML tags. All others, except for those found above, will be stripped
// Convention: array([tag name], [allowed attributes]);
$presets['ui_format_tags'] = array(
	array('a', 'style,class,title,href,rel,target'),
	array('abbr', 'style,class,title'),
	array('acronym', 'style,class,title'),
	array('blockquote', 'style,class,title,dir,lang,xml:lang'),
	array('br', 'style,class'),
	array('caption', 'style,class,title'),
	array('cite', 'style,class,title'),
	array('code', 'style,class,title'),
	array('del', 'style,class,title'),
	array('em', 'style,class,title'),
	array('h1', 'style,class,title'),
	array('h2', 'style,class,title'),
	array('h3', 'style,class,title'),
	array('h4', 'style,class,title'),
	array('h5', 'style,class,title'),
	array('h6', 'style,class,title'),
	array('hr', 'style,class'),
	array('img', 'style,class,src,height,width,border,hspace,vspace,alt,longdesc'),
	array('ins', 'style,class,title,cite'),
	array('li', 'style,class,title'),
	array('ol', 'style,class,title'),
	array('p', 'style,class,title,align,dir,lang,xml:lang'),
	array('pre', 'style,class,title,dir,lang,xml:lang'),
	array('strong', 'style,class,title'),
	array('span', 'style,class,title,dir,lang,xml:lang'),
	array('table', 'style,class,title,border\-collapse,bgcolor,background'),
	array('tfoot', 'style,class,title,align'),
	array('thead', 'style,class,title,align'),
	array('tbody', 'style,class,title,align'),
	array('td', 'style,class,title,align,valign'),
	array('th', 'style,class,title,align,valign'),
	array('tr', 'style,class,title,align,valign'),
	array('ul', 'style,class,title')
);

// Prohibited keywords in attribute values (from W3C)
// It is STRONGLY recommended that you not remove any of these 
// as certain browsers may allow their execution in unpredictable ways.
$presets['ui_format_invalid_attributes'] = array(
	'onabort',
	'onactivate',
	'onafterprint',
	'onafterupdate',
	'onbeforeactivate',
	'onbeforecopy',
	'onbeforecut',
	'onbeforedeactivate',
	'onbeforeeditfocus',
	'onbeforepaste',
	'onbeforeprint',
	'onbeforeunload',
	'onbeforeupdate',
	'onblur',
	'onbounce',
	'oncellchange',
	'onchange',
	'onclick',
	'oncontextmenu',
	'oncontrolselect',
	'oncopy',
	'oncut',
	'ondataavaible',
	'ondatasetchanged',
	'ondatasetcomplete',
	'ondblclick',
	'ondeactivate',
	'ondrag',
	'ondragdrop',
	'ondragend',
	'ondragenter',
	'ondragleave',
	'ondragover',
	'ondragstart',
	'ondrop',
	'onerror',
	'onerrorupdate',
	'onfilterupdate',
	'onfinish',
	'onfocus',
	'onfocusin',
	'onfocusout',
	'onhelp',
	'onkeydown',
	'onkeypress',
	'onkeyup',
	'onlayoutcomplete',
	'onload',
	'onlosecapture',
	'onmousedown',
	'onmouseenter',
	'onmouseleave',
	'onmousemove',
	'onmoveout',
	'onmouseover',
	'onmouseup',
	'onmousewheel',
	'onmove',
	'onmoveend',
	'onmovestart',
	'onpaste',
	'onpropertychange',
	'onreadystatechange',
	'onreset',
	'onresize',
	'onresizeend',
	'onresizestart',
	'onrowexit',
	'onrowsdelete',
	'onrowsinserted',
	'onscroll',
	'onselect',
	'onselectionchange',
	'onselectstart',
	'onstart',
	'onstop',
	'onsubmit',
	'onunload'
);




/******************************************************************************

	######################## End editing ########################

*******************************************************************************/

// Class loader (required)
function __autoload($class)
{
	global $presets;
	
	// Try and get a class file
	$cfile = $presets['site_root'] . 'lib/' . $class . '.class.php';
	
	// Or module file
	$mfile = $presets['site_root'] . 'modules/' . strtolower($class) . '/module.php';
	
	if(file_exists($cfile))
		require_once($cfile);
	elseif(file_exists($mfile))
		require_once($mfile);
	else
		exit("Unable to Find $class in the library folder or plugin modules folder");
	
	if(!class_exists($class, false))
		exit("Unable to load $class class");
}

6 thoughts on “Forum core source dump (as of July 31)

  1. Pingback: I have developer ADHD « This page intentionally left ugly

  2. This was a very interesting read for me!
    Although I have a question,
    I am a beginning php programmer, currently developing drupal modules on my internship, but looking to develop some sort of forum script/cms/framework/… . I’m not planning on actually making it public, it’s just a personal project to teach myself some things. So, my question…, I saw in your main.php you do:
    Core::getInstance and Modules::getInstance, is it the same as doing:
    $core = new Core();
    $core->getInstance(…); ? and did you have to define ‘Core’ somewhere or does php automatically recognise it as a class and searches for it (with the autoload function you wrote)?
    thanks in advance!

    You can contact me on my email if you want

    • Hi Jelle

      Yes, the basic idea is to let the autoload function load the class dynamically so you wouldn’t need to declare it elsewhere.

      Technically $core = new Core(); wouldn’t work in this case becuse the __construct function in that class is set to private.

      So you would always have to use the getInstance method when you want to create a new instance unless you’re calling new Core() inside the Core class itself.

  3. Pingback: (Snippet) Blocking IPs from a list file with PHP « This page intentionally left ugly

  4. Pingback: PHP Plugin/Module system | This page intentionally left ugly

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s