@@ -12,6 +12,9 @@ discard block |
||
| 12 | 12 | $app->post('/test', 'testX'); |
| 13 | 13 | } |
| 14 | 14 | |
| 15 | +/** |
|
| 16 | + * @param string $function |
|
| 17 | + */ |
|
| 15 | 18 | function sendToBackend($function, $payload) |
| 16 | 19 | { |
| 17 | 20 | $context = new ZMQContext(); |
@@ -72,6 +75,9 @@ discard block |
||
| 72 | 75 | } |
| 73 | 76 | } |
| 74 | 77 | |
| 78 | +/** |
|
| 79 | + * @param string $test |
|
| 80 | + */ |
|
| 75 | 81 | function endswith($string, $test) |
| 76 | 82 | { |
| 77 | 83 | $strlen = strlen($string); |
@@ -43,6 +43,9 @@ discard block |
||
| 43 | 43 | } |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | +/** |
|
| 47 | + * @param boolean $message |
|
| 48 | + */ |
|
| 46 | 49 | function validateCanCreateUser($proposedUser, $auth, &$message) |
| 47 | 50 | { |
| 48 | 51 | $user = $auth->getUsersByFilter(new \Data\Filter('mail eq '.$proposedUser->mail)); |
@@ -103,6 +106,9 @@ discard block |
||
| 103 | 106 | return ($uid === 'me' || $uid === $app->user->uid); |
| 104 | 107 | } |
| 105 | 108 | |
| 109 | +/** |
|
| 110 | + * @param string $uid |
|
| 111 | + */ |
|
| 106 | 112 | function getUserByUIDReadOnly($app, $uid) |
| 107 | 113 | { |
| 108 | 114 | if(userIsMe($app, $uid)) |
@@ -185,6 +191,9 @@ discard block |
||
| 185 | 191 | } |
| 186 | 192 | } |
| 187 | 193 | |
| 194 | +/** |
|
| 195 | + * @param Exception $e |
|
| 196 | + */ |
|
| 188 | 197 | function exceptionCodeToHttpCode($e) |
| 189 | 198 | { |
| 190 | 199 | if($e->getCode() === 3) |
@@ -194,6 +203,9 @@ discard block |
||
| 194 | 203 | return 500; |
| 195 | 204 | } |
| 196 | 205 | |
| 206 | +/** |
|
| 207 | + * @param string $uid |
|
| 208 | + */ |
|
| 197 | 209 | function getUser($app, $uid, $payload) |
| 198 | 210 | { |
| 199 | 211 | if(!$app->user) |
@@ -323,6 +335,10 @@ discard block |
||
| 323 | 335 | echo json_encode(array('success'=>true)); |
| 324 | 336 | } |
| 325 | 337 | |
| 338 | +/** |
|
| 339 | + * @param Data\Filter $filter |
|
| 340 | + * @param boolean $pending |
|
| 341 | + */ |
|
| 326 | 342 | function getAllUsersByFilter($filter, &$pending) |
| 327 | 343 | { |
| 328 | 344 | $auth = AuthProvider::getInstance(); |
@@ -71,7 +71,7 @@ |
||
| 71 | 71 | { |
| 72 | 72 | return false; |
| 73 | 73 | } |
| 74 | - $domain = substr($email, $pos+1); |
|
| 74 | + $domain = substr($email, $pos + 1); |
|
| 75 | 75 | if(checkdnsrr($domain, 'MX') === false) |
| 76 | 76 | { |
| 77 | 77 | return false; |
@@ -71,7 +71,7 @@ |
||
| 71 | 71 | { |
| 72 | 72 | return false; |
| 73 | 73 | } |
| 74 | - $domain = substr($email, $pos+1); |
|
| 74 | + $domain = substr($email, $pos + 1); |
|
| 75 | 75 | if(checkdnsrr($domain, 'MX') === false) |
| 76 | 76 | { |
| 77 | 77 | return false; |
@@ -24,18 +24,18 @@ discard block |
||
| 24 | 24 | |
| 25 | 25 | switch($src) |
| 26 | 26 | { |
| 27 | - case 'google': |
|
| 28 | - $google = $auth->getMethodByName('Auth\GoogleAuthenticator'); |
|
| 29 | - if(!isset($_GET['code'])) |
|
| 30 | - { |
|
| 31 | - $google->redirect(); |
|
| 32 | - die(); |
|
| 33 | - } |
|
| 34 | - else |
|
| 35 | - { |
|
| 36 | - $res = $google->authenticate($_GET['code'], $current_user); |
|
| 37 | - switch($res) |
|
| 27 | + case 'google': |
|
| 28 | + $google = $auth->getMethodByName('Auth\GoogleAuthenticator'); |
|
| 29 | + if(!isset($_GET['code'])) |
|
| 30 | + { |
|
| 31 | + $google->redirect(); |
|
| 32 | + die(); |
|
| 33 | + } |
|
| 34 | + else |
|
| 38 | 35 | { |
| 36 | + $res = $google->authenticate($_GET['code'], $current_user); |
|
| 37 | + switch($res) |
|
| 38 | + { |
|
| 39 | 39 | case \Auth\Authenticator::SUCCESS: |
| 40 | 40 | header('Location: '.$ref); |
| 41 | 41 | die(); |
@@ -46,21 +46,21 @@ discard block |
||
| 46 | 46 | case \Auth\Authenticator::ALREADY_PRESENT: |
| 47 | 47 | header('Location: user_exists.php?src=google&uid='.$current_user->uid); |
| 48 | 48 | die(); |
| 49 | - } |
|
| 49 | + } |
|
| 50 | 50 | } |
| 51 | 51 | break; |
| 52 | - case 'twitter': |
|
| 53 | - $twitter = $auth->getMethodByName('Auth\TwitterAuthenticator'); |
|
| 54 | - if(!isset($_GET['oauth_token']) || !isset($_GET['oauth_verifier'])) |
|
| 55 | - { |
|
| 56 | - $twitter->redirect(); |
|
| 57 | - die(); |
|
| 58 | - } |
|
| 59 | - else |
|
| 60 | - { |
|
| 61 | - $twitter->authenticate($_GET['oauth_token'], $_GET['oauth_verifier'], $current_user); |
|
| 62 | - switch($res) |
|
| 52 | + case 'twitter': |
|
| 53 | + $twitter = $auth->getMethodByName('Auth\TwitterAuthenticator'); |
|
| 54 | + if(!isset($_GET['oauth_token']) || !isset($_GET['oauth_verifier'])) |
|
| 55 | + { |
|
| 56 | + $twitter->redirect(); |
|
| 57 | + die(); |
|
| 58 | + } |
|
| 59 | + else |
|
| 63 | 60 | { |
| 61 | + $twitter->authenticate($_GET['oauth_token'], $_GET['oauth_verifier'], $current_user); |
|
| 62 | + switch($res) |
|
| 63 | + { |
|
| 64 | 64 | case \Auth\Authenticator::SUCCESS: |
| 65 | 65 | header('Location: '.$ref); |
| 66 | 66 | die(); |
@@ -71,21 +71,21 @@ discard block |
||
| 71 | 71 | case \Auth\Authenticator::ALREADY_PRESENT: |
| 72 | 72 | header('Location: user_exists.php?src=twitter&uid='.$current_user->uid); |
| 73 | 73 | die(); |
| 74 | - } |
|
| 74 | + } |
|
| 75 | 75 | } |
| 76 | 76 | break; |
| 77 | - case 'gitlab': |
|
| 78 | - $gitlab = $auth->getMethodByName('Auth\OAuth2\GitLabAuthenticator'); |
|
| 79 | - if(!isset($_GET['code'])) |
|
| 80 | - { |
|
| 81 | - $google->redirect(); |
|
| 82 | - die(); |
|
| 83 | - } |
|
| 84 | - else |
|
| 85 | - { |
|
| 86 | - $res = $gitlab->authenticate($_GET['code'], $current_user); |
|
| 87 | - switch($res) |
|
| 77 | + case 'gitlab': |
|
| 78 | + $gitlab = $auth->getMethodByName('Auth\OAuth2\GitLabAuthenticator'); |
|
| 79 | + if(!isset($_GET['code'])) |
|
| 80 | + { |
|
| 81 | + $google->redirect(); |
|
| 82 | + die(); |
|
| 83 | + } |
|
| 84 | + else |
|
| 88 | 85 | { |
| 86 | + $res = $gitlab->authenticate($_GET['code'], $current_user); |
|
| 87 | + switch($res) |
|
| 88 | + { |
|
| 89 | 89 | case \Auth\Authenticator::SUCCESS: |
| 90 | 90 | header('Location: '.$ref); |
| 91 | 91 | die(); |
@@ -96,11 +96,11 @@ discard block |
||
| 96 | 96 | case \Auth\Authenticator::ALREADY_PRESENT: |
| 97 | 97 | header('Location: user_exists.php?src=gitlab&uid='.$current_user->uid); |
| 98 | 98 | die(); |
| 99 | - } |
|
| 99 | + } |
|
| 100 | 100 | } |
| 101 | 101 | //Generic OAuth... |
| 102 | - default: |
|
| 103 | - print_r($_SERVER); |
|
| 104 | - break; |
|
| 102 | + default: |
|
| 103 | + print_r($_SERVER); |
|
| 104 | + break; |
|
| 105 | 105 | } |
| 106 | 106 | ?> |
@@ -6,14 +6,14 @@ discard block |
||
| 6 | 6 | |
| 7 | 7 | // array holding allowed Origin domains |
| 8 | 8 | $allowedOrigins = array( |
| 9 | - $settings->getGlobalSetting('www_url', 'https://www.burningflipside.com/'), |
|
| 10 | - $settings->getGlobalSetting('wiki_url', 'https://wiki.burningflipside.com/'), |
|
| 11 | - $settings->getGlobalSetting('profiles_url', 'https://profiles.burningflipside.com/'), |
|
| 12 | - $settings->getGlobalSetting('secure_url', 'https://secure.burningflipside.com/') |
|
| 9 | + $settings->getGlobalSetting('www_url', 'https://www.burningflipside.com/'), |
|
| 10 | + $settings->getGlobalSetting('wiki_url', 'https://wiki.burningflipside.com/'), |
|
| 11 | + $settings->getGlobalSetting('profiles_url', 'https://profiles.burningflipside.com/'), |
|
| 12 | + $settings->getGlobalSetting('secure_url', 'https://secure.burningflipside.com/') |
|
| 13 | 13 | ); |
| 14 | 14 | |
| 15 | 15 | if (isset($_SERVER['HTTP_ORIGIN']) && $_SERVER['HTTP_ORIGIN'] != '') { |
| 16 | - foreach ($allowedOrigins as $allowedOrigin) { |
|
| 16 | + foreach ($allowedOrigins as $allowedOrigin) { |
|
| 17 | 17 | if (preg_match('#' . $allowedOrigin . '#', $_SERVER['HTTP_ORIGIN'])) { |
| 18 | 18 | header('Access-Control-Allow-Origin: ' . $_SERVER['HTTP_ORIGIN']); |
| 19 | 19 | header('Access-Control-Allow-Methods: GET, PUT, POST, DELETE, OPTIONS'); |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | header('Access-Control-Allow-Headers: Authorization,Cookie,apikey'); |
| 22 | 22 | break; |
| 23 | 23 | } |
| 24 | - } |
|
| 24 | + } |
|
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | require_once('class.FlipREST.php'); |
@@ -12,10 +12,10 @@ |
||
| 12 | 12 | $settings->getGlobalSetting('secure_url', 'https://secure.burningflipside.com/') |
| 13 | 13 | ); |
| 14 | 14 | |
| 15 | -if (isset($_SERVER['HTTP_ORIGIN']) && $_SERVER['HTTP_ORIGIN'] != '') { |
|
| 16 | - foreach ($allowedOrigins as $allowedOrigin) { |
|
| 17 | - if (preg_match('#' . $allowedOrigin . '#', $_SERVER['HTTP_ORIGIN'])) { |
|
| 18 | - header('Access-Control-Allow-Origin: ' . $_SERVER['HTTP_ORIGIN']); |
|
| 15 | +if(isset($_SERVER['HTTP_ORIGIN']) && $_SERVER['HTTP_ORIGIN'] != '') { |
|
| 16 | + foreach($allowedOrigins as $allowedOrigin) { |
|
| 17 | + if(preg_match('#'.$allowedOrigin.'#', $_SERVER['HTTP_ORIGIN'])) { |
|
| 18 | + header('Access-Control-Allow-Origin: '.$_SERVER['HTTP_ORIGIN']); |
|
| 19 | 19 | header('Access-Control-Allow-Methods: GET, PUT, POST, DELETE, OPTIONS'); |
| 20 | 20 | header('Access-Control-Allow-Credentials: true'); |
| 21 | 21 | header('Access-Control-Allow-Headers: Authorization,Cookie,apikey'); |
@@ -12,9 +12,12 @@ |
||
| 12 | 12 | $settings->getGlobalSetting('secure_url', 'https://secure.burningflipside.com/') |
| 13 | 13 | ); |
| 14 | 14 | |
| 15 | -if (isset($_SERVER['HTTP_ORIGIN']) && $_SERVER['HTTP_ORIGIN'] != '') { |
|
| 16 | - foreach ($allowedOrigins as $allowedOrigin) { |
|
| 17 | - if (preg_match('#' . $allowedOrigin . '#', $_SERVER['HTTP_ORIGIN'])) { |
|
| 15 | +if (isset($_SERVER['HTTP_ORIGIN']) && $_SERVER['HTTP_ORIGIN'] != '') |
|
| 16 | +{ |
|
| 17 | + foreach ($allowedOrigins as $allowedOrigin) |
|
| 18 | + { |
|
| 19 | + if (preg_match('#' . $allowedOrigin . '#', $_SERVER['HTTP_ORIGIN'])) |
|
| 20 | + { |
|
| 18 | 21 | header('Access-Control-Allow-Origin: ' . $_SERVER['HTTP_ORIGIN']); |
| 19 | 22 | header('Access-Control-Allow-Methods: GET, PUT, POST, DELETE, OPTIONS'); |
| 20 | 23 | header('Access-Control-Allow-Credentials: true'); |
@@ -42,24 +42,24 @@ |
||
| 42 | 42 | |
| 43 | 43 | function add_links() |
| 44 | 44 | { |
| 45 | - $dirMenu = array( |
|
| 46 | - 'All' => 'directory.php', |
|
| 47 | - 'AAR' => 'directory.php?filter=aar', |
|
| 48 | - 'AFs' => 'directory.php?filter=af', |
|
| 49 | - 'CC' => 'directory.php?filter=cc', |
|
| 50 | - '360/24/7 Department' => 'directory.php?filter=360', |
|
| 51 | - 'Art' => 'directory.php?filter=Art', |
|
| 52 | - 'City Planning' => 'directory.php?filter=CityPlanning', |
|
| 53 | - 'Communications' => 'directory.php?filter=Comm', |
|
| 54 | - 'Genesis' => 'directory.php?filter=Genesis', |
|
| 55 | - 'Safety' => 'directory.php?filter=Safety', |
|
| 56 | - 'Site-Ops' => 'directory.php?filter=site-ops', |
|
| 57 | - 'Site Prep' => 'directory.php?filter=siteprep', |
|
| 58 | - 'Site Sign-Off' => 'directory.php?filter=sign-off', |
|
| 59 | - 'Volunteer Coordinator' => 'directory.php?filter=vc' |
|
| 60 | - ); |
|
| 61 | - $this->addLink('<span class="fa fa-dashboard"></span> Dashboard', 'index.php'); |
|
| 62 | - $this->addLink('<span class="fa fa-th-list"></span> Directory', false, $dirMenu); |
|
| 45 | + $dirMenu = array( |
|
| 46 | + 'All' => 'directory.php', |
|
| 47 | + 'AAR' => 'directory.php?filter=aar', |
|
| 48 | + 'AFs' => 'directory.php?filter=af', |
|
| 49 | + 'CC' => 'directory.php?filter=cc', |
|
| 50 | + '360/24/7 Department' => 'directory.php?filter=360', |
|
| 51 | + 'Art' => 'directory.php?filter=Art', |
|
| 52 | + 'City Planning' => 'directory.php?filter=CityPlanning', |
|
| 53 | + 'Communications' => 'directory.php?filter=Comm', |
|
| 54 | + 'Genesis' => 'directory.php?filter=Genesis', |
|
| 55 | + 'Safety' => 'directory.php?filter=Safety', |
|
| 56 | + 'Site-Ops' => 'directory.php?filter=site-ops', |
|
| 57 | + 'Site Prep' => 'directory.php?filter=siteprep', |
|
| 58 | + 'Site Sign-Off' => 'directory.php?filter=sign-off', |
|
| 59 | + 'Volunteer Coordinator' => 'directory.php?filter=vc' |
|
| 60 | + ); |
|
| 61 | + $this->addLink('<span class="fa fa-dashboard"></span> Dashboard', 'index.php'); |
|
| 62 | + $this->addLink('<span class="fa fa-th-list"></span> Directory', false, $dirMenu); |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | public function isAdmin() |