예제 #1
0
파일: Freeze.php 프로젝트: sinfocol/gwf3
 public function validate_siteid(Module_WeChall $m, $arg)
 {
     if (false === ($this->site = WC_Site::getByID($arg))) {
         return $m->lang('err_site');
     }
     return false;
 }
예제 #2
0
function Upgrade_WeChall_5_03(Module_WeChall $module)
{
    GWF_Website::addDefaultOutput(GWF_HTML::message('WC5', "Sites can have multiple warboxes now. (thx awe)"));
    $module->includeClass('WC_Site');
    $sites = GDO::table('WC_Site');
    $columns = array('site_warport', 'site_warhost', 'site_war_rs', 'site_war_ip');
    $back = '';
    foreach ($columns as $column) {
        if (!$sites->dropColumn($column)) {
            $back .= GWF_HTML::lang('ERR_DATABASE', array(__FILE__, __LINE__));
        }
    }
    return $back;
}
예제 #3
0
파일: SiteAdd.php 프로젝트: sinfocol/gwf3
 public function validate_site_classname(Module_WeChall $m, $arg)
 {
     if (false !== WC_Site::getByClassName($arg)) {
         return $m->lang('err_classname_dup');
     }
     $max = $m->cfgMaxSitenameLen();
     if (1 !== preg_match('/^[a-z][a-z0-9_]+$/iD', $arg)) {
         return $m->lang('err_site_classname', array(1, $max));
     }
     $len = GWF_String::strlen($arg);
     if ($len < 1 || $len > $max) {
         return $m->lang('err_site_classname', array(1, $max));
     }
     return false;
 }
예제 #4
0
function formSolutionboxValidate(WC_Challenge $chall)
{
    $form = formSolutionboxForm($chall);
    if (false !== ($error = $form->validate(Module_WeChall::instance()))) {
        return $error;
    }
    return false;
}
예제 #5
0
function Upgrade_WeChall_5_04(Module_WeChall $module)
{
    GWF_Website::addDefaultOutput(GWF_HTML::message('WC5', "Warboxes can have flags now. (thx Steven)"));
    $back = '';
    # Kill Old Warbox mode bit
    $killbit = WC_Site::NO_V1_SCRIPTS;
    $module->includeClass('WC_Site');
    $sites = GDO::table('WC_Site');
    if (!$sites->update("site_options=site_options&{$killbit}")) {
        $back .= GWF_HTML::lang('ERR_DATABASE', array(__FILE__, __LINE__));
    }
    $module->includeClass('WC_Warbox');
    $boxes = GDO::table('WC_Warbox');
    if (!$boxes->createColumn('wb_options')) {
        $back .= GWF_HTML::lang('ERR_DATABASE', array(__FILE__, __LINE__));
    }
    return $back;
}
예제 #6
0
파일: Warbox.php 프로젝트: sinfocol/gwf3
 private function templateToken()
 {
     $user = GWF_Session::getUser();
     $token = WC_WarToken::genWarToken($user->getID());
     $host = Module_WeChall::instance()->cfgWarboxURL();
     $ip = gethostbyname(Common::getHostname($host));
     $port = Module_WeChall::instance()->cfgWarboxPort();
     $tVars = array('epoch' => $this->getEpochUser(), 'warboxes' => $this->getWarboxes(true), 'token' => $token, 'port' => $port, 'host' => $host, 'netcat_cmd' => sprintf('(echo -e "%s\\n%s"; cat) | nc %s %s', $user->displayUsername(), $token, $ip, $port));
     return $this->module->templatePHP('wartoken.php', $tVars);
 }
