Issues (1369)

includes/alliance/ali_info.inc (5 issues)

1
<?php
2
3
use Alliance\AllianceHelper;
4
use Alliance\DBStaticAlly;
5
use DBAL\db_mysql;
6
7
if(!defined('SN_IN_ALLY') || SN_IN_ALLY !== true)
8
{
9
  $debug->error("Attempt to call ALLIANCE page mode {$mode} directly - not from alliance.php", 'Forbidden', 403);
10
}
11
12
$template = SnTemplate::gettemplate('ali_info', true);
0 ignored issues
show
true of type true is incompatible with the type null|template expected by parameter $template of SnTemplate::gettemplate(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

12
$template = SnTemplate::gettemplate('ali_info', /** @scrutinizer ignore-type */ true);
Loading history...
13
14
if($mode == 'exit')
15
{
16
  if ($ally['ally_owner'] == $user['id'])
17
  {
18
    SnTemplate::messageBox($lang['Owner_cant_go_out'], $lang['Alliance']);
19
  }
20
21
  if (sys_get_param_int('ali_info_leave_confirm'))
22
  {
23
    db_mysql::db_transaction_start();
24
    db_user_set_by_id($user['id'], "`ally_id` = null, `ally_name` = null, `ally_tag` = null, `ally_register_time` = 0, `ally_rank_id` = 0");
0 ignored issues
show
Deprecated Code introduced by
The function db_user_set_by_id() has been deprecated. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

24
    /** @scrutinizer ignore-deprecated */ db_user_set_by_id($user['id'], "`ally_id` = null, `ally_name` = null, `ally_tag` = null, `ally_register_time` = 0, `ally_rank_id` = 0");
Loading history...
25
    DBStaticAlly::db_ally_list_recalc_counts();
26
    db_mysql::db_transaction_commit();
27
    $lang['Go_out_welldone'] = str_replace("%s", $ally_name, $lang['Go_out_welldone']);
28
    SnTemplate::messageBox(sprintf($lang['ali_info_leave_success'], $ally['ally_name']), $lang['sys_alliance']);
29
  }
30
}
31
elseif($mode == 'ainfo')
32
{
33
  $tag = sys_get_param_str('tag');
34
  $id_ally = sys_get_param_id('a');
35
  if($tag)
36
  {
37
    $ally = doquery("SELECT * FROM {{alliance}} WHERE ally_tag='{$tag}' LIMIT 1;", '', true);
0 ignored issues
show
Deprecated Code introduced by
The function doquery() has been deprecated. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

37
    $ally = /** @scrutinizer ignore-deprecated */ doquery("SELECT * FROM {{alliance}} WHERE ally_tag='{$tag}' LIMIT 1;", '', true);
Loading history...
38
  }
39
  elseif($id_ally)
40
  {
41
    $ally = doquery("SELECT * FROM {{alliance}} WHERE id='{$id_ally}' LIMIT 1;", '', true);
0 ignored issues
show
Deprecated Code introduced by
The function doquery() has been deprecated. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

41
    $ally = /** @scrutinizer ignore-deprecated */ doquery("SELECT * FROM {{alliance}} WHERE id='{$id_ally}' LIMIT 1;", '', true);
Loading history...
42
  }
43
44
  if(!$ally)
45
  {
46
    SnTemplate::messageBox($lang['ali_sys_notFound'], $lang['Ally_info_1']);
47
  }
48
49
  if(!$ally['ally_description'])
50
  {
51
    $ally['ally_description'] = $lang['Ally_nodescription'];
52
  }
53
54
  $template->assign_vars(array(
55
    'EXTERNAL'     => true,
56
    'USER_ALLY_ID' => $user['ally_id'],
57
  ));
58
  $page_header          = $lang['sys_alliance'];
59
}
60
else
61
{
62
  $page_header = $lang['your_alliance'];
63
64
  if($ally['ally_owner'] == $user['id'])
65
  {
66
    $range = $ally['ally_owner_range'] ? $ally['ally_owner_range'] : $lang['Founder'];
67
  }
68
  elseif($user['ally_rank_id'] != 0 && isset($ranks[$user['ally_rank_id']]['name']))
69
  {
70
    $range = $ranks[$user['ally_rank_id']]['name'];
71
  }
72
  else
73
  {
74
    $range = $lang['member'];
75
  }
76
77
  $request = doquery("SELECT COUNT(*) AS request_count FROM {{alliance_requests}} WHERE `id_ally` ='{$ally['id']}'", '', true);
0 ignored issues
show
Deprecated Code introduced by
The function doquery() has been deprecated. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

77
  $request = /** @scrutinizer ignore-deprecated */ doquery("SELECT COUNT(*) AS request_count FROM {{alliance_requests}} WHERE `id_ally` ='{$ally['id']}'", '', true);
Loading history...
78
79
  $template->assign_vars(array(
80
    'range' => $range,
81
    'ALLY_REQUESTS' => $request['request_count'],
82
83
    'ALLY_ADMIN' => $user_admin,
84
    'ALLY_CAN_KICK' => $user_can_kick,
85
    'MASS_MAIL' => $user_can_send_mails,
86
    'MANAGE_REQUESTS' => $user_admin_applications,
87
    'ALLY_NEGOTIATE' => $user_can_negotiate,
88
  ));
89
}
90
91
$template->assign_vars([
92
  'ALLY_DESCRIPTION' => AllianceHelper::formatText($ally['ally_description']),
93
  'ALLY_TEXT'        => AllianceHelper::formatText($ally['ally_text']),
94
  'ally_id'          => $ally['id'],
95
  'ALLY_MEMBERS'     => $ally['ally_members'],
96
  'ally_web'         => $ally['ally_web'],
97
  'ally_tag'         => $ally['ally_tag'],
98
  'ally_image'       => $ally['ally_image'],
99
  'ally_name'        => $ally['ally_name'],
100
]);
101
102
$relations = ali_relations($ally['id']);
103
foreach($relations as $relation)
104
{
105
  if($relation['alliance_diplomacy_contr_ally_id'] && $relation['alliance_diplomacy_ally_id'])
106
  {
107
    $template->assign_block_vars('relation', array(
108
      'NAME'     => $relation['alliance_diplomacy_contr_ally_name'],
109
      'RELATION' => $lang['ali_dip_relations'][$relation['alliance_diplomacy_relation']],
110
      'TIME'     => date(FMT_DATE_TIME, $relation['alliance_diplomacy_time']),
111
    ));
112
  }
113
}
114
115
SN::$gc->pimp->allyInfoView();
116
117
SnTemplate::display($template, "{$lang['alliance']} [{$ally['ally_name']}]");
118