@@ -28,7 +28,8 @@ discard block |
||
28 | 28 | |
29 | 29 | $posts[0] = $data; |
30 | 30 | |
31 | - if(array_key_exists('children', $data)) { |
|
31 | + if(array_key_exists('children', $data)) |
|
32 | + { |
|
32 | 33 | foreach($data['children'] as $key => $child) |
33 | 34 | { |
34 | 35 | |
@@ -91,7 +92,9 @@ discard block |
||
91 | 92 | } ?> |
92 | 93 | </content> |
93 | 94 | |
94 | - <?php if(!isset($_GET['postId']) && !isset($_GET['getPostDetails'])) { ?> |
|
95 | + <?php if(!isset($_GET['postId']) && !isset($_GET['getPostDetails'])) |
|
96 | +{ |
|
97 | +?> |
|
95 | 98 | <p id="loading"> |
96 | 99 | Loading… |
97 | 100 | </p> |
@@ -99,12 +102,20 @@ discard block |
||
99 | 102 | </article> |
100 | 103 | |
101 | 104 | <aside class="topSidebar col-sm-4 sidebar-outer"> |
102 | - <div class="fixed<?php if(!$view->isDetailedView) echo(' hide-mobile');?>"> |
|
105 | + <div class="fixed<?php if(!$view->isDetailedView) |
|
106 | +{ |
|
107 | + echo(' hide-mobile'); |
|
108 | +} |
|
109 | +?>"> |
|
103 | 110 | <article> |
104 | 111 | <div> |
105 | 112 | <h2>Position / Hashtag</h2> |
106 | 113 | <form action="index.php" method="get"> |
107 | - <input type="text" id="city" name="search" placeholder="<?php if(isset($newPositionStatus)) echo $newPositionStatus; ?>" required> |
|
114 | + <input type="text" id="city" name="search" placeholder="<?php if(isset($newPositionStatus)) |
|
115 | +{ |
|
116 | + echo $newPositionStatus; |
|
117 | +} |
|
118 | +?>" required> |
|
108 | 119 | <label>try: #jhj</label><br> |
109 | 120 | <input type="submit" value="Set Location" /> |
110 | 121 | </form> |
@@ -120,7 +131,9 @@ discard block |
||
120 | 131 | |
121 | 132 | <article> |
122 | 133 | <div> |
123 | - <?php if(isset($_GET['postId']) && isset($_GET['getPostDetails'])) { ?> |
|
134 | + <?php if(isset($_GET['postId']) && isset($_GET['getPostDetails'])) |
|
135 | +{ |
|
136 | +?> |
|
124 | 137 | <h2>Comment on Jodel</h2> |
125 | 138 | <form method="POST"> |
126 | 139 | <input type="hidden" name="ancestor" value="<?php echo htmlspecialchars($_GET['postId']);?>" /> |
@@ -128,7 +141,10 @@ discard block |
||
128 | 141 | <br /> |
129 | 142 | <input type="submit" value="SEND" /> |
130 | 143 | </form> |
131 | - <?php } else { ?> |
|
144 | + <?php } |
|
145 | +else |
|
146 | +{ |
|
147 | +?> |
|
132 | 148 | <h2>New Jodel</h2> |
133 | 149 | <form enctype="multipart/form-data" method="POST"> |
134 | 150 | <textarea id="message" name="message" placeholder="Send a Jodel to all students within 10km" required></textarea> |
@@ -48,27 +48,27 @@ discard block |
||
48 | 48 | |
49 | 49 | function user_log($msg) |
50 | 50 | { |
51 | - $log = $msg . PHP_EOL; |
|
52 | - file_put_contents(realpath(__DIR__ . '/..') . '/logs/user_log-' . date("j.n.Y") . '.txt', $log, FILE_APPEND); |
|
51 | + $log = $msg . PHP_EOL; |
|
52 | + file_put_contents(realpath(__DIR__ . '/..') . '/logs/user_log-' . date("j.n.Y") . '.txt', $log, FILE_APPEND); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | function isUserBot() |
56 | 56 | { |
57 | - preg_match('/bot|spider|google|twitter/i', $_SERVER['HTTP_USER_AGENT'], $matches); |
|
57 | + preg_match('/bot|spider|google|twitter/i', $_SERVER['HTTP_USER_AGENT'], $matches); |
|
58 | 58 | |
59 | - return (isset($matches[0])) ? true : false; |
|
59 | + return (isset($matches[0])) ? true : false; |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | function configPropertyExists($config, $property) |
63 | 63 | { |
64 | - if(!array_key_exists($property, $config) || !isset($config[$property]) || $config[$property] == '' || $config[$property] == 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx') |
|
65 | - { |
|
66 | - return FALSE; |
|
67 | - } |
|
68 | - else |
|
69 | - { |
|
70 | - return TRUE; |
|
71 | - } |
|
64 | + if(!array_key_exists($property, $config) || !isset($config[$property]) || $config[$property] == '' || $config[$property] == 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx') |
|
65 | + { |
|
66 | + return FALSE; |
|
67 | + } |
|
68 | + else |
|
69 | + { |
|
70 | + return TRUE; |
|
71 | + } |
|
72 | 72 | } |
73 | 73 | function isUserAdmin() { |
74 | 74 | global $config; |
@@ -84,17 +84,17 @@ discard block |
||
84 | 84 | |
85 | 85 | function isDeviceUidInDatabase($deviceUid) |
86 | 86 | { |
87 | - $db = new DatabaseConnect(); |
|
88 | - $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $deviceUid . "'"); |
|
87 | + $db = new DatabaseConnect(); |
|
88 | + $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $deviceUid . "'"); |
|
89 | 89 | |
90 | - if ($result->num_rows > 0) |
|
91 | - { |
|
92 | - return TRUE; |
|
93 | - } |
|
94 | - else |
|
95 | - { |
|
96 | - return FALSE; |
|
97 | - } |
|
90 | + if ($result->num_rows > 0) |
|
91 | + { |
|
92 | + return TRUE; |
|
93 | + } |
|
94 | + else |
|
95 | + { |
|
96 | + return FALSE; |
|
97 | + } |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | //Check if it's a Spider or Google Bot |
@@ -121,14 +121,14 @@ discard block |
||
121 | 121 | } |
122 | 122 | |
123 | 123 | if(configPropertyExists($config, 'karmaDeviceUid')) |
124 | - { |
|
125 | - $jodelAccountForKarma = new JodelAccount($config['karmaDeviceUid']); |
|
126 | - } |
|
127 | - else |
|
128 | - { |
|
129 | - error_log("No Karma deviceUid set in config file"); |
|
124 | + { |
|
125 | + $jodelAccountForKarma = new JodelAccount($config['karmaDeviceUid']); |
|
126 | + } |
|
127 | + else |
|
128 | + { |
|
129 | + error_log("No Karma deviceUid set in config file"); |
|
130 | 130 | $jodelAccountForKarma = new JodelAccount($deviceUid); |
131 | - } |
|
131 | + } |
|
132 | 132 | |
133 | 133 | /* |
134 | 134 | * Cunstruct View |
@@ -241,14 +241,14 @@ discard block |
||
241 | 241 | { |
242 | 242 | $jodelAccountForKarma->votePostId($_GET['postId'], $_GET['vote']); |
243 | 243 | if(isset($_GET['getPostDetails']) && isset($_GET['getPostDetails'])) |
244 | - { |
|
245 | - header('Location: index.php?getPostDetails=true&postId=' . htmlspecialchars($_GET['postId_parent']) . '#postId-' . htmlspecialchars($_GET['postId'])); |
|
246 | - } |
|
247 | - else |
|
248 | - { |
|
249 | - header("Location: index.php#postId-" . htmlspecialchars($_GET['postId'])); |
|
250 | - } |
|
251 | - die(); |
|
244 | + { |
|
245 | + header('Location: index.php?getPostDetails=true&postId=' . htmlspecialchars($_GET['postId_parent']) . '#postId-' . htmlspecialchars($_GET['postId'])); |
|
246 | + } |
|
247 | + else |
|
248 | + { |
|
249 | + header("Location: index.php#postId-" . htmlspecialchars($_GET['postId'])); |
|
250 | + } |
|
251 | + die(); |
|
252 | 252 | } |
253 | 253 | |
254 | 254 | //SendJodel |
@@ -2,564 +2,564 @@ |
||
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 | - function showCaptcha() |
|
48 | - { |
|
49 | - $accountCreator = new GetCaptcha(); |
|
50 | - $accountCreator->setAccessToken($this->accessToken); |
|
51 | - $captcha = $accountCreator->execute(); |
|
47 | + function showCaptcha() |
|
48 | + { |
|
49 | + $accountCreator = new GetCaptcha(); |
|
50 | + $accountCreator->setAccessToken($this->accessToken); |
|
51 | + $captcha = $accountCreator->execute(); |
|
52 | 52 | |
53 | - echo $captcha['image_url']; |
|
54 | - echo('<br><img width="100%" src="' . $captcha['image_url'] . '">'); |
|
55 | - echo "<br>Key: " . $captcha['key']; |
|
56 | - echo "<br>"; |
|
53 | + echo $captcha['image_url']; |
|
54 | + echo('<br><img width="100%" src="' . $captcha['image_url'] . '">'); |
|
55 | + echo "<br>Key: " . $captcha['key']; |
|
56 | + echo "<br>"; |
|
57 | 57 | |
58 | - //Form |
|
58 | + //Form |
|
59 | 59 | |
60 | - echo '<form method="get">'; |
|
61 | - echo '<p>Enter Key (copy pasta from top): <input type="text" value="' . $captcha['key'] . '" name="key" /></p>'; |
|
62 | - echo '<p>Find the Coons (example: they are on picture 3, 4 and 5. You enter 2-3-4. Becouse we start counting at 0): <input type="text" name="solution" /></p>'; |
|
63 | - echo '<input type="hidden" name="deviceUid" value="' . $this->deviceUid . '">'; |
|
64 | - echo '<input type="hidden" name="pw" value="upVote">'; |
|
65 | - echo '<p><input type="submit" /></p>'; |
|
66 | - echo '</form>'; |
|
67 | - |
|
68 | - die(); |
|
60 | + echo '<form method="get">'; |
|
61 | + echo '<p>Enter Key (copy pasta from top): <input type="text" value="' . $captcha['key'] . '" name="key" /></p>'; |
|
62 | + echo '<p>Find the Coons (example: they are on picture 3, 4 and 5. You enter 2-3-4. Becouse we start counting at 0): <input type="text" name="solution" /></p>'; |
|
63 | + echo '<input type="hidden" name="deviceUid" value="' . $this->deviceUid . '">'; |
|
64 | + echo '<input type="hidden" name="pw" value="upVote">'; |
|
65 | + echo '<p><input type="submit" /></p>'; |
|
66 | + echo '</form>'; |
|
67 | + |
|
68 | + die(); |
|
69 | 69 | |
70 | - } |
|
70 | + } |
|
71 | 71 | |
72 | - function getCaptcha() |
|
73 | - { |
|
74 | - $accountCreator = new GetCaptcha(); |
|
75 | - $accountCreator->setAccessToken($this->accessToken); |
|
76 | - $captcha = $accountCreator->execute(); |
|
72 | + function getCaptcha() |
|
73 | + { |
|
74 | + $accountCreator = new GetCaptcha(); |
|
75 | + $accountCreator->setAccessToken($this->accessToken); |
|
76 | + $captcha = $accountCreator->execute(); |
|
77 | 77 | |
78 | - return array("image_url" => $captcha['image_url'], "key" => $captcha['key']); |
|
79 | - } |
|
78 | + return array("image_url" => $captcha['image_url'], "key" => $captcha['key']); |
|
79 | + } |
|
80 | 80 | |
81 | - function isAccountVerified() |
|
82 | - { |
|
83 | - $accountCreator = new GetUserConfig(); |
|
84 | - $accountCreator->setAccessToken($this->accessToken); |
|
85 | - $data = $accountCreator->execute(); |
|
81 | + function isAccountVerified() |
|
82 | + { |
|
83 | + $accountCreator = new GetUserConfig(); |
|
84 | + $accountCreator->setAccessToken($this->accessToken); |
|
85 | + $data = $accountCreator->execute(); |
|
86 | 86 | |
87 | - //error_log(print_r($data, true)); |
|
87 | + //error_log(print_r($data, true)); |
|
88 | 88 | |
89 | - return $data['verified']; |
|
90 | - } |
|
89 | + return $data['verified']; |
|
90 | + } |
|
91 | 91 | |
92 | - function locationEquals($city) |
|
93 | - { |
|
94 | - $url = 'https://maps.googleapis.com/maps/api/geocode/json?address=' . htmlspecialchars($city) . '&key=AIzaSyCwhnja-or07012HqrhPW7prHEDuSvFT4w'; |
|
95 | - $result = Requests::post($url); |
|
96 | - if(json_decode($result->body, true)['status'] == 'ZERO_RESULTS' || json_decode($result->body, true)['status'] == 'INVALID_REQUEST') |
|
97 | - { |
|
98 | - error_log('Error locationEquals'); |
|
99 | - return FALSE; |
|
100 | - } |
|
101 | - else |
|
102 | - { |
|
103 | - $name = json_decode($result->body, true)['results']['0']['address_components']['0']['long_name']; |
|
104 | - $lat = json_decode($result->body, true)['results']['0']['geometry']['location']['lat']; |
|
105 | - $lng = json_decode($result->body, true)['results']['0']['geometry']['location']['lng']; |
|
106 | - } |
|
92 | + function locationEquals($city) |
|
93 | + { |
|
94 | + $url = 'https://maps.googleapis.com/maps/api/geocode/json?address=' . htmlspecialchars($city) . '&key=AIzaSyCwhnja-or07012HqrhPW7prHEDuSvFT4w'; |
|
95 | + $result = Requests::post($url); |
|
96 | + if(json_decode($result->body, true)['status'] == 'ZERO_RESULTS' || json_decode($result->body, true)['status'] == 'INVALID_REQUEST') |
|
97 | + { |
|
98 | + error_log('Error locationEquals'); |
|
99 | + return FALSE; |
|
100 | + } |
|
101 | + else |
|
102 | + { |
|
103 | + $name = json_decode($result->body, true)['results']['0']['address_components']['0']['long_name']; |
|
104 | + $lat = json_decode($result->body, true)['results']['0']['geometry']['location']['lat']; |
|
105 | + $lng = json_decode($result->body, true)['results']['0']['geometry']['location']['lng']; |
|
106 | + } |
|
107 | 107 | |
108 | - $db = new DatabaseConnect(); |
|
109 | - $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'"); |
|
108 | + $db = new DatabaseConnect(); |
|
109 | + $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'"); |
|
110 | 110 | |
111 | - $location = new Location(); |
|
111 | + $location = new Location(); |
|
112 | 112 | |
113 | - if ($result->num_rows > 0) |
|
114 | - { |
|
115 | - // output data of each row |
|
116 | - while($row = $result->fetch_assoc()) |
|
117 | - { |
|
118 | - $location->setLat($row['lat']); |
|
119 | - $location->setLng($row['lng']); |
|
120 | - $location->setCityName($row['name']); |
|
121 | - } |
|
122 | - } |
|
123 | - else |
|
124 | - { |
|
125 | - error_log("Error no Location found - getLocation"); |
|
126 | - } |
|
113 | + if ($result->num_rows > 0) |
|
114 | + { |
|
115 | + // output data of each row |
|
116 | + while($row = $result->fetch_assoc()) |
|
117 | + { |
|
118 | + $location->setLat($row['lat']); |
|
119 | + $location->setLng($row['lng']); |
|
120 | + $location->setCityName($row['name']); |
|
121 | + } |
|
122 | + } |
|
123 | + else |
|
124 | + { |
|
125 | + error_log("Error no Location found - getLocation"); |
|
126 | + } |
|
127 | 127 | |
128 | - if($location->getLat() == $lat && $location->getLng() == $lng && $location->getCityName() == $name) |
|
129 | - { |
|
130 | - return TRUE; |
|
131 | - } |
|
132 | - else |
|
133 | - { |
|
134 | - return FALSE; |
|
135 | - } |
|
136 | - } |
|
137 | - |
|
138 | - function setLocation() |
|
139 | - { |
|
140 | - //Is Channel or City |
|
141 | - if(substr($_GET['city'], 0, 1) === '#') |
|
142 | - { |
|
143 | - return htmlspecialchars($_GET['city']) . " " . $this->location->cityName; |
|
144 | - } |
|
145 | - else |
|
146 | - { |
|
147 | - $url = 'https://maps.googleapis.com/maps/api/geocode/json?address=' . htmlspecialchars($_GET['city']) . '&key=AIzaSyCwhnja-or07012HqrhPW7prHEDuSvFT4w'; |
|
148 | - $result = Requests::post($url); |
|
149 | - if(json_decode($result->body, true)['status'] == 'ZERO_RESULTS' || json_decode($result->body, true)['status'] == 'INVALID_REQUEST') |
|
150 | - { |
|
151 | - return "0 results"; |
|
152 | - } |
|
153 | - else |
|
154 | - { |
|
155 | - $name = json_decode($result->body, true)['results']['0']['address_components']['0']['long_name']; |
|
156 | - $lat = json_decode($result->body, true)['results']['0']['geometry']['location']['lat']; |
|
157 | - $lng = json_decode($result->body, true)['results']['0']['geometry']['location']['lng']; |
|
158 | - |
|
159 | - $location = new Location(); |
|
160 | - $location->setLat($lat); |
|
161 | - $location->setLng($lng); |
|
162 | - $location->setCityName($name); |
|
163 | - $accountCreator = new UpdateLocation(); |
|
164 | - $accountCreator->setLocation($location); |
|
165 | - $accountCreator->setAccessToken($this->accessToken); |
|
166 | - $data = $accountCreator->execute(); |
|
167 | - |
|
168 | - //safe location to db |
|
169 | - $db = new DatabaseConnect(); |
|
170 | - |
|
171 | - if($data == 'Success') |
|
172 | - { |
|
173 | - $result = $db->query("UPDATE accounts |
|
128 | + if($location->getLat() == $lat && $location->getLng() == $lng && $location->getCityName() == $name) |
|
129 | + { |
|
130 | + return TRUE; |
|
131 | + } |
|
132 | + else |
|
133 | + { |
|
134 | + return FALSE; |
|
135 | + } |
|
136 | + } |
|
137 | + |
|
138 | + function setLocation() |
|
139 | + { |
|
140 | + //Is Channel or City |
|
141 | + if(substr($_GET['city'], 0, 1) === '#') |
|
142 | + { |
|
143 | + return htmlspecialchars($_GET['city']) . " " . $this->location->cityName; |
|
144 | + } |
|
145 | + else |
|
146 | + { |
|
147 | + $url = 'https://maps.googleapis.com/maps/api/geocode/json?address=' . htmlspecialchars($_GET['city']) . '&key=AIzaSyCwhnja-or07012HqrhPW7prHEDuSvFT4w'; |
|
148 | + $result = Requests::post($url); |
|
149 | + if(json_decode($result->body, true)['status'] == 'ZERO_RESULTS' || json_decode($result->body, true)['status'] == 'INVALID_REQUEST') |
|
150 | + { |
|
151 | + return "0 results"; |
|
152 | + } |
|
153 | + else |
|
154 | + { |
|
155 | + $name = json_decode($result->body, true)['results']['0']['address_components']['0']['long_name']; |
|
156 | + $lat = json_decode($result->body, true)['results']['0']['geometry']['location']['lat']; |
|
157 | + $lng = json_decode($result->body, true)['results']['0']['geometry']['location']['lng']; |
|
158 | + |
|
159 | + $location = new Location(); |
|
160 | + $location->setLat($lat); |
|
161 | + $location->setLng($lng); |
|
162 | + $location->setCityName($name); |
|
163 | + $accountCreator = new UpdateLocation(); |
|
164 | + $accountCreator->setLocation($location); |
|
165 | + $accountCreator->setAccessToken($this->accessToken); |
|
166 | + $data = $accountCreator->execute(); |
|
167 | + |
|
168 | + //safe location to db |
|
169 | + $db = new DatabaseConnect(); |
|
170 | + |
|
171 | + if($data == 'Success') |
|
172 | + { |
|
173 | + $result = $db->query("UPDATE accounts |
|
174 | 174 | SET name='" . $name . "', |
175 | 175 | lat='" . $lat . "', |
176 | 176 | lng='" . $lng . "' |
177 | 177 | WHERE access_token='" . $this->accessToken . "'"); |
178 | 178 | |
179 | - if($result === false) |
|
180 | - { |
|
181 | - echo "Updating location failed: (" . $db->errno . ") " . $db->error; |
|
182 | - } |
|
183 | - else |
|
184 | - { |
|
185 | - user_log('User with JodelDeviceId:' . $this->deviceUid . ' [' . $_SERVER['REMOTE_ADDR'] . '][' . $_SERVER ['HTTP_USER_AGENT'] . '] changed to Location: ' . $name); |
|
186 | - } |
|
187 | - } |
|
188 | - |
|
189 | - return $name; |
|
190 | - } |
|
191 | - } |
|
192 | - } |
|
193 | - |
|
194 | - function getLocation() |
|
195 | - { |
|
196 | - $db = new DatabaseConnect(); |
|
197 | - $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'"); |
|
179 | + if($result === false) |
|
180 | + { |
|
181 | + echo "Updating location failed: (" . $db->errno . ") " . $db->error; |
|
182 | + } |
|
183 | + else |
|
184 | + { |
|
185 | + user_log('User with JodelDeviceId:' . $this->deviceUid . ' [' . $_SERVER['REMOTE_ADDR'] . '][' . $_SERVER ['HTTP_USER_AGENT'] . '] changed to Location: ' . $name); |
|
186 | + } |
|
187 | + } |
|
188 | + |
|
189 | + return $name; |
|
190 | + } |
|
191 | + } |
|
192 | + } |
|
193 | + |
|
194 | + function getLocation() |
|
195 | + { |
|
196 | + $db = new DatabaseConnect(); |
|
197 | + $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'"); |
|
198 | 198 | |
199 | - $location = new Location(); |
|
199 | + $location = new Location(); |
|
200 | 200 | |
201 | - if ($result->num_rows > 0) |
|
202 | - { |
|
203 | - // output data of each row |
|
204 | - while($row = $result->fetch_assoc()) |
|
205 | - { |
|
206 | - $location->setLat($row['lat']); |
|
207 | - $location->setLng($row['lng']); |
|
208 | - $location->setCityName($row['name']); |
|
209 | - } |
|
210 | - } |
|
211 | - else |
|
212 | - { |
|
213 | - echo "Error: 0 results"; |
|
214 | - error_log("Error no Location found - getLocation"); |
|
215 | - } |
|
201 | + if ($result->num_rows > 0) |
|
202 | + { |
|
203 | + // output data of each row |
|
204 | + while($row = $result->fetch_assoc()) |
|
205 | + { |
|
206 | + $location->setLat($row['lat']); |
|
207 | + $location->setLng($row['lng']); |
|
208 | + $location->setCityName($row['name']); |
|
209 | + } |
|
210 | + } |
|
211 | + else |
|
212 | + { |
|
213 | + echo "Error: 0 results"; |
|
214 | + error_log("Error no Location found - getLocation"); |
|
215 | + } |
|
216 | 216 | |
217 | - return $location; |
|
218 | - } |
|
217 | + return $location; |
|
218 | + } |
|
219 | 219 | |
220 | - function verifyCaptcha() |
|
221 | - { |
|
222 | - if(isset($_GET['deviceUid'])) |
|
223 | - { |
|
224 | - $deviceUid = $_GET['deviceUid']; |
|
225 | - $jodelAccountForVerify = new JodelAccount($deviceUid); |
|
226 | - } |
|
227 | - else if(isset($_POST['deviceUid'])) |
|
228 | - { |
|
229 | - $deviceUid = $_POST['deviceUid']; |
|
230 | - $jodelAccountForVerify = new JodelAccount($deviceUid); |
|
231 | - } |
|
232 | - else |
|
233 | - { |
|
234 | - $deviceUid = $this->deviceUid; |
|
235 | - $jodelAccountForVerify = $this; |
|
236 | - } |
|
220 | + function verifyCaptcha() |
|
221 | + { |
|
222 | + if(isset($_GET['deviceUid'])) |
|
223 | + { |
|
224 | + $deviceUid = $_GET['deviceUid']; |
|
225 | + $jodelAccountForVerify = new JodelAccount($deviceUid); |
|
226 | + } |
|
227 | + else if(isset($_POST['deviceUid'])) |
|
228 | + { |
|
229 | + $deviceUid = $_POST['deviceUid']; |
|
230 | + $jodelAccountForVerify = new JodelAccount($deviceUid); |
|
231 | + } |
|
232 | + else |
|
233 | + { |
|
234 | + $deviceUid = $this->deviceUid; |
|
235 | + $jodelAccountForVerify = $this; |
|
236 | + } |
|
237 | 237 | |
238 | - $solution = $_GET['solution']; |
|
239 | - $solution = array_map('intval', explode('-', $solution)); |
|
238 | + $solution = $_GET['solution']; |
|
239 | + $solution = array_map('intval', explode('-', $solution)); |
|
240 | 240 | |
241 | - $accountCreator = new PostCaptcha(); |
|
242 | - $accountCreator->setAccessToken($jodelAccountForVerify->accessToken); |
|
243 | - $accountCreator->captchaKey = $_GET['key']; |
|
244 | - $accountCreator->captchaSolution = $solution; |
|
245 | - $verified = $accountCreator->execute(); |
|
241 | + $accountCreator = new PostCaptcha(); |
|
242 | + $accountCreator->setAccessToken($jodelAccountForVerify->accessToken); |
|
243 | + $accountCreator->captchaKey = $_GET['key']; |
|
244 | + $accountCreator->captchaSolution = $solution; |
|
245 | + $verified = $accountCreator->execute(); |
|
246 | 246 | |
247 | - if(isset($verified->status_code)) |
|
248 | - { |
|
249 | - return $verified->status_code; |
|
250 | - } |
|
251 | - return $verified['verified']; |
|
252 | - } |
|
253 | - |
|
254 | - //ToDo Spider Check |
|
255 | - function votePostId($postId, $vote) |
|
256 | - { |
|
257 | - if(!$this->isBot) |
|
258 | - { |
|
259 | - if(!$this->isAccountVerified()) |
|
260 | - { |
|
261 | - $view = new View(); |
|
262 | - $this->showCaptcha(); |
|
263 | - } |
|
264 | - |
|
265 | - if(!$this->hasVoted($postId)) |
|
266 | - { |
|
267 | - if($vote == "up") |
|
268 | - { |
|
269 | - $accountCreator = new Upvote(); |
|
270 | - } |
|
271 | - else if($vote == "down") |
|
272 | - { |
|
273 | - $accountCreator = new Downvote(); |
|
274 | - } |
|
275 | - |
|
276 | - $accountCreator->setAccessToken($this->accessToken); |
|
277 | - $accountCreator->postId = htmlspecialchars($postId); |
|
278 | - $data = $accountCreator->execute(); |
|
279 | - |
|
280 | - error_log('Could not vote: ' . print_r($data, true)); |
|
281 | - |
|
282 | - if(array_key_exists('post', $data)) |
|
283 | - { |
|
284 | - $this->addVoteWithPostIdAndType($postId, $vote); |
|
285 | - return TRUE; |
|
286 | - } |
|
287 | - else if(array_key_exists('error', $data)) |
|
288 | - { |
|
289 | - error_log('Could not vote - Error: ' . $data['error']); |
|
290 | - } |
|
291 | - else |
|
292 | - { |
|
293 | - error_log('Could not vote: ' . print_r($data, true)); |
|
294 | - return FALSE; |
|
295 | - } |
|
296 | - } |
|
297 | - else |
|
298 | - { |
|
299 | - return FALSE; |
|
300 | - } |
|
301 | - } |
|
302 | - |
|
303 | - return FALSE; |
|
304 | - } |
|
305 | - |
|
306 | - //ToDo Spider Check |
|
307 | - function sendJodel($location, $view) |
|
308 | - { |
|
309 | - if(!$this->isAccountVerified()) |
|
310 | - { |
|
311 | - $this->showCaptcha(); |
|
312 | - } |
|
247 | + if(isset($verified->status_code)) |
|
248 | + { |
|
249 | + return $verified->status_code; |
|
250 | + } |
|
251 | + return $verified['verified']; |
|
252 | + } |
|
313 | 253 | |
314 | - $accountCreator = new SendJodel(); |
|
254 | + //ToDo Spider Check |
|
255 | + function votePostId($postId, $vote) |
|
256 | + { |
|
257 | + if(!$this->isBot) |
|
258 | + { |
|
259 | + if(!$this->isAccountVerified()) |
|
260 | + { |
|
261 | + $view = new View(); |
|
262 | + $this->showCaptcha(); |
|
263 | + } |
|
264 | + |
|
265 | + if(!$this->hasVoted($postId)) |
|
266 | + { |
|
267 | + if($vote == "up") |
|
268 | + { |
|
269 | + $accountCreator = new Upvote(); |
|
270 | + } |
|
271 | + else if($vote == "down") |
|
272 | + { |
|
273 | + $accountCreator = new Downvote(); |
|
274 | + } |
|
275 | + |
|
276 | + $accountCreator->setAccessToken($this->accessToken); |
|
277 | + $accountCreator->postId = htmlspecialchars($postId); |
|
278 | + $data = $accountCreator->execute(); |
|
279 | + |
|
280 | + error_log('Could not vote: ' . print_r($data, true)); |
|
281 | + |
|
282 | + if(array_key_exists('post', $data)) |
|
283 | + { |
|
284 | + $this->addVoteWithPostIdAndType($postId, $vote); |
|
285 | + return TRUE; |
|
286 | + } |
|
287 | + else if(array_key_exists('error', $data)) |
|
288 | + { |
|
289 | + error_log('Could not vote - Error: ' . $data['error']); |
|
290 | + } |
|
291 | + else |
|
292 | + { |
|
293 | + error_log('Could not vote: ' . print_r($data, true)); |
|
294 | + return FALSE; |
|
295 | + } |
|
296 | + } |
|
297 | + else |
|
298 | + { |
|
299 | + return FALSE; |
|
300 | + } |
|
301 | + } |
|
315 | 302 | |
316 | - if(isset($_POST['ancestor'])) |
|
317 | - { |
|
318 | - $ancestor = $_POST['ancestor']; |
|
319 | - $accountCreator->ancestor = $ancestor; |
|
320 | - } |
|
321 | - if(isset($_POST['color'])) |
|
322 | - { |
|
323 | - $color = $_POST['color']; |
|
324 | - switch ($color) { |
|
325 | - case '8ABDB0': |
|
326 | - $color = '8ABDB0'; |
|
327 | - break; |
|
328 | - case '9EC41C': |
|
329 | - $color = '9EC41C'; |
|
330 | - break; |
|
331 | - case '06A3CB': |
|
332 | - $color = '06A3CB'; |
|
333 | - break; |
|
334 | - case 'FFBA00': |
|
335 | - $color = 'FFBA00'; |
|
336 | - break; |
|
337 | - case 'DD5F5F': |
|
338 | - $color = 'DD5F5F'; |
|
339 | - break; |
|
340 | - case 'FF9908': |
|
341 | - $color = 'FF9908'; |
|
342 | - break; |
|
343 | - default: |
|
344 | - $color = '8ABDB0'; |
|
345 | - break; |
|
346 | - } |
|
347 | - $accountCreator->color = $color; |
|
348 | - } |
|
349 | - |
|
350 | - $accountCreatorLocation = new UpdateLocation(); |
|
351 | - $accountCreatorLocation->setLocation($location); |
|
352 | - $accountCreatorLocation->setAccessToken($this->accessToken); |
|
353 | - $data = $accountCreatorLocation->execute(); |
|
303 | + return FALSE; |
|
304 | + } |
|
305 | + |
|
306 | + //ToDo Spider Check |
|
307 | + function sendJodel($location, $view) |
|
308 | + { |
|
309 | + if(!$this->isAccountVerified()) |
|
310 | + { |
|
311 | + $this->showCaptcha(); |
|
312 | + } |
|
313 | + |
|
314 | + $accountCreator = new SendJodel(); |
|
315 | + |
|
316 | + if(isset($_POST['ancestor'])) |
|
317 | + { |
|
318 | + $ancestor = $_POST['ancestor']; |
|
319 | + $accountCreator->ancestor = $ancestor; |
|
320 | + } |
|
321 | + if(isset($_POST['color'])) |
|
322 | + { |
|
323 | + $color = $_POST['color']; |
|
324 | + switch ($color) { |
|
325 | + case '8ABDB0': |
|
326 | + $color = '8ABDB0'; |
|
327 | + break; |
|
328 | + case '9EC41C': |
|
329 | + $color = '9EC41C'; |
|
330 | + break; |
|
331 | + case '06A3CB': |
|
332 | + $color = '06A3CB'; |
|
333 | + break; |
|
334 | + case 'FFBA00': |
|
335 | + $color = 'FFBA00'; |
|
336 | + break; |
|
337 | + case 'DD5F5F': |
|
338 | + $color = 'DD5F5F'; |
|
339 | + break; |
|
340 | + case 'FF9908': |
|
341 | + $color = 'FF9908'; |
|
342 | + break; |
|
343 | + default: |
|
344 | + $color = '8ABDB0'; |
|
345 | + break; |
|
346 | + } |
|
347 | + $accountCreator->color = $color; |
|
348 | + } |
|
349 | + |
|
350 | + $accountCreatorLocation = new UpdateLocation(); |
|
351 | + $accountCreatorLocation->setLocation($location); |
|
352 | + $accountCreatorLocation->setAccessToken($this->accessToken); |
|
353 | + $data = $accountCreatorLocation->execute(); |
|
354 | 354 | |
355 | 355 | if($data != 'Success') |
356 | 356 | { |
357 | 357 | error_log('Could not set location befor Post: ' . print_r($data, true)); |
358 | 358 | } |
359 | 359 | |
360 | - $accountCreator->location = $this->location; |
|
360 | + $accountCreator->location = $this->location; |
|
361 | 361 | |
362 | - $image = ''; |
|
363 | - if(isset($_FILES['image']) && $_FILES['image']['size'] > 0) |
|
364 | - { |
|
365 | - $image = file_get_contents($_FILES['image']['tmp_name']); |
|
366 | - } |
|
362 | + $image = ''; |
|
363 | + if(isset($_FILES['image']) && $_FILES['image']['size'] > 0) |
|
364 | + { |
|
365 | + $image = file_get_contents($_FILES['image']['tmp_name']); |
|
366 | + } |
|
367 | 367 | |
368 | - $accountCreator->image = $image; |
|
368 | + $accountCreator->image = $image; |
|
369 | 369 | |
370 | - $accountCreator->setAccessToken($this->accessToken); |
|
371 | - $data = $accountCreator->execute(); |
|
370 | + $accountCreator->setAccessToken($this->accessToken); |
|
371 | + $data = $accountCreator->execute(); |
|
372 | 372 | |
373 | - error_log(print_r($data, true)); |
|
373 | + error_log(print_r($data, true)); |
|
374 | 374 | |
375 | - if(isset($_POST['ancestor'])) |
|
376 | - { |
|
377 | - header('Location: ' . $view->toUrl()); |
|
378 | - exit; |
|
379 | - } |
|
380 | - else |
|
381 | - { |
|
382 | - header('Location: ' . $view->baseUrl); |
|
383 | - exit; |
|
384 | - } |
|
385 | - } |
|
375 | + if(isset($_POST['ancestor'])) |
|
376 | + { |
|
377 | + header('Location: ' . $view->toUrl()); |
|
378 | + exit; |
|
379 | + } |
|
380 | + else |
|
381 | + { |
|
382 | + header('Location: ' . $view->baseUrl); |
|
383 | + exit; |
|
384 | + } |
|
385 | + } |
|
386 | 386 | |
387 | - function isTokenFresh() |
|
388 | - { |
|
389 | - $db = new DatabaseConnect(); |
|
390 | - $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'"); |
|
387 | + function isTokenFresh() |
|
388 | + { |
|
389 | + $db = new DatabaseConnect(); |
|
390 | + $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'"); |
|
391 | 391 | |
392 | - if ($result->num_rows > 0) |
|
393 | - { |
|
394 | - // output data of each row |
|
395 | - while($row = $result->fetch_assoc()) |
|
396 | - { |
|
397 | - $expiration_date = $row["expiration_date"]; |
|
398 | - } |
|
399 | - } |
|
400 | - else |
|
401 | - { |
|
402 | - error_log('0 results'); |
|
403 | - } |
|
392 | + if ($result->num_rows > 0) |
|
393 | + { |
|
394 | + // output data of each row |
|
395 | + while($row = $result->fetch_assoc()) |
|
396 | + { |
|
397 | + $expiration_date = $row["expiration_date"]; |
|
398 | + } |
|
399 | + } |
|
400 | + else |
|
401 | + { |
|
402 | + error_log('0 results'); |
|
403 | + } |
|
404 | 404 | |
405 | - if($expiration_date <= time()) |
|
406 | - { |
|
407 | - return FALSE; |
|
408 | - } |
|
405 | + if($expiration_date <= time()) |
|
406 | + { |
|
407 | + return FALSE; |
|
408 | + } |
|
409 | 409 | |
410 | - return TRUE; |
|
411 | - } |
|
412 | - |
|
413 | - function refreshToken() |
|
414 | - { |
|
415 | - $accountCreator = new CreateUser(); |
|
416 | - $accountCreator->setAccessToken($this->accessToken); |
|
417 | - $accountCreator->setDeviceUid($this->deviceUid); |
|
418 | - $accountCreator->setLocation($this->location); |
|
419 | - $data = $accountCreator->execute(); |
|
420 | - |
|
421 | - $access_token = (string)$data[0]['access_token']; |
|
422 | - $expiration_date = $data[0]['expiration_date']; |
|
423 | - $device_uid = (string)$data[1]; |
|
410 | + return TRUE; |
|
411 | + } |
|
412 | + |
|
413 | + function refreshToken() |
|
414 | + { |
|
415 | + $accountCreator = new CreateUser(); |
|
416 | + $accountCreator->setAccessToken($this->accessToken); |
|
417 | + $accountCreator->setDeviceUid($this->deviceUid); |
|
418 | + $accountCreator->setLocation($this->location); |
|
419 | + $data = $accountCreator->execute(); |
|
420 | + |
|
421 | + $access_token = (string)$data[0]['access_token']; |
|
422 | + $expiration_date = $data[0]['expiration_date']; |
|
423 | + $device_uid = (string)$data[1]; |
|
424 | 424 | |
425 | - $db = new DatabaseConnect(); |
|
426 | - $result = $db->query("UPDATE accounts |
|
425 | + $db = new DatabaseConnect(); |
|
426 | + $result = $db->query("UPDATE accounts |
|
427 | 427 | SET access_token='" . $access_token . "', |
428 | 428 | expiration_date='" . $expiration_date . "' |
429 | 429 | WHERE device_uid='" . $device_uid . "'"); |
430 | 430 | |
431 | - if($result === false){ |
|
432 | - error_log("Adding account failed: (" . $db->errno . ") " . $db->error); |
|
433 | - } |
|
434 | - } |
|
431 | + if($result === false){ |
|
432 | + error_log("Adding account failed: (" . $db->errno . ") " . $db->error); |
|
433 | + } |
|
434 | + } |
|
435 | 435 | |
436 | 436 | |
437 | 437 | |
438 | - function getAccessToken() |
|
439 | - { |
|
440 | - $db = new DatabaseConnect(); |
|
441 | - $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'"); |
|
438 | + function getAccessToken() |
|
439 | + { |
|
440 | + $db = new DatabaseConnect(); |
|
441 | + $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'"); |
|
442 | 442 | |
443 | - $accessToken; |
|
443 | + $accessToken; |
|
444 | 444 | |
445 | - if ($result->num_rows > 0) |
|
446 | - { |
|
447 | - // output data of each row |
|
448 | - while($row = $result->fetch_assoc()) |
|
449 | - { |
|
450 | - $accessToken = $row['access_token']; |
|
451 | - } |
|
452 | - } |
|
453 | - else |
|
454 | - { |
|
455 | - error_log('Error: 0 results'); |
|
456 | - } |
|
445 | + if ($result->num_rows > 0) |
|
446 | + { |
|
447 | + // output data of each row |
|
448 | + while($row = $result->fetch_assoc()) |
|
449 | + { |
|
450 | + $accessToken = $row['access_token']; |
|
451 | + } |
|
452 | + } |
|
453 | + else |
|
454 | + { |
|
455 | + error_log('Error: 0 results'); |
|
456 | + } |
|
457 | 457 | |
458 | - return $accessToken; |
|
459 | - } |
|
458 | + return $accessToken; |
|
459 | + } |
|
460 | 460 | |
461 | 461 | |
462 | - function getKarma() |
|
463 | - { |
|
464 | - $accountCreator = new GetKarma(); |
|
465 | - $accountCreator->setAccessToken($this->accessToken); |
|
466 | - $data = $accountCreator->execute(); |
|
462 | + function getKarma() |
|
463 | + { |
|
464 | + $accountCreator = new GetKarma(); |
|
465 | + $accountCreator->setAccessToken($this->accessToken); |
|
466 | + $data = $accountCreator->execute(); |
|
467 | 467 | |
468 | - return $data['karma']; |
|
469 | - } |
|
468 | + return $data['karma']; |
|
469 | + } |
|
470 | 470 | |
471 | - function hasVoted($postId) |
|
472 | - { |
|
473 | - $db = new DatabaseConnect(); |
|
471 | + function hasVoted($postId) |
|
472 | + { |
|
473 | + $db = new DatabaseConnect(); |
|
474 | 474 | |
475 | - $postId = $db->real_escape_string($postId); |
|
475 | + $postId = $db->real_escape_string($postId); |
|
476 | 476 | |
477 | - $result = $db->query("SELECT id FROM votes WHERE (postId = '" . $postId . "' AND device_uid = '" . $this->deviceUid . "')"); |
|
477 | + $result = $db->query("SELECT id FROM votes WHERE (postId = '" . $postId . "' AND device_uid = '" . $this->deviceUid . "')"); |
|
478 | 478 | |
479 | - if($result === false) |
|
480 | - { |
|
481 | - $error = db_error(); |
|
482 | - echo $error; |
|
483 | - error_log("Adding Vote failed: (" . $result->errno . ") " . $result->error); |
|
484 | - } |
|
479 | + if($result === false) |
|
480 | + { |
|
481 | + $error = db_error(); |
|
482 | + echo $error; |
|
483 | + error_log("Adding Vote failed: (" . $result->errno . ") " . $result->error); |
|
484 | + } |
|
485 | 485 | |
486 | - if($result->num_rows == 0) |
|
487 | - { |
|
488 | - return FALSE; |
|
489 | - } |
|
490 | - else |
|
491 | - { |
|
492 | - return TRUE; |
|
493 | - } |
|
494 | - } |
|
486 | + if($result->num_rows == 0) |
|
487 | + { |
|
488 | + return FALSE; |
|
489 | + } |
|
490 | + else |
|
491 | + { |
|
492 | + return TRUE; |
|
493 | + } |
|
494 | + } |
|
495 | 495 | |
496 | - function addVoteWithPostIdAndType($postId, $voteType) |
|
497 | - { |
|
498 | - $db = new DatabaseConnect(); |
|
496 | + function addVoteWithPostIdAndType($postId, $voteType) |
|
497 | + { |
|
498 | + $db = new DatabaseConnect(); |
|
499 | 499 | |
500 | - $postId = $db->real_escape_string($postId); |
|
501 | - $voteType = $db->real_escape_string($voteType); |
|
500 | + $postId = $db->real_escape_string($postId); |
|
501 | + $voteType = $db->real_escape_string($voteType); |
|
502 | 502 | |
503 | - if($this->hasVoted($postId)) |
|
504 | - { |
|
505 | - return "Already voted"; |
|
506 | - } |
|
503 | + if($this->hasVoted($postId)) |
|
504 | + { |
|
505 | + return "Already voted"; |
|
506 | + } |
|
507 | 507 | |
508 | - $result = $db->query("INSERT INTO votes (device_uid, postId, type) |
|
508 | + $result = $db->query("INSERT INTO votes (device_uid, postId, type) |
|
509 | 509 | VALUES ('" . $this->deviceUid . "','" . $postId . "','" . $voteType . "')"); |
510 | 510 | |
511 | - if($result === false){ |
|
512 | - $error = db_error(); |
|
513 | - echo $error; |
|
514 | - echo "Adding Vote failed: (" . $result->errno . ") " . $result->error; |
|
515 | - } |
|
516 | - } |
|
517 | - |
|
518 | - function registerAccount($location) { |
|
519 | - $accountCreator = new CreateUser(); |
|
520 | - $accountCreator->setLocation($location); |
|
521 | - $data = $accountCreator->execute(); |
|
511 | + if($result === false){ |
|
512 | + $error = db_error(); |
|
513 | + echo $error; |
|
514 | + echo "Adding Vote failed: (" . $result->errno . ") " . $result->error; |
|
515 | + } |
|
516 | + } |
|
517 | + |
|
518 | + function registerAccount($location) { |
|
519 | + $accountCreator = new CreateUser(); |
|
520 | + $accountCreator->setLocation($location); |
|
521 | + $data = $accountCreator->execute(); |
|
522 | 522 | |
523 | - $access_token = (string)$data[0]['access_token']; |
|
524 | - $refresh_token = (string)$data[0]['refresh_token']; |
|
525 | - $token_type = (string)$data[0]['token_type']; |
|
526 | - $expires_in = $data[0]['expires_in']; |
|
527 | - $expiration_date = $data[0]['expiration_date']; |
|
528 | - $distinct_id = (string)$data[0]['distinct_id']; |
|
529 | - $device_uid = (string)$data[1]; |
|
530 | - |
|
531 | - $name = $location->cityName; |
|
532 | - $lat = $location->lat; |
|
533 | - $lng = $location->lng; |
|
523 | + $access_token = (string)$data[0]['access_token']; |
|
524 | + $refresh_token = (string)$data[0]['refresh_token']; |
|
525 | + $token_type = (string)$data[0]['token_type']; |
|
526 | + $expires_in = $data[0]['expires_in']; |
|
527 | + $expiration_date = $data[0]['expiration_date']; |
|
528 | + $distinct_id = (string)$data[0]['distinct_id']; |
|
529 | + $device_uid = (string)$data[1]; |
|
530 | + |
|
531 | + $name = $location->cityName; |
|
532 | + $lat = $location->lat; |
|
533 | + $lng = $location->lng; |
|
534 | 534 | |
535 | - $db = new DatabaseConnect(); |
|
536 | - $result = $db->query("INSERT INTO accounts (access_token, refresh_token, token_type, |
|
535 | + $db = new DatabaseConnect(); |
|
536 | + $result = $db->query("INSERT INTO accounts (access_token, refresh_token, token_type, |
|
537 | 537 | expires_in, expiration_date, distinct_id, device_uid, name, lat, lng) |
538 | 538 | VALUES ('" . $access_token . "','" . $refresh_token . "','" . $token_type . |
539 | - "','" . $expires_in . "','" . $expiration_date . "','" . $distinct_id . |
|
540 | - "','" . $device_uid . "','" . $name . "','" . $lat . "','" . $lng . "') "); |
|
541 | - |
|
542 | - $success = TRUE; |
|
543 | - if($result === false){ |
|
544 | - $error = $db->error(); |
|
545 | - echo $error; |
|
546 | - echo "Adding account failed: (" . $result->errno . ") " . $result->error; |
|
547 | - $success = FALSE; |
|
548 | - } |
|
539 | + "','" . $expires_in . "','" . $expiration_date . "','" . $distinct_id . |
|
540 | + "','" . $device_uid . "','" . $name . "','" . $lat . "','" . $lng . "') "); |
|
541 | + |
|
542 | + $success = TRUE; |
|
543 | + if($result === false){ |
|
544 | + $error = $db->error(); |
|
545 | + echo $error; |
|
546 | + echo "Adding account failed: (" . $result->errno . ") " . $result->error; |
|
547 | + $success = FALSE; |
|
548 | + } |
|
549 | 549 | |
550 | - return $device_uid; |
|
551 | - } |
|
550 | + return $device_uid; |
|
551 | + } |
|
552 | 552 | |
553 | - function createAccount() |
|
554 | - { |
|
555 | - $config = parse_ini_file('config/config.ini.php'); |
|
556 | - $location = new Location(); |
|
557 | - $location->setLat($config['default_lat']); |
|
558 | - $location->setLng($config['default_lng']); |
|
559 | - $location->setCityName($config['default_location']); |
|
553 | + function createAccount() |
|
554 | + { |
|
555 | + $config = parse_ini_file('config/config.ini.php'); |
|
556 | + $location = new Location(); |
|
557 | + $location->setLat($config['default_lat']); |
|
558 | + $location->setLng($config['default_lng']); |
|
559 | + $location->setCityName($config['default_location']); |
|
560 | 560 | |
561 | - $deviceUid = $this->registerAccount($location); |
|
561 | + $deviceUid = $this->registerAccount($location); |
|
562 | 562 | |
563 | - return $deviceUid; |
|
564 | - } |
|
563 | + return $deviceUid; |
|
564 | + } |
|
565 | 565 | } |
566 | 566 | \ No newline at end of file |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | { |
36 | 36 | $this->refreshToken(); |
37 | 37 | } |
38 | - $this->accessToken = $this->getAccessToken(); |
|
38 | + $this->accessToken = $this->getAccessToken(); |
|
39 | 39 | |
40 | 40 | /* if($this->isAccountVerified() != 1) |
41 | 41 | { |
@@ -106,11 +106,11 @@ discard block |
||
106 | 106 | } |
107 | 107 | |
108 | 108 | $db = new DatabaseConnect(); |
109 | - $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'"); |
|
109 | + $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'"); |
|
110 | 110 | |
111 | 111 | $location = new Location(); |
112 | 112 | |
113 | - if ($result->num_rows > 0) |
|
113 | + if($result->num_rows > 0) |
|
114 | 114 | { |
115 | 115 | // output data of each row |
116 | 116 | while($row = $result->fetch_assoc()) |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | } |
183 | 183 | else |
184 | 184 | { |
185 | - user_log('User with JodelDeviceId:' . $this->deviceUid . ' [' . $_SERVER['REMOTE_ADDR'] . '][' . $_SERVER ['HTTP_USER_AGENT'] . '] changed to Location: ' . $name); |
|
185 | + user_log('User with JodelDeviceId:' . $this->deviceUid . ' [' . $_SERVER['REMOTE_ADDR'] . '][' . $_SERVER ['HTTP_USER_AGENT'] . '] changed to Location: ' . $name); |
|
186 | 186 | } |
187 | 187 | } |
188 | 188 | |
@@ -194,11 +194,11 @@ discard block |
||
194 | 194 | function getLocation() |
195 | 195 | { |
196 | 196 | $db = new DatabaseConnect(); |
197 | - $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'"); |
|
197 | + $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'"); |
|
198 | 198 | |
199 | 199 | $location = new Location(); |
200 | 200 | |
201 | - if ($result->num_rows > 0) |
|
201 | + if($result->num_rows > 0) |
|
202 | 202 | { |
203 | 203 | // output data of each row |
204 | 204 | while($row = $result->fetch_assoc()) |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | if(isset($_POST['color'])) |
322 | 322 | { |
323 | 323 | $color = $_POST['color']; |
324 | - switch ($color) { |
|
324 | + switch($color) { |
|
325 | 325 | case '8ABDB0': |
326 | 326 | $color = '8ABDB0'; |
327 | 327 | break; |
@@ -389,7 +389,7 @@ discard block |
||
389 | 389 | $db = new DatabaseConnect(); |
390 | 390 | $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'"); |
391 | 391 | |
392 | - if ($result->num_rows > 0) |
|
392 | + if($result->num_rows > 0) |
|
393 | 393 | { |
394 | 394 | // output data of each row |
395 | 395 | while($row = $result->fetch_assoc()) |
@@ -428,7 +428,7 @@ discard block |
||
428 | 428 | expiration_date='" . $expiration_date . "' |
429 | 429 | WHERE device_uid='" . $device_uid . "'"); |
430 | 430 | |
431 | - if($result === false){ |
|
431 | + if($result === false) { |
|
432 | 432 | error_log("Adding account failed: (" . $db->errno . ") " . $db->error); |
433 | 433 | } |
434 | 434 | } |
@@ -438,11 +438,11 @@ discard block |
||
438 | 438 | function getAccessToken() |
439 | 439 | { |
440 | 440 | $db = new DatabaseConnect(); |
441 | - $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'"); |
|
441 | + $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'"); |
|
442 | 442 | |
443 | 443 | $accessToken; |
444 | 444 | |
445 | - if ($result->num_rows > 0) |
|
445 | + if($result->num_rows > 0) |
|
446 | 446 | { |
447 | 447 | // output data of each row |
448 | 448 | while($row = $result->fetch_assoc()) |
@@ -508,7 +508,7 @@ discard block |
||
508 | 508 | $result = $db->query("INSERT INTO votes (device_uid, postId, type) |
509 | 509 | VALUES ('" . $this->deviceUid . "','" . $postId . "','" . $voteType . "')"); |
510 | 510 | |
511 | - if($result === false){ |
|
511 | + if($result === false) { |
|
512 | 512 | $error = db_error(); |
513 | 513 | echo $error; |
514 | 514 | echo "Adding Vote failed: (" . $result->errno . ") " . $result->error; |
@@ -536,11 +536,11 @@ discard block |
||
536 | 536 | $result = $db->query("INSERT INTO accounts (access_token, refresh_token, token_type, |
537 | 537 | expires_in, expiration_date, distinct_id, device_uid, name, lat, lng) |
538 | 538 | VALUES ('" . $access_token . "','" . $refresh_token . "','" . $token_type . |
539 | - "','" . $expires_in . "','" . $expiration_date . "','" . $distinct_id . |
|
539 | + "','" . $expires_in . "','" . $expiration_date . "','" . $distinct_id . |
|
540 | 540 | "','" . $device_uid . "','" . $name . "','" . $lat . "','" . $lng . "') "); |
541 | 541 | |
542 | 542 | $success = TRUE; |
543 | - if($result === false){ |
|
543 | + if($result === false) { |
|
544 | 544 | $error = $db->error(); |
545 | 545 | echo $error; |
546 | 546 | echo "Adding account failed: (" . $result->errno . ") " . $result->error; |
@@ -2,107 +2,107 @@ 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; |
|
9 | + public $postId; |
|
10 | + public $isDetailedView; |
|
11 | + public $baseUrl; |
|
12 | 12 | |
13 | 13 | public $lastPostId = ''; |
14 | 14 | |
15 | - function __construct($baseUrl, $country, $city, $hashtag = '%23all', $view = 'time', $postId = '') |
|
16 | - { |
|
17 | - $this->baseUrl = $baseUrl; |
|
18 | - $this->country = $country; |
|
19 | - $this->city = $city; |
|
20 | - $this->hashtag = urldecode($hashtag); |
|
21 | - $this->view = $view; |
|
22 | - $this->postId = $postId; |
|
15 | + function __construct($baseUrl, $country, $city, $hashtag = '%23all', $view = 'time', $postId = '') |
|
16 | + { |
|
17 | + $this->baseUrl = $baseUrl; |
|
18 | + $this->country = $country; |
|
19 | + $this->city = $city; |
|
20 | + $this->hashtag = urldecode($hashtag); |
|
21 | + $this->view = $view; |
|
22 | + $this->postId = $postId; |
|
23 | 23 | |
24 | - if($postId == '') |
|
25 | - { |
|
26 | - $this->isDetailedView = FALSE; |
|
27 | - } |
|
28 | - else |
|
29 | - { |
|
30 | - $this->isDetailedView = TRUE; |
|
31 | - } |
|
32 | - } |
|
24 | + if($postId == '') |
|
25 | + { |
|
26 | + $this->isDetailedView = FALSE; |
|
27 | + } |
|
28 | + else |
|
29 | + { |
|
30 | + $this->isDetailedView = TRUE; |
|
31 | + } |
|
32 | + } |
|
33 | 33 | /** |
34 | 34 | * Compute HTML Code |
35 | 35 | */ |
36 | 36 | function jodelToHtml($post) |
37 | - { //ToDO |
|
38 | - //Replace # with link |
|
39 | - //preg_replace('~(\#)([^\s!,. /()"\'?]+)~', '<a href="tag/$2">#$2</a>', $text); |
|
37 | + { //ToDO |
|
38 | + //Replace # with link |
|
39 | + //preg_replace('~(\#)([^\s!,. /()"\'?]+)~', '<a href="tag/$2">#$2</a>', $text); |
|
40 | 40 | |
41 | - //Time to time difference |
|
42 | - $now = new DateTime(); |
|
43 | - $d = new DateTime($post['created_at']); |
|
44 | - $timediff = $now->diff($d); |
|
41 | + //Time to time difference |
|
42 | + $now = new DateTime(); |
|
43 | + $d = new DateTime($post['created_at']); |
|
44 | + $timediff = $now->diff($d); |
|
45 | 45 | |
46 | - $timediff_inSeconds = (string)$timediff->format('%s'); |
|
47 | - $timediff_inMinutes = (string)$timediff->format('%i'); |
|
48 | - $timediff_inHours = (string)$timediff->format('%h'); |
|
49 | - $timediff_inDays = (string)$timediff->format('%d'); |
|
50 | - $timediff_inMonth = (string)$timediff->format('%m'); |
|
46 | + $timediff_inSeconds = (string)$timediff->format('%s'); |
|
47 | + $timediff_inMinutes = (string)$timediff->format('%i'); |
|
48 | + $timediff_inHours = (string)$timediff->format('%h'); |
|
49 | + $timediff_inDays = (string)$timediff->format('%d'); |
|
50 | + $timediff_inMonth = (string)$timediff->format('%m'); |
|
51 | 51 | |
52 | - if($timediff_inMonth!=0) |
|
53 | - { |
|
54 | - $timediff = $timediff_inMonth . "m"; |
|
55 | - } |
|
56 | - else |
|
57 | - { |
|
58 | - if($timediff_inDays!=0) |
|
59 | - { |
|
60 | - $timediff = $timediff_inDays . "d"; |
|
61 | - } |
|
62 | - else |
|
63 | - { |
|
64 | - if($timediff_inHours!=0) |
|
65 | - { |
|
66 | - $timediff = $timediff_inHours . "h"; |
|
67 | - } |
|
68 | - else |
|
69 | - { |
|
70 | - if($timediff_inMinutes!=0) |
|
71 | - { |
|
72 | - $timediff = $timediff_inMinutes . "m"; |
|
73 | - } |
|
74 | - else |
|
75 | - { |
|
76 | - $timediff = $timediff_inSeconds . "s"; |
|
77 | - } |
|
78 | - } |
|
79 | - } |
|
80 | - } |
|
52 | + if($timediff_inMonth!=0) |
|
53 | + { |
|
54 | + $timediff = $timediff_inMonth . "m"; |
|
55 | + } |
|
56 | + else |
|
57 | + { |
|
58 | + if($timediff_inDays!=0) |
|
59 | + { |
|
60 | + $timediff = $timediff_inDays . "d"; |
|
61 | + } |
|
62 | + else |
|
63 | + { |
|
64 | + if($timediff_inHours!=0) |
|
65 | + { |
|
66 | + $timediff = $timediff_inHours . "h"; |
|
67 | + } |
|
68 | + else |
|
69 | + { |
|
70 | + if($timediff_inMinutes!=0) |
|
71 | + { |
|
72 | + $timediff = $timediff_inMinutes . "m"; |
|
73 | + } |
|
74 | + else |
|
75 | + { |
|
76 | + $timediff = $timediff_inSeconds . "s"; |
|
77 | + } |
|
78 | + } |
|
79 | + } |
|
80 | + } |
|
81 | 81 | |
82 | 82 | |
83 | - ?> |
|
83 | + ?> |
|
84 | 84 | <article id ="postId-<?php echo $post['post_id']; ?>" class="jodel" style="background-color: #<?php echo $post['color'];?>;"> |
85 | 85 | <content> |
86 | 86 | <?php |
87 | - if(isset($post['image_url'])) |
|
88 | - { |
|
89 | - $regexRest = '/[^\w$ .!?-]+/u'; |
|
87 | + if(isset($post['image_url'])) |
|
88 | + { |
|
89 | + $regexRest = '/[^\w$ .!?-]+/u'; |
|
90 | 90 | |
91 | - echo '<img src="' . $post['image_url'] . '" alt="' . htmlspecialchars(preg_replace($regexRest, '', $post['message'])) . '">'; |
|
92 | - } |
|
93 | - else { |
|
94 | - echo str_replace(' ', ' ', nl2br(htmlspecialchars($post['message']))); |
|
95 | - } |
|
96 | - ?> |
|
91 | + echo '<img src="' . $post['image_url'] . '" alt="' . htmlspecialchars(preg_replace($regexRest, '', $post['message'])) . '">'; |
|
92 | + } |
|
93 | + else { |
|
94 | + echo str_replace(' ', ' ', nl2br(htmlspecialchars($post['message']))); |
|
95 | + } |
|
96 | + ?> |
|
97 | 97 | </content> |
98 | 98 | <aside> |
99 | 99 | <?php |
100 | - if($this->isDetailedView) |
|
101 | - {?> |
|
100 | + if($this->isDetailedView) |
|
101 | + {?> |
|
102 | 102 | <a href="index.php?vote=up&getPostDetails=true&postId=<?php echo $post['post_id'];?>&postId_parent=<?php echo htmlspecialchars($_GET['postId']);?>" rel="nofollow"> |
103 | 103 | <?php } |
104 | - else |
|
105 | - {?> |
|
104 | + else |
|
105 | + {?> |
|
106 | 106 | <a href="index.php?vote=up&postId=<?php echo $post['post_id'];?>" rel="nofollow"> |
107 | 107 | <?php } ?> |
108 | 108 | <i class="fa fa-angle-up fa-3x"></i> |
@@ -110,12 +110,12 @@ discard block |
||
110 | 110 | <br /> |
111 | 111 | <?php echo $post["vote_count"];?><br /> |
112 | 112 | <?php |
113 | - if($this->isDetailedView) |
|
114 | - {?> |
|
113 | + if($this->isDetailedView) |
|
114 | + {?> |
|
115 | 115 | <a href="index.php?vote=down&getPostDetails=true&postId=<?php echo $post['post_id'];?>&postId_parent=<?php echo htmlspecialchars($_GET['postId']);?>" rel="nofollow"> |
116 | 116 | <?php } |
117 | - else |
|
118 | - {?> |
|
117 | + else |
|
118 | + {?> |
|
119 | 119 | <a href="index.php?vote=down&postId=<?php echo $post['post_id'];?>" rel="nofollow"> |
120 | 120 | <?php } ?> |
121 | 121 | <i class="fa fa-angle-down fa-3x"></i> |
@@ -138,9 +138,9 @@ discard block |
||
138 | 138 | <a href="<?php echo $this->changePostId($post['post_id'])->toUrl();?>"> |
139 | 139 | <i class="fa fa-commenting-o"></i> |
140 | 140 | <?php if(array_key_exists("child_count", $post)) { |
141 | - echo $post["child_count"]; |
|
142 | - } else echo "0"; |
|
143 | - ?> |
|
141 | + echo $post["child_count"]; |
|
142 | + } else echo "0"; |
|
143 | + ?> |
|
144 | 144 | </a> |
145 | 145 | </span> |
146 | 146 | |
@@ -160,30 +160,30 @@ discard block |
||
160 | 160 | ?> |
161 | 161 | <span class="distance"> |
162 | 162 | <?php |
163 | - if($this->isDetailedView) |
|
164 | - { |
|
165 | - if(isset($post["parent_creator"]) && $post["parent_creator"] == 1) |
|
166 | - { |
|
167 | - ?> |
|
163 | + if($this->isDetailedView) |
|
164 | + { |
|
165 | + if(isset($post["parent_creator"]) && $post["parent_creator"] == 1) |
|
166 | + { |
|
167 | + ?> |
|
168 | 168 | <span data-tooltip="Author"> |
169 | 169 | <i class="fa fa-user-o"></i> OJ | |
170 | 170 | </span> |
171 | 171 | <?php |
172 | - } |
|
173 | - else |
|
174 | - { |
|
175 | - //Is not parent Jodel in detailed View |
|
176 | - if(!array_key_exists('child_count', $post) && array_key_exists('parent_creator', $post)) |
|
177 | - { |
|
178 | - ?> |
|
172 | + } |
|
173 | + else |
|
174 | + { |
|
175 | + //Is not parent Jodel in detailed View |
|
176 | + if(!array_key_exists('child_count', $post) && array_key_exists('parent_creator', $post)) |
|
177 | + { |
|
178 | + ?> |
|
179 | 179 | <span data-tooltip="Author"> |
180 | 180 | <i class="fa fa-user-o"></i> #<?php echo $post["user_handle"];?> | |
181 | 181 | </span> |
182 | 182 | <?php |
183 | - } |
|
184 | - } |
|
185 | - } |
|
186 | - ?> |
|
183 | + } |
|
184 | + } |
|
185 | + } |
|
186 | + ?> |
|
187 | 187 | |
188 | 188 | <span class="tip" data-tooltip="Distance"> |
189 | 189 | <i class="fa fa-map-marker"></i> |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | </footer> |
197 | 197 | </article> |
198 | 198 | <?php |
199 | - } |
|
199 | + } |
|
200 | 200 | |
201 | 201 | |
202 | 202 | /** |
@@ -233,135 +233,135 @@ discard block |
||
233 | 233 | return $description; |
234 | 234 | } |
235 | 235 | |
236 | - function toUrl() |
|
237 | - { |
|
238 | - $url = $this->baseUrl . 'index.php?country=DE' . |
|
239 | - '&city=' . urlencode($this->city) . |
|
240 | - '&hashtag=' . urlencode($this->hashtag) . |
|
241 | - '&view=' . $this->view; |
|
242 | - if($this->postId != '') |
|
243 | - { |
|
244 | - $url .= '&postId=' . $this->postId . |
|
245 | - '&getPostDetails=TRUE'; |
|
246 | - } |
|
236 | + function toUrl() |
|
237 | + { |
|
238 | + $url = $this->baseUrl . 'index.php?country=DE' . |
|
239 | + '&city=' . urlencode($this->city) . |
|
240 | + '&hashtag=' . urlencode($this->hashtag) . |
|
241 | + '&view=' . $this->view; |
|
242 | + if($this->postId != '') |
|
243 | + { |
|
244 | + $url .= '&postId=' . $this->postId . |
|
245 | + '&getPostDetails=TRUE'; |
|
246 | + } |
|
247 | 247 | |
248 | - return $url; |
|
249 | - } |
|
248 | + return $url; |
|
249 | + } |
|
250 | 250 | |
251 | - function changePostId($postId) |
|
252 | - { |
|
253 | - $tempView = clone $this; |
|
254 | - $tempView->postId = $postId; |
|
255 | - $tempView->isDetailedView = TRUE; |
|
256 | - return $tempView; |
|
257 | - } |
|
251 | + function changePostId($postId) |
|
252 | + { |
|
253 | + $tempView = clone $this; |
|
254 | + $tempView->postId = $postId; |
|
255 | + $tempView->isDetailedView = TRUE; |
|
256 | + return $tempView; |
|
257 | + } |
|
258 | 258 | |
259 | - function back() |
|
260 | - { |
|
261 | - $tempView = clone $this; |
|
262 | - $tempView->postId = ''; |
|
263 | - return $tempView; |
|
264 | - } |
|
259 | + function back() |
|
260 | + { |
|
261 | + $tempView = clone $this; |
|
262 | + $tempView->postId = ''; |
|
263 | + return $tempView; |
|
264 | + } |
|
265 | 265 | |
266 | - function changeView($view) |
|
267 | - { |
|
268 | - $tempView = clone $this; |
|
269 | - $tempView->view = $view; |
|
270 | - return $tempView; |
|
271 | - } |
|
266 | + function changeView($view) |
|
267 | + { |
|
268 | + $tempView = clone $this; |
|
269 | + $tempView->view = $view; |
|
270 | + return $tempView; |
|
271 | + } |
|
272 | 272 | |
273 | 273 | function getPosts($jodelAccount) |
274 | 274 | { |
275 | - if($this->hashtag != '#all' && $this->hashtag != '' && $this->hashtag != NULL) |
|
276 | - { |
|
277 | - $accountCreator = new GetChannel(); |
|
278 | - $accountCreator->view = $this->view; |
|
279 | - $accountCreator->setAccessToken($jodelAccount->accessToken); |
|
280 | - $accountCreator->channel = $this->hashtag; |
|
281 | - $accountCreator->lastPostId = $this->lastPostId; |
|
282 | - $data = $accountCreator->execute(); |
|
283 | - } |
|
284 | - else |
|
285 | - { |
|
286 | - if($this->lastPostId == '' && $this->view == 'combo') |
|
287 | - { |
|
288 | - $url = "/v3/posts/location/combo"; |
|
289 | - } |
|
290 | - else |
|
291 | - { |
|
292 | - if($this->view == 'discussed') |
|
293 | - { |
|
294 | - $url = "/v2/posts/location/discussed/"; |
|
295 | - } |
|
296 | - else |
|
297 | - { |
|
298 | - if($this->view == 'popular') |
|
299 | - { |
|
300 | - $url = "/v2/posts/location/popular/"; |
|
301 | - } |
|
302 | - else |
|
303 | - { |
|
304 | - $url = "/v2/posts/location/"; |
|
305 | - } |
|
306 | - } |
|
307 | - } |
|
275 | + if($this->hashtag != '#all' && $this->hashtag != '' && $this->hashtag != NULL) |
|
276 | + { |
|
277 | + $accountCreator = new GetChannel(); |
|
278 | + $accountCreator->view = $this->view; |
|
279 | + $accountCreator->setAccessToken($jodelAccount->accessToken); |
|
280 | + $accountCreator->channel = $this->hashtag; |
|
281 | + $accountCreator->lastPostId = $this->lastPostId; |
|
282 | + $data = $accountCreator->execute(); |
|
283 | + } |
|
284 | + else |
|
285 | + { |
|
286 | + if($this->lastPostId == '' && $this->view == 'combo') |
|
287 | + { |
|
288 | + $url = "/v3/posts/location/combo"; |
|
289 | + } |
|
290 | + else |
|
291 | + { |
|
292 | + if($this->view == 'discussed') |
|
293 | + { |
|
294 | + $url = "/v2/posts/location/discussed/"; |
|
295 | + } |
|
296 | + else |
|
297 | + { |
|
298 | + if($this->view == 'popular') |
|
299 | + { |
|
300 | + $url = "/v2/posts/location/popular/"; |
|
301 | + } |
|
302 | + else |
|
303 | + { |
|
304 | + $url = "/v2/posts/location/"; |
|
305 | + } |
|
306 | + } |
|
307 | + } |
|
308 | 308 | |
309 | - $accountCreator = new GetPosts(); |
|
310 | - $accountCreator->setLastPostId($this->lastPostId); |
|
311 | - $accountCreator->setAccessToken($jodelAccount->accessToken); |
|
312 | - $accountCreator->setUrl($url); |
|
313 | - $accountCreator->version = 'v3'; |
|
309 | + $accountCreator = new GetPosts(); |
|
310 | + $accountCreator->setLastPostId($this->lastPostId); |
|
311 | + $accountCreator->setAccessToken($jodelAccount->accessToken); |
|
312 | + $accountCreator->setUrl($url); |
|
313 | + $accountCreator->version = 'v3'; |
|
314 | 314 | |
315 | - $config = parse_ini_file('config/config.ini.php'); |
|
316 | - $location = new Location(); |
|
317 | - $location->setLat($config['default_lat']); |
|
318 | - $location->setLng($config['default_lng']); |
|
319 | - $location->setCityName($config['default_location']); |
|
320 | - $accountCreator->location = $location; |
|
321 | - $data = $accountCreator->execute(); |
|
322 | - } |
|
323 | - if(array_key_exists('recent', $data) && array_key_exists(0, $data['recent'])) |
|
324 | - { |
|
325 | - return $data['recent']; |
|
326 | - } |
|
327 | - else if(array_key_exists('posts', $data)&& array_key_exists(0, $data['posts'])) |
|
328 | - { |
|
329 | - return $data['posts']; |
|
330 | - } |
|
331 | - else |
|
332 | - { |
|
333 | - error_log('Could not find Posts in: ' . $this->city . ' Error: ' . print_r($data, true)); |
|
334 | - //error_log(print_r($data, true)); |
|
315 | + $config = parse_ini_file('config/config.ini.php'); |
|
316 | + $location = new Location(); |
|
317 | + $location->setLat($config['default_lat']); |
|
318 | + $location->setLng($config['default_lng']); |
|
319 | + $location->setCityName($config['default_location']); |
|
320 | + $accountCreator->location = $location; |
|
321 | + $data = $accountCreator->execute(); |
|
322 | + } |
|
323 | + if(array_key_exists('recent', $data) && array_key_exists(0, $data['recent'])) |
|
324 | + { |
|
325 | + return $data['recent']; |
|
326 | + } |
|
327 | + else if(array_key_exists('posts', $data)&& array_key_exists(0, $data['posts'])) |
|
328 | + { |
|
329 | + return $data['posts']; |
|
330 | + } |
|
331 | + else |
|
332 | + { |
|
333 | + error_log('Could not find Posts in: ' . $this->city . ' Error: ' . print_r($data, true)); |
|
334 | + //error_log(print_r($data, true)); |
|
335 | 335 | |
336 | - $notFound[0] = array( |
|
337 | - "post_id" => "0", |
|
338 | - "discovered_by" => 0, |
|
339 | - "message" => "No more Posts found", |
|
340 | - "created_at" => "2017-02-11T16:44:50.385Z", |
|
341 | - "updated_at" => "2017-02-11T16:44:50.385Z", |
|
342 | - "pin_count" => 0, |
|
343 | - "color" => "5682a3", |
|
344 | - "got_thanks" => FALSE, |
|
345 | - "post_own" => "friend", |
|
346 | - "discovered" => 0, |
|
347 | - "distance" => 9, |
|
348 | - "vote_count" => 0, |
|
349 | - "location" => |
|
350 | - array("name" => "Berlin", |
|
351 | - "loc_coordinates" => |
|
352 | - array( |
|
353 | - "lat" => 0, |
|
354 | - "lng" => 0 |
|
355 | - ), |
|
356 | - "loc_accuracy" => 0, |
|
357 | - "country" => "", |
|
358 | - "city" => "", |
|
359 | - ), |
|
360 | - "tags" => |
|
361 | - array(), |
|
362 | - "user_handle" => "0" |
|
363 | - ); |
|
364 | - return $notFound; |
|
365 | - } |
|
336 | + $notFound[0] = array( |
|
337 | + "post_id" => "0", |
|
338 | + "discovered_by" => 0, |
|
339 | + "message" => "No more Posts found", |
|
340 | + "created_at" => "2017-02-11T16:44:50.385Z", |
|
341 | + "updated_at" => "2017-02-11T16:44:50.385Z", |
|
342 | + "pin_count" => 0, |
|
343 | + "color" => "5682a3", |
|
344 | + "got_thanks" => FALSE, |
|
345 | + "post_own" => "friend", |
|
346 | + "discovered" => 0, |
|
347 | + "distance" => 9, |
|
348 | + "vote_count" => 0, |
|
349 | + "location" => |
|
350 | + array("name" => "Berlin", |
|
351 | + "loc_coordinates" => |
|
352 | + array( |
|
353 | + "lat" => 0, |
|
354 | + "lng" => 0 |
|
355 | + ), |
|
356 | + "loc_accuracy" => 0, |
|
357 | + "country" => "", |
|
358 | + "city" => "", |
|
359 | + ), |
|
360 | + "tags" => |
|
361 | + array(), |
|
362 | + "user_handle" => "0" |
|
363 | + ); |
|
364 | + return $notFound; |
|
365 | + } |
|
366 | 366 | } |
367 | 367 | } |
@@ -2,20 +2,20 @@ 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 | - { |
|
17 | + public function execute() |
|
18 | + { |
|
19 | 19 | $result = new \stdClass(); |
20 | 20 | |
21 | 21 | $this->payLoad = $this->getPayload(); |
@@ -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,95 +45,95 @@ 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 | - } |
|
73 | - switch ($result->status_code) { |
|
74 | - case 200: |
|
75 | - $result = json_decode($result->body, true); |
|
76 | - break; |
|
77 | - case 204: |
|
78 | - $result = 'Success'; |
|
79 | - break; |
|
80 | - case 400: |
|
81 | - $result = json_decode($result->body, true); |
|
82 | - error_log('Error 400 - ' . print_r($result, true)); |
|
83 | - break; |
|
84 | - case 401: |
|
85 | - $result = json_decode($result->body, true); |
|
86 | - error_log('Error 401 - ' . print_r($result, true)); |
|
87 | - break; |
|
88 | - case 404: |
|
89 | - error_log('Error 404 - ' . print_r($result, true)); |
|
90 | - $result = json_decode($result->body, true); |
|
91 | - break; |
|
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 | + switch ($result->status_code) { |
|
74 | + case 200: |
|
75 | + $result = json_decode($result->body, true); |
|
76 | + break; |
|
77 | + case 204: |
|
78 | + $result = 'Success'; |
|
79 | + break; |
|
80 | + case 400: |
|
81 | + $result = json_decode($result->body, true); |
|
82 | + error_log('Error 400 - ' . print_r($result, true)); |
|
83 | + break; |
|
84 | + case 401: |
|
85 | + $result = json_decode($result->body, true); |
|
86 | + error_log('Error 401 - ' . print_r($result, true)); |
|
87 | + break; |
|
88 | + case 404: |
|
89 | + error_log('Error 404 - ' . print_r($result, true)); |
|
90 | + $result = json_decode($result->body, true); |
|
91 | + break; |
|
92 | 92 | case 477: |
93 | - $result = json_decode($result->body, true); |
|
94 | - error_log('Error 477 - ' . print_r($result, true)); |
|
95 | - break; |
|
96 | - case 429: |
|
97 | - error_log('Error 429 - Too Many Requests' . print_r(json_decode($result->body, true), true)); |
|
98 | - exit("Error 429: Too Many Requests"); |
|
99 | - break; |
|
100 | - case 403: |
|
101 | - error_log('Error 403 - Access denied:' . print_r(json_decode($result->body, true), true)); |
|
102 | - $result = json_decode($result->body, true); |
|
103 | - break; |
|
104 | - case 503: |
|
105 | - error_log('Error 503 - ' . print_r($result, true)); |
|
106 | - $result = json_decode($result->body, true); |
|
93 | + $result = json_decode($result->body, true); |
|
94 | + error_log('Error 477 - ' . print_r($result, true)); |
|
95 | + break; |
|
96 | + case 429: |
|
97 | + error_log('Error 429 - Too Many Requests' . print_r(json_decode($result->body, true), true)); |
|
98 | + exit("Error 429: Too Many Requests"); |
|
99 | + break; |
|
100 | + case 403: |
|
101 | + error_log('Error 403 - Access denied:' . print_r(json_decode($result->body, true), true)); |
|
102 | + $result = json_decode($result->body, true); |
|
103 | + break; |
|
104 | + case 503: |
|
105 | + error_log('Error 503 - ' . print_r($result, true)); |
|
106 | + $result = json_decode($result->body, true); |
|
107 | 107 | |
108 | - if(array_key_exists('error', $result) && $result['error'] == 'Service Unavailable"') |
|
109 | - { |
|
110 | - header('location:'.$_SERVER['PHP_SELF']); |
|
111 | - } |
|
112 | - break; |
|
113 | - default: |
|
114 | - error_log('Error '.$result->status_code.' - Unauthorized'); |
|
115 | - $result = json_decode($result->body, true); |
|
116 | - } |
|
108 | + if(array_key_exists('error', $result) && $result['error'] == 'Service Unavailable"') |
|
109 | + { |
|
110 | + header('location:'.$_SERVER['PHP_SELF']); |
|
111 | + } |
|
112 | + break; |
|
113 | + default: |
|
114 | + error_log('Error '.$result->status_code.' - Unauthorized'); |
|
115 | + $result = json_decode($result->body, true); |
|
116 | + } |
|
117 | 117 | |
118 | - //important for account refresh |
|
119 | - if($device_uid != '') |
|
120 | - { |
|
118 | + //important for account refresh |
|
119 | + if($device_uid != '') |
|
120 | + { |
|
121 | 121 | $result[0] = $result; |
122 | 122 | $result[1] = $device_uid; |
123 | - } |
|
123 | + } |
|
124 | 124 | |
125 | 125 | |
126 | - /* var_dump($result); */ |
|
126 | + /* var_dump($result); */ |
|
127 | 127 | |
128 | - return $result; |
|
129 | - } |
|
130 | - abstract function getPayload(); |
|
131 | - /** |
|
132 | - * Gets Sign headers |
|
133 | - * @return array headers |
|
134 | - */ |
|
135 | - private function getSignHeaders() |
|
136 | - { |
|
128 | + return $result; |
|
129 | + } |
|
130 | + abstract function getPayload(); |
|
131 | + /** |
|
132 | + * Gets Sign headers |
|
133 | + * @return array headers |
|
134 | + */ |
|
135 | + private function getSignHeaders() |
|
136 | + { |
|
137 | 137 | if($this->getAccessToken() == null) { |
138 | 138 | $payload_accessToken = ""; |
139 | 139 | } |
@@ -142,54 +142,54 @@ discard block |
||
142 | 142 | } |
143 | 143 | |
144 | 144 | |
145 | - $headers = array( |
|
146 | - "Connection" => "keep-alive", |
|
147 | - "Accept-Encoding" => "gzip", |
|
148 | - "Content-Type" => "application/json; charset=UTF-8", |
|
149 | - "User-Agent" => self::USERAGENT |
|
150 | - ); |
|
151 | - $timestamp = new DateTime(); |
|
152 | - $timestamp = $timestamp->format(DateTime::ATOM); |
|
153 | - $timestamp = substr($timestamp, 0, -6); |
|
154 | - $timestamp .= "Z"; |
|
155 | - $urlParts = parse_url($this->getFullUrl()); |
|
156 | - $url2 = ""; |
|
157 | - $req = [$this->getMethod(), |
|
158 | - $urlParts['host'], |
|
159 | - "443", |
|
160 | - $urlParts['path'], |
|
161 | - $payload_accessToken, |
|
162 | - $timestamp, |
|
163 | - $url2, |
|
164 | - $this->payLoad]; |
|
165 | - $reqString = implode("%", $req); |
|
166 | - $secret = self::SECRET; |
|
167 | - $signature = hash_hmac('sha1', $reqString, $secret); |
|
168 | - $signature = strtoupper($signature); |
|
169 | - $headers['X-Authorization'] = 'HMAC ' . $signature; |
|
170 | - $headers['X-Client-Type'] = self::CLIENT_TYPE; |
|
171 | - $headers['X-Timestamp'] = $timestamp; |
|
172 | - $headers['X-Api-Version'] = '0.2'; |
|
173 | - return $headers; |
|
174 | - } |
|
175 | - private function getFullUrl() |
|
176 | - { |
|
177 | - return self::APIURL . $this->getApiEndPoint(); |
|
178 | - } |
|
179 | - abstract function getApiEndPoint(); |
|
180 | - abstract function getMethod(); |
|
181 | - /** |
|
182 | - * @return string |
|
183 | - */ |
|
184 | - private function getAccessToken() |
|
185 | - { |
|
186 | - return $this->accessToken; |
|
187 | - } |
|
188 | - /** |
|
189 | - * @param string $accessToken |
|
190 | - */ |
|
191 | - public function setAccessToken($accessToken) |
|
192 | - { |
|
193 | - $this->accessToken = $accessToken; |
|
194 | - } |
|
145 | + $headers = array( |
|
146 | + "Connection" => "keep-alive", |
|
147 | + "Accept-Encoding" => "gzip", |
|
148 | + "Content-Type" => "application/json; charset=UTF-8", |
|
149 | + "User-Agent" => self::USERAGENT |
|
150 | + ); |
|
151 | + $timestamp = new DateTime(); |
|
152 | + $timestamp = $timestamp->format(DateTime::ATOM); |
|
153 | + $timestamp = substr($timestamp, 0, -6); |
|
154 | + $timestamp .= "Z"; |
|
155 | + $urlParts = parse_url($this->getFullUrl()); |
|
156 | + $url2 = ""; |
|
157 | + $req = [$this->getMethod(), |
|
158 | + $urlParts['host'], |
|
159 | + "443", |
|
160 | + $urlParts['path'], |
|
161 | + $payload_accessToken, |
|
162 | + $timestamp, |
|
163 | + $url2, |
|
164 | + $this->payLoad]; |
|
165 | + $reqString = implode("%", $req); |
|
166 | + $secret = self::SECRET; |
|
167 | + $signature = hash_hmac('sha1', $reqString, $secret); |
|
168 | + $signature = strtoupper($signature); |
|
169 | + $headers['X-Authorization'] = 'HMAC ' . $signature; |
|
170 | + $headers['X-Client-Type'] = self::CLIENT_TYPE; |
|
171 | + $headers['X-Timestamp'] = $timestamp; |
|
172 | + $headers['X-Api-Version'] = '0.2'; |
|
173 | + return $headers; |
|
174 | + } |
|
175 | + private function getFullUrl() |
|
176 | + { |
|
177 | + return self::APIURL . $this->getApiEndPoint(); |
|
178 | + } |
|
179 | + abstract function getApiEndPoint(); |
|
180 | + abstract function getMethod(); |
|
181 | + /** |
|
182 | + * @return string |
|
183 | + */ |
|
184 | + private function getAccessToken() |
|
185 | + { |
|
186 | + return $this->accessToken; |
|
187 | + } |
|
188 | + /** |
|
189 | + * @param string $accessToken |
|
190 | + */ |
|
191 | + public function setAccessToken($accessToken) |
|
192 | + { |
|
193 | + $this->accessToken = $accessToken; |
|
194 | + } |
|
195 | 195 | } |
@@ -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; |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | $result = Requests::put($url, $header, $this->payLoad); |
71 | 71 | break; |
72 | 72 | } |
73 | - switch ($result->status_code) { |
|
73 | + switch($result->status_code) { |
|
74 | 74 | case 200: |
75 | 75 | $result = json_decode($result->body, true); |
76 | 76 | break; |
@@ -107,11 +107,11 @@ discard block |
||
107 | 107 | |
108 | 108 | if(array_key_exists('error', $result) && $result['error'] == 'Service Unavailable"') |
109 | 109 | { |
110 | - header('location:'.$_SERVER['PHP_SELF']); |
|
110 | + header('location:' . $_SERVER['PHP_SELF']); |
|
111 | 111 | } |
112 | 112 | break; |
113 | 113 | default: |
114 | - error_log('Error '.$result->status_code.' - Unauthorized'); |
|
114 | + error_log('Error ' . $result->status_code . ' - Unauthorized'); |
|
115 | 115 | $result = json_decode($result->body, true); |
116 | 116 | } |
117 | 117 |
@@ -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'; |
@@ -72,38 +72,38 @@ discard block |
||
72 | 72 | } |
73 | 73 | switch ($result->status_code) { |
74 | 74 | case 200: |
75 | - $result = json_decode($result->body, true); |
|
75 | + $result = json_decode($result->body, TRUE); |
|
76 | 76 | break; |
77 | 77 | case 204: |
78 | 78 | $result = 'Success'; |
79 | 79 | break; |
80 | 80 | case 400: |
81 | - $result = json_decode($result->body, true); |
|
82 | - error_log('Error 400 - ' . print_r($result, true)); |
|
81 | + $result = json_decode($result->body, TRUE); |
|
82 | + error_log('Error 400 - ' . print_r($result, TRUE)); |
|
83 | 83 | break; |
84 | 84 | case 401: |
85 | - $result = json_decode($result->body, true); |
|
86 | - error_log('Error 401 - ' . print_r($result, true)); |
|
85 | + $result = json_decode($result->body, TRUE); |
|
86 | + error_log('Error 401 - ' . print_r($result, TRUE)); |
|
87 | 87 | break; |
88 | 88 | case 404: |
89 | - error_log('Error 404 - ' . print_r($result, true)); |
|
90 | - $result = json_decode($result->body, true); |
|
89 | + error_log('Error 404 - ' . print_r($result, TRUE)); |
|
90 | + $result = json_decode($result->body, TRUE); |
|
91 | 91 | break; |
92 | 92 | case 477: |
93 | - $result = json_decode($result->body, true); |
|
94 | - error_log('Error 477 - ' . print_r($result, true)); |
|
93 | + $result = json_decode($result->body, TRUE); |
|
94 | + error_log('Error 477 - ' . print_r($result, TRUE)); |
|
95 | 95 | break; |
96 | 96 | case 429: |
97 | - error_log('Error 429 - Too Many Requests' . print_r(json_decode($result->body, true), true)); |
|
97 | + error_log('Error 429 - Too Many Requests' . print_r(json_decode($result->body, TRUE), TRUE)); |
|
98 | 98 | exit("Error 429: Too Many Requests"); |
99 | 99 | break; |
100 | 100 | case 403: |
101 | - error_log('Error 403 - Access denied:' . print_r(json_decode($result->body, true), true)); |
|
102 | - $result = json_decode($result->body, true); |
|
101 | + error_log('Error 403 - Access denied:' . print_r(json_decode($result->body, TRUE), TRUE)); |
|
102 | + $result = json_decode($result->body, TRUE); |
|
103 | 103 | break; |
104 | 104 | case 503: |
105 | - error_log('Error 503 - ' . print_r($result, true)); |
|
106 | - $result = json_decode($result->body, true); |
|
105 | + error_log('Error 503 - ' . print_r($result, TRUE)); |
|
106 | + $result = json_decode($result->body, TRUE); |
|
107 | 107 | |
108 | 108 | if(array_key_exists('error', $result) && $result['error'] == 'Service Unavailable"') |
109 | 109 | { |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | break; |
113 | 113 | default: |
114 | 114 | error_log('Error '.$result->status_code.' - Unauthorized'); |
115 | - $result = json_decode($result->body, true); |
|
115 | + $result = json_decode($result->body, TRUE); |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | //important for account refresh |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | */ |
135 | 135 | private function getSignHeaders() |
136 | 136 | { |
137 | - if($this->getAccessToken() == null) { |
|
137 | + if($this->getAccessToken() == NULL) { |
|
138 | 138 | $payload_accessToken = ""; |
139 | 139 | } |
140 | 140 | else { |
@@ -1,41 +1,41 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | class SendJodel extends AbstractRequest { |
4 | - public $location; |
|
5 | - public $ancestor = ""; |
|
6 | - public $color = ""; |
|
7 | - public $image = ''; |
|
4 | + public $location; |
|
5 | + public $ancestor = ""; |
|
6 | + public $color = ""; |
|
7 | + public $image = ''; |
|
8 | 8 | |
9 | - function getApiEndPoint() |
|
10 | - { |
|
11 | - return '/v3/posts/'; |
|
12 | - } |
|
9 | + function getApiEndPoint() |
|
10 | + { |
|
11 | + return '/v3/posts/'; |
|
12 | + } |
|
13 | 13 | |
14 | - function getPayload() |
|
15 | - { |
|
16 | - if($this->image != '') |
|
17 | - { |
|
18 | - return array( |
|
19 | - "ancestor" => $this->ancestor, |
|
20 | - "color" => $this->color, |
|
21 | - "location" => $this->location->toArray(), |
|
22 | - "message" => $_POST['message'], |
|
23 | - 'image' => base64_encode($this->image), |
|
24 | - ); |
|
25 | - } |
|
26 | - else |
|
27 | - { |
|
28 | - return array( |
|
29 | - "ancestor" => $this->ancestor, |
|
30 | - "color" => $this->color, |
|
31 | - "location" => $this->location->toArray(), |
|
32 | - "message" => $_POST['message'], |
|
33 | - ); |
|
34 | - } |
|
14 | + function getPayload() |
|
15 | + { |
|
16 | + if($this->image != '') |
|
17 | + { |
|
18 | + return array( |
|
19 | + "ancestor" => $this->ancestor, |
|
20 | + "color" => $this->color, |
|
21 | + "location" => $this->location->toArray(), |
|
22 | + "message" => $_POST['message'], |
|
23 | + 'image' => base64_encode($this->image), |
|
24 | + ); |
|
25 | + } |
|
26 | + else |
|
27 | + { |
|
28 | + return array( |
|
29 | + "ancestor" => $this->ancestor, |
|
30 | + "color" => $this->color, |
|
31 | + "location" => $this->location->toArray(), |
|
32 | + "message" => $_POST['message'], |
|
33 | + ); |
|
34 | + } |
|
35 | 35 | |
36 | - } |
|
37 | - function getMethod() |
|
38 | - { |
|
39 | - return 'POST'; |
|
40 | - } |
|
36 | + } |
|
37 | + function getMethod() |
|
38 | + { |
|
39 | + return 'POST'; |
|
40 | + } |
|
41 | 41 | } |