Fibinger Ádám
2019-10-17 b40e9386fb4253a5866b8e4cdcda0c2023783856
form.php
@@ -1,65 +1,49 @@
<?php
ini_set('display_errors', E_ALL);
include "vendor/autoload.php";
define('IS_DEV', (!isset($_SERVER['HTTP_HOST'])));
define('SITE_ROOT', __DIR__);
if (IS_DEV)
{
   define('OVERLAY_DIR', dirname(__DIR__) . '/esl-overlay/');
}
else
{
   define('OVERLAY_DIR', dirname(__DIR__) . '/overlays/');
}
$last_json = OVERLAY_DIR . 'last.json';
$twig = \EOG\Utils\TwigFactory::getEnvironment(SITE_ROOT);
include_once "common/base.php";
$s = new \EOG\Models\Stripe();
if (!empty($_POST['stripe']))
{
   $s->loadFromArray($_POST['stripe']);
if (!empty($_POST['stripe'])) {
    $s->loadFromArray($_POST['stripe']);
   if (!empty($s->getState()))
   {
      file_put_contents($last_json, $s->getJson());
   }
    if (!empty($s->getState())) {
        file_put_contents($last_json, $s->getJson());
    }
   $s->setClass('simple');
   $html_content = $twig->render('templates/overlay-base.twig', ['stripe' => $s]);
   file_put_contents(OVERLAY_DIR . 'simple.html', $html_content);
    $s->setClass('simple');
    $html_content = $twig->render('templates/overlay-base.twig', ['stripe' => $s]);
    file_put_contents(OVERLAY_DIR . 'simple.html', $html_content);
   $s->setClass('team');
   $html_content = $twig->render('templates/overlay-base.twig', ['stripe' => $s]);
   file_put_contents(OVERLAY_DIR . 'team.html', $html_content);
    $s->setClass('team');
    $html_content = $twig->render('templates/overlay-base.twig', ['stripe' => $s]);
    file_put_contents(OVERLAY_DIR . 'team.html', $html_content);
   $s->setClass('team-ban');
   $html_content = $twig->render('templates/overlay-base.twig', ['stripe' => $s]);
   file_put_contents(OVERLAY_DIR . 'team-ban.html', $html_content);
    $s->setClass('team-ban');
    $html_content = $twig->render('templates/overlay-base.twig', ['stripe' => $s]);
    file_put_contents(OVERLAY_DIR . 'team-ban.html', $html_content);
} else {
    if (file_exists($last_json)) {
        $raw_json = file_get_contents($last_json);
        $stateArray = json_decode($raw_json, true);
        if (is_array($stateArray)) {
            $s->loadFromArray($stateArray);
        }
    }
}
else
{
   if (file_exists($last_json))
   {
      $raw_json = file_get_contents($last_json);
      $stateArray = json_decode($raw_json, true);
      if (is_array($stateArray))
      {
         $s->loadFromArray($stateArray);
      }
   }
$teams = new \EOG\Models\TeamList();
if (file_exists(OVERLAY_DIR . 'teams.json')) {
    var_dump($teams->fromJson(file_get_contents(OVERLAY_DIR . 'teams.json')));
}
$var = [
   'stripe'    => $s,
   'operators' => $s->getOperators(),
   'post'      => !empty($_POST['stripe'])
    'stripe' => $s,
    'teamNames' => $teams->getTeamNames(),
    'operators' => $s->getOperators(),
    'post' => !empty($_POST['stripe'])
];
echo $twig->render('templates/admin/form.twig', $var);
echo $twig->render('templates/admin/stripe-form.twig', $var);