supernova-ws /
SuperNova
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | |||
| 3 | include('common.' . substr(strrchr(__FILE__, '.'), 1)); |
||
| 4 | |||
| 5 | View Code Duplication | if(classSupernova::$config->game_mode == GAME_BLITZ) { |
|
|
0 ignored issues
–
show
|
|||
| 6 | message(classLocale::$lang['sys_blitz_page_disabled'], classLocale::$lang['sys_error'], 'overview.php', 10); |
||
| 7 | die(); |
||
| 8 | } |
||
| 9 | |||
| 10 | define('SN_IN_ALLY', true); |
||
| 11 | |||
| 12 | // Main admin page save themes |
||
| 13 | lng_include('alliance'); |
||
| 14 | |||
| 15 | $mode = sys_get_param_str('mode'); |
||
| 16 | |||
| 17 | if($mode == 'ainfo') { |
||
| 18 | include('includes/alliance/ali_info.inc'); |
||
| 19 | } |
||
| 20 | |||
| 21 | if(!$user['ally_id']) { |
||
| 22 | $user_request = DBStaticAlly::db_ally_request_get_by_user_id($user['id']); |
||
| 23 | if($user_request['id_user']) { |
||
| 24 | require('includes/alliance/ali_external_request.inc'); |
||
| 25 | } else { |
||
| 26 | switch($mode) { |
||
| 27 | case 'search': |
||
| 28 | require('includes/alliance/ali_external_search.inc'); |
||
| 29 | break; |
||
| 30 | |||
| 31 | case 'apply': |
||
| 32 | require('includes/alliance/ali_external_request.inc'); |
||
| 33 | break; |
||
| 34 | |||
| 35 | case 'make': |
||
| 36 | require('includes/alliance/ali_external_create_ally.inc'); |
||
| 37 | break; |
||
| 38 | |||
| 39 | default: |
||
| 40 | display(parsetemplate(gettemplate('ali_external', true)), classLocale::$lang['alliance']); |
||
| 41 | break; |
||
| 42 | } |
||
| 43 | } |
||
| 44 | } |
||
| 45 | |||
| 46 | sn_ali_fill_user_ally($user); |
||
| 47 | if(!isset($user['ally'])) { |
||
| 48 | DBStaticUser::db_user_set_by_id( |
||
| 49 | $user['id'], |
||
| 50 | array( |
||
| 51 | 'ally_id' => null, |
||
| 52 | 'ally_name' => null, |
||
| 53 | 'ally_register_time' => 0, |
||
| 54 | 'ally_rank_id' => 0, |
||
| 55 | ) |
||
| 56 | ); |
||
| 57 | message(classLocale::$lang['ali_sys_notFound'], classLocale::$lang['your_alliance'], 'alliance.php'); |
||
| 58 | } |
||
| 59 | $ally = &$user['ally']; |
||
| 60 | /* |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
56% 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. Loading history...
|
|||
| 61 | $ally_rights = array( |
||
| 62 | 0 => 'name', |
||
| 63 | 1 => 'mail', |
||
| 64 | 2 => 'online', |
||
| 65 | 3 => 'invite', |
||
| 66 | 4 => 'kick', |
||
| 67 | 5 => 'admin', |
||
| 68 | 6 => 'forum', |
||
| 69 | 7 => 'diplomacy' |
||
| 70 | ); |
||
| 71 | */ |
||
| 72 | $rights_old = array( |
||
| 73 | 0 => 'name', |
||
| 74 | 1 => 'mails', |
||
| 75 | 2 => 'onlinestatus', |
||
| 76 | 3 => 'bewerbungenbearbeiten', |
||
| 77 | 4 => 'kick', |
||
| 78 | 5 => 'rechtehand' |
||
| 79 | ); |
||
| 80 | |||
| 81 | // This piece converting old ally data to new one |
||
| 82 | // unset($ally['ranklist']); |
||
| 83 | if(!$ally['ranklist'] && $ally['ally_ranks']) { |
||
| 84 | $ally_ranks = unserialize($ally['ally_ranks']); |
||
| 85 | $i = 0; |
||
| 86 | foreach($ally_ranks as $rank_id => $rank) { |
||
| 87 | foreach($ally_rights as $key => $value) { |
||
| 88 | $ranks[$i][$value] = $rank[$rights_old[$key]]; |
||
| 89 | } |
||
| 90 | classSupernova::$gc->cacheOperator->db_upd_record_list( |
||
|
0 ignored issues
–
show
The method
db_upd_record_list does only exist in SnDbCachedOperator, but not in Closure.
It seems like the method you are trying to call exists only in some of the possible types. Let’s take a look at an example: class A
{
public function foo() { }
}
class B extends A
{
public function bar() { }
}
/**
* @param A|B $x
*/
function someFunction($x)
{
$x->foo(); // This call is fine as the method exists in A and B.
$x->bar(); // This method only exists in B and might cause an error.
}
Available Fixes
Loading history...
|
|||
| 91 | LOC_USER, |
||
| 92 | array( |
||
| 93 | 'ally_rank_id' => $i, |
||
| 94 | ), |
||
| 95 | array(), |
||
| 96 | array( |
||
| 97 | 'ally_id' => $user['ally_id'], |
||
| 98 | 'ally_rank_id' => $rank_id, |
||
| 99 | ) |
||
| 100 | ); |
||
| 101 | |||
| 102 | $i++; |
||
| 103 | } |
||
| 104 | |||
| 105 | if(!empty($ranks)) { |
||
| 106 | ali_rank_list_save($ranks); |
||
| 107 | } |
||
| 108 | } |
||
| 109 | |||
| 110 | $ranks = ally_get_ranks($ally); |
||
| 111 | |||
| 112 | $isAllyOwner = $ally['ally_owner'] == $user['id']; |
||
| 113 | $user_can_send_mails = $ranks[$user['ally_rank_id']]['mail'] || $isAllyOwner; |
||
| 114 | $userCanPostForum = $ranks[$user['ally_rank_id']]['forum'] || $isAllyOwner; |
||
| 115 | $user_onlinestatus = $ranks[$user['ally_rank_id']]['online'] || $isAllyOwner; |
||
| 116 | $user_admin_applications = $ranks[$user['ally_rank_id']]['invite'] || $isAllyOwner; |
||
| 117 | $user_can_kick = $ranks[$user['ally_rank_id']]['kick'] || $isAllyOwner; |
||
| 118 | $user_can_negotiate = $ranks[$user['ally_rank_id']]['diplomacy'] || $isAllyOwner; |
||
| 119 | $user_can_edit_rights = $user_admin = $ranks[$user['ally_rank_id']]['admin'] || $isAllyOwner; |
||
| 120 | |||
| 121 | $edit = sys_get_param_str('edit'); |
||
| 122 | ally_pre_call(); |
||
| 123 | switch($mode) { |
||
| 124 | case 'admin': |
||
| 125 | if(!array_key_exists($edit, $sn_ali_admin_internal)) { |
||
| 126 | $edit = 'default'; |
||
| 127 | } |
||
| 128 | if($sn_ali_admin_internal[$edit]['include']) { |
||
| 129 | require("includes/{$sn_ali_admin_internal[$edit]['include']}"); |
||
| 130 | } |
||
| 131 | if(isset($sn_ali_admin_internal[$edit]['function']) && is_callable($sn_ali_admin_internal[$edit]['function'])) { |
||
| 132 | call_user_func($sn_ali_admin_internal[$edit]['function']); |
||
| 133 | } |
||
| 134 | break; |
||
| 135 | |||
| 136 | case 'memberslist': |
||
| 137 | require('includes/alliance/ali_internal_members.inc'); |
||
| 138 | break; |
||
| 139 | case 'circular': |
||
| 140 | require('includes/alliance/ali_internal_admin_mail.inc'); |
||
| 141 | break; |
||
| 142 | default: |
||
| 143 | require('includes/alliance/ali_info.inc'); |
||
| 144 | break; |
||
| 145 | } |
||
| 146 | |||
| 147 | function ally_pre_call() { |
||
| 148 | $func_args = func_get_args(); |
||
| 149 | |||
| 150 | return sn_function_call(__FUNCTION__, $func_args); |
||
| 151 | } |
||
| 152 |
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.