Completed
Pull Request — master (#10)
by
unknown
02:50
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
6
$config = parse_ini_file('config/config.ini.php');
7
8
$location = new Location();
9
$location->setLat($config['default_lat']);
10
$location->setLng($config['default_lng']);
11
$location->setCityName($config['default_location']);
12
13
$accessToken;
14
$accessToken_forId1;
15
$deviceUid;
16
17
18
if(!isset($_COOKIE["JodelDeviceId"]))
19
{
20
	$deviceUid = createAccount();
21
	setcookie("JodelDeviceId", $deviceUid, time()+60*60*24*365*10);
22
	
23
}
24
else
25
{
26
	$deviceUid = $db->real_escape_string($_COOKIE["JodelDeviceId"]);
27
}
28
29
$location = getLocationByDeviceUid($deviceUid);
30
$newPositionStatus = $location->getCityName();
31
$accessToken = isTokenFreshByDeviceUid($location, $deviceUid);
32
//Acc is fresh. token and location is set
33
34
$accessToken_forId1 = isTokenFresh($location);
35
36
37
38 View Code Duplication
	if(isset($_GET['view']))
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...
39
	{
40
		switch ($_GET['view']) {
41
			case 'comment':
42
				$view = 'comment';
43
				break;
44
			
45
			case 'upVote':
46
				$view = 'upVote';
47
				break;
48
49
			default:
50
				$view = 'time';
51
				break;
52
		}
53
	}
54
	else
55
	{
56
		$view = 'time';
57
	}
58
59
	if($view=='comment')
60
	{
61
		$url = "/v2/posts/location/discussed/";
62
	}
63
	else
64
	{
65
		if($view=='upVote')
66
		{
67
			$url = "/v2/posts/location/popular/";
68
		}
69
		else
70
		{
71
			$url = "/v2/posts/location/";
72
		}
73
	}
74
75
	if(isset($_GET['lastPostId']))
76
	{
77
		$lastPostId = htmlspecialchars($_GET['lastPostId']);
78
		
79
		$posts = getPosts($lastPostId, $accessToken, $url)['posts'];
80
		$loops = 29;
81
		$showCommentIcon = TRUE;
82
		?>
83
		<div class="nextPosts">
84
		<?php
85
		for($i = 0; $i<$loops; $i++)
86
		{
87
			if(isset($posts[$i]))
88
			{
89
				$lastPostId = $posts[$i]['post_id'];
90
				jodelToHtml($posts[$i], $view);	
91
			}
92
		}
93
		?>
94
		</div>
95
		<div class="lastPostId">
96
		<?php echo $lastPostId; ?>
97
		</div>
98
		<?php
99
	}
100