예제 #1
0
파일: Admin.php 프로젝트: sinfocol/gwf3
 private function sanitize()
 {
     $this->table = new GWF_UserActivation(false);
     $this->ipp = $this->module->getActivationsPerPage();
     $this->nItems = $this->table->countRows();
     $this->nPages = GWF_PageMenu::getPagecount($this->ipp, $this->nItems);
     $this->page = Common::clamp((int) Common::getGet('page', 1), 1, $this->nPages);
     $this->by = $this->table->getWhitelistedBy(Common::getGetString('by'), 'timestamp');
     $this->dir = GDO::getWhitelistedDirS(Common::getGetString('dir'), 'DESC');
     $this->orderby = "{$this->by} {$this->dir}";
 }
예제 #2
0
파일: Admin.php 프로젝트: sinfocol/gwf3
 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);
 }
예제 #3
0
 public function templateSites()
 {
     $whitelist = array('site_name', 'site_challcount', 'regat_score', 'site_score', 'regat_solved', 'regat_lastdate', 'regat_onsitename');
     $form_link = $this->getFormLink();
     $form_all = $this->getFormAll();
     $by = Common::getGet('by', 'site_name');
     $dir = Common::getGet('dir', 'ASC');
     $by = GDO::getWhitelistedByS($by, $whitelist, 'site_name');
     $dir = GDO::getWhitelistedDirS($dir, 'ASC');
     $orderby = "{$by} {$dir}";
     $tVars = array('form_link' => $form_link === false ? '' : $form_link->templateX($this->module->lang('ft_link_site')), 'action' => GWF_WEB_ROOT . 'linked_sites', 'linked' => $this->getLinkedSites(GWF_Session::getUserID(), $orderby), 'form_update_all' => $form_all->templateX(), 'can_link' => count($this->not_linked) > 0, 'sort_url' => GWF_WEB_ROOT . 'index.php?mo=WeChall&me=LinkedSites&by=%BY%&dir=%DIR%');
     return $this->module->templatePHP('linked_sites.php', $tVars);
 }
예제 #4
0
 public function templateChalls(GWF_User $user)
 {
     $whitelist = array('chall_score', 'chall_title', 'chall_creator_name', 'chall_solvecount', 'chall_date', 'chall_dif', 'chall_edu', 'chall_fun', 'csolve_date', 'csolve_time_taken');
     require_once GWF_CORE_PATH . 'module/WeChall/WC_ChallSolved.php';
     $challs = GDO::table('WC_Challenge');
     $db = gdo_db();
     $uid = $user->getVar('user_id');
     $challs = GWF_TABLE_PREFIX . 'wc_chall';
     $solved = GWF_TABLE_PREFIX . 'wc_chall_solved';
     $by = GDO::getWhitelistedByS(Common::getGet('pcby'), $whitelist, self::DEFAULT_BY);
     $dir = GDO::getWhitelistedDirS(Common::getGet('pcdir'), self::DEFAULT_DIR);
     $orderby = "ORDER BY {$by} {$dir}";
     $query = "SELECT c.*, s.* FROM {$challs} c LEFT JOIN {$solved} s ON c.chall_id=s.csolve_cid AND s.csolve_uid={$uid} {$orderby}";
     $tVars = array('data' => $db->queryAll($query), 'sort_url' => GWF_WEB_ROOT . 'index.php?mo=Profile&me=Profile&username='******'user_name') . '&pcby=%BY%&pcdir=%DIR%#wc_profile_challenges', 'table_title' => $this->module->lang('tt_challs_for', array('', $user->display('user_name'))));
     return $this->module->templatePHP('challs_profile.php', $tVars);
 }
예제 #5
0
파일: Search.php 프로젝트: sinfocol/gwf3
 private function onQuickSearch($term)
 {
     $fields = array('link_href', 'link_descr');
     if ($this->module->cfgLongDescription()) {
         $fields[] = 'link_descr2';
     }
     $links = GDO::table('GWF_Links');
     $by = $links->getWhitelistedBy(Common::getGet('by'), 'link_id');
     $dir = GDO::getWhitelistedDirS(Common::getGet('dir'), 'DESC');
     $conditions = $this->module->getPermQuery(GWF_Session::getUser());
     $limit = 50;
     $from = 0;
     if (false === ($matches = GWF_QuickSearch::search($links, $fields, $term, "{$by} {$dir}", $limit, $from, $conditions))) {
         return $this->templateSearch(array(), '');
     }
     return $this->templateSearch($matches, $term);
 }
