Beispiel #1
0
 public function execute()
 {
     if (false === ($site = WC_Site::getByID(Common::getGet('siteid')))) {
         return $this->module->error('err_site');
     }
     return $this->templateDDOS($site);
 }
Beispiel #2
0
 private function templateUsers($term = '')
 {
     $ipp = $this->module->cfgIPP();
     $form = $this->getFormQuick();
     $usertable = GDO::table('GWF_User');
     $by = Common::getGet('by', '');
     $dir = Common::getGet('dir', '');
     $orderby = $usertable->getMultiOrderby($by, $dir);
     if ($term === '') {
         $users = array();
         $page = 1;
         $nPages = 0;
     } else {
         $eterm = GDO::escape($term);
         $deleted = GWF_User::DELETED;
         $conditions = "user_name LIKE '%{$eterm}%' AND user_options&{$deleted}=0";
         $nItems = $usertable->countRows($conditions);
         $nPages = GWF_PageMenu::getPagecount($ipp, $nItems);
         $page = Common::clamp(intval(Common::getGet('page', 1)), 1, $nPages);
         $from = GWF_PageMenu::getFrom($page, $ipp);
         $users = $usertable->selectObjects('*', $conditions, $orderby, $ipp, $from);
     }
     $href_pagemenu = GWF_WEB_ROOT . 'index.php?mo=Usergroups&me=Search&term=' . urlencode($term) . '&by=' . urlencode($by) . '&dir=' . urlencode($dir) . '&page=%PAGE%';
     $tVars = array('form' => $form->templateX(false, false), 'users' => $users, 'sort_url' => GWF_WEB_ROOT . 'index.php?mo=Usergroups&me=Search&term=' . urlencode($term) . '&by=%BY%&dir=%DIR%&page=1', 'page_menu' => GWF_PageMenu::display($page, $nPages, $href_pagemenu), 'href_adv' => $this->module->getMethodURL('SearchAdv'));
     return $this->module->templatePHP('search.php', $tVars);
 }
Beispiel #3
0
 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;
 }
Beispiel #4
0
 public function execute()
 {
     if (false === ($gb = GWF_Guestbook::getByID(Common::getGet('gbid')))) {
         return $this->module->error('err_gb');
     }
     if (!$gb->canSign(GWF_Session::getUser(), $this->module->cfgAllowGuest())) {
         return GWF_HTML::err('ERR_NO_PERMISSION');
     }
     # In Reply To
     if (false !== ($msgid = Common::getGet('msgid'))) {
         if (false === ($gbe = GWF_GuestbookMSG::getByID($msgid))) {
             return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
         }
         if ($gbe->getVar('gbm_gbid') !== $gb->getID()) {
             return GWF_HTML::err('ERR_NO_PERMISSION');
         }
         if (false !== Common::getPost('sign')) {
             return $this->onSign($gb, $gbe);
         }
         return $this->templateReply($gb, $gbe);
     }
     if (false !== Common::getPost('sign')) {
         return $this->onSign($gb);
     }
     return $this->templateSign($gb);
 }
Beispiel #5
0
 public function execute()
 {
     if (false !== ($state = Common::getGet('rightpanel'))) {
         GWF_Session::set('WC_RIGHT_PANEL', $state > 0);
         GWF_Website::redirectBack();
     }
 }
