Completed
Push — master ( dc3cec...6a6184 )
by mains
03:04
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';/*
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
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 View Code Duplication
	if($view=='comment')
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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