-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp_class.php
More file actions
executable file
·84 lines (76 loc) · 1.31 KB
/
app_class.php
File metadata and controls
executable file
·84 lines (76 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<?php
class application_vcd extends application
{
public function cout($str)
{
$args = func_get_args();
$str = array_shift($args);
$out = vsprintf($str,$args).BR;
if($this->captureCout)
$this->captureCoutStr .= $out;
else
print $out;
}
public function captureCout($name = null)
{
if(!$name)
{
$this->captureCout = null;
return $this->captureCoutStr;
}
$this->captureCoutStr = '';
$this->captureCout = $name;
}
public function cHex($str)
{
$out = '';
$out = raw2hex($str);
$this->cout($out);
}
}
function hex2raw($hex)
{
$data = '';
for($i = 0; $i < strlen($hex);)
{
$data .= chr(hexdec($hex[$i++].$hex[$i++]));
}
return $data;
}
function flipEnd($data)
{
return strrev($data);
}
function raw2hex($str)
{
$out = '';
for($i = 0; $i < strlen($str); $i++)
$out .= bin2hex($str[$i]);
return $out;
}
function raw2dec($data)
{
$dec = 0;
for($i = strlen($data); $i >= 0; $i--)
{
$dec += ord($data[$i]);
}
return $dec;
}
function raw2dec2($data)
{
$hex = bin2hex($data);
return hexdec($data);
}
/*
set_error_handler('error_handler');
function error_handler($code,$error)
{
if($code == E_WARNING)
if(1)
app()->cout('WARNING: '.$error);
else
print 'WARNING: '.$error.BR;
}
*/
?>