Completed
Push — master ( 9607b1...a546a7 )
by mains
02:34
created

admin.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
error_reporting(-1);
3
include 'php/jodel-web.php';
4
5
$location = new Location();
6
$location->setLat('52.5134288');
7
$location->setLng('13.2746394');
8
$location->setCityName('Berlin');
9
10
11
12
if(isset($_POST['createAccount']) && $_POST['createAccount'])
13
{
14
	createAccount();
15
}
16
17
18
//Vote
19
if(isset($_POST['vote']) && isset($_POST['postId']) && isset($_POST['quantity']))
20
{
21
	$i = 0;
22
	$result = $db->query("SELECT access_token FROM accounts");
23
24
	if ($result->num_rows > 0)
25
	{
26
		// output data of each row
27
		while(($row = $result->fetch_assoc()) && $i < $_POST['quantity'])
28
		{
29
			$accessToken = $row['access_token'];
30
			var_dump($accessToken);
31
			isTokenFreshByAccessToken($location, $accessToken);
32
33 View Code Duplication
			if($_POST['vote'] == "up") {
34
				$accountCreator = new Upvote();
35
			}
36
			else if($_POST['vote'] == "down") {
37
				$accountCreator = new Downvote();
38
			}
39
40
			$accountCreator->setAccessToken($accessToken);
41
			$accountCreator->postId = $_POST['postId'];
42
			$data = $accountCreator->execute();
43
			$i++;
44
		}
45
	}
46
	else
47
	{
48
		echo "Error: 0 results";
49
	}
50
}
51
52
53
?>
54
<!DOCTYPE html>
55
<html lang="en">
56
	<head>
57
		<title>Backend - JodelBlue WebClient</title>
58
		
59
		<meta charset="utf8">
60
		<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
61
		<meta http-equiv="x-ua-compatible" content="ie=edge">
62
		
63
		<meta name="description" content="JodelBlue is a WebClient for the Jodel App. No registration required! Browse Jodels all over the world. Send your own Jodels or upvote others.">
64
		<meta name="keywords" content="jodelblue, jodel, blue, webclient, web, client">
65
		
66
		<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">
67
		<link rel="stylesheet" href="css/font-awesome.min.css">
68
		<link rel="stylesheet" href="style.css" type="text/css">
69
		
70
		<link rel="shortcut icon" type="image/x-icon" href="./img/favicon/favicon.ico">
71
		<link rel="icon" type="image/x-icon" href="./img/favicon/favicon.ico">
72
		<link rel="icon" type="image/gif" href="./img/favicon/favicon.gif">
73
		<link rel="icon" type="image/png" href="./img/favicon/favicon.png">
74
		<link rel="apple-touch-icon" href="./img/favicon/apple-touch-icon.png">
75
		<link rel="apple-touch-icon" href="./img/favicon/apple-touch-icon-57x57.png" sizes="57x57">
76
		<link rel="apple-touch-icon" href="./img/favicon/apple-touch-icon-60x60.png" sizes="60x60">
77
		<link rel="apple-touch-icon" href="./img/favicon/apple-touch-icon-72x72.png" sizes="72x72">
78
		<link rel="apple-touch-icon" href="./img/favicon/apple-touch-icon-76x76.png" sizes="76x76">
79
		<link rel="apple-touch-icon" href="./img/favicon/apple-touch-icon-114x114.png" sizes="114x114">
80
		<link rel="apple-touch-icon" href="./img/favicon/apple-touch-icon-120x120.png" sizes="120x120">
81
		<link rel="apple-touch-icon" href="./img/favicon/apple-touch-icon-128x128.png" sizes="128x128">
82
		<link rel="apple-touch-icon" href="./img/favicon/apple-touch-icon-144x144.png" sizes="144x144">
83
		<link rel="apple-touch-icon" href="./img/favicon/apple-touch-icon-152x152.png" sizes="152x152">
84
		<link rel="apple-touch-icon" href="./img/favicon/apple-touch-icon-180x180.png" sizes="180x180">
