-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathupdate3.php
94 lines (74 loc) · 1.68 KB
/
update3.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
<?php
$out = array();
$cleaning_list = array(
'.github',
'admin/config-dist.php',
'install',
'tools',
'.gitignore',
'.php-cs-fixer.php_cs',
'CHANGELOG.md',
'composer.json',
'composer.lock',
'config-dist.php',
'deleted.txt',
'README.md',
'LICENSE.txt',
'phpstan.neon',
);
function delete($dir) {
if (!file_exists($dir)) {
return true;
}
if (!is_dir($dir)) {
return unlink($dir);
}
foreach (scandir($dir) as $item) {
if ($item == '.' || $item == '..') {
continue;
}
if (!delete($dir . DIRECTORY_SEPARATOR . $item)) {
return false;
}
}
return rmdir($dir);
}
echo date('Y-m-d H:i:s') . ': starting...' . '<br/>';
switch (true) {
case !is_dir('.git') && isset($_GET['install']):
exec('git clone https://github.com/ocmod-space/opencart-3 ./x', $out);
exec('mv x/.* x/* .');
exec('rm -rf ./x');
break;
case isset($_GET['rename']):
exec('git remote rm origin', $out);
exec('git remote add origin https://github.com/ocmod-space/opencart-3', $out);
exec('git branch -m 3.0.x.x main', $out);
exec('git fetch origin', $out);
exec('git branch -u origin/main main', $out);
exec('git remote set-head origin -a', $out);
break;
case isset($_GET['update']) && is_dir('.git'):
exec('git reset --hard origin/main', $out);
exec('git pull', $out);
foreach ($cleaning_list as $item) {
delete($item);
}
break;
case isset($_GET['status']):
exec('git status', $out);
break;
default:
# code...
break;
}
if ($out) {
echo '<br/>';
foreach ($out as $s) {
echo $s . '<br/>';
}
echo '<br/>';
}
echo date('Y-m-d H:i:s') . ': Resetting OPCache: ' . (opcache_reset() ? 'true' : 'false');
echo '<br/>';
echo date('Y-m-d H:i:s') . ': done...';