Пример #1
0
 public function parseStats($url)
 {
     if (false === ($result = GWF_HTTP::getFromURL($url, false))) {
         return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName())));
     }
     $result = str_replace("", '', $result);
     # BOM
     $result = trim($result);
     $stats = explode(":", $result);
     if (count($stats) !== 7) {
         return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName())));
     }
     $i = 0;
     $username = $stats[$i++];
     $rank = intval($stats[$i++]);
     $onsitescore = intval($stats[$i++]);
     $onsitescore = Common::clamp($onsitescore, 0);
     $maxscore = intval($stats[$i++]);
     $challssolved = intval($stats[$i++]);
     $challcount = intval($stats[$i++]);
     $usercount = intval($stats[$i++]);
     if ($maxscore === 0 || $challcount === 0 || $usercount === 0) {
         return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName())));
     }
     return array($onsitescore, $rank, $challssolved, $maxscore, $usercount, $challcount);
 }
Пример #2
0
 public function onThrow(SR_Player $player, SR_Player $target)
 {
     $firearms = $player->get('firearms');
     $atk = 20 + $firearms;
     $mindmg = 1;
     $maxdmg = 6;
     $out_dmg = '';
     $out_dmgep = '';
     $out_eff = '';
     $inaccuracy = rand(2, 4) - ($firearms ? 1 : 0);
     $targets = $this->computeDistances($target, $inaccuracy);
     foreach ($targets as $data) {
         list($t, $d) = $data;
         $t instanceof SR_Player;
         $a = $atk - $d + rand(-1, 2);
         $a = Common::clamp($a, 0, $atk);
         $def = $t->get('defense');
         $arm = $t->get('marm');
         $hits = Shadowfunc::diceHits($mindmg, $arm, $atk, $def, $player, $t);
         $hits -= $arm;
         $hits = Common::clamp($hits, 0);
         if ($hits == 0) {
             continue;
         }
         $dmg = round($mindmg + $hits / 10, 2);
         if ($dmg <= 0) {
             continue;
         }
     }
 }
Пример #3
0
 public static function execute(SR_Player $player, array $args)
 {
     $pp = Shadowrun4::getParties();
     foreach ($pp as $i => $p) {
         $p instanceof SR_Party;
         if (!$p->isHuman()) {
             unset($pp[$i]);
         }
     }
     $page = isset($args[0]) ? intval($args[0]) : 1;
     $nItems = count($pp);
     $nPages = GWF_PageMenu::getPagecount(self::PPP, $nItems);
     $page = Common::clamp($page, 1, $nPages);
     $from = GWF_PageMenu::getFrom($page, self::PPP);
     $slice = array_slice($pp, $from, self::PPP);
     $out = '';
     $format = $player->lang('fmt_list');
     foreach ($slice as $p) {
         $p instanceof SR_Party;
         $leader = $p->getLeader()->displayName();
         $l = $p->getSum('level', true);
         $ll = $p->getSum('level', false);
         $mc = $p->getMemberCount();
         $item = sprintf('%s(L%s(%s))(M%s)', $leader, $l, $ll, $mc);
         $out .= sprintf($format, $item);
         // 			$out .= sprintf(', %s(L%s(%s))(M%s)', $leader, $l, $ll, $mc);
     }
     return self::rply($player, '5248', array($page, $nPages, ltrim($out, ',; ')));
     // 		$bot = Shadowrap::instance($player);
     // 		$bot->reply(sprintf('Parties page %s from %s: %s.', $page, $nPages, substr($out, 2)));
 }
