PageRenderTime 45ms CodeModel.GetById 10ms RepoModel.GetById 0ms app.codeStats 0ms

/upload/install/controller/step_2.php

https://github.com/anugrah/opencart
PHP | 111 lines | 86 code | 25 blank | 0 comment | 23 complexity | 667fc3c7552aa398cc69733974423057 MD5 | raw file
Possible License(s): GPL-3.0
  1. <?php
  2. class ControllerStep2 extends Controller {
  3. private $error = array();
  4. public function index() {
  5. if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
  6. $this->redirect($this->url->link('step_3'));
  7. }
  8. if (isset($this->error['warning'])) {
  9. $this->data['error_warning'] = $this->error['warning'];
  10. } else {
  11. $this->data['error_warning'] = '';
  12. }
  13. $this->data['action'] = $this->url->link('step_2');
  14. $this->data['config_catalog'] = DIR_OPENCART . 'config.php';
  15. $this->data['config_admin'] = DIR_OPENCART . 'admin/config.php';
  16. $this->data['cache'] = DIR_SYSTEM . 'cache';
  17. $this->data['logs'] = DIR_SYSTEM . 'logs';
  18. $this->data['image'] = DIR_OPENCART . 'image';
  19. $this->data['image_cache'] = DIR_OPENCART . 'image/cache';
  20. $this->data['image_data'] = DIR_OPENCART . 'image/data';
  21. $this->data['download'] = DIR_OPENCART . 'download';
  22. $this->data['back'] = $this->url->link('step_1');
  23. $this->template = 'step_2.tpl';
  24. $this->children = array(
  25. 'header',
  26. 'footer'
  27. );
  28. $this->response->setOutput($this->render());
  29. }
  30. private function validate() {
  31. if (phpversion() < '5.0') {
  32. $this->error['warning'] = 'Warning: You need to use PHP5 or above for OpenCart to work!';
  33. }
  34. if (!ini_get('file_uploads')) {
  35. $this->error['warning'] = 'Warning: file_uploads needs to be enabled!';
  36. }
  37. if (ini_get('session.auto_start')) {
  38. $this->error['warning'] = 'Warning: OpenCart will not work with session.auto_start enabled!';
  39. }
  40. if (!extension_loaded('mysql')) {
  41. $this->error['warning'] = 'Warning: MySQL extension needs to be loaded for OpenCart to work!';
  42. }
  43. if (!extension_loaded('gd')) {
  44. $this->error['warning'] = 'Warning: GD extension needs to be loaded for OpenCart to work!';
  45. }
  46. if (!extension_loaded('curl')) {
  47. $this->error['warning'] = 'Warning: CURL extension needs to be loaded for OpenCart to work!';
  48. }
  49. if (!function_exists('mcrypt_encrypt')) {
  50. $this->error['warning'] = 'Warning: mCrypt extension needs to be loaded for OpenCart to work!';
  51. }
  52. if (!extension_loaded('zlib')) {
  53. $this->error['warning'] = 'Warning: ZLIB extension needs to be loaded for OpenCart to work!';
  54. }
  55. if (!is_writable(DIR_OPENCART . 'config.php')) {
  56. $this->error['warning'] = 'Warning: config.php needs to be writable for OpenCart to be installed!';
  57. }
  58. if (!is_writable(DIR_OPENCART . 'admin/config.php')) {
  59. $this->error['warning'] = 'Warning: admin/config.php needs to be writable for OpenCart to be installed!';
  60. }
  61. if (!is_writable(DIR_SYSTEM . 'cache')) {
  62. $this->error['warning'] = 'Warning: Cache directory needs to be writable for OpenCart to work!';
  63. }
  64. if (!is_writable(DIR_SYSTEM . 'logs')) {
  65. $this->error['warning'] = 'Warning: Logs directory needs to be writable for OpenCart to work!';
  66. }
  67. if (!is_writable(DIR_OPENCART . 'image')) {
  68. $this->error['warning'] = 'Warning: Image directory needs to be writable for OpenCart to work!';
  69. }
  70. if (!is_writable(DIR_OPENCART . 'image/cache')) {
  71. $this->error['warning'] = 'Warning: Image cache directory needs to be writable for OpenCart to work!';
  72. }
  73. if (!is_writable(DIR_OPENCART . 'image/data')) {
  74. $this->error['warning'] = 'Warning: Image data directory needs to be writable for OpenCart to work!';
  75. }
  76. if (!is_writable(DIR_OPENCART . 'download')) {
  77. $this->error['warning'] = 'Warning: Download directory needs to be writable for OpenCart to work!';
  78. }
  79. if (!$this->error) {
  80. return true;
  81. } else {
  82. return false;
  83. }
  84. }
  85. }
  86. ?>