Example #1
0
	function __construct ($debug_level=0) {
		$php_errormsg = '';
		if ($debug_level) $this->debug_level = $debug_level;
		if ($this->debug_level>0) printf("\nDEBUG_LEVEL: %s <br>\n",$this->debug_level);
		$this->exceptions();
		$this->sys_log();

		//local function variables
		$congif_simple_xml = simplexml_load_file(CONFIG_XML_FILE);	//container for xml object tree

		if ($congif_simple_xml === FALSE) {
			sys_log::create_log("Error while parsing XML configuration document for database connection",ADMIN_EMAIL);
			$status["location"] = "db_connection";
			$status["exception_type"] = "fail at constructor";
			$status["error"] = $php_errormsg;
			exceptions::halt($status);
		}

		// extract information for DB connection
		$this->username = $congif_simple_xml->DatabaseAccount->username;
		$this->password = $congif_simple_xml->DatabaseAccount->password;
		$this->host = $congif_simple_xml->DatabaseAccount->host;
		$this->port = $congif_simple_xml->DatabaseAccount->port;
		$this->database = $congif_simple_xml->DatabaseAccount->database;
		$this->client_flags = $congif_simple_xml->DatabaseAccount->client_flags;
		$this->new_connection = $congif_simple_xml->DatabaseAccount->new_connection;
		$this->tty = $congif_simple_xml->DatabaseAccount->tty;
		$this->security_level = $congif_simple_xml->DatabaseAccount->security_level;

		// establish connection
		$this->connect ();

		register_shutdown_function(array(&$this, 'close'));
	}
Example #2
0
// this constant is used to send an e-mail to the address
// given as its value for critical errors
//define ("ADMIN_EMAIL", "*****@*****.**");
//define ("LOG_FILE", "/var/www/logs/php_app_log");

// this is to set $php_errormsg on errors
$error_tracking = ini_set("track_errors","1");
if ($error_tracking===false || $error_tracking===null) {
  //prepare available values
  $status["location"] = "sys_log.app";
  $status["exception_type"] = "track errors";
  $status["error"] = "failed to set php.ini flag to track_errors=1";

  //log and then halt
  exceptions::halt($status);
}

class sys_log {

  //*****  member variables
  var $date = "";	//private
  var $location = "";	//private
  var $info_array = array ();	//protected
  var $message = "";	//protected
  var $error = "";	//protected
  var $errno = "";	//protected

  //*****  class constructor
  //private
  //needs to be explicitly called from extending function
Example #3
0
  function log_halt ($exception="",$email=null) {

    //declare array for status
    $status = array ();

    //prepare available values
    $status["location"] = $this->location;
    $status["exception_type"] = $exception;
    $status["error"] = $this->error;
    $status["errno"] = $this->errno;
    $status["info"] = $this->info_array;

    //log and then halt
    $this->log ($email);
    exceptions::halt($status);
  }