Beispiel #1
0
 public static function cleanup($message = 'Clean shutdown!')
 {
     GWF_CachedCounter::persist();
     if (NULL !== Dog_Init::getStartupTime()) {
         GWF_Counter::increaseCount('dog_uptime', Dog_Init::getUptime());
     }
     if (self::$CLEANED === false) {
         self::$CLEANED = true;
         foreach (Dog::getServers() as $server) {
             $server instanceof Dog_Server;
             if ($server->isConnected()) {
                 $server->disconnect($message);
             }
         }
     }
     die(0);
 }
Beispiel #2
0
 public function execute()
 {
     if (Common::getGetString('list', '0') === '1') {
         return $this->module->template("tools/list.tpl");
     }
     $whitelist = array('jpk', 'yabfdbg', 'jcs', 'jdictac', 'wordpat', 'wordlists', 'startcpp', 'encodings');
     $file = Common::getGet('file');
     if (!in_array($file, $whitelist, true)) {
         return GWF_HTML::err('ERR_PARAMETER', array(__FILE__, __LINE__, 'file'));
     }
     # Counter Box
     $count = GWF_Counter::getAndCount($file, 1);
     $box = GWF_Box::box($this->module->lang('pi_viewcount', array($count)));
     # Translations
     $langpath = $this->module->getDir() . '/lang/' . $file;
     #.'/'.$file;
     $trans = new GWF_LangTrans($langpath);
     GWF_Website::setPageTitle($trans->lang('page_title'));
     GWF_Website::setMetaTags($trans->lang('meta_tags'));
     $tVars = array('lang2' => $trans);
     return $this->module->templatePHP("tools/{$file}/{$file}.php", $tVars) . $box;
 }
Beispiel #3
0
 private function increasePageView($by = 1)
 {
     //		require_once 'GWF_Pageview.php';
     //		GWF_Pageview::increaseTodayView($by);
     self::$pagecount = GWF_Counter::getAndCount('pagecount', $by);
     //		$this->saveModuleVar('pagecount', $this->cfgPagecount()+$by);
 }
Beispiel #4
0
<?php

$lang = array('en' => array('help' => 'Usage: %CMD%. Print statistics about the bots uptime.', 'out' => 'This bot is running since %s. Total runtime: %s.'));
$plugin = Dog::getPlugin();
if ($plugin->argc() > 0) {
    $plugin->showHelp();
} else {
    $uptime = round(Dog_Init::getUptime());
    $total = GWF_Counter::getCount('dog_uptime') + $uptime;
    $plugin->rply('out', array(GWF_Time::humanDuration($uptime), GWF_Time::humanDuration($total)));
}
Beispiel #5
0
<?php

chdir('../../../');
define('GWF_PAGE_TITLE', 'The Last Hope');
require_once 'challenge/html_head.php';
require GWF_CORE_PATH . 'module/WeChall/solutionbox.php';
if (false === ($chall = WC_Challenge::getByTitle(GWF_PAGE_TITLE))) {
    $chall = WC_Challenge::dummyChallenge(GWF_PAGE_TITLE, 4, 'challenge/bsdhell/thelasthope/index.php', false);
}
$chall->showHeader();
if (strcasecmp(Common::getPost('answer'), 'username_password') === 0) {
    $count = GWF_Counter::getCount('WC_BSD_LH_DOLT');
    if (false === GWF_Session::getOrDefault('WC_BSD_LH_DOLT', false)) {
        $count++;
        GWF_Counter::saveCounter('WC_BSD_LH_DOLT', $count);
        GWF_Session::set('WC_BSD_LH_DOLT', '1');
    }
    echo GWF_HTML::message('The Last Hope', $chall->lang('msg_literal'), false);
    echo GWF_HTML::error('The Last Hope', $chall->lang('err_literal', array($count)), false);
} else {
    $chall->onCheckSolution();
}
htmlTitleBox($chall->lang('title'), $chall->lang('info', array('bsd_thelasthope.elf')));
formSolutionbox($chall);
echo $chall->copyrightFooter();
require_once 'challenge/html_foot.php';
Beispiel #6
0
 public static function shadowTimer()
 {
     # 1 second over in the Shadowlamb world.
     self::$sr_timestamp = GWF_Counter::getAndCount('SR4_TIME', self::SECONDS_PER_TICK);
     # Execute Web Commands
     // 		self::shadowTimerWebcommands();
     if (defined('SL4_REALS')) {
         self::shadowTimerRealNPCs();
     }
     # All parties:
     $partyids = array_keys(self::$parties);
     shuffle($partyids);
     # Shuffle which party goes first to have evenly distributed winners in race conditions.
     foreach ($partyids as $id) {
         # still there?
         if (isset(self::$parties[$id])) {
             if (self::$parties[$id]->getTimestamp() < time() - self::KICK_IDLE_TIMEOUT) {
                 self::removeParty(self::$parties[$id]);
             } else {
                 self::$parties[$id] instanceof SR_Party;
                 self::$parties[$id]->timer(self::$sr_timestamp);
             }
         }
     }
     # Next tick in one second pls.
     Dog_Timer::addTimer(array(__CLASS__, 'shadowTimer'), NULL, self::TICKLEN, false);
 }
Beispiel #7
0
 private function onVote($by)
 {
     if ('' === ($message = $this->msgarg())) {
         $a = $by > 0 ? '++' : '--';
         $this->showHelp('link' . $a);
     } elseif (false === ($link = Dog_Link::getByID($message))) {
         $this->rply('err_link_id', array(intval($message)));
     } elseif (!$link->increase('link_rating', $by)) {
         Dog::err('ERR_DATABASE', array(__FILE__, __LINE__));
     } elseif (!GWF_Counter::increaseCount('dog_linkvotes', 1)) {
         Dog::err('ERR_DATABASE', array(__FILE__, __LINE__));
     } else {
         $this->rply('voted');
     }
 }
Beispiel #8
0
 public function on_quotes_Pb()
 {
     $votes = GWF_Counter::getCount('dog_quotevotes');
     $quotes = GDO::table('Dog_Quote');
     $count = $quotes->countRows();
     $last = $quotes->selectFirstObject('*', '', 'quot_date DESC');
     $last = $last === false ? '' : sprintf(' The last quote has been added by %s at %s.', $last->getVar('quot_username'), $last->displayDate());
     Dog::reply(sprintf('I have %d quotes in the database.%s The quotes have been voted %d times.', $count, $last, $votes));
 }
Beispiel #9
0
 public function deliver($from, $to, $title, $message, $parent1 = 0, $parent2 = 0)
 {
     require_once 'GWF_PM.php';
     $pm1 = GWF_PM::fakePM($from, $to, $title, $message, $from, GWF_PM::OUTBOX, $parent1);
     $pm1->setOption(GWF_PM::READ, true);
     if (false === $pm1->insert()) {
         return -1;
     }
     $pm2 = GWF_PM::fakePM($from, $to, $title, $message, $to, GWF_PM::INBOX, $parent2, $pm1->getID());
     $pm2->setOption(GWF_PM::OTHER_READ, true);
     if (false === $pm2->insert()) {
         return -2;
     }
     if (false === $pm1->saveVar('pm_otherid', $pm2->getID())) {
         return -3;
     }
     if (false === GWF_Counter::increaseCount('gwf3_pms_sent', 1)) {
         return -4;
     }
     if (!$this->cfgEmailOnPM()) {
         return 0;
     }
     $this->includeClass('GWF_EMailOnPM');
     return GWF_EMailOnPM::deliver($this, $pm2);
 }