function syscheck($items) { foreach ($items as $key => $item) { if ($item['list'] == 'php') { $items[$key]['current'] = PHP_VERSION; } elseif ($item['list'] == 'upload') { $items[$key]['current'] = @ini_get('file_uploads') ? ini_get('upload_max_filesize') : 'unknow'; } elseif ($item['list'] == 'gdversion') { $tmp = function_exists('gd_info') ? gd_info() : array(); $items[$key]['current'] = empty($tmp['GD Version']) ? 'noext' : $tmp['GD Version']; unset($tmp); } elseif ($item['list'] == 'disk') { if (function_exists('disk_free_space')) { $items[$key]['current'] = floor(disk_free_space(admin_ROOT) / (1024 * 1024)) . 'M'; } else { $items[$key]['current'] = 'unknow'; } } elseif (isset($item['c'])) { $items[$key]['current'] = constant($item['c']); } $items[$key]['status'] = 1; if ($item['r'] != 'notset' && strcmp($items[$key]['current'], $item['r']) < 0) { $items[$key]['status'] = 0; } } return $items; }
public function listAction() { $form = new \Control\Forms(); $form->setTitle('Информационный модуль'); $form->setTemplate('list'); $form->addHead(array(array('width' => 100), array('width' => 300))); $rows = array(); // версия CMS $rows[] = array('Aquarel CMS', $this->conf->ac_ver); // версия PHP $rows[] = array('PHP', phpversion()); // версия GD-библиотеки $gd = gd_info(); $rows[] = array('GD', $gd['GD Version']); // список установленных модулей $modules_installed = array(); $modules = $this->em->getRepository('Modules\\Entities\\Module')->findBy(array('install' => 1, 'active' => 1, 'group' => 'custom'), array('name' => 'ASC')); foreach ($modules as $module) { $modules_installed[] = $module->name . ' (' . $module->title . ')'; } $rows[] = array('Установленные модули', implode('<br/>', $modules_installed)); $form->addRows($rows); $output = $form->render(); return $output; }
public static function check() { if (!function_exists('gd_info')) { throw new Kohana_Exception('GD is either not installed or not enabled, check your configuration'); } if (defined('GD_BUNDLED')) { // Get the version via a constant, available in PHP 5. Image_GD::$_bundled = GD_BUNDLED; } else { // Get the version information $info = gd_info(); // Extract the bundled status Image_GD::$_bundled = (bool) preg_match('/\\bbundled\\b/i', $info['GD Version']); } if (defined('GD_VERSION')) { // Get the version via a constant, available in PHP 5.2.4+ $version = GD_VERSION; } else { // Get the version information $info = gd_info(); // Extract the version number preg_match('/\\d+\\.\\d+(?:\\.\\d+)?/', $info['GD Version'], $matches); // Get the major version $version = $matches[0]; } if (!version_compare($version, '2.0.1', '>=')) { throw new Kohana_Exception('Image_GD requires GD version :required or greater, you have :version', array('required' => '2.0.1', ':version' => $version)); } return Image_GD::$_checked = TRUE; }
/** Print GD library information */ static function gd_library_information() { header('Content-type: text/plain'); echo 'GD Library Information'; echo "\n\n"; echo array_format(gd_info()); }
/** * ============================================================================ * WSTMall开源商城 * 官网地址:http://www.wstmall.com * 联系QQ:707563272 * ============================================================================ */ function env_check(&$env_items) { foreach ($env_items as $key => $item) { $env_items[$key]['status'] = 1; if ($key == 'os') { $env_items[$key]['current'] = PHP_OS; } elseif ($key == 'php') { $env_items[$key]['current'] = PHP_VERSION; } elseif ($key == 'attachmentupload') { if (@ini_get('file_uploads')) { $env_items[$key]['current'] = ini_get('upload_max_filesize'); } else { $env_items[$key]['status'] = -1; $env_items[$key]['current'] = '没有开启文件上传'; } } elseif ($key == 'gdversion') { if (extension_loaded('gd')) { $tmp = gd_info(); $env_items[$key]['current'] = empty($tmp['GD Version']) ? '' : $tmp['GD Version']; unset($tmp); } else { $env_items[$key]['current'] = "没有开启GD扩展"; $env_items[$key]['status'] = -1; } } elseif ($key == 'diskspace') { if (function_exists('disk_free_space')) { $env_items[$key]['current'] = floor(disk_free_space(INSTALL_ROOT) / (1024 * 1024)) . 'M'; } else { $env_items[$key]['current'] = '未知的磁盘空间'; $env_items[$key]['status'] = 0; } } } return $env_items; }
/** * 系统环境检测 * @return array 系统环境数据 * @author jry <*****@*****.**> */ function check_env() { $items = array('os' => array('title' => '操作系统', 'limit' => '不限制', 'current' => PHP_OS, 'icon' => 'glyphicon-ok text-success'), 'php' => array('title' => 'PHP版本', 'limit' => '5.3+', 'current' => PHP_VERSION, 'icon' => 'glyphicon-ok text-success'), 'upload' => array('title' => '附件上传', 'limit' => '不限制', 'current' => ini_get('file_uploads') ? ini_get('upload_max_filesize') : '未知', 'icon' => 'glyphicon-ok text-success'), 'gd' => array('title' => 'GD库', 'limit' => '2.0+', 'current' => '未知', 'icon' => 'glyphicon-ok text-success'), 'disk' => array('title' => '磁盘空间', 'limit' => '100M+', 'current' => '未知', 'icon' => 'glyphicon-ok text-success')); //PHP环境检测 if ($items['php']['current'] < 5.3) { $items['php']['icon'] = 'glyphicon-remove text-danger'; session('error', true); } //GD库检测 $tmp = function_exists('gd_info') ? gd_info() : array(); if (!$tmp['GD Version']) { $items['gd']['current'] = '未安装'; $items['gd']['icon'] = 'glyphicon-remove text-danger'; session('error', true); } else { $items['gd']['current'] = $tmp['GD Version']; } unset($tmp); //磁盘空间检测 if (function_exists('disk_free_space')) { $disk_size = floor(disk_free_space('./') / (1024 * 1024)) . 'M'; $items['disk']['current'] = $disk_size . 'MB'; if ($disk_size < 100) { $items['disk']['icon'] = 'glyphicon-remove text-danger'; session('error', true); } } return $items; }
/** * 系统环境检测 * @return array 系统环境数据 */ function check_env() { $items = array('os' => array('操作系统', '不限制', '类Unix', PHP_OS, 'success'), 'php' => array('PHP版本', '5.3', '5.3+', PHP_VERSION, 'success'), 'upload' => array('附件上传', '不限制', '2M+', '未知', 'success'), 'gd' => array('GD库', '2.0', '2.0+', '未知', 'success'), 'disk' => array('磁盘空间', '5M', '不限制', '未知', 'success')); //PHP环境检测 if ($items['php'][3] < $items['php'][1]) { $items['php'][4] = 'error'; session('error', true); } //附件上传检测 if (@ini_get('file_uploads')) { $items['upload'][3] = ini_get('upload_max_filesize'); } //GD库检测 $tmp = function_exists('gd_info') ? gd_info() : array(); if (empty($tmp['GD Version'])) { $items['gd'][3] = '未安装'; $items['gd'][4] = 'error'; session('error', true); } else { $items['gd'][3] = $tmp['GD Version']; } unset($tmp); //磁盘空间检测 if (function_exists('disk_free_space')) { $items['disk'][3] = floor(disk_free_space(INSTALL_APP_PATH) / (1024 * 1024)) . 'M'; } return $items; }
/** * Checks if GD is enabled and verify that key methods exist, some of which require GD to * be bundled with PHP. Exceptions will be thrown from those methods when GD is not * bundled. * * @return boolean */ public static function check() { if (!function_exists('gd_info')) { throw new Kohana_Exception('GD is either not installed or not enabled, check your configuration'); } $functions = array(Image_GD::IMAGEROTATE, Image_GD::IMAGECONVOLUTION, Image_GD::IMAGEFILTER, Image_GD::IMAGELAYEREFFECT); foreach ($functions as $function) { Image_GD::$_available_functions[$function] = function_exists($function); } if (defined('GD_VERSION')) { // Get the version via a constant, available in PHP 5.2.4+ $version = GD_VERSION; } else { // Get the version information $info = gd_info(); // Extract the version number preg_match('/\\d+\\.\\d+(?:\\.\\d+)?/', $info['GD Version'], $matches); // Get the major version $version = $matches[0]; } if (!version_compare($version, '2.0.1', '>=')) { throw new Kohana_Exception('Image_GD requires GD version :required or greater, you have :version', array('required' => '2.0.1', ':version' => $version)); } return Image_GD::$_checked = TRUE; }
public function actionIndex() { if (version_compare(PHP_VERSION, '4.3', '<')) { echo 'php版本过低,请先安装php4.3以上版本'; exist; } $requirementsChecker = new RequirementChecker(); $gdMemo = $imagickMemo = '启用验证码时需要安装php的gd组件或imagick组件。'; $gdOK = $imagickOK = false; if (extension_loaded('imagick')) { $imagick = new Imagick(); $imagickFormats = $imagick->queryFormats('PNG'); if (in_array('PNG', $imagickFormats)) { $imagickOK = true; } else { $imagickMemo = 'Imagick组件不支持png。'; } } if (extension_loaded('gd')) { $gdInfo = gd_info(); if (!empty($gdInfo['FreeType Support'])) { $gdOK = true; } else { $gdMemo = 'gd组件不支持FreeType。'; } } /** * Adjust requirements according to your application specifics. */ $requirements = array(array('name' => 'PHP版本', 'mandatory' => true, 'condition' => version_compare(PHP_VERSION, '5.4.0', '>='), 'by' => '<a href="http://www.yiiframework.com">Yii Framework</a>', 'memo' => 'PHP 5.4.0及以上'), array('name' => 'config目录写权限', 'mandatory' => true, 'condition' => is_writeable(Yii::getAlias('@app/config')), 'by' => '<a href="http://simpleforum.org">Simple Forum</a>', 'memo' => 'config目录需要写权限'), array('name' => 'runtime目录写权限', 'mandatory' => true, 'condition' => is_writeable(Yii::getAlias('@app/runtime')), 'by' => '<a href="http://simpleforum.org">Simple Forum</a>', 'memo' => 'runtime目录需要写权限'), array('name' => 'web/assets目录写权限', 'mandatory' => true, 'condition' => is_writeable(Yii::getAlias('@webroot/assets')), 'by' => '<a href="http://simpleforum.org">Simple Forum</a>', 'memo' => 'web/assets目录需要写权限'), array('name' => 'web/avatar目录写权限', 'mandatory' => true, 'condition' => is_writeable(Yii::getAlias('@webroot/avatar')), 'by' => '<a href="http://simpleforum.org">Simple Forum</a>', 'memo' => 'web/avatar目录需要写权限'), array('name' => 'PDO扩展', 'mandatory' => true, 'condition' => extension_loaded('pdo'), 'by' => 'DB连接', 'memo' => 'MySQL连接。'), array('name' => 'PDO_MySQL扩展', 'mandatory' => true, 'condition' => extension_loaded('pdo_mysql'), 'by' => 'DB连接', 'memo' => 'MySQL连接。'), array('name' => 'OpenSSL扩展', 'mandatory' => true, 'condition' => extension_loaded('openssl'), 'by' => '<a href="http://simpleforum.org">Simple Forum</a>', 'memo' => '用于用户密码加密'), array('name' => 'Memcache(d)扩展', 'mandatory' => false, 'condition' => extension_loaded('memcache') || extension_loaded('memcached'), 'by' => 'memcache/memcached缓存', 'memo' => '用于开启缓存'), array('name' => 'APC扩展', 'mandatory' => false, 'condition' => extension_loaded('apc'), 'by' => 'APC缓存', 'memo' => '用于开启缓存'), array('name' => 'GD扩展(支持FreeType)', 'mandatory' => false, 'condition' => $gdOK, 'by' => '验证码', 'memo' => $gdMemo), array('name' => 'ImageMagick扩展(支持png)', 'mandatory' => false, 'condition' => $imagickOK, 'by' => '验证码', 'memo' => $imagickMemo), 'phpExposePhp' => array('name' => 'php.ini的expose_php设值', 'mandatory' => false, 'condition' => $requirementsChecker->checkPhpIniOff("expose_php"), 'by' => '安全问题', 'memo' => '请修改为 expose_php = Off'), 'phpAllowUrlInclude' => array('name' => 'php.ini的allow_url_include设值', 'mandatory' => false, 'condition' => $requirementsChecker->checkPhpIniOff("allow_url_include"), 'by' => '安全问题', 'memo' => '请修改为 allow_url_include = Off'), 'phpSmtp' => array('name' => 'PHP SMTP邮件', 'mandatory' => false, 'condition' => strlen(ini_get('SMTP')) > 0, 'by' => '邮件', 'memo' => '用于发送邮件'), array('name' => 'MBString扩展', 'mandatory' => true, 'condition' => extension_loaded('mbstring'), 'by' => '<a href="http://www.php.net/manual/en/book.mbstring.php">Multibyte string</a> processing', 'memo' => ''), array('name' => 'Reflection扩展', 'mandatory' => true, 'condition' => class_exists('Reflection', false), 'by' => '<a href="http://www.yiiframework.com">Yii Framework</a>'), array('name' => 'PCRE扩展', 'mandatory' => true, 'condition' => extension_loaded('pcre'), 'by' => '<a href="http://www.yiiframework.com">Yii Framework</a>'), array('name' => 'SPL扩展', 'mandatory' => true, 'condition' => extension_loaded('SPL'), 'by' => '<a href="http://www.yiiframework.com">Yii Framework</a>')); $requirementsChecker->check($requirements); return $this->render('index', ['check' => $requirementsChecker]); }
function gd_info() { if (null !== GdAdapterTest::$mockGdInfoResult) { return GdAdapterTest::$mockGdInfoResult; } return \gd_info(); }
public function getInstallInfo() { $this->installinfo['php_version'] = phpversion(); if (!session_id()) { $this->installerror['session_disabled'] = true; } $this->installinfo['config_file'] = $this->bsiCoreRoot . $this->bsiDBCONFile; // check writable settings file if (!is_writable($this->installinfo['config_file'])) { $this->installerror['config_notwritable'] = true; } $this->installinfo['gallery_path'] = $this->bsiCoreRoot . $this->bsiGallery; if (!$this->checkFolder($this->installinfo['gallery_path'])) { $this->installerror['gallery_notwritable'] = true; } if (!in_array("gd", get_loaded_extensions())) { $this->installerror['gd_notinstalled'] = true; $this->installerror['gd_versionnotpermit'] = true; } if (!$this->installerror['gd_notinstalled'] && function_exists('gd_info')) { $info = gd_info(); $this->installinfo['gd_version'] = preg_replace("/[^\\d\\.]/", "", $info['GD Version']) * 1; if ($this->installinfo['gd_version'] < 2) { $this->installerror['gd_versionnotpermit'] = true; } } if (!in_array("mysql", get_loaded_extensions())) { $this->installerror['mysql_notavailable'] = true; } }
/** * Class constructor. * * @param mixed $source Either a file path for a source image or a GD resource handler for an image. * * @since 11.3 * @throws RuntimeException */ public function __construct($source = null) { // Verify that GD support for PHP is available. if (!extension_loaded('gd')) { // @codeCoverageIgnoreStart JLog::add('The GD extension for PHP is not available.', JLog::ERROR); throw new RuntimeException('The GD extension for PHP is not available.'); // @codeCoverageIgnoreEnd } // Determine which image types are supported by GD, but only once. if (!isset(self::$formats[IMAGETYPE_JPEG])) { $info = gd_info(); self::$formats[IMAGETYPE_JPEG] = ($info['JPEG Support']) ? true : false; self::$formats[IMAGETYPE_PNG] = ($info['PNG Support']) ? true : false; self::$formats[IMAGETYPE_GIF] = ($info['GIF Read Support']) ? true : false; } // If the source input is a resource, set it as the image handle. if (is_resource($source) && (get_resource_type($source) == 'gd')) { $this->handle = &$source; } elseif (!empty($source) && is_string($source)) { // If the source input is not empty, assume it is a path and populate the image handle. $this->loadFile($source); } }
function image_gdVersion($user_ver = 0) { if (! extension_loaded('gd')) { return; } static $gd_ver = 0; // Just accept the specified setting if it's 1. if ($user_ver == 1) { $gd_ver = 1; return 1; } // Use the static variable if function was called previously. if ($user_ver !=2 && $gd_ver > 0 ) { return $gd_ver; } // Use the gd_info() function if possible. if (function_exists('gd_info')) { $ver_info = gd_info(); preg_match('/\d/', $ver_info['GD Version'], $match); $gd_ver = $match[0]; return $match[0]; } // If phpinfo() is disabled use a specified / fail-safe choice... if (preg_match('/phpinfo/', ini_get('disable_functions'))) { if ($user_ver == 2) { $gd_ver = 2; return 2; } else { $gd_ver = 1; return 1; } } // ...otherwise use phpinfo(). ob_start(); phpinfo(8); $info = ob_get_contents(); ob_end_clean(); $info = stristr($info, 'gd version'); preg_match('/\d/', $info, $match); $gd_ver = $match[0]; return $match[0]; }
function com_install() { global $mainframe; jimport('joomla.filesystem.folder'); // Initialize variables jimport('joomla.client.helper'); $FTPOptions = JClientHelper::getCredentials('ftp'); $language =& JFactory::getLanguage(); $language->load('com_jce_imgmanager_ext', JPATH_SITE); $cache = $mainframe->getCfg('tmp_path'); // Check for tmp folder if (!JFolder::exists($cache)) { // Create if does not exist if (!JFolder::create($cache)) { $mainframe->enqueueMessage(JText::_('NO CACHE DESC'), 'error'); } } // Check if folder exists and is writable or the FTP layer is enabled if (JFolder::exists($cache) && (is_writable($cache) || $FTPOptions['enabled'] == 1)) { $mainframe->enqueueMessage(JText::_('CACHE DESC')); } else { $mainframe->enqueueMessage(JText::_('NO CACHE DESC'), 'error'); } // Check for GD if (!function_exists('gd_info')) { $mainframe->enqueueMessage(JText::_('NO GD DESC'), 'error'); } else { $info = gd_info(); $mainframe->enqueueMessage(JText::_('GD DESC') . ' - ' . $info['GD Version']); } }
protected function loadData() { $this->vars['cms'] = substr(DB::table('system_parameters')->where('item', 'build')->pluck('value'), 1, -1); $this->vars['php'] = PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION . '.' . PHP_RELEASE_VERSION; $gd = gd_info(); $this->vars['gd'] = substr($gd['GD Version'], 9, 3); }
/** * @return array information of installed GD library */ public function getInfo() { if (is_null($this->gdInfo)) { $this->gdInfo = gd_info(); } return $this->gdInfo; }
/** * Test if the GD library is available * * @return array */ protected static function testGD() { $gd = array(); $output = ''; $gdVersion = null; $gdInfo = null; //$GDfuncList = get_extension_funcs('gd'); if (function_exists('gd_info')) { $gdInfo = gd_info(); $gdVersion = $gdInfo['GD Version']; } else { ob_start(); @phpinfo(INFO_MODULES); $output = ob_get_contents(); ob_end_clean(); $matches[1] = ''; if ($output !== '') { if (preg_match("/GD Version[ \t]*(<[^>]+>[ \t]*)+([^<>]+)/s", $output, $matches)) { $gdVersion = $matches[2]; } else { return $gd; } } } if (function_exists('imagecreatetruecolor') && function_exists('imagecreatefromjpeg')) { $gdVersion = isset($gdVersion) ? $gdVersion : 2; $gd['gd2'] = "GD: " . $gdVersion; } elseif (function_exists('imagecreatefromjpeg')) { $gdVersion = isset($gdVersion) ? $gdVersion : 1; $gd['gd1'] = "GD: " . $gdVersion; } return $gd; }
function get_gdinfo() { $gdinfo = array(); $gdversion = ''; if (function_exists("gd_info")) { $gdinfo = gd_info(); preg_match("/[0-9]+\\.[0-9]+/", $gdinfo["GD Version"], $gdversiontmp); $gdversion = $gdversiontmp[0]; } else { //next try ob_start(); phpinfo(INFO_MODULES); $gdversion = preg_match('/GD Version.*2.0/', ob_get_contents()) ? '2.0' : '1.0'; $gdinfo["JPG Support"] = preg_match('/JPG Support.*enabled/', ob_get_contents()); $gdinfo["PNG Support"] = preg_match('/PNG Support.*enabled/', ob_get_contents()); $gdinfo["GIF Create Support"] = preg_match('/GIF Create Support.*enabled/', ob_get_contents()); $gdinfo["WBMP Support"] = preg_match('/WBMP Support.*enabled/', ob_get_contents()); $gdinfo["XBM Support"] = preg_match('/XBM Support.*enabled/', ob_get_contents()); ob_end_clean(); } if (isset($this)) { $this->gdinfo = $gdinfo; $this->gdversion = $gdversion; } return $gdinfo; }
function com_install() { $mainframe = JFactory::getApplication(); jimport('joomla.filesystem.folder'); // Initialize variables jimport('joomla.client.helper'); $FTPOptions = JClientHelper::getCredentials('ftp'); $language = JFactory::getLanguage(); $language->load('com_jce_imgmanager_ext', JPATH_SITE); $cache = $mainframe->getCfg('tmp_path'); // Check for tmp folder if (!JFolder::exists($cache)) { // Create if does not exist if (!JFolder::create($cache)) { $mainframe->enqueueMessage(WFText::_('WF_IMGMANAGER_EXT_NO_CACHE_DESC'), 'error'); } } // Check if folder exists and is writable or the FTP layer is enabled if (JFolder::exists($cache) && (is_writable($cache) || $FTPOptions['enabled'] == 1)) { $mainframe->enqueueMessage(WFText::_('WF_IMGMANAGER_EXT_CACHE_DESC')); } else { $mainframe->enqueueMessage(WFText::_('WF_IMGMANAGER_EXT_NO_CACHE_DESC'), 'error'); } // Check for GD if (!function_exists('gd_info')) { $mainframe->enqueueMessage(WFText::_('WF_IMGMANAGER_EXT_NO_GD_DESC'), 'error'); } else { $info = gd_info(); $mainframe->enqueueMessage(WFText::_('WF_IMGMANAGER_EXT_GD_DESC') . ' - ' . $info['GD Version']); } // remove wideimage folder if (JFolder::exists(dirname(__FILE) . '/classes/wideimage')) { @JFolder::delete(dirname(__FILE) . '/classes/wideimage'); } }
public function __construct() { if (gd_info()) { return true; } return false(); }
/** * Check which version of GD is installed * @return int 0 if GD isn't installed, 1 if GD 1.x is installed and 2 if GD 2.x is installed */ function Image_Graph_gd_version() { if (function_exists("gd_info")) { $info = gd_info(); $version = $info['GD Version']; } else { ob_start(); phpinfo(8); $php_info = ob_get_contents(); ob_end_clean(); if (ereg("<td[^>]*>GD Version *<\/td><td[^>]*>([^<]*)<\/td>", $php_info, $result)) { $version = $result[1]; } } if ($version) { //define("GD_VERSION", $version); } if (ereg("1\.[0-9]{1,2}", $version)) { return 1; } elseif (ereg("2\.[0-9]{1,2}", $version)) { return 2; } else { return 0; } }
/** * Object constructor * * @param string $imageFileName * @throws \Zend\Pdf\Exception */ public function __construct($imageFileName) { if (!function_exists('gd_info')) { throw new Exception\RuntimeException('Image extension is not installed.'); } $gd_options = gd_info(); if ((!isset($gd_options['JPG Support']) || $gd_options['JPG Support'] != true) && (!isset($gd_options['JPEG Support']) || $gd_options['JPEG Support'] != true)) { throw new Exception\RuntimeException('JPG support is not configured properly.'); } if (!is_readable($imageFileName)) { throw new Exception\IOException("File '{$imageFileName}' is not readable."); } if (($imageInfo = getimagesize($imageFileName)) === false) { throw new Exception\CorruptedImageException('Corrupted image.'); } if ($imageInfo[2] != IMAGETYPE_JPEG && $imageInfo[2] != IMAGETYPE_JPEG2000) { throw new Exception\DomainException('ImageType is not JPG'); } parent::__construct(); switch ($imageInfo['channels']) { case 3: $colorSpace = 'DeviceRGB'; break; case 4: $colorSpace = 'DeviceCMYK'; break; default: $colorSpace = 'DeviceGray'; break; } $imageDictionary = $this->_resource->dictionary; $imageDictionary->Width = new InternalType\NumericObject($imageInfo[0]); $imageDictionary->Height = new InternalType\NumericObject($imageInfo[1]); $imageDictionary->ColorSpace = new InternalType\NameObject($colorSpace); $imageDictionary->BitsPerComponent = new InternalType\NumericObject($imageInfo['bits']); if ($imageInfo[2] == IMAGETYPE_JPEG) { $imageDictionary->Filter = new InternalType\NameObject('DCTDecode'); } else { if ($imageInfo[2] == IMAGETYPE_JPEG2000) { $imageDictionary->Filter = new InternalType\NameObject('JPXDecode'); } } if (($imageFile = @fopen($imageFileName, 'rb')) === false) { throw new Exception\IOException("Can not open '{$imageFileName}' file for reading."); } $byteCount = filesize($imageFileName); $this->_resource->value = ''; while ($byteCount > 0 && ($nextBlock = fread($imageFile, $byteCount)) != false) { $this->_resource->value .= $nextBlock; $byteCount -= strlen($nextBlock); } fclose($imageFile); $this->_resource->skipFilters(); $this->_width = $imageInfo[0]; $this->_height = $imageInfo[1]; $this->_imageProperties = array(); $this->_imageProperties['bitDepth'] = $imageInfo['bits']; $this->_imageProperties['jpegImageType'] = $imageInfo[2]; $this->_imageProperties['jpegColorType'] = $imageInfo['channels']; }
private function loadGdInfo() { if (!function_exists('gd_info')) { throw new RuntimeException('Gd not installed'); } $this->info = gd_info(); }
/** * Load GD library. * * @throws RuntimeException if gd_info doesn't exists */ private function loadGDInfo() { if (!function_exists('gd_info')) { throw new \RuntimeException('GD library has not been installed'); } $this->gd = gd_info(); }
/** * Get GD version * * @return string|false */ public static function getGDVer() { if (self::$_gdVer != null) { return self::$_gdVer; } $res = false; if (!extension_loaded('gd')) { if (dl('gd.so')) { $res = true; } } else { $res = true; } if ($res) { if (function_exists('gd_info')) { $gdInfo = gd_info(); preg_match('/\\d/', $gdInfo['GD Version'], $match); self::$_gdVer = $match[0]; if (self::$_gdVer >= 2) { $res = self::$_gdVer; } } else { $res = false; } } return $res; }
/** * Simple Debug info * * @version 1.0 * @since 1.0.0 * @author Dan Aldridge * * @return void */ public function systeminfo() { $objSQL = Core_Classes_coreObj::getDBO(); $objTPL = Core_Classes_coreObj::getTPL(); $objTime = Core_Classes_coreObj::getTime(); $objForm = Core_Classes_coreObj::getForm(); $objTPL->set_filenames(array('body' => cmsROOT . Core_Classes_Page::$THEME_ROOT . 'block.tpl')); // checkers // grab some info about GD if (function_exists('gd_info')) { $a = gd_info(); $gdVer = preg_replace('/[[:alpha:][:space:]()]+/', '', $a['GD Version']); } else { $gdVer = 'Not Installed.'; } $info = '<div class="alert alert-info"><strong>Important!</strong> This panel needs more updating to output more useful data that has been made avaliable during the last overhaul</div>'; $content = 'This panel gives the CMS dev team some information about your setup. ;--System Setup CMS Version: ' . CMS_VERSION . ' PHP Version: ' . PHP_VERSION . ' (' . (@ini_get('safe_mode') == '1' || strtolower(@ini_get('safe_mode')) == 'on' ? 'Safe Mode Enabled' : 'Safe Mode Disabled') . ') MySQL Version: ' . mysql_get_server_info() . ' GD Version: ' . $gdVer . ' ;--CMS Setup Install Path: /' . root() . ' ' . json_encode($objSQL->fetchAll('SELECT * FROM `#__config`')) . ''; Core_Classes_coreObj::getAdminCP()->setupBlock('body', array('cols' => 3, 'vars' => array('TITLE' => 'System Info', 'CONTENT' => $info . $objForm->textarea('sysInfo', $content, array('style' => 'width: 99%', 'rows' => 20)), 'ICON' => 'fa-icon-user'))); }
/** * Retourne la couleur du pixel en bas a gauche de l'image **/ function colorImageBottom($imageName) { // recuperer le type et la taille de l'image // Pb sur certains JPG qui retourne '' list($imgW, $imgH, $imgTyp) = getimagesize($imageName); switch ($imgTyp) { case 1: $im = imagecreatefromgif($imageName); break; case 2: case ' ': $im = imagecreatefromjpeg($imageName); break; case 3: $im = imagecreatefrompng($imageName); break; default: $app = JFactory::getApplication(); $app->enqueueMessage(JTEXT::_('IMGNAME_ERROR') . '[name=' . $imageName . '] [ type=' . $imgTyp . '] [ format= ' . $imgW . 'x' . $imgH, 'error'); var_dump(gd_info()); return ""; } $rgb = imagecolorat($im, 2, $imgH - 2); $hex = sprintf("%06X", $rgb); return $hex; }
/** * Info about driver's version * * @param string $sDriver * * @return bool */ public function GetDriverVersion($sDriver) { $sVersion = false; $sDriver = strtolower($sDriver); if (isset($this->aDrivers[$sDriver])) { if ($this->aDrivers[$sDriver] == 'Imagick') { if (class_exists('Imagick')) { $img = new \Imagick(); $aInfo = $img->getVersion(); $sVersion = $aInfo['versionString']; if (preg_match('/\\w+\\s\\d+\\.[\\d\\.\\-]+/', $sVersion, $aMatches)) { $sVersion = $aMatches[0]; } } } elseif ($this->aDrivers[$sDriver] == 'Gmagick') { if (class_exists('Gmagick')) { $aInfo = Gmagick::getVersion(); $sVersion = $aInfo['versionString']; if (preg_match('/\\w+\\s\\d+\\.[\\d\\.\\-]+/', $sVersion, $aMatches)) { $sVersion = $aMatches[0]; } } } else { if (function_exists('gd_info')) { $aInfo = gd_info(); $sVersion = $aInfo['GD Version']; if (preg_match('/\\d+\\.[\\d\\.]+/', $sVersion, $aMatches)) { $sVersion = $aMatches[0]; } } } } return $sVersion; }
/** * Check if the photo is supported, including extension check, file size check * and library support checks. * @param string location of the file. * @return $_FILE[] on successful, null on failure. */ function checkPhoto($file) { global $stripslashes; global $msg, $_config; $msg = new AjaxMessage(); // check if GD is installed if (!extension_loaded('gd')) { $msg->printInfos('FEATURE_NOT_AVAILABLE'); return false; } // check if folder exists, if not, create it if (!is_dir(AT_PA_CONTENT_DIR)) { mkdir(AT_PA_CONTENT_DIR); } //check GD support $gd_info = gd_info(); $supported_images = array(); if ($gd_info['GIF Create Support']) { $supported_images[] = 'gif'; } if ($gd_info['JPG Support'] || $gd_info['JPEG Support']) { $supported_images[] = 'jpg'; } if ($gd_info['PNG Support']) { $supported_images[] = 'png'; } if (!$supported_images) { $msg->printInfos('FEATURE_NOT_AVAILABLE'); return false; } // check if this is a supported file type $filename = $stripslashes($file['name']); $path_parts = pathinfo($filename); $extension = strtolower($path_parts['extension']); $image_attributes = getimagesize($file['tmp_name']); //check Extension if ($extension == 'jpeg') { $extension = 'jpg'; } if (!in_array($extension, $supported_images)) { $msg->addError(array('FILE_ILLEGAL', $extension)); return false; } else { if ($image_attributes[2] > IMAGETYPE_PNG) { $msg->addError(array('FILE_ILLEGAL', $extension)); return false; } } // make sure under max file size $allowed_usage = $_config['pa_max_memory_per_member'] * 1024 * 1024; //mb if (memoryUsage($_SESSION['member_id']) > $allowed_usage) { $msg->addError('PA_EXCEEDED_MAX_USAGE'); return false; } //check filename $file['name'] = str_replace(array('\'', '"', ' ', '|', '\\', '/', '<', '>', ':'), '_', $file['name']); $file['name'] = preg_replace("/[^A-Za-z0-9._\\-]/", '', $file['name']); return $file; }
public function __construct() { $gd = gd_info(); if (!$gd['PNG Support'] || !$gd['JPEG Support']) { throw new Exception("No support for png and jpg found"); } }