@@ -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); |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | global $app; |
| 39 | 39 | $array = $app->getJSONBody(true); |
| 40 | 40 | |
| 41 | - try{ |
|
| 41 | + try { |
|
| 42 | 42 | $message = Message::fromArray($array); |
| 43 | 43 | |
| 44 | 44 | // Validate the message |
@@ -76,13 +76,13 @@ discard block |
||
| 76 | 76 | { |
| 77 | 77 | $strlen = strlen($string); |
| 78 | 78 | $testlen = strlen($test); |
| 79 | - if ($testlen > $strlen) return false; |
|
| 79 | + if($testlen > $strlen) return false; |
|
| 80 | 80 | return substr_compare($string, $test, $strlen - $testlen, $testlen) === 0; |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | function getDestinationsForID($id) |
| 84 | 84 | { |
| 85 | - if(strcasecmp($id,'pboyd') === 0) |
|
| 85 | + if(strcasecmp($id, 'pboyd') === 0) |
|
| 86 | 86 | { |
| 87 | 87 | return array('[email protected]'); |
| 88 | 88 | } |
@@ -38,13 +38,16 @@ discard block |
||
| 38 | 38 | global $app; |
| 39 | 39 | $array = $app->getJSONBody(true); |
| 40 | 40 | |
| 41 | - try{ |
|
| 41 | + try |
|
| 42 | + { |
|
| 42 | 43 | $message = Message::fromArray($array); |
| 43 | 44 | |
| 44 | 45 | // Validate the message |
| 45 | 46 | $validator = new MessageValidator(); |
| 46 | 47 | $validator->validate($message); |
| 47 | - } catch(\Exception $e) { |
|
| 48 | + } |
|
| 49 | + catch(\Exception $e) |
|
| 50 | + { |
|
| 48 | 51 | $app->notFound(); |
| 49 | 52 | } |
| 50 | 53 | |
@@ -76,7 +79,10 @@ discard block |
||
| 76 | 79 | { |
| 77 | 80 | $strlen = strlen($string); |
| 78 | 81 | $testlen = strlen($test); |
| 79 | - if ($testlen > $strlen) return false; |
|
| 82 | + if ($testlen > $strlen) |
|
| 83 | + { |
|
| 84 | + return false; |
|
| 85 | + } |
|
| 80 | 86 | return substr_compare($string, $test, $strlen - $testlen, $testlen) === 0; |
| 81 | 87 | } |
| 82 | 88 | |
@@ -14,8 +14,8 @@ |
||
| 14 | 14 | $provider = $auth->getSuplementalProviderByHost($_GET['src']); |
| 15 | 15 | if($provider !== false) |
| 16 | 16 | { |
| 17 | - $user = $provider->getUserFromToken(false); |
|
| 18 | - $email = $user->getEmail(); |
|
| 17 | + $user = $provider->getUserFromToken(false); |
|
| 18 | + $email = $user->getEmail(); |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | $page->body .= ' |
@@ -24,18 +24,18 @@ discard block |
||
| 24 | 24 | |
| 25 | 25 | switch($src) |
| 26 | 26 | { |
| 27 | - case 'google': |
|
| 28 | - $google = $auth->getAuthenticator('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->getAuthenticator('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->getUid()); |
| 48 | 48 | die(); |
| 49 | - } |
|
| 49 | + } |
|
| 50 | 50 | } |
| 51 | 51 | break; |
| 52 | - case 'twitter': |
|
| 53 | - $twitter = $auth->getAuthenticator('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->getAuthenticator('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->getUid()); |
| 73 | 73 | die(); |
| 74 | - } |
|
| 74 | + } |
|
| 75 | 75 | } |
| 76 | 76 | break; |
| 77 | - case 'gitlab': |
|
| 78 | - $gitlab = $auth->getAuthenticator('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->getAuthenticator('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->getUid()); |
| 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 | ?> |
@@ -28,7 +28,7 @@ |
||
| 28 | 28 | $page->add_card('fa-cc', $cc_count, 'Combustion Chamger', 'directory.php?filter=cc', $page::CARD_YELLOW); |
| 29 | 29 | $page->add_card('fa-fire', $aar_count, 'Board Members', 'directory.php?filter=aar', $page::CARD_RED); |
| 30 | 30 | |
| 31 | -$page->body .='</div>'; |
|
| 31 | +$page->body .= '</div>'; |
|
| 32 | 32 | |
| 33 | 33 | $page->print_page(); |
| 34 | 34 | ?> |
@@ -85,7 +85,7 @@ |
||
| 85 | 85 | { |
| 86 | 86 | if($res) |
| 87 | 87 | { |
| 88 | - $app->redirect('../../'); |
|
| 88 | + $app->redirect('../../'); |
|
| 89 | 89 | } |
| 90 | 90 | else |
| 91 | 91 | { |
@@ -41,7 +41,10 @@ discard block |
||
| 41 | 41 | { |
| 42 | 42 | $user = \AuthProvider::getInstance()->getPendingUsersByFilter(new \Data\Filter("hash eq '$hash'")); |
| 43 | 43 | } |
| 44 | - if($user === false) $app->halt(404); |
|
| 44 | + if($user === false) |
|
| 45 | + { |
|
| 46 | + $app->halt(404); |
|
| 47 | + } |
|
| 45 | 48 | if(!is_object($user) && isset($user[0])) |
| 46 | 49 | { |
| 47 | 50 | $user = $user[0]; |
@@ -79,7 +82,10 @@ discard block |
||
| 79 | 82 | { |
| 80 | 83 | $auth = \AuthProvider::getInstance(); |
| 81 | 84 | $user = $auth->getPendingUsersByFilter(new \Data\Filter("hash eq '$hash'")); |
| 82 | - if($user === false || !isset($user[0])) $app->halt(404); |
|
| 85 | + if($user === false || !isset($user[0])) |
|
| 86 | + { |
|
| 87 | + $app->halt(404); |
|
| 88 | + } |
|
| 83 | 89 | $res = $auth->activatePendingUser($user[0]); |
| 84 | 90 | if($app->request->isGet()) |
| 85 | 91 | { |
@@ -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 | function add_header() |
@@ -139,10 +139,10 @@ |
||
| 139 | 139 | |
| 140 | 140 | function current_url() |
| 141 | 141 | { |
| 142 | - return 'http'.(isset($_SERVER['HTTPS'])?'s':'').'://'."{$_SERVER['HTTP_HOST']}/{$_SERVER['REQUEST_URI']}"; |
|
| 142 | + return 'http'.(isset($_SERVER['HTTPS']) ? 's' : '').'://'."{$_SERVER['HTTP_HOST']}/{$_SERVER['REQUEST_URI']}"; |
|
| 143 | 143 | } |
| 144 | 144 | |
| 145 | - function print_page($header=true) |
|
| 145 | + function print_page($header = true) |
|
| 146 | 146 | { |
| 147 | 147 | if($this->user == false) |
| 148 | 148 | { |
@@ -21,7 +21,7 @@ |
||
| 21 | 21 | $this->add_profiles_css(); |
| 22 | 22 | $this->add_profiles_script(); |
| 23 | 23 | $this->add_login_form(); |
| 24 | - $this->body_tags='data-login-url="'.$this->profiles_root.'/api/v1/login"'; |
|
| 24 | + $this->body_tags = 'data-login-url="'.$this->profiles_root.'/api/v1/login"'; |
|
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | function add_profiles_css() |
@@ -7,10 +7,10 @@ |
||
| 7 | 7 | $page->addWellKnownJS(JS_BOOTSTRAP_FH); |
| 8 | 8 | $page->addJSByURI('js/user_edit.js'); |
| 9 | 9 | |
| 10 | -$hidden=''; |
|
| 10 | +$hidden = ''; |
|
| 11 | 11 | if(!isset($_GET['uid'])) |
| 12 | 12 | { |
| 13 | - $hidden='style="display: none"'; |
|
| 13 | + $hidden = 'style="display: none"'; |
|
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | $page->body .= ' |
@@ -8,10 +8,10 @@ |
||
| 8 | 8 | $page->addWellKnownCSS(CSS_DATATABLE); |
| 9 | 9 | $page->addJSByURI('js/group_edit.js'); |
| 10 | 10 | |
| 11 | -$hidden=''; |
|
| 11 | +$hidden = ''; |
|
| 12 | 12 | if(!isset($_GET['gid'])) |
| 13 | 13 | { |
| 14 | - $hidden='style="display: none"'; |
|
| 14 | + $hidden = 'style="display: none"'; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | $page->body .= ' |