Completed
Push — master ( 5c086a...710747 )
by mains
07:28
created

index.php (8 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('error', $data))
15
		{
16
			echo $data['error'];
17
			exit();
18
			renderTemplate('The post has been blocked');
19
			exit();
20
		}
21
22
		if(array_key_exists('status_code', $data) && $data->status_code == 404)
23
		{
24
			header('HTTP/1.1 410 Gone');
25
			include 'error-pages/410.php';
26
			exit();
27
		}
28
29
		$posts[0] = $data;
30
31
		if(array_key_exists('children', $data)) {
32
			foreach($data['children'] as $key => $child)
33
			{
34
				
35
				if(array_key_exists('parent_creator', $child) && !$child['parent_creator'] == 1)
36
				{
37
					$numberForUser = array_search($child['user_handle'], $userHandleBuffer);
38
					if($numberForUser === FALSE)
39
					{
40
						array_push($userHandleBuffer, $child['user_handle']);
41
						$data['children'][$key]['user_handle'] = count($userHandleBuffer);
42
					}
43
					else
44
					{
45
						$data['children'][$key]['user_handle'] = $numberForUser + 1;
46
					}
47
				}
48
49
				array_push($posts, $data['children'][$key]);
50
			}
51
		}
52
	}
53
	//Get Posts and Hashtags
54
	else
55
	{
56
		$posts = $view->getPosts($jodelAccountForView);
57
	}
58
	if(!isset($posts[0]))
59
	{
60
		error_log('Fehler: ' . print_r($posts, true) . print_r($posts['recent'], true) . print_r($posts['posts'], true));
61
		$title = $view->getTitle();
0 ignored issues
show
Equals sign not aligned with surrounding assignments; expected 7 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
62
		$description = $view->getMetaDescription();
63
	}
64
	else
65
	{
66
		$title = $view->getTitle($posts[0]);
0 ignored issues
show
Equals sign not aligned with surrounding assignments; expected 7 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
67
		$description = $view->getMetaDescription($posts[0]);
68
	}
69
70
	if($view->isDetailedView)
71
	{
72
		$backButton = $view->back()->toUrl() . '#postId-' . $view->postId;
73
	}
74
	else
75
	{
76
		$backButton = '';
77
	}
78
	include 'templates/header.php';
79
?>
80
		
81
		<div class="mainContent container">		
82
			<div class="content row">
83
				<article class="topContent col-sm-8">
84
85
					<content id="posts">
86
						<?php
87
							foreach($posts as $post)
88
							{
89
								$view->lastPostId = $post['post_id'];
90
								$view->jodelToHtml($post);
91
							} ?>
92
					</content>
93
					
94
					<?php if(!isset($_GET['postId']) && !isset($_GET['getPostDetails'])) { ?>
95
						<p id="loading">
96
							Loading…
97
						</p>
98
					<?php } ?>
99
				</article>
100
			
101
				<aside class="topSidebar col-sm-4 sidebar-outer">
102
					<div class="fixed<?php if(!$view->isDetailedView) echo(' hide-mobile');?>">
103
						<article>
104
							<div>
105
								<h2>Position / Hashtag</h2>
106
								<form action="index.php" method="get">
107
									<input type="text" id="city" name="search" placeholder="<?php if(isset($newPositionStatus)) echo $newPositionStatus; ?>" required>
0 ignored issues
show
This line exceeds maximum limit of 120 characters; contains 139 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...
108
									<label>try: #jhj</label><br>
109
									<input type="submit" value="Set Location" /> 
110
								</form>
111
							</div>
112
						</article>
113
114
						<article>
115
							<div>
116
								<h2>Karma</h2>
117
								<?php echo $jodelAccountForKarma->getKarma(); ?>
118
							</div>
119
						</article>
120
121
						<article>
122
							<div>
123
								<?php if(isset($_GET['postId']) && isset($_GET['getPostDetails'])) { ?>
124
								<h2>Comment on Jodel</h2>
125
								<form method="POST">				
126
										<input type="hidden" name="ancestor" value="<?php echo htmlspecialchars($_GET['postId']);?>" />
127
										<textarea id="message" name="message" placeholder="Send a comment on a Jodel to all students within 10km" required></textarea> 
0 ignored issues
show
This line exceeds maximum limit of 120 characters; contains 137 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...
128
									<br />
129
									<input type="submit" value="SEND" /> 
130
								</form>
131
									<?php } else { ?>
132
								<h2>New Jodel</h2>
133
								<form enctype="multipart/form-data" method="POST">
134
									<textarea id="message" name="message" placeholder="Send a Jodel to all students within 10km" required></textarea> 
0 ignored issues
show
This line exceeds maximum limit of 120 characters; contains 123 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...
135
									<br />
136
									<select id="postColorPicker" name="color">
137
										<option value="06A3CB">Blue</option>
138
										<option value="8ABDB0">Teal</option>
139
										<option value="9EC41C">Green</option>
140
										<option value="FFBA00">Yellow</option>
141
										<option value="DD5F5F">Red</option>
142
										<option value="FF9908">Orange</option>
143
									</select> 
144
									<br />
145
									<input type="hidden" name="MAX_FILE_SIZE" value="999990000" />
146
									<input name="image" type="file" />
147
									<input type="submit" value="SEND" /> 
148
								</form>
149
								<?php } ?>
150
							</div>
151
						</article>
152
							
153
						<article>
154
							<div>
155
								<h2>Donate to JodelBlue</h2>
156
157
								<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
158
								<input type="hidden" name="cmd" value="_s-xclick">
159
								<input type="hidden" name="hosted_button_id" value="RR45538QV3VXE">
160
								<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
0 ignored issues
show
This line exceeds maximum limit of 120 characters; contains 171 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...
161
								<img alt="" border="0" src="https://www.paypalobjects.com/de_DE/i/scr/pixel.gif" width="1" height="1">
162
								</form>
163
164
								<p class="bitcoin-address">Bitcoin-address: <a href="img/bitcoin-address.png">1DzaUWm9Du6CUQLj6QTGC9kpxzKE3yZZHV</a></p>
0 ignored issues
show
This line exceeds maximum limit of 120 characters; contains 128 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...
165
166
								<progress max="3500" value="2111"></progress>
167
								<p>
168
									My payments to keep this Project up so far:
169
								</p>
170
								<ul>
171
									<li>Webspace 15€ - goes till 01-03-2018</li>
172
									<li>Domain 20€ - goes till 06-12-2017</li>
173
								</ul>
174
							</div>
175
						</article>
176
177
						<article>
178
							<div>
179
								<h2>Beta - Votebot</h2>
180
181
								<p>The Beta for the vote bot feature is starting soon. You are cordially invited to test. Please contact us: [email protected]</p>
0 ignored issues
show
This line exceeds maximum limit of 120 characters; contains 139 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...
182
							</div>
183
						</article>
184
					</div>
185
				</aside>
186
			</div>
187
			<?php include 'templates/nav-bottom.php';?>
188
		</div>
189
		<?php
190
			$includeEmojiAndAjax = TRUE;
191
			include 'templates/footer.php';
192
		?>