85
		<link rel="apple-touch-icon" href="./img/favicon/apple-touch-icon-precomposed.png">
86
		<link rel="icon" type="image/png" href="./img/favicon/favicon-16x16.png" sizes="16x16">
87
		<link rel="icon" type="image/png" href="./img/favicon/favicon-32x32.png" sizes="32x32">
88
		<link rel="icon" type="image/png" href="./img/favicon/favicon-96x96.png" sizes="96x96">
89
		<link rel="icon" type="image/png" href="./img/favicon/favicon-160x160.png" sizes="160x160">
90
		<link rel="icon" type="image/png" href="./img/favicon/favicon-192x192.png" sizes="192x192">
91
		<link rel="icon" type="image/png" href="./img/favicon/favicon-196x196.png" sizes="196x196">
92
		<meta name="msapplication-TileImage" content="./img/favicon/win8-tile-144x144.png"> 
93
		<meta name="msapplication-TileColor" content="#5682a3"> 
94
		<meta name="msapplication-navbutton-color" content="#5682a3"> 
95
		<meta name="application-name" content="JodelBlue"/> 
96
		<meta name="msapplication-tooltip" content="JodelBlue"/> 
97
		<meta name="apple-mobile-web-app-title" content="JodelBlue"/> 
98
		<meta name="msapplication-square70x70logo" content="./img/favicon/win8-tile-70x70.png"> 
99
		<meta name="msapplication-square144x144logo" content="./img/favicon/win8-tile-144x144.png"> 
100
		<meta name="msapplication-square150x150logo" content="./img/favicon/win8-tile-150x150.png"> 
101
		<meta name="msapplication-wide310x150logo" content="./img/favicon/win8-tile-310x150.png"> 
102
		<meta name="msapplication-square310x310logo" content="./img/favicon/win8-tile-310x310.png"> 
103
	</head>
104
	
105
	<body>
106
		<header>
107
			<nav class="navbar navbar-full navbar-dark navbar-fixed-top">
108
				<div class="container">					
109
						<?php
110 View Code Duplication
							if(isset($_GET['postID']) && isset($_GET['getPostDetails']))
111
							{
112
								echo '<a id="comment-back" onclick="goBack()" href="index.php?view=' . $view . '#postId-' . htmlspecialchars($_GET['postID']) . '">';
113
								echo '<i class="fa fa-angle-left fa-3x"></i>';
114
								echo '</a>';
115
								echo '<h1>';
116
								echo '<a href="index.php?getPostDetails=' . htmlspecialchars($_GET['getPostDetails']) . '&postID=' . htmlspecialchars($_GET['postID']) . '" class="spinnable">';
117
							}
118
							else
119
							{
120
								echo '<h1>';	
121
								echo '<a href="./" class="spinnable">';
122
							}
123
						?>
124
						JodelBlue <i class="fa fa-refresh fa-1x"></i></a>
125
					</h1>					
126
				</div>
127
			</nav>
128
		</header>
129
		
130
		<div class="mainContent container">		
131
			<div class="content row">
132
				<article class="topContent col-sm-8">
133
134
					<content id="posts">
135
						<form method="post">
136
							<button type="submit" name="createAccount" value="TRUE">Create new Account</button>
137
						</form>
138
139
						<form method="post">
140
							quantity<input type="number" name="quantity">
141
							postId<input type="text" name="postId">
142
							<button type="submit" name="vote" value="up">Upvote</button>
143
							<button type="submit" name="vote" value="down">Downvote</button>
144
						</form>
145
					</content>
146
				</article>
147
			
148
				<aside class="topSidebar col-sm-4 sidebar-outer">
149
					<div class="fixed">
150
						<article>
151
							<div>
152
								<h2>Position</h2>
153
								<form method="get">
154
									<input type="text" id="city" name="city" placeholder="<?php if(isset($newPositionStatus)) echo $newPositionStatus; ?>" required>
155
156
									<input type="submit" value="Set Location" /> 
157
								</form>
158
							</div>
159
						</article>
160
161
						<article>
162
							<div>
163
								<h2>Karma</h2>
