Completed
Push — master ( 027077...76536b )
by mains
02:56
created

index.php (2 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)
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
?>
51
<!DOCTYPE html>
52
<html lang="en">
53
	<head>
54
		<title><?php echo $view->getTitle($posts[0]);?></title>
55
		
56
		<meta charset="utf-8">
57
		<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
58
		<meta http-equiv="x-ua-compatible" content="ie=edge">
59
		
60
		<meta name="description" content="<?php echo $view->getMetaDescription($posts[0]);?>">
61
		<meta name="keywords" content="jodelblue, jodel, blue, webclient, web, client, web-app, browser, app">
62
		
63
		<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">
64
		<link rel="stylesheet" href="<?php echo $baseUrl;?>css/font-awesome.min.css">
65
		<link rel="stylesheet" href="<?php echo $baseUrl;?>style.css" type="text/css">
66
		
67
		<link rel="shortcut icon" type="image/x-icon" href="<?php echo $baseUrl;?>img/favicon/favicon.ico">
68
		<link rel="icon" type="image/x-icon" href="<?php echo $baseUrl;?>img/favicon/favicon.ico">
69
		<link rel="icon" type="image/gif" href="<?php echo $baseUrl;?>img/favicon/favicon.gif">
70
		<link rel="icon" type="image/png" href="<?php echo $baseUrl;?>img/favicon/favicon.png">
71
		<link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon.png">
72
		<link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon-57x57.png" sizes="57x57">
73
		<link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon-60x60.png" sizes="60x60">
74
		<link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon-72x72.png" sizes="72x72">
75
		<link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon-76x76.png" sizes="76x76">
76
		<link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon-114x114.png" sizes="114x114">
77
		<link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon-120x120.png" sizes="120x120">
78
		<link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon-128x128.png" sizes="128x128">
79
		<link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon-144x144.png" sizes="144x144">
80
		<link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon-152x152.png" sizes="152x152">
81
		<link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon-180x180.png" sizes="180x180">
82
		<link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon-precomposed.png">
83
		<link rel="icon" type="image/png" href="<?php echo $baseUrl;?>img/favicon/favicon-16x16.png" sizes="16x16">
84
		<link rel="icon" type="image/png" href="<?php echo $baseUrl;?>img/favicon/favicon-32x32.png" sizes="32x32">
85
		<link rel="icon" type="image/png" href="<?php echo $baseUrl;?>img/favicon/favicon-96x96.png" sizes="96x96">
86
		<link rel="icon" type="image/png" href="<?php echo $baseUrl;?>img/favicon/favicon-160x160.png" sizes="160x160">
87
		<link rel="icon" type="image/png" href="<?php echo $baseUrl;?>img/favicon/favicon-192x192.png" sizes="192x192">
88
		<link rel="icon" type="image/png" href="<?php echo $baseUrl;?>img/favicon/favicon-196x196.png" sizes="196x196">
89
		<meta name="msapplication-TileImage" content="<?php echo $baseUrl;?>img/favicon/win8-tile-144x144.png"> 
90
		<meta name="msapplication-TileColor" content="#5682a3"> 
91
		<meta name="msapplication-navbutton-color" content="#5682a3"> 
92
		<meta name="application-name" content="JodelBlue"/> 
93
		<meta name="msapplication-tooltip" content="JodelBlue"/> 
94
		<meta name="apple-mobile-web-app-title" content="JodelBlue"/> 
95
		<meta name="msapplication-square70x70logo" content="<?php echo $baseUrl;?>img/favicon/win8-tile-70x70.png"> 
96
		<meta name="msapplication-square144x144logo" content="<?php echo $baseUrl;?>img/favicon/win8-tile-144x144.png"> 
97
		<meta name="msapplication-square150x150logo" content="<?php echo $baseUrl;?>img/favicon/win8-tile-150x150.png"> 
98
		<meta name="msapplication-wide310x150logo" content="<?php echo $baseUrl;?>img/favicon/win8-tile-310x150.png"> 
99
		<meta name="msapplication-square310x310logo" content="<?php echo $baseUrl;?>img/favicon/win8-tile-310x310.png"> 
100
	</head>
101
	
102
	<body>
103
		<header>
104
			<nav class="navbar navbar-full navbar-dark navbar-fixed-top">
105
				<div class="container">					
106
						<?php
107
108
							if(isset($_GET['postId']) && isset($_GET['getPostDetails']))
