Example #1
0
 public function templateComments(Module_Comments $mod_c, GWF_News $news, GWF_Comments $comments)
 {
     $ipp = 10;
     $cid = $comments->getID();
     $nItems = $comments->getVar('cmts_count');
     $nPages = GWF_PageMenu::getPagecount($ipp, $nItems);
     $page = Common::clamp(Common::getGetInt('cpage'), 1, $nPages);
     $from = GWF_PageMenu::getFrom($page, $ipp);
     // Method
     $me = $mod_c->getMethod('Reply');
     $me instanceof Comments_Reply;
     $where = "cmt_cid={$cid}";
     $with_perms = !GWF_User::isInGroupS('moderator');
     if ($with_perms) {
         $visible = GWF_Comment::VISIBLE;
         $deleted = GWF_Comment::DELETED;
         $flags = $visible | $deleted;
         $where .= " cmt_options & {$flags} = {$visible}";
     }
     $c = GDO::table('GWF_Comment')->selectObjects('*', 'cmt_cid=' . $comments->getID(), 'cmt_date ASC', $ipp, $from);
     $href = GWF_WEB_ROOT . 'news-comments-' . $news->getID() . '-' . $news->displayTitle() . '-page-' . $page . '.html';
     $hrefp = GWF_WEB_ROOT . 'news-comments-' . $news->getID() . '-' . $news->displayTitle() . '-page-%PAGE%.html';
     $tVars = array('news' => $news, 'newsitem' => Module_News::displayBoxB(array($news)), 'pagemenu' => GWF_PageMenu::display($page, $nPages, $hrefp), 'comments' => $comments->displayComments($c, $href), 'form' => $me->templateReply($href));
     return $this->module->template('comments.tpl', $tVars);
 }
Example #2
0
function Upgrade_Slaytags_1_01(Module_Slaytags $module)
{
    GWF_Website::addDefaultOutput(GWF_HTML::message('Slaytags', "BPM and Key"));
    $songs = GDO::table('Slay_Song');
    $songs->createColumn('ss_bpm');
    $songs->createColumn('ss_key');
}
Example #3
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);
 }
Example #4
0
 /**
  * Select Users For Global Ranking.
  * @param int $count
  * @param int $from
  * @return array
  */
 private function selectUsers($count, $from)
 {
     $db = gdo_db();
     $count = (int) $count;
     $from = (int) $from;
     $regat = GDO::table('WC_RegAt')->getTableName();
     $users = GDO::table('GWF_User')->getTableName();
     $query = "SELECT user_id,user_name,user_level,SUM(regat_score) AS lts, COUNT(regat_score) AS nlinks, regat_langid,user_countryid FROM {$regat} AS B JOIN (SELECT user_id,user_name,user_level,user_countryid FROM {$users} WHERE user_options&0x10000000=0 ORDER BY user_level DESC, user_id ASC LIMIT {$from}, {$count}) AS C ON user_id=regat_uid GROUP by user_id,regat_langid ORDER BY user_level DESC, user_id ASC";
     $back = array();
     if (false === ($result = $db->queryRead($query))) {
         return $back;
     }
     $current = false;
     while (false !== ($row = $db->fetchAssoc($result))) {
         if ($current === false) {
             $current = new GWF_User($row);
             $current->setVar('nlinks', 0);
             $back[] = $current;
         } elseif ($current->getVar('user_id') !== $row['user_id']) {
             if (count($back) === $count) {
                 break;
             }
             $current = new GWF_User($row);
             $current->setVar('nlinks', 0);
             $back[] = $current;
         }
         $current->setVar('grank_' . $row['regat_langid'], $row['lts']);
         $current->setVar('nlinks', $current->getVar('nlinks') + $row['nlinks']);
         //			var_dump($current->getGDOData());
     }
     $db->free($result);
     //		var_dump($back);
     return $back;
 }
