addError(array('MODULE_INSTALL', '
'.$directory.' does not exist. Please create it.'));
} else if (!is_writable($directory) && @chmod($directory, 0777)) {
$msg->addError(array('MODULE_INSTALL', ''.$directory.' is not writeable. On Unix issue the command chmod a+rw.'));
}
}
/**
* check if GD is installed and is version 2 or higher
*/
if (! extension_loaded('gd')) {
$msg->addError(array('MODULE_INSTALL', 'This module requires the GD Library. Please install it.'));
} else {
if (function_exists('gd_info')) {
// use gd_info if possible...
$gd_ver_info = gd_info();
preg_match('/\d/', $gd_ver_info['GD Version'], $match);
if ($match[0] < 2) {
$msg->addError(array('MODULE_INSTALL', 'This module requires GD version 2 or higher. Please install it.'));
}
} else {
// ...otherwise use phpinfo().
ob_start();
phpinfo(8);
$info = ob_get_contents();
ob_end_clean();
$info = stristr($info, 'gd version');
preg_match('/\d/', $info, $match);
if ($match[0] < 2) {
$msg->addError(array('MODULE_INSTALL', 'This module requires the GD Library version 2 or higher. Please install it.'));
}
}
}
/**
* check if PEAR is installed
* TODO: find a better way to test this - a silent include may not be the best way to do it
*/
if (!class_exists('PEAR') || !(@include 'PEAR.php')) {
$msg->addError(array('MODULE_INSTALL', 'This module requires the PEAR Library. Please install it.'));
}
/**
* the following code checks if there are any errors (generated previously)
* then uses the SqlUtility to run any database queries it needs, ie. to create
* its own tables.
*/
if (!$msg->containsErrors() && file_exists(dirname(__FILE__) . '/module.sql')) {
// deal with the SQL file:
require(AT_INCLUDE_PATH . 'classes/sqlutility.class.php');
$sqlUtility =& new SqlUtility();
/**
* the SQL file could be stored anywhere, and named anything, "module.sql" is simply
* a convention we're using.
*/
$sqlUtility->queryFromFile(dirname(__FILE__) . '/module.sql', TABLE_PREFIX);
}
?>