109
							{
110
								echo '<a id="comment-back" href="index.php?view=' . $view->view . '#postId-' . htmlspecialchars($_GET['postId']) . '">';
111
								echo '<i class="fa fa-angle-left fa-3x"></i>';
112
								echo '</a>';
113
								echo '<h1>';
114
								echo '<a href="index.php?getPostDetails=' . htmlspecialchars($_GET['getPostDetails']) . '&postId=' . htmlspecialchars($_GET['postId']) . '" class="spinnable hidden-xs-down">';
115
							}
116
							else
117
							{
118
								echo '<h1>';	
119
								echo '<a href="./" class="spinnable">';
120
							}
121
						?>
122
						JodelBlue <i class="fa fa-refresh fa-1x"></i></a>
123
					</h1>
124
125
					<div id="location_mobile" class="hidden-sm-up">
126
						<form method="get">
127
							<input type="text" id="city_mobile" name="search" placeholder="<?php if(isset($newPositionStatus)) echo $newPositionStatus; ?>" required>
128
129
							<input type="submit" id="submit_mobile" class="fa" value="&#xf0ac;" />
130
						</form>
131
					</div>
132
				</div>
133
			</nav>
134
		</header>
135
		
136
		<div class="mainContent container">		
137
			<div class="content row">
138
				<article class="topContent col-sm-8">
139
140
					<content id="posts">
141
						<?php
142
							foreach($posts as $post)
143
							{
144
								$view->lastPostId = $post['post_id'];
145
								$view->jodelToHtml($post);
146
							} ?>
147
					</content>
148
					
149
					<?php if(!isset($_GET['postId']) && !isset($_GET['getPostDetails'])) { ?>
150
						<p id="loading">
151
							Loading…
152
						</p>
153
					<?php } ?>
154
				</article>
155
			
156
				<aside class="topSidebar col-sm-4 sidebar-outer">
157
					<div class="fixed">
158
						<article>
159
							<div>
160
								<h2>Position / Hashtag</h2>
161
								<form method="get">
162
									<input type="text" id="city" name="search" placeholder="<?php if(isset($newPositionStatus)) echo $newPositionStatus; ?>" required>
163
									<label>try: #jhj</label><br>
164
									<input type="submit" value="Set Location" /> 
165
								</form>
166
							</div>
167
						</article>
168
169
						<article>
170
							<div>
171
								<h2>Karma</h2>
172
								<?php echo $jodelAccountForKarma->getKarma(); ?>
173
							</div>
174
						</article>
175
176
						<article>
177
							<div>
178
								<?php if(isset($_GET['postId']) && isset($_GET['getPostDetails'])) { ?>
179
								<h2>Comment on Jodel</h2>
180
								<form method="POST">				
181
										<input type="hidden" name="ancestor" value="<?php echo htmlspecialchars($_GET['postId']);?>" />
182
										<textarea id="message" name="message" placeholder="Send a comment on a Jodel to all students within 10km" required></textarea> 
183
									<br />
184
									<input type="submit" value="SEND" /> 
185
								</form>
186
									<?php } else { ?>
187
								<h2>New Jodel</h2>
188
								<form method="POST">
189
									<textarea id="message" name="message" placeholder="Send a Jodel to all students within 10km" required></textarea> 
190
									<br />
191
									<select id="postColorPicker" name="color">
192
										<option value="06A3CB">Blue</option>
193
										<option value="8ABDB0">Teal</option>
194
										<option value="9EC41C">Green</option>
195
										<option value="FFBA00">Yellow</option>
196
										<option value="DD5F5F">Red</option>
197
										<option value="FF9908">Orange</option>
198
									</select> 
199
									<br />
200
									<input type="submit" value="SEND" /> 
201
								</form>
202
								<?php } ?>
203
							</div>
204
						</article>
205
							
206
						<article>
207
							<div>
208
								<h2>Login</h2>
209
							</div>
210
						</article>
211
					</div>
212
				</aside>
213
			</div>
214
			<?php include './template/nav-bottom.php';?>
215
		
216
		
217
		<!-- jQuery, Tether, Bootstrap JS and own-->
218
		<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js" integrity="sha384-3ceskX3iaEnIogmQchP8opvBy3Mi7Ce34nWjpBIwVTHfGYWQS9jwHDVRnpKKHJg7" crossorigin="anonymous"></script>
