Fibinger Ádám
2020-06-04 ffa7c6f5c007dfc826aef0ca27d23bb69bbeed7e
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
<?php
include_once "common/base.php";
 
$s = new \EOG\Models\Stripe();
 
if (!empty($_POST['stripe'])) {
    $s->loadFromArray($_POST['stripe']);
 
    if (!empty($s->getState())) {
        file_put_contents(STRIPE_JSON, $s->getJson());
    }
 
    $s->setClass('simple');
    $html_content = $twig->render('overlays/stripe.twig', ['stripe' => $s]);
    file_put_contents(OVERLAY_DIR . 'simple.html', $html_content);
 
    $s->setClass('team');
    $html_content = $twig->render('overlays/stripe.twig', ['stripe' => $s]);
    file_put_contents(OVERLAY_DIR . 'team.html', $html_content);
 
    $s->setClass('team-ban');
    $html_content = $twig->render('overlays/stripe.twig', ['stripe' => $s]);
    file_put_contents(OVERLAY_DIR . 'team-ban.html', $html_content);
 
    $s->setClass('team-ban');
    $html_content = $twig->render('overlays/stripe.twig', ['stripe' => $s, 'autorefresh' => 30]);
    file_put_contents(OVERLAY_DIR . 'team-ban-refresh.html', $html_content);
 
    $redis = new Redis();
    $redis->pconnect('127.0.0.1');
    $redis->publish('overlay', 'update');
    $redis->close();
 
} else {
    if (file_exists(STRIPE_JSON)) {
        $raw_json = file_get_contents(STRIPE_JSON);
        $stateArray = json_decode($raw_json, true);
        if (is_array($stateArray)) {
            $s->loadFromArray($stateArray);
        }
    }
}
 
$teams = new \EOG\Models\TeamList();
 
if (file_exists(TEAMS_JSON)) {
    $teams->fromJson(file_get_contents(TEAMS_JSON));
}
$page = isset($_GET['page']) ? $_GET['page'] : 'overlay';
$page = in_array($page,['overlay','interview','update']) ? $page : 'overlay';
 
$var = [
    'page' => $page,
    'stripe' => $s,
    'teamNames' => $teams->getTeamNames(),
    'operators' => $s->getOperators(),
    'post' => !empty($_POST['stripe'])
];
 
echo $twig->render('admin/modules/'.$page .'.twig', $var);