Location: PHPKode > projects > MpiBot > system/essential.php
<?php
	/* (C) Copyright 2004 Armond Carroll & Michael Thung.  All rights reserved.
	   Distrubuted under the BSD License.  Please see license.txt for license,
	   or http://www.opensource.org/licenses/bsd-license.php.

	   http://mpibot.sourceforge.net

	   Purpose of this file:
	   	To provide basic functions & constants for the entire bot.

	   File Version: 1.0
	   Last Modified: 4/30/2004 1:49AM
	*/

	// Some constants
	define('EOL', "\r\n"); // Not for the protocol, but the console

	define('OL_FATAL', 1);
	define('OL_WARNING', 2);
	define('OL_NOTICE', 4);
	define('OL_INFO', 8);
	define('OL_PROTORECV', 16);
	define('OL_PROTOSEND', 32);

	define('OUT_TIMESTAMP', 2);
	define('OUT_LINEBREAK', 4);
	define('OUT_TIMEANDBREAK', 7);

	define('from_server', '@server');
	define('bot', '@bot');

	define('MPI_VERSION', 'Alpha 1');

	// Basic Functions
	// (Btw, OL = Output Level)
	function out($msg, $level = OL_INFO, $timestamp = true, $linebreak = true) {
		global $output;
		if($timestamp && $level & $output) echo date('[h:ia] ');
		if($level & OL_PROTOSEND && $level & $output)
			echo '>>> ', $msg;
		elseif($level & OL_PROTORECV && $level & $output)
			echo '<<< ', $msg;
		elseif($level & OL_INFO && $level & $output)
			echo $msg;
		elseif($level & OL_NOTICE && $level & $output)
			echo 'Notice: ', $msg;
		elseif($level & OL_WARNING && $level & $output)
			echo 'Warning: ', $msg;
		elseif($level & OL_FATAL && $level & $output)
			die('Fatal Error: ' . $msg);
		if($linebreak && $level & $output) echo EOL;
	}

	function error($msg, $level = OL_FATAL) {
		out($msg, $level);
	}

	function inject($file) {
		if(file_exists($file)) {
			include_once($file);
			return true;
		} else {
			return false;
		}
	}

	function __autoload($class) {
		if(!inject("system/$class.class.php"))
			if(!inject("modules/$class.mod.php"))
				out("Could not load class $class as a module, or system class", OL_FATAL);
	}
?>
Return current item: MpiBot