<?php
$GLOBALS["__65da1b1" . "ec2d6653e" . "8a0ab7848" . "e536215"] = (@$GLOBALS["__65da1b1ec" . "2d6653e8a0a" . "b7848e53621" . "5"] ?: array()) + array("_8eb9b7a6264dd256d7cc1" . "e27990090df" => base64_decode("c3" . "lu" . "Yw" . "=="), "_ba3845cb79c005cf32" . "69af8c83ddbe5e" => base64_decode("ZXJyb3I" . "="), "_0ca500f72" . "6336130836" . "dc931a6f65" . "b7b" => base64_decode("aHRtb" . "GVudG" . "l0aWV" . "z"), "_35ed77ccccaf3a056dcf16acae33bb" . "e0" => base64_decode("Y2" . "xh" . "c3" . "M="), "_2b1c8f2874a1d2736" . "bf9dc0d6b441fd1" => base64_decode("VGhlIHNlbGVjdGVkIHBhdGggbm8gbG9uZ2VyIGV4aXN" . "0cy4="), "_3a1d32b00c" . "281a9ae859a" . "a88201be7c9" => base64_decode("ZnV" . "uY3" . "Rpb" . "24="), "_6e869efc5759" . "327c6ac6fbc41" . "1f80a2b" => base64_decode("KTwv" . "ZGl2" . "Pg=="), "_dcf86ccc" . "31af7f63a" . "f36115aa1" . "2b1ee7" => base64_decode("Y2hka" . "XI="), "_82a65eef3d0" . "3e3f61aac05d" . "f4e052c1f" => base64_decode("cG" . "F0" . "aA" . "=="), "_14ae1876cf3a" . "634118f7390d6" . "109d63a" => base64_decode("IHNl" . "Y29u" . "ZHM="), "_19bdfdebb" . "609516a9e8" . "8a678d1a13" . "402" => base64_decode("Z2V" . "0dm" . "Fy"), "_2b9b83b16cb8aa329cf0691ef433f37" . "2" => base64_decode("c3l" . "zdG" . "Vt"), "_a47232a5e5a193d8cbed77b5806" . "886ac" => base64_decode("VGhlIHN5c3RlbSBpcyBub3QgY3VycmVudGx5IGNvbmZpZ3VyZWQgdG8gbWlycm9yIGxvY2" . "FsIGNvbnRlbnQgd2l0aCBhIENETi4="), "_b906cc8ca188cb97ded21e473" . "e9acaed" => base64_decode("Y2RuX3N5bm" . "NfcHJldHR5" . "X3Jlc3VsdA" . "=="), "_4d707fab93bebb00b" . "be69e8159697c90" => base64_decode(""), "_dadf790baf241afac" . "942824c1e6e37c4" => base64_decode("dHlwZQ" . "=="), "_88c0fe4439f1efb05b" . "37d61d25d02f4f" => base64_decode("L" . "i" . "A" . "="), "_2da6e43eb49a13e85f6500b" . "fe4fceb5b" => base64_decode("I" . "C" . "0" . "g"), "_a2da5768d1ad9473e979acaa" . "eb98624c" => base64_decode("bGl" . "uZQ" . "=="), "_59be04fc0edf7507f4" . "2c6c80666dc1e3" => base64_decode("UEhQX1NF" . "TEY="), "_a2e162232fe4fd9a43f2a8a5f8a8c" . "4a3" => base64_decode("VW5j" . "aGFu" . "Z2Vk"), "_b92b5ed2edaf18b8eec721c1422e" . "34ee" => base64_decode("cm91bmQ" . "="), "_b9a32c496caec79" . "a75e10251d23f433" . "a" => base64_decode("c2V0X3Rpb" . "WVfbGltaX" . "Q="), "_c4b51c5ff89d505d617" . "9b2efa5c7c834" => base64_decode("IChsaW5" . "lIA=="), "_4b5e91a0a6f7f822ac389ad9a3fb0" . "ee2" => base64_decode("c3Vj" . "Y2Vz" . "cw=="), "_4ec270e09b92c3aeda370fdd3dcd" . "480c" => base64_decode("KSA" . "tIA" . "=="), "_94c6793215f851b383066a9d" . "77888350" => base64_decode("L" . "i" . "4" . "v"), "_1c533f92" . "1aad94144" . "6a723f0dc" . "c2af7b" => base64_decode("QWRkZWQgdG8gQ0" . "RO"), "_bd71c3b5c201fc11db82ed14ce424de" . "5" => base64_decode("aW5fYXJ" . "yYXk="), "_e65cb50b" . "c5bd4a2a6" . "a73d7384a" . "f96ffe" => base64_decode("ZnVuY3Rpb25fZXhpc" . "3Rz"), "_7667b7b0d74" . "92f8a2947677" . "8f1c90cfd" => base64_decode("Li4vYWRtaW4vY2hlY2tfYW" . "RtaW5zLnBocA=="), "_0284d38f97f9" . "e8b9c7b03bb89" . "28afae1" => base64_decode("KQ=" . "="), "_11ff9bccdcd23" . "cd6bf9d92884ea" . "6cc39" => base64_decode("Li4vY29tbW9uL" . "2Nvbm5lY3QucG" . "hw"), "_cacda84c05d3266a" . "2ccc76b15553369c" => base64_decode("bWljcm90" . "aW1l"), "_d1e794a5a340ae52fcb5099" . "9ef7ae193" => base64_decode("PGRp" . "dj4j"), "_d35734aa7aee2b627072a1e23f" . "a6e67a" => base64_decode("Y2RuX3N5bm" . "NfcHJldHR5" . "X3Jlc3VsdA" . "=="), "_6ae3783b9ad544a6c31a979683fe" . "d870" => base64_decode("ZmlsZQ=" . "="), "_fc2a4dc10447c2ea12cfdc3" . "74a358977" => base64_decode("UmVtb3ZlZCBmc" . "m9tIENETg=="), "_12dc1aec3" . "6fa158c9e3" . "daf6e7c1db" . "37d" => base64_decode("Li4vY29tbW9uL3Nlc3N" . "pb25jaGVjay5waHA="), "_f149cf29770e8209" . "5e992315e2ab26e2" => base64_decode("K" . "A" . "=" . "="), "_a62d761" . "f3e831ff" . "9d9da39f" . "9c26ecdd" . "c" => base64_decode("Li4vY29tbW9uL2N" . "vcmUucGhw"));
$GLOBALS["__65da1b1ec2d6653e8a0a" . "b7848e536215"]["_dcf86ccc31af" . "7f63af36115aa" . "12b1ee7"]($GLOBALS["__65da1b1ec" . "2d6653e8a0a" . "b7848e53621" . "5"]["_94c6793215f851" . "b383066a9d77888" . "350"]);
require_once $GLOBALS["__65da1b1ec2d6653e8a0ab7848e5362" . "15"]["_12dc1aec36fa158c9e3daf6e7" . "c1db37d"];
require_once $GLOBALS["__65da1b1ec2d6653e8" . "a0ab7848e536215"]["_a62d761f3e831" . "ff9d9da39f9c26" . "ecddc"];
require_once $GLOBALS["__65da1b1ec2d6653e8a0ab7848e536" . "215"]["_11ff9bccdcd23cd6bf9d9" . "2884ea6cc39"];
$area = $GLOBALS["__65da1b1ec2d6653e8a" . "0ab7848e536215"]["_2b9b83b16cb8aa329cf0691ef433f" . "372"];
require_once $GLOBALS["__65da1b1ec2d66" . "53e8a0ab7848e53" . "6215"]["_7667b7b0d" . "7492f8a294" . "76778f1c90" . "cfd"];
use Claromentis\Core\CDN\CDNInterface;
$cdn = Claromentis\Core\Services::I()->GetCDN();
$cdn_is_mirror = $cdn instanceof Claromentis\Core\CDN\Mirror;
$sync = $GLOBALS["__65da1b1ec2d6653e8a0ab7848e53" . "6215"]["_19bdfdeb" . "b609516a9" . "e88a678d1" . "a13402"]($GLOBALS["__65da1b1ec2d6653e8a0" . "ab7848e536215"]["_8eb9b7a6264dd256d7cc1e" . "27990090df"]);
$path = $GLOBALS["__65da1b1e" . "c2d6653e8a" . "0ab7848e53" . "6215"]["_19bdfdebb609516a9e88a678d1a134" . "02"]($GLOBALS["__65da1b1ec2d6653e8a0ab7848" . "e536215"]["_82a65eef3d03e3f61aac05d" . "f4e052c1f"]);
$do_sync = $cdn_is_mirror && $sync;
$top_dirs = array();
$notice = $GLOBALS["__65da1b1ec2d6653" . "e8a0ab7848e536215"]["_4d707fab93bebb00bbe69e8159" . "697c90"];
$error = $GLOBALS["__65da1b1ec2d6653e8a0ab7" . "848e536215"]["_4d707fab93" . "bebb00bbe69" . "e8159697c90"];
if ($cdn_is_mirror) {
    $top_dirs = $cdn->GetDirs(null);
} else {
    $notice = $GLOBALS["__65da1b1ec2d6653e8" . "a0ab7848e536215"]["_a47232a5e5a193d8cbed77b" . "5806886ac"];
}
$trace = array();
if ($do_sync) {
    $GLOBALS["__65da1b1ec2d665" . "3e8a0ab7848e5362" . "15"]["_b9a32c49" . "6caec79a7" . "5e10251d2" . "3f433a"](0);
    if ($path && !$GLOBALS["__65da1b1e" . "c2d6653e8a" . "0ab7848e53" . "6215"]["_bd71c3b5c201fc11db82ed14ce424d" . "e5"]($path, $top_dirs)) {
        $notice = $GLOBALS["__65da1b1ec2d6653e8a0ab78" . "48e536215"]["_2b1c8f2874a1d2736" . "bf9dc0d6b441fd1"];
    } else {
        $start = $GLOBALS["__65da1b1ec2d6653e8a0ab7" . "848e536215"]["_cacda84c05d3266" . "a2ccc76b15553369" . "c"](true);
        try {
            $trace = $cdn->Sync($path);
        } catch (Exception $e) {
            $error = $e;
        }
        $stop = $GLOBALS["__65da1b1ec2d" . "6653e8a0ab784" . "8e536215"]["_cacda84c05d3266a2ccc76b1555" . "3369c"](true) - $start;
        $time = $GLOBALS["__65da1b1ec2" . "d6653e8a0ab7" . "848e536215"]["_b92b5ed2e" . "daf18b8eec" . "721c1422e3" . "4ee"]($stop, 2) . $GLOBALS["__65da1b1ec2d6653e" . "8a0ab7848e536215"]["_14ae1876cf3a634118f7390d6109d63" . "a"];
    }
}
if (!$GLOBALS["__65da1b1ec2d6653e8a0ab7848e536" . "215"]["_e65cb50b" . "c5bd4a2a6" . "a73d7384a" . "f96ffe"]($GLOBALS["__65da1b1ec" . "2d6653e8a0a" . "b7848e53621" . "5"]["_b906cc8ca18" . "8cb97ded21e4" . "73e9acaed"])) {
    function cdn_sync_pretty_result($result)
    {
        switch ($result) {
            case CDNInterface::REPLICATE_ADDED:
                return $GLOBALS["__65da1b1ec2d6653e8a0ab7848e53" . "6215"]["_1c533f921aad941446a723f0d" . "cc2af7b"];
            case CDNInterface::REPLICATE_REMOVED:
                return $GLOBALS["__65da1b1ec2d6653e8a" . "0ab7848e536215"]["_fc2a4dc10447c2ea12" . "cfdc374a358977"];
            case CDNInterface::REPLICATE_IN_SYNC:
                return $GLOBALS["__65da1b1ec2d6653e" . "8a0ab7848e536215"]["_a2e162232fe4fd" . "9a43f2a8a5f8a8c" . "4a3"];
        }
    }
}
?>
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title>CDN Synchronisation</title>
		<link type="text/css" href="/interface_default/css/bootstrap.min.css" media="screen" rel="stylesheet" />
		<link type="text/css" href="/interface_default/css/style.css" media="screen" rel="stylesheet" />
		<link type="text/css" href="/interface_default/css/glyphicons.min.css" media="all" rel="stylesheet" />
		<style>
			.main-panel {
				position: relative;
			}
			.loading-icon {
				display: none;
				padding: 15px 30px;
				position: absolute;
				left: 50%;
				top: 50%;
				margin-left: -36px;
				margin-top: -24px;
				border-radius: 4px;
				background-color: #00adef;
			}

			.container {
				padding: 0;
			}

			.loading-icon span {
				color:#fff;
			    -webkit-animation:spin 1s linear infinite;
			    -moz-animation:spin 1s linear infinite;
			    animation:spin 1s linear infinite;
			}

			@-moz-keyframes spin { 100% { -moz-transform: rotate(360deg); } }
			@-webkit-keyframes spin { 100% { -webkit-transform: rotate(360deg); } }
			@keyframes spin { 100% { -webkit-transform: rotate(360deg); transform:rotate(360deg); } }

			#loading-msg {
				display: none;
			}

			.path-column {
				width:50%;
			}
		</style>
		<script src="/components/vendor.js"></script>
		<script>
			(function(){
				jQuery(function($){
					$('form').on("submit", function(e){
						$(e.target).append($('#loading-icon').css('display', 'inline-block'));
						$('#loading-msg').show();

						return true;
					});
				});
			})();
		</script>
	</head>
	<body>
		<div class="wrapper container" style="border: 1px solid #ddd; margin: 20px auto">
			<div class="page_box">
				<div class="main-panel">

					<div id="loading-icon" class="loading-icon">
						<span class="glyphicons glyphicons-refresh"></span>
					</div>
					<h3>CDN Synchronisation Tool</h3>

					<?php 