예제 #7
0
function Upgrade_WeChall_5_02(Module_WeChall $module)
{
    GWF_Website::addDefaultOutput(GWF_HTML::message('WC5', "Sites have hostname, port, reducescore and IP now. (thx epoch)"));
    $module->includeClass('WC_Site');
    $sites = GDO::table('WC_Site');
    if (!$sites->createColumn('site_warhost')) {
        return GWF_HTML::lang('ERR_DATABASE', array(__FILE__, __LINE__));
    }
    if (!$sites->createColumn('site_warport')) {
        return GWF_HTML::lang('ERR_DATABASE', array(__FILE__, __LINE__));
    }
    if (!$sites->createColumn('site_war_rs')) {
        return GWF_HTML::lang('ERR_DATABASE', array(__FILE__, __LINE__));
    }
    if (!$sites->createColumn('site_war_ip')) {
        return GWF_HTML::lang('ERR_DATABASE', array(__FILE__, __LINE__));
    }
    return '';
}
예제 #8
0
 public function templateVotes(WC_Challenge $chall)
 {
     $user = GWF_User::getStaticOrGuest();
     $userid = $user->getID();
     $has_solved = WC_ChallSolved::hasSolved($userid, $chall->getID());
     Module_WeChall::includeForums();
     $form_vote = $this->getFormVote($chall, $has_solved, $userid);
     $tVars = array('chall' => $chall, 'has_solved' => $has_solved, 'form_vote' => $form_vote->templateX($this->module->lang('ft_vote_chall', array($chall->display('chall_title')))));
     return $this->module->templatePHP('chall_votes.php', $tVars);
 }
예제 #9
0
파일: Challs.php 프로젝트: sinfocol/gwf3
 private function getTableTitle($for_userid, $from_userid, $tag, $challcount)
 {
     $module = Module_WeChall::instance();
     $dtag = GWF_HTML::display($tag);
     if ($for_userid != 0) {
         return $module->lang('tt_challs_for', array($dtag, GWF_User::getByIDOrGuest($for_userid)->displayUsername()));
     } else {
         if ($from_userid != 0) {
             return $module->lang('tt_challs_from', array($challcount, $dtag, GWF_User::getByIDOrGuest($from_userid)->displayUsername()));
         } else {
             return $module->lang('tt_challs', array($dtag));
         }
     }
 }
예제 #10
0
파일: crackcha.php 프로젝트: sinfocol/gwf3
function crackcha_answer(WC_Challenge $chall)
{
    if ('' === ($answer = Common::getGetString('answer', ''))) {
        echo $chall->lang('err_no_answer');
        return;
    }
    if (false === ($solution = GWF_Session::getOrDefault('WCC_CRACKCHA_CHARS', false))) {
        echo $chall->lang('err_no_problem');
        return;
    }
    if ($answer === $solution) {
        crackcha_increase_solved();
        echo $chall->lang('msg_success', array(GWF_Session::getOrDefault('WCC_CRACKCHA_SOLVED', 0), WCC_CRACKCHA_NEED));
        if (crackcha_solved()) {
            GWF_Module::loadModuleDB('Forum', true, true);
            Module_WeChall::includeForums();
            $chall->onChallengeSolved(GWF_Session::getUserID());
        }
    } else {
        echo $chall->lang('msg_failed', array($answer, $solution));
    }
    GWF_Session::remove('WCC_CRACKCHA_CHARS');
}
예제 #11
0
파일: Warflags.php 프로젝트: sinfocol/gwf3
 public function validate_wf_status(Module_WeChall $m, $arg)
 {
     return in_array($arg, WC_Warflag::$STATUS) ? false : $m->lang('err_wf_status');
 }
예제 #12
0
파일: show_old.php 프로젝트: sinfocol/gwf3
<?php

$is_admin = GWF_User::isAdminS();
$wc = Module_WeChall::instance();
echo $tVars['page_menu'];
if ($tVars['page'] === 1) {
    echo $wc->showBirthdayNews();
    echo $wc->showChallengeNews();
    echo $wc->showSiteMasterNews();
    echo $wc->showAccountLinkNews();
}
?>

