forked from vanilla/porter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
executable file
·99 lines (87 loc) · 2.99 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<?php
/**
* Vanilla 2 Exporter
*
* This script exports other forum databases to the Vanilla 2 import format.
* To use this script, copy it to your web server and open it in your browser.
* If you have a large database, make the directory writable so that the export file can be saved locally and zipped.
*
* @copyright 2010-2014 Vanilla Forums Inc.
* @license GNU GPLv2
* @package VanillaPorter
*/
define('APPLICATION', 'Porter');
define('APPLICATION_VERSION', '2.2');
error_reporting(E_ERROR | E_PARSE | E_CORE_ERROR | E_COMPILE_ERROR | E_USER_ERROR | E_RECOVERABLE_ERROR);
ini_set('display_errors', 'on');
ini_set('track_errors', 1);
// Make sure a default time zone is set
if (ini_get('date.timezone') == '') {
date_default_timezone_set('America/Montreal');
}
// Recognize if we're running from cli.
if (PHP_SAPI == 'cli') {
define('CONSOLE', true);
}
/** @var array Supported forum packages: classname => array(name, prefix, features) */
global $Supported;
// Support Files
include_once 'class.exportmodel.php';
include_once 'class.exportcontroller.php';
include_once 'functions/core-functions.php';
include_once 'functions/render-functions.php';
include_once 'functions/filter-functions.php';
include_once 'functions/commandline-functions.php';
include_once 'functions/structure-functions.php';
include_once 'functions/feature-functions.php';
// Use error handler in functions.php
set_error_handler("ErrorHandler");
// Set Vanilla to appear first in the list.
$Supported = array(
'vanilla1' => array('name' => 'Vanilla 1', 'prefix' => 'LUM_'),
'vanilla2' => array('name' => 'Vanilla 2', 'prefix' => 'GDN_')
);
// Include individual software porters.
// MAKESKIPSTART
$Paths = glob(dirname(__FILE__) . '/packages/*.php');
foreach ($Paths as $Path) {
include_once $Path;
}
// MAKESKIPEND
// If running from cli, execute its command.
if (defined('CONSOLE')) {
ParseCommandLine();
}
// Instantiate the appropriate controller or display the input page.
$Method = 'DoExport';
if (isset($_REQUEST['features'])) {
// Feature list or table.
$Set = (isset($_REQUEST['cloud'])) ? array('core', 'addons', 'cloud') : false;
$Set = VanillaFeatures($Set);
if (isset($_REQUEST['type'])) {
ViewFeatureList($_REQUEST['type'], $Set);
} else {
ViewFeatureTable($Set);
}
} elseif (isset($_POST['type'])) {
if (array_key_exists($_POST['type'], $Supported)) {
// Mini-Factory for conducting exports.
$class = ucwords($_POST['type']);
$Controller = new $class();
if (!method_exists($Controller, $Method)) {
echo "This datasource type does not support {$Method}.\n";
exit();
}
$Controller->$Method();
} else {
echo 'Invalid type specified: ' . $_POST['type'];
}
} else {
// Show the web UI to start an export.
$CanWrite = TestWrite();
ViewForm(array('Supported' => $Supported, 'CanWrite' => $CanWrite));
}
// Console output should end in newline.
if (defined('CONSOLE')) {
echo "\n";
}