Пример #4
0
 private function templateSongs()
 {
     //		$user = GWF_Session::getUser();
     //		$uid = $user->getID();
     $table = GDO::table('Slay_Song');
     $joins = NULL;
     $headers = array();
     $headers[] = array($this->module->lang('th_artist'), 'ss_artist');
     $headers[] = array($this->module->lang('th_title'), 'ss_title');
     $headers[] = array($this->module->lang('th_duration'), 'ss_duration');
     $headers[] = array($this->module->lang('th_bpm'), 'ss_bpm');
     $headers[] = array($this->module->lang('th_key'), 'ss_key');
     $headers[] = array($this->module->lang('D'));
     $headers[] = array($this->module->lang('L'));
     $headers[] = array($this->module->lang('T'));
     $headers[] = array($this->module->lang('th_tags'));
     $where = "";
     $nItems = $table->selectVar('COUNT(ss_id)', $where, '', $joins);
     $nPages = GWF_PageMenu::getPagecount(self::IPP, $nItems);
     $page = Common::clamp(Common::getGetInt('page'), 1, $nPages);
     $by = Common::getGetString('by', self::BY);
     $dir = Common::getGetString('dir', self::DIR);
     $orderby = $table->getMultiOrderby($by, $dir, false);
     $songs = $table->selectAll('*', $where, $orderby, $joins, self::IPP, GWF_PageMenu::getFrom($page, self::IPP), GDO::ARRAY_O);
     $tVars = array('is_dj' => GWF_User::isInGroupS('dj'), 'sort_url' => GWF_WEB_ROOT . 'index.php?mo=Slaytags&me=Songs&by=%BY%&dir=%DIR%&page=1', 'pagemenu' => GWF_PageMenu::display($page, $nPages, GWF_WEB_ROOT . sprintf('index.php?mo=Slaytags&me=Songs&by=%s&dir=%s&page=%%PAGE%%', urlencode($by), urlencode($dir))), 'songs' => $songs, 'headers' => $headers);
     return $this->module->template('songs.tpl', $tVars);
 }
Пример #5
0
 public function onNPCTalk(SR_Player $player, $word, array $args)
 {
     $price = 800 - Common::clamp($player->get('negotiation'), 0, 10) * 10;
     $time = 1000 * $player->get('charisma') * 60;
     $b = chr(2);
     switch ($word) {
         case 'shadowrun':
             return $this->reply("I am in for a run, Do you want to {$b}hire{$b} my hacking skills?");
         case 'yes':
             return $this->reply("Yes, {$b}hire{$b} me and i'll aid you in combat and hacking.");
         case 'no':
             if ($player->hasTemp(self::MANIFESTO)) {
                 return $this->reply('Yes, no, what else?');
             } else {
                 $this->reply("This is our world now... The world of the electron and the switch, the beauty of the baud.");
                 $this->reply("We make use of a service already existing without paying for what could be dirt-cheap if it wasn't run by profiteering gluttons, and you call us criminals.");
                 $this->reply("We explore... And you call us criminals. We seek after knowledge... And you call us criminals. We exist without skin color, without nationality, without religious bias... And you call us criminals.");
                 $this->reply("You build atomic bombs, you wage wars, you murder, cheat, and lie to us and try to make us believe it's for our own good, yet we're the criminals.");
                 $this->reply("Yes, I am a criminal. My crime is that of curiosity. My crime is that of judging people by what they say and think, not what they look like. My crime is that of outsmarting you, something that you will never forgive me for.");
                 $this->reply("I am a hacker, and this is my manifesto. You may stop this individual, but you can't stop us all... After all, we're all alike.");
                 $player->setTemp(self::MANIFESTO, 1);
                 return true;
             }
             break;
         case 'hire':
             return $this->reply($this->onHire($player, $price, $time));
         default:
             return $this->reply("Need a hacker?");
             break;
     }
 }
Пример #6
0
 /**
  * Filter Store Items through availability.
  * @param SR_Player $player
  */
 public function getStoreItemsB(SR_Player $player)
 {
     $key = $this->getStoreItemsKey();
     if ($player->hasTemp($key)) {
         return $player->getTemp($key);
     }
     $rep = Common::clamp($player->get('reputation'), 0, 25) * 0.5;
     $items = $this->getStoreItems($player);
     if (!is_array($items)) {
         return array();
     }
     $back = array();
     $unique = false;
     foreach ($items as $i => $data) {
         $avail = isset($data[1]) ? $data[1] : 100.0;
         $avail += $rep;
         if (Shadowfunc::dicePercent($avail)) {
             $back[] = $data;
         } else {
             $unique = true;
         }
     }
     if ($unique === true) {
         $player->setTemp($key, $back);
     }
     return $back;
 }
