Completed
Push — master ( fc7130...f4e497 )
by mains
03:18
created
index.php 3 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -616,7 +616,7 @@
 block discarded – undo
616 616
 		<?php  
617 617
 			if(is_file('./piwik-script.html'))
618 618
 			{
619
-			    require_once('./piwik-script.html');
619
+				require_once('./piwik-script.html');
620 620
 			}
621 621
 		?>
622 622
 
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,14 +1,14 @@  discard block
 block discarded – undo
1
-<?php include 'php/jodel-web.php';?>
1
+<?php include 'php/jodel-web.php'; ?>
2 2
 <!DOCTYPE html>
3 3
 <html lang="en">
4 4
 	<head>
5
-		<title><?php echo $viewTest::getTitle($posts[0], $view, $isDetailedView);?></title>
5
+		<title><?php echo $viewTest::getTitle($posts[0], $view, $isDetailedView); ?></title>
6 6
 		
7 7
 		<meta charset="utf-8">
8 8
 		<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
9 9
 		<meta http-equiv="x-ua-compatible" content="ie=edge">
10 10
 		
11
-		<meta name="description" content="<?php echo $viewTest::getMetaDescription($posts[0], $view, $isDetailedView);?>">
11
+		<meta name="description" content="<?php echo $viewTest::getMetaDescription($posts[0], $view, $isDetailedView); ?>">
12 12
 		<meta name="keywords" content="jodelblue, jodel, blue, webclient, web, client, web-app, browser, app">
13 13
 		
14 14
 		<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.5/css/bootstrap.min.css" integrity="sha384-AysaV+vQoT3kOAXZkl02PThvDr8HYKPZhNT5h/CXfBThSRXQ6jW5DO2ekP5ViFdi" crossorigin="anonymous">
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 
91 91
 					<content id="posts">
92 92
 						<?php
