Completed
Push — master ( c16962...925f8b )
by mains
03:47 queued 25s
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
		$ojHandle = $posts[0]['user_handle'];
31
32
		if(array_key_exists('children', $data))
33
		{
34
			foreach($data['children'] as $key => $child)
35
			{
36
				//is Comment from OJ?
37
				if($ojHandle == $child['user_handle'])
38
				{
39
					$data['children'][$key]['user_handle'] = 'OJ';
40
				}
41
				else
42
				{
43
					$numberForUser = array_search($child['user_handle'], $userHandleBuffer);
44
					if($numberForUser === FALSE)
45
					{
46
						array_push($userHandleBuffer, $child['user_handle']);
47
						$data['children'][$key]['user_handle'] = count($userHandleBuffer);
48
					}
49
					else
50
					{
51
						$data['children'][$key]['user_handle'] = $numberForUser + 1;
52
					}
53
				}
54
				array_push($posts, $data['children'][$key]);
55
			}
56
		}
57
	}
58
	//Get Posts and Hashtags
59
	else
60
	{
61
		$posts = $view->getPosts($jodelAccountForView);
62
	}
63
	if(!isset($posts[0]))
64
	{
65
		error_log('Fehler: ' . print_r($posts, true) . print_r($posts['recent'], true) . print_r($posts['posts'], true));
66
		$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...
67
		$description = $view->getMetaDescription();
68
	}
69
	else
70
	{
71
		$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...
72
		$description = $view->getMetaDescription($posts[0]);
73
	}
74
75
	if($view->isDetailedView)
76
	{
77
		$backButton = $view->back()->toUrl() . '#postId-' . $view->postId;
78
	}
79
	else
80
	{
81
		$backButton = '';
82
	}
83
	include 'templates/header.php';
84
?>
85
		
86
		<div class="mainContent container">		
87
			<div class="content row">
88
				<article class="topContent col-sm-8">
89
					<div id="errorMsg"></div>
90
91
					<content id="posts">
92
						<?php
93
							foreach($posts as $post)
94
							{
95
								$view->lastPostId = $post['post_id'];
96
								$view->jodelToHtml($post);
97
							} ?>
98
					</content>
99
					
100
					<?php if(!isset($_GET['postId']) && !isset($_GET['getPostDetails'])) { ?>
101
						<p id="loading">
102
							Loading…
103
						</p>
104
					<?php } ?>
105
				</article>
106
			
107
				<aside class="topSidebar col-sm-4 sidebar-outer">
108
					<div class="fixed<?php if(!$view->isDetailedView) echo(' hide-mobile');?>">
109
						<article>
110
							<div>
111
								<h2>Position / Hashtag</h2>
112
								<form action="index.php" method="get">
113
									<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...
114
									<label>try: #jhj</label><br>
115
									<input type="submit" value="Set Location" /> 
116
								</form>
117
							</div>
118
						</article>
119
120
						<article>
121
							<div>
122
								<h2>Karma</h2>
123
								<?php echo $jodelAccountForKarma->getKarma(); ?>
124
							</div>
125
						</article>
126
127
						<article>
128
							<div>
129
								<?php if(!$jodelAccountForView->isAccountVerified())
130
								{
131
								?>
132
								<h2>New Jodel</h2>
133
								
134
								<button href="templates/captcha.php" data-title="Verify Captcha" data-width="1200" data-toggle="lightbox" data-gallery="remoteload">I am not a robot</button>
0 ignored issues
show
This line exceeds maximum limit of 120 characters; contains 165 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
136
								<?php 
137
								}
138
								else
139
								{
140
141
142
									if(isset($_GET['postId']) && isset($_GET['getPostDetails'])) { ?>
143
									<h2>Comment on Jodel</h2>
144
									<form method="POST">				
145
											<input type="hidden" name="ancestor" value="<?php echo htmlspecialchars($_GET['postId']);?>" />
146
											<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 138 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...
147
										<br />
148
										<input type="submit" value="SEND" /> 
149
									</form>
150
										<?php } else { ?>
151
									<h2>New Jodel</h2>
152
									<form enctype="multipart/form-data" method="POST">
153
										<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 124 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...
154
										<br />
155
										<select id="postColorPicker" name="color">
156
											<option value="06A3CB">Blue</option>
157
											<option value="8ABDB0">Teal</option>
158
											<option value="9EC41C">Green</option>
159
											<option value="FFBA00">Yellow</option>
160
											<option value="DD5F5F">Red</option>
161
											<option value="FF9908">Orange</option>
162
										</select> 
163
										<br />
164
										<input type="hidden" name="MAX_FILE_SIZE" value="999990000" />
165
										<input name="image" type="file" />
166
										<input type="submit" value="SEND" /> 
167
									</form>
168
								<?php } ?>
169
							<?php } ?>
170
							</div>
171
						</article>
172
							
173
						<article>
174
							<div>
175
								<h2>Donate to JodelBlue</h2>
176
177
								<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
178
								<input type="hidden" name="cmd" value="_s-xclick">
179
								<input type="hidden" name="hosted_button_id" value="RR45538QV3VXE">
180
								<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...
181
								<img alt="" border="0" src="https://www.paypalobjects.com/de_DE/i/scr/pixel.gif" width="1" height="1">
182
								</form>
183
184
								<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...
185
186
								<progress max="3500" value="2470"></progress>
187
								<p>
188
									My payments to keep this Project up so far:
189
								</p>
190
								<ul>
191
									<li>Webspace 15€ - goes till 01-03-2018</li>
192
									<li>Domain 20€ - goes till 06-12-2017</li>
193
								</ul>
194
							</div>
195
						</article>
196
					</div>
197
				</aside>
198
			</div>
199
			<?php include 'templates/nav-bottom.php';?>
200
		</div>
201
		<?php
202
			$includeEmojiAndAjax = TRUE;
203
			include 'templates/footer.php';
204
		?>