Beispiel #1
0
 public function onAddSite()
 {
     $form = $this->getForm();
     if (false !== ($error = $form->validate($this->module))) {
         return $error . $this->templateSiteAdd();
     }
     $site = new WC_Site(array('site_status' => 'wanted', 'site_name' => $form->getVar('site_name'), 'site_classname' => $form->getVar('site_classname'), 'site_country' => 0, 'site_language' => 0, 'site_joindate' => GWF_Time::getDate(GWF_Date::LEN_SECOND), 'site_launchdate' => '', 'site_authkey' => GWF_Random::randomKey(32), 'site_xauthkey' => GWF_Random::randomKey(32), 'site_irc' => '', 'site_url' => '', 'site_url_mail' => '', 'site_url_score' => '', 'site_url_profile' => '', 'site_score' => 0, 'site_basescore' => 0, 'site_avg' => 0, 'site_vote_dif' => 0, 'site_vote_fun' => 0, 'site_challcount' => 0, 'site_usercount' => 0, 'site_visit_in' => 0, 'site_visit_out' => 0, 'site_options' => 0, 'site_boardid' => 0, 'site_threadid' => 0, 'site_tags' => ''));
     if (false === $site->insert()) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     Module_WeChall::includeVotes();
     if (false === $site->onCreateVotes()) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     Module_WeChall::includeForums();
     if (false === $site->onCreateBoard()) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     if (false === $site->onCreateThread($this->module)) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     require_once GWF_CORE_PATH . 'module/WeChall/WC_SiteDescr.php';
     if (false === WC_SiteDescr::insertDescr($site->getID(), 1, 'Please edit me :)')) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     return $this->module->message('msg_site_added');
 }
Beispiel #2
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);
 }
Beispiel #3
0
 public function templateSiteDetail(WC_Site $site)
 {
     $this->module->includeVotes();
     //		$this->module->includeForums();
     //		GWF_Module::loadModuleDB('Forum', true, true);
     //		GWF_ForumBoard::init(true, true);
     //		GWF_Module::loadModuleDB('Votes', true);
     $time = $this->module->cfgLastPlayersTime();
     $tVars = array('site' => $site, 'boxcount' => $site->getBoxCount(), 'descr' => WC_SiteDescr::getDescription($site->getID()), 'site_quickjump' => $this->module->templateSiteQuickjumpDetail(), 'latest_players_time' => GWF_Time::humanDuration($time), 'latest_players' => $this->getLatestPlayers($time, $site->getID()), 'jquery' => Common::getGet('ajax') !== false, 'can_vote' => $site->canVote(GWF_User::getStaticOrGuest()));
     $ajax = isset($_GET['ajax']) ? '_ajax' : '';
     return $this->module->templatePHP('site_detail' . $ajax . '.php', $tVars);
 }
Beispiel #4
0
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 '';
}
Beispiel #5
0
 private static function installSiteWeChall(Module_WeChall $module)
 {
     if (false !== ($site = WC_Site::getWeChall())) {
         return '';
     }
     $options = WC_Site::AUTO_UPDATE;
     $site = new WC_Site(array('site_id' => 1, 'site_status' => WC_Site::UP, 'site_name' => 'WeChall', 'site_classname' => 'WC', 'site_logo_v' => 0, 'site_country' => 0, 'site_language' => GWF_Language::getEnglish()->getID(), 'site_joindate' => '20080218000000', 'site_launchdate' => '20080218', 'site_authkey' => 'iusdgsdgsiog3!s', 'site_xauthkey' => 'rw98t693g!9sg', 'site_irc' => 'irc://irc.idlemonkeys.net#wechall', 'site_url' => 'http://' . GWF_DOMAIN . GWF_WEB_ROOT, 'site_url_mail' => 'index.php?mo=WeChall&me=CrossSite&link=%USERNAME%&email=%EMAIL%&no_session=yes', 'site_url_score' => 'index.php?mo=WeChall&me=CrossSite&score=%USERNAME%&no_session=yes', 'site_url_profile' => 'profile/%USERNAME%', 'site_score' => 0, 'site_basescore' => 10000, 'site_avg' => 0.0, 'site_dif' => 3.0, 'site_fun' => 3.0, 'site_vote_dif' => 0, 'site_vote_fun' => 0, 'site_maxscore' => 0, 'site_challcount' => 0, 'site_usercount' => 0, 'site_linkcount' => 0, 'site_visit_in' => 0, 'site_visit_out' => 0, 'site_options' => $options, 'site_tags' => 'Exploit,Programming,Stegano,Crypto', 'site_boardid' => 0, 'site_threadid' => 0, 'site_tagbits' => 0, 'site_color' => '0000FF'));
     if (false === $site->onCreateSite($module, $back)) {
         return $back;
     }
     require_once GWF_CORE_PATH . 'module/WeChall/WC_SiteDescr.php';
     if (false === WC_SiteDescr::insertDescr($site->getID(), 1, 'Please edit me :)')) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     return '';
 }
Beispiel #6
0
 private function onDefault()
 {
     if (false === ($langid = $this->getPostLangID('default'))) {
         return GWF_HTML::err('ERR_UNKNOWN_LANGUAGE');
     }
     $form = $this->getFormEdit($langid, '');
     if (false !== ($error = $form->validate($this->module))) {
         return $error;
     }
     if ($this->site->getVar('site_descr_lid') == $langid) {
         return '';
     }
     $descr = WC_SiteDescr::getDescriptions($this->site->getID());
     if (!isset($descr[$langid])) {
         return $this->module->error('err_no_descr');
     }
     if (false === $this->site->saveVars(array('site_descr_lid' => $langid))) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     return $this->module->message('msg_def_descr', array(GWF_Language::getByID($langid)->displayName()));
 }
Beispiel #7
0
 private function showSiteDetail($input)
 {
     $classname = trim(Common::substrFrom($input, ' ', ''));
     if (false === ($site = WC_Site::getByClassName($classname))) {
         die('Unknown Site ' . $classname);
     }
     require_once GWF_CORE_PATH . 'module/WeChall/WC_SiteDescr.php';
     $descr = WC_SiteDescr::getDescription($site->getID());
     //		$descr = $site->getVar('site_description');
     //		$message = $descr;
     $message = Common::stripMessage($descr, 148);
     die(sprintf('%s (%s challs): %s - %s', $site->displayName(), $site->getChallcount(), $site->getVar('site_url'), $message));
 }