@@ -44,6 +44,9 @@ |
||
| 44 | 44 | return (isset($matches[0])) ? true : false; |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | +/** |
|
| 48 | + * @param string $property |
|
| 49 | + */ |
|
| 47 | 50 | function configPropertyExists($config, $property) |
| 48 | 51 | { |
| 49 | 52 | if(!array_key_exists($property, $config) || !isset($config[$property]) || $config[$property] == '' || $config[$property] == 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx') |
@@ -39,21 +39,21 @@ discard block |
||
| 39 | 39 | |
| 40 | 40 | function isUserBot() |
| 41 | 41 | { |
| 42 | - preg_match('/bot|spider|google|twitter/i', $_SERVER['HTTP_USER_AGENT'], $matches); |
|
| 42 | + preg_match('/bot|spider|google|twitter/i', $_SERVER['HTTP_USER_AGENT'], $matches); |
|
| 43 | 43 | |
| 44 | - return (isset($matches[0])) ? true : false; |
|
| 44 | + return (isset($matches[0])) ? true : false; |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | function configPropertyExists($config, $property) |
| 48 | 48 | { |
| 49 | - if(!array_key_exists($property, $config) || !isset($config[$property]) || $config[$property] == '' || $config[$property] == 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx') |
|
| 50 | - { |
|
| 51 | - return FALSE; |
|
| 52 | - } |
|
| 53 | - else |
|
| 54 | - { |
|
| 55 | - return TRUE; |
|
| 56 | - } |
|
| 49 | + if(!array_key_exists($property, $config) || !isset($config[$property]) || $config[$property] == '' || $config[$property] == 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx') |
|
| 50 | + { |
|
| 51 | + return FALSE; |
|
| 52 | + } |
|
| 53 | + else |
|
| 54 | + { |
|
| 55 | + return TRUE; |
|
| 56 | + } |
|
| 57 | 57 | } |
| 58 | 58 | function isUserAdmin() { |
| 59 | 59 | global $config; |
@@ -69,17 +69,17 @@ discard block |
||
| 69 | 69 | |
| 70 | 70 | function isDeviceUidInDatabase($deviceUid) |
| 71 | 71 | { |
| 72 | - $db = new DatabaseConnect(); |
|
| 73 | - $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $deviceUid . "'"); |
|
| 74 | - |
|
| 75 | - if ($result->num_rows > 0) |
|
| 76 | - { |
|
| 77 | - return TRUE; |
|
| 78 | - } |
|
| 79 | - else |
|
| 80 | - { |
|
| 81 | - return FALSE; |
|
| 82 | - } |
|
| 72 | + $db = new DatabaseConnect(); |
|
| 73 | + $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $deviceUid . "'"); |
|
| 74 | + |
|
| 75 | + if ($result->num_rows > 0) |
|
| 76 | + { |
|
| 77 | + return TRUE; |
|
| 78 | + } |
|
| 79 | + else |
|
| 80 | + { |
|
| 81 | + return FALSE; |
|
| 82 | + } |
|
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | //Check if it's a Spider or Google Bot |
@@ -106,14 +106,14 @@ discard block |
||
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | if(configPropertyExists($config, 'karmaDeviceUid')) |
| 109 | - { |
|
| 110 | - $jodelAccountForKarma = new JodelAccount($config['karmaDeviceUid']); |
|
| 111 | - } |
|
| 112 | - else |
|
| 113 | - { |
|
| 114 | - error_log("No Karma deviceUid set in config file"); |
|
| 109 | + { |
|
| 110 | + $jodelAccountForKarma = new JodelAccount($config['karmaDeviceUid']); |
|
| 111 | + } |
|
| 112 | + else |
|
| 113 | + { |
|
| 114 | + error_log("No Karma deviceUid set in config file"); |
|
| 115 | 115 | $jodelAccountForKarma = new JodelAccount($deviceUid); |
| 116 | - } |
|
| 116 | + } |
|
| 117 | 117 | |
| 118 | 118 | /* |
| 119 | 119 | * Cunstruct View |
@@ -223,14 +223,14 @@ discard block |
||
| 223 | 223 | { |
| 224 | 224 | $jodelAccountForKarma->votePostId($_GET['postId'], $_GET['vote']); |
| 225 | 225 | if(isset($_GET['getPostDetails']) && isset($_GET['getPostDetails'])) |
| 226 | - { |
|
| 227 | - header('Location: index.php?getPostDetails=true&postId=' . htmlspecialchars($_GET['postId_parent']) . '#postId-' . htmlspecialchars($_GET['postId'])); |
|
| 228 | - } |
|
| 229 | - else |
|
| 230 | - { |
|
| 231 | - header("Location: index.php#postId-" . htmlspecialchars($_GET['postId'])); |
|
| 232 | - } |
|
| 233 | - die(); |
|
| 226 | + { |
|
| 227 | + header('Location: index.php?getPostDetails=true&postId=' . htmlspecialchars($_GET['postId_parent']) . '#postId-' . htmlspecialchars($_GET['postId'])); |
|
| 228 | + } |
|
| 229 | + else |
|
| 230 | + { |
|
| 231 | + header("Location: index.php#postId-" . htmlspecialchars($_GET['postId'])); |
|
| 232 | + } |
|
| 233 | + die(); |
|
| 234 | 234 | } |
| 235 | 235 | |
| 236 | 236 | //SendJodel |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | { |
| 42 | 42 | preg_match('/bot|spider|google|twitter/i', $_SERVER['HTTP_USER_AGENT'], $matches); |
| 43 | 43 | |
| 44 | - return (isset($matches[0])) ? true : false; |
|
| 44 | + return (isset($matches[0]))?true : false; |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | function configPropertyExists($config, $property) |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | } |
| 58 | 58 | function isUserAdmin() { |
| 59 | 59 | global $config; |
| 60 | - if (isset($_COOKIE['JodelAdminPassword']) && configPropertyExists($config, 'pw') && $config['pw'] == $_COOKIE['JodelAdminPassword']) |
|
| 60 | + if(isset($_COOKIE['JodelAdminPassword']) && configPropertyExists($config, 'pw') && $config['pw'] == $_COOKIE['JodelAdminPassword']) |
|
| 61 | 61 | { |
| 62 | 62 | return TRUE; |
| 63 | 63 | } |
@@ -70,9 +70,9 @@ discard block |
||
| 70 | 70 | function isDeviceUidInDatabase($deviceUid) |
| 71 | 71 | { |
| 72 | 72 | $db = new DatabaseConnect(); |
| 73 | - $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $deviceUid . "'"); |
|
| 73 | + $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $deviceUid . "'"); |
|
| 74 | 74 | |
| 75 | - if ($result->num_rows > 0) |
|
| 75 | + if($result->num_rows > 0) |
|
| 76 | 76 | { |
| 77 | 77 | return TRUE; |
| 78 | 78 | } |
@@ -94,8 +94,8 @@ discard block |
||
| 94 | 94 | if(!isset($_COOKIE['JodelDeviceId']) || !isDeviceUidInDatabase($_COOKIE['JodelDeviceId'])) |
| 95 | 95 | { |
| 96 | 96 | $jodelAccountForView = new JodelAccount(); |
| 97 | - setcookie('JodelDeviceId', $jodelAccountForView->deviceUid, time()+60*60*24*365*10); |
|
| 98 | - error_log('Created account with JodelDeviceId:' . $jodelAccountForView->deviceUid . ' for [' . $_SERVER ['HTTP_USER_AGENT'] . ']'); |
|
| 97 | + setcookie('JodelDeviceId', $jodelAccountForView->deviceUid, time() + 60 * 60 * 24 * 365 * 10); |
|
| 98 | + error_log('Created account with JodelDeviceId:' . $jodelAccountForView->deviceUid . ' for [' . $_SERVER ['HTTP_USER_AGENT'] . ']'); |
|
| 99 | 99 | |
| 100 | 100 | } |
| 101 | 101 | else |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | |
| 177 | 177 | if(isset($_GET['view'])) |
| 178 | 178 | { |
| 179 | - switch ($_GET['view']) { |
|
| 179 | + switch($_GET['view']) { |
|
| 180 | 180 | case 'discussed': |
| 181 | 181 | $view = 'discussed'; |
| 182 | 182 | break; |
@@ -55,7 +55,8 @@ discard block |
||
| 55 | 55 | return TRUE; |
| 56 | 56 | } |
| 57 | 57 | } |
| 58 | -function isUserAdmin() { |
|
| 58 | +function isUserAdmin() |
|
| 59 | +{ |
|
| 59 | 60 | global $config; |
| 60 | 61 | if (isset($_COOKIE['JodelAdminPassword']) && configPropertyExists($config, 'pw') && $config['pw'] == $_COOKIE['JodelAdminPassword']) |
| 61 | 62 | { |
@@ -106,7 +107,7 @@ discard block |
||
| 106 | 107 | } |
| 107 | 108 | |
| 108 | 109 | if(configPropertyExists($config, 'karmaDeviceUid')) |
| 109 | - { |
|
| 110 | + { |
|
| 110 | 111 | $jodelAccountForKarma = new JodelAccount($config['karmaDeviceUid']); |
| 111 | 112 | } |
| 112 | 113 | else |
@@ -176,7 +177,8 @@ discard block |
||
| 176 | 177 | |
| 177 | 178 | if(isset($_GET['view'])) |
| 178 | 179 | { |
| 179 | - switch ($_GET['view']) { |
|
| 180 | + switch ($_GET['view']) |
|
| 181 | + { |
|
| 180 | 182 | case 'discussed': |
| 181 | 183 | $view = 'discussed'; |
| 182 | 184 | break; |
@@ -223,7 +225,7 @@ discard block |
||
| 223 | 225 | { |
| 224 | 226 | $jodelAccountForKarma->votePostId($_GET['postId'], $_GET['vote']); |
| 225 | 227 | if(isset($_GET['getPostDetails']) && isset($_GET['getPostDetails'])) |
| 226 | - { |
|
| 228 | + { |
|
| 227 | 229 | header('Location: index.php?getPostDetails=true&postId=' . htmlspecialchars($_GET['postId_parent']) . '#postId-' . htmlspecialchars($_GET['postId'])); |
| 228 | 230 | } |
| 229 | 231 | else |
@@ -4,12 +4,12 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | if((!isset($_GET['pw']) || $config['pw'] != $_GET['pw']) && !isUserAdmin()) |
| 6 | 6 | { |
| 7 | - error_log($_SERVER['REMOTE_ADDR'] . ' used a wrong password on admin.php'); |
|
| 7 | + error_log($_SERVER['REMOTE_ADDR'] . ' used a wrong password on admin.php'); |
|
| 8 | 8 | die(); |
| 9 | 9 | } |
| 10 | -else if (isset($_GET['pw'])) |
|
| 10 | +else if(isset($_GET['pw'])) |
|
| 11 | 11 | { |
| 12 | - setcookie('JodelAdminPassword', $_GET['pw'], time()+60*60*24*365*10); |
|
| 12 | + setcookie('JodelAdminPassword', $_GET['pw'], time() + 60 * 60 * 24 * 365 * 10); |
|
| 13 | 13 | error_log('admin password saved for [' . $_SERVER ['HTTP_USER_AGENT'] . ']'); |
| 14 | 14 | } |
| 15 | 15 | |
@@ -61,42 +61,42 @@ discard block |
||
| 61 | 61 | <meta name="keywords" content="jodelblue, jodel, blue, webclient, web, client"> |
| 62 | 62 | |
| 63 | 63 | <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"> |
| 64 | - <link rel="stylesheet" href="<?php echo $baseUrl;?>css/font-awesome.min.css"> |
|
| 65 | - <link rel="stylesheet" href="<?php echo $baseUrl;?>style.css" type="text/css"> |
|
| 64 | + <link rel="stylesheet" href="<?php echo $baseUrl; ?>css/font-awesome.min.css"> |
|
| 65 | + <link rel="stylesheet" href="<?php echo $baseUrl; ?>style.css" type="text/css"> |
|
| 66 | 66 | |
| 67 | - <link rel="shortcut icon" type="image/x-icon" href="<?php echo $baseUrl;?>img/favicon/favicon.ico"> |
|
| 68 | - <link rel="icon" type="image/x-icon" href="<?php echo $baseUrl;?>img/favicon/favicon.ico"> |
|
| 69 | - <link rel="icon" type="image/gif" href="<?php echo $baseUrl;?>img/favicon/favicon.gif"> |
|
| 70 | - <link rel="icon" type="image/png" href="<?php echo $baseUrl;?>img/favicon/favicon.png"> |
|
| 71 | - <link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon.png"> |
|
| 72 | - <link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon-57x57.png" sizes="57x57"> |
|
| 73 | - <link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon-60x60.png" sizes="60x60"> |
|
| 74 | - <link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon-72x72.png" sizes="72x72"> |
|
| 75 | - <link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon-76x76.png" sizes="76x76"> |
|
| 76 | - <link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon-114x114.png" sizes="114x114"> |
|
| 77 | - <link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon-120x120.png" sizes="120x120"> |
|
| 78 | - <link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon-128x128.png" sizes="128x128"> |
|
| 79 | - <link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon-144x144.png" sizes="144x144"> |
|
| 80 | - <link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon-152x152.png" sizes="152x152"> |
|
| 81 | - <link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon-180x180.png" sizes="180x180"> |
|
| 82 | - <link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon-precomposed.png"> |
|
| 83 | - <link rel="icon" type="image/png" href="<?php echo $baseUrl;?>img/favicon/favicon-16x16.png" sizes="16x16"> |
|
| 84 | - <link rel="icon" type="image/png" href="<?php echo $baseUrl;?>img/favicon/favicon-32x32.png" sizes="32x32"> |
|
| 85 | - <link rel="icon" type="image/png" href="<?php echo $baseUrl;?>img/favicon/favicon-96x96.png" sizes="96x96"> |
|
| 86 | - <link rel="icon" type="image/png" href="<?php echo $baseUrl;?>img/favicon/favicon-160x160.png" sizes="160x160"> |
|
| 87 | - <link rel="icon" type="image/png" href="<?php echo $baseUrl;?>img/favicon/favicon-192x192.png" sizes="192x192"> |
|
| 88 | - <link rel="icon" type="image/png" href="<?php echo $baseUrl;?>img/favicon/favicon-196x196.png" sizes="196x196"> |
|
| 89 | - <meta name="msapplication-TileImage" content="<?php echo $baseUrl;?>img/favicon/win8-tile-144x144.png"> |
|
| 67 | + <link rel="shortcut icon" type="image/x-icon" href="<?php echo $baseUrl; ?>img/favicon/favicon.ico"> |
|
| 68 | + <link rel="icon" type="image/x-icon" href="<?php echo $baseUrl; ?>img/favicon/favicon.ico"> |
|
| 69 | + <link rel="icon" type="image/gif" href="<?php echo $baseUrl; ?>img/favicon/favicon.gif"> |
|
| 70 | + <link rel="icon" type="image/png" href="<?php echo $baseUrl; ?>img/favicon/favicon.png"> |
|
| 71 | + <link rel="apple-touch-icon" href="<?php echo $baseUrl; ?>img/favicon/apple-touch-icon.png"> |
|
| 72 | + <link rel="apple-touch-icon" href="<?php echo $baseUrl; ?>img/favicon/apple-touch-icon-57x57.png" sizes="57x57"> |
|
| 73 | + <link rel="apple-touch-icon" href="<?php echo $baseUrl; ?>img/favicon/apple-touch-icon-60x60.png" sizes="60x60"> |
|
| 74 | + <link rel="apple-touch-icon" href="<?php echo $baseUrl; ?>img/favicon/apple-touch-icon-72x72.png" sizes="72x72"> |
|
| 75 | + <link rel="apple-touch-icon" href="<?php echo $baseUrl; ?>img/favicon/apple-touch-icon-76x76.png" sizes="76x76"> |
|
| 76 | + <link rel="apple-touch-icon" href="<?php echo $baseUrl; ?>img/favicon/apple-touch-icon-114x114.png" sizes="114x114"> |
|
| 77 | + <link rel="apple-touch-icon" href="<?php echo $baseUrl; ?>img/favicon/apple-touch-icon-120x120.png" sizes="120x120"> |
|
| 78 | + <link rel="apple-touch-icon" href="<?php echo $baseUrl; ?>img/favicon/apple-touch-icon-128x128.png" sizes="128x128"> |
|
| 79 | + <link rel="apple-touch-icon" href="<?php echo $baseUrl; ?>img/favicon/apple-touch-icon-144x144.png" sizes="144x144"> |
|
| 80 | + <link rel="apple-touch-icon" href="<?php echo $baseUrl; ?>img/favicon/apple-touch-icon-152x152.png" sizes="152x152"> |
|
| 81 | + <link rel="apple-touch-icon" href="<?php echo $baseUrl; ?>img/favicon/apple-touch-icon-180x180.png" sizes="180x180"> |
|
| 82 | + <link rel="apple-touch-icon" href="<?php echo $baseUrl; ?>img/favicon/apple-touch-icon-precomposed.png"> |
|
| 83 | + <link rel="icon" type="image/png" href="<?php echo $baseUrl; ?>img/favicon/favicon-16x16.png" sizes="16x16"> |
|
| 84 | + <link rel="icon" type="image/png" href="<?php echo $baseUrl; ?>img/favicon/favicon-32x32.png" sizes="32x32"> |
|
| 85 | + <link rel="icon" type="image/png" href="<?php echo $baseUrl; ?>img/favicon/favicon-96x96.png" sizes="96x96"> |
|
| 86 | + <link rel="icon" type="image/png" href="<?php echo $baseUrl; ?>img/favicon/favicon-160x160.png" sizes="160x160"> |
|
| 87 | + <link rel="icon" type="image/png" href="<?php echo $baseUrl; ?>img/favicon/favicon-192x192.png" sizes="192x192"> |
|
| 88 | + <link rel="icon" type="image/png" href="<?php echo $baseUrl; ?>img/favicon/favicon-196x196.png" sizes="196x196"> |
|
| 89 | + <meta name="msapplication-TileImage" content="<?php echo $baseUrl; ?>img/favicon/win8-tile-144x144.png"> |
|
| 90 | 90 | <meta name="msapplication-TileColor" content="#5682a3"> |
| 91 | 91 | <meta name="msapplication-navbutton-color" content="#5682a3"> |
| 92 | 92 | <meta name="application-name" content="JodelBlue"/> |
| 93 | 93 | <meta name="msapplication-tooltip" content="JodelBlue"/> |
| 94 | 94 | <meta name="apple-mobile-web-app-title" content="JodelBlue"/> |
| 95 | - <meta name="msapplication-square70x70logo" content="<?php echo $baseUrl;?>img/favicon/win8-tile-70x70.png"> |
|
| 96 | - <meta name="msapplication-square144x144logo" content="<?php echo $baseUrl;?>img/favicon/win8-tile-144x144.png"> |
|
| 97 | - <meta name="msapplication-square150x150logo" content="<?php echo $baseUrl;?>img/favicon/win8-tile-150x150.png"> |
|
| 98 | - <meta name="msapplication-wide310x150logo" content="<?php echo $baseUrl;?>img/favicon/win8-tile-310x150.png"> |
|
| 99 | - <meta name="msapplication-square310x310logo" content="<?php echo $baseUrl;?>img/favicon/win8-tile-310x310.png"> |
|
| 95 | + <meta name="msapplication-square70x70logo" content="<?php echo $baseUrl; ?>img/favicon/win8-tile-70x70.png"> |
|
| 96 | + <meta name="msapplication-square144x144logo" content="<?php echo $baseUrl; ?>img/favicon/win8-tile-144x144.png"> |
|
| 97 | + <meta name="msapplication-square150x150logo" content="<?php echo $baseUrl; ?>img/favicon/win8-tile-150x150.png"> |
|
| 98 | + <meta name="msapplication-wide310x150logo" content="<?php echo $baseUrl; ?>img/favicon/win8-tile-310x150.png"> |
|
| 99 | + <meta name="msapplication-square310x310logo" content="<?php echo $baseUrl; ?>img/favicon/win8-tile-310x310.png"> |
|
| 100 | 100 | </head> |
| 101 | 101 | |
| 102 | 102 | <body> |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | { |
| 200 | 200 | $.ajax({ |
| 201 | 201 | type: "POST", |
| 202 | - url: "<?php echo $baseUrl;?>vote-ajax.php?pw=<?php echo $_GET["pw"]?>", |
|
| 202 | + url: "<?php echo $baseUrl; ?>vote-ajax.php?pw=<?php echo $_GET["pw"]?>", |
|
| 203 | 203 | data: {"vote" : data["vote"], |
| 204 | 204 | "postId" : data["id"]}, |
| 205 | 205 | success: function(result){ |
@@ -246,7 +246,7 @@ discard block |
||
| 246 | 246 | console.log(solution); |
| 247 | 247 | $.ajax({ |
| 248 | 248 | type: "POST", |
| 249 | - url: "<?php echo $baseUrl;?>vote-ajax.php?pw=<?php echo $_GET["pw"]?>&solution=" + solution + "&key="+key, |
|
| 249 | + url: "<?php echo $baseUrl; ?>vote-ajax.php?pw=<?php echo $_GET["pw"]?>&solution=" + solution + "&key="+key, |
|
| 250 | 250 | data: {"deviceUid" : deviceUid}, |
| 251 | 251 | success: function(result){ |
| 252 | 252 | var response = JSON.parse(result); |
@@ -3,8 +3,8 @@ discard block |
||
| 3 | 3 | |
| 4 | 4 | if((!isset($_GET['pw']) || $config['pw'] != $_GET['pw']) && !isUserAdmin()) |
| 5 | 5 | { |
| 6 | - error_log($_SERVER['REMOTE_ADDR'] . ' used a wrong password on vote-ajax.php'); |
|
| 7 | - $respone = array("message" => $_SERVER['REMOTE_ADDR'] . ' used a wrong password on vote-ajax.php',"success" => false); |
|
| 6 | + error_log($_SERVER['REMOTE_ADDR'] . ' used a wrong password on vote-ajax.php'); |
|
| 7 | + $respone = array("message" => $_SERVER['REMOTE_ADDR'] . ' used a wrong password on vote-ajax.php', "success" => false); |
|
| 8 | 8 | echo json_encode($response); |
| 9 | 9 | die(); |
| 10 | 10 | } |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | } |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | -if (isset($captcha)) |
|
| 57 | +if(isset($captcha)) |
|
| 58 | 58 | { |
| 59 | 59 | $response = array("success" => $success, "message" => $message, "captcha" => $captcha, "deviceUid" => $deviceUid); |
| 60 | 60 | } |
@@ -4,7 +4,7 @@ discard block |
||
| 4 | 4 | if((!isset($_GET['pw']) || $config['pw'] != $_GET['pw']) && !isUserAdmin()) |
| 5 | 5 | { |
| 6 | 6 | error_log($_SERVER['REMOTE_ADDR'] . ' used a wrong password on vote-ajax.php'); |
| 7 | - $respone = array("message" => $_SERVER['REMOTE_ADDR'] . ' used a wrong password on vote-ajax.php',"success" => false); |
|
| 7 | + $respone = array("message" => $_SERVER['REMOTE_ADDR'] . ' used a wrong password on vote-ajax.php',"success" => FALSE); |
|
| 8 | 8 | echo json_encode($response); |
| 9 | 9 | die(); |
| 10 | 10 | } |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | $message = ""; |
| 23 | -$success = true; |
|
| 23 | +$success = TRUE; |
|
| 24 | 24 | $token = ""; |
| 25 | 25 | if(isset($_POST['vote']) && isset($_POST['postId'])) |
| 26 | 26 | { |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | $view = new View(); |
| 41 | 41 | $message = "This account is not verified. Please verify this account first."; |
| 42 | 42 | $captcha = $view->getCaptcha($accessToken); |
| 43 | - $success = false; |
|
| 43 | + $success = FALSE; |
|
| 44 | 44 | } |
| 45 | 45 | else |
| 46 | 46 | { |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | else |
| 51 | 51 | { |
| 52 | 52 | $message = 'There is no account available for this jodel. Please create at least one new account to vote this jodel.'; |
| 53 | - $success = false; |
|
| 53 | + $success = FALSE; |
|
| 54 | 54 | } |
| 55 | 55 | } |
| 56 | 56 | |
@@ -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; |
|
| 23 | - |
|
| 24 | - if($postId == '') |
|
| 25 | - { |
|
| 26 | - $this->isDetailedView = FALSE; |
|
| 27 | - } |
|
| 28 | - else |
|
| 29 | - { |
|
| 30 | - $this->isDetailedView = TRUE; |
|
| 31 | - } |
|
| 32 | - } |
|
| 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 | + |
|
| 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); |
|
| 40 | - |
|
| 41 | - //Time to time difference |
|
| 42 | - $now = new DateTime(); |
|
| 43 | - $d = new DateTime($post['created_at']); |
|
| 44 | - $timediff = $now->diff($d); |
|
| 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'); |
|
| 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 | - } |
|
| 81 | - |
|
| 82 | - |
|
| 83 | - ?> |
|
| 37 | + { //ToDO |
|
| 38 | + //Replace # with link |
|
| 39 | + //preg_replace('~(\#)([^\s!,. /()"\'?]+)~', '<a href="tag/$2">#$2</a>', $text); |
|
| 40 | + |
|
| 41 | + //Time to time difference |
|
| 42 | + $now = new DateTime(); |
|
| 43 | + $d = new DateTime($post['created_at']); |
|
| 44 | + $timediff = $now->diff($d); |
|
| 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'); |
|
| 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 | + } |
|
| 81 | + |
|
| 82 | + |
|
| 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'; |
|
| 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 | - ?> |
|
| 87 | + if(isset($post['image_url'])) |
|
| 88 | + { |
|
| 89 | + $regexRest = '/[^\w$ .!?-]+/u'; |
|
| 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 | + ?> |
|
| 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 | /** |
@@ -267,135 +267,135 @@ discard block |
||
| 267 | 267 | |
| 268 | 268 | } |
| 269 | 269 | |
| 270 | - function toUrl() |
|
| 271 | - { |
|
| 272 | - $url = $this->baseUrl . 'index.php?country=DE' . |
|
| 273 | - '&city=' . urlencode($this->city) . |
|
| 274 | - '&hashtag=' . urlencode($this->hashtag) . |
|
| 275 | - '&view=' . $this->view; |
|
| 276 | - if($this->postId != '') |
|
| 277 | - { |
|
| 278 | - $url .= '&postId=' . $this->postId . |
|
| 279 | - '&getPostDetails=TRUE'; |
|
| 280 | - } |
|
| 281 | - |
|
| 282 | - return $url; |
|
| 283 | - } |
|
| 284 | - |
|
| 285 | - function changePostId($postId) |
|
| 286 | - { |
|
| 287 | - $tempView = clone $this; |
|
| 288 | - $tempView->postId = $postId; |
|
| 289 | - $tempView->isDetailedView = TRUE; |
|
| 290 | - return $tempView; |
|
| 291 | - } |
|
| 292 | - |
|
| 293 | - function back() |
|
| 294 | - { |
|
| 295 | - $tempView = clone $this; |
|
| 296 | - $tempView->postId = ''; |
|
| 297 | - return $tempView; |
|
| 298 | - } |
|
| 299 | - |
|
| 300 | - function changeView($view) |
|
| 301 | - { |
|
| 302 | - $tempView = clone $this; |
|
| 303 | - $tempView->view = $view; |
|
| 304 | - return $tempView; |
|
| 305 | - } |
|
| 270 | + function toUrl() |
|
| 271 | + { |
|
| 272 | + $url = $this->baseUrl . 'index.php?country=DE' . |
|
| 273 | + '&city=' . urlencode($this->city) . |
|
| 274 | + '&hashtag=' . urlencode($this->hashtag) . |
|
| 275 | + '&view=' . $this->view; |
|
| 276 | + if($this->postId != '') |
|
| 277 | + { |
|
| 278 | + $url .= '&postId=' . $this->postId . |
|
| 279 | + '&getPostDetails=TRUE'; |
|
| 280 | + } |
|
| 281 | + |
|
| 282 | + return $url; |
|
| 283 | + } |
|
| 284 | + |
|
| 285 | + function changePostId($postId) |
|
| 286 | + { |
|
| 287 | + $tempView = clone $this; |
|
| 288 | + $tempView->postId = $postId; |
|
| 289 | + $tempView->isDetailedView = TRUE; |
|
| 290 | + return $tempView; |
|
| 291 | + } |
|
| 292 | + |
|
| 293 | + function back() |
|
| 294 | + { |
|
| 295 | + $tempView = clone $this; |
|
| 296 | + $tempView->postId = ''; |
|
| 297 | + return $tempView; |
|
| 298 | + } |
|
| 299 | + |
|
| 300 | + function changeView($view) |
|
| 301 | + { |
|
| 302 | + $tempView = clone $this; |
|
| 303 | + $tempView->view = $view; |
|
| 304 | + return $tempView; |
|
| 305 | + } |
|
| 306 | 306 | |
| 307 | 307 | function getPosts($jodelAccount) |
| 308 | 308 | { |
| 309 | - if($this->hashtag != '#all' && $this->hashtag != '' && $this->hashtag != NULL) |
|
| 310 | - { |
|
| 311 | - $accountCreator = new GetChannel(); |
|
| 312 | - $accountCreator->view = $this->view; |
|
| 313 | - $accountCreator->setAccessToken($jodelAccount->accessToken); |
|
| 314 | - $accountCreator->channel = $this->hashtag; |
|
| 315 | - $accountCreator->lastPostId = $this->lastPostId; |
|
| 316 | - $data = $accountCreator->execute(); |
|
| 317 | - } |
|
| 318 | - else |
|
| 319 | - { |
|
| 320 | - if($this->lastPostId == '' && $this->view == 'combo') |
|
| 321 | - { |
|
| 322 | - $url = "/v3/posts/location/combo"; |
|
| 323 | - } |
|
| 324 | - else |
|
| 325 | - { |
|
| 326 | - if($this->view == 'discussed') |
|
| 327 | - { |
|
| 328 | - $url = "/v2/posts/location/discussed/"; |
|
| 329 | - } |
|
| 330 | - else |
|
| 331 | - { |
|
| 332 | - if($this->view == 'popular') |
|
| 333 | - { |
|
| 334 | - $url = "/v2/posts/location/popular/"; |
|
| 335 | - } |
|
| 336 | - else |
|
| 337 | - { |
|
| 338 | - $url = "/v2/posts/location/"; |
|
| 339 | - } |
|
| 340 | - } |
|
| 341 | - } |
|
| 342 | - |
|
| 343 | - $accountCreator = new GetPosts(); |
|
| 344 | - $accountCreator->setLastPostId($this->lastPostId); |
|
| 345 | - $accountCreator->setAccessToken($jodelAccount->accessToken); |
|
| 346 | - $accountCreator->setUrl($url); |
|
| 347 | - $accountCreator->version = 'v3'; |
|
| 348 | - |
|
| 349 | - $config = parse_ini_file('config/config.ini.php'); |
|
| 350 | - $location = new Location(); |
|
| 351 | - $location->setLat($config['default_lat']); |
|
| 352 | - $location->setLng($config['default_lng']); |
|
| 353 | - $location->setCityName($config['default_location']); |
|
| 354 | - $accountCreator->location = $location; |
|
| 355 | - $data = $accountCreator->execute(); |
|
| 356 | - } |
|
| 357 | - if(array_key_exists('recent', $data)) |
|
| 358 | - { |
|
| 359 | - return $data['recent']; |
|
| 360 | - } |
|
| 361 | - else if(array_key_exists('posts', $data)) |
|
| 362 | - { |
|
| 363 | - return $data['posts']; |
|
| 364 | - } |
|
| 365 | - else |
|
| 366 | - { |
|
| 367 | - error_log('Fehler View getPosts '); |
|
| 368 | - error_log(print_r($data, true)); |
|
| 369 | - |
|
| 370 | - $notFound[0] = array( |
|
| 371 | - "post_id" => "0", |
|
| 372 | - "discovered_by" => 0, |
|
| 373 | - "message" => "Not found", |
|
| 374 | - "created_at" => "2017-02-11T16:44:50.385Z", |
|
| 375 | - "updated_at" => "2017-02-11T16:44:50.385Z", |
|
| 376 | - "pin_count" => 0, |
|
| 377 | - "color" => "FFBA00", |
|
| 378 | - "got_thanks" => FALSE, |
|
| 379 | - "post_own" => "friend", |
|
| 380 | - "discovered" => 0, |
|
| 381 | - "distance" => 9, |
|
| 382 | - "vote_count" => 0, |
|
| 383 | - "location" => |
|
| 384 | - array("name" => "Berlin", |
|
| 385 | - "loc_coordinates" => |
|
| 386 | - array( |
|
| 387 | - "lat" => 0, |
|
| 388 | - "lng" => 0 |
|
| 389 | - ), |
|
| 390 | - "loc_accuracy" => 0, |
|
| 391 | - "country" => "", |
|
| 392 | - "city" => "", |
|
| 393 | - ), |
|
| 394 | - "tags" => |
|
| 395 | - array(), |
|
| 396 | - "user_handle" => "0" |
|
| 397 | - ); |
|
| 398 | - return $notFound; |
|
| 399 | - } |
|
| 309 | + if($this->hashtag != '#all' && $this->hashtag != '' && $this->hashtag != NULL) |
|
| 310 | + { |
|
| 311 | + $accountCreator = new GetChannel(); |
|
| 312 | + $accountCreator->view = $this->view; |
|
| 313 | + $accountCreator->setAccessToken($jodelAccount->accessToken); |
|
| 314 | + $accountCreator->channel = $this->hashtag; |
|
| 315 | + $accountCreator->lastPostId = $this->lastPostId; |
|
| 316 | + $data = $accountCreator->execute(); |
|
| 317 | + } |
|
| 318 | + else |
|
| 319 | + { |
|
| 320 | + if($this->lastPostId == '' && $this->view == 'combo') |
|
| 321 | + { |
|
| 322 | + $url = "/v3/posts/location/combo"; |
|
| 323 | + } |
|
| 324 | + else |
|
| 325 | + { |
|
| 326 | + if($this->view == 'discussed') |
|
| 327 | + { |
|
| 328 | + $url = "/v2/posts/location/discussed/"; |
|
| 329 | + } |
|
| 330 | + else |
|
| 331 | + { |
|
| 332 | + if($this->view == 'popular') |
|
| 333 | + { |
|
| 334 | + $url = "/v2/posts/location/popular/"; |
|
| 335 | + } |
|
| 336 | + else |
|
| 337 | + { |
|
| 338 | + $url = "/v2/posts/location/"; |
|
| 339 | + } |
|
| 340 | + } |
|
| 341 | + } |
|
| 342 | + |
|
| 343 | + $accountCreator = new GetPosts(); |
|
| 344 | + $accountCreator->setLastPostId($this->lastPostId); |
|
| 345 | + $accountCreator->setAccessToken($jodelAccount->accessToken); |
|
| 346 | + $accountCreator->setUrl($url); |
|
| 347 | + $accountCreator->version = 'v3'; |
|
| 348 | + |
|
| 349 | + $config = parse_ini_file('config/config.ini.php'); |
|
| 350 | + $location = new Location(); |
|
| 351 | + $location->setLat($config['default_lat']); |
|
| 352 | + $location->setLng($config['default_lng']); |
|
| 353 | + $location->setCityName($config['default_location']); |
|
| 354 | + $accountCreator->location = $location; |
|
| 355 | + $data = $accountCreator->execute(); |
|
| 356 | + } |
|
| 357 | + if(array_key_exists('recent', $data)) |
|
| 358 | + { |
|
| 359 | + return $data['recent']; |
|
| 360 | + } |
|
| 361 | + else if(array_key_exists('posts', $data)) |
|
| 362 | + { |
|
| 363 | + return $data['posts']; |
|
| 364 | + } |
|
| 365 | + else |
|
| 366 | + { |
|
| 367 | + error_log('Fehler View getPosts '); |
|
| 368 | + error_log(print_r($data, true)); |
|
| 369 | + |
|
| 370 | + $notFound[0] = array( |
|
| 371 | + "post_id" => "0", |
|
| 372 | + "discovered_by" => 0, |
|
| 373 | + "message" => "Not found", |
|
| 374 | + "created_at" => "2017-02-11T16:44:50.385Z", |
|
| 375 | + "updated_at" => "2017-02-11T16:44:50.385Z", |
|
| 376 | + "pin_count" => 0, |
|
| 377 | + "color" => "FFBA00", |
|
| 378 | + "got_thanks" => FALSE, |
|
| 379 | + "post_own" => "friend", |
|
| 380 | + "discovered" => 0, |
|
| 381 | + "distance" => 9, |
|
| 382 | + "vote_count" => 0, |
|
| 383 | + "location" => |
|
| 384 | + array("name" => "Berlin", |
|
| 385 | + "loc_coordinates" => |
|
| 386 | + array( |
|
| 387 | + "lat" => 0, |
|
| 388 | + "lng" => 0 |
|
| 389 | + ), |
|
| 390 | + "loc_accuracy" => 0, |
|
| 391 | + "country" => "", |
|
| 392 | + "city" => "", |
|
| 393 | + ), |
|
| 394 | + "tags" => |
|
| 395 | + array(), |
|
| 396 | + "user_handle" => "0" |
|
| 397 | + ); |
|
| 398 | + return $notFound; |
|
| 399 | + } |
|
| 400 | 400 | } |
| 401 | 401 | } |
| 402 | 402 | \ No newline at end of file |
@@ -49,25 +49,25 @@ discard block |
||
| 49 | 49 | $timediff_inDays = (string)$timediff->format('%d'); |
| 50 | 50 | $timediff_inMonth = (string)$timediff->format('%m'); |
| 51 | 51 | |
| 52 | - if($timediff_inMonth!=0) |
|
| 52 | + if($timediff_inMonth != 0) |
|
| 53 | 53 | { |
| 54 | 54 | $timediff = $timediff_inMonth . "m"; |
| 55 | 55 | } |
| 56 | 56 | else |
| 57 | 57 | { |
| 58 | - if($timediff_inDays!=0) |
|
| 58 | + if($timediff_inDays != 0) |
|
| 59 | 59 | { |
| 60 | 60 | $timediff = $timediff_inDays . "d"; |
| 61 | 61 | } |
| 62 | 62 | else |
| 63 | 63 | { |
| 64 | - if($timediff_inHours!=0) |
|
| 64 | + if($timediff_inHours != 0) |
|
| 65 | 65 | { |
| 66 | 66 | $timediff = $timediff_inHours . "h"; |
| 67 | 67 | } |
| 68 | 68 | else |
| 69 | 69 | { |
| 70 | - if($timediff_inMinutes!=0) |
|
| 70 | + if($timediff_inMinutes != 0) |
|
| 71 | 71 | { |
| 72 | 72 | $timediff = $timediff_inMinutes . "m"; |
| 73 | 73 | } |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | |
| 82 | 82 | |
| 83 | 83 | ?> |
| 84 | - <article id ="postId-<?php echo $post['post_id']; ?>" class="jodel" style="background-color: #<?php echo $post['color'];?>;"> |
|
| 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 | 87 | if(isset($post['image_url'])) |
@@ -99,24 +99,24 @@ discard block |
||
| 99 | 99 | <?php |
| 100 | 100 | if($this->isDetailedView) |
| 101 | 101 | {?> |
| 102 | - <a href="index.php?vote=up&getPostDetails=true&postId=<?php echo $post['post_id'];?>&postId_parent=<?php echo htmlspecialchars($_GET['postId']);?>" rel="nofollow"> |
|
| 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 | 104 | else |
| 105 | 105 | {?> |
| 106 | - <a href="index.php?vote=up&postId=<?php echo $post['post_id'];?>" rel="nofollow"> |
|
| 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> |
| 109 | 109 | </a> |
| 110 | 110 | <br /> |
| 111 | - <?php echo $post["vote_count"];?><br /> |
|
| 111 | + <?php echo $post["vote_count"]; ?><br /> |
|
| 112 | 112 | <?php |
| 113 | 113 | if($this->isDetailedView) |
| 114 | 114 | {?> |
| 115 | - <a href="index.php?vote=down&getPostDetails=true&postId=<?php echo $post['post_id'];?>&postId_parent=<?php echo htmlspecialchars($_GET['postId']);?>" rel="nofollow"> |
|
| 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 | 117 | else |
| 118 | 118 | {?> |
| 119 | - <a href="index.php?vote=down&postId=<?php echo $post['post_id'];?>" rel="nofollow"> |
|
| 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> |
| 122 | 122 | </a> |
@@ -128,14 +128,14 @@ discard block |
||
| 128 | 128 | <span class="time"> |
| 129 | 129 | <span class="tip" data-tooltip="Time"> |
| 130 | 130 | <i class="fa fa-clock-o"></i> |
| 131 | - <?php echo $timediff;?> |
|
| 132 | - <span class="tiptext"><?php echo $d->format('Y-m-d H:i:s');?></span> |
|
| 131 | + <?php echo $timediff; ?> |
|
| 132 | + <span class="tiptext"><?php echo $d->format('Y-m-d H:i:s'); ?></span> |
|
| 133 | 133 | </span> |
| 134 | 134 | </span> |
| 135 | 135 | <?php if(!$this->isDetailedView) {?> |
| 136 | 136 | <span class="comments"> |
| 137 | 137 | <span data-tooltip="Comments"> |
| 138 | - <a href="<?php echo $this->changePostId($post['post_id'])->toUrl();?>"> |
|
| 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 | 141 | echo $post["child_count"]; |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | </span> |
| 148 | 148 | <?php |
| 149 | 149 | } |
| 150 | - if (isUserAdmin()) |
|
| 150 | + if(isUserAdmin()) |
|
| 151 | 151 | { |
| 152 | 152 | ?> |
| 153 | 153 | <span class="voting"> |
@@ -177,7 +177,7 @@ discard block |
||
| 177 | 177 | { |
| 178 | 178 | ?> |
| 179 | 179 | <span data-tooltip="Author"> |
| 180 | - <i class="fa fa-user-o"></i> #<?php echo $post["user_handle"];?> | |
|
| 180 | + <i class="fa fa-user-o"></i> #<?php echo $post["user_handle"]; ?> | |
|
| 181 | 181 | </span> |
| 182 | 182 | <?php |
| 183 | 183 | } |
@@ -187,8 +187,8 @@ discard block |
||
| 187 | 187 | |
| 188 | 188 | <span class="tip" data-tooltip="Distance"> |
| 189 | 189 | <i class="fa fa-map-marker"></i> |
| 190 | - <?php echo $post['distance'];?> km |
|
| 191 | - <span class="tiptext"><?php echo $post['location']['name'];?></span> |
|
| 190 | + <?php echo $post['distance']; ?> km |
|
| 191 | + <span class="tiptext"><?php echo $post['location']['name']; ?></span> |
|
| 192 | 192 | </span> |
| 193 | 193 | </span> |
| 194 | 194 | |
@@ -34,7 +34,8 @@ discard block |
||
| 34 | 34 | * Compute HTML Code |
| 35 | 35 | */ |
| 36 | 36 | function jodelToHtml($post) |
| 37 | - { //ToDO |
|
| 37 | + { |
|
| 38 | +//ToDO |
|
| 38 | 39 | //Replace # with link |
| 39 | 40 | //preg_replace('~(\#)([^\s!,. /()"\'?]+)~', '<a href="tag/$2">#$2</a>', $text); |
| 40 | 41 | |
@@ -90,7 +91,8 @@ discard block |
||
| 90 | 91 | |
| 91 | 92 | echo '<img src="' . $post['image_url'] . '" alt="' . htmlspecialchars(preg_replace($regexRest, '', $post['message'])) . '">'; |
| 92 | 93 | } |
| 93 | - else { |
|
| 94 | + else |
|
| 95 | + { |
|
| 94 | 96 | echo str_replace(' ', ' ', nl2br(htmlspecialchars($post['message']))); |
| 95 | 97 | } |
| 96 | 98 | ?> |
@@ -98,11 +100,13 @@ discard block |
||
| 98 | 100 | <aside> |
| 99 | 101 | <?php |
| 100 | 102 | if($this->isDetailedView) |
| 101 | - {?> |
|
| 103 | + { |
|
| 104 | +?> |
|
| 102 | 105 | <a href="index.php?vote=up&getPostDetails=true&postId=<?php echo $post['post_id'];?>&postId_parent=<?php echo htmlspecialchars($_GET['postId']);?>" rel="nofollow"> |
| 103 | 106 | <?php } |
| 104 | - else |
|
| 105 | - {?> |
|
| 107 | +else |
|
| 108 | + { |
|
| 109 | +?> |
|
| 106 | 110 | <a href="index.php?vote=up&postId=<?php echo $post['post_id'];?>" rel="nofollow"> |
| 107 | 111 | <?php } ?> |
| 108 | 112 | <i class="fa fa-angle-up fa-3x"></i> |
@@ -111,11 +115,13 @@ discard block |
||
| 111 | 115 | <?php echo $post["vote_count"];?><br /> |
| 112 | 116 | <?php |
| 113 | 117 | if($this->isDetailedView) |
| 114 | - {?> |
|
| 118 | + { |
|
| 119 | +?> |
|
| 115 | 120 | <a href="index.php?vote=down&getPostDetails=true&postId=<?php echo $post['post_id'];?>&postId_parent=<?php echo htmlspecialchars($_GET['postId']);?>" rel="nofollow"> |
| 116 | 121 | <?php } |
| 117 | - else |
|
| 118 | - {?> |
|
| 122 | +else |
|
| 123 | + { |
|
| 124 | +?> |
|
| 119 | 125 | <a href="index.php?vote=down&postId=<?php echo $post['post_id'];?>" rel="nofollow"> |
| 120 | 126 | <?php } ?> |
| 121 | 127 | <i class="fa fa-angle-down fa-3x"></i> |
@@ -132,14 +138,20 @@ discard block |
||
| 132 | 138 | <span class="tiptext"><?php echo $d->format('Y-m-d H:i:s');?></span> |
| 133 | 139 | </span> |
| 134 | 140 | </span> |
| 135 | - <?php if(!$this->isDetailedView) {?> |
|
| 141 | + <?php if(!$this->isDetailedView) |
|
| 142 | +{ |
|
| 143 | +?> |
|
| 136 | 144 | <span class="comments"> |
| 137 | 145 | <span data-tooltip="Comments"> |
| 138 | 146 | <a href="<?php echo $this->changePostId($post['post_id'])->toUrl();?>"> |
| 139 | 147 | <i class="fa fa-commenting-o"></i> |
| 140 | - <?php if(array_key_exists("child_count", $post)) { |
|
| 148 | + <?php if(array_key_exists("child_count", $post)) |
|
| 149 | +{ |
|
| 141 | 150 | echo $post["child_count"]; |
| 142 | - } else echo "0"; |
|
| 151 | + } |
|
| 152 | + else { |
|
| 153 | + echo "0"; |
|
| 154 | + } |
|
| 143 | 155 | ?> |
| 144 | 156 | </a> |
| 145 | 157 | </span> |
@@ -355,7 +367,7 @@ discard block |
||
| 355 | 367 | $data = $accountCreator->execute(); |
| 356 | 368 | } |
| 357 | 369 | if(array_key_exists('recent', $data)) |
| 358 | - { |
|
| 370 | + { |
|
| 359 | 371 | return $data['recent']; |
| 360 | 372 | } |
| 361 | 373 | else if(array_key_exists('posts', $data)) |