public function onVote(WC_Challenge $chall) { if ('0' === ($userid = GWF_Session::getUserID())) { return GWF_HTML::err('ERR_LOGIN_REQUIRED'); } if (!WC_ChallSolved::hasSolved($userid, $chall->getID())) { return $this->module->error('err_chall_vote'); } $form = $this->getFormVote($chall, false, $userid); if (false !== ($error = $form->validate($this->module))) { return $error; } if (false !== ($vs = $chall->getVotesDif())) { $vs->onUserVoteSafe($_POST['dif'], $userid); } if (false !== ($vs = $chall->getVotesEdu())) { $vs->onUserVoteSafe($_POST['edu'], $userid); } if (false !== ($vs = $chall->getVotesFun())) { $vs->onUserVoteSafe($_POST['fun'], $userid); } if (false === WC_ChallSolved::setVoted($userid, $chall->getID(), true)) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } if (false === $chall->onRecalcVotes()) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } return $this->module->message('msg_chall_voted'); }
public function execute() { if (false === ($chall = WC_Challenge::getByID(Common::getGetString('cid')))) { return $this->module->error('err_chall'); } $user = GWF_User::getStaticOrGuest(); $token = Common::getGetString('token'); $length = Common::clamp(Common::getGetInt('length'), 1); require_once GWF_CORE_PATH . 'module/WeChall/WC_ChallSolved.php'; require_once GWF_CORE_PATH . 'module/WeChall/WC_MathChall.php'; if (!WC_ChallSolved::hasSolved($user->getID(), $chall->getID())) { if (!WC_MathChall::checkToken($chall, $length, $token)) { return $this->module->error('err_token'); } } return $this->templateSolutions($chall, $user, $length, $token); }
} else { $c1 = '<b>Momo</b>'; } if (false !== ($jinx = GWF_User::getByName('Jinx'))) { $c2 = $jinx->displayProfileLink(); } else { $c2 = '<b>Jinx</b>'; } if (false !== ($paipai = GWF_User::getByName('paipai'))) { $c3 = $paipai->displayProfileLink(); } else { $c3 = '<b>paipai</b>'; } $c4 = '<b>Miles Kaufmann</b>'; echo GWF_Box::box($chall->lang('info', array($maxlen, $img, $c1, $c2, $c3, $c4)), $chall->lang('title')); if (WC_ChallSolved::hasSolved(GWF_Session::getUserID(), $chall->getID())) { require_once GWF_CORE_PATH . 'module/WeChall/WC_MathChall.php'; echo GWF_Box::box(WC_HTML::lang('msg_wmc_solved', array($chall->display('chall_title'), WC_MathChall::getLimitedHREF($chall, 0)))); } if ('' !== ($formula = Common::getPostString('formula'))) { math_pyramid_check($chall, $formula, $maxlen); } ?> <div class="box box_c"> <form action="index.php" method="post"> <div><?php echo $chall->lang('th_formula'); ?> : <input type="text" name="formula" value="<?php echo htmlspecialchars($formula); ?>
include 'stalking_solution.php'; chdir('../../../'); define('GWF_PAGE_TITLE', 'Stalking'); require_once 'challenge/html_head.php'; require_once GWF_CORE_PATH . 'module/WeChall/solutionbox.php'; if (false === ($chall = WC_Challenge::getByTitle(GWF_PAGE_TITLE))) { $chall = WC_Challenge::dummyChallenge(GWF_PAGE_TITLE, 10, 'challenge/identity/stalking/index.php', false); } $chall->showHeader(); # That would be you! $user = GWF_User::getStaticOrGuest(); # Get prerequisite challenge if (false === ($identity = WC_Challenge::getByTitle('Identity'))) { echo GWF_HTML::err('ERR_GENERAL', array(__FILE__, __LINE__)); } else { if (!WC_ChallSolved::hasSolved($user->getID(), $identity->getID())) { $ida = sprintf('<a href="%s">%s</a>', htmlspecialchars($identity->hrefChallenge()), htmlspecialchars($identity->getName())); echo GWF_HTML::error($chall->lang('title'), $chall->lang('err_identity', $ida)); } else { # Did we get an anwer at all? if ('' !== ($answer = Common::getPostString('answer', ''))) { # Bruteforcing answers? if (false !== ($error = $chall->isAnswerBlocked($user))) { echo $error; } elseif (false !== ($error = stalking_check_answer($chall, $answer))) { echo GWF_HTML::error($chall->lang('title'), $error); } else { echo GWF_HTML::message($chall->lang('title'), $chall->lang('msg_correct')); $chall->onChallengeSolved($user->getID()); } }