This repository has been archived on 2025-01-19. You can view files and clone it, but cannot push or open issues or pull requests.
oliverdavies.uk-old-sculpin/scripts/redirects.php

33 lines
550 B
PHP
Raw Normal View History

2015-08-07 00:47:27 +00:00
#!/usr/bin/env php
<?php
$template = <<<EOS
---
layout: redirect
destination: %DESTINATION%
---
EOS;
$filename = dirname(__FILE__) . '/redirects.csv';
$row = 1;
if (($handle = fopen($filename, 'r')) !== FALSE) {
while (($data = fgetcsv($handle, filesize($filename))) !== FALSE) {
var_dump($data[0]);
$templateData = [
'%DESTINATION%' => $destination,
];
$output = strtr($template, $templateData);
file_put_contents("source/{$data[0]}.html", $output);
$row++;
}
}
fclose($handle);