219
    	<script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.3.7/js/tether.min.js" integrity="sha384-XTs3FgkjiBgo8qjEjBk0tGmf3wPrWtA6coPfQDfFEY8AnYJwjalXCiosYRBIBZX8" crossorigin="anonymous"></script>
220
    	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.5/js/bootstrap.min.js" integrity="sha384-BLiI7JTZm+JWlgKa0M0kGRpJbF2J8q+qreVrKBC47e3K6BW78kGLrCkeRX6I9RoK" crossorigin="anonymous"></script>
221
    	<script src="<?php echo $baseUrl;?>js/jQueryEmoji.js"></script>
222
223
		<script>
224
			//BackButton
225
			function goBack()
226
			{
227
				window.history.back();
228
			}
229
230
			$(document).ready(function()
231
			{
232
				//Transform UTF-8 Emoji to img
233
				$('.jodel > content').Emoji();
234
235
				$('a').on('click', function(){
236
				    $('a').removeClass('selected');
237
				    $(this).addClass('selected');
238
				});
239
240
				function scrollToAnchor(aid){
241
				    var aTag = $("article[id='"+ aid +"']");
242
				    $('html,body').animate({scrollTop: aTag.offset().top-90},'slow');
243
				}
244
245
				<?php if(!isset($_GET['postId']) && !isset($_GET['getPostDetails'])) { ?>
246
247
				
248
249
250
251
				var win = $(window);
252
				var lastPostId = "<?php echo $view->lastPostId; ?>";
253
				var view = "<?php echo $view->view; ?>";
254
				var hashtag = "<?php echo $view->hashtag; ?>";
255
				var old_lastPostId = "";
256
				var morePostsAvailable = true;
257
258
				if(window.location.hash)
259
				{
260
					var hash = window.location.hash.slice(1);
261
262
					if(!$("article[id='"+ hash +"']").length)
263
					{
264
						for (var i = 5; i >= 0; i--)
265
						{
266
							if(!$("article[id='"+ hash +"']").length)
267
							{
268
								$.ajax({
269
									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...
270
									dataType: 'html',
271
									async: false,
272
									success: function(html) {
273
										var div = document.createElement('div');
274
										div.innerHTML = html;
275
										var elements = div.childNodes;
276
										old_lastPostId = lastPostId;
277
										lastPostId = elements[3].textContent;
278
										lastPostId = lastPostId.replace(/\s+/g, '');
279
										//alert('Neu: ' + lastPostId + " Alt: " + old_lastPostId);
280
										if(lastPostId == old_lastPostId) {
281
											
282
											//morePostsAvailable = false;
283
										}
284
										else {
285
											//alert(elements[3].textContent);
286
											$('#posts').append(elements[1].innerHTML);
287
											$('#posts').hide().show(0);
288
										}
289
										$('#loading').hide();
290
									}
291
								});
292
293
								$('.jodel > content').Emoji();
294
							}
295
							
296
						}
297
						scrollToAnchor(hash);
298
299
					}						
300
				}
301
302
				// Each time the user scrolls
303
				win.scroll(function() {
304
305
306
					// End of the document reached?
307
					if ($(window).scrollTop() + $(window).height() > $(document).height() - 100 && morePostsAvailable)
308
					{
309
						$('#loading').show();
310
311
						$.ajax({
312
							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...
313
							dataType: 'html',
314
							async: false,
315
							success: function(html) {
316
								var div = document.createElement('div');
317
								div.innerHTML = html;
318
								var elements = div.childNodes;
319
								old_lastPostId = lastPostId;
320
								lastPostId = elements[3].textContent;
321
								lastPostId = lastPostId.replace(/\s+/g, '');
322
								//alert('Neu: ' + lastPostId + " Alt: " + old_lastPostId);
323
								if(lastPostId == old_lastPostId)
324
								{
325
									
326
									//morePostsAvailable = false;
327
								}
328
								else
329
								{
330
									//alert(elements[3].textContent);
331
									$('#posts').append(elements[1].innerHTML);
332
								}
333
								$('#loading').hide();
334
							}
335
						});
336
337
						$('.jodel > content').Emoji();
338
					}
339
				});
340
			<?php } ?>
341
			});	
342
343
		</script>
344
345
		<?php  
346
			if(is_file($baseUrl . 'piwik-script.html'))
347
			{
348
			    require_once($baseUrl . 'piwik-script.html');
349
			}
350
		?>
351
352
	</body>
353
</html>
354
355