public static function fixCatBits() { self::table(__CLASS__)->truncate(); require_once 'WC_RegAt.php'; $sites = WC_Site::getSites(); $tag_c = array(); foreach ($sites as $site) { $site instanceof WC_Site; $tags = $site->getTagArray(); $curr = array(); foreach ($tags as $tag) { $tag = trim($tag); if ($tag === '') { continue; } $curr[] = $tag; if (!isset($tag_c[$tag])) { $tag_c[$tag] = 1; } else { $tag_c[$tag]++; } self::addToCat($site->getID(), $tag); } $site->saveVars(array('site_tagbits' => self::calcTagBits($tags, $tag_c), 'site_tags' => implode(',', $curr))); WC_RegAt::fixTagBits($site, $site->getTagBits()); } self::adjustBits($tag_c); }
private function showAllSites() { if (false === ($sites = WC_Site::getSites('site_name ASC'))) { return GWF_HTML::lang('ERR_DATABASE', array(__FILE__, __LINE__)); } $back = ''; foreach ($sites as $site) { $site instanceof WC_Site; if ($site->getURL() !== '') { $back .= $this->showSite($site); } } return $back; }
private function templateHistory(GWF_User $user) { require_once GWF_CORE_PATH . 'module/WeChall/WC_SiteDescr.php'; require_once GWF_CORE_PATH . 'module/WeChall/WC_HistoryUser2.php'; $uid = $user->getID(); $ipp = 50; $history = GDO::table('WC_HistoryUser2'); $nItems = $history->countRows("userhist_uid={$uid}"); $nPages = GWF_PageMenu::getPagecount($ipp, $nItems); $page = Common::clamp(Common::getGet('page', 1), 1, $nPages); $from = GWF_PageMenu::getFrom($page, $ipp); $by = Common::getGet('by', ''); $dir = Common::getGet('dir', ''); $orderby = $history->getMultiOrderby($by, $dir); $uuname = $user->urlencode2('user_name'); $duname = $user->displayUsername(); GWF_Website::setPageTitle($this->module->lang('pt_texthis', array($duname))); GWF_Website::setMetaDescr($this->module->lang('md_texthis', array($duname))); GWF_Website::setMetaTags($this->module->lang('mt_texthis', array($duname))); $tVars = array('user' => $user, 'duname' => $duname, 'sites' => WC_Site::getSites('site_id'), 'data' => $history->selectObjects('*', "userhist_uid={$uid}", $orderby, $ipp, $from), 'sort_url' => GWF_WEB_ROOT . 'history/for/' . $uuname . '/by/%BY%/%DIR%/page-1', 'page_menu' => GWF_PageMenu::display($page, $nPages, GWF_WEB_ROOT . 'history/for/' . $uuname . '/by/' . urlencode($by) . '/' . urlencode($dir) . '/page-%PAGE%')); return $this->module->templatePHP('text_history.php', $tVars); }
function Upgrade_WeChall_1_04(Module_WeChall $module) { $db = gdo_db(); $sites = GWF_TABLE_PREFIX . 'wc_site'; $query = "ALTER TABLE {$sites} ADD COLUMN site_descr_lid INT(11) UNSIGNED NOT NULL DEFAULT 1"; if (false === $db->queryWrite($query)) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } require_once 'core/module/WeChall/WC_SiteDescr.php'; if (false === GDO::table('WC_SiteDescr')->createTable(true)) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } $patches = array(13 => 5, 43 => 3, 17 => 5); foreach (WC_Site::getSites('site_id ASC') as $site) { $site instanceof WC_Site; $siteid = $site->getID(); $desc = $site->getVar('site_description'); if (isset($patches[$siteid])) { $langid = $patches[$siteid]; } else { $langid = 1; } if (false === WC_SiteDescr::insertDescr($siteid, $langid, $desc)) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } if (false === $site->saveVar('site_descr_lid', $langid)) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } } $query = "ALTER TABLE `{$sites}` DROP `site_description`"; if (false === $db->queryWrite($query)) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } GWF_HTML::message('WC', '[+] Multi Lang Descriptions', true, true); return ''; }
private function getSiteSelect() { $data = array(); foreach (WC_Site::getSites('site_name ASC') as $site) { $data[] = array($site->getID(), $site->getVar('site_name')); } return GWF_Select::display('site', $data, Common::getPostString('site', '0')); }
public function templateSiteQuickjump($mode) { $actions = array('boxdetail' => GWF_WEB_ROOT . 'index.php?mo=WeChall&me=WarboxDetails', 'boxdetails' => GWF_WEB_ROOT . 'index.php?mo=WeChall&me=WarboxesDetails', 'boxranking' => GWF_WEB_ROOT . 'index.php?mo=WeChall&me=WarboxPlayers', 'detail' => GWF_WEB_ROOT . 'index.php?mo=WeChall&me=SiteDetails', 'ranking' => GWF_WEB_ROOT . 'index.php?mo=WeChall&me=SiteRankings', 'history' => GWF_WEB_ROOT . 'index.php?mo=WeChall&me=SiteHistory'); $tVars = array('sites' => WC_Site::getSites(), 'mode' => $mode, 'form_action' => $actions[$mode]); return $this->templatePHP('site_quickjump.php', $tVars); }
public static function fixAllPercents() { $sites = WC_Site::getSites(); foreach ($sites as $site) { if (false === self::fixPercent($site)) { return false; } } return true; }