예제 #6
0
파일: Staff.php 프로젝트: sinfocol/gwf3
 private function sanitize()
 {
     $links = GDO::table('GWF_Links');
     $this->user = GWF_Session::getUser();
     $this->by = $links->getWhitelistedBy(Common::getGetString('by'), self::DEFAULT_BY);
     $this->dir = GDO::getWhitelistedDirS(Common::getGetString('dir'), self::DEFAULT_DIR);
     $this->orderby = $this->by . ' ' . $this->dir;
     $this->ipp = $this->module->cfgLinksPerPage();
     $this->nItems = $links->countRows();
     $this->nPages = GWF_PageMenu::getPagecount($this->ipp, $this->nItems);
     $this->page = Common::clamp(intval(Common::getGet('page', 1)), 1, $this->nPages);
     $this->from = GWF_PageMenu::getFrom($this->page, $this->ipp);
     $this->sort_url = $this->getMethodHref('&by=%BY%&dir=%DIR%&page=1');
     if (false === ($this->links = $links->selectObjects('*', '', $this->orderby, $this->ipp, $this->from))) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     return false;
 }
예제 #7
0
 private function templateRanking()
 {
     $whitelist = array('countryname', 'totalscore', 'users', 'avg', 'top3', 'topuser', 'spc');
     $by = GDO::getWhitelistedByS(Common::getGet('by', 'avg'), $whitelist, 'avg');
     $dir = GDO::getWhitelistedDirS(Common::getGet('dir', 'DESC'), 'DESC');
     $users = GWF_TABLE_PREFIX . 'user';
     $countries = GWF_TABLE_PREFIX . 'country';
     $hide_ranking = 'user_options&0x10000000=0';
     // 		$deleted = GWF_User::DELETED;
     $desc = "ORDER BY `user_level` DESC";
     $not_deleted = "`user_options`&2=0";
     $country_condition = "{$not_deleted} AND `user_countryid` = `country_id` AND {$hide_ranking}";
     $ranked_condition = "{$country_condition} {$desc}";
     $query = "SELECT " . "`c`.`country_id`, " . "`c`.`country_name` AS `countryname`, " . "COUNT(`u`.`user_id`) AS `users`, " . "SUM(`user_level`) AS `totalscore`, " . "MAX(`u`.`user_level`) AS `topscore`, " . "(SELECT `u`.`user_name` {$desc} LIMIT 1,1) as `topuser`, " . "AVG(`u`.`user_level`) AS `avg`, " . "SUM(`u`.`user_level`) AS `totalscore`, " . "(SELECT SUM(`u`.`user_level`) {$desc} LIMIT 3) as `top3`, " . 'ROUND(SUM(`u`.`user_level`) / `c`.`country_pop` * 1000, 2) AS `spc` ' . "FROM `{$countries}` AS `c` " . "LEFT JOIN `{$users}` AS `u` ON {$country_condition} " . "WHERE `c`.`country_id` > 0 " . "AND `user_level` > 0 " . "GROUP BY  `c`.`country_id` " . "ORDER BY {$by} {$dir}";
     $db = gdo_db();
     if (false === ($result = $db->queryAll($query))) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     $tVars = array('highlight_country' => $this->getHighlightCountry(), 'data' => $result, 'sort_url' => GWF_WEB_ROOT . 'country_ranking/by/%BY%/%DIR%/page-1');
     return $this->module->templatePHP('ranking_countries.php', $tVars);
 }
예제 #8
0
파일: Modules.php 프로젝트: sinfocol/gwf3
 private function templateModules()
 {
     $gdo = GDO::table('GWF_Module');
     $by = $gdo->getWhitelistedBy(Common::getGetString('by'), 'module_name');
     $dir = GDO::getWhitelistedDirS(Common::getGetString('dir', 'ASC'));
     $headers = array(array($this->module->lang('th_priority'), 'module_priority', 'ASC'), array($this->module->lang('th_move')), array($this->module->lang('th_name'), 'module_name', 'ASC'), array($this->module->lang('th_version_db')), array($this->module->lang('th_version_hd')), array($this->module->lang('th_install')), array($this->module->lang('th_basic')), array($this->module->lang('th_adv')));
     $modules = $this->module->getAllModules($by, $dir);
     # Need install?
     $install_all = '';
     foreach ($modules as $name => $d) {
         if (!$d['enabled']) {
             continue;
         }
         if ($d['vdb'] < $d['vfs']) {
             $install_all = $this->module->lang('install_info', array(Module_Admin::getInstallAllURL()));
             break;
         }
     }
     $tVars = array('modules' => $modules, 'install_all' => $install_all, 'tablehead' => GWF_Table::displayHeaders1($headers, Module_Admin::getSortURL('%BY%', '%DIR%'), 'module_name', 'ASC'), 'install' => $this->module->lang('btn_install'), 'configure' => $this->module->lang('btn_config'), 'adminsect' => $this->module->lang('btn_admin_section'));
     return $this->module->template('modules.tpl', $tVars);
 }