164
								<?php //echo getKarma($accessToken); ?>
165
							</div>
166
						</article>
167
168
						<article>
169
							<div>
170 View Code Duplication
								<?php if(isset($_GET['postID']) && isset($_GET['getPostDetails'])) { ?>
171
								<h2>Comment on Jodel</h2>
172
								<form method="POST">				
173
										<input type="hidden" name="ancestor" value="<?php echo htmlspecialchars($_GET['postID']);?>" />
174
										<textarea id="message" name="message" placeholder="Send a comment on a Jodel to all students within 10km" required></textarea> 
175
									<br />
176
									<input type="submit" value="SEND" /> 
177
								</form>
178
									<?php } else { ?>
179
								<h2>New Jodel</h2>
180
								<form method="POST">
181
									<textarea id="message" name="message" placeholder="Send a Jodel to all students within 10km" required></textarea> 
182
									<br />
183
									<select id="postColorPicker" name="color">
184
										<option value="06A3CB">Blue</option>
185
										<option value="8ABDB0">Teal</option>
186
										<option value="9EC41C">Green</option>
187
										<option value="FFBA00">Yellow</option>
188
										<option value="DD5F5F">Red</option>
189
										<option value="FF9908">Orange</option>
190
									</select> 
191
									<br />
192
									<input type="submit" value="SEND" /> 
193
								</form>
194
								<?php } ?>
195
							</div>
196
						</article>
197
							
198
						<article>
199
							<div>
200
								<h2>Login</h2>
201
							</div>
202
						</article>
203
					</div>
204
				</aside>
205
			</div>
206
			<div id="sortJodelBy" class="row">
207
				<div class="col-sm-12">
208
					<div class="row">
209
						<div class="col-sm-3">
210
							<a href="index.php" <?php if($view=='time') echo 'class="active"';?>><i class="fa fa-clock-o fa-3x"></i></a>
211
						</div>
212
						<div class="col-sm-3">
213
							<a href="index.php?view=comment" <?php if($view=='comment') echo 'class="active"';?>><i class="fa fa-commenting-o fa-3x"></i></a>
0 ignored issues
show
This line exceeds maximum limit of 120 characters; contains 136 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...
214
						</div>
215
						<div class="col-sm-3">
216
							<a href="index.php?view=upVote" <?php if($view=='upVote') echo 'class="active"';?>><i class="fa fa-angle-up fa-3x"></i></a>
0 ignored issues
show
This line exceeds maximum limit of 120 characters; contains 130 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...
217
						</div>
218
						<div class="col-sm-3">
219
							<nav>
220
								<a href="./about-us.html">about us</a>
221
							</nav>
222
						</div>
223
					</div>
224
				</div>	
225
			</div>
226
		</div>
227
		
228
		
229
		<!-- jQuery, Tether, Bootstrap JS and own-->
230
		<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js" integrity="sha384-3ceskX3iaEnIogmQchP8opvBy3Mi7Ce34nWjpBIwVTHfGYWQS9jwHDVRnpKKHJg7" crossorigin="anonymous"></script>
231
    	<script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.3.7/js/tether.min.js" integrity="sha384-XTs3FgkjiBgo8qjEjBk0tGmf3wPrWtA6coPfQDfFEY8AnYJwjalXCiosYRBIBZX8" crossorigin="anonymous"></script>
232
    	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.5/js/bootstrap.min.js" integrity="sha384-BLiI7JTZm+JWlgKa0M0kGRpJbF2J8q+qreVrKBC47e3K6BW78kGLrCkeRX6I9RoK" crossorigin="anonymous"></script>
233
    	<script src="js/jQueryEmoji.js"></script>
234
235
		<script>
236
			//BackButton
237
			function goBack()
238
			{
239
				window.history.back();
240
			}
