Failed Conditions
Pull Request — master (#368)
by
unknown
02:34
created

index.php (1 issue)

Upgrade to new PHP Analysis Engine

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_once('config.php');
4
include_once('functions.php');
5
include_once('core/process/data.loader.php');
6
7
function menuitems($menu, $level) {
8
9
	global $locales;
10
	
11
	if (isset($menu->locale)) {
12
		$locale = $menu->locale;
13
		$text	= $locales->$locale;
14
	} elseif (isset($menu->text)) {
15
		$text	= $menu->text;
16
	}
17
18
	switch ($menu->type) {
19
		case 'group':
20
			?>
21
			
22
			<li>
23
			<a class="menu-label"><i class="fa <?= $menu->icon ?>" aria-hidden="true"></i> <?= $text ?></a>
0 ignored issues
show
The variable $text does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
24
			<ul class="dropdown">
25
			
26
			<?php 
27
			foreach ($menu->members as $childmenu) { 
28
				menuitems($childmenu, $level + 1);
29
			}
30
			?>
31
			
32
			</ul>
33
			</li>
34
35
			<?php
36
			break;
37
		case 'link':
38
			?>
39
40
			<li>
41
				<a href="<?= $menu->href ?>" class="menu-label"><i class="fa <?= $menu->icon ?>" aria-hidden="true"></i> <?= $text ?></a>
42
			</li>
43
44
			<?php
45
			break;
46
47
		case 'link_external':
48
			?>
49
50
			<li>
51
				<a href="<?= $menu->href ?>" target="_blank" class="menu-label"><i class="fa <?= $menu->icon ?>" aria-hidden="true"></i> <?= $menu->text ?></a>
52
			</li>
53
54
			<?php
55
			break;
56
57
		case 'html':
58
			?>
59
60
			<li> <?= $menu->value ?> </li>
61
62
			<?php
63
			break;
64
	}	
65
}
66
67
?>
68
69
<!DOCTYPE html>
70
<html>
71
	<head>
72
		<meta charset="utf-8">
73
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
74
		<meta name="viewport" content="width=device-width, initial-scale=1">
75
76
		<?php include_once('core/inc/meta.inc.php') ?>
77
78
		<!-- Bootstrap -->
79
		<link href="core/css/bootstrap.min.css" rel="stylesheet">
80
		<link href="https://fonts.googleapis.com/css?family=Lato:400,300,700" rel="stylesheet" type="text/css">
81
		<link href="core/css/font-awesome.min.css" rel="stylesheet">
82
		<link href="<?php auto_ver('core/css/style.css'); ?>" rel="stylesheet">
83
		<?php if ($page == "pokemon") { ?>
84
			<link href="<?php auto_ver('core/css/jQRangeSlider-bootstrap.min.css'); ?>" rel="stylesheet">
85
		<?php } ?>
86
	</head>
87
	<body id="page-top" data-spy="scroll" data-target=".navbar-fixed-top">
88
89
		<?php
90
		// Google Analytics
91
		if (is_file("analyticstracking.php")) {
92
			include_once("analyticstracking.php");
93
		}
94
		?>
95
96
		<nav class="navbar navbar-default navbar-fixed-top">
97
			<div class="container">
98
				<!-- Brand and toggle get grouped for better mobile display -->
99
				<div class="navbar-header">
100
					<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#menu" aria-expanded="false">
101
						<span class="sr-only">Toggle navigation</span>
102
						<span class="icon-bar"></span>
103
						<span class="icon-bar"></span>
104
						<span class="icon-bar"></span>
105
					</button>
106
					<a class="navbar-brand" href="<?= HOST_URL ?>"><img src="<?= $config->infos->logo_path ?>" width="25" style="display:inline-block;" alt="<?= $config->infos->site_name ?>" id="logo-img" /> <?= $config->infos->site_name ?></a>
107
				</div>
108
109
				<!-- Collect the nav links, forms, and other content for toggling -->
110
				<div class="collapse navbar-collapse" id="menu">
111
					<ul class="nav navbar-nav navbar-right">
112
113
						<?php
114
						if (!isset($config->menu)) {
115
							echo "Please update variables.json file with menu values";
116
							exit();
117
						}
118
119
						foreach ($config->menu as $menu) {
120
							
121
							menuitems($menu, 1);
122
123
						}
124
						?>
125
126
					</ul>
127
				</div> <!-- /.navbar-collapse -->
128
			</div> <!-- /.container-fluid -->
129
		</nav>
130
131
		<div class="container">
132
			<?php
133
			# Include the pages
134
			if (!empty($_GET['page'])) {
135
				$file = SYS_PATH.'/pages/'.$page.'.page.php';
136
137
				if (is_file($file)) {
138
					echo '<!-- Page :: '.$page.' -->';
139
					include($file);
140
				} else {
141
					include('pages/home.page.php');
142
				}
143
			} else {
144
				include('pages/home.page.php');
145
			}
146
147
			?>
148
		</div>
149
150
		<footer>
151
			<div class="container">
152
				<div class="row">
153
					<div class="col-md-12 text-center">
154
						<img src="core/img/logo.png" width=50 class="big-icon" alt="Brusselopole icon">
155
						<h2><?= $locales->FOOTER_TITLE ?></h2>
156
						<p><?= $locales->FOOTER_SUB ?></p>
157
						<?= $locales->FOOTER_VISUAL_CONTENT ?>
158
						<p><?= $locales->FOOTER_MADE_BY ?></p>
159
						<h3>Pokémon™</h3>
160
						<?= $locales->FOOTER_POKEMON_CONTENT ?>
161
					</div>
162
				</div>
163
			</div>
164
		</footer>
165
166
		<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
167
		<script src="core/js/bootstrap.min.js"></script>
168
169
		<?php // Load scripts only for page
170
		if (empty($page)) { ?>
171
172
			<script src="<?php auto_ver('core/js/home.script.js') ?>"></script>
173
174
			<script>
175
				updateCounter(<?= $home->pokemon_now ?>,'.total-pkm-js');
176
				updateCounter(<?= $home->pokestop_lured ?>,'.total-lure-js');
177
				updateCounter(<?= $home->active_raids ?>,'.total-raids-js');
178
				updateCounter(<?= $home->gyms ?>,'.total-gym-js');
179
180
				updateCounter(<?= $home->teams->valor ?>,'.total-valor-js');
181
				updateCounter(<?= $home->teams->mystic ?>,'.total-mystic-js');
182
				updateCounter(<?= $home->teams->instinct ?>,'.total-instinct-js');
183
				updateCounter(<?= $home->teams->rocket ?>,'.total-rocket-js');
184
			</script>
185
		<?php
186
		} else {
187
			switch ($page) {
188
				case 'pokemon':
189
					?>
190
191
					<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.5.0/Chart.min.js"></script>
192
					<script src="core/js/pokemon.graph.js.php?id=<?= $pokemon_id ?>"></script>
193
194
					<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
195
					<script src="<?php auto_ver('core/js/jQAllRangeSliders-withRuler.min.js') ?>"></script>
196
					<script src="<?php auto_ver('core/js/pokemon.maps.js') ?>"></script>
197
					<script>
198
						var pokemon_id = <?= $pokemon_id ?>;
199
					</script>
200
					<script src="https://maps.googleapis.com/maps/api/js?key=<?= $config->system->GMaps_Key ?>&libraries=visualization&callback=initMap&v=3"></script>
201
202
					<?php
203
					break;
204
205
				case 'pokestops':
206
					?>
207
208
					<script src="<?php auto_ver('core/js/pokestops.maps.js') ?>"></script>
209
					<script src="https://maps.googleapis.com/maps/api/js?key=<?= $config->system->GMaps_Key ?>&libraries=visualization&callback=initMap&v=3"></script>
210
211
					<?php
212
					break;
213
214
				case 'gym':
215
					?>
216
217
					<script src="<?php auto_ver('core/js/gym.script.js') ?>"></script>
218
					<script>
219
						updateCounter(<?= $teams->valor->gym_owned ?>,'.gym-valor-js');
220
						updateCounter(<?= $teams->valor->average ?>,'.average-valor-js');
221
222
						updateCounter(<?= $teams->instinct->gym_owned ?>,'.gym-instinct-js');
223
						updateCounter(<?= $teams->instinct->average ?>,'.average-instinct-js');
224
225
						updateCounter(<?= $teams->mystic->gym_owned ?>,'.gym-mystic-js');
226
						updateCounter(<?= $teams->mystic->average ?>,'.average-mystic-js');
227
					</script>
228
229
					<script src="<?php auto_ver('core/js/gym.maps.js') ?>"></script>
230
					<script src="https://maps.googleapis.com/maps/api/js?key=<?= $config->system->GMaps_Key ?>&libraries=visualization&callback=initMap&v=3"></script>
231
232
					<?php
233
					break;
234
235
				case 'pokedex':
236
					?>
237
238
					<script src="core/js/holmes.min.js"></script>
239
					<script>
240
						// holmes setup
241
						var h = new holmes({
242
							input: '.search input',
243
							find: '.results .pokemon-single',
244
							placeholder: '<h3>— No results, my dear Ash. —</h3>',
245
							class: {
246
								visible: 'visible',
247
								hidden: 'hidden'
248
							}
249
						});
250
					</script>
251
252
					<?php
253
					break;
254
255
				case 'dashboard':
256
					?>
257
258
					<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.5.0/Chart.min.js"></script>
259
					<script src="core/js/dashboard.graph.js.php"></script>
260
261
					<?php
262
					break;
263
264
				case 'trainer':
265
					?>
266
267
					<script src="<?php auto_ver('core/js/trainer.content.js') ?>"></script>
268
					<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.5.0/Chart.min.js"></script>
269
					<script src="core/js/trainer.graph.js.php"></script>
270
271
					<?php
272
					break;
273
274
				case 'nests':
275
					?>
276
277
					<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.countdown/2.2.0/jquery.countdown.min.js"></script>
278
					<script src="core/js/nests.maps.js.php"></script>
279
					<script src="https://maps.googleapis.com/maps/api/js?key=<?= $config->system->GMaps_Key ?>&libraries=visualization&callback=initMap&v=3"></script>
280
281
					<?php
282
					break;
283
284
				case 'raids':
285
					?>
286
287
					<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.countdown/2.2.0/jquery.countdown.min.js"></script>
288
					<script src="<?php auto_ver('core/js/raids.content.js') ?>"></script>
289
290
					<?php
291
					break;
292
293
				case 'gymhistory':
294
					?>
295
296
					<script src="<?php auto_ver('core/js/gymhistory.content.js') ?>"></script>
297
298
					<?php
299
					break;
300
			}
301
		}
302
		?>
303
304
	</body>
305
</html>
306