Fibinger Ádám
2020-06-04 acb792c92398ed0dd9b45a0a3007c4747de2eba7
commit | author | age
812087 1 <?php
b40e93 2 include_once "common/base.php";
812087 3
cc3ac8 4 $s = new \EOG\Models\Stripe();
5
b40e93 6 if (!empty($_POST['stripe'])) {
7     $s->loadFromArray($_POST['stripe']);
812087 8
b40e93 9     if (!empty($s->getState())) {
a4186a 10         file_put_contents(STRIPE_JSON, $s->getJson());
b40e93 11     }
cc3ac8 12
b40e93 13     $s->setClass('simple');
c5946f 14     $html_content = $twig->render('overlays/stripe.twig', ['stripe' => $s]);
b40e93 15     file_put_contents(OVERLAY_DIR . 'simple.html', $html_content);
1867e1 16
b40e93 17     $s->setClass('team');
c5946f 18     $html_content = $twig->render('overlays/stripe.twig', ['stripe' => $s]);
b40e93 19     file_put_contents(OVERLAY_DIR . 'team.html', $html_content);
1867e1 20
b40e93 21     $s->setClass('team-ban');
c5946f 22     $html_content = $twig->render('overlays/stripe.twig', ['stripe' => $s]);
b40e93 23     file_put_contents(OVERLAY_DIR . 'team-ban.html', $html_content);
1867e1 24
cffd2c 25     $s->setClass('team-ban');
26     $html_content = $twig->render('overlays/stripe.twig', ['stripe' => $s, 'autorefresh' => 30]);
27     file_put_contents(OVERLAY_DIR . 'team-ban-refresh.html', $html_content);
28
906fcf 29     $redis = new Redis();
30     $redis->pconnect('127.0.0.1');
31     $redis->publish('overlay', 'update');
32     $redis->close();
33
b40e93 34 } else {
a4186a 35     if (file_exists(STRIPE_JSON)) {
36         $raw_json = file_get_contents(STRIPE_JSON);
b40e93 37         $stateArray = json_decode($raw_json, true);
38         if (is_array($stateArray)) {
39             $s->loadFromArray($stateArray);
40         }
41     }
1867e1 42 }
b40e93 43
44 $teams = new \EOG\Models\TeamList();
45
a4186a 46 if (file_exists(TEAMS_JSON)) {
47     $teams->fromJson(file_get_contents(TEAMS_JSON));
1867e1 48 }
f6a0dc 49 $page = isset($_GET['page']) ? $_GET['page'] : 'overlay';
50 $page = in_array($page,['overlay','interview','update']) ? $page : 'overlay';
268b32 51
cc3ac8 52 $var = [
f6a0dc 53     'page' => $page,
b40e93 54     'stripe' => $s,
55     'teamNames' => $teams->getTeamNames(),
56     'operators' => $s->getOperators(),
57     'post' => !empty($_POST['stripe'])
cc3ac8 58 ];
b40e93 59
f6a0dc 60 echo $twig->render('admin/modules/'.$page .'.twig', $var);
812087 61