Commit ba59200e by Frederick

init Dateien

1 parent 1e376b4e
<?php
/**
* @filesource class_Error.inc.php
*
* @category losp
* @copyright Copyright by mensch.coop e.G. 2009
* @mailto dev [at] mensch.coop
* @version 0.4.200901
* @link http://mensch.coop
*/
class Error extends mcReport {
public static $ErrorArray = array(
1 => 'E_ERROR',
2 => 'E_WARNING',
4 => 'E_PARSE',
8 => 'E_NOTICE',
16 => 'E_CORE_ERROR',
32 => 'E_CORE_WARNING',
64 => 'E_COMPILE_ERROR',
128 => 'E_COMPILE_WARNING',
256 => 'E_USER_ERROR',
512 => 'E_USER_WARNING',
1024 => 'E_USER_NOTICE',
2048 => 'E_STRICT',
4096 => 'E_RECOVERABLE_ERROR',
) ;
private static $ErrorList;
public static $Quantity=0;
private $ErrorFunction;
/**
* @var string code word for error level
*
* DevError - Error which is for user invisible
* DisplayError - Errir which is for user visible
*/
private $Title;
/**
* @var string code word for errors
*
* NoLoadBE - Error BE cant be load
* NoSaveBE - Error BE cant be save
* NoExistBE - Error BE not exist
* NoLinkBE - Error BE cant be link with others BEs
*/
private $Comment;
private $Code;
private $array_debug_backtrace;
private function __construct($param_title="",$param_comment="", $param_code=""){
$this->array_debug_backtrace = debug_backtrace();
$this->ErrorFunction = $this->array_debug_backtrace[2]["class"].$this->array_debug_backtrace[2]["type"]
.$this->array_debug_backtrace[2]["function"]."(...) :".$this->array_debug_backtrace[1]["line"]."";
$this->Title = $param_title;
$this->Comment = $param_comment;
$this->Code = $param_code;
}
/**
* @todo klar die Parameter definieren, es werden leider immer wieder unterschiedliche Werte übergeben
*
*
* @param <type> $param_title
* @param <type> $param_comment
* @param <type> $param_code
*/
public static function newError($param_title="",$param_comment="", $param_code="") {
global $_LOSP_DEV;
if($_LOSP_DEV) {
D::ulli('<b>'.$param_title.'</b> -- '.$param_comment.' -- '.$param_code);
}
self::$ErrorList[self::$Quantity] = new Error($param_title,$param_comment, $param_code);
mcReport::add(self::$ErrorList[self::$Quantity]);
self::$Quantity++;
}
protected function getTextMessage() {
if(is_null($this->TextMessage)) {
$this->TextMessage .= 'Title:'. mcCONST::TAB. $this->Title. mcCONST::LINEBREAK;
if(array_key_exists($this->Code, Error::$ErrorArray)) {
$this->TextMessage .= 'Typ:'. mcCONST::TAB. Error::$ErrorArray[$this->Code].mcCONST::LINEBREAK;
} else {
$this->TextMessage .= 'Code:'. mcCONST::TAB. $this->Code. mcCONST::LINEBREAK;
}
$this->TextMessage .= 'Notice:'. mcCONST::TAB. $this->Comment. mcCONST::LINEBREAK;
$this->TextMessage .= 'ErrorFnc:'. mcCONST::TAB. $this->ErrorFunction. mcCONST::LINEBREAK;
$this->TextMessage .= mcCONST::LINEBREAK;
}
return $this->TextMessage;
}
/********************************************************************************
* *
* XML Funktionen (Es wird jeweils immer ein DOMElement zurück gegeben)
* *
********************************************************************************/
protected function getDOMElement(DOMDocument $DOMDocument){
$DOMElement = parent::getDOMElement($DOMDocument);
$DOMElement->setAttribute('class', 'error');
$DOMElement->appendChild($DOMDocument->createElement('Function',$this->ErrorFunction));
$DOMElement->appendChild($DOMDocument->createElement('Title',$this->Title));
if($this->Comment) {
$DOMElement->appendChild($DOMDocument->createElement('Comment',$this->Comment));
}
$DOMElement->appendChild($DOMDocument->createElement('Code',$this->Code));
return $DOMElement;
}
public static function getAllXML($DOMDocument){
$DOMElement = $DOMDocument->createElement("ErrorList");
// D::ulli(self::$Quantity.'('.count(self::$ErrorList).'/'.self::$Quantity.'): '.$param_title);
for($i=0; $i<count(self::$ErrorList);$i++){
$DOMElement->appendChild(self::$ErrorList[$i]->getDOMElement($DOMDocument));
}
return $DOMElement;
}
}
?>
\ No newline at end of file
<?php
/**
* @filesource class_Message.inc.php
*
* @category losp
* @copyright Copyright by mensch.coop e.G. 2009
* @mailto dev [at] mensch.coop
* @version 0.4.200901
* @link http://mensch.coop
*/
class Message extends mcReport {
private static $MessageList;
private static $Quantity=0;
private $Kind;
private $ObjectClass;
private $ObjectName;
private function __construct($param_kind="", $param_objectClass="", $param_objectName="", array $param_values = array()){
$this->Kind = $param_kind;
$this->ObjectClass = $param_objectClass;
$this->ObjectName = $param_objectName;
$this->setValues($param_values);
// $this->Values = $param_values;
}
public static function newMessage($param_kind='',$param_objectClass='', $param_objectName='', $param_values = array()) {
self::$MessageList[self::$Quantity] = new Message($param_kind,$param_objectClass, $param_objectName, $param_values);
mcReport::add(self::$MessageList[self::$Quantity]);
self::$Quantity++;
}
protected function getDOMElement(DOMDocument $DOMDocument){
$DOMElement = parent::getDOMElement($DOMDocument);
$DOMElement->setAttribute('kind', $this->Kind);
$DOMElement->setAttribute('classLabel', $this->ObjectClass);
$DOMElement->setAttribute('name', $this->ObjectName);
$DOMElement->setAttribute('label', Language::getMessage($this->Kind, 'label'));
return $DOMElement;
}
public static function getAllXML($DOMDocument){
$DOMElement = $DOMDocument->createElement("MessageList");
for($i=0; $i<count(self::$MessageList);$i++){
$DOMElement->appendChild(self::$MessageList[$i]->getDOMElement($DOMDocument));
}
return $DOMElement;
}
}
?>
\ No newline at end of file
<?
class mcEvent extends mcReport {
/**
* @var int -- errno, contains the level of the error raised
*/
private $errno;
/**
* @var string -- errstr, contains the error message
*/
private $errstr;
/**
* @var string -- errfile, which contains the filename that the error was raised in
*/
private $errfile;
/**
* @var int -- errline, which contains the line number the error was raised at
*/
private $errline;
/**
* @var array -- errcontext, which is an array that points to the active symbol
* table at the point the error occurred. In other words,
* errcontext will contain an array of every variable that
* existed in the scope the error was triggered in. User error
* handler must not modify error context.
*/
private $errcontext;
private $array_debug_backtrace = null;
private $ErrorFunction = null;
protected function __construct($param_errno, $param_errstr, $param_errfile=null, $param_errline=null, $param_errcontext=null) {
$this->errno = $param_errno;
$this->errstr = $param_errstr;
$this->errcontext = $param_errcontext;
$this->array_debug_backtrace = debug_backtrace();
if($param_errfile == null || $param_errline == null) {
$this->ErrorFunction = $this->array_debug_backtrace[2]["class"].$this->array_debug_backtrace[2]["type"]
.$this->array_debug_backtrace[2]["function"]."(...) :".$this->array_debug_backtrace[1]["line"]."";
$this->errfile = $this->array_debug_backtrace[1]['file'];
$this->errline = $this->array_debug_backtrace[1]['line'];
} else {
$this->errfile = $param_errfile;
$this->errline = $param_errline;
}
}
protected function getTextMessage() {
if(is_null($this->TextMessage)) {
$this->TextMessage = self::mkMessage($this->errno, $this->errstr, $this->errfile, $this->errline, $this->errcontext, mcCONST::CODEOFFSET);
}
return $this->TextMessage;
}
private static function mkMessage($param_errno, $param_errstr, $param_errfile, $param_errline, $param_errcontext, $param_offset) {
$var_message = mcCONST::LINEBREAK.'-------------------------------------------------------------'.mcCONST::LINEBREAK;
if(array_key_exists($param_errno, Error::$ErrorArray)) {
$var_message .= 'Typ:'. mcCONST::TAB. Error::$ErrorArray[$param_errno]. mcCONST::TAB. date('d.m.Y G:i').mcCONST::LINEBREAK;
} else {
$var_message .= 'Typ:'. mcCONST::TAB.$param_errno. mcCONST::TAB. date('d. m. Y G:i').mcCONST::LINEBREAK;
}
$var_message .= 'Notice:'. mcCONST::TAB. $param_errstr.mcCONST::LINEBREAK;
$var_message .= 'File:'. mcCONST::TAB. $param_errfile.' (row: '.$param_errline.')'.mcCONST::LINEBREAK;
// $var_message .= 'Url:'. mcCONST::TAB. urldecode(http_build_query($_GET)).mcCONST::LINEBREAK;
// $var_message .= 'PHP: '. mcCONST::TAB. PHP_VERSION . ' (' . PHP_OS . ')'.mcCONST::LINEBREAK;
// $var_message .= mcCONST::LINEBREAK;
$var_message .= self::getCodeFromRow($param_errfile, $param_errline, $param_offset);
$var_message .= mcCONST::LINEBREAK.$param_errcontext.mcCONST::LINEBREAK;
return $var_message;
}
}
class mcNoticeEvent extends mcEvent {
public static $count =0;
public static function handle($param_errno, $param_errstr, $param_errfile, $param_errline, $param_errcontext) {
self::add(new mcNoticeEvent($param_errno, $param_errstr, $param_errfile, $param_errline, $param_errcontext));
mcNoticeEvent::$count++;
}
}
class mcErrorEvent extends mcEvent {
public static $count =0;
public static function handle($param_errno, $param_errstr, $param_errfile, $param_errline, $param_errcontext) {
self::add(new mcErrorEvent($param_errno, $param_errstr, $param_errfile, $param_errline, $param_errcontext));
mcErrorEvent::$count++;
}
}
\ No newline at end of file
<?
/**
* @filesource class_mcReport.inc.php
* @category mcClasses
* @author f@mensch.coop
* @since 2010-12-20
*/
class mcReport {
private static $Stack = array();
protected static function add(mcReport $param_obj) {
if(!array_key_exists(get_class($param_obj), self::$Stack)) {
self::$Stack[get_class($param_obj)] = array();
}
self::$Stack[get_class($param_obj)][] = $param_obj;
}
/**
*
* @param array $param_config
*/
public static function distribute(array $param_config=null) {
if($param_config !== null) {
//D::show($_SERVER);
foreach($param_config as $kindOfReport => $whatToDo) {
if(array_key_exists($kindOfReport, self::$Stack)) {
$GENERAL_TEXT = mcCONST::LINEBREAK.date('d.m.Y G:i:s').mcCONST::LINEBREAK;
$GENERAL_TEXT .= 'File: '.mcCONST::TAB.$_SERVER['SCRIPT_NAME'].mcCONST::LINEBREAK;
if(!empty ($_GET)) {
$GENERAL_TEXT .= 'Url: '.mcCONST::TAB.urldecode(http_build_query($_GET)).mcCONST::LINEBREAK;
}
$GENERAL_TEXT .= 'PHP: '.mcCONST::TAB.PHP_VERSION.' ('.PHP_OS.')'.mcCONST::LINEBREAK;
$GENERAL_TEXT .= 'User: '.mcCONST::TAB.$_SERVER['HTTP_USER_AGENT'].mcCONST::LINEBREAK;
$GENERAL_TEXT .= mcCONST::LINEBREAK;
foreach($whatToDo as $kindOfToDo => $params) {
if($kindOfToDo == 'toScreen' ) {
if(!empty ($params) && array_key_exists('text', $params)) {
self::informUser($params['text']);
}
} else if($kindOfToDo == 'toFile') {
if(array_key_exists('file', $params)) {
$Text = $GENERAL_TEXT;
$Text .= 'KindOf: '.$kindOfReport.' ('.count(self::$Stack[$kindOfReport]).')'.mcCONST::LINEBREAK.mcCONST::LINEBREAK;
$Text .= self::getTextMessageFrom($kindOfReport);
if(array_key_exists('writemode', $params)) {
$writemode = $params['writemode'];
} else {
$writemode = 'a';
}
mcFile::write($params['file'], $Text, $writemode);
}
} else if($kindOfToDo == 'toMail') {
if(array_key_exists('subject', $params)) {
$MailSubject = $params['subject'];
} else {
$MailSubject = '';
}
if(array_key_exists('mail', $params)) {
$MailAdr = $params['mail'];
} else {
break;
}
$MailMessage = $GENERAL_TEXT;
$MailMessage .= self::getTextMessageFrom($kindOfReport);
mcMail::mail($MailAdr, $MailSubject, $MailMessage);
} else {
D::li('kind of mcReport ('.$kindOfToDo.') not supported');
}
}
}
}
}
}
private $Values = array();
protected function setValues(array $param_values) {
$this->Values = $param_values;
}
protected function getDOMElement(DOMDocument $DOMDocument) {
$DOMElement = $DOMDocument->createElement(get_class($this));
foreach($this->Values as $key => $value){
$DOMElement->setAttribute($key,$value);
}
return $DOMElement;
}
private static $TextMessageReports = array();
private static function getTextMessageFrom($param_KindOfReport) {
if(array_key_exists($param_KindOfReport, self::$Stack)) {
if(!array_key_exists($param_KindOfReport, self::$TextMessageReports)) {
self::$TextMessageReports[$param_KindOfReport] = '';
foreach(self::$Stack[$param_KindOfReport] as $mcReportObj) {
self::$TextMessageReports[$param_KindOfReport] .= $mcReportObj->getTextMessage();
}
}
return self::$TextMessageReports[$param_KindOfReport];
} else {
return false;
}
}
protected $TextMessage = null;
protected function getTextMessage() {
if(is_null($this->TextMessage)) {
$this->TextMessage = get_class($this);
}
return $this->TextMessage;
}
protected static function informUser($param_string = null) {
if(is_null($param_string)) {
$param_string = 'leider ist ein Fehler aufgetreten, der Admin wurde informiert, wir hoffen das er bald behoben ist ;) ';
}
/**
* @todo Achtung wie wird genau ein User informiert!!!!
*/
Error::newError('UserError',$param_string,'256');
}
protected static function getCodeFromRow($param_errfile, $param_errline, $param_offset=0) {
$var_result = '';
@$var_file = file($param_errfile);
if($var_file === false) {
$var_result .= 'could not read file'.mcCONST::LINEBREAK;
} else {
if(count($var_file) < $param_errline) {
$var_result .= 'row not in the file'.mcCONST::LINEBREAK;
} else {
if($param_errline-$param_offset < 0) {
$var_StartCode = 0;
} else {
$var_StartCode = $param_errline - $param_offset ;
}
$var_EndCode = $param_errline + $param_offset;
$var_result .= mcCONST::LINEBREAK.'<php>'.mcCONST::LINEBREAK;
for($i=$var_StartCode; $i < count($var_file);$i++) {
if($i > $var_EndCode) {
break;
}
if($i == $param_errline) {
$var_marker = ' => ';
} else {
$var_marker = ' ';
}
if($i-1 >=0) {
$var_result .= $i.$var_marker.mcCONST::TAB.$var_file[$i-1];
}
}
$var_result .= '</php>';
}
}
return $var_result;
}
}
?>
\ No newline at end of file
<?
/**
* @filesource fnc_mcErrorHandler.inc.php
*
* @category losp
* @copyright Copyright by mensch.coop e.G. 2009
* @mailto dev [at] mensch.coop
* @version 0.4.200901
* @link http://mensch.coop
*/
function mcErrorHandler($param_typ, $param_notice, $param_file, $param_row, $param_More) {
switch ($param_typ) {
case E_ERROR: // 1
mcErrorEvent::handle($param_typ, $param_notice, $param_file, $param_row, $param_More);
die();
break;
case E_WARNING: // 2
mcNoticeEvent::handle($param_typ, $param_notice, $param_file, $param_row, $param_More);
break;
case E_PARSE: // 4
mcNoticeEvent::handle($param_typ, $param_notice, $param_file, $param_row, $param_More);
break;
case E_NOTICE: // 8
mcNoticeEvent::handle($param_typ, $param_notice, $param_file, $param_row, $param_More);
break;
case E_CORE_ERROR: // 16
mcErrorEvent::handle($param_typ, $param_notice, $param_file, $param_row, $param_More);
break;
case E_CORE_WARNING: // 32
mcNoticeEvent::handle($param_typ, $param_notice, $param_file, $param_row, $param_More);
break;
case E_COMPILE_ERROR: // 64
mcErrorEvent::handle($param_typ, $param_notice, $param_file, $param_row, $param_More);
break;
case E_COMPILE_WARNING: // 128
mcNoticeEvent::handle($param_typ, $param_notice, $param_file, $param_row, $param_More);
break;
case E_USER_ERROR: // 256
mcErrorEvent::handle($param_typ, $param_notice, $param_file, $param_row, $param_More);
break;
case E_USER_WARNING: // 512
mcNoticeEvent::handle($param_typ, $param_notice, $param_file, $param_row, $param_More);
break;
case E_USER_NOTICE: // 1024 since PHP 4
mcNoticeEvent::handle($param_typ, $param_notice, $param_file, $param_row, $param_More);
break;
case E_STRICT: // 2048 since PHP 5
mcNoticeEvent::handle($param_typ, $param_notice, $param_file, $param_row, $param_More);
break;
case E_RECOVERABLE_ERROR : // 4096 since PHP 5.2.0
mcErrorEvent::handle($param_typ, $param_notice, $param_file, $param_row, $param_More);
break;
case E_DEPRECATED: // 8192 since PHP 5.3.0
mcNoticeEvent::handle($param_typ, $param_notice, $param_file, $param_row, $param_More);
break;
case E_USER_DEPRECATED: // 16384 since PHP 5.3.0
mcNoticeEvent::handle($param_typ, $param_notice, $param_file, $param_row, $param_More);
break;
case E_ALL: // 30719 in PHP 5.3.x, 6143 in PHP 5.2.x, 2047 previously
mcNoticeEvent::handle($param_typ, $param_notice, $param_file, $param_row, $param_More);
break;
default:
D::li('___Typ: '.$param_typ.' (E_NOTICE = '.E_NOTICE.' E_WARNING = '.E_WARNING.' E_ERROR = '.E_ERROR.') <b>[anscheinend ein neuer Typ .. da muss doch gleich mal auf der <a href="http://php.net/manual/en/errorfunc.constants.php">Predefined Constants</a> seite nachgeschaut werden]</b>');
D::ulli('Notiz: '.$param_notice);
D::ulli('Datei: '.$param_file);
D::ulli('Zeile: '.$param_row);
}
// return FALSE;
}
?>
\ No newline at end of file
<?php
/**
* @var link to the basic path from the mcClasses dir
*/
$__BASEPATH_EX='../../../';
/**
* @var link from the basic path to the mcClasses dir,
* copy this var in the main basepath.inc.php if you want use include.php
*/
$__PATH_to_mcClasses= $__BASEPATH_EX .'include/Lib/Tools/mcClasses/';
?>
\ No newline at end of file
<?php
class mcCONST {
/**
* @var constant -- old ::$zeilenumbruch
*/
const LINEBREAK = '
';
/**
* @var constant -- old ::$tab
*/
const TAB = ' ';
/**
* @var int Anzahl der Zeilen die vor und nach der Warnung mit ausgegeben werden soll
*/
const CODEOFFSET = 3;
/**
* arrays gehen leider noch nicht als CONSTante
* @var array
*/
public static $HTMLTAGS2TEXT = array(
'<i style="font-size:10;color:gray;">' => '[',
'<i>' => '[',
'</i>' => ']',
"<li>" => "* ",
"</li>" => "",
"<ul>" => "\t",
"</ul>" => "",
"<p>" => "\n",
"</p>" => "\n",
"<b>" => " __",
"</b>" => "__ ",
"<span title='Rekursionstiefe'>" => "",
"</span>" => "",
'<h2>' => "\n______________________________\n",
'</h2>' => "\n##############################\n",
'<h1>' => "\n______________________________\n",
'</h1>' => "\n##############################\n##############################\n",
'<pre>' => "",
'</pre>' => "",
'<br>' => "\n",
'<br/>' => "\n",
'<br />' => "\n",
);
}
?>
<?php
class mcCsv {
public static function exportCsv($param_xml,$param_name){
$cut_Array=explode('CUT_VALUE_FOR_NOT_THE_HEADER',$param_xml);
//file_name
$var_filename = 'export_'.$param_name.'.csv';
// Header senden
header("Content-Disposition: attachment; filename =".$var_filename);
header("Content-Type: text/plain");
// Datei ausgeben
echo trim($cut_Array[1]);
}
}
?>
\ No newline at end of file
<?php
/**
*
*/
class mcDeprecated {
public static function is($param_deprecated) {
global $__mc_DEPRECATED;
global $__mc_DEPRECATED_OUTPUT;
if($__mc_DEPRECATED < $param_deprecated) {
if($__mc_DEPRECATED_OUTPUT) {
D::li('software runs which is @deprecated since '. substr($param_deprecated, 0,4).'-'. substr($param_deprecated, 4,2).'-'. substr($param_deprecated, 6,2).' v('. substr($__mc_DEPRECATED, 0,4).'-'. substr($__mc_DEPRECATED, 4,2).'-'. substr($__mc_DEPRECATED, 6,2).')');
}
return true;
} else {
return false;
}
}
}
?>
\ No newline at end of file
<?
class mcException extends mcEvent {
public static function handleException (Exception $e) {
// D::h2('Exception Error ('.$e->getCode().') in '.$e->getFile().' in row '.$e->getLine());
// D::e('Message: '.$e->getMessage().' '. c.'<br>');
// D::show($e->getTraceAsString(), 'TraceAsString');
// if($e->getPrevious()) {
// D::e('there is a previous exception');
// }
if(get_class($e) == 'PDOException') {
foreach($e->getTrace() as $i => $array) {
// D::li($i);
if(array_key_exists('args', $array)) {
$out1 = null;
foreach($array['args'] as $arg) {
if(get_class ($arg) == 'PDOStatement') {
ob_start();
$arg->debugDumpParams();
$out1 = ob_get_contents();
ob_end_clean();
// D::ulli($out1);
break;
}
}
if($out1) {
break;
}
}
}
}
self::handle(E_ERROR, $e->getCode(), $e->getFile(), $e->getLine(), $e->getMessage().mcCONST::LINEBREAK.$out1);
return false;
}
public static $count =0;
private static function handle($param_errno, $param_errstr, $param_errfile, $param_errline, $param_errcontext) {
self::add(new mcException($param_errno, $param_errstr, $param_errfile, $param_errline, $param_errcontext));
self::$count++;
}
}
?>
\ No newline at end of file
<?
class mcFile {
/**
*
*
* @param string $param_filename
* @param string $param_text
* @param string $param_kindof -- r|r+|w|w+|a|a+ @see http://de3.php.net/manual/de/function.fopen.php
* r - ptr at the beginning
* w - ptr at the beginning and file size 0
* a - ptr at the end
* @return bool
*/
public static function write($param_filename, $param_text, $param_kindof = null) {
if($param_filename && $param_text) {
if($param_kindof === null) {
$param_kindof = 'a';
}
try {
@$var_file = fopen($param_filename,$param_kindof);
if ($var_file === false) {
return false;
} else {
fputs($var_file, $param_text);
fputs($var_file, mcCONST::LINEBREAK.mcCONST::LINEBREAK);
}
fclose($var_file);
return true;
} catch (Exception $e) {
mcException::handleException($e);
}
} else {
return false;
}
}
}
?>
<?
class mcMail {
// private static $tab = ' ';
private static $CollectionForMailToAdmin = array();
public static function collectForMailToAdmin($param_to, $param_subject, $param_message, $param_logfile=null) {
if(!array_key_exists($param_to, self::$CollectionForMailToAdmin)) {
self::$CollectionForMailToAdmin[$param_to] = array();
}
self::$CollectionForMailToAdmin[$param_to][] = array(
'subject' => $param_subject,
'message' => $param_message
);
// mail($param_to, $param_subject, $param_message);
}
public static function mail($param_to, $param_subject, $param_message) {
mail($param_to, $param_subject, $param_message);
}
public static function mailToAdmin() {
foreach(self::$CollectionForMailToAdmin as $to => $array_message) {
$subject = false;
if(empty ($_GET)) {
$message = false;
} else {
$message = mcCONST::LINEBREAK.'Url: '.urldecode(http_build_query($_GET)).mcCONST::LINEBREAK;
}
$message .= 'PHP: '. mcCONST::TAB. PHP_VERSION . ' (' . PHP_OS . ')'.mcCONST::LINEBREAK.mcCONST::LINEBREAK;
if(is_array($array_message)) {
foreach($array_message as $var_message) {
if($subject===false) {
$subject = $var_message['subject'].' ';
} else {
$subject .= '.';
}
$message .= mcCONST::LINEBREAK.mcCONST::LINEBREAK
.$var_message['subject'].mcCONST::LINEBREAK
. $var_message['message'].mcCONST::LINEBREAK;
}
self::mail($to, $subject, $message);
}
}
}
}
?>
\ No newline at end of file
<?
class mcPerformance {
private static $StaticCalls = array();
private static function prepareStaticCalls($param_ClassName, $param_FncName, array $param_toDiffParams=array()) {
if(!array_key_exists($param_ClassName, mcPerformance::$StaticCalls)) {
mcPerformance::$StaticCalls[$param_ClassName] = array();
}
if(!array_key_exists($param_FncName, mcPerformance::$StaticCalls[$param_ClassName])) {
mcPerformance::$StaticCalls[$param_ClassName][$param_FncName] = array( );
}
global $__mcPerformance_backtrace;
if($__mcPerformance_backtrace) {
$string_backtrace = D::getBacktrace($param_htmltags=false, $param_start=2, $param_end=2);
} else {
$string_backtrace = '__mcPerformance_backtrace = false';
}
$toDiffParams = serialize($param_toDiffParams);
$obj_key = null;
$count_objects = count(mcPerformance::$StaticCalls[$param_ClassName][$param_FncName]);
for($i=0; $i<$count_objects; $i++ ) {
if(mcPerformance::$StaticCalls[$param_ClassName][$param_FncName][$i]['param'] === $toDiffParams) {
$obj_key = $i;
}
}
if(is_null($obj_key)) {
mcPerformance::$StaticCalls[$param_ClassName][$param_FncName][] = array('count'=>1, 'param' => $toDiffParams, 'backtraceStrings' => array($string_backtrace));
} else {
mcPerformance::$StaticCalls[$param_ClassName][$param_FncName][$obj_key]['count']++;
mcPerformance::$StaticCalls[$param_ClassName][$param_FncName][$obj_key]['backtraceStrings'][] = $string_backtrace;
}
}
private static $ObjectCalls = array();
private static function prepareObjectCalls($param_ClassName, $param_FncName, &$param_Object, array $param_toDiffParams=array()) {
if(!array_key_exists($param_ClassName, mcPerformance::$ObjectCalls)) {
mcPerformance::$ObjectCalls[$param_ClassName] = array();
}
if(!array_key_exists($param_FncName, mcPerformance::$ObjectCalls[$param_ClassName])) {
mcPerformance::$ObjectCalls[$param_ClassName][$param_FncName] = array( );
}
global $__mcPerformance_backtrace;
if($__mcPerformance_backtrace) {
$string_backtrace = D::getBacktrace($param_htmltags=false, $param_start=2, $param_end=2);
} else {
$string_backtrace ='__mcPerformance_backtrace = false';
}
if(array_search('getID', get_class_methods($param_ClassName))) {
$getIDFnc = true;
if(!array_key_exists($param_Object->getID(), mcPerformance::$ObjectCalls[$param_ClassName][$param_FncName])) {
mcPerformance::$ObjectCalls[$param_ClassName][$param_FncName][$param_Object->getID()] = array( );
}
$ObjArray = &mcPerformance::$ObjectCalls[$param_ClassName][$param_FncName][$param_Object->getID()];
} else {
$getIDFnc = false;
$ObjArray = &mcPerformance::$ObjectCalls[$param_ClassName][$param_FncName];
}
$toDiffParams = serialize($param_toDiffParams);
$obj_key = null;
$count_objects = count($ObjArray);
for($i=0; $i<$count_objects; $i++ ) {
if($param_Object === $ObjArray[$i]['object'] && $ObjArray[$i]['param'] === $toDiffParams) {
$obj_key = $i;
}
}
if(is_null($obj_key)) {
$ObjArray[] = array('count'=>1, 'object' => &$param_Object, 'param' => $toDiffParams, 'backtraceStrings' => array($string_backtrace));
} else {
$ObjArray[$obj_key]['count']++;
$ObjArray[$obj_key]['backtraceStrings'][] = $string_backtrace;
}
}
/**
* erstellt eine kleine Statistik über die Funktion in der checkMultipleCalls() aufgerufen wird
* Statistik kann über mcPerformance::showStats() angezeigt werden
*
* @param array $param_toDiffParams default array() --- wenn gesetzt, unterscheidet fnc auch nach Parametern
*/
public static function checkMultipleCalls(array $param_toDiffParams=array()) {
global $_LOSP_DEV;
if($_LOSP_DEV) {
$array_backtrace = debug_backtrace();
/**
* static class function call
*/
if($array_backtrace[1]['type'] == '::') {
mcPerformance::prepareStaticCalls($array_backtrace[1]['class'], $array_backtrace[1]['function'], $param_toDiffParams);
/**
* object function call
*/
} else if($array_backtrace[1]['type'] == '->') {
mcPerformance::prepareObjectCalls($array_backtrace[1]['class'], $array_backtrace[1]['function'], $array_backtrace[1]['object'], $param_toDiffParams);
} else {
D::li('type ('.$array_backtrace[1]['type'].') not implemantated');
}
}
}
public static function showStats() {
global $_LOSP_DEV;
if($_LOSP_DEV) {
D::h1('static calls');
foreach(mcPerformance::$StaticCalls as $classname => $fnc) {
D::li('<b>'.$classname.'</b>');
foreach($fnc as $fncname => $FncCalls) {
D::ulli('<b>'.$fncname.' with '.count($FncCalls).' different fnc calls </b>');
$allFncCalls = 0;
foreach($FncCalls as $FncCall) {
$backtraceString = '';
foreach($FncCall['backtraceStrings'] as $index => $string_backtrace) {
if($index==0) {
$backtraceString .= '<i title="'.$string_backtrace.'">'.$index.'</i> ';
} else {
$backtraceString .= '- <b><i title="'.$string_backtrace.'">'.$index.'</i></b> ';
}
}
$string_param = str_replace('"', '', $FncCall['param']);
if(strlen($string_param) < 32) {
$string4param = " ".$string_param." ";
} else {
$string4param = ' <u title="'.$string_param.'">'.md5($FncCall['param'])."</u> ";
}
D::ulli('<i>'.$fncname.'('.$string4param.') wurde '.$FncCall['count'].' aufgerufen</i>'.' backtrace '.$backtraceString);
$allFncCalls += $FncCall['count'];
}
D::ulli('<b>'.$fncname.' general: '.$allFncCalls.' </b>');
}
}
D::h1('object calls');
foreach(mcPerformance::$ObjectCalls as $classname => $fnc) {
if(array_search('getID', get_class_methods($classname))) {
$getIDFnc = true;
} else {
$getIDFnc = false;
}
D::li('<b>'.$classname.'</b>');
foreach($fnc as $fncname => $objects) {
if($getIDFnc) {
D::ulli('<b>'.$fncname.' mit '.count($objects).' unterschiedlichen objects </b>');
foreach($objects as $objID => $objIDArray) {
D::ulli('<b><i>'.$objID.' => wurde '.count($objIDArray).' geladen</i></b>');
foreach($objIDArray as $obj) {
if(strlen($obj['param']) < 32) {
$string4param = "\t Param(".$obj['param'].")";
} else {
$string4param = "\t Param_md5(".md5($obj['param']).")";
}
$backtraceString = '';
foreach($obj['backtraceStrings'] as $index => $string_backtrace) {
if($index==0) {
$backtraceString .= '<i title="'.$string_backtrace.'">'.$index.'</i> ';
} else {
$backtraceString .= '- <b><i title="'.$string_backtrace.'">'.$index.'</i></b> ';
}
}
D::ulli($obj['object'].' => '.$obj['count'].' x '.$fncname. $string4param.' backtrace '.$backtraceString);
}
}
} else {
D::ulli('<b>'.$fncname.' mit '.count($objects).' objects</b>');
foreach($objects as $obj) {
$string_param = str_replace('"', '', $obj['param']);
if(strlen($string_param) < 32) {
$string4param = "\t Param(".$string_param.")";
} else {
$string4param = ' <i title="'.$string_param.'">Param_md5('.md5($obj['param']).")</i>";
}
$backtraceString = '';
foreach($obj['backtraceStrings'] as $index => $string_backtrace) {
if($index==0) {
$backtraceString .= '<i title="'.$string_backtrace.'">'.$index.'</i> ';
} else {
$backtraceString .= '- <b><i title="'.$string_backtrace.'">'.$index.'</i></b> ';
}
}
D::ulli($obj['object'].' => '.$obj['count'].' x '.$fncname. $string4param.' backtrace '.$backtraceString);
}
}
}
}
}
}
}
?>
<?php
// $__PATH_to_mcClasses;
if(!isset($_LOSP_DEV)) {
/**
* @var boolean -- activate the dev modus
*/
$_LOSP_DEV = true;
}
if(!isset($__mc_D_LOGFILE)) {
/**
* @todo @since 20110325 die vars müssen eigentlich hier aus __mc raus ... da sie freeSN abhängig sind @author f@mensch.coop
*/
if(isset($_TREE) && $_TREE) {
$string = $_TREE;
} else if(isset($_PAGE_NAME) && $_PAGE_NAME) {
$string = $_PAGE_NAME;
} else {
$string = 'no';
}
/**
* @var string -- file for the D Output
*/
$__mc_D_LOGFILE = $__BASEPATH_EX.'log/mc.'.$string.'.DEV_D.log';
}
if(!isset($__mc_D_SCREENOUTPUT)) {
/**
* @var boolean -- activate the D Output on screen
*/
$__mc_D_SCREENOUTPUT = false;
}
if(!isset($__mcPerformance_backtrace)) {
/**
* @var boolean -- activate the D Output on screen
*/
$__mcPerformance_backtrace = true;
}
if(!isset($__mc_ERRORHANDLER)) {
/**
* @var boolean -- is true use the mcErrorHandler
*/
$__mc_ERRORHANDLER = true;
}
if(!isset($__mc_DEPRECATED)) {
/**
* @var int
* if you want @deprecated functions since a date (format: yyyymmdd)
*/
$__mc_DEPRECATED = 20110201;
}
if(!isset($__mc_Report)) {
/**
* @var array -- configuration of the report (mcNoticeEvent, mcErrorEvent, Error)
*/
$__mc_Report = array(
'mcNoticeEvent' => array(
'toScreen' => array(),
'toFile' => array('file' => 'log/NoticeEvent.log')
),
'mcErrorEvent' => array(
'toScreen' => array(),
'toFile' => array(
'file' => 'log/ErrorEvent.log',
'writemode' => 'a',
'reset' => false,
),
// 'toMail' => array(
// 'mail' => 'mail@localhost.tld',
// 'subject' => 'Error:'
// )
),
'mcException' => array(
'toScreen' => array(),
'toFile' => array(
'file' => 'log/Exception.log',
'writemode' => 'a',
'reset' => false,
),
// 'toMail' => array(
// 'mail' => 'mail@localhost.tld',
// 'subject' => 'Error:'
// )
),
'Error' => array(
'toScreen' => array('text' => 'ERROR Error ERROR Error ERROR'),
'toFile' => array(
'file' => 'log/Error.config.log',
'writemode' => 'a',
'reset' => false,
),
// 'toMail' => array(
// 'mail' => 'mail@localhost.tld',
// 'subject' => 'Error:'
// )
),
);
}
?>
\ No newline at end of file
<?
/**
* dinge die am Ende noch ausgeführt werden sollen
*
* (nur für Dinge die unter mcClasses sind)
*
* @author f@mensch.coop @since 2010-12-01
*/
mcReport::distribute($__mc_Report);
/**
* developer things
*/
if($_LOSP_DEV) {
D::showStats($__mc_Report, $__BASEPATH_EX, $__mc_D_LOGFILE);
if($__mc_D_SCREENOUTPUT) {
D::printToScreen();
}
if($__mc_D_LOGFILE) {
D::printToFile($__mc_D_LOGFILE,'a');
}
}
?>
\ No newline at end of file
<?
require_once $__PATH_to_mcClasses .'include.php';
require_once $__PATH_to_mcClasses .'config.php';
/**
* dinge die am Ende noch ausgeführt werden sollen
*
* (nur für Dinge die unter mcClasses sind)
*
* @author f@mensch.coop @since 2010-12-17
*/
if($__mc_ERRORHANDLER) {
require_once $__PATH_to_mcClasses.'ReportHandling/fnc_mcErrorHandler.inc.php';
set_error_handler('mcErrorHandler');
}
if($_LOSP_DEV) {
error_reporting(E_ALL);
$var_message = '['.date('d. m. Y G:i').'] DEVMODE: logfile wurde zurvor geloescht';
if($__mc_D_LOGFILE) {
unlink ( $__mc_D_LOGFILE );
mcFile::write($__mc_D_LOGFILE, $var_message, 'w');
}
//mcFile::write('log/tmp.bla', date('d.m.Y G:i:s').': '.$_SERVER['SCRIPT_NAME'].' -- '.$_SERVER['REQUEST_URI'].mcCONST::TAB.($_SERVER['SCRIPT_NAME']==$_SERVER['REQUEST_URI']).mcCONST::LINEBREAK, 'a');
foreach($__mc_Report as $Report) {
foreach($Report as $kindofDistribute => $params) {
if($kindofDistribute == 'toFile') {
if($params['reset']) {
unlink ( $params['file'] );
mcFile::write($params['file'], $var_message, 'w');
}
}
}
}
D::start();
}
?>
\ No newline at end of file
<?
/**
* include the mcClasses libary
*
* @author dev@mensch.coop
* @since 2011-01-07
*/
require_once("basepath.inc.php");
require_once $__PATH_to_mcClasses . 'class_mcMail.inc.php';
require_once $__PATH_to_mcClasses . 'class_mcFile.inc.php';
require_once $__PATH_to_mcClasses . 'class_mcCONST.inc.php';
require_once $__PATH_to_mcClasses . 'class_mcCsv.inc.php';
require_once $__PATH_to_mcClasses . 'class_mcDeprecated.inc.php';
require_once $__PATH_to_mcClasses . 'ReportHandling/class_mcReport.inc.php';
require_once $__PATH_to_mcClasses . 'ReportHandling/class_Error.inc.php';
require_once $__PATH_to_mcClasses . 'ReportHandling/class_Message.inc.php';
require_once $__PATH_to_mcClasses . 'ReportHandling/class_mcEvent.inc.php';
require_once $__PATH_to_mcClasses . 'ReportHandling/class_mcEvent.inc.php';
require_once $__PATH_to_mcClasses . 'D/class_D.inc.php';
require_once $__PATH_to_mcClasses . 'class_mcException.inc.php';
require_once $__PATH_to_mcClasses . 'class_mcPerformance.inc.php';
?>
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!