Beispiel #6
0
 public function execute()
 {
     if (false === ($user = GWF_User::getByID(Common::getGet('userid')))) {
         return GWF_HTML::err('ERR_UNKNOWN_USER');
     }
     $tmpfile = GWF_PATH . 'extra/temp/gpg/' . $user->getVar('user_id');
     if (!is_file($tmpfile) || !is_readable($tmpfile)) {
         return GWF_HTML::err('ERR_FILE_NOT_FOUND', array($tmpfile));
     }
     if (false === ($file_content = file_get_contents($tmpfile))) {
         return GWF_HTML::err('ERR_FILE_NOT_FOUND', array($tmpfile));
     }
     if (false === unlink($tmpfile)) {
         return GWF_HTML::err('ERR_WRITE_FILE', array($tmpfile));
     }
     if (false === ($fingerprint = GWF_PublicKey::grabFingerprint($file_content))) {
         return $this->module->error('err_gpg_key');
     }
     if (Common::getGet('token') !== $fingerprint) {
         return $this->module->error('err_gpg_token');
     }
     if (false === GWF_PublicKey::updateKey($user->getID(), $file_content)) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     if (false === $user->saveOption(GWF_User::EMAIL_GPG, true)) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     return $this->module->message('msg_setup_gpg');
 }
Beispiel #7
0
 public function execute()
 {
     if (Common::getGet('recalc') === 'all') {
         return $this->onRecalcEverything();
     }
     if (false !== Common::getGet('fix_challs')) {
         return $this->onFixChalls();
     }
     if (false !== Common::getGet('fix_irc')) {
         return $this->onFixIRC();
     }
     if (false !== Common::getGet('chall_cache')) {
         return $this->onCacheChallTags();
     }
     if (false !== Common::getGet('sitetags')) {
         return $this->onCacheSiteTags();
     }
     if (false !== Common::getGet('remote_update')) {
         return $this->templateRemoteUpdate();
     }
     if (false !== Common::getPost('remote_update')) {
         return $this->onRemoteUpdate();
     }
     if (false !== Common::getPost('hardlink')) {
         return $this->onHardlink() . $this->templateAdmin();
     }
     return $this->templateAdmin();
 }
Beispiel #8
0
 public function onSearch()
 {
     $form = $this->getForm();
     //		if (false !== ($error = $form->validate($this->module))) {
     //			return $error.$this->templateSearch();
     //		}
     $users = GDO::table('GWF_User');
     $term = Common::getRequest('term');
     if (false !== ($error = $this->validate_term($this->module, $term))) {
         return $error;
     }
     $fields = array('user_name', 'user_email');
     $by = Common::getGet('by', self::DEFAULT_BY);
     $dir = Common::getGet('dir', self::DEFAULT_DIR);
     $orderby = $users->getMultiOrderby($by, $dir);
     if (false === ($conditions = GWF_QuickSearch::getQuickSearchConditions($users, $fields, $term))) {
         $conditions = '0';
     }
     $hits = $users->countRows($conditions);
     $ipp = $this->module->cfgUsersPerPage();
     $nPages = GWF_PageMenu::getPagecount($ipp, $hits);
     $page = Common::clamp((int) Common::getGet('page', 1), 1, $nPages);
     $from = GWF_PageMenu::getFrom($page, $ipp);
     $tVars = array('searched' => true, 'form' => $form->templateX($this->module->lang('ft_search')), 'hits' => $hits, 'users' => $users->selectObjects('*', $conditions, $orderby, $ipp, $from), 'term' => $term, 'pagemenu' => GWF_PageMenu::display($page, $nPages, GWF_WEB_ROOT . 'index.php?mo=Admin&me=UserSearch&term=' . urlencode($term) . '&by=' . urlencode($by) . '&dir=' . urlencode($dir) . '&page=1'), 'sort_url' => GWF_WEB_ROOT . 'index.php?mo=Admin&me=UserSearch&term=' . urlencode($term) . '&by=%BY%&dir=%DIR%&page=1');
     return $this->module->templatePHP('user_search.php', $tVars);
 }
