-
Notifications
You must be signed in to change notification settings - Fork 7
/
source_changelog.php
24 lines (20 loc) · 1.07 KB
/
source_changelog.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
<?php
$changelog_json_file = "source_changelog.json";
$data = getopt(null, ["server:", "username:", "password:", "database:", "date:"]);
$db_login = mysqli_connect($data['server'], $data['username'], $data['password'], 'configs_'.$data['database']);
$changelog_query = "SELECT `changelog` from `common_config`";
$changelog = mysqli_query($db_login, $changelog_query) or die(mysqli_error($db_login));
$changelog = mysqli_fetch_assoc($changelog)['changelog'];
if (!is_file($changelog_json_file))
file_put_contents($changelog_json_file, "");
$changelog_json = json_decode(file_get_contents($changelog_json_file), true);
if (isset($changelog) && $changelog != null) {
if (isset($data['date']) && $data['date'])
$changelog_json[$data['database']][$data['date']] = $changelog;
else
$changelog_json[$data['database']][date("d-m-Y")] = $changelog;
}
$changelog_json_write = fopen($changelog_json_file, "w") or die("Unable to open file");
fwrite($changelog_json_write, json_encode($changelog_json, JSON_PRETTY_PRINT));
fclose($changelog_json_write);
?>