prepare to v1.6

This commit is contained in:
xiaomlove
2021-01-28 20:37:35 +08:00
parent 96e9eb42db
commit 1980b30829
11 changed files with 8 additions and 257 deletions
+1 -1
View File
@@ -160,7 +160,7 @@ class Install
public function listSettingTableRows()
{
$defaultSettingsFile = ROOT_PATH . '_doc/install/settings.default.php';
$defaultSettingsFile = __DIR__ . '/settings.default.php';
$originalConfigFile = ROOT_PATH . 'config/allconfig.php';
if (!file_exists($defaultSettingsFile)) {
throw new \RuntimeException("default setting file: $defaultSettingsFile not exists.");
+218
View File
@@ -0,0 +1,218 @@
<?php
ini_set('error_reporting', E_ALL);
ini_set('display_errors', 0);
if (!session_id()) {
session_start();
}
$rootpath = dirname(dirname(__DIR__)) . '/';
define('ROOT_PATH', $rootpath);
$isPost = $_SERVER['REQUEST_METHOD'] == 'POST';
require $rootpath . 'vendor/autoload.php';
require $rootpath . 'include/globalfunctions.php';
require $rootpath . 'include/functions.php';
require $rootpath . 'nexus/Database/helpers.php';
$install = new \Nexus\Install\Install();
$currentStep = $install->currentStep();
$maxStep = $install->maxStep();
//step 1
if ($currentStep == 1) {
$requirements = $install->listRequirementTableRows();
$pass = $requirements['pass'];
if ($isPost) {
$install->nextStep();
}
}
if ($currentStep == 2) {
$envExampleFile = "$rootpath.env.example";
$envExampleData = readEnvFile($envExampleFile);
$envFormControls = $install->listEnvFormControls();
$newData = array_column($envFormControls, 'value', 'name');
while ($isPost) {
try {
$install->createEnvFile($_POST);
$install->nextStep();
} catch (\Exception $exception) {
$_SESSION['error'] = $exception->getMessage();
break;
}
break;
}
$tableRows = [
[
'label' => '.env.example',
'required' => 'exists && readable',
'current' => $envExampleFile,
'result' => $install->yesOrNo(file_exists($envExampleFile) && is_readable($envExampleFile)),
],
];
$fails = array_filter($tableRows, function ($value) {return $value['result'] == 'NO';});
$pass = empty($fails);
}
if ($currentStep == 3) {
$pass = true;
$shouldCreateTable = $install->listShouldCreateTable();
while ($isPost) {
try {
$install->createTable($shouldCreateTable);
$install->nextStep();
} catch (\Exception $exception) {
$_SESSION['error'] = $exception->getMessage();
break;
}
break;
}
}
//if ($currentStep == 4) {
// $pass = true;
// while (true) {
// $shouldAlterTable = listShouldAlterTable();
// if ($isPost) {
// if (!empty($shouldAlterTable)) {
// try {
// sql_query('SET sql_mode=(SELECT REPLACE(@@sql_mode,"NO_ZERO_DATE", ""));');
// foreach ($shouldAlterTable as $table => $fields) {
// $sqlAlter = "alter table $table";
// $sqlUpdate = "update $table";
// $updateWhere = [];
// foreach ($fields as $field) {
// $sqlAlter .= " modify $field datetime default null,";
// $sqlUpdate .= " set $field = null,";
// $updateWhere[] = "$field = '0000-00-00 00:00:00'";
// }
// $sqlAlter = rtrim($sqlAlter, ',');
// $sqlUpdate = rtrim($sqlUpdate, ',') . " where " . implode(' or ', $updateWhere);
// sql_query($sqlUpdate);
// sql_query($sqlAlter);
// }
// } catch (\Exception $e) {
// $_SESSION['error'] = $e->getMessage();
// break;
// }
// }
// goStep($currentStep + 1);
// }
// break;
// }
//}
if ($currentStep == 4) {
$settingTableRows = $install->listSettingTableRows();
$settings = $settingTableRows['settings'];
$symbolicLinks = $settingTableRows['symbolic_links'];
$tableRows = $settingTableRows['table_rows'];
$pass = $settingTableRows['pass'];
while ($isPost) {
try {
$install->importInitialData();
$install->saveSettings($settings);
$install->createSymbolicLinks($symbolicLinks);
$install->nextStep();
} catch (\Exception $e) {
$_SESSION['error'] = $e->getMessage();
break;
}
break;
}
}
if ($currentStep == 5) {
if ($isPost) {
try {
$install->createAdministrator($_POST['username'], $_POST['email'], $_POST['password'], $_POST['confirm_password']);
$install->nextStep();
} catch (\Exception $exception) {
$_SESSION['error'] = $exception->getMessage();
}
}
$pass = true;
$userFormControls = [
['label' => '用户名', 'name' => 'username', 'value' => $_POST['username'] ?? ''],
['label' => '邮箱', 'name' => 'email', 'value' => $_POST['email'] ?? ''],
['label' => '密码', 'name' => 'password', 'value' => $_POST['password'] ?? ''],
['label' => '重复密码', 'name' => 'confirm_password', 'value' => $_POST['confirm_password'] ?? ''],
];
}
?>
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css" rel="stylesheet">
<title>Install NexusPHP | step <?php echo $currentStep?></title>
</head>
<body>
<div class="container mx-auto">
<?php echo $install->renderSteps()?>
<div class="mt-10">
<form method="post" action="<?php echo getBaseUrl() . '?step=' . $currentStep?>">
<input type="hidden" name="step" value="<?php echo $currentStep?>">
<?php
echo'<div class="step-' . $currentStep . ' text-center">';
$header = ['项目', '要求', '当前', '结果'];
if ($currentStep == 1) {
echo $install->renderTable($header, $requirements['table_rows']);
} elseif ($currentStep == 2) {
echo $install->renderTable($header, $tableRows);
echo '<div class="text-gray-700 p-4 text-red-400">若 Redis 不启用,相关项目留空</div>';
echo $install->renderForm($envFormControls);
} elseif ($currentStep == 3) {
echo '<h1 class="mb-4 text-lg font-bold">需要新建以下数据表</h1>';
if (empty($shouldCreateTable)) {
echo '<div class="text-green-600 text-center">恭喜,需要的表均已创建!</div>';
} else {
echo sprintf('<div class="h-64 text-left inline-block w-2/3"><code class="bolck w-px-100">%s</code></div>', implode(', ', array_keys($shouldCreateTable)));
}
} elseif ($currentStep == 4) {
echo $install->renderTable($header, $tableRows);
echo '<div class="text-blue-500 pt-10">';
echo sprintf('这一步会把 <code>%s</code> 的数据合并到 <code>%s</code>, 然后插入数据库中。', $tableRows[1]['label'], $tableRows[0]['label']);
echo '</div>';
} elseif ($currentStep == 5) {
echo $install->renderForm($userFormControls, '1/3', '1/4', '3/4');
} elseif ($currentStep > $maxStep) {
echo '<div class="text-green-900 text-6xl p-10">恭喜,一切就绪!</div>';
echo '<div class="mb-6">有问题可查阅安装日志:<code>' . $install->getLogFile() . '</code></div>';
echo '<div class="text-red-500">为安全起见,请删除以下目录</div>';
echo '<div class="text-red-500"><code>' . $install->getInsallDirectory() . '</code></div>';
}
echo'</div>';
if (!empty($_SESSION['error'])) {
echo sprintf('<div class="text-center text-red-500 p-4">Error: %s</div>', nl2br($_SESSION['error']));
unset($_SESSION['error']);
}
if (!empty($_SESSION['copy'])) {
echo sprintf('<div class="text-center"><textarea class="w-1/2 h-40 border">%s</textarea></div>', $_SESSION['copy']);
unset($_SESSION['copy']);
}
?>
<div class="mt-10 text-center">
<button class="bg-blue-500 p-2 m-4 text-white rounded" type="button" onclick="goBack()">上一步</button>
<?php if ($currentStep <= $maxStep) {?>
<button class="bg-blue-<?php echo $pass ? 500 : 200;?> p-2 m-4 text-white rounded" type="submit" <?php echo $pass ? '' : 'disabled';?>>下一步</button>
<?php } else {?>
<a class="bg-blue-500 p-2 m-4 text-white rounded" href="<?php echo getSchemaAndHttpHost()?>">回首页</a>
<?php }?>
</div>
</form>
</div>
</div>
<div class="mt-10 text-center">
欢迎使用 NexusPHP 安装程序,如有疑问,点击<a href="http://nexusphp.cn/" target="_blank" class="text-blue-500 p-1">这里</a>获取参考。
</div>
</body>
<script>
function goBack() {
window.location.search="step=<?php echo $currentStep == 1 ? 1 : $currentStep - 1?>"
}
</script>
</html>
+354
View File
@@ -0,0 +1,354 @@
<?php
return array (
'basic' =>
array (
'SITENAME' => 'NexusPHP',
),
'main' =>
array (
'site_online' => 'yes',
'max_torrent_size' => '1048576',
'announce_interval' => '1800',
'annintertwoage' => '7',
'annintertwo' => '2700',
'anninterthreeage' => '30',
'anninterthree' => '3600',
'signup_timeout' => '259200',
'minoffervotes' => '15',
'offervotetimeout' => '259200',
'offeruptimeout' => '86400',
'maxsubsize' => '3145728',
'postsperpage' => '10',
'topicsperpage' => '20',
'torrentsperpage' => '50',
'maxnewsnum' => '3',
'max_dead_torrent_time' => '21600',
'maxusers' => '50000',
'torrent_dir' => 'torrents',
'iniupload' => '0',
'SITEEMAIL' => '353856593@qq.com',
'ACCOUNTANTID' => '1',
'ALIPAYACCOUNT' => '',
'PAYPALACCOUNT' => '',
'SLOGAN' => 'The Ultimate File Sharing Experience',
'icplicense' => '',
'autoclean_interval_one' => '900',
'autoclean_interval_two' => '1800',
'autoclean_interval_three' => '3600',
'autoclean_interval_four' => '43200',
'autoclean_interval_five' => '648000',
'reportemail' => '353856593@qq.com',
'invitesystem' => 'yes',
'registration' => 'yes',
'showhotmovies' => 'no',
'showclassicmovies' => 'no',
'showimdbinfo' => 'no',
'enablenfo' => 'yes',
'enableschool' => 'no',
'restrictemail' => 'no',
'showpolls' => 'yes',
'showstats' => 'yes',
'showlastxtorrents' => 'no',
'showtrackerload' => 'yes',
'showshoutbox' => 'yes',
'showfunbox' => 'yes',
'showoffer' => 'yes',
'sptime' => 'no',
'showhelpbox' => 'no',
'enablebitbucket' => 'yes',
'smalldescription' => 'yes',
'altname' => 'no',
'extforum' => 'no',
'extforumurl' => 'http://www.cc98.org',
'defaultlang' => 'en',
'defstylesheet' => '3',
'donation' => 'yes',
'spsct' => 'no',
'browsecat' => '4',
'specialcat' => '4',
'waitsystem' => 'no',
'maxdlsystem' => 'no',
'bitbucket' => 'bitbucket',
'torrentnameprefix' => '[Nexus]',
'showforumstats' => 'yes',
'verification' => 'automatic',
'invite_count' => '0',
'invite_timeout' => '7',
'seeding_leeching_time_calc_start' => '',
'startsubid' => NULL,
'logo' => '',
'use_cron_trigger_cleanup' => 'yes',
'showlastxforumposts' => 'no',
'pt_gen_api_point' => 'https://ptgen.rhilip.info',
'enable_pt_gen_system' => 'yes',
),
'smtp' =>
array (
'smtptype' => 'external',
'emailnotify' => 'no',
'smtp_host' => 'localhost',
'smtp_port' => '233',
'smtp_from' => NULL,
'smtpaddress' => 'smtp.qq.com',
'smtpport' => '25',
'accountname' => '',
'accountpassword' => '',
),
'security' =>
array (
'securelogin' => 'no',
'securetracker' => 'no',
'https_announce_url' => '',
'iv' => 'yes',
'maxip' => '2',
'maxloginattempts' => '10',
'changeemail' => 'no',
'cheaterdet' => '1',
'nodetect' => '11',
),
'authority' =>
array (
'defaultclass' => '1',
'staffmem' => '13',
'newsmanage' => '14',
'newfunitem' => '1',
'funmanage' => '13',
'sbmanage' => '13',
'pollmanage' => '14',
'applylink' => '1',
'linkmanage' => '14',
'postmanage' => '13',
'commanage' => '13',
'forummanage' => '14',
'viewuserlist' => '2',
'torrentmanage' => '13',
'torrentsticky' => '14',
'torrentonpromotion' => '0',
'askreseed' => '2',
'viewnfo' => '2',
'torrentstructure' => '8',
'sendinvite' => '2',
'viewhistory' => '6',
'topten' => '2',
'log' => '5',
'confilog' => '13',
'userprofile' => '14',
'torrenthistory' => '2',
'prfmanage' => '13',
'cruprfmanage' => '14',
'uploadsub' => '1',
'delownsub' => '2',
'submanage' => '13',
'updateextinfo' => '7',
'viewanonymous' => '12',
'beanonymous' => '4',
'addoffer' => '0',
'offermanage' => '13',
'upload' => '2',
'uploadspecial' => '0',
'movetorrent' => '0',
'chrmanage' => '13',
'viewinvite' => '13',
'buyinvite' => '5',
'seebanned' => '12',
'againstoffer' => '1',
'userbar' => '2',
),
'tweak' =>
array (
'where' => 'no',
'iplog1' => 'yes',
'bonus' => 'enable',
'datefounded' => '2010-08-19',
'enablelocation' => 'yes',
'titlekeywords' => '',
'metakeywords' => '',
'metadescription' => '',
'enablesqldebug' => 'yes',
'sqldebug' => '13',
'cssdate' => '',
'enabletooltip' => 'yes',
'prolinkimg' => 'pic/prolink.png',
'analyticscode' => '',
'logging' => '/tmp/nexus.log',
),
'bonus' =>
array (
'donortimes' => '2',
'perseeding' => '1',
'maxseeding' => '7',
'tzero' => '4',
'nzero' => '7',
'bzero' => '100',
'l' => '300',
'uploadtorrent' => '15',
'uploadsubtitle' => '5',
'starttopic' => '2',
'makepost' => '1',
'addcomment' => '1',
'pollvote' => '1',
'offervote' => '1',
'funboxvote' => '1',
'saythanks' => '0.5',
'receivethanks' => '0',
'funboxreward' => '5',
'onegbupload' => '300',
'fivegbupload' => '800',
'tengbupload' => '1300',
'ratiolimit' => '6',
'dlamountlimit' => '50',
'oneinvite' => '1000',
'customtitle' => '5000',
'vipstatus' => '8000',
'bonusgift' => 'yes',
'basictax' => '4',
'taxpercentage' => '10',
'prolinkpoint' => '1',
'prolinktime' => '600',
),
'account' =>
array (
'neverdelete' => '6',
'neverdeletepacked' => '3',
'deletepacked' => '400',
'deleteunpacked' => '150',
'deletenotransfer' => '60',
'deletenotransfertwo' => '0',
'deletepeasant' => '30',
'psdlone' => '50',
'psratioone' => '0.4',
'psdltwo' => '100',
'psratiotwo' => '0.5',
'psdlthree' => '200',
'psratiothree' => '0.6',
'psdlfour' => '400',
'psratiofour' => '0.7',
'psdlfive' => '800',
'psratiofive' => '0.8',
'putime' => '4',
'pudl' => '50',
'puprratio' => '1.05',
'puderatio' => '0.95',
'eutime' => '8',
'eudl' => '120',
'euprratio' => '1.55',
'euderatio' => '1.45',
'cutime' => '15',
'cudl' => '300',
'cuprratio' => '2.05',
'cuderatio' => '1.95',
'iutime' => '25',
'iudl' => '500',
'iuprratio' => '2.55',
'iuderatio' => '2.45',
'vutime' => '40',
'vudl' => '750',
'vuprratio' => '3.05',
'vuderatio' => '2.95',
'exutime' => '60',
'exudl' => '1024',
'exuprratio' => '3.55',
'exuderatio' => '3.45',
'uutime' => '80',
'uudl' => '1536',
'uuprratio' => '4.05',
'uuderatio' => '3.95',
'nmtime' => '100',
'nmdl' => '3072',
'nmprratio' => '4.55',
'nmderatio' => '4.45',
'getInvitesByPromotion' =>
array (
2 => '1',
3 => '0',
4 => '2',
5 => '0',
6 => '3',
7 => '0',
8 => '5',
9 => '10',
),
),
'torrent' =>
array (
'prorules' => 'no',
'randomhalfleech' => '5',
'randomfree' => '2',
'randomtwoup' => '2',
'randomtwoupfree' => '1',
'randomtwouphalfdown' => '0',
'largesize' => '20',
'largepro' => '2',
'expirehalfleech' => '150',
'expirefree' => '60',
'expiretwoup' => '60',
'expiretwoupfree' => '30',
'expiretwouphalfleech' => '30',
'expirenormal' => '0',
'hotdays' => '7',
'hotseeder' => '10',
'halfleechbecome' => '1',
'freebecome' => '1',
'twoupbecome' => '1',
'twoupfreebecome' => '1',
'twouphalfleechbecome' => '1',
'normalbecome' => '1',
'uploaderdouble' => '1',
'deldeadtorrent' => '0',
'randomthirtypercentdown' => '0',
'thirtypercentleechbecome' => '1',
'expirethirtypercentleech' => '0',
'minvotes' => '10',
),
'attachment' =>
array (
'enableattach' => 'yes',
'classone' => '1',
'countone' => '5',
'sizeone' => '256',
'extone' => 'jpg, jpeg, png, gif',
'classtwo' => '2',
'counttwo' => '10',
'sizetwo' => '512',
'exttwo' => 'torrent, zip, rar, 7z, gzip, gz',
'classthree' => '5',
'countthree' => '20',
'sizethree' => '1024',
'extthree' => 'mp3, ogg, oga, flv',
'classfour' => '13',
'countfour' => '500',
'sizefour' => '2048',
'extfour' => 'doc, xls',
'savedirectory' => './attachments',
'httpdirectory' => 'attachments',
'savedirectorytype' => 'monthdir',
'thumbnailtype' => 'createthumb',
'thumbquality' => '80',
'thumbwidth' => '500',
'thumbheight' => '500',
'watermarkpos' => '9',
'watermarkwidth' => '300',
'watermarkheight' => '300',
'watermarkquality' => '85',
'altthumbwidth' => '180',
'altthumbheight' => '135',
),
'advertisement' =>
array (
'enablead' => 'yes',
'enablenoad' => 'yes',
'noad' => '12',
'enablebonusnoad' => 'yes',
'bonusnoad' => '2',
'bonusnoadpoint' => '10000',
'bonusnoadtime' => '15',
'adclickbonus' => '1',
),
'code' =>
array (
'mainversion' => 'NexusPHP',
'subversion' => 'Standard v1.5 Beta 4 by xiaomlove',
'releasedate' => '2010-09-19',
'website' => '<a href="http://nexusphp.cn">http://nexusphp.cn</a>',
),
);