Beispiel #9
0
 public function execute()
 {
     require_once GWF_CORE_PATH . 'module/WeChall/WC_SiteAdmin.php';
     if (false === ($site = WC_Site::getByID(Common::getGet('siteid')))) {
         return $this->module->error('err_site');
     }
     $this->site = $site;
     if (false === ($is_admin = GWF_User::isInGroupS(GWF_Group::STAFF))) {
         if (false === $site->isSiteAdmin(GWF_Session::getUser())) {
             return GWF_HTML::err('ERR_NO_PERMISSION');
         }
     }
     if (false !== Common::getPost('add_sitemin')) {
         return $this->onAddSitemin($site, $is_admin) . $this->templateEdit($site, $is_admin);
     }
     if (false !== Common::getPost('rem_sitemin')) {
         return $this->onRemSitemin($site, $is_admin) . $this->templateEdit($site, $is_admin);
     }
     if (false !== Common::getPost('rem_logo')) {
         return $this->onRemLogo($site, $is_admin) . $this->templateEdit($site, $is_admin);
     }
     if (false !== Common::getPost('set_logo')) {
         return $this->onSetLogo($site, $is_admin) . $this->templateEdit($site, $is_admin);
     }
     if (false !== Common::getPost('edit')) {
         return $this->onEdit($site, $is_admin) . $this->templateEdit($site, $is_admin);
     }
     return $this->templateEdit($site, $is_admin);
 }
Beispiel #10
0
 private function onApprove($lid, $approve)
 {
     if (false === ($link = GWF_Links::getByID($lid))) {
         return $this->module->error('err_link');
     }
     if (!$link->isInModeration()) {
         return $this->module->error('err_approved');
     }
     if ($link->getToken() !== Common::getGet('token')) {
         return $this->module->error('err_token');
     }
     if ($approve) {
         if (false !== ($error = $link->insertTags($this->module))) {
             return $error;
         }
         if (false === $link->saveOption(GWF_Links::IN_MODERATION, false)) {
             return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
         }
         if (false === $link->setVotesEnabled(true)) {
             return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
         }
     } else {
         if (false !== ($error = $link->deleteLink($this->module))) {
             return $error;
         }
     }
     return $this->module->message($approve ? 'msg_approved' : 'msg_deleted');
 }
Beispiel #11
0
 private function sanitize()
 {
     if (false === ($this->user = GWF_User::getByID(Common::getGet('uid')))) {
         return GWF_HTML::err('ERR_UNKNOWN_USER');
     }
     return false;
 }
Beispiel #12
0
 public static function getGDOHeaders2(GWF_Module $module, GWF_Sortable $gdo, $user, $sortURL)
 {
     # Possible fields...
     $fields = $gdo->getSortableFields($user);
     # Gather the current selected sorting
     $curBy = explode(',', Common::getGet('by', ''));
     $curDir = explode(',', Common::getGet('dir', ''));
     $cur = array();
     foreach ($curBy as $i => $cby) {
         if (preg_match('/^[a-zA-Z_]+&?[0-9]*$/', $cby) !== 1) {
             continue;
         }
         if (!in_array($cby, $fields, true)) {
             continue;
         }
         //			if (false === ($cby = $gdo->getWhitelistedBy($cby, false))) {
         //				continue;
         //			}
         $cd = isset($curDir[$i]) ? $curDir[$i] : 'ASC';
         $cd = GDO::getWhitelistedDirS($cd, 'ASC');
         $cur[$cby] = $cd;
     }
     $headers = array();
     foreach ($fields as $field) {
         $curV = array_key_exists($field, $cur) ? $cur[$field] : '';
         $headers[] = array($module->lang('th_' . $field), $curV === 'ASC' ? self::getTHeadURL($sortURL, $cur, $field, 'ASC', $field) : self::getTHeadURL($sortURL, $cur, $field, 'ASC'), $curV === 'DESC' ? self::getTHeadURL($sortURL, $cur, $field, 'DESC', $field) : self::getTHeadURL($sortURL, $cur, $field, 'DESC'), $curV === 'ASC', $curV === 'DESC', $curV === '');
     }
     return $headers;
 }
