-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
38 changed files
with
11,194 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,26 @@ | ||
{ | ||
"name": "autoflow/securephp", | ||
"description": "PHP error mailer - replacement for exception-, error- and shutdown-handler", | ||
"description": "PHP error mailer and replacement for error-, exception- and shutdown-handler", | ||
"require": { | ||
"php": "^5.3.3" | ||
}, | ||
"keywords": [ | ||
"error", | ||
"mailer", | ||
"log", | ||
"error", | ||
"exception", | ||
"shutdown", | ||
"handler" | ||
], | ||
"homepage": "https://github.com/Autoflow/SecurePHP", | ||
"type": "library", | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "Alexander Münch", | ||
"email": "[email protected]", | ||
"homepage": "http://www.autoflow.org" | ||
} | ||
] | ||
"error", | ||
"mailer", | ||
"log", | ||
"error", | ||
"exception", | ||
"shutdown", | ||
"handler" | ||
], | ||
"homepage": "https://github.com/Autoflow/SecurePHP", | ||
"type": "library", | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "Alexander Münch", | ||
"email": "[email protected]", | ||
"homepage": "http://www.autoflow.org" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
<?php | ||
|
||
// Version 2.0, 24.10.2016 | ||
# 1) Initial release, no info | ||
|
||
/** | ||
* @package SECUREPHP | ||
* @author Alexander Münch | ||
* @copyright Alexander Münch | ||
* @version 2.0 | ||
* @date 26.10.2016 | ||
*/ | ||
|
||
namespace AUTOFLOW\SECUREPHP | ||
|
||
{ | ||
|
||
trait MAGIC | ||
|
||
{ | ||
|
||
/** | ||
* Public setter method to prevent from bugs. | ||
* @param string $name | ||
* @param mixed $value | ||
* @throws E_ACCESS | ||
*/ | ||
final public function x__set($name, $value) | ||
{ | ||
$message = 'Schreibzugriff auf nicht vorhandene ' . get_class($this) . '-Eigenschaft ' . $name; | ||
if(PROTECT::getInstance()->in_progress()) trigger_error($message, E_USER_NOTICE); | ||
else throw new E_ACCESS($message); | ||
} | ||
|
||
/** | ||
* Public getter method to prevent from bugs. | ||
* @param string $name | ||
* @throws E_ACCESS | ||
*/ | ||
final public function x__get($name) | ||
{ | ||
$message = 'Lesezugriff auf nicht vorhandene ' . get_class($this) . '-Eigenschaft ' . $name; | ||
if(PROTECT::getInstance()->in_progress()) trigger_error($message, E_USER_NOTICE); | ||
else throw new E_ACCESS($message); | ||
} | ||
|
||
/** | ||
* Public call method to prevent from bugs. | ||
* @param string $name | ||
* @param array $arguments | ||
* @throws E_ACCESS | ||
*/ | ||
final public function x__call($name, $arguments) | ||
{ | ||
$message = 'Zugriff auf nicht vorhandene ' . get_class($this) . '-Methode ' . $name; | ||
if(PROTECT::getInstance()->in_progress()) trigger_error($message, E_USER_NOTICE); | ||
else throw new E_ACCESS($message); | ||
} | ||
} | ||
|
||
/** | ||
* Class USERCLASS | ||
* @package SECUREPHP | ||
*/ | ||
class USERCLASS | ||
{ | ||
|
||
use MAGIC; | ||
|
||
} | ||
|
||
/** | ||
* Class BASECLASS | ||
* @package SECUREPHP | ||
*/ | ||
class SINGLETON | ||
|
||
{ | ||
|
||
use MAGIC; | ||
|
||
/** | ||
* Private clone method to prevent cloning of the instance of the | ||
* *Singleton* instance. | ||
* | ||
* @return void | ||
*/ | ||
final private function __clone() | ||
{ | ||
} | ||
|
||
/** | ||
* Private unserialize method to prevent unserializing of the *Singleton* | ||
* instance. | ||
* | ||
* @return void | ||
*/ | ||
final private function __wakeup() | ||
{ | ||
} | ||
|
||
/** | ||
* Private construct method to prevent cloning of the instance of the | ||
* Singleton instance. | ||
*/ | ||
protected function __construct() | ||
{ | ||
} | ||
} | ||
} | ||
|
||
// EOF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,215 @@ | ||
<?php | ||
|
||
// Version 2.0, 24.10.2016 | ||
# 1) Initial release, no info | ||
|
||
/** | ||
* Base package for SecurePHP reports and exceptions. | ||
* | ||
* Don't use this classed directly in code. | ||
* | ||
* \ErrorException | ||
* -> \SECUREPHP\ERROR_EXCEPTION | ||
* -> i.e. \SECUREPHP\PhpRunTimeError | ||
* | ||
* \Exceptions | ||
* -> \SecurePHP\EXCEPTION | ||
* -> \SecurePHP\E_FATAL | ||
* -> \SecurePHP\E_ACCESS | ||
* -> \SecurePHP\E_RECURSION | ||
* -> \SecurePHP\E_INIT | ||
* -> \SecurePHP\E_CONFLICT | ||
* -> \SecurePHP\E_CONFIG | ||
* -> ie. \SECUREPHP\ERRORTICKET | ||
* -> ie. \SecurePHP\ERRORREPORT | ||
* | ||
* @package SECUREPHP | ||
* @author Alexander Münch | ||
* @copyright Alexander Münch | ||
* @version 1.1 | ||
*/ | ||
|
||
namespace AUTOFLOW\SECUREPHP | ||
|
||
{ | ||
|
||
/** | ||
* Class EXCEPTION. | ||
* @package SECUREPHP | ||
*/ | ||
trait BASE | ||
{ | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function __toString() | ||
{ | ||
|
||
$message = ''; | ||
|
||
$message .= $this->toString($this); | ||
|
||
if ($prev = $this->getPrevious()) do | ||
{ | ||
$message .= '*' . SECUREPHP_LINE_BREAK; | ||
$message .= "* Vorausgehend:" . SECUREPHP_LINE_BREAK; | ||
$message .= '*' . SECUREPHP_LINE_BREAK; | ||
$message .= '* '.get_class($prev) . SECUREPHP_LINE_BREAK; | ||
$message .= $this->toString($prev); | ||
} | ||
while | ||
( | ||
$prev = $prev->getPrevious() | ||
); | ||
|
||
return $message; | ||
} | ||
|
||
/** | ||
* @param \Exception $e | ||
* @return string | ||
*/ | ||
public function toString(\Exception $e) | ||
{ | ||
|
||
$message = ''; | ||
|
||
$message .= '* Erstellt in: ' . $e->getFile() . ', Zeile ' . $e->getLine() . SECUREPHP_LINE_BREAK; | ||
|
||
$message .= '* Beschreibung: ' . $e->getMessage() . SECUREPHP_LINE_BREAK; | ||
|
||
if(\AUTOFLOW\SECUREPHP\BOOTSTRAP::getInstance()->debug()) | ||
{ | ||
$message .= '*' . SECUREPHP_LINE_BREAK; | ||
$message .= '* Programmablauf: ' . SECUREPHP_LINE_BREAK; | ||
$message .= $this->formatTrace($e); | ||
} | ||
return $message; | ||
} | ||
|
||
|
||
/** | ||
* @param \Exception $e | ||
* @return string | ||
*/ | ||
final public function formatTrace(\Exception $e) | ||
{ | ||
|
||
$message = ''; | ||
$tracestack = $e->getTrace(); | ||
|
||
foreach($tracestack AS $l => $trace) | ||
{ | ||
if(!isset($trace['file'])) $trace['file'] = '(intern) '; | ||
if(!isset($trace['line'])) $trace['line'] = ''; else $trace['line'] = "({$trace['line']})"; | ||
if(!isset($trace['class'])) $trace['class'] = ''; else $trace['class'] = $trace['class'] . '->'; | ||
$params = ARRAY(); | ||
foreach($trace['args'] AS $arg) | ||
{ | ||
if(empty($arg)) $params[] = 'NULL'; | ||
elseif(is_object($arg)) $params[] = 'Object('.get_class($arg).')'; | ||
elseif(is_string($arg)) | ||
{ | ||
if(strlen($arg) > 10) $params[] = "'" . substr($arg, 0, 5) . " .. " . substr($arg, -5) ."'"; | ||
else $params[] = (string) "'$arg'"; | ||
} | ||
elseif(is_numeric($arg)) $params[] = (int) $arg; | ||
elseif(is_array($arg)) $params[] = 'ARRAY'; | ||
else $params[] = gettype($arg); | ||
} | ||
$message .= '* ' .$l. ' '.$trace['file'] . $trace['line'] . $trace['class'] . $trace['function'] . '(' . implode(', ', $params) .')' . SECUREPHP_LINE_BREAK; | ||
} | ||
|
||
|
||
$message .= '* {main}' . SECUREPHP_LINE_BREAK; | ||
|
||
return $message; | ||
} | ||
|
||
} | ||
|
||
/** | ||
* Class EXCEPTION. | ||
* @package SECUREPHP | ||
*/ | ||
class EXCEPTION extends \Exception | ||
{ | ||
|
||
use MAGIC; | ||
use BASE; | ||
|
||
} | ||
|
||
/** | ||
* Class ERROR_EXCEPTION | ||
* @package SECUREPHP | ||
*/ | ||
class ERROR_EXCEPTION extends \ErrorException | ||
{ | ||
use MAGIC; | ||
use BASE; | ||
} | ||
|
||
/** | ||
* Class E_FATAL | ||
* | ||
* Base class of fatal SecurePHP exceptions. | ||
* | ||
* Das Versenden eines Reports hat zu einem | ||
* schwerwiegenden, internen Fehler geführt. | ||
* | ||
* Fehler dieser Klasse sollten auf einem | ||
* anderen Weg als über SecurePHP gemeldet | ||
* werden. | ||
* | ||
* @package SECUREPHP | ||
*/ | ||
class E_FATAL extends EXCEPTION | ||
{ | ||
} | ||
|
||
/** | ||
* Class E_INIT. | ||
* | ||
* SecurePHP Initialisierungsfehler. | ||
* | ||
* @package SECUREPHP | ||
*/ | ||
class E_INIT extends E_FATAL | ||
{ | ||
} | ||
|
||
|
||
/** | ||
* Class E_CONFIG. | ||
* | ||
* Konfigurationsfehler. | ||
* | ||
* @package SECUREPHP | ||
*/ | ||
class E_CONFIG extends EXCEPTION | ||
{ | ||
} | ||
|
||
/** | ||
* Class E_SHUTDOWN | ||
* @package SECUREPHP | ||
*/ | ||
class E_SHUTDOWN extends ERROR_EXCEPTION | ||
{ | ||
|
||
} | ||
|
||
/** | ||
* Class E_SHUTDOWN | ||
* @package SECUREPHP | ||
*/ | ||
class E_EOF extends ERROR_EXCEPTION | ||
{ | ||
|
||
} | ||
|
||
} | ||
|
||
// EOF |
Oops, something went wrong.