Esempio n. 1
0
 /**
  * @param $link
  * @return Season
  */
 public static function getByLink($link)
 {
     foreach (Season::find('1=1') as $season) {
         if (($season->ispublic || Team::isAdmin()) && $season->getLink() == $link) {
             return $season;
         }
     }
 }
Esempio n. 2
0
    /**
     * @return void
     */
    public function show()
    {
        if (!Team::isSuperAdmin()) {
            HTMLResponse::exitWithRoute('/');
        }

        if (!($csrf = $_SESSION['csrf'])) {
            $_SESSION['csrf'] = $csrf = rand(1, 1000000);
        }
        $postCsrf = HTMLResponse::fromPOST('csrf', '');

        if ($postCsrf == $csrf) {
            $newSeason = Season::create();
            $newSeason->ispublic = false;
            $newSeason->isdefault = false;
            $newSeason->save();
            $newSeason->name = "Temporada {$newSeason->seasonid}";
            $newSeason->save();
        }

        ?>
        <table style="width: 512px; margin: 0 auto">
            <thead>
            <tr>
                <td>#</td>
                <td>Nombre</td>
                <td>Opciones</td>
                <td>Acciones</td>
            </tr>
            </thead>
            <?
            foreach(Season::find('1=1') as $season) {
                ?>
                <tr>
                    <td><?=$season->seasonid?></td>
                    <td><?=htmlentities($season->name)?></td>
                    <td>
                        <?= $season->ispublic ? 'Pública' : 'Oculta' ?>
                        <?= $season->isdefault ? '(por defecto)' : '' ?>
                    </td>
                    <td style="text-align: left">
                        <a href="/admin/temporadas/<?=$season->seasonid?>/">
                            Editar temporada
                        </a><br>
                        <a href="/admin/temporadas/<?=$season->seasonid?>/jornadas/">
                            Editar jornadas
                        </a><br>
                        <a href="/admin/temporadas/<?=$season->seasonid?>/eventos/">
                            Editar eventos
                        </a>
                    </td>
                </tr>
                <?
            }
            ?>
        </table><br>

        <form action="<?=HTMLResponse::getRoute()?>" method="post">
            <input type="hidden" name="csrf" value="<?=$csrf?>">
            <button type="submit">Añadir nueva temporada</button>
        </form><br>
        <?
    }
Esempio n. 3
0
    public function showBody()
    {
        ?>
        <div id="main" class="public">
            <div class="content">
                <div class="banner"></div>
                <div class="nav" style="text-align: left">
                    <?php
                    foreach ($this->topMenu as $arr) {
                        list($link, $label, $re) = $arr;
                        $status = '';
                        if (preg_match("'^$re$'", HTMLResponse::getRoute())) {
                            $status = 'selected';
                        }

                        ?><a href="<?= $link ?>" class="<?= $status ?>"><?= $label ?></a><?php }
                    ?>
                    <div style="float: right">
                        <select name="season" id="navSeason">
                            <?php
                            $seasons = Team::isSuperAdmin() ?
                                Season::find('1=1') :
                                Season::find('ispublic');
                            foreach($seasons as $season) {
                                $selected = $season->seasonid == $this->season->seasonid ? 'selected' : '';
                                ?>
                                <option value="<?=$season->getLink()?>" <?=$selected?>>
                                    <?=htmlentities($season->name)?>
                                </option>
                            <? } ?>
                        </select>
                    </div>
                </div>
                <div style="padding: 6px">
                    <?php if (TwitterAuth::isLogged()) { ?>
                        Estás identificado como <?=htmlentities(TwitterAuth::getUserName())?>. <a href="<?=HTMLResponse::getRoute()?>?logout=1">Cerrar sesión</a>
                        <?php if (Team::isMember()) {
                            ?>/ <a href="/votaciones/">Votaciones</a><?php
                        } ?>
                        <?php if (Team::isSuperAdmin()) {
                            ?>/ <a href="/admin/">Panel de admin</a><?php
                        } ?>
                        <br>
                        <?php
                        if (TwitterAuth::isBot()) {
                            $botConfig = TwitterAuth::getBotConfig();
                            ?>
                            <br>Eres la cuenta oficial de la LCE, haz <a href="/?authenticatebot=1">click aquí</a> para autorizar esta web a usarte como un bot.<br>
                            <b>Última autorización:</b> <?= isset($botConfig['dateline'])
                                ? date('Y/m/d H:i:s', $botConfig['dateline'])
                                : 'Nunca' ?>
                            <?php
                        }
                        ?>
                    <?php } else { ?>
                        No estás identificado. <a href="<?=HTMLResponse::getRoute()?>?authenticate=1">Iniciar sesión</a><br>
                    <?php } ?>
                </div>

                <div class="title">
                    <?= $this->section->getSubtitle() ?>
                </div>

                <?=$this->contents?>
            </div>
        </div>
        <?php
    }
Esempio n. 4
0
File: bot.php Progetto: xJakub/LCE
                            $team = Team::get($teamid);
                            $msg = "Hola {$team->username}, falta por poner el vídeo de tu combate de hoy.";
                            echo "-> {$msg}\n";
                            TwitterAuth::botSendPrivateMessage($team->username, $msg);
                            sleep(1);
                        }
                    }
                }
            }
        }
    }
}
if (date('H') * 1 == 17 && date('i') * 1 < 15) {
    // 17:00 - 17:15
    // Videos
    foreach (Season::find('1=1') as $season) {
        $weeksCount = $season->getWeeksCount();
        for ($week = 1; $week <= $weeksCount; $week++) {
            if ($season->getWeekDate($week) == $date) {
                $weekName = $season->getWeekName($week);
                $matches = Match::find('seasonid = ? and week = ?', [$season->seasonid, $week]);
                foreach ($matches as $match) {
                    /** @var Team $team1 */
                    $team1 = $match->getTeam1();
                    /** @var Team $team2 */
                    $team2 = $match->getTeam2();
                    $video1 = Video::findOne('matchid = ? and teamid = ? and type = ?', [$match->matchid, $team1->teamid, 1]);
                    $video2 = Video::findOne('matchid = ? and teamid = ? and type = ?', [$match->matchid, $team2->teamid, 1]);
                    if ($video1 || $video2) {
                        $msg = "{$weekName} {$season->name}: #" . $team1->getHashtag() . " VS #" . $team2->getHashtag();
                        $msg .= " @{$team1->username} VS @{$team2->username}";