Issues (1369)

search.php (3 issues)

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
if(SN::$config->game_mode == GAME_BLITZ) {
16
  SnTemplate::messageBox($lang['sys_blitz_page_disabled'], $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 = SnTemplate::gettemplate('search', 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

26
$template = SnTemplate::gettemplate('search', /** @scrutinizer ignore-type */ true);
Loading history...
27
28
if($searchtext && $type)
29
{
30
  switch($type)
31
  {
32
    case "planetname":
33
      // $search = db_planet_list_search($searchtext);
34
    break;
35
36
    case "ally":
37
      $search = doquery("SELECT ally_name, ally_tag, total_rank, ally_members FROM {{alliance}} WHERE ally_tag LIKE '%{$searchtext}%' OR ally_name LIKE '%{$searchtext}%' LIMIT 30");
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
      $search = /** @scrutinizer ignore-deprecated */ doquery("SELECT ally_name, ally_tag, total_rank, ally_members FROM {{alliance}} WHERE ally_tag LIKE '%{$searchtext}%' OR ally_name LIKE '%{$searchtext}%' LIMIT 30");
Loading history...
38
    break;
39
40
    case "playername":
41
    default:
42
      $search = db_user_list_search($searchtext);
43
    break;
44
  }
45
46
  while($row = db_fetch($search))
0 ignored issues
show
Deprecated Code introduced by
The function db_fetch() 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

46
  while($row = /** @scrutinizer ignore-deprecated */ db_fetch($search))
Loading history...
47
  {
48
    if($type=='playername' || $type=='planetname')
49
    {
50
      $template->assign_block_vars('search_result', array(
51
        'PLAYER_ID' => $row['uid'],
52
        'PLAYER_NAME' => htmlentities($row['username'], ENT_COMPAT, 'UTF-8'),
53
        'PLAYER_NAME_OLD' => htmlentities($row['player_name'], ENT_COMPAT, 'UTF-8'),
54
        'PLAYER_RANK' => HelperString::numberFloorAndFormat($row['total_rank']),
55
        'PLAYER_RANK_RAW' => floatval($row['total_rank']),
56
        'PLANET_NAME' => htmlentities($row['planet_name'], ENT_COMPAT, 'UTF-8'),
57
        'PLANET_GALAXY' => $row['galaxy'],
58
        'PLANET_SYSTEM' => $row['system'],
59
        'PLANET_PLANET' => $row['planet'],
60
        'PLANET_TYPE' => $lang['sys_planet_type_sh'][$row['planet_type']],
61
        'ALLY_NAME' => htmlentities($row['ally_name'], ENT_COMPAT, 'UTF-8'),
62
        'ALLY_TAG' => htmlentities($row['ally_tag'], ENT_COMPAT, 'UTF-8'),
63
      ));
64
    }
65
    elseif($type=='ally')
66
    {
67
      $template->assign_block_vars('search_result', array(
68
        'ALLY_NAME' => htmlentities($row['ally_name'], ENT_COMPAT, 'UTF-8'),
69
        'ALLY_TAG' => htmlentities($row['ally_tag'], ENT_COMPAT, 'UTF-8'),
70
        'ALLY_RANK' => HelperString::numberFloorAndFormat($row['total_rank']),
71
        'ALLY_RANK_RAW' => floatval($row['total_rank']),
72
        'ALLY_MEMBERS' => HelperString::numberFloorAndFormat($row['ally_members']),
73
      ));
74
    }
75
  }
76
}
77
78
$search_type = array(
79
  'playername' => 'srch_player_name',
80
//  'planetname' => 'srch_planet_name',
81
  'ally' => 'sys_alliance',
82
);
83
84
foreach($search_type as $type_id => $type_lang)
85
{
86
  $template->assign_block_vars('type', array(
87
    'ID' => $type_id,
88
    'TEXT' => $lang[$type_lang],
89
    'SELECTED' => $type_id == $type,
90
  ));
91
}
92
93
$template->assign_vars(array(
94
  'PAGE_HEADER' => $lang['Search'],
95
  'PAGE_HINT' => $lang['srch_page_hint'],
96
  'TEXT' => $searchtext,
97
  'IS_ALLY' => $type == 'ally',
98
  'STATS_HIDE_PM_LINK' => SN::$config->stats_hide_pm_link,
99
));
100
101
SnTemplate::display($template);
102