Example #5
0
 public static function core($drop = false, &$success)
 {
     $db = gdo_db();
     $tables = self::get_core_tables();
     $success = true;
     $ret = '<br/><br/>';
     foreach ($tables as $classname) {
         $ret .= sprintf("Installing %s table ... ", $classname);
         if (false === ($result = GDO::table($classname)->createTable($drop))) {
             #error
             $ret .= '<b class="gwfinstallno">FAILED!<br/>' . PHP_EOL;
             $success = false;
         } else {
             #success
             $ret .= '<b class="gwfinstallyes">OK</b><br/>' . PHP_EOL;
         }
     }
     $ret .= '<br/>';
     /** Try to set a birthdate **/
     if (false === GWF_Settings::getSetting('gwf_site_birthday', false)) {
         $ret .= sprintf("Setting up a birthdate ... %s.", date('Ymd'));
         if (false === GWF_Settings::setSetting('gwf_site_birthday', date('Ymd'))) {
             $ret .= '<b class="gwfinstallno">Cannot set site birthdate.<br/>' . PHP_EOL;
             $success = false;
         }
     }
     return $ret;
 }
Example #6
0
 /** @return array|false */
 private function getNavigation($id)
 {
     if (false === ($navis = GWF_Navigations::getById($id))) {
         return false;
         # TODO
     }
     $nsid = $navis->getID();
     $pb = $navis->isnotPB() ? 'navi_vars' : 'navi_pbvars';
     $cols = 't.*, page_url, page_title, page_lang, page_meta_desc/*, page_views,*/';
     $t = GDO::table('GWF_Navigation');
     # TODO: page_lang, permissions
     $where = "navi_nid={$nsid}";
     $navi = array();
     $navi['category_name'] = $navis->getName();
     $navi['subs'] = array();
     $navi['links'] = false !== ($links = $t->selectAll($cols, $where, 'navi_position', array($pb))) ? $links : array();
     if (false === ($subs = $navis->selectAll('navis_id', 'navis_pid=' . $nsid))) {
         $subs = array();
         # TODO: error
     }
     foreach ($subs as $sub) {
         if (false !== ($sn = $this->getNavigation($sub['navis_id']))) {
             $navi['subs'][] = $sn;
         } else {
             # TODO
         }
     }
     return $navi;
 }
Example #7
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);
 }
Example #8
0
 private function templateSongs()
 {
     //		$user = GWF_Session::getUser();
     //		$uid = $user->getID();
     $table = GDO::table('Slay_Song');
     $joins = NULL;
     $headers = array();
     $headers[] = array($this->module->lang('th_artist'), 'ss_artist');
     $headers[] = array($this->module->lang('th_title'), 'ss_title');
     $headers[] = array($this->module->lang('th_duration'), 'ss_duration');
     $headers[] = array($this->module->lang('th_bpm'), 'ss_bpm');
     $headers[] = array($this->module->lang('th_key'), 'ss_key');
     $headers[] = array($this->module->lang('D'));
     $headers[] = array($this->module->lang('L'));
     $headers[] = array($this->module->lang('T'));
     $headers[] = array($this->module->lang('th_tags'));
     $where = "";
     $nItems = $table->selectVar('COUNT(ss_id)', $where, '', $joins);
     $nPages = GWF_PageMenu::getPagecount(self::IPP, $nItems);
     $page = Common::clamp(Common::getGetInt('page'), 1, $nPages);
     $by = Common::getGetString('by', self::BY);
     $dir = Common::getGetString('dir', self::DIR);
     $orderby = $table->getMultiOrderby($by, $dir, false);
     $songs = $table->selectAll('*', $where, $orderby, $joins, self::IPP, GWF_PageMenu::getFrom($page, self::IPP), GDO::ARRAY_O);
     $tVars = array('is_dj' => GWF_User::isInGroupS('dj'), 'sort_url' => GWF_WEB_ROOT . 'index.php?mo=Slaytags&me=Songs&by=%BY%&dir=%DIR%&page=1', 'pagemenu' => GWF_PageMenu::display($page, $nPages, GWF_WEB_ROOT . sprintf('index.php?mo=Slaytags&me=Songs&by=%s&dir=%s&page=%%PAGE%%', urlencode($by), urlencode($dir))), 'songs' => $songs, 'headers' => $headers);
     return $this->module->template('songs.tpl', $tVars);
 }
