Conditions | 13 |
Paths | 250 |
Total Lines | 47 |
Code Lines | 22 |
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 |
||
18 | public function execute() { |
||
19 | $OSCOM_Session = Registry::get('Session'); |
||
20 | |||
21 | // initialize a session token |
||
22 | if (!isset($_SESSION['sessiontoken'])) { |
||
23 | $_SESSION['sessiontoken'] = md5(Hash::getRandomInt() . Hash::getRandomInt() . Hash::getRandomInt() . Hash::getRandomInt()); |
||
24 | } |
||
25 | |||
26 | // verify the ssl_session_id if the feature is enabled |
||
27 | if ((HTTP::getRequestType() === 'SSL') && (SESSION_CHECK_SSL_SESSION_ID == 'True') && $OSCOM_Session->hasStarted()) { |
||
28 | if (!isset($_SESSION['SSL_SESSION_ID'])) { |
||
29 | $_SESSION['SESSION_SSL_ID'] = $_SERVER['SSL_SESSION_ID']; |
||
30 | } |
||
31 | |||
32 | if ($_SESSION['SESSION_SSL_ID'] != $_SERVER['SSL_SESSION_ID']) { |
||
33 | $OSCOM_Session->kill(); |
||
34 | |||
35 | OSCOM::redirect('ssl_check.php'); |
||
36 | } |
||
37 | } |
||
38 | |||
39 | // verify the browser user agent if the feature is enabled |
||
40 | if (SESSION_CHECK_USER_AGENT == 'True') { |
||
41 | if (!isset($_SESSION['SESSION_USER_AGENT'])) { |
||
42 | $_SESSION['SESSION_USER_AGENT'] = $_SERVER['HTTP_USER_AGENT']; |
||
43 | } |
||
44 | |||
45 | if ($_SESSION['SESSION_USER_AGENT'] != $_SERVER['HTTP_USER_AGENT']) { |
||
46 | $OSCOM_Session->kill(); |
||
47 | |||
48 | OSCOM::redirect('login.php'); |
||
49 | } |
||
50 | } |
||
51 | |||
52 | // verify the IP address if the feature is enabled |
||
53 | if (SESSION_CHECK_IP_ADDRESS == 'True') { |
||
54 | if (!isset($_SESSION['SESSION_IP_ADDRESS'])) { |
||
55 | $_SESSION['SESSION_IP_ADDRESS'] = HTTP::getIpAddress(); |
||
56 | } |
||
57 | |||
58 | if ($_SESSION['SESSION_IP_ADDRESS'] != HTTP::getIpAddress()) { |
||
59 | $OSCOM_Session->kill(); |
||
60 | |||
61 | OSCOM::redirect('login.php'); |
||
62 | } |
||
63 | } |
||
64 | } |
||
65 | } |
||
66 |