本文整理汇总了PHP中can_load_dll函数的典型用法代码示例。如果您正苦于以下问题:PHP can_load_dll函数的具体用法?PHP can_load_dll怎么用?PHP can_load_dll使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了can_load_dll函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkDB
/**
* Checks which databases the server can run
*
* @return bool Return true if it can run MySQL; false if not
*/
function checkDB()
{
$available_dbms = array('mysql' => array('LABEL' => 'MySQL', 'SCHEMA' => 'mysql', 'MODULE' => 'mysql', 'DELIM' => ';', 'COMMENTS' => 'remove_remarks', 'DRIVER' => 'mysql', 'AVAILABLE' => true, '2.0.x' => true));
foreach ($available_dbms as $db_name => $db_ary) {
if ($only_20x_options and !$db_ary['2.0.x']) {
if ($return_unavailable) {
$available_dbms[$db_name]['AVAILABLE'] = false;
} else {
unset($available_dbms[$db_name]);
}
continue;
}
$dll = $db_ary['MODULE'];
if (!@extension_loaded($dll)) {
if (!can_load_dll($dll)) {
if ($return_unavailable) {
$available_dbms[$db_name]['AVAILABLE'] = false;
} else {
unset($available_dbms[$db_name]);
}
continue;
}
}
$any_db_support = true;
}
if ($any_db_support) {
$check = true;
} else {
$check = false;
}
return $check;
}
示例2: is_available
function is_available()
{
if (@extension_loaded('gd')) {
return true;
}
if (!function_exists('can_load_dll')) {
include IP_ROOT_PATH . 'includes/functions_install.' . PHP_EXT;
}
return can_load_dll('gd');
}
示例3: is_available
function is_available()
{
global $phpbb_root_path, $phpEx;
if (@extension_loaded('gd')) {
return true;
}
if (!function_exists('can_load_dll')) {
include $phpbb_root_path . 'includes/functions_install.' . $phpEx;
}
return can_load_dll('gd');
}
示例4: get_available_dbms
/**
* Returns an array of available DBMS with some data, if a DBMS is specified it will only
* return data for that DBMS and will load its extension if necessary.
*/
function get_available_dbms($dbms = false, $return_unavailable = false, $only_20x_options = false)
{
global $lang;
$available_dbms = array('firebird' => array('LABEL' => 'FireBird', 'SCHEMA' => 'firebird', 'MODULE' => 'interbase', 'DELIM' => ';;', 'COMMENTS' => 'remove_remarks', 'DRIVER' => 'firebird', 'AVAILABLE' => true, '2.0.x' => false), 'mysqli' => array('LABEL' => 'MySQL with MySQLi Extension', 'SCHEMA' => 'mysql_41', 'MODULE' => 'mysqli', 'DELIM' => ';', 'COMMENTS' => 'remove_remarks', 'DRIVER' => 'mysqli', 'AVAILABLE' => true, '2.0.x' => true), 'mysql' => array('LABEL' => 'MySQL', 'SCHEMA' => 'mysql', 'MODULE' => 'mysql', 'DELIM' => ';', 'COMMENTS' => 'remove_remarks', 'DRIVER' => 'mysql', 'AVAILABLE' => true, '2.0.x' => true), 'mssql' => array('LABEL' => 'MS SQL Server 2000+', 'SCHEMA' => 'mssql', 'MODULE' => 'mssql', 'DELIM' => 'GO', 'COMMENTS' => 'remove_comments', 'DRIVER' => 'mssql', 'AVAILABLE' => true, '2.0.x' => true), 'mssql_odbc' => array('LABEL' => 'MS SQL Server [ ODBC ]', 'SCHEMA' => 'mssql', 'MODULE' => 'odbc', 'DELIM' => 'GO', 'COMMENTS' => 'remove_comments', 'DRIVER' => 'mssql_odbc', 'AVAILABLE' => true, '2.0.x' => true), 'mssqlnative' => array('LABEL' => 'MS SQL Server 2005+ [ Native ]', 'SCHEMA' => 'mssql', 'MODULE' => 'sqlsrv', 'DELIM' => 'GO', 'COMMENTS' => 'remove_comments', 'DRIVER' => 'mssqlnative', 'AVAILABLE' => true, '2.0.x' => false), 'oracle' => array('LABEL' => 'Oracle', 'SCHEMA' => 'oracle', 'MODULE' => 'oci8', 'DELIM' => '/', 'COMMENTS' => 'remove_comments', 'DRIVER' => 'oracle', 'AVAILABLE' => true, '2.0.x' => false), 'postgres' => array('LABEL' => 'PostgreSQL 7.x/8.x', 'SCHEMA' => 'postgres', 'MODULE' => 'pgsql', 'DELIM' => ';', 'COMMENTS' => 'remove_comments', 'DRIVER' => 'postgres', 'AVAILABLE' => true, '2.0.x' => true), 'sqlite' => array('LABEL' => 'SQLite', 'SCHEMA' => 'sqlite', 'MODULE' => 'sqlite', 'DELIM' => ';', 'COMMENTS' => 'remove_remarks', 'DRIVER' => 'sqlite', 'AVAILABLE' => true, '2.0.x' => false));
if ($dbms) {
if (isset($available_dbms[$dbms])) {
$available_dbms = array($dbms => $available_dbms[$dbms]);
} else {
return array();
}
}
// now perform some checks whether they are really available
foreach ($available_dbms as $db_name => $db_ary) {
if ($only_20x_options && !$db_ary['2.0.x']) {
if ($return_unavailable) {
$available_dbms[$db_name]['AVAILABLE'] = false;
} else {
unset($available_dbms[$db_name]);
}
continue;
}
$dll = $db_ary['MODULE'];
if (!@extension_loaded($dll)) {
if (!can_load_dll($dll)) {
if ($return_unavailable) {
$available_dbms[$db_name]['AVAILABLE'] = false;
} else {
unset($available_dbms[$db_name]);
}
continue;
}
}
$any_db_support = true;
}
if ($return_unavailable) {
$available_dbms['ANY_DB_SUPPORT'] = $any_db_support;
}
return $available_dbms;
}
示例5: get_available_dbms
/**
* Returns an array of available DBMS with some data, if a DBMS is specified it will only
* return data for that DBMS and will load its extension if necessary.
*/
function get_available_dbms($dbms = false, $return_unavailable = false, $only_20x_options = false)
{
global $lang;
$available_dbms = array('mysqli' => array('LABEL' => 'MySQL with MySQLi Extension', 'SCHEMA' => 'mysql_41', 'MODULE' => 'mysqli', 'DELIM' => ';', 'COMMENTS' => 'remove_remarks', 'DRIVER' => 'mysqli', 'AVAILABLE' => true, '2.0.x' => true), 'mysql' => array('LABEL' => 'MySQL', 'SCHEMA' => 'mysql', 'MODULE' => 'mysql', 'DELIM' => ';', 'COMMENTS' => 'remove_remarks', 'DRIVER' => 'mysql', 'AVAILABLE' => true, '2.0.x' => true));
if ($dbms) {
if (isset($available_dbms[$dbms])) {
$available_dbms = array($dbms => $available_dbms[$dbms]);
} else {
return array();
}
}
// now perform some checks whether they are really available
foreach ($available_dbms as $db_name => $db_ary) {
if ($only_20x_options && !$db_ary['2.0.x']) {
if ($return_unavailable) {
$available_dbms[$db_name]['AVAILABLE'] = false;
} else {
unset($available_dbms[$db_name]);
}
continue;
}
$dll = $db_ary['MODULE'];
if (!@extension_loaded($dll)) {
if (!can_load_dll($dll)) {
if ($return_unavailable) {
$available_dbms[$db_name]['AVAILABLE'] = false;
} else {
unset($available_dbms[$db_name]);
}
continue;
}
}
$any_db_support = true;
}
if ($return_unavailable) {
$available_dbms['ANY_DB_SUPPORT'] = $any_db_support;
}
return $available_dbms;
}
示例6: load_schema
//.........这里部分代码省略.........
'UPDATE ' . $data['table_prefix'] . "config
SET config_value = '" . $db->sql_escape($data['server_protocol']) . "'
WHERE config_name = 'server_protocol'",
'UPDATE ' . $data['table_prefix'] . "config
SET config_value = '" . $db->sql_escape($data['admin_name']) . "'
WHERE config_name = 'newest_username'",
'UPDATE ' . $data['table_prefix'] . "config
SET config_value = '" . md5(mt_rand()) . "'
WHERE config_name = 'avatar_salt'",
'UPDATE ' . $data['table_prefix'] . "users
SET username = '" . $db->sql_escape($data['admin_name']) . "', user_password='" . $db->sql_escape(md5($data['admin_pass1'])) . "', user_ip = '" . $db->sql_escape($user_ip) . "', user_lang = '" . $db->sql_escape($data['default_lang']) . "', user_email='" . $db->sql_escape($data['board_email1']) . "', user_dateformat='" . $db->sql_escape($lang['default_dateformat']) . "', user_email_hash = " . $db->sql_escape(phpbb_email_hash($data['board_email1'])) . ", username_clean = '" . $db->sql_escape(utf8_clean_string($data['admin_name'])) . "'
WHERE username = 'Admin'",
'UPDATE ' . $data['table_prefix'] . "moderator_cache
SET username = '" . $db->sql_escape($data['admin_name']) . "'
WHERE username = 'Admin'",
'UPDATE ' . $data['table_prefix'] . "forums
SET forum_last_poster_name = '" . $db->sql_escape($data['admin_name']) . "'
WHERE forum_last_poster_name = 'Admin'",
'UPDATE ' . $data['table_prefix'] . "topics
SET topic_first_poster_name = '" . $db->sql_escape($data['admin_name']) . "', topic_last_poster_name = '" . $db->sql_escape($data['admin_name']) . "'
WHERE topic_first_poster_name = 'Admin'
OR topic_last_poster_name = 'Admin'",
'UPDATE ' . $data['table_prefix'] . "users
SET user_regdate = $current_time",
'UPDATE ' . $data['table_prefix'] . "posts
SET post_time = $current_time, poster_ip = '" . $db->sql_escape($user_ip) . "'",
'UPDATE ' . $data['table_prefix'] . "topics
SET topic_time = $current_time, topic_last_post_time = $current_time",
'UPDATE ' . $data['table_prefix'] . "forums
SET forum_last_post_time = $current_time",
'UPDATE ' . $data['table_prefix'] . "config
SET config_value = '" . $db->sql_escape($db->sql_server_info(true)) . "'
WHERE config_name = 'dbms_version'",
);
if (@extension_loaded('gd') || can_load_dll('gd'))
{
$sql_ary[] = 'UPDATE ' . $data['table_prefix'] . "config
SET config_value = 'phpbb_captcha_gd'
WHERE config_name = 'captcha_plugin'";
$sql_ary[] = 'UPDATE ' . $data['table_prefix'] . "config
SET config_value = '1'
WHERE config_name = 'captcha_gd'";
}
$ref = substr($referer, strpos($referer, '://') + 3);
if (!(stripos($ref, $server_name) === 0))
{
$sql_ary[] = 'UPDATE ' . $data['table_prefix'] . "config
SET config_value = '0'
WHERE config_name = 'referer_validation'";
}
// We set a (semi-)unique cookie name to bypass login issues related to the cookie name.
$cookie_name = 'phpbb3_';
$rand_str = md5(mt_rand());
$rand_str = str_replace('0', 'z', base_convert($rand_str, 16, 35));
$rand_str = substr($rand_str, 0, 5);
$cookie_name .= strtolower($rand_str);
$sql_ary[] = 'UPDATE ' . $data['table_prefix'] . "config
SET config_value = '" . $db->sql_escape($cookie_name) . "'
WHERE config_name = 'cookie_name'";
foreach ($sql_ary as $sql)
{
//$sql = trim(str_replace('|', ';', $sql));
if (!$db->sql_query($sql))
{
$error = $db->sql_error();
$this->p_master->db_error($error['message'], $sql, __LINE__, __FILE__);
}
}
$submit = $lang['NEXT_STEP'];
$url = $this->p_master->module_url . "?mode=$mode&sub=final";
$template->assign_vars(array(
'BODY' => $lang['STAGE_CREATE_TABLE_EXPLAIN'],
'L_SUBMIT' => $submit,
'S_HIDDEN' => build_hidden_fields($data),
'U_ACTION' => $url,
));
}
示例7: check_server_requirements
/**
* Checks that the server we are installing on meets the requirements for running phpBB
*/
function check_server_requirements($mode, $sub)
{
global $user, $template, $phpbb_root_path, $phpEx, $db;
$this->page_title = $user->lang['STAGE_REQUIREMENTS'];
$template->assign_vars(array('TITLE' => $user->lang['REQUIREMENTS_TITLE'], 'BODY' => $user->lang['REQUIREMENTS_EXPLAIN']));
$passed = array('php' => false, 'files' => false);
// Test for basic PHP settings
$template->assign_block_vars('checks', array('S_LEGEND' => true, 'LEGEND' => $user->lang['PHP_SETTINGS'], 'LEGEND_EXPLAIN' => $user->lang['PHP_SETTINGS_EXP']));
// Check for GD-Library
if (@extension_loaded('gd') || can_load_dll('gd')) {
$passed['php'] = true;
$result = '<strong style="color:green">' . $user->lang['YES'] . '</strong>';
} else {
$result = '<strong style="color:red">' . $user->lang['NO'] . '</strong>';
}
$template->assign_block_vars('checks', array('TITLE' => $user->lang['REQ_GD_LIBRARY'], 'RESULT' => $result, 'S_EXPLAIN' => false, 'S_LEGEND' => false));
// Test for optional PHP settings
$template->assign_block_vars('checks', array('S_LEGEND' => true, 'LEGEND' => $user->lang['PHP_SETTINGS_OPTIONAL'], 'LEGEND_EXPLAIN' => $user->lang['PHP_SETTINGS_OPTIONAL_EXP']));
// Image rotate
if (function_exists('imagerotate')) {
$result = '<strong style="color:green">' . $user->lang['YES'] . '</strong>';
} else {
$gd_info = gd_info();
$result = '<strong style="color:red">' . $user->lang['NO'] . '</strong><br />' . sprintf($user->lang['OPTIONAL_IMAGEROTATE_EXP'], $gd_info['GD Version']);
}
$template->assign_block_vars('checks', array('TITLE' => $user->lang['OPTIONAL_IMAGEROTATE'], 'TITLE_EXPLAIN' => $user->lang['OPTIONAL_IMAGEROTATE_EXPLAIN'], 'RESULT' => $result, 'S_EXPLAIN' => true, 'S_LEGEND' => false));
// Exif data
if (function_exists('exif_read_data')) {
$result = '<strong style="color:green">' . $user->lang['YES'] . '</strong>';
} else {
$result = '<strong style="color:red">' . $user->lang['NO'] . '</strong><br />' . $user->lang['OPTIONAL_EXIFDATA_EXP'];
}
$template->assign_block_vars('checks', array('TITLE' => $user->lang['OPTIONAL_EXIFDATA'], 'TITLE_EXPLAIN' => $user->lang['OPTIONAL_EXIFDATA_EXPLAIN'], 'RESULT' => $result, 'S_EXPLAIN' => true, 'S_LEGEND' => false));
// Check permissions on files/directories we need access to
$template->assign_block_vars('checks', array('S_LEGEND' => true, 'LEGEND' => $user->lang['FILES_REQUIRED'], 'LEGEND_EXPLAIN' => $user->lang['FILES_REQUIRED_EXPLAIN']));
$directories = array('import', 'upload', 'medium', 'cache');
umask(0);
$passed['dirs'] = true;
foreach ($directories as $dir) {
$write = false;
// Now really check
if (phpbb_gallery_url::_file_exists('', $dir, '') && is_dir(phpbb_gallery_url::_return_file('', $dir, ''))) {
if (!phpbb_gallery_url::_is_writable('', $dir, '')) {
@chmod(phpbb_gallery_url::_return_file('', $dir, ''), 0777);
}
}
// Now check if it is writable by storing a simple file
$fp = @fopen(phpbb_gallery_url::_return_file('', $dir, '') . 'test_lock', 'wb');
if ($fp !== false) {
$write = true;
}
@fclose($fp);
@unlink(phpbb_gallery_url::_return_file('', $dir, '') . 'test_lock');
$passed['dirs'] = $write && $passed['dirs'] ? true : false;
$write = $write ? '<strong style="color:green">' . $user->lang['WRITABLE'] . '</strong>' : '<strong style="color:red">' . $user->lang['UNWRITABLE'] . '</strong>';
$template->assign_block_vars('checks', array('TITLE' => $dir, 'RESULT' => $write, 'S_EXPLAIN' => false, 'S_LEGEND' => false));
}
$url = !in_array(false, $passed) ? append_sid("{$phpbb_root_path}install/index.{$phpEx}", "mode={$mode}&sub=copy_table") : append_sid("{$phpbb_root_path}install/index.{$phpEx}", "mode={$mode}&sub=requirements");
$submit = !in_array(false, $passed) ? $user->lang['INSTALL_START'] : $user->lang['INSTALL_TEST'];
$template->assign_vars(array('L_SUBMIT' => $submit, 'S_HIDDEN' => '', 'U_ACTION' => $url));
}
示例8: check_server_requirements
/**
* Checks that the server we are installing on meets the requirements for running phpBB
*/
function check_server_requirements($mode, $sub)
{
global $user, $template, $phpbb_root_path, $phpEx;
$this->page_title = $user->lang['STAGE_REQUIREMENTS'];
$template->assign_vars(array('TITLE' => $user->lang['REQUIREMENTS_TITLE'], 'BODY' => $user->lang['REQUIREMENTS_EXPLAIN']));
$passed = array('php' => false, 'files' => false, 'dirs' => false);
// Test for basic PHP settings
$template->assign_block_vars('checks', array('S_LEGEND' => true, 'LEGEND' => $user->lang['PHP_SETTINGS'], 'LEGEND_EXPLAIN' => $user->lang['PHP_SETTINGS_EXP']));
// Check for GD-Library
if (@extension_loaded('gd') || can_load_dll('gd')) {
$passed['php'] = true;
$result = '<strong style="color:green">' . $user->lang['YES'] . '</strong>';
} else {
$result = '<strong style="color:red">' . $user->lang['NO'] . '</strong>';
}
$template->assign_block_vars('checks', array('TITLE' => $user->lang['REQ_GD_LIBRARY'], 'RESULT' => $result, 'S_EXPLAIN' => false, 'S_LEGEND' => false));
// Test for optional PHP settings
$template->assign_block_vars('checks', array('S_LEGEND' => true, 'LEGEND' => $user->lang['PHP_SETTINGS_OPTIONAL'], 'LEGEND_EXPLAIN' => $user->lang['PHP_SETTINGS_OPTIONAL_EXP']));
// Image rotate
if (function_exists('imagerotate')) {
$result = '<strong style="color:green">' . $user->lang['YES'] . '</strong>';
} else {
$gd_info = gd_info();
$result = '<strong style="color:red">' . $user->lang['NO'] . '</strong><br />' . sprintf($user->lang['OPTIONAL_IMAGEROTATE_EXP'], $gd_info['GD Version']);
}
$template->assign_block_vars('checks', array('TITLE' => $user->lang['OPTIONAL_IMAGEROTATE'], 'TITLE_EXPLAIN' => $user->lang['OPTIONAL_IMAGEROTATE_EXPLAIN'], 'RESULT' => $result, 'S_EXPLAIN' => true, 'S_LEGEND' => false));
// Exif data
if (function_exists('exif_read_data')) {
$result = '<strong style="color:green">' . $user->lang['YES'] . '</strong>';
} else {
$result = '<strong style="color:red">' . $user->lang['NO'] . '</strong><br />' . $user->lang['OPTIONAL_EXIFDATA_EXP'];
}
$template->assign_block_vars('checks', array('TITLE' => $user->lang['OPTIONAL_EXIFDATA'], 'TITLE_EXPLAIN' => $user->lang['OPTIONAL_EXIFDATA_EXPLAIN'], 'RESULT' => $result, 'S_EXPLAIN' => true, 'S_LEGEND' => false));
// Check permissions on files/directories we need access to
$template->assign_block_vars('checks', array('S_LEGEND' => true, 'LEGEND' => $user->lang['FILES_REQUIRED'], 'LEGEND_EXPLAIN' => $user->lang['FILES_REQUIRED_EXPLAIN']));
$directories = array('import', 'upload', 'medium', 'cache');
umask(0);
$passed['dirs'] = true;
foreach ($directories as $dir) {
$write = false;
// Now really check
if (phpbb_gallery_url::_file_exists('', $dir, '') && is_dir(phpbb_gallery_url::_return_file('', $dir, ''))) {
if (!phpbb_gallery_url::_is_writable('', $dir, '')) {
@chmod(phpbb_gallery_url::_return_file('', $dir, ''), 0777);
}
}
// Now check if it is writable by storing a simple file
$fp = @fopen(phpbb_gallery_url::_return_file('', $dir, '') . 'test_lock', 'wb');
if ($fp !== false) {
$write = true;
}
@fclose($fp);
@unlink(phpbb_gallery_url::_return_file('', $dir, '') . 'test_lock');
$passed['dirs'] = $write && $passed['dirs'] ? true : false;
$write = $write ? '<strong style="color:green">' . $user->lang['WRITABLE'] . '</strong>' : '<strong style="color:red">' . $user->lang['UNWRITABLE'] . '</strong>';
$template->assign_block_vars('checks', array('TITLE' => $dir, 'RESULT' => $write, 'S_EXPLAIN' => false, 'S_LEGEND' => false));
}
// Check whether all old files are deleted
include $phpbb_root_path . 'install/outdated_files.' . $phpEx;
umask(0);
$passed['files'] = true;
$delete = isset($_POST['delete']) ? true : false;
foreach ($oudated_files as $file) {
// Replace gallery root path with the constant.
if (strpos($file, 'gallery/') == 0) {
$file = substr_replace($file, phpbb_gallery_url::path('relative'), 0, 8);
}
$file = preg_replace('/\\.php$/i', ".{$phpEx}", $file);
if ($delete) {
if (@file_exists($phpbb_root_path . $file)) {
// Try to set CHMOD and then delete it
@chmod($phpbb_root_path . $file, 0777);
@unlink($phpbb_root_path . $file);
// Delete failed, tell the user to delete it manually
if (@file_exists($phpbb_root_path . $file)) {
if ($passed['files']) {
$template->assign_block_vars('checks', array('S_LEGEND' => true, 'LEGEND' => $user->lang['FILES_OUTDATED'], 'LEGEND_EXPLAIN' => $user->lang['FILES_OUTDATED_EXPLAIN']));
}
$template->assign_block_vars('checks', array('TITLE' => $file, 'RESULT' => '<strong style="color:red">' . $user->lang['FILE_DELETE_FAIL'] . '</strong>', 'S_EXPLAIN' => false, 'S_LEGEND' => false));
$passed['files'] = false;
}
}
} elseif (@file_exists($phpbb_root_path . $file)) {
if ($passed['files']) {
$template->assign_block_vars('checks', array('S_LEGEND' => true, 'LEGEND' => $user->lang['FILES_OUTDATED'], 'LEGEND_EXPLAIN' => $user->lang['FILES_OUTDATED_EXPLAIN']));
}
$template->assign_block_vars('checks', array('TITLE' => $file, 'RESULT' => '<strong style="color:red">' . $user->lang['FILE_STILL_EXISTS'] . '</strong>', 'S_EXPLAIN' => false, 'S_LEGEND' => false));
$passed['files'] = false;
}
}
if (!$passed['files']) {
$template->assign_block_vars('checks', array('TITLE' => '<strong>' . $user->lang['FILES_DELETE_OUTDATED'] . '</strong>', 'TITLE_EXPLAIN' => $user->lang['FILES_DELETE_OUTDATED_EXPLAIN'], 'RESULT' => '<input class="button1" type="submit" id="delete" onclick="this.className = \'button1 disabled\';" name="delete" value="' . $user->lang['FILES_DELETE_OUTDATED'] . '" />', 'S_EXPLAIN' => true, 'S_LEGEND' => false));
}
$url = !in_array(false, $passed) ? append_sid("{$phpbb_root_path}install/index.{$phpEx}", "mode={$mode}&sub=update_db") : append_sid("{$phpbb_root_path}install/index.{$phpEx}", "mode={$mode}&sub=requirements");
$submit = !in_array(false, $passed) ? $user->lang['INSTALL_START'] : $user->lang['INSTALL_TEST'];
$template->assign_vars(array('L_SUBMIT' => $submit, 'S_HIDDEN' => '', 'U_ACTION' => $url));
}
示例9: check_server_requirements
/**
* Checks that the server we are installing on meets the requirements for running phpBB Garage
*/
function check_server_requirements($mode, $sub)
{
global $lang, $template, $phpbb_root_path, $phpEx, $language;
$this->page_title = $lang['STAGE_REQUIREMENTS'];
$template->assign_vars(array('TITLE' => $lang['REQUIREMENTS_TITLE'], 'BODY' => $lang['REQUIREMENTS_EXPLAIN']));
$passed = array('php' => false, 'files' => false, 'imagesize' => false);
// Test for basic PHP settings
$template->assign_block_vars('checks', array('S_LEGEND' => true, 'LEGEND' => $lang['PHP_SETTINGS'], 'LEGEND_EXPLAIN' => $lang['PHP_SETTINGS_EXPLAIN']));
// Test the minimum PHP version
$php_version = PHP_VERSION;
if (version_compare($php_version, '4.3.3') < 0) {
$result = '<strong style="color:red">' . $lang['NO'] . '</strong>';
} else {
$passed['php'] = true;
// We also give feedback on whether we're running in safe mode
$result = '<strong style="color:green">' . $lang['YES'];
if (@ini_get('safe_mode') || strtolower(@ini_get('safe_mode')) == 'on') {
$result .= ', ' . $lang['PHP_SAFE_MODE'];
}
$result .= '</strong>';
}
$template->assign_block_vars('checks', array('TITLE' => $lang['PHP_VERSION_REQD'], 'RESULT' => $result, 'S_EXPLAIN' => false, 'S_LEGEND' => false));
// Check for url_fopen
if (@ini_get('allow_url_fopen') == '1' || strtolower(@ini_get('allow_url_fopen')) == 'on') {
$result = '<strong style="color:green">' . $lang['YES'] . '</strong>';
} else {
$result = '<strong style="color:red">' . $lang['NO'] . '</strong>';
}
$template->assign_block_vars('checks', array('TITLE' => $lang['PHP_URL_FOPEN_SUPPORT'], 'TITLE_EXPLAIN' => $lang['PHP_URL_FOPEN_SUPPORT_EXPLAIN'], 'RESULT' => $result, 'S_EXPLAIN' => true, 'S_LEGEND' => false));
// Check for getimagesize
if (@function_exists('getimagesize')) {
$passed['imagesize'] = true;
$result = '<strong style="color:green">' . $lang['YES'] . '</strong>';
} else {
$result = '<strong style="color:red">' . $lang['NO'] . '</strong>';
}
$template->assign_block_vars('checks', array('TITLE' => $lang['PHP_GETIMAGESIZE_SUPPORT'], 'TITLE_EXPLAIN' => $lang['PHP_GETIMAGESIZE_SUPPORT_EXPLAIN'], 'RESULT' => $result, 'S_EXPLAIN' => true, 'S_LEGEND' => false));
// Test for other modules
$template->assign_block_vars('checks', array('S_LEGEND' => true, 'LEGEND' => $lang['PHP_REQUIRED_MODULE'], 'LEGEND_EXPLAIN' => $lang['PHP_REQUIRED_MODULE_EXPLAIN']));
foreach ($this->php_dlls_other as $dll) {
if (!@extension_loaded($dll)) {
if (!can_load_dll($dll)) {
$template->assign_block_vars('checks', array('TITLE' => $lang['DLL_' . strtoupper($dll)], 'RESULT' => '<strong style="color:red">' . $lang['UNAVAILABLE'] . '</strong>', 'S_EXPLAIN' => false, 'S_LEGEND' => false));
continue;
}
}
$template->assign_block_vars('checks', array('TITLE' => $lang['DLL_' . strtoupper($dll)], 'RESULT' => '<strong style="color:green">' . $lang['AVAILABLE'] . '</strong>', 'S_EXPLAIN' => false, 'S_LEGEND' => false));
}
// Check permissions on files/directories we need access to
$template->assign_block_vars('checks', array('S_LEGEND' => true, 'LEGEND' => $lang['FILES_REQUIRED'], 'LEGEND_EXPLAIN' => $lang['FILES_REQUIRED_EXPLAIN']));
$directories = array('garage/upload/');
umask(0);
$passed['files'] = true;
foreach ($directories as $dir) {
$exists = $write = false;
// Try to create the directory if it does not exist
if (!file_exists($phpbb_root_path . $dir)) {
@mkdir($phpbb_root_path . $dir, 0777);
@chmod($phpbb_root_path . $dir, 0777);
}
// Now really check
if (file_exists($phpbb_root_path . $dir) && is_dir($phpbb_root_path . $dir)) {
if (!@is_writable($phpbb_root_path . $dir)) {
@chmod($phpbb_root_path . $dir, 0777);
}
$exists = true;
}
// Now check if it is writable by storing a simple file
$fp = @fopen($phpbb_root_path . $dir . 'test_lock', 'wb');
if ($fp !== false) {
$write = true;
}
@fclose($fp);
@unlink($phpbb_root_path . $dir . 'test_lock');
$passed['files'] = $exists && $write && $passed['files'] ? true : false;
$exists = $exists ? '<strong style="color:green">' . $lang['FOUND'] . '</strong>' : '<strong style="color:red">' . $lang['NOT_FOUND'] . '</strong>';
$write = $write ? ', <strong style="color:green">' . $lang['WRITABLE'] . '</strong>' : ($exists ? ', <strong style="color:red">' . $lang['UNWRITABLE'] . '</strong>' : '');
$template->assign_block_vars('checks', array('TITLE' => $dir, 'RESULT' => $exists . $write, 'S_EXPLAIN' => false, 'S_LEGEND' => false));
}
// And finally where do we want to go next (well today is taken isn't it :P)
$s_hidden_fields = '';
$url = !in_array(false, $passed) ? $this->p_master->module_url . "?mode={$mode}&sub=optional&language={$language}" : $this->p_master->module_url . "?mode={$mode}&sub=requirements&language={$language}\t";
$submit = !in_array(false, $passed) ? $lang['INSTALL_START'] : $lang['INSTALL_TEST'];
$template->assign_vars(array('L_SUBMIT' => $submit, 'S_HIDDEN' => $s_hidden_fields, 'U_ACTION' => $url));
}
示例10: __construct
//.........这里部分代码省略.........
$default_lang = 'en';
qi::add_lang('install', $phpbb_root_path . 'language/en/');
}
// perform sql
load_schema($phpbb_root_path . 'install/schemas/', $dbms);
$current_time = time();
$user_ip = !empty($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '0.0.0.0';
$user_ip = htmlspecialchars($user_ip);
$script_path = !empty($_SERVER['PHP_SELF']) ? $_SERVER['PHP_SELF'] : getenv('PHP_SELF');
if (!$script_path) {
$script_path = !empty($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : getenv('REQUEST_URI');
}
// Replace backslashes and doubled slashes (could happen on some proxy setups)
$script_path = trim(dirname($script_path));
$script_path = str_replace(array('\\', '//'), '/', $script_path);
// Make sure $script_path ends with a slash (/).
$script_path = substr($script_path, -1) != '/' ? $script_path . '/' : $script_path;
$script_path .= $settings->get_boards_dir() . $site_dir . '/';
$config_ary = array('board_startdate' => $current_time, 'default_lang' => $default_lang, 'server_name' => $settings->get_config('server_name'), 'server_port' => $settings->get_config('server_port', 0), 'board_email' => $settings->get_config('board_email'), 'board_contact' => $settings->get_config('board_email'), 'cookie_domain' => $settings->get_config('cookie_domain'), 'default_dateformat' => $user->lang['default_dateformat'], 'email_enable' => $settings->get_config('email_enable', 0), 'smtp_delivery' => $settings->get_config('smtp_delivery', 0), 'smtp_host' => $settings->get_config('smtp_host'), 'smtp_auth_method' => $settings->get_config('smtp_auth'), 'smtp_username' => $settings->get_config('smtp_user'), 'smtp_port' => $settings->get_config('smtp_port', 0), 'smtp_password' => $settings->get_config('smtp_pass'), 'cookie_secure' => $settings->get_config('cookie_secure', 0), 'script_path' => $script_path, 'server_protocol' => $settings->get_server_protocol(), 'newest_username' => $admin_name, 'avatar_salt' => md5(mt_rand()), 'cookie_name' => 'phpbb3_' . strtolower(gen_rand_string(5)));
if (defined('PHPBB_31')) {
$config_ary['board_timezone'] = $settings->get_config('qi_tz', '');
$tz_data = "user_timezone = '{$config_ary['board_timezone']}'";
} else {
$tz = new DateTimeZone($settings->get_config('qi_tz', ''));
$tz_ary = $tz->getTransitions(time());
$offset = (double) $tz_ary[0]['offset'] / 3600;
// 3600 seconds = 1 hour.
$dst = $tz_ary[0]['isdst'] ? 1 : 0;
$tz_data = "user_timezone = {$offset}, user_dst = {$dst}";
$config_ary['user_timezone'] = $offset;
$config_ary['user_dst'] = $dst;
unset($tz_ary, $tz, $offset, $dst);
}
if (@extension_loaded('gd') || can_load_dll('gd')) {
$config_ary['captcha_gd'] = 1;
}
if (defined('PHPBB_31')) {
$current_config = $config;
$config = new \phpbb\config\db($db, $cache, "{$table_prefix}config");
set_config(false, false, false, $config);
foreach ($current_config as $key => $value) {
$config->set($key, $value);
}
}
foreach ($config_ary as $config_name => $config_value) {
set_config($config_name, $config_value);
}
// Set default config and post data, this applies to all DB's
$sql_ary = array("UPDATE {$table_prefix}users\n\t\t\t\tSET username\t\t= '" . $db->sql_escape($admin_name) . "',\n\t\t\t\t\tuser_password\t= '" . $db->sql_escape(md5($admin_pass)) . "',\n\t\t\t\t\tuser_ip\t\t\t= '" . $db->sql_escape($user_ip) . "',\n\t\t\t\t\tuser_lang\t\t= '" . $db->sql_escape($default_lang) . "',\n\t\t\t\t\tuser_email\t\t= '" . $db->sql_escape($settings->get_config('board_email')) . "',\n\t\t\t\t\tuser_dateformat\t= '" . $db->sql_escape($user->lang['default_dateformat']) . "',\n\t\t\t\t\tuser_email_hash\t= " . (crc32($settings->get_config('board_email')) . strlen($settings->get_config('board_email'))) . ",\n\t\t\t\t\tusername_clean\t= '" . $db->sql_escape(utf8_clean_string($admin_name)) . "',\n\t\t\t\t\t{$tz_data}\n\t\t\t\tWHERE username = 'Admin'", "UPDATE {$table_prefix}moderator_cache\n\t\t\t\tSET username = '" . $db->sql_escape($admin_name) . "'\n\t\t\t\tWHERE username = 'Admin'", "UPDATE {$table_prefix}forums\n\t\t\t\tSET forum_last_poster_name = '" . $db->sql_escape($admin_name) . "'\n\t\t\t\tWHERE forum_last_poster_name = 'Admin'", "UPDATE {$table_prefix}topics\n\t\t\t\tSET topic_first_poster_name = '" . $db->sql_escape($admin_name) . "', topic_last_poster_name = '" . $db->sql_escape($admin_name) . "'\n\t\t\t\tWHERE topic_first_poster_name = 'Admin'\n\t\t\t\t\tOR topic_last_poster_name = 'Admin'", "UPDATE {$table_prefix}users\n\t\t\t\tSET user_regdate = {$current_time}", "UPDATE {$table_prefix}posts\n\t\t\t\tSET post_time = {$current_time}, poster_ip = '" . $db->sql_escape($user_ip) . "'", "UPDATE {$table_prefix}topics\n\t\t\t\tSET topic_time = {$current_time}, topic_last_post_time = {$current_time}", "UPDATE {$table_prefix}forums\n\t\t\t\tSET forum_last_post_time = {$current_time}", "UPDATE {$table_prefix}config\n\t\t\t\tSET config_value = '" . $db->sql_escape($site_name) . "'\n\t\t\t\tWHERE config_name = 'sitename'", "UPDATE {$table_prefix}config\n\t\t\t\tSET config_value = '" . $db->sql_escape($site_desc) . "'\n\t\t\t\tWHERE config_name = 'site_desc'", "UPDATE {$table_prefix}config\n\t\t\t\tSET config_value = '1'\n\t\t\t\tWHERE config_name = 'load_tplcompile'");
foreach ($sql_ary as $sql) {
if (!$db->sql_query($sql)) {
$error = $db->sql_error();
trigger_error($error['message']);
}
}
// main sql is done, let's get a fresh $config array
$sql = 'SELECT *
FROM ' . CONFIG_TABLE;
$result = $db->sql_query($sql);
if (defined('PHPBB_31')) {
$config = new \phpbb\config\config(array());
} else {
$config = array();
}
while ($row = $db->sql_fetchrow($result)) {
$config[$row['config_name']] = $row['config_value'];
示例11: __construct
//.........这里部分代码省略.........
// Check if the database exists.
if ($dbms == 'sqlite' || $dbms == 'firebird') {
$db_check = $db->sql_select_db($quickinstall_path . 'cache/' . $qi_config['db_prefix'] . $dbname);
} else {
$db_check = $db->sql_select_db($qi_config['db_prefix'] . $dbname);
}
if ($db_check) {
trigger_error(sprintf($user->lang['DB_EXISTS'], $qi_config['db_prefix'] . $dbname));
}
}
if ($dbms == 'sqlite' || $dbms == 'firebird') {
$db->sql_query('CREATE DATABASE ' . $quickinstall_path . 'cache/' . $qi_config['db_prefix'] . $dbname);
$db->sql_select_db($quickinstall_path . 'cache/' . $qi_config['db_prefix'] . $dbname);
} else {
$db->sql_query('CREATE DATABASE ' . $qi_config['db_prefix'] . $dbname);
$db->sql_select_db($qi_config['db_prefix'] . $dbname);
}
// include install lang fom phpbb
qi::add_lang('install', $phpbb_root_path . 'language/' . $qi_config['default_lang'] . '/');
// perform sql
load_schema($phpbb_root_path . 'install/schemas/', $dbms);
$current_time = time();
$user_ip = !empty($_SERVER['REMOTE_ADDR']) ? htmlspecialchars($_SERVER['REMOTE_ADDR']) : '';
$script_path = !empty($_SERVER['PHP_SELF']) ? $_SERVER['PHP_SELF'] : getenv('PHP_SELF');
if (!$script_path) {
$script_path = !empty($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : getenv('REQUEST_URI');
}
// Replace backslashes and doubled slashes (could happen on some proxy setups)
$script_path = str_replace(array('\\', '//'), '/', $script_path);
$script_path = trim(dirname($script_path));
// add the dbname to script path
$script_path .= '/boards/' . $dbname;
$config_ary = array('board_startdate' => $current_time, 'default_lang' => $qi_config['default_lang'], 'server_name' => $qi_config['server_name'], 'server_port' => $qi_config['server_port'], 'board_email' => $qi_config['board_email'], 'board_contact' => $qi_config['board_email'], 'cookie_domain' => $qi_config['cookie_domain'], 'default_dateformat' => $user->lang['default_dateformat'], 'email_enable' => $qi_config['email_enable'], 'smtp_delivery' => $qi_config['smtp_delivery'], 'smtp_host' => $qi_config['smtp_host'], 'smtp_auth_method' => $qi_config['smtp_auth'], 'smtp_username' => $qi_config['smtp_user'], 'smtp_password' => $qi_config['smtp_pass'], 'cookie_secure' => $qi_config['cookie_secure'], 'script_path' => $script_path, 'server_protocol' => !empty($qi_config['server_protocol']) ? $qi_config['server_protocol'] : 'http://', 'newest_username' => $qi_config['admin_name'], 'avatar_salt' => md5(mt_rand()), 'cookie_name' => 'phpbb3_' . strtolower(gen_rand_string(5)));
if (@extension_loaded('gd') || can_load_dll('gd')) {
$config_ary['captcha_gd'] = 1;
}
foreach ($config_ary as $config_name => $config_value) {
set_config($config_name, $config_value);
}
// Set default config and post data, this applies to all DB's
$sql_ary = array("UPDATE {$table_prefix}users\n\t\t\t\tSET username = '" . $db->sql_escape($qi_config['admin_name']) . "', user_password='" . $db->sql_escape(md5($qi_config['admin_pass'])) . "', user_ip = '" . $db->sql_escape($user_ip) . "', user_lang = '" . $db->sql_escape($qi_config['default_lang']) . "', user_email='" . $db->sql_escape($qi_config['board_email']) . "', user_dateformat='" . $db->sql_escape($user->lang['default_dateformat']) . "', user_email_hash = " . (crc32($qi_config['board_email']) . strlen($qi_config['board_email'])) . ", username_clean = '" . $db->sql_escape(utf8_clean_string($qi_config['admin_name'])) . "'\n\t\t\t\tWHERE username = 'Admin'", "UPDATE {$table_prefix}moderator_cache\n\t\t\t\tSET username = '" . $db->sql_escape($qi_config['admin_name']) . "'\n\t\t\t\tWHERE username = 'Admin'", "UPDATE {$table_prefix}forums\n\t\t\t\tSET forum_last_poster_name = '" . $db->sql_escape($qi_config['admin_name']) . "'\n\t\t\t\tWHERE forum_last_poster_name = 'Admin'", "UPDATE {$table_prefix}topics\n\t\t\t\tSET topic_first_poster_name = '" . $db->sql_escape($qi_config['admin_name']) . "', topic_last_poster_name = '" . $db->sql_escape($qi_config['admin_name']) . "'\n\t\t\t\tWHERE topic_first_poster_name = 'Admin'\n\t\t\t\t\tOR topic_last_poster_name = 'Admin'", "UPDATE {$table_prefix}users\n\t\t\t\tSET user_regdate = {$current_time}", "UPDATE {$table_prefix}posts\n\t\t\t\tSET post_time = {$current_time}, poster_ip = '" . $db->sql_escape($user_ip) . "'", "UPDATE {$table_prefix}topics\n\t\t\t\tSET topic_time = {$current_time}, topic_last_post_time = {$current_time}", "UPDATE {$table_prefix}forums\n\t\t\t\tSET forum_last_post_time = {$current_time}", "UPDATE {$table_prefix}config\n\t\t\t\tSET config_value = '" . $db->sql_escape($qi_config['site_name']) . "'\n\t\t\t\tWHERE config_name = 'sitename'", "UPDATE {$table_prefix}config\n\t\t\t\tSET config_value = '" . $db->sql_escape($qi_config['site_desc']) . "'\n\t\t\t\tWHERE config_name = 'site_desc'", "UPDATE {$table_prefix}config\n\t\t\t\tSET config_value = '1'\n\t\t\t\tWHERE config_name = 'load_tplcompile'");
foreach ($sql_ary as $sql) {
if (!$db->sql_query($sql)) {
$error = $db->sql_error();
trigger_error($error['message']);
}
}
// main sql is done, let's get a fresh $config array
$sql = 'SELECT *
FROM ' . CONFIG_TABLE;
$result = $db->sql_query($sql);
$config = array();
while ($row = $db->sql_fetchrow($result)) {
$config[$row['config_name']] = $row['config_value'];
}
$db->sql_freeresult($result);
// no templates though :P
$config['load_tplcompile'] = '1';
// build search index
include_once $phpbb_root_path . 'includes/search/fulltext_native.' . $phpEx;
$search = new fulltext_native($error = false);
$sql = 'SELECT post_id, post_subject, post_text, poster_id, forum_id
FROM ' . POSTS_TABLE;
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) {
$search->index('post', $row['post_id'], $row['post_text'], $row['post_subject'], $row['poster_id'], $row['forum_id']);