Beispiel #1
0
    /**
     * @return void
     */
    public function show()
    {
        if (!Team::isSuperAdmin()) {
            HTMLResponse::exitWithRoute('/');
        }
        if (!TwitterAuth::getBotConfig()) {
            ?>Error: el bot no está configurado<br><?
            return;
            }

        if (HTMLResponse::fromPOST('csrf', '') && strlen(trim(HTMLResponse::fromPOST('message','')))) {
            if ($_SESSION['csrf'] != HTMLResponse::fromPOST('csrf', '')) {
                ?>Error: código de seguridad incorrecto.<br><br><?
            }
            else {
                $message = HTMLResponse::fromPOST('message');
                ?>
                <b>Mensaje</b>: <?=htmlentities($message)?><br><br>

<?
                foreach(Team::find('ismember order by username asc') as $team) {
                    $lowname = strtolower($team->username);
                    if (HTMLResponse::fromPOST("check{$lowname}", '')) {
                        $ok = false;

                        $ok = !!TwitterAuth::botSendPrivateMessage($lowname, $message);

                        ?>-<?=$team->username?>:
                        <?= $ok?'Enviado correctamente':'Error en el envío' ?>
                        <br>
                        <?
                    }
                }
                ?><br><br><?
                return;
            }
        }

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

        ?><div style="max-width: 640px; margin: 0 auto">
        <form action="<?=HTMLResponse::getRoute()?>" method="post">
            <b>Texto del comunicado (será enviado por MD en Twitter):</b><br>
            <textarea style="width: 320px" name="message"></textarea><br>
            <br>
            <b>Destinatarios del comunicado (
                <a href="javascript:void(0)" onclick="$(this).closest('div').find('input[type=checkbox]').attr('checked','checked')">
                    seleccionar todos
                </a>
                ):</b><br>
            <?
            foreach(Team::find('ismember order by username asc') as $team) {
                $lowname = strtolower($team->username);
                ?>
                <div class="inblock" style="margin: 6px; text-align: left; width: 180px">
                    <div class="inblock middle">
                        <input id="check<?=$lowname?>"type="checkbox" name="check<?=$lowname?>">
                    </div>
                    <div class="inblock middle">
                        <label for="check<?=$lowname?>">
                            <?= $team->username ?><br>
                            <span style="font-style:italic; color: #666">
                                <?= $team->name ?>
                            </span>
                        </label>
                    </div>
                </div>
                <?
            }
            ?></div><br>
            <input type="hidden" name="csrf" value="<?= $csrf ?>">
            <button type="submit">Enviar comunicado</button>
        </form><br><br><?
    }
Beispiel #2
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
    }