update
This commit is contained in:
@@ -142,12 +142,27 @@ class UpdateRepository
|
||||
$file_name = 'update.zip';
|
||||
|
||||
$path = pathinfo( realpath( $file_name ), PATHINFO_DIRNAME );
|
||||
$path = substr( $path, 0, strlen( $path ) - 5 );
|
||||
$path = rtrim( substr( $path, 0, strlen( $path ) - 5 ), '/\\' ) . '/';
|
||||
$zip = new \ZipArchive;
|
||||
$res = $zip -> open( $file_name );
|
||||
if ( $res === TRUE )
|
||||
{
|
||||
$zip -> extractTo( $path );
|
||||
for ( $i = 0; $i < $zip->numFiles; $i++ )
|
||||
{
|
||||
$entry = str_replace( '\\', '/', $zip->getNameIndex( $i ) );
|
||||
if ( substr( $entry, -1 ) === '/' )
|
||||
{
|
||||
$dir = $path . $entry;
|
||||
if ( !is_dir( $dir ) )
|
||||
mkdir( $dir, 0755, true );
|
||||
continue;
|
||||
}
|
||||
$targetPath = $path . $entry;
|
||||
$targetDir = dirname( $targetPath );
|
||||
if ( !is_dir( $targetDir ) )
|
||||
mkdir( $targetDir, 0755, true );
|
||||
file_put_contents( $targetPath, $zip->getFromIndex( $i ) );
|
||||
}
|
||||
$zip -> close();
|
||||
unlink( $file_name );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user