| Conditions | 12 |
| Paths | 289 |
| Total Lines | 91 |
| Code Lines | 60 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 46 | public function doLoginForm($msg = '') |
||
|
1 ignored issue
–
show
|
|||
| 47 | { |
||
| 48 | $lang = $this->lang; |
||
| 49 | |||
| 50 | $this->misc->setNoDBConnection(true); |
||
| 51 | |||
| 52 | $server_id = $this->container->requestobj->getQueryParam('server'); |
||
| 53 | |||
| 54 | if (null === $server_id) { |
||
| 55 | $this->prtrace('invalid server param'); |
||
| 56 | |||
| 57 | return $this->lang['strinvalidserverparam']; |
||
| 58 | } |
||
| 59 | |||
| 60 | $login_html = $this->printHeader($lang[$this->controller_title], $this->scripts, false); |
||
| 61 | $login_html .= $this->printBody(false); |
||
| 62 | $login_html .= $this->printTrail('root', false); |
||
| 63 | |||
| 64 | if (!empty($_POST)) { |
||
| 65 | $vars = &$_POST; |
||
| 66 | } else { |
||
| 67 | $vars = &$_GET; |
||
| 68 | } |
||
| 69 | foreach ($_REQUEST as $key => $val) { |
||
| 70 | if (false !== strpos($key, '?')) { |
||
| 71 | $namexploded = explode('?', $key); |
||
| 72 | $_REQUEST[$namexploded[1]] = htmlspecialchars($val); |
||
| 73 | } |
||
| 74 | } |
||
| 75 | |||
| 76 | $server_info = $this->misc->getServerInfo($server_id); |
||
| 77 | $title = sprintf($lang['strlogintitle'], $server_info['desc']); |
||
| 78 | |||
| 79 | $printTitle = $this->printTitle($title, null, false); |
||
| 80 | |||
| 81 | $login_html .= $printTitle; |
||
| 82 | |||
| 83 | if (isset($msg)) { |
||
| 84 | $login_html .= $this->printMsg($msg, false); |
||
| 85 | } |
||
| 86 | |||
| 87 | $login_html .= '<form id="login_form" method="post" name="login_form" action="' . \SUBFOLDER . '/redirect/server?server=' . htmlspecialchars($server_id) . '">'; |
||
| 88 | |||
| 89 | $md5_server = md5($server_id); |
||
| 90 | // Pass request vars through form (is this a security risk???) |
||
| 91 | foreach ($vars as $key => $val) { |
||
| 92 | if ('login' == substr($key, 0, 5)) { |
||
| 93 | continue; |
||
| 94 | } |
||
| 95 | if (false !== strpos($key, '?')) { |
||
| 96 | $key = explode('?', $key)[1]; |
||
| 97 | } |
||
| 98 | |||
| 99 | $login_html .= '<input type="hidden" name="' . htmlspecialchars($key) . '" value="' . htmlspecialchars($val) . '" />' . "\n"; |
||
| 100 | } |
||
| 101 | |||
| 102 | $login_html .= '<input type="hidden" name="loginServer" value="' . htmlspecialchars($server_id) . '" />'; |
||
| 103 | $login_html .= '<table class="navbar" border="0" cellpadding="5" cellspacing="3">'; |
||
| 104 | $login_html .= '<tr>'; |
||
| 105 | $login_html .= '<td>' . $lang['strusername'] . '</td>'; |
||
| 106 | $loginusername = isset($_POST['loginUsername']) ? htmlspecialchars($_POST['loginUsername']) : ''; |
||
| 107 | |||
| 108 | $login_html .= '<td><input type="text" name="loginUsername" value="' . $loginusername . '" size="24" /></td>'; |
||
| 109 | $login_html .= '</tr>'; |
||
| 110 | $login_html .= '<tr>'; |
||
| 111 | $login_html .= '<td>' . $lang['strpassword'] . '</td>'; |
||
| 112 | $login_html .= '<td><input id="loginPassword" type="password" name="loginPassword_' . $md5_server . '" size="24" /></td>'; |
||
| 113 | $login_html .= '</tr>'; |
||
| 114 | $login_html .= '</table>'; |
||
| 115 | if (sizeof($this->conf['servers']) > 1) { |
||
| 116 | $checked = isset($_POST['loginShared']) ? 'checked="checked"' : ''; |
||
| 117 | $login_html .= '<p><input type="checkbox" id="loginShared" name="loginShared" ' . $checked . ' />'; |
||
| 118 | $login_html .= '<label for="loginShared">' . $lang['strtrycred'] . '</label></p>'; |
||
| 119 | } |
||
| 120 | $login_html .= '<p><input type="submit" name="loginSubmit" value="' . $lang['strlogin'] . '" /></p>'; |
||
| 121 | $login_html .= '</form>'; |
||
| 122 | |||
| 123 | $login_html .= '<script type="text/javascript">'; |
||
| 124 | $login_html .= ' var uname = document.login_form.loginUsername;'; |
||
| 125 | $login_html .= ' var pword = document.login_form.loginPassword_' . $md5_server . ';'; |
||
| 126 | $login_html .= ' if (uname.value == "") {'; |
||
| 127 | $login_html .= ' uname.focus();'; |
||
| 128 | $login_html .= ' } else {'; |
||
| 129 | $login_html .= ' pword.focus();'; |
||
| 130 | $login_html .= ' }'; |
||
| 131 | $login_html .= '</script>'; |
||
| 132 | |||
| 133 | // Output footer |
||
| 134 | $login_html .= $this->printFooter(false); |
||
| 135 | |||
| 136 | return $login_html; |
||
| 137 | } |
||
| 139 |