1
|
|
|
<?php |
|
|
|
|
2
|
|
|
/** |
3
|
|
|
* start page for webaccess |
4
|
|
|
* redirect the user to the supported page type by the users webbrowser (js available or not) |
5
|
|
|
* |
6
|
|
|
* PHP version 5 |
7
|
|
|
* |
8
|
|
|
* @category PHP |
9
|
|
|
* @package PSI |
10
|
|
|
* @author Michael Cramer <[email protected]> |
11
|
|
|
* @copyright 2009 phpSysInfo |
12
|
|
|
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License |
13
|
|
|
* @version SVN: $Id: index.php 687 2012-09-06 20:54:49Z namiltd $ |
14
|
|
|
* @link http://phpsysinfo.sourceforge.net |
15
|
|
|
*/ |
16
|
|
|
/** |
17
|
|
|
* define the application root path on the webserver |
18
|
|
|
* @var string |
19
|
|
|
*/ |
20
|
|
|
define('APP_ROOT', dirname(__FILE__)); |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* internal xml or external |
24
|
|
|
* external is needed when running in static mode |
25
|
|
|
* |
26
|
|
|
* @var boolean |
27
|
|
|
*/ |
28
|
|
|
define('PSI_INTERNAL_XML', false); |
29
|
|
|
|
30
|
|
|
if (version_compare("5.1.3", PHP_VERSION, ">")) { |
31
|
|
|
die("PHP 5.1.3 or greater is required!!!"); |
32
|
|
|
} |
33
|
|
|
if (!extension_loaded("pcre")) { |
34
|
|
|
die("phpSysInfo requires the pcre extension to php in order to work properly."); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
require_once APP_ROOT.'/includes/autoloader.inc.php'; |
38
|
|
|
|
39
|
|
|
// Load configuration |
40
|
|
|
require_once APP_ROOT.'/read_config.php'; |
41
|
|
|
|
42
|
|
|
if (!defined('PSI_CONFIG_FILE') || !defined('PSI_DEBUG')) { |
43
|
|
|
$tpl = new Template("/templates/html/error_config.html"); |
44
|
|
|
echo $tpl->fetch(); |
45
|
|
|
die(); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
// redirect to page with and without javascript |
49
|
|
|
$display = strtolower(isset($_GET['disp']) ? $_GET['disp'] : PSI_DEFAULT_DISPLAY_MODE); |
50
|
|
|
switch ($display) { |
51
|
|
|
case "static": |
52
|
|
|
$webpage = new WebpageXSLT(); |
53
|
|
|
$webpage->run(); |
54
|
|
|
break; |
55
|
|
|
case "dynamic": |
56
|
|
|
$webpage = new Webpage(); |
57
|
|
|
$webpage->run(); |
58
|
|
|
break; |
59
|
|
|
case "xml": |
60
|
|
|
$webpage = new WebpageXML(true, null); |
61
|
|
|
$webpage->run(); |
62
|
|
|
break; |
63
|
|
|
case "bootstrap": |
64
|
|
|
/* |
|
|
|
|
65
|
|
|
$tpl = new Template("/templates/html/index_bootstrap.html"); |
66
|
|
|
echo $tpl->fetch(); |
67
|
|
|
*/ |
68
|
|
|
$webpage = new Webpage("bootstrap"); |
69
|
|
|
$webpage->run(); |
70
|
|
|
break; |
71
|
|
|
case "auto": |
72
|
|
|
$tpl = new Template("/templates/html/index_all.html"); |
73
|
|
|
echo $tpl->fetch(); |
74
|
|
|
break; |
75
|
|
|
default: |
76
|
|
|
$defaultdisplay = strtolower(PSI_DEFAULT_DISPLAY_MODE); |
77
|
|
|
switch ($defaultdisplay) { |
78
|
|
|
case "static": |
79
|
|
|
$webpage = new WebpageXSLT(); |
80
|
|
|
$webpage->run(); |
81
|
|
|
break; |
82
|
|
|
case "dynamic": |
83
|
|
|
$webpage = new Webpage(); |
84
|
|
|
$webpage->run(); |
85
|
|
|
break; |
86
|
|
|
case "bootstrap": |
87
|
|
|
$webpage = new Webpage("bootstrap"); |
88
|
|
|
$webpage->run(); |
89
|
|
|
break; |
90
|
|
|
default: |
91
|
|
|
$tpl = new Template("/templates/html/index_all.html"); |
92
|
|
|
echo $tpl->fetch(); |
93
|
|
|
break; |
94
|
|
|
} |
95
|
|
|
break; |
96
|
|
|
} |
97
|
|
|
|
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.