Example #9
0
 private function onCleanupUntagged()
 {
     $songs = GDO::table('Slay_Song');
     $cut = GWF_Time::getDate(14, time() - 3600);
     $songs->deleteWhere("ss_taggers=0 AND ss_last_played<'{$cut}'");
     return $this->module->message('msg_cleanup');
 }
Example #10
0
 public function templateChalls($for_userid = false, $from_userid = false, $tag = '', $by = '', $dir = '', $show_cloud = true, $show_empty = true)
 {
     require_once GWF_CORE_PATH . 'module/WeChall/WC_ChallSolved.php';
     $challs = GDO::table('WC_Challenge');
     $for_userid = (int) $for_userid;
     $from_userid = (int) $from_userid;
     $solved_bits = $for_userid > 0 ? WC_ChallSolved::getSolvedForUser($for_userid, true) : array();
     if (count($solved_bits) === 0 && !$show_empty && $from_userid === 0) {
         return '';
     }
     $solve_filter = Common::getGetString('filter', '');
     if ($solve_filter === 'solved' or $solve_filter == 'open') {
         $filter_prefix = $solve_filter . '_';
     } else {
         $filter_prefix = '';
     }
     $from_query = $from_userid === 0 ? '1' : "chall_creator LIKE '%,{$from_userid},%'";
     $conditions = "({$from_query})";
     if (0 === ($count = $challs->countRows($conditions))) {
         return '';
     }
     $orderby = $challs->getMultiOrderby($by, $dir);
     $tag_2 = $tag == '' ? '' : $tag . '/';
     $this->setPageDescr($for_userid, $from_userid, $tag, $count);
     $sort_url = 'challs/' . $tag_2 . 'by/' . $by . '/' . $dir . '/page-1';
     $tVars = array('filter_prefix' => $filter_prefix, 'sort_url' => GWF_WEB_ROOT . $filter_prefix . 'challs/' . $tag_2 . 'by/%BY%/%DIR%/page-1', 'challs' => $challs->selectObjects('*', $conditions, $orderby), 'tags' => $show_cloud ? $this->getTags() : '', 'solved_bits' => $solved_bits, 'table_title' => $this->getTableTitle($for_userid, $from_userid, $tag, $count), 'tag' => $tag, 'by' => $by, 'dir' => $dir, 'href_all' => GWF_WEB_ROOT . $sort_url, 'href_solved' => GWF_WEB_ROOT . 'solved_' . $sort_url, 'href_unsolved' => GWF_WEB_ROOT . 'open_' . $sort_url, 'sel_all' => $solve_filter === '', 'sel_solved' => $solve_filter === 'solved', 'sel_unsolved' => $solve_filter === 'open');
     return $this->module->templatePHP('challs.php', $tVars);
 }
