PageRenderTime 51ms CodeModel.GetById 30ms RepoModel.GetById 0ms app.codeStats 0ms

/modules/ranking/character.php

https://github.com/chokoleytdesignoper/fluxcp_choko
PHP | 47 lines | 36 code | 11 blank | 0 comment | 8 complexity | c2547bb5bb41246826e527febe2a084c MD5 | raw file
Possible License(s): LGPL-2.1, LGPL-3.0, BSD-3-Clause
  1. <?php
  2. if (!defined('FLUX_ROOT')) exit;
  3. $title = 'Character Ranking';
  4. $classes = Flux::config('JobClasses')->toArray();
  5. $jobClass = $params->get('jobclass');
  6. $bind = array((int)Flux::config('RankingHideLevel'));
  7. if (!is_null($jobClass) && !array_key_exists($jobClass, $classes)) {
  8. $this->deny();
  9. }
  10. $col = "ch.char_id, ch.name AS char_name, ch.class AS char_class, ch.base_level, ch.base_exp, ch.job_level, ch.job_exp, ";
  11. $col .= "ch.guild_id, guild.name AS guild_name, guild.emblem_len AS guild_emblem_len";
  12. $sql = "SELECT $col FROM {$server->charMapDatabase}.`char` AS ch ";
  13. $sql .= "LEFT JOIN {$server->charMapDatabase}.guild ON guild.guild_id = ch.guild_id ";
  14. $sql .= "LEFT JOIN {$server->loginDatabase}.login ON login.account_id = ch.account_id ";
  15. $sql .= "WHERE 1=1 ";
  16. if (Flux::config('HidePermBannedCharRank')) {
  17. $sql .= "AND login.state != 5 ";
  18. }
  19. if (Flux::config('HideTempBannedCharRank')) {
  20. $sql .= "AND (login.unban_time IS NULL OR login.unban_time = 0) ";
  21. }
  22. $sql .= "AND login.level < ? ";
  23. if ($days=Flux::config('CharRankingThreshold')) {
  24. $sql .= 'AND (UNIX_TIMESTAMP() - UNIX_TIMESTAMP(login.lastlogin)) <= ? ';
  25. $bind[] = $days * 24 * 60 * 60;
  26. }
  27. if (!is_null($jobClass)) {
  28. $sql .= "AND ch.class = ? ";
  29. $bind[] = $jobClass;
  30. }
  31. $sql .= "ORDER BY ch.base_level DESC, ch.job_level DESC, ch.base_exp DESC, ch.job_exp DESC, ch.char_id ASC ";
  32. $sql .= "LIMIT ".(int)Flux::config('CharRankingLimit');
  33. $sth = $server->connection->getStatement($sql);
  34. $sth->execute($bind);
  35. $chars = $sth->fetchAll();
  36. ?>