Created
May 23, 2016 14:27
-
-
Save asvae/801378550cb4310a6390c65806142aec to your computer and use it in GitHub Desktop.
Baldr sky manual converter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use League\Flysystem\Adapter\Local; | |
use League\Flysystem\Filesystem; | |
require_once($_SERVER["DOCUMENT_ROOT"] . '/autoload/bootstrap.php'); | |
$path = 'baldr_sky_manual/manual'; | |
$dir = new Filesystem(new Local($_SERVER["DOCUMENT_ROOT"])); | |
$files = $dir->listContents($path, true); | |
$files = collect($files)->where('extension', 'htm'); | |
foreach ($files as $file) { | |
$newPath = "baldr_sky_manual/manual_converted/{$file['basename']}l"; | |
$contents = $dir->read($file['path']); | |
$contents = mb_convert_encoding($contents, 'UTF-8', 'SJIS'); | |
$contents = trim($contents); | |
$contents = str_replace('<html>', '<!doctype html><html lang="jp">', $contents); | |
$contents = str_replace('<head>', '<head><meta charset="UTF-8">', $contents); | |
$dir->put($newPath, $contents); | |
} | |
dd('Okay!'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment