| Conditions | 16 |
| Paths | 224 |
| Total Lines | 40 |
| Code Lines | 27 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 1 | Features | 1 |
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 |
||
| 67 | function preflight($s) { |
||
| 68 | if (isset($_GET['FORCE_DEBUG'])) { |
||
| 69 | $s->setOption(PhpXmlRpc\Server::OPT_DEBUG, $_GET['FORCE_DEBUG']); |
||
| 70 | } |
||
| 71 | if (isset($_GET['RESPONSE_ENCODING'])) { |
||
| 72 | $s->setOption(PhpXmlRpc\Server::OPT_RESPONSE_CHARSET_ENCODING, $_GET['RESPONSE_ENCODING']); |
||
| 73 | } |
||
| 74 | if (isset($_GET['DETECT_ENCODINGS'])) { |
||
| 75 | PhpXmlRpc\PhpXmlRpc::$xmlrpc_detectencodings = $_GET['DETECT_ENCODINGS']; |
||
| 76 | } |
||
| 77 | if (isset($_GET['EXCEPTION_HANDLING'])) { |
||
| 78 | $s->setOption(PhpXmlRpc\Server::OPT_EXCEPTION_HANDLING, $_GET['EXCEPTION_HANDLING']); |
||
| 79 | } |
||
| 80 | if (isset($_GET['FORCE_AUTH'])) { |
||
| 81 | // We implement both Basic and Digest auth in php to avoid having to set it up in a vhost. |
||
| 82 | // Code taken from php.net |
||
| 83 | // NB: we do NOT check for valid credentials! |
||
| 84 | if ($_GET['FORCE_AUTH'] == 'Basic') { |
||
| 85 | if (!isset($_SERVER['PHP_AUTH_USER']) && !isset($_SERVER['REMOTE_USER']) && !isset($_SERVER['REDIRECT_REMOTE_USER'])) { |
||
| 86 | header('HTTP/1.0 401 Unauthorized'); |
||
| 87 | header('WWW-Authenticate: Basic realm="Phpxmlrpc Basic Realm"'); |
||
| 88 | die('Text visible if user hits Cancel button'); |
||
| 89 | } |
||
| 90 | } elseif ($_GET['FORCE_AUTH'] == 'Digest') { |
||
| 91 | if (empty($_SERVER['PHP_AUTH_DIGEST'])) { |
||
| 92 | header('HTTP/1.1 401 Unauthorized'); |
||
| 93 | header('WWW-Authenticate: Digest realm="Phpxmlrpc Digest Realm",qop="auth",nonce="' . uniqid() . '",opaque="' . md5('Phpxmlrpc Digest Realm') . '"'); |
||
| 94 | die('Text visible if user hits Cancel button'); |
||
| 95 | } |
||
| 96 | } |
||
| 97 | } |
||
| 98 | if (isset($_GET['FORCE_REDIRECT'])) { |
||
| 99 | header('HTTP/1.0 302 Found'); |
||
| 100 | unset($_GET['FORCE_REDIRECT']); |
||
| 101 | header('Location: ' . $_SERVER['REQUEST_URI'] . (count($_GET) ? '?' . http_build_query($_GET) : '')); |
||
| 102 | die(); |
||
| 103 | } |
||
| 104 | if (isset($_GET['SLOW_LORIS']) && $_GET['SLOW_LORIS'] > 0) { |
||
| 105 | slowLoris((int)$_GET['SLOW_LORIS'], $s); |
||
| 106 | die(); |
||
| 107 | } |
||
| 130 |