/** * @return void */ public function show() { $editing = false; if (Team::isSuperAdmin()) { $editing = HTMLResponse::fromGET('edit', ''); if (!$editing) { ?> <a href="<?=HTMLResponse::getRoute()?>?edit=1"> Editar página </a> <? } else { ?> <a href="<?=HTMLResponse::getRoute()?>" onclick="return confirm('Quieres descartar los cambios?')"> Descartar y volver a la página </a> <? } ?> <div style="height: 6px"></div> <? } $content = Setting::getKey('rules_content'); if (!$editing) { ?><div class="inblock" style="margin: 0 auto; max-width: 90%; text-align: justify"> <?=$content?> </div><? } else { if (!$csrf = $_SESSION['csrf']) { $_SESSION['csrf'] = $csrf = rand(1, 1000000); } if (HTMLResponse::fromGETorPOST('csrf', '') == $csrf) { $content = HTMLResponse::fromPOST('content'); Setting::setKey('rules_content', $content); HTMLResponse::exitWithRoute(HTMLResponse::getRoute()); } $this->design->addJavaScript('//cdn.ckeditor.com/4.5.7/full/ckeditor.js'); $this->design->addJavaScript(" CKEDITOR.replace( 'editor' ) ", false); ?> <form action="<?=HTMLResponse::getRoute()?>?edit=1" method="post"> <div style="width:90%; margin: 0 auto"> <textarea name="content" id="editor"><?=htmlentities($content)?></textarea> </div> <br> <input type="hidden" name="csrf" value="<?=$csrf?>"> <button type="submit">Guardar cambios</button> </form> <? } }
public static function doBotLogin() { $oauth_token = HTMLResponse::fromGETorPOST('oauth_token'); $oauth_verifier = HTMLResponse::fromGETorPOST('oauth_verifier'); if ($oauth_token && $oauth_verifier && $oauth_token === $_SESSION['oauth_token_bot']) { $connection = new TwitterOAuth(CONSUMER_KEY_BOT, CONSUMER_SECRET_BOT, $oauth_token, $_SESSION['oauth_token_secret_bot']); $access_token = $connection->oauth("oauth/access_token", array("oauth_verifier" => $oauth_verifier)); if ($userid = $access_token['user_id']) { $botConfig['twitter-userid'] = $userid; $botConfig['twitter-username'] = $access_token['screen_name']; $botConfig['oauth_token'] = $access_token['oauth_token']; $botConfig['oauth_token_secret'] = $access_token['oauth_token_secret']; $botConfig['dateline'] = time(); unset($_SESSION['oauth_token_bot']); $con = "<?php return " . var_export($botConfig, true) . "; ?>"; file_put_contents("botconfig.php", $con); return true; } } return false; }