|
|
@ -1059,50 +1059,41 @@ func (w WebsiteService) UpdatePHPConfig(req request.WebsitePHPConfigUpdate) (err |
|
|
|
return err |
|
|
|
return err |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if req.Scope == "params" { |
|
|
|
content := string(contentBytes) |
|
|
|
content := string(contentBytes) |
|
|
|
lines := strings.Split(content, "\n") |
|
|
|
lines := strings.Split(content, "\n") |
|
|
|
for i, line := range lines { |
|
|
|
for i, line := range lines { |
|
|
|
if strings.HasPrefix(line, ";") { |
|
|
|
if strings.HasPrefix(line, ";") { |
|
|
|
continue |
|
|
|
continue |
|
|
|
} |
|
|
|
} |
|
|
|
switch req.Scope { |
|
|
|
|
|
|
|
case "params": |
|
|
|
for key, value := range req.Params { |
|
|
|
for key, value := range req.Params { |
|
|
|
pattern := "^" + regexp.QuoteMeta(key) + "\\s*=\\s*.*$" |
|
|
|
pattern := "^" + regexp.QuoteMeta(key) + "\\s*=\\s*.*$" |
|
|
|
if matched, _ := regexp.MatchString(pattern, line); matched { |
|
|
|
if matched, _ := regexp.MatchString(pattern, line); matched { |
|
|
|
lines[i] = key + " = " + value |
|
|
|
lines[i] = key + " = " + value |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
case "disable_functions": |
|
|
|
updatedContent := strings.Join(lines, "\n") |
|
|
|
pattern := "^" + regexp.QuoteMeta("disable_functions") + "\\s*=\\s*.*$" |
|
|
|
if err := fileOp.WriteFile(phpConfigPath, strings.NewReader(updatedContent), 0755); err != nil { |
|
|
|
if matched, _ := regexp.MatchString(pattern, line); matched { |
|
|
|
return err |
|
|
|
lines[i] = "disable_functions" + " = " + strings.Join(req.DisableFunctions, ",") |
|
|
|
|
|
|
|
break |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
case "upload_max_filesize": |
|
|
|
|
|
|
|
pattern := "^" + regexp.QuoteMeta("post_max_size") + "\\s*=\\s*.*$" |
|
|
|
|
|
|
|
if matched, _ := regexp.MatchString(pattern, line); matched { |
|
|
|
|
|
|
|
lines[i] = "post_max_size" + " = " + req.UploadMaxSize |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
patternUpload := "^" + regexp.QuoteMeta("upload_max_filesize") + "\\s*=\\s*.*$" |
|
|
|
|
|
|
|
if matched, _ := regexp.MatchString(patternUpload, line); matched { |
|
|
|
|
|
|
|
lines[i] = "upload_max_filesize" + " = " + req.UploadMaxSize |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
updatedContent := strings.Join(lines, "\n") |
|
|
|
cfg, err := ini.Load(phpConfigPath) |
|
|
|
if err := fileOp.WriteFile(phpConfigPath, strings.NewReader(updatedContent), 0755); err != nil { |
|
|
|
if err != nil { |
|
|
|
|
|
|
|
return err |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
phpConfig, err := cfg.GetSection("PHP") |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
|
|
return err |
|
|
|
return err |
|
|
|
} |
|
|
|
} |
|
|
|
if req.Scope == "disable_functions" { |
|
|
|
|
|
|
|
disable := phpConfig.Key("disable_functions") |
|
|
|
|
|
|
|
disable.SetValue(strings.Join(req.DisableFunctions, ",")) |
|
|
|
|
|
|
|
if err = cfg.SaveTo(phpConfigPath); err != nil { |
|
|
|
|
|
|
|
return err |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if req.Scope == "upload_max_filesize" { |
|
|
|
|
|
|
|
postMaxSize := phpConfig.Key("post_max_size") |
|
|
|
|
|
|
|
postMaxSize.SetValue(req.UploadMaxSize) |
|
|
|
|
|
|
|
uploadMaxFileSize := phpConfig.Key("upload_max_filesize") |
|
|
|
|
|
|
|
uploadMaxFileSize.SetValue(req.UploadMaxSize) |
|
|
|
|
|
|
|
if err = cfg.SaveTo(phpConfigPath); err != nil { |
|
|
|
|
|
|
|
return err |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
appInstallReq := request.AppInstalledOperate{ |
|
|
|
appInstallReq := request.AppInstalledOperate{ |
|
|
|
InstallId: appInstall.ID, |
|
|
|
InstallId: appInstall.ID, |
|
|
|