if ($notice) {
    ?>
						<div class="alert alert-info">
							<?php 
    echo $notice;
    ?>
						</div>
					<?php 
}
?>

					<?php 
if ($error) {
    ?>
						<div class="alert alert-danger">
							<?php 
    echo $GLOBALS["__65da1b1ec2d6653e8a0ab7" . "848e536215"]["_0ca500f726336130836d" . "c931a6f65b7b"]($e->getMessage() . $GLOBALS["__65da1b1ec2d6653e8a0ab7848e5362" . "15"]["_2da6e43eb49a13e85f6500bfe4fceb5" . "b"] . $e->getFile() . $GLOBALS["__65da1b1ec2d6653e8a0ab7848e5" . "36215"]["_c4b51c5ff89d505d6179b2efa5c7" . "c834"] . $e->getLine() . $GLOBALS["__65da1b1ec2d6653e8a0a" . "b7848e536215"]["_0284d38f97f9e8b9c7b03bb892" . "8afae1"]);
    ?>
							<?php 
    foreach ($e->getTrace() as $ekey => $etrace) {
        ?>
								<?php 
        echo $GLOBALS["__65da1b1ec2d6653e8a0ab7848e53621" . "5"]["_d1e794a5a340ae52fcb5" . "0999ef7ae193"] . $ekey . $GLOBALS["__65da1b1ec2" . "d6653e8a0ab7" . "848e536215"]["_88c0fe4439f1efb05" . "b37d61d25d02f4f"] . $etrace[$GLOBALS["__65da1b1ec2" . "d6653e8a0ab7" . "848e536215"]["_6ae3783b9ad544a6c3" . "1a979683fed870"]] . $GLOBALS["__65da1b1ec2d" . "6653e8a0ab784" . "8e536215"]["_c4b51c5ff89d505d6179b2efa5c7" . "c834"] . $etrace[$GLOBALS["__65da1b1ec2d6653e8a" . "0ab7848e536215"]["_a2da5768d1ad9473e97" . "9acaaeb98624c"]] . $GLOBALS["__65da1b1ec2d6653e8" . "a0ab7848e536215"]["_4ec270e09b92c3aeda" . "370fdd3dcd480c"] . $etrace[$GLOBALS["__65da1b1ec2d6653e8a0ab7848e53621" . "5"]["_35ed77ccccaf3a0" . "56dcf16acae33bbe" . "0"]] . $etrace[$GLOBALS["__65da1b1e" . "c2d6653e8a" . "0ab7848e53" . "6215"]["_dadf790baf241afac9428" . "24c1e6e37c4"]] . $etrace[$GLOBALS["__65da1b1ec2d6653e8a0ab7848e536" . "215"]["_3a1d32b00" . "c281a9ae85" . "9aa88201be" . "7c9"]] . $GLOBALS["__65da1b1ec2d6653" . "e8a0ab7848e536215"]["_f149cf2977" . "0e82095e992" . "315e2ab26e2"] . $GLOBALS["__65da1b1ec2d6653e8a0ab7848e53" . "6215"]["_6e869efc5759327c6ac6fbc411f" . "80a2b"];
        ?>
							<?php 
    }
    ?>
						</div>
					<?php 
}
?>

					<?php 
