Implemented setting to enable/disable updates

This commit is contained in:
kolaente 2017-10-06 16:43:03 +02:00
parent a485c1763c
commit a7b7007346
6 changed files with 56 additions and 173 deletions

View File

@ -3,25 +3,25 @@ require_once '../inc/autoload_adm.php';
printHeader($lang->get('general_config'));
tinymce();
?>
<div class="main">
<form method="POST" action="action.php?general">
<div class="form">
<div class="main">
<form method="POST" action="action.php?general">
<div class="form">
<?php
if (hasPerm('edit_title'))
{
?>
<p><span><?php echo $lang->get('general_website_title'); ?></span>
<input type="text" name="titel" value="<?php
<p><span><?php echo $lang->get('general_website_title'); ?></span>
<input type="text" name="titel" value="<?php
echo $MCONF['title'];
?>"/>
</p>
</p>
<?php
}
if (hasPerm('construction'))
{
?>
<p><span><?php echo $lang->get('general_construction_mode'); ?></span>
<p><span><?php echo $lang->get('general_construction_mode'); ?></span>
<?php
if (file_exists('../content/.system/construction.txt'))
{
@ -31,51 +31,56 @@ tinymce();
echo '<a href="action.php?construction" class="button">' . $lang->get('general_start_construction_mode') . '</a>';
}
?> <a href="action.php?construction&constr_message"
class="button"><?php echo $lang->get('general_edit_message'); ?></a>
</p>
class="button"><?php echo $lang->get('general_edit_message'); ?></a>
</p>
<?php
}
if (hasPerm('update'))
{
?>
<i class="divider"></i>
<h1><?php echo $lang->get('update_version'); ?></h1>
<p><?php echo $lang->get('update_version_current'); ?>:
<i class="divider"></i>
<h1><?php echo $lang->get('update_version'); ?></h1>
<p><?php echo $lang->get('update_version_current'); ?>:
<?php
echo $MCONF['version'];
?>
</p>
<p>
<div id="checkUpdate">
<div class="spinner-container" style="margin: 0;">
<svg class="spinner" style="width:41px;height:40px;" viewBox="0 0 44 44">
<circle class="path" cx="22" cy="22" r="20" fill="none" stroke-width="4"></circle>
</svg>
</div>
<div style="margin: -35px 0 0 55px;padding-bottom: 10px;">Überprüfe auf Updates...</div>
</div>
</p>
</p>
<?php
if ($MCONF['update_enabled'])
{
?>
<p>
<div id="checkUpdate">
<div class="spinner-container" style="margin: 0;">
<svg class="spinner" style="width:41px;height:40px;" viewBox="0 0 44 44">
<circle class="path" cx="22" cy="22" r="20" fill="none" stroke-width="4"></circle>
</svg>
</div>
<div style="margin: -35px 0 0 55px;padding-bottom: 10px;"></div>
</div>
</p>
<script>
$.get('update.php?checkUpdate', function (data) {
$('#checkUpdate').html('');
$('#checkUpdate').html(data);
});
</script>
<script>
$.get('update.php?checkUpdate', function (data) {
$('#checkUpdate').html('');
$('#checkUpdate').html(data);
});
</script>
<?php
}
}
if (hasPerm('db_dump'))
{
?>
<i class="divider"></i>
<h1><?php echo $lang->get('general_database'); ?></h1>
<p>
<a href="action.php?dbbackup" class="button" download="download"><i
class="fa fa-database"></i> <?php echo $lang->get('general_create_backup'); ?>
</a>
</p>
<i class="divider"></i>
<h1><?php echo $lang->get('general_database'); ?></h1>
<p>
<a href="action.php?dbbackup" class="button" download="download"><i
class="fa fa-database"></i> <?php echo $lang->get('general_create_backup'); ?>
</a>
</p>
<?php
}
@ -86,7 +91,7 @@ tinymce();
require $appUri . $appconf['app_path'] . '/config.php';
if (isset($_CONF['general_conf']) && $_CONF['general_conf'] != '' && file_exists($appUri . $appconf['app_path'] . '/' . $_CONF['general_conf']))
{
if(file_exists($appUri . $appconf['app_path'] . '/lang/') && is_dir($appUri . $appconf['app_path'] . '/lang/'))
if (file_exists($appUri . $appconf['app_path'] . '/lang/') && is_dir($appUri . $appconf['app_path'] . '/lang/'))
{
$lang->setLangFolder($appUri . $appconf['app_path'] . '/lang/');
}
@ -96,11 +101,11 @@ tinymce();
}
?>
<i class="divider"></i>
<input type="submit" class="speichern" value="<?php echo $lang->get('general_save_changes'); ?>"
style="width: auto;"/>
</div>
</form>
<i class="divider"></i>
<input type="submit" class="speichern" value="<?php echo $lang->get('general_save_changes'); ?>"
style="width: auto;"/>
</div>
</form>
<?php
require_once '../inc/footer.php';
?>

