|
1
|
|
|
<?php |
|
2
|
|
|
$installMode = isset($_POST['installmode']) ? (int)$_POST['installmode'] : 0; |
|
3
|
|
|
|
|
4
|
|
|
// Determine upgradeability |
|
5
|
|
|
$upgradeable= 0; |
|
6
|
|
|
if ($installMode === 0) { |
|
7
|
|
|
$database_name= ''; |
|
8
|
|
|
$database_server= 'localhost'; |
|
9
|
|
|
$table_prefix= substr(md5(time()), rand(0, 27), rand(3, 5))."_"; |
|
10
|
|
|
} else { |
|
11
|
|
|
$database_name = ''; |
|
12
|
|
|
if (!is_file($base_path.MGR_DIR.'/includes/config.inc.php')) $upgradeable = 0; |
|
13
|
|
|
else { |
|
14
|
|
|
// Include the file so we can test its validity |
|
15
|
|
|
include($base_path.MGR_DIR.'/includes/config.inc.php'); |
|
16
|
|
|
// We need to have all connection settings - but prefix may be empty so we have to ignore it |
|
17
|
|
|
if ($dbase) { |
|
18
|
|
|
$database_name = trim($dbase, '`'); |
|
19
|
|
View Code Duplication |
if (!$conn = mysqli_connect($database_server, $database_user, $database_password)) |
|
20
|
|
|
$upgradeable = (isset($_POST['installmode']) && $_POST['installmode']=='new') ? 0 : 2; |
|
21
|
|
|
elseif (! mysqli_select_db($conn, trim($dbase, '`'))) |
|
22
|
|
|
$upgradeable = (isset($_POST['installmode']) && $_POST['installmode']=='new') ? 0 : 2; |
|
23
|
|
|
else |
|
24
|
|
|
$upgradeable = 1; |
|
25
|
|
|
} |
|
26
|
|
|
else $upgradable= 2; |
|
27
|
|
|
} |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
// check the database collation if not specified in the configuration |
|
31
|
|
View Code Duplication |
if ($upgradeable && (!isset ($database_connection_charset) || empty($database_connection_charset))) { |
|
32
|
|
|
if (!$rs = mysqli_query($conn, "show session variables like 'collation_database'")) { |
|
33
|
|
|
$rs = mysqli_query($conn, "show session variables like 'collation_server'"); |
|
34
|
|
|
} |
|
35
|
|
|
if ($rs && $collation = mysqli_fetch_row($rs)) { |
|
36
|
|
|
$database_collation = $collation[1]; |
|
37
|
|
|
} |
|
38
|
|
|
if (empty ($database_collation)) { |
|
39
|
|
|
$database_collation = 'utf8_general_ci'; |
|
40
|
|
|
} |
|
41
|
|
|
$database_charset = substr($database_collation, 0, strpos($database_collation, '_')); |
|
42
|
|
|
$database_connection_charset = $database_charset; |
|
43
|
|
|
} else { |
|
44
|
|
|
$database_collation = 'utf8_general_ci'; |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
// determine the database connection method if not specified in the configuration |
|
48
|
|
|
if ($upgradeable && (!isset($database_connection_method) || empty($database_connection_method))) { |
|
49
|
|
|
$database_connection_method = 'SET CHARACTER SET'; |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
$ph['database_name'] = isset($_POST['database_name']) ? $_POST['database_name']: $database_name; |
|
53
|
|
|
$ph['tableprefix'] = isset($_POST['tableprefix']) ? $_POST['tableprefix']: $table_prefix; |
|
54
|
|
|
$ph['selected_set_character_set'] = isset($database_connection_method) && $database_connection_method == 'SET CHARACTER SET' ? 'selected' : ''; |
|
55
|
|
|
$ph['selected_set_names'] = isset($database_connection_method) && $database_connection_method == 'SET NAMES' ? 'selected' : ''; |
|
56
|
|
|
$ph['show#connection_method'] = (($installMode == 0) || ($installMode == 2)) ? 'block' : 'none'; |
|
57
|
|
|
$ph['database_collation'] = isset($_POST['database_collation']) ? $_POST['database_collation']: $database_collation; |
|
58
|
|
|
$ph['show#AUH'] = ($installMode == 0) ? 'block':'none'; |
|
59
|
|
|
$ph['cmsadmin'] = isset($_POST['cmsadmin']) ? $_POST['cmsadmin']:'admin'; |
|
60
|
|
|
$ph['cmsadminemail'] = isset($_POST['cmsadminemail']) ? $_POST['cmsadminemail']:""; |
|
61
|
|
|
$ph['cmspassword'] = isset($_POST['cmspassword']) ? $_POST['cmspassword']:""; |
|
62
|
|
|
$ph['cmspasswordconfirm'] = isset($_POST['cmspasswordconfirm']) ? $_POST['cmspasswordconfirm']:""; |
|
63
|
|
|
$ph['managerLangs'] = getLangs($install_language); |
|
64
|
|
|
$ph['install_language'] = $install_language; |
|
65
|
|
|
$ph['installMode'] = $installMode; |
|
66
|
|
|
$ph['checkedChkagree'] = isset($_POST['chkagree']) ? 'checked':""; |
|
67
|
|
|
$ph['database_connection_method'] = isset($database_connection_method) ? $database_connection_method : ''; |
|
68
|
|
|
$ph['databasehost'] = isset($_POST['databasehost']) ? $_POST['databasehost']: $database_server; |
|
69
|
|
|
$ph['databaseloginname'] = isset($_SESSION['databaseloginname']) ? $_SESSION['databaseloginname']: ''; |
|
70
|
|
|
$ph['databaseloginpassword'] = isset($_SESSION['databaseloginpassword']) ? $_SESSION['databaseloginpassword']: ""; |
|
71
|
|
|
$ph['MGR_DIR'] = MGR_DIR; |
|
72
|
|
|
|
|
73
|
|
|
$content = file_get_contents('./actions/tpl_connection.html'); |
|
74
|
|
|
$content = parse($content, $_lang, '[%','%]'); |
|
75
|
|
|
$content = parse($content, $ph); |
|
76
|
|
|
echo $content; |
|
77
|
|
|
|
|
78
|
|
|
if( ! function_exists('getLangs')) { |
|
79
|
|
|
/** |
|
80
|
|
|
* @param $install_language |
|
81
|
|
|
* @return string |
|
82
|
|
|
*/ |
|
83
|
|
|
function getLangs($install_language) |
|
84
|
|
|
{ |
|
85
|
|
|
if ($install_language !== "english" && is_file(sprintf("../%s/includes/lang/%s.inc.php", MGR_DIR, $install_language))) { |
|
86
|
|
|
$manager_language = $install_language; |
|
87
|
|
|
} else { |
|
88
|
|
|
$manager_language = "english"; |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
$langs = array(); |
|
92
|
|
|
if ($handle = opendir("../" . MGR_DIR . "/includes/lang")) { |
|
93
|
|
|
while (false !== ($file = readdir($handle))) { |
|
94
|
|
|
if (strpos($file, '.inc.') !== false) { |
|
95
|
|
|
$langs[] = $file; |
|
96
|
|
|
} |
|
97
|
|
|
} |
|
98
|
|
|
closedir($handle); |
|
99
|
|
|
} |
|
100
|
|
|
sort($langs); |
|
101
|
|
|
|
|
102
|
|
|
$_ = array(); |
|
103
|
|
|
foreach ($langs as $language) { |
|
104
|
|
|
$abrv_language = explode('.', $language); |
|
105
|
|
|
$selected = (strtolower($abrv_language[0]) == strtolower($manager_language)) ? ' selected' : ''; |
|
106
|
|
|
$_[] = sprintf('<option value="%s" %s>%s</option>', $abrv_language[0], $selected, |
|
107
|
|
|
ucwords($abrv_language[0])); |
|
108
|
|
|
} |
|
109
|
|
|
|
|
110
|
|
|
return implode("\n", $_); |
|
111
|
|
|
} |
|
112
|
|
|
} |
|
113
|
|
|
|