Пример #7
0
 public function execute()
 {
     if (false === ($user = GWF_User::getByName(Common::getGetString('username')))) {
         return GWF_HTML::err('ERR_UNKNOWN_USER');
     }
     if (false !== ($error = $this->module->isExcludedFromAPI($user, false))) {
         return $error;
     }
     $this->module->includeClass('WC_RegAt');
     $format = Common::getGetString('format', self::FORMAT);
     $bg = Common::getGetString('bg', self::BGCOLOR);
     $fg = Common::getGetString('fg', self::FGCOLOR);
     $size = Common::clamp(Common::getGetInt('s', self::SIZE), 6, 30);
     $spacingx = Common::clamp(Common::getGetInt('sx', 1), 0, 30);
     $spacingy = Common::clamp(Common::getGetInt('sy', 1), 0, 30);
     $marginx = Common::clamp(Common::getGetInt('mx', 1), 0, 30);
     $marginy = Common::clamp(Common::getGetInt('my', 1), 0, 30);
     $divider = Common::getGetString('div', '  ');
     $font = Common::getGetString('font', self::FONT);
     $_GET['font'] = $font;
     if (!preg_match('/^[a-z_0-9]+$/iD', $font) || !Common::isFile(GWF_EXTRA_PATH . 'font/' . $font . '.ttf')) {
         return "Font not found. Available fonts: " . $this->listFonts();
     }
     die($this->displayBanner($user, $format, $bg, $fg, $size, $spacingx, $spacingy, $marginx, $marginy, $divider));
 }
Пример #8
0
 private function templateUsers($term = '')
 {
     $ipp = $this->module->cfgIPP();
     $form = $this->getFormQuick();
     $usertable = GDO::table('GWF_User');
     $by = Common::getGet('by', '');
     $dir = Common::getGet('dir', '');
     $orderby = $usertable->getMultiOrderby($by, $dir);
     if ($term === '') {
         $users = array();
         $page = 1;
         $nPages = 0;
     } else {
         $eterm = GDO::escape($term);
         $deleted = GWF_User::DELETED;
         $conditions = "user_name LIKE '%{$eterm}%' AND user_options&{$deleted}=0";
         $nItems = $usertable->countRows($conditions);
         $nPages = GWF_PageMenu::getPagecount($ipp, $nItems);
         $page = Common::clamp(intval(Common::getGet('page', 1)), 1, $nPages);
         $from = GWF_PageMenu::getFrom($page, $ipp);
         $users = $usertable->selectObjects('*', $conditions, $orderby, $ipp, $from);
     }
     $href_pagemenu = GWF_WEB_ROOT . 'index.php?mo=Usergroups&me=Search&term=' . urlencode($term) . '&by=' . urlencode($by) . '&dir=' . urlencode($dir) . '&page=%PAGE%';
     $tVars = array('form' => $form->templateX(false, false), 'users' => $users, 'sort_url' => GWF_WEB_ROOT . 'index.php?mo=Usergroups&me=Search&term=' . urlencode($term) . '&by=%BY%&dir=%DIR%&page=1', 'page_menu' => GWF_PageMenu::display($page, $nPages, $href_pagemenu), 'href_adv' => $this->module->getMethodURL('SearchAdv'));
     return $this->module->templatePHP('search.php', $tVars);
 }
Пример #9
0
 public function onSearch()
 {
     $form = $this->getForm();
     //		if (false !== ($error = $form->validate($this->module))) {
     //			return $error.$this->templateSearch();
     //		}
     $users = GDO::table('GWF_User');
     $term = Common::getRequest('term');
     if (false !== ($error = $this->validate_term($this->module, $term))) {
         return $error;
     }
     $fields = array('user_name', 'user_email');
     $by = Common::getGet('by', self::DEFAULT_BY);
     $dir = Common::getGet('dir', self::DEFAULT_DIR);
     $orderby = $users->getMultiOrderby($by, $dir);
     if (false === ($conditions = GWF_QuickSearch::getQuickSearchConditions($users, $fields, $term))) {
         $conditions = '0';
     }
     $hits = $users->countRows($conditions);
     $ipp = $this->module->cfgUsersPerPage();
     $nPages = GWF_PageMenu::getPagecount($ipp, $hits);
     $page = Common::clamp((int) Common::getGet('page', 1), 1, $nPages);
     $from = GWF_PageMenu::getFrom($page, $ipp);
     $tVars = array('searched' => true, 'form' => $form->templateX($this->module->lang('ft_search')), 'hits' => $hits, 'users' => $users->selectObjects('*', $conditions, $orderby, $ipp, $from), 'term' => $term, 'pagemenu' => GWF_PageMenu::display($page, $nPages, GWF_WEB_ROOT . 'index.php?mo=Admin&me=UserSearch&term=' . urlencode($term) . '&by=' . urlencode($by) . '&dir=' . urlencode($dir) . '&page=1'), 'sort_url' => GWF_WEB_ROOT . 'index.php?mo=Admin&me=UserSearch&term=' . urlencode($term) . '&by=%BY%&dir=%DIR%&page=1');
     return $this->module->templatePHP('user_search.php', $tVars);
 }