View File

@ -66,9 +66,9 @@ if (isset($_POST['submit']))
$CONFIG['Templating']['tpl_title'] = 'title';
$CONFIG['Templating']['tpl_content'] = 'content';
$CONFIG['Templating']['tpl_webUri'] = 'website_uri';
$CONFIG['Versioning']['version'] = '0.96';
$CONFIG['Versioning']['version_num'] = 9;
$CONFIG['Versioning']['update_servers'][] = 'https://cdn.kola-entertainments.de/cms/';
$CONFIG['Versioning']['version'] = '0.97';
$CONFIG['Versioning']['update_enabled'] = true;
$CONFIG['Versioning']['update_servers'][] = 'https://update.mowie.cc/';
$CONFIG['Mail']['smtp'] = false;
//Mail Settings

View File

@ -238,6 +238,7 @@ $lang['update_log'] = '{user} hat das System geupdated.';
$lang['update_folder_not_writeable'] = 'Der Updateordner ist nicht schreibbar. Bitte stelle sicher, dass der Webserver Schreibrechte im Updateordner hat.';
$lang['update_create_backup_error'] = 'Beim Erstellen eines Backups ist ein Fehler aufgetreten.';
$lang['update_cleanup_error'] = 'Beim Aufräumen ist ein Fehler aufgetreten.';
$lang['update_checking'] = 'Überprüfe auf Updates...';
//Stream Messages
$lang['stream_saved_settings'] = '{user} hat seinen Benutzername/Email-Adresse geändert.';

View File

@ -231,7 +231,8 @@ $lang['update_app_update_available'] = 'App-Update - New Version for "%1$s" avai
$lang['update_log'] = '{user} updated the System.';
$lang['update_folder_not_writeable'] = 'The updatefolder is not writeable. Please make sure your webserver can write into the folder.';
$lang['update_create_backup_error'] = 'An error occured while creating a backup.';
$lang['update_cleanup_error'] = 'Beim Aufräumen ist ein Fehler aufgetreten.';
$lang['update_cleanup_error'] = 'An error occured during cleanup.';
$lang['update_checking'] = 'Checking for updates...';
//Stream Messages
$lang['stream_saved_settings'] = '{user} changed it\'s username and/or email-adress.';

View File

