Completed
Push — master ( bb7cb4...4a054a )
by mains
02:45
created

index.php (14 issues)

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
	include 'php/jodel-web.php';
3
	$posts;
4
	
5
	//Get Post Details
6
	if(isset($_GET['postId']) && isset($_GET['getPostDetails']))
7
	{
8
		$userHandleBuffer = [];
9
10
		$accountCreator = new GetPostDetails();
11
		$accountCreator->setAccessToken($jodelAccountForView->accessToken);
12
		$data = $accountCreator->execute();
13
14
		if(array_key_exists('status_code', $data) && $data->status_code == 404)
15
		{
16
			header('HTTP/1.1 410 Gone');
17
			include './error-pages/410.php';
18
			exit;
19
		}
20
21
		$posts[0] = $data;
22
23
		if(array_key_exists('children', $data)) {
24
			foreach($data['children'] as $key => $child)
25
			{
26
				
27
				if(!$child["parent_creator"] == 1)
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal parent_creator does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
28
				{
29
					$numberForUser = array_search($child['user_handle'], $userHandleBuffer);
30
					if($numberForUser === FALSE)
31
					{
32
						array_push($userHandleBuffer, $child['user_handle']);
33
						$data['children'][$key]['user_handle'] = count($userHandleBuffer);
34
					}
35
					else
36
					{
37
						$data['children'][$key]['user_handle'] = $numberForUser + 1;
38
					}
39
				}
40
41
				array_push($posts, $data['children'][$key]);
42
			}
43
		}
44
	}
45
	//Get Posts and Hashtags
46
	else
47
	{
48
		$posts = $view->getPosts($jodelAccountForView);
49
	}
50
	if(!isset($posts[0]))
51
	{
52
		error_log('Fehler: ' . print_r($object, true));
53
	}
54
?>
55
<!DOCTYPE html>
56
<html lang="en">
57
	<head>
58
		<title><?php echo $view->getTitle($posts[0]);?></title>
59
		
60
		<meta charset="utf-8">
61
		<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
62
		<meta http-equiv="x-ua-compatible" content="ie=edge">
63
		
64
		<meta name="description" content="<?php echo $view->getMetaDescription($posts[0]);?>">
65
		<meta name="keywords" content="jodelblue, jodel, blue, webclient, web, client, web-app, browser, app">
66
		
67
		<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.5/css/bootstrap.min.css" integrity="sha384-AysaV+vQoT3kOAXZkl02PThvDr8HYKPZhNT5h/CXfBThSRXQ6jW5DO2ekP5ViFdi" crossorigin="anonymous">
0 ignored issues
show
This line exceeds maximum limit of 120 characters; contains 218 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
68
		<link rel="stylesheet" href="<?php echo $baseUrl;?>css/font-awesome.min.css">
69
		<link rel="stylesheet" href="<?php echo $baseUrl;?>style.css" type="text/css">
70
		
71
		<link rel="shortcut icon" type="image/x-icon" href="<?php echo $baseUrl;?>img/favicon/favicon.ico">
72
		<link rel="icon" type="image/x-icon" href="<?php echo $baseUrl;?>img/favicon/favicon.ico">
73
		<link rel="icon" type="image/gif" href="<?php echo $baseUrl;?>img/favicon/favicon.gif">
74
		<link rel="icon" type="image/png" href="<?php echo $baseUrl;?>img/favicon/favicon.png">
75
		<link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon.png">
76
		<link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon-57x57.png" sizes="57x57">
77
		<link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon-60x60.png" sizes="60x60">
78
		<link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon-72x72.png" sizes="72x72">
79
		<link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon-76x76.png" sizes="76x76">
80
		<link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon-114x114.png" sizes="114x114">
81
		<link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon-120x120.png" sizes="120x120">
82
		<link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon-128x128.png" sizes="128x128">
83
		<link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon-144x144.png" sizes="144x144">
84
		<link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon-152x152.png" sizes="152x152">
85
		<link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon-180x180.png" sizes="180x180">
86
		<link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon-precomposed.png">
87
		<link rel="icon" type="image/png" href="<?php echo $baseUrl;?>img/favicon/favicon-16x16.png" sizes="16x16">
