1
0

Make checksum code skippable

This commit is contained in:
Garvin Hicking
2008-12-09 10:41:48 +00:00
parent 63fe29e942
commit d9a5d6a8c8
6 changed files with 34 additions and 6 deletions

View File

@ -9,10 +9,15 @@ if (IN_serendipity !== true) {
die ("Don't hack!\n");
}
echo "Creating checksums.\n";
$basedir = realpath(dirname(__FILE__) . '/../') . '/';
require_once $basedir . 'include/functions_installer.inc.php';
require_once $basedir . 'include/functions_images.inc.php';
$conf = file_get_contents($basedir . 'serendipity_config.inc.php');
preg_match('@\$serendipity\[\'version\'\]\s*=\s*\'(.+)\'@imsU', $conf, $vmatch);
// Find all the files in the serendipity directory and calculate their md5 sums
$sums = array();
$excludes = array(
@ -21,6 +26,7 @@ $excludes = array(
);
$files = serendipity_traversePath($basedir, '', false);
foreach ($files as $fdata) {
echo $fdata['relpath'] . "\n";
// Don't take checksums of directories
if ($fdata['directory']) {
continue;
@ -48,7 +54,7 @@ if (!empty($sums)) {
if (!$file) {
die('Unable to open output file!');
}
fwrite($file, '<?php' . "\n" . 'global $serendipity;' . "\n" . '$serendipity[\'checksums\'] = array (' . "\n");
fwrite($file, '<?php' . "\n" . 'global $serendipity;' . "\n" . '$serendipity[\'checksums_' . $vmatch[1] . '\'] = array (' . "\n");
foreach ($sums as $fname => $sum) {
fwrite($file, "'$fname' => '$sum',\n");
}