mirror of https://gitee.com/karson/fastadmin.git
parent
dc99d26252
commit
4260ee14e3
|
|
@ -1,12 +1,11 @@
|
||||||
/nbproject/
|
/nbproject/
|
||||||
/thinkphp/
|
/thinkphp/
|
||||||
/vendor/
|
/vendor/
|
||||||
/runtime/
|
/runtime/*
|
||||||
/addons/*
|
/addons/*
|
||||||
/application/admin/command/Install/*.lock
|
|
||||||
/public/assets/libs/
|
/public/assets/libs/
|
||||||
/public/assets/addons/*
|
/public/assets/addons/*
|
||||||
/public/uploads/
|
/public/uploads/*
|
||||||
.idea
|
.idea
|
||||||
composer.lock
|
composer.lock
|
||||||
*.log
|
*.log
|
||||||
|
|
|
||||||
|
|
@ -19,8 +19,9 @@ class Addon extends Command
|
||||||
$this
|
$this
|
||||||
->setName('addon')
|
->setName('addon')
|
||||||
->addOption('name', 'a', Option::VALUE_REQUIRED, 'addon name', null)
|
->addOption('name', 'a', Option::VALUE_REQUIRED, 'addon name', null)
|
||||||
->addOption('action', 'c', Option::VALUE_REQUIRED, 'action(create/enable/disable/install/uninstall/refresh)', 'create')
|
->addOption('action', 'c', Option::VALUE_REQUIRED, 'action(create/enable/disable/install/uninstall/refresh/upgrade/package)', 'create')
|
||||||
->addOption('force', 'f', Option::VALUE_OPTIONAL, 'force override', null)
|
->addOption('force', 'f', Option::VALUE_OPTIONAL, 'force override', null)
|
||||||
|
->addOption('release', 'r', Option::VALUE_OPTIONAL, 'addon release version', null)
|
||||||
->setDescription('Addon manager');
|
->setDescription('Addon manager');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -30,6 +31,8 @@ class Addon extends Command
|
||||||
$action = $input->getOption('action') ?: '';
|
$action = $input->getOption('action') ?: '';
|
||||||
//强制覆盖
|
//强制覆盖
|
||||||
$force = $input->getOption('force');
|
$force = $input->getOption('force');
|
||||||
|
//版本
|
||||||
|
$release = $input->getOption('release') ?: '';
|
||||||
|
|
||||||
include dirname(__DIR__) . DS . 'common.php';
|
include dirname(__DIR__) . DS . 'common.php';
|
||||||
|
|
||||||
|
|
@ -37,15 +40,15 @@ class Addon extends Command
|
||||||
{
|
{
|
||||||
throw new Exception('Addon name could not be empty');
|
throw new Exception('Addon name could not be empty');
|
||||||
}
|
}
|
||||||
if (!$action || !in_array($action, ['create', 'disable', 'enable', 'install', 'uninstall', 'refresh']))
|
if (!$action || !in_array($action, ['create', 'disable', 'enable', 'install', 'uninstall', 'refresh', 'upgrade', 'package']))
|
||||||
{
|
{
|
||||||
throw new Exception('Please input correct action name');
|
throw new Exception('Please input correct action name');
|
||||||
}
|
}
|
||||||
|
|
||||||
// 查询一次SQL,判断连接是否正常
|
// 查询一次SQL,判断连接是否正常
|
||||||
Db::execute("SELECT 1");
|
Db::execute("SELECT 1");
|
||||||
|
|
||||||
$addonDir = ADDON_PATH . $name;
|
$addonDir = ADDON_PATH . $name . DS;
|
||||||
switch ($action)
|
switch ($action)
|
||||||
{
|
{
|
||||||
case 'create':
|
case 'create':
|
||||||
|
|
@ -65,9 +68,9 @@ class Addon extends Command
|
||||||
'addon' => $name,
|
'addon' => $name,
|
||||||
'addonClassName' => ucfirst($name)
|
'addonClassName' => ucfirst($name)
|
||||||
];
|
];
|
||||||
$this->writeToFile("addon", $data, $addonDir . DS . ucfirst($name) . '.php');
|
$this->writeToFile("addon", $data, $addonDir . ucfirst($name) . '.php');
|
||||||
$this->writeToFile("config", $data, $addonDir . DS . 'config.php');
|
$this->writeToFile("config", $data, $addonDir . 'config.php');
|
||||||
$this->writeToFile("info", $data, $addonDir . DS . 'info.ini');
|
$this->writeToFile("info", $data, $addonDir . 'info.ini');
|
||||||
$output->info("Create Successed!");
|
$output->info("Create Successed!");
|
||||||
break;
|
break;
|
||||||
case 'disable':
|
case 'disable':
|
||||||
|
|
@ -117,7 +120,7 @@ class Addon extends Command
|
||||||
}
|
}
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Service::install($name, 0);
|
Service::install($name, 0, ['version' => $release]);
|
||||||
}
|
}
|
||||||
catch (AddonException $e)
|
catch (AddonException $e)
|
||||||
{
|
{
|
||||||
|
|
@ -137,7 +140,7 @@ class Addon extends Command
|
||||||
{
|
{
|
||||||
throw new Exception("Operation is aborted!");
|
throw new Exception("Operation is aborted!");
|
||||||
}
|
}
|
||||||
Service::install($name, 1);
|
Service::install($name, 1, ['version' => $release]);
|
||||||
}
|
}
|
||||||
catch (Exception $e)
|
catch (Exception $e)
|
||||||
{
|
{
|
||||||
|
|
@ -187,6 +190,67 @@ class Addon extends Command
|
||||||
Service::refresh();
|
Service::refresh();
|
||||||
$output->info("Refresh Successed!");
|
$output->info("Refresh Successed!");
|
||||||
break;
|
break;
|
||||||
|
case 'upgrade':
|
||||||
|
Service::upgrade($name, ['version' => $release]);
|
||||||
|
$output->info("Upgrade Successed!");
|
||||||
|
break;
|
||||||
|
case 'package':
|
||||||
|
$infoFile = $addonDir . 'info.ini';
|
||||||
|
if (!is_file($infoFile))
|
||||||
|
{
|
||||||
|
throw new Exception(__('Addon info file was not found'));
|
||||||
|
}
|
||||||
|
|
||||||
|
$info = get_addon_info($name);
|
||||||
|
if (!$info)
|
||||||
|
{
|
||||||
|
throw new Exception(__('Addon info file data incorrect'));
|
||||||
|
}
|
||||||
|
$infoname = isset($info['name']) ? $info['name'] : '';
|
||||||
|
if (!$infoname || !preg_match("/^[a-z]+$/i", $infoname) || $infoname != $name)
|
||||||
|
{
|
||||||
|
throw new Exception(__('Addon info name incorrect'));
|
||||||
|
}
|
||||||
|
|
||||||
|
$infoversion = isset($info['version']) ? $info['version'] : '';
|
||||||
|
if (!$infoversion || !preg_match("/^\d+\.\d+\.\d+$/i", $infoversion))
|
||||||
|
{
|
||||||
|
throw new Exception(__('Addon info version incorrect'));
|
||||||
|
}
|
||||||
|
|
||||||
|
$addonTmpDir = RUNTIME_PATH . 'addons' . DS;
|
||||||
|
if (!is_dir($addonTmpDir))
|
||||||
|
{
|
||||||
|
@mkdir($addonTmpDir, 0755, true);
|
||||||
|
}
|
||||||
|
$addonFile = $addonTmpDir . $infoname . '-' . $infoversion . '.zip';
|
||||||
|
if (!class_exists('ZipArchive'))
|
||||||
|
{
|
||||||
|
throw new Exception(__('ZinArchive not install'));
|
||||||
|
}
|
||||||
|
$zip = new \ZipArchive;
|
||||||
|
$zip->open($addonFile, \ZipArchive::CREATE | \ZipArchive::OVERWRITE);
|
||||||
|
|
||||||
|
$files = new \RecursiveIteratorIterator(
|
||||||
|
new \RecursiveDirectoryIterator($addonDir), \RecursiveIteratorIterator::LEAVES_ONLY
|
||||||
|
);
|
||||||
|
|
||||||
|
foreach ($files as $name => $file)
|
||||||
|
{
|
||||||
|
if (!$file->isDir())
|
||||||
|
{
|
||||||
|
$filePath = $file->getRealPath();
|
||||||
|
$relativePath = substr($filePath, strlen($addonDir));
|
||||||
|
if (!in_array($file->getFilename(), ['.git', '.DS_Store', 'Thumbs.db']))
|
||||||
|
{
|
||||||
|
$zip->addFile($filePath, $relativePath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$zip->close();
|
||||||
|
$output->info("Package Successed!");
|
||||||
|
break;
|
||||||
|
|
||||||
default :
|
default :
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
1
|
||||||
|
|
@ -126,7 +126,7 @@ class Auth extends \fast\Auth
|
||||||
$expiretime = time() + $keeptime;
|
$expiretime = time() + $keeptime;
|
||||||
$key = md5(md5($this->id) . md5($keeptime) . md5($expiretime) . $this->token);
|
$key = md5(md5($this->id) . md5($keeptime) . md5($expiretime) . $this->token);
|
||||||
$data = [$this->id, $keeptime, $expiretime, $key];
|
$data = [$this->id, $keeptime, $expiretime, $key];
|
||||||
Cookie::set('keeplogin', implode('|', $data));
|
Cookie::set('keeplogin', implode('|', $data), 86400 * 30);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
|
|
@ -77,7 +77,7 @@ else if (!extension_loaded("PDO"))
|
||||||
}
|
}
|
||||||
else if (!is_really_writable($dbConfigFile))
|
else if (!is_really_writable($dbConfigFile))
|
||||||
{
|
{
|
||||||
$errInfo = "当前权限不足,无法写入配置文件application/database.php";
|
$errInfo = '当前权限不足,无法写入配置文件application/database.php<br><a href="http://forum.fastadmin.net/?q=%E6%9D%83%E9%99%90%E4%B8%8D%E8%B6%B3" target="_blank">点击查看解决办法</a>';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -86,7 +86,7 @@ else
|
||||||
{
|
{
|
||||||
if (!is_dir(ROOT_PATH . $v))
|
if (!is_dir(ROOT_PATH . $v))
|
||||||
{
|
{
|
||||||
$errInfo = '当前代码不完整,请加入QQ群(<a href="' . $link['qqun'] . '" target="_blank">636393962</a>),在群共享免费下载FastAdmin完整包后再尝试安装';
|
$errInfo = '当前代码仅包含核心代码,请前往官网下载完整包或资源包覆盖后再尝试安装,<a href="http://www.fastadmin.net/download.html?ref=install" target="_blank">立即前往下载</a>';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -95,7 +95,7 @@ else
|
||||||
if (!$errInfo && isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == 'POST')
|
if (!$errInfo && isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == 'POST')
|
||||||
{
|
{
|
||||||
$err = '';
|
$err = '';
|
||||||
$mysqlHostname = isset($_POST['mysqlHost']) ? $_POST['mysqlHost'] : 'localhost';
|
$mysqlHostname = isset($_POST['mysqlHost']) ? $_POST['mysqlHost'] : '127.0.0.1';
|
||||||
$mysqlHostport = 3306;
|
$mysqlHostport = 3306;
|
||||||
$hostArr = explode(':', $mysqlHostname);
|
$hostArr = explode(':', $mysqlHostname);
|
||||||
if (count($hostArr) > 1)
|
if (count($hostArr) > 1)
|
||||||
|
|
@ -330,7 +330,7 @@ if (!$errInfo && isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD']
|
||||||
<h2>安装 <?php echo $sitename; ?></h2>
|
<h2>安装 <?php echo $sitename; ?></h2>
|
||||||
<div>
|
<div>
|
||||||
|
|
||||||
<p>若你在安装中遇到麻烦可点击 <a href="<?php echo $link['doc']; ?>" target="_blank">安装文档</a> <a href="<?php echo $link['forum']; ?>" target="_blank">交流论坛</a> <a href="<?php echo $link['qqun']; ?>">QQ交流群</a></p>
|
<p>若你在安装中遇到麻烦可点击 <a href="<?php echo $link['doc']; ?>" target="_blank">安装文档</a> <a href="<?php echo $link['forum']; ?>" target="_blank">交流社区</a> <a href="<?php echo $link['qqun']; ?>">QQ交流群</a></p>
|
||||||
<!--<p><?php echo $sitename; ?>还支持在命令行php think install一键安装</p>-->
|
<!--<p><?php echo $sitename; ?>还支持在命令行php think install一键安装</p>-->
|
||||||
|
|
||||||
<form method="post">
|
<form method="post">
|
||||||
|
|
@ -345,7 +345,7 @@ if (!$errInfo && isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD']
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div class="form-field">
|
<div class="form-field">
|
||||||
<label>MySQL 数据库地址</label>
|
<label>MySQL 数据库地址</label>
|
||||||
<input type="text" name="mysqlHost" value="localhost" required="">
|
<input type="text" name="mysqlHost" value="127.0.0.1" required="">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-field">
|
<div class="form-field">
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
|
||||||
Loading…
Reference in New Issue