$ftp_server_array = unserialize($ftp_server_array); } if (isset($ftp_server_array['ftp_check_login']) and intval($ftp_server_array['ftp_check_login']) == 1) { // Set up basic connection $conn_id = ftp_connect($ftp_server_array['ftp_server'], $ftp_server_array['ftp_port'], 10); // Login with username and password $login_result = ftp_login($conn_id, $ftp_server_array['ftp_user_name'], $ftp_server_array['ftp_user_pass']); if (!$conn_id || !$login_result) { $ftp_check_login = 3; } elseif (ftp_chdir($conn_id, $ftp_server_array['ftp_path'])) { $ftp_check_login = 1; } } if ($ftp_check_login == 1) { ftp_rename($conn_id, NV_TEMP_DIR . '/' . NV_CONFIG_FILENAME, NV_CONFIG_FILENAME); nv_chmod_dir($conn_id, NV_UPLOADS_DIR, true); ftp_chmod($conn_id, 0644, NV_CONFIG_FILENAME); ftp_close($conn_id); } else { @rename(NV_ROOTDIR . '/' . NV_TEMP_DIR . '/' . NV_CONFIG_FILENAME, NV_ROOTDIR . '/' . NV_CONFIG_FILENAME); } } if (file_exists(NV_ROOTDIR . '/' . NV_CONFIG_FILENAME)) { $finish = 1; } else { $finish = 2; } $title = $lang_module['done']; $contents = nv_step_7($finish); } echo nv_site_theme($step, $title, $contents);
/** * nv_chmod_dir() * * @param mixed $conn_id * @param mixed $dir * @param bool $subdir * @return */ function nv_chmod_dir($conn_id, $dir, $subdir = false) { global $array_cmd_dir; $no_file = array('.', '..', '.htaccess', 'index.html'); if (ftp_chmod($conn_id, 0777, $dir) !== false) { $array_cmd_dir[] = $dir; if ($subdir and is_dir(NV_ROOTDIR . '/' . $dir)) { $list_files = ftp_nlist($conn_id, $dir); foreach ($list_files as $file_i) { if (!in_array($file_i, $no_file)) { if (is_dir(NV_ROOTDIR . '/' . $dir . '/' . $file_i)) { nv_chmod_dir($conn_id, $dir . '/' . $file_i, $subdir); } else { ftp_chmod($conn_id, 0777, $dir . '/' . $file_i); } } } } } else { $array_cmd_dir[] = '<b>' . $dir . ' --> no chmod 777 </b>'; } }
$error[] = $lang_module['checkchmod_error_account']; } elseif (ftp_chdir($conn_id, $global_config['ftp_path'])) { $ftp_check_login = 1; } else { $error[] = $lang_module['checkchmod_error_path']; } } if ($sys_info['allowed_set_time_limit']) { set_time_limit(1200); } foreach ($array_dir as $dir) { if ($ftp_check_login == 1) { if (!is_dir(NV_ROOTDIR . '/' . $dir)) { ftp_mkdir($conn_id, $dir); } if (!is_writable(NV_ROOTDIR . '/' . $dir)) { nv_chmod_dir($conn_id, $dir, true); } } else { //try chmod unix command if (!chmod(NV_ROOTDIR . '/' . $dir, 0777)) { $error[] = $lang_module['checkchmod_error_unable_chmod'] . $dir; } } } if (!empty($error)) { echo implode('', $error); } else { echo $lang_module['checkchmod_success']; } }
/** * nv_chmod_dir() * * @param mixed $conn_id * @param mixed $dir * @param bool $subdir * @return */ function nv_chmod_dir($conn_id, $dir, $subdir = false) { global $sys_info, $array_cmd_dir; $no_file = array('.', '..', '.htaccess', 'index.html'); if (substr($sys_info['os'], 0, 3) != 'WIN' and ftp_chmod($conn_id, 0777, $dir) !== false) { $array_cmd_dir[] = $dir; if ($subdir and is_dir(NV_ROOTDIR . '/' . $dir)) { ftp_chmod($conn_id, 0777, $dir); $list_files = ftp_nlist($conn_id, $dir); foreach ($list_files as $file_i) { $file_i = basename($file_i); if (!in_array($file_i, $no_file)) { if (is_dir(NV_ROOTDIR . '/' . $dir . '/' . $file_i)) { nv_chmod_dir($conn_id, $dir . '/' . $file_i, $subdir); } else { ftp_chmod($conn_id, 0777, $dir . '/' . $file_i); } } } } } else { $array_cmd_dir[] = '<strong>' . $dir . ' --> no chmod 777 </strong>'; } }
$ftp_check_login = 1; } else { $ftp_check_login = 2; } } $dir_not_is_writable = array(); foreach ($folder as $dir) { if (is_dir(NV_ROOTDIR . '/themes/' . trim($dir))) { if ($ftp_check_login == 1) { nv_chmod_dir($conn_id, 'themes/' . trim($dir), true); } else { chmod(NV_ROOTDIR . '/themes/' . trim($dir), 0777); } } elseif ($ftp_check_login == 1) { if (ftp_mkdir($conn_id, 'themes/' . trim($dir))) { nv_chmod_dir($conn_id, 'themes/' . trim($dir), true); } } else { if (mkdir(NV_ROOTDIR . '/themes/' . trim($dir))) { chmod(NV_ROOTDIR . '/themes/' . trim($dir), 0777); } } if (!is_writable(NV_ROOTDIR . '/themes/' . trim($dir))) { $dir_not_is_writable = 'themes/' . trim($dir); } } if (intval($global_config['ftp_check_login']) == 1) { ftp_close($conn_id); } if ($dir_not_is_writable != array()) { echo '<div id="install_content"><h4>' . $lang_module['autoinstall_theme_unzip_abort'] . '</h4>';
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass); if (!$conn_id || !$login_result) { $ftp_check_login = 3; } elseif (ftp_chdir($conn_id, $ftp_path)) { $ftp_check_login = 1; } else { $ftp_check_login = 2; } } foreach ($folder as $dir) { if ($ftp_check_login) { if (is_dir(NV_ROOTDIR . '/' . trim($dir))) { nv_chmod_dir($conn_id, trim($dir), true); } else { $continueflag = ftp_mkdir($conn_id, trim($dir)); nv_chmod_dir($conn_id, trim($dir), true); //try to create if ftp error if (!$continueflag) { if (mkdir(NV_ROOTDIR . '/' . trim($dir))) { chmod(NV_ROOTDIR . '/' . trim($dir), 0777); } } } } else { if (mkdir(NV_ROOTDIR . '/' . trim($dir))) { chmod(NV_ROOTDIR . '/' . trim($dir), 0777); } } if (!is_writable(NV_ROOTDIR . '/' . trim($dir))) { echo NV_ROOTDIR . '/' . trim($dir); echo '<div id="install_content"><h4>' . $lang_module['autoinstall_module_unzip_abort'] . '</h4><input style="margin-top:10px;font-size:15px" type="button" name="checkfile" value="' . $lang_module['autoinstall_module_checkfile'] . '"/><br /><br />';