PageRenderTime 87ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/modules/ranking/zeny.php

https://github.com/chokoleytdesignoper/fluxcp_choko
PHP | 56 lines | 42 code | 13 blank | 1 comment | 8 complexity | 68b6ed9dc946bbbbb872fb0b84c7048f 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 = 'Zeny 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. $charPrefsTable = Flux::config('FluxTables.CharacterPrefsTable');
  11. $col = "ch.char_id, ch.name AS char_name, ch.zeny, ch.class AS char_class, ch.base_level, ch.base_exp, ch.job_level, ch.job_exp, ";
  12. $col .= "ch.guild_id, guild.name AS guild_name, guild.emblem_len AS guild_emblem_len";
  13. $sql = "SELECT $col FROM {$server->charMapDatabase}.`char` AS ch ";
  14. $sql .= "LEFT JOIN {$server->charMapDatabase}.$charPrefsTable AS hide_from_zr ON ";
  15. $sql .= "(hide_from_zr.name = 'HideFromZenyRanking' AND hide_from_zr.char_id = ch.char_id) ";
  16. $sql .= "LEFT JOIN {$server->charMapDatabase}.guild ON guild.guild_id = ch.guild_id ";
  17. $sql .= "LEFT JOIN {$server->loginDatabase}.login ON login.account_id = ch.account_id ";
  18. $sql .= "WHERE 1=1 ";
  19. if (Flux::config('HidePermBannedZenyRank')) {
  20. $sql .= "AND login.state != 5 ";
  21. }
  22. if (Flux::config('HideTempBannedZenyRank')) {
  23. $sql .= "AND (login.unban_time IS NULL OR login.unban_time = 0) ";
  24. }
  25. $sql .= "AND login.level < ? ";
  26. if ($days=Flux::config('ZenyRankingThreshold')) {
  27. $sql .= 'AND (UNIX_TIMESTAMP() - UNIX_TIMESTAMP(login.lastlogin)) <= ? ';
  28. $bind[] = $days * 24 * 60 * 60;
  29. }
  30. // Whether or not the character is allowed to hide themselves from the Zeny Ranking.
  31. $sql .= "AND (((hide_from_zr.value IS NULL OR hide_from_zr.value = 0) AND login.level >= ?) OR login.level < ?) ";
  32. $bind[] = $auth->getLevelToHideFromZenyRank;
  33. $bind[] = $auth->getLevelToHideFromZenyRank;
  34. if (!is_null($jobClass)) {
  35. $sql .= "AND ch.class = ? ";
  36. $bind[] = $jobClass;
  37. }
  38. $sql .= "ORDER BY ch.zeny DESC, ch.base_level DESC, ch.base_exp DESC, ch.job_level DESC, ch.job_exp DESC, ch.char_id ASC ";
  39. $sql .= "LIMIT ".(int)Flux::config('ZenyRankingLimit');
  40. $sth = $server->connection->getStatement($sql);
  41. $sth->execute($bind);
  42. $chars = $sth->fetchAll();
  43. ?>