/
platform.php
179 lines (165 loc) · 4.03 KB
/
platform.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
<?php
/**
* This is platform class implementation
* @version $Id: platform.php 40 2011-02-09 14:10:00Z biyi $
* @package Platform
* @category Class
* @author Biyi Akinpelu
* @link mailto:biyi@entilda.com
* @copyright Copyright (C) 2011 Entilda IT Solutions. All rights reserved.
* @license GNU/GPL, see LICENSE.php
* Platform is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/
class Platform {
/**
* __construct: This is a constructor
* @param void
*
* @return void
*/
public function __construct(){
//$this->launch_start_profiler();
$this->launch_initialize();
$this->launch_debug(true);
//if (!IS_CLI) $this->launch_dispatch($_SERVER['QUERY_STRING']);
//$this->launch_stop_profiler($xhprof_data);
}
/**
* launch: used to attach/include a file
* @param string $file The file to launch and load
*
* @return void
*/
public function launch($file){
require_once "{$file}";
}
/**
* launch_php: used to attach/include a php file
* @param string $file The php file to launch and load
*
* @return void
*/
public function launch_php($file){
$this->launch("{$file}.php");
}
/**
* launch_phtml: used to attach/include a phtml file
* @param string $file The phtml file to launch and load
*
* @return void
*/
function launch_phtml($file){
$this->launch("{$file}.phtml");
}
/**
* launch_initialize: used to initialize bootstrapping process
* @param void
*
* @return void
*/
function launch_initialize(){
global $paths;
foreach ($paths as $instance => $path)
{
$contents = $this->launch_list_php($path);
if (is_dir($path))
{
if (!stristr($instance, 'templates')){ // excluding templates
if (!empty($contents)){
foreach ($contents as $file) {
$full_filename = $path . DS . $file;
$this->launch($full_filename);
}
}
}
} else {
break;
}
}
}
/**
* launch_list_php: used to list all php files contained within $path
* @param string $path The path to get all php file lists
*
* @return Mixed $contents Array containing the list of php files within $path
*/
function launch_list_php($path){
$this->launch_php(PLATFORM_SANDBOX_SYSTEM_FUNCTIONS_PATH . DS . 'filesystem');
$contents = list_files($path, 'php');
return $contents;
}
/**
* launch_dispatch: used to dispatch system requests
* @param void
*
* @return void
*/
function launch_dispatch($request=null){
switch($request){
case 'platform':
$this->launch_sandbox_system_index();
break;
case 'security':
$this->launch_ip_authorization_checks();
break;
case 'browser':
default:
if (empty($request) || is_null($request)){
$this->launch_browser();
} else {
$this->launch_sandbox_system_index();
//benchmark_view();
}
break;
}
}
/**
* platform_launch_start_profiler: used to start system profiler
* @param void
*
* @return void
*/
function launch_start_profiler(){
xhprof_enable(XHPROF_FLAGS_CPU + XHPROF_FLAGS_MEMORY);
}
/**
* platform_launch_stop_profiler: used to stop system profiler
* @param Mixed $xhprof_data Data generated from profiling the system
*
* @return void
*/
function launch_stop_profiler(&$xhprof_data){
$xhprof_data = xhprof_disable();
}
/**
* platform_launch_debug: used to load the system debugger
* @param string $status The path to list
*
* @return void
*/
function launch_debug($status=0){
$this->launch_php('debug');
switch($status){
case 1:
error_reporting(E_ALL | E_STRICT);
ini_set("display", $status);
break;
case 0:
default:
error_reporting($status);
break;
}
}
/**
* __construct: This is a destructor
* @param void
*
* @return void
*/
public function __destruct(){
}
}