-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathphpinit.php
More file actions
116 lines (98 loc) · 3.51 KB
/
phpinit.php
File metadata and controls
116 lines (98 loc) · 3.51 KB
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
<?php
// init some php stuff
function phpinit ($session = true, $header = false, $libloader = null) {
// Header?
if ($header !== false) {
// Set header
header($header);
}
// Start Session
if ($session)
session_start();
// Disable magic_quotes if available
if (get_magic_quotes_gpc() || get_magic_quotes_runtime()) {
ini_set('magic_quotes_gpc', 0);
ini_set('magic_quotes_runtime', 0);
}
// Default libloader
if (is_null($libloader)) {
$libloader = create_function ('$classname', '
$step = \'./steps/\'.$classname.\'.php\';
$lib = \'./lib/\'.$classname.\'.php\';
$class = \'./classes/\'.$classname.\'.php\';
if (file_exists($step) && false !== (require_once($step)))
return;
if (file_exists($lib) && false !== (require_once($lib)))
return;
if (file_exists($class) && false !== (require_once($class)))
return;');
}
// no libloader?
if ($libloader === false)
spl_autoload_register();
else
spl_autoload_register($libloader);
// load exceptions
require('./classes/Exceptions.php');
}
// turn on debuggin mode
function debug() {
// turn on errors
error_reporting(E_ALL);
ini_set('display_errors', true);
}
// setup file access type
function fileaccess() {
@include('./copy/file_connection.php');
if (isset($wrapper) && ini_get('allow_url_fopen')) {
// set path prefixes
if (!empty($wrapper['target']) && isset($wrapper['install_to'])) {
Path::setPrefix($wrapper['target'].$wrapper['install_to'], 'target', 'write_wrapper');
}
if (!empty($wrapper['installer']) && isset($wrapper['installer_path'])) {
Path::setPrefix($wrapper['installer'].$wrapper['installer_path'], 'current', 'write_wrapper');
}
}
unset($wrapper);
// create wrapper url
//~ $conn = ($ftp['ssl']?'ftps://':'ftp://')
//~ .(!empty($ftp['user'])?$ftp['user'].(!empty($ftp['pass'])?':'.$ftp['pass']:'').'@':'')
//~ .$ftp['host'];
}
// perform some inits for the installer
function setup() {
// setup fileaccess
fileaccess();
// Installer Folder Name
define('INSTALLER_FOLDER', 'fs2installer', true);
// installer path
if (!isset($_SESSION['installer_path'])) {
$_SESSION['installer_path'] = '.';
}
define('INSTALLER_PATH', $_SESSION['installer_path'], true);
Path::setPrefix(INSTALLER_PATH, 'current');
// New version to be installed
$_SESSION['upgrade_to'] = trim(Files::file_get_contents(new Path('copy/version', 'current')));
define('UPGRADE_TO', $_SESSION['upgrade_to'], true);
// check for install path and from version
if (isset($_SESSION['install_to'])) {
$_SESSION['install_to'] = rtrim($_SESSION['install_to'], '/\\');
define('INSTALL_TO', $_SESSION['install_to'], true);
Path::setPrefix(INSTALL_TO, 'target');
if (!isset($_SESSION['upgrade_from'])) {
if (false === $_SESSION['upgrade_from'] = InstallerFunctions::getInstalledFS2Version(INSTALL_TO)) {
$_SESSION['upgrade_from'] = 'none';
}
}
}
// old version
if (isset($_SESSION['upgrade_from'])) {
define('UPGRADE_FROM', $_SESSION['upgrade_from'], true);
}
// URL to installed property
if (!isset($_SESSION['url'])) {
$_SESSION['url'] = $_SERVER['PHP_SELF'];
}
define('URL', $_SESSION['url'], true);
}
?>