Example #11
0
 private function templateSites()
 {
     require_once GWF_CORE_PATH . 'module/WeChall/WC_SiteAdmin.php';
     require_once GWF_CORE_PATH . 'module/WeChall/WC_SiteCats.php';
     require_once GWF_CORE_PATH . 'module/WeChall/WC_SiteDescr.php';
     $tag = Common::getGet('tag', '');
     if (0 === ($tag_bit = WC_SiteCats::getBitForCat($tag))) {
         $tag = '';
     }
     $this->setPageDescription($tag);
     $status_query = $this->getStatusQuery();
     $lang_query = $this->getLangQuery();
     $tag_query = $this->getTagQuery($tag_bit);
     $ipp = $this->module->cfgItemsPerPage();
     $by = Common::getGet('by', 'site_id');
     $dir = Common::getGet('dir', 'DESC');
     $page = intval(Common::getGet('page', 1));
     $table = GDO::table('WC_Site');
     $orderby = $table->getMultiOrderby($by, $dir);
     $conditions = "({$status_query}) AND ({$lang_query}) AND ({$tag_query})";
     $nItems = $table->countRows($conditions);
     $nPages = GWF_PageMenu::getPagecount($ipp, $nItems);
     $page = Common::clamp($page, 1, $nPages);
     $href = $this->getPageMenuHREF();
     $tVars = array('sites' => $table->selectObjects('*', $conditions, $orderby, $ipp, GWF_PageMenu::getFrom($page, $ipp)), 'descrs' => WC_SiteDescr::getAllDescr(), 'site_quickjump' => $this->module->templateSiteQuickjumpDetail(), 'pagemenu' => GWF_PageMenu::display($page, $nPages, $href), 'sortURL' => $this->getTableSortURL(), 'which' => intval(Common::getGet('which')), 'tag' => $tag, 'page_title' => $this->pageTitle);
     return $this->module->templatePHP('sites.php', $tVars);
 }
Example #12
0
 public static function getDescription($siteid)
 {
     $siteid = (int) $siteid;
     $browser_lid = GWF_Language::getCurrentID();
     if (false === ($result = GDO::table('WC_Site')->selectAll('site_desc_lid, site_desc_txt', "site_desc_sid={$siteid} AND (site_desc_lid= {$browser_lid} OR site_desc_lid=site_descr_lid)", '', array('description'), 2, 0, GDO::ARRAY_N))) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     //		$sites = GWF_TABLE_PREFIX.'wc_site';
     //		$descr = GWF_TABLE_PREFIX.'wc_site_descr';
     //		$db = gdo_db();
     //
     //		$query = "SELECT site_desc_lid, site_desc_txt FROM $sites JOIN $descr ON site_desc_sid=site_id WHERE site_desc_sid=$siteid AND (site_desc_lid=$browser_lid OR site_desc_lid=site_descr_lid)";
     //
     //		if (false === ($result = $db->queryAll($query, false))) {
     //			return '';
     //		}
     //
     if (count($result) === 2) {
         if ($result[0][0] === $browser_lid) {
             return $result[0][1];
         } else {
             return $result[1][1];
         }
     } else {
         return $result[0][1];
     }
 }
Example #13
0
 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;
 }
Example #14
0
 private static function createForums(Module_WeChall $module, $dropTable)
 {
     $back = '';
     //		if (false === ($module_forum = GWF_Module::getModule('Forum'))) {
     //			return GWF_HTML::err('ERR_MODULE_MISSING', 'Forum');
     //		}
     //		$module_forum->onInclude();
     $boards = GDO::table('GWF_ForumBoard');
     $t = $boards->escape(Module_WeChall::BOARD_CHALLS);
     if (false === ($board = $boards->getBy('board_title', $t))) {
         if (false === ($board = GWF_ForumBoard::createBoard(Module_WeChall::BOARD_CHALLS, Module_WeChall::BOARD_CHALLS_DESCR, 1, GWF_ForumBoard::GUEST_VIEW | GWF_ForumBoard::ALLOW_THREADS, 0))) {
             $back .= GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
         }
     }
     $boardid = $board === false ? 0 : $board->getID();
     $module->saveModuleVar('wc_chall_board', $boardid);
     $t = $boards->escape(Module_WeChall::BOARD_SOLUTIONS);
     if (false === ($board = $boards->getBy('board_title', $t))) {
         if (false === ($board = GWF_ForumBoard::createBoard(Module_WeChall::BOARD_SOLUTIONS, Module_WeChall::BOARD_SOLUTIONS_DESCR, 1, GWF_ForumBoard::GUEST_VIEW | GWF_ForumBoard::ALLOW_THREADS, 0))) {
             $back .= GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
         }
     }
     $boardid = $board === false ? 0 : $board->getID();
     $module->saveModuleVar('wc_sol_board', $boardid);
     $t = $boards->escape(Module_WeChall::BOARD_SITES);
     if (false === ($board = $boards->getBy('board_title', $t))) {
         if (false === ($board = GWF_ForumBoard::createBoard(Module_WeChall::BOARD_SITES, Module_WeChall::BOARD_SITES_DESCR, 1, GWF_ForumBoard::GUEST_VIEW | GWF_ForumBoard::ALLOW_THREADS, 0))) {
             $back .= GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
         }
     }
     $boardid = $board === false ? 0 : $board->getID();
     $module->saveModuleVar('wc_site_board', $boardid);
     return $back;
 }
