@@ -19,8 +19,8 @@ discard block |
||
19 | 19 | |
20 | 20 | if(!isUserVoter() && !isUserAdmin()) |
21 | 21 | { |
22 | - error_log($_SERVER['REMOTE_ADDR'] . ' used a wrong password on vote-ajax.php'); |
|
23 | - $response = array("message" => $_SERVER['REMOTE_ADDR'] . ' used a wrong password on vote-ajax.php',"success" => false); |
|
22 | + error_log($_SERVER['REMOTE_ADDR'] . ' used a wrong password on vote-ajax.php'); |
|
23 | + $response = array("message" => $_SERVER['REMOTE_ADDR'] . ' used a wrong password on vote-ajax.php', "success" => false); |
|
24 | 24 | echo json_encode($response); |
25 | 25 | die(); |
26 | 26 | } |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | } |
111 | 111 | } |
112 | 112 | |
113 | - if (isset($captcha)) |
|
113 | + if(isset($captcha)) |
|
114 | 114 | { |
115 | 115 | $response = array("success" => $success, "message" => $message, "captcha" => $captcha, "deviceUid" => $deviceUid); |
116 | 116 | } |
@@ -114,7 +114,7 @@ |
||
114 | 114 | { |
115 | 115 | $response = array("success" => $success, "message" => $message, "captcha" => $captcha, "deviceUid" => $deviceUid); |
116 | 116 | } |
117 | - else |
|
117 | + else |
|
118 | 118 | { |
119 | 119 | $response = array("success" => $success, "message" => $message); |
120 | 120 | } |
@@ -20,14 +20,14 @@ discard block |
||
20 | 20 | if(!isUserVoter() && !isUserAdmin()) |
21 | 21 | { |
22 | 22 | error_log($_SERVER['REMOTE_ADDR'] . ' used a wrong password on vote-ajax.php'); |
23 | - $response = array("message" => $_SERVER['REMOTE_ADDR'] . ' used a wrong password on vote-ajax.php',"success" => false); |
|
23 | + $response = array("message" => $_SERVER['REMOTE_ADDR'] . ' used a wrong password on vote-ajax.php',"success" => FALSE); |
|
24 | 24 | echo json_encode($response); |
25 | 25 | die(); |
26 | 26 | } |
27 | 27 | else |
28 | 28 | { |
29 | 29 | $message = ""; |
30 | - $success = true; |
|
30 | + $success = TRUE; |
|
31 | 31 | $token = ""; |
32 | 32 | if(isset($_POST['vote']) && isset($_POST['postId'])) |
33 | 33 | { |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | //$response = array("success" => $jodelAccount->verifyCaptcha()); |
97 | 97 | //echo json_encode($response); |
98 | 98 | //die(); |
99 | - $success = false; |
|
99 | + $success = FALSE; |
|
100 | 100 | } |
101 | 101 | else |
102 | 102 | { |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | else |
107 | 107 | { |
108 | 108 | $message = 'There is no account available for this jodel. Please create at least one new account to vote this jodel.'; |
109 | - $success = false; |
|
109 | + $success = FALSE; |
|
110 | 110 | } |
111 | 111 | } |
112 | 112 |
@@ -44,17 +44,17 @@ |
||
44 | 44 | { |
45 | 45 | //insert voter into db |
46 | 46 | $db = new DatabaseConnect(); |
47 | - $result = $db->query("INSERT INTO users (user_token, remaining_votes, device_uid, rights) |
|
47 | + $result = $db->query("INSERT INTO users (user_token, remaining_votes, device_uid, rights) |
|
48 | 48 | VALUES ('" . $db->escape_string($_POST['user_token']) |
49 | - . "','" . $db->escape_string($_POST['remaining_votes']) |
|
50 | - . "','" . $db->escape_string($_POST['device_uid']) |
|
51 | - . "','" . $db->escape_string($_POST['rights']) . "')"); |
|
49 | + . "','" . $db->escape_string($_POST['remaining_votes']) |
|
50 | + . "','" . $db->escape_string($_POST['device_uid']) |
|
51 | + . "','" . $db->escape_string($_POST['rights']) . "')"); |
|
52 | 52 | |
53 | - if($result === false){ |
|
54 | - $error = db_error(); |
|
55 | - error_log($error); |
|
56 | - error_log("Adding Voter failed: (" . $result->errno . ") " . $result->error); |
|
57 | - } |
|
53 | + if($result === false){ |
|
54 | + $error = db_error(); |
|
55 | + error_log($error); |
|
56 | + error_log("Adding Voter failed: (" . $result->errno . ") " . $result->error); |
|
57 | + } |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | //Vote |
@@ -5,14 +5,14 @@ discard block |
||
5 | 5 | |
6 | 6 | if(isset($_GET['pw'])) |
7 | 7 | { |
8 | - setcookie('JodelAdminPassword', $_GET['pw'], time()+60*60*24*365*10); |
|
8 | + setcookie('JodelAdminPassword', $_GET['pw'], time() + 60 * 60 * 24 * 365 * 10); |
|
9 | 9 | error_log('admin password saved for [' . $_SERVER ['HTTP_USER_AGENT'] . ']'); |
10 | 10 | header('Location: ' . $baseUrl . 'admin.php'); |
11 | 11 | exit; |
12 | 12 | } |
13 | 13 | else if(isset($_GET['voterPw'])) |
14 | 14 | { |
15 | - setcookie('JodelVoterPassword', $_GET['voterPw'], time()+60*60*24*365*10); |
|
15 | + setcookie('JodelVoterPassword', $_GET['voterPw'], time() + 60 * 60 * 24 * 365 * 10); |
|
16 | 16 | error_log('voter password saved for [' . $_SERVER ['HTTP_USER_AGENT'] . ']'); |
17 | 17 | header('Location: ' . $baseUrl . 'admin.php'); |
18 | 18 | exit; |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | } |
31 | 31 | else |
32 | 32 | { |
33 | - error_log($_SERVER['REMOTE_ADDR'] . ' used a wrong voterPw / pw on admin.php'); |
|
33 | + error_log($_SERVER['REMOTE_ADDR'] . ' used a wrong voterPw / pw on admin.php'); |
|
34 | 34 | die(); |
35 | 35 | } |
36 | 36 | |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | . "','" . $db->escape_string($_POST['device_uid']) |
51 | 51 | . "','" . $db->escape_string($_POST['rights']) . "')"); |
52 | 52 | |
53 | - if($result === false){ |
|
53 | + if($result === false) { |
|
54 | 54 | $error = db_error(); |
55 | 55 | error_log($error); |
56 | 56 | error_log("Adding Voter failed: (" . $result->errno . ") " . $result->error); |
@@ -98,42 +98,42 @@ discard block |
||
98 | 98 | <meta name="keywords" content="jodelblue, jodel, blue, webclient, web, client"> |
99 | 99 | |
100 | 100 | <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"> |
101 | - <link rel="stylesheet" href="<?php echo $baseUrl;?>css/font-awesome.min.css"> |
|
102 | - <link rel="stylesheet" href="<?php echo $baseUrl;?>style.css" type="text/css"> |
|
101 | + <link rel="stylesheet" href="<?php echo $baseUrl; ?>css/font-awesome.min.css"> |
|
102 | + <link rel="stylesheet" href="<?php echo $baseUrl; ?>style.css" type="text/css"> |
|
103 | 103 | |
104 | - <link rel="shortcut icon" type="image/x-icon" href="<?php echo $baseUrl;?>img/favicon/favicon.ico"> |
|
105 | - <link rel="icon" type="image/x-icon" href="<?php echo $baseUrl;?>img/favicon/favicon.ico"> |
|
106 | - <link rel="icon" type="image/gif" href="<?php echo $baseUrl;?>img/favicon/favicon.gif"> |
|
107 | - <link rel="icon" type="image/png" href="<?php echo $baseUrl;?>img/favicon/favicon.png"> |
|
108 | - <link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon.png"> |
|
109 | - <link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon-57x57.png" sizes="57x57"> |
|
110 | - <link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon-60x60.png" sizes="60x60"> |
|
111 | - <link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon-72x72.png" sizes="72x72"> |
|
112 | - <link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon-76x76.png" sizes="76x76"> |
|
113 | - <link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon-114x114.png" sizes="114x114"> |
|
114 | - <link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon-120x120.png" sizes="120x120"> |
|
115 | - <link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon-128x128.png" sizes="128x128"> |
|
116 | - <link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon-144x144.png" sizes="144x144"> |
|
117 | - <link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon-152x152.png" sizes="152x152"> |
|
118 | - <link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon-180x180.png" sizes="180x180"> |
|
119 | - <link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon-precomposed.png"> |
|
120 | - <link rel="icon" type="image/png" href="<?php echo $baseUrl;?>img/favicon/favicon-16x16.png" sizes="16x16"> |
|
121 | - <link rel="icon" type="image/png" href="<?php echo $baseUrl;?>img/favicon/favicon-32x32.png" sizes="32x32"> |
|
122 | - <link rel="icon" type="image/png" href="<?php echo $baseUrl;?>img/favicon/favicon-96x96.png" sizes="96x96"> |
|
123 | - <link rel="icon" type="image/png" href="<?php echo $baseUrl;?>img/favicon/favicon-160x160.png" sizes="160x160"> |
|
124 | - <link rel="icon" type="image/png" href="<?php echo $baseUrl;?>img/favicon/favicon-192x192.png" sizes="192x192"> |
|
125 | - <link rel="icon" type="image/png" href="<?php echo $baseUrl;?>img/favicon/favicon-196x196.png" sizes="196x196"> |
|
126 | - <meta name="msapplication-TileImage" content="<?php echo $baseUrl;?>img/favicon/win8-tile-144x144.png"> |
|
104 | + <link rel="shortcut icon" type="image/x-icon" href="<?php echo $baseUrl; ?>img/favicon/favicon.ico"> |
|
105 | + <link rel="icon" type="image/x-icon" href="<?php echo $baseUrl; ?>img/favicon/favicon.ico"> |
|
106 | + <link rel="icon" type="image/gif" href="<?php echo $baseUrl; ?>img/favicon/favicon.gif"> |
|
107 | + <link rel="icon" type="image/png" href="<?php echo $baseUrl; ?>img/favicon/favicon.png"> |
|
108 | + <link rel="apple-touch-icon" href="<?php echo $baseUrl; ?>img/favicon/apple-touch-icon.png"> |
|
109 | + <link rel="apple-touch-icon" href="<?php echo $baseUrl; ?>img/favicon/apple-touch-icon-57x57.png" sizes="57x57"> |
|
110 | + <link rel="apple-touch-icon" href="<?php echo $baseUrl; ?>img/favicon/apple-touch-icon-60x60.png" sizes="60x60"> |
|
111 | + <link rel="apple-touch-icon" href="<?php echo $baseUrl; ?>img/favicon/apple-touch-icon-72x72.png" sizes="72x72"> |
|
112 | + <link rel="apple-touch-icon" href="<?php echo $baseUrl; ?>img/favicon/apple-touch-icon-76x76.png" sizes="76x76"> |
|
113 | + <link rel="apple-touch-icon" href="<?php echo $baseUrl; ?>img/favicon/apple-touch-icon-114x114.png" sizes="114x114"> |
|
114 | + <link rel="apple-touch-icon" href="<?php echo $baseUrl; ?>img/favicon/apple-touch-icon-120x120.png" sizes="120x120"> |
|
115 | + <link rel="apple-touch-icon" href="<?php echo $baseUrl; ?>img/favicon/apple-touch-icon-128x128.png" sizes="128x128"> |
|
116 | + <link rel="apple-touch-icon" href="<?php echo $baseUrl; ?>img/favicon/apple-touch-icon-144x144.png" sizes="144x144"> |
|
117 | + <link rel="apple-touch-icon" href="<?php echo $baseUrl; ?>img/favicon/apple-touch-icon-152x152.png" sizes="152x152"> |
|
118 | + <link rel="apple-touch-icon" href="<?php echo $baseUrl; ?>img/favicon/apple-touch-icon-180x180.png" sizes="180x180"> |
|
119 | + <link rel="apple-touch-icon" href="<?php echo $baseUrl; ?>img/favicon/apple-touch-icon-precomposed.png"> |
|
120 | + <link rel="icon" type="image/png" href="<?php echo $baseUrl; ?>img/favicon/favicon-16x16.png" sizes="16x16"> |
|
121 | + <link rel="icon" type="image/png" href="<?php echo $baseUrl; ?>img/favicon/favicon-32x32.png" sizes="32x32"> |
|
122 | + <link rel="icon" type="image/png" href="<?php echo $baseUrl; ?>img/favicon/favicon-96x96.png" sizes="96x96"> |
|
123 | + <link rel="icon" type="image/png" href="<?php echo $baseUrl; ?>img/favicon/favicon-160x160.png" sizes="160x160"> |
|
124 | + <link rel="icon" type="image/png" href="<?php echo $baseUrl; ?>img/favicon/favicon-192x192.png" sizes="192x192"> |
|
125 | + <link rel="icon" type="image/png" href="<?php echo $baseUrl; ?>img/favicon/favicon-196x196.png" sizes="196x196"> |
|
126 | + <meta name="msapplication-TileImage" content="<?php echo $baseUrl; ?>img/favicon/win8-tile-144x144.png"> |
|
127 | 127 | <meta name="msapplication-TileColor" content="#5682a3"> |
128 | 128 | <meta name="msapplication-navbutton-color" content="#5682a3"> |
129 | 129 | <meta name="application-name" content="JodelBlue"/> |
130 | 130 | <meta name="msapplication-tooltip" content="JodelBlue"/> |
131 | 131 | <meta name="apple-mobile-web-app-title" content="JodelBlue"/> |
132 | - <meta name="msapplication-square70x70logo" content="<?php echo $baseUrl;?>img/favicon/win8-tile-70x70.png"> |
|
133 | - <meta name="msapplication-square144x144logo" content="<?php echo $baseUrl;?>img/favicon/win8-tile-144x144.png"> |
|
134 | - <meta name="msapplication-square150x150logo" content="<?php echo $baseUrl;?>img/favicon/win8-tile-150x150.png"> |
|
135 | - <meta name="msapplication-wide310x150logo" content="<?php echo $baseUrl;?>img/favicon/win8-tile-310x150.png"> |
|
136 | - <meta name="msapplication-square310x310logo" content="<?php echo $baseUrl;?>img/favicon/win8-tile-310x310.png"> |
|
132 | + <meta name="msapplication-square70x70logo" content="<?php echo $baseUrl; ?>img/favicon/win8-tile-70x70.png"> |
|
133 | + <meta name="msapplication-square144x144logo" content="<?php echo $baseUrl; ?>img/favicon/win8-tile-144x144.png"> |
|
134 | + <meta name="msapplication-square150x150logo" content="<?php echo $baseUrl; ?>img/favicon/win8-tile-150x150.png"> |
|
135 | + <meta name="msapplication-wide310x150logo" content="<?php echo $baseUrl; ?>img/favicon/win8-tile-310x150.png"> |
|
136 | + <meta name="msapplication-square310x310logo" content="<?php echo $baseUrl; ?>img/favicon/win8-tile-310x310.png"> |
|
137 | 137 | </head> |
138 | 138 | |
139 | 139 | <body> |
@@ -184,9 +184,9 @@ discard block |
||
184 | 184 | <h2>Voting</h2> |
185 | 185 | <form> |
186 | 186 | <input placeholder="quantity" id="quantityDelay" type="number" name="quantity"><br> |
187 | - <input placeholder="min interval" id="minDelay" value="<?php echo $config['minInterval'];?>" type="text" name="min"><br> |
|
188 | - <input placeholder="max interval" id="maxDelay" value="<?php echo $config['maxInterval'];?>" type="text" name="max"><br> |
|
189 | - <input placeholder="postId" id="postIdDelay" value="<?php if(isset($_GET['postId'])) echo $_GET['postId'];?>" type="text" name="postId"><br> |
|
187 | + <input placeholder="min interval" id="minDelay" value="<?php echo $config['minInterval']; ?>" type="text" name="min"><br> |
|
188 | + <input placeholder="max interval" id="maxDelay" value="<?php echo $config['maxInterval']; ?>" type="text" name="max"><br> |
|
189 | + <input placeholder="postId" id="postIdDelay" value="<?php if(isset($_GET['postId'])) echo $_GET['postId']; ?>" type="text" name="postId"><br> |
|
190 | 190 | <button type="button" name="vote" value="up" class="half" onclick="voteWithAjax('up');">Upvote</button> |
191 | 191 | <button type="button" name="vote" value="down" class="half" onclick="voteWithAjax('down');">Downvote</button><br> |
192 | 192 | </form> |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | { |
248 | 248 | $.ajax({ |
249 | 249 | type: "POST", |
250 | - url: "<?php echo $baseUrl;?>vote-ajax.php", |
|
250 | + url: "<?php echo $baseUrl; ?>vote-ajax.php", |
|
251 | 251 | data: {"vote" : data["vote"], |
252 | 252 | "postId" : data["id"]}, |
253 | 253 | success: function(result){ |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | console.log(solution); |
302 | 302 | $.ajax({ |
303 | 303 | type: "POST", |
304 | - url: "<?php echo $baseUrl;?>vote-ajax.php?solution=" + solution + "&key="+key, |
|
304 | + url: "<?php echo $baseUrl; ?>vote-ajax.php?solution=" + solution + "&key="+key, |
|
305 | 305 | data: {"deviceUid" : deviceUid}, |
306 | 306 | success: function(result){ |
307 | 307 | var response = JSON.parse(result); |
@@ -50,7 +50,8 @@ discard block |
||
50 | 50 | . "','" . $db->escape_string($_POST['device_uid']) |
51 | 51 | . "','" . $db->escape_string($_POST['rights']) . "')"); |
52 | 52 | |
53 | - if($result === false){ |
|
53 | + if($result === false) |
|
54 | + { |
|
54 | 55 | $error = db_error(); |
55 | 56 | error_log($error); |
56 | 57 | error_log("Adding Voter failed: (" . $result->errno . ") " . $result->error); |
@@ -154,7 +155,9 @@ discard block |
||
154 | 155 | <article class="topContent col-sm-8"> |
155 | 156 | |
156 | 157 | <content id="posts" class="adminpanel"> |
157 | - <?php if($userIsAdmin) { ?> |
|
158 | + <?php if($userIsAdmin) |
|
159 | +{ |
|
160 | +?> |
|
158 | 161 | <h2>account management</h2> |
159 | 162 | <form method="post"> |
160 | 163 | <div> |
@@ -179,14 +182,19 @@ discard block |
||
179 | 182 | <?php |
180 | 183 | } |
181 | 184 | |
182 | - if($userIsVoter) { |
|
185 | + if($userIsVoter) |
|
186 | + { |
|
183 | 187 | ?> |
184 | 188 | <h2>Voting</h2> |
185 | 189 | <form> |
186 | 190 | <input placeholder="quantity" id="quantityDelay" type="number" name="quantity"><br> |
187 | 191 | <input placeholder="min interval" id="minDelay" value="<?php echo $config['minInterval'];?>" type="text" name="min"><br> |
188 | 192 | <input placeholder="max interval" id="maxDelay" value="<?php echo $config['maxInterval'];?>" type="text" name="max"><br> |
189 | - <input placeholder="postId" id="postIdDelay" value="<?php if(isset($_GET['postId'])) echo $_GET['postId'];?>" type="text" name="postId"><br> |
|
193 | + <input placeholder="postId" id="postIdDelay" value="<?php if(isset($_GET['postId'])) |
|
194 | +{ |
|
195 | + echo $_GET['postId']; |
|
196 | +} |
|
197 | +?>" type="text" name="postId"><br> |
|
190 | 198 | <button type="button" name="vote" value="up" class="half" onclick="voteWithAjax('up');">Upvote</button> |
191 | 199 | <button type="button" name="vote" value="down" class="half" onclick="voteWithAjax('down');">Downvote</button><br> |
192 | 200 | </form> |
@@ -20,13 +20,13 @@ discard block |
||
20 | 20 | |
21 | 21 | if(isUserAdmin()) |
22 | 22 | { |
23 | - $userIsAdmin = true; |
|
24 | - $userIsVoter = true; |
|
23 | + $userIsAdmin = TRUE; |
|
24 | + $userIsVoter = TRUE; |
|
25 | 25 | } |
26 | 26 | else if(isUserVoter()) |
27 | 27 | { |
28 | - $userIsAdmin = false; |
|
29 | - $userIsVoter = true; |
|
28 | + $userIsAdmin = FALSE; |
|
29 | + $userIsVoter = TRUE; |
|
30 | 30 | } |
31 | 31 | else |
32 | 32 | { |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | . "','" . $db->escape_string($_POST['device_uid']) |
51 | 51 | . "','" . $db->escape_string($_POST['rights']) . "')"); |
52 | 52 | |
53 | - if($result === false){ |
|
53 | + if($result === FALSE){ |
|
54 | 54 | $error = db_error(); |
55 | 55 | error_log($error); |
56 | 56 | error_log("Adding Voter failed: (" . $result->errno . ") " . $result->error); |
@@ -49,27 +49,27 @@ discard block |
||
49 | 49 | |
50 | 50 | function user_log($msg) |
51 | 51 | { |
52 | - $log = $msg . PHP_EOL; |
|
53 | - file_put_contents(realpath(__DIR__ . '/..') . '/logs/user_log-' . date("j.n.Y") . '.txt', $log, FILE_APPEND); |
|
52 | + $log = $msg . PHP_EOL; |
|
53 | + file_put_contents(realpath(__DIR__ . '/..') . '/logs/user_log-' . date("j.n.Y") . '.txt', $log, FILE_APPEND); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | function isUserBot() |
57 | 57 | { |
58 | - preg_match('/bot|spider|google|twitter/i', $_SERVER['HTTP_USER_AGENT'], $matches); |
|
58 | + preg_match('/bot|spider|google|twitter/i', $_SERVER['HTTP_USER_AGENT'], $matches); |
|
59 | 59 | |
60 | - return (isset($matches[0])) ? true : false; |
|
60 | + return (isset($matches[0])) ? true : false; |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | function configPropertyExists($config, $property) |
64 | 64 | { |
65 | - if(!array_key_exists($property, $config) || !isset($config[$property]) || $config[$property] == '' || $config[$property] == 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx') |
|
66 | - { |
|
67 | - return FALSE; |
|
68 | - } |
|
69 | - else |
|
70 | - { |
|
71 | - return TRUE; |
|
72 | - } |
|
65 | + if(!array_key_exists($property, $config) || !isset($config[$property]) || $config[$property] == '' || $config[$property] == 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx') |
|
66 | + { |
|
67 | + return FALSE; |
|
68 | + } |
|
69 | + else |
|
70 | + { |
|
71 | + return TRUE; |
|
72 | + } |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | function isUserVoter() |
@@ -110,17 +110,17 @@ discard block |
||
110 | 110 | |
111 | 111 | function isDeviceUidInDatabase($deviceUid) |
112 | 112 | { |
113 | - $db = new DatabaseConnect(); |
|
114 | - $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $deviceUid . "'"); |
|
113 | + $db = new DatabaseConnect(); |
|
114 | + $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $deviceUid . "'"); |
|
115 | 115 | |
116 | - if ($result->num_rows > 0) |
|
117 | - { |
|
118 | - return TRUE; |
|
119 | - } |
|
120 | - else |
|
121 | - { |
|
122 | - return FALSE; |
|
123 | - } |
|
116 | + if ($result->num_rows > 0) |
|
117 | + { |
|
118 | + return TRUE; |
|
119 | + } |
|
120 | + else |
|
121 | + { |
|
122 | + return FALSE; |
|
123 | + } |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | //Check if it's a Spider or Google Bot |
@@ -147,14 +147,14 @@ discard block |
||
147 | 147 | } |
148 | 148 | |
149 | 149 | if(configPropertyExists($config, 'karmaDeviceUid')) |
150 | - { |
|
151 | - $jodelAccountForKarma = new JodelAccount($config['karmaDeviceUid']); |
|
152 | - } |
|
153 | - else |
|
154 | - { |
|
155 | - error_log("No Karma deviceUid set in config file"); |
|
150 | + { |
|
151 | + $jodelAccountForKarma = new JodelAccount($config['karmaDeviceUid']); |
|
152 | + } |
|
153 | + else |
|
154 | + { |
|
155 | + error_log("No Karma deviceUid set in config file"); |
|
156 | 156 | $jodelAccountForKarma = new JodelAccount($deviceUid); |
157 | - } |
|
157 | + } |
|
158 | 158 | |
159 | 159 | /* |
160 | 160 | * Cunstruct View |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | |
50 | 50 | function user_log($msg) |
51 | 51 | { |
52 | - $log = $msg . PHP_EOL; |
|
52 | + $log = $msg . PHP_EOL; |
|
53 | 53 | file_put_contents(realpath(__DIR__ . '/..') . '/logs/user_log-' . date("j.n.Y") . '.txt', $log, FILE_APPEND); |
54 | 54 | } |
55 | 55 | |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | { |
58 | 58 | preg_match('/bot|spider|google|twitter/i', $_SERVER['HTTP_USER_AGENT'], $matches); |
59 | 59 | |
60 | - return (isset($matches[0])) ? true : false; |
|
60 | + return (isset($matches[0]))?true : false; |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | function configPropertyExists($config, $property) |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | function isUserAdmin() |
99 | 99 | { |
100 | 100 | global $config; |
101 | - if (isset($_COOKIE['JodelAdminPassword']) && configPropertyExists($config, 'pw') && $config['pw'] == $_COOKIE['JodelAdminPassword']) |
|
101 | + if(isset($_COOKIE['JodelAdminPassword']) && configPropertyExists($config, 'pw') && $config['pw'] == $_COOKIE['JodelAdminPassword']) |
|
102 | 102 | { |
103 | 103 | return TRUE; |
104 | 104 | } |
@@ -111,9 +111,9 @@ discard block |
||
111 | 111 | function isDeviceUidInDatabase($deviceUid) |
112 | 112 | { |
113 | 113 | $db = new DatabaseConnect(); |
114 | - $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $deviceUid . "'"); |
|
114 | + $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $deviceUid . "'"); |
|
115 | 115 | |
116 | - if ($result->num_rows > 0) |
|
116 | + if($result->num_rows > 0) |
|
117 | 117 | { |
118 | 118 | return TRUE; |
119 | 119 | } |
@@ -135,8 +135,8 @@ discard block |
||
135 | 135 | if(!isset($_COOKIE['JodelDeviceId']) || !isDeviceUidInDatabase($_COOKIE['JodelDeviceId'])) |
136 | 136 | { |
137 | 137 | $jodelAccountForView = new JodelAccount(); |
138 | - setcookie('JodelDeviceId', $jodelAccountForView->deviceUid, time()+60*60*24*365*10); |
|
139 | - user_log('Created account with JodelDeviceId:' . $jodelAccountForView->deviceUid . ' for [' . $_SERVER ['HTTP_USER_AGENT'] . ']'); |
|
138 | + setcookie('JodelDeviceId', $jodelAccountForView->deviceUid, time() + 60 * 60 * 24 * 365 * 10); |
|
139 | + user_log('Created account with JodelDeviceId:' . $jodelAccountForView->deviceUid . ' for [' . $_SERVER ['HTTP_USER_AGENT'] . ']'); |
|
140 | 140 | |
141 | 141 | } |
142 | 142 | else |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | if(isset($_GET['search'])) |
166 | 166 | { |
167 | 167 | |
168 | - user_log('User with JodelDeviceId:' . $jodelAccountForView->deviceUid . ' [' . $_SERVER['REMOTE_ADDR'] . '][' . $_SERVER ['HTTP_USER_AGENT'] . '] searched for ' . $_GET['search']); |
|
168 | + user_log('User with JodelDeviceId:' . $jodelAccountForView->deviceUid . ' [' . $_SERVER['REMOTE_ADDR'] . '][' . $_SERVER ['HTTP_USER_AGENT'] . '] searched for ' . $_GET['search']); |
|
169 | 169 | |
170 | 170 | if(substr($_GET['search'], 0, 1) === "#") |
171 | 171 | { |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | |
221 | 221 | if(isset($_GET['view'])) |
222 | 222 | { |
223 | - switch ($_GET['view']) { |
|
223 | + switch($_GET['view']) { |
|
224 | 224 | case 'discussed': |
225 | 225 | $view = 'discussed'; |
226 | 226 | break; |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | function isUserVoter() |
76 | 76 | { |
77 | 77 | if(isset($_COOKIE['JodelVoterPassword'])) |
78 | - { |
|
78 | + { |
|
79 | 79 | $db = new DatabaseConnect(); |
80 | 80 | $result = $db->query("SELECT id FROM users WHERE user_token = '" . $_COOKIE['JodelVoterPassword'] . "'"); |
81 | 81 | if($result->num_rows == 0) |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | } |
148 | 148 | |
149 | 149 | if(configPropertyExists($config, 'karmaDeviceUid')) |
150 | - { |
|
150 | + { |
|
151 | 151 | $jodelAccountForKarma = new JodelAccount($config['karmaDeviceUid']); |
152 | 152 | } |
153 | 153 | else |
@@ -220,7 +220,8 @@ discard block |
||
220 | 220 | |
221 | 221 | if(isset($_GET['view'])) |
222 | 222 | { |
223 | - switch ($_GET['view']) { |
|
223 | + switch ($_GET['view']) |
|
224 | + { |
|
224 | 225 | case 'discussed': |
225 | 226 | $view = 'discussed'; |
226 | 227 | break; |
@@ -2,21 +2,21 @@ discard block |
||
2 | 2 | |
3 | 3 | abstract class AbstractRequest |
4 | 4 | { |
5 | - const CLIENTID = '81e8a76e-1e02-4d17-9ba0-8a7020261b26'; |
|
6 | - const APIURL = 'https://api.go-tellm.com/api'; |
|
7 | - const SECRET = 'SDydTnTdqqaiAMfneLkqXYxamvNuUYOmkqpdiZTu'; |
|
8 | - const USERAGENT = 'Jodel/4.34.2 Dalvik/2.1.0 (Linux; U; Android 5.1.1; )'; |
|
9 | - const CLIENT_TYPE = 'android_4.34.2'; |
|
5 | + const CLIENTID = '81e8a76e-1e02-4d17-9ba0-8a7020261b26'; |
|
6 | + const APIURL = 'https://api.go-tellm.com/api'; |
|
7 | + const SECRET = 'SDydTnTdqqaiAMfneLkqXYxamvNuUYOmkqpdiZTu'; |
|
8 | + const USERAGENT = 'Jodel/4.34.2 Dalvik/2.1.0 (Linux; U; Android 5.1.1; )'; |
|
9 | + const CLIENT_TYPE = 'android_4.34.2'; |
|
10 | 10 | |
11 | - private $accessToken = null; |
|
12 | - private $payLoad; |
|
13 | - public $expects = ''; |
|
14 | - public $version = 'v2'; |
|
15 | - public $hasPayload = FALSE; |
|
11 | + private $accessToken = null; |
|
12 | + private $payLoad; |
|
13 | + public $expects = ''; |
|
14 | + public $version = 'v2'; |
|
15 | + public $hasPayload = FALSE; |
|
16 | 16 | |
17 | - public function execute() |
|
18 | - { |
|
19 | - $result = new \stdClass(); |
|
17 | + public function execute() |
|
18 | + { |
|
19 | + $result = new \stdClass(); |
|
20 | 20 | |
21 | 21 | $this->payLoad = $this->getPayload(); |
22 | 22 | $device_uid = ''; |
@@ -25,16 +25,16 @@ discard block |
||
25 | 25 | } |
26 | 26 | |
27 | 27 | |
28 | - $this->payLoad = json_encode($this->payLoad); |
|
29 | - $header = $this->getSignHeaders(); |
|
30 | - $url = $this->getFullUrl(); |
|
28 | + $this->payLoad = json_encode($this->payLoad); |
|
29 | + $header = $this->getSignHeaders(); |
|
30 | + $url = $this->getFullUrl(); |
|
31 | 31 | |
32 | - if ($this->getAccessToken()) { |
|
33 | - $header['Authorization'] = "Bearer " . $this->getAccessToken(); |
|
34 | - } |
|
35 | - //Comment out to debug the Request: |
|
32 | + if ($this->getAccessToken()) { |
|
33 | + $header['Authorization'] = "Bearer " . $this->getAccessToken(); |
|
34 | + } |
|
35 | + //Comment out to debug the Request: |
|
36 | 36 | |
37 | - /* |
|
37 | + /* |
|
38 | 38 | printf("URL: "); |
39 | 39 | var_dump($url); |
40 | 40 | echo "<br />"; |
@@ -45,112 +45,112 @@ discard block |
||
45 | 45 | var_dump($this->payLoad); |
46 | 46 | echo "<br />"; |
47 | 47 | */ |
48 | - /* |
|
48 | + /* |
|
49 | 49 | $options = array( |
50 | 50 | 'timeout' => 100, |
51 | 51 | 'connect_timeout' => 100, |
52 | 52 | 'proxy' => '186.103.169.165:8080', |
53 | 53 | );*/ |
54 | 54 | |
55 | - switch ($this->getMethod()) { |
|
56 | - case 'POST': |
|
57 | - $result = Requests::post($url, $header, $this->payLoad); |
|
58 | - break; |
|
59 | - case 'GET': |
|
60 | - if($this->hasPayload) |
|
61 | - { |
|
62 | - $result = Requests::get($url, $header, $this->payLoad); |
|
63 | - } |
|
64 | - else |
|
65 | - { |
|
66 | - $result = Requests::get($url, $header); |
|
67 | - } |
|
68 | - break; |
|
69 | - case 'PUT': |
|
70 | - $result = Requests::put($url, $header, $this->payLoad); |
|
71 | - break; |
|
72 | - } |
|
55 | + switch ($this->getMethod()) { |
|
56 | + case 'POST': |
|
57 | + $result = Requests::post($url, $header, $this->payLoad); |
|
58 | + break; |
|
59 | + case 'GET': |
|
60 | + if($this->hasPayload) |
|
61 | + { |
|
62 | + $result = Requests::get($url, $header, $this->payLoad); |
|
63 | + } |
|
64 | + else |
|
65 | + { |
|
66 | + $result = Requests::get($url, $header); |
|
67 | + } |
|
68 | + break; |
|
69 | + case 'PUT': |
|
70 | + $result = Requests::put($url, $header, $this->payLoad); |
|
71 | + break; |
|
72 | + } |
|
73 | 73 | |
74 | - http_response_code($result->status_code); |
|
74 | + http_response_code($result->status_code); |
|
75 | 75 | |
76 | - switch ($result->status_code) { |
|
77 | - case 200: |
|
78 | - $result = json_decode($result->body, true); |
|
79 | - break; |
|
80 | - case 204: |
|
81 | - $result = 'Success'; |
|
82 | - http_response_code(200); |
|
83 | - break; |
|
84 | - case 400: |
|
85 | - $result = json_decode($result->body, true); |
|
86 | - error_log('Error 400 - ' . print_r($result, true)); |
|
87 | - break; |
|
88 | - case 401: |
|
89 | - $result = json_decode($result->body, true); |
|
76 | + switch ($result->status_code) { |
|
77 | + case 200: |
|
78 | + $result = json_decode($result->body, true); |
|
79 | + break; |
|
80 | + case 204: |
|
81 | + $result = 'Success'; |
|
82 | + http_response_code(200); |
|
83 | + break; |
|
84 | + case 400: |
|
85 | + $result = json_decode($result->body, true); |
|
86 | + error_log('Error 400 - ' . print_r($result, true)); |
|
87 | + break; |
|
88 | + case 401: |
|
89 | + $result = json_decode($result->body, true); |
|
90 | 90 | |
91 | - if(array_key_exists('error', $result) && $result['error'] == 'length') |
|
92 | - { |
|
91 | + if(array_key_exists('error', $result) && $result['error'] == 'length') |
|
92 | + { |
|
93 | 93 | |
94 | - } |
|
95 | - else |
|
96 | - { |
|
97 | - error_log('Error 401 - ' . print_r($result, true)); |
|
98 | - } |
|
99 | - break; |
|
100 | - case 404: |
|
101 | - error_log('Error 404 - ' . print_r($result, true)); |
|
102 | - $result = json_decode($result->body, true); |
|
103 | - break; |
|
94 | + } |
|
95 | + else |
|
96 | + { |
|
97 | + error_log('Error 401 - ' . print_r($result, true)); |
|
98 | + } |
|
99 | + break; |
|
100 | + case 404: |
|
101 | + error_log('Error 404 - ' . print_r($result, true)); |
|
102 | + $result = json_decode($result->body, true); |
|
103 | + break; |
|
104 | 104 | case 477: |
105 | - $result = json_decode($result->body, true); |
|
106 | - error_log('Error 477 - ' . print_r($result, true)); |
|
107 | - break; |
|
108 | - case 429: |
|
109 | - error_log('Error 429 - Too Many Requests' . print_r(json_decode($result->body, true), true)); |
|
110 | - exit("Error 429: Too Many Requests"); |
|
111 | - break; |
|
112 | - case 403: |
|
113 | - error_log('Error 403 - Access denied:' . print_r(json_decode($result->body, true), true)); |
|
114 | - $result = json_decode($result->body, true); |
|
115 | - break; |
|
116 | - case 502: |
|
117 | - error_log('Error 502 - ' . print_r($result, true)); |
|
118 | - $result = json_decode($result->body, true); |
|
119 | - header('location:'.$_SERVER['PHP_SELF']); |
|
120 | - break; |
|
121 | - case 503: |
|
122 | - error_log('Error 503 - ' . print_r($result, true)); |
|
123 | - $result = json_decode($result->body, true); |
|
105 | + $result = json_decode($result->body, true); |
|
106 | + error_log('Error 477 - ' . print_r($result, true)); |
|
107 | + break; |
|
108 | + case 429: |
|
109 | + error_log('Error 429 - Too Many Requests' . print_r(json_decode($result->body, true), true)); |
|
110 | + exit("Error 429: Too Many Requests"); |
|
111 | + break; |
|
112 | + case 403: |
|
113 | + error_log('Error 403 - Access denied:' . print_r(json_decode($result->body, true), true)); |
|
114 | + $result = json_decode($result->body, true); |
|
115 | + break; |
|
116 | + case 502: |
|
117 | + error_log('Error 502 - ' . print_r($result, true)); |
|
118 | + $result = json_decode($result->body, true); |
|
119 | + header('location:'.$_SERVER['PHP_SELF']); |
|
120 | + break; |
|
121 | + case 503: |
|
122 | + error_log('Error 503 - ' . print_r($result, true)); |
|
123 | + $result = json_decode($result->body, true); |
|
124 | 124 | |
125 | - if(array_key_exists('error', $result) && $result['error'] == 'Service Unavailable') |
|
126 | - { |
|
127 | - header('location:'.$_SERVER['PHP_SELF']); |
|
128 | - } |
|
129 | - break; |
|
130 | - default: |
|
131 | - error_log('Error '.$result->status_code.' - unknown error'); |
|
132 | - $result = json_decode($result->body, true); |
|
133 | - } |
|
125 | + if(array_key_exists('error', $result) && $result['error'] == 'Service Unavailable') |
|
126 | + { |
|
127 | + header('location:'.$_SERVER['PHP_SELF']); |
|
128 | + } |
|
129 | + break; |
|
130 | + default: |
|
131 | + error_log('Error '.$result->status_code.' - unknown error'); |
|
132 | + $result = json_decode($result->body, true); |
|
133 | + } |
|
134 | 134 | |
135 | - //important for account refresh |
|
136 | - if($device_uid != '') |
|
137 | - { |
|
135 | + //important for account refresh |
|
136 | + if($device_uid != '') |
|
137 | + { |
|
138 | 138 | $result[0] = $result; |
139 | 139 | $result[1] = $device_uid; |
140 | - } |
|
140 | + } |
|
141 | 141 | |
142 | 142 | |
143 | - /* var_dump($result); */ |
|
143 | + /* var_dump($result); */ |
|
144 | 144 | |
145 | - return $result; |
|
146 | - } |
|
147 | - abstract function getPayload(); |
|
148 | - /** |
|
149 | - * Gets Sign headers |
|
150 | - * @return array headers |
|
151 | - */ |
|
152 | - private function getSignHeaders() |
|
153 | - { |
|
145 | + return $result; |
|
146 | + } |
|
147 | + abstract function getPayload(); |
|
148 | + /** |
|
149 | + * Gets Sign headers |
|
150 | + * @return array headers |
|
151 | + */ |
|
152 | + private function getSignHeaders() |
|
153 | + { |
|
154 | 154 | if($this->getAccessToken() == null) { |
155 | 155 | $payload_accessToken = ""; |
156 | 156 | } |
@@ -159,54 +159,54 @@ discard block |
||
159 | 159 | } |
160 | 160 | |
161 | 161 | |
162 | - $headers = array( |
|
163 | - "Connection" => "keep-alive", |
|
164 | - "Accept-Encoding" => "gzip", |
|
165 | - "Content-Type" => "application/json; charset=UTF-8", |
|
166 | - "User-Agent" => self::USERAGENT |
|
167 | - ); |
|
168 | - $timestamp = new DateTime(); |
|
169 | - $timestamp = $timestamp->format(DateTime::ATOM); |
|
170 | - $timestamp = substr($timestamp, 0, -6); |
|
171 | - $timestamp .= "Z"; |
|
172 | - $urlParts = parse_url($this->getFullUrl()); |
|
173 | - $url2 = ""; |
|
174 | - $req = [$this->getMethod(), |
|
175 | - $urlParts['host'], |
|
176 | - "443", |
|
177 | - $urlParts['path'], |
|
178 | - $payload_accessToken, |
|
179 | - $timestamp, |
|
180 | - $url2, |
|
181 | - $this->payLoad]; |
|
182 | - $reqString = implode("%", $req); |
|
183 | - $secret = self::SECRET; |
|
184 | - $signature = hash_hmac('sha1', $reqString, $secret); |
|
185 | - $signature = strtoupper($signature); |
|
186 | - $headers['X-Authorization'] = 'HMAC ' . $signature; |
|
187 | - $headers['X-Client-Type'] = self::CLIENT_TYPE; |
|
188 | - $headers['X-Timestamp'] = $timestamp; |
|
189 | - $headers['X-Api-Version'] = '0.2'; |
|
190 | - return $headers; |
|
191 | - } |
|
192 | - private function getFullUrl() |
|
193 | - { |
|
194 | - return self::APIURL . $this->getApiEndPoint(); |
|
195 | - } |
|
196 | - abstract function getApiEndPoint(); |
|
197 | - abstract function getMethod(); |
|
198 | - /** |
|
199 | - * @return string |
|
200 | - */ |
|
201 | - private function getAccessToken() |
|
202 | - { |
|
203 | - return $this->accessToken; |
|
204 | - } |
|
205 | - /** |
|
206 | - * @param string $accessToken |
|
207 | - */ |
|
208 | - public function setAccessToken($accessToken) |
|
209 | - { |
|
210 | - $this->accessToken = $accessToken; |
|
211 | - } |
|
162 | + $headers = array( |
|
163 | + "Connection" => "keep-alive", |
|
164 | + "Accept-Encoding" => "gzip", |
|
165 | + "Content-Type" => "application/json; charset=UTF-8", |
|
166 | + "User-Agent" => self::USERAGENT |
|
167 | + ); |
|
168 | + $timestamp = new DateTime(); |
|
169 | + $timestamp = $timestamp->format(DateTime::ATOM); |
|
170 | + $timestamp = substr($timestamp, 0, -6); |
|
171 | + $timestamp .= "Z"; |
|
172 | + $urlParts = parse_url($this->getFullUrl()); |
|
173 | + $url2 = ""; |
|
174 | + $req = [$this->getMethod(), |
|
175 | + $urlParts['host'], |
|
176 | + "443", |
|
177 | + $urlParts['path'], |
|
178 | + $payload_accessToken, |
|
179 | + $timestamp, |
|
180 | + $url2, |
|
181 | + $this->payLoad]; |
|
182 | + $reqString = implode("%", $req); |
|
183 | + $secret = self::SECRET; |
|
184 | + $signature = hash_hmac('sha1', $reqString, $secret); |
|
185 | + $signature = strtoupper($signature); |
|
186 | + $headers['X-Authorization'] = 'HMAC ' . $signature; |
|
187 | + $headers['X-Client-Type'] = self::CLIENT_TYPE; |
|
188 | + $headers['X-Timestamp'] = $timestamp; |
|
189 | + $headers['X-Api-Version'] = '0.2'; |
|
190 | + return $headers; |
|
191 | + } |
|
192 | + private function getFullUrl() |
|
193 | + { |
|
194 | + return self::APIURL . $this->getApiEndPoint(); |
|
195 | + } |
|
196 | + abstract function getApiEndPoint(); |
|
197 | + abstract function getMethod(); |
|
198 | + /** |
|
199 | + * @return string |
|
200 | + */ |
|
201 | + private function getAccessToken() |
|
202 | + { |
|
203 | + return $this->accessToken; |
|
204 | + } |
|
205 | + /** |
|
206 | + * @param string $accessToken |
|
207 | + */ |
|
208 | + public function setAccessToken($accessToken) |
|
209 | + { |
|
210 | + $this->accessToken = $accessToken; |
|
211 | + } |
|
212 | 212 | } |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | $header = $this->getSignHeaders(); |
30 | 30 | $url = $this->getFullUrl(); |
31 | 31 | |
32 | - if ($this->getAccessToken()) { |
|
32 | + if($this->getAccessToken()) { |
|
33 | 33 | $header['Authorization'] = "Bearer " . $this->getAccessToken(); |
34 | 34 | } |
35 | 35 | //Comment out to debug the Request: |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | 'proxy' => '186.103.169.165:8080', |
53 | 53 | );*/ |
54 | 54 | |
55 | - switch ($this->getMethod()) { |
|
55 | + switch($this->getMethod()) { |
|
56 | 56 | case 'POST': |
57 | 57 | $result = Requests::post($url, $header, $this->payLoad); |
58 | 58 | break; |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | |
74 | 74 | http_response_code($result->status_code); |
75 | 75 | |
76 | - switch ($result->status_code) { |
|
76 | + switch($result->status_code) { |
|
77 | 77 | case 200: |
78 | 78 | $result = json_decode($result->body, true); |
79 | 79 | break; |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | case 502: |
117 | 117 | error_log('Error 502 - ' . print_r($result, true)); |
118 | 118 | $result = json_decode($result->body, true); |
119 | - header('location:'.$_SERVER['PHP_SELF']); |
|
119 | + header('location:' . $_SERVER['PHP_SELF']); |
|
120 | 120 | break; |
121 | 121 | case 503: |
122 | 122 | error_log('Error 503 - ' . print_r($result, true)); |
@@ -124,11 +124,11 @@ discard block |
||
124 | 124 | |
125 | 125 | if(array_key_exists('error', $result) && $result['error'] == 'Service Unavailable') |
126 | 126 | { |
127 | - header('location:'.$_SERVER['PHP_SELF']); |
|
127 | + header('location:' . $_SERVER['PHP_SELF']); |
|
128 | 128 | } |
129 | 129 | break; |
130 | 130 | default: |
131 | - error_log('Error '.$result->status_code.' - unknown error'); |
|
131 | + error_log('Error ' . $result->status_code . ' - unknown error'); |
|
132 | 132 | $result = json_decode($result->body, true); |
133 | 133 | } |
134 | 134 |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | const USERAGENT = 'Jodel/4.34.2 Dalvik/2.1.0 (Linux; U; Android 5.1.1; )'; |
9 | 9 | const CLIENT_TYPE = 'android_4.34.2'; |
10 | 10 | |
11 | - private $accessToken = null; |
|
11 | + private $accessToken = NULL; |
|
12 | 12 | private $payLoad; |
13 | 13 | public $expects = ''; |
14 | 14 | public $version = 'v2'; |
@@ -75,18 +75,18 @@ discard block |
||
75 | 75 | |
76 | 76 | switch ($result->status_code) { |
77 | 77 | case 200: |
78 | - $result = json_decode($result->body, true); |
|
78 | + $result = json_decode($result->body, TRUE); |
|
79 | 79 | break; |
80 | 80 | case 204: |
81 | 81 | $result = 'Success'; |
82 | 82 | http_response_code(200); |
83 | 83 | break; |
84 | 84 | case 400: |
85 | - $result = json_decode($result->body, true); |
|
86 | - error_log('Error 400 - ' . print_r($result, true)); |
|
85 | + $result = json_decode($result->body, TRUE); |
|
86 | + error_log('Error 400 - ' . print_r($result, TRUE)); |
|
87 | 87 | break; |
88 | 88 | case 401: |
89 | - $result = json_decode($result->body, true); |
|
89 | + $result = json_decode($result->body, TRUE); |
|
90 | 90 | |
91 | 91 | if(array_key_exists('error', $result) && $result['error'] == 'length') |
92 | 92 | { |
@@ -94,33 +94,33 @@ discard block |
||
94 | 94 | } |
95 | 95 | else |
96 | 96 | { |
97 | - error_log('Error 401 - ' . print_r($result, true)); |
|
97 | + error_log('Error 401 - ' . print_r($result, TRUE)); |
|
98 | 98 | } |
99 | 99 | break; |
100 | 100 | case 404: |
101 | - error_log('Error 404 - ' . print_r($result, true)); |
|
102 | - $result = json_decode($result->body, true); |
|
101 | + error_log('Error 404 - ' . print_r($result, TRUE)); |
|
102 | + $result = json_decode($result->body, TRUE); |
|
103 | 103 | break; |
104 | 104 | case 477: |
105 | - $result = json_decode($result->body, true); |
|
106 | - error_log('Error 477 - ' . print_r($result, true)); |
|
105 | + $result = json_decode($result->body, TRUE); |
|
106 | + error_log('Error 477 - ' . print_r($result, TRUE)); |
|
107 | 107 | break; |
108 | 108 | case 429: |
109 | - error_log('Error 429 - Too Many Requests' . print_r(json_decode($result->body, true), true)); |
|
109 | + error_log('Error 429 - Too Many Requests' . print_r(json_decode($result->body, TRUE), TRUE)); |
|
110 | 110 | exit("Error 429: Too Many Requests"); |
111 | 111 | break; |
112 | 112 | case 403: |
113 | - error_log('Error 403 - Access denied:' . print_r(json_decode($result->body, true), true)); |
|
114 | - $result = json_decode($result->body, true); |
|
113 | + error_log('Error 403 - Access denied:' . print_r(json_decode($result->body, TRUE), TRUE)); |
|
114 | + $result = json_decode($result->body, TRUE); |
|
115 | 115 | break; |
116 | 116 | case 502: |
117 | - error_log('Error 502 - ' . print_r($result, true)); |
|
118 | - $result = json_decode($result->body, true); |
|
117 | + error_log('Error 502 - ' . print_r($result, TRUE)); |
|
118 | + $result = json_decode($result->body, TRUE); |
|
119 | 119 | header('location:'.$_SERVER['PHP_SELF']); |
120 | 120 | break; |
121 | 121 | case 503: |
122 | - error_log('Error 503 - ' . print_r($result, true)); |
|
123 | - $result = json_decode($result->body, true); |
|
122 | + error_log('Error 503 - ' . print_r($result, TRUE)); |
|
123 | + $result = json_decode($result->body, TRUE); |
|
124 | 124 | |
125 | 125 | if(array_key_exists('error', $result) && $result['error'] == 'Service Unavailable') |
126 | 126 | { |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | break; |
130 | 130 | default: |
131 | 131 | error_log('Error '.$result->status_code.' - unknown error'); |
132 | - $result = json_decode($result->body, true); |
|
132 | + $result = json_decode($result->body, TRUE); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | //important for account refresh |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | */ |
152 | 152 | private function getSignHeaders() |
153 | 153 | { |
154 | - if($this->getAccessToken() == null) { |
|
154 | + if($this->getAccessToken() == NULL) { |
|
155 | 155 | $payload_accessToken = ""; |
156 | 156 | } |
157 | 157 | else { |
@@ -65,6 +65,6 @@ |
||
65 | 65 | |
66 | 66 | if(!$db->query($query) || !$db->query($query2) || !$db->query($query3)) |
67 | 67 | { |
68 | - throw new Exception($db->error($mysqli)); |
|
68 | + throw new Exception($db->error($mysqli)); |
|
69 | 69 | } |
70 | 70 |
@@ -17,10 +17,10 @@ discard block |
||
17 | 17 | { |
18 | 18 | error_log('ER_TOO_MANY_USER_CONNECTIONS'); |
19 | 19 | sleep(1); |
20 | - header('location: '.$_SERVER['PHP_SELF']); |
|
20 | + header('location: ' . $_SERVER['PHP_SELF']); |
|
21 | 21 | } |
22 | 22 | |
23 | -if ($db->connect_errno) { |
|
23 | +if($db->connect_errno) { |
|
24 | 24 | echo 'Sorry, die Verbindung zu unserem |
25 | 25 | Server ist hops gegangen. Wegen '. $db -> connect_error; |
26 | 26 | } |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | PRIMARY KEY (`id`) |
55 | 55 | ) DEFAULT CHARSET=utf8"; |
56 | 56 | |
57 | -$query3 = "CREATE TABLE IF NOT EXISTS `users` ( |
|
57 | +$query3 = "CREATE TABLE IF NOT EXISTS `users` ( |
|
58 | 58 | `id` int(11) unsigned NOT NULL auto_increment, |
59 | 59 | `device_uid` varchar(255) NOT NULL, |
60 | 60 | `rights` varchar(255) NOT NULL, |
@@ -2,112 +2,112 @@ discard block |
||
2 | 2 | |
3 | 3 | class View |
4 | 4 | { |
5 | - public $country; |
|
6 | - public $city; |
|
7 | - public $hashtag; |
|
5 | + public $country; |
|
6 | + public $city; |
|
7 | + public $hashtag; |
|
8 | 8 | public $view; |
9 | - public $postId; |
|
10 | - public $isDetailedView; |
|
11 | - public $baseUrl; |
|
12 | - public $rights; |
|
9 | + public $postId; |
|
10 | + public $isDetailedView; |
|
11 | + public $baseUrl; |
|
12 | + public $rights; |
|
13 | 13 | |
14 | 14 | public $lastPostId = ''; |
15 | 15 | |
16 | - function __construct($baseUrl, $country, $city, $hashtag = '%23all', $view = 'time', $postId = '') |
|
17 | - { |
|
18 | - $this->baseUrl = $baseUrl; |
|
19 | - $this->country = $country; |
|
20 | - $this->city = $city; |
|
21 | - $this->hashtag = urldecode($hashtag); |
|
22 | - $this->view = $view; |
|
23 | - $this->postId = $postId; |
|
16 | + function __construct($baseUrl, $country, $city, $hashtag = '%23all', $view = 'time', $postId = '') |
|
17 | + { |
|
18 | + $this->baseUrl = $baseUrl; |
|
19 | + $this->country = $country; |
|
20 | + $this->city = $city; |
|
21 | + $this->hashtag = urldecode($hashtag); |
|
22 | + $this->view = $view; |
|
23 | + $this->postId = $postId; |
|
24 | 24 | |
25 | - if(isUserAdmin()) |
|
26 | - { |
|
27 | - $this->rights = 'admin'; |
|
28 | - } |
|
29 | - else if(isUserVoter()) |
|
30 | - { |
|
31 | - $this->rights = 'voter'; |
|
32 | - } |
|
33 | - else |
|
34 | - { |
|
35 | - $this->rights = 'user'; |
|
36 | - } |
|
25 | + if(isUserAdmin()) |
|
26 | + { |
|
27 | + $this->rights = 'admin'; |
|
28 | + } |
|
29 | + else if(isUserVoter()) |
|
30 | + { |
|
31 | + $this->rights = 'voter'; |
|
32 | + } |
|
33 | + else |
|
34 | + { |
|
35 | + $this->rights = 'user'; |
|
36 | + } |
|
37 | 37 | |
38 | - if($postId == '') |
|
39 | - { |
|
40 | - $this->isDetailedView = FALSE; |
|
41 | - } |
|
42 | - else |
|
43 | - { |
|
44 | - $this->isDetailedView = TRUE; |
|
45 | - } |
|
46 | - } |
|
38 | + if($postId == '') |
|
39 | + { |
|
40 | + $this->isDetailedView = FALSE; |
|
41 | + } |
|
42 | + else |
|
43 | + { |
|
44 | + $this->isDetailedView = TRUE; |
|
45 | + } |
|
46 | + } |
|
47 | 47 | /** |
48 | 48 | * Compute HTML Code |
49 | 49 | */ |
50 | 50 | function jodelToHtml($post) |
51 | - { //ToDO |
|
52 | - //Replace # with link |
|
53 | - //preg_replace('~(\#)([^\s!,. /()"\'?]+)~', '<a href="tag/$2">#$2</a>', $text); |
|
51 | + { //ToDO |
|
52 | + //Replace # with link |
|
53 | + //preg_replace('~(\#)([^\s!,. /()"\'?]+)~', '<a href="tag/$2">#$2</a>', $text); |
|
54 | 54 | |
55 | - //Time to time difference |
|
56 | - $now = new DateTime(); |
|
57 | - $d = new DateTime($post['created_at']); |
|
58 | - $timediff = $now->diff($d); |
|
55 | + //Time to time difference |
|
56 | + $now = new DateTime(); |
|
57 | + $d = new DateTime($post['created_at']); |
|
58 | + $timediff = $now->diff($d); |
|
59 | 59 | |
60 | - $timediff_inSeconds = (string)$timediff->format('%s'); |
|
61 | - $timediff_inMinutes = (string)$timediff->format('%i'); |
|
62 | - $timediff_inHours = (string)$timediff->format('%h'); |
|
63 | - $timediff_inDays = (string)$timediff->format('%d'); |
|
64 | - $timediff_inMonth = (string)$timediff->format('%m'); |
|
60 | + $timediff_inSeconds = (string)$timediff->format('%s'); |
|
61 | + $timediff_inMinutes = (string)$timediff->format('%i'); |
|
62 | + $timediff_inHours = (string)$timediff->format('%h'); |
|
63 | + $timediff_inDays = (string)$timediff->format('%d'); |
|
64 | + $timediff_inMonth = (string)$timediff->format('%m'); |
|
65 | 65 | |
66 | - if($timediff_inMonth!=0) |
|
67 | - { |
|
68 | - $timediff = $timediff_inMonth . "m"; |
|
69 | - } |
|
70 | - else |
|
71 | - { |
|
72 | - if($timediff_inDays!=0) |
|
73 | - { |
|
74 | - $timediff = $timediff_inDays . "d"; |
|
75 | - } |
|
76 | - else |
|
77 | - { |
|
78 | - if($timediff_inHours!=0) |
|
79 | - { |
|
80 | - $timediff = $timediff_inHours . "h"; |
|
81 | - } |
|
82 | - else |
|
83 | - { |
|
84 | - if($timediff_inMinutes!=0) |
|
85 | - { |
|
86 | - $timediff = $timediff_inMinutes . "m"; |
|
87 | - } |
|
88 | - else |
|
89 | - { |
|
90 | - $timediff = $timediff_inSeconds . "s"; |
|
91 | - } |
|
92 | - } |
|
93 | - } |
|
94 | - } |
|
66 | + if($timediff_inMonth!=0) |
|
67 | + { |
|
68 | + $timediff = $timediff_inMonth . "m"; |
|
69 | + } |
|
70 | + else |
|
71 | + { |
|
72 | + if($timediff_inDays!=0) |
|
73 | + { |
|
74 | + $timediff = $timediff_inDays . "d"; |
|
75 | + } |
|
76 | + else |
|
77 | + { |
|
78 | + if($timediff_inHours!=0) |
|
79 | + { |
|
80 | + $timediff = $timediff_inHours . "h"; |
|
81 | + } |
|
82 | + else |
|
83 | + { |
|
84 | + if($timediff_inMinutes!=0) |
|
85 | + { |
|
86 | + $timediff = $timediff_inMinutes . "m"; |
|
87 | + } |
|
88 | + else |
|
89 | + { |
|
90 | + $timediff = $timediff_inSeconds . "s"; |
|
91 | + } |
|
92 | + } |
|
93 | + } |
|
94 | + } |
|
95 | 95 | |
96 | 96 | |
97 | - ?> |
|
97 | + ?> |
|
98 | 98 | <article id ="postId-<?php echo $post['post_id']; ?>" class="jodel" style="background-color: #<?php echo $post['color'];?>;"> |
99 | 99 | <content> |
100 | 100 | <?php |
101 | - if(isset($post['image_url'])) |
|
102 | - { |
|
103 | - $regexRest = '/[^\w$ .!?-]+/u'; |
|
101 | + if(isset($post['image_url'])) |
|
102 | + { |
|
103 | + $regexRest = '/[^\w$ .!?-]+/u'; |
|
104 | 104 | |
105 | - echo '<img src="' . $post['image_url'] . '" alt="' . htmlspecialchars(preg_replace($regexRest, '', $post['message'])) . '">'; |
|
106 | - } |
|
107 | - else { |
|
108 | - echo str_replace(' ', ' ', nl2br(htmlspecialchars($post['message']))); |
|
109 | - } |
|
110 | - ?> |
|
105 | + echo '<img src="' . $post['image_url'] . '" alt="' . htmlspecialchars(preg_replace($regexRest, '', $post['message'])) . '">'; |
|
106 | + } |
|
107 | + else { |
|
108 | + echo str_replace(' ', ' ', nl2br(htmlspecialchars($post['message']))); |
|
109 | + } |
|
110 | + ?> |
|
111 | 111 | </content> |
112 | 112 | <aside> |
113 | 113 | <button onclick="vote('<?php echo $post['post_id'];?>', 'up', this)"> |
@@ -136,10 +136,10 @@ discard block |
||
136 | 136 | <a href="<?php echo $this->changePostId($post['post_id'])->toUrl();?>"> |
137 | 137 | <i class="fa fa-commenting-o"></i> |
138 | 138 | <?php if(array_key_exists("child_count", $post)) |
139 | - { |
|
140 | - echo $post["child_count"]; |
|
141 | - } else echo "0"; |
|
142 | - ?> |
|
139 | + { |
|
140 | + echo $post["child_count"]; |
|
141 | + } else echo "0"; |
|
142 | + ?> |
|
143 | 143 | </a> |
144 | 144 | </span> |
145 | 145 | |
@@ -159,30 +159,30 @@ discard block |
||
159 | 159 | ?> |
160 | 160 | <span class="distance"> |
161 | 161 | <?php |
162 | - if($this->isDetailedView) |
|
163 | - { |
|
164 | - if(isset($post['user_handle']) && $post['user_handle'] == 'OJ') |
|
165 | - { |
|
166 | - ?> |
|
162 | + if($this->isDetailedView) |
|
163 | + { |
|
164 | + if(isset($post['user_handle']) && $post['user_handle'] == 'OJ') |
|
165 | + { |
|
166 | + ?> |
|
167 | 167 | <span data-tooltip="Author"> |
168 | 168 | <i class="fa fa-user-o"></i> OJ | |
169 | 169 | </span> |
170 | 170 | <?php |
171 | - } |
|
172 | - else |
|
173 | - { |
|
174 | - //Is not parent Jodel in detailed View |
|
175 | - if(!array_key_exists('child_count', $post)) |
|
176 | - { |
|
177 | - ?> |
|
171 | + } |
|
172 | + else |
|
173 | + { |
|
174 | + //Is not parent Jodel in detailed View |
|
175 | + if(!array_key_exists('child_count', $post)) |
|
176 | + { |
|
177 | + ?> |
|
178 | 178 | <span data-tooltip="Author"> |
179 | 179 | <i class="fa fa-user-o"></i> #<?php echo $post['user_handle'];?> | |
180 | 180 | </span> |
181 | 181 | <?php |
182 | - } |
|
183 | - } |
|
184 | - } |
|
185 | - ?> |
|
182 | + } |
|
183 | + } |
|
184 | + } |
|
185 | + ?> |
|
186 | 186 | |
187 | 187 | <span class="tip" data-tooltip="Distance"> |
188 | 188 | <i class="fa fa-map-marker"></i> |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | </footer> |
196 | 196 | </article> |
197 | 197 | <?php |
198 | - } |
|
198 | + } |
|
199 | 199 | |
200 | 200 | |
201 | 201 | /** |
@@ -232,147 +232,147 @@ discard block |
||
232 | 232 | return $description; |
233 | 233 | } |
234 | 234 | |
235 | - function toUrl($msg = '') |
|
236 | - { |
|
237 | - $url = $this->baseUrl . 'index.php?country=DE' . |
|
238 | - '&city=' . urlencode($this->city) . |
|
239 | - '&hashtag=' . urlencode($this->hashtag) . |
|
240 | - '&view=' . $this->view; |
|
241 | - if($this->postId != '') |
|
242 | - { |
|
243 | - $url .= '&postId=' . $this->postId . |
|
244 | - '&getPostDetails=TRUE'; |
|
245 | - } |
|
235 | + function toUrl($msg = '') |
|
236 | + { |
|
237 | + $url = $this->baseUrl . 'index.php?country=DE' . |
|
238 | + '&city=' . urlencode($this->city) . |
|
239 | + '&hashtag=' . urlencode($this->hashtag) . |
|
240 | + '&view=' . $this->view; |
|
241 | + if($this->postId != '') |
|
242 | + { |
|
243 | + $url .= '&postId=' . $this->postId . |
|
244 | + '&getPostDetails=TRUE'; |
|
245 | + } |
|
246 | 246 | |
247 | - if($msg != '') |
|
248 | - { |
|
249 | - $url .= '&msg=' . urlencode($msg); |
|
250 | - } |
|
247 | + if($msg != '') |
|
248 | + { |
|
249 | + $url .= '&msg=' . urlencode($msg); |
|
250 | + } |
|
251 | 251 | |
252 | - return $url; |
|
253 | - } |
|
252 | + return $url; |
|
253 | + } |
|
254 | 254 | |
255 | - function changePostId($postId) |
|
256 | - { |
|
257 | - $tempView = clone $this; |
|
258 | - $tempView->postId = $postId; |
|
259 | - $tempView->isDetailedView = TRUE; |
|
260 | - return $tempView; |
|
261 | - } |
|
255 | + function changePostId($postId) |
|
256 | + { |
|
257 | + $tempView = clone $this; |
|
258 | + $tempView->postId = $postId; |
|
259 | + $tempView->isDetailedView = TRUE; |
|
260 | + return $tempView; |
|
261 | + } |
|
262 | 262 | |
263 | - function back() |
|
264 | - { |
|
265 | - $tempView = clone $this; |
|
266 | - $tempView->postId = ''; |
|
267 | - return $tempView; |
|
268 | - } |
|
263 | + function back() |
|
264 | + { |
|
265 | + $tempView = clone $this; |
|
266 | + $tempView->postId = ''; |
|
267 | + return $tempView; |
|
268 | + } |
|
269 | 269 | |
270 | - function changeView($view) |
|
271 | - { |
|
272 | - $tempView = clone $this; |
|
273 | - $tempView->view = $view; |
|
274 | - return $tempView; |
|
275 | - } |
|
270 | + function changeView($view) |
|
271 | + { |
|
272 | + $tempView = clone $this; |
|
273 | + $tempView->view = $view; |
|
274 | + return $tempView; |
|
275 | + } |
|
276 | 276 | |
277 | 277 | function getPosts($jodelAccount) |
278 | 278 | { |
279 | - if($this->hashtag != '#all' && $this->hashtag != '' && $this->hashtag != NULL) |
|
280 | - { |
|
281 | - $accountCreator = new GetChannel(); |
|
282 | - $accountCreator->view = $this->view; |
|
283 | - $accountCreator->setAccessToken($jodelAccount->accessToken); |
|
284 | - $accountCreator->channel = $this->hashtag; |
|
285 | - $accountCreator->lastPostId = $this->lastPostId; |
|
286 | - $data = $accountCreator->execute(); |
|
287 | - } |
|
288 | - else |
|
289 | - { |
|
290 | - if($this->lastPostId == '' && $this->view == 'combo') |
|
291 | - { |
|
292 | - $url = "/v3/posts/location/combo"; |
|
293 | - } |
|
294 | - else |
|
295 | - { |
|
296 | - if($this->view == 'discussed') |
|
297 | - { |
|
298 | - $url = "/v2/posts/location/discussed/"; |
|
299 | - } |
|
300 | - else |
|
301 | - { |
|
302 | - if($this->view == 'popular') |
|
303 | - { |
|
304 | - $url = "/v2/posts/location/popular/"; |
|
305 | - } |
|
306 | - else |
|
307 | - { |
|
308 | - $url = "/v2/posts/location/"; |
|
309 | - } |
|
310 | - } |
|
311 | - } |
|
279 | + if($this->hashtag != '#all' && $this->hashtag != '' && $this->hashtag != NULL) |
|
280 | + { |
|
281 | + $accountCreator = new GetChannel(); |
|
282 | + $accountCreator->view = $this->view; |
|
283 | + $accountCreator->setAccessToken($jodelAccount->accessToken); |
|
284 | + $accountCreator->channel = $this->hashtag; |
|
285 | + $accountCreator->lastPostId = $this->lastPostId; |
|
286 | + $data = $accountCreator->execute(); |
|
287 | + } |
|
288 | + else |
|
289 | + { |
|
290 | + if($this->lastPostId == '' && $this->view == 'combo') |
|
291 | + { |
|
292 | + $url = "/v3/posts/location/combo"; |
|
293 | + } |
|
294 | + else |
|
295 | + { |
|
296 | + if($this->view == 'discussed') |
|
297 | + { |
|
298 | + $url = "/v2/posts/location/discussed/"; |
|
299 | + } |
|
300 | + else |
|
301 | + { |
|
302 | + if($this->view == 'popular') |
|
303 | + { |
|
304 | + $url = "/v2/posts/location/popular/"; |
|
305 | + } |
|
306 | + else |
|
307 | + { |
|
308 | + $url = "/v2/posts/location/"; |
|
309 | + } |
|
310 | + } |
|
311 | + } |
|
312 | 312 | |
313 | - $accountCreator = new GetPosts(); |
|
314 | - $accountCreator->setLastPostId($this->lastPostId); |
|
315 | - $accountCreator->setAccessToken($jodelAccount->accessToken); |
|
316 | - $accountCreator->setUrl($url); |
|
317 | - $accountCreator->version = 'v3'; |
|
313 | + $accountCreator = new GetPosts(); |
|
314 | + $accountCreator->setLastPostId($this->lastPostId); |
|
315 | + $accountCreator->setAccessToken($jodelAccount->accessToken); |
|
316 | + $accountCreator->setUrl($url); |
|
317 | + $accountCreator->version = 'v3'; |
|
318 | 318 | |
319 | - $config = parse_ini_file('config/config.ini.php'); |
|
320 | - $location = new Location(); |
|
321 | - $location->setLat($config['default_lat']); |
|
322 | - $location->setLng($config['default_lng']); |
|
323 | - $location->setCityName($config['default_location']); |
|
324 | - $accountCreator->location = $location; |
|
325 | - $data = $accountCreator->execute(); |
|
326 | - } |
|
327 | - if(array_key_exists('recent', $data) && array_key_exists(0, $data['recent'])) |
|
328 | - { |
|
329 | - return $data['recent']; |
|
330 | - } |
|
331 | - else if(array_key_exists('posts', $data)&& array_key_exists(0, $data['posts'])) |
|
332 | - { |
|
333 | - return $data['posts']; |
|
334 | - } |
|
335 | - else |
|
336 | - { |
|
337 | - if($this->lastPostId == '') |
|
338 | - { |
|
339 | - error_log('Could not find Posts in: ' . $this->city . ' Error: ' . print_r($data, true)); |
|
340 | - //error_log(print_r($data, true)); |
|
319 | + $config = parse_ini_file('config/config.ini.php'); |
|
320 | + $location = new Location(); |
|
321 | + $location->setLat($config['default_lat']); |
|
322 | + $location->setLng($config['default_lng']); |
|
323 | + $location->setCityName($config['default_location']); |
|
324 | + $accountCreator->location = $location; |
|
325 | + $data = $accountCreator->execute(); |
|
326 | + } |
|
327 | + if(array_key_exists('recent', $data) && array_key_exists(0, $data['recent'])) |
|
328 | + { |
|
329 | + return $data['recent']; |
|
330 | + } |
|
331 | + else if(array_key_exists('posts', $data)&& array_key_exists(0, $data['posts'])) |
|
332 | + { |
|
333 | + return $data['posts']; |
|
334 | + } |
|
335 | + else |
|
336 | + { |
|
337 | + if($this->lastPostId == '') |
|
338 | + { |
|
339 | + error_log('Could not find Posts in: ' . $this->city . ' Error: ' . print_r($data, true)); |
|
340 | + //error_log(print_r($data, true)); |
|
341 | 341 | |
342 | - $notFound[0] = array( |
|
343 | - "post_id" => "0", |
|
344 | - "discovered_by" => 0, |
|
345 | - "message" => "No more Posts found", |
|
346 | - "created_at" => "2017-02-11T16:44:50.385Z", |
|
347 | - "updated_at" => "2017-02-11T16:44:50.385Z", |
|
348 | - "pin_count" => 0, |
|
349 | - "color" => "5682a3", |
|
350 | - "got_thanks" => FALSE, |
|
351 | - "post_own" => "friend", |
|
352 | - "discovered" => 0, |
|
353 | - "distance" => 9, |
|
354 | - "vote_count" => 0, |
|
355 | - "location" => |
|
356 | - array("name" => "Berlin", |
|
357 | - "loc_coordinates" => |
|
358 | - array( |
|
359 | - "lat" => 0, |
|
360 | - "lng" => 0 |
|
361 | - ), |
|
362 | - "loc_accuracy" => 0, |
|
363 | - "country" => "", |
|
364 | - "city" => "", |
|
365 | - ), |
|
366 | - "tags" => |
|
367 | - array(), |
|
368 | - "user_handle" => "0" |
|
369 | - ); |
|
370 | - return $notFound; |
|
371 | - } |
|
372 | - else |
|
373 | - { |
|
374 | - return FALSE; |
|
375 | - } |
|
376 | - } |
|
342 | + $notFound[0] = array( |
|
343 | + "post_id" => "0", |
|
344 | + "discovered_by" => 0, |
|
345 | + "message" => "No more Posts found", |
|
346 | + "created_at" => "2017-02-11T16:44:50.385Z", |
|
347 | + "updated_at" => "2017-02-11T16:44:50.385Z", |
|
348 | + "pin_count" => 0, |
|
349 | + "color" => "5682a3", |
|
350 | + "got_thanks" => FALSE, |
|
351 | + "post_own" => "friend", |
|
352 | + "discovered" => 0, |
|
353 | + "distance" => 9, |
|
354 | + "vote_count" => 0, |
|
355 | + "location" => |
|
356 | + array("name" => "Berlin", |
|
357 | + "loc_coordinates" => |
|
358 | + array( |
|
359 | + "lat" => 0, |
|
360 | + "lng" => 0 |
|
361 | + ), |
|
362 | + "loc_accuracy" => 0, |
|
363 | + "country" => "", |
|
364 | + "city" => "", |
|
365 | + ), |
|
366 | + "tags" => |
|
367 | + array(), |
|
368 | + "user_handle" => "0" |
|
369 | + ); |
|
370 | + return $notFound; |
|
371 | + } |
|
372 | + else |
|
373 | + { |
|
374 | + return FALSE; |
|
375 | + } |
|
376 | + } |
|
377 | 377 | } |
378 | 378 | } |
@@ -63,25 +63,25 @@ discard block |
||
63 | 63 | $timediff_inDays = (string)$timediff->format('%d'); |
64 | 64 | $timediff_inMonth = (string)$timediff->format('%m'); |
65 | 65 | |
66 | - if($timediff_inMonth!=0) |
|
66 | + if($timediff_inMonth != 0) |
|
67 | 67 | { |
68 | 68 | $timediff = $timediff_inMonth . "m"; |
69 | 69 | } |
70 | 70 | else |
71 | 71 | { |
72 | - if($timediff_inDays!=0) |
|
72 | + if($timediff_inDays != 0) |
|
73 | 73 | { |
74 | 74 | $timediff = $timediff_inDays . "d"; |
75 | 75 | } |
76 | 76 | else |
77 | 77 | { |
78 | - if($timediff_inHours!=0) |
|
78 | + if($timediff_inHours != 0) |
|
79 | 79 | { |
80 | 80 | $timediff = $timediff_inHours . "h"; |
81 | 81 | } |
82 | 82 | else |
83 | 83 | { |
84 | - if($timediff_inMinutes!=0) |
|
84 | + if($timediff_inMinutes != 0) |
|
85 | 85 | { |
86 | 86 | $timediff = $timediff_inMinutes . "m"; |
87 | 87 | } |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | |
96 | 96 | |
97 | 97 | ?> |
98 | - <article id ="postId-<?php echo $post['post_id']; ?>" class="jodel" style="background-color: #<?php echo $post['color'];?>;"> |
|
98 | + <article id ="postId-<?php echo $post['post_id']; ?>" class="jodel" style="background-color: #<?php echo $post['color']; ?>;"> |
|
99 | 99 | <content> |
100 | 100 | <?php |
101 | 101 | if(isset($post['image_url'])) |
@@ -110,12 +110,12 @@ discard block |
||
110 | 110 | ?> |
111 | 111 | </content> |
112 | 112 | <aside> |
113 | - <button onclick="vote('<?php echo $post['post_id'];?>', 'up', this)"> |
|
113 | + <button onclick="vote('<?php echo $post['post_id']; ?>', 'up', this)"> |
|
114 | 114 | <i class="fa fa-angle-up fa-3x"></i> |
115 | 115 | </button> |
116 | - <br><span><?php echo $post["vote_count"];?></span><br> |
|
116 | + <br><span><?php echo $post["vote_count"]; ?></span><br> |
|
117 | 117 | |
118 | - <button onclick="vote('<?php echo $post['post_id'];?>', 'down', this)"> |
|
118 | + <button onclick="vote('<?php echo $post['post_id']; ?>', 'down', this)"> |
|
119 | 119 | <i class="fa fa-angle-down fa-3x"></i> |
120 | 120 | </button> |
121 | 121 | </aside> |
@@ -126,14 +126,14 @@ discard block |
||
126 | 126 | <span class="time"> |
127 | 127 | <span class="tip" data-tooltip="Time"> |
128 | 128 | <i class="fa fa-clock-o"></i> |
129 | - <?php echo $timediff;?> |
|
130 | - <span class="tiptext"><?php echo $d->format('Y-m-d H:i:s');?></span> |
|
129 | + <?php echo $timediff; ?> |
|
130 | + <span class="tiptext"><?php echo $d->format('Y-m-d H:i:s'); ?></span> |
|
131 | 131 | </span> |
132 | 132 | </span> |
133 | 133 | <?php if(!$this->isDetailedView) {?> |
134 | 134 | <span class="comments"> |
135 | 135 | <span data-tooltip="Comments"> |
136 | - <a href="<?php echo $this->changePostId($post['post_id'])->toUrl();?>"> |
|
136 | + <a href="<?php echo $this->changePostId($post['post_id'])->toUrl(); ?>"> |
|
137 | 137 | <i class="fa fa-commenting-o"></i> |
138 | 138 | <?php if(array_key_exists("child_count", $post)) |
139 | 139 | { |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | { |
177 | 177 | ?> |
178 | 178 | <span data-tooltip="Author"> |
179 | - <i class="fa fa-user-o"></i> #<?php echo $post['user_handle'];?> | |
|
179 | + <i class="fa fa-user-o"></i> #<?php echo $post['user_handle']; ?> | |
|
180 | 180 | </span> |
181 | 181 | <?php |
182 | 182 | } |
@@ -186,8 +186,8 @@ discard block |
||
186 | 186 | |
187 | 187 | <span class="tip" data-tooltip="Distance"> |
188 | 188 | <i class="fa fa-map-marker"></i> |
189 | - <?php echo $post['distance'];?> km |
|
190 | - <span class="tiptext"><?php echo $post['location']['name'];?></span> |
|
189 | + <?php echo $post['distance']; ?> km |
|
190 | + <span class="tiptext"><?php echo $post['location']['name']; ?></span> |
|
191 | 191 | </span> |
192 | 192 | </span> |
193 | 193 | |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | |
227 | 227 | if($post != '' && array_key_exists('message', $post) && $post['message'] != '' && $this->isDetailedView) |
228 | 228 | { |
229 | - $description = 'On JodelBlue in ' . htmlspecialchars($this->city) . ' with ' . htmlspecialchars($post['vote_count']) . ' Upvotes: ' . substr(htmlspecialchars($post['message']), 0, 130); |
|
229 | + $description = 'On JodelBlue in ' . htmlspecialchars($this->city) . ' with ' . htmlspecialchars($post['vote_count']) . ' Upvotes: ' . substr(htmlspecialchars($post['message']), 0, 130); |
|
230 | 230 | } |
231 | 231 | |
232 | 232 | return $description; |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | { |
329 | 329 | return $data['recent']; |
330 | 330 | } |
331 | - else if(array_key_exists('posts', $data)&& array_key_exists(0, $data['posts'])) |
|
331 | + else if(array_key_exists('posts', $data) && array_key_exists(0, $data['posts'])) |
|
332 | 332 | { |
333 | 333 | return $data['posts']; |
334 | 334 | } |
@@ -2,47 +2,47 @@ discard block |
||
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; |
|
14 | + // array of voted Jodels |
|
15 | + public $votes; |
|
16 | 16 | |
17 | - //Location of the Account |
|
18 | - public $location; |
|
17 | + //Location of the Account |
|
18 | + public $location; |
|
19 | 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 | - } |
|
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 | 30 | |
31 | - $this->isBot = $isBot; |
|
32 | - $this->location = $this->getLocation(); |
|
31 | + $this->isBot = $isBot; |
|
32 | + $this->location = $this->getLocation(); |
|
33 | 33 | |
34 | - if(!$this->isTokenFresh()) |
|
35 | - { |
|
36 | - $this->refreshToken(); |
|
37 | - } |
|
38 | - $this->accessToken = $this->getAccessToken(); |
|
34 | + if(!$this->isTokenFresh()) |
|
35 | + { |
|
36 | + $this->refreshToken(); |
|
37 | + } |
|
38 | + $this->accessToken = $this->getAccessToken(); |
|
39 | 39 | |
40 | - /* if($this->isAccountVerified() != 1) |
|
40 | + /* if($this->isAccountVerified() != 1) |
|
41 | 41 | { |
42 | 42 | $this->showCaptcha(); |
43 | 43 | //$this->verifyCaptcha(); |
44 | 44 | }*/ |
45 | - } |
|
45 | + } |
|
46 | 46 | |
47 | 47 | /* |
48 | 48 | function showCaptcha() |
@@ -71,503 +71,503 @@ discard block |
||
71 | 71 | } |
72 | 72 | */ |
73 | 73 | |
74 | - function getCaptcha() |
|
75 | - { |
|
76 | - $accountCreator = new GetCaptcha(); |
|
77 | - $accountCreator->setAccessToken($this->accessToken); |
|
78 | - $captcha = $accountCreator->execute(); |
|
74 | + function getCaptcha() |
|
75 | + { |
|
76 | + $accountCreator = new GetCaptcha(); |
|
77 | + $accountCreator->setAccessToken($this->accessToken); |
|
78 | + $captcha = $accountCreator->execute(); |
|
79 | 79 | |
80 | - return array("image_url" => $captcha['image_url'], "key" => $captcha['key']); |
|
81 | - } |
|
80 | + return array("image_url" => $captcha['image_url'], "key" => $captcha['key']); |
|
81 | + } |
|
82 | 82 | |
83 | - function isAccountVerified() |
|
84 | - { |
|
85 | - $accountCreator = new GetUserConfig(); |
|
86 | - $accountCreator->setAccessToken($this->accessToken); |
|
87 | - $data = $accountCreator->execute(); |
|
83 | + function isAccountVerified() |
|
84 | + { |
|
85 | + $accountCreator = new GetUserConfig(); |
|
86 | + $accountCreator->setAccessToken($this->accessToken); |
|
87 | + $data = $accountCreator->execute(); |
|
88 | 88 | |
89 | - //error_log(print_r($data, true)); |
|
89 | + //error_log(print_r($data, true)); |
|
90 | 90 | |
91 | - return $data['verified']; |
|
92 | - } |
|
91 | + return $data['verified']; |
|
92 | + } |
|
93 | 93 | |
94 | - function locationEquals($city) |
|
95 | - { |
|
96 | - $url = 'https://maps.googleapis.com/maps/api/geocode/json?address=' . htmlspecialchars($city) . '&key=AIzaSyCwhnja-or07012HqrhPW7prHEDuSvFT4w'; |
|
97 | - $result = Requests::post($url); |
|
98 | - if(json_decode($result->body, true)['status'] == 'ZERO_RESULTS' || json_decode($result->body, true)['status'] == 'INVALID_REQUEST') |
|
99 | - { |
|
100 | - error_log('Error locationEquals'); |
|
101 | - return FALSE; |
|
102 | - } |
|
103 | - else |
|
104 | - { |
|
105 | - $name = json_decode($result->body, true)['results']['0']['address_components']['0']['long_name']; |
|
106 | - $lat = json_decode($result->body, true)['results']['0']['geometry']['location']['lat']; |
|
107 | - $lng = json_decode($result->body, true)['results']['0']['geometry']['location']['lng']; |
|
108 | - } |
|
94 | + function locationEquals($city) |
|
95 | + { |
|
96 | + $url = 'https://maps.googleapis.com/maps/api/geocode/json?address=' . htmlspecialchars($city) . '&key=AIzaSyCwhnja-or07012HqrhPW7prHEDuSvFT4w'; |
|
97 | + $result = Requests::post($url); |
|
98 | + if(json_decode($result->body, true)['status'] == 'ZERO_RESULTS' || json_decode($result->body, true)['status'] == 'INVALID_REQUEST') |
|
99 | + { |
|
100 | + error_log('Error locationEquals'); |
|
101 | + return FALSE; |
|
102 | + } |
|
103 | + else |
|
104 | + { |
|
105 | + $name = json_decode($result->body, true)['results']['0']['address_components']['0']['long_name']; |
|
106 | + $lat = json_decode($result->body, true)['results']['0']['geometry']['location']['lat']; |
|
107 | + $lng = json_decode($result->body, true)['results']['0']['geometry']['location']['lng']; |
|
108 | + } |
|
109 | 109 | |
110 | - $db = new DatabaseConnect(); |
|
111 | - $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'"); |
|
110 | + $db = new DatabaseConnect(); |
|
111 | + $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'"); |
|
112 | 112 | |
113 | - $location = new Location(); |
|
113 | + $location = new Location(); |
|
114 | 114 | |
115 | - if ($result->num_rows > 0) |
|
116 | - { |
|
117 | - // output data of each row |
|
118 | - while($row = $result->fetch_assoc()) |
|
119 | - { |
|
120 | - $location->setLat($row['lat']); |
|
121 | - $location->setLng($row['lng']); |
|
122 | - $location->setCityName($row['name']); |
|
123 | - } |
|
124 | - } |
|
125 | - else |
|
126 | - { |
|
127 | - error_log("Error no Location found - getLocation"); |
|
128 | - } |
|
115 | + if ($result->num_rows > 0) |
|
116 | + { |
|
117 | + // output data of each row |
|
118 | + while($row = $result->fetch_assoc()) |
|
119 | + { |
|
120 | + $location->setLat($row['lat']); |
|
121 | + $location->setLng($row['lng']); |
|
122 | + $location->setCityName($row['name']); |
|
123 | + } |
|
124 | + } |
|
125 | + else |
|
126 | + { |
|
127 | + error_log("Error no Location found - getLocation"); |
|
128 | + } |
|
129 | 129 | |
130 | - if($location->getLat() == $lat && $location->getLng() == $lng && $location->getCityName() == $name) |
|
131 | - { |
|
132 | - return TRUE; |
|
133 | - } |
|
134 | - else |
|
135 | - { |
|
136 | - return FALSE; |
|
137 | - } |
|
138 | - } |
|
130 | + if($location->getLat() == $lat && $location->getLng() == $lng && $location->getCityName() == $name) |
|
131 | + { |
|
132 | + return TRUE; |
|
133 | + } |
|
134 | + else |
|
135 | + { |
|
136 | + return FALSE; |
|
137 | + } |
|
138 | + } |
|
139 | 139 | |
140 | - function setLocation() |
|
141 | - { |
|
142 | - //Is Channel or City |
|
143 | - if(substr($_GET['city'], 0, 1) === '#') |
|
144 | - { |
|
145 | - return htmlspecialchars($_GET['city']) . " " . $this->location->cityName; |
|
146 | - } |
|
147 | - else |
|
148 | - { |
|
149 | - $url = 'https://maps.googleapis.com/maps/api/geocode/json?address=' . htmlspecialchars($_GET['city']) . '&key=AIzaSyCwhnja-or07012HqrhPW7prHEDuSvFT4w'; |
|
150 | - $result = Requests::post($url); |
|
151 | - if(json_decode($result->body, true)['status'] == 'ZERO_RESULTS' || json_decode($result->body, true)['status'] == 'INVALID_REQUEST') |
|
152 | - { |
|
153 | - return "0 results"; |
|
154 | - } |
|
155 | - else |
|
156 | - { |
|
157 | - $name = json_decode($result->body, true)['results']['0']['address_components']['0']['long_name']; |
|
158 | - $lat = json_decode($result->body, true)['results']['0']['geometry']['location']['lat']; |
|
159 | - $lng = json_decode($result->body, true)['results']['0']['geometry']['location']['lng']; |
|
160 | - |
|
161 | - $location = new Location(); |
|
162 | - $location->setLat($lat); |
|
163 | - $location->setLng($lng); |
|
164 | - $location->setCityName($name); |
|
165 | - $accountCreator = new UpdateLocation(); |
|
166 | - $accountCreator->setLocation($location); |
|
167 | - $accountCreator->setAccessToken($this->accessToken); |
|
168 | - $data = $accountCreator->execute(); |
|
169 | - |
|
170 | - //safe location to db |
|
171 | - $db = new DatabaseConnect(); |
|
172 | - |
|
173 | - if($data == 'Success') |
|
174 | - { |
|
175 | - $result = $db->query("UPDATE accounts |
|
140 | + function setLocation() |
|
141 | + { |
|
142 | + //Is Channel or City |
|
143 | + if(substr($_GET['city'], 0, 1) === '#') |
|
144 | + { |
|
145 | + return htmlspecialchars($_GET['city']) . " " . $this->location->cityName; |
|
146 | + } |
|
147 | + else |
|
148 | + { |
|
149 | + $url = 'https://maps.googleapis.com/maps/api/geocode/json?address=' . htmlspecialchars($_GET['city']) . '&key=AIzaSyCwhnja-or07012HqrhPW7prHEDuSvFT4w'; |
|
150 | + $result = Requests::post($url); |
|
151 | + if(json_decode($result->body, true)['status'] == 'ZERO_RESULTS' || json_decode($result->body, true)['status'] == 'INVALID_REQUEST') |
|
152 | + { |
|
153 | + return "0 results"; |
|
154 | + } |
|
155 | + else |
|
156 | + { |
|
157 | + $name = json_decode($result->body, true)['results']['0']['address_components']['0']['long_name']; |
|
158 | + $lat = json_decode($result->body, true)['results']['0']['geometry']['location']['lat']; |
|
159 | + $lng = json_decode($result->body, true)['results']['0']['geometry']['location']['lng']; |
|
160 | + |
|
161 | + $location = new Location(); |
|
162 | + $location->setLat($lat); |
|
163 | + $location->setLng($lng); |
|
164 | + $location->setCityName($name); |
|
165 | + $accountCreator = new UpdateLocation(); |
|
166 | + $accountCreator->setLocation($location); |
|
167 | + $accountCreator->setAccessToken($this->accessToken); |
|
168 | + $data = $accountCreator->execute(); |
|
169 | + |
|
170 | + //safe location to db |
|
171 | + $db = new DatabaseConnect(); |
|
172 | + |
|
173 | + if($data == 'Success') |
|
174 | + { |
|
175 | + $result = $db->query("UPDATE accounts |
|
176 | 176 | SET name='" . $name . "', |
177 | 177 | lat='" . $lat . "', |
178 | 178 | lng='" . $lng . "' |
179 | 179 | WHERE access_token='" . $this->accessToken . "'"); |
180 | 180 | |
181 | - if($result === false) |
|
182 | - { |
|
183 | - echo "Updating location failed: (" . $db->errno . ") " . $db->error; |
|
184 | - } |
|
185 | - else |
|
186 | - { |
|
187 | - user_log('User with JodelDeviceId:' . $this->deviceUid . ' [' . $_SERVER['REMOTE_ADDR'] . '][' . $_SERVER ['HTTP_USER_AGENT'] . '] changed to Location: ' . $name); |
|
188 | - } |
|
189 | - } |
|
190 | - |
|
191 | - return $name; |
|
192 | - } |
|
193 | - } |
|
194 | - } |
|
181 | + if($result === false) |
|
182 | + { |
|
183 | + echo "Updating location failed: (" . $db->errno . ") " . $db->error; |
|
184 | + } |
|
185 | + else |
|
186 | + { |
|
187 | + user_log('User with JodelDeviceId:' . $this->deviceUid . ' [' . $_SERVER['REMOTE_ADDR'] . '][' . $_SERVER ['HTTP_USER_AGENT'] . '] changed to Location: ' . $name); |
|
188 | + } |
|
189 | + } |
|
190 | + |
|
191 | + return $name; |
|
192 | + } |
|
193 | + } |
|
194 | + } |
|
195 | 195 | |
196 | - function getLocation() |
|
197 | - { |
|
198 | - $db = new DatabaseConnect(); |
|
199 | - $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'"); |
|
196 | + function getLocation() |
|
197 | + { |
|
198 | + $db = new DatabaseConnect(); |
|
199 | + $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'"); |
|
200 | 200 | |
201 | - $location = new Location(); |
|
201 | + $location = new Location(); |
|
202 | 202 | |
203 | - if ($result->num_rows > 0) |
|
204 | - { |
|
205 | - // output data of each row |
|
206 | - while($row = $result->fetch_assoc()) |
|
207 | - { |
|
208 | - $location->setLat($row['lat']); |
|
209 | - $location->setLng($row['lng']); |
|
210 | - $location->setCityName($row['name']); |
|
211 | - } |
|
212 | - } |
|
213 | - else |
|
214 | - { |
|
215 | - echo "Error: 0 results"; |
|
216 | - error_log("Error no Location found - getLocation"); |
|
217 | - } |
|
203 | + if ($result->num_rows > 0) |
|
204 | + { |
|
205 | + // output data of each row |
|
206 | + while($row = $result->fetch_assoc()) |
|
207 | + { |
|
208 | + $location->setLat($row['lat']); |
|
209 | + $location->setLng($row['lng']); |
|
210 | + $location->setCityName($row['name']); |
|
211 | + } |
|
212 | + } |
|
213 | + else |
|
214 | + { |
|
215 | + echo "Error: 0 results"; |
|
216 | + error_log("Error no Location found - getLocation"); |
|
217 | + } |
|
218 | 218 | |
219 | - return $location; |
|
220 | - } |
|
219 | + return $location; |
|
220 | + } |
|
221 | 221 | |
222 | - function verifyCaptcha() |
|
223 | - { |
|
224 | - if(isset($_GET['deviceUid'])) |
|
225 | - { |
|
226 | - $deviceUid = $_GET['deviceUid']; |
|
227 | - $jodelAccountForVerify = new JodelAccount($deviceUid); |
|
228 | - } |
|
229 | - else if(isset($_POST['deviceUid'])) |
|
230 | - { |
|
231 | - $deviceUid = $_POST['deviceUid']; |
|
232 | - $jodelAccountForVerify = new JodelAccount($deviceUid); |
|
233 | - } |
|
234 | - else |
|
235 | - { |
|
236 | - $deviceUid = $this->deviceUid; |
|
237 | - $jodelAccountForVerify = $this; |
|
238 | - } |
|
222 | + function verifyCaptcha() |
|
223 | + { |
|
224 | + if(isset($_GET['deviceUid'])) |
|
225 | + { |
|
226 | + $deviceUid = $_GET['deviceUid']; |
|
227 | + $jodelAccountForVerify = new JodelAccount($deviceUid); |
|
228 | + } |
|
229 | + else if(isset($_POST['deviceUid'])) |
|
230 | + { |
|
231 | + $deviceUid = $_POST['deviceUid']; |
|
232 | + $jodelAccountForVerify = new JodelAccount($deviceUid); |
|
233 | + } |
|
234 | + else |
|
235 | + { |
|
236 | + $deviceUid = $this->deviceUid; |
|
237 | + $jodelAccountForVerify = $this; |
|
238 | + } |
|
239 | 239 | |
240 | - $solution = $_GET['solution']; |
|
241 | - $solution = array_map('intval', explode('-', $solution)); |
|
240 | + $solution = $_GET['solution']; |
|
241 | + $solution = array_map('intval', explode('-', $solution)); |
|
242 | 242 | |
243 | - $accountCreator = new PostCaptcha(); |
|
244 | - $accountCreator->setAccessToken($jodelAccountForVerify->accessToken); |
|
245 | - $accountCreator->captchaKey = $_GET['key']; |
|
246 | - $accountCreator->captchaSolution = $solution; |
|
247 | - $verified = $accountCreator->execute(); |
|
243 | + $accountCreator = new PostCaptcha(); |
|
244 | + $accountCreator->setAccessToken($jodelAccountForVerify->accessToken); |
|
245 | + $accountCreator->captchaKey = $_GET['key']; |
|
246 | + $accountCreator->captchaSolution = $solution; |
|
247 | + $verified = $accountCreator->execute(); |
|
248 | 248 | |
249 | - if(isset($verified->status_code)) |
|
250 | - { |
|
251 | - return $verified->status_code; |
|
252 | - } |
|
253 | - return $verified['verified']; |
|
254 | - } |
|
249 | + if(isset($verified->status_code)) |
|
250 | + { |
|
251 | + return $verified->status_code; |
|
252 | + } |
|
253 | + return $verified['verified']; |
|
254 | + } |
|
255 | 255 | |
256 | - //ToDo Spider Check |
|
257 | - function votePostId($postId, $vote) |
|
258 | - { |
|
259 | - if(!$this->isBot) |
|
260 | - { |
|
261 | - if(!$this->isAccountVerified()) |
|
262 | - { |
|
256 | + //ToDo Spider Check |
|
257 | + function votePostId($postId, $vote) |
|
258 | + { |
|
259 | + if(!$this->isBot) |
|
260 | + { |
|
261 | + if(!$this->isAccountVerified()) |
|
262 | + { |
|
263 | 263 | |
264 | - } |
|
265 | - |
|
266 | - if(!$this->hasVoted($postId)) |
|
267 | - { |
|
268 | - if($vote == "up") |
|
269 | - { |
|
270 | - $accountCreator = new Upvote(); |
|
271 | - } |
|
272 | - else if($vote == "down") |
|
273 | - { |
|
274 | - $accountCreator = new Downvote(); |
|
275 | - } |
|
276 | - |
|
277 | - $accountCreator->setAccessToken($this->accessToken); |
|
278 | - $accountCreator->postId = htmlspecialchars($postId); |
|
279 | - $data = $accountCreator->execute(); |
|
280 | - |
|
281 | - user_log('User voted: ' . print_r($data, true)); |
|
282 | - |
|
283 | - if(array_key_exists('post', $data)) |
|
284 | - { |
|
285 | - $this->addVoteWithPostIdAndType($postId, $vote); |
|
286 | - return TRUE; |
|
287 | - } |
|
288 | - else if(array_key_exists('error', $data)) |
|
289 | - { |
|
290 | - error_log('Could not vote - Error: ' . $data['error']); |
|
291 | - } |
|
292 | - else |
|
293 | - { |
|
294 | - error_log('Could not vote: ' . print_r($data, true)); |
|
295 | - return FALSE; |
|
296 | - } |
|
297 | - } |
|
298 | - else |
|
299 | - { |
|
300 | - return FALSE; |
|
301 | - } |
|
302 | - } |
|
303 | - |
|
304 | - return FALSE; |
|
305 | - } |
|
264 | + } |
|
265 | + |
|
266 | + if(!$this->hasVoted($postId)) |
|
267 | + { |
|
268 | + if($vote == "up") |
|
269 | + { |
|
270 | + $accountCreator = new Upvote(); |
|
271 | + } |
|
272 | + else if($vote == "down") |
|
273 | + { |
|
274 | + $accountCreator = new Downvote(); |
|
275 | + } |
|
276 | + |
|
277 | + $accountCreator->setAccessToken($this->accessToken); |
|
278 | + $accountCreator->postId = htmlspecialchars($postId); |
|
279 | + $data = $accountCreator->execute(); |
|
280 | + |
|
281 | + user_log('User voted: ' . print_r($data, true)); |
|
282 | + |
|
283 | + if(array_key_exists('post', $data)) |
|
284 | + { |
|
285 | + $this->addVoteWithPostIdAndType($postId, $vote); |
|
286 | + return TRUE; |
|
287 | + } |
|
288 | + else if(array_key_exists('error', $data)) |
|
289 | + { |
|
290 | + error_log('Could not vote - Error: ' . $data['error']); |
|
291 | + } |
|
292 | + else |
|
293 | + { |
|
294 | + error_log('Could not vote: ' . print_r($data, true)); |
|
295 | + return FALSE; |
|
296 | + } |
|
297 | + } |
|
298 | + else |
|
299 | + { |
|
300 | + return FALSE; |
|
301 | + } |
|
302 | + } |
|
306 | 303 | |
307 | - //ToDo Spider Check |
|
308 | - function sendJodel($location, $view) |
|
309 | - { |
|
310 | - if($this->isAccountVerified() != 1) |
|
311 | - { |
|
312 | - $this->showCaptcha(); |
|
313 | - //$this->verifyCaptcha(); |
|
314 | - } |
|
304 | + return FALSE; |
|
305 | + } |
|
315 | 306 | |
316 | - $accountCreator = new SendJodel(); |
|
307 | + //ToDo Spider Check |
|
308 | + function sendJodel($location, $view) |
|
309 | + { |
|
310 | + if($this->isAccountVerified() != 1) |
|
311 | + { |
|
312 | + $this->showCaptcha(); |
|
313 | + //$this->verifyCaptcha(); |
|
314 | + } |
|
317 | 315 | |
318 | - if(isset($_POST['ancestor'])) |
|
319 | - { |
|
320 | - $ancestor = $_POST['ancestor']; |
|
321 | - $accountCreator->ancestor = $ancestor; |
|
322 | - } |
|
323 | - if(isset($_POST['color'])) |
|
324 | - { |
|
325 | - $color = $_POST['color']; |
|
326 | - switch ($color) { |
|
327 | - case '8ABDB0': |
|
328 | - $color = '8ABDB0'; |
|
329 | - break; |
|
330 | - case '9EC41C': |
|
331 | - $color = '9EC41C'; |
|
332 | - break; |
|
333 | - case '06A3CB': |
|
334 | - $color = '06A3CB'; |
|
335 | - break; |
|
336 | - case 'FFBA00': |
|
337 | - $color = 'FFBA00'; |
|
338 | - break; |
|
339 | - case 'DD5F5F': |
|
340 | - $color = 'DD5F5F'; |
|
341 | - break; |
|
342 | - case 'FF9908': |
|
343 | - $color = 'FF9908'; |
|
344 | - break; |
|
345 | - default: |
|
346 | - $color = '8ABDB0'; |
|
347 | - break; |
|
348 | - } |
|
349 | - $accountCreator->color = $color; |
|
350 | - } |
|
351 | - |
|
352 | - $accountCreatorLocation = new UpdateLocation(); |
|
353 | - $accountCreatorLocation->setLocation($location); |
|
354 | - $accountCreatorLocation->setAccessToken($this->accessToken); |
|
355 | - $data = $accountCreatorLocation->execute(); |
|
316 | + $accountCreator = new SendJodel(); |
|
317 | + |
|
318 | + if(isset($_POST['ancestor'])) |
|
319 | + { |
|
320 | + $ancestor = $_POST['ancestor']; |
|
321 | + $accountCreator->ancestor = $ancestor; |
|
322 | + } |
|
323 | + if(isset($_POST['color'])) |
|
324 | + { |
|
325 | + $color = $_POST['color']; |
|
326 | + switch ($color) { |
|
327 | + case '8ABDB0': |
|
328 | + $color = '8ABDB0'; |
|
329 | + break; |
|
330 | + case '9EC41C': |
|
331 | + $color = '9EC41C'; |
|
332 | + break; |
|
333 | + case '06A3CB': |
|
334 | + $color = '06A3CB'; |
|
335 | + break; |
|
336 | + case 'FFBA00': |
|
337 | + $color = 'FFBA00'; |
|
338 | + break; |
|
339 | + case 'DD5F5F': |
|
340 | + $color = 'DD5F5F'; |
|
341 | + break; |
|
342 | + case 'FF9908': |
|
343 | + $color = 'FF9908'; |
|
344 | + break; |
|
345 | + default: |
|
346 | + $color = '8ABDB0'; |
|
347 | + break; |
|
348 | + } |
|
349 | + $accountCreator->color = $color; |
|
350 | + } |
|
351 | + |
|
352 | + $accountCreatorLocation = new UpdateLocation(); |
|
353 | + $accountCreatorLocation->setLocation($location); |
|
354 | + $accountCreatorLocation->setAccessToken($this->accessToken); |
|
355 | + $data = $accountCreatorLocation->execute(); |
|
356 | 356 | |
357 | 357 | if($data != 'Success') |
358 | 358 | { |
359 | 359 | error_log('Could not set location befor Post: ' . print_r($data, true)); |
360 | 360 | } |
361 | 361 | |
362 | - $accountCreator->location = $this->location; |
|
362 | + $accountCreator->location = $this->location; |
|
363 | 363 | |
364 | - $image = ''; |
|
365 | - if(isset($_FILES['image']) && $_FILES['image']['size'] > 0) |
|
366 | - { |
|
367 | - $image = file_get_contents($_FILES['image']['tmp_name']); |
|
368 | - } |
|
364 | + $image = ''; |
|
365 | + if(isset($_FILES['image']) && $_FILES['image']['size'] > 0) |
|
366 | + { |
|
367 | + $image = file_get_contents($_FILES['image']['tmp_name']); |
|
368 | + } |
|
369 | 369 | |
370 | - $accountCreator->image = $image; |
|
370 | + $accountCreator->image = $image; |
|
371 | 371 | |
372 | - $accountCreator->setAccessToken($this->accessToken); |
|
373 | - $data = $accountCreator->execute(); |
|
372 | + $accountCreator->setAccessToken($this->accessToken); |
|
373 | + $data = $accountCreator->execute(); |
|
374 | 374 | |
375 | - if(isset($data['error']) && $data['error'] == 'length') |
|
376 | - { |
|
377 | - $errorMsg = 'Error: The input was to long'; |
|
378 | - return $errorMsg; |
|
379 | - } |
|
375 | + if(isset($data['error']) && $data['error'] == 'length') |
|
376 | + { |
|
377 | + $errorMsg = 'Error: The input was to long'; |
|
378 | + return $errorMsg; |
|
379 | + } |
|
380 | 380 | |
381 | - user_log('User posted: ' . print_r($data, true)); |
|
381 | + user_log('User posted: ' . print_r($data, true)); |
|
382 | 382 | |
383 | - if(isset($_POST['ancestor'])) |
|
384 | - { |
|
385 | - header('Location: ' . $view->toUrl()); |
|
386 | - exit; |
|
387 | - } |
|
388 | - else |
|
389 | - { |
|
390 | - header('Location: ' . $view->baseUrl); |
|
391 | - exit; |
|
392 | - } |
|
393 | - } |
|
383 | + if(isset($_POST['ancestor'])) |
|
384 | + { |
|
385 | + header('Location: ' . $view->toUrl()); |
|
386 | + exit; |
|
387 | + } |
|
388 | + else |
|
389 | + { |
|
390 | + header('Location: ' . $view->baseUrl); |
|
391 | + exit; |
|
392 | + } |
|
393 | + } |
|
394 | 394 | |
395 | - function isTokenFresh() |
|
396 | - { |
|
397 | - $db = new DatabaseConnect(); |
|
398 | - $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'"); |
|
395 | + function isTokenFresh() |
|
396 | + { |
|
397 | + $db = new DatabaseConnect(); |
|
398 | + $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'"); |
|
399 | 399 | |
400 | - if ($result->num_rows > 0) |
|
401 | - { |
|
402 | - // output data of each row |
|
403 | - while($row = $result->fetch_assoc()) |
|
404 | - { |
|
405 | - $expiration_date = $row["expiration_date"]; |
|
406 | - } |
|
407 | - } |
|
408 | - else |
|
409 | - { |
|
410 | - error_log('0 results'); |
|
411 | - } |
|
400 | + if ($result->num_rows > 0) |
|
401 | + { |
|
402 | + // output data of each row |
|
403 | + while($row = $result->fetch_assoc()) |
|
404 | + { |
|
405 | + $expiration_date = $row["expiration_date"]; |
|
406 | + } |
|
407 | + } |
|
408 | + else |
|
409 | + { |
|
410 | + error_log('0 results'); |
|
411 | + } |
|
412 | 412 | |
413 | - if($expiration_date <= time()) |
|
414 | - { |
|
415 | - return FALSE; |
|
416 | - } |
|
413 | + if($expiration_date <= time()) |
|
414 | + { |
|
415 | + return FALSE; |
|
416 | + } |
|
417 | 417 | |
418 | - return TRUE; |
|
419 | - } |
|
420 | - |
|
421 | - function refreshToken() |
|
422 | - { |
|
423 | - $accountCreator = new CreateUser(); |
|
424 | - $accountCreator->setAccessToken($this->accessToken); |
|
425 | - $accountCreator->setDeviceUid($this->deviceUid); |
|
426 | - $accountCreator->setLocation($this->location); |
|
427 | - $data = $accountCreator->execute(); |
|
428 | - |
|
429 | - $access_token = (string)$data[0]['access_token']; |
|
430 | - $expiration_date = $data[0]['expiration_date']; |
|
431 | - $device_uid = (string)$data[1]; |
|
418 | + return TRUE; |
|
419 | + } |
|
420 | + |
|
421 | + function refreshToken() |
|
422 | + { |
|
423 | + $accountCreator = new CreateUser(); |
|
424 | + $accountCreator->setAccessToken($this->accessToken); |
|
425 | + $accountCreator->setDeviceUid($this->deviceUid); |
|
426 | + $accountCreator->setLocation($this->location); |
|
427 | + $data = $accountCreator->execute(); |
|
428 | + |
|
429 | + $access_token = (string)$data[0]['access_token']; |
|
430 | + $expiration_date = $data[0]['expiration_date']; |
|
431 | + $device_uid = (string)$data[1]; |
|
432 | 432 | |
433 | - $db = new DatabaseConnect(); |
|
434 | - $result = $db->query("UPDATE accounts |
|
433 | + $db = new DatabaseConnect(); |
|
434 | + $result = $db->query("UPDATE accounts |
|
435 | 435 | SET access_token='" . $access_token . "', |
436 | 436 | expiration_date='" . $expiration_date . "' |
437 | 437 | WHERE device_uid='" . $device_uid . "'"); |
438 | 438 | |
439 | - if($result === false){ |
|
440 | - error_log("Adding account failed: (" . $db->errno . ") " . $db->error); |
|
441 | - } |
|
442 | - } |
|
439 | + if($result === false){ |
|
440 | + error_log("Adding account failed: (" . $db->errno . ") " . $db->error); |
|
441 | + } |
|
442 | + } |
|
443 | 443 | |
444 | 444 | |
445 | 445 | |
446 | - function getAccessToken() |
|
447 | - { |
|
448 | - $db = new DatabaseConnect(); |
|
449 | - $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'"); |
|
446 | + function getAccessToken() |
|
447 | + { |
|
448 | + $db = new DatabaseConnect(); |
|
449 | + $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'"); |
|
450 | 450 | |
451 | - $accessToken; |
|
451 | + $accessToken; |
|
452 | 452 | |
453 | - if ($result->num_rows > 0) |
|
454 | - { |
|
455 | - // output data of each row |
|
456 | - while($row = $result->fetch_assoc()) |
|
457 | - { |
|
458 | - $accessToken = $row['access_token']; |
|
459 | - } |
|
460 | - } |
|
461 | - else |
|
462 | - { |
|
463 | - error_log('Error: 0 results'); |
|
464 | - } |
|
453 | + if ($result->num_rows > 0) |
|
454 | + { |
|
455 | + // output data of each row |
|
456 | + while($row = $result->fetch_assoc()) |
|
457 | + { |
|
458 | + $accessToken = $row['access_token']; |
|
459 | + } |
|
460 | + } |
|
461 | + else |
|
462 | + { |
|
463 | + error_log('Error: 0 results'); |
|
464 | + } |
|
465 | 465 | |
466 | - return $accessToken; |
|
467 | - } |
|
466 | + return $accessToken; |
|
467 | + } |
|
468 | 468 | |
469 | 469 | |
470 | - function getKarma() |
|
471 | - { |
|
472 | - $accountCreator = new GetKarma(); |
|
473 | - $accountCreator->setAccessToken($this->accessToken); |
|
474 | - $data = $accountCreator->execute(); |
|
470 | + function getKarma() |
|
471 | + { |
|
472 | + $accountCreator = new GetKarma(); |
|
473 | + $accountCreator->setAccessToken($this->accessToken); |
|
474 | + $data = $accountCreator->execute(); |
|
475 | 475 | |
476 | - return $data['karma']; |
|
477 | - } |
|
476 | + return $data['karma']; |
|
477 | + } |
|
478 | 478 | |
479 | - function hasVoted($postId) |
|
480 | - { |
|
481 | - $db = new DatabaseConnect(); |
|
479 | + function hasVoted($postId) |
|
480 | + { |
|
481 | + $db = new DatabaseConnect(); |
|
482 | 482 | |
483 | - $postId = $db->real_escape_string($postId); |
|
483 | + $postId = $db->real_escape_string($postId); |
|
484 | 484 | |
485 | - $result = $db->query("SELECT id FROM votes WHERE (postId = '" . $postId . "' AND device_uid = '" . $this->deviceUid . "')"); |
|
485 | + $result = $db->query("SELECT id FROM votes WHERE (postId = '" . $postId . "' AND device_uid = '" . $this->deviceUid . "')"); |
|
486 | 486 | |
487 | - if($result === false) |
|
488 | - { |
|
489 | - $error = db_error(); |
|
490 | - echo $error; |
|
491 | - error_log("Adding Vote failed: (" . $result->errno . ") " . $result->error); |
|
492 | - } |
|
487 | + if($result === false) |
|
488 | + { |
|
489 | + $error = db_error(); |
|
490 | + echo $error; |
|
491 | + error_log("Adding Vote failed: (" . $result->errno . ") " . $result->error); |
|
492 | + } |
|
493 | 493 | |
494 | - if($result->num_rows == 0) |
|
495 | - { |
|
496 | - return FALSE; |
|
497 | - } |
|
498 | - else |
|
499 | - { |
|
500 | - return TRUE; |
|
501 | - } |
|
502 | - } |
|
494 | + if($result->num_rows == 0) |
|
495 | + { |
|
496 | + return FALSE; |
|
497 | + } |
|
498 | + else |
|
499 | + { |
|
500 | + return TRUE; |
|
501 | + } |
|
502 | + } |
|
503 | 503 | |
504 | - function addVoteWithPostIdAndType($postId, $voteType) |
|
505 | - { |
|
506 | - $db = new DatabaseConnect(); |
|
504 | + function addVoteWithPostIdAndType($postId, $voteType) |
|
505 | + { |
|
506 | + $db = new DatabaseConnect(); |
|
507 | 507 | |
508 | - $postId = $db->real_escape_string($postId); |
|
509 | - $voteType = $db->real_escape_string($voteType); |
|
508 | + $postId = $db->real_escape_string($postId); |
|
509 | + $voteType = $db->real_escape_string($voteType); |
|
510 | 510 | |
511 | - if($this->hasVoted($postId)) |
|
512 | - { |
|
513 | - return "Already voted"; |
|
514 | - } |
|
511 | + if($this->hasVoted($postId)) |
|
512 | + { |
|
513 | + return "Already voted"; |
|
514 | + } |
|
515 | 515 | |
516 | - $result = $db->query("INSERT INTO votes (device_uid, postId, type) |
|
516 | + $result = $db->query("INSERT INTO votes (device_uid, postId, type) |
|
517 | 517 | VALUES ('" . $this->deviceUid . "','" . $postId . "','" . $voteType . "')"); |
518 | 518 | |
519 | - if($result === false){ |
|
520 | - $error = db_error(); |
|
521 | - echo $error; |
|
522 | - echo "Adding Vote failed: (" . $result->errno . ") " . $result->error; |
|
523 | - } |
|
524 | - } |
|
525 | - |
|
526 | - function registerAccount($location) { |
|
527 | - $accountCreator = new CreateUser(); |
|
528 | - $accountCreator->setLocation($location); |
|
529 | - $data = $accountCreator->execute(); |
|
519 | + if($result === false){ |
|
520 | + $error = db_error(); |
|
521 | + echo $error; |
|
522 | + echo "Adding Vote failed: (" . $result->errno . ") " . $result->error; |
|
523 | + } |
|
524 | + } |
|
525 | + |
|
526 | + function registerAccount($location) { |
|
527 | + $accountCreator = new CreateUser(); |
|
528 | + $accountCreator->setLocation($location); |
|
529 | + $data = $accountCreator->execute(); |
|
530 | 530 | |
531 | - $access_token = (string)$data[0]['access_token']; |
|
532 | - $refresh_token = (string)$data[0]['refresh_token']; |
|
533 | - $token_type = (string)$data[0]['token_type']; |
|
534 | - $expires_in = $data[0]['expires_in']; |
|
535 | - $expiration_date = $data[0]['expiration_date']; |
|
536 | - $distinct_id = (string)$data[0]['distinct_id']; |
|
537 | - $device_uid = (string)$data[1]; |
|
538 | - |
|
539 | - $name = $location->cityName; |
|
540 | - $lat = $location->lat; |
|
541 | - $lng = $location->lng; |
|
531 | + $access_token = (string)$data[0]['access_token']; |
|
532 | + $refresh_token = (string)$data[0]['refresh_token']; |
|
533 | + $token_type = (string)$data[0]['token_type']; |
|
534 | + $expires_in = $data[0]['expires_in']; |
|
535 | + $expiration_date = $data[0]['expiration_date']; |
|
536 | + $distinct_id = (string)$data[0]['distinct_id']; |
|
537 | + $device_uid = (string)$data[1]; |
|
538 | + |
|
539 | + $name = $location->cityName; |
|
540 | + $lat = $location->lat; |
|
541 | + $lng = $location->lng; |
|
542 | 542 | |
543 | - $db = new DatabaseConnect(); |
|
544 | - $result = $db->query("INSERT INTO accounts (access_token, refresh_token, token_type, |
|
543 | + $db = new DatabaseConnect(); |
|
544 | + $result = $db->query("INSERT INTO accounts (access_token, refresh_token, token_type, |
|
545 | 545 | expires_in, expiration_date, distinct_id, device_uid, name, lat, lng) |
546 | 546 | VALUES ('" . $access_token . "','" . $refresh_token . "','" . $token_type . |
547 | - "','" . $expires_in . "','" . $expiration_date . "','" . $distinct_id . |
|
548 | - "','" . $device_uid . "','" . $name . "','" . $lat . "','" . $lng . "') "); |
|
549 | - |
|
550 | - $success = TRUE; |
|
551 | - if($result === false){ |
|
552 | - $error = $db->error(); |
|
553 | - echo $error; |
|
554 | - echo "Adding account failed: (" . $result->errno . ") " . $result->error; |
|
555 | - $success = FALSE; |
|
556 | - } |
|
547 | + "','" . $expires_in . "','" . $expiration_date . "','" . $distinct_id . |
|
548 | + "','" . $device_uid . "','" . $name . "','" . $lat . "','" . $lng . "') "); |
|
549 | + |
|
550 | + $success = TRUE; |
|
551 | + if($result === false){ |
|
552 | + $error = $db->error(); |
|
553 | + echo $error; |
|
554 | + echo "Adding account failed: (" . $result->errno . ") " . $result->error; |
|
555 | + $success = FALSE; |
|
556 | + } |
|
557 | 557 | |
558 | - return $device_uid; |
|
559 | - } |
|
558 | + return $device_uid; |
|
559 | + } |
|
560 | 560 | |
561 | - function createAccount() |
|
562 | - { |
|
563 | - $config = parse_ini_file('config/config.ini.php'); |
|
564 | - $location = new Location(); |
|
565 | - $location->setLat($config['default_lat']); |
|
566 | - $location->setLng($config['default_lng']); |
|
567 | - $location->setCityName($config['default_location']); |
|
561 | + function createAccount() |
|
562 | + { |
|
563 | + $config = parse_ini_file('config/config.ini.php'); |
|
564 | + $location = new Location(); |
|
565 | + $location->setLat($config['default_lat']); |
|
566 | + $location->setLng($config['default_lng']); |
|
567 | + $location->setCityName($config['default_location']); |
|
568 | 568 | |
569 | - $deviceUid = $this->registerAccount($location); |
|
569 | + $deviceUid = $this->registerAccount($location); |
|
570 | 570 | |
571 | - return $deviceUid; |
|
572 | - } |
|
571 | + return $deviceUid; |
|
572 | + } |
|
573 | 573 | } |
574 | 574 | \ No newline at end of file |