@@ -204,6 +204,9 @@ |
||
204 | 204 | return array("image_url" => $captcha['image_url'], "key" => $captcha['key']); |
205 | 205 | } |
206 | 206 | |
207 | + /** |
|
208 | + * @param string $deviceUid |
|
209 | + */ |
|
207 | 210 | function showCaptcha($accessToken, $deviceUid) |
208 | 211 | { |
209 | 212 | $accountCreator = new GetCaptcha(); |
@@ -9,75 +9,75 @@ discard block |
||
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(' ', ' ', 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(' ', ' ', 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 |
||
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 |
||
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 |
||
158 | 158 | </footer> |
159 | 159 | </article> |
160 | 160 | <?php |
161 | - } |
|
161 | + } |
|
162 | 162 | |
163 | 163 | |
164 | 164 | /** |
@@ -24,25 +24,25 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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> |
@@ -9,7 +9,8 @@ discard block |
||
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 |
||
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(' ', ' ', nl2br(htmlspecialchars($post['message']))); |
70 | 72 | } |
71 | 73 | ?> |
@@ -73,11 +75,13 @@ discard block |
||
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 |
||
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 |
||
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> |
@@ -230,7 +242,7 @@ discard block |
||
230 | 242 | } |
231 | 243 | |
232 | 244 | function getPosts($lastPostId, $accessToken, $url, $version = 'v2') |
233 | - { |
|
245 | + { |
|
234 | 246 | $accountCreator = new GetPosts(); |
235 | 247 | $accountCreator->setLastPostId($lastPostId); |
236 | 248 | $accountCreator->setAccessToken($accessToken); |
@@ -1,14 +1,14 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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> |
@@ -75,7 +75,11 @@ discard block |
||
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="" /> |
81 | 85 | </form> |
@@ -102,7 +106,9 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
@@ -2,445 +2,445 @@ |
||
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 | - $this->deviceUid = $this->createAccount(); |
|
25 | - } |
|
26 | - else |
|
27 | - { |
|
28 | - $this->deviceUid = $deviceUid; |
|
29 | - } |
|
30 | - |
|
31 | - $this->isBot = $isBot; |
|
32 | - $this->location = $this->getLocation(); |
|
33 | - |
|
34 | - if(!$this->isTokenFresh()) |
|
35 | - { |
|
36 | - $this->refreshToken(); |
|
37 | - } |
|
38 | - $this->accessToken = $this->getAccessToken(); |
|
39 | - } |
|
40 | - |
|
41 | - function isAccountVerified() |
|
42 | - { |
|
43 | - $accountCreator = new GetUserConfig(); |
|
44 | - $accountCreator->setAccessToken($this->accessToken); |
|
45 | - $data = $accountCreator->execute(); |
|
46 | - |
|
47 | - return $data['verified']; |
|
48 | - } |
|
49 | - |
|
50 | - function setLocation() |
|
51 | - { |
|
52 | - //Is Channel or City |
|
53 | - if(substr($_GET['city'], 0, 1) === '#') |
|
54 | - { |
|
55 | - return htmlspecialchars($_GET['city']) . " " . $this->location->cityName; |
|
56 | - } |
|
57 | - else |
|
58 | - { |
|
59 | - $url = 'https://maps.googleapis.com/maps/api/geocode/json?address=' . htmlspecialchars($_GET['city']) . '&key=AIzaSyCwhnja-or07012HqrhPW7prHEDuSvFT4w'; |
|
60 | - $result = Requests::post($url); |
|
61 | - if(json_decode($result->body, true)['status'] == 'ZERO_RESULTS' || json_decode($result->body, true)['status'] == 'INVALID_REQUEST') |
|
62 | - { |
|
63 | - return "0 results"; |
|
64 | - } |
|
65 | - else |
|
66 | - { |
|
67 | - $name = json_decode($result->body, true)['results']['0']['address_components']['0']['long_name']; |
|
68 | - $lat = json_decode($result->body, true)['results']['0']['geometry']['location']['lat']; |
|
69 | - $lng = json_decode($result->body, true)['results']['0']['geometry']['location']['lng']; |
|
70 | - |
|
71 | - $location = new Location(); |
|
72 | - $location->setLat($lat); |
|
73 | - $location->setLng($lng); |
|
74 | - $location->setCityName($name); |
|
75 | - $accountCreator = new UpdateLocation(); |
|
76 | - $accountCreator->setLocation($location); |
|
77 | - $accountCreator->setAccessToken($this->accessToken); |
|
78 | - $data = $accountCreator->execute(); |
|
79 | - |
|
80 | - //safe location to db |
|
81 | - $db = new DatabaseConnect(); |
|
82 | - |
|
83 | - if($data == 'Success') |
|
84 | - { |
|
85 | - $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 | + $this->deviceUid = $this->createAccount(); |
|
25 | + } |
|
26 | + else |
|
27 | + { |
|
28 | + $this->deviceUid = $deviceUid; |
|
29 | + } |
|
30 | + |
|
31 | + $this->isBot = $isBot; |
|
32 | + $this->location = $this->getLocation(); |
|
33 | + |
|
34 | + if(!$this->isTokenFresh()) |
|
35 | + { |
|
36 | + $this->refreshToken(); |
|
37 | + } |
|
38 | + $this->accessToken = $this->getAccessToken(); |
|
39 | + } |
|
40 | + |
|
41 | + function isAccountVerified() |
|
42 | + { |
|
43 | + $accountCreator = new GetUserConfig(); |
|
44 | + $accountCreator->setAccessToken($this->accessToken); |
|
45 | + $data = $accountCreator->execute(); |
|
46 | + |
|
47 | + return $data['verified']; |
|
48 | + } |
|
49 | + |
|
50 | + function setLocation() |
|
51 | + { |
|
52 | + //Is Channel or City |
|
53 | + if(substr($_GET['city'], 0, 1) === '#') |
|
54 | + { |
|
55 | + return htmlspecialchars($_GET['city']) . " " . $this->location->cityName; |
|
56 | + } |
|
57 | + else |
|
58 | + { |
|
59 | + $url = 'https://maps.googleapis.com/maps/api/geocode/json?address=' . htmlspecialchars($_GET['city']) . '&key=AIzaSyCwhnja-or07012HqrhPW7prHEDuSvFT4w'; |
|
60 | + $result = Requests::post($url); |
|
61 | + if(json_decode($result->body, true)['status'] == 'ZERO_RESULTS' || json_decode($result->body, true)['status'] == 'INVALID_REQUEST') |
|
62 | + { |
|
63 | + return "0 results"; |
|
64 | + } |
|
65 | + else |
|
66 | + { |
|
67 | + $name = json_decode($result->body, true)['results']['0']['address_components']['0']['long_name']; |
|
68 | + $lat = json_decode($result->body, true)['results']['0']['geometry']['location']['lat']; |
|
69 | + $lng = json_decode($result->body, true)['results']['0']['geometry']['location']['lng']; |
|
70 | + |
|
71 | + $location = new Location(); |
|
72 | + $location->setLat($lat); |
|
73 | + $location->setLng($lng); |
|
74 | + $location->setCityName($name); |
|
75 | + $accountCreator = new UpdateLocation(); |
|
76 | + $accountCreator->setLocation($location); |
|
77 | + $accountCreator->setAccessToken($this->accessToken); |
|
78 | + $data = $accountCreator->execute(); |
|
79 | + |
|
80 | + //safe location to db |
|
81 | + $db = new DatabaseConnect(); |
|
82 | + |
|
83 | + if($data == 'Success') |
|
84 | + { |
|
85 | + $result = $db->query("UPDATE accounts |
|
86 | 86 | SET name='" . $name . "', |
87 | 87 | lat='" . $lat . "', |
88 | 88 | lng='" . $lng . "' |
89 | 89 | WHERE access_token='" . $this->accessToken . "'"); |
90 | 90 | |
91 | - if($result === false) |
|
92 | - { |
|
93 | - echo "Updating location failed: (" . $db->errno . ") " . $db->error; |
|
94 | - } |
|
95 | - else |
|
96 | - { |
|
97 | - error_log('User with JodelDeviceId:' . $this->deviceUid . ' [' . $_SERVER['REMOTE_ADDR'] . '][' . $_SERVER ['HTTP_USER_AGENT'] . '] changed to Location: ' . $name); |
|
98 | - } |
|
99 | - } |
|
100 | - |
|
101 | - return $name; |
|
102 | - } |
|
103 | - } |
|
104 | - } |
|
105 | - |
|
106 | - function getLocation() |
|
107 | - { |
|
108 | - $db = new DatabaseConnect(); |
|
109 | - $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'"); |
|
91 | + if($result === false) |
|
92 | + { |
|
93 | + echo "Updating location failed: (" . $db->errno . ") " . $db->error; |
|
94 | + } |
|
95 | + else |
|
96 | + { |
|
97 | + error_log('User with JodelDeviceId:' . $this->deviceUid . ' [' . $_SERVER['REMOTE_ADDR'] . '][' . $_SERVER ['HTTP_USER_AGENT'] . '] changed to Location: ' . $name); |
|
98 | + } |
|
99 | + } |
|
100 | + |
|
101 | + return $name; |
|
102 | + } |
|
103 | + } |
|
104 | + } |
|
105 | + |
|
106 | + function getLocation() |
|
107 | + { |
|
108 | + $db = new DatabaseConnect(); |
|
109 | + $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'"); |
|
110 | 110 | |
111 | - $location = new Location(); |
|
111 | + $location = new Location(); |
|
112 | 112 | |
113 | - if ($result->num_rows > 0) |
|
114 | - { |
|
115 | - // output data of each row |
|
116 | - while($row = $result->fetch_assoc()) |
|
117 | - { |
|
118 | - $location->setLat($row['lat']); |
|
119 | - $location->setLng($row['lng']); |
|
120 | - $location->setCityName($row['name']); |
|
121 | - } |
|
122 | - } |
|
123 | - else |
|
124 | - { |
|
125 | - echo "Error: 0 results"; |
|
126 | - error_log("Error no Location found - getLocation"); |
|
127 | - } |
|
128 | - |
|
129 | - return $location; |
|
130 | - } |
|
131 | - |
|
132 | - function verifyCaptcha() |
|
133 | - { |
|
134 | - if(isset($_GET['deviceUid'])) |
|
135 | - { |
|
136 | - $deviceUid = $_GET['deviceUid']; |
|
137 | - } |
|
138 | - if(isset($_POST['deviceUid'])) |
|
139 | - { |
|
140 | - $deviceUid = $_POST['deviceUid']; |
|
141 | - } |
|
142 | - $jodelAccountForVerify = new JodelAccount($deviceUid); |
|
143 | - |
|
144 | - $solution = $_GET['solution']; |
|
145 | - $solution = array_map('intval', explode('-', $solution)); |
|
146 | - |
|
147 | - $accountCreator = new PostCaptcha(); |
|
148 | - $accountCreator->setAccessToken($jodelAccountForVerify->accessToken); |
|
149 | - $accountCreator->captchaKey = $_GET['key']; |
|
150 | - $accountCreator->captchaSolution = $solution; |
|
151 | - $verified = $accountCreator->execute(); |
|
152 | - |
|
153 | - if(isset($verified->status_code)) |
|
154 | - { |
|
155 | - return $verified->status_code; |
|
156 | - } |
|
157 | - return $verified['verified']; |
|
158 | - } |
|
159 | - |
|
160 | - //ToDo Spider Check |
|
161 | - function votePostId($postId, $vote) |
|
162 | - { |
|
163 | - if(!$this->isAccountVerified()) |
|
164 | - { |
|
165 | - $view = new View(); |
|
166 | - $view->showCaptcha($this->accessToken, $this->deviceUid); |
|
167 | - } |
|
168 | - |
|
169 | - if(!$this->deviceUidHasVotedThisPostId($postId)) |
|
170 | - { |
|
171 | - if($vote == "up") |
|
172 | - { |
|
173 | - $accountCreator = new Upvote(); |
|
174 | - } |
|
175 | - else if($vote == "down") |
|
176 | - { |
|
177 | - $accountCreator = new Downvote(); |
|
178 | - } |
|
179 | - $accountCreator->setAccessToken($this->accessToken); |
|
180 | - $accountCreator->postId = htmlspecialchars($postId); |
|
181 | - $data = $accountCreator->execute(); |
|
182 | - |
|
183 | - if(array_key_exists('post', $data)) |
|
184 | - { |
|
185 | - $this->addVoteWithPostIdAndTypeToDeviceUid($postId, $vote); |
|
186 | - return TRUE; |
|
187 | - } |
|
188 | - else |
|
189 | - { |
|
190 | - return FALSE; |
|
191 | - error_log("Could not vote: " . var_dump($data)); |
|
192 | - } |
|
193 | - } |
|
194 | - } |
|
195 | - |
|
196 | - //ToDo Spider Check |
|
197 | - function sendJodel() |
|
198 | - { |
|
199 | - if(!$this->isAccountVerified()) |
|
200 | - { |
|
201 | - showCaptcha($this->accessToken); |
|
202 | - } |
|
203 | - |
|
204 | - $accountCreator = new SendJodel(); |
|
205 | - |
|
206 | - if(isset($_POST['ancestor'])) |
|
207 | - { |
|
208 | - $ancestor = $_POST['ancestor']; |
|
209 | - $accountCreator->ancestor = $ancestor; |
|
210 | - } |
|
211 | - if(isset($_POST['color'])) |
|
212 | - { |
|
213 | - $color = $_POST['color']; |
|
214 | - switch ($color) { |
|
215 | - case '8ABDB0': |
|
216 | - $color = '8ABDB0'; |
|
217 | - break; |
|
218 | - case '9EC41C': |
|
219 | - $color = '9EC41C'; |
|
220 | - break; |
|
221 | - case '06A3CB': |
|
222 | - $color = '06A3CB'; |
|
223 | - break; |
|
224 | - case 'FFBA00': |
|
225 | - $color = 'FFBA00'; |
|
226 | - break; |
|
227 | - case 'DD5F5F': |
|
228 | - $color = 'DD5F5F'; |
|
229 | - break; |
|
230 | - case 'FF9908': |
|
231 | - $color = 'FF9908'; |
|
232 | - break; |
|
233 | - default: |
|
234 | - $color = '8ABDB0'; |
|
235 | - break; |
|
236 | - } |
|
237 | - $accountCreator->color = $color; |
|
238 | - } |
|
239 | - |
|
240 | - $accountCreatorLocation = new UpdateLocation(); |
|
241 | - $accountCreatorLocation->setLocation($this->location); |
|
242 | - $accountCreatorLocation->setAccessToken($this->accessToken); |
|
243 | - $data = $accountCreatorLocation->execute(); |
|
113 | + if ($result->num_rows > 0) |
|
114 | + { |
|
115 | + // output data of each row |
|
116 | + while($row = $result->fetch_assoc()) |
|
117 | + { |
|
118 | + $location->setLat($row['lat']); |
|
119 | + $location->setLng($row['lng']); |
|
120 | + $location->setCityName($row['name']); |
|
121 | + } |
|
122 | + } |
|
123 | + else |
|
124 | + { |
|
125 | + echo "Error: 0 results"; |
|
126 | + error_log("Error no Location found - getLocation"); |
|
127 | + } |
|
128 | + |
|
129 | + return $location; |
|
130 | + } |
|
131 | + |
|
132 | + function verifyCaptcha() |
|
133 | + { |
|
134 | + if(isset($_GET['deviceUid'])) |
|
135 | + { |
|
136 | + $deviceUid = $_GET['deviceUid']; |
|
137 | + } |
|
138 | + if(isset($_POST['deviceUid'])) |
|
139 | + { |
|
140 | + $deviceUid = $_POST['deviceUid']; |
|
141 | + } |
|
142 | + $jodelAccountForVerify = new JodelAccount($deviceUid); |
|
143 | + |
|
144 | + $solution = $_GET['solution']; |
|
145 | + $solution = array_map('intval', explode('-', $solution)); |
|
146 | + |
|
147 | + $accountCreator = new PostCaptcha(); |
|
148 | + $accountCreator->setAccessToken($jodelAccountForVerify->accessToken); |
|
149 | + $accountCreator->captchaKey = $_GET['key']; |
|
150 | + $accountCreator->captchaSolution = $solution; |
|
151 | + $verified = $accountCreator->execute(); |
|
152 | + |
|
153 | + if(isset($verified->status_code)) |
|
154 | + { |
|
155 | + return $verified->status_code; |
|
156 | + } |
|
157 | + return $verified['verified']; |
|
158 | + } |
|
159 | + |
|
160 | + //ToDo Spider Check |
|
161 | + function votePostId($postId, $vote) |
|
162 | + { |
|
163 | + if(!$this->isAccountVerified()) |
|
164 | + { |
|
165 | + $view = new View(); |
|
166 | + $view->showCaptcha($this->accessToken, $this->deviceUid); |
|
167 | + } |
|
168 | + |
|
169 | + if(!$this->deviceUidHasVotedThisPostId($postId)) |
|
170 | + { |
|
171 | + if($vote == "up") |
|
172 | + { |
|
173 | + $accountCreator = new Upvote(); |
|
174 | + } |
|
175 | + else if($vote == "down") |
|
176 | + { |
|
177 | + $accountCreator = new Downvote(); |
|
178 | + } |
|
179 | + $accountCreator->setAccessToken($this->accessToken); |
|
180 | + $accountCreator->postId = htmlspecialchars($postId); |
|
181 | + $data = $accountCreator->execute(); |
|
182 | + |
|
183 | + if(array_key_exists('post', $data)) |
|
184 | + { |
|
185 | + $this->addVoteWithPostIdAndTypeToDeviceUid($postId, $vote); |
|
186 | + return TRUE; |
|
187 | + } |
|
188 | + else |
|
189 | + { |
|
190 | + return FALSE; |
|
191 | + error_log("Could not vote: " . var_dump($data)); |
|
192 | + } |
|
193 | + } |
|
194 | + } |
|
195 | + |
|
196 | + //ToDo Spider Check |
|
197 | + function sendJodel() |
|
198 | + { |
|
199 | + if(!$this->isAccountVerified()) |
|
200 | + { |
|
201 | + showCaptcha($this->accessToken); |
|
202 | + } |
|
203 | + |
|
204 | + $accountCreator = new SendJodel(); |
|
205 | + |
|
206 | + if(isset($_POST['ancestor'])) |
|
207 | + { |
|
208 | + $ancestor = $_POST['ancestor']; |
|
209 | + $accountCreator->ancestor = $ancestor; |
|
210 | + } |
|
211 | + if(isset($_POST['color'])) |
|
212 | + { |
|
213 | + $color = $_POST['color']; |
|
214 | + switch ($color) { |
|
215 | + case '8ABDB0': |
|
216 | + $color = '8ABDB0'; |
|
217 | + break; |
|
218 | + case '9EC41C': |
|
219 | + $color = '9EC41C'; |
|
220 | + break; |
|
221 | + case '06A3CB': |
|
222 | + $color = '06A3CB'; |
|
223 | + break; |
|
224 | + case 'FFBA00': |
|
225 | + $color = 'FFBA00'; |
|
226 | + break; |
|
227 | + case 'DD5F5F': |
|
228 | + $color = 'DD5F5F'; |
|
229 | + break; |
|
230 | + case 'FF9908': |
|
231 | + $color = 'FF9908'; |
|
232 | + break; |
|
233 | + default: |
|
234 | + $color = '8ABDB0'; |
|
235 | + break; |
|
236 | + } |
|
237 | + $accountCreator->color = $color; |
|
238 | + } |
|
239 | + |
|
240 | + $accountCreatorLocation = new UpdateLocation(); |
|
241 | + $accountCreatorLocation->setLocation($this->location); |
|
242 | + $accountCreatorLocation->setAccessToken($this->accessToken); |
|
243 | + $data = $accountCreatorLocation->execute(); |
|
244 | 244 | |
245 | - $accountCreator->location = $this->location; |
|
245 | + $accountCreator->location = $this->location; |
|
246 | 246 | |
247 | - $accountCreator->setAccessToken($this->accessToken); |
|
248 | - $data = $accountCreator->execute(); |
|
249 | - |
|
250 | - if(isset($_POST['ancestor'])) |
|
251 | - { |
|
252 | - $actual_link = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; |
|
253 | - header('Location: ' . $actual_link . '#postId-' . htmlspecialchars($data['post_id'])); |
|
254 | - exit; |
|
255 | - } |
|
256 | - else |
|
257 | - { |
|
258 | - header('Location: ./#'); |
|
259 | - exit; |
|
260 | - } |
|
261 | - } |
|
262 | - |
|
263 | - function isTokenFresh() |
|
264 | - { |
|
265 | - $db = new DatabaseConnect(); |
|
266 | - $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'"); |
|
267 | - |
|
268 | - $access_token; |
|
269 | - |
|
270 | - if ($result->num_rows > 0) |
|
271 | - { |
|
272 | - // output data of each row |
|
273 | - while($row = $result->fetch_assoc()) { |
|
274 | - //$access_token = $row["access_token"]; |
|
275 | - $expiration_date = $row["expiration_date"]; |
|
276 | - $deviceUid = $row["device_uid"]; |
|
277 | - $access_token = $row["access_token"]; |
|
278 | - } |
|
279 | - } |
|
280 | - else |
|
281 | - { |
|
282 | - echo '0 results'; |
|
283 | - } |
|
284 | - |
|
285 | - if($expiration_date <= time()) { |
|
286 | - $accountCreator = new CreateUser(); |
|
287 | - $accountCreator->setAccessToken($access_token); |
|
288 | - $accountCreator->setDeviceUid($deviceUid); |
|
289 | - $accountCreator->setLocation($this->location); |
|
290 | - $data = $accountCreator->execute(); |
|
291 | - |
|
292 | - $access_token = (string)$data[0]['access_token']; |
|
293 | - $expiration_date = $data[0]['expiration_date']; |
|
294 | - $device_uid = (string)$data[1]; |
|
247 | + $accountCreator->setAccessToken($this->accessToken); |
|
248 | + $data = $accountCreator->execute(); |
|
249 | + |
|
250 | + if(isset($_POST['ancestor'])) |
|
251 | + { |
|
252 | + $actual_link = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; |
|
253 | + header('Location: ' . $actual_link . '#postId-' . htmlspecialchars($data['post_id'])); |
|
254 | + exit; |
|
255 | + } |
|
256 | + else |
|
257 | + { |
|
258 | + header('Location: ./#'); |
|
259 | + exit; |
|
260 | + } |
|
261 | + } |
|
262 | + |
|
263 | + function isTokenFresh() |
|
264 | + { |
|
265 | + $db = new DatabaseConnect(); |
|
266 | + $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'"); |
|
267 | + |
|
268 | + $access_token; |
|
269 | + |
|
270 | + if ($result->num_rows > 0) |
|
271 | + { |
|
272 | + // output data of each row |
|
273 | + while($row = $result->fetch_assoc()) { |
|
274 | + //$access_token = $row["access_token"]; |
|
275 | + $expiration_date = $row["expiration_date"]; |
|
276 | + $deviceUid = $row["device_uid"]; |
|
277 | + $access_token = $row["access_token"]; |
|
278 | + } |
|
279 | + } |
|
280 | + else |
|
281 | + { |
|
282 | + echo '0 results'; |
|
283 | + } |
|
284 | + |
|
285 | + if($expiration_date <= time()) { |
|
286 | + $accountCreator = new CreateUser(); |
|
287 | + $accountCreator->setAccessToken($access_token); |
|
288 | + $accountCreator->setDeviceUid($deviceUid); |
|
289 | + $accountCreator->setLocation($this->location); |
|
290 | + $data = $accountCreator->execute(); |
|
291 | + |
|
292 | + $access_token = (string)$data[0]['access_token']; |
|
293 | + $expiration_date = $data[0]['expiration_date']; |
|
294 | + $device_uid = (string)$data[1]; |
|
295 | 295 | |
296 | - $db = new DatabaseConnect(); |
|
297 | - $result = $db->query("UPDATE accounts |
|
296 | + $db = new DatabaseConnect(); |
|
297 | + $result = $db->query("UPDATE accounts |
|
298 | 298 | SET access_token='" . $access_token . "', |
299 | 299 | expiration_date='" . $expiration_date . "' |
300 | 300 | WHERE device_uid='" . $device_uid . "'"); |
301 | 301 | |
302 | - if($result === false){ |
|
303 | - echo "Adding account failed: (" . $db->errno . ") " . $db->error; |
|
304 | - } |
|
305 | - } |
|
302 | + if($result === false){ |
|
303 | + echo "Adding account failed: (" . $db->errno . ") " . $db->error; |
|
304 | + } |
|
305 | + } |
|
306 | 306 | |
307 | - return $access_token; |
|
308 | - } |
|
307 | + return $access_token; |
|
308 | + } |
|
309 | 309 | |
310 | - function refreshToken() |
|
311 | - { |
|
310 | + function refreshToken() |
|
311 | + { |
|
312 | 312 | |
313 | - } |
|
313 | + } |
|
314 | 314 | |
315 | 315 | |
316 | 316 | |
317 | - function getAccessToken() |
|
318 | - { |
|
319 | - $db = new DatabaseConnect(); |
|
320 | - $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'"); |
|
317 | + function getAccessToken() |
|
318 | + { |
|
319 | + $db = new DatabaseConnect(); |
|
320 | + $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'"); |
|
321 | 321 | |
322 | - $accessToken; |
|
322 | + $accessToken; |
|
323 | 323 | |
324 | - if ($result->num_rows > 0) |
|
325 | - { |
|
326 | - // output data of each row |
|
327 | - while($row = $result->fetch_assoc()) |
|
328 | - { |
|
329 | - $accessToken = $row['access_token']; |
|
330 | - } |
|
331 | - } |
|
332 | - else |
|
333 | - { |
|
334 | - echo "Error: 0 results"; |
|
335 | - } |
|
336 | - |
|
337 | - return $accessToken; |
|
338 | - } |
|
339 | - |
|
340 | - |
|
341 | - function getKarma() |
|
342 | - { |
|
343 | - $accountCreator = new GetKarma(); |
|
344 | - $accountCreator->setAccessToken($this->accessToken); |
|
345 | - $data = $accountCreator->execute(); |
|
324 | + if ($result->num_rows > 0) |
|
325 | + { |
|
326 | + // output data of each row |
|
327 | + while($row = $result->fetch_assoc()) |
|
328 | + { |
|
329 | + $accessToken = $row['access_token']; |
|
330 | + } |
|
331 | + } |
|
332 | + else |
|
333 | + { |
|
334 | + echo "Error: 0 results"; |
|
335 | + } |
|
336 | + |
|
337 | + return $accessToken; |
|
338 | + } |
|
339 | + |
|
340 | + |
|
341 | + function getKarma() |
|
342 | + { |
|
343 | + $accountCreator = new GetKarma(); |
|
344 | + $accountCreator->setAccessToken($this->accessToken); |
|
345 | + $data = $accountCreator->execute(); |
|
346 | 346 | |
347 | - return $data["karma"]; |
|
348 | - } |
|
347 | + return $data["karma"]; |
|
348 | + } |
|
349 | 349 | |
350 | - function deviceUidHasVotedThisPostId($postId) |
|
351 | - { |
|
352 | - $db = new DatabaseConnect(); |
|
350 | + function deviceUidHasVotedThisPostId($postId) |
|
351 | + { |
|
352 | + $db = new DatabaseConnect(); |
|
353 | 353 | |
354 | - $postId = $db->real_escape_string($postId); |
|
354 | + $postId = $db->real_escape_string($postId); |
|
355 | 355 | |
356 | - $result = $db->query("SELECT id |
|
356 | + $result = $db->query("SELECT id |
|
357 | 357 | FROM votes |
358 | 358 | WHERE (postId = '" . $postId . "' AND device_uid = '" . $this->deviceUid . "')"); |
359 | 359 | |
360 | - if($result === false) |
|
361 | - { |
|
362 | - $error = db_error(); |
|
363 | - echo $error; |
|
364 | - echo "Adding Vote failed: (" . $result->errno . ") " . $result->error; |
|
365 | - } |
|
366 | - |
|
367 | - if($result->num_rows == 0) |
|
368 | - { |
|
369 | - return FALSE; |
|
370 | - } |
|
371 | - else |
|
372 | - { |
|
373 | - return TRUE; |
|
374 | - } |
|
375 | - } |
|
376 | - |
|
377 | - function addVoteWithPostIdAndTypeToDeviceUid($postId, $voteType) |
|
378 | - { |
|
379 | - $db = new DatabaseConnect(); |
|
380 | - |
|
381 | - $postId = $db->real_escape_string($postId); |
|
382 | - $voteType = $db->real_escape_string($voteType); |
|
360 | + if($result === false) |
|
361 | + { |
|
362 | + $error = db_error(); |
|
363 | + echo $error; |
|
364 | + echo "Adding Vote failed: (" . $result->errno . ") " . $result->error; |
|
365 | + } |
|
366 | + |
|
367 | + if($result->num_rows == 0) |
|
368 | + { |
|
369 | + return FALSE; |
|
370 | + } |
|
371 | + else |
|
372 | + { |
|
373 | + return TRUE; |
|
374 | + } |
|
375 | + } |
|
376 | + |
|
377 | + function addVoteWithPostIdAndTypeToDeviceUid($postId, $voteType) |
|
378 | + { |
|
379 | + $db = new DatabaseConnect(); |
|
380 | + |
|
381 | + $postId = $db->real_escape_string($postId); |
|
382 | + $voteType = $db->real_escape_string($voteType); |
|
383 | 383 | |
384 | - if($this->deviceUidHasVotedThisPostId($postId)) |
|
385 | - { |
|
386 | - return "Already voted"; |
|
387 | - } |
|
384 | + if($this->deviceUidHasVotedThisPostId($postId)) |
|
385 | + { |
|
386 | + return "Already voted"; |
|
387 | + } |
|
388 | 388 | |
389 | - $result = $db->query("INSERT INTO votes (device_uid, postId, type) |
|
389 | + $result = $db->query("INSERT INTO votes (device_uid, postId, type) |
|
390 | 390 | VALUES ('" . $this->deviceUid . "','" . $postId . "','" . $voteType . "')"); |
391 | 391 | |
392 | - if($result === false){ |
|
393 | - $error = db_error(); |
|
394 | - echo $error; |
|
395 | - echo "Adding Vote failed: (" . $result->errno . ") " . $result->error; |
|
396 | - } |
|
397 | - } |
|
398 | - |
|
399 | - function registerAccount($location) { |
|
400 | - $accountCreator = new CreateUser(); |
|
401 | - $accountCreator->setLocation($location); |
|
402 | - $data = $accountCreator->execute(); |
|
392 | + if($result === false){ |
|
393 | + $error = db_error(); |
|
394 | + echo $error; |
|
395 | + echo "Adding Vote failed: (" . $result->errno . ") " . $result->error; |
|
396 | + } |
|
397 | + } |
|
398 | + |
|
399 | + function registerAccount($location) { |
|
400 | + $accountCreator = new CreateUser(); |
|
401 | + $accountCreator->setLocation($location); |
|
402 | + $data = $accountCreator->execute(); |
|
403 | 403 | |
404 | - $access_token = (string)$data[0]['access_token']; |
|
405 | - $refresh_token = (string)$data[0]['refresh_token']; |
|
406 | - $token_type = (string)$data[0]['token_type']; |
|
407 | - $expires_in = $data[0]['expires_in']; |
|
408 | - $expiration_date = $data[0]['expiration_date']; |
|
409 | - $distinct_id = (string)$data[0]['distinct_id']; |
|
410 | - $device_uid = (string)$data[1]; |
|
411 | - |
|
412 | - $name = $location->cityName; |
|
413 | - $lat = $location->lat; |
|
414 | - $lng = $location->lng; |
|
404 | + $access_token = (string)$data[0]['access_token']; |
|
405 | + $refresh_token = (string)$data[0]['refresh_token']; |
|
406 | + $token_type = (string)$data[0]['token_type']; |
|
407 | + $expires_in = $data[0]['expires_in']; |
|
408 | + $expiration_date = $data[0]['expiration_date']; |
|
409 | + $distinct_id = (string)$data[0]['distinct_id']; |
|
410 | + $device_uid = (string)$data[1]; |
|
411 | + |
|
412 | + $name = $location->cityName; |
|
413 | + $lat = $location->lat; |
|
414 | + $lng = $location->lng; |
|
415 | 415 | |
416 | - $db = new DatabaseConnect(); |
|
417 | - $result = $db->query("INSERT INTO accounts (access_token, refresh_token, token_type, |
|
416 | + $db = new DatabaseConnect(); |
|
417 | + $result = $db->query("INSERT INTO accounts (access_token, refresh_token, token_type, |
|
418 | 418 | expires_in, expiration_date, distinct_id, device_uid, name, lat, lng) |
419 | 419 | VALUES ('" . $access_token . "','" . $refresh_token . "','" . $token_type . |
420 | - "','" . $expires_in . "','" . $expiration_date . "','" . $distinct_id . |
|
421 | - "','" . $device_uid . "','" . $name . "','" . $lat . "','" . $lng . "') "); |
|
422 | - |
|
423 | - $success = TRUE; |
|
424 | - if($result === false){ |
|
425 | - $error = db_error(); |
|
426 | - echo $error; |
|
427 | - echo "Adding account failed: (" . $result->errno . ") " . $result->error; |
|
428 | - $success = FALSE; |
|
429 | - } |
|
420 | + "','" . $expires_in . "','" . $expiration_date . "','" . $distinct_id . |
|
421 | + "','" . $device_uid . "','" . $name . "','" . $lat . "','" . $lng . "') "); |
|
422 | + |
|
423 | + $success = TRUE; |
|
424 | + if($result === false){ |
|
425 | + $error = db_error(); |
|
426 | + echo $error; |
|
427 | + echo "Adding account failed: (" . $result->errno . ") " . $result->error; |
|
428 | + $success = FALSE; |
|
429 | + } |
|
430 | 430 | |
431 | - return $device_uid; |
|
432 | - } |
|
431 | + return $device_uid; |
|
432 | + } |
|
433 | 433 | |
434 | - function createAccount() |
|
435 | - { |
|
436 | - $config = parse_ini_file('config/config.ini.php'); |
|
437 | - $location = new Location(); |
|
438 | - $location->setLat($config['default_lat']); |
|
439 | - $location->setLng($config['default_lng']); |
|
440 | - $location->setCityName($config['default_location']); |
|
434 | + function createAccount() |
|
435 | + { |
|
436 | + $config = parse_ini_file('config/config.ini.php'); |
|
437 | + $location = new Location(); |
|
438 | + $location->setLat($config['default_lat']); |
|
439 | + $location->setLng($config['default_lng']); |
|
440 | + $location->setCityName($config['default_location']); |
|
441 | 441 | |
442 | - $deviceUid = $this->registerAccount($location); |
|
442 | + $deviceUid = $this->registerAccount($location); |
|
443 | 443 | |
444 | - return $deviceUid; |
|
445 | - } |
|
444 | + return $deviceUid; |
|
445 | + } |
|
446 | 446 | } |
447 | 447 | \ No newline at end of file |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | { |
36 | 36 | $this->refreshToken(); |
37 | 37 | } |
38 | - $this->accessToken = $this->getAccessToken(); |
|
38 | + $this->accessToken = $this->getAccessToken(); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | function isAccountVerified() |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | } |
95 | 95 | else |
96 | 96 | { |
97 | - error_log('User with JodelDeviceId:' . $this->deviceUid . ' [' . $_SERVER['REMOTE_ADDR'] . '][' . $_SERVER ['HTTP_USER_AGENT'] . '] changed to Location: ' . $name); |
|
97 | + error_log('User with JodelDeviceId:' . $this->deviceUid . ' [' . $_SERVER['REMOTE_ADDR'] . '][' . $_SERVER ['HTTP_USER_AGENT'] . '] changed to Location: ' . $name); |
|
98 | 98 | } |
99 | 99 | } |
100 | 100 | |
@@ -106,11 +106,11 @@ discard block |
||
106 | 106 | function getLocation() |
107 | 107 | { |
108 | 108 | $db = new DatabaseConnect(); |
109 | - $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'"); |
|
109 | + $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'"); |
|
110 | 110 | |
111 | 111 | $location = new Location(); |
112 | 112 | |
113 | - if ($result->num_rows > 0) |
|
113 | + if($result->num_rows > 0) |
|
114 | 114 | { |
115 | 115 | // output data of each row |
116 | 116 | while($row = $result->fetch_assoc()) |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | if(isset($_POST['color'])) |
212 | 212 | { |
213 | 213 | $color = $_POST['color']; |
214 | - switch ($color) { |
|
214 | + switch($color) { |
|
215 | 215 | case '8ABDB0': |
216 | 216 | $color = '8ABDB0'; |
217 | 217 | break; |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | |
268 | 268 | $access_token; |
269 | 269 | |
270 | - if ($result->num_rows > 0) |
|
270 | + if($result->num_rows > 0) |
|
271 | 271 | { |
272 | 272 | // output data of each row |
273 | 273 | while($row = $result->fetch_assoc()) { |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | expiration_date='" . $expiration_date . "' |
300 | 300 | WHERE device_uid='" . $device_uid . "'"); |
301 | 301 | |
302 | - if($result === false){ |
|
302 | + if($result === false) { |
|
303 | 303 | echo "Adding account failed: (" . $db->errno . ") " . $db->error; |
304 | 304 | } |
305 | 305 | } |
@@ -317,11 +317,11 @@ discard block |
||
317 | 317 | function getAccessToken() |
318 | 318 | { |
319 | 319 | $db = new DatabaseConnect(); |
320 | - $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'"); |
|
320 | + $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'"); |
|
321 | 321 | |
322 | 322 | $accessToken; |
323 | 323 | |
324 | - if ($result->num_rows > 0) |
|
324 | + if($result->num_rows > 0) |
|
325 | 325 | { |
326 | 326 | // output data of each row |
327 | 327 | while($row = $result->fetch_assoc()) |
@@ -389,7 +389,7 @@ discard block |
||
389 | 389 | $result = $db->query("INSERT INTO votes (device_uid, postId, type) |
390 | 390 | VALUES ('" . $this->deviceUid . "','" . $postId . "','" . $voteType . "')"); |
391 | 391 | |
392 | - if($result === false){ |
|
392 | + if($result === false) { |
|
393 | 393 | $error = db_error(); |
394 | 394 | echo $error; |
395 | 395 | echo "Adding Vote failed: (" . $result->errno . ") " . $result->error; |
@@ -417,11 +417,11 @@ discard block |
||
417 | 417 | $result = $db->query("INSERT INTO accounts (access_token, refresh_token, token_type, |
418 | 418 | expires_in, expiration_date, distinct_id, device_uid, name, lat, lng) |
419 | 419 | VALUES ('" . $access_token . "','" . $refresh_token . "','" . $token_type . |
420 | - "','" . $expires_in . "','" . $expiration_date . "','" . $distinct_id . |
|
420 | + "','" . $expires_in . "','" . $expiration_date . "','" . $distinct_id . |
|
421 | 421 | "','" . $device_uid . "','" . $name . "','" . $lat . "','" . $lng . "') "); |
422 | 422 | |
423 | 423 | $success = TRUE; |
424 | - if($result === false){ |
|
424 | + if($result === false) { |
|
425 | 425 | $error = db_error(); |
426 | 426 | echo $error; |
427 | 427 | echo "Adding account failed: (" . $result->errno . ") " . $result->error; |
@@ -3,18 +3,18 @@ |
||
3 | 3 | |
4 | 4 | class GetPostDetails extends AbstractRequest { |
5 | 5 | |
6 | - function getApiEndPoint() |
|
7 | - { |
|
8 | - return '/v2/posts/' . $_GET['postId']; |
|
9 | - } |
|
10 | - function getPayload() |
|
11 | - { |
|
12 | - return array( |
|
13 | - ); |
|
14 | - } |
|
15 | - function getMethod() |
|
16 | - { |
|
17 | - return 'GET'; |
|
18 | - } |
|
6 | + function getApiEndPoint() |
|
7 | + { |
|
8 | + return '/v2/posts/' . $_GET['postId']; |
|
9 | + } |
|
10 | + function getPayload() |
|
11 | + { |
|
12 | + return array( |
|
13 | + ); |
|
14 | + } |
|
15 | + function getMethod() |
|
16 | + { |
|
17 | + return 'GET'; |
|
18 | + } |
|
19 | 19 | } |
20 | 20 |
@@ -41,36 +41,36 @@ discard block |
||
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 |
@@ -97,14 +97,14 @@ discard block |
||
97 | 97 | } |
98 | 98 | |
99 | 99 | if(configPropertyExists($config, 'karmaDeviceUid')) |
100 | - { |
|
101 | - $jodelAccountForKarma = new JodelAccount($config['karmaDeviceUid']); |
|
102 | - } |
|
103 | - else |
|
104 | - { |
|
105 | - error_log("No Karma deviceUid set in config file"); |
|
100 | + { |
|
101 | + $jodelAccountForKarma = new JodelAccount($config['karmaDeviceUid']); |
|
102 | + } |
|
103 | + else |
|
104 | + { |
|
105 | + error_log("No Karma deviceUid set in config file"); |
|
106 | 106 | $jodelAccountForKarma = new JodelAccount($deviceUid); |
107 | - } |
|
107 | + } |
|
108 | 108 | |
109 | 109 | $newPositionStatus = $jodelAccountForView->location->getCityName(); |
110 | 110 | |
@@ -151,14 +151,14 @@ discard block |
||
151 | 151 | { |
152 | 152 | $jodelAccountForKarma->votePostId($_GET['postId'], $_GET['vote']); |
153 | 153 | if(isset($_GET['getPostDetails']) && isset($_GET['getPostDetails'])) |
154 | - { |
|
155 | - header('Location: index.php?getPostDetails=true&postId=' . htmlspecialchars($_GET['postId_parent']) . '#postId-' . htmlspecialchars($_GET['postId'])); |
|
156 | - } |
|
157 | - else |
|
158 | - { |
|
159 | - header("Location: index.php#postId-" . htmlspecialchars($_GET['postId'])); |
|
160 | - } |
|
161 | - die(); |
|
154 | + { |
|
155 | + header('Location: index.php?getPostDetails=true&postId=' . htmlspecialchars($_GET['postId_parent']) . '#postId-' . htmlspecialchars($_GET['postId'])); |
|
156 | + } |
|
157 | + else |
|
158 | + { |
|
159 | + header("Location: index.php#postId-" . htmlspecialchars($_GET['postId'])); |
|
160 | + } |
|
161 | + die(); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | //SendJodel |
@@ -203,32 +203,32 @@ discard block |
||
203 | 203 | if(!array_key_exists(0, $posts)) |
204 | 204 | { |
205 | 205 | $posts[0] = array( |
206 | - "post_id" => "0", |
|
207 | - "discovered_by" => 0, |
|
208 | - "message" => "Not found", |
|
209 | - "created_at" => "2017-02-11T16:44:50.385Z", |
|
210 | - "updated_at" => "2017-02-11T16:44:50.385Z", |
|
211 | - "pin_count" => 0, |
|
212 | - "color" => "FFBA00", |
|
213 | - "got_thanks" => FALSE, |
|
214 | - "post_own" => "friend", |
|
215 | - "discovered" => 0, |
|
216 | - "distance" => 9, |
|
217 | - "vote_count" => 0, |
|
218 | - "location" => |
|
219 | - array("name" => "Berlin", |
|
220 | - "loc_coordinates" => |
|
221 | - array( |
|
222 | - "lat" => 0, |
|
223 | - "lng" => 0 |
|
224 | - ), |
|
225 | - "loc_accuracy" => 0, |
|
226 | - "country" => "", |
|
227 | - "city" => "", |
|
228 | - ), |
|
229 | - "tags" => |
|
230 | - array(), |
|
231 | - "user_handle" => "0" |
|
206 | + "post_id" => "0", |
|
207 | + "discovered_by" => 0, |
|
208 | + "message" => "Not found", |
|
209 | + "created_at" => "2017-02-11T16:44:50.385Z", |
|
210 | + "updated_at" => "2017-02-11T16:44:50.385Z", |
|
211 | + "pin_count" => 0, |
|
212 | + "color" => "FFBA00", |
|
213 | + "got_thanks" => FALSE, |
|
214 | + "post_own" => "friend", |
|
215 | + "discovered" => 0, |
|
216 | + "distance" => 9, |
|
217 | + "vote_count" => 0, |
|
218 | + "location" => |
|
219 | + array("name" => "Berlin", |
|
220 | + "loc_coordinates" => |
|
221 | + array( |
|
222 | + "lat" => 0, |
|
223 | + "lng" => 0 |
|
224 | + ), |
|
225 | + "loc_accuracy" => 0, |
|
226 | + "country" => "", |
|
227 | + "city" => "", |
|
228 | + ), |
|
229 | + "tags" => |
|
230 | + array(), |
|
231 | + "user_handle" => "0" |
|
232 | 232 | ); |
233 | 233 | } |
234 | 234 | } |
@@ -237,32 +237,32 @@ discard block |
||
237 | 237 | $posts = array(); |
238 | 238 | $posts[0] = |
239 | 239 | array( |
240 | - "post_id" => "0", |
|
241 | - "discovered_by" => 0, |
|
242 | - "message" => "Bad Request", |
|
243 | - "created_at" => "2017-02-11T16:44:50.385Z", |
|
244 | - "updated_at" => "2017-02-11T16:44:50.385Z", |
|
245 | - "pin_count" => 0, |
|
246 | - "color" => "FFBA00", |
|
247 | - "got_thanks" => FALSE, |
|
248 | - "post_own" => "friend", |
|
249 | - "discovered" => 0, |
|
250 | - "distance" => 9, |
|
251 | - "vote_count" => 0, |
|
252 | - "location" => |
|
253 | - array("name" => "Berlin", |
|
254 | - "loc_coordinates" => |
|
255 | - array( |
|
256 | - "lat" => 0, |
|
257 | - "lng" => 0 |
|
258 | - ), |
|
259 | - "loc_accuracy" => 0, |
|
260 | - "country" => "", |
|
261 | - "city" => "", |
|
262 | - ), |
|
263 | - "tags" => |
|
264 | - array(), |
|
265 | - "user_handle" => "0" |
|
240 | + "post_id" => "0", |
|
241 | + "discovered_by" => 0, |
|
242 | + "message" => "Bad Request", |
|
243 | + "created_at" => "2017-02-11T16:44:50.385Z", |
|
244 | + "updated_at" => "2017-02-11T16:44:50.385Z", |
|
245 | + "pin_count" => 0, |
|
246 | + "color" => "FFBA00", |
|
247 | + "got_thanks" => FALSE, |
|
248 | + "post_own" => "friend", |
|
249 | + "discovered" => 0, |
|
250 | + "distance" => 9, |
|
251 | + "vote_count" => 0, |
|
252 | + "location" => |
|
253 | + array("name" => "Berlin", |
|
254 | + "loc_coordinates" => |
|
255 | + array( |
|
256 | + "lat" => 0, |
|
257 | + "lng" => 0 |
|
258 | + ), |
|
259 | + "loc_accuracy" => 0, |
|
260 | + "country" => "", |
|
261 | + "city" => "", |
|
262 | + ), |
|
263 | + "tags" => |
|
264 | + array(), |
|
265 | + "user_handle" => "0" |
|
266 | 266 | ); |
267 | 267 | |
268 | 268 |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | } |
98 | 98 | |
99 | 99 | if(configPropertyExists($config, 'karmaDeviceUid')) |
100 | - { |
|
100 | + { |
|
101 | 101 | $jodelAccountForKarma = new JodelAccount($config['karmaDeviceUid']); |
102 | 102 | } |
103 | 103 | else |
@@ -114,7 +114,8 @@ discard block |
||
114 | 114 | //Set View |
115 | 115 | if(isset($_GET['view'])) |
116 | 116 | { |
117 | - switch ($_GET['view']) { |
|
117 | + switch ($_GET['view']) |
|
118 | + { |
|
118 | 119 | case 'comment': |
119 | 120 | $view = 'comment'; |
120 | 121 | break; |
@@ -151,7 +152,7 @@ discard block |
||
151 | 152 | { |
152 | 153 | $jodelAccountForKarma->votePostId($_GET['postId'], $_GET['vote']); |
153 | 154 | if(isset($_GET['getPostDetails']) && isset($_GET['getPostDetails'])) |
154 | - { |
|
155 | + { |
|
155 | 156 | header('Location: index.php?getPostDetails=true&postId=' . htmlspecialchars($_GET['postId_parent']) . '#postId-' . htmlspecialchars($_GET['postId'])); |
156 | 157 | } |
157 | 158 | else |
@@ -169,7 +170,7 @@ discard block |
||
169 | 170 | |
170 | 171 | |
171 | 172 | function getPosts($lastPostId, $accessToken, $url, $version = 'v2') |
172 | - { |
|
173 | + { |
|
173 | 174 | $accountCreator = new GetPosts(); |
174 | 175 | $accountCreator->setLastPostId($lastPostId); |
175 | 176 | $accountCreator->setAccessToken($accessToken); |
@@ -290,7 +291,8 @@ discard block |
||
290 | 291 | |
291 | 292 | $posts[0] = $data; |
292 | 293 | |
293 | - if(array_key_exists('children', $data)) { |
|
294 | + if(array_key_exists('children', $data)) |
|
295 | + { |
|
294 | 296 | foreach($data['children'] as $key => $child) |
295 | 297 | { |
296 | 298 |
@@ -3,8 +3,8 @@ discard block |
||
3 | 3 | $config = parse_ini_file('config/config.ini.php'); |
4 | 4 | if(!isset($_GET['pw']) || $config['pw'] != $_GET['pw']) |
5 | 5 | { |
6 | - error_log($_SERVER['REMOTE_ADDR'] . ' used a wrong password on vote-ajax.php'); |
|
7 | - $respone = array("message" => $_SERVER['REMOTE_ADDR'] . ' used a wrong password on vote-ajax.php',"success" => false); |
|
6 | + error_log($_SERVER['REMOTE_ADDR'] . ' used a wrong password on vote-ajax.php'); |
|
7 | + $respone = array("message" => $_SERVER['REMOTE_ADDR'] . ' used a wrong password on vote-ajax.php', "success" => false); |
|
8 | 8 | echo json_encode($response); |
9 | 9 | |
10 | 10 | die(); |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | } |
56 | 56 | } |
57 | 57 | |
58 | -if (isset($captcha)) |
|
58 | +if(isset($captcha)) |
|
59 | 59 | { |
60 | 60 | $response = array("success" => $success, "message" => $message, "captcha" => $captcha, "deviceUid" => $deviceUid); |
61 | 61 | } |
@@ -59,7 +59,7 @@ |
||
59 | 59 | { |
60 | 60 | $response = array("success" => $success, "message" => $message, "captcha" => $captcha, "deviceUid" => $deviceUid); |
61 | 61 | } |
62 | -else |
|
62 | +else |
|
63 | 63 | { |
64 | 64 | $response = array("success" => $success, "message" => $message); |
65 | 65 | } |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | if(!isset($_GET['pw']) || $config['pw'] != $_GET['pw']) |
5 | 5 | { |
6 | 6 | error_log($_SERVER['REMOTE_ADDR'] . ' used a wrong password on vote-ajax.php'); |
7 | - $respone = array("message" => $_SERVER['REMOTE_ADDR'] . ' used a wrong password on vote-ajax.php',"success" => false); |
|
7 | + $respone = array("message" => $_SERVER['REMOTE_ADDR'] . ' used a wrong password on vote-ajax.php',"success" => FALSE); |
|
8 | 8 | echo json_encode($response); |
9 | 9 | |
10 | 10 | die(); |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | } |
22 | 22 | |
23 | 23 | $message = ""; |
24 | -$success = true; |
|
24 | +$success = TRUE; |
|
25 | 25 | $token = ""; |
26 | 26 | if(isset($_POST['vote']) && isset($_POST['postId'])) |
27 | 27 | { |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | $view = new View(); |
42 | 42 | $message = "This account is not verified. Please verify this account first."; |
43 | 43 | $captcha = $view->getCaptcha($accessToken); |
44 | - $success = false; |
|
44 | + $success = FALSE; |
|
45 | 45 | } |
46 | 46 | else |
47 | 47 | { |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | else |
52 | 52 | { |
53 | 53 | $message = 'There is no account available for this jodel. Please create at least one new account to vote this jodel.'; |
54 | - $success = false; |
|
54 | + $success = FALSE; |
|
55 | 55 | } |
56 | 56 | } |
57 | 57 |
@@ -4,7 +4,7 @@ |
||
4 | 4 | |
5 | 5 | if(!isset($_GET['pw']) || $config['pw'] != $_GET['pw']) |
6 | 6 | { |
7 | - error_log($_SERVER['REMOTE_ADDR'] . ' used a wrong password on admin.php'); |
|
7 | + error_log($_SERVER['REMOTE_ADDR'] . ' used a wrong password on admin.php'); |
|
8 | 8 | die(); |
9 | 9 | } |
10 | 10 |