BurningFlipside /
Profiles
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | require('Autoload.php'); |
||
| 3 | |||
| 4 | function doAuthByType($type, $src, $auth, $ref) |
||
|
1 ignored issue
–
show
|
|||
| 5 | { |
||
| 6 | $currentUser = false; |
||
| 7 | $google = $auth->getMethodByName($type); |
||
| 8 | if(!isset($_GET['code'])) |
||
| 9 | { |
||
| 10 | $google->redirect(); |
||
| 11 | die(); |
||
| 12 | } |
||
| 13 | View Code Duplication | else |
|
| 14 | { |
||
| 15 | $res = $google->authenticate($_GET['code'], $currentUser); |
||
| 16 | switch($res) |
||
| 17 | { |
||
| 18 | case \Auth\Authenticator::SUCCESS: |
||
| 19 | header('Location: '.$ref); |
||
| 20 | die(); |
||
| 21 | default: |
||
| 22 | case \Auth\Authenticator::LOGIN_FAILED: |
||
| 23 | header('Location: login.php'); |
||
| 24 | die(); |
||
| 25 | case \Auth\Authenticator::ALREADY_PRESENT: |
||
| 26 | header('Location: user_exists.php?src='.$src.'&uid='.$currentUser->uid); |
||
| 27 | die(); |
||
| 28 | } |
||
| 29 | } |
||
| 30 | } |
||
| 31 | |||
| 32 | $auth = AuthProvider::getInstance(); |
||
| 33 | $src = false; |
||
| 34 | if(isset($_GET['src'])) |
||
| 35 | { |
||
| 36 | $src = $_GET['src']; |
||
| 37 | } |
||
| 38 | else if(strstr($_SERVER['HTTP_REFERER'], 'google.com') !== false) |
||
| 39 | { |
||
| 40 | $src = 'google'; |
||
| 41 | } |
||
| 42 | else if(strstr($_SERVER['HTTP_REFERER'], 'gitlab.com') !== false) |
||
| 43 | { |
||
| 44 | $src = 'gitlab'; |
||
| 45 | } |
||
| 46 | |||
| 47 | $ref = '.'; |
||
| 48 | if(isset($_SERVER['HTTP_REFERER']) && strstr($_SERVER['HTTP_REFERER'], 'google.com') === false) |
||
| 49 | { |
||
| 50 | $ref = $_SERVER['HTTP_REFERER']; |
||
| 51 | } |
||
| 52 | |||
| 53 | switch($src) |
||
| 54 | { |
||
| 55 | case 'google': |
||
| 56 | doAuthByType('Auth\GoogleAuthenticator', $src, $auth, $ref); |
||
| 57 | break; |
||
| 58 | case 'twitter': |
||
| 59 | $twitter = $auth->getMethodByName('Auth\TwitterAuthenticator'); |
||
| 60 | if(!isset($_GET['oauth_token']) || !isset($_GET['oauth_verifier'])) |
||
| 61 | { |
||
| 62 | $twitter->redirect(); |
||
| 63 | die(); |
||
| 64 | } |
||
| 65 | View Code Duplication | else |
|
| 66 | { |
||
| 67 | $twitter->authenticate($_GET['oauth_token'], $_GET['oauth_verifier'], $current_user); |
||
| 68 | switch($res) |
||
| 69 | { |
||
| 70 | case \Auth\Authenticator::SUCCESS: |
||
| 71 | header('Location: '.$ref); |
||
| 72 | die(); |
||
| 73 | default: |
||
| 74 | case \Auth\Authenticator::LOGIN_FAILED: |
||
| 75 | header('Location: login.php'); |
||
| 76 | die(); |
||
| 77 | case \Auth\Authenticator::ALREADY_PRESENT: |
||
| 78 | header('Location: user_exists.php?src=twitter&uid='.$current_user->uid); |
||
| 79 | die(); |
||
| 80 | } |
||
| 81 | } |
||
| 82 | break; |
||
| 83 | case 'gitlab': |
||
| 84 | doAuthByType('Auth\OAuth2\GitLabAuthenticator', $src, $auth, $ref); |
||
| 85 | break; |
||
| 86 | //Generic OAuth... |
||
| 87 | default: |
||
| 88 | print_r($_SERVER); |
||
| 89 | break; |
||
| 90 | } |
||
| 91 | /* vim: set tabstop=4 shiftwidth=4 expandtab: */ |
||
| 92 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.