Example #15
0
 private function getWarboxes($all = false)
 {
     $table = GDO::table('WC_Warbox');
     $joins = array('sites');
     $orderby = 'site_name ASC, wb_name ASC';
     if (!$all) {
         $where = 'site_status IN ("up","down")';
     } else {
         $where = '';
     }
     return $table->selectAll('*', $where, $orderby, $joins, -1, -1, GDO::ARRAY_O);
     // 		$table = GDO::table('WC_Site');
     // 		$back = array();
     // 		$where = 'site_options&'.WC_Site::IS_WARBOX;
     // 		$where .= $all ? '' : ' AND site_status IN ("up","down")';
     // 		if (false === ($result = $table->selectColumn('site_id', $where)))
     // 		{
     // 			return $back;
     // 		}
     // 		foreach ($result as $siteid)
     // 		{
     // 			if (false !== ($site = WC_Site::getByID_Class($siteid)))
     // 			{
     // 				$back[] = $site;
     // 			}
     // 		}
     // 		return $back;
 }
Example #16
0
 public function onDeleteFolder($folderid)
 {
     # Permission
     $folderid = (int) $folderid;
     $user = GWF_Session::getUser();
     if (false === ($folder = GWF_PMFolder::getByID($folderid)) || $folder->getVar('pmf_uid') !== $user->getID()) {
         return $this->module->error('err_folder_perm');
     }
     # Delete PMs$result
     $count = 0;
     $pms = GDO::table('GWF_PM');
     $uid = $user->getVar('user_id');
     $fid = "{$folderid}";
     $del = GWF_PM::OWNER_DELETED;
     if (false === ($result = $pms->update("pm_options=pm_options|{$del}", "pm_owner={$uid} AND pm_folder={$fid}"))) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     $count += $pms->affectedRows($result);
     //		$del = GWF_PM::FROM_DELETED;
     //		if (false === $pms->update("pm_options=pm_options|$del", "pm_from=$uid AND pm_from_folder=$fid")) {
     //			return GWF_HTML::err('ERR_DATABASE', array( __FILE__, __LINE__));
     //		}
     //		$count += $pms->affectedRows();
     if ($folderid > 2) {
         # Delete Folder
         if (false === $folder->delete()) {
             return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
         }
     }
     # Done
     return $this->module->message('msg_folder_deleted', array($folder->display('pmf_name'), $count));
 }
Example #17
0
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);
    }
}
Example #18
0
 public function templateLinks()
 {
     if (false === ($links = GDO::table('GWF_PageLinks')->selectAll())) {
         $links = array();
     }
     $tVars = array('links' => $links, 'form' => $this->formLinks());
     return $this->module->template($this->_tpl, $tVars);
 }
Example #19
0
 private function sanitize()
 {
     $table = GDO::table('GWF_ForumBoard');
     if (false === ($this->board = $table->getRow($this->module->getBoardID()))) {
         return $this->module->error('err_parent');
     }
     return false;
 }
Example #20
0
 public static function getPeak(Dog_Channel $channel)
 {
     $cid = $channel->getID();
     if (false !== ($peak = GDO::table(__CLASS__)->getRow($cid))) {
         return $peak;
     }
     return self::createPeak($cid);
 }
