Completed
Push — master ( 20d307...1b4b29 )
by mains
02:48
created

get-posts-ajax.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
error_reporting(-1);
3
4
include 'php/jodel-web.php';/*
0 ignored issues
show
Unused Code Comprehensibility introduced by
59% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
5
include 'php/DatabaseConnect.php';
6
include 'php/Requests/AbstractRequest.php';
7
include 'php/Requests/CreateUser.php';
8
include 'php/AccountData.php';
9
include 'php/Location.php';
10
include 'php/Requests/GetPosts.php';
11
include 'php/Requests/GetKarma.php';
12
include 'php/Requests/UpdateLocation.php';
13
include 'php/Requests/Upvote.php';
14
include 'php/Requests/Downvote.php';
15
include 'php/Requests/GetPostDetails.php';
16
include 'php/Requests/SendJodel.php';
17
18
require_once 'php/Requests/libary/Requests.php';
19
Requests::register_autoloader();*/
20
$location = new Location();
21
$location->setLat('0.1');
22
$location->setLng('0.1');
23
$location->setCityName('Munich');
24
25
isTokenFresh($location);
26
27
$result = $db->query("SELECT * FROM accounts WHERE id='1'");
28
29
$accessToken;
30
$newPositionStatus;
31
32 View Code Duplication
if ($result->num_rows > 0)
33
{
34
	// output data of each row
35
	while($row = $result->fetch_assoc())
36
	{
37
		$accessToken = $row["access_token"];
38
	}
39
}
40
else
41
{
42
	echo "Error: 0 results";
43
}
44
45
46 View Code Duplication
	if(isset($_GET['view']))
47
	{
48
		switch ($_GET['view']) {
49
			case 'comment':
50
				$view = 'comment';
51
				break;
52
			
53
			case 'upVote':
54
				$view = 'upVote';
55
				break;
56
57
			default:
58
				$view = 'time';
59
				break;
60
		}
61
	}
62
	else
63
	{
64
		$view = 'time';
65
	}
66
67
	if($view=='comment')
68
	{
69
		$url = "/v2/posts/location/discussed/";
70
	}
71
	else
72
	{
73
		if($view=='upVote')
74
		{
75
			$url = "/v2/posts/location/popular/";
76
		}
77
		else
78
		{
79
			$url = "/v2/posts/location/";
80
		}
81
	}
82
83
	if(isset($_GET['lastPostId']))
84
	{
85
		$lastPostId = htmlspecialchars($_GET['lastPostId']);
86
		
87
		$posts = getPosts($lastPostId, $accessToken, $url)['posts'];
88
		$loops = 29;
89
		$showCommentIcon = TRUE;
90
		?>
91
		<div class="nextPosts">
92
		<?php
93 View Code Duplication
		for($i = 0; $i<$loops; $i++)
94
		{
95
			if(isset($posts[$i]))
96
			{
97
				$lastPostId = $posts[$i]['post_id'];
98
				jodelToHtml($posts[$i], $view);	
99
			}
100
		}
101
		?>
102
		</div>
103
		<div class="lastPostId">
104
		<?php echo $lastPostId; ?>
105
		</div>
106
		<?php
107
	}
108