Added general comment stubs
[ssproject1617.git] / testcms-final-anon / upgrade / run.php
1 <?php
2
3 // report all errors
4 error_reporting(E_ALL);
5
6 // show all error uncaught
7 ini_set('display_errors', true);
8
9 /*
10 Define some paths and get current config
11 */
12 define('IN_CMS', true);
13 define('PATH', pathinfo(dirname(__FILE__), PATHINFO_DIRNAME) . '/');
14
15 /*
16 Helper functions
17 */
18 function random($length = 16) {
19 $pool = str_split('0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', 1);
20 $value = '';
21
22 for ($i = 0; $i < $length; $i++) {
23 $value .= $pool[mt_rand(0, 61)];
24 }
25
26 return $value;
27 }
28
29 /*
30 Include some files.
31 */
32 require PATH . 'system/classes/autoload.php';
33 require PATH . 'system/classes/helpers.php';
34
35 // map classes
36 Autoloader::map(array(
37 'Schema' => PATH . 'upgrade/classes/schema.php',
38 'Migrations' => PATH . 'upgrade/classes/migrations.php'
39 ));
40
41 // tell the autoloader where to find classes
42 Autoloader::directory(array(
43 PATH . 'system/classes/'
44 ));
45
46 // register the auto loader
47 Autoloader::register();
48
49 /**
50 Report all errors let our error class decide which to display
51 */
52 error_reporting(-1);
53
54 /**
55 Error display will be handled by our error class
56 */
57 ini_safe_set('display_errors', false);
58
59 // Register the default timezone for the application.
60 date_default_timezone_set(Config::get('application.timezone'));
61
62 // Register the PHP exception handler.
63 set_exception_handler(array('Error', 'exception'));
64
65 // Register the PHP error handler.
66 set_error_handler(array('Error', 'native'));
67
68 // Register the shutdown handler.
69 register_shutdown_function(array('Error', 'shutdown'));
70
71 // load current config file
72 Config::load(PATH . 'config.php');
73
74 // add and apply migrations
75 require PATH . 'upgrade/migrations.php';
76
77 // write any config changes
78 Config::write(PATH . 'config.php', Config::get());
79
80 // redirect
81 header('Location: complete.php');