File: upgrade-cli.php

package info (click to toggle)
dotclear 2.6.4%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 8,420 kB
  • sloc: php: 54,270; sql: 1,290; sh: 213; xml: 173; makefile: 158
file content (52 lines) | stat: -rw-r--r-- 1,230 bytes parent folder | download
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
#!/usr/bin/env php
<?php
# -- BEGIN LICENSE BLOCK ---------------------------------------
#
# This file is part of Dotclear 2.
#
# Copyright (c) 2003-2013 Olivier Meunier & Association Dotclear
# Licensed under the GPL version 2.0 license.
# See LICENSE file or
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
#
# -- END LICENSE BLOCK -----------------------------------------
if (!defined('DC_RC_PATH')) { return; }

try
{
	if (isset($_SERVER['argv'][1])) {
		$dc_conf = $_SERVER['argv'][1];
	} elseif (isset($_SERVER['DC_RC_PATH'])) {
		$dc_conf = realpath($_SERVER['DC_RC_PATH']);
	} else {
		$dc_conf = dirname(__FILE__).'/../config.php';
	}

	if (!is_file($dc_conf)) {
		throw new Exception(sprintf('%s is not a file',$dc_conf));
	}

	$_SERVER['DC_RC_PATH'] = $dc_conf;
	unset($dc_conf);

	require dirname(__FILE__).'/../prepend.php';
	require dirname(__FILE__).'/upgrade.php';

	echo "Starting upgrade process\n";
	$core->con->begin();
	try {
		$changes = dotclearUpgrade($core);
	} catch (Exception $e) {
		$core->con->rollback();
		throw $e;
	}
	$core->con->commit();
	echo 'Upgrade process successfully completed ('.$changes."). \n";
	exit(0);
}
catch (Exception $e)
{
	echo $e->getMessage()."\n";
	exit(1);
}
?>