blue-twilight/public/license-required.php

98 lines
2.6 KiB
PHP

<?php
/* START EXISTING LICENSE CHECK */
/* For security reasons, don't allow use of this page if a license file already exists */
$licenseFile = sprintf('%s/blue-twilight.lic', dirname(__DIR__));
if (file_exists($licenseFile))
{
header('Location: index.php');
exit();
}
/* END EXISTING LICENSE CHECK */
/* START LANGUAGE */
$lang = 'en';
if (isset($_GET['lang']))
{
$lang = trim(strtolower(stripslashes($_GET['lang'])));
}
$langFile = sprintf('%s/raw/lang.%s.php', __DIR__, $lang);
if (!file_exists($langFile))
{
$langFile = sprintf('%s/raw/lang.en.php', __DIR__);
}
$lang = include $langFile;
/* END LANGUAGE */
/* START UPLOAD PROCESSING */
$uploadError = null;
if (strtolower($_SERVER['REQUEST_METHOD']) == 'post' && isset($_FILES['upload-license-file']))
{
if ($_FILES['upload-license-file']['error'] != 0)
{
$uploadError = $lang['upload_errors'][$_FILES['upload-license-file']['error']];
}
elseif (!move_uploaded_file($_FILES['upload-license-file']['tmp_name'], $licenseFile))
{
$uploadError = $lang['upload_errors'][99];
}
else
{
header('Location: index.php');
exit();
}
}
/* END UPLOAD PROCESSING */
/* START LICENSE ERROR */
$licenseError = null;
if (isset($_GET['licerror']))
{
$licenseErrorNumber = intval($_GET['licerror']);
if (isset($lang['license_errors'][$licenseErrorNumber]))
{
$licenseError = $lang['license_errors'][$licenseErrorNumber];
}
else
{
$licenseError = $lang['license_errors'][99];
}
}
/* END LICENSE ERROR */
ob_start();
?>
<h1><?php echo $lang['license_required_title']; ?></h1>
<p><?php echo $lang['license_required_p1']; ?></p>
<p><?php echo str_replace(':host_name', sprintf('<b>%s</b>', $_SERVER['SERVER_NAME']), $lang['license_required_p2']); ?></p>
<hr/>
<?php if (!is_null($uploadError)): ?>
<div class="alert alert-danger">
<p><?php echo $uploadError; ?></p>
</div>
<?php endif; ?>
<?php if (!is_null($licenseError)): ?>
<div class="alert alert-danger">
<p><?php echo $licenseError; ?></p>
</div>
<?php endif; ?>
<form action="license-required.php" method="post" enctype="multipart/form-data">
<div class="form-group">
<label class="control-label"><?php echo $lang['upload_license_label']; ?></label>
<input type="file" name="upload-license-file"/>
</div>
<div class="form-group">
<button class="btn btn-success" type="submit"><?php echo $lang['upload_action']; ?></button>
</div>
</form>
<?php
$content = ob_get_clean();
require sprintf('%s/raw/layout.php', __DIR__);
?>