PageRenderTime 50ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/opencart/trunk/upload/install/controller/step_2.php

http://coderstalk.googlecode.com/
PHP | 97 lines | 75 code | 22 blank | 0 comment | 20 complexity | fc1931de41c35d2ffc2b84c2431ee1df MD5 | raw file
Possible License(s): GPL-3.0, LGPL-2.1, AGPL-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->http('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->http('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['download'] = DIR_OPENCART . 'download';
  21. $this->children = array(
  22. 'header',
  23. 'footer'
  24. );
  25. $this->template = 'step_2.tpl';
  26. $this->response->setOutput($this->render(TRUE));
  27. }
  28. private function validate() {
  29. if (phpversion() < '5.0') {
  30. $this->error['warning'] = 'Warning: You need to use PHP5 or above for OpenCart to work!';
  31. }
  32. if (!ini_get('file_uploads')) {
  33. $this->error['warning'] = 'Warning: file_uploads needs to be enabled!';
  34. }
  35. if (ini_get('session.auto_start')) {
  36. $this->error['warning'] = 'Warning: OpenCart will not work with session.auto_start enabled!';
  37. }
  38. if (!extension_loaded('mysql')) {
  39. $this->error['warning'] = 'Warning: MySQL extension needs to be loaded for OpenCart to work!';
  40. }
  41. if (!extension_loaded('gd')) {
  42. $this->error['warning'] = 'Warning: GD extension needs to be loaded for OpenCart to work!';
  43. }
  44. if (!extension_loaded('zlib')) {
  45. $this->error['warning'] = 'Warning: ZLIB extension needs to be loaded for OpenCart to work!';
  46. }
  47. if (!is_writable(DIR_OPENCART . 'config.php')) {
  48. $this->error['warning'] = 'Warning: config.php needs to be writable for OpenCart to be installed!';
  49. }
  50. if (!is_writable(DIR_OPENCART . 'admin/config.php')) {
  51. $this->error['warning'] = 'Warning: admin/config.php needs to be writable for OpenCart to be installed!';
  52. }
  53. if (!is_writable(DIR_SYSTEM . 'cache')) {
  54. $this->error['warning'] = 'Warning: Cache directory needs to be writable for OpenCart to work!';
  55. }
  56. if (!is_writable(DIR_SYSTEM . 'logs')) {
  57. $this->error['warning'] = 'Warning: Logs directory needs to be writable for OpenCart to work!';
  58. }
  59. if (!is_writable(DIR_OPENCART . 'image')) {
  60. $this->error['warning'] = 'Warning: Image directory needs to be writable for OpenCart to work!';
  61. }
  62. if (!is_writable(DIR_OPENCART . 'image/cache')) {
  63. $this->error['warning'] = 'Warning: Image cache directory needs to be writable for OpenCart to work!';
  64. }
  65. if (!is_writable(DIR_OPENCART . 'download')) {
  66. $this->error['warning'] = 'Warning: Download directory needs to be writable for OpenCart to work!';
  67. }
  68. if (!$this->error) {
  69. return TRUE;
  70. } else {
  71. return FALSE;
  72. }
  73. }
  74. }
  75. ?>