예제 #9
0
 private function templateSolutions(WC_Challenge $chall, GWF_User $user, $length, $token)
 {
     $tt = $this->module->lang('pt_wmc_sol', array($chall->display('chall_title'), $length));
     GWF_Website::setPageTitle($tt);
     $ipp = 50;
     $cid = $chall->getID();
     $length = (int) $length;
     $whitelist = array('user_name', 'wmc_date', 'wmc_length', 'wmc_solution');
     $by = GDO::getWhitelistedByS(Common::getGetString('by'), $whitelist, self::DEFAULT_BY);
     $dir = GDO::getWhitelistedDirS(Common::getGetString('dir'), self::DEFAULT_DIR);
     $wmc = GWF_TABLE_PREFIX . 'wc_math_chall';
     $users = GWF_TABLE_PREFIX . 'user';
     $where = "wmc_cid={$cid} AND wmc_length>={$length}";
     $db = gdo_db();
     $result = $db->queryFirst("SELECT COUNT(*) c FROM {$wmc} WHERE {$where}");
     $nRows = (int) $result['c'];
     $nPages = GWF_PageMenu::getPagecount($ipp, $nRows);
     $page = Common::clamp(Common::getGetInt('page', 1), 1, $nPages);
     $from = GWF_PageMenu::getFrom($page, $ipp);
     $limit = GDO::getLimit($ipp, $from);
     $query = "SELECT user_name, wmc_date, wmc_length, wmc_solution FROM {$wmc} LEFT JOIN {$users} ON user_id=wmc_uid WHERE {$where} ORDER BY {$by} {$dir} {$limit}";
     $tVars = array('sort_url' => GWF_WEB_ROOT . "index.php?mo=WeChall&me=MathSolutions&cid={$cid}&length={$length}&token={$token}&by=%BY%&dir=%DIR%", 'data' => $db->queryAll($query), 'page_menu' => GWF_PageMenu::display($page, $nPages, GWF_WEB_ROOT . sprintf('index.php?mo=WeChall&me=MathSolutions&cid=%d&length=%d&token=%s&by=%s&dir=%s&page=%%PAGE%%', $cid, $length, $token, urlencode($by), urlencode($dir))), 'table_title' => $tt, 'chall' => $chall);
     return $this->module->templatePHP('math_solutions.php', $tVars);
 }
예제 #10
0
파일: GWF_Table.php 프로젝트: sinfocol/gwf3
 private static function getHeaders2(array $headers, $sortURL = '', $key_by = 'by', $key_dir = 'dir')
 {
     $sortURL = htmlspecialchars($sortURL);
     $allowed = array();
     foreach ($headers as $header) {
         if (isset($header[1])) {
             $allowed[] = $header[1];
         }
     }
     # Gather the current selected sorting
     $curBy = explode(',', Common::getGet($key_by, ''));
     $curDir = explode(',', Common::getGet($key_dir, ''));
     $cur = array();
     foreach ($curBy as $i => $cby) {
         if (!in_array($cby, $allowed, true)) {
             continue;
         }
         $cd = isset($curDir[$i]) ? $curDir[$i] : 'ASC';
         $cd = GDO::getWhitelistedDirS($cd, 'ASC');
         $cur[$cby] = $cd;
     }
     $back = array();
     foreach ($headers as $header) {
         if (isset($header[1]) && $sortURL !== '') {
             if ($header[1] === false) {
                 continue;
             }
             $curV = array_key_exists($header[1], $cur) ? $cur[$header[1]] : '';
             $back[] = array($header[0], $curV === 'ASC' ? self::getTHeadURL($sortURL, $cur, $header[1], 'ASC', $header[1]) : self::getTHeadURL($sortURL, $cur, $header[1], 'ASC'), $curV === 'DESC' ? self::getTHeadURL($sortURL, $cur, $header[1], 'DESC', $header[1]) : self::getTHeadURL($sortURL, $cur, $header[1], 'DESC'), $curV === 'ASC', $curV === 'DESC', $curV === '');
         } else {
             $back[] = array(isset($header[0]) ? $header[0] : '', false);
         }
     }
     return $back;
 }
