/** * Returns value by request * * @param string $name Type of value * * @return string */ public function get($name) { $return = ''; switch ($name) { case 'phpversion': $return = PHP_VERSION; break; case 'os_type': list($osType) = explode(' ', PHP_OS); $return = $osType; break; case 'mysql_server': $return = \Includes\Utils\Database::getDbVersion(); break; case 'innodb_support': $return = \Includes\Utils\Database::isInnoDBSupported(); break; case 'root_folder': $return = getcwd(); break; case 'web_server': if (isset($_SERVER['SERVER_SOFTWARE'])) { $return = $_SERVER['SERVER_SOFTWARE']; } else { $return = ''; } break; case 'xml_parser': ob_start(); phpinfo(INFO_MODULES); $phpInfo = ob_get_contents(); ob_end_clean(); if (preg_match('/EXPAT.+>([\\.\\d]+)/mi', $phpInfo, $m)) { $return = $m[1]; } else { $return = function_exists('xml_parser_create') ? 'found' : ''; } break; case 'gdlib': if (!$this->is('GDLibLoaded')) { $return = ''; } else { ob_start(); phpinfo(INFO_MODULES); $phpInfo = ob_get_contents(); ob_end_clean(); if (preg_match('/GD.+>([\\.\\d]+)/mi', $phpInfo, $m)) { $gdVersion = $m[1]; } else { $gdVersion = @gd_info(); if (is_array($gdVersion) && isset($gdVersion['GD Version'])) { $gdVersion = $gdVersion['GD Version']; } else { $gdVersion = 'unknown'; } } $return = 'found (' . $gdVersion . ')'; } break; case 'core_version': $return = \XLite::getInstance()->getVersion(); break; case 'libcurl': $libcurlVersion = curl_version(); if (is_array($libcurlVersion)) { $libcurlVersion = $libcurlVersion['version']; } $return = $libcurlVersion; break; case 'check_files': $result = array(); $files = array(); foreach ($files as $file) { $mode = $this->getFilePermission($file); $modeStr = $this->getFilePermissionStr($file); $res = array('file' => $file, 'error' => ''); if (!is_file($file)) { $res['error'] = 'does_not_exist'; $result[] = $res; continue; } $perm = substr(sprintf('%o', @fileperms($file)), -4); if ($perm != $modeStr) { if (!@chmod($file, $mode)) { $res['error'] = 'cannot_chmod'; $result[] = $res; continue; } } else { if ($this->getComplex('xlite.suMode') != 0) { if (!@chmod($file, $mode)) { $res['error'] = 'wrong_owner'; $result[] = $res; continue; } } } $result[] = $res; } $return = $result; break; // :FIXME: checng to the constants // :FIXME: checng to the constants case 'check_dirs': $result = array(); $dirs = array('var/run', 'var/log', 'var/html', 'var/backup', 'var/tmp', 'catalog', 'images', 'classes/modules', 'skins/default/en/modules', 'skins/admin/en/modules', 'skins/default/en/images/modules', 'skins/admin/en/images/modules', 'skins/mail/en/modules', 'skins/mail/en/images/modules'); foreach ($dirs as $dir) { $mode = $this->getDirPermission($dir); $modeStr = $this->getDirPermissionStr($dir); $res = array('dir' => $dir, 'error' => '', 'subdirs' => array()); if (!is_dir($dir)) { $fullPath = ''; $path = explode('/', $dir); foreach ($path as $sub) { $fullPath .= $sub . '/'; if (!is_dir($fullPath) && @mkdir($fullPath, $mode) !== true) { break; } } } if (!is_dir($dir)) { $res['error'] = 'cannot_create'; $result[] = $res; continue; } $perm = substr(sprintf('%o', @fileperms($dir)), -4); if ($perm != $modeStr) { if (!@chmod($dir, $mode)) { $res['error'] = 'cannot_chmod'; $result[] = $res; continue; } } else { if ($this->getComplex('xlite.suMode') != 0 || strpos($dir, 'var') !== false) { if (!@chmod($dir, $mode)) { $res['error'] = 'wrong_owner'; $result[] = $res; continue; } } } $subdirs = array(); if ('catalog' != $dir && 'images' != $dir) { $this->checkSubdirs($dir, $subdirs); } if (!empty($subdirs)) { $res['error'] = 'cannot_chmod_subdirs'; $res['subdirs'] = $subdirs; $result[] = $res; continue; } $result[] = $res; } $return = $result; break; default: $return = parent::get($name); } return $return; }