-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexecUpdate.php
More file actions
50 lines (40 loc) · 1.3 KB
/
execUpdate.php
File metadata and controls
50 lines (40 loc) · 1.3 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
<?php
/**
* @copyright (C) 2025, 299Ko, based on code (2010-2021) 99ko https://github.com/99kocms/
* @license https://www.gnu.org/licenses/gpl-3.0.en.html GPLv3
* @author Maxence Cauderlier <[email protected]>
*
* @package 299Ko https://github.com/299Ko/299ko
*/
// need to be started in CLI, in versions folder
// php execUpdate.php
// Create a new version for auto update
require 'config.php';
chdir(KOPATH);
$result = null;
exec('git diff --name-status ' . $commitLastVersion . ' ' . $commitFutureVersion, $result);
chdir(VERSIONSPATH);
@mkdir('update_to/' . $version);
$deleted = [];
$json = [];
foreach ($result as $r) {
$line = explode("\t", $r);
if (count($line) === 2) {
$json[$line[0]][] = $line[1];
if ($line[0] === 'D') {
$deleted[] = $line[1];
}
} elseif (count($line) === 3) {
if (substr($line[0],0,1) === "R") {
// Rename detected
$deleted[] = $line[1];
$json["D"][] = $line[1];
$json["A"][] = $line[2];
}
}
}
if (!is_dir('core/' . $version)) {
mkdir('core/' . $version, 0777, true);
}
file_put_contents('core/' . $version . '/files.json', json_encode($json, JSON_PRETTY_PRINT));
file_put_contents('core/' . $version . '/deleted.json', json_encode($deleted, JSON_PRETTY_PRINT));