예제 #11
0
 private static function getMultiOrderBy(GDO $gdo, $user)
 {
     $fields = $gdo->getSortableFields($user);
     # Gather the current selected sorting
     $curBy = explode(',', Common::getGetString('by', ''));
     $curDir = explode(',', Common::getGetString('dir', ''));
     $back = '';
     foreach ($curBy as $i => $cby) {
         if (in_array($cby, $fields, true)) {
             $cd = isset($curDir[$i]) ? $curDir[$i] : 'ASC';
             $cd = GDO::getWhitelistedDirS($cd, 'ASC');
             $back .= sprintf(',`%s` %s', $cby, $cd);
         }
     }
     return $back === '' ? '1' : substr($back, 1);
 }
예제 #12
0
파일: ranking.php 프로젝트: sinfocol/gwf3
<?php

require 'config.php';
require 'header.php';
?>
<h1>Ranking</h1>
<?php 
$ipp = 50;
$table = GDO::table('DLDC_User');
$nItems = $table->countRows();
$nPages = GWF_PageMenu::getPagecount($ipp, $nItems);
$page = Common::clamp(Common::getGetInt('page', 1), 1, $nPages);
$by = $table->getWhitelistedBy(Common::getGetString('by'), 'level');
$dir = GDO::getWhitelistedDirS(Common::getGetString('dir'), 'DESC');
$from = GWF_PageMenu::getFrom($page, $ipp);
$headers = array(array('Lvl', 'level', 'DESC'), array('Username', 'username', 'ASC'), array('Firstname', 'firstname', 'ASC'), array('Lastname', 'lastname', 'ASC'), array('Regdate', 'regdate', 'DESC'));
$pagemenu = GWF_PageMenu::display($page, $nPages, "?page=%PAGE%&by={$by}&dir={$dir}");
echo $pagemenu;
echo GWF_Table::start('ranking_table');
echo GWF_Table::displayHeaders1($headers, "?page=1&by=%BY%&dir=%DIR%");
$result = $table->select('*', '', "{$by} {$dir}", null, $ipp, $from);
while ($user = $table->fetch($result, GDO::ARRAY_O)) {
    $user instanceof DLDC_User;
    echo GWF_Table::rowStart();
    echo GWF_Table::column($user->getVar('level'), 'gwf_num');
    echo GWF_Table::column($user->display('username'));
    echo GWF_Table::column($user->display('firstname'));
    echo GWF_Table::column($user->display('lastname'));
    echo GWF_Table::column($user->displayRegdate(), 'gwf_date');
    echo GWF_Table::rowEnd();
}
예제 #13
0
파일: SearchAdv.php 프로젝트: sinfocol/gwf3
 private function onSearchB()
 {
     $whitelist = array('user_name', 'user_countryid', 'prof_icq', 'prof_msn', 'prof_jabber', 'prof_skype', 'prof_yahoo', 'prof_aim');
     $ipp = 50;
     $db = gdo_db();
     if ('' === ($where = $this->getWhereQuery())) {
         $where = "'1'='0'";
     }
     $deleted = GWF_User::DELETED;
     $where .= " AND user_options&{$deleted}=0";
     $users = GWF_TABLE_PREFIX . 'user';
     $profiles = GWF_TABLE_PREFIX . 'profile';
     $query = "SELECT COUNT(*) AS c FROM {$users} LEFT JOIN {$profiles} ON prof_uid=user_id WHERE {$where}";
     if (false === ($result = $db->queryFirst($query, false))) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     $nRows = (int) $result['c'];
     $nPages = GWF_PageMenu::getPagecount($ipp, $nRows);
     $page = Common::clamp(Common::getGetInt('page', 1), 1, $nPages);
     $from = GWF_PageMenu::getFrom($page, $ipp);
     $limit = GDO::getLimit($ipp, $from);
     $by = GDO::getWhitelistedByS(Common::getGetString('by'), $whitelist, 'user_name');
     $dir = GDO::getWhitelistedDirS(Common::getGetString('dir'), 'ASC');
     $_GET['search'] = 'yes';
     $query = "SELECT u.*, p.* FROM {$users} u LEFT JOIN {$profiles} p ON prof_uid=user_id WHERE {$where} ORDER BY {$by} {$dir} {$limit}";
     $form = $this->formSearch();
     $tVars = array('result' => $db->queryAll($query, true), 'form' => $form->templateY($this->module->lang('ft_search_adv'), $this->module->getMethodURL('SearchAdv')), 'pagemenu' => GWF_PageMenu::display($page, $nPages, $this->getPageMenuHREF()), 'sort_url' => $this->getSortHREF());
     return $this->module->templatePHP('search_adv.php', $tVars);
 }