<div class="gwf_newsbox">
<?php 
foreach ($tVars['news'] as $newsid => $news) {
    $t = $news->getTranslation();
    $news instanceof GWF_News;
    $newsid = $news->getID();
    ?>
<div class="gwf_newsbox_item">
	<div class="gwf_newsbox_head">
		<span class="gwf_newsbox_title"><?php 
    echo $news->displayTitle();
    ?>
</span>
		<span class="gwf_newsbox_date"><?php 
    echo $news->displayDate();
    ?>
</span>
		<span class="gwf_newsbox_author"><?php 
예제 #13
0
 public function showChallengeNews()
 {
     # Logged in?
     if (false === ($user = GWF_Session::getUser())) {
         return '';
     }
     $userid = $user->getID();
     $sites = GWF_TABLE_PREFIX . 'wc_site';
     $regat = GWF_TABLE_PREFIX . 'wc_regat';
     $query = "SELECT site_name, regat_challcount, site_challcount, site_url FROM {$regat} JOIN {$sites} ON site_id=regat_sid WHERE regat_challcount != site_challcount AND regat_uid={$userid}";
     $db = gdo_db();
     if (false === ($result = $db->queryRead($query))) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     if ($db->numRows($result) === 0) {
         $db->free($result);
         return '';
     }
     $href = '/index.php?mo=WeChall&me=ChallNewsRead';
     $title = $this->lang('cnews_title');
     $text = $this->lang('cnews_body', array($href)) . PHP_EOL . PHP_EOL;
     while (false !== ($row = $db->fetchRow($result))) {
         $mark = intval($row[1]);
         $total = intval($row[2]);
         $anchor = sprintf('[url=%s]%s[/url]', htmlspecialchars($row[3]), htmlspecialchars($row[0]));
         $text .= $this->lang('cnews_item', array($total - $mark, $anchor, $total)) . PHP_EOL;
     }
     $db->free($result);
     if (false === ($thm = Module_WeChall::instance()->cfgWeChallUser())) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     $english = GWF_Language::getEnglish();
     $news = GWF_News::newNews(GWF_Time::getDate(GWF_Date::LEN_SECOND), 0, $thm->getID(), $english->getID(), $title, $text, true);
     return Module_News::displayItem($news);
 }
예제 #14
0
파일: settings.php 프로젝트: sinfocol/gwf3
<?php

echo WC_HTML::accountButtons();
?>

<?php 
$user = GWF_Session::getUser();
if (false !== ($mod_gb = GWF_Module::getModule('Guestbook'))) {
    $mod_gb->onInclude();
    if (false !== ($gb = $mod_gb->getGuestbook($user->getID()))) {
        echo GWF_Button::generic(WC_HTML::lang('btn_manage_gb'), $gb->hrefEdit());
    } elseif ($mod_gb->canCreateGuestbook($user)) {
        echo GWF_Button::generic(WC_HTML::lang('btn_manage_gb'), Module_WeChall::hrefCreateGB());
    }
}
//
//if (false !== ($mod_ug = GWF_Module::getModule('Usergroups'))) {
//	if ($mod_ug->hasGroup($user)) {
//		echo GWF_Button::generic(WC_HTML::lang('btn_manage_ug'), $mod_ug->hrefEdit($user->getID()));
//	}
//	elseif ($mod_ug->canCreateGroup($user)) {
//		echo GWF_Button::generic(WC_HTML::lang('btn_manage_ug'), $mod_ug->hrefCreate());
//	}
//}
?>
<h1><?php 
echo $tLang->lang('ft_settings');
?>
</h1>
<p><?php 
echo $tLang->lang('pi_help');
예제 #15
0
파일: WC_HTML.php 프로젝트: sinfocol/gwf3
 public static function accountButtons()
 {
     return Module_WeChall::instance()->templatePHP('wcaccountbuttons.php');
 }
예제 #16
0
파일: ChallEdit.php 프로젝트: sinfocol/gwf3
 private function onReset(WC_Challenge $chall)
 {
     require_once GWF_CORE_PATH . 'module/WeChall/WC_ChallSolved.php';
     # Remove solved
     $cid = $chall->getID();
     $solved = GDO::table('WC_ChallSolved');
     if (false === $solved->update("csolve_date='', csolve_options=0", "csolve_cid={$cid}")) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     $affected = $solved->affectedRows();
     $back = GWF_HTML::message('WeChall', "Reset {$affected} players that have solved it.");
     # Remove from users from groups
     $gid = $chall->getGID();
     $usergroup = GDO::table('GWF_UserGroup');
     if (false === $usergroup->deleteWhere("ug_groupid={$gid}")) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     $affected = $usergroup->affectedRows();
     $back .= GWF_HTML::message('WeChall', "Removed {$affected} players from the challenge group.");
     # Reset votes
     Module_WeChall::includeVotes();
     if (false === $chall->getVotesDif()->resetVotesSameSettings()) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     if (false === $chall->getVotesEdu()->resetVotesSameSettings()) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     if (false === $chall->getVotesFun()->resetVotesSameSettings()) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     if (false === $chall->onRecalcVotes()) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     # reset solve count and various vars
     if (false === $chall->saveVars(array('chall_solvecount' => 0, 'chall_views' => 0, 'chall_date' => GWF_Time::getDate(GWF_Date::LEN_SECOND)))) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     return $back;
 }
예제 #17
0
파일: index.php 프로젝트: sinfocol/gwf3
<?php

chdir('../../../../');
define('WCC_IP6_SESS', 'WCC_IP6_SESS');
define('GWF_PAGE_TITLE', 'Training: IPv6');
require_once 'challenge/html_head.php';
require_once GWF_CORE_PATH . 'module/WeChall/solutionbox.php';
if (false === ($chall = WC_Challenge::getByTitle(GWF_PAGE_TITLE))) {
    $chall = WC_Challenge::dummyChallenge(GWF_PAGE_TITLE, 1, 'challenge/training/www/ip6/index.php');
}
$chall->showHeader();
$wechall = Module_WeChall::instance();
$level = GWF_Session::getOrDefault(WCC_IP6_SESS, 1);
if (isset($_POST['answer']) && is_string($_POST['answer'])) {
    if (true === wcc_ip6_check_answer($chall, $_POST['answer'], $level)) {
        $_POST['answer'] = '';
        GWF_Session::set(WCC_IP6_SESS, ++$level);
        echo GWF_HTML::message('WCIPv6', $chall->lang('msg_correct', array($level)));
    } else {
        echo $wechall->error('err_wrong');
    }
}
echo GWF_Box::box($chall->lang('info_' . $level), $chall->lang('title', array($level)));
formSolutionbox($chall);
echo $chall->copyrightFooter();
require_once 'challenge/html_foot.php';
function wcc_ip6_check_answer(WC_Challenge $chall, $answer, $level)
{
    require_once 'solutions.php';
    if ($level === count($solutions)) {
        $ip = $_SERVER['REMOTE_ADDR'];
예제 #18
0
파일: Warboxes.php 프로젝트: sinfocol/gwf3
 private function onEdit(WC_Warbox $box)
 {
     $form = $this->formEdit($box);
     if (false !== ($error = $form->validate($this->module))) {
         return $error . $this->templateEdit($box);
     }
     $options = 0;
     $options |= isset($_POST['warbox']) ? WC_Warbox::WARBOX : 0;
     $options |= isset($_POST['multi']) ? WC_Warbox::MULTI_SOLVE : 0;
     if (!$box->saveVars(array('wb_name' => $form->getVar('name'), 'wb_port' => $form->getVar('port'), 'wb_host' => $form->getVar('host'), 'wb_user' => $form->getVar('user'), 'wb_pass' => $form->getVar('pass'), 'wb_status' => $form->getVar('status'), 'wb_weburl' => $form->getVar('url'), 'wb_ip' => gethostbyname($form->getVar('host')), 'wb_whitelist' => $form->getVar('wlist'), 'wb_blacklist' => $form->getVar('blist'), 'wb_launched_at' => $form->getVar('launch'), 'wb_updated_at' => GWF_Time::getDate(14), 'wb_options' => $options))) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)) . $this->templateEdit($box);
     }
     Module_WeChall::instance()->flushWarboxConfig();
     return $this->module->message('msg_warbox_edited') . $this->templateOverview();
 }
