These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /** |
||
3 | * search.php |
||
4 | * |
||
5 | * 1.3 copyright (c) 2009-2010 by Gorlum for http://supernova.ws |
||
6 | * [%] Fixed search of players without alliance |
||
7 | * 1.2 - Security checks & tests by Gorlum for http://supernova.ws |
||
8 | * @version 1.1 |
||
9 | * @copyright 2009 by angelus_ira for Project. XNova |
||
10 | * @copyright 2008 by ??????? for XNova |
||
11 | */ |
||
12 | |||
13 | include('common.' . substr(strrchr(__FILE__, '.'), 1)); |
||
14 | |||
15 | View Code Duplication | if(classSupernova::$config->game_mode == GAME_BLITZ) { |
|
0 ignored issues
–
show
|
|||
16 | message(classLocale::$lang['sys_blitz_page_disabled'], classLocale::$lang['sys_error'], 'overview.php', 10); |
||
17 | die(); |
||
18 | } |
||
19 | |||
20 | lng_include('search'); |
||
21 | |||
22 | $searchtext = sys_get_param_str('searchtext'); |
||
23 | $type = sys_get_param_str('type'); |
||
24 | |||
25 | |||
26 | $template = gettemplate('search', true); |
||
27 | |||
28 | if($searchtext && $type) { |
||
29 | switch($type) { |
||
30 | case "planetname": |
||
31 | // $search = db_planet_list_search($searchtext); |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
50% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
32 | break; |
||
33 | |||
34 | case "ally": |
||
35 | $search = DBStaticAlly::db_ally_list_search($searchtext); |
||
36 | break; |
||
37 | |||
38 | case "playername": |
||
39 | default: |
||
40 | $search = db_user_list_search($searchtext); |
||
41 | break; |
||
42 | } |
||
43 | |||
44 | while($row = db_fetch($search)) { |
||
45 | if($type == 'playername' || $type == 'planetname') { |
||
46 | $template->assign_block_vars('search_result', array( |
||
47 | 'PLAYER_ID' => $row['uid'], |
||
48 | 'PLAYER_NAME' => htmlentities($row['username'], ENT_COMPAT, 'UTF-8'), |
||
49 | 'PLAYER_NAME_OLD' => htmlentities($row['player_name'], ENT_COMPAT, 'UTF-8'), |
||
50 | 'PLAYER_RANK' => pretty_number($row['total_rank']), |
||
51 | 'PLAYER_RANK_RAW' => floatval($row['total_rank']), |
||
52 | 'PLANET_NAME' => htmlentities($row['planet_name'], ENT_COMPAT, 'UTF-8'), |
||
53 | 'PLANET_GALAXY' => $row['galaxy'], |
||
54 | 'PLANET_SYSTEM' => $row['system'], |
||
55 | 'PLANET_PLANET' => $row['planet'], |
||
56 | 'PLANET_TYPE' => classLocale::$lang['sys_planet_type_sh'][$row['planet_type']], |
||
57 | 'ALLY_NAME' => htmlentities($row['ally_name'], ENT_COMPAT, 'UTF-8'), |
||
58 | 'ALLY_TAG' => htmlentities($row['ally_tag'], ENT_COMPAT, 'UTF-8'), |
||
59 | )); |
||
60 | } elseif($type == 'ally') { |
||
61 | $template->assign_block_vars('search_result', array( |
||
62 | 'ALLY_NAME' => htmlentities($row['ally_name'], ENT_COMPAT, 'UTF-8'), |
||
63 | 'ALLY_TAG' => htmlentities($row['ally_tag'], ENT_COMPAT, 'UTF-8'), |
||
64 | 'ALLY_RANK' => pretty_number($row['total_rank']), |
||
65 | 'ALLY_RANK_RAW' => floatval($row['total_rank']), |
||
66 | 'ALLY_MEMBERS' => pretty_number($row['ally_members']), |
||
67 | )); |
||
68 | } |
||
69 | } |
||
70 | } |
||
71 | |||
72 | $search_type = array( |
||
73 | 'playername' => 'srch_player_name', |
||
74 | // 'planetname' => 'srch_planet_name', |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
58% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
75 | 'ally' => 'sys_alliance', |
||
76 | ); |
||
77 | |||
78 | foreach($search_type as $type_id => $type_lang) { |
||
79 | $template->assign_block_vars('type', array( |
||
80 | 'ID' => $type_id, |
||
81 | 'TEXT' => classLocale::$lang[$type_lang], |
||
82 | 'SELECTED' => $type_id == $type, |
||
83 | )); |
||
84 | } |
||
85 | |||
86 | $template->assign_vars(array( |
||
87 | 'PAGE_HEADER' => classLocale::$lang['Search'], |
||
88 | 'PAGE_HINT' => classLocale::$lang['srch_page_hint'], |
||
89 | 'TEXT' => $searchtext, |
||
90 | 'IS_ALLY' => $type == 'ally', |
||
91 | 'STATS_HIDE_PM_LINK' => classSupernova::$config->stats_hide_pm_link, |
||
92 | )); |
||
93 | |||
94 | display($template); |
||
95 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.