Completed
Push — master ( 710747...fb0372 )
by mains
02:59
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
90
					<content id="posts">
91
						<?php
92
							foreach($posts as $post)
93
							{
94
								$view->lastPostId = $post['post_id'];
95
								$view->jodelToHtml($post);
96
							} ?>
97
					</content>
98
					
99
					<?php if(!isset($_GET['postId']) && !isset($_GET['getPostDetails'])) { ?>
100
						<p id="loading">
101
							Loading…
102
						</p>
103
					<?php } ?>
104
				</article>
105
			
106
				<aside class="topSidebar col-sm-4 sidebar-outer">
107
					<div class="fixed<?php if(!$view->isDetailedView) echo(' hide-mobile');?>">
108
						<article>
109
							<div>
110
								<h2>Position / Hashtag</h2>
111
								<form action="index.php" method="get">
112
									<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...
113
									<label>try: #jhj</label><br>
114
									<input type="submit" value="Set Location" /> 
115
								</form>
116
							</div>
117
						</article>
118
119
						<article>
120
							<div>
121
								<h2>Karma</h2>
122
								<?php echo $jodelAccountForKarma->getKarma(); ?>
123
							</div>
124
						</article>
125
126
						<article>
127
							<div>
128
								<?php if(isset($_GET['postId']) && isset($_GET['getPostDetails'])) { ?>
129
								<h2>Comment on Jodel</h2>
130
								<form method="POST">				
131
										<input type="hidden" name="ancestor" value="<?php echo htmlspecialchars($_GET['postId']);?>" />
132
										<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...
133
									<br />
134
									<input type="submit" value="SEND" /> 
135
								</form>
136
									<?php } else { ?>
137
								<h2>New Jodel</h2>
138
								<form enctype="multipart/form-data" method="POST">
139
									<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...
140
									<br />
141
									<select id="postColorPicker" name="color">
142
										<option value="06A3CB">Blue</option>
143
										<option value="8ABDB0">Teal</option>
144
										<option value="9EC41C">Green</option>
145
										<option value="FFBA00">Yellow</option>
146
										<option value="DD5F5F">Red</option>
147
										<option value="FF9908">Orange</option>
148
									</select> 
149
									<br />
150
									<input type="hidden" name="MAX_FILE_SIZE" value="999990000" />
151
									<input name="image" type="file" />
152
									<input type="submit" value="SEND" /> 
153
								</form>
154
								<?php } ?>
155
							</div>
156
						</article>
157
							
158
						<article>
159
							<div>
160
								<h2>Donate to JodelBlue</h2>
161
162
								<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
163
								<input type="hidden" name="cmd" value="_s-xclick">
164
								<input type="hidden" name="hosted_button_id" value="RR45538QV3VXE">
165
								<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...
166
								<img alt="" border="0" src="https://www.paypalobjects.com/de_DE/i/scr/pixel.gif" width="1" height="1">
167
								</form>
168
169
								<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...
170
171
								<progress max="3500" value="2111"></progress>
172
								<p>
173
									My payments to keep this Project up so far:
174
								</p>
175
								<ul>
176
									<li>Webspace 15€ - goes till 01-03-2018</li>
177
									<li>Domain 20€ - goes till 06-12-2017</li>
178
								</ul>
179
							</div>
180
						</article>
181
182
						<article>
183
							<div>
184
								<h2>Beta - Votebot</h2>
185
186
								<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...
187
							</div>
188
						</article>
189
					</div>
190
				</aside>
191
			</div>
192
			<?php include 'templates/nav-bottom.php';?>
193
		</div>
194
		<?php
195
			$includeEmojiAndAjax = TRUE;
196
			include 'templates/footer.php';
197
		?>