예제 #19
0
파일: show_post.php 프로젝트: sinfocol/gwf3
echo GWF_HTML::div($tLang->lang('th_postcount') . ':&nbsp;' . $opts->getPostcount());
?>
		<?php 
echo GWF_HTML::div($tLang->lang('th_thread_thanks') . ':&nbsp;' . $opts->getVar('fopt_thanks'));
?>
		<?php 
echo GWF_HTML::div($tLang->lang('th_thread_votes_up') . ':&nbsp;' . $opts->getVar('fopt_upvotes'));
?>
		<?php 
echo GWF_HTML::div($tLang->lang('th_user_regdate') . ':&nbsp;' . GWF_Time::displayAge($user->getVar('user_regdate')));
?>
		<?php 
echo GWF_HTML::div($user->displayAvatar());
?>
		<?php 
echo Module_WeChall::displayIcons($user);
?>
		
		<?php 
echo GWF_HTML::div($user->isOptionEnabled(GWF_User::HIDE_ONLINE) ? '' : sprintf('<div>%s</div>', $tLang->lang('last_seen', array(GWF_Time::displayAgeTS($user->getVar('user_lastactivity'))))));
?>
		<?php 
echo GWF_HTML::div($user->isOnline() ? $tLang->lang('online') : $tLang->lang('offline'));
$buttons = '';
if ('' !== ($email = $user->getValidMail())) {
    $txt = $tLang->lang('at_mailto', array($user->displayUsername()));
    if ($user->isOptionEnabled(GWF_User::SHOW_EMAIL)) {
        $buttons .= GWF_Button::mail('mailto:' . $email, $txt);
    } elseif ($user->isOptionEnabled(GWF_User::ALLOW_EMAIL)) {
        $buttons .= GWF_Button::mail(GWF_WEB_ROOT . 'send/email/to/' . $user->urlencode('user_name'));
    }
예제 #20
0
파일: index.php 프로젝트: sinfocol/gwf3
{
    public function validate_text($m, $v)
    {
        return false;
    }
}
$validator = new NootherForm();
$form = the_form($chall, $validator);
# Your sourcecode
if (isset($_GET['source'])) {
    $code = file_get_contents('challenge/noother/preg_evasion/index.php');
    echo GWF_Message::display('[code lang=php title=preg_evasion]' . $code . '[/code]');
}
# Your trigger
if (isset($_POST['hackit']) && isset($_POST['text']) && is_string($_POST['text'])) {
    if (false !== ($error = $form->validate(Module_WeChall::instance()))) {
        echo $error;
    } else {
        # Let's examine your POST
        $text = $_POST['text'];
        # Not Evil?
        if (the_preg_match($chall, $text)) {
            #But Evil?
            if (the_strpos($chall, $text)) {
                # Try to get here!
                $chall->onChallengeSolved(GWF_Session::getUserID());
            }
        }
    }
}
# Your mission
예제 #21
0
<?php

$l = $tVars['join'];
echo GWF_Button::wrapStart();
echo GWF_Button::generic($l->lang('btn_join'), GWF_WEB_ROOT . 'join_us');
echo GWF_Button::generic($l->lang('btn_join_war'), GWF_WEB_ROOT . 'index.php?mo=WeChall&me=JoinUs&section=warbox', 'generic', '', true);
echo GWF_Button::generic($l->lang('btn_join_opt'), GWF_WEB_ROOT . 'index.php?mo=WeChall&me=JoinUs&section=optional');
echo GWF_Button::generic($l->lang('btn_api'), GWF_WEB_ROOT . 'index.php?mo=WeChall&me=JoinUs&section=wechall_api');
echo GWF_Button::wrapEnd();
$url = Module_WeChall::instance()->cfgWarboxURL();
$port = Module_WeChall::instance()->cfgWarboxPort();
echo GWF_Box::box($l->lang('war_1b', array($url, $port)), $l->lang('war_1t'));
echo GWF_Box::box($l->lang('war_4b', array($url, $port)), $l->lang('war_4t'));
$box = "";
$box .= $l->lang('war_2b') . "\n<br/>\n";
foreach ($l->lang('war_2b_os') as $os => $code) {
    $box .= $os . "<br/>\n";
    $box .= $code . "\n";
}
$box .= "<br/>\n";
echo GWF_Box::box($box, $l->lang('war_2t'));
echo GWF_Box::box($l->lang('war_3b', array($url, $port)), $l->lang('war_3t'));
echo GWF_Button::wrapStart();
echo GWF_Button::generic($l->lang('btn_join'), GWF_WEB_ROOT . 'join_us');
echo GWF_Button::generic($l->lang('btn_join_war'), GWF_WEB_ROOT . 'index.php?mo=WeChall&me=JoinUs&section=warbox', 'generic', '', true);
echo GWF_Button::generic($l->lang('btn_join_opt'), GWF_WEB_ROOT . 'index.php?mo=WeChall&me=JoinUs&section=optional');
echo GWF_Button::generic($l->lang('btn_api'), GWF_WEB_ROOT . 'index.php?mo=WeChall&me=JoinUs&section=wechall_api');
echo GWF_Button::wrapEnd();
예제 #22
0
<?php

Module_WeChall::includeForums();
$chall = $tVars['chall'];
$chall instanceof WC_Challenge;
$headers = array(array($tLang->lang('th_length'), 'wmc_length'), array($tLang->lang('th_csolve_date'), 'wmc_date'), array($tLang->lang('th_user_name'), 'user_name'), array($tLang->lang('th_solution'), 'wmc_solution'));
$chall->showHeader(true);
echo GWF_Box::box($tVars['table_title']);
echo $tVars['page_menu'];
echo GWF_Table::start();
//echo GWF_Table::displayHeaders1($headers, $tVars['sort_url'], 'wmc_date', 'ASC', 'by', 'dir', $tVars['table_title']);
echo GWF_Table::displayHeaders1($headers, $tVars['sort_url']);
$guest = GWF_Guest::getGuest();
$userr = new GWF_User(false);
foreach ($tVars['data'] as $row) {
    if ($row['user_name'] === NULL) {
        $username = GWF_HTML::lang('guest');
    } else {
        $userr->setGDOData($row);
        $username = $userr->displayProfileLink();
    }
    echo GWF_Table::rowStart();
    echo GWF_Table::column($row['wmc_length'], 'gwf_num');
    echo GWF_Table::column(GWF_Time::displayDate($row['wmc_date']), 'gwf_date');
    echo GWF_Table::column($username);
    echo GWF_Table::column($row['wmc_solution']);
    echo GWF_Table::rowEnd();
}
echo GWF_Table::end();
echo $tVars['page_menu'];
예제 #23
0
파일: wcheader.php 프로젝트: sinfocol/gwf3
<?php

if (WC_HTML::$HEADER === false) {
    return;
}
$module = Module_WeChall::instance();
$logo_url = $module->cfgLogoURL();
$style = '
min-height: 140px;
max-height: 140px;
display: block;
float: left;
';
echo '<header id="wc_head">' . PHP_EOL . '<a href="' . $logo_url . '" style="' . $style . '" title="WeChall"><img src="/favicon.png" style="' . $style . '" alt="HACKITO, ERGO SUM!" /></a>' . PHP_EOL . '<div id="wc_head_stats">' . PHP_EOL . WC_HTML::displayHeaderLogin($module) . PHP_EOL . WC_HTML::displayHeaderOnline($module) . PHP_EOL . '</div>' . PHP_EOL . '</header>' . PHP_EOL . '<div class="cb"></div>' . PHP_EOL;
예제 #24
0
파일: smile.php 프로젝트: sinfocol/gwf3
 public function onAdd(WC_Challenge $chall)
 {
     $module = Module_WeChall::instance();
     $form = $this->getForm($chall);
     if (false !== ($error = $form->validate($module))) {
         return $error;
     }
     $pattern = $form->getVar('pattern');
     $path = $form->getVar('filename');
     // 		if (!preg_match('/^[\x00-\x7f]+$/D', $pattern))
     // 		{
     // 			return GWF_HTML::error('Smile Pattern', array($chall->lang('err_ascii')));
     // 		}
     if (!preg_match('/^[\\x00-\\x7f]+$/D', $path)) {
         return GWF_HTML::error('Smile Path', array($chall->lang('err_ascii')));
     }
     # Show a sample output for the new smiley :)
     if (!LIVIN_Smile::testSmiley($chall, $pattern, $path)) {
         return GWF_HTML::error('Smile', array($chall->lang('err_test')));
     }
     # If it looks valid we even add it globally :)
     if (!LIVIN_Smile::looksHarmless($path)) {
         return GWF_HTML::error('Smile', array($chall->lang('err_xss')));
     }
     if (!LIVIN_Smile::imageExists($path)) {
         return GWF_HTML::error('Smile', array($chall->lang('err_path')));
     }
     # Like this :)
     LIVIN_Smile::onAddSmiley($pattern, $path);
     return GWF_HTML::message('Smile', array($chall->lang('msg_rule_added')));
 }
예제 #25
0
function Upgrade_WeChall_5_06(Module_WeChall $module)
{
    GWF_Website::addDefaultOutput(GWF_HTML::message('WC5', "Database additions for speedy warboxes."));
    gdo_db()->setDieOnError(false);
    GWF_Debug::setDieOnError(false);
    $back = '';
    # Copy warchalls to warflags table
    $module->includeClass('WC_Warchall');
    $module->includeClass('WC_Warchalls');
    $module->includeClass('WC_Warflag');
    $module->includeClass('WC_Warflags');
    $flag = GDO::table('WC_Warflag');
    $flags = GDO::table('WC_Warflags');
    #
    if (!$flag->createColumn('wf_solvers')) {
        $back .= GWF_HTML::lang('ERR_DATABASE', array(__FILE__, __LINE__));
    }
    if (!$flag->createColumn('wf_options')) {
        $back .= GWF_HTML::lang('ERR_DATABASE', array(__FILE__, __LINE__));
    }
    if (!$flag->dropColumn('wf_flag')) {
        $back .= GWF_HTML::lang('ERR_DATABASE', array(__FILE__, __LINE__));
    }
    $flag->update("wf_options=1");
    $now = GWF_Time::getDate();
    $chall = GDO::table('WC_Warchall');
    $challs = GDO::table('WC_Warchalls');
    foreach ($chall->selectAll('*', '', '', NULL, -1, -1, GDO::ARRAY_O) as $c) {
        $c instanceof WC_Warchall;
        $boxid = $c->getVar('wc_boxid');
        $newflag = new WC_Warflag(array('wf_id' => '0', 'wf_wbid' => $boxid, 'wf_order' => '0', 'wf_cat' => 'exploit', 'wf_score' => '1', 'wf_solvers' => '0', 'wf_title' => $c->getVar('wc_level'), 'wf_url' => '', 'wf_authors' => 'Steven', 'wf_status' => 'up', 'wf_login' => '', 'wf_flag_enc' => NULL, 'wf_created_at' => $now, 'wf_last_solved_at' => NULL, 'wf_last_solved_by' => NULL, 'wf_options' => WC_Warflag::WARCHALL));
        $newflag->replace();
        $nfid = $newflag->getID();
        foreach ($challs->selectAll('*', "wc_wcid={$c->getID()}", '', NULL, -1, -1, GDO::ARRAY_O) as $entry) {
            $entry instanceof WC_Warchalls;
            $flags->insertAssoc(array('wf_wfid' => $nfid, 'wf_uid' => $entry->getVar('wc_uid'), 'wf_solved_at' => $entry->getVar('wc_solved_at'), 'wf_attempts' => '1', 'wf_last_attempt' => NULL));
        }
    }
    $flag->update("wf_solvers = (SELECT COUNT(*) FROM wc4_wc_warflags WHERE wf_wfid=wf_id)");
    $flag->update("wf_last_solved_at = (SELECT MAX(wf_solved_at) FROM wc4_wc_warflags WHERE wf_wfid=wf_id)");
    $flag->update("wf_last_solved_by = (SELECT wf_uid FROM wc4_wc_warflags WHERE wf_wfid=wf_id ORDER BY wf_solved_at DESC LIMIT 1)");
    $module->includeClass('WC_Warbox');
    $boxes = GDO::table('WC_Warbox');
    if (!$boxes->createColumn('wb_players')) {
        $back .= GWF_HTML::lang('ERR_DATABASE', array(__FILE__, __LINE__));
    }
    if (!$boxes->createColumn('wb_flags')) {
        $back .= GWF_HTML::lang('ERR_DATABASE', array(__FILE__, __LINE__));
    }
    if (!$boxes->createColumn('wb_challs')) {
        $back .= GWF_HTML::lang('ERR_DATABASE', array(__FILE__, __LINE__));
    }
    if (!$boxes->createColumn('wb_totalscore')) {
        $back .= GWF_HTML::lang('ERR_DATABASE', array(__FILE__, __LINE__));
    }
    foreach ($boxes->selectAll('*', "", "", NULL, -1, -1, GDO::ARRAY_O) as $box) {
        $box instanceof WC_Warbox;
        $box->recalcPlayersAndScore();
    }
    $box->update("wb_challs=(SELECT COUNT(*) FROM wc4_wc_warflag WHERE wf_wbid=wb_id)");
    $box->update("wb_levels=(SELECT COUNT(*) FROM wc4_wc_warflag WHERE wf_wbid=wb_id AND wf_options&2)");
    $box->update("wb_flags=(SELECT COUNT(*) FROM wc4_wc_warflag WHERE wf_wbid=wb_id AND wf_options&1)");
    $chall->dropTable();
    $challs->dropTable();
    return $back;
}
예제 #26
0
 private static function fixWeChallUser(Module_WeChall $module)
 {
     if (false === ($user = GWF_User::getByName('WeChall'))) {
         $user = new GWF_User(array('user_name' => 'WeChall', 'user_email' => '*****@*****.**', 'user_password' => GWF_Password::hashPasswordS('wechallbot'), 'user_regdate' => GWF_Time::getDate(GWF_Date::LEN_SECOND), 'user_regip' => GWF_IP6::getIP(GWF_IP_EXACT, '127.0.0.1'), 'user_lastactivity' => time(), 'user_options' => GWF_User::BOT));
         if (false === $user->insert()) {
             echo GWF_HTML::error('WeChall Install', 'Can not find user WeChall');
             $uid = 0;
         } else {
             $uid = $user->getID();
         }
     } else {
         $uid = $user->getID();
     }
     if (false === $module->saveModuleVar('wc_uid', $uid)) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     return '';
 }
예제 #27
0
파일: SiteEdit.php 프로젝트: sinfocol/gwf3
 public function validate_site_color(Module_WeChall $m, $arg)
 {
     return preg_match('/^[a-z0-9]{6}$/iD', $arg) ? false : $m->lang('err_site_color');
 }
예제 #28
0
파일: Admin.php 프로젝트: sinfocol/gwf3
 public function validate_percent(Module_WeChall $module, $arg)
 {
     if (!Common::isNumeric($arg, true) || $arg < 0 || $arg > 100) {
         return $module->lang('err_percent');
     }
     return false;
 }
예제 #29
0
파일: WC_Site.php 프로젝트: sinfocol/gwf3
 /**
  * Recalc the score for this site.
  * @return boolean
  */
 private function recalcScore()
 {
     if ($this->isLinear()) {
         $wc = Module_WeChall::instance();
         $wc->includeClass('WC_Warbox');
         $wc->includeClass('WC_Warflag');
         $basescore = WC_Warflag::getTotalscoreForSite($this);
         if ($this->isNoV1()) {
             // 				WC_RegAt::calcTotalscores()
         }
     } else {
         $basescore = $this->getBasescore();
         $average = $this->getAverage();
         $challcnt = $this->getChallcount();
         $spc = $this->getVar('site_spc');
         $basescore += $spc * $challcnt;
         $basescore += $basescore - $average * $basescore;
         $basescore = intval(round($basescore));
     }
     if ($basescore !== $this->getVar('site_score')) {
         require_once 'WC_HistorySite.php';
         if (false === WC_HistorySite::insertEntry($this->getID(), $this->getScore(), $this->getUsercount(), $this->getChallcount())) {
             echo GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
             return false;
         }
         return $this->saveVar('site_score', $basescore);
     }
     return true;
 }