Location: PHPKode > projects > GroundOS > groundos/logic/rootclass/rootclass.class.php
<?php
/**
 * /logic/rootclass/rootclass.class.php
 *
 * This is the root class from which all other classes descend.  If you're writing a new class period, whether for your own app or just to mod AgaresCore 4, you should always base your class off of rootclass
 * 
 * @package AgaresCore4
 * @author Agares Media <hide@address.com>
 * @copyright Copyright (c) 2007, 2008, 2009 Agares Media.  All rights reserved.
 */
 
class rootclass {
	/*
	 * Error Reporting
	 * 
	 * This is the error reporting method which will give detailed information on each error
	 */
	public function errorReport($e, $additionalMessage = NULL) {
		global $debug, $body_output;
	    // if error has been supressed with an @
	    if (error_reporting() == 0) {
	        return;
	    }
		if($debug==true) {
			$arr = get_defined_vars();
			echo '<div style="padding:25px 25px 25px 25px;border:1px solid #999999;font-family:Courier New,Terminal,Fixedsys,Courier;background:#eff5fe;color:#000000;">';
			echo '<h1>AgaresCore 4 Error Report</h1>';
			echo '<br />' . $additionalMessage. ' <br /><br />';
			echo '<b>ERROR MESSAGE:</b> ' . $e->getMessage() . '<br /><br />';
			echo '<b>CODE:</b> ' . $e->getCode() . '<br /><br />';
			echo '<b>FILENAME:</b> ' . $e->getFile() . '<br /><br />';
			echo '<b>ON LINE #</b>' . $e->getLine() . '<br /><br />';
			echo '<b>BACKTRACE:</b> <pre>'; print_r($e->getTrace()); echo '</pre><br /><br />';
			echo '<b>BACKTRACE:</b> '. $e->getTraceAsString(). '<br /><br />';
			echo '<b>VARIABLES:</b> <pre>';print_r(array_keys(get_defined_vars())); echo '</pre><br /><br />';
			echo '<b>VARIABLE VALUES:</b> <pre>';print_r($arr); echo '</pre><br /><br />';		
			echo '</div>';
		} else {
			$body_output .= '<div class="error">' . $e->getCode() . ' ' .$e->getMessage() .'</div>';
		}
	}

	/*
	 * Test for numeric data
	 * 
	 * For security purposes, this method allows you to validate whether or not the inputed data is numeric.
	 */
	public function numeric($input) {
		try {
			if (is_numeric($input)) {
				return $input;
			} else {
				throw new Exception('Non numeric data given when only numeric data accepted.');
			}
		} catch(Exception $e) {
			$this->errorReport($e, 'FATAL EXCEPTION.');
			exit; // This exception is always fatal.
		}
	}

	/*
	 * Clean strings
	 * 
	 * The clean method helps prevent against SQL injections.  A MySQL database connection has to be
	 * open for the clean() method to work.
	 */
	public function clean($input) {
		try {
			global $installed;
			if($installed==true) {
				return mysql_real_escape_string($input);
			} else {
				return $input;
			}
		} catch(Exception $e) {
			$this->errorReport($e, 'FATAL EXCEPTION.');
			exit; // This exception is always fatal.
		}
	}	
	
	/**
	 * debug() Method
	 * 
	 * This global method allows you to easily pass debug messages to the debug window
	 * @access public
	 * @param string $message The message you would like to send to the debugger 
	 * @param boolean $notags If this is set to true, then the debug message is sent without opening and closing javascript tags
	 * @return void
	 */
	public function debug($message, $notags=false) {
		global $headbottom_output, $debug;
		if($debug==true) {
			if($notags==false) {
				$headbottom_output .= '<script type="text/javascript"><!--//--><![CDATA[//><!--
';
			}
			$headbottom_output .= 'top.debug("'.$message.'");
';
			if($notags==false) {
				$headbottom_output .= '//--><!]]></script>
';
			}
		}
	}
	
	

}

?>
Return current item: GroundOS