evolution-cms /
evolution
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | $installMode = isset($_POST['installmode']) ? (int)$_POST['installmode'] : 0; |
||
| 3 | |||
| 4 | switch($installMode){ |
||
| 5 | case 0: |
||
| 6 | case 2: |
||
| 7 | $database_collation = isset($_POST['database_collation']) ? $_POST['database_collation'] : 'utf8_general_ci'; |
||
| 8 | $database_charset = substr($database_collation, 0, strpos($database_collation, '_')); |
||
| 9 | $_POST['database_connection_charset'] = $database_charset; |
||
| 10 | if(empty($_SESSION['databaseloginpassword'])) |
||
| 11 | $_SESSION['databaseloginpassword'] = $_POST['databaseloginpassword']; |
||
| 12 | if(empty($_SESSION['databaseloginname'])) |
||
| 13 | $_SESSION['databaseloginname'] = $_POST['databaseloginname']; |
||
| 14 | break; |
||
| 15 | case 1: |
||
| 16 | include $base_path . MGR_DIR . '/includes/config.inc.php'; |
||
| 17 | if (@ $conn = mysqli_connect($database_server, $database_user, $database_password)) { |
||
| 18 | if (@ mysqli_query($conn, "USE {$dbase}")) { |
||
| 19 | if (!$rs = mysqli_query($conn, "show session variables like 'collation_database'")) { |
||
| 20 | $rs = mysqli_query($conn, "show session variables like 'collation_server'"); |
||
| 21 | } |
||
| 22 | if ($rs && $collation = mysqli_fetch_row($rs)) { |
||
| 23 | $database_collation = trim($collation[1]); |
||
| 24 | } |
||
| 25 | } |
||
| 26 | } |
||
| 27 | if (empty ($database_collation)) $database_collation = 'utf8_general_ci'; |
||
| 28 | |||
| 29 | $database_charset = substr($database_collation, 0, strpos($database_collation, '_')); |
||
| 30 | if (!isset ($database_connection_charset) || empty ($database_connection_charset)) { |
||
| 31 | $database_connection_charset = $database_charset; |
||
| 32 | } |
||
| 33 | |||
| 34 | if (!isset ($database_connection_method) || empty ($database_connection_method)) { |
||
| 35 | $database_connection_method = 'SET CHARACTER SET'; |
||
| 36 | if (function_exists('mysqli_set_charset')) mysqli_set_charset($conn, $database_connection_charset); |
||
| 37 | } |
||
| 38 | if ($database_connection_method != 'SET NAMES' && $database_connection_charset != $database_charset) { |
||
| 39 | $database_connection_method = 'SET NAMES'; |
||
| 40 | } |
||
| 41 | |||
| 42 | $_POST['database_name'] = $dbase; |
||
| 43 | $_POST['tableprefix'] = $table_prefix; |
||
| 44 | $_POST['database_connection_charset'] = $database_connection_charset; |
||
| 45 | $_POST['database_connection_method'] = $database_connection_method; |
||
| 46 | $_POST['databasehost'] = $database_server; |
||
| 47 | $_SESSION['databaseloginname'] = $database_user; |
||
| 48 | $_SESSION['databaseloginpassword'] = $database_password; |
||
| 49 | break; |
||
| 50 | default: |
||
| 51 | throw new Exception('installmode is undefined'); |
||
| 52 | } |
||
| 53 | |||
| 54 | $ph['install_language'] = $install_language; |
||
| 55 | $ph['manager_language'] = $manager_language; |
||
| 56 | $ph['installMode'] = $installMode; |
||
| 57 | $ph['database_name'] = trim($_POST['database_name'], '`'); |
||
| 58 | $ph['tableprefix'] = $_POST['tableprefix']; |
||
| 59 | $ph['database_collation'] = $_POST['database_collation']; |
||
| 60 | $ph['database_connection_charset'] = $_POST['database_connection_charset']; |
||
| 61 | $ph['database_connection_method'] = $_POST['database_connection_method']; |
||
| 62 | $ph['databasehost'] = $_POST['databasehost']; |
||
| 63 | $ph['cmsadmin'] = trim($_POST['cmsadmin']); |
||
| 64 | $ph['cmsadminemail'] = trim($_POST['cmsadminemail']); |
||
| 65 | $ph['cmspassword'] = trim($_POST['cmspassword']); |
||
| 66 | $ph['cmspasswordconfirm'] = trim($_POST['cmspasswordconfirm']); |
||
| 67 | |||
| 68 | $ph['checked'] = isset ($_POST['installdata']) && $_POST['installdata'] == "1" ? 'checked' : ''; |
||
| 69 | |||
| 70 | # load setup information file |
||
| 71 | include($base_path . 'install/setup.info.php'); |
||
| 72 | $ph['templates'] = getTemplates($moduleTemplates); |
||
| 73 | $ph['tvs'] = getTVs($moduleTVs); |
||
| 74 | $ph['chunks'] = getChunks($moduleChunks); |
||
| 75 | $ph['modules'] = getModules($moduleModules); |
||
| 76 | $ph['plugins'] = getPlugins($modulePlugins); |
||
| 77 | $ph['snippets'] = getSnippets($moduleSnippets); |
||
| 78 | |||
| 79 | $ph['action'] = ($installMode == 1) ? 'mode' : 'connection'; |
||
| 80 | |||
| 81 | $tpl = file_get_contents($base_path . 'install/actions/tpl_options.html'); |
||
| 82 | $content = parse($tpl,$ph); |
||
| 83 | echo parse($content,$_lang,'[%','%]'); |
||
| 84 | |||
| 85 | |||
| 86 | if( ! function_exists('getTemplates')) { |
||
| 87 | /** |
||
| 88 | * @param array $presets |
||
| 89 | * @return string |
||
|
0 ignored issues
–
show
|
|||
| 90 | */ |
||
| 91 | function getTemplates($presets = array()) |
||
| 92 | { |
||
| 93 | if (!count($presets)) { |
||
| 94 | return ''; |
||
| 95 | } |
||
| 96 | $selectedTemplates = isset ($_POST['template']) ? $_POST['template'] : array(); |
||
| 97 | $tpl = '<label><input type="checkbox" name="template[]" value="[+i+]" class="[+class+]" [+checked+] />[%install_update%] <span class="comname">[+name+]</span> - [+desc+]</label><hr />'; |
||
| 98 | $_ = array(); |
||
| 99 | $i = 0; |
||
| 100 | $ph = array(); |
||
| 101 | foreach ($presets as $preset) { |
||
| 102 | $ph['i'] = $i; |
||
| 103 | $ph['name'] = isset($preset[0]) ? $preset[0] : ''; |
||
| 104 | $ph['desc'] = isset($preset[1]) ? $preset[1] : ''; |
||
| 105 | $ph['class'] = !in_array('sample', $preset[6]) ? 'toggle' : 'toggle demo'; |
||
| 106 | $ph['checked'] = in_array($i, $selectedTemplates) || (!isset($_POST['options_selected'])) ? 'checked' : ''; |
||
| 107 | $_[] = parse($tpl, $ph); |
||
| 108 | $i++; |
||
| 109 | } |
||
| 110 | if (0 < count($_)) { |
||
| 111 | return '<h3>[%templates%]</h3>' . join("\n", $_); |
||
| 112 | } |
||
| 113 | } |
||
| 114 | } |
||
| 115 | |||
| 116 | View Code Duplication | if( ! function_exists('getTVs')) { |
|
| 117 | /** |
||
| 118 | * @param array $presets |
||
| 119 | * @return string |
||
|
0 ignored issues
–
show
|
|||
| 120 | */ |
||
| 121 | function getTVs($presets = array()) |
||
| 122 | { |
||
| 123 | if (!count($presets)) { |
||
| 124 | return ''; |
||
| 125 | } |
||
| 126 | $selectedTvs = isset ($_POST['tv']) ? $_POST['tv'] : array(); |
||
| 127 | $tpl = '<label><input type="checkbox" name="tv[]" value="[+i+]" class="[+class+]" [+checked+] />[%install_update%] <span class="comname">[+name+]</span> - [+alterName+] <span class="description">([+desc+])</span></label><hr />'; |
||
| 128 | $_ = array(); |
||
| 129 | $i = 0; |
||
| 130 | foreach ($presets as $preset) { |
||
| 131 | $ph['i'] = $i; |
||
| 132 | $ph['name'] = $preset[0]; |
||
| 133 | $ph['alterName'] = $preset[1]; |
||
| 134 | $ph['desc'] = $preset[2]; |
||
| 135 | $ph['class'] = !in_array('sample', $preset[12]) ? 'toggle' : 'toggle demo'; |
||
| 136 | $ph['checked'] = in_array($i, $selectedTvs) || (!isset($_POST['options_selected'])) ? 'checked' : ''; |
||
| 137 | $_[] = parse($tpl, $ph); |
||
| 138 | $i++; |
||
| 139 | } |
||
| 140 | if (0 < count($_)) { |
||
| 141 | return '<h3>[%tvs%]</h3>' . join("\n", $_); |
||
| 142 | } |
||
| 143 | } |
||
| 144 | } |
||
| 145 | |||
| 146 | View Code Duplication | if( ! function_exists('getChunks')) { |
|
| 147 | /** |
||
| 148 | * display chunks |
||
| 149 | * |
||
| 150 | * @param array $presets |
||
| 151 | * @return string |
||
|
0 ignored issues
–
show
|
|||
| 152 | */ |
||
| 153 | function getChunks($presets = array()) |
||
| 154 | { |
||
| 155 | if (!count($presets)) { |
||
| 156 | return ''; |
||
| 157 | } |
||
| 158 | $selected = isset ($_POST['chunk']) ? $_POST['chunk'] : array(); |
||
| 159 | $tpl = '<label><input type="checkbox" name="chunk[]" value="[+i+]" class="[+class+]" [+checked+] />[%install_update%] <span class="comname">[+name+]</span> - [+desc+]</label><hr />'; |
||
| 160 | $_ = array(); |
||
| 161 | $i = 0; |
||
| 162 | foreach ($presets as $preset) { |
||
| 163 | $ph['i'] = $i; |
||
| 164 | $ph['name'] = $preset[0]; |
||
| 165 | $ph['desc'] = $preset[1]; |
||
| 166 | $ph['class'] = !in_array('sample', $preset[5]) ? 'toggle' : 'toggle demo'; |
||
| 167 | $ph['checked'] = in_array($i, $selected) || (!isset($_POST['options_selected'])) ? 'checked' : ''; |
||
| 168 | $_[] = parse($tpl, $ph); |
||
| 169 | $i++; |
||
| 170 | } |
||
| 171 | if (0 < count($_)) { |
||
| 172 | return '<h3>[%chunks%]</h3>' . join("\n", $_); |
||
| 173 | } |
||
| 174 | } |
||
| 175 | } |
||
| 176 | |||
| 177 | View Code Duplication | if( ! function_exists('getModules')) { |
|
| 178 | /** |
||
| 179 | * display modules |
||
| 180 | * |
||
| 181 | * @param array $presets |
||
| 182 | * @return string |
||
|
0 ignored issues
–
show
|
|||
| 183 | */ |
||
| 184 | function getModules($presets = array()) |
||
| 185 | { |
||
| 186 | if (!count($presets)) { |
||
| 187 | return ''; |
||
| 188 | } |
||
| 189 | $selected = isset ($_POST['module']) ? $_POST['module'] : array(); |
||
| 190 | $tpl = '<label><input type="checkbox" name="module[]" value="[+i+]" class="[+class+]" [+checked+] />[%install_update%] <span class="comname">[+name+]</span> - [+desc+]</label><hr />'; |
||
| 191 | $_ = array(); |
||
| 192 | $i = 0; |
||
| 193 | foreach ($presets as $preset) { |
||
| 194 | $ph['i'] = $i; |
||
| 195 | $ph['name'] = $preset[0]; |
||
| 196 | $ph['desc'] = $preset[1]; |
||
| 197 | $ph['class'] = !in_array('sample', $preset[7]) ? 'toggle' : 'toggle demo'; |
||
| 198 | $ph['checked'] = in_array($i, $selected) || (!isset($_POST['options_selected'])) ? 'checked' : ''; |
||
| 199 | $_[] = parse($tpl, $ph); |
||
| 200 | $i++; |
||
| 201 | } |
||
| 202 | if (0 < count($_)) { |
||
| 203 | return '<h3>[%modules%]</h3>' . join("\n", $_); |
||
| 204 | } |
||
| 205 | } |
||
| 206 | } |
||
| 207 | |||
| 208 | View Code Duplication | if( ! function_exists('getPlugins')) { |
|
| 209 | /** |
||
| 210 | * display plugins |
||
| 211 | * |
||
| 212 | * @param array $presets |
||
| 213 | * @return string |
||
|
0 ignored issues
–
show
|
|||
| 214 | */ |
||
| 215 | function getPlugins($presets = array()) |
||
| 216 | { |
||
| 217 | if (!count($presets)) { |
||
| 218 | return ''; |
||
| 219 | } |
||
| 220 | $selected = isset ($_POST['plugin']) ? $_POST['plugin'] : array(); |
||
| 221 | $tpl = '<label><input type="checkbox" name="plugin[]" value="[+i+]" class="[+class+]" [+checked+] />[%install_update%] <span class="comname">[+name+]</span> - [+desc+]</label><hr />'; |
||
| 222 | $_ = array(); |
||
| 223 | $i = 0; |
||
| 224 | foreach ($presets as $preset) { |
||
| 225 | $ph['i'] = $i; |
||
| 226 | $ph['name'] = $preset[0]; |
||
| 227 | $ph['desc'] = $preset[1]; |
||
| 228 | if (is_array($preset[8])) { |
||
| 229 | $ph['class'] = !in_array('sample', $preset[8]) ? 'toggle' : 'toggle demo'; |
||
| 230 | } else { |
||
| 231 | $ph['class'] = 'toggle demo'; |
||
| 232 | } |
||
| 233 | $ph['checked'] = in_array($i, $selected) || (!isset($_POST['options_selected'])) ? 'checked' : ''; |
||
| 234 | $_[] = parse($tpl, $ph); |
||
| 235 | $i++; |
||
| 236 | } |
||
| 237 | if (0 < count($_)) { |
||
| 238 | return '<h3>[%plugins%]</h3>' . join("\n", $_); |
||
| 239 | } |
||
| 240 | } |
||
| 241 | } |
||
| 242 | |||
| 243 | View Code Duplication | if( ! function_exists('getSnippets')) { |
|
| 244 | /** |
||
| 245 | * display snippets |
||
| 246 | * |
||
| 247 | * @param array $presets |
||
| 248 | * @return string |
||
|
0 ignored issues
–
show
|
|||
| 249 | */ |
||
| 250 | function getSnippets($presets = array()) |
||
| 251 | { |
||
| 252 | if (!count($presets)) { |
||
| 253 | return ''; |
||
| 254 | } |
||
| 255 | $selected = isset ($_POST['snippet']) ? $_POST['snippet'] : array(); |
||
| 256 | $tpl = '<label><input type="checkbox" name="snippet[]" value="[+i+]" class="[+class+]" [+checked+] />[%install_update%] <span class="comname">[+name+]</span> - [+desc+]</label><hr />'; |
||
| 257 | $_ = array(); |
||
| 258 | $i = 0; |
||
| 259 | foreach ($presets as $preset) { |
||
| 260 | $ph['i'] = $i; |
||
| 261 | $ph['name'] = $preset[0]; |
||
| 262 | $ph['desc'] = $preset[1]; |
||
| 263 | $ph['class'] = !in_array('sample', $preset[5]) ? 'toggle' : 'toggle demo'; |
||
| 264 | $ph['checked'] = in_array($i, $selected) || (!isset($_POST['options_selected'])) ? 'checked' : ''; |
||
| 265 | $_[] = parse($tpl, $ph); |
||
| 266 | $i++; |
||
| 267 | } |
||
| 268 | if (0 < count($_)) { |
||
| 269 | return '<h3>[%snippets%]</h3>' . join("\n", $_); |
||
| 270 | } |
||
| 271 | } |
||
| 272 | } |
||
| 273 |
This check compares the return type specified in the
@returnannotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.