-
-
Save danjesus/8867872 to your computer and use it in GitHub Desktop.
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 | |
// Add the correct Content-Type for the cache manifest | |
header('Content-Type: text/cache-manifest'); | |
// Write the first line | |
echo "CACHE MANIFEST\n"; | |
// Initialize the $hashes string | |
$hashes = ""; | |
function create_manifest($folder) { | |
$dir = new RecursiveDirectoryIterator($folder); | |
// Iterate through all the files/folders in the current directory | |
foreach (new RecursiveIteratorIterator($dir) as $file) { | |
$info = pathinfo($file); | |
// If the object is a file | |
// and it's not called manifest.php (this file), | |
// and it's not a dotfile, add it to the list | |
if ($file -> IsFile() && $file != "./manifest.php" && substr($file -> getFilename(), 0, 1) != ".") { | |
// Replace spaces with %20 or it will break | |
echo str_replace(' ', '%20', $file) . "\n"; | |
// Add this file's hash to the $hashes string | |
$hashes .= md5_file($file); | |
} | |
} | |
} | |
create_manifest("."); | |
// Write the $hashes string | |
echo "# Hash: " . md5($hashes) . "\n"; | |
?> |
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 | |
// Add the correct Content-Type for the cache manifest | |
header('Content-Type: text/cache-manifest'); | |
// Write the first line | |
echo "CACHE MANIFEST\n"; | |
?> |
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 | |
function create_manifest($folder) { | |
$dir = new RecursiveDirectoryIterator($folder); | |
// Iterate through all the files/folders in the current directory | |
foreach (new RecursiveIteratorIterator($dir) as $file) { | |
$info = pathinfo($file); | |
// If the object is a file | |
// and it's not called manifest.php (this file), | |
// and it's not a dotfile, add it to the list | |
if ($file -> IsFile() && $file != "./manifest.php" && substr($file -> getFilename(), 0, 1) != ".") { | |
// Replace spaces with %20 or it will break | |
echo str_replace(' ', '%20', $file) . "\n"; | |
// Add this file's hash to the $hashes string | |
$hashes .= md5_file($file); | |
} | |
} | |
} | |
?> |
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 | |
create_manifest("."); | |
?> |
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 | |
// Write the $hashes string | |
echo "# Hash: " . md5($hashes) . "\n"; | |
?> |
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
<!DOCTYPE html> | |
<html manifest="manifest.php"> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment