Skip to content

Commit 847f5c6

Browse files
committed
Releasing 1.1.5
2 parents 39e2e4a + 7c75a56 commit 847f5c6

File tree

4 files changed

+77
-3
lines changed

4 files changed

+77
-3
lines changed

src/TgUtils/FormatUtils.php

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,5 +58,70 @@ public static function formatUnit($size, $unit, $precision = 1, $language = NULL
5858
$size = $rc != $unit ? number_format($size, $precision, I18N::_('decimal_point', $language), I18N::_('thousand_sep', $language)) : number_format($size, 0, I18N::_('decimal_point', $language), I18N::_('thousand_sep', $language));
5959
return $size.' '.$rc;
6060
}
61+
62+
/**
63+
* Provides the complete Exception message as string with newlines.
64+
* This method does not shorten any string as the getTraceAsString() method does.
65+
* @param Throwable $throwable the exception to trace
66+
* @return string the complete exception message and stack
67+
*/
68+
public static function getTraceAsString($throwable) {
69+
return implode("\n", self::getTraceLines($throwable));
70+
}
71+
72+
/**
73+
* Provides the complete Exception message as array of strings.
74+
* This method does not shorten any string as the getTraceAsString() method does.
75+
* @param Throwable $throwable the exception to trace
76+
* @return array the complete exception message and stack in separate strings
77+
*/
78+
public static function getTraceLines($throwable) {
79+
$rc = array(get_class($throwable).': '.$throwable->getMessage());
80+
$rc[] = 'at '.$throwable->getFile().'(line '.$throwable->getLine().'): ';
81+
82+
$trace = $throwable->getTrace();
83+
foreach ($trace AS $traceLine) {
84+
$rc[] = self::getTraceLine($traceLine);
85+
}
86+
$previous = $throwable->getPrevious();
87+
if ($previous != NULL) {
88+
$rc[] = 'Caused by:';
89+
$rc = array_merge($rc, self::getTraceLines($previous));
90+
}
91+
return $rc;
92+
}
93+
94+
/**
95+
* Provides the line of a stack trace as string (no shortening).
96+
* @param array $entry - the entry of the stack trace as given by getTrace()
97+
* @return string the entry as string
98+
*/
99+
protected static function getTraceLine($entry) {
100+
$rc = 'at ';
101+
if (isset($entry['file'])) $rc .= $entry['file'];
102+
if (isset($entry['line'])) $rc .= ' (line '.$entry['line'].')';
103+
if (isset($entry['class']) || isset($entry['type']) || isset($entry['function'])) {
104+
if (isset($entry['file'])) $rc .= ': ';
105+
if (isset($entry['class'])) $rc .= $entry['class'];
106+
if (isset($entry['type'])) $rc .= $entry['type'];
107+
if (isset($entry['function'])) {
108+
$rc .= $entry['function'].'(';
109+
if (isset($entry['args'])) {
110+
$first = TRUE;
111+
foreach ($entry['args'] AS $arg) {
112+
if ($first) $first = FALSE;
113+
else $rc .= ',';
114+
if (is_object($arg)) $rc .= get_class($arg);
115+
else if (is_array($arg)) $rc .= 'array';
116+
else if (is_string($arg)) $rc .= "'$arg'";
117+
else $rc .= $arg;
118+
}
119+
}
120+
$rc .= ')';
121+
}
122+
}
123+
return $rc;
124+
}
125+
61126
}
62127

src/TgUtils/Obfuscation.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public static function obfuscateEmail($email, $id = NULL, $charSet = Obfuscation
2828
if (is_array($obfuscated)) {
2929
$a = $obfuscated[0];
3030
$e = $obfuscated[1];
31-
$script = '<script type="text/javascript">var a="'.$a.'";var b=a.split("").sort().join("");var c="'.$e.'";var d="";for(var e=0;e<c.length;e++)d+=b.charAt(a.indexOf(c.charAt(e)));jQuery("#'.$id.'").html("<a href=\""+d+"\">"+d+"</a>")</script>';
31+
$script = '<script type="text/javascript">var a="'.$a.'";var b=a.split("").sort().join("");var c="'.$e.'";var d="";for(var e=0;e<c.length;e++)d+=b.charAt(a.indexOf(c.charAt(e)));jQuery("#'.$id.'").html("<a href=\"mailto:"+d+"\">"+d+"</a>")</script>';
3232
if ($id == NULL) {
3333
$id = self::generateObfuscationId();
3434
return self::getObfuscatedHtmlSpan($id).$script;

src/TgUtils/Request.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,10 +235,10 @@ public function getPostParams() {
235235
if ($len) {
236236
$len = intval($len);
237237
// Check that we have a valid content-length
238-
if (($len>0) && ($len<10000)) {
238+
if ($len>0) {
239239
$this->postParams = $_POST;
240240
} else {
241-
Log::registerMessage(new Error('POST content too big'));
241+
Log::register(new Error('POST content invalid'));
242242
}
243243
}
244244
}

src/TgUtils/Utils.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,17 @@
22

33
namespace TgUtils;
44

5+
56
class Utils {
67

8+
public const ALPHA = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
9+
public const NUMERIC = '01234567890';
10+
public const SPECIAL = '!§$%&/()=?*_:;>{[]+~#-.,<^`´@';
11+
public const ALPHANUMERIC = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
12+
public const ALPHASPECIAL = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!§$%&/()=?*_:;>{[]+~#-.,<^`´@';
13+
public const NUMERICSPECIAL = '0123456789!§$%&/()=?*_:;>{[]+~#-.,<^`´@';
14+
public const ALPHNUMERICSPECIAL = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!§$%&/()=?*_:;>{[]+~#-.,<^`´@';
15+
716
/**
817
* Anonymizes a string.
918
* <p>This function replaces most

0 commit comments

Comments
 (0)