Example #21
0
 private function templateTree()
 {
     $table = GDO::table('GWF_Category');
     $group = 'news';
     $egroup = $table->escape($group);
     $tVars = array('group' => $group, 'cats' => $table->selectAll('cat_tree_id id, cat_tree_key `key`, cat_tree_pid pid, cat_tree_left `left`, cat_tree_right `right`', "cat_group='{$egroup}'", 'cat_tree_pid asc', NULL, -1, -1, GDO::ARRAY_A));
     return $this->module->templatePHP('tree.php', $tVars);
 }
Example #22
0
 private function onAdvSearch(GWF_Form $form)
 {
     $table = GDO::table('GWF_Links');
     if (false === ($matches = $table->searchAdv(GWF_Session::getUser(), $form->getVars()))) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)) . $this->templateSearch(array(), '');
     }
     return $this->templateSearch($matches, '');
 }
Example #23
0
 private function getData()
 {
     $table = GDO::table('WC_Warflags');
     $by = Common::getGetString('by', 'wf_order');
     $dir = Common::getGetString('dir', 'ASC');
     $orderby = $table->getMultiOrderby($by, $dir);
     return WC_Warflag::getForBoxAndUser($this->box, GWF_User::getStaticOrGuest(), $orderby);
 }
Example #24
0
 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}]";
 }
Example #25
0
 private static function dropVotes($module, $dropTable)
 {
     if ($dropTable) {
         if (false === GDO::table('GWF_VoteScore')->deleteWhere("vs_name LIKE 'dl_%'")) {
             return GWF_HTML::err('ERR_WRITE_FILE', array($dir));
         }
     }
     return '';
 }
Example #26
0
 public static function getFailedData(GWF_User $user, $time)
 {
     $ip = GDO::escape(GWF_IP6::getIP(GWF_IP_EXACT));
     $cut = time() - $time;
     if (false === ($result = GDO::table(__CLASS__)->selectFirst('COUNT(*) c, MIN(logfail_time) min', "logfail_ip='{$ip}' AND logfail_time>{$cut}"))) {
         return array(0, 0);
     }
     return array((int) $result['c'], (int) $result['min']);
 }
Example #27
0
 private static function installAdminAsPMBot(Module_PM $module)
 {
     if (false === ($admin = GDO::table('GWF_UserGroup')->selectFirst('ug_userid', 'group_name="admin"', 'ug_userid ASC', array('group')))) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     if (false === GWF_ModuleLoader::saveModuleVar($module, 'pm_bot_uid', $admin['ug_userid'])) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     return '';
 }
Example #28
0
function Upgrade_Register_1_01(Module_Register $module)
{
    echo GWF_HTML::message('GWF', 'Triggering Upgrade_Register_1_01');
    echo GWF_HTML::message('GWF', 'The email field in user activation database is now UTF8.');
    echo GWF_HTML::message('GWF', 'I simply re-created the table!');
    if (false === GDO::table('GWF_UserActivation')->createTable(true)) {
        return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
    }
    return '';
}
Example #29
0
 private static function installCoreClasses(Module_Admin $module)
 {
     require_once GWF_CORE_PATH . 'inc/install/GWF_InstallFunctions.php';
     foreach (GWF_InstallFunctions::get_core_tables() as $classname) {
         if (false === GDO::table($classname)->createTable(false)) {
             return GWF_HTML::err('ERR_DATABASE', __FILE__, __LINE__);
         }
     }
     return '';
 }
Example #30
0
 private static function deletePlayer(SR_Player $player)
 {
     $epname = GDO::escape($player->getName());
     if (false === GDO::table('SR_BazarShop')->deleteWhere("sr4bs_pname='{$epname}'")) {
         return false;
     }
     if (false === GDO::table('SR_BazarItem')->deleteWhere("sr4ba_pname='{$epname}'")) {
         return false;
     }
 }