93
-							for($i = 0; $i<$loops; $i++)
93
+							for($i = 0; $i < $loops; $i++)
94 94
 							{
95 95
 								if(array_key_exists($i, $posts) && array_key_exists('post_id', $posts[$i]) && isset($posts[$i]['post_id']))
96 96
 								{
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 								<?php if(isset($_GET['postID']) && isset($_GET['getPostDetails'])) { ?>
135 135
 								<h2>Comment on Jodel</h2>
136 136
 								<form method="POST">				
137
-										<input type="hidden" name="ancestor" value="<?php echo htmlspecialchars($_GET['postID']);?>" />
137
+										<input type="hidden" name="ancestor" value="<?php echo htmlspecialchars($_GET['postID']); ?>" />
138 138
 										<textarea id="message" name="message" placeholder="Send a comment on a Jodel to all students within 10km" required></textarea> 
139 139
 									<br />
140 140
 									<input type="submit" value="SEND" /> 
@@ -171,13 +171,13 @@  discard block
 block discarded – undo
171 171
 				<div class="col-xs-12">
172 172
 					<div class="row">
173 173
 						<div class="col-xs-3">
174
-							<a href="index.php" <?php if($view=='time') echo 'class="active"';?>><i class="fa fa-clock-o fa-3x"></i></a>
174
+							<a href="index.php" <?php if($view == 'time') echo 'class="active"'; ?>><i class="fa fa-clock-o fa-3x"></i></a>
175 175
 						</div>
176 176
 						<div class="col-xs-3">
177
-							<a href="index.php?view=comment" <?php if($view=='comment') echo 'class="active"';?>><i class="fa fa-commenting-o fa-3x"></i></a>
177
+							<a href="index.php?view=comment" <?php if($view == 'comment') echo 'class="active"'; ?>><i class="fa fa-commenting-o fa-3x"></i></a>
178 178
 						</div>
179 179
 						<div class="col-xs-3">
180
-							<a href="index.php?view=upVote" <?php if($view=='upVote') echo 'class="active"';?>><i class="fa fa-angle-up fa-3x"></i></a>
180
+							<a href="index.php?view=upVote" <?php if($view == 'upVote') echo 'class="active"'; ?>><i class="fa fa-angle-up fa-3x"></i></a>
181 181
 						</div>
182 182
 						<div class="col-xs-3">
183 183
 							<nav>
Please login to merge, or discard this patch.
Braces   +38 added lines, -9 removed lines patch added patch discarded remove patch
@@ -75,7 +75,11 @@  discard block
 block discarded – undo
75 75
 
76 76
 					<div id="location_mobile" class="hidden-sm-up">
77 77
 						<form method="get">
78
-							<input type="text" id="city_mobile" name="city" placeholder="<?php if(isset($newPositionStatus)) echo $newPositionStatus; ?>" required>
78
+							<input type="text" id="city_mobile" name="city" placeholder="<?php if(isset($newPositionStatus))
79
+{
80
+	echo $newPositionStatus;
81
+}
82
+?>" required>
79 83
 
80 84
 							<input type="submit" id="submit_mobile" class="fa" value="&#xf0ac;" />
81 85
 						</form>
@@ -102,7 +106,9 @@  discard block
 block discarded – undo
102 106
 
103 107
 					</content>
104 108
 					
105
-					<?php if(!isset($_GET['postID']) && !isset($_GET['getPostDetails'])) { ?>
109
+					<?php if(!isset($_GET['postID']) && !isset($_GET['getPostDetails']))
110
+{
111
+?>
106 112
 						<p id="loading">
107 113
 							Loading…
108 114
 						</p>
@@ -115,7 +121,11 @@  discard block
 block discarded – undo
115 121
 							<div>
116 122
 								<h2>Position / Hashtag</h2>
117 123
 								<form method="get">
118
-									<input type="text" id="city" name="city" placeholder="<?php if(isset($newPositionStatus)) echo $newPositionStatus; ?>" required>
124
+									<input type="text" id="city" name="city" placeholder="<?php if(isset($newPositionStatus))
125
+{
126
+	echo $newPositionStatus;
127
+}
128
+?>" required>
119 129
 									<label>try: #jhj</label><br>
120 130
 									<input type="submit" value="Set Location" /> 
121 131
 								</form>
@@ -131,7 +141,9 @@  discard block
 block discarded – undo
131 141
 
132 142
 						<article>
133 143
 							<div>
134
-								<?php if(isset($_GET['postID']) && isset($_GET['getPostDetails'])) { ?>
144
+								<?php if(isset($_GET['postID']) && isset($_GET['getPostDetails']))
145
+{
146
+?>
135 147
 								<h2>Comment on Jodel</h2>
136 148
 								<form method="POST">				
137 149
 										<input type="hidden" name="ancestor" value="<?php echo htmlspecialchars($_GET['postID']);?>" />
@@ -139,7 +151,10 @@  discard block
 block discarded – undo
139 151
 									<br />
140 152
 									<input type="submit" value="SEND" /> 
141 153
 								</form>
142
-									<?php } else { ?>
154
+									<?php }
155
+else
156
+{
157
+?>
143 158
 								<h2>New Jodel</h2>
144 159
 								<form method="POST">
145 160
 									<textarea id="message" name="message" placeholder="Send a Jodel to all students within 10km" required></textarea> 
@@ -171,13 +186,25 @@  discard block
 block discarded – undo
171 186
 				<div class="col-xs-12">
172 187
 					<div class="row">
173 188
 						<div class="col-xs-3">
174
-							<a href="index.php" <?php if($view=='time') echo 'class="active"';?>><i class="fa fa-clock-o fa-3x"></i></a>
189
+							<a href="index.php" <?php if($view=='time')
190
+{
191
+	echo 'class="active"';
192
+}
193
+?>><i class="fa fa-clock-o fa-3x"></i></a>
175 194
 						</div>
176 195
 						<div class="col-xs-3">
177
-							<a href="index.php?view=comment" <?php if($view=='comment') echo 'class="active"';?>><i class="fa fa-commenting-o fa-3x"></i></a>
196
+							<a href="index.php?view=comment" <?php if($view=='comment')
197
+{
198
+	echo 'class="active"';
199
+}
200
+?>><i class="fa fa-commenting-o fa-3x"></i></a>
178 201
 						</div>
179 202
 						<div class="col-xs-3">
180
-							<a href="index.php?view=upVote" <?php if($view=='upVote') echo 'class="active"';?>><i class="fa fa-angle-up fa-3x"></i></a>
203
+							<a href="index.php?view=upVote" <?php if($view=='upVote')
204
+{
205
+	echo 'class="active"';
206
+}
207
+?>><i class="fa fa-angle-up fa-3x"></i></a>
181 208
 						</div>
182 209
 						<div class="col-xs-3">
183 210
 							<nav>
@@ -218,7 +245,9 @@  discard block
 block discarded – undo
218 245
 				    $('html,body').animate({scrollTop: aTag.offset().top-90},'slow');
219 246
 				}
220 247
 
221
-				<?php if(!isset($_GET['postID']) && !isset($_GET['getPostDetails'])) { ?>
248
+				<?php if(!isset($_GET['postID']) && !isset($_GET['getPostDetails']))
249
+{
250
+?>
222 251
 
223 252
 				
224 253
 
Please login to merge, or discard this patch.
php/Jodel.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@
 block discarded – undo
2 2
 
3 3
 class Jodel
4 4
 {
5
-    public $jodel;
5
+	public $jodel;
6 6
 
7 7
    
8 8
 }
9 9
\ No newline at end of file
Please login to merge, or discard this patch.
php/View.php 3 patches
Indentation   +85 added lines, -85 removed lines patch added patch discarded remove patch
@@ -9,75 +9,75 @@  discard block
 block discarded – undo
9 9
 	 * Compute HTML Code
10 10
 	 */
11 11
  	function jodelToHtml($post, $view = 'time', $isDetailedView = FALSE)
12
-    {   //ToDO
13
-        //Replace # with link
14
-        //preg_replace('~(\#)([^\s!,. /()"\'?]+)~', '<a href="tag/$2">#$2</a>', $text);
15
-
16
-        //Time to time difference
17
-        $now = new DateTime();
18
-        $d = new DateTime($post['created_at']);
19
-        $timediff = $now->diff($d);
20
-
21
-        $timediff_inSeconds = (string)$timediff->format('%s');
22
-        $timediff_inMinutes = (string)$timediff->format('%i');
23
-        $timediff_inHours = (string)$timediff->format('%h');
24
-        $timediff_inDays = (string)$timediff->format('%d');
25
-        $timediff_inMonth = (string)$timediff->format('%m');
26
-
27
-        if($timediff_inMonth!=0)
28
-        {
29
-                $timediff = $timediff_inMonth . "m";
30
-        }
31
-        else
32
-        {
33
-            if($timediff_inDays!=0)
34
-            {
35
-                $timediff = $timediff_inDays . "d";
36
-            }
37
-            else
38
-            {
39
-                if($timediff_inHours!=0)
40
-                {
41
-                    $timediff = $timediff_inHours . "h";
42
-                }
43
-                else
44
-                {
45
-                    if($timediff_inMinutes!=0)
46
-                    {
47
-                        $timediff = $timediff_inMinutes . "m";
48
-                    }
49
-                    else
50
-                    {
51
-                        $timediff = $timediff_inSeconds . "s";
52
-                    }
53
-                }
54
-            }
55
-        }
56
-
57
-
58
-        ?>
12
+	{   //ToDO
13
+		//Replace # with link
14
+		//preg_replace('~(\#)([^\s!,. /()"\'?]+)~', '<a href="tag/$2">#$2</a>', $text);
15
+
16
+		//Time to time difference
17
+		$now = new DateTime();
18
+		$d = new DateTime($post['created_at']);
19
+		$timediff = $now->diff($d);
20
+
21
+		$timediff_inSeconds = (string)$timediff->format('%s');
22
+		$timediff_inMinutes = (string)$timediff->format('%i');
23
+		$timediff_inHours = (string)$timediff->format('%h');
24
+		$timediff_inDays = (string)$timediff->format('%d');
25
+		$timediff_inMonth = (string)$timediff->format('%m');
26
+
27
+		if($timediff_inMonth!=0)
28
+		{
29
+				$timediff = $timediff_inMonth . "m";
30
+		}
31
+		else
32
+		{
33
+			if($timediff_inDays!=0)
34
+			{
35
+				$timediff = $timediff_inDays . "d";
36
+			}
37
+			else
38
+			{
39
+				if($timediff_inHours!=0)
40
+				{
41
+					$timediff = $timediff_inHours . "h";
42
+				}
43
+				else
44
+				{
45
+					if($timediff_inMinutes!=0)
46
+					{
47
+						$timediff = $timediff_inMinutes . "m";
48
+					}
49
+					else
50
+					{
51
+						$timediff = $timediff_inSeconds . "s";
52
+					}
53
+				}
54
+			}
55
+		}
56
+
57
+
58
+		?>
59 59
         <article id ="postId-<?php echo $post['post_id']; ?>" class="jodel" style="background-color: #<?php echo $post['color'];?>;">
60 60
             <content>
61 61
                 <?php 
62
-                if(isset($post['image_url']))
63
-                {
64
-                    $regexRest = '/[^\w$ .!?-]+/u';
65
-
66
-                    echo '<img src="' . $post['image_url'] . '" alt="' . htmlspecialchars(preg_replace($regexRest, '', $post['message'])) . '">';
67
-                }
68
-                else {
69
-                    echo str_replace('  ', ' &nbsp;', nl2br(htmlspecialchars($post['message'])));
70
-                }
71
-                ?>
62
+				if(isset($post['image_url']))
63
+				{
64
+					$regexRest = '/[^\w$ .!?-]+/u';
65
+
66
+					echo '<img src="' . $post['image_url'] . '" alt="' . htmlspecialchars(preg_replace($regexRest, '', $post['message'])) . '">';
67
+				}
68
+				else {
69
+					echo str_replace('  ', ' &nbsp;', nl2br(htmlspecialchars($post['message'])));
70
+				}
71
+				?>
72 72
             </content>
73 73
             <aside>
74 74
                 <?php
75
-                    if($isDetailedView)
76
-                    {?>
75
+					if($isDetailedView)
76
+					{?>
77 77
                         <a href="index.php?vote=up&getPostDetails=true&postID=<?php echo $post['post_id'];?>&postID_parent=<?php echo htmlspecialchars($_GET['postID']);?>" rel="nofollow">
78 78
               <?php }
79
-                    else
80
-                    {?>
79
+					else
80
+					{?>
81 81
                         <a href="index.php?vote=up&postID=<?php echo $post['post_id'];?>" rel="nofollow">
82 82
               <?php } ?>
83 83
                             <i class="fa fa-angle-up fa-3x"></i>
@@ -85,12 +85,12 @@  discard block
 block discarded – undo
85 85
                             <br />
86 86
                         <?php echo $post["vote_count"];?><br />
87 87
                 <?php
88
-                    if($isDetailedView)
89
-                    {?>
88
+					if($isDetailedView)
89
+					{?>
90 90
                         <a href="index.php?vote=down&getPostDetails=true&postID=<?php echo $post['post_id'];?>&postID_parent=<?php echo htmlspecialchars($_GET['postID']);?>" rel="nofollow">
91 91
               <?php }
92
-                    else
93
-                    {?>
92
+					else
93
+					{?>
94 94
                         <a href="index.php?vote=down&postID=<?php echo $post['post_id'];?>" rel="nofollow">
95 95
               <?php } ?>
96 96
                             <i class="fa fa-angle-down fa-3x"></i>
@@ -113,39 +113,39 @@  discard block
 block discarded – undo
113 113
                                 <a href="index.php?getPostDetails=true&view=<?php echo $view;?>&postID=<?php echo $post["post_id"];?>">
114 114
                                     <i class="fa fa-commenting-o"></i>
115 115
                                     <?php if(array_key_exists("child_count", $post)) {
116
-                                                echo $post["child_count"];
117
-                                            } else echo "0";
118
-                                    ?>
116
+												echo $post["child_count"];
117
+											} else echo "0";
118
+									?>
119 119
                                     </a>
120 120
                             </span>
121 121
                             <?php } ?>
122 122
                         </td>
123 123
                         <td class="distance">
124 124
                             <?php
125
-                                if($isDetailedView)
126
-                                {
127
-                                    if(isset($post["parent_creator"]) && $post["parent_creator"] == 1)
128
-                                    {
129
-                                        ?>
125
+								if($isDetailedView)
126
+								{
127
+									if(isset($post["parent_creator"]) && $post["parent_creator"] == 1)
128
+									{
129
+										?>
130 130
                                         <span data-tooltip="Author">
131 131
                                             <i class="fa fa-user-o"></i> OJ |
132 132
                                         </span>
133 133
                                         <?php 
134
-                                    }
135
-                                    else
136
-                                    {
137
-                                        //Is not parent Jodel in detailed View
138
-                                        if(!array_key_exists('child_count', $post) && array_key_exists('parent_creator', $post))
139
-                                        {
140
-                                            ?>
134
+									}
135
+									else
136
+									{
137
+										//Is not parent Jodel in detailed View
138
+										if(!array_key_exists('child_count', $post) && array_key_exists('parent_creator', $post))
139
+										{
140
+											?>
141 141
                                             <span data-tooltip="Author">
142 142
                                                 <i class="fa fa-user-o"></i> #<?php echo $post["user_handle"];?> |
143 143
                                             </span>
144 144
                                             <?php
145
-                                        }
146
-                                    }
147
-                                }
148
-                                ?>
145
+										}
146
+									}
147
+								}
148
+								?>
149 149
 
150 150
                             <span class="tip" data-tooltip="Distance">
151 151
                                 <i class="fa fa-map-marker"></i>
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
             </footer>
159 159
         </article>
160 160
     <?php
161
-    }
161
+	}
162 162
 
163 163
 
164 164
 	/**
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -24,25 +24,25 @@  discard block
 block discarded – undo
24 24
         $timediff_inDays = (string)$timediff->format('%d');
25 25
         $timediff_inMonth = (string)$timediff->format('%m');
26 26
 
27
-        if($timediff_inMonth!=0)
27
+        if($timediff_inMonth != 0)
28 28
         {
29 29
                 $timediff = $timediff_inMonth . "m";
30 30
         }
31 31
         else
32 32
         {
33
-            if($timediff_inDays!=0)
33
+            if($timediff_inDays != 0)
34 34
             {
35 35
                 $timediff = $timediff_inDays . "d";
36 36
             }
37 37
             else
38 38
             {
39
-                if($timediff_inHours!=0)
39
+                if($timediff_inHours != 0)
40 40
                 {
41 41
                     $timediff = $timediff_inHours . "h";
42 42
                 }
43 43
                 else
44 44
                 {
45
-                    if($timediff_inMinutes!=0)
45
+                    if($timediff_inMinutes != 0)
46 46
                     {
47 47
                         $timediff = $timediff_inMinutes . "m";
48 48
                     }
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 
57 57
 
58 58
         ?>
59
-        <article id ="postId-<?php echo $post['post_id']; ?>" class="jodel" style="background-color: #<?php echo $post['color'];?>;">
59
+        <article id ="postId-<?php echo $post['post_id']; ?>" class="jodel" style="background-color: #<?php echo $post['color']; ?>;">
60 60
             <content>
61 61
                 <?php 
62 62
                 if(isset($post['image_url']))
@@ -74,24 +74,24 @@  discard block
 block discarded – undo
74 74
                 <?php
75 75
                     if($isDetailedView)
76 76
                     {?>
77
-                        <a href="index.php?vote=up&getPostDetails=true&postID=<?php echo $post['post_id'];?>&postID_parent=<?php echo htmlspecialchars($_GET['postID']);?>" rel="nofollow">
77
+                        <a href="index.php?vote=up&getPostDetails=true&postID=<?php echo $post['post_id']; ?>&postID_parent=<?php echo htmlspecialchars($_GET['postID']); ?>" rel="nofollow">
78 78
               <?php }
79 79
                     else
80 80
                     {?>
81
-                        <a href="index.php?vote=up&postID=<?php echo $post['post_id'];?>" rel="nofollow">
81
+                        <a href="index.php?vote=up&postID=<?php echo $post['post_id']; ?>" rel="nofollow">
82 82
               <?php } ?>
83 83
                             <i class="fa fa-angle-up fa-3x"></i>
84 84
                         </a>    
85 85
                             <br />
86
-                        <?php echo $post["vote_count"];?><br />
86
+                        <?php echo $post["vote_count"]; ?><br />
87 87
                 <?php
88 88
                     if($isDetailedView)
89 89
                     {?>
90
-                        <a href="index.php?vote=down&getPostDetails=true&postID=<?php echo $post['post_id'];?>&postID_parent=<?php echo htmlspecialchars($_GET['postID']);?>" rel="nofollow">
90
+                        <a href="index.php?vote=down&getPostDetails=true&postID=<?php echo $post['post_id']; ?>&postID_parent=<?php echo htmlspecialchars($_GET['postID']); ?>" rel="nofollow">
91 91
               <?php }
92 92
                     else
93 93
                     {?>
94
-                        <a href="index.php?vote=down&postID=<?php echo $post['post_id'];?>" rel="nofollow">
94
+                        <a href="index.php?vote=down&postID=<?php echo $post['post_id']; ?>" rel="nofollow">
95 95
               <?php } ?>
96 96
                             <i class="fa fa-angle-down fa-3x"></i>
97 97
                         </a>
@@ -103,14 +103,14 @@  discard block
 block discarded – undo
103 103
                         <td class="time">
104 104
                             <span class="tip" data-tooltip="Time">
105 105
                                 <i class="fa fa-clock-o"></i>
106
-                                <?php echo $timediff;?>
107
-                                <span class="tiptext"><?php echo $d->format('Y-m-d H:i:s');?></span>
106
+                                <?php echo $timediff; ?>
107
+                                <span class="tiptext"><?php echo $d->format('Y-m-d H:i:s'); ?></span>
108 108
                             </span> 
109 109
                         </td>
110 110
                         <td class="comments">
111 111
                             <?php if(!$isDetailedView) {?>
112 112
                             <span data-tooltip="Comments">
113
-                                <a href="index.php?getPostDetails=true&view=<?php echo $view;?>&postID=<?php echo $post["post_id"];?>">
113
+                                <a href="index.php?getPostDetails=true&view=<?php echo $view; ?>&postID=<?php echo $post["post_id"]; ?>">
114 114
                                     <i class="fa fa-commenting-o"></i>
115 115
                                     <?php if(array_key_exists("child_count", $post)) {
116 116
                                                 echo $post["child_count"];
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
                                         {
140 140
                                             ?>
141 141
                                             <span data-tooltip="Author">
142
-                                                <i class="fa fa-user-o"></i> #<?php echo $post["user_handle"];?> |
142
+                                                <i class="fa fa-user-o"></i> #<?php echo $post["user_handle"]; ?> |
143 143
                                             </span>
144 144
                                             <?php
145 145
                                         }
@@ -149,8 +149,8 @@  discard block
 block discarded – undo
149 149
 
150 150
                             <span class="tip" data-tooltip="Distance">
151 151
                                 <i class="fa fa-map-marker"></i>
152
-                                <?php echo $post['distance'];?> km
153
-                                <span class="tiptext"><?php echo $post['location']['name'];?></span>
152
+                                <?php echo $post['distance']; ?> km
153
+                                <span class="tiptext"><?php echo $post['location']['name']; ?></span>
154 154
                             </span>
155 155
                         </td>
156 156
                     </tr>
Please login to merge, or discard this patch.
Braces   +24 added lines, -12 removed lines patch added patch discarded remove patch
@@ -9,7 +9,8 @@  discard block
 block discarded – undo
9 9
 	 * Compute HTML Code
10 10
 	 */
11 11
  	function jodelToHtml($post, $view = 'time', $isDetailedView = FALSE)
12
-    {   //ToDO
12
+ 	{
13
+//ToDO
13 14
         //Replace # with link
14 15
         //preg_replace('~(\#)([^\s!,. /()"\'?]+)~', '<a href="tag/$2">#$2</a>', $text);
15 16
 
@@ -65,7 +66,8 @@  discard block
 block discarded – undo
65 66
 
66 67
                     echo '<img src="' . $post['image_url'] . '" alt="' . htmlspecialchars(preg_replace($regexRest, '', $post['message'])) . '">';
67 68
                 }
68
-                else {
69
+                else
70
+                {
69 71
                     echo str_replace('  ', ' &nbsp;', nl2br(htmlspecialchars($post['message'])));
70 72
                 }
71 73
                 ?>
@@ -73,11 +75,13 @@  discard block
 block discarded – undo
73 75
             <aside>
74 76
                 <?php
75 77
                     if($isDetailedView)
76
-                    {?>
78
+                    {
79
+?>
77 80
                         <a href="index.php?vote=up&getPostDetails=true&postID=<?php echo $post['post_id'];?>&postID_parent=<?php echo htmlspecialchars($_GET['postID']);?>" rel="nofollow">
78 81
               <?php }
79
-                    else
80
-                    {?>
82
+else
83
+                    {
84
+?>
81 85
                         <a href="index.php?vote=up&postID=<?php echo $post['post_id'];?>" rel="nofollow">
82 86
               <?php } ?>
83 87
                             <i class="fa fa-angle-up fa-3x"></i>
@@ -86,11 +90,13 @@  discard block
 block discarded – undo
86 90
                         <?php echo $post["vote_count"];?><br />
87 91
                 <?php
88 92
                     if($isDetailedView)
89
-                    {?>
93
+                    {
94
+?>
90 95
                         <a href="index.php?vote=down&getPostDetails=true&postID=<?php echo $post['post_id'];?>&postID_parent=<?php echo htmlspecialchars($_GET['postID']);?>" rel="nofollow">
91 96
               <?php }
92
-                    else
93
-                    {?>
97
+else
98
+                    {
99
+?>
94 100
                         <a href="index.php?vote=down&postID=<?php echo $post['post_id'];?>" rel="nofollow">
95 101
               <?php } ?>
96 102
                             <i class="fa fa-angle-down fa-3x"></i>
@@ -108,13 +114,19 @@  discard block
 block discarded – undo
108 114
                             </span> 
109 115
                         </td>
110 116
                         <td class="comments">
111
-                            <?php if(!$isDetailedView) {?>
117
+                            <?php if(!$isDetailedView)
118
+{
119
+?>
112 120
                             <span data-tooltip="Comments">
113 121
                                 <a href="index.php?getPostDetails=true&view=<?php echo $view;?>&postID=<?php echo $post["post_id"];?>">
114 122
                                     <i class="fa fa-commenting-o"></i>
115
-                                    <?php if(array_key_exists("child_count", $post)) {
123
+                                    <?php if(array_key_exists("child_count", $post))
124
+{
116 125
                                                 echo $post["child_count"];
117
-                                            } else echo "0";
126
+                                            }
127
+                                            else {
128
+                                            	echo "0";
129
+                                            }
118 130
                                     ?>
119 131
                                     </a>
120 132
                             </span>
@@ -228,7 +240,7 @@  discard block
 block discarded – undo
228 240
 	}
229 241
 
230 242
 	function getPosts($lastPostId, $accessToken, $url, $version = 'v2')
231
-	{	
243
+	{
232 244
 		$accountCreator = new GetPosts();
233 245
 		$accountCreator->setLastPostId($lastPostId);
234 246
 		$accountCreator->setAccessToken($accessToken);
Please login to merge, or discard this patch.
php/jodel-web.php 4 patches
Indentation   +79 added lines, -79 removed lines patch added patch discarded remove patch
@@ -41,36 +41,36 @@  discard block
 block discarded – undo
41 41
 
42 42
 function isUserBot()
43 43
 {
44
-    preg_match('/bot|spider|google|twitter/i', $_SERVER['HTTP_USER_AGENT'], $matches);
44
+	preg_match('/bot|spider|google|twitter/i', $_SERVER['HTTP_USER_AGENT'], $matches);
45 45
 
46
-    return (isset($matches[0])) ? true : false;
46
+	return (isset($matches[0])) ? true : false;
47 47
 }
48 48
 
49 49
 function configPropertyExists($config, $property)
50 50
 {
51
-    if(!array_key_exists($property, $config) || !isset($config[$property]) || $config[$property] == '' || $config[$property] == 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx')
52
-    {
53
-        return FALSE;
54
-    }
55
-    else
56
-    {
57
-        return TRUE;
58
-    }
51
+	if(!array_key_exists($property, $config) || !isset($config[$property]) || $config[$property] == '' || $config[$property] == 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx')
52
+	{
53
+		return FALSE;
54
+	}
55
+	else
56
+	{
57
+		return TRUE;
58
+	}
59 59
 }
60 60
 
61 61
 function isDeviceUidInDatabase($deviceUid)
62 62
 {
63
-    $db = new DatabaseConnect();  
64
-    $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $deviceUid  . "'");
63
+	$db = new DatabaseConnect();  
64
+	$result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $deviceUid  . "'");
65 65
 
66
-    if ($result->num_rows > 0)
67
-    {
68
-        return TRUE;
69
-    }
70
-    else
71
-    {
72
-        return FALSE;
73
-    }
66
+	if ($result->num_rows > 0)
67
+	{
68
+		return TRUE;
69
+	}
70
+	else
71
+	{
72
+		return FALSE;
73
+	}
74 74
 }
75 75
 
76 76
 	//Check if it's a Spider or Google Bot
@@ -98,14 +98,14 @@  discard block
 block discarded – undo
98 98
 	}
99 99
 	
100 100
 	if(configPropertyExists($config, 'karmaDeviceUid'))
101
-    {
102
-    	$jodelAccountForKarma = new JodelAccount($config['botDeviceUid']);
103
-    }
104
-    else
105
-    {
106
-    	error_log("No Karma deviceUid set in config file");
101
+	{
102
+		$jodelAccountForKarma = new JodelAccount($config['botDeviceUid']);
103
+	}
104
+	else
105
+	{
106
+		error_log("No Karma deviceUid set in config file");
107 107
 		$jodelAccountForKarma = new JodelAccount($deviceUid);
108
-    }
108
+	}
109 109
 
110 110
 	$newPositionStatus = $jodelAccountForView->location->getCityName();
111 111
 
@@ -194,32 +194,32 @@  discard block
 block discarded – undo
194 194
 			if(!array_key_exists(0, $posts))
195 195
 			{
196 196
 				$posts[0] = array(
197
-			    "post_id" => "0",
198
-			    "discovered_by" => 0,
199
-			    "message" => "Not found",
200
-			    "created_at" => "2017-02-11T16:44:50.385Z",
201
-			    "updated_at" => "2017-02-11T16:44:50.385Z",
202
-			    "pin_count" => 0,
203
-			    "color" => "FFBA00",
204
-			    "got_thanks" => FALSE,
205
-			    "post_own" => "friend",
206
-			    "discovered" => 0,
207
-			    "distance" => 9,
208
-			    "vote_count" => 0,
209
-			    "location" =>
210
-			    array("name" => "Berlin",
211
-			      "loc_coordinates" =>
212
-			      array(
213
-			        "lat" => 0,
214
-			        "lng" => 0
215
-			      ),
216
-			      "loc_accuracy" => 0,
217
-			      "country" => "",
218
-			      "city" => "",
219
-			    ),
220
-			    "tags" =>
221
-			    array(),
222
-			    "user_handle" => "0"
197
+				"post_id" => "0",
198
+				"discovered_by" => 0,
199
+				"message" => "Not found",
200
+				"created_at" => "2017-02-11T16:44:50.385Z",
201
+				"updated_at" => "2017-02-11T16:44:50.385Z",
202
+				"pin_count" => 0,
203
+				"color" => "FFBA00",
204
+				"got_thanks" => FALSE,
205
+				"post_own" => "friend",
206
+				"discovered" => 0,
207
+				"distance" => 9,
208
+				"vote_count" => 0,
209
+				"location" =>
210
+				array("name" => "Berlin",
211
+				  "loc_coordinates" =>
212
+				  array(
213
+					"lat" => 0,
214
+					"lng" => 0
215
+				  ),
216
+				  "loc_accuracy" => 0,
217
+				  "country" => "",
218
+				  "city" => "",
219
+				),
220
+				"tags" =>
221
+				array(),
222
+				"user_handle" => "0"
223 223
 			 );
224 224
 			}
225 225
 		}
@@ -228,32 +228,32 @@  discard block
 block discarded – undo
228 228
 			$posts = array();
229 229
 			$posts[0] = 
230 230
 			array(
231
-			    "post_id" => "0",
232
-			    "discovered_by" => 0,
233
-			    "message" => "Bad Request",
234
-			    "created_at" => "2017-02-11T16:44:50.385Z",
235
-			    "updated_at" => "2017-02-11T16:44:50.385Z",
236
-			    "pin_count" => 0,
237
-			    "color" => "FFBA00",
238
-			    "got_thanks" => FALSE,
239
-			    "post_own" => "friend",
240
-			    "discovered" => 0,
241
-			    "distance" => 9,
242
-			    "vote_count" => 0,
243
-			    "location" =>
244
-			    array("name" => "Berlin",
245
-			      "loc_coordinates" =>
246
-			      array(
247
-			        "lat" => 0,
248
-			        "lng" => 0
249
-			      ),
250
-			      "loc_accuracy" => 0,
251
-			      "country" => "",
252
-			      "city" => "",
253
-			    ),
254
-			    "tags" =>
255
-			    array(),
256
-			    "user_handle" => "0"
231
+				"post_id" => "0",
232
+				"discovered_by" => 0,
233
+				"message" => "Bad Request",
234
+				"created_at" => "2017-02-11T16:44:50.385Z",
235
+				"updated_at" => "2017-02-11T16:44:50.385Z",
236
+				"pin_count" => 0,
237
+				"color" => "FFBA00",
238
+				"got_thanks" => FALSE,
239
+				"post_own" => "friend",
240
+				"discovered" => 0,
241
+				"distance" => 9,
242
+				"vote_count" => 0,
243
+				"location" =>
244
+				array("name" => "Berlin",
245
+				  "loc_coordinates" =>
246
+				  array(
247
+					"lat" => 0,
248
+					"lng" => 0
249
+				  ),
250
+				  "loc_accuracy" => 0,
251
+				  "country" => "",
252
+				  "city" => "",
253
+				),
254
+				"tags" =>
255
+				array(),
256
+				"user_handle" => "0"
257 257
 			 );
258 258
 
259 259
 
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 {
44 44
     preg_match('/bot|spider|google|twitter/i', $_SERVER['HTTP_USER_AGENT'], $matches);
45 45
 
46
-    return (isset($matches[0])) ? true : false;
46
+    return (isset($matches[0]))?true : false;
47 47
 }
48 48
 
49 49
 function configPropertyExists($config, $property)
@@ -61,9 +61,9 @@  discard block
 block discarded – undo
61 61
 function isDeviceUidInDatabase($deviceUid)
62 62
 {
63 63
     $db = new DatabaseConnect();  
64
-    $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $deviceUid  . "'");
64
+    $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $deviceUid . "'");
65 65
 
66
-    if ($result->num_rows > 0)
66
+    if($result->num_rows > 0)
67 67
     {
68 68
         return TRUE;
69 69
     }
@@ -86,8 +86,8 @@  discard block
 block discarded – undo
86 86
 		{
87 87
 			//$deviceUid = createAccount();
88 88
 			$jodelAccountForView = new JodelAccount();
89
-			setcookie('JodelDeviceId', $jodelAccountForView->deviceUid, time()+60*60*24*365*10);
90
-			error_log('Created account with JodelDeviceId:' . $jodelAccountForView->deviceUid .  ' for [' . $_SERVER ['HTTP_USER_AGENT'] . ']');
89
+			setcookie('JodelDeviceId', $jodelAccountForView->deviceUid, time() + 60 * 60 * 24 * 365 * 10);
90
+			error_log('Created account with JodelDeviceId:' . $jodelAccountForView->deviceUid . ' for [' . $_SERVER ['HTTP_USER_AGENT'] . ']');
91 91
 			
92 92
 		}
93 93
 		else
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
 	//Set View
116 116
 	if(isset($_GET['view']))
117 117
 	{
118
-		switch ($_GET['view']) {
118
+		switch($_GET['view']) {
119 119
 			case 'comment':
120 120
 				$view = 'comment';
121 121
 				break;
@@ -313,13 +313,13 @@  discard block
 block discarded – undo
313 313
 		else
314 314
 		{
315 315
 			$version = 'v2';
316
-			if($view=='comment')
316
+			if($view == 'comment')
317 317
 			{
318 318
 				$url = "/v2/posts/location/discussed/";
319 319
 			}
320 320
 			else
321 321
 			{
322
-				if($view=='upVote')
322
+				if($view == 'upVote')
323 323
 				{
324 324
 					$url = "/v2/posts/location/popular/";
325 325
 				}
Please login to merge, or discard this patch.
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 	}
99 99
 	
100 100
 	if(configPropertyExists($config, 'karmaDeviceUid'))
101
-    {
101
+	{
102 102
     	$jodelAccountForKarma = new JodelAccount($config['botDeviceUid']);
103 103
     }
104 104
     else
@@ -115,7 +115,8 @@  discard block
 block discarded – undo
115 115
 	//Set View
116 116
 	if(isset($_GET['view']))
117 117
 	{
118
-		switch ($_GET['view']) {
118
+		switch ($_GET['view'])
119
+		{
119 120
 			case 'comment':
120 121
 				$view = 'comment';
121 122
 				break;
@@ -160,7 +161,7 @@  discard block
 block discarded – undo
160 161
 
161 162
 
162 163
 	function getPosts($lastPostId, $accessToken, $url, $version = 'v2')
163
-	{	
164
+	{
164 165
 		$accountCreator = new GetPosts();
165 166
 		$accountCreator->setLastPostId($lastPostId);
166 167
 		$accountCreator->setAccessToken($accessToken);
@@ -281,7 +282,8 @@  discard block
 block discarded – undo
281 282
 
282 283
 			$posts[0] = $data;
283 284
 
284
-			if(array_key_exists('children', $data)) {
285
+			if(array_key_exists('children', $data))
286
+			{
285 287
 				foreach($data['children'] as $key => $child)
286 288
 				{
287 289
 					
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@
 block discarded – undo
43 43
 {
44 44
     preg_match('/bot|spider|google|twitter/i', $_SERVER['HTTP_USER_AGENT'], $matches);
45 45
 
46
-    return (isset($matches[0])) ? true : false;
46
+    return (isset($matches[0])) ? TRUE : FALSE;
47 47
 }
48 48
 
49 49
 function configPropertyExists($config, $property)
Please login to merge, or discard this patch.
php/JodelAccount.php 4 patches
Indentation   +389 added lines, -389 removed lines patch added patch discarded remove patch
@@ -2,437 +2,437 @@
 block discarded – undo
2 2
 
3 3
 class JodelAccount
4 4
 {
5
-    public $accessToken;
6
-    public $expirationDate;
7
-    public $refreshToken;
8
-    public $distinctId;
9
-    public $deviceUid;
10
-
11
-    //is the Account a Bot or Spider?
12
-    public $isBot;
5
+	public $accessToken;
6
+	public $expirationDate;
7
+	public $refreshToken;
8
+	public $distinctId;
9
+	public $deviceUid;
10
+
11
+	//is the Account a Bot or Spider?
12
+	public $isBot;
13 13
     
14
-    // array of voted Jodels
15
-    public $votes;
16
-
17
-    //Location of the Account
18
-    public $location;
19
-
20
-    function __construct($deviceUid = NULL, $isBot = FALSE)
21
-    {
22
-        if($deviceUid == NULL)
23
-        {
24
-            //Create New Account
25
-            $this->deviceUid = $deviceUid;
26
-        }
27
-        else
28
-        {
29
-            $this->deviceUid = $deviceUid;
30
-        }
31
-
32
-        $this->isBot        = $isBot;
33
-        $this->location     = $this::getLocation();
34
-
35
-        if(!$this::isTokenFresh())
36
-        {
37
-            $this::refreshToken();
38
-        }
39
-        $this->accessToken  = $this::getAccessToken();
40
-
41
-
42
-    }
43
-
44
-    function isAccountVerified()
45
-    {
46
-        $accountCreator = new GetUserConfig();
47
-        $accountCreator->setAccessToken($this->accessToken);
48
-        $data = $accountCreator->execute();
49
-
50
-        return $data['verified'];
51
-    }
52
-
53
-    function setLocation()
54
-    {
55
-        //Is Channel or City
56
-        if(substr($_GET['city'], 0, 1) === '#')
57
-        {
58
-            return htmlspecialchars($_GET['city']) . " " . $this->location->cityName;
59
-        }                
60
-        else
61
-        {
62
-            $url = 'https://maps.googleapis.com/maps/api/geocode/json?address=' . htmlspecialchars($_GET['city']) . '&key=AIzaSyCwhnja-or07012HqrhPW7prHEDuSvFT4w';
63
-            $result = Requests::post($url);
64
-            if(json_decode($result->body, true)['status'] == 'ZERO_RESULTS' || json_decode($result->body, true)['status'] == 'INVALID_REQUEST')
65
-            {
66
-                return "0 results";
67
-            }
68
-            else
69
-            {
70
-                $name = json_decode($result->body, true)['results']['0']['address_components']['0']['long_name'];
71
-                $lat = json_decode($result->body, true)['results']['0']['geometry']['location']['lat'];
72
-                $lng = json_decode($result->body, true)['results']['0']['geometry']['location']['lng'];
73
-
74
-                $location = new Location();
75
-                $location->setLat($lat);
76
-                $location->setLng($lng);
77
-                $location->setCityName($name);
78
-                $accountCreator = new UpdateLocation();
79
-                $accountCreator->setLocation($location);
80
-                $accountCreator->setAccessToken($this->accessToken);
81
-                $data = $accountCreator->execute();
82
-
83
-                //safe location to db
84
-                $db = new DatabaseConnect();
85
-
86
-                if($data == 'Success')
87
-                {
88
-                    $result = $db->query("UPDATE accounts 
14
+	// array of voted Jodels
15
+	public $votes;
16
+
17
+	//Location of the Account
18
+	public $location;
19
+
20
+	function __construct($deviceUid = NULL, $isBot = FALSE)
21
+	{
22
+		if($deviceUid == NULL)
23
+		{
24
+			//Create New Account
25
+			$this->deviceUid = $deviceUid;
26
+		}
27
+		else
28
+		{
29
+			$this->deviceUid = $deviceUid;
30
+		}
31
+
32
+		$this->isBot        = $isBot;
33
+		$this->location     = $this::getLocation();
34
+
35
+		if(!$this::isTokenFresh())
36
+		{
37
+			$this::refreshToken();
38
+		}
39
+		$this->accessToken  = $this::getAccessToken();
40
+
41
+
42
+	}
43
+
44
+	function isAccountVerified()
45
+	{
46
+		$accountCreator = new GetUserConfig();
47
+		$accountCreator->setAccessToken($this->accessToken);
48
+		$data = $accountCreator->execute();
49
+
50
+		return $data['verified'];
51
+	}
52
+
53
+	function setLocation()
54
+	{
55
+		//Is Channel or City
56
+		if(substr($_GET['city'], 0, 1) === '#')
57
+		{
58
+			return htmlspecialchars($_GET['city']) . " " . $this->location->cityName;
59
+		}                
60
+		else
61
+		{
62
+			$url = 'https://maps.googleapis.com/maps/api/geocode/json?address=' . htmlspecialchars($_GET['city']) . '&key=AIzaSyCwhnja-or07012HqrhPW7prHEDuSvFT4w';
63
+			$result = Requests::post($url);
64
+			if(json_decode($result->body, true)['status'] == 'ZERO_RESULTS' || json_decode($result->body, true)['status'] == 'INVALID_REQUEST')
65
+			{
66
+				return "0 results";
67
+			}
68
+			else
69
+			{
70
+				$name = json_decode($result->body, true)['results']['0']['address_components']['0']['long_name'];
71
+				$lat = json_decode($result->body, true)['results']['0']['geometry']['location']['lat'];
72
+				$lng = json_decode($result->body, true)['results']['0']['geometry']['location']['lng'];
73
+
74
+				$location = new Location();
75
+				$location->setLat($lat);
76
+				$location->setLng($lng);
77
+				$location->setCityName($name);
78
+				$accountCreator = new UpdateLocation();
79
+				$accountCreator->setLocation($location);
80
+				$accountCreator->setAccessToken($this->accessToken);
81
+				$data = $accountCreator->execute();
82
+
83
+				//safe location to db
84
+				$db = new DatabaseConnect();
85
+
86
+				if($data == 'Success')
87
+				{
88
+					$result = $db->query("UPDATE accounts 
89 89
                             SET name='" . $name . "',
90 90
                                 lat='" . $lat . "',
91 91
                                 lng='" . $lng . "'
92 92
                             WHERE access_token='" . $this->accessToken . "'");
93 93
 
94
-                    if($result === false)
95
-                    {
96
-                            echo "Updating location failed: (" . $db->errno . ") " . $db->error;
97
-                    }
98
-                    else
99
-                    {
100
-                        error_log('User with JodelDeviceId:' . $this->deviceUid .  ' [' . $_SERVER['REMOTE_ADDR'] . '][' . $_SERVER ['HTTP_USER_AGENT'] . '] changed to Location: ' . $name);
101
-                    }
102
-                }
103
-
104
-                return $name;
105
-            }
106
-        }
107
-    }
108
-
109
-    function getLocation()
110
-    {
111
-        $db = new DatabaseConnect();
112
-        $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid  . "'");
94
+					if($result === false)
95
+					{
96
+							echo "Updating location failed: (" . $db->errno . ") " . $db->error;
97
+					}
98
+					else
99
+					{
100
+						error_log('User with JodelDeviceId:' . $this->deviceUid .  ' [' . $_SERVER['REMOTE_ADDR'] . '][' . $_SERVER ['HTTP_USER_AGENT'] . '] changed to Location: ' . $name);
101
+					}
102
+				}
103
+
104
+				return $name;
105
+			}
106
+		}
107
+	}
108
+
109
+	function getLocation()
110
+	{
111
+		$db = new DatabaseConnect();
112
+		$result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid  . "'");
113 113
         
114
-        $location = new Location();
114
+		$location = new Location();
115 115
         
116
-        if ($result->num_rows > 0)
117
-        {
118
-            // output data of each row
119
-            while($row = $result->fetch_assoc())
120
-            {
121
-                $location->setLat($row['lat']);
122
-                $location->setLng($row['lng']);
123
-                $location->setCityName($row['name']);
124
-            }
125
-        }
126
-        else
127
-        {
128
-            echo "Error: 0 results";
129
-            error_log("Error no Location found - getLocation");
130
-        }
131
-
132
-        return $location;
133
-    }
134
-
135
-    function verifyCaptcha()
136
-    {
137
-        $solution = $_GET['solution'];
138
-        $solution = array_map('intval', explode('-', $solution));
139
-
140
-        $accountCreator = new PostCaptcha();
141
-        $accountCreator->setAccessToken($this->accessToken);
142
-        $accountCreator->captchaKey = $_GET['key'];
143
-        $accountCreator->captchaSolution = $solution;
144
-        $verified = $accountCreator->execute();
145
-
146
-        return $verified['verified'];
147
-    }
148
-
149
-    //ToDo Spider Check
150
-    function votePostId()
151
-    {
152
-        if(!$this->isAccountVerified())
153
-        {
154
-            $view = new View();
155
-            $view->showCaptcha($this->accessToken);
156
-        }
157
-
158
-        if(!$this->deviceUidHasVotedThisPostId($_GET['postID']))
159
-        {
160
-            if($_GET['vote'] == "up")
161
-            {
162
-                $accountCreator = new Upvote();
163
-            }
164
-            else if($_GET['vote'] == "down")
165
-            {
166
-                $accountCreator = new Downvote();
167
-            }
168
-            $accountCreator->setAccessToken($this->accessToken);
169
-            $accountCreator->postId = htmlspecialchars($_GET['postID']);
170
-            $data = $accountCreator->execute();
171
-
172
-
173
-            $this->addVoteWithPostIdAndTypeToDeviceUid($_GET['postID'], $_GET['vote']);
174
-        }
116
+		if ($result->num_rows > 0)
117
+		{
118
+			// output data of each row
119
+			while($row = $result->fetch_assoc())
120
+			{
121
+				$location->setLat($row['lat']);
122
+				$location->setLng($row['lng']);
123
+				$location->setCityName($row['name']);
124
+			}
125
+		}
126
+		else
127
+		{
128
+			echo "Error: 0 results";
129
+			error_log("Error no Location found - getLocation");
130
+		}
131
+
132
+		return $location;
133
+	}
134
+
135
+	function verifyCaptcha()
136
+	{
137
+		$solution = $_GET['solution'];
138
+		$solution = array_map('intval', explode('-', $solution));
139
+
140
+		$accountCreator = new PostCaptcha();
141
+		$accountCreator->setAccessToken($this->accessToken);
142
+		$accountCreator->captchaKey = $_GET['key'];
143
+		$accountCreator->captchaSolution = $solution;
144
+		$verified = $accountCreator->execute();
145
+
146
+		return $verified['verified'];
147
+	}
148
+
149
+	//ToDo Spider Check
150
+	function votePostId()
151
+	{
152
+		if(!$this->isAccountVerified())
153
+		{
154
+			$view = new View();
155
+			$view->showCaptcha($this->accessToken);
156
+		}
157
+
158
+		if(!$this->deviceUidHasVotedThisPostId($_GET['postID']))
159
+		{
160
+			if($_GET['vote'] == "up")
161
+			{
162
+				$accountCreator = new Upvote();
163
+			}
164
+			else if($_GET['vote'] == "down")
165
+			{
166
+				$accountCreator = new Downvote();
167
+			}
168
+			$accountCreator->setAccessToken($this->accessToken);
169
+			$accountCreator->postId = htmlspecialchars($_GET['postID']);
170
+			$data = $accountCreator->execute();
171
+
172
+
173
+			$this->addVoteWithPostIdAndTypeToDeviceUid($_GET['postID'], $_GET['vote']);
174
+		}
175 175
 
176 176
         
177
-        if(isset($_GET['getPostDetails']) && isset($_GET['getPostDetails']))
178
-        {
179
-            header('Location: index.php?getPostDetails=true&postID=' . htmlspecialchars($_GET['postID_parent']) . '#postId-' . htmlspecialchars($_GET['postID']));
180
-        }
181
-        else
182
-        {
183
-            header("Location: index.php#postId-" . htmlspecialchars($_GET['postID']));
184
-        }   
185
-        die();
186
-    }
187
-
188
-    //ToDo Spider Check
189
-    function sendJodel()
190
-    {
191
-        if(!$this->isAccountVerified())
192
-        {
193
-            showCaptcha($this->accessToken);
194
-        }
195
-
196
-        $accountCreator = new SendJodel();
197
-
198
-        if(isset($_POST['ancestor']))
199
-        {
200
-            $ancestor = $_POST['ancestor'];
201
-            $accountCreator->ancestor = $ancestor;
202
-        }
203
-        if(isset($_POST['color']))
204
-        {
205
-            $color = $_POST['color'];
206
-            switch ($color) {
207
-                case '8ABDB0':
208
-                    $color = '8ABDB0';
209
-                    break;
210
-                case '9EC41C':
211
-                    $color = '9EC41C';
212
-                    break;
213
-                case '06A3CB':
214
-                    $color = '06A3CB';
215
-                    break;
216
-                case 'FFBA00':
217
-                    $color = 'FFBA00';
218
-                    break;
219
-                case 'DD5F5F':
220
-                    $color = 'DD5F5F';
221
-                    break;
222
-                case 'FF9908':
223
-                    $color = 'FF9908';
224
-                    break;
225
-                default:
226
-                    $color = '8ABDB0';
227
-                    break;
228
-            }
229
-            $accountCreator->color = $color;
230
-        }
231
-
232
-        $accountCreatorLocation = new UpdateLocation();
233
-        $accountCreatorLocation->setLocation($this->location);
234
-        $accountCreatorLocation->setAccessToken($this->accessToken);
235
-        $data = $accountCreatorLocation->execute();
177
+		if(isset($_GET['getPostDetails']) && isset($_GET['getPostDetails']))
178
+		{
179
+			header('Location: index.php?getPostDetails=true&postID=' . htmlspecialchars($_GET['postID_parent']) . '#postId-' . htmlspecialchars($_GET['postID']));
180
+		}
181
+		else
182
+		{
183
+			header("Location: index.php#postId-" . htmlspecialchars($_GET['postID']));
184
+		}   
185
+		die();
186
+	}
187
+
188
+	//ToDo Spider Check
189
+	function sendJodel()
190
+	{
191
+		if(!$this->isAccountVerified())
192
+		{
193
+			showCaptcha($this->accessToken);
194
+		}
195
+
196
+		$accountCreator = new SendJodel();
197
+
198
+		if(isset($_POST['ancestor']))
199
+		{
200
+			$ancestor = $_POST['ancestor'];
201
+			$accountCreator->ancestor = $ancestor;
202
+		}
203
+		if(isset($_POST['color']))
204
+		{
205
+			$color = $_POST['color'];
206
+			switch ($color) {
207
+				case '8ABDB0':
208
+					$color = '8ABDB0';
209
+					break;
210
+				case '9EC41C':
211
+					$color = '9EC41C';
212
+					break;
213
+				case '06A3CB':
214
+					$color = '06A3CB';
215
+					break;
216
+				case 'FFBA00':
217
+					$color = 'FFBA00';
218
+					break;
219
+				case 'DD5F5F':
220
+					$color = 'DD5F5F';
221
+					break;
222
+				case 'FF9908':
223
+					$color = 'FF9908';
224
+					break;
225
+				default:
226
+					$color = '8ABDB0';
227
+					break;
228
+			}
229
+			$accountCreator->color = $color;
230
+		}
231
+
232
+		$accountCreatorLocation = new UpdateLocation();
233
+		$accountCreatorLocation->setLocation($this->location);
234
+		$accountCreatorLocation->setAccessToken($this->accessToken);
235
+		$data = $accountCreatorLocation->execute();
236 236
         
237
-        $accountCreator->location = $this->location;
237
+		$accountCreator->location = $this->location;
238 238
         
239
-        $accountCreator->setAccessToken($this->accessToken);
240
-        $data = $accountCreator->execute();
241
-
242
-        if(isset($_POST['ancestor']))
243
-        {
244
-            $actual_link = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
245
-            header('Location: ' . $actual_link . '#postId-' . htmlspecialchars($data['post_id']));
246
-            exit;
247
-        }
248
-        else
249
-        {
250
-            header('Location: ./#');
251
-            exit;
252
-        }
253
-    }
254
-
255
-    function isTokenFresh()
256
-    {
257
-        $db = new DatabaseConnect();  
258
-        $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'");
259
-
260
-        $access_token;
261
-
262
-        if ($result->num_rows > 0)
263
-        {
264
-                // output data of each row
265
-                while($row = $result->fetch_assoc()) {
266
-                        //$access_token = $row["access_token"];
267
-                        $expiration_date = $row["expiration_date"];
268
-                        $deviceUid = $row["device_uid"];
269
-                        $access_token = $row["access_token"];
270
-                }
271
-        }
272
-        else
273
-        {
274
-                echo '0 results';
275
-        }
276
-
277
-        if($expiration_date <= time()) {
278
-            $accountCreator = new CreateUser();
279
-            $accountCreator->setAccessToken($access_token);
280
-            $accountCreator->setDeviceUid($deviceUid);
281
-            $accountCreator->setLocation($this->location);
282
-            $data = $accountCreator->execute();
283
-
284
-            $access_token = (string)$data[0]['access_token'];
285
-            $expiration_date = $data[0]['expiration_date'];
286
-            $device_uid = (string)$data[1];
239
+		$accountCreator->setAccessToken($this->accessToken);
240
+		$data = $accountCreator->execute();
241
+
242
+		if(isset($_POST['ancestor']))
243
+		{
244
+			$actual_link = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
245
+			header('Location: ' . $actual_link . '#postId-' . htmlspecialchars($data['post_id']));
246
+			exit;
247
+		}
248
+		else
249
+		{
250
+			header('Location: ./#');
251
+			exit;
252
+		}
253
+	}
254
+
255
+	function isTokenFresh()
256
+	{
257
+		$db = new DatabaseConnect();  
258
+		$result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'");
259
+
260
+		$access_token;
261
+
262
+		if ($result->num_rows > 0)
263
+		{
264
+				// output data of each row
265
+				while($row = $result->fetch_assoc()) {
266
+						//$access_token = $row["access_token"];
267
+						$expiration_date = $row["expiration_date"];
268
+						$deviceUid = $row["device_uid"];
269
+						$access_token = $row["access_token"];
270
+				}
271
+		}
272
+		else
273
+		{
274
+				echo '0 results';
275
+		}
276
+
277
+		if($expiration_date <= time()) {
278
+			$accountCreator = new CreateUser();
279
+			$accountCreator->setAccessToken($access_token);
280
+			$accountCreator->setDeviceUid($deviceUid);
281
+			$accountCreator->setLocation($this->location);
282
+			$data = $accountCreator->execute();
283
+
284
+			$access_token = (string)$data[0]['access_token'];
285
+			$expiration_date = $data[0]['expiration_date'];
286
+			$device_uid = (string)$data[1];
287 287
             
288
-            $db = new DatabaseConnect();  
289
-            $result = $db->query("UPDATE accounts 
288
+			$db = new DatabaseConnect();  
289
+			$result = $db->query("UPDATE accounts 
290 290
                                     SET access_token='" . $access_token . "',
291 291
                                         expiration_date='" . $expiration_date . "'
292 292
                                     WHERE device_uid='" . $device_uid . "'");
293 293
 
294
-            if($result === false){
295
-                    echo "Adding account failed: (" . $db->errno . ") " . $db->error;
296
-            }   
297
-        }
294
+			if($result === false){
295
+					echo "Adding account failed: (" . $db->errno . ") " . $db->error;
296
+			}   
297
+		}
298 298
         
299
-        return $access_token;
300
-    }
299
+		return $access_token;
300
+	}
301 301
 
302
-    function refreshToken()
303
-    {
302
+	function refreshToken()
303
+	{
304 304
 
305
-    }
305
+	}
306 306
 
307 307
 
308 308
 
309
-    function getAccessToken()
310
-    {
311
-        $db = new DatabaseConnect();
312
-        $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid  . "'");
309
+	function getAccessToken()
310
+	{
311
+		$db = new DatabaseConnect();
312
+		$result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid  . "'");
313 313
         
314
-        $accessToken;
314
+		$accessToken;
315 315
         
316
-        if ($result->num_rows > 0)
317
-        {
318
-            // output data of each row
319
-            while($row = $result->fetch_assoc())
320
-            {
321
-                $accessToken = $row['access_token'];
322
-            }
323
-        }
324
-        else
325
-        {
326
-            echo "Error: 0 results";
327
-        }
328
-
329
-        return $accessToken;
330
-    }
331
-
332
-
333
-    function getKarma()
334
-    {
335
-        $accountCreator = new GetKarma();
336
-        $accountCreator->setAccessToken($this->accessToken);
337
-        $data = $accountCreator->execute();
316
+		if ($result->num_rows > 0)
317
+		{
318
+			// output data of each row
319
+			while($row = $result->fetch_assoc())
320
+			{
321
+				$accessToken = $row['access_token'];
322
+			}
323
+		}
324
+		else
325
+		{
326
+			echo "Error: 0 results";
327
+		}
328
+
329
+		return $accessToken;
330
+	}
331
+
332
+
333
+	function getKarma()
334
+	{
335
+		$accountCreator = new GetKarma();
336
+		$accountCreator->setAccessToken($this->accessToken);
337
+		$data = $accountCreator->execute();
338 338
         
339
-        return $data["karma"];
340
-    }
339
+		return $data["karma"];
340
+	}
341 341
 
342
-    function deviceUidHasVotedThisPostId($postId)
343
-    {
344
-        $db = new DatabaseConnect();
342
+	function deviceUidHasVotedThisPostId($postId)
343
+	{
344
+		$db = new DatabaseConnect();
345 345
 
346
-        $postId = $db->real_escape_string($postId);
346
+		$postId = $db->real_escape_string($postId);
347 347
 
348
-        $result = $db->query("SELECT id
348
+		$result = $db->query("SELECT id
349 349
                               FROM votes
350 350
                               WHERE (postId = '" . $postId . "' AND device_uid = '" . $this->deviceUid . "')");
351 351
         
352
-        if($result === false)
353
-        {
354
-            $error = db_error();
355
-            echo $error;
356
-            echo "Adding Vote failed: (" . $result->errno . ") " . $result->error;
357
-        }
358
-
359
-        if($result->num_rows == 0)
360
-        {
361
-            return FALSE;
362
-        }
363
-        else
364
-        {
365
-            return TRUE;
366
-        }
367
-    }
368
-
369
-    function addVoteWithPostIdAndTypeToDeviceUid($postId, $voteType)
370
-    {
371
-        $db = new DatabaseConnect();  
372
-
373
-        $postId = $db->real_escape_string($postId);
374
-        $voteType = $db->real_escape_string($voteType);
352
+		if($result === false)
353
+		{
354
+			$error = db_error();
355
+			echo $error;
356
+			echo "Adding Vote failed: (" . $result->errno . ") " . $result->error;
357
+		}
358
+
359
+		if($result->num_rows == 0)
360
+		{
361
+			return FALSE;
362
+		}
363
+		else
364
+		{
365
+			return TRUE;
366
+		}
367
+	}
368
+
369
+	function addVoteWithPostIdAndTypeToDeviceUid($postId, $voteType)
370
+	{
371
+		$db = new DatabaseConnect();  
372
+
373
+		$postId = $db->real_escape_string($postId);
374
+		$voteType = $db->real_escape_string($voteType);
375 375
         
376
-        if($this->deviceUidHasVotedThisPostId($postId))
377
-        {
378
-            return "Already voted";
379
-        }
376
+		if($this->deviceUidHasVotedThisPostId($postId))
377
+		{
378
+			return "Already voted";
379
+		}
380 380
 
381
-        $result = $db->query("INSERT INTO votes (device_uid, postId, type)
381
+		$result = $db->query("INSERT INTO votes (device_uid, postId, type)
382 382
                         VALUES ('" . $this->deviceUid . "','" . $postId . "','" . $voteType . "')");
383 383
         
384
-        if($result === false){
385
-                $error = db_error();
386
-                echo $error;
387
-                echo "Adding Vote failed: (" . $result->errno . ") " . $result->error;
388
-        }       
389
-    }
390
-
391
-    function registerAccount($location) {
392
-        $accountCreator = new CreateUser();
393
-        $accountCreator->setLocation($location);
394
-        $data = $accountCreator->execute();
384
+		if($result === false){
385
+				$error = db_error();
386
+				echo $error;
387
+				echo "Adding Vote failed: (" . $result->errno . ") " . $result->error;
388
+		}       
389
+	}
390
+
391
+	function registerAccount($location) {
392
+		$accountCreator = new CreateUser();
393
+		$accountCreator->setLocation($location);
394
+		$data = $accountCreator->execute();
395 395
         
396
-        $access_token = (string)$data[0]['access_token'];
397
-        $refresh_token = (string)$data[0]['refresh_token'];
398
-        $token_type = (string)$data[0]['token_type'];
399
-        $expires_in = $data[0]['expires_in'];
400
-        $expiration_date = $data[0]['expiration_date'];
401
-        $distinct_id = (string)$data[0]['distinct_id'];
402
-        $device_uid = (string)$data[1];
403
-
404
-        $name = $location->cityName;
405
-        $lat = $location->lat;
406
-        $lng = $location->lng;
396
+		$access_token = (string)$data[0]['access_token'];
397
+		$refresh_token = (string)$data[0]['refresh_token'];
398
+		$token_type = (string)$data[0]['token_type'];
399
+		$expires_in = $data[0]['expires_in'];
400
+		$expiration_date = $data[0]['expiration_date'];
401
+		$distinct_id = (string)$data[0]['distinct_id'];
402
+		$device_uid = (string)$data[1];
403
+
404
+		$name = $location->cityName;
405
+		$lat = $location->lat;
406
+		$lng = $location->lng;
407 407
         
408
-        $db = new DatabaseConnect();  
409
-        $result = $db->query("INSERT INTO accounts (access_token, refresh_token, token_type,
408
+		$db = new DatabaseConnect();  
409
+		$result = $db->query("INSERT INTO accounts (access_token, refresh_token, token_type,
410 410
                         expires_in, expiration_date, distinct_id, device_uid, name, lat, lng)
411 411
                         VALUES ('" . $access_token . "','" . $refresh_token . "','" . $token_type .
412
-                        "','" .  $expires_in . "','" . $expiration_date . "','" . $distinct_id .
413
-                        "','" . $device_uid . "','" . $name . "','" . $lat . "','" . $lng . "') ");
414
-
415
-        $success = TRUE;
416
-        if($result === false){
417
-                $error = db_error();
418
-                echo $error;
419
-                echo "Adding account failed: (" . $result->errno . ") " . $result->error;
420
-                $success = FALSE;
421
-        }   
412
+						"','" .  $expires_in . "','" . $expiration_date . "','" . $distinct_id .
413
+						"','" . $device_uid . "','" . $name . "','" . $lat . "','" . $lng . "') ");
414
+
415
+		$success = TRUE;
416
+		if($result === false){
417
+				$error = db_error();
418
+				echo $error;
419
+				echo "Adding account failed: (" . $result->errno . ") " . $result->error;
420
+				$success = FALSE;
421
+		}   
422 422
         
423
-        return $device_uid;
424
-    }
423
+		return $device_uid;
424
+	}
425 425
 
426
-    function createAccount()
427
-    {
428
-        $config = parse_ini_file('config/config.ini.php');
429
-        $location = new Location();
430
-        $location->setLat($config['default_lat']);
431
-        $location->setLng($config['default_lng']);
432
-        $location->setCityName($config['default_location']);
426
+	function createAccount()
427
+	{
428
+		$config = parse_ini_file('config/config.ini.php');
429
+		$location = new Location();
430
+		$location->setLat($config['default_lat']);
431
+		$location->setLng($config['default_lng']);
432
+		$location->setCityName($config['default_location']);
433 433
 
434
-        $deviceUid = registerAccount($location);
434
+		$deviceUid = registerAccount($location);
435 435
 
436
-        return $deviceUid;
437
-    }
436
+		return $deviceUid;
437
+	}
438 438
 }
439 439
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
         {
37 37
             $this::refreshToken();
38 38
         }
39
-        $this->accessToken  = $this::getAccessToken();
39
+        $this->accessToken = $this::getAccessToken();
40 40
 
41 41
 
42 42
     }
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
                     }
98 98
                     else
99 99
                     {
100
-                        error_log('User with JodelDeviceId:' . $this->deviceUid .  ' [' . $_SERVER['REMOTE_ADDR'] . '][' . $_SERVER ['HTTP_USER_AGENT'] . '] changed to Location: ' . $name);
100
+                        error_log('User with JodelDeviceId:' . $this->deviceUid . ' [' . $_SERVER['REMOTE_ADDR'] . '][' . $_SERVER ['HTTP_USER_AGENT'] . '] changed to Location: ' . $name);
101 101
                     }
102 102
                 }
103 103
 
@@ -109,11 +109,11 @@  discard block
 block discarded – undo
109 109
     function getLocation()
110 110
     {
111 111
         $db = new DatabaseConnect();
112
-        $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid  . "'");
112
+        $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'");
113 113
         
114 114
         $location = new Location();
115 115
         
116
-        if ($result->num_rows > 0)
116
+        if($result->num_rows > 0)
117 117
         {
118 118
             // output data of each row
119 119
             while($row = $result->fetch_assoc())
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
         if(isset($_POST['color']))
204 204
         {
205 205
             $color = $_POST['color'];
206
-            switch ($color) {
206
+            switch($color) {
207 207
                 case '8ABDB0':
208 208
                     $color = '8ABDB0';
209 209
                     break;
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
 
260 260
         $access_token;
261 261
 
262
-        if ($result->num_rows > 0)
262
+        if($result->num_rows > 0)
263 263
         {
264 264
                 // output data of each row
265 265
                 while($row = $result->fetch_assoc()) {
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
                                         expiration_date='" . $expiration_date . "'
292 292
                                     WHERE device_uid='" . $device_uid . "'");
293 293
 
294
-            if($result === false){
294
+            if($result === false) {
295 295
                     echo "Adding account failed: (" . $db->errno . ") " . $db->error;
296 296
             }   
297 297
         }
@@ -309,11 +309,11 @@  discard block
 block discarded – undo
309 309
     function getAccessToken()
310 310
     {
311 311
         $db = new DatabaseConnect();
312
-        $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid  . "'");
312
+        $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'");
313 313
         
314 314
         $accessToken;
315 315
         
316
-        if ($result->num_rows > 0)
316
+        if($result->num_rows > 0)
317 317
         {
318 318
             // output data of each row
319 319
             while($row = $result->fetch_assoc())
@@ -381,7 +381,7 @@  discard block
 block discarded – undo
381 381
         $result = $db->query("INSERT INTO votes (device_uid, postId, type)
382 382
                         VALUES ('" . $this->deviceUid . "','" . $postId . "','" . $voteType . "')");
383 383
         
384
-        if($result === false){
384
+        if($result === false) {
385 385
                 $error = db_error();
386 386
                 echo $error;
387 387
                 echo "Adding Vote failed: (" . $result->errno . ") " . $result->error;
@@ -409,11 +409,11 @@  discard block
 block discarded – undo
409 409
         $result = $db->query("INSERT INTO accounts (access_token, refresh_token, token_type,
410 410
                         expires_in, expiration_date, distinct_id, device_uid, name, lat, lng)
411 411
                         VALUES ('" . $access_token . "','" . $refresh_token . "','" . $token_type .
412
-                        "','" .  $expires_in . "','" . $expiration_date . "','" . $distinct_id .
412
+                        "','" . $expires_in . "','" . $expiration_date . "','" . $distinct_id .
413 413
                         "','" . $device_uid . "','" . $name . "','" . $lat . "','" . $lng . "') ");
414 414
 
415 415
         $success = TRUE;
416
-        if($result === false){
416
+        if($result === false) {
417 417
                 $error = db_error();
418 418
                 echo $error;
419 419
                 echo "Adding account failed: (" . $result->errno . ") " . $result->error;
Please login to merge, or discard this patch.
Braces   +15 added lines, -8 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
         if(substr($_GET['city'], 0, 1) === '#')
57 57
         {
58 58
             return htmlspecialchars($_GET['city']) . " " . $this->location->cityName;
59
-        }                
59
+        }
60 60
         else
61 61
         {
62 62
             $url = 'https://maps.googleapis.com/maps/api/geocode/json?address=' . htmlspecialchars($_GET['city']) . '&key=AIzaSyCwhnja-or07012HqrhPW7prHEDuSvFT4w';
@@ -203,7 +203,8 @@  discard block
 block discarded – undo
203 203
         if(isset($_POST['color']))
204 204
         {
205 205
             $color = $_POST['color'];
206
-            switch ($color) {
206
+            switch ($color)
207
+            {
207 208
                 case '8ABDB0':
208 209
                     $color = '8ABDB0';
209 210
                     break;
@@ -262,7 +263,8 @@  discard block
 block discarded – undo
262 263
         if ($result->num_rows > 0)
263 264
         {
264 265
                 // output data of each row
265
-                while($row = $result->fetch_assoc()) {
266
+                while($row = $result->fetch_assoc())
267
+                {
266 268
                         //$access_token = $row["access_token"];
267 269
                         $expiration_date = $row["expiration_date"];
268 270
                         $deviceUid = $row["device_uid"];
@@ -274,7 +276,8 @@  discard block
 block discarded – undo
274 276
                 echo '0 results';
275 277
         }
276 278
 
277
-        if($expiration_date <= time()) {
279
+        if($expiration_date <= time())
280
+        {
278 281
             $accountCreator = new CreateUser();
279 282
             $accountCreator->setAccessToken($access_token);
280 283
             $accountCreator->setDeviceUid($deviceUid);
@@ -291,7 +294,8 @@  discard block
 block discarded – undo
291 294
                                         expiration_date='" . $expiration_date . "'
292 295
                                     WHERE device_uid='" . $device_uid . "'");
293 296
 
294
-            if($result === false){
297
+            if($result === false)
298
+            {
295 299
                     echo "Adding account failed: (" . $db->errno . ") " . $db->error;
296 300
             }   
297 301
         }
@@ -381,14 +385,16 @@  discard block
 block discarded – undo
381 385
         $result = $db->query("INSERT INTO votes (device_uid, postId, type)
382 386
                         VALUES ('" . $this->deviceUid . "','" . $postId . "','" . $voteType . "')");
383 387
         
384
-        if($result === false){
388
+        if($result === false)
389
+        {
385 390
                 $error = db_error();
386 391
                 echo $error;
387 392
                 echo "Adding Vote failed: (" . $result->errno . ") " . $result->error;
388 393
         }       
389 394
     }
390 395
 
391
-    function registerAccount($location) {
396
+    function registerAccount($location)
397
+    {
392 398
         $accountCreator = new CreateUser();
393 399
         $accountCreator->setLocation($location);
394 400
         $data = $accountCreator->execute();
@@ -413,7 +419,8 @@  discard block
 block discarded – undo
413 419
                         "','" . $device_uid . "','" . $name . "','" . $lat . "','" . $lng . "') ");
414 420
 
415 421
         $success = TRUE;
416
-        if($result === false){
422
+        if($result === false)
423
+        {
417 424
                 $error = db_error();
418 425
                 echo $error;
419 426
                 echo "Adding account failed: (" . $result->errno . ") " . $result->error;
Please login to merge, or discard this patch.
Upper-Lower-Casing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -61,15 +61,15 @@  discard block
 block discarded – undo
61 61
         {
62 62
             $url = 'https://maps.googleapis.com/maps/api/geocode/json?address=' . htmlspecialchars($_GET['city']) . '&key=AIzaSyCwhnja-or07012HqrhPW7prHEDuSvFT4w';
63 63
             $result = Requests::post($url);
64
-            if(json_decode($result->body, true)['status'] == 'ZERO_RESULTS' || json_decode($result->body, true)['status'] == 'INVALID_REQUEST')
64
+            if(json_decode($result->body, TRUE)['status'] == 'ZERO_RESULTS' || json_decode($result->body, TRUE)['status'] == 'INVALID_REQUEST')
65 65
             {
66 66
                 return "0 results";
67 67
             }
68 68
             else
69 69
             {
70
-                $name = json_decode($result->body, true)['results']['0']['address_components']['0']['long_name'];
71
-                $lat = json_decode($result->body, true)['results']['0']['geometry']['location']['lat'];
72
-                $lng = json_decode($result->body, true)['results']['0']['geometry']['location']['lng'];
70
+                $name = json_decode($result->body, TRUE)['results']['0']['address_components']['0']['long_name'];
71
+                $lat = json_decode($result->body, TRUE)['results']['0']['geometry']['location']['lat'];
72
+                $lng = json_decode($result->body, TRUE)['results']['0']['geometry']['location']['lng'];
73 73
 
74 74
                 $location = new Location();
75 75
                 $location->setLat($lat);
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
                                 lng='" . $lng . "'
92 92
                             WHERE access_token='" . $this->accessToken . "'");
93 93
 
94
-                    if($result === false)
94
+                    if($result === FALSE)
95 95
                     {
96 96
                             echo "Updating location failed: (" . $db->errno . ") " . $db->error;
97 97
                     }
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
                                         expiration_date='" . $expiration_date . "'
292 292
                                     WHERE device_uid='" . $device_uid . "'");
293 293
 
294
-            if($result === false){
294
+            if($result === FALSE){
295 295
                     echo "Adding account failed: (" . $db->errno . ") " . $db->error;
296 296
             }   
297 297
         }
@@ -349,7 +349,7 @@  discard block
 block discarded – undo
349 349
                               FROM votes
350 350
                               WHERE (postId = '" . $postId . "' AND device_uid = '" . $this->deviceUid . "')");
351 351
         
352
-        if($result === false)
352
+        if($result === FALSE)
353 353
         {
354 354
             $error = db_error();
355 355
             echo $error;
@@ -381,7 +381,7 @@  discard block
 block discarded – undo
381 381
         $result = $db->query("INSERT INTO votes (device_uid, postId, type)
382 382
                         VALUES ('" . $this->deviceUid . "','" . $postId . "','" . $voteType . "')");
383 383
         
384
-        if($result === false){
384
+        if($result === FALSE){
385 385
                 $error = db_error();
386 386
                 echo $error;
387 387
                 echo "Adding Vote failed: (" . $result->errno . ") " . $result->error;
@@ -413,7 +413,7 @@  discard block
 block discarded – undo
413 413
                         "','" . $device_uid . "','" . $name . "','" . $lat . "','" . $lng . "') ");
414 414
 
415 415
         $success = TRUE;
416
-        if($result === false){
416
+        if($result === FALSE){
417 417
                 $error = db_error();
418 418
                 echo $error;
419 419
                 echo "Adding account failed: (" . $result->errno . ") " . $result->error;
Please login to merge, or discard this patch.
get-posts-ajax.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 
5 5
 	if(isset($_GET['view']))
6 6
 	{
7
-		switch ($_GET['view']) {
7
+		switch($_GET['view']) {
8 8
 			case 'comment':
9 9
 				$view = 'comment';
10 10
 				break;
@@ -23,13 +23,13 @@  discard block
 block discarded – undo
23 23
 		$view = 'time';
24 24
 	}
25 25
 
26
-	if($view=='comment')
26
+	if($view == 'comment')
27 27
 	{
28 28
 		$url = "/v2/posts/location/discussed/";
29 29
 	}
30 30
 	else
31 31
 	{
32
-		if($view=='upVote')
32
+		if($view == 'upVote')
33 33
 		{
34 34
 			$url = "/v2/posts/location/popular/";
35 35
 		}
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 		?>
50 50
 		<div class="nextPosts">
51 51
 		<?php
52
-		for($i = 0; $i<$loops; $i++)
52
+		for($i = 0; $i < $loops; $i++)
53 53
 		{
54 54
 			if(isset($posts[$i]))
55 55
 			{
Please login to merge, or discard this patch.