These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
0 ignored issues
–
show
|
|||
2 | /** |
||
3 | * @title Constants |
||
4 | * |
||
5 | * @author Pierre-Henry Soria <[email protected]> |
||
6 | * @copyright (c) 2012-2017, Pierre-Henry Soria. All Rights Reserved. |
||
7 | * @license GNU General Public License; See PH7.LICENSE.txt and PH7.COPYRIGHT.txt in the root directory. |
||
8 | * @link http://ph7cms.com |
||
9 | * @package PH7 |
||
10 | */ |
||
11 | |||
12 | namespace PH7; |
||
13 | defined('PH7') or exit(header('Location: ./')); |
||
14 | |||
15 | ################################### VARIABLES ################################### |
||
16 | |||
17 | #################### PATH #################### |
||
18 | |||
19 | #################### URL #################### |
||
20 | |||
21 | // Check the SSL protocol compatibility |
||
22 | $sHttp = (!empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS'] == 'on')) ? 'https://' : 'http://'; |
||
23 | // Determine the domain name, with the port if necessary |
||
24 | $sDomain = (($_SERVER['SERVER_PORT'] != '80') && ($_SERVER['SERVER_PORT'] != '443')) ? $_SERVER['SERVER_NAME'] . ':' . $_SERVER['SERVER_PORT'] : $_SERVER['SERVER_NAME']; |
||
25 | |||
26 | // Get the domain that the cookie and cookie session is available (Set-Cookie: domain=your_site_name.com) |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
39% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them.
Loading history...
|
|||
27 | // $sDomain_cookie = (substr($_SERVER['HTTP_HOST'], 0, 4) === 'www.') ? '.' . substr($_SERVER['HTTP_HOST'], 4) : '.' . $_SERVER['HTTP_HOST']; |
||
28 | $sDomain_cookie = '.' . str_replace('www.', '', $sDomain); |
||
29 | |||
30 | // Determine the current file of the application |
||
31 | $sPhp_self = str_replace('\\', '', dirname(htmlspecialchars($_SERVER['PHP_SELF'], ENT_QUOTES))); // Remove backslashes for Windows compatibility |
||
32 | |||
33 | |||
34 | ################################### CONSTANTS ################################### |
||
35 | |||
36 | #################### OTHER #################### |
||
37 | |||
38 | define('PH7_DS', DIRECTORY_SEPARATOR); |
||
39 | define('PH7_PS', PATH_SEPARATOR); |
||
40 | define('PH7_SH', '/'); // SlasH |
||
41 | define('PH7_SELF', (substr($sPhp_self, -1) !== PH7_SH) ? $sPhp_self . PH7_SH : $sPhp_self); |
||
42 | define('PH7_RELATIVE', PH7_SELF); |
||
43 | |||
44 | #################### PATH #################### |
||
45 | |||
46 | define('PH7_PATH_ROOT', __DIR__ . PH7_DS); |
||
47 | define('PH7_PATH_PROTECTED', '%path_protected%'); |
||
48 | define('PH7_PATH_APP', PH7_PATH_PROTECTED . 'app/'); |
||
49 | define('PH7_PATH_FRAMEWORK', PH7_PATH_PROTECTED . 'framework/'); |
||
50 | define('PH7_PATH_LIBRARY', PH7_PATH_PROTECTED . 'library/'); |
||
51 | |||
52 | #################### URL (PUBLIC) #################### |
||
53 | |||
54 | define('PH7_URL_PROT', $sHttp); // URL protocol |
||
55 | define('PH7_DOMAIN', $sDomain); // URL domain |
||
56 | define('PH7_DOMAIN_COOKIE', $sDomain_cookie); |
||
57 | define('PH7_URL_ROOT', PH7_URL_PROT . PH7_DOMAIN . PH7_SELF); |
||
58 |
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.