88
		<link rel="icon" type="image/png" href="<?php echo $baseUrl;?>img/favicon/favicon-32x32.png" sizes="32x32">
89
		<link rel="icon" type="image/png" href="<?php echo $baseUrl;?>img/favicon/favicon-96x96.png" sizes="96x96">
90
		<link rel="icon" type="image/png" href="<?php echo $baseUrl;?>img/favicon/favicon-160x160.png" sizes="160x160">
91
		<link rel="icon" type="image/png" href="<?php echo $baseUrl;?>img/favicon/favicon-192x192.png" sizes="192x192">
92
		<link rel="icon" type="image/png" href="<?php echo $baseUrl;?>img/favicon/favicon-196x196.png" sizes="196x196">
93
		<meta name="msapplication-TileImage" content="<?php echo $baseUrl;?>img/favicon/win8-tile-144x144.png"> 
94
		<meta name="msapplication-TileColor" content="#5682a3"> 
95
		<meta name="msapplication-navbutton-color" content="#5682a3"> 
96
		<meta name="application-name" content="JodelBlue"/> 
97
		<meta name="msapplication-tooltip" content="JodelBlue"/> 
98
		<meta name="apple-mobile-web-app-title" content="JodelBlue"/> 
99
		<meta name="msapplication-square70x70logo" content="<?php echo $baseUrl;?>img/favicon/win8-tile-70x70.png"> 
100
		<meta name="msapplication-square144x144logo" content="<?php echo $baseUrl;?>img/favicon/win8-tile-144x144.png"> 
101
		<meta name="msapplication-square150x150logo" content="<?php echo $baseUrl;?>img/favicon/win8-tile-150x150.png"> 
102
		<meta name="msapplication-wide310x150logo" content="<?php echo $baseUrl;?>img/favicon/win8-tile-310x150.png"> 
103
		<meta name="msapplication-square310x310logo" content="<?php echo $baseUrl;?>img/favicon/win8-tile-310x310.png"> 
104
	</head>
105
	
106
	<body>
107
		<header>
108
			<nav class="navbar navbar-full navbar-dark navbar-fixed-top">
109
				<div class="container">					
110
						<?php
111
112
							if(isset($_GET['postId']) && isset($_GET['getPostDetails']))
113
							{
114
								echo '<a id="comment-back" href="index.php?view=' . $view->view . '#postId-' . htmlspecialchars($_GET['postId']) . '">';
0 ignored issues
show
This line exceeds maximum limit of 120 characters; contains 128 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
115
								echo '<i class="fa fa-angle-left fa-3x"></i>';
116
								echo '</a>';
117
								echo '<h1>';
118
								echo '<a href="index.php?getPostDetails=' . htmlspecialchars($_GET['getPostDetails']) . '&postId=' . htmlspecialchars($_GET['postId']) . '" class="spinnable hidden-xs-down">';
0 ignored issues
show
This line exceeds maximum limit of 120 characters; contains 183 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
119
							}
120
							else
121
							{
122
								echo '<h1>';	
123
								echo '<a href="' . $view->toUrl() . '" class="spinnable">';
124
							}
125
						?>
126
						JodelBlue <i class="fa fa-refresh fa-1x"></i></a>
127
					</h1>
128
129
					<div id="location_mobile" class="hidden-sm-up">
130
						<form method="get">
131
							<input type="text" id="city_mobile" name="search" placeholder="<?php if(isset($newPositionStatus)) echo $newPositionStatus; ?>" required>
0 ignored issues
show
This line exceeds maximum limit of 120 characters; contains 144 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
132
133
							<input type="submit" id="submit_mobile" class="fa" value="&#xf0ac;" />
134
						</form>
135
					</div>
136
				</div>
137
			</nav>
138
		</header>
139
		
140
		<div class="mainContent container">		
141
			<div class="content row">
142
				<article class="topContent col-sm-8">
143
144
					<content id="posts">
145
						<?php
146
							foreach($posts as $post)
147
							{
148
								$view->lastPostId = $post['post_id'];
149
								$view->jodelToHtml($post);
150
							} ?>
151
					</content>
152
					