@ -18,7 +18,7 @@ $update->thingsToNotUpdate = [
if (isset($_GET['checkUpdate']))
{
//sleep(50);
if (hasPerm('update'))
if (hasPerm('update') && $MCONF['update_enabled'])
{
//Check for newer Version
try
@ -75,7 +75,7 @@ if (isset($_GET['showChangelog']))
if (isset($_GET['update']))
{
printHeader($lang->get('update_title'));
if (hasPerm('update'))
if (hasPerm('update') && $MCONF['update_enabled'])
{
//Check for newer Version
try
@ -175,130 +175,6 @@ if (isset($_GET['update']))
{
echo msg('info', $lang->get('update_version_current_new'));
}
/*
$updated = false;
foreach ($MCONF['update_servers'] as $update_server)
{
$nextVersion = $MCONF['version_num'] + 1;
$installedVersion = $MCONF['version_num'];
//If we want to see the changelog for an app, we need to look in a different directory
$remoteSubDir = 'System';
$systemSubDir = '../';
if (isset($_GET['appUpdate']))
{
require '../apps/' . urldecode($_GET['appUpdate']) . '/config.php';
$remoteSubDir = 'apps/' . str_replace(' ', '-', $_CONF['app_name']);
$nextVersion = $_CONF['app_build'] + 1;
$systemSubDir = '../apps/' . urldecode($_GET['appUpdate']) . '/';
$installedVersion = $_CONF['app_build'];
}
//Check for version.json on the remote server
$dUri = $update_server . $remoteSubDir . '/v' . $nextVersion . '/';
if (remote_file_exists($dUri . 'version.json'))
{
$version_remote = json_decode(file_get_contents($dUri . 'version.json'));
//Check if the remote version is newer
if ($version_remote->versionNum > $installedVersion)
{
//Download the update
if (copy($dUri . 'update.v' . $version_remote->versionNum . '.incremental.zip', 'update.zip'))
{
$updated = true;
//Check for md5 hash
if (md5_file('update.zip') == $version_remote->md5)
{
//unzip to temporary folder
$updateTmpDir = 'updateTmp/';
if (!file_exists($updateTmpDir))
{
if (mkdir($updateTmpDir, 0777) === false)
{
echo msg('fail', 'Error creating temporary folder.');
}
}
$zip = new ZipArchive;
$res = $zip->open('update.zip');
if ($res === true)
{
$zip->extractTo($updateTmpDir);
$zip->close();
$updateInfos = json_decode(file_get_contents($updateTmpDir . 'filesToUpdate.json'));
$isUp = false;
$fTU = [];
foreach ($updateInfos->files as $num => $file)
{
$fTU[] = $file;
$upNeu = $updateTmpDir . $file;
$upRem = $systemSubDir . $file;
if (copy($upNeu, $upRem))
{
echo msg('success', sprintf($lang->get('update_item_succss'), $file));
$isUp = true;
} else
{
echo msg('fail', sprintf($lang->get('update_item_fail'), $file));
}
}
//Update Version in Config File - only if we don't update an app
if (!isset($_GET['appUpdate']))
{
$config = Yaml::parse(file_get_contents('../config/config.yml', FILE_USE_INCLUDE_PATH));
$config['Versioning']['version'] = $version_remote->version;
$config['Versioning']['version_num'] = $version_remote->versionNum;
$configfile = Yaml::dump($config);
if (!file_put_contents('../config/config.yml', $configfile))
{
echo msg('fail', $lang->get('general_config_fail'));
}
}
//Remove "old" update
if (rrmdir($updateTmpDir) && $isUp && unlink('update.zip'))
{
if(isset($_GET['appUpdate']))
{
echo msg('success', sprintf($lang->get('update_app_succss'), $_CONF['app_name']) . ' <a href="general_config.php">' . $lang->get('back') . '</a>');
stream_message('{user} updated the app "{extra}".', 2, $_CONF['app_name']);
}
else
{
echo msg('success', $lang->get('update_succss') . ' <a href="general_config.php">' . $lang->get('back') . '</a>');
stream_message('{user} updated the system.', 2);
}
} else
{
echo msg('fail', $lang->get('update_fail') . ' <a href="general_config.php">' . $lang->get('back') . '</a>');
}
} else
{
echo msg('fail', $lang->get('update_fail_unzip'));
}
} else
{
echo msg('fail', $lang->get('update_md5_fake'));
}
} else
{
echo msg('fail', $lang->get('update_fail_copy'));
}
} else
{
echo msg('info', $lang->get('update_version_current_new'));
}
}
}
if(!$updated)
{
echo msg('info', $lang->get('update_version_current_new'));
}
*/
}
require_once '../inc/footer.php';
}

View File

@ -49,7 +49,7 @@ $MCONF['tpl_webUri'] = $config['Templating']['tpl_webUri'];
//Versioning
$MCONF['version'] = $config['Versioning']['version'];
$MCONF['version_num'] = $config['Versioning']['version_num'];
$MCONF['update_enabled'] = $config['Versioning']['update_enabled'];
$MCONF['update_servers'] = $config['Versioning']['update_servers'];
//Mailer