Beispiel #13
0
 public function execute()
 {
     # Permissions
     if (false === ($gb = GWF_Guestbook::getByID(Common::getGet('gbid')))) {
         return $this->module->error('err_gb');
     }
     if (false === $gb->canModerate(GWF_Session::getUser())) {
         return GWF_HTML::err('ERR_NO_PERMISSION');
     }
     # Toggle Moderation Flag
     if (false !== ($state = Common::getGet('set_moderation'))) {
         return $this->onSetModeration($gb, Common::getGet('gbmid', 0), $state > 0);
     }
     # Toggle Public Flag
     if (false !== ($state = Common::getGet('set_public'))) {
         return $this->onSetPublic($gb, Common::getGet('gbmid', 0), $state > 0);
     }
     # Edit Guestbook
     if (false !== Common::getPost('edit')) {
         return $this->onEdit($gb) . $this->templateEditGB($gb);
     }
     # Edit Single Entry
     if (false !== Common::getPost('edit_entry')) {
         return $this->onEditEntry($gb, Common::getGet('gbmid', 0), false);
     }
     if (false !== Common::getPost('del_entry')) {
         return $this->onEditEntry($gb, Common::getGet('gbmid', 0), true);
     }
     if (false !== Common::getGet('edit_entry')) {
         return $this->templateEditEntry($gb, Common::getGet('gbmid', 0));
     }
     return $this->templateEditGB($gb);
 }
Beispiel #14
0
 public function execute()
 {
     GWF_Website::plaintext();
     $input = trim(Common::getGetString('username', ''));
     if (false !== ($onsitename = Common::getGet('onsitename')) && false !== ($sitename = Common::getGet('sitename'))) {
         die($this->rawOnSiteStats($sitename, $onsitename));
     }
     require_once GWF_CORE_PATH . 'module/WeChall/WC_RegAt.php';
     if (Common::getGet('wechall') === 'yes') {
         die($this->wechallChalls($input));
     }
     if ($input === '') {
         $message = sprintf('Try %s?username=name/rank. New: ?username=!sitename username/rank. Or: ?username=!sites usernname', 'wechall.php');
         die($message);
     }
     if (strpos($input, '!sites') === 0) {
         $this->showSites($input);
     } elseif (strpos($input, '!site') === 0) {
         $this->showSiteDetail($input);
     } elseif (strpos($input, '!') === 0) {
         $this->showSite($input);
     } else {
         die($this->showGlobal($input));
     }
 }
Beispiel #15
0
function prog2CheckResult(WC_Challenge $chall)
{
    if (false === ($user = GWF_Session::getUser())) {
        die($chall->lang('err_login'));
    }
    if (false === ($answer = Common::getGet('answer'))) {
        die($chall->lang('err_no_answer'));
    }
    $solution = GWF_Session::getOrDefault('prog2_solution', false);
    $startTime = GWF_Session::getOrDefault('prog2_timeout', false);
    if ($solution === false || $startTime === false) {
        die($chall->lang('err_no_request'));
    }
    $back = "";
    if (trim($answer) !== $solution) {
        $back .= $chall->lang('err_wrong', array(htmlspecialchars($answer, ENT_QUOTES), $solution));
    } else {
        $back .= $chall->lang('msg_correct');
    }
    $timeNeeded = microtime(true) - $startTime;
    if ($timeNeeded > TIMELIMIT) {
        return $back . $chall->lang('err_timeout', array(sprintf('%.02f', $timeNeeded), TIMELIMIT));
    }
    return trim($answer) === $solution ? true : $back;
}
Beispiel #16
0
 public function execute()
 {
     if (false === ($mod_pay = GWF_Module::getModule('Payment'))) {
         return GWF_HTML::err('ERR_MODULE_MISSING', array('Payment'));
     }
     // INIT
     $isAdmin = GWF_User::isAdminS();
     $modules = GWF_Module::loadModulesFS();
     foreach ($modules as $i => $m) {
         if (!$isAdmin) {
             if ($m->getPrice() > 100000) {
                 unset($modules[$i]);
             }
         }
     }
     GWF_Module::sortModules($modules, 'module_name', 'asc');
     $this->modules = $modules;
     // Modules to purchase
     if (false !== Common::getPost('on_order_2_x')) {
         return $this->onOrder();
     }
     // Actions
     if (Common::getPost('purchase')) {
         return $this->onPurchase();
     }
     if (false !== Common::getGet('zipper')) {
         return $this->onZip();
     }
     return $this->templatePurchase();
 }
