public function isFlooding() { $uid = GWF_Session::getUserID(); $uname = GWF_Shoutbox::generateUsername(); $euname = GDO::escape($uname); $table = GDO::table('GWF_Shoutbox'); $max = $uid === 0 ? $this->module->cfgMaxPerDayGuest() : $this->module->cfgMaxPerDayUser(); // $cut = GWF_Time::getDate(GWF_Time::LEN_SECOND, time()-$this->module->cfgTimeout()); // $cnt = $table->countRows("shout_uname='$euname' AND shout_date>'$cut'"); # Check captcha if ($this->module->cfgCaptcha()) { require_once GWF_CORE_PATH . 'inc/3p/Class_Captcha.php'; if (!PhpCaptcha::Validate(Common::getPostString('captcha'), true)) { return GWF_HTML::err('ERR_WRONG_CAPTCHA'); } } # Check date $timeout = $this->module->cfgTimeout(); $last_date = $table->selectVar('MAX(shout_date)', "shout_uid={$uid} AND shout_uname='{$euname}'"); $last_time = $last_date === NULL ? 0 : GWF_Time::getTimestamp($last_date); $next_time = $last_time + $timeout; if ($last_time + $timeout > time()) { return $this->module->error('err_flood_time', array(GWF_Time::humanDuration($next_time - time()))); } # Check amount $today = GWF_Time::getDate(GWF_Date::LEN_SECOND, time() - $timeout); $count = $table->countRows("shout_uid={$uid} AND shout_date>='{$today}'"); if ($count >= $max) { return $this->module->error('err_flood_limit', array($max)); } # All fine return false; }
private function sanitize() { $this->quoted = Common::getGet('quote') !== false; if (false === ($pid = Common::getGet('pid'))) { if (false === ($this->thread = $this->module->getCurrentThread())) { return $this->module->error('err_post'); } if (false === ($this->post = $this->thread->getLastPost())) { // return $this->module->error('err_post'); } $this->replyThread = true; } elseif (false === ($this->post = $this->module->getCurrentPost())) { return $this->module->error('err_post'); } else { if (false === ($this->thread = $this->post->getThread())) { return $this->module->error('err_post'); } } # Check Permission $user = GWF_Session::getUser(); if (!$this->thread->hasReplyPermission($user, $this->module)) { $a = GWF_HTML::display($this->post->getShowHREF()); return $this->module->error('err_reply_perm', array($a)); } if (false !== ($last_post = $this->thread->getLastPost())) { if ($last_post->getPosterID() === GWF_Session::getUserID()) { if (!$this->module->cfgDoublePost()) { $a = GWF_HTML::display($this->post->getShowHREF()); return $this->module->error('err_better_edit', array($a)); } } } return false; }
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'); }
private function onAdd() { $form = $this->formAdd(); if (false !== ($error = $form->validate($this->module))) { return $error . $this->templateAdd(); } $file = $form->getVar('file'); $tmp = $file['tmp_name']; $postid = $this->post->getID(); $userid = GWF_Session::getUserID(); $options = 0; $options |= isset($_POST['guest_view']) ? GWF_ForumAttachment::GUEST_VISIBLE : 0; $options |= isset($_POST['guest_down']) ? GWF_ForumAttachment::GUEST_DOWNLOAD : 0; # Put in db $attach = new GWF_ForumAttachment(array('fatt_aid' => 0, 'fatt_uid' => $userid, 'fatt_pid' => $postid, 'fatt_mime' => GWF_Upload::getMimeType($tmp), 'fatt_size' => filesize($tmp), 'fatt_downloads' => 0, 'fatt_filename' => $file['name'], 'fatt_options' => $options, 'fatt_date' => GWF_Time::getDate(GWF_Date::LEN_SECOND))); if (false === $attach->insert()) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } $aid = $attach->getID(); # Copy file $path = $attach->dbimgPath(); if (false === GWF_Upload::moveTo($file, $path)) { @unlink($tmp); return GWF_HTML::err('ERR_WRITE_FILE', $path); } @unlink($tmp); $this->post->increase('post_attachments', 1); return $this->module->message('msg_attach_added', array($this->post->getShowHREF())); }
public function __wakeup() { if (false === ($chall = WC_Challenge::getByTitle(GWF_PAGE_TITLE))) { $chall = WC_Challenge::dummyChallenge(GWF_PAGE_TITLE, 2, 'challenge/are_you_serial/index.php'); } $chall->onChallengeSolved(GWF_Session::getUserID()); }
function dldc_cleanup() { $table = GDO::table('DLDC_User'); $table->deleteWhere("wechall_userid=" . GWF_Session::getUserID()); if ($table->affectedRows() > 0) { echo GWF_HTML::message('Disclosures', 'We have deleted your old account for this challenge!', false); } }
private function getTicketCountStaff() { $uid = GWF_Session::getUserID(); $read = GWF_HelpdeskTicket::STAFF_READ; if (0 == ($c = GDO::table('GWF_HelpdeskTicket')->countRows("hdt_worker={$uid} AND hdt_options&{$read}=0"))) { return ''; } return "[{$c}]"; }
function www_basic_go(WC_Challenge $chall, $url, $content) { if (false === ($response = GWF_HTTP::getFromURL($url))) { echo GWF_HTML::error('WWW Basics', $chall->lang('err_file_not_found')); } elseif ($response !== $content) { echo GWF_HTML::error('WWW Basics', $chall->lang('err_wrong', array(htmlspecialchars($response), htmlspecialchars($content), strlen($response), strlen($content)))); } else { $chall->onChallengeSolved(GWF_Session::getUserID()); } }
public function execute() { GWF_Website::plaintext(); GWF3::setConfig('store_last_url', false); $id = Common::getGetInt('pp_id'); if (!GWF_ProfilePOI::changeAllowed($id, GWF_Session::getUserID())) { $this->module->ajaxError('Permission error!'); } GDO::table('GWF_ProfilePOI')->deleteWhere("pp_id = {$id}"); die("{$id}"); }
private function sanitize() { if (false === ($this->site = WC_Site::getByID(Common::getGetInt('siteid', 0)))) { return array($this->module->lang('err_site')); } require_once GWF_CORE_PATH . 'module/WeChall/WC_SiteAdmin.php'; if (!WC_SiteAdmin::isSiteAdmin(GWF_Session::getUserID(), $this->site->getID()) && !GWF_User::isAdminS()) { return array(GWF_HTML::lang('ERR_NO_PERMISSION')); } return false; }
private function onUnSubscribe() { $back = $this->thread->getLastPageHREF(); if (!$this->thread->canUnSubscribe()) { return $this->module->error('err_no_unsubscr', array($back)); } if (false === GWF_ForumSubscription::unsubscribe(GWF_Session::getUserID(), $this->thread->getID())) { return $this->module->error('err_unsubscr', array($back)); } return $this->module->message('msg_unsubscribed', array($back)); }
function wcc_ip6_check_answer(WC_Challenge $chall, $answer, $level) { require_once 'solutions.php'; if ($level === count($solutions)) { $ip = $_SERVER['REMOTE_ADDR']; if (GWF_IP6::isV6($ip)) { $chall->onChallengeSolved(GWF_Session::getUserID()); } return false; } return in_array(strtolower($answer), $solutions[$level], true); }
private function templateShow($translate) { $pm = $this->pm; $pm->markRead(GWF_Session::getUser()); $sender = $this->module->lang('th_pm_from') . ' ' . $pm->getSender()->displayProfileLink(); $receiver = $this->module->lang('th_pm_to') . ' ' . $pm->getReceiver()->displayProfileLink(); if ('' === ($translated = $this->getTranslated($translate))) { $translated = $pm->displayMessage(); } $tVars = array('pm' => $this->pm, 'actions' => true, 'title' => $this->pm->display('pm_title'), 'unread' => GWF_PM::getUnreadPMs($this->module, GWF_Session::getUserID()), 'translated' => $translated, 'sender' => $sender, 'receiver' => $receiver, 'sendrec' => $pm->isRecipient() ? $sender : $receiver, 'transid' => 'pm_trans_' . $pm->getID(), 'buttons' => $this->getButtons($this->pm)); return $this->module->template('show.tpl', $tVars); }
private function onUnSubscribe($boardid) { if (false !== ($error = $this->sanitize($boardid))) { return $error; } $userid = GWF_Session::getUserID(); if (false === GWF_ForumSubscrBoard::unsubscribe($userid, $boardid)) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } $href = htmlspecialchars($this->module->getMethodURL('Subscriptions')); return $this->module->message('msg_unsubscrboard', array($href)); }
public static function getCart() { $sessid = GWF_Session::getSessID(); if (false !== ($cart = self::table(__CLASS__)->selectFirst("orderc_sessid='{$sessid}'"))) { return $cart; } else { $cart = new self(array('orderc_uid' => GWF_Session::getUserID(), 'orderc_sessid' => $sessid)); if (false === $cart->insert()) { return false; } return $cart; } }
function www_rewrite_go(WC_Challenge $chall, $url) { $n1 = rand(1000000, 1000000000) . rand(1000000, 1000000000); $n2 = rand(1000000, 1000000000) . rand(1000000, 1000000000); $solution = bcmul($n1, $n2); $url .= $n1 . '_mul_' . $n2 . '.html'; if (false === ($response = GWF_HTTP::getFromURL($url))) { echo GWF_HTML::error('WWW Rewrite', $chall->lang('err_file_not_found')); } elseif ($response !== $solution) { echo GWF_HTML::error('WWW Rewrite', $chall->lang('err_wrong', array(htmlspecialchars($response), htmlspecialchars($solution), strlen($response), strlen($solution)))); } else { $chall->onChallengeSolved(GWF_Session::getUserID()); } }
private function onRefuse($gid) { if (false === ($group = GWF_Group::getByID($gid))) { return $this->module->error('err_unk_group'); } $userid = GWF_Session::getUserID(); if (false === ($row = GWF_UsergroupsInvite::getInviteRow($userid, $group->getID()))) { return $this->module->error('err_not_invited'); } if (false === $row->deny()) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } return $this->module->message('msg_refused', array($group->display('group_name'))); }
public function execute() { Module_WeChall::includeForums(); if (false !== ($cid = Common::getGet('solver'))) { return $this->templateSolvers($cid); } WC_HTML::$RIGHT_PANEL = WC_HTML::$LEFT_PANEL = -1; $for_userid = GWF_Session::getUserID(); $from_userid = false; $tag = Common::getGetString('tag', ''); $by = $_GET['by'] = Common::getGetString('by', self::DEFAULT_BY); $dir = $_GET['dir'] = Common::getGetString('dir', self::DEFAULT_DIR); return $this->templateChalls($for_userid, $from_userid, $tag, $by, $dir); }
private function onClear() { $form = $this->formDelete(); if (false !== ($error = $form->validate($this->module))) { return $error; } $userid = GWF_Session::getUserID(); if (false === GWF_LoginCleared::updateCleared($userid)) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } if (false === GDO::table('GWF_LoginHistory')->deleteWhere("loghis_uid={$userid}")) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } return $this->module->message('msg_cleared'); }
private function onZip() { $client = GWF_Client::getClient(GWF_Session::getUserID()); $rand = Common::randomDateStamp(); $archivename = 'dbimg/gwf_purchase_' . $rand . '.zip'; $zipper = $this->module->getMethod('Zipper'); $zipper instanceof VersionServer_Zipper; $zipper->setArchiveName($archivename); $error = $zipper->onZip($client->getModuleNames(), 'default'); if ($zipper->hasError()) { return $error; } GWF_Upload::outputFile($archivename, 'arc/zip'); return $error; }
public function execute() { if (false === ($this->row = BAIM_MC::getByUID(GWF_Session::getUserID()))) { return $this->module->error('err_not_purchased'); } if ($this->row->isDemo()) { return $this->module->error('err_not_purchased'); } // var_dump($this->row); $back = ''; if (false !== Common::getPost('set')) { $back = $this->onSetMC($this->row); } return $back . $this->templateMC($this->row); }
private function onAddLyrics(Slay_Song $song) { $form = $this->formAddLyrics($song); if (false !== ($error = $form->validate($this->module))) { return $error; } $options = isset($_POST['enabled']) ? Slay_Lyrics::ENABLED : 0; if (false === GDO::table('Slay_Lyrics')->insertAssoc(array('ssl_sid' => $song->getID(), 'ssl_uid' => GWF_Session::getUserID(), 'ssl_date' => GWF_Time::getDate(GWF_Date::LEN_SECOND), 'ssl_edit_date' => NULL, 'ssl_lyrics' => $form->getVar('lyrics'), 'ssl_options' => $options), true)) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } if (false === $song->updateLyricsCount()) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } return $this->module->message('msg_added_lyrics'); }
public function execute() { if (false === ($ban = GWF_Ban::getByID(Common::getGet('bid')))) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } if ($ban->getUser()->getID() !== GWF_Session::getUserID()) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } if (!$ban->isWarning()) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } if (false === $ban->saveOption(GWF_Ban::READ, true)) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } return $this->module->message('msg_marked_read'); }
private function templateTickets() { $limit = 25; $uid = GWF_Session::getUserID(); $tickets = GDO::table('GWF_HelpdeskTicket'); $where = "hdt_uid={$uid}"; $by = Common::getGetString('by', 'hdt_date'); $dir = Common::getGetString('dir', 'DESC'); $orderby = $tickets->getMultiOrderby($by, $dir); $nItems = $tickets->countRows($where); $nPages = GWF_PageMenu::getPagecount($limit, $nItems); $page = Common::clamp(Common::getGetInt('page'), 1, $nPages); $from = GWF_PageMenu::getFrom($page, $limit); $tVars = array('tickets' => $tickets->selectAll('*, worker.user_name worker_name', $where, $orderby, array('worker'), $limit, $from, GDO::ARRAY_O), 'pagemenu' => GWF_PageMenu::display($page, $nPages, GWF_WEB_ROOT . 'index.php?mo=Helpdesk&me=ShowTickets&by=' . urlencode($by) . '&dir=' . urlencode($dir) . '&page=%PAGE%'), 'sort_url' => GWF_WEB_ROOT . 'index.php?mo=Helpdesk&me=ShowTickets&by=%BY%&dir=%DIR%'); return $this->module->template('user.tpl', $tVars); }
private static function getQuickUpdateBar() { if ('0' === ($uid = GWF_Session::getUserID())) { return ''; } $sites = WC_Site::getQuickUpdateSites($uid); $back = ''; if (count($sites) > 0) { foreach ($sites as $site) { $site instanceof WC_Site; $back .= sprintf('<a href="%s">%s</a>', GWF_WEB_ROOT . 'index.php?mo=WeChall&me=LinkedSites&quick_update=' . $site->getVar('site_id'), $site->displayLogo(20, $site->getVar('site_name'), false)); } return sprintf('<div id="wc_qupdatebar">%s: %s</div>', self::lang('th_quickupdate'), $back); } return ''; }
private function onVote(GWF_ForumPost $post, $up = 1) { if (!$this->module->cfgVotesEnabled()) { return $this->module->error('err_votes_off'); } $userid = GWF_Session::getUserID(); if ($userid === $post->getUserID()) { return $this->module->error('err_vote_self'); } if ($up === 1) { $post->onVoteUp($userid); } else { $post->onVoteDown($userid); } return '1:' . $post->getVar('post_votes_up') . ':' . $post->getVar('post_votes_down'); // return $this->module->message('msg_voted'); }
function shadowlamb3solver(WC_Challenge $chall, $answer) { if (!GWF_Session::isLoggedIn()) { echo GWF_HTML::error('Shadowlamb', 'Better login first!'); return; } $code = WC5Lamb_Solution::validateSolution3($answer, GWF_Session::getUserID()); switch ($code) { case 1: echo GWF_HTML::message('Shadowlamb', $chall->lang('msg_right')); $chall->onChallengeSolved(GWF_Session::getUserID()); break; default: echo GWF_HTML::error('Shadowlamb', $chall->lang('err_wrong_' . $code)); break; } }
private function getPollSelect() { if (false === ($mv = GWF_Module::getModule('Votes'))) { return GWF_HTML::lang('ERR_MODULE_MISSING', array('Votes')); } $uid = GWF_Session::getUserID(); if (false === ($polltable = GDO::table('GWF_VoteMulti'))) { return GWF_HTML::lang('ERR_MODULE_MISSING', array('Votes')); } $polls = $polltable->selectAll('vm_id, vm_title', "vm_uid={$uid}", 'vm_title ASC', NULL, -1, -1, GDO::ARRAY_N); $data = array(array('0', $this->module->lang('sel_poll'))); foreach ($polls as $poll) { $data[] = $poll; // $data[] = $poll;array($poll[0], $poll->getVar('vm_title'), ); } return GWF_Select::display('pollid', $data, Common::getPostString('pollid', '0')); }
public function onMarkRead(GWF_HelpdeskTicket $ticket, GWF_HelpdeskMsg $message) { if (false === $message->saveOption(GWF_HelpdeskMsg::READ, true)) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } $bit = 0; if (GWF_Session::getUserID() === $ticket->getWorkerID()) { $bit |= GWF_HelpdeskTicket::STAFF_READ; } if (GWF_Session::getUserID() === $ticket->getCreatorID()) { $bit |= GWF_HelpdeskTicket::USER_READ; } if (false === $ticket->saveOption($bit, true)) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } return $this->module->message('msg_read'); }
private function getConditions() { switch (Common::getGetString('mode')) { case 'own': $uid = GWF_Session::getUserID(); return "hdt_worker={$uid}"; case 'open': return "hdt_status='open'"; case 'work': return "hdt_status='working'"; case 'closed': return "hdt_status='solved'"; case 'unsolved': return "hdt_status='unsolved'"; default: return ''; } }