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) |
||
| 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 |
|
|
0 ignored issues
–
show
|
|||
| 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: |
||
|
0 ignored issues
–
show
case \Auth\Authenticator...: login.php'); die; does not seem to be reachable.
This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed. Unreachable code is most often the result of function fx() {
try {
doSomething();
return true;
}
catch (\Exception $e) {
return false;
}
return false;
}
In the above example, the last Loading history...
|
|||
| 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 |
|
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. Loading history...
|
|||
| 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 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.