153
					<?php if(!isset($_GET['postId']) && !isset($_GET['getPostDetails'])) { ?>
154
						<p id="loading">
155
							Loading…
156
						</p>
157
					<?php } ?>
158
				</article>
159
			
160
				<aside class="topSidebar col-sm-4 sidebar-outer">
161
					<div class="fixed">
162
						<article>
163
							<div>
164
								<h2>Position / Hashtag</h2>
165
								<form method="get">
166
									<input type="text" id="city" name="search" placeholder="<?php if(isset($newPositionStatus)) echo $newPositionStatus; ?>" required>
0 ignored issues
show
This line exceeds maximum limit of 120 characters; contains 139 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
167
									<label>try: #jhj</label><br>
168
									<input type="submit" value="Set Location" /> 
169
								</form>
170
							</div>
171
						</article>
172
173
						<article>
174
							<div>
175
								<h2>Karma</h2>
176
								<?php echo $jodelAccountForKarma->getKarma(); ?>
177
							</div>
178
						</article>
179
180
						<article>
181
							<div>
182
								<?php if(isset($_GET['postId']) && isset($_GET['getPostDetails'])) { ?>
183
								<h2>Comment on Jodel</h2>
184
								<form method="POST">				
185
										<input type="hidden" name="ancestor" value="<?php echo htmlspecialchars($_GET['postId']);?>" />
186
										<textarea id="message" name="message" placeholder="Send a comment on a Jodel to all students within 10km" required></textarea> 
0 ignored issues
show
This line exceeds maximum limit of 120 characters; contains 137 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
187
									<br />
188
									<input type="submit" value="SEND" /> 
189
								</form>
190
									<?php } else { ?>
191
								<h2>New Jodel</h2>
192
								<form method="POST">
193
									<textarea id="message" name="message" placeholder="Send a Jodel to all students within 10km" required></textarea> 
0 ignored issues
show
This line exceeds maximum limit of 120 characters; contains 123 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
194
									<br />
195
									<select id="postColorPicker" name="color">
196
										<option value="06A3CB">Blue</option>
197
										<option value="8ABDB0">Teal</option>
198
										<option value="9EC41C">Green</option>
199
										<option value="FFBA00">Yellow</option>
200
										<option value="DD5F5F">Red</option>
201
										<option value="FF9908">Orange</option>
202
									</select> 
203
									<br />
204
									<input type="submit" value="SEND" /> 
205
								</form>
206
								<?php } ?>
207
							</div>
208
						</article>
209
							
210
						<article>
211
							<div>
212
								<h2>Login</h2>
213
							</div>
214
						</article>
215
					</div>
216
				</aside>
217
			</div>
218
			<?php include './template/nav-bottom.php';?>
219
		
220
		
221
		<!-- jQuery, Tether, Bootstrap JS and own-->
222
		<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js" integrity="sha384-3ceskX3iaEnIogmQchP8opvBy3Mi7Ce34nWjpBIwVTHfGYWQS9jwHDVRnpKKHJg7" crossorigin="anonymous"></script>
0 ignored issues
show
This line exceeds maximum limit of 120 characters; contains 198 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
223
    	<script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.3.7/js/tether.min.js" integrity="sha384-XTs3FgkjiBgo8qjEjBk0tGmf3wPrWtA6coPfQDfFEY8AnYJwjalXCiosYRBIBZX8" crossorigin="anonymous"></script>
0 ignored issues
show
This line exceeds maximum limit of 120 characters; contains 205 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
224
    	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.5/js/bootstrap.min.js" integrity="sha384-BLiI7JTZm+JWlgKa0M0kGRpJbF2J8q+qreVrKBC47e3K6BW78kGLrCkeRX6I9RoK" crossorigin="anonymous"></script>
0 ignored issues
show
This line exceeds maximum limit of 120 characters; contains 212 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
225
    	<script src="<?php echo $baseUrl;?>js/jQueryEmoji.js"></script>
226
227
		<script>
228
			//BackButton
229
			function goBack()
230
			{
231
				window.history.back();
232
			}