Пример #10
0
 public static function display(GWF_Module $module, GDO $gdo, $user, $sortURL, $conditions = '', $ipp = 25, $pageURL = false, $joins = NULL)
 {
     $fields = $gdo->getSortableFields($user);
     $headers = self::getGDOHeaders2($module, $gdo, $user, $sortURL);
     $nItems = $gdo->countRows($conditions);
     $nPages = GWF_PageMenu::getPagecount($ipp, $nItems);
     $page = Common::clamp(intval(Common::getGet('page', 1)), 1, $nPages);
     $orderby = self::getMultiOrderBy($gdo, $user);
     $from = GWF_PageMenu::getFrom($page, $ipp);
     $i = 0;
     $data = array();
     if (false === ($result = $gdo->select('*', $conditions, $orderby, $joins, $ipp, $from))) {
         echo GWF_HTML::err(ERR_DATABASE, __FILE__, __LINE__);
         return false;
     }
     while (false !== ($row = $gdo->fetch($result, GDO::ARRAY_O))) {
         $row instanceof GWF_Sortable;
         $data[$i] = array();
         foreach ($fields as $field) {
             $data[$i][] = $row->displayColumn($module, $user, $field);
         }
         $i++;
     }
     $gdo->free($result);
     if ($pageURL === false) {
         $pageURL = '';
     } elseif ($pageURL === true) {
         $pageURL = str_replace(array('%BY%', '%DIR%'), array(urlencode(Common::getGet('by')), urlencode(Common::getGet('dir'))), $sortURL);
         $pageURL .= '&page=%PAGE%';
     }
     $pagemenu = $pageURL === '' ? '' : GWF_PageMenu::display($page, $nPages, $pageURL);
     return $pagemenu . self::display2($headers, $data) . $pagemenu;
 }
Пример #11
0
 public function calcTicketPrice($price, SR_Player $player)
 {
     $neg = Common::clamp($player->get('negotiation'), 0, 10) * 0.01;
     $mc = $player->getParty()->getMemberCount();
     $price = $price * $mc;
     $price = $price * (1.0 - $neg);
     return $price;
 }
Пример #12
0
 public function getNPCMeetPercent(SR_Party $party)
 {
     if ($this->getNPCCityClass()->isAlert($party)) {
         return 300;
     }
     $bad_karma = $party->getSum('bad_karma', true);
     $perc = $bad_karma / 5 * 100;
     return Common::clamp($perc, 0.0, 100.0);
 }
Пример #13
0
 private static function getShoutWait(SR_Player $player)
 {
     $range = self::MAX_DELAY - self::MIN_DELAY;
     $tpl = $range / self::MAX_LEVEL;
     $level = Common::clamp($player->getBase('level'), 0, self::MAX_LEVEL);
     $delay = self::MIN_DELAY + $tpl * (self::MAX_LEVEL - $level);
     $last = $player->hasTemp(self::TEMP_KEY) ? $player->getTemp(self::TEMP_KEY) : 0;
     $next = $last + $delay;
     return $next - time();
 }
Пример #14
0
 public function getTrollCount(SR_Player $player)
 {
     $c2 = SR_PlayerVar::getVal($player, 'THQLVTRC', 0);
     if ($c2 >= 1) {
         return 0;
     }
     $p = $player->getParty();
     $mc = $p->getMemberCount();
     $c = $mc * 2 + 1;
     return Common::clamp($c, 1, 10);
 }
Пример #15
0
 private function sanitize()
 {
     $this->table = new GWF_UserActivation(false);
     $this->ipp = $this->module->getActivationsPerPage();
     $this->nItems = $this->table->countRows();
     $this->nPages = GWF_PageMenu::getPagecount($this->ipp, $this->nItems);
     $this->page = Common::clamp((int) Common::getGet('page', 1), 1, $this->nPages);
     $this->by = $this->table->getWhitelistedBy(Common::getGetString('by'), 'timestamp');
     $this->dir = GDO::getWhitelistedDirS(Common::getGetString('dir'), 'DESC');
     $this->orderby = "{$this->by} {$this->dir}";
 }
