2014-04-30 09:10:31 +00:00
|
|
|
<?php
|
|
|
|
|
2016-01-26 14:31:53 +00:00
|
|
|
namespace Lychee\Access;
|
2014-04-30 09:10:31 +00:00
|
|
|
|
2016-01-26 14:31:53 +00:00
|
|
|
use Lychee\Modules\Config;
|
2016-02-07 13:32:46 +00:00
|
|
|
use Lychee\Modules\Response;
|
2016-01-30 20:33:31 +00:00
|
|
|
use Lychee\Modules\Validator;
|
2014-04-30 09:10:31 +00:00
|
|
|
|
2016-01-30 20:33:31 +00:00
|
|
|
final class Installation extends Access {
|
2014-04-30 09:10:31 +00:00
|
|
|
|
2016-01-30 20:33:31 +00:00
|
|
|
public static function init($fn) {
|
2014-04-30 09:10:31 +00:00
|
|
|
|
|
|
|
switch ($fn) {
|
|
|
|
|
2016-01-30 20:43:57 +00:00
|
|
|
case 'Config::create': self::configCreateAction(); break;
|
2014-04-30 09:10:31 +00:00
|
|
|
|
2016-01-30 20:43:57 +00:00
|
|
|
default: self::initAction(); break;
|
2014-04-30 09:10:31 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-02-13 22:34:24 +00:00
|
|
|
self::fnNotFound();
|
2014-04-30 09:10:31 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-01-30 20:33:31 +00:00
|
|
|
private static function configCreateAction() {
|
|
|
|
|
2016-01-30 23:56:16 +00:00
|
|
|
Validator::required(isset($_POST['dbHost'], $_POST['dbUser'], $_POST['dbPassword'], $_POST['dbName'], $_POST['dbTablePrefix']), __METHOD__);
|
2014-04-30 09:10:31 +00:00
|
|
|
|
2016-01-24 21:14:20 +00:00
|
|
|
echo Config::create($_POST['dbHost'], $_POST['dbUser'], $_POST['dbPassword'], $_POST['dbName'], $_POST['dbTablePrefix']);
|
2014-04-30 09:10:31 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-01-30 20:33:31 +00:00
|
|
|
private static function initAction() {
|
2015-03-06 22:29:55 +00:00
|
|
|
|
|
|
|
$return = array(
|
|
|
|
'status' => LYCHEE_STATUS_NOCONFIG
|
|
|
|
);
|
|
|
|
|
2016-02-07 13:32:46 +00:00
|
|
|
Response::json($return);
|
2015-03-06 22:29:55 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-04-30 09:10:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
?>
|