/** * @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><? }
foreach ([$match->team1id, $match->team2id] as $teamid) { if ($match->result == 0) { // Falta resultado $team = Team::get($teamid); $msg = "Hola {$team->username}, falta por poner el resultado de tu combate de hoy."; echo "-> {$msg}\n"; TwitterAuth::botSendPrivateMessage($team->username, $msg); sleep(1); } $video = Video::findOne('matchid = ? and teamid = ? and type = ?', [$match->matchid, $teamid, 1]); if (!$video) { // Falta video $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) {