Пример #16
0
 private function onReply(Module_Comments $mod_c, GWF_News $news, GWF_Comments $comments)
 {
     $ipp = 10;
     $nItems = $comments->getVar('cmts_count');
     $nPages = GWF_PageMenu::getPagecount($ipp, $nItems);
     $page = Common::clamp(Common::getGetInt('cpage'), 1, $nPages);
     $href = GWF_WEB_ROOT . 'news-comments-' . $news->getID() . '-' . $news->displayTitle() . '-page-' . $page . '.html';
     $me = $mod_c->getMethod('Reply');
     $me instanceof Comments_Reply;
     return $me->onReply($href);
 }
Пример #17
0
 private function sanitize()
 {
     $news = GDO::table('GWF_News');
     $this->nItems = $news->countRows();
     $this->ipp = $this->module->getNewsPerAdminPage();
     $this->nPages = GWF_PageMenu::getPagecount($this->ipp, $this->nItems);
     $this->page = Common::clamp(Common::getGet('page', 1), 1, $this->nPages);
     $this->by = $news->getWhitelistedBy(Common::getGet('by', 'news_date'), 'news_date', false);
     $this->dir = GDO::getWhitelistedDirS(Common::getGet('dir', 'DESC'), 'DESC');
     $this->orderby = $news->getMultiOrderby($this->by, $this->dir);
 }
Пример #18
0
 public function cfgAllowedPOIs()
 {
     $level = GWF_User::getStaticOrGuest()->getLevel();
     $minpnts = $this->cfgMinPntPOIsAdd();
     $allowed = 0;
     if ($level >= $minpnts && 0 < ($ppp = $this->cfgPntPOIs())) {
         $level -= $minpnts;
         $allowed = intval($level / $ppp);
     }
     return Common::clamp($allowed, $this->cfgMinPOIs(), $this->cfgMaxPOIs());
 }
Пример #19
0
 public function templateShow($href = NULL)
 {
     $nItems = $this->comments->getVar('cmts_count');
     $nPages = GWF_PageMenu::getPagecount($this->module->cfgIPP(), $nItems);
     $page = Common::clamp(Common::getGetInt('cpage', 1), 1, $nPages);
     $cid = $this->comments->getID();
     $visible = GWF_Comment::VISIBLE;
     $comments = GDO::table('GWF_Comment')->selectObjects('*', "cmt_cid={$cid} AND cmt_options&{$visible}", 'cmt_date ASC');
     $tVars = array('pagemenu' => GWF_PageMenu::display($page, $nPages, $href), 'comments' => $this->comments->displayComments($comments, $href));
     return $this->module->template('show.tpl', $tVars);
 }
Пример #20
0
 private function templateHistory()
 {
     $table = GDO::table('Slay_PlayHistory');
     $ipp = Slay_PlayHistory::IPP;
     $where = '';
     $nItems = $table->countRows($where);
     $nPages = GWF_PageMenu::getPagecount($ipp, $nItems);
     $page = Common::clamp(Common::getGetInt('page'), 1, $nPages);
     $from = GWF_PageMenu::getFrom($page, $ipp);
     $tVars = array('is_admin' => GWF_User::isStaffS(), 'page' => $page, 'pagemenu' => GWF_PageMenu::display($page, $nPages, GWF_WEB_ROOT . 'index.php?mo=Slaytags&me=History&page=%PAGE%'), 'history' => $table->selectAll('*', $where, 'sph_date ASC', array('songs'), $ipp, $from, 'Slay_Song'));
     return $this->module->template('history.tpl', $tVars);
 }
Пример #21
0
 private function sanitize()
 {
     $this->threads = GDO::table('GWF_ForumThread');
     $this->conditions = sprintf('thread_postcount>0 AND (%s) AND thread_options&%d=0', GWF_ForumThread::getPermQuery(), GWF_ForumThread::IN_MODERATION | GWF_ForumThread::INVISIBLE);
     $this->nThreads = $this->threads->countRows($this->conditions);
     $this->tpp = $this->module->getThreadsPerPage();
     $this->nPages = GWF_PageMenu::getPagecount($this->tpp, $this->nThreads);
     $this->page = Common::clamp(Common::getGet('page', $this->nPages), 1, $this->nPages);
     $this->by = $_GET['by'] = Common::getGet('by', 'thread_lastdate');
     $this->dir = $_GET['dir'] = Common::getGet('dir', 'ASC');
     $this->orderby = $this->threads->getMultiOrderby($this->by, $this->dir);
 }
