-
Notifications
You must be signed in to change notification settings - Fork 67
Expand file tree
/
Copy pathupgrade.php
More file actions
101 lines (89 loc) · 3.64 KB
/
upgrade.php
File metadata and controls
101 lines (89 loc) · 3.64 KB
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
100
101
<?php
/**
* The upgrade router file of ZenTaoPMS.
*
* @copyright Copyright 2009-2015 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.cnezsoft.com)
* @license ZPL(http://zpl.pub/page/zplv12.html) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html)
* @author Chunsheng Wang <chunsheng@cnezsoft.com>
* @package ZenTaoPMS
* @version $Id: upgrade.php 4677 2013-04-26 06:23:58Z chencongzhi520@gmail.com $
* @link http://www.zentao.net
*/
/* Judge my.php exists or not. */
$basePath = dirname(dirname(__FILE__));
$dbConfig = $basePath . '/config/db.php';
$myConfig = $basePath . '/config/my.php';
if(file_exists($dbConfig))
{
if(file_exists($myConfig))
{
$myContent = trim(file_get_contents($myConfig));
$myContent = str_replace('<?php', '', $myContent);
}
if(!@rename($dbConfig, $myConfig))
{
$configDir = $basePath . '/config/';
echo "请执行命令 chmod 777 $configDir 来修改权限,保证禅道在该目录有操作文件权限" . "<br />";
echo "Please execute the command 'chmod 777 $configDir' to modify the permissions to ensure that the ZenTao has operating file permissions in this directory";
exit;
}
if(!empty($myContent))
{
$myContent = file_get_contents($myConfig) . "\n" . $myContent;
file_put_contents($myConfig, $myContent);
}
}
if(!file_exists($myConfig)) die(header('location: install.php'));
if(file_exists("{$basePath}/config/ext/secret.php") and !unlink("{$basePath}/config/ext/secret.php"))
{
echo "请删除文件 {$basePath}/config/ext/secret.php,后刷新页面<br />";
echo "Please delete {$basePath}/config/ext/secret.php and refresh.";
exit;
}
error_reporting(0);
/* Load the framework. */
include '../framework/router.class.php';
include '../framework/control.class.php';
include '../framework/model.class.php';
include '../framework/helper.class.php';
/* Instance the app. */
$app = router::createApp('pms', dirname(dirname(__FILE__)), 'router', 'upgrading');
$common = $app->loadCommon();
/* Reset the config params to make sure the install program will be lauched. */
$oldRequestType = zget($config, 'requestType', '');
$config->set('requestType', 'GET');
$config->set('default.module', 'upgrade');
if($config->debug > 1) $config->debug = true;
$app->setDebug();
/* Check the installed version is the latest or not. */
$config->installedVersion = $common->loadModel('setting')->getVersion();
if(!$app->session->upgrading && ($config->version[0] == $config->installedVersion[0] or (is_numeric($config->version[0]) and is_numeric($config->installedVersion[0]))) and version_compare($config->version, $config->installedVersion) <= 0) die(header('location: index.php'));
/* 删除临时 model 文件。*/
/* Delete tmp mode files. */
if(!isset($_SESSION['deleteTmpModel']))
{
$upgradeModel = $common->loadModel('upgrade');
$upgradeModel->deleteTmpModel();
$_SESSION['deleteTmpModel'] = true;
}
/* Upgrade to latest version if it can be upgraded automatically. */
if($app->canAutoUpgrade())
{
$upgradeModel = $common->loadModel('upgrade');
$alterSQL = $upgradeModel->checkConsistency();
if(!empty($alterSQL)) $upgradeModel->dao->query("SET @@sql_mode= '';" . $alterSQL);
$config->set('default.method', 'execute');
$app->session->set('upgrading', true);
$app->session->set('step', '');
$app->post->set('fromVersion', str_replace( '.', '_', strtolower($config->installedVersion)));
}
try
{
/* Run it. */
$app->parseRequest();
$app->loadModule();
}
catch (EndResponseException $endResponseException)
{
echo $endResponseException->getContent();
}