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; }
private static function initHooks() { if (self::$HOOKS === true) { if (false !== ($hooks = GWF_Settings::getSetting('gwf3_hooks', false))) { self::$HOOKS = unserialize($hooks); } else { self::$HOOKS = array(); } } }
function dog_svn_info($key, $repo, $user = '', $pass = '', $displayurl = '', $channels = array()) { $keyshort = $key; $key = 'DOG_SVNINFO_REVISION_' . $key; $svninfo = new GWF_SvnInfo(); $svninfo->setRepository($repo, $user, $pass); if (0 == ($currentRevision = $svninfo->getCurrentRevision())) { return Dog_Log::debug('Fetching current revision failed.'); } $lastRevision = GWF_Settings::getSetting($key, $currentRevision); if ($currentRevision <= $lastRevision) { GWF_Settings::setSetting($key, $currentRevision); return; } $svnlog = $svninfo->getLog($lastRevision + 1, $currentRevision); foreach ($svnlog as $entry) { $msg = sprintf('[%s] New revision %s by %s: %s', $keyshort, $entry['version-name'], $entry['creator-displayname'], html_entity_decode($entry['comment'])); if ($displayurl != '') { $msg .= ' ( ' . str_replace('%REV%', $entry['version-name'], $displayurl) . ' )'; } if (count($channels) === 0) { # To all servers in the main channel foreach (DOG::getServers() as $server) { $server instanceof Dog_Server; $channels = $server->getChannels(); if (count($channels) > 0) { $channel = array_shift($channels); $channel = $channel->getVar('chan_name'); $server->sendPRIVMSG($channel, $msg); } } } else { # To all servers in matching channels foreach (DOG::getServers() as $server) { $server instanceof Dog_Server; $channels_now = $server->getChannels(); foreach ($channels_now as $channel) { $channel instanceof Dog_Channel; $channel = $channel->getName(); foreach ($channels as $c) { if (!strcasecmp($c, $channel)) { $server->sendPRIVMSG($channel, $msg); } } } } } } GWF_Settings::setSetting($key, $currentRevision); }
public function templateShow() { if (false === ($news = GWF_News::getNewsQuick($this->module->getNewsPerPage(), $this->catid, $this->page, GWF_Language::getCurrentID()))) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } $date = count($news) > 0 ? $news[0]['news_date'] : GWF_Settings::getSetting('gwf_site_birthday') . '090000'; $date = GWF_Time::displayDate($date); GWF_Website::setPageTitle($this->module->lang('pt_news', array($date))); GWF_Website::setMetaTags($this->module->lang('mt_news', array($date))); GWF_Website::setMetaDescr($this->module->lang('md_news', array($this->page, $this->nPages))); // $mod_forum = GWF_Module::getModule('Forum', true); $tVars = array('news' => $news, 'titles' => GWF_News::getTitlesQuick($this->catid, GWF_Language::getCurrentID()), 'cats' => GWF_News::getCategories(), 'catid' => $this->catid, 'cat' => GWF_HTML::display($this->catTitle), 'page_menu' => $this->getPageMenu(), 'page' => $this->page, 'can_sign' => $this->module->canSignNewsletter(GWF_Session::getUser()), 'href_sign_news' => $this->module->hrefSignNewsletter(), 'may_add' => GWF_User::isAdminS() || GWF_User::isStaffS(), 'href_add' => $this->module->hrefAddNews()); return $this->module->templatePHP('show.php', $tVars); }
public function onOnline() { $this->links_saved = GWF_Settings::getSetting('dog_irc_links', ''); // echo "Loading irc_links: $this->links_saved.\n"; $links = explode(';', $this->links_saved); foreach ($links as $i => $link) { if ($link === '') { unset($links[$i]); } elseif ('' !== $this->checkLinkChain($link)) { unset($links[$i]); // echo "Removed Link from memory: $link"; } } $this->links = array_values($links); }
public function cfgChallTags() { return GWF_Settings::getSetting('WC_CHALL_CLOUD', ''); }
<?php /** * This file is part of the Lamb2 IRC Bot. * @author gizmore */ # Date we want to query $date = GWF_Settings::getSetting('WC_FORUM_DATE', date('YmdH0000')); # We already know these threads for the current data stored $known = GWF_Settings::getSetting('WC_FORUM_LAST', ','); # Set output channel $server instanceof Lamb_Server; $channels = $server->getChannels(); $channel = array_shift($channels); $channel = $channel->getVar('chan_name'); # Query URL $url = sprintf('http://www.wechall.net/nimda_forum.php?datestamp=%s&limit=5', $date); if (false === ($content = GWF_HTTP::getFromURL($url))) { return; } # Nothing happened if ($content === '') { return ''; } $latest_date = $date; $new_known = $known; $lines = explode("\n", $content); foreach ($lines as $line) { if ('' === ($line = trim($line))) { continue; }
function dog_wc_solvers($key, $name, $url, $channels = array(), $max_solvercount = 100, $format) { # Date we want to query $lastdate = GWF_Settings::getSetting('DOG_SOLVERS_DATE_' . $key, ''); if (strlen($lastdate) !== 14) { $lastdate = date('YmdHis'); GWF_Settings::setSetting('DOG_SOLVERS_DATE_' . $key, $lastdate); } $lastpair = GWF_Settings::getSetting('DOG_SOLVERS_PAIR_' . $key, ''); # Query URL $url = str_replace(array('%DATE%'), array($lastdate), $url); // echo $url.PHP_EOL; GWF_HTTP::setTimeout(3); GWF_HTTP::setConnectTimeout(2); if (false === ($content = GWF_HTTP::getFromURL($url))) { return; } GWF_HTTP::setTimeout(); GWF_HTTP::setConnectTimeout(); // echo $content.PHP_EOL; # Nothing happened if ($content === '') { return; } $lines = explode("\n", $content); $changed = false; $badlines = 0; $latestdate = $lastdate; $firstpair = false; foreach ($lines as $line) { // echo "$line\n"; if ('' === ($line = trim($line))) { continue; } $thedata = explode('::', $line); if (count($thedata) !== 12) { $badlines++; echo 'Invalid line in dog_wc_solvers: ' . $line . PHP_EOL; if ($badlines > 3) { echo "BAD URL IS: {$url}\n"; return; } continue; } $badlines = 0; $thedata = array_map('unescape_csv_like', $thedata); # Fetch line # uid::cid::solve_date::1st_look::viewcount::options::time_taken::tries::username::challname::solvecount::url list($uid, $cid, $solvedate, $firstdate, $views, $options, $timetaken, $tries, $username, $challname, $solvercount, $challurl) = $thedata; if (strlen($solvedate) !== 14) { echo "Dateformat in {$url} is invalid: {$solvedate}\n"; return false; } $latestdate = $solvedate; $pair = "{$uid}:{$cid}"; if ($firstpair === false) { $firstpair = $pair; } if ($pair === $lastpair) { break; } if ($solvercount > $max_solvercount) { continue; } $msg = sprintf($format, $name, $username, $challname, $solvercount, $challurl); if (count($channels) === 0) { # To all servers in the main channel foreach (Dog::getServers() as $server) { $server instanceof Dog_Server; $channels = $server->getChannels(); if (count($channels) > 0) { $channel = array_shift($channels); $channel = $channel->getName(); $server->sendPRIVMSG($channel, $msg); } } } else { # To all servers in matching channels foreach (Dog::getServers() as $server) { $server instanceof Dog_Server; $channels_now = $server->getChannels(); foreach ($channels_now as $channel) { $channel instanceof Dog_Channel; $channel = $channel->getName(); echo $channel . PHP_EOL; foreach ($channels as $c) { if (!strcasecmp($c, $channel)) { $server->sendPRIVMSG($channel, $msg); } } } } } $changed = true; } # Save state if ($changed) { GWF_Settings::setSetting('DOG_SOLVERS_DATE_' . $key, $latestdate); GWF_Settings::setSetting('DOG_SOLVERS_PAIR_' . $key, $firstpair); } }
<?php # Change dir to web root chdir('../../../../'); define('GWF_PAGE_TITLE', 'Training: Math Pyramid'); require_once 'challenge/html_head.php'; require_once GWF_CORE_PATH . 'inc/3p/EvalMath.php'; if (false === ($chall = WC_Challenge::getByTitle(GWF_PAGE_TITLE))) { $chall = WC_Challenge::dummyChallenge(GWF_PAGE_TITLE, 2, 'challenge/training/math/pyramid/index.php', false); } $chall->showHeader(); $maxlen = GWF_Settings::getSetting('WC_MATH_PYRAMID', 1000); $img = sprintf('<img src="%schallenge/training/math/pyramid/pyramid.png" title="pyramid.png" alt="pyramid.png" />', GWF_WEB_ROOT); # credits if (false !== ($momo = GWF_User::getByName('momo'))) { $c1 = $momo->displayProfileLink(); } else { $c1 = '<b>Momo</b>'; } if (false !== ($jinx = GWF_User::getByName('Jinx'))) { $c2 = $jinx->displayProfileLink(); } else { $c2 = '<b>Jinx</b>'; } if (false !== ($paipai = GWF_User::getByName('paipai'))) { $c3 = $paipai->displayProfileLink(); } else { $c3 = '<b>paipai</b>'; } $c4 = '<b>Miles Kaufmann</b>'; echo GWF_Box::box($chall->lang('info', array($maxlen, $img, $c1, $c2, $c3, $c4)), $chall->lang('title'));
public static function getBirthdate() { return GWF_Settings::getSetting('gwf_site_birthdate', date('Ymd')); }
function dog_wc_forum($key, $name, $url, $channels = array(), $limit = 5, $onlygids = false, $skipgids = false) { # Date we want to query $date = GWF_Settings::getSetting('DOG_FORUM_DATE_' . $key, date('Ymd000000')); if (strlen($date) !== 14) { $date = date('Ymd000000'); } # We already know these threads for the current data stored $known = GWF_Settings::getSetting('DOG_FORUM_LAST_' . $key, ','); # Query URL $url = str_replace(array('%DATE%', '%LIMIT%'), array($date, $limit), $url); // echo $url.PHP_EOL; GWF_HTTP::setTimeout(3); GWF_HTTP::setConnectTimeout(2); if (false === ($content = GWF_HTTP::getFromURL($url))) { return; } GWF_HTTP::setTimeout(); GWF_HTTP::setConnectTimeout(); // echo $content.PHP_EOL; # Nothing happened if ($content === '') { return; } $latest_date = $date; $new_known = $known; $lines = explode("\n", $content); $changed = false; $badlines = 0; foreach ($lines as $line) { if ('' === ($line = trim($line))) { continue; } $thedata = explode('::', $line); if (count($thedata) !== 6) { $badlines++; echo 'Invalid line in dog_wc_forum: ' . $line . PHP_EOL; if ($badlines === 1) { echo "BAD URL IS: {$url}\n"; } if ($badlines > 3) { return; } continue; } $badlines = 0; $thedata = array_map('unescape_csv_like', $thedata); # Fetch line list($threadid, $lastdate, $lock, $url, $username, $title) = $thedata; if (strlen($lastdate) !== 14) { echo "Dateformat in {$url} is invalid: {$lastdate}\n"; return false; } $gid = (int) $lock; if (is_array($onlygids)) { if (!in_array($gid, $onlygids, true)) { // echo "Not an only gid: $gid\n"; continue; } } if (is_array($skipgids)) { if (in_array($gid, $skipgids, true)) { // echo "Skipped gid: $gid\n"; continue; } } # Duplicate output? if ($lastdate === $date && strpos($known, ',' . $threadid . ',') !== false) { continue; } # Is it private? $lock = $lock === '0' ? '' : ' locked'; # does the date change? if ($latest_date !== $lastdate) { $latest_date = $lastdate; $new_known = ','; } # Mark this thread as known for this datestamp $new_known .= $threadid . ','; if (strpos($url, 'http') !== 0) { $url = 'http://' . $url; } # Output message if ($lock === ' locked') { $msg = sprintf('%s New%s post: %s', $name, $lock, $url); } else { $msg = sprintf('%s New post by %s in %s: %s', $name, $username, $title, $url); } if (count($channels) === 0) { # To all servers in the main channel foreach (Dog::getServers() as $server) { $server instanceof Dog_Server; $channels = $server->getChannels(); if (count($channels) > 0) { $channel = array_shift($channels); $channel = $channel->getVar('chan_name'); $server->sendPRIVMSG($channel, $msg); } } } else { # To all servers in matching channels foreach (Dog::getServers() as $server) { $server instanceof Dog_Server; $channels_now = $server->getChannels(); foreach ($channels_now as $channel) { $channel instanceof Dog_Channel; $channel = $channel->getName(); echo $channel . PHP_EOL; foreach ($channels as $c) { if (!strcasecmp($c, $channel)) { $server->sendPRIVMSG($channel, $msg); } } } } } $changed = true; } # Save state if ($changed) { GWF_Settings::setSetting('DOG_FORUM_DATE_' . $key, $lastdate); GWF_Settings::setSetting('DOG_FORUM_LAST_' . $key, $new_known); } }
$lines = preg_split('/\\n/', $result); $map = array('Revolution Elite' => '#revolutionelite', 'Hacker.org' => '#hacker.org', 'Security Traps' => '#securitytraps', 'Rankk' => '#pyramid'); foreach ($lines as $line) { $data = explode('::', $line); if (count($data) === 1) { continue; } foreach ($data as $i => $d) { $data[$i] = str_replace('\\:', ':', $d); } list($sitename, $class, $status, $url, $purl, $users, $links, $challs, $basescore, $avg, $score) = $data; if ($status !== 'up') { continue; } $setname = "DOG_SITECC_{$class}"; $old = GWF_Settings::getSetting($setname, false); if ($old != $challs && $old !== false) { $amt = $challs - $old; if (abs($amt) > 1) { $message = sprintf('There are %d new challenges on %s ( %s ).', $amt, $sitename, $url); } else { $message = sprintf('There is %d new challenge on %s ( %s ).', $amt, $sitename, $url); } foreach (Dog::getServers() as $s) { $s instanceof Dog_Server; $c = $s->getChannels(); if (count($c) > 0) { $c = array_shift($c); $c instanceof Dog_Channel; // echo $c->getName().': '.$message.PHP_EOL; if (stripos($s->getName(), 'idlemonkeys') === false) {
public function getStoreSettings() { return GWF_Settings::getSetting($this->getStoreSettingsName(), NULL); }
public static function isPlaying(Slay_Song $song) { return GWF_Settings::getSetting(self::NP_KEY) === $song->getID(); }