Пример #22
0
 private function sanitize()
 {
     static $valid = array('gif', 'jpg', 'png');
     $this->size = Common::clamp(Common::getGet('size', 1), 16, 64);
     $this->of = Common::clamp(Common::getGet('of', 1), 1, 16);
     $this->num = Common::clamp(Common::getGet('num', 1), 1, $this->of);
     $this->ext = Common::getGet('ext');
     if (!in_array($this->ext, $valid, true)) {
         $this->ext = 'gif';
     }
     return false;
 }
Пример #23
0
 private function sanitize()
 {
     $this->ipp = $this->module->getHistmsgPerPage();
     $channel = Common::getGet('channel', '');
     if (Common::startsWith($channel, 'G-')) {
         $channel = 'G#' . substr($channel, 2);
     }
     $this->channel = $this->module->getWhitelistedChannel($channel);
     $this->nItems = $this->module->countHistoryMessages($this->channel);
     $this->nPages = GWF_PageMenu::getPagecount($this->ipp, $this->nItems);
     $this->page = Common::clamp((int) Common::getGet('page', $this->nPages), 1, $this->nPages);
 }
Пример #24
0
 private function onWereAttack(SR_Player $player)
 {
     $p = $player->getParty();
     $mc = $p->getMemberCount();
     $numEnemies = rand(2, 2 + $mc + 2);
     $numEnemies = Common::clamp($numEnemies, 2, SR_Party::MAX_MEMBERS);
     $enemies = array();
     for ($i = 0; $i < $numEnemies; $i++) {
         $enemies[] = 'Forest_Werewolf';
     }
     return $p->fight(SR_NPC::createEnemyNPC($enemies));
 }
Пример #25
0
 private function sanitize()
 {
     $this->user = GWF_Session::getUser();
     $links = GDO::table('GWF_Links');
     $this->by = Common::getGet('by', self::DEFAULT_BY);
     $this->dir = Common::getGet('dir', self::DEFAULT_DIR);
     //		if ($this->by === false && $this->dir === false)
     //		{
     //			$this->by = self::DEFAULT_BY;
     //			$this->dir = self::DEFAULT_DIR;
     //			$this->orderby = self::DEFAULT_ORDERBY;
     //		}
     //		else
     //		{
     $this->orderby = $links->getMultiOrderby($this->by, $this->dir);
     //		}
     $this->tag = GWF_LinksTag::getWhitelistedTag(Common::getGet('tag'), '');
     $this->lpp = $this->module->cfgLinksPerPage();
     $this->nLinks = $links->countLinks($this->module, $this->user, $this->tag, false);
     $this->nPages = GWF_PageMenu::getPagecount($this->lpp, $this->nLinks);
     $this->page = Common::clamp(Common::getGet('page', 1), 1, $this->nPages);
     $this->from = GWF_PageMenu::getFrom($this->page, $this->lpp);
     if ($this->tag === '') {
         $this->sortURL = GWF_WEB_ROOT . 'links/by/%BY%/%DIR%/page-1';
         $href = GWF_WEB_ROOT . 'links/by/' . $this->by . '/' . $this->dir . '/page-%PAGE%';
     } else {
         $this->sortURL = GWF_WEB_ROOT . 'links/' . $this->tag . '/by/%BY%/%DIR%/page-1';
         $href = GWF_WEB_ROOT . 'links/' . Common::urlencodeSEO($this->tag) . '/by/' . $this->by . '/' . $this->dir . '/page-%PAGE%';
     }
     //		var_dump($this->tag);
     //		$unread_query = $this->module->getUnreadQuery($this->user);
     $tag_query = $links->getTagQuery($this->tag);
     //		var_dump($tag_query);
     if ($this->module->cfgShowPermitted()) {
         $conditions = "({$tag_query})";
     } else {
         $perm_query = $this->module->getPermQuery($this->user);
         $mod_query = $links->getModQuery($this->user);
         $member_query = $links->getMemberQuery($this->user);
         $private_query = $links->getPrivateQuery($this->user);
         $conditions = "({$perm_query}) AND ({$tag_query}) AND ({$mod_query}) AND ({$member_query}) AND ({$private_query})";
         # AND (NOT $unread_query))";
     }
     //		var_dump($conditions);
     if (false === ($this->links = $links->selectObjects('*', $conditions, $this->orderby, $this->lpp, $this->from))) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     $this->pagemenu = GWF_PageMenu::display($this->page, $this->nPages, $href);
     $this->add_link_text = GWF_LinksValidator::mayAddLink($this->module, $this->user);
     $this->hrefAdd = $this->add_link_text === false ? $this->module->getMethodURL('Add', '&tag=' . $this->tag) : false;
     //		$this->newLinks = $links->select("(($perm_query) AND ($unread_query) AND ($mod_query) AND ($member_query) AND ($tag_query))", 'link_date ASC');
     return false;
 }