Beispiel #17
0
 private function templateUserTable()
 {
     //		$href = sprintf('%s/users/by/%s/%s/page-%%PAGE%%', Module_Admin::ADMIN_URL_NAME, $this->by, $this->dir);
     $href = GWF_WEB_ROOT . sprintf('index.php?mo=Admin&me=Users&by=%s&dir=%s&page=%%PAGE%%', urlencode(Common::getGet('by')), urlencode(Common::getGet('dir')));
     //		$href = '';
     $tVars = array('users' => $this->getUsers(), 'pagemenu' => GWF_PageMenu::display($this->page, $this->nPages, $href), 'sort_url' => $this->getTableSortURL(), 'search_form' => $this->getSearchForm()->templateX($this->module->lang('ft_search'), GWF_WEB_ROOT . 'index.php?mo=Admin&me=UserSearch'));
     return $this->module->templatePHP('users.php', $tVars);
 }
Beispiel #18
0
 public function execute()
 {
     if (false !== ($username = Common::getGet('score'))) {
         $this->outputScore($username);
     }
     if (false !== ($username = Common::getGet('link'))) {
         $this->outputLink($username, trim(Common::getGet('email')));
     }
 }
Beispiel #19
0
 private function sanitize()
 {
     if (false === ($this->mod = GWF_Module::loadModuleDB(Common::getGet('module')))) {
         return GWF_HTML::err('ERR_MODULE_MISSING', array(Common::displayGet('module')));
     }
     //		$this->mod->onInclude();
     $this->mod->onLoadLanguage();
     return false;
 }
Beispiel #20
0
 public function execute()
 {
     if (false === ($gb = GWF_Guestbook::getByID(Common::getGet('gb')))) {
         return $this->module->error('err_gb');
     }
     if (false === $gb->canModerate(GWF_Session::getUser())) {
         return GWF_HTML::err('ERR_NO_PERMISSION');
     }
     return $this->templateModerate();
 }
Beispiel #21
0
 private function sanitize()
 {
     if (false === ($this->link = GWF_Links::getByID(Common::getGet('lid')))) {
         return $this->module->error('err_link');
     }
     if (false === $this->link->mayEdit(GWF_Session::getUser())) {
         return $this->module->error('err_edit_perm');
     }
     return false;
 }
Beispiel #22
0
 public function execute()
 {
     if (false !== ($gid = Common::getGet('deny'))) {
         return $this->onRefuse($gid);
     }
     if (false !== ($gid = Common::getGet('gid'))) {
         return $this->onJoin($gid);
     }
     return '';
 }
Beispiel #23
0
 public function execute()
 {
     if (false !== ($vsid = Common::getGet('vsid'))) {
         return $this->statsVoteScore($vsid);
     }
     if (false !== ($vmid = Common::getGet('vmid'))) {
         return $this->statsVoteMulti($vmid);
     }
     return GWF_HTML::err('ERR_GENERAL', array(__FILE__, __LINE__));
 }
Beispiel #24
0
 public function execute()
 {
     if (false !== Common::getGet('search')) {
         return $this->onSearchB();
     }
     if (false !== Common::getPost('search')) {
         return $this->onSearch();
     }
     return $this->templateForm();
 }
Beispiel #25
0
 public function execute()
 {
     if (false !== ($iso = Common::getGet('iso'))) {
         $this->module->setLanguage($iso);
     }
     //		GWF_Session::commit();
     GWF_Website::redirectBack();
     die;
     //		header(sprintf('Location: %s', GWF_Website::getRedirectURL()));
 }