233
234
			$(document).ready(function()
235
			{
236
				//Transform UTF-8 Emoji to img
237
				$('.jodel > content').Emoji();
238
239
				$('a').on('click', function(){
240
				    $('a').removeClass('selected');
241
				    $(this).addClass('selected');
242
				});
243
244
				function scrollToAnchor(aid){
245
				    var aTag = $("article[id='"+ aid +"']");
246
				    $('html,body').animate({scrollTop: aTag.offset().top-90},'slow');
247
				}
248
249
				<?php if(!isset($_GET['postId']) && !isset($_GET['getPostDetails'])) { ?>
250
251
				
252
253
254
255
				var win = $(window);
256
				var lastPostId = "<?php echo $view->lastPostId; ?>";
257
				var view = "<?php echo $view->view; ?>";
258
				var hashtag = "<?php echo $view->hashtag; ?>";
259
				var old_lastPostId = "";
260
				var morePostsAvailable = true;
261
262
				if(window.location.hash)
263
				{
264
					var hash = window.location.hash.slice(1);
265
266
					if(!$("article[id='"+ hash +"']").length)
267
					{
268
						for (var i = 5; i >= 0; i--)
269
						{
270
							if(!$("article[id='"+ hash +"']").length)
271
							{
272
								$.ajax({
273
									url: '<?php echo $baseUrl;?>get-posts-ajax.php?lastPostId=' + lastPostId + '&view=' + view + '&hashtag=' + encodeURI(hashtag),
0 ignored issues
show
This line exceeds maximum limit of 120 characters; contains 135 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
274
									dataType: 'html',
275
									async: false,
276
									success: function(html) {
277
										var div = document.createElement('div');
278
										div.innerHTML = html;
279
										var elements = div.childNodes;
280
										old_lastPostId = lastPostId;
281
										lastPostId = elements[3].textContent;
282
										lastPostId = lastPostId.replace(/\s+/g, '');
283
										//alert('Neu: ' + lastPostId + " Alt: " + old_lastPostId);
284
										if(lastPostId == old_lastPostId) {
285
											
286
											//morePostsAvailable = false;
287
										}
288
										else {
289
											//alert(elements[3].textContent);
290
											$('#posts').append(elements[1].innerHTML);
291
											$('#posts').hide().show(0);
292
										}
293
										$('#loading').hide();
294
									}
295
								});
296
297
								$('.jodel > content').Emoji();
298
							}
299
							
300
						}
301
						scrollToAnchor(hash);
302
303
					}						
304
				}
305
306
				// Each time the user scrolls
307
				win.scroll(function() {
308
309
310
					// End of the document reached?
311
					if ($(window).scrollTop() + $(window).height() > $(document).height() - 100 && morePostsAvailable)
312
					{
313
						$('#loading').show();
314
315
						$.ajax({
316
							url: '<?php echo $baseUrl;?>get-posts-ajax.php?lastPostId=' + lastPostId + '&view=' + view + '&hashtag=' + encodeURI(hashtag),
0 ignored issues
show
This line exceeds maximum limit of 120 characters; contains 133 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
317
							dataType: 'html',
318
							async: false,
319
							success: function(html) {
320
								var div = document.createElement('div');
321
								div.innerHTML = html;
322
								var elements = div.childNodes;
323
								old_lastPostId = lastPostId;
324
								lastPostId = elements[3].textContent;
325
								lastPostId = lastPostId.replace(/\s+/g, '');
326
								//alert('Neu: ' + lastPostId + " Alt: " + old_lastPostId);
327
								if(lastPostId == old_lastPostId)
328
								{
329
									
330
									//morePostsAvailable = false;
331
								}
332
								else
333
								{
334
									//alert(elements[3].textContent);
335
									$('#posts').append(elements[1].innerHTML);
336
								}
337
								$('#loading').hide();
338
							}
339
						});
340
341
						$('.jodel > content').Emoji();
342
					}
343
				});
344
			<?php } ?>
345
			});	
346
347
		</script>
348
349
		<?php  
350
			if(is_file($baseUrl . 'piwik-script.html'))
351
			{
352
			    require_once($baseUrl . 'piwik-script.html');
353
			}
354
		?>
355
356
	</body>
357
</html>
358
0 ignored issues
show
As per coding style, files should not end with a newline character.

This check marks files that end in a newline character, i.e. an empy line.

Loading history...
359