241
242
			$(document).ready(function()
243
			{
244
245
246
				//Transform UTF-8 Emoji to img
247
				$('.jodel > content').Emoji();
248
249
				$('a').on('click', function(){
250
				    $('a').removeClass('selected');
251
				    $(this).addClass('selected');
252
				});
253
254
				function scrollToAnchor(aid){
255
				    var aTag = $("article[id='"+ aid +"']");
256
				    $('html,body').animate({scrollTop: aTag.offset().top-90},'slow');
257
				}
258
259 View Code Duplication
				<?php if(!isset($_GET['postID']) && !isset($_GET['getPostDetails'])) { ?>
260
261
				
262
263
264
265
				var win = $(window);
266
				var lastPostId = "<?php echo $lastPostId; ?>";
267
				var view = "<?php echo $view; ?>"
268
				var old_lastPostId = "";
269
				var morePostsAvailable = true;
270
271
				if(window.location.hash)
272
				{
273
					var hash = window.location.hash.slice(1);
274
275
					if(!$("article[id='"+ hash +"']").length)
276
					{
277
						for (var i = 5; i >= 0; i--)
278
						{
279
							if(!$("article[id='"+ hash +"']").length)
280
							{
281
								$.ajax({
282
									url: 'get-posts-ajax.php?lastPostId=' + lastPostId + '&view=' + view,
283
									dataType: 'html',
284
									async: false,
285
									success: function(html) {
286
										var div = document.createElement('div');
287
										div.innerHTML = html;
288
										var elements = div.childNodes;
289
										old_lastPostId = lastPostId;
290
										lastPostId = elements[3].textContent;
291
										lastPostId = lastPostId.replace(/\s+/g, '');
292
										//alert('Neu: ' + lastPostId + " Alt: " + old_lastPostId);
293
										if(lastPostId == old_lastPostId) {
294
											
295
											//morePostsAvailable = false;
296
										}
297
										else {
298
											//alert(elements[3].textContent);
299
											$('#posts').append(elements[1].innerHTML);
300
											$('#posts').hide().show(0);
301
										}
302
										$('#loading').hide();
303
									}
304
								});
305
306
								$('.jodel > content').Emoji();
307
							}
308
							
309
						}
310
						scrollToAnchor(hash);
311
312
					}						
313
				}
314
315
				// Each time the user scrolls
316
				win.scroll(function() {
317
318
319
					// End of the document reached?
320
					if (($(document).height() - win.height() == win.scrollTop()) && morePostsAvailable) {
321
						$('#loading').show();
322
323
						
324
						
325
						$.ajax({
326
							url: 'get-posts-ajax.php?lastPostId=' + lastPostId + '&view=' + view,
327
							dataType: 'html',
328
							async: false,
329
							success: function(html) {
330
								var div = document.createElement('div');
331
								div.innerHTML = html;
332
								var elements = div.childNodes;
333
								old_lastPostId = lastPostId;
334
								lastPostId = elements[3].textContent;
335
								lastPostId = lastPostId.replace(/\s+/g, '');
336
								//alert('Neu: ' + lastPostId + " Alt: " + old_lastPostId);
337
								if(lastPostId == old_lastPostId)
338
								{
339
									
340
									//morePostsAvailable = false;
341
								}
342
								else
343
								{
344
									//alert(elements[3].textContent);
345
									$('#posts').append(elements[1].innerHTML);
346
								}
347
								$('#loading').hide();
348
							}
349
						});
350
351
						$('.jodel > content').Emoji();
352
					}
353
				});
354
			<?php } ?>
355
			});	
356
357
		</script>
358
359
		<!-- Piwik -->
360
		<script type="text/javascript">
361
		  var _paq = _paq || [];
362
		  _paq.push(['trackPageView']);
363
		  _paq.push(['enableLinkTracking']);
364
		  (function() {
365
		    var u="//www.jodelblue.com/piwik/";
366
		    _paq.push(['setTrackerUrl', u+'piwik.php']);
367
		    _paq.push(['setSiteId', '1']);
368
		    var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
369
		    g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
370
		  })();
371
		</script>
372
		<noscript><p><img src="//www.jodelblue.com/piwik/piwik.php?idsite=1" style="border:0;" alt="" /></p></noscript>
373
		<!-- End Piwik Code -->
374
375
	</body>
376
</html>