1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Apps\Model\Install\Main; |
4
|
|
|
|
5
|
|
|
use Apps\Console\MainChmodCommand; |
6
|
|
|
use Ffcms\Core\Arch\Model; |
7
|
|
|
use Ffcms\Core\Helper\FileSystem\Directory; |
8
|
|
|
use Ffcms\Core\Helper\FileSystem\File; |
9
|
|
|
use Ffcms\Core\Helper\Type\Arr; |
10
|
|
|
use Ffcms\Core\Helper\Type\Str; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* Class EntityCheck. Main admin business logic model of statistics and environment status |
14
|
|
|
* @package Apps\Model\Install\Main |
15
|
|
|
*/ |
16
|
|
|
class EntityCheck extends Model |
17
|
|
|
{ |
18
|
|
|
public $phpVersion; |
19
|
|
|
public $pdo; |
20
|
|
|
public $gd; |
21
|
|
|
|
22
|
|
|
private $_chmodDirs = []; |
23
|
|
|
|
24
|
|
|
public $chmodCheck = []; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* Get default server information and prepare chmod info |
28
|
|
|
*/ |
29
|
|
|
public function before() |
30
|
|
|
{ |
31
|
|
|
$this->phpVersion = phpversion(); |
32
|
|
|
$this->pdo = extension_loaded('pdo'); |
33
|
|
|
$this->gd = extension_loaded('gd') && function_exists('gd_info'); |
34
|
|
|
|
35
|
|
|
// autoload is disabled, lets get chmod file & dirs from console app data |
36
|
|
|
File::inc('/Apps/Controller/Console/Main.php'); |
37
|
|
|
$this->_chmodDirs = MainChmodCommand::$installDirs; |
38
|
|
|
// for each file or directory in list - check permissions |
39
|
|
|
foreach ($this->_chmodDirs as $object) { |
40
|
|
|
if (Str::endsWith('.php', $object)) { // sounds like a file |
41
|
|
|
$this->chmodCheck[$object] = (File::exist($object) && File::writable($object)); |
42
|
|
|
} else { |
43
|
|
|
$this->chmodCheck[$object] = (Directory::exist($object) && Directory::writable($object)); |
44
|
|
|
} |
45
|
|
|
} |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* Check php version |
50
|
|
|
* @return bool |
51
|
|
|
*/ |
52
|
|
|
public function checkPhpVersion() |
53
|
|
|
{ |
54
|
|
|
return version_compare($this->phpVersion, '5.4', '>='); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* Check all params |
59
|
|
|
* @return bool |
60
|
|
|
*/ |
61
|
|
|
public function checkAll() |
62
|
|
|
{ |
63
|
|
|
return $this->checkPhpVersion() && $this->pdo && $this->gd && !Arr::in(false, $this->chmodCheck); |
|
|
|
|
64
|
|
|
} |
65
|
|
|
} |
66
|
|
|
|