Beispiel #26
0
 public function execute()
 {
     if (false !== ($bid = Common::getGet('up'))) {
         return $this->move(-1, $bid);
     }
     if (false !== ($bid = Common::getGet('down'))) {
         return $this->move(+1, $bid);
     }
     return GWF_HTML::err('ERR_PARAMETER', array(_FILE__, __LINE__, 'move'));
 }
Beispiel #27
0
 private function sanitize()
 {
     $news = GDO::table('GWF_News');
     $this->nItems = $news->countRows();
     $this->ipp = $this->module->getNewsPerAdminPage();
     $this->nPages = GWF_PageMenu::getPagecount($this->ipp, $this->nItems);
     $this->page = Common::clamp(Common::getGet('page', 1), 1, $this->nPages);
     $this->by = $news->getWhitelistedBy(Common::getGet('by', 'news_date'), 'news_date', false);
     $this->dir = GDO::getWhitelistedDirS(Common::getGet('dir', 'DESC'), 'DESC');
     $this->orderby = $news->getMultiOrderby($this->by, $this->dir);
 }
Beispiel #28
0
 public function execute()
 {
     if (false === ($user = GWF_User::getByID(intval(Common::getGet('uid', '0'))))) {
         return GWF_HTML::err('ERR_UNKNOWN_USER');
     }
     $user->loadGroups();
     if (false !== Common::getPost('add_to_group')) {
         return $this->onAddToGroup($user) . $this->showGroups($user);
     }
     return $this->showGroups($user);
 }
Beispiel #29
0
 private function validate()
 {
     if (false !== ($this->user1 = GWF_User::getByName(Common::getPost('wc_stat_user1')))) {
         #nice
     } elseif (false === Common::getGet('user1')) {
         $this->user1 = false;
         $score1 = 0;
     } elseif (false === ($this->user1 = GWF_User::getByName(Common::getGet('user1', 0)))) {
         if (false === ($this->user1 = GWF_Session::getUser())) {
             GWF_HTML::err('ERR_UNKNOWN_USER', NULL, true, true);
         }
     }
     if (false === ($this->user2 = GWF_User::getByName(Common::getGet('user2', 0)))) {
         if (false === ($this->user2 = GWF_User::getByName(Common::getPost('wc_stat_user2', 0)))) {
             $score2 = 0;
         }
     }
     if ($this->user2 !== false) {
         $score2 = $this->user2->getLevel();
     }
     if ($this->user1 !== false) {
         $score1 = $this->user1->getLevel();
     }
     //		if ($score1 <= 0 && $score2 <= 0) {
     //			return $this->module->error('err_graph_empty');
     //		}
     $sel = Common::getRequest('site', false);
     if (is_array($sel) && count($sel) === 0) {
         $sel = false;
     }
     //		var_dump($sel);
     if ($sel === false) {
         $sel = $this->getSelDefault(false);
     } elseif ($sel === 'all') {
         $sel = $this->getSelDefault(true);
     }
     if (!is_array($sel)) {
         $sel = trim($sel);
         if ($sel !== '') {
             $sel = array(intval($sel) => 'yes');
         } else {
             $sel = array();
         }
     } else {
         $sel2 = array();
         foreach ($sel as $sid => $on) {
             $sel2[intval($sid)] = 'on';
         }
         $sel = $sel2;
     }
     $this->sel = $sel;
     //		var_dump($sel);
     return false;
 }
Beispiel #30
0
 private function sanitize()
 {
     if (false === ($this->pm = GWF_PM::getByID(Common::getGet('pmid')))) {
         return $this->module->error('err_pm');
     }
     if (false === $this->pm->canRead(GWF_Session::getUser())) {
         return $this->module->error('err_perm_read');
     }
     //		$this->term = Common::getGet('term', '');
     return false;
 }