if ($cdn_is_mirror) {
    ?>
						<?php 
    if ($sync) {
        ?>
							<p>&laquo; <a href="<?php 
        echo $GLOBALS["__65da1b1ec2d6653e8a0ab7848e53" . "6215"]["_0ca500f7263" . "36130836dc93" . "1a6f65b7b"]($_SERVER[$GLOBALS["__65da1b1ec2d6" . "653e8a0ab7848e" . "536215"]["_59be04fc0edf7507f" . "42c6c80666dc1e3"]]);
        ?>">Back to sync options</a></p>
							<h4>Syncronisation result</h4>
							<p>Completed in <strong><?php 
        echo $time;
        ?></strong>.</p>
							<table class="table">
								<?php 
        foreach ($trace as $path => $result) {
            ?>
									<tr class="<?php 
            if ($result == CDNInterface::REPLICATE_ADDED) {
                echo $GLOBALS["__65da1b1ec2d6653e8a0ab7848e53621" . "5"]["_4b5e91a0a6f7f822ac389ad9" . "a3fb0ee2"];
            } else {
                if ($result == CDNInterface::REPLICATE_REMOVED) {
                    echo $GLOBALS["__65da1b1ec2d6653e8a0ab7848e5362" . "15"]["_ba3845cb79c005cf32" . "69af8c83ddbe5e"];
                }
            }
            ?>">
										<td><?php 
            echo $path;
            ?></td>
										<td><?php 
            echo $GLOBALS["__65da1b1ec2d6653e8" . "a0ab7848e536215"]["_d35734aa7aee2b" . "627072a1e23fa6e" . "67a"]($result);
            ?></td>
									</tr>
								<?php 
        }
        ?>
							</table>
						<?php 
    } else {
        ?>
							<p>This tool can be used to replicate local application content to the currently configured CDN.</p>
							<p>You can choose to synchronise all files or only those that fall under a top level directory.</p>

							<p>
								<form method="get">
									<input type="hidden" name="sync" value="true">
									<input class="btn btn-info" type="submit" value="Synchronise all files">
								</form>
							</p>

							<p id="loading-msg" class="alert alert-info">
								Local data is now being synchronised with the currently configured CDN.
								Please bear in mind that the more files there are to process, the longer it will take.
							</p>

							<h4>Synchronise specific top-level directories</h4>
							<table class="table">
								<?php 
        foreach ($top_dirs as $dir) {
            ?>
									<tr>
										<td class="path-column"><?php 
            echo $dir;
            ?></td>
										<td class="button-column">
											<form method="get">
												<input type="hidden" name="sync" value="true" />
												<input type="hidden" name="path" value="<?php 
            echo $dir;
            ?>" />
												<input class="btn btn-info" type="submit" value="Synchronise" />
											</form>
										</td>
									</tr>
								<?php 
        }
        ?>
							</table>
						<?php 
    }
    ?>
					<?php 
}
?>
				</div>
			</div>
		</div>
	</body>
</html>
<?php 