Verzeichnisstruktur phpBB-3.3.15
- Veröffentlicht
- 28.08.2024
So funktioniert es
|
Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück |
Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
convertor.php
001 <?php
002 /**
003 *
004 * This file is part of the phpBB Forum Software package.
005 *
006 * @copyright (c) phpBB Limited <https://www.phpbb.com>
007 * @license GNU General Public License, version 2 (GPL-2.0)
008 *
009 * For full copyright and license information, please see
010 * the docs/CREDITS.txt file.
011 *
012 */
013
014 namespace phpbb\convert\controller;
015
016 use phpbb\cache\driver\driver_interface;
017 use phpbb\exception\http_exception;
018 use phpbb\install\controller\helper;
019 use phpbb\install\helper\container_factory;
020 use phpbb\install\helper\database;
021 use phpbb\install\helper\install_helper;
022 use phpbb\install\helper\iohandler\factory;
023 use phpbb\install\helper\iohandler\iohandler_interface;
024 use phpbb\install\helper\navigation\navigation_provider;
025 use phpbb\language\language;
026 use phpbb\request\request_interface;
027 use phpbb\template\template;
028 use Symfony\Component\HttpFoundation\StreamedResponse;
029
030 /**
031 * Controller for forum convertors
032 *
033 * WARNING: This file did not meant to be present in a production environment, so moving
034 * this file to a location which is accessible after board installation might
035 * lead to security issues.
036 */
037 class convertor
038 {
039 /**
040 * @var driver_interface
041 */
042 protected $cache;
043
044 /**
045 * @var driver_interface
046 */
047 protected $installer_cache;
048
049 /**
050 * @var \phpbb\config\db
051 */
052 protected $config;
053
054 /**
055 * @var \phpbb\config_php_file
056 */
057 protected $config_php_file;
058
059 /**
060 * @var string
061 */
062 protected $config_table;
063
064 /**
065 * @var helper
066 */
067 protected $controller_helper;
068
069 /**
070 * @var database
071 */
072 protected $db_helper;
073
074 /**
075 * @var \phpbb\db\driver\driver_interface
076 */
077 protected $db;
078
079 /**
080 * @var install_helper
081 */
082 protected $install_helper;
083
084 /**
085 * @var iohandler_interface
086 */
087 protected $iohandler;
088
089 /**
090 * @var language
091 */
092 protected $language;
093
094 /**
095 * @var navigation_provider
096 */
097 protected $navigation_provider;
098
099 /**
100 * @var request_interface
101 */
102 protected $request;
103
104 /**
105 * @var string
106 */
107 protected $session_keys_table;
108
109 /**
110 * @var string
111 */
112 protected $session_table;
113
114 /**
115 * @var template
116 */
117 protected $template;
118
119 /**
120 * @var string
121 */
122 protected $phpbb_root_path;
123
124 /**
125 * @var string
126 */
127 protected $php_ext;
128
129 /**
130 * Constructor
131 *
132 * @param driver_interface $cache
133 * @param container_factory $container
134 * @param database $db_helper
135 * @param helper $controller_helper
136 * @param install_helper $install_helper
137 * @param factory $iohandler
138 * @param language $language
139 * @param navigation_provider $nav
140 * @param request_interface $request
141 * @param template $template
142 * @param string $phpbb_root_path
143 * @param string $php_ext
144 */
145 public function __construct(driver_interface $cache, container_factory $container, database $db_helper, helper $controller_helper, install_helper $install_helper, factory $iohandler, language $language, navigation_provider $nav, request_interface $request, template $template, $phpbb_root_path, $php_ext)
146 {
147 $this->installer_cache = $cache;
148 $this->controller_helper = $controller_helper;
149 $this->db_helper = $db_helper;
150 $this->install_helper = $install_helper;
151 $this->language = $language;
152 $this->navigation_provider = $nav;
153 $this->request = $request;
154 $this->template = $template;
155 $this->phpbb_root_path = $phpbb_root_path;
156 $this->php_ext = $php_ext;
157
158 $iohandler->set_environment('ajax');
159 $this->iohandler = $iohandler->get();
160
161 if (!$this->install_helper->is_phpbb_installed() || !defined('IN_INSTALL'))
162 {
163 throw new http_exception(403, 'INSTALL_PHPBB_NOT_INSTALLED');
164 }
165
166 $this->controller_helper->handle_language_select();
167
168 $this->cache = $container->get('cache.driver');
169 $this->config = $container->get('config');
170 $this->config_php_file = new \phpbb\config_php_file($this->phpbb_root_path, $this->php_ext);
171 $this->db = $container->get('dbal.conn.driver');
172
173 $this->config_table = $container->get_parameter('tables.config');
174 $this->session_keys_table = $container->get_parameter('tables.sessions_keys');
175 $this->session_table = $container->get_parameter('tables.sessions');
176 }
177
178 /**
179 * Render the intro page
180 *
181 * @param bool|int $start_new Whether or not to force to start a new convertor
182 *
183 * @return \Symfony\Component\HttpFoundation\Response
184 */
185 public function intro($start_new)
186 {
187 $this->setup_navigation('intro');
188
189 if ($start_new)
190 {
191 if ($this->request->is_ajax())
192 {
193 $response = new StreamedResponse();
194 $iohandler = $this->iohandler;
195 $url = $this->controller_helper->route('phpbb_convert_intro', array('start_new' => 'new'));
196 $response->setCallback(function() use ($iohandler, $url) {
197 $iohandler->redirect($url);
198 });
199 $response->headers->set('X-Accel-Buffering', 'no');
200
201 return $response;
202 }
203
204 $this->config['convert_progress'] = '';
205 $this->config['convert_db_server'] = '';
206 $this->config['convert_db_user'] = '';
207 $this->db->sql_query('DELETE FROM ' . $this->config_table . "
208 WHERE config_name = 'convert_progress'
209 OR config_name = 'convert_db_server'
210 OR config_name = 'convert_db_user'"
211 );
212 }
213
214 // Let's see if there is a conversion in the works...
215 $options = array();
216 if (!empty($this->config['convert_progress']) &&
217 !empty($this->config['convert_db_server']) &&
218 !empty($this->config['convert_db_user']) &&
219 !empty($this->config['convert_options']))
220 {
221 $options = unserialize($this->config['convert_progress']);
222 $options = array_merge($options,
223 unserialize($this->config['convert_db_server']),
224 unserialize($this->config['convert_db_user']),
225 unserialize($this->config['convert_options'])
226 );
227 }
228
229 // This information should have already been checked once, but do it again for safety
230 if (!empty($options) && !empty($options['tag']) &&
231 isset($options['dbms']) &&
232 isset($options['dbhost']) &&
233 isset($options['dbport']) &&
234 isset($options['dbuser']) &&
235 isset($options['dbpasswd']) &&
236 isset($options['dbname']) &&
237 isset($options['table_prefix']))
238 {
239 $this->template->assign_vars(array(
240 'TITLE' => $this->language->lang('CONTINUE_CONVERT'),
241 'BODY' => $this->language->lang('CONTINUE_CONVERT_BODY'),
242 'S_CONTINUE' => true,
243 'U_NEW_ACTION' => $this->controller_helper->route('phpbb_convert_intro', array('start_new' => 'new')),
244 'U_CONTINUE_ACTION' => $this->controller_helper->route('phpbb_convert_convert', array('converter' => $options['tag'])),
245 ));
246
247 return $this->controller_helper->render('installer_convert.html', 'CONTINUE_CONVERT', true);
248 }
249
250 return $this->render_convert_list();
251 }
252
253 /**
254 * Obtain convertor settings
255 *
256 * @param string $converter Name of the convertor
257 *
258 * @return \Symfony\Component\HttpFoundation\Response|StreamedResponse
259 */
260 public function settings($converter)
261 {
262 $this->setup_navigation('settings');
263
264 require_once ($this->phpbb_root_path . 'includes/constants.' . $this->php_ext);
265 require_once ($this->phpbb_root_path . 'includes/functions_convert.' . $this->php_ext);
266
267 // Include convertor if available
268 $convertor_file_path = $this->phpbb_root_path . 'install/convertors/convert_' . $converter . '.' . $this->php_ext;
269 if (!file_exists($convertor_file_path))
270 {
271 if ($this->request->is_ajax())
272 {
273 $response = new StreamedResponse();
274 $ref = $this;
275 $response->setCallback(function() use ($ref) {
276 $ref->render_error('CONVERT_NOT_EXIST');
277 });
278 $response->headers->set('X-Accel-Buffering', 'no');
279
280 return $response;
281 }
282
283 $this->render_error('CONVERT_NOT_EXIST');
284 return $this->controller_helper->render('installer_convert.html', 'STAGE_SETTINGS', true);
285 }
286
287 $get_info = true;
288 $phpbb_root_path = $this->phpbb_root_path; // These globals are required
289 $phpEx = $this->php_ext; // See above
290 include_once ($convertor_file_path);
291
292 // The test_file is a file that should be present in the location of the old board.
293 if (!isset($test_file))
294 {
295 if ($this->request->is_ajax())
296 {
297 $response = new StreamedResponse();
298 $ref = $this;
299 $response->setCallback(function() use ($ref) {
300 $ref->render_error('DEV_NO_TEST_FILE');
301 });
302 $response->headers->set('X-Accel-Buffering', 'no');
303
304 return $response;
305 }
306
307 $this->render_error('DEV_NO_TEST_FILE');
308 return $this->controller_helper->render('installer_convert.html', 'STAGE_SETTINGS', true);
309 }
310
311 if ($this->request->variable('submit', false))
312 {
313 // It must be an AJAX request at this point
314 $response = new StreamedResponse();
315 $ref = $this;
316 $response->setCallback(function() use ($ref, $converter) {
317 $ref->proccess_settings_form($converter);
318 });
319 $response->headers->set('X-Accel-Buffering', 'no');
320
321 return $response;
322 }
323 else
324 {
325 $this->template->assign_vars(array(
326 'U_ACTION' => $this->controller_helper->route('phpbb_convert_settings', array(
327 'converter' => $converter,
328 ))
329 ));
330
331 if ($this->request->is_ajax())
332 {
333 $response = new StreamedResponse();
334 $ref = $this;
335 $response->setCallback(function() use ($ref) {
336 $ref->render_settings_form();
337 });
338 $response->headers->set('X-Accel-Buffering', 'no');
339
340 return $response;
341 }
342
343 $this->render_settings_form();
344 }
345
346 return $this->controller_helper->render('installer_convert.html', 'STAGE_SETTINGS', true);
347 }
348
349 /**
350 * Run conversion
351 */
352 public function convert($converter)
353 {
354 $this->setup_navigation('convert');
355
356 if ($this->request->is_ajax())
357 {
358 $route = $this->controller_helper->route('phpbb_convert_convert', array('converter' => $converter));
359 $response = new StreamedResponse();
360 $ref = $this;
361 $response->setCallback(function() use ($ref, $route) {
362 $ref->redirect_to_html($route);
363 });
364 $response->headers->set('X-Accel-Buffering', 'no');
365
366 return $response;
367 }
368
369 $convertor = new \phpbb\convert\convertor($this->template, $this->controller_helper);
370 $convertor->convert_data($converter);
371
372 return $this->controller_helper->render('installer_convert.html', 'STAGE_IN_PROGRESS');
373 }
374
375 /**
376 * Render the final page of the convertor
377 */
378 public function finish()
379 {
380 $this->setup_navigation('finish');
381
382 $this->template->assign_vars(array(
383 'TITLE' => $this->language->lang('CONVERT_COMPLETE'),
384 'BODY' => $this->language->lang('CONVERT_COMPLETE_EXPLAIN'),
385 ));
386
387 // If we reached this step (conversion completed) we want to purge the cache and log the user out.
388 // This is for making sure the session get not screwed due to the 3.0.x users table being completely new.
389 $this->cache->purge();
390 $this->installer_cache->purge();
391
392 require_once($this->phpbb_root_path . 'includes/constants.' . $this->php_ext);
393 require_once($this->phpbb_root_path . 'includes/functions_convert.' . $this->php_ext);
394
395 $sql = 'SELECT config_value
396 FROM ' . $this->config_table . '
397 WHERE config_name = \'search_type\'';
398 $result = $this->db->sql_query($sql);
399
400 if ($this->db->sql_fetchfield('config_value') != 'fulltext_mysql')
401 {
402 $this->template->assign_vars(array(
403 'S_ERROR_BOX' => true,
404 'ERROR_TITLE' => $this->language->lang('SEARCH_INDEX_UNCONVERTED'),
405 'ERROR_MSG' => $this->language->lang('SEARCH_INDEX_UNCONVERTED_EXPLAIN'),
406 ));
407 }
408
409 $this->db->sql_freeresult($result);
410
411 switch ($this->db->get_sql_layer())
412 {
413 case 'sqlite3':
414 $this->db->sql_query('DELETE FROM ' . $this->session_keys_table);
415 $this->db->sql_query('DELETE FROM ' . $this->session_table);
416 break;
417
418 default:
419 $this->db->sql_query('TRUNCATE TABLE ' . $this->session_keys_table);
420 $this->db->sql_query('TRUNCATE TABLE ' . $this->session_table);
421 break;
422 }
423
424 return $this->controller_helper->render('installer_convert.html', 'CONVERT_COMPLETE');
425 }
426
427 /**
428 * Validates settings form
429 *
430 * @param string $convertor
431 */
432 public function proccess_settings_form($convertor)
433 {
434 global $phpbb_root_path, $phpEx, $get_info;
435
436 $phpbb_root_path = $this->phpbb_root_path;
437 $phpEx = $this->php_ext;
438 $get_info = true;
439
440 require_once($this->phpbb_root_path . 'includes/constants.' . $this->php_ext);
441 require_once($this->phpbb_root_path . 'includes/functions_convert.' . $this->php_ext);
442
443 // Include convertor if available
444 $convertor_file_path = $this->phpbb_root_path . 'install/convertors/convert_' . $convertor . '.' . $this->php_ext;
445 include ($convertor_file_path);
446
447 // We expect to have an AJAX request here
448 $src_dbms = $this->request->variable('src_dbms', $convertor_data['dbms']);
449 $src_dbhost = $this->request->variable('src_dbhost', $convertor_data['dbhost']);
450 $src_dbport = $this->request->variable('src_dbport', $convertor_data['dbport']);
451 $src_dbuser = $this->request->variable('src_dbuser', $convertor_data['dbuser']);
452 $src_dbpasswd = $this->request->variable('src_dbpasswd', $convertor_data['dbpasswd']);
453 $src_dbname = $this->request->variable('src_dbname', $convertor_data['dbname']);
454 $src_table_prefix = $this->request->variable('src_table_prefix', $convertor_data['table_prefix']);
455 $forum_path = $this->request->variable('forum_path', $convertor_data['forum_path']);
456 $refresh = $this->request->variable('refresh', 1);
457
458 // Default URL of the old board
459 // @todo Are we going to use this for attempting to convert URL references in posts, or should we remove it?
460 // -> We should convert old urls to the new relative urls format
461 // $src_url = $request->variable('src_url', 'Not in use at the moment');
462
463 // strip trailing slash from old forum path
464 $forum_path = (strlen($forum_path) && $forum_path[strlen($forum_path) - 1] == '/') ? substr($forum_path, 0, -1) : $forum_path;
465
466 $error = array();
467 if (!file_exists($this->phpbb_root_path . $forum_path . '/' . $test_file))
468 {
469 $error[] = $this->language->lang('COULD_NOT_FIND_PATH', $forum_path);
470 }
471
472 $connect_test = false;
473 $available_dbms = $this->db_helper->get_available_dbms(false, true, true);
474 if (!isset($available_dbms[$src_dbms]) || !$available_dbms[$src_dbms]['AVAILABLE'])
475 {
476 $error[] = $this->language->lang('INST_ERR_NO_DB');
477 }
478 else
479 {
480 $connect_test = $this->db_helper->check_database_connection($src_dbms, $src_dbhost, $src_dbport, $src_dbuser, $src_dbpasswd, $src_dbname, $src_table_prefix);
481 }
482
483 extract($this->config_php_file->get_all());
484
485 // The forum prefix of the old and the new forum can only be the same if two different databases are used.
486 if ($src_table_prefix === $table_prefix && $src_dbms === $dbms && $src_dbhost === $dbhost && $src_dbport === $dbport && $src_dbname === $dbname)
487 {
488 $error[] = $this->language->lang('TABLE_PREFIX_SAME', $src_table_prefix);
489 }
490
491 if (!$connect_test)
492 {
493 $error[] = $this->language->lang('INST_ERR_DB_CONNECT');
494 }
495
496 $src_dbms = $this->config_php_file->convert_30_dbms_to_31($src_dbms);
497
498 // Check table prefix
499 if (empty($error))
500 {
501 // initiate database connection to old db if old and new db differ
502 global $src_db, $same_db;
503 $src_db = $same_db = false;
504
505 if ($src_dbms != $dbms || $src_dbhost != $dbhost || $src_dbport != $dbport || $src_dbname != $dbname || $src_dbuser != $dbuser)
506 {
507 /** @var \phpbb\db\driver\driver_interface $src_db */
508 $src_db = new $src_dbms();
509 $src_db->sql_connect($src_dbhost, $src_dbuser, htmlspecialchars_decode($src_dbpasswd, ENT_COMPAT), $src_dbname, $src_dbport, false, true);
510 $same_db = false;
511 }
512 else
513 {
514 $src_db = $this->db;
515 $same_db = true;
516 }
517
518 $src_db->sql_return_on_error(true);
519 $this->db->sql_return_on_error(true);
520
521 // Try to select one row from the first table to see if the prefix is OK
522 $result = $src_db->sql_query_limit('SELECT * FROM ' . $src_table_prefix . $tables[0], 1);
523
524 if (!$result)
525 {
526 $prefixes = array();
527
528 $db_tools_factory = new \phpbb\db\tools\factory();
529 $db_tools = $db_tools_factory->get($src_db);
530 $tables_existing = $db_tools->sql_list_tables();
531 $tables_existing = array_map('strtolower', $tables_existing);
532 foreach ($tables_existing as $table_name)
533 {
534 compare_table($tables, $table_name, $prefixes);
535 }
536 unset($tables_existing);
537
538 foreach ($prefixes as $prefix => $count)
539 {
540 if ($count >= count($tables))
541 {
542 $possible_prefix = $prefix;
543 break;
544 }
545 }
546
547 $msg = '';
548 if (!empty($convertor_data['table_prefix']))
549 {
550 $msg .= $this->language->lang_array('DEFAULT_PREFIX_IS', array($convertor_data['forum_name'], $convertor_data['table_prefix']));
551 }
552
553 if (!empty($possible_prefix))
554 {
555 $msg .= '<br />';
556 $msg .= ($possible_prefix == '*') ? $this->language->lang('BLANK_PREFIX_FOUND') : $this->language->lang_array('PREFIX_FOUND', array($possible_prefix));
557 $src_table_prefix = ($possible_prefix == '*') ? '' : $possible_prefix;
558 }
559
560 $error[] = $msg;
561 }
562
563 $src_db->sql_freeresult($result);
564 $src_db->sql_return_on_error(false);
565 }
566
567 if (empty($error))
568 {
569 // Save convertor Status
570 $this->config->set('convert_progress', serialize(array(
571 'step' => '',
572 'table_prefix' => $src_table_prefix,
573 'tag' => $convertor,
574 )), false);
575 $this->config->set('convert_db_server', serialize(array(
576 'dbms' => $src_dbms,
577 'dbhost' => $src_dbhost,
578 'dbport' => $src_dbport,
579 'dbname' => $src_dbname,
580 )), false);
581 $this->config->set('convert_db_user', serialize(array(
582 'dbuser' => $src_dbuser,
583 'dbpasswd' => $src_dbpasswd,
584 )), false);
585
586 // Save options
587 $this->config->set('convert_options', serialize(array(
588 'forum_path' => $this->phpbb_root_path . $forum_path,
589 'refresh' => $refresh
590 )), false);
591
592 $url = $this->controller_helper->route('phpbb_convert_convert', array('converter' => $convertor));
593 $this->iohandler->redirect($url);
594 $this->iohandler->send_response(true);
595 }
596 else
597 {
598 $this->render_settings_form($error);
599 }
600 }
601
602 /**
603 * Renders settings form
604 *
605 * @param array $error Array of errors
606 */
607 public function render_settings_form($error = array())
608 {
609 foreach ($error as $msg)
610 {
611 $this->iohandler->add_error_message($msg);
612 }
613
614 $dbms_options = array();
615 foreach ($this->db_helper->get_available_dbms() as $dbms_key => $dbms_array)
616 {
617 $dbms_options[] = array(
618 'value' => $dbms_key,
619 'label' => 'DB_OPTION_' . strtoupper($dbms_key),
620 );
621 }
622
623 $form_title = 'SPECIFY_OPTIONS';
624 $form_data = array(
625 'src_dbms' => array(
626 'label' => 'DBMS',
627 'type' => 'select',
628 'options' => $dbms_options,
629 ),
630 'src_dbhost' => array(
631 'label' => 'DB_HOST',
632 'description' => 'DB_HOST_EXPLAIN',
633 'type' => 'text',
634 ),
635 'src_dbport' => array(
636 'label' => 'DB_PORT',
637 'description' => 'DB_PORT_EXPLAIN',
638 'type' => 'text',
639 ),
640 'src_dbname' => array(
641 'label' => 'DB_NAME',
642 'type' => 'text',
643 ),
644 'src_dbuser' => array(
645 'label' => 'DB_USERNAME',
646 'type' => 'text',
647 ),
648 'src_dbpasswd' => array(
649 'label' => 'DB_PASSWORD',
650 'type' => 'password',
651 ),
652 'src_table_prefix' => array(
653 'label' => 'TABLE_PREFIX',
654 'description' => 'TABLE_PREFIX_EXPLAIN',
655 'type' => 'text',
656 ),
657 'forum_path' => array(
658 'label' => 'FORUM_PATH',
659 'description' => 'FORUM_PATH_EXPLAIN',
660 'type' => 'text',
661 ),
662 'refresh' => array(
663 'label' => 'REFRESH_PAGE',
664 'description' => 'REFRESH_PAGE_EXPLAIN',
665 'type' => 'radio',
666 'options' => array(
667 array(
668 'value' => 0,
669 'label' => 'NO',
670 'selected' => true,
671 ),
672 array(
673 'value' => 1,
674 'label' => 'YES',
675 'selected' => false,
676 ),
677 ),
678 ),
679 'submit' => array(
680 'label' => 'SUBMIT',
681 'type' => 'submit',
682 ),
683 );
684
685 if ($this->request->is_ajax())
686 {
687 $this->iohandler->add_user_form_group($form_title, $form_data);
688 $this->iohandler->send_response(true);
689 }
690 else
691 {
692 $rendered_form = $this->iohandler->generate_form_render_data($form_title, $form_data);
693
694 $this->template->assign_vars(array(
695 'TITLE' => $this->language->lang('STAGE_SETTINGS'),
696 'CONTENT' => $rendered_form,
697 ));
698 }
699 }
700
701 /**
702 * Render the list of available convertors
703 *
704 * @return \Symfony\Component\HttpFoundation\Response
705 */
706 protected function render_convert_list()
707 {
708 $this->template->assign_vars(array(
709 'TITLE' => $this->language->lang('CONVERT_INTRO'),
710 'BODY' => $this->language->lang('CONVERT_INTRO_BODY'),
711 'S_LIST' => true,
712 ));
713
714 $convertors = $sort = array();
715 $get_info = true; // Global flag
716
717 $handle = @opendir($this->phpbb_root_path . 'install/convertors/');
718
719 if (!$handle)
720 {
721 die('Unable to access the convertors directory');
722 }
723
724 while ($entry = readdir($handle))
725 {
726 if (preg_match('/^convert_([a-z0-9_]+).' . $this->php_ext . '$/i', $entry, $m))
727 {
728 $phpbb_root_path = $this->phpbb_root_path; // These globals are required
729 $phpEx = $this->php_ext; // See above
730 include_once($this->phpbb_root_path . 'install/convertors/' . $entry);
731 if (isset($convertor_data))
732 {
733 $sort[strtolower($convertor_data['forum_name'])] = count($convertors);
734
735 $convertors[] = array(
736 'tag' => $m[1],
737 'forum_name' => $convertor_data['forum_name'],
738 'version' => $convertor_data['version'],
739 'dbms' => $convertor_data['dbms'],
740 'dbhost' => $convertor_data['dbhost'],
741 'dbport' => $convertor_data['dbport'],
742 'dbuser' => $convertor_data['dbuser'],
743 'dbpasswd' => $convertor_data['dbpasswd'],
744 'dbname' => $convertor_data['dbname'],
745 'table_prefix' => $convertor_data['table_prefix'],
746 'author' => $convertor_data['author']
747 );
748 }
749 unset($convertor_data);
750 }
751 }
752 closedir($handle);
753
754 @ksort($sort);
755
756 foreach ($sort as $void => $index)
757 {
758 $this->template->assign_block_vars('convertors', array(
759 'AUTHOR' => $convertors[$index]['author'],
760 'SOFTWARE' => $convertors[$index]['forum_name'],
761 'VERSION' => $convertors[$index]['version'],
762
763 'U_CONVERT' => $this->controller_helper->route('phpbb_convert_settings', array('converter' => $convertors[$index]['tag'])),
764 ));
765 }
766
767 return $this->controller_helper->render('installer_convert.html', 'SUB_INTRO', true);
768 }
769
770 /**
771 * Renders an error form
772 *
773 * @param string $msg
774 * @param string|bool $desc
775 */
776 public function render_error($msg, $desc = false)
777 {
778 if ($this->request->is_ajax())
779 {
780 $this->iohandler->add_error_message($msg, $desc);
781 $this->iohandler->send_response(true);
782 }
783 else
784 {
785 $this->template->assign_vars(array(
786 'S_ERROR_BOX' => true,
787 'ERROR_TITLE' => $this->language->lang($msg),
788 ));
789
790 if ($desc)
791 {
792 $this->template->assign_var('ERROR_MSG', $this->language->lang($desc));
793 }
794 }
795 }
796
797 /**
798 * Redirects an AJAX request to a non-JS version
799 *
800 * @param string $url URL to redirect to
801 */
802 public function redirect_to_html($url)
803 {
804 $this->iohandler->redirect($url);
805 $this->iohandler->send_response(true);
806 }
807
808 private function setup_navigation($stage)
809 {
810 $active = true;
811 $completed = false;
812
813 switch ($stage)
814 {
815 case 'finish':
816 $this->navigation_provider->set_nav_property(
817 array('convert', 0, 'finish'),
818 array(
819 'selected' => $active,
820 'completed' => $completed,
821 )
822 );
823
824 $active = false;
825 $completed = true;
826 // no break;
827
828 case 'convert':
829 $this->navigation_provider->set_nav_property(
830 array('convert', 0, 'convert'),
831 array(
832 'selected' => $active,
833 'completed' => $completed,
834 )
835 );
836
837 $active = false;
838 $completed = true;
839 // no break;
840
841 case 'settings':
842 $this->navigation_provider->set_nav_property(
843 array('convert', 0, 'settings'),
844 array(
845 'selected' => $active,
846 'completed' => $completed,
847 )
848 );
849
850 $active = false;
851 $completed = true;
852 // no break;
853
854 case 'intro':
855 $this->navigation_provider->set_nav_property(
856 array('convert', 0, 'intro'),
857 array(
858 'selected' => $active,
859 'completed' => $completed,
860 )
861 );
862 break;
863 }
864 }
865 }
866