/** * 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)); }
/** * 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)); }
function create_import_schema($import_schema, $album_id, $user_row, $start_time, $num_offset, $done_images, $todo_images, $image_name, $filename, $images) { $import_file = "<?php\n\nif (!defined('IN_PHPBB'))\n{\n\texit;\n}\n\n"; $import_file .= "\$album_id = " . $album_id . ";\n"; $import_file .= "\$start_time = " . $start_time . ";\n"; $import_file .= "\$num_offset = " . $num_offset . ";\n"; $import_file .= "\$done_images = " . $done_images . ";\n"; $import_file .= "\$todo_images = " . $todo_images . ";\n"; // We add a space at the end of the name, to not get troubles with \'; $import_file .= "\$image_name = '" . str_replace("'", "{{$import_schema}}", $image_name) . " ';\n"; $import_file .= "\$filename = " . ($filename ? 'true' : 'false') . ";\n"; $import_file .= "\$user_data = array(\n"; $import_file .= "\t'user_id'\t\t=> " . $user_row['user_id'] . ",\n"; // We add a space at the end of the name, to not get troubles with \', $import_file .= "\t'username'\t\t=> '" . str_replace("'", "{{$import_schema}}", $user_row['username']) . " ',\n"; $import_file .= "\t'user_colour'\t=> '" . $user_row['user_colour'] . "',\n"; $import_file .= ");\n"; $import_file .= "\$images = array(\n"; // We need to replace some characters to find the image and not produce syntax errors $replace_chars = array("'", "&"); $replace_with = array("{{$import_schema}}", "&"); foreach ($images as $image_src) { $import_file .= "\t'" . str_replace($replace_chars, $replace_with, $image_src) . "',\n"; } $import_file .= ");\n\n?" . '>'; // Done this to prevent highlighting editors getting confused! // Write to disc if (phpbb_gallery_url::_file_exists($import_schema, 'import', '') && phpbb_gallery_url::_is_writable($import_schema, 'import', '') || phpbb_gallery_url::_is_writable('', 'import', '')) { $written = true; if (!($fp = @fopen(phpbb_gallery_url::_return_file($import_schema, 'import', ''), 'w'))) { $written = false; } if (!@fwrite($fp, $import_file)) { $written = false; } @fclose($fp); } }