$res = $dbconnect->query("delete from upstreams where id=" . $_GET['id']); is_error($res); $addconfig_header = "location: addconfigs.php?serviceid=" . $_REQUEST['serviceid']; $status = 1; if (upserivce_status($status, $_REQUEST['serviceid'])) { header($addconfig_header); } else { die("update service status error!! service id" . $_POST['serviceid']); } break; case "modiflocation": $location_path = mysql_escape_string($_POST['location_path']); $res = $dbconnect->query("update locations set location_path='" . $location_path . "', alias='" . $_POST['alias'] . "', root_path='" . $_POST['root_path'] . "', proxy_pass='******'proxypass'] . "', valid_referers='" . $_POST['valid_referers'] . "', proxy_next_upstream='" . $_POST['proxy_next_upstream'] . "', access_log='" . $_POST['access_log'] . "' where id=" . $_POST['locationid']); is_error($res); $status = 1; if (upserivce_status($status, $_REQUEST['serviceid'])) { $addconfig_header = "location: addconfigs.php?serviceid=" . $_REQUEST['serviceid']; header($addconfig_header); } else { die("update service status error!! service id" . $_POST['serviceid']); } break; case "dellocation": $res = $dbconnect->query("delete from locations where id=" . $_GET['id']); is_error($res); $addconfig_header = "location: addconfigs.php?serviceid=" . $_REQUEST['locationserviceid']; header($addconfig_header); default: echo "program error!"; break; }
} } } $template_location_file = "template/" . $_POST['template_location']; $template_location_buffer = template_read($template_location_file); $location_commit_array = array(); array_push($location_commit_array, $commit_location_info['location_path'], $commit_location_info['alias'], $commit_location_info['root_path'], $commit_location_info['proxy_pass'], $commit_location_info['proxy_next_upstream'], $commit_location_info['access_log'], $commit_rewirtes_contect, $commit_location_info['valid_referers']); $commit_location_contect .= preg_replace($location_commit_command, $location_commit_array, $template_location_buffer); } $template_server_file = "template/server.template"; $template_server_buffer = template_read($template_server_file); $template_server_buffer = preg_replace("/}/", "", $template_server_buffer); $commit_server_contect = preg_replace($server_commit_comand, $server_commit_array, $template_server_buffer); $commit_nginx_config_content = $commit_upstream_content . $commit_server_contect . $commit_location_contect . " }\n"; if (commit_config_write($service_config_file, $commit_nginx_config_content)) { if (commit_log(time(), $service_name, $service_config_file, $_CONF['commit_log']) == false) { die("commit file is ok,write log error!!"); } $md5_code = md5_file($_CONF['commit_log']); if (md5file_write($md5_code, $_CONF['md5_file']) == false) { die("write md5_file error!!"); } upserivce_status(2, $service_info['id']); $header_info = "location: services.php"; header($header_info); } else { $header_info = "location: commitconf.php?commit_error=2"; header($header_info); } } }