forked from oraoto/pib
-
-
Notifications
You must be signed in to change notification settings - Fork 57
/
Copy pathcallbacks.php
44 lines (33 loc) · 1.09 KB
/
callbacks.php
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
<?php // {"autorun":true, "persist":true, "single-expression": false, "render-as": "text"}
##################################
# #
# Open your JS console and run: #
# #
# > phpFuncA() #
# > phpFuncB() #
# #
##################################
$setup = $setup ?? false;
$x = $x ?? 0;
$y = $y ?? 0;
var_dump($x);
if(!$setup)
{
$window = new Vrzno;
$f = $window->phpFuncA = function() use(&$x, &$y, $window) {
printf('RAN phpFuncA! $x: %d, $y: %d' . PHP_EOL, ++$x, $y);
return $x;
};
$g = $window->phpFuncB = function() use(&$x, &$y, $window) {
$window->alert(sprintf('RAN phpFuncB! $x: %d, $y: %d', $x, ++$y));
return $y;
};
$setup = true;
echo "Initialized.\n";
fprintf(fopen('php://STDERR', 'w'), 'Open your JS console and run' . PHP_EOL);
fprintf(fopen('php://STDERR', 'w'), 'phpFuncA() or phpFuncB()' . PHP_EOL);
}
$window->phpFuncA();
// $window->phpFuncB();
// vrzno_eval('window.phpFuncA()');
vrzno_eval('window.phpFuncB()');