Replies: 1 comment
-
Looks like this was created by accident, closing. If needed, feel free to reopen with more details, thank you! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
' . $github.com . '
directory.'); return true; } else { $output .= addItem('neutral', false, $fail . 'Failed to create new' . $path . ' 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
Install X3 with sample content ~ 48 MB ');
// 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 .= '' . $basename . ' ';
}
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:Start X3 Install ';
?>
<title>X3 Installer</title>
<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>
>
<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>
<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 = '';
if(title) str += '' + title + '';
str += '' + description + ' ';
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
_cache/.htaccess
to prevent cache files from being accessible.'); // remove ZIP if(@unlink($myfile)) { $output .= addItem("neutral", false, $tick . 'Successfully removed' . $myfile . '
'); } else { $output .= addItem("neutral", false, $fail . 'Failed to remove temporary ZIP file' . $myfile . '
. This file will need to be removed manually.'); } // remove installer script if(@unlink($script_name)) { $output .= addItem("neutral", false, $tick . 'Successfully removed' . $script_name . '
script.'); } else { $output .= addItem("neutral", false, $fail . 'Failed to remove' . $script_name . '
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 'FAIL: curl_setopt(CURLOPT_NOBODY)
'; if(!@curl_exec($ch)) return 'FAIL: curl_exec()
'; $code = @curl_getinfo($ch, CURLINFO_HTTP_CODE); if(!$code) return 'FAIL: curl_getinfo(CURLINFO_HTTP_CODE)
'; curl_close($ch); return $code === 200 ? true : 'This is likely because your server does not allow cURL to external resources for security reasons.'; } else { return 'This is likely because your server does not allow cURL to external resources for security reasons.FAIL: curl_init()
'; } } // 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 " . $zip_file . ". X3 will be installed from the zip file." . (has_curl() ? '* Remove or rename the zip file if you want to re-download latest X3.' : '')); // info $output .= addItem("neutral", "Ready to install X3!", 'The X3 installer will attempt to perform the following tasks:
' . ($zip_file ? '' : '- Download latest X3.
') . '- ' . ($zip_file ? 'Install X3 from file ' . $zip_file . '' : 'Install X3 in this directory') . '.
- Perform various maintenance tasks.
- Redirect to X3 diagnostics page.
'); // curl: choose install if(!$zip_file) $output .= addItem("neutral", null, 'Minimal X3 Install ~ 5 MB
' . $dir_content_warning . '
'); } // 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 PHP cURL installed, we failed to access the remote X3 ZIP file. " . $curl_test); } // no cURL :( } else { $warning .= addItem("warning", "Missing PHP cURL", 'X3 installer requires PHP cURL to be able to install from remote URL. If you download 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 ZipArchive to be able to unzip an X3 release."); if(!has_curl() && !$zip_file) $critical .= addItem("danger", "Missing PHP cURL", "X3 installer requires PHP cURL to be able to install from a remote URL."); } // output $output = $critical.$warning.$output; // button if($proceed) $output .= 'X3 Installer
' + file + '
and' + 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('Proceed to X3 diagnostics'); 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 = ' ',
tick = '✓ ',
file = '',
zip_file = ,
script_name = '',
new_x3_version,
version = ,
download_path = '';
// 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 ');
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 Adblock 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 X3 demo website.' : '* 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('', 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>
[devcontainer.json](https://github.com/user-attachments/files/17172069/devcontainer.json)
' + version + '
was not found.'); } else if(!success) { diagnostics_wrapper.children().remove(); // test for adblock diagnostics_container.append('<p=p/>
Beta Was this translation helpful? Give feedback.
All reactions