-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathicms-update.php
More file actions
55 lines (35 loc) · 1.49 KB
/
icms-update.php
File metadata and controls
55 lines (35 loc) · 1.49 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
<?php
/// Last update to do auto update
$last_update = strtotime( "now" ) - filemtime( __DIR__ . '/' . APP_MOD_PREFIX . 'update.php' );
if ( $last_update > ( (60 * 60) * 1 ) ){
$fileupdater = fopen( "icms-update.php", "r");
file_put_contents( "icms-update.php", fread($fileupdater,filesize("icms-update.php")) );
fclose( $fileupdater );
$updatestatus = json_decode(file_get_contents('https://raw.githubusercontent.com/GreenRunchly/icms/main/server/latest.json'), true);
$updatestatus[0][1] = '1.8';
if ( ! empty( $updatestatus[0][0] ) ){
if ( $updatestatus[0][0] != $updatestatus[0][1] ){
$randomea = md5( floor( microtime(true) * 1000 ) );
$updatefile = file_put_contents( $randomea . '.zip',file_get_contents('https://github.com/GreenRunchly/icms/archive/refs/heads/main.zip'));
$zip = new ZipArchive;
$openedzipfile = $zip->open( $randomea . '.zip');
if ($openedzipfile == true) {
foreach ( $updatestatus[1] as $zipfilekey => $zipfilename) {
$datafile = $zip->getFromName( $zipfilename );
$zipfilename = ltrim( str_ireplace( "icms-main", '', $zipfilename), '/' );
unlink( $zipfilename );
if ( ! is_dir( dirname( $zipfilename ) ) ) {
if ( ! file_exists( $zipfilename ))
mkdir( dirname( $zipfilename ) , 0777, true);
}
if ( ! file_exists( $zipfilename ) )
file_put_contents( $zipfilename , $datafile);
}
$zip->close();
unlink( $randomea . '.zip');
}
}else{
}
}
}
?>