<!DOCTYPE html>
<html>

<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<title>YUNYECMS <?php echo YUNYECMS_VERSION; ?></title>
	<!-- Tell the browser to be responsive to screen width -->
	<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
	<!-- Bootstrap 3.3.6 -->
	<link rel="stylesheet" href="<?php echo YUNYECMS_UI; ?>bootstrap/css/bootstrap.min.css">
	<!-- Font Awesome -->
	<link rel="stylesheet" href="<?php echo YUNYECMS_UI; ?>plugins/fontawesome-free/css/all.min.css">
	<!-- Theme style -->
	<link rel="stylesheet" href="<?php echo YUNYECMS_UI; ?>plugins/iCheck/all.css">
	<link rel="stylesheet" href="<?php echo YUNYECMS_UI; ?>dist/css/AdminLTE.min.css">
	<!-- AdminLTE Skins. Choose a skin from the css/skins
       folder instead of downloading all of them to reduce the load. -->
	<link rel="stylesheet" href="<?php echo YUNYECMS_UI; ?>dist/css/skins/_all-skins.min.css">
	<link rel="stylesheet" href="<?php echo YUNYECMS_UI; ?>dist/css/admin.css">
	<link rel="stylesheet" href="<?php echo YUNYECMS_UI; ?>validator/dist/css/bootstrapValidator.css" />

	<link rel="stylesheet" href="<?php echo YUNYECMS_UI; ?>plugins/daterangepicker/daterangepicker.css">
	<!-- bootstrap datepicker -->
	<link rel="stylesheet" href="<?php echo YUNYECMS_UI; ?>plugins/datepicker/datepicker3.css">
	<!-- Bootstrap time Picker -->
	<link rel="stylesheet" href="<?php echo YUNYECMS_UI; ?>plugins/timepicker/bootstrap-timepicker.min.css">
	<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
	<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
	<!--[if lt IE 9]>
  <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
  <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
  <![endif]-->
</head>

<body class="hold-transition rightbgcolor" onload="changefrmHeight()">
	<!-- Content Wrapper. Contains page content -->
	<div class="container-fluid" id="mainwrap">
		<!-- Main content -->
		<section class="content">
			<div class="row">
				<!-- left column -->
				<div class="col-xs-12">
					<div class="card card-primary card-outline">
						<div class="card-header">
							<div class="col-xs-12 col-sm-12 col-md-8 pb10">
								<h3 class="card-title">自动更新</h3> &nbsp;
								<a href="<?php echo url_admin("init", "autoupdate"); ?>" class="btn btn-info btn-sm btn-flat"><i class="fa fa-refresh" aria-hidden="true"> </i> 检测更新</a> &nbsp;

								<a href="<?php echo url_admin("uplist", "autoupdate"); ?>" class="btn bg-blue btn-sm btn-flat"><i class="fa fa-list" aria-hidden="true"> </i> 升级记录</a> &nbsp;
							</div>
						</div>
						<div class="card-body">
							<div class="table-responsive" style="padding-left: 20px;line-height: 2;">
								<div id="versioninfo" style="line-height: 2;">
									当前版本： <?php echo $cur_ver; ?>
								</div>
								<div id="updateinfo" style="line-height: 2;display: none;"> </div>
								<div id="upgrade"> </div>
							</div>
						</div>

						<!-- /.box-header -->

					</div>
					<!-- /.box -->
				</div>
				<!--/.col (left) -->
			</div>
			<!-- /.row -->
		</section>
		<!-- /.content -->
	</div>
	<!-- /.content-wrapper -->
	<?php require tpl_adm('foot'); ?>
	<!-- jQuery 2.2.3 -->
	<script src="<?php echo YUNYECMS_UI; ?>plugins/jQuery/jquery-3.6.1.min.js"></script>
	<!-- Bootstrap 3.3.6 -->
	<script src="<?php echo YUNYECMS_UI; ?>bootstrap/js/bootstrap.min.js"></script>
	<!-- FastClick -->
	<script src="<?php echo YUNYECMS_UI; ?>plugins/fastclick/fastclick.js"></script>
	<!-- AdminLTE for demo purposes -->
	<script src="<?php echo YUNYECMS_UI; ?>dist/js/admin.js"></script>
	<script src="<?php echo YUNYECMS_UI; ?>dist/js/modal.js"></script>

	<script language="javascript" type="text/javascript">
		$(function() {
			var navudinfo = "<?php echo $parnav; ?>";
			$('.breadcrumb', window.parent.document).children('#homeitem').nextAll().remove();
			$('.breadcrumb', window.parent.document).children('#homeitem').after(navudinfo);
			$.ajax({
				type: "get",
				dataType: "text",
				async: true,
				url: "<?php echo url_admin('getver', 'autoupdate'); ?>",
				success: function(data) {
					//console.log(data);
					var versiondata = JSON.parse(data);
					$("#versioninfo").html("当前版本：" + versiondata.cur_ver);
					<?php if (ROUTE_A == "init") : ?>
						$("#updateinfo").show();
						$("#updateinfo").html(versiondata.ver_content);
					<?php endif ?>
				},
				error: function() {
					return false;
				}
			})
		});

		function upgrade(step, para) {
			var parameter = arguments[1] ? arguments[1] : "";
			$("#updateinfo").hide();
			$.ajax({
				type: "post",
				dataType: "json",
				data: {
					step: step,
					para: parameter,
					<?php echo $this->PostHash['ehashvar'] . ":'" . $this->PostHash['ehash'] . "'"; ?>,
					<?php echo $this->PostHash['rhashvar'] . ":'" . $this->PostHash['rhash'] . "'"; ?>
				},
				async: true,
				url: "<?php echo url_admin('upgrade', 'autoupdate'); ?>",
				success: function(data) {
					console.log(step);
					//var msg = JSON.parse(data);
					var msg = data;
					if (step == "getpackage") {
						$("#upgrade").html("");
						$("#upgrade").append(msg.loaded);
					}
					$("#upgrade").append("<br\>" + msg.desc);
					if (!empty(msg.step) && msg.code != '999') {
						if (msg.para) {
							upgrade(msg.step, msg.para);
						} else {
							upgrade(msg.step);
						}
					} else if (msg.code == '999') {
						$("#upgrade_loading").hide();
						$("#upgrade").append("<br/><span class='text-green'>升级完成！</span>");
						upversion();
					} else {
						$("#upgrade_loading").hide();
						$("#upgrade").append("<br/><span class='text-red'>升级失败！</span>");
					}
				},
				error: function() {
					return false;
				}
			})

		}

		function upversion() {
			$.ajax({
				type: "get",
				dataType: "text",
				async: true,
				url: "<?php echo url_admin('getver', 'autoupdate'); ?>",
				success: function(data) {
					//console.log(data);
					var versiondata = JSON.parse(data);
					$("#versioninfo").html("当前版本：" + versiondata.cur_ver);
				},
				error: function() {
					return false;
				}
			})
		}
	</script>

</body>

</html>