Пример #26
0
 /**
  * Return the last position of a char, counting backwards from offset.
  * This function does not work with strings, only with a char as needle.
  * @param string $s
  * @param char $c
  * @param int $offset
  */
 public static function strrchr($s, $c, $offset = 0)
 {
     $len = strlen($s);
     $i = Common::clamp((int) $offset, 0, $len - 1);
     while ($i >= 0) {
         if ($s[$i] === $c) {
             return $i;
         }
         $i--;
     }
     return false;
 }
Пример #27
0
 public function cast(SR_Player $player, SR_Player $target, $level, $hits, SR_Player $potion_player)
 {
     $seconds = Common::clamp(90 - $hits, 30, 90);
     $amount = rand($level, $level + $hits / 3) + rand(0, $player->get('wisdom'));
     $per_sec = round($amount / $seconds, 2);
     $per_sec = $this->lowerSpellIncrement($target, $per_sec, 'hp');
     echo "Casting flu with level {$level} and {$hits} hits. The target will loose {$amount} HP within {$seconds} seconds.\n";
     $modifiers = array('hp' => -$per_sec);
     $target->addEffects(new SR_Effect($seconds, $modifiers, SR_Effect::MODE_REPEAT));
     $this->announceADV($player, $target, $level);
     return true;
 }
Пример #28
0
 private function sanitize()
 {
     $users = GDO::table('GWF_User');
     $this->upp = $this->module->cfgUsersPerPage();
     $this->nUsers = $users->countRows();
     //		$this->by = $users->getWhitelistedBy(Common::getGet('by'), 'user_regdate');
     //		$this->dir = $users->getWhitelistedDir(Common::getGet('dir'), 'DESC');
     $this->orderby = $users->getMultiOrderby(Common::getGet('by'), Common::getGet('dir'));
     $this->nPages = GWF_PageMenu::getPagecount($this->upp, $this->nUsers);
     $this->page = Common::clamp((int) Common::getGet('page', 1), 1, $this->nPages);
     return false;
 }
Пример #29
0
 public function execute()
 {
     $_GET['ajax'] = 1;
     header('Content-Type: text/plain');
     if (false === ($date = Common::getGetString('datestamp', false))) {
         return 'Missing parameter: datestamp.';
     }
     if (!GWF_Time::isValidDate($date, false, GWF_Date::LEN_SECOND)) {
         return 'Error in parameter: datestamp.';
     }
     $amt = Common::clamp(Common::getGetInt('amt', 5), 1, self::MAX_OUT);
     return $this->templateOutput($date, $amt);
 }
Пример #30
0
 private function sanitize()
 {
     $this->user = GWF_Session::getUser();
     $this->table = GDO::table('GWF_AccountAccess');
     $where = "accacc_uid={$this->user->getID()}";
     $this->nItems = $this->table->countRows($where);
     $this->nPages = GWF_PageMenu::getPagecount($this->perpage, $this->nItems);
     $this->page = Common::clamp(Common::getGetInt('page'), 1, $this->nPages);
     $this->from = GWF_PageMenu::getFrom($this->page, $this->perpage);
     $this->by = $this->table->getWhitelistedBy(Common::getGetString('by', self::DEFAULT_BY), self::DEFAULT_BY);
     $this->dir = $this->table->getWhitelistedBy(Common::getGetString('dir', self::DEFAULT_DIR), self::DEFAULT_DIR);
     $this->result = $this->table->select('*', $where, "{$this->by} {$this->dir}", null, $this->perpage, $this->from);
 }