Installation.php 834 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. namespace Lychee\Access;
  3. use Lychee\Modules\Config;
  4. use Lychee\Modules\Response;
  5. use Lychee\Modules\Validator;
  6. final class Installation extends Access {
  7. public static function init($fn) {
  8. switch ($fn) {
  9. case 'Config::create': self::configCreateAction(); break;
  10. // Error
  11. default: self::initAction(); break;
  12. }
  13. return true;
  14. }
  15. private static function configCreateAction() {
  16. Validator::required(isset($_POST['dbHost'], $_POST['dbUser'], $_POST['dbPassword'], $_POST['dbName'], $_POST['dbTablePrefix']), __METHOD__);
  17. echo Config::create($_POST['dbHost'], $_POST['dbUser'], $_POST['dbPassword'], $_POST['dbName'], $_POST['dbTablePrefix']);
  18. }
  19. private static function initAction() {
  20. $return = array(
  21. 'status' => LYCHEE_STATUS_NOCONFIG
  22. );